@dice-roller/vue 1.2.0 → 1.2.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/dist/vue.js +4100 -4063
- package/dist/vue.umd.cjs +25 -25
- package/package.json +2 -2
package/dist/vue.umd.cjs
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
(function(Vr,Ne){typeof exports=="object"&&typeof module<"u"?Ne(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],Ne):(Vr=typeof globalThis<"u"?globalThis:Vr||self,Ne(Vr.DiceRollerVue={},Vr.Vue))})(this,function(Vr,Ne){"use strict";var xI=Object.defineProperty;var wI=(Vr,Ne,Sr)=>Ne in Vr?xI(Vr,Ne,{enumerable:!0,configurable:!0,writable:!0,value:Sr}):Vr[Ne]=Sr;var
|
|
1
|
+
(function(Vr,Ne){typeof exports=="object"&&typeof module<"u"?Ne(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],Ne):(Vr=typeof globalThis<"u"?globalThis:Vr||self,Ne(Vr.DiceRollerVue={},Vr.Vue))})(this,function(Vr,Ne){"use strict";var xI=Object.defineProperty;var wI=(Vr,Ne,Sr)=>Ne in Vr?xI(Vr,Ne,{enumerable:!0,configurable:!0,writable:!0,value:Sr}):Vr[Ne]=Sr;var tt=(Vr,Ne,Sr)=>(wI(Vr,typeof Ne!="symbol"?Ne+"":Ne,Sr),Sr);function Sr(){return Sr=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=t[a])}return r},Sr.apply(this,arguments)}var ol={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function tr(r){return typeof r=="number"}function rr(r){return!r||typeof r!="object"||typeof r.constructor!="function"?!1:r.isBigNumber===!0&&typeof r.constructor.prototype=="object"&&r.constructor.prototype.isBigNumber===!0||typeof r.constructor.isDecimal=="function"&&r.constructor.isDecimal(r)===!0}function kt(r){return r&&typeof r=="object"&&Object.getPrototypeOf(r).isComplex===!0||!1}function za(r){return r&&typeof r=="object"&&Object.getPrototypeOf(r).isFraction===!0||!1}function Vt(r){return r&&r.constructor.prototype.isUnit===!0||!1}function Wr(r){return typeof r=="string"}var cr=Array.isArray;function Ve(r){return r&&r.constructor.prototype.isMatrix===!0||!1}function Ft(r){return Array.isArray(r)||Ve(r)}function ui(r){return r&&r.isDenseMatrix&&r.constructor.prototype.isMatrix===!0||!1}function En(r){return r&&r.isSparseMatrix&&r.constructor.prototype.isMatrix===!0||!1}function Uo(r){return r&&r.constructor.prototype.isRange===!0||!1}function li(r){return r&&r.constructor.prototype.isIndex===!0||!1}function R0(r){return typeof r=="boolean"}function _0(r){return r&&r.constructor.prototype.isResultSet===!0||!1}function sl(r){return r&&r.constructor.prototype.isHelp===!0||!1}function q0(r){return typeof r=="function"}function z0(r){return r instanceof Date}function P0(r){return r instanceof RegExp}function Lo(r){return!!(r&&typeof r=="object"&&r.constructor===Object&&!kt(r)&&!za(r))}function U0(r){return r===null}function L0(r){return r===void 0}function Sn(r){return r&&r.isAccessorNode===!0&&r.constructor.prototype.isNode===!0||!1}function ot(r){return r&&r.isArrayNode===!0&&r.constructor.prototype.isNode===!0||!1}function k0(r){return r&&r.isAssignmentNode===!0&&r.constructor.prototype.isNode===!0||!1}function V0(r){return r&&r.isBlockNode===!0&&r.constructor.prototype.isNode===!0||!1}function G0(r){return r&&r.isConditionalNode===!0&&r.constructor.prototype.isNode===!0||!1}function ir(r){return r&&r.isConstantNode===!0&&r.constructor.prototype.isNode===!0||!1}function ko(r){return ir(r)||Br(r)&&r.args.length===1&&ir(r.args[0])&&"-+~".includes(r.op)}function Pa(r){return r&&r.isFunctionAssignmentNode===!0&&r.constructor.prototype.isNode===!0||!1}function nn(r){return r&&r.isFunctionNode===!0&&r.constructor.prototype.isNode===!0||!1}function Jn(r){return r&&r.isIndexNode===!0&&r.constructor.prototype.isNode===!0||!1}function fr(r){return r&&r.isNode===!0&&r.constructor.prototype.isNode===!0||!1}function ci(r){return r&&r.isObjectNode===!0&&r.constructor.prototype.isNode===!0||!1}function Br(r){return r&&r.isOperatorNode===!0&&r.constructor.prototype.isNode===!0||!1}function Gt(r){return r&&r.isParenthesisNode===!0&&r.constructor.prototype.isNode===!0||!1}function H0(r){return r&&r.isRangeNode===!0&&r.constructor.prototype.isNode===!0||!1}function Z0(r){return r&&r.isRelationalNode===!0&&r.constructor.prototype.isNode===!0||!1}function qr(r){return r&&r.isSymbolNode===!0&&r.constructor.prototype.isNode===!0||!1}function ul(r){return r&&r.constructor.prototype.isChain===!0||!1}function br(r){var e=typeof r;return e==="object"?r===null?"null":rr(r)?"BigNumber":r.constructor&&r.constructor.name?r.constructor.name:"Object":e}function Ge(r){var e=typeof r;if(e==="number"||e==="string"||e==="boolean"||r===null||r===void 0)return r;if(typeof r.clone=="function")return r.clone();if(Array.isArray(r))return r.map(function(t){return Ge(t)});if(r instanceof Date)return new Date(r.valueOf());if(rr(r))return r;if(r instanceof RegExp)throw new TypeError("Cannot clone "+r);return J0(r,Ge)}function J0(r,e){var t={};for(var a in r)Re(r,a)&&(t[a]=e(r[a]));return t}function ll(r,e){for(var t in e)Re(e,t)&&(r[t]=e[t]);return r}function Ua(r,e){var t,a,n;if(Array.isArray(r)){if(!Array.isArray(e)||r.length!==e.length)return!1;for(a=0,n=r.length;a<n;a++)if(!Ua(r[a],e[a]))return!1;return!0}else{if(typeof r=="function")return r===e;if(r instanceof Object){if(Array.isArray(e)||!(e instanceof Object))return!1;for(t in r)if(!(t in e)||!Ua(r[t],e[t]))return!1;for(t in e)if(!(t in r))return!1;return!0}else return r===e}}function X0(r,e,t){var a=!0,n;Object.defineProperty(r,e,{get:function(){return a&&(n=t(),a=!1),n},set:function(o){n=o,a=!1},configurable:!0,enumerable:!0})}function Re(r,e){return r&&Object.hasOwnProperty.call(r,e)}function W0(r,e){for(var t={},a=0;a<e.length;a++){var n=e[a],i=r[n];i!==void 0&&(t[n]=i)}return t}var Y0=["Matrix","Array"],Q0=["number","BigNumber","Fraction"],ge=function(e){if(e)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(
|
|
9
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i=!0,o=!1,f;return{s:function(){t=t.call(r)},n:function(){var u=t.next();return i=u.done,u},e:function(u){o=!0,f=u},f:function(){try{!i&&t.return!=null&&t.return()}finally{if(o)throw f}}}}function G0(r,e){if(!!r){if(typeof r=="string")return ul(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);if(t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set")return Array.from(r);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return ul(r,e)}}function ul(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,a=new Array(e);t<e;t++)a[t]=r[t];return a}function Jn(r){return Jn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Jn(r)}function ll(){return!0}function ot(){return!1}function Xn(){}var cl="Argument is not a typed-function.";function fl(){function r(z){return Jn(z)==="object"&&z!==null&&z.constructor===Object}var e=[{name:"number",test:function(U){return typeof U=="number"}},{name:"string",test:function(U){return typeof U=="string"}},{name:"boolean",test:function(U){return typeof U=="boolean"}},{name:"Function",test:function(U){return typeof U=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(U){return U instanceof Date}},{name:"RegExp",test:function(U){return U instanceof RegExp}},{name:"Object",test:r},{name:"null",test:function(U){return U===null}},{name:"undefined",test:function(U){return U===void 0}}],t={name:"any",test:ll,isAny:!0},a,n,i=0,o={createCount:0};function f(z){var U=a.get(z);if(U)return U;var ee='Unknown type "'+z+'"',ue=z.toLowerCase(),ve,de=pt(n),be;try{for(de.s();!(be=de.n()).done;)if(ve=be.value,ve.toLowerCase()===ue){ee+='. Did you mean "'+ve+'" ?';break}}catch(pe){de.e(pe)}finally{de.f()}throw new TypeError(ee)}function l(z){for(var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any",ee=U?f(U).index:n.length,ue=[],ve=0;ve<z.length;++ve){if(!z[ve]||typeof z[ve].name!="string"||typeof z[ve].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");var de=z[ve].name;if(a.has(de))throw new TypeError('Duplicate type name "'+de+'"');ue.push(de),a.set(de,{name:de,test:z[ve].test,isAny:z[ve].isAny,index:ee+ve,conversionsTo:[]})}var be=n.slice(ee);n=n.slice(0,ee).concat(ue).concat(be);for(var pe=ee+ue.length;pe<n.length;++pe)a.get(n[pe]).index=pe}function u(){a=new Map,n=[],i=0,l([t],!1)}u(),l(e);function s(){var z,U=pt(n),ee;try{for(U.s();!(ee=U.n()).done;)z=ee.value,a.get(z).conversionsTo=[]}catch(ue){U.e(ue)}finally{U.f()}i=0}function c(z){var U=n.filter(function(ee){var ue=a.get(ee);return!ue.isAny&&ue.test(z)});return U.length?U:["any"]}function m(z){return z&&typeof z=="function"&&"_typedFunctionData"in z}function v(z,U,ee){if(!m(z))throw new TypeError(cl);var ue=ee&&ee.exact,ve=Array.isArray(U)?U.join(","):U,de=w(ve),be=g(de);if(!ue||be in z.signatures){var pe=z._typedFunctionData.signatureMap.get(be);if(pe)return pe}var we=de.length,_e;if(ue){_e=[];var Le;for(Le in z.signatures)_e.push(z._typedFunctionData.signatureMap.get(Le))}else _e=z._typedFunctionData.signatures;for(var Be=0;Be<we;++Be){var ar=de[Be],Je=[],mr=void 0,C=pt(_e),Z;try{for(C.s();!(Z=C.n()).done;){mr=Z.value;var se=A(mr.params,Be);if(!(!se||ar.restParam&&!se.restParam)){if(!se.hasAny){var Ee=function(){var _r=d(se);if(ar.types.some(function(en){return!_r.has(en.name)}))return"continue"}();if(Ee==="continue")continue}Je.push(mr)}}}catch(_r){C.e(_r)}finally{C.f()}if(_e=Je,_e.length===0)break}var ze,ke=pt(_e),Fr;try{for(ke.s();!(Fr=ke.n()).done;)if(ze=Fr.value,ze.params.length<=we)return ze}catch(_r){ke.e(_r)}finally{ke.f()}throw new TypeError("Signature not found (signature: "+(z.name||"unnamed")+"("+g(de,", ")+"))")}function h(z,U,ee){return v(z,U,ee).implementation}function p(z,U){var ee=f(U);if(ee.test(z))return z;var ue=ee.conversionsTo;if(ue.length===0)throw new Error("There are no conversions to "+U+" defined.");for(var ve=0;ve<ue.length;ve++){var de=f(ue[ve].from);if(de.test(z))return ue[ve].convert(z)}throw new Error("Cannot convert "+z+" to "+U)}function g(z){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return z.map(function(ee){return ee.name}).join(U)}function y(z){var U=z.indexOf("...")===0,ee=U?z.length>3?z.slice(3):"any":z,ue=ee.split("|").map(function(pe){return f(pe.trim())}),ve=!1,de=U?"...":"",be=ue.map(function(pe){return ve=pe.isAny||ve,de+=pe.name+"|",{name:pe.name,typeIndex:pe.index,test:pe.test,isAny:pe.isAny,conversion:null,conversionIndex:-1}});return{types:be,name:de.slice(0,-1),hasAny:ve,hasConversion:!1,restParam:U}}function N(z){var U=z.types.map(function(be){return be.name}),ee=F(U),ue=z.hasAny,ve=z.name,de=ee.map(function(be){var pe=f(be.from);return ue=pe.isAny||ue,ve+="|"+be.from,{name:be.from,typeIndex:pe.index,test:pe.test,isAny:pe.isAny,conversion:be,conversionIndex:be.index}});return{types:z.types.concat(de),name:ve,hasAny:ue,hasConversion:de.length>0,restParam:z.restParam}}function d(z){return z.typeSet||(z.typeSet=new Set,z.types.forEach(function(U){return z.typeSet.add(U.name)})),z.typeSet}function w(z){var U=[];if(typeof z!="string")throw new TypeError("Signatures must be strings");var ee=z.trim();if(ee==="")return U;for(var ue=ee.split(","),ve=0;ve<ue.length;++ve){var de=y(ue[ve].trim());if(de.restParam&&ve!==ue.length-1)throw new SyntaxError('Unexpected rest parameter "'+ue[ve]+'": only allowed for the last parameter');if(de.types.length===0)return null;U.push(de)}return U}function x(z){var U=ce(z);return U?U.restParam:!1}function b(z){if(!z||z.types.length===0)return ll;if(z.types.length===1)return f(z.types[0].name).test;if(z.types.length===2){var U=f(z.types[0].name).test,ee=f(z.types[1].name).test;return function(de){return U(de)||ee(de)}}else{var ue=z.types.map(function(ve){return f(ve.name).test});return function(de){for(var be=0;be<ue.length;be++)if(ue[be](de))return!0;return!1}}}function E(z){var U,ee,ue;if(x(z)){U=he(z).map(b);var ve=U.length,de=b(ce(z)),be=function(we){for(var _e=ve;_e<we.length;_e++)if(!de(we[_e]))return!1;return!0};return function(we){for(var _e=0;_e<U.length;_e++)if(!U[_e](we[_e]))return!1;return be(we)&&we.length>=ve+1}}else return z.length===0?function(we){return we.length===0}:z.length===1?(ee=b(z[0]),function(we){return ee(we[0])&&we.length===1}):z.length===2?(ee=b(z[0]),ue=b(z[1]),function(we){return ee(we[0])&&ue(we[1])&&we.length===2}):(U=z.map(b),function(we){for(var _e=0;_e<U.length;_e++)if(!U[_e](we[_e]))return!1;return we.length===U.length})}function A(z,U){return U<z.length?z[U]:x(z)?ce(z):null}function S(z,U){var ee=A(z,U);return ee?d(ee):new Set}function D(z){return z.conversion===null||z.conversion===void 0}function T(z,U){var ee=new Set;return z.forEach(function(ue){var ve=S(ue.params,U),de,be=pt(ve),pe;try{for(be.s();!(pe=be.n()).done;)de=pe.value,ee.add(de)}catch(we){be.e(we)}finally{be.f()}}),ee.has("any")?["any"]:Array.from(ee)}function B(z,U,ee){var ue,ve,de=z||"unnamed",be=ee,pe,we=function(){var C=[];if(be.forEach(function(se){var Ee=A(se.params,pe),ze=b(Ee);(pe<se.params.length||x(se.params))&&ze(U[pe])&&C.push(se)}),C.length===0){if(ve=T(be,pe),ve.length>0){var Z=c(U[pe]);return ue=new TypeError("Unexpected type of argument in function "+de+" (expected: "+ve.join(" or ")+", actual: "+Z.join(" | ")+", index: "+pe+")"),ue.data={category:"wrongType",fn:de,index:pe,actual:Z,expected:ve},{v:ue}}}else be=C};for(pe=0;pe<U.length;pe++){var _e=we();if(Jn(_e)==="object")return _e.v}var Le=be.map(function(mr){return x(mr.params)?1/0:mr.params.length});if(U.length<Math.min.apply(null,Le))return ve=T(be,pe),ue=new TypeError("Too few arguments in function "+de+" (expected: "+ve.join(" or ")+", index: "+U.length+")"),ue.data={category:"tooFewArgs",fn:de,index:U.length,expected:ve},ue;var Be=Math.max.apply(null,Le);if(U.length>Be)return ue=new TypeError("Too many arguments in function "+de+" (expected: "+Be+", actual: "+U.length+")"),ue.data={category:"tooManyArgs",fn:de,index:U.length,expectedLength:Be},ue;for(var ar=[],Je=0;Je<U.length;++Je)ar.push(c(U[Je]).join("|"));return ue=new TypeError('Arguments of type "'+ar.join(", ")+'" do not match any of the defined signatures of function '+de+"."),ue.data={category:"mismatch",actual:ar},ue}function I(z){for(var U=n.length+1,ee=0;ee<z.types.length;ee++)D(z.types[ee])&&(U=Math.min(U,z.types[ee].typeIndex));return U}function P(z){for(var U=i+1,ee=0;ee<z.types.length;ee++)D(z.types[ee])||(U=Math.min(U,z.types[ee].conversionIndex));return U}function R(z,U){if(z.hasAny){if(!U.hasAny)return 1}else if(U.hasAny)return-1;if(z.restParam){if(!U.restParam)return 1}else if(U.restParam)return-1;if(z.hasConversion){if(!U.hasConversion)return 1}else if(U.hasConversion)return-1;var ee=I(z)-I(U);if(ee<0)return-1;if(ee>0)return 1;var ue=P(z)-P(U);return ue<0?-1:ue>0?1:0}function M(z,U){var ee=z.params,ue=U.params,ve=ce(ee),de=ce(ue),be=x(ee),pe=x(ue);if(be&&ve.hasAny){if(!pe||!de.hasAny)return 1}else if(pe&&de.hasAny)return-1;var we=0,_e=0,Le,Be=pt(ee),ar;try{for(Be.s();!(ar=Be.n()).done;)Le=ar.value,Le.hasAny&&++we,Le.hasConversion&&++_e}catch(Ln){Be.e(Ln)}finally{Be.f()}var Je=0,mr=0,C=pt(ue),Z;try{for(C.s();!(Z=C.n()).done;)Le=Z.value,Le.hasAny&&++Je,Le.hasConversion&&++mr}catch(Ln){C.e(Ln)}finally{C.f()}if(we!==Je)return we-Je;if(be&&ve.hasConversion){if(!pe||!de.hasConversion)return 1}else if(pe&&de.hasConversion)return-1;if(_e!==mr)return _e-mr;if(be){if(!pe)return 1}else if(pe)return-1;var se=(ee.length-ue.length)*(be?-1:1);if(se!==0)return se;for(var Ee=[],ze=0,ke=0;ke<ee.length;++ke){var Fr=R(ee[ke],ue[ke]);Ee.push(Fr),ze+=Fr}if(ze!==0)return ze;for(var _r,en=0,Un=Ee;en<Un.length;en++)if(_r=Un[en],_r!==0)return _r;return 0}function F(z){if(z.length===0)return[];var U=z.map(f);z.length>1&&U.sort(function(we,_e){return we.index-_e.index});var ee=U[0].conversionsTo;if(z.length===1)return ee;ee=ee.concat([]);for(var ue=new Set(z),ve=1;ve<U.length;++ve){var de=void 0,be=pt(U[ve].conversionsTo),pe;try{for(be.s();!(pe=be.n()).done;)de=pe.value,ue.has(de.from)||(ee.push(de),ue.add(de.from))}catch(we){be.e(we)}finally{be.f()}}return ee}function H(z,U){var ee=U;if(z.some(function(pe){return pe.hasConversion})){var ue=x(z),ve=z.map($);ee=function(){for(var we=[],_e=ue?arguments.length-1:arguments.length,Le=0;Le<_e;Le++)we[Le]=ve[Le](arguments[Le]);return ue&&(we[_e]=arguments[_e].map(ve[_e])),U.apply(this,we)}}var de=ee;if(x(z)){var be=z.length-1;de=function(){return ee.apply(this,ie(arguments,0,be).concat([ie(arguments,be)]))}}return de}function $(z){var U,ee,ue,ve,de=[],be=[];switch(z.types.forEach(function(pe){pe.conversion&&(de.push(f(pe.conversion.from).test),be.push(pe.conversion.convert))}),be.length){case 0:return function(we){return we};case 1:return U=de[0],ue=be[0],function(we){return U(we)?ue(we):we};case 2:return U=de[0],ee=de[1],ue=be[0],ve=be[1],function(we){return U(we)?ue(we):ee(we)?ve(we):we};default:return function(we){for(var _e=0;_e<be.length;_e++)if(de[_e](we))return be[_e](we);return we}}}function k(z){function U(ee,ue,ve){if(ue<ee.length){var de=ee[ue],be=[];if(de.restParam){var pe=de.types.filter(D);pe.length<de.types.length&&be.push({types:pe,name:"..."+pe.map(function(we){return we.name}).join("|"),hasAny:pe.some(function(we){return we.isAny}),hasConversion:!1,restParam:!0}),be.push(de)}else be=de.types.map(function(we){return{types:[we],name:we.name,hasAny:we.isAny,hasConversion:we.conversion,restParam:!1}});return Oe(be,function(we){return U(ee,ue+1,ve.concat([we]))})}else return[ve]}return U(z,0,[])}function Q(z,U){for(var ee=Math.max(z.length,U.length),ue=0;ue<ee;ue++){var ve=S(z,ue),de=S(U,ue),be=!1,pe=void 0,we=pt(de),_e;try{for(we.s();!(_e=we.n()).done;)if(pe=_e.value,ve.has(pe)){be=!0;break}}catch(mr){we.e(mr)}finally{we.f()}if(!be)return!1}var Le=z.length,Be=U.length,ar=x(z),Je=x(U);return ar?Je?Le===Be:Be>=Le:Je?Le>=Be:Le===Be}function K(z){return z.map(function(U){return oe(U)?V(U.referToSelf.callback):X(U)?$e(U.referTo.references,U.referTo.callback):U})}function L(z,U,ee){var ue=[],ve,de=pt(z),be;try{for(de.s();!(be=de.n()).done;){ve=be.value;var pe=ee[ve];if(typeof pe!="number")throw new TypeError('No definition for referenced signature "'+ve+'"');if(pe=U[pe],typeof pe!="function")return!1;ue.push(pe)}}catch(we){de.e(we)}finally{de.f()}return ue}function j(z,U,ee){for(var ue=K(z),ve=new Array(ue.length).fill(!1),de=!0;de;){de=!1;for(var be=!0,pe=0;pe<ue.length;++pe)if(!ve[pe]){var we=ue[pe];if(oe(we))ue[pe]=we.referToSelf.callback(ee),ue[pe].referToSelf=we.referToSelf,ve[pe]=!0,be=!1;else if(X(we)){var _e=L(we.referTo.references,ue,U);_e?(ue[pe]=we.referTo.callback.apply(this,_e),ue[pe].referTo=we.referTo,ve[pe]=!0,be=!1):de=!0}}if(be&&de)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return ue}function ae(z){var U=/\bthis(\(|\.signatures\b)/;Object.keys(z).forEach(function(ee){var ue=z[ee];if(U.test(ue.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 re(z,U){if(o.createCount++,Object.keys(U).length===0)throw new SyntaxError("No signatures provided");o.warnAgainstDeprecatedThis&&ae(U);var ee=[],ue=[],ve={},de=[],be,pe=function(){if(!Object.prototype.hasOwnProperty.call(U,be))return"continue";var Tr=w(be);if(!Tr)return"continue";ee.forEach(function(wn){if(Q(wn,Tr))throw new TypeError('Conflicting signatures "'+g(wn)+'" and "'+g(Tr)+'".')}),ee.push(Tr);var Fo=ue.length;ue.push(U[be]);var Ku=Tr.map(N),Ia=void 0,Ra=pt(k(Ku)),To;try{for(Ra.s();!(To=Ra.n()).done;){Ia=To.value;var Bo=g(Ia);de.push({params:Ia,name:Bo,fn:Fo}),Ia.every(function(wn){return!wn.hasConversion})&&(ve[Bo]=Fo)}}catch(wn){Ra.e(wn)}finally{Ra.f()}};for(be in U)var we=pe();de.sort(M);var _e=j(ue,ve,Vn),Le;for(Le in ve)Object.prototype.hasOwnProperty.call(ve,Le)&&(ve[Le]=_e[ve[Le]]);for(var Be=[],ar=new Map,Je=0,mr=de;Je<mr.length;Je++)Le=mr[Je],ar.has(Le.name)||(Le.fn=_e[Le.fn],Be.push(Le),ar.set(Le.name,Le));for(var C=Be[0]&&Be[0].params.length<=2&&!x(Be[0].params),Z=Be[1]&&Be[1].params.length<=2&&!x(Be[1].params),se=Be[2]&&Be[2].params.length<=2&&!x(Be[2].params),Ee=Be[3]&&Be[3].params.length<=2&&!x(Be[3].params),ze=Be[4]&&Be[4].params.length<=2&&!x(Be[4].params),ke=Be[5]&&Be[5].params.length<=2&&!x(Be[5].params),Fr=C&&Z&&se&&Ee&&ze&&ke,_r=0;_r<Be.length;++_r)Be[_r].test=E(Be[_r].params);for(var en=C?b(Be[0].params[0]):ot,Un=Z?b(Be[1].params[0]):ot,Ln=se?b(Be[2].params[0]):ot,Fu=Ee?b(Be[3].params[0]):ot,Tu=ze?b(Be[4].params[0]):ot,Bu=ke?b(Be[5].params[0]):ot,$u=C?b(Be[0].params[1]):ot,Ou=Z?b(Be[1].params[1]):ot,Iu=se?b(Be[2].params[1]):ot,Ru=Ee?b(Be[3].params[1]):ot,_u=ze?b(Be[4].params[1]):ot,qu=ke?b(Be[5].params[1]):ot,kn=0;kn<Be.length;++kn)Be[kn].implementation=H(Be[kn].params,Be[kn].fn);var zu=C?Be[0].implementation:Xn,Pu=Z?Be[1].implementation:Xn,$a=se?Be[2].implementation:Xn,Oa=Ee?Be[3].implementation:Xn,Uu=ze?Be[4].implementation:Xn,Lu=ke?Be[5].implementation:Xn,ku=C?Be[0].params.length:-1,Vu=Z?Be[1].params.length:-1,Gu=se?Be[2].params.length:-1,Hu=Ee?Be[3].params.length:-1,Zu=ze?Be[4].params.length:-1,Ju=ke?Be[5].params.length:-1,Xu=Fr?6:0,Wu=Be.length,Yu=Be.map(function(jr){return jr.test}),Qu=Be.map(function(jr){return jr.implementation}),Mo=function(){for(var Tr=Xu;Tr<Wu;Tr++)if(Yu[Tr](arguments))return Qu[Tr].apply(this,arguments);return o.onMismatch(z,arguments,Be)};function Vn(jr,Tr){return arguments.length===ku&&en(jr)&&$u(Tr)?zu.apply(this,arguments):arguments.length===Vu&&Un(jr)&&Ou(Tr)?Pu.apply(this,arguments):arguments.length===Gu&&Ln(jr)&&Iu(Tr)?$a.apply(this,arguments):arguments.length===Hu&&Fu(jr)&&Ru(Tr)?Oa.apply(this,arguments):arguments.length===Zu&&Tu(jr)&&_u(Tr)?Uu.apply(this,arguments):arguments.length===Ju&&Bu(jr)&&qu(Tr)?Lu.apply(this,arguments):Mo.apply(this,arguments)}try{Object.defineProperty(Vn,"name",{value:z})}catch{}return Vn.signatures=ve,Vn._typedFunctionData={signatures:Be,signatureMap:ar},Vn}function fe(z,U,ee){throw B(z,U,ee)}function he(z){return ie(z,0,z.length-1)}function ce(z){return z[z.length-1]}function ie(z,U,ee){return Array.prototype.slice.call(z,U,ee)}function Ae(z,U){for(var ee=0;ee<z.length;ee++)if(U(z[ee]))return z[ee]}function Oe(z,U){return Array.prototype.concat.apply([],z.map(U))}function Ce(){var z=he(arguments).map(function(ee){return g(w(ee))}),U=ce(arguments);if(typeof U!="function")throw new TypeError("Callback function expected as last argument");return $e(z,U)}function $e(z,U){return{referTo:{references:z,callback:U}}}function V(z){if(typeof z!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:z}}}function X(z){return z&&Jn(z.referTo)==="object"&&Array.isArray(z.referTo.references)&&typeof z.referTo.callback=="function"}function oe(z){return z&&Jn(z.referToSelf)==="object"&&typeof z.referToSelf.callback=="function"}function G(z,U){if(!z)return U;if(U&&U!==z){var ee=new Error("Function names do not match (expected: "+z+", actual: "+U+")");throw ee.data={actual:U,expected:z},ee}return z}function Y(z){var U;for(var ee in z)Object.prototype.hasOwnProperty.call(z,ee)&&(m(z[ee])||typeof z[ee].signature=="string")&&(U=G(U,z[ee].name));return U}function te(z,U){var ee;for(ee in U)if(Object.prototype.hasOwnProperty.call(U,ee)){if(ee in z&&U[ee]!==z[ee]){var ue=new Error('Signature "'+ee+'" is defined twice');throw ue.data={signature:ee,sourceFunction:U[ee],destFunction:z[ee]},ue}z[ee]=U[ee]}}var ye=o;o=function(U){for(var ee=typeof U=="string",ue=ee?1:0,ve=ee?U:"",de={},be=ue;be<arguments.length;++be){var pe=arguments[be],we={},_e=void 0;if(typeof pe=="function"?(_e=pe.name,typeof pe.signature=="string"?we[pe.signature]=pe:m(pe)&&(we=pe.signatures)):r(pe)&&(we=pe,ee||(_e=Y(pe))),Object.keys(we).length===0){var Le=new TypeError("Argument to 'typed' at index "+be+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw Le.data={index:be,argument:pe},Le}ee||(ve=G(ve,_e)),te(de,we)}return re(ve||"",de)},o.create=fl,o.createCount=ye.createCount,o.onMismatch=fe,o.throwMismatchError=fe,o.createError=B,o.clear=u,o.clearConversions=s,o.addTypes=l,o._findType=f,o.referTo=Ce,o.referToSelf=V,o.convert=p,o.findSignature=v,o.find=h,o.isTypedFunction=m,o.warnAgainstDeprecatedThis=!0,o.addType=function(z,U){var ee="any";U!==!1&&a.has("Object")&&(ee="Object"),o.addTypes([z],ee)};function me(z){if(!z||typeof z.from!="string"||typeof z.to!="string"||typeof z.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(z.to===z.from)throw new SyntaxError('Illegal to define conversion from "'+z.from+'" to itself.')}return o.addConversion=function(z){me(z);var U=f(z.to);if(U.conversionsTo.every(function(ee){return ee.from!==z.from}))U.conversionsTo.push({from:z.from,convert:z.convert,index:i++});else throw new Error('There is already a conversion from "'+z.from+'" to "'+U.name+'"')},o.addConversions=function(z){z.forEach(o.addConversion)},o.removeConversion=function(z){me(z);var U=f(z.to),ee=Ae(U.conversionsTo,function(ve){return ve.from===z.from});if(!ee)throw new Error("Attempt to remove nonexistent conversion from "+z.from+" to "+z.to);if(ee.convert!==z.convert)throw new Error("Conversion to remove does not match existing conversion");var ue=U.conversionsTo.indexOf(ee);U.conversionsTo.splice(ue,1)},o.resolve=function(z,U){if(!m(z))throw new TypeError(cl);for(var ee=z._typedFunctionData.signatures,ue=0;ue<ee.length;++ue)if(ee[ue].test(U))return ee[ue];return null},o}const ml=fl();function qe(r){return typeof r=="boolean"?!0:isFinite(r)?r===Math.round(r):!1}var tn=Math.sign||function(r){return r>0?1:r<0?-1:0},H0=Math.log2||function(e){return Math.log(e)/Math.LN2},Z0=Math.log10||function(e){return Math.log(e)/Math.LN10},J0=Math.log1p||function(r){return Math.log(r+1)},X0=Math.cbrt||function(e){if(e===0)return e;var t=e<0,a;return t&&(e=-e),isFinite(e)?(a=Math.exp(Math.log(e)/3),a=(e/(a*a)+2*a)/3):a=e,t?-a:a},W0=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function Vo(r,e,t){var a={2:"0b",8:"0o",16:"0x"},n=a[e],i="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!qe(t))throw new Error("size must be an integer");if(r>2**(t-1)-1||r<-(2**(t-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!qe(r))throw new Error("Value must be an integer");r<0&&(r=r+2**t),i="i".concat(t)}var o="";return r<0&&(r=-r,o="-"),"".concat(o).concat(n).concat(r.toString(e)).concat(i)}function Sn(r,e){if(typeof e=="function")return e(r);if(r===1/0)return"Infinity";if(r===-1/0)return"-Infinity";if(isNaN(r))return"NaN";var t="auto",a,n;if(e&&(e.notation&&(t=e.notation),tr(e)?a=e:tr(e.precision)&&(a=e.precision),e.wordSize&&(n=e.wordSize,typeof n!="number")))throw new Error('Option "wordSize" must be a number');switch(t){case"fixed":return vl(r,a);case"exponential":return pl(r,a);case"engineering":return Y0(r,a);case"bin":return Vo(r,2,n);case"oct":return Vo(r,8,n);case"hex":return Vo(r,16,n);case"auto":return Q0(r,a,e&&e).replace(/((\.\d*?)(0+))($|e)/,function(){var i=arguments[2],o=arguments[4];return i!=="."?i+o:o});default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function fi(r){var e=String(r).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!e)throw new SyntaxError("Invalid number "+r);var t=e[1],a=e[2],n=parseFloat(e[4]||"0"),i=a.indexOf(".");n+=i!==-1?i-1:a.length-1;var o=a.replace(".","").replace(/^0*/,function(f){return n-=f.length,""}).replace(/0*$/,"").split("").map(function(f){return parseInt(f)});return o.length===0&&(o.push(0),n++),{sign:t,coefficients:o,exponent:n}}function Y0(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=fi(r),a=mi(t,e),n=a.exponent,i=a.coefficients,o=n%3===0?n:n<0?n-3-n%3:n-n%3;if(tr(e))for(;e>i.length||n-o+1>i.length;)i.push(0);else for(var f=Math.abs(n-o)-(i.length-1),l=0;l<f;l++)i.push(0);for(var u=Math.abs(n-o),s=1;u>0;)s++,u--;var c=i.slice(s).join(""),m=tr(e)&&c.length||c.match(/[1-9]/)?"."+c:"",v=i.slice(0,s).join("")+m+"e"+(n>=0?"+":"")+o.toString();return a.sign+v}function vl(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=fi(r),a=typeof e=="number"?mi(t,t.exponent+1+e):t,n=a.coefficients,i=a.exponent+1,o=i+(e||0);return n.length<o&&(n=n.concat(Wn(o-n.length))),i<0&&(n=Wn(-i+1).concat(n),i=1),i<n.length&&n.splice(i,0,i===0?"0.":"."),a.sign+n.join("")}function pl(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=fi(r),a=e?mi(t,e):t,n=a.coefficients,i=a.exponent;n.length<e&&(n=n.concat(Wn(e-n.length)));var o=n.shift();return a.sign+o+(n.length>0?"."+n.join(""):"")+"e"+(i>=0?"+":"")+i}function Q0(r,e,t){if(isNaN(r)||!isFinite(r))return String(r);var a=t&&t.lowerExp!==void 0?t.lowerExp:-3,n=t&&t.upperExp!==void 0?t.upperExp:5,i=fi(r),o=e?mi(i,e):i;if(o.exponent<a||o.exponent>=n)return pl(r,e);var f=o.coefficients,l=o.exponent;f.length<e&&(f=f.concat(Wn(e-f.length))),f=f.concat(Wn(l-f.length+1+(f.length<e?e-f.length:0))),f=Wn(-l).concat(f);var u=l>0?l:0;return u<f.length-1&&f.splice(u+1,0,"."),o.sign+f.join("")}function mi(r,e){for(var t={sign:r.sign,coefficients:r.coefficients,exponent:r.exponent},a=t.coefficients;e<=0;)a.unshift(0),t.exponent++,e++;if(a.length>e){var n=a.splice(e,a.length-e);if(n[0]>=5){var i=e-1;for(a[i]++;a[i]===10;)a.pop(),i===0&&(a.unshift(0),t.exponent++,i++),i--,a[i]++}}return t}function Wn(r){for(var e=[],t=0;t<r;t++)e.push(0);return e}function K0(r){return r.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var j0=Number.EPSILON||2220446049250313e-31;function tt(r,e,t){if(t==null)return r===e;if(r===e)return!0;if(isNaN(r)||isNaN(e))return!1;if(isFinite(r)&&isFinite(e)){var a=Math.abs(r-e);return a<j0?!0:a<=Math.max(Math.abs(r),Math.abs(e))*t}return!1}var eg=Math.acosh||function(r){return Math.log(Math.sqrt(r*r-1)+r)},rg=Math.asinh||function(r){return Math.log(Math.sqrt(r*r+1)+r)},tg=Math.atanh||function(r){return Math.log((1+r)/(1-r))/2},ng=Math.cosh||function(r){return(Math.exp(r)+Math.exp(-r))/2},ag=Math.sinh||function(r){return(Math.exp(r)-Math.exp(-r))/2},ig=Math.tanh||function(r){var e=Math.exp(2*r);return(e-1)/(e+1)};function og(r,e){var t=r>0?!0:r<0?!1:1/r===1/0,a=e>0?!0:e<0?!1:1/e===1/0;return t^a?-r:r}function Go(r,e,t){var a=r.constructor,n=new a(2),i="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!qe(t))throw new Error("size must be an integer");if(r.greaterThan(n.pow(t-1).sub(1))||r.lessThan(n.pow(t-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!r.isInteger())throw new Error("Value must be an integer");r.lessThan(0)&&(r=r.add(n.pow(t))),i="i".concat(t)}switch(e){case 2:return"".concat(r.toBinary()).concat(i);case 8:return"".concat(r.toOctal()).concat(i);case 16:return"".concat(r.toHexadecimal()).concat(i);default:throw new Error("Base ".concat(e," not supported "))}}function sg(r,e){if(typeof e=="function")return e(r);if(!r.isFinite())return r.isNaN()?"NaN":r.gt(0)?"Infinity":"-Infinity";var t="auto",a,n;if(e!==void 0&&(e.notation&&(t=e.notation),typeof e=="number"?a=e:e.precision&&(a=e.precision),e.wordSize&&(n=e.wordSize,typeof n!="number")))throw new Error('Option "wordSize" must be a number');switch(t){case"fixed":return lg(r,a);case"exponential":return hl(r,a);case"engineering":return ug(r,a);case"bin":return Go(r,2,n);case"oct":return Go(r,8,n);case"hex":return Go(r,16,n);case"auto":{var i=e&&e.lowerExp!==void 0?e.lowerExp:-3,o=e&&e.upperExp!==void 0?e.upperExp:5;if(r.isZero())return"0";var f,l=r.toSignificantDigits(a),u=l.e;return u>=i&&u<o?f=l.toFixed():f=hl(r,a),f.replace(/((\.\d*?)(0+))($|e)/,function(){var s=arguments[2],c=arguments[4];return s!=="."?s+c:c})}default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function ug(r,e){var t=r.e,a=t%3===0?t:t<0?t-3-t%3:t-t%3,n=r.mul(Math.pow(10,-a)),i=n.toPrecision(e);return i.indexOf("e")!==-1&&(i=n.toString()),i+"e"+(t>=0?"+":"")+a.toString()}function hl(r,e){return e!==void 0?r.toExponential(e-1):r.toExponential()}function lg(r,e){return r.toFixed(e)}function cg(r,e){var t=r.length-e.length,a=r.length;return r.substring(t,a)===e}function Ye(r,e){var t=fg(r,e);return e&&typeof e=="object"&&"truncate"in e&&t.length>e.truncate?t.substring(0,e.truncate-3)+"...":t}function fg(r,e){if(typeof r=="number")return Sn(r,e);if(rr(r))return sg(r,e);if(mg(r))return!e||e.fraction!=="decimal"?r.s*r.n+"/"+r.d:r.toString();if(Array.isArray(r))return dl(r,e);if(Wr(r))return'"'+r+'"';if(typeof r=="function")return r.syntax?String(r.syntax):"function";if(r&&typeof r=="object"){if(typeof r.format=="function")return r.format(e);if(r&&r.toString(e)!=={}.toString())return r.toString(e);var t=Object.keys(r).map(a=>'"'+a+'": '+Ye(r[a],e));return"{"+t.join(", ")+"}"}return String(r)}function vi(r){for(var e=String(r),t="",a=0;a<e.length;){var n=e.charAt(a);n==="\\"?(t+=n,a++,n=e.charAt(a),(n===""||'"\\/bfnrtu'.indexOf(n)===-1)&&(t+="\\"),t+=n):n==='"'?t+='\\"':t+=n,a++}return'"'+t+'"'}function st(r){var e=String(r);return e=e.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"),e}function dl(r,e){if(Array.isArray(r)){for(var t="[",a=r.length,n=0;n<a;n++)n!==0&&(t+=", "),t+=dl(r[n],e);return t+="]",t}else return Ye(r,e)}function mg(r){return r&&typeof r=="object"&&typeof r.s=="number"&&typeof r.n=="number"&&typeof r.d=="number"||!1}function Ho(r,e){if(!Wr(r))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+br(r)+", index: 0)");if(!Wr(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+br(e)+", index: 1)");return r===e?0:r>e?1:-1}function Ke(r,e,t){if(!(this instanceof Ke))throw new SyntaxError("Constructor must be called with the new operator");this.actual=r,this.expected=e,this.relation=t,this.message="Dimension mismatch ("+(Array.isArray(r)?"["+r.join(", ")+"]":r)+" "+(this.relation||"!=")+" "+(Array.isArray(e)?"["+e.join(", ")+"]":e)+")",this.stack=new Error().stack}Ke.prototype=new RangeError,Ke.prototype.constructor=RangeError,Ke.prototype.name="DimensionError",Ke.prototype.isDimensionError=!0;function ht(r,e,t){if(!(this instanceof ht))throw new SyntaxError("Constructor must be called with the new operator");this.index=r,arguments.length<3?(this.min=0,this.max=e):(this.min=e,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}ht.prototype=new RangeError,ht.prototype.constructor=RangeError,ht.prototype.name="IndexError",ht.prototype.isIndexError=!0;function er(r){for(var e=[];Array.isArray(r);)e.push(r.length),r=r[0];return e}function gl(r,e,t){var a,n=r.length;if(n!==e[t])throw new Ke(n,e[t]);if(t<e.length-1){var i=t+1;for(a=0;a<n;a++){var o=r[a];if(!Array.isArray(o))throw new Ke(e.length-1,e.length,"<");gl(r[a],e,i)}}else for(a=0;a<n;a++)if(Array.isArray(r[a]))throw new Ke(e.length+1,e.length,">")}function yl(r,e){var t=e.length===0;if(t){if(Array.isArray(r))throw new Ke(r.length,0)}else gl(r,e,0)}function vr(r,e){if(!tr(r)||!qe(r))throw new TypeError("Index must be an integer (value: "+r+")");if(r<0||typeof e=="number"&&r>=e)throw new ht(r,e)}function Yn(r,e,t){if(!Array.isArray(r)||!Array.isArray(e))throw new TypeError("Array expected");if(e.length===0)throw new Error("Resizing to scalar is not supported");e.forEach(function(n){if(!tr(n)||!qe(n)||n<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Ye(e)+")")});var a=t!==void 0?t:0;return Zo(r,e,0,a),r}function Zo(r,e,t,a){var n,i,o=r.length,f=e[t],l=Math.min(o,f);if(r.length=f,t<e.length-1){var u=t+1;for(n=0;n<l;n++)i=r[n],Array.isArray(i)||(i=[i],r[n]=i),Zo(i,e,u,a);for(n=l;n<f;n++)i=[],r[n]=i,Zo(i,e,u,a)}else{for(n=0;n<l;n++)for(;Array.isArray(r[n]);)r[n]=r[n][0];for(n=l;n<f;n++)r[n]=a}}function bl(r,e){var t=or(r),a=t.length;if(!Array.isArray(r)||!Array.isArray(e))throw new TypeError("Array expected");if(e.length===0)throw new Ke(0,a,"!=");e=Jo(e,a);var n=xl(e);if(a!==n)throw new Ke(n,a,"!=");try{return vg(t,e)}catch(i){throw i instanceof Ke?new Ke(n,a,"!="):i}}function Jo(r,e){var t=xl(r),a=r.slice(),n=-1,i=r.indexOf(n),o=r.indexOf(n,i+1)>=0;if(o)throw new Error("More than one wildcard in sizes");var f=i>=0,l=e%t===0;if(f)if(l)a[i]=-e/t;else throw new Error("Could not replace wildcard, since "+e+" is no multiple of "+-t);return a}function xl(r){return r.reduce((e,t)=>e*t,1)}function vg(r,e){for(var t=r,a,n=e.length-1;n>0;n--){var i=e[n];a=[];for(var o=t.length/i,f=0;f<o;f++)a.push(t.slice(f*i,(f+1)*i));t=a}return t}function pi(r,e){for(var t=e||er(r);Array.isArray(r)&&r.length===1;)r=r[0],t.shift();for(var a=t.length;t[a-1]===1;)a--;return a<t.length&&(r=wl(r,a,0),t.length=a),r}function wl(r,e,t){var a,n;if(t<e){var i=t+1;for(a=0,n=r.length;a<n;a++)r[a]=wl(r[a],e,i)}else for(;Array.isArray(r);)r=r[0];return r}function Nl(r,e,t,a){var n=a||er(r);if(t)for(var i=0;i<t;i++)r=[r],n.unshift(1);for(r=Dl(r,e,0);n.length<e;)n.push(1);return r}function Dl(r,e,t){var a,n;if(Array.isArray(r)){var i=t+1;for(a=0,n=r.length;a<n;a++)r[a]=Dl(r[a],e,i)}else for(var o=t;o<e;o++)r=[r];return r}function or(r){if(!Array.isArray(r))return r;var e=[];return r.forEach(function t(a){Array.isArray(a)?a.forEach(t):e.push(a)}),e}function Gt(r,e){return Array.prototype.map.call(r,e)}function hi(r,e){Array.prototype.forEach.call(r,e)}function Al(r,e){if(er(r).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(r,e)}function di(r,e){if(er(r).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(r,t=>e.test(t))}function El(r,e){return Array.prototype.join.call(r,e)}function Qn(r){if(!Array.isArray(r))throw new TypeError("Array input expected");if(r.length===0)return r;var e=[],t=0;e[0]={value:r[0],identifier:0};for(var a=1;a<r.length;a++)r[a]===r[a-1]?t++:t=0,e.push({value:r[a],identifier:t});return e}function gi(r){if(!Array.isArray(r))throw new TypeError("Array input expected");if(r.length===0)return r;for(var e=[],t=0;t<r.length;t++)e.push(r[t].value);return e}function Ua(r,e){for(var t,a=0,n=0;n<r.length;n++){var i=r[n],o=Array.isArray(i);if(n===0&&o&&(a=i.length),o&&i.length!==a)return;var f=o?Ua(i,e):e(i);if(t===void 0)t=f;else if(t!==f)return"mixed"}return t}function q(r,e,t,a){function n(i){var o=L0(i,e.map(dg));return pg(r,e,i),t(o)}return n.isFactory=!0,n.fn=r,n.dependencies=e.slice().sort(),a&&(n.meta=a),n}function pg(r,e,t){var a=e.filter(i=>!hg(i)).every(i=>t[i]!==void 0);if(!a){var n=e.filter(i=>t[i]===void 0);throw new Error('Cannot create function "'.concat(r,'", ')+"some dependencies are missing: ".concat(n.map(i=>'"'.concat(i,'"')).join(", "),"."))}}function hg(r){return r&&r[0]==="?"}function dg(r){return r&&r[0]==="?"?r.slice(1):r}function ut(r,e){if(Sl(r)&&Xo(r,e))return r[e];throw typeof r[e]=="function"&&Wo(r,e)?new Error('Cannot access method "'+e+'" as a property'):new Error('No access to property "'+e+'"')}function Kn(r,e,t){if(Sl(r)&&Xo(r,e))return r[e]=t,t;throw new Error('No access to property "'+e+'"')}function gg(r,e){return e in r}function Xo(r,e){return!r||typeof r!="object"?!1:Re(bg,e)?!0:!(e in Object.prototype||e in Function.prototype)}function yg(r,e){if(!Wo(r,e))throw new Error('No access to method "'+e+'"')}function Wo(r,e){return r==null||typeof r[e]!="function"||Re(r,e)&&Object.getPrototypeOf&&e in Object.getPrototypeOf(r)?!1:Re(xg,e)?!0:!(e in Object.prototype||e in Function.prototype)}function Sl(r){return typeof r=="object"&&r&&r.constructor===Object}var bg={length:!0,name:!0},xg={toString:!0,valueOf:!0,toLocaleString:!0};class Yo{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return ut(this.wrappedObject,e)}set(e,t){return Kn(this.wrappedObject,e,t),this}has(e){return gg(this.wrappedObject,e)}}function jn(){return new Map}function ea(r){if(!r)return jn();if(Qo(r))return r;if(Lo(r))return new Yo(r);throw new Error("createMap can create maps from objects or Maps")}function wg(r){if(r instanceof Yo)return r.wrappedObject;var e={};for(var t of r.keys()){var a=r.get(t);Kn(e,t,a)}return e}function Qo(r){return r?r instanceof Map||r instanceof Yo||typeof r.set=="function"&&typeof r.get=="function"&&typeof r.keys=="function"&&typeof r.has=="function":!1}function Cl(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),a=1;a<e;a++)t[a-1]=arguments[a];for(var n of t)if(!!n){if(Qo(n))for(var i of n.keys())r.set(i,n.get(i));else if(Lo(n))for(var o of Object.keys(n))r.set(o,n[o])}return r}var Ml=function(){return Ml=ml.create,ml},Ng=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],Dg=q("typed",Ng,function(e){var{BigNumber:t,Complex:a,DenseMatrix:n,Fraction:i}=e,o=Ml();return o.clear(),o.addTypes([{name:"number",test:tr},{name:"Complex",test:Lt},{name:"BigNumber",test:rr},{name:"Fraction",test:qa},{name:"Unit",test:kt},{name:"identifier",test:f=>Wr&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])*$/.test(f)},{name:"string",test:Wr},{name:"Chain",test:ol},{name:"Array",test:cr},{name:"Matrix",test:Ve},{name:"DenseMatrix",test:ui},{name:"SparseMatrix",test:An},{name:"Range",test:Uo},{name:"Index",test:li},{name:"boolean",test:C0},{name:"ResultSet",test:M0},{name:"Help",test:il},{name:"function",test:F0},{name:"Date",test:T0},{name:"RegExp",test:B0},{name:"null",test:$0},{name:"undefined",test:O0},{name:"AccessorNode",test:En},{name:"ArrayNode",test:it},{name:"AssignmentNode",test:I0},{name:"BlockNode",test:R0},{name:"ConditionalNode",test:_0},{name:"ConstantNode",test:ir},{name:"FunctionNode",test:rn},{name:"FunctionAssignmentNode",test:za},{name:"IndexNode",test:Zn},{name:"Node",test:fr},{name:"ObjectNode",test:ci},{name:"OperatorNode",test:Br},{name:"ParenthesisNode",test:Vt},{name:"RangeNode",test:q0},{name:"RelationalNode",test:z0},{name:"SymbolNode",test:qr},{name:"Map",test:Qo},{name:"Object",test:Lo}]),o.addConversions([{from:"number",to:"BigNumber",convert:function(l){if(t||Ko(l),K0(l)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+l+"). Use function bignumber(x) to convert to BigNumber.");return new t(l)}},{from:"number",to:"Complex",convert:function(l){return a||yi(l),new a(l,0)}},{from:"BigNumber",to:"Complex",convert:function(l){return a||yi(l),new a(l.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(l){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(l){return a||yi(l),new a(l.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(l){i||jo(l);var u=new i(l);if(u.valueOf()!==l)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+l+"). Use function fraction(x) to convert to Fraction.");return u}},{from:"string",to:"number",convert:function(l){var u=Number(l);if(isNaN(u))throw new Error('Cannot convert "'+l+'" to a number');return u}},{from:"string",to:"BigNumber",convert:function(l){t||Ko(l);try{return new t(l)}catch{throw new Error('Cannot convert "'+l+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(l){i||jo(l);try{return new i(l)}catch{throw new Error('Cannot convert "'+l+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(l){a||yi(l);try{return new a(l)}catch{throw new Error('Cannot convert "'+l+'" to Complex')}}},{from:"boolean",to:"number",convert:function(l){return+l}},{from:"boolean",to:"BigNumber",convert:function(l){return t||Ko(l),new t(+l)}},{from:"boolean",to:"Fraction",convert:function(l){return i||jo(l),new i(+l)}},{from:"boolean",to:"string",convert:function(l){return String(l)}},{from:"Array",to:"Matrix",convert:function(l){return n||Ag(),new n(l)}},{from:"Matrix",to:"Array",convert:function(l){return l.valueOf()}}]),o.onMismatch=(f,l,u)=>{var s=o.createError(f,l,u);if(["wrongType","mismatch"].includes(s.data.category)&&l.length===1&&Mt(l[0])&&u.some(m=>!m.params.includes(","))){var c=new TypeError("Function '".concat(f,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(f,")'."));throw c.data=s.data,c}throw s},o.onMismatch=(f,l,u)=>{var s=o.createError(f,l,u);if(["wrongType","mismatch"].includes(s.data.category)&&l.length===1&&Mt(l[0])&&u.some(m=>!m.params.includes(","))){var c=new TypeError("Function '".concat(f,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(f,")'."));throw c.data=s.data,c}throw s},o});function Ko(r){throw new Error("Cannot convert value ".concat(r," into a BigNumber: no class 'BigNumber' provided"))}function yi(r){throw new Error("Cannot convert value ".concat(r," into a Complex number: no class 'Complex' provided"))}function Ag(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function jo(r){throw new Error("Cannot convert value ".concat(r," into a Fraction, no class 'Fraction' provided."))}var Eg="ResultSet",Sg=[],Cg=q(Eg,Sg,()=>{function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this.entries=e||[]}return r.prototype.type="ResultSet",r.prototype.isResultSet=!0,r.prototype.valueOf=function(){return this.entries},r.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},r.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},r.fromJSON=function(e){return new r(e.entries)},r},{isClass:!0});/*!
|
|
8
|
+
`);return Object.freeze(ol)};Sr(ge,ol,{MATRIX_OPTIONS:Y0,NUMBER_OPTIONS:Q0});function ht(r,e){var t=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=K0(r))||e&&r&&typeof r.length=="number"){t&&(r=t);var a=0,n=function(){};return{s:n,n:function(){return a>=r.length?{done:!0}:{done:!1,value:r[a++]}},e:function(u){throw u},f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
9
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i=!0,o=!1,f;return{s:function(){t=t.call(r)},n:function(){var u=t.next();return i=u.done,u},e:function(u){o=!0,f=u},f:function(){try{!i&&t.return!=null&&t.return()}finally{if(o)throw f}}}}function K0(r,e){if(!!r){if(typeof r=="string")return cl(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);if(t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set")return Array.from(r);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return cl(r,e)}}function cl(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,a=new Array(e);t<e;t++)a[t]=r[t];return a}function Xn(r){return Xn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Xn(r)}function fl(){return!0}function st(){return!1}function Wn(){}var ml="Argument is not a typed-function.";function vl(){function r(z){return Xn(z)==="object"&&z!==null&&z.constructor===Object}var e=[{name:"number",test:function(U){return typeof U=="number"}},{name:"string",test:function(U){return typeof U=="string"}},{name:"boolean",test:function(U){return typeof U=="boolean"}},{name:"Function",test:function(U){return typeof U=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(U){return U instanceof Date}},{name:"RegExp",test:function(U){return U instanceof RegExp}},{name:"Object",test:r},{name:"null",test:function(U){return U===null}},{name:"undefined",test:function(U){return U===void 0}}],t={name:"any",test:fl,isAny:!0},a,n,i=0,o={createCount:0};function f(z){var U=a.get(z);if(U)return U;var ee='Unknown type "'+z+'"',ue=z.toLowerCase(),ve,de=ht(n),be;try{for(de.s();!(be=de.n()).done;)if(ve=be.value,ve.toLowerCase()===ue){ee+='. Did you mean "'+ve+'" ?';break}}catch(pe){de.e(pe)}finally{de.f()}throw new TypeError(ee)}function l(z){for(var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any",ee=U?f(U).index:n.length,ue=[],ve=0;ve<z.length;++ve){if(!z[ve]||typeof z[ve].name!="string"||typeof z[ve].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");var de=z[ve].name;if(a.has(de))throw new TypeError('Duplicate type name "'+de+'"');ue.push(de),a.set(de,{name:de,test:z[ve].test,isAny:z[ve].isAny,index:ee+ve,conversionsTo:[]})}var be=n.slice(ee);n=n.slice(0,ee).concat(ue).concat(be);for(var pe=ee+ue.length;pe<n.length;++pe)a.get(n[pe]).index=pe}function u(){a=new Map,n=[],i=0,l([t],!1)}u(),l(e);function s(){var z,U=ht(n),ee;try{for(U.s();!(ee=U.n()).done;)z=ee.value,a.get(z).conversionsTo=[]}catch(ue){U.e(ue)}finally{U.f()}i=0}function c(z){var U=n.filter(function(ee){var ue=a.get(ee);return!ue.isAny&&ue.test(z)});return U.length?U:["any"]}function m(z){return z&&typeof z=="function"&&"_typedFunctionData"in z}function v(z,U,ee){if(!m(z))throw new TypeError(ml);var ue=ee&&ee.exact,ve=Array.isArray(U)?U.join(","):U,de=w(ve),be=g(de);if(!ue||be in z.signatures){var pe=z._typedFunctionData.signatureMap.get(be);if(pe)return pe}var we=de.length,_e;if(ue){_e=[];var Le;for(Le in z.signatures)_e.push(z._typedFunctionData.signatureMap.get(Le))}else _e=z._typedFunctionData.signatures;for(var Be=0;Be<we;++Be){var ar=de[Be],Je=[],mr=void 0,C=ht(_e),Z;try{for(C.s();!(Z=C.n()).done;){mr=Z.value;var se=A(mr.params,Be);if(!(!se||ar.restParam&&!se.restParam)){if(!se.hasAny){var Ee=function(){var _r=d(se);if(ar.types.some(function(tn){return!_r.has(tn.name)}))return"continue"}();if(Ee==="continue")continue}Je.push(mr)}}}catch(_r){C.e(_r)}finally{C.f()}if(_e=Je,_e.length===0)break}var ze,ke=ht(_e),Fr;try{for(ke.s();!(Fr=ke.n()).done;)if(ze=Fr.value,ze.params.length<=we)return ze}catch(_r){ke.e(_r)}finally{ke.f()}throw new TypeError("Signature not found (signature: "+(z.name||"unnamed")+"("+g(de,", ")+"))")}function h(z,U,ee){return v(z,U,ee).implementation}function p(z,U){var ee=f(U);if(ee.test(z))return z;var ue=ee.conversionsTo;if(ue.length===0)throw new Error("There are no conversions to "+U+" defined.");for(var ve=0;ve<ue.length;ve++){var de=f(ue[ve].from);if(de.test(z))return ue[ve].convert(z)}throw new Error("Cannot convert "+z+" to "+U)}function g(z){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return z.map(function(ee){return ee.name}).join(U)}function y(z){var U=z.indexOf("...")===0,ee=U?z.length>3?z.slice(3):"any":z,ue=ee.split("|").map(function(pe){return f(pe.trim())}),ve=!1,de=U?"...":"",be=ue.map(function(pe){return ve=pe.isAny||ve,de+=pe.name+"|",{name:pe.name,typeIndex:pe.index,test:pe.test,isAny:pe.isAny,conversion:null,conversionIndex:-1}});return{types:be,name:de.slice(0,-1),hasAny:ve,hasConversion:!1,restParam:U}}function N(z){var U=z.types.map(function(be){return be.name}),ee=F(U),ue=z.hasAny,ve=z.name,de=ee.map(function(be){var pe=f(be.from);return ue=pe.isAny||ue,ve+="|"+be.from,{name:be.from,typeIndex:pe.index,test:pe.test,isAny:pe.isAny,conversion:be,conversionIndex:be.index}});return{types:z.types.concat(de),name:ve,hasAny:ue,hasConversion:de.length>0,restParam:z.restParam}}function d(z){return z.typeSet||(z.typeSet=new Set,z.types.forEach(function(U){return z.typeSet.add(U.name)})),z.typeSet}function w(z){var U=[];if(typeof z!="string")throw new TypeError("Signatures must be strings");var ee=z.trim();if(ee==="")return U;for(var ue=ee.split(","),ve=0;ve<ue.length;++ve){var de=y(ue[ve].trim());if(de.restParam&&ve!==ue.length-1)throw new SyntaxError('Unexpected rest parameter "'+ue[ve]+'": only allowed for the last parameter');if(de.types.length===0)return null;U.push(de)}return U}function x(z){var U=ce(z);return U?U.restParam:!1}function b(z){if(!z||z.types.length===0)return fl;if(z.types.length===1)return f(z.types[0].name).test;if(z.types.length===2){var U=f(z.types[0].name).test,ee=f(z.types[1].name).test;return function(de){return U(de)||ee(de)}}else{var ue=z.types.map(function(ve){return f(ve.name).test});return function(de){for(var be=0;be<ue.length;be++)if(ue[be](de))return!0;return!1}}}function E(z){var U,ee,ue;if(x(z)){U=he(z).map(b);var ve=U.length,de=b(ce(z)),be=function(we){for(var _e=ve;_e<we.length;_e++)if(!de(we[_e]))return!1;return!0};return function(we){for(var _e=0;_e<U.length;_e++)if(!U[_e](we[_e]))return!1;return be(we)&&we.length>=ve+1}}else return z.length===0?function(we){return we.length===0}:z.length===1?(ee=b(z[0]),function(we){return ee(we[0])&&we.length===1}):z.length===2?(ee=b(z[0]),ue=b(z[1]),function(we){return ee(we[0])&&ue(we[1])&&we.length===2}):(U=z.map(b),function(we){for(var _e=0;_e<U.length;_e++)if(!U[_e](we[_e]))return!1;return we.length===U.length})}function A(z,U){return U<z.length?z[U]:x(z)?ce(z):null}function S(z,U){var ee=A(z,U);return ee?d(ee):new Set}function D(z){return z.conversion===null||z.conversion===void 0}function T(z,U){var ee=new Set;return z.forEach(function(ue){var ve=S(ue.params,U),de,be=ht(ve),pe;try{for(be.s();!(pe=be.n()).done;)de=pe.value,ee.add(de)}catch(we){be.e(we)}finally{be.f()}}),ee.has("any")?["any"]:Array.from(ee)}function B(z,U,ee){var ue,ve,de=z||"unnamed",be=ee,pe,we=function(){var C=[];if(be.forEach(function(se){var Ee=A(se.params,pe),ze=b(Ee);(pe<se.params.length||x(se.params))&&ze(U[pe])&&C.push(se)}),C.length===0){if(ve=T(be,pe),ve.length>0){var Z=c(U[pe]);return ue=new TypeError("Unexpected type of argument in function "+de+" (expected: "+ve.join(" or ")+", actual: "+Z.join(" | ")+", index: "+pe+")"),ue.data={category:"wrongType",fn:de,index:pe,actual:Z,expected:ve},{v:ue}}}else be=C};for(pe=0;pe<U.length;pe++){var _e=we();if(Xn(_e)==="object")return _e.v}var Le=be.map(function(mr){return x(mr.params)?1/0:mr.params.length});if(U.length<Math.min.apply(null,Le))return ve=T(be,pe),ue=new TypeError("Too few arguments in function "+de+" (expected: "+ve.join(" or ")+", index: "+U.length+")"),ue.data={category:"tooFewArgs",fn:de,index:U.length,expected:ve},ue;var Be=Math.max.apply(null,Le);if(U.length>Be)return ue=new TypeError("Too many arguments in function "+de+" (expected: "+Be+", actual: "+U.length+")"),ue.data={category:"tooManyArgs",fn:de,index:U.length,expectedLength:Be},ue;for(var ar=[],Je=0;Je<U.length;++Je)ar.push(c(U[Je]).join("|"));return ue=new TypeError('Arguments of type "'+ar.join(", ")+'" do not match any of the defined signatures of function '+de+"."),ue.data={category:"mismatch",actual:ar},ue}function I(z){for(var U=n.length+1,ee=0;ee<z.types.length;ee++)D(z.types[ee])&&(U=Math.min(U,z.types[ee].typeIndex));return U}function P(z){for(var U=i+1,ee=0;ee<z.types.length;ee++)D(z.types[ee])||(U=Math.min(U,z.types[ee].conversionIndex));return U}function R(z,U){if(z.hasAny){if(!U.hasAny)return 1}else if(U.hasAny)return-1;if(z.restParam){if(!U.restParam)return 1}else if(U.restParam)return-1;if(z.hasConversion){if(!U.hasConversion)return 1}else if(U.hasConversion)return-1;var ee=I(z)-I(U);if(ee<0)return-1;if(ee>0)return 1;var ue=P(z)-P(U);return ue<0?-1:ue>0?1:0}function M(z,U){var ee=z.params,ue=U.params,ve=ce(ee),de=ce(ue),be=x(ee),pe=x(ue);if(be&&ve.hasAny){if(!pe||!de.hasAny)return 1}else if(pe&&de.hasAny)return-1;var we=0,_e=0,Le,Be=ht(ee),ar;try{for(Be.s();!(ar=Be.n()).done;)Le=ar.value,Le.hasAny&&++we,Le.hasConversion&&++_e}catch(kn){Be.e(kn)}finally{Be.f()}var Je=0,mr=0,C=ht(ue),Z;try{for(C.s();!(Z=C.n()).done;)Le=Z.value,Le.hasAny&&++Je,Le.hasConversion&&++mr}catch(kn){C.e(kn)}finally{C.f()}if(we!==Je)return we-Je;if(be&&ve.hasConversion){if(!pe||!de.hasConversion)return 1}else if(pe&&de.hasConversion)return-1;if(_e!==mr)return _e-mr;if(be){if(!pe)return 1}else if(pe)return-1;var se=(ee.length-ue.length)*(be?-1:1);if(se!==0)return se;for(var Ee=[],ze=0,ke=0;ke<ee.length;++ke){var Fr=R(ee[ke],ue[ke]);Ee.push(Fr),ze+=Fr}if(ze!==0)return ze;for(var _r,tn=0,Ln=Ee;tn<Ln.length;tn++)if(_r=Ln[tn],_r!==0)return _r;return 0}function F(z){if(z.length===0)return[];var U=z.map(f);z.length>1&&U.sort(function(we,_e){return we.index-_e.index});var ee=U[0].conversionsTo;if(z.length===1)return ee;ee=ee.concat([]);for(var ue=new Set(z),ve=1;ve<U.length;++ve){var de=void 0,be=ht(U[ve].conversionsTo),pe;try{for(be.s();!(pe=be.n()).done;)de=pe.value,ue.has(de.from)||(ee.push(de),ue.add(de.from))}catch(we){be.e(we)}finally{be.f()}}return ee}function H(z,U){var ee=U;if(z.some(function(pe){return pe.hasConversion})){var ue=x(z),ve=z.map($);ee=function(){for(var we=[],_e=ue?arguments.length-1:arguments.length,Le=0;Le<_e;Le++)we[Le]=ve[Le](arguments[Le]);return ue&&(we[_e]=arguments[_e].map(ve[_e])),U.apply(this,we)}}var de=ee;if(x(z)){var be=z.length-1;de=function(){return ee.apply(this,ie(arguments,0,be).concat([ie(arguments,be)]))}}return de}function $(z){var U,ee,ue,ve,de=[],be=[];switch(z.types.forEach(function(pe){pe.conversion&&(de.push(f(pe.conversion.from).test),be.push(pe.conversion.convert))}),be.length){case 0:return function(we){return we};case 1:return U=de[0],ue=be[0],function(we){return U(we)?ue(we):we};case 2:return U=de[0],ee=de[1],ue=be[0],ve=be[1],function(we){return U(we)?ue(we):ee(we)?ve(we):we};default:return function(we){for(var _e=0;_e<be.length;_e++)if(de[_e](we))return be[_e](we);return we}}}function k(z){function U(ee,ue,ve){if(ue<ee.length){var de=ee[ue],be=[];if(de.restParam){var pe=de.types.filter(D);pe.length<de.types.length&&be.push({types:pe,name:"..."+pe.map(function(we){return we.name}).join("|"),hasAny:pe.some(function(we){return we.isAny}),hasConversion:!1,restParam:!0}),be.push(de)}else be=de.types.map(function(we){return{types:[we],name:we.name,hasAny:we.isAny,hasConversion:we.conversion,restParam:!1}});return Oe(be,function(we){return U(ee,ue+1,ve.concat([we]))})}else return[ve]}return U(z,0,[])}function Q(z,U){for(var ee=Math.max(z.length,U.length),ue=0;ue<ee;ue++){var ve=S(z,ue),de=S(U,ue),be=!1,pe=void 0,we=ht(de),_e;try{for(we.s();!(_e=we.n()).done;)if(pe=_e.value,ve.has(pe)){be=!0;break}}catch(mr){we.e(mr)}finally{we.f()}if(!be)return!1}var Le=z.length,Be=U.length,ar=x(z),Je=x(U);return ar?Je?Le===Be:Be>=Le:Je?Le>=Be:Le===Be}function K(z){return z.map(function(U){return oe(U)?V(U.referToSelf.callback):X(U)?$e(U.referTo.references,U.referTo.callback):U})}function L(z,U,ee){var ue=[],ve,de=ht(z),be;try{for(de.s();!(be=de.n()).done;){ve=be.value;var pe=ee[ve];if(typeof pe!="number")throw new TypeError('No definition for referenced signature "'+ve+'"');if(pe=U[pe],typeof pe!="function")return!1;ue.push(pe)}}catch(we){de.e(we)}finally{de.f()}return ue}function j(z,U,ee){for(var ue=K(z),ve=new Array(ue.length).fill(!1),de=!0;de;){de=!1;for(var be=!0,pe=0;pe<ue.length;++pe)if(!ve[pe]){var we=ue[pe];if(oe(we))ue[pe]=we.referToSelf.callback(ee),ue[pe].referToSelf=we.referToSelf,ve[pe]=!0,be=!1;else if(X(we)){var _e=L(we.referTo.references,ue,U);_e?(ue[pe]=we.referTo.callback.apply(this,_e),ue[pe].referTo=we.referTo,ve[pe]=!0,be=!1):de=!0}}if(be&&de)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return ue}function ae(z){var U=/\bthis(\(|\.signatures\b)/;Object.keys(z).forEach(function(ee){var ue=z[ee];if(U.test(ue.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 re(z,U){if(o.createCount++,Object.keys(U).length===0)throw new SyntaxError("No signatures provided");o.warnAgainstDeprecatedThis&&ae(U);var ee=[],ue=[],ve={},de=[],be,pe=function(){if(!Object.prototype.hasOwnProperty.call(U,be))return"continue";var Tr=w(be);if(!Tr)return"continue";ee.forEach(function(Nn){if(Q(Nn,Tr))throw new TypeError('Conflicting signatures "'+g(Nn)+'" and "'+g(Tr)+'".')}),ee.push(Tr);var Fo=ue.length;ue.push(U[be]);var el=Tr.map(N),Ra=void 0,_a=ht(k(el)),To;try{for(_a.s();!(To=_a.n()).done;){Ra=To.value;var Bo=g(Ra);de.push({params:Ra,name:Bo,fn:Fo}),Ra.every(function(Nn){return!Nn.hasConversion})&&(ve[Bo]=Fo)}}catch(Nn){_a.e(Nn)}finally{_a.f()}};for(be in U)var we=pe();de.sort(M);var _e=j(ue,ve,Gn),Le;for(Le in ve)Object.prototype.hasOwnProperty.call(ve,Le)&&(ve[Le]=_e[ve[Le]]);for(var Be=[],ar=new Map,Je=0,mr=de;Je<mr.length;Je++)Le=mr[Je],ar.has(Le.name)||(Le.fn=_e[Le.fn],Be.push(Le),ar.set(Le.name,Le));for(var C=Be[0]&&Be[0].params.length<=2&&!x(Be[0].params),Z=Be[1]&&Be[1].params.length<=2&&!x(Be[1].params),se=Be[2]&&Be[2].params.length<=2&&!x(Be[2].params),Ee=Be[3]&&Be[3].params.length<=2&&!x(Be[3].params),ze=Be[4]&&Be[4].params.length<=2&&!x(Be[4].params),ke=Be[5]&&Be[5].params.length<=2&&!x(Be[5].params),Fr=C&&Z&&se&&Ee&&ze&&ke,_r=0;_r<Be.length;++_r)Be[_r].test=E(Be[_r].params);for(var tn=C?b(Be[0].params[0]):st,Ln=Z?b(Be[1].params[0]):st,kn=se?b(Be[2].params[0]):st,Bu=Ee?b(Be[3].params[0]):st,$u=ze?b(Be[4].params[0]):st,Ou=ke?b(Be[5].params[0]):st,Iu=C?b(Be[0].params[1]):st,Ru=Z?b(Be[1].params[1]):st,_u=se?b(Be[2].params[1]):st,qu=Ee?b(Be[3].params[1]):st,zu=ze?b(Be[4].params[1]):st,Pu=ke?b(Be[5].params[1]):st,Vn=0;Vn<Be.length;++Vn)Be[Vn].implementation=H(Be[Vn].params,Be[Vn].fn);var Uu=C?Be[0].implementation:Wn,Lu=Z?Be[1].implementation:Wn,Oa=se?Be[2].implementation:Wn,Ia=Ee?Be[3].implementation:Wn,ku=ze?Be[4].implementation:Wn,Vu=ke?Be[5].implementation:Wn,Gu=C?Be[0].params.length:-1,Hu=Z?Be[1].params.length:-1,Zu=se?Be[2].params.length:-1,Ju=Ee?Be[3].params.length:-1,Xu=ze?Be[4].params.length:-1,Wu=ke?Be[5].params.length:-1,Yu=Fr?6:0,Qu=Be.length,Ku=Be.map(function(jr){return jr.test}),ju=Be.map(function(jr){return jr.implementation}),Mo=function(){for(var Tr=Yu;Tr<Qu;Tr++)if(Ku[Tr](arguments))return ju[Tr].apply(this,arguments);return o.onMismatch(z,arguments,Be)};function Gn(jr,Tr){return arguments.length===Gu&&tn(jr)&&Iu(Tr)?Uu.apply(this,arguments):arguments.length===Hu&&Ln(jr)&&Ru(Tr)?Lu.apply(this,arguments):arguments.length===Zu&&kn(jr)&&_u(Tr)?Oa.apply(this,arguments):arguments.length===Ju&&Bu(jr)&&qu(Tr)?Ia.apply(this,arguments):arguments.length===Xu&&$u(jr)&&zu(Tr)?ku.apply(this,arguments):arguments.length===Wu&&Ou(jr)&&Pu(Tr)?Vu.apply(this,arguments):Mo.apply(this,arguments)}try{Object.defineProperty(Gn,"name",{value:z})}catch{}return Gn.signatures=ve,Gn._typedFunctionData={signatures:Be,signatureMap:ar},Gn}function fe(z,U,ee){throw B(z,U,ee)}function he(z){return ie(z,0,z.length-1)}function ce(z){return z[z.length-1]}function ie(z,U,ee){return Array.prototype.slice.call(z,U,ee)}function Ae(z,U){for(var ee=0;ee<z.length;ee++)if(U(z[ee]))return z[ee]}function Oe(z,U){return Array.prototype.concat.apply([],z.map(U))}function Ce(){var z=he(arguments).map(function(ee){return g(w(ee))}),U=ce(arguments);if(typeof U!="function")throw new TypeError("Callback function expected as last argument");return $e(z,U)}function $e(z,U){return{referTo:{references:z,callback:U}}}function V(z){if(typeof z!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:z}}}function X(z){return z&&Xn(z.referTo)==="object"&&Array.isArray(z.referTo.references)&&typeof z.referTo.callback=="function"}function oe(z){return z&&Xn(z.referToSelf)==="object"&&typeof z.referToSelf.callback=="function"}function G(z,U){if(!z)return U;if(U&&U!==z){var ee=new Error("Function names do not match (expected: "+z+", actual: "+U+")");throw ee.data={actual:U,expected:z},ee}return z}function Y(z){var U;for(var ee in z)Object.prototype.hasOwnProperty.call(z,ee)&&(m(z[ee])||typeof z[ee].signature=="string")&&(U=G(U,z[ee].name));return U}function te(z,U){var ee;for(ee in U)if(Object.prototype.hasOwnProperty.call(U,ee)){if(ee in z&&U[ee]!==z[ee]){var ue=new Error('Signature "'+ee+'" is defined twice');throw ue.data={signature:ee,sourceFunction:U[ee],destFunction:z[ee]},ue}z[ee]=U[ee]}}var ye=o;o=function(U){for(var ee=typeof U=="string",ue=ee?1:0,ve=ee?U:"",de={},be=ue;be<arguments.length;++be){var pe=arguments[be],we={},_e=void 0;if(typeof pe=="function"?(_e=pe.name,typeof pe.signature=="string"?we[pe.signature]=pe:m(pe)&&(we=pe.signatures)):r(pe)&&(we=pe,ee||(_e=Y(pe))),Object.keys(we).length===0){var Le=new TypeError("Argument to 'typed' at index "+be+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw Le.data={index:be,argument:pe},Le}ee||(ve=G(ve,_e)),te(de,we)}return re(ve||"",de)},o.create=vl,o.createCount=ye.createCount,o.onMismatch=fe,o.throwMismatchError=fe,o.createError=B,o.clear=u,o.clearConversions=s,o.addTypes=l,o._findType=f,o.referTo=Ce,o.referToSelf=V,o.convert=p,o.findSignature=v,o.find=h,o.isTypedFunction=m,o.warnAgainstDeprecatedThis=!0,o.addType=function(z,U){var ee="any";U!==!1&&a.has("Object")&&(ee="Object"),o.addTypes([z],ee)};function me(z){if(!z||typeof z.from!="string"||typeof z.to!="string"||typeof z.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(z.to===z.from)throw new SyntaxError('Illegal to define conversion from "'+z.from+'" to itself.')}return o.addConversion=function(z){me(z);var U=f(z.to);if(U.conversionsTo.every(function(ee){return ee.from!==z.from}))U.conversionsTo.push({from:z.from,convert:z.convert,index:i++});else throw new Error('There is already a conversion from "'+z.from+'" to "'+U.name+'"')},o.addConversions=function(z){z.forEach(o.addConversion)},o.removeConversion=function(z){me(z);var U=f(z.to),ee=Ae(U.conversionsTo,function(ve){return ve.from===z.from});if(!ee)throw new Error("Attempt to remove nonexistent conversion from "+z.from+" to "+z.to);if(ee.convert!==z.convert)throw new Error("Conversion to remove does not match existing conversion");var ue=U.conversionsTo.indexOf(ee);U.conversionsTo.splice(ue,1)},o.resolve=function(z,U){if(!m(z))throw new TypeError(ml);for(var ee=z._typedFunctionData.signatures,ue=0;ue<ee.length;++ue)if(ee[ue].test(U))return ee[ue];return null},o}const pl=vl();function qe(r){return typeof r=="boolean"?!0:isFinite(r)?r===Math.round(r):!1}var an=Math.sign||function(r){return r>0?1:r<0?-1:0},j0=Math.log2||function(e){return Math.log(e)/Math.LN2},eg=Math.log10||function(e){return Math.log(e)/Math.LN10},rg=Math.log1p||function(r){return Math.log(r+1)},tg=Math.cbrt||function(e){if(e===0)return e;var t=e<0,a;return t&&(e=-e),isFinite(e)?(a=Math.exp(Math.log(e)/3),a=(e/(a*a)+2*a)/3):a=e,t?-a:a},ng=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function Vo(r,e,t){var a={2:"0b",8:"0o",16:"0x"},n=a[e],i="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!qe(t))throw new Error("size must be an integer");if(r>2**(t-1)-1||r<-(2**(t-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!qe(r))throw new Error("Value must be an integer");r<0&&(r=r+2**t),i="i".concat(t)}var o="";return r<0&&(r=-r,o="-"),"".concat(o).concat(n).concat(r.toString(e)).concat(i)}function Cn(r,e){if(typeof e=="function")return e(r);if(r===1/0)return"Infinity";if(r===-1/0)return"-Infinity";if(isNaN(r))return"NaN";var t="auto",a,n;if(e&&(e.notation&&(t=e.notation),tr(e)?a=e:tr(e.precision)&&(a=e.precision),e.wordSize&&(n=e.wordSize,typeof n!="number")))throw new Error('Option "wordSize" must be a number');switch(t){case"fixed":return hl(r,a);case"exponential":return dl(r,a);case"engineering":return ag(r,a);case"bin":return Vo(r,2,n);case"oct":return Vo(r,8,n);case"hex":return Vo(r,16,n);case"auto":return ig(r,a,e&&e).replace(/((\.\d*?)(0+))($|e)/,function(){var i=arguments[2],o=arguments[4];return i!=="."?i+o:o});default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function fi(r){var e=String(r).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!e)throw new SyntaxError("Invalid number "+r);var t=e[1],a=e[2],n=parseFloat(e[4]||"0"),i=a.indexOf(".");n+=i!==-1?i-1:a.length-1;var o=a.replace(".","").replace(/^0*/,function(f){return n-=f.length,""}).replace(/0*$/,"").split("").map(function(f){return parseInt(f)});return o.length===0&&(o.push(0),n++),{sign:t,coefficients:o,exponent:n}}function ag(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=fi(r),a=mi(t,e),n=a.exponent,i=a.coefficients,o=n%3===0?n:n<0?n-3-n%3:n-n%3;if(tr(e))for(;e>i.length||n-o+1>i.length;)i.push(0);else for(var f=Math.abs(n-o)-(i.length-1),l=0;l<f;l++)i.push(0);for(var u=Math.abs(n-o),s=1;u>0;)s++,u--;var c=i.slice(s).join(""),m=tr(e)&&c.length||c.match(/[1-9]/)?"."+c:"",v=i.slice(0,s).join("")+m+"e"+(n>=0?"+":"")+o.toString();return a.sign+v}function hl(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=fi(r),a=typeof e=="number"?mi(t,t.exponent+1+e):t,n=a.coefficients,i=a.exponent+1,o=i+(e||0);return n.length<o&&(n=n.concat(Yn(o-n.length))),i<0&&(n=Yn(-i+1).concat(n),i=1),i<n.length&&n.splice(i,0,i===0?"0.":"."),a.sign+n.join("")}function dl(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=fi(r),a=e?mi(t,e):t,n=a.coefficients,i=a.exponent;n.length<e&&(n=n.concat(Yn(e-n.length)));var o=n.shift();return a.sign+o+(n.length>0?"."+n.join(""):"")+"e"+(i>=0?"+":"")+i}function ig(r,e,t){if(isNaN(r)||!isFinite(r))return String(r);var a=t&&t.lowerExp!==void 0?t.lowerExp:-3,n=t&&t.upperExp!==void 0?t.upperExp:5,i=fi(r),o=e?mi(i,e):i;if(o.exponent<a||o.exponent>=n)return dl(r,e);var f=o.coefficients,l=o.exponent;f.length<e&&(f=f.concat(Yn(e-f.length))),f=f.concat(Yn(l-f.length+1+(f.length<e?e-f.length:0))),f=Yn(-l).concat(f);var u=l>0?l:0;return u<f.length-1&&f.splice(u+1,0,"."),o.sign+f.join("")}function mi(r,e){for(var t={sign:r.sign,coefficients:r.coefficients,exponent:r.exponent},a=t.coefficients;e<=0;)a.unshift(0),t.exponent++,e++;if(a.length>e){var n=a.splice(e,a.length-e);if(n[0]>=5){var i=e-1;for(a[i]++;a[i]===10;)a.pop(),i===0&&(a.unshift(0),t.exponent++,i++),i--,a[i]++}}return t}function Yn(r){for(var e=[],t=0;t<r;t++)e.push(0);return e}function og(r){return r.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var sg=Number.EPSILON||2220446049250313e-31;function nt(r,e,t){if(t==null)return r===e;if(r===e)return!0;if(isNaN(r)||isNaN(e))return!1;if(isFinite(r)&&isFinite(e)){var a=Math.abs(r-e);return a<sg?!0:a<=Math.max(Math.abs(r),Math.abs(e))*t}return!1}var ug=Math.acosh||function(r){return Math.log(Math.sqrt(r*r-1)+r)},lg=Math.asinh||function(r){return Math.log(Math.sqrt(r*r+1)+r)},cg=Math.atanh||function(r){return Math.log((1+r)/(1-r))/2},fg=Math.cosh||function(r){return(Math.exp(r)+Math.exp(-r))/2},mg=Math.sinh||function(r){return(Math.exp(r)-Math.exp(-r))/2},vg=Math.tanh||function(r){var e=Math.exp(2*r);return(e-1)/(e+1)};function pg(r,e){var t=r>0?!0:r<0?!1:1/r===1/0,a=e>0?!0:e<0?!1:1/e===1/0;return t^a?-r:r}function Go(r,e,t){var a=r.constructor,n=new a(2),i="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!qe(t))throw new Error("size must be an integer");if(r.greaterThan(n.pow(t-1).sub(1))||r.lessThan(n.pow(t-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!r.isInteger())throw new Error("Value must be an integer");r.lessThan(0)&&(r=r.add(n.pow(t))),i="i".concat(t)}switch(e){case 2:return"".concat(r.toBinary()).concat(i);case 8:return"".concat(r.toOctal()).concat(i);case 16:return"".concat(r.toHexadecimal()).concat(i);default:throw new Error("Base ".concat(e," not supported "))}}function hg(r,e){if(typeof e=="function")return e(r);if(!r.isFinite())return r.isNaN()?"NaN":r.gt(0)?"Infinity":"-Infinity";var t="auto",a,n;if(e!==void 0&&(e.notation&&(t=e.notation),typeof e=="number"?a=e:e.precision&&(a=e.precision),e.wordSize&&(n=e.wordSize,typeof n!="number")))throw new Error('Option "wordSize" must be a number');switch(t){case"fixed":return gg(r,a);case"exponential":return gl(r,a);case"engineering":return dg(r,a);case"bin":return Go(r,2,n);case"oct":return Go(r,8,n);case"hex":return Go(r,16,n);case"auto":{var i=e&&e.lowerExp!==void 0?e.lowerExp:-3,o=e&&e.upperExp!==void 0?e.upperExp:5;if(r.isZero())return"0";var f,l=r.toSignificantDigits(a),u=l.e;return u>=i&&u<o?f=l.toFixed():f=gl(r,a),f.replace(/((\.\d*?)(0+))($|e)/,function(){var s=arguments[2],c=arguments[4];return s!=="."?s+c:c})}default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function dg(r,e){var t=r.e,a=t%3===0?t:t<0?t-3-t%3:t-t%3,n=r.mul(Math.pow(10,-a)),i=n.toPrecision(e);return i.indexOf("e")!==-1&&(i=n.toString()),i+"e"+(t>=0?"+":"")+a.toString()}function gl(r,e){return e!==void 0?r.toExponential(e-1):r.toExponential()}function gg(r,e){return r.toFixed(e)}function yg(r,e){var t=r.length-e.length,a=r.length;return r.substring(t,a)===e}function Ye(r,e){var t=bg(r,e);return e&&typeof e=="object"&&"truncate"in e&&t.length>e.truncate?t.substring(0,e.truncate-3)+"...":t}function bg(r,e){if(typeof r=="number")return Cn(r,e);if(rr(r))return hg(r,e);if(xg(r))return!e||e.fraction!=="decimal"?r.s*r.n+"/"+r.d:r.toString();if(Array.isArray(r))return yl(r,e);if(Wr(r))return'"'+r+'"';if(typeof r=="function")return r.syntax?String(r.syntax):"function";if(r&&typeof r=="object"){if(typeof r.format=="function")return r.format(e);if(r&&r.toString(e)!=={}.toString())return r.toString(e);var t=Object.keys(r).map(a=>'"'+a+'": '+Ye(r[a],e));return"{"+t.join(", ")+"}"}return String(r)}function vi(r){for(var e=String(r),t="",a=0;a<e.length;){var n=e.charAt(a);n==="\\"?(t+=n,a++,n=e.charAt(a),(n===""||'"\\/bfnrtu'.indexOf(n)===-1)&&(t+="\\"),t+=n):n==='"'?t+='\\"':t+=n,a++}return'"'+t+'"'}function ut(r){var e=String(r);return e=e.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"),e}function yl(r,e){if(Array.isArray(r)){for(var t="[",a=r.length,n=0;n<a;n++)n!==0&&(t+=", "),t+=yl(r[n],e);return t+="]",t}else return Ye(r,e)}function xg(r){return r&&typeof r=="object"&&typeof r.s=="number"&&typeof r.n=="number"&&typeof r.d=="number"||!1}function Ho(r,e){if(!Wr(r))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+br(r)+", index: 0)");if(!Wr(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+br(e)+", index: 1)");return r===e?0:r>e?1:-1}function Ke(r,e,t){if(!(this instanceof Ke))throw new SyntaxError("Constructor must be called with the new operator");this.actual=r,this.expected=e,this.relation=t,this.message="Dimension mismatch ("+(Array.isArray(r)?"["+r.join(", ")+"]":r)+" "+(this.relation||"!=")+" "+(Array.isArray(e)?"["+e.join(", ")+"]":e)+")",this.stack=new Error().stack}Ke.prototype=new RangeError,Ke.prototype.constructor=RangeError,Ke.prototype.name="DimensionError",Ke.prototype.isDimensionError=!0;function dt(r,e,t){if(!(this instanceof dt))throw new SyntaxError("Constructor must be called with the new operator");this.index=r,arguments.length<3?(this.min=0,this.max=e):(this.min=e,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}dt.prototype=new RangeError,dt.prototype.constructor=RangeError,dt.prototype.name="IndexError",dt.prototype.isIndexError=!0;function er(r){for(var e=[];Array.isArray(r);)e.push(r.length),r=r[0];return e}function bl(r,e,t){var a,n=r.length;if(n!==e[t])throw new Ke(n,e[t]);if(t<e.length-1){var i=t+1;for(a=0;a<n;a++){var o=r[a];if(!Array.isArray(o))throw new Ke(e.length-1,e.length,"<");bl(r[a],e,i)}}else for(a=0;a<n;a++)if(Array.isArray(r[a]))throw new Ke(e.length+1,e.length,">")}function xl(r,e){var t=e.length===0;if(t){if(Array.isArray(r))throw new Ke(r.length,0)}else bl(r,e,0)}function vr(r,e){if(!tr(r)||!qe(r))throw new TypeError("Index must be an integer (value: "+r+")");if(r<0||typeof e=="number"&&r>=e)throw new dt(r,e)}function Qn(r,e,t){if(!Array.isArray(r)||!Array.isArray(e))throw new TypeError("Array expected");if(e.length===0)throw new Error("Resizing to scalar is not supported");e.forEach(function(n){if(!tr(n)||!qe(n)||n<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Ye(e)+")")});var a=t!==void 0?t:0;return Zo(r,e,0,a),r}function Zo(r,e,t,a){var n,i,o=r.length,f=e[t],l=Math.min(o,f);if(r.length=f,t<e.length-1){var u=t+1;for(n=0;n<l;n++)i=r[n],Array.isArray(i)||(i=[i],r[n]=i),Zo(i,e,u,a);for(n=l;n<f;n++)i=[],r[n]=i,Zo(i,e,u,a)}else{for(n=0;n<l;n++)for(;Array.isArray(r[n]);)r[n]=r[n][0];for(n=l;n<f;n++)r[n]=a}}function wl(r,e){var t=or(r),a=t.length;if(!Array.isArray(r)||!Array.isArray(e))throw new TypeError("Array expected");if(e.length===0)throw new Ke(0,a,"!=");e=Jo(e,a);var n=Nl(e);if(a!==n)throw new Ke(n,a,"!=");try{return wg(t,e)}catch(i){throw i instanceof Ke?new Ke(n,a,"!="):i}}function Jo(r,e){var t=Nl(r),a=r.slice(),n=-1,i=r.indexOf(n),o=r.indexOf(n,i+1)>=0;if(o)throw new Error("More than one wildcard in sizes");var f=i>=0,l=e%t===0;if(f)if(l)a[i]=-e/t;else throw new Error("Could not replace wildcard, since "+e+" is no multiple of "+-t);return a}function Nl(r){return r.reduce((e,t)=>e*t,1)}function wg(r,e){for(var t=r,a,n=e.length-1;n>0;n--){var i=e[n];a=[];for(var o=t.length/i,f=0;f<o;f++)a.push(t.slice(f*i,(f+1)*i));t=a}return t}function pi(r,e){for(var t=e||er(r);Array.isArray(r)&&r.length===1;)r=r[0],t.shift();for(var a=t.length;t[a-1]===1;)a--;return a<t.length&&(r=Dl(r,a,0),t.length=a),r}function Dl(r,e,t){var a,n;if(t<e){var i=t+1;for(a=0,n=r.length;a<n;a++)r[a]=Dl(r[a],e,i)}else for(;Array.isArray(r);)r=r[0];return r}function Al(r,e,t,a){var n=a||er(r);if(t)for(var i=0;i<t;i++)r=[r],n.unshift(1);for(r=El(r,e,0);n.length<e;)n.push(1);return r}function El(r,e,t){var a,n;if(Array.isArray(r)){var i=t+1;for(a=0,n=r.length;a<n;a++)r[a]=El(r[a],e,i)}else for(var o=t;o<e;o++)r=[r];return r}function or(r){if(!Array.isArray(r))return r;var e=[];return r.forEach(function t(a){Array.isArray(a)?a.forEach(t):e.push(a)}),e}function Ht(r,e){return Array.prototype.map.call(r,e)}function hi(r,e){Array.prototype.forEach.call(r,e)}function Sl(r,e){if(er(r).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(r,e)}function di(r,e){if(er(r).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(r,t=>e.test(t))}function Cl(r,e){return Array.prototype.join.call(r,e)}function Kn(r){if(!Array.isArray(r))throw new TypeError("Array input expected");if(r.length===0)return r;var e=[],t=0;e[0]={value:r[0],identifier:0};for(var a=1;a<r.length;a++)r[a]===r[a-1]?t++:t=0,e.push({value:r[a],identifier:t});return e}function gi(r){if(!Array.isArray(r))throw new TypeError("Array input expected");if(r.length===0)return r;for(var e=[],t=0;t<r.length;t++)e.push(r[t].value);return e}function La(r,e){for(var t,a=0,n=0;n<r.length;n++){var i=r[n],o=Array.isArray(i);if(n===0&&o&&(a=i.length),o&&i.length!==a)return;var f=o?La(i,e):e(i);if(t===void 0)t=f;else if(t!==f)return"mixed"}return t}function q(r,e,t,a){function n(i){var o=W0(i,e.map(Ag));return Ng(r,e,i),t(o)}return n.isFactory=!0,n.fn=r,n.dependencies=e.slice().sort(),a&&(n.meta=a),n}function Ng(r,e,t){var a=e.filter(i=>!Dg(i)).every(i=>t[i]!==void 0);if(!a){var n=e.filter(i=>t[i]===void 0);throw new Error('Cannot create function "'.concat(r,'", ')+"some dependencies are missing: ".concat(n.map(i=>'"'.concat(i,'"')).join(", "),"."))}}function Dg(r){return r&&r[0]==="?"}function Ag(r){return r&&r[0]==="?"?r.slice(1):r}function lt(r,e){if(Ml(r)&&Xo(r,e))return r[e];throw typeof r[e]=="function"&&Wo(r,e)?new Error('Cannot access method "'+e+'" as a property'):new Error('No access to property "'+e+'"')}function jn(r,e,t){if(Ml(r)&&Xo(r,e))return r[e]=t,t;throw new Error('No access to property "'+e+'"')}function Eg(r,e){return e in r}function Xo(r,e){return!r||typeof r!="object"?!1:Re(Cg,e)?!0:!(e in Object.prototype||e in Function.prototype)}function Sg(r,e){if(!Wo(r,e))throw new Error('No access to method "'+e+'"')}function Wo(r,e){return r==null||typeof r[e]!="function"||Re(r,e)&&Object.getPrototypeOf&&e in Object.getPrototypeOf(r)?!1:Re(Mg,e)?!0:!(e in Object.prototype||e in Function.prototype)}function Ml(r){return typeof r=="object"&&r&&r.constructor===Object}var Cg={length:!0,name:!0},Mg={toString:!0,valueOf:!0,toLocaleString:!0};class Yo{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return lt(this.wrappedObject,e)}set(e,t){return jn(this.wrappedObject,e,t),this}has(e){return Eg(this.wrappedObject,e)}}function ea(){return new Map}function ra(r){if(!r)return ea();if(Qo(r))return r;if(Lo(r))return new Yo(r);throw new Error("createMap can create maps from objects or Maps")}function Fg(r){if(r instanceof Yo)return r.wrappedObject;var e={};for(var t of r.keys()){var a=r.get(t);jn(e,t,a)}return e}function Qo(r){return r?r instanceof Map||r instanceof Yo||typeof r.set=="function"&&typeof r.get=="function"&&typeof r.keys=="function"&&typeof r.has=="function":!1}function Fl(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),a=1;a<e;a++)t[a-1]=arguments[a];for(var n of t)if(!!n){if(Qo(n))for(var i of n.keys())r.set(i,n.get(i));else if(Lo(n))for(var o of Object.keys(n))r.set(o,n[o])}return r}var Tl=function(){return Tl=pl.create,pl},Tg=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],Bg=q("typed",Tg,function(e){var{BigNumber:t,Complex:a,DenseMatrix:n,Fraction:i}=e,o=Tl();return o.clear(),o.addTypes([{name:"number",test:tr},{name:"Complex",test:kt},{name:"BigNumber",test:rr},{name:"Fraction",test:za},{name:"Unit",test:Vt},{name:"identifier",test:f=>Wr&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])*$/.test(f)},{name:"string",test:Wr},{name:"Chain",test:ul},{name:"Array",test:cr},{name:"Matrix",test:Ve},{name:"DenseMatrix",test:ui},{name:"SparseMatrix",test:En},{name:"Range",test:Uo},{name:"Index",test:li},{name:"boolean",test:R0},{name:"ResultSet",test:_0},{name:"Help",test:sl},{name:"function",test:q0},{name:"Date",test:z0},{name:"RegExp",test:P0},{name:"null",test:U0},{name:"undefined",test:L0},{name:"AccessorNode",test:Sn},{name:"ArrayNode",test:ot},{name:"AssignmentNode",test:k0},{name:"BlockNode",test:V0},{name:"ConditionalNode",test:G0},{name:"ConstantNode",test:ir},{name:"FunctionNode",test:nn},{name:"FunctionAssignmentNode",test:Pa},{name:"IndexNode",test:Jn},{name:"Node",test:fr},{name:"ObjectNode",test:ci},{name:"OperatorNode",test:Br},{name:"ParenthesisNode",test:Gt},{name:"RangeNode",test:H0},{name:"RelationalNode",test:Z0},{name:"SymbolNode",test:qr},{name:"Map",test:Qo},{name:"Object",test:Lo}]),o.addConversions([{from:"number",to:"BigNumber",convert:function(l){if(t||Ko(l),og(l)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+l+"). Use function bignumber(x) to convert to BigNumber.");return new t(l)}},{from:"number",to:"Complex",convert:function(l){return a||yi(l),new a(l,0)}},{from:"BigNumber",to:"Complex",convert:function(l){return a||yi(l),new a(l.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(l){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(l){return a||yi(l),new a(l.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(l){i||jo(l);var u=new i(l);if(u.valueOf()!==l)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+l+"). Use function fraction(x) to convert to Fraction.");return u}},{from:"string",to:"number",convert:function(l){var u=Number(l);if(isNaN(u))throw new Error('Cannot convert "'+l+'" to a number');return u}},{from:"string",to:"BigNumber",convert:function(l){t||Ko(l);try{return new t(l)}catch{throw new Error('Cannot convert "'+l+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(l){i||jo(l);try{return new i(l)}catch{throw new Error('Cannot convert "'+l+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(l){a||yi(l);try{return new a(l)}catch{throw new Error('Cannot convert "'+l+'" to Complex')}}},{from:"boolean",to:"number",convert:function(l){return+l}},{from:"boolean",to:"BigNumber",convert:function(l){return t||Ko(l),new t(+l)}},{from:"boolean",to:"Fraction",convert:function(l){return i||jo(l),new i(+l)}},{from:"boolean",to:"string",convert:function(l){return String(l)}},{from:"Array",to:"Matrix",convert:function(l){return n||$g(),new n(l)}},{from:"Matrix",to:"Array",convert:function(l){return l.valueOf()}}]),o.onMismatch=(f,l,u)=>{var s=o.createError(f,l,u);if(["wrongType","mismatch"].includes(s.data.category)&&l.length===1&&Ft(l[0])&&u.some(m=>!m.params.includes(","))){var c=new TypeError("Function '".concat(f,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(f,")'."));throw c.data=s.data,c}throw s},o.onMismatch=(f,l,u)=>{var s=o.createError(f,l,u);if(["wrongType","mismatch"].includes(s.data.category)&&l.length===1&&Ft(l[0])&&u.some(m=>!m.params.includes(","))){var c=new TypeError("Function '".concat(f,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(f,")'."));throw c.data=s.data,c}throw s},o});function Ko(r){throw new Error("Cannot convert value ".concat(r," into a BigNumber: no class 'BigNumber' provided"))}function yi(r){throw new Error("Cannot convert value ".concat(r," into a Complex number: no class 'Complex' provided"))}function $g(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function jo(r){throw new Error("Cannot convert value ".concat(r," into a Fraction, no class 'Fraction' provided."))}var Og="ResultSet",Ig=[],Rg=q(Og,Ig,()=>{function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this.entries=e||[]}return r.prototype.type="ResultSet",r.prototype.isResultSet=!0,r.prototype.valueOf=function(){return this.entries},r.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},r.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},r.fromJSON=function(e){return new r(e.entries)},r},{isClass:!0});/*!
|
|
10
10
|
* decimal.js v10.4.3
|
|
11
11
|
* An arbitrary-precision Decimal type for JavaScript.
|
|
12
12
|
* https://github.com/MikeMcl/decimal.js
|
|
13
13
|
* Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
14
14
|
* MIT Licence
|
|
15
|
-
*/var ra=9e15,nn=1e9,es="0123456789abcdef",bi="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",xi="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",rs={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ra,maxE:ra,crypto:!1},Fl,Ht,Xe=!0,wi="[DecimalError] ",an=wi+"Invalid argument: ",Tl=wi+"Precision limit exceeded",Bl=wi+"crypto unavailable",$l="[object Decimal]",Gr=Math.floor,Or=Math.pow,Mg=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Fg=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Tg=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Ol=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,dt=1e7,He=7,Bg=9007199254740991,$g=bi.length-1,ts=xi.length-1,xe={toStringTag:$l};xe.absoluteValue=xe.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),Pe(r)},xe.ceil=function(){return Pe(new this.constructor(this),this.e+1,2)},xe.clampedTo=xe.clamp=function(r,e){var t,a=this,n=a.constructor;if(r=new n(r),e=new n(e),!r.s||!e.s)return new n(NaN);if(r.gt(e))throw Error(an+e);return t=a.cmp(r),t<0?r:a.cmp(e)>0?e:new n(a)},xe.comparedTo=xe.cmp=function(r){var e,t,a,n,i=this,o=i.d,f=(r=new i.constructor(r)).d,l=i.s,u=r.s;if(!o||!f)return!l||!u?NaN:l!==u?l:o===f?0:!o^l<0?1:-1;if(!o[0]||!f[0])return o[0]?l:f[0]?-u:0;if(l!==u)return l;if(i.e!==r.e)return i.e>r.e^l<0?1:-1;for(a=o.length,n=f.length,e=0,t=a<n?a:n;e<t;++e)if(o[e]!==f[e])return o[e]>f[e]^l<0?1:-1;return a===n?0:a>n^l<0?1:-1},xe.cosine=xe.cos=function(){var r,e,t=this,a=t.constructor;return t.d?t.d[0]?(r=a.precision,e=a.rounding,a.precision=r+Math.max(t.e,t.sd())+He,a.rounding=1,t=Og(a,Pl(a,t)),a.precision=r,a.rounding=e,Pe(Ht==2||Ht==3?t.neg():t,r,e,!0)):new a(1):new a(NaN)},xe.cubeRoot=xe.cbrt=function(){var r,e,t,a,n,i,o,f,l,u,s=this,c=s.constructor;if(!s.isFinite()||s.isZero())return new c(s);for(Xe=!1,i=s.s*Or(s.s*s,1/3),!i||Math.abs(i)==1/0?(t=Pr(s.d),r=s.e,(i=(r-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=Or(t,1/3),r=Gr((r+1)/3)-(r%3==(r<0?-1:2)),i==1/0?t="5e"+r:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),a=new c(t),a.s=s.s):a=new c(i.toString()),o=(r=c.precision)+3;;)if(f=a,l=f.times(f).times(f),u=l.plus(s),a=gr(u.plus(s).times(f),u.plus(l),o+2,1),Pr(f.d).slice(0,o)===(t=Pr(a.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!n&&t=="4999"){if(!n&&(Pe(f,r+1,0),f.times(f).times(f).eq(s))){a=f;break}o+=4,n=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Pe(a,r+1,1),e=!a.times(a).times(a).eq(s));break}return Xe=!0,Pe(a,r,c.rounding,e)},xe.decimalPlaces=xe.dp=function(){var r,e=this.d,t=NaN;if(e){if(r=e.length-1,t=(r-Gr(this.e/He))*He,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t},xe.dividedBy=xe.div=function(r){return gr(this,new this.constructor(r))},xe.dividedToIntegerBy=xe.divToInt=function(r){var e=this,t=e.constructor;return Pe(gr(e,new t(r),0,1,1),t.precision,t.rounding)},xe.equals=xe.eq=function(r){return this.cmp(r)===0},xe.floor=function(){return Pe(new this.constructor(this),this.e+1,3)},xe.greaterThan=xe.gt=function(r){return this.cmp(r)>0},xe.greaterThanOrEqualTo=xe.gte=function(r){var e=this.cmp(r);return e==1||e===0},xe.hyperbolicCosine=xe.cosh=function(){var r,e,t,a,n,i=this,o=i.constructor,f=new o(1);if(!i.isFinite())return new o(i.s?1/0:NaN);if(i.isZero())return f;t=o.precision,a=o.rounding,o.precision=t+Math.max(i.e,i.sd())+4,o.rounding=1,n=i.d.length,n<32?(r=Math.ceil(n/3),e=(1/Ei(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),i=ta(o,1,i.times(e),new o(1),!0);for(var l,u=r,s=new o(8);u--;)l=i.times(i),i=f.minus(l.times(s.minus(l.times(s))));return Pe(i,o.precision=t,o.rounding=a,!0)},xe.hyperbolicSine=xe.sinh=function(){var r,e,t,a,n=this,i=n.constructor;if(!n.isFinite()||n.isZero())return new i(n);if(e=i.precision,t=i.rounding,i.precision=e+Math.max(n.e,n.sd())+4,i.rounding=1,a=n.d.length,a<3)n=ta(i,2,n,n,!0);else{r=1.4*Math.sqrt(a),r=r>16?16:r|0,n=n.times(1/Ei(5,r)),n=ta(i,2,n,n,!0);for(var o,f=new i(5),l=new i(16),u=new i(20);r--;)o=n.times(n),n=n.times(f.plus(o.times(l.times(o).plus(u))))}return i.precision=e,i.rounding=t,Pe(n,e,t,!0)},xe.hyperbolicTangent=xe.tanh=function(){var r,e,t=this,a=t.constructor;return t.isFinite()?t.isZero()?new a(t):(r=a.precision,e=a.rounding,a.precision=r+7,a.rounding=1,gr(t.sinh(),t.cosh(),a.precision=r,a.rounding=e)):new a(t.s)},xe.inverseCosine=xe.acos=function(){var r,e=this,t=e.constructor,a=e.abs().cmp(1),n=t.precision,i=t.rounding;return a!==-1?a===0?e.isNeg()?gt(t,n,i):new t(0):new t(NaN):e.isZero()?gt(t,n+4,i).times(.5):(t.precision=n+6,t.rounding=1,e=e.asin(),r=gt(t,n+4,i).times(.5),t.precision=n,t.rounding=i,r.minus(e))},xe.inverseHyperbolicCosine=xe.acosh=function(){var r,e,t=this,a=t.constructor;return t.lte(1)?new a(t.eq(1)?0:NaN):t.isFinite()?(r=a.precision,e=a.rounding,a.precision=r+Math.max(Math.abs(t.e),t.sd())+4,a.rounding=1,Xe=!1,t=t.times(t).minus(1).sqrt().plus(t),Xe=!0,a.precision=r,a.rounding=e,t.ln()):new a(t)},xe.inverseHyperbolicSine=xe.asinh=function(){var r,e,t=this,a=t.constructor;return!t.isFinite()||t.isZero()?new a(t):(r=a.precision,e=a.rounding,a.precision=r+2*Math.max(Math.abs(t.e),t.sd())+6,a.rounding=1,Xe=!1,t=t.times(t).plus(1).sqrt().plus(t),Xe=!0,a.precision=r,a.rounding=e,t.ln())},xe.inverseHyperbolicTangent=xe.atanh=function(){var r,e,t,a,n=this,i=n.constructor;return n.isFinite()?n.e>=0?new i(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(r=i.precision,e=i.rounding,a=n.sd(),Math.max(a,r)<2*-n.e-1?Pe(new i(n),r,e,!0):(i.precision=t=a-n.e,n=gr(n.plus(1),new i(1).minus(n),t+r,1),i.precision=r+4,i.rounding=1,n=n.ln(),i.precision=r,i.rounding=e,n.times(.5))):new i(NaN)},xe.inverseSine=xe.asin=function(){var r,e,t,a,n=this,i=n.constructor;return n.isZero()?new i(n):(e=n.abs().cmp(1),t=i.precision,a=i.rounding,e!==-1?e===0?(r=gt(i,t+4,a).times(.5),r.s=n.s,r):new i(NaN):(i.precision=t+6,i.rounding=1,n=n.div(new i(1).minus(n.times(n)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=a,n.times(2)))},xe.inverseTangent=xe.atan=function(){var r,e,t,a,n,i,o,f,l,u=this,s=u.constructor,c=s.precision,m=s.rounding;if(u.isFinite()){if(u.isZero())return new s(u);if(u.abs().eq(1)&&c+4<=ts)return o=gt(s,c+4,m).times(.25),o.s=u.s,o}else{if(!u.s)return new s(NaN);if(c+4<=ts)return o=gt(s,c+4,m).times(.5),o.s=u.s,o}for(s.precision=f=c+10,s.rounding=1,t=Math.min(28,f/He+2|0),r=t;r;--r)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(Xe=!1,e=Math.ceil(f/He),a=1,l=u.times(u),o=new s(u),n=u;r!==-1;)if(n=n.times(l),i=o.minus(n.div(a+=2)),n=n.times(l),o=i.plus(n.div(a+=2)),o.d[e]!==void 0)for(r=e;o.d[r]===i.d[r]&&r--;);return t&&(o=o.times(2<<t-1)),Xe=!0,Pe(o,s.precision=c,s.rounding=m,!0)},xe.isFinite=function(){return!!this.d},xe.isInteger=xe.isInt=function(){return!!this.d&&Gr(this.e/He)>this.d.length-2},xe.isNaN=function(){return!this.s},xe.isNegative=xe.isNeg=function(){return this.s<0},xe.isPositive=xe.isPos=function(){return this.s>0},xe.isZero=function(){return!!this.d&&this.d[0]===0},xe.lessThan=xe.lt=function(r){return this.cmp(r)<0},xe.lessThanOrEqualTo=xe.lte=function(r){return this.cmp(r)<1},xe.logarithm=xe.log=function(r){var e,t,a,n,i,o,f,l,u=this,s=u.constructor,c=s.precision,m=s.rounding,v=5;if(r==null)r=new s(10),e=!0;else{if(r=new s(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new s(NaN);e=r.eq(10)}if(t=u.d,u.s<0||!t||!t[0]||u.eq(1))return new s(t&&!t[0]?-1/0:u.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)i=!0;else{for(n=t[0];n%10===0;)n/=10;i=n!==1}if(Xe=!1,f=c+v,o=sn(u,f),a=e?Ai(s,f+10):sn(r,f),l=gr(o,a,f,1),La(l.d,n=c,m))do if(f+=10,o=sn(u,f),a=e?Ai(s,f+10):sn(r,f),l=gr(o,a,f,1),!i){+Pr(l.d).slice(n+1,n+15)+1==1e14&&(l=Pe(l,c+1,0));break}while(La(l.d,n+=10,m));return Xe=!0,Pe(l,c,m)},xe.minus=xe.sub=function(r){var e,t,a,n,i,o,f,l,u,s,c,m,v=this,h=v.constructor;if(r=new h(r),!v.d||!r.d)return!v.s||!r.s?r=new h(NaN):v.d?r.s=-r.s:r=new h(r.d||v.s!==r.s?v:NaN),r;if(v.s!=r.s)return r.s=-r.s,v.plus(r);if(u=v.d,m=r.d,f=h.precision,l=h.rounding,!u[0]||!m[0]){if(m[0])r.s=-r.s;else if(u[0])r=new h(v);else return new h(l===3?-0:0);return Xe?Pe(r,f,l):r}if(t=Gr(r.e/He),s=Gr(v.e/He),u=u.slice(),i=s-t,i){for(c=i<0,c?(e=u,i=-i,o=m.length):(e=m,t=s,o=u.length),a=Math.max(Math.ceil(f/He),o)+2,i>a&&(i=a,e.length=1),e.reverse(),a=i;a--;)e.push(0);e.reverse()}else{for(a=u.length,o=m.length,c=a<o,c&&(o=a),a=0;a<o;a++)if(u[a]!=m[a]){c=u[a]<m[a];break}i=0}for(c&&(e=u,u=m,m=e,r.s=-r.s),o=u.length,a=m.length-o;a>0;--a)u[o++]=0;for(a=m.length;a>i;){if(u[--a]<m[a]){for(n=a;n&&u[--n]===0;)u[n]=dt-1;--u[n],u[a]+=dt}u[a]-=m[a]}for(;u[--o]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(r.d=u,r.e=Di(u,t),Xe?Pe(r,f,l):r):new h(l===3?-0:0)},xe.modulo=xe.mod=function(r){var e,t=this,a=t.constructor;return r=new a(r),!t.d||!r.s||r.d&&!r.d[0]?new a(NaN):!r.d||t.d&&!t.d[0]?Pe(new a(t),a.precision,a.rounding):(Xe=!1,a.modulo==9?(e=gr(t,r.abs(),0,3,1),e.s*=r.s):e=gr(t,r,0,a.modulo,1),e=e.times(r),Xe=!0,t.minus(e))},xe.naturalExponential=xe.exp=function(){return ns(this)},xe.naturalLogarithm=xe.ln=function(){return sn(this)},xe.negated=xe.neg=function(){var r=new this.constructor(this);return r.s=-r.s,Pe(r)},xe.plus=xe.add=function(r){var e,t,a,n,i,o,f,l,u,s,c=this,m=c.constructor;if(r=new m(r),!c.d||!r.d)return!c.s||!r.s?r=new m(NaN):c.d||(r=new m(r.d||c.s===r.s?c:NaN)),r;if(c.s!=r.s)return r.s=-r.s,c.minus(r);if(u=c.d,s=r.d,f=m.precision,l=m.rounding,!u[0]||!s[0])return s[0]||(r=new m(c)),Xe?Pe(r,f,l):r;if(i=Gr(c.e/He),a=Gr(r.e/He),u=u.slice(),n=i-a,n){for(n<0?(t=u,n=-n,o=s.length):(t=s,a=i,o=u.length),i=Math.ceil(f/He),o=i>o?i+1:o+1,n>o&&(n=o,t.length=1),t.reverse();n--;)t.push(0);t.reverse()}for(o=u.length,n=s.length,o-n<0&&(n=o,t=s,s=u,u=t),e=0;n;)e=(u[--n]=u[n]+s[n]+e)/dt|0,u[n]%=dt;for(e&&(u.unshift(e),++a),o=u.length;u[--o]==0;)u.pop();return r.d=u,r.e=Di(u,a),Xe?Pe(r,f,l):r},xe.precision=xe.sd=function(r){var e,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(an+r);return t.d?(e=Il(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e},xe.round=function(){var r=this,e=r.constructor;return Pe(new e(r),r.e+1,e.rounding)},xe.sine=xe.sin=function(){var r,e,t=this,a=t.constructor;return t.isFinite()?t.isZero()?new a(t):(r=a.precision,e=a.rounding,a.precision=r+Math.max(t.e,t.sd())+He,a.rounding=1,t=Rg(a,Pl(a,t)),a.precision=r,a.rounding=e,Pe(Ht>2?t.neg():t,r,e,!0)):new a(NaN)},xe.squareRoot=xe.sqrt=function(){var r,e,t,a,n,i,o=this,f=o.d,l=o.e,u=o.s,s=o.constructor;if(u!==1||!f||!f[0])return new s(!u||u<0&&(!f||f[0])?NaN:f?o:1/0);for(Xe=!1,u=Math.sqrt(+o),u==0||u==1/0?(e=Pr(f),(e.length+l)%2==0&&(e+="0"),u=Math.sqrt(e),l=Gr((l+1)/2)-(l<0||l%2),u==1/0?e="5e"+l:(e=u.toExponential(),e=e.slice(0,e.indexOf("e")+1)+l),a=new s(e)):a=new s(u.toString()),t=(l=s.precision)+3;;)if(i=a,a=i.plus(gr(o,i,t+2,1)).times(.5),Pr(i.d).slice(0,t)===(e=Pr(a.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!n&&e=="4999"){if(!n&&(Pe(i,l+1,0),i.times(i).eq(o))){a=i;break}t+=4,n=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(Pe(a,l+1,1),r=!a.times(a).eq(o));break}return Xe=!0,Pe(a,l,s.rounding,r)},xe.tangent=xe.tan=function(){var r,e,t=this,a=t.constructor;return t.isFinite()?t.isZero()?new a(t):(r=a.precision,e=a.rounding,a.precision=r+10,a.rounding=1,t=t.sin(),t.s=1,t=gr(t,new a(1).minus(t.times(t)).sqrt(),r+10,0),a.precision=r,a.rounding=e,Pe(Ht==2||Ht==4?t.neg():t,r,e,!0)):new a(NaN)},xe.times=xe.mul=function(r){var e,t,a,n,i,o,f,l,u,s=this,c=s.constructor,m=s.d,v=(r=new c(r)).d;if(r.s*=s.s,!m||!m[0]||!v||!v[0])return new c(!r.s||m&&!m[0]&&!v||v&&!v[0]&&!m?NaN:!m||!v?r.s/0:r.s*0);for(t=Gr(s.e/He)+Gr(r.e/He),l=m.length,u=v.length,l<u&&(i=m,m=v,v=i,o=l,l=u,u=o),i=[],o=l+u,a=o;a--;)i.push(0);for(a=u;--a>=0;){for(e=0,n=l+a;n>a;)f=i[n]+v[a]*m[n-a-1]+e,i[n--]=f%dt|0,e=f/dt|0;i[n]=(i[n]+e)%dt|0}for(;!i[--o];)i.pop();return e?++t:i.shift(),r.d=i,r.e=Di(i,t),Xe?Pe(r,c.precision,c.rounding):r},xe.toBinary=function(r,e){return is(this,2,r,e)},xe.toDecimalPlaces=xe.toDP=function(r,e){var t=this,a=t.constructor;return t=new a(t),r===void 0?t:(et(r,0,nn),e===void 0?e=a.rounding:et(e,0,8),Pe(t,r+t.e+1,e))},xe.toExponential=function(r,e){var t,a=this,n=a.constructor;return r===void 0?t=Ft(a,!0):(et(r,0,nn),e===void 0?e=n.rounding:et(e,0,8),a=Pe(new n(a),r+1,e),t=Ft(a,!0,r+1)),a.isNeg()&&!a.isZero()?"-"+t:t},xe.toFixed=function(r,e){var t,a,n=this,i=n.constructor;return r===void 0?t=Ft(n):(et(r,0,nn),e===void 0?e=i.rounding:et(e,0,8),a=Pe(new i(n),r+n.e+1,e),t=Ft(a,!1,r+a.e+1)),n.isNeg()&&!n.isZero()?"-"+t:t},xe.toFraction=function(r){var e,t,a,n,i,o,f,l,u,s,c,m,v=this,h=v.d,p=v.constructor;if(!h)return new p(v);if(u=t=new p(1),a=l=new p(0),e=new p(a),i=e.e=Il(h)-v.e-1,o=i%He,e.d[0]=Or(10,o<0?He+o:o),r==null)r=i>0?e:u;else{if(f=new p(r),!f.isInt()||f.lt(u))throw Error(an+f);r=f.gt(e)?i>0?e:u:f}for(Xe=!1,f=new p(Pr(h)),s=p.precision,p.precision=i=h.length*He*2;c=gr(f,e,0,1,1),n=t.plus(c.times(a)),n.cmp(r)!=1;)t=a,a=n,n=u,u=l.plus(c.times(n)),l=n,n=e,e=f.minus(c.times(n)),f=n;return n=gr(r.minus(t),a,0,1,1),l=l.plus(n.times(u)),t=t.plus(n.times(a)),l.s=u.s=v.s,m=gr(u,a,i,1).minus(v).abs().cmp(gr(l,t,i,1).minus(v).abs())<1?[u,a]:[l,t],p.precision=s,Xe=!0,m},xe.toHexadecimal=xe.toHex=function(r,e){return is(this,16,r,e)},xe.toNearest=function(r,e){var t=this,a=t.constructor;if(t=new a(t),r==null){if(!t.d)return t;r=new a(1),e=a.rounding}else{if(r=new a(r),e===void 0?e=a.rounding:et(e,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(Xe=!1,t=gr(t,r,0,e,1).times(r),Xe=!0,Pe(t)):(r.s=t.s,t=r),t},xe.toNumber=function(){return+this},xe.toOctal=function(r,e){return is(this,8,r,e)},xe.toPower=xe.pow=function(r){var e,t,a,n,i,o,f=this,l=f.constructor,u=+(r=new l(r));if(!f.d||!r.d||!f.d[0]||!r.d[0])return new l(Or(+f,u));if(f=new l(f),f.eq(1))return f;if(a=l.precision,i=l.rounding,r.eq(1))return Pe(f,a,i);if(e=Gr(r.e/He),e>=r.d.length-1&&(t=u<0?-u:u)<=Bg)return n=Rl(l,f,t,a),r.s<0?new l(1).div(n):Pe(n,a,i);if(o=f.s,o<0){if(e<r.d.length-1)return new l(NaN);if((r.d[e]&1)==0&&(o=1),f.e==0&&f.d[0]==1&&f.d.length==1)return f.s=o,f}return t=Or(+f,u),e=t==0||!isFinite(t)?Gr(u*(Math.log("0."+Pr(f.d))/Math.LN10+f.e+1)):new l(t+"").e,e>l.maxE+1||e<l.minE-1?new l(e>0?o/0:0):(Xe=!1,l.rounding=f.s=1,t=Math.min(12,(e+"").length),n=ns(r.times(sn(f,a+t)),a),n.d&&(n=Pe(n,a+5,1),La(n.d,a,i)&&(e=a+10,n=Pe(ns(r.times(sn(f,e+t)),e),e+5,1),+Pr(n.d).slice(a+1,a+15)+1==1e14&&(n=Pe(n,a+1,0)))),n.s=o,Xe=!0,l.rounding=i,Pe(n,a,i))},xe.toPrecision=function(r,e){var t,a=this,n=a.constructor;return r===void 0?t=Ft(a,a.e<=n.toExpNeg||a.e>=n.toExpPos):(et(r,1,nn),e===void 0?e=n.rounding:et(e,0,8),a=Pe(new n(a),r,e),t=Ft(a,r<=a.e||a.e<=n.toExpNeg,r)),a.isNeg()&&!a.isZero()?"-"+t:t},xe.toSignificantDigits=xe.toSD=function(r,e){var t=this,a=t.constructor;return r===void 0?(r=a.precision,e=a.rounding):(et(r,1,nn),e===void 0?e=a.rounding:et(e,0,8)),Pe(new a(t),r,e)},xe.toString=function(){var r=this,e=r.constructor,t=Ft(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t},xe.truncated=xe.trunc=function(){return Pe(new this.constructor(this),this.e+1,1)},xe.valueOf=xe.toJSON=function(){var r=this,e=r.constructor,t=Ft(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function Pr(r){var e,t,a,n=r.length-1,i="",o=r[0];if(n>0){for(i+=o,e=1;e<n;e++)a=r[e]+"",t=He-a.length,t&&(i+=on(t)),i+=a;o=r[e],a=o+"",t=He-a.length,t&&(i+=on(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return i+o}function et(r,e,t){if(r!==~~r||r<e||r>t)throw Error(an+r)}function La(r,e,t,a){var n,i,o,f;for(i=r[0];i>=10;i/=10)--e;return--e<0?(e+=He,n=0):(n=Math.ceil((e+1)/He),e%=He),i=Or(10,He-e),f=r[n]%i|0,a==null?e<3?(e==0?f=f/100|0:e==1&&(f=f/10|0),o=t<4&&f==99999||t>3&&f==49999||f==5e4||f==0):o=(t<4&&f+1==i||t>3&&f+1==i/2)&&(r[n+1]/i/100|0)==Or(10,e-2)-1||(f==i/2||f==0)&&(r[n+1]/i/100|0)==0:e<4?(e==0?f=f/1e3|0:e==1?f=f/100|0:e==2&&(f=f/10|0),o=(a||t<4)&&f==9999||!a&&t>3&&f==4999):o=((a||t<4)&&f+1==i||!a&&t>3&&f+1==i/2)&&(r[n+1]/i/1e3|0)==Or(10,e-3)-1,o}function Ni(r,e,t){for(var a,n=[0],i,o=0,f=r.length;o<f;){for(i=n.length;i--;)n[i]*=e;for(n[0]+=es.indexOf(r.charAt(o++)),a=0;a<n.length;a++)n[a]>t-1&&(n[a+1]===void 0&&(n[a+1]=0),n[a+1]+=n[a]/t|0,n[a]%=t)}return n.reverse()}function Og(r,e){var t,a,n;if(e.isZero())return e;a=e.d.length,a<32?(t=Math.ceil(a/3),n=(1/Ei(4,t)).toString()):(t=16,n="2.3283064365386962890625e-10"),r.precision+=t,e=ta(r,1,e.times(n),new r(1));for(var i=t;i--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return r.precision-=t,e}var gr=function(){function r(a,n,i){var o,f=0,l=a.length;for(a=a.slice();l--;)o=a[l]*n+f,a[l]=o%i|0,f=o/i|0;return f&&a.unshift(f),a}function e(a,n,i,o){var f,l;if(i!=o)l=i>o?1:-1;else for(f=l=0;f<i;f++)if(a[f]!=n[f]){l=a[f]>n[f]?1:-1;break}return l}function t(a,n,i,o){for(var f=0;i--;)a[i]-=f,f=a[i]<n[i]?1:0,a[i]=f*o+a[i]-n[i];for(;!a[0]&&a.length>1;)a.shift()}return function(a,n,i,o,f,l){var u,s,c,m,v,h,p,g,y,N,d,w,x,b,E,A,S,D,T,B,I=a.constructor,P=a.s==n.s?1:-1,R=a.d,M=n.d;if(!R||!R[0]||!M||!M[0])return new I(!a.s||!n.s||(R?M&&R[0]==M[0]:!M)?NaN:R&&R[0]==0||!M?P*0:P/0);for(l?(v=1,s=a.e-n.e):(l=dt,v=He,s=Gr(a.e/v)-Gr(n.e/v)),T=M.length,S=R.length,y=new I(P),N=y.d=[],c=0;M[c]==(R[c]||0);c++);if(M[c]>(R[c]||0)&&s--,i==null?(b=i=I.precision,o=I.rounding):f?b=i+(a.e-n.e)+1:b=i,b<0)N.push(1),h=!0;else{if(b=b/v+2|0,c=0,T==1){for(m=0,M=M[0],b++;(c<S||m)&&b--;c++)E=m*l+(R[c]||0),N[c]=E/M|0,m=E%M|0;h=m||c<S}else{for(m=l/(M[0]+1)|0,m>1&&(M=r(M,m,l),R=r(R,m,l),T=M.length,S=R.length),A=T,d=R.slice(0,T),w=d.length;w<T;)d[w++]=0;B=M.slice(),B.unshift(0),D=M[0],M[1]>=l/2&&++D;do m=0,u=e(M,d,T,w),u<0?(x=d[0],T!=w&&(x=x*l+(d[1]||0)),m=x/D|0,m>1?(m>=l&&(m=l-1),p=r(M,m,l),g=p.length,w=d.length,u=e(p,d,g,w),u==1&&(m--,t(p,T<g?B:M,g,l))):(m==0&&(u=m=1),p=M.slice()),g=p.length,g<w&&p.unshift(0),t(d,p,w,l),u==-1&&(w=d.length,u=e(M,d,T,w),u<1&&(m++,t(d,T<w?B:M,w,l))),w=d.length):u===0&&(m++,d=[0]),N[c++]=m,u&&d[0]?d[w++]=R[A]||0:(d=[R[A]],w=1);while((A++<S||d[0]!==void 0)&&b--);h=d[0]!==void 0}N[0]||N.shift()}if(v==1)y.e=s,Fl=h;else{for(c=1,m=N[0];m>=10;m/=10)c++;y.e=c+s*v-1,Pe(y,f?i+y.e+1:i,o,h)}return y}}();function Pe(r,e,t,a){var n,i,o,f,l,u,s,c,m,v=r.constructor;e:if(e!=null){if(c=r.d,!c)return r;for(n=1,f=c[0];f>=10;f/=10)n++;if(i=e-n,i<0)i+=He,o=e,s=c[m=0],l=s/Or(10,n-o-1)%10|0;else if(m=Math.ceil((i+1)/He),f=c.length,m>=f)if(a){for(;f++<=m;)c.push(0);s=l=0,n=1,i%=He,o=i-He+1}else break e;else{for(s=f=c[m],n=1;f>=10;f/=10)n++;i%=He,o=i-He+n,l=o<0?0:s/Or(10,n-o-1)%10|0}if(a=a||e<0||c[m+1]!==void 0||(o<0?s:s%Or(10,n-o-1)),u=t<4?(l||a)&&(t==0||t==(r.s<0?3:2)):l>5||l==5&&(t==4||a||t==6&&(i>0?o>0?s/Or(10,n-o):0:c[m-1])%10&1||t==(r.s<0?8:7)),e<1||!c[0])return c.length=0,u?(e-=r.e+1,c[0]=Or(10,(He-e%He)%He),r.e=-e||0):c[0]=r.e=0,r;if(i==0?(c.length=m,f=1,m--):(c.length=m+1,f=Or(10,He-i),c[m]=o>0?(s/Or(10,n-o)%Or(10,o)|0)*f:0),u)for(;;)if(m==0){for(i=1,o=c[0];o>=10;o/=10)i++;for(o=c[0]+=f,f=1;o>=10;o/=10)f++;i!=f&&(r.e++,c[0]==dt&&(c[0]=1));break}else{if(c[m]+=f,c[m]!=dt)break;c[m--]=0,f=1}for(i=c.length;c[--i]===0;)c.pop()}return Xe&&(r.e>v.maxE?(r.d=null,r.e=NaN):r.e<v.minE&&(r.e=0,r.d=[0])),r}function Ft(r,e,t){if(!r.isFinite())return zl(r);var a,n=r.e,i=Pr(r.d),o=i.length;return e?(t&&(a=t-o)>0?i=i.charAt(0)+"."+i.slice(1)+on(a):o>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(r.e<0?"e":"e+")+r.e):n<0?(i="0."+on(-n-1)+i,t&&(a=t-o)>0&&(i+=on(a))):n>=o?(i+=on(n+1-o),t&&(a=t-n-1)>0&&(i=i+"."+on(a))):((a=n+1)<o&&(i=i.slice(0,a)+"."+i.slice(a)),t&&(a=t-o)>0&&(n+1===o&&(i+="."),i+=on(a))),i}function Di(r,e){var t=r[0];for(e*=He;t>=10;t/=10)e++;return e}function Ai(r,e,t){if(e>$g)throw Xe=!0,t&&(r.precision=t),Error(Tl);return Pe(new r(bi),e,1,!0)}function gt(r,e,t){if(e>ts)throw Error(Tl);return Pe(new r(xi),e,t,!0)}function Il(r){var e=r.length-1,t=e*He+1;if(e=r[e],e){for(;e%10==0;e/=10)t--;for(e=r[0];e>=10;e/=10)t++}return t}function on(r){for(var e="";r--;)e+="0";return e}function Rl(r,e,t,a){var n,i=new r(1),o=Math.ceil(a/He+4);for(Xe=!1;;){if(t%2&&(i=i.times(e),Ul(i.d,o)&&(n=!0)),t=Gr(t/2),t===0){t=i.d.length-1,n&&i.d[t]===0&&++i.d[t];break}e=e.times(e),Ul(e.d,o)}return Xe=!0,i}function _l(r){return r.d[r.d.length-1]&1}function ql(r,e,t){for(var a,n=new r(e[0]),i=0;++i<e.length;)if(a=new r(e[i]),a.s)n[t](a)&&(n=a);else{n=a;break}return n}function ns(r,e){var t,a,n,i,o,f,l,u=0,s=0,c=0,m=r.constructor,v=m.rounding,h=m.precision;if(!r.d||!r.d[0]||r.e>17)return new m(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:0/0);for(e==null?(Xe=!1,l=h):l=e,f=new m(.03125);r.e>-2;)r=r.times(f),c+=5;for(a=Math.log(Or(2,c))/Math.LN10*2+5|0,l+=a,t=i=o=new m(1),m.precision=l;;){if(i=Pe(i.times(r),l,1),t=t.times(++s),f=o.plus(gr(i,t,l,1)),Pr(f.d).slice(0,l)===Pr(o.d).slice(0,l)){for(n=c;n--;)o=Pe(o.times(o),l,1);if(e==null)if(u<3&&La(o.d,l-a,v,u))m.precision=l+=10,t=i=f=new m(1),s=0,u++;else return Pe(o,m.precision=h,v,Xe=!0);else return m.precision=h,o}o=f}}function sn(r,e){var t,a,n,i,o,f,l,u,s,c,m,v=1,h=10,p=r,g=p.d,y=p.constructor,N=y.rounding,d=y.precision;if(p.s<0||!g||!g[0]||!p.e&&g[0]==1&&g.length==1)return new y(g&&!g[0]?-1/0:p.s!=1?NaN:g?0:p);if(e==null?(Xe=!1,s=d):s=e,y.precision=s+=h,t=Pr(g),a=t.charAt(0),Math.abs(i=p.e)<15e14){for(;a<7&&a!=1||a==1&&t.charAt(1)>3;)p=p.times(r),t=Pr(p.d),a=t.charAt(0),v++;i=p.e,a>1?(p=new y("0."+t),i++):p=new y(a+"."+t.slice(1))}else return u=Ai(y,s+2,d).times(i+""),p=sn(new y(a+"."+t.slice(1)),s-h).plus(u),y.precision=d,e==null?Pe(p,d,N,Xe=!0):p;for(c=p,l=o=p=gr(p.minus(1),p.plus(1),s,1),m=Pe(p.times(p),s,1),n=3;;){if(o=Pe(o.times(m),s,1),u=l.plus(gr(o,new y(n),s,1)),Pr(u.d).slice(0,s)===Pr(l.d).slice(0,s))if(l=l.times(2),i!==0&&(l=l.plus(Ai(y,s+2,d).times(i+""))),l=gr(l,new y(v),s,1),e==null)if(La(l.d,s-h,N,f))y.precision=s+=h,u=o=p=gr(c.minus(1),c.plus(1),s,1),m=Pe(p.times(p),s,1),n=f=1;else return Pe(l,y.precision=d,N,Xe=!0);else return y.precision=d,l;l=u,n+=2}}function zl(r){return String(r.s*r.s/0)}function as(r,e){var t,a,n;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(a=e.search(/e/i))>0?(t<0&&(t=a),t+=+e.slice(a+1),e=e.substring(0,a)):t<0&&(t=e.length),a=0;e.charCodeAt(a)===48;a++);for(n=e.length;e.charCodeAt(n-1)===48;--n);if(e=e.slice(a,n),e){if(n-=a,r.e=t=t-a-1,r.d=[],a=(t+1)%He,t<0&&(a+=He),a<n){for(a&&r.d.push(+e.slice(0,a)),n-=He;a<n;)r.d.push(+e.slice(a,a+=He));e=e.slice(a),a=He-e.length}else a-=n;for(;a--;)e+="0";r.d.push(+e),Xe&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}function Ig(r,e){var t,a,n,i,o,f,l,u,s;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Ol.test(e))return as(r,e)}else if(e==="Infinity"||e==="NaN")return+e||(r.s=NaN),r.e=NaN,r.d=null,r;if(Fg.test(e))t=16,e=e.toLowerCase();else if(Mg.test(e))t=2;else if(Tg.test(e))t=8;else throw Error(an+e);for(i=e.search(/p/i),i>0?(l=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),o=i>=0,a=r.constructor,o&&(e=e.replace(".",""),f=e.length,i=f-i,n=Rl(a,new a(t),i,i*2)),u=Ni(e,t,dt),s=u.length-1,i=s;u[i]===0;--i)u.pop();return i<0?new a(r.s*0):(r.e=Di(u,s),r.d=u,Xe=!1,o&&(r=gr(r,n,f*4)),l&&(r=r.times(Math.abs(l)<54?Or(2,l):un.pow(2,l))),Xe=!0,r)}function Rg(r,e){var t,a=e.d.length;if(a<3)return e.isZero()?e:ta(r,2,e,e);t=1.4*Math.sqrt(a),t=t>16?16:t|0,e=e.times(1/Ei(5,t)),e=ta(r,2,e,e);for(var n,i=new r(5),o=new r(16),f=new r(20);t--;)n=e.times(e),e=e.times(i.plus(n.times(o.times(n).minus(f))));return e}function ta(r,e,t,a,n){var i,o,f,l,u=r.precision,s=Math.ceil(u/He);for(Xe=!1,l=t.times(t),f=new r(a);;){if(o=gr(f.times(l),new r(e++*e++),u,1),f=n?a.plus(o):a.minus(o),a=gr(o.times(l),new r(e++*e++),u,1),o=f.plus(a),o.d[s]!==void 0){for(i=s;o.d[i]===f.d[i]&&i--;);if(i==-1)break}i=f,f=a,a=o,o=i}return Xe=!0,o.d.length=s+1,o}function Ei(r,e){for(var t=r;--e;)t*=r;return t}function Pl(r,e){var t,a=e.s<0,n=gt(r,r.precision,1),i=n.times(.5);if(e=e.abs(),e.lte(i))return Ht=a?4:1,e;if(t=e.divToInt(n),t.isZero())Ht=a?3:2;else{if(e=e.minus(t.times(n)),e.lte(i))return Ht=_l(t)?a?2:3:a?4:1,e;Ht=_l(t)?a?1:4:a?3:2}return e.minus(n).abs()}function is(r,e,t,a){var n,i,o,f,l,u,s,c,m,v=r.constructor,h=t!==void 0;if(h?(et(t,1,nn),a===void 0?a=v.rounding:et(a,0,8)):(t=v.precision,a=v.rounding),!r.isFinite())s=zl(r);else{for(s=Ft(r),o=s.indexOf("."),h?(n=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):n=e,o>=0&&(s=s.replace(".",""),m=new v(1),m.e=s.length-o,m.d=Ni(Ft(m),10,n),m.e=m.d.length),c=Ni(s,10,n),i=l=c.length;c[--l]==0;)c.pop();if(!c[0])s=h?"0p+0":"0";else{if(o<0?i--:(r=new v(r),r.d=c,r.e=i,r=gr(r,m,t,a,0,n),c=r.d,i=r.e,u=Fl),o=c[t],f=n/2,u=u||c[t+1]!==void 0,u=a<4?(o!==void 0||u)&&(a===0||a===(r.s<0?3:2)):o>f||o===f&&(a===4||u||a===6&&c[t-1]&1||a===(r.s<0?8:7)),c.length=t,u)for(;++c[--t]>n-1;)c[t]=0,t||(++i,c.unshift(1));for(l=c.length;!c[l-1];--l);for(o=0,s="";o<l;o++)s+=es.charAt(c[o]);if(h){if(l>1)if(e==16||e==8){for(o=e==16?4:3,--l;l%o;l++)s+="0";for(c=Ni(s,n,e),l=c.length;!c[l-1];--l);for(o=1,s="1.";o<l;o++)s+=es.charAt(c[o])}else s=s.charAt(0)+"."+s.slice(1);s=s+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)s="0"+s;s="0."+s}else if(++i>l)for(i-=l;i--;)s+="0";else i<l&&(s=s.slice(0,i)+"."+s.slice(i))}s=(e==16?"0x":e==2?"0b":e==8?"0o":"")+s}return r.s<0?"-"+s:s}function Ul(r,e){if(r.length>e)return r.length=e,!0}function _g(r){return new this(r).abs()}function qg(r){return new this(r).acos()}function zg(r){return new this(r).acosh()}function Pg(r,e){return new this(r).plus(e)}function Ug(r){return new this(r).asin()}function Lg(r){return new this(r).asinh()}function kg(r){return new this(r).atan()}function Vg(r){return new this(r).atanh()}function Gg(r,e){r=new this(r),e=new this(e);var t,a=this.precision,n=this.rounding,i=a+4;return!r.s||!e.s?t=new this(NaN):!r.d&&!e.d?(t=gt(this,i,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?gt(this,a,n):new this(0),t.s=r.s):!r.d||e.isZero()?(t=gt(this,i,1).times(.5),t.s=r.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(gr(r,e,i,1)),e=gt(this,i,1),this.precision=a,this.rounding=n,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(gr(r,e,i,1)),t}function Hg(r){return new this(r).cbrt()}function Zg(r){return Pe(r=new this(r),r.e+1,2)}function Jg(r,e,t){return new this(r).clamp(e,t)}function Xg(r){if(!r||typeof r!="object")throw Error(wi+"Object expected");var e,t,a,n=r.defaults===!0,i=["precision",1,nn,"rounding",0,8,"toExpNeg",-ra,0,"toExpPos",0,ra,"maxE",0,ra,"minE",-ra,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],n&&(this[t]=rs[t]),(a=r[t])!==void 0)if(Gr(a)===a&&a>=i[e+1]&&a<=i[e+2])this[t]=a;else throw Error(an+t+": "+a);if(t="crypto",n&&(this[t]=rs[t]),(a=r[t])!==void 0)if(a===!0||a===!1||a===0||a===1)if(a)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Bl);else this[t]=!1;else throw Error(an+t+": "+a);return this}function Wg(r){return new this(r).cos()}function Yg(r){return new this(r).cosh()}function Ll(r){var e,t,a;function n(i){var o,f,l,u=this;if(!(u instanceof n))return new n(i);if(u.constructor=n,kl(i)){u.s=i.s,Xe?!i.d||i.e>n.maxE?(u.e=NaN,u.d=null):i.e<n.minE?(u.e=0,u.d=[0]):(u.e=i.e,u.d=i.d.slice()):(u.e=i.e,u.d=i.d?i.d.slice():i.d);return}if(l=typeof i,l==="number"){if(i===0){u.s=1/i<0?-1:1,u.e=0,u.d=[0];return}if(i<0?(i=-i,u.s=-1):u.s=1,i===~~i&&i<1e7){for(o=0,f=i;f>=10;f/=10)o++;Xe?o>n.maxE?(u.e=NaN,u.d=null):o<n.minE?(u.e=0,u.d=[0]):(u.e=o,u.d=[i]):(u.e=o,u.d=[i]);return}else if(i*0!==0){i||(u.s=NaN),u.e=NaN,u.d=null;return}return as(u,i.toString())}else if(l!=="string")throw Error(an+i);return(f=i.charCodeAt(0))===45?(i=i.slice(1),u.s=-1):(f===43&&(i=i.slice(1)),u.s=1),Ol.test(i)?as(u,i):Ig(u,i)}if(n.prototype=xe,n.ROUND_UP=0,n.ROUND_DOWN=1,n.ROUND_CEIL=2,n.ROUND_FLOOR=3,n.ROUND_HALF_UP=4,n.ROUND_HALF_DOWN=5,n.ROUND_HALF_EVEN=6,n.ROUND_HALF_CEIL=7,n.ROUND_HALF_FLOOR=8,n.EUCLID=9,n.config=n.set=Xg,n.clone=Ll,n.isDecimal=kl,n.abs=_g,n.acos=qg,n.acosh=zg,n.add=Pg,n.asin=Ug,n.asinh=Lg,n.atan=kg,n.atanh=Vg,n.atan2=Gg,n.cbrt=Hg,n.ceil=Zg,n.clamp=Jg,n.cos=Wg,n.cosh=Yg,n.div=Qg,n.exp=Kg,n.floor=jg,n.hypot=e1,n.ln=r1,n.log=t1,n.log10=a1,n.log2=n1,n.max=i1,n.min=o1,n.mod=s1,n.mul=u1,n.pow=l1,n.random=c1,n.round=f1,n.sign=m1,n.sin=v1,n.sinh=p1,n.sqrt=h1,n.sub=d1,n.sum=g1,n.tan=y1,n.tanh=b1,n.trunc=x1,r===void 0&&(r={}),r&&r.defaults!==!0)for(a=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<a.length;)r.hasOwnProperty(t=a[e++])||(r[t]=this[t]);return n.config(r),n}function Qg(r,e){return new this(r).div(e)}function Kg(r){return new this(r).exp()}function jg(r){return Pe(r=new this(r),r.e+1,3)}function e1(){var r,e,t=new this(0);for(Xe=!1,r=0;r<arguments.length;)if(e=new this(arguments[r++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return Xe=!0,new this(1/0);t=e}return Xe=!0,t.sqrt()}function kl(r){return r instanceof un||r&&r.toStringTag===$l||!1}function r1(r){return new this(r).ln()}function t1(r,e){return new this(r).log(e)}function n1(r){return new this(r).log(2)}function a1(r){return new this(r).log(10)}function i1(){return ql(this,arguments,"lt")}function o1(){return ql(this,arguments,"gt")}function s1(r,e){return new this(r).mod(e)}function u1(r,e){return new this(r).mul(e)}function l1(r,e){return new this(r).pow(e)}function c1(r){var e,t,a,n,i=0,o=new this(1),f=[];if(r===void 0?r=this.precision:et(r,1,nn),a=Math.ceil(r/He),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(a));i<a;)n=e[i],n>=429e7?e[i]=crypto.getRandomValues(new Uint32Array(1))[0]:f[i++]=n%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(a*=4);i<a;)n=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+((e[i+3]&127)<<24),n>=214e7?crypto.randomBytes(4).copy(e,i):(f.push(n%1e7),i+=4);i=a/4}else throw Error(Bl);else for(;i<a;)f[i++]=Math.random()*1e7|0;for(a=f[--i],r%=He,a&&r&&(n=Or(10,He-r),f[i]=(a/n|0)*n);f[i]===0;i--)f.pop();if(i<0)t=0,f=[0];else{for(t=-1;f[0]===0;t-=He)f.shift();for(a=1,n=f[0];n>=10;n/=10)a++;a<He&&(t-=He-a)}return o.e=t,o.d=f,o}function f1(r){return Pe(r=new this(r),r.e+1,this.rounding)}function m1(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function v1(r){return new this(r).sin()}function p1(r){return new this(r).sinh()}function h1(r){return new this(r).sqrt()}function d1(r,e){return new this(r).sub(e)}function g1(){var r=0,e=arguments,t=new this(e[r]);for(Xe=!1;t.s&&++r<e.length;)t=t.plus(e[r]);return Xe=!0,Pe(t,this.precision,this.rounding)}function y1(r){return new this(r).tan()}function b1(r){return new this(r).tanh()}function x1(r){return Pe(r=new this(r),r.e+1,1)}xe[Symbol.for("nodejs.util.inspect.custom")]=xe.toString,xe[Symbol.toStringTag]="Decimal";var un=xe.constructor=Ll(rs);bi=new un(bi),xi=new un(xi);var w1="BigNumber",N1=["?on","config"],D1=q(w1,N1,r=>{var{on:e,config:t}=r,a=un.clone({precision:t.precision,modulo:un.EUCLID});return a.prototype=Object.create(a.prototype),a.prototype.type="BigNumber",a.prototype.isBigNumber=!0,a.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},a.fromJSON=function(n){return new a(n.value)},e&&e("config",function(n,i){n.precision!==i.precision&&a.config({precision:n.precision})}),a},{isClass:!0}),Cn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vl(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function A1(r){var e=r.default;if(typeof e=="function"){var t=function(){return e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(a){var n=Object.getOwnPropertyDescriptor(r,a);Object.defineProperty(t,a,n.get?n:{enumerable:!0,get:function(){return r[a]}})}),t}var Gl={exports:{}};/**
|
|
15
|
+
*/var ta=9e15,on=1e9,es="0123456789abcdef",bi="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",xi="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",rs={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ta,maxE:ta,crypto:!1},Bl,Zt,Xe=!0,wi="[DecimalError] ",sn=wi+"Invalid argument: ",$l=wi+"Precision limit exceeded",Ol=wi+"crypto unavailable",Il="[object Decimal]",Gr=Math.floor,Or=Math.pow,_g=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,qg=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,zg=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Rl=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,gt=1e7,He=7,Pg=9007199254740991,Ug=bi.length-1,ts=xi.length-1,xe={toStringTag:Il};xe.absoluteValue=xe.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),Pe(r)},xe.ceil=function(){return Pe(new this.constructor(this),this.e+1,2)},xe.clampedTo=xe.clamp=function(r,e){var t,a=this,n=a.constructor;if(r=new n(r),e=new n(e),!r.s||!e.s)return new n(NaN);if(r.gt(e))throw Error(sn+e);return t=a.cmp(r),t<0?r:a.cmp(e)>0?e:new n(a)},xe.comparedTo=xe.cmp=function(r){var e,t,a,n,i=this,o=i.d,f=(r=new i.constructor(r)).d,l=i.s,u=r.s;if(!o||!f)return!l||!u?NaN:l!==u?l:o===f?0:!o^l<0?1:-1;if(!o[0]||!f[0])return o[0]?l:f[0]?-u:0;if(l!==u)return l;if(i.e!==r.e)return i.e>r.e^l<0?1:-1;for(a=o.length,n=f.length,e=0,t=a<n?a:n;e<t;++e)if(o[e]!==f[e])return o[e]>f[e]^l<0?1:-1;return a===n?0:a>n^l<0?1:-1},xe.cosine=xe.cos=function(){var r,e,t=this,a=t.constructor;return t.d?t.d[0]?(r=a.precision,e=a.rounding,a.precision=r+Math.max(t.e,t.sd())+He,a.rounding=1,t=Lg(a,Ll(a,t)),a.precision=r,a.rounding=e,Pe(Zt==2||Zt==3?t.neg():t,r,e,!0)):new a(1):new a(NaN)},xe.cubeRoot=xe.cbrt=function(){var r,e,t,a,n,i,o,f,l,u,s=this,c=s.constructor;if(!s.isFinite()||s.isZero())return new c(s);for(Xe=!1,i=s.s*Or(s.s*s,1/3),!i||Math.abs(i)==1/0?(t=Pr(s.d),r=s.e,(i=(r-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=Or(t,1/3),r=Gr((r+1)/3)-(r%3==(r<0?-1:2)),i==1/0?t="5e"+r:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),a=new c(t),a.s=s.s):a=new c(i.toString()),o=(r=c.precision)+3;;)if(f=a,l=f.times(f).times(f),u=l.plus(s),a=gr(u.plus(s).times(f),u.plus(l),o+2,1),Pr(f.d).slice(0,o)===(t=Pr(a.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!n&&t=="4999"){if(!n&&(Pe(f,r+1,0),f.times(f).times(f).eq(s))){a=f;break}o+=4,n=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Pe(a,r+1,1),e=!a.times(a).times(a).eq(s));break}return Xe=!0,Pe(a,r,c.rounding,e)},xe.decimalPlaces=xe.dp=function(){var r,e=this.d,t=NaN;if(e){if(r=e.length-1,t=(r-Gr(this.e/He))*He,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t},xe.dividedBy=xe.div=function(r){return gr(this,new this.constructor(r))},xe.dividedToIntegerBy=xe.divToInt=function(r){var e=this,t=e.constructor;return Pe(gr(e,new t(r),0,1,1),t.precision,t.rounding)},xe.equals=xe.eq=function(r){return this.cmp(r)===0},xe.floor=function(){return Pe(new this.constructor(this),this.e+1,3)},xe.greaterThan=xe.gt=function(r){return this.cmp(r)>0},xe.greaterThanOrEqualTo=xe.gte=function(r){var e=this.cmp(r);return e==1||e===0},xe.hyperbolicCosine=xe.cosh=function(){var r,e,t,a,n,i=this,o=i.constructor,f=new o(1);if(!i.isFinite())return new o(i.s?1/0:NaN);if(i.isZero())return f;t=o.precision,a=o.rounding,o.precision=t+Math.max(i.e,i.sd())+4,o.rounding=1,n=i.d.length,n<32?(r=Math.ceil(n/3),e=(1/Ei(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),i=na(o,1,i.times(e),new o(1),!0);for(var l,u=r,s=new o(8);u--;)l=i.times(i),i=f.minus(l.times(s.minus(l.times(s))));return Pe(i,o.precision=t,o.rounding=a,!0)},xe.hyperbolicSine=xe.sinh=function(){var r,e,t,a,n=this,i=n.constructor;if(!n.isFinite()||n.isZero())return new i(n);if(e=i.precision,t=i.rounding,i.precision=e+Math.max(n.e,n.sd())+4,i.rounding=1,a=n.d.length,a<3)n=na(i,2,n,n,!0);else{r=1.4*Math.sqrt(a),r=r>16?16:r|0,n=n.times(1/Ei(5,r)),n=na(i,2,n,n,!0);for(var o,f=new i(5),l=new i(16),u=new i(20);r--;)o=n.times(n),n=n.times(f.plus(o.times(l.times(o).plus(u))))}return i.precision=e,i.rounding=t,Pe(n,e,t,!0)},xe.hyperbolicTangent=xe.tanh=function(){var r,e,t=this,a=t.constructor;return t.isFinite()?t.isZero()?new a(t):(r=a.precision,e=a.rounding,a.precision=r+7,a.rounding=1,gr(t.sinh(),t.cosh(),a.precision=r,a.rounding=e)):new a(t.s)},xe.inverseCosine=xe.acos=function(){var r,e=this,t=e.constructor,a=e.abs().cmp(1),n=t.precision,i=t.rounding;return a!==-1?a===0?e.isNeg()?yt(t,n,i):new t(0):new t(NaN):e.isZero()?yt(t,n+4,i).times(.5):(t.precision=n+6,t.rounding=1,e=e.asin(),r=yt(t,n+4,i).times(.5),t.precision=n,t.rounding=i,r.minus(e))},xe.inverseHyperbolicCosine=xe.acosh=function(){var r,e,t=this,a=t.constructor;return t.lte(1)?new a(t.eq(1)?0:NaN):t.isFinite()?(r=a.precision,e=a.rounding,a.precision=r+Math.max(Math.abs(t.e),t.sd())+4,a.rounding=1,Xe=!1,t=t.times(t).minus(1).sqrt().plus(t),Xe=!0,a.precision=r,a.rounding=e,t.ln()):new a(t)},xe.inverseHyperbolicSine=xe.asinh=function(){var r,e,t=this,a=t.constructor;return!t.isFinite()||t.isZero()?new a(t):(r=a.precision,e=a.rounding,a.precision=r+2*Math.max(Math.abs(t.e),t.sd())+6,a.rounding=1,Xe=!1,t=t.times(t).plus(1).sqrt().plus(t),Xe=!0,a.precision=r,a.rounding=e,t.ln())},xe.inverseHyperbolicTangent=xe.atanh=function(){var r,e,t,a,n=this,i=n.constructor;return n.isFinite()?n.e>=0?new i(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(r=i.precision,e=i.rounding,a=n.sd(),Math.max(a,r)<2*-n.e-1?Pe(new i(n),r,e,!0):(i.precision=t=a-n.e,n=gr(n.plus(1),new i(1).minus(n),t+r,1),i.precision=r+4,i.rounding=1,n=n.ln(),i.precision=r,i.rounding=e,n.times(.5))):new i(NaN)},xe.inverseSine=xe.asin=function(){var r,e,t,a,n=this,i=n.constructor;return n.isZero()?new i(n):(e=n.abs().cmp(1),t=i.precision,a=i.rounding,e!==-1?e===0?(r=yt(i,t+4,a).times(.5),r.s=n.s,r):new i(NaN):(i.precision=t+6,i.rounding=1,n=n.div(new i(1).minus(n.times(n)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=a,n.times(2)))},xe.inverseTangent=xe.atan=function(){var r,e,t,a,n,i,o,f,l,u=this,s=u.constructor,c=s.precision,m=s.rounding;if(u.isFinite()){if(u.isZero())return new s(u);if(u.abs().eq(1)&&c+4<=ts)return o=yt(s,c+4,m).times(.25),o.s=u.s,o}else{if(!u.s)return new s(NaN);if(c+4<=ts)return o=yt(s,c+4,m).times(.5),o.s=u.s,o}for(s.precision=f=c+10,s.rounding=1,t=Math.min(28,f/He+2|0),r=t;r;--r)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(Xe=!1,e=Math.ceil(f/He),a=1,l=u.times(u),o=new s(u),n=u;r!==-1;)if(n=n.times(l),i=o.minus(n.div(a+=2)),n=n.times(l),o=i.plus(n.div(a+=2)),o.d[e]!==void 0)for(r=e;o.d[r]===i.d[r]&&r--;);return t&&(o=o.times(2<<t-1)),Xe=!0,Pe(o,s.precision=c,s.rounding=m,!0)},xe.isFinite=function(){return!!this.d},xe.isInteger=xe.isInt=function(){return!!this.d&&Gr(this.e/He)>this.d.length-2},xe.isNaN=function(){return!this.s},xe.isNegative=xe.isNeg=function(){return this.s<0},xe.isPositive=xe.isPos=function(){return this.s>0},xe.isZero=function(){return!!this.d&&this.d[0]===0},xe.lessThan=xe.lt=function(r){return this.cmp(r)<0},xe.lessThanOrEqualTo=xe.lte=function(r){return this.cmp(r)<1},xe.logarithm=xe.log=function(r){var e,t,a,n,i,o,f,l,u=this,s=u.constructor,c=s.precision,m=s.rounding,v=5;if(r==null)r=new s(10),e=!0;else{if(r=new s(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new s(NaN);e=r.eq(10)}if(t=u.d,u.s<0||!t||!t[0]||u.eq(1))return new s(t&&!t[0]?-1/0:u.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)i=!0;else{for(n=t[0];n%10===0;)n/=10;i=n!==1}if(Xe=!1,f=c+v,o=ln(u,f),a=e?Ai(s,f+10):ln(r,f),l=gr(o,a,f,1),ka(l.d,n=c,m))do if(f+=10,o=ln(u,f),a=e?Ai(s,f+10):ln(r,f),l=gr(o,a,f,1),!i){+Pr(l.d).slice(n+1,n+15)+1==1e14&&(l=Pe(l,c+1,0));break}while(ka(l.d,n+=10,m));return Xe=!0,Pe(l,c,m)},xe.minus=xe.sub=function(r){var e,t,a,n,i,o,f,l,u,s,c,m,v=this,h=v.constructor;if(r=new h(r),!v.d||!r.d)return!v.s||!r.s?r=new h(NaN):v.d?r.s=-r.s:r=new h(r.d||v.s!==r.s?v:NaN),r;if(v.s!=r.s)return r.s=-r.s,v.plus(r);if(u=v.d,m=r.d,f=h.precision,l=h.rounding,!u[0]||!m[0]){if(m[0])r.s=-r.s;else if(u[0])r=new h(v);else return new h(l===3?-0:0);return Xe?Pe(r,f,l):r}if(t=Gr(r.e/He),s=Gr(v.e/He),u=u.slice(),i=s-t,i){for(c=i<0,c?(e=u,i=-i,o=m.length):(e=m,t=s,o=u.length),a=Math.max(Math.ceil(f/He),o)+2,i>a&&(i=a,e.length=1),e.reverse(),a=i;a--;)e.push(0);e.reverse()}else{for(a=u.length,o=m.length,c=a<o,c&&(o=a),a=0;a<o;a++)if(u[a]!=m[a]){c=u[a]<m[a];break}i=0}for(c&&(e=u,u=m,m=e,r.s=-r.s),o=u.length,a=m.length-o;a>0;--a)u[o++]=0;for(a=m.length;a>i;){if(u[--a]<m[a]){for(n=a;n&&u[--n]===0;)u[n]=gt-1;--u[n],u[a]+=gt}u[a]-=m[a]}for(;u[--o]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(r.d=u,r.e=Di(u,t),Xe?Pe(r,f,l):r):new h(l===3?-0:0)},xe.modulo=xe.mod=function(r){var e,t=this,a=t.constructor;return r=new a(r),!t.d||!r.s||r.d&&!r.d[0]?new a(NaN):!r.d||t.d&&!t.d[0]?Pe(new a(t),a.precision,a.rounding):(Xe=!1,a.modulo==9?(e=gr(t,r.abs(),0,3,1),e.s*=r.s):e=gr(t,r,0,a.modulo,1),e=e.times(r),Xe=!0,t.minus(e))},xe.naturalExponential=xe.exp=function(){return ns(this)},xe.naturalLogarithm=xe.ln=function(){return ln(this)},xe.negated=xe.neg=function(){var r=new this.constructor(this);return r.s=-r.s,Pe(r)},xe.plus=xe.add=function(r){var e,t,a,n,i,o,f,l,u,s,c=this,m=c.constructor;if(r=new m(r),!c.d||!r.d)return!c.s||!r.s?r=new m(NaN):c.d||(r=new m(r.d||c.s===r.s?c:NaN)),r;if(c.s!=r.s)return r.s=-r.s,c.minus(r);if(u=c.d,s=r.d,f=m.precision,l=m.rounding,!u[0]||!s[0])return s[0]||(r=new m(c)),Xe?Pe(r,f,l):r;if(i=Gr(c.e/He),a=Gr(r.e/He),u=u.slice(),n=i-a,n){for(n<0?(t=u,n=-n,o=s.length):(t=s,a=i,o=u.length),i=Math.ceil(f/He),o=i>o?i+1:o+1,n>o&&(n=o,t.length=1),t.reverse();n--;)t.push(0);t.reverse()}for(o=u.length,n=s.length,o-n<0&&(n=o,t=s,s=u,u=t),e=0;n;)e=(u[--n]=u[n]+s[n]+e)/gt|0,u[n]%=gt;for(e&&(u.unshift(e),++a),o=u.length;u[--o]==0;)u.pop();return r.d=u,r.e=Di(u,a),Xe?Pe(r,f,l):r},xe.precision=xe.sd=function(r){var e,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(sn+r);return t.d?(e=_l(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e},xe.round=function(){var r=this,e=r.constructor;return Pe(new e(r),r.e+1,e.rounding)},xe.sine=xe.sin=function(){var r,e,t=this,a=t.constructor;return t.isFinite()?t.isZero()?new a(t):(r=a.precision,e=a.rounding,a.precision=r+Math.max(t.e,t.sd())+He,a.rounding=1,t=Vg(a,Ll(a,t)),a.precision=r,a.rounding=e,Pe(Zt>2?t.neg():t,r,e,!0)):new a(NaN)},xe.squareRoot=xe.sqrt=function(){var r,e,t,a,n,i,o=this,f=o.d,l=o.e,u=o.s,s=o.constructor;if(u!==1||!f||!f[0])return new s(!u||u<0&&(!f||f[0])?NaN:f?o:1/0);for(Xe=!1,u=Math.sqrt(+o),u==0||u==1/0?(e=Pr(f),(e.length+l)%2==0&&(e+="0"),u=Math.sqrt(e),l=Gr((l+1)/2)-(l<0||l%2),u==1/0?e="5e"+l:(e=u.toExponential(),e=e.slice(0,e.indexOf("e")+1)+l),a=new s(e)):a=new s(u.toString()),t=(l=s.precision)+3;;)if(i=a,a=i.plus(gr(o,i,t+2,1)).times(.5),Pr(i.d).slice(0,t)===(e=Pr(a.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!n&&e=="4999"){if(!n&&(Pe(i,l+1,0),i.times(i).eq(o))){a=i;break}t+=4,n=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(Pe(a,l+1,1),r=!a.times(a).eq(o));break}return Xe=!0,Pe(a,l,s.rounding,r)},xe.tangent=xe.tan=function(){var r,e,t=this,a=t.constructor;return t.isFinite()?t.isZero()?new a(t):(r=a.precision,e=a.rounding,a.precision=r+10,a.rounding=1,t=t.sin(),t.s=1,t=gr(t,new a(1).minus(t.times(t)).sqrt(),r+10,0),a.precision=r,a.rounding=e,Pe(Zt==2||Zt==4?t.neg():t,r,e,!0)):new a(NaN)},xe.times=xe.mul=function(r){var e,t,a,n,i,o,f,l,u,s=this,c=s.constructor,m=s.d,v=(r=new c(r)).d;if(r.s*=s.s,!m||!m[0]||!v||!v[0])return new c(!r.s||m&&!m[0]&&!v||v&&!v[0]&&!m?NaN:!m||!v?r.s/0:r.s*0);for(t=Gr(s.e/He)+Gr(r.e/He),l=m.length,u=v.length,l<u&&(i=m,m=v,v=i,o=l,l=u,u=o),i=[],o=l+u,a=o;a--;)i.push(0);for(a=u;--a>=0;){for(e=0,n=l+a;n>a;)f=i[n]+v[a]*m[n-a-1]+e,i[n--]=f%gt|0,e=f/gt|0;i[n]=(i[n]+e)%gt|0}for(;!i[--o];)i.pop();return e?++t:i.shift(),r.d=i,r.e=Di(i,t),Xe?Pe(r,c.precision,c.rounding):r},xe.toBinary=function(r,e){return is(this,2,r,e)},xe.toDecimalPlaces=xe.toDP=function(r,e){var t=this,a=t.constructor;return t=new a(t),r===void 0?t:(et(r,0,on),e===void 0?e=a.rounding:et(e,0,8),Pe(t,r+t.e+1,e))},xe.toExponential=function(r,e){var t,a=this,n=a.constructor;return r===void 0?t=Tt(a,!0):(et(r,0,on),e===void 0?e=n.rounding:et(e,0,8),a=Pe(new n(a),r+1,e),t=Tt(a,!0,r+1)),a.isNeg()&&!a.isZero()?"-"+t:t},xe.toFixed=function(r,e){var t,a,n=this,i=n.constructor;return r===void 0?t=Tt(n):(et(r,0,on),e===void 0?e=i.rounding:et(e,0,8),a=Pe(new i(n),r+n.e+1,e),t=Tt(a,!1,r+a.e+1)),n.isNeg()&&!n.isZero()?"-"+t:t},xe.toFraction=function(r){var e,t,a,n,i,o,f,l,u,s,c,m,v=this,h=v.d,p=v.constructor;if(!h)return new p(v);if(u=t=new p(1),a=l=new p(0),e=new p(a),i=e.e=_l(h)-v.e-1,o=i%He,e.d[0]=Or(10,o<0?He+o:o),r==null)r=i>0?e:u;else{if(f=new p(r),!f.isInt()||f.lt(u))throw Error(sn+f);r=f.gt(e)?i>0?e:u:f}for(Xe=!1,f=new p(Pr(h)),s=p.precision,p.precision=i=h.length*He*2;c=gr(f,e,0,1,1),n=t.plus(c.times(a)),n.cmp(r)!=1;)t=a,a=n,n=u,u=l.plus(c.times(n)),l=n,n=e,e=f.minus(c.times(n)),f=n;return n=gr(r.minus(t),a,0,1,1),l=l.plus(n.times(u)),t=t.plus(n.times(a)),l.s=u.s=v.s,m=gr(u,a,i,1).minus(v).abs().cmp(gr(l,t,i,1).minus(v).abs())<1?[u,a]:[l,t],p.precision=s,Xe=!0,m},xe.toHexadecimal=xe.toHex=function(r,e){return is(this,16,r,e)},xe.toNearest=function(r,e){var t=this,a=t.constructor;if(t=new a(t),r==null){if(!t.d)return t;r=new a(1),e=a.rounding}else{if(r=new a(r),e===void 0?e=a.rounding:et(e,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(Xe=!1,t=gr(t,r,0,e,1).times(r),Xe=!0,Pe(t)):(r.s=t.s,t=r),t},xe.toNumber=function(){return+this},xe.toOctal=function(r,e){return is(this,8,r,e)},xe.toPower=xe.pow=function(r){var e,t,a,n,i,o,f=this,l=f.constructor,u=+(r=new l(r));if(!f.d||!r.d||!f.d[0]||!r.d[0])return new l(Or(+f,u));if(f=new l(f),f.eq(1))return f;if(a=l.precision,i=l.rounding,r.eq(1))return Pe(f,a,i);if(e=Gr(r.e/He),e>=r.d.length-1&&(t=u<0?-u:u)<=Pg)return n=ql(l,f,t,a),r.s<0?new l(1).div(n):Pe(n,a,i);if(o=f.s,o<0){if(e<r.d.length-1)return new l(NaN);if((r.d[e]&1)==0&&(o=1),f.e==0&&f.d[0]==1&&f.d.length==1)return f.s=o,f}return t=Or(+f,u),e=t==0||!isFinite(t)?Gr(u*(Math.log("0."+Pr(f.d))/Math.LN10+f.e+1)):new l(t+"").e,e>l.maxE+1||e<l.minE-1?new l(e>0?o/0:0):(Xe=!1,l.rounding=f.s=1,t=Math.min(12,(e+"").length),n=ns(r.times(ln(f,a+t)),a),n.d&&(n=Pe(n,a+5,1),ka(n.d,a,i)&&(e=a+10,n=Pe(ns(r.times(ln(f,e+t)),e),e+5,1),+Pr(n.d).slice(a+1,a+15)+1==1e14&&(n=Pe(n,a+1,0)))),n.s=o,Xe=!0,l.rounding=i,Pe(n,a,i))},xe.toPrecision=function(r,e){var t,a=this,n=a.constructor;return r===void 0?t=Tt(a,a.e<=n.toExpNeg||a.e>=n.toExpPos):(et(r,1,on),e===void 0?e=n.rounding:et(e,0,8),a=Pe(new n(a),r,e),t=Tt(a,r<=a.e||a.e<=n.toExpNeg,r)),a.isNeg()&&!a.isZero()?"-"+t:t},xe.toSignificantDigits=xe.toSD=function(r,e){var t=this,a=t.constructor;return r===void 0?(r=a.precision,e=a.rounding):(et(r,1,on),e===void 0?e=a.rounding:et(e,0,8)),Pe(new a(t),r,e)},xe.toString=function(){var r=this,e=r.constructor,t=Tt(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t},xe.truncated=xe.trunc=function(){return Pe(new this.constructor(this),this.e+1,1)},xe.valueOf=xe.toJSON=function(){var r=this,e=r.constructor,t=Tt(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function Pr(r){var e,t,a,n=r.length-1,i="",o=r[0];if(n>0){for(i+=o,e=1;e<n;e++)a=r[e]+"",t=He-a.length,t&&(i+=un(t)),i+=a;o=r[e],a=o+"",t=He-a.length,t&&(i+=un(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return i+o}function et(r,e,t){if(r!==~~r||r<e||r>t)throw Error(sn+r)}function ka(r,e,t,a){var n,i,o,f;for(i=r[0];i>=10;i/=10)--e;return--e<0?(e+=He,n=0):(n=Math.ceil((e+1)/He),e%=He),i=Or(10,He-e),f=r[n]%i|0,a==null?e<3?(e==0?f=f/100|0:e==1&&(f=f/10|0),o=t<4&&f==99999||t>3&&f==49999||f==5e4||f==0):o=(t<4&&f+1==i||t>3&&f+1==i/2)&&(r[n+1]/i/100|0)==Or(10,e-2)-1||(f==i/2||f==0)&&(r[n+1]/i/100|0)==0:e<4?(e==0?f=f/1e3|0:e==1?f=f/100|0:e==2&&(f=f/10|0),o=(a||t<4)&&f==9999||!a&&t>3&&f==4999):o=((a||t<4)&&f+1==i||!a&&t>3&&f+1==i/2)&&(r[n+1]/i/1e3|0)==Or(10,e-3)-1,o}function Ni(r,e,t){for(var a,n=[0],i,o=0,f=r.length;o<f;){for(i=n.length;i--;)n[i]*=e;for(n[0]+=es.indexOf(r.charAt(o++)),a=0;a<n.length;a++)n[a]>t-1&&(n[a+1]===void 0&&(n[a+1]=0),n[a+1]+=n[a]/t|0,n[a]%=t)}return n.reverse()}function Lg(r,e){var t,a,n;if(e.isZero())return e;a=e.d.length,a<32?(t=Math.ceil(a/3),n=(1/Ei(4,t)).toString()):(t=16,n="2.3283064365386962890625e-10"),r.precision+=t,e=na(r,1,e.times(n),new r(1));for(var i=t;i--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return r.precision-=t,e}var gr=function(){function r(a,n,i){var o,f=0,l=a.length;for(a=a.slice();l--;)o=a[l]*n+f,a[l]=o%i|0,f=o/i|0;return f&&a.unshift(f),a}function e(a,n,i,o){var f,l;if(i!=o)l=i>o?1:-1;else for(f=l=0;f<i;f++)if(a[f]!=n[f]){l=a[f]>n[f]?1:-1;break}return l}function t(a,n,i,o){for(var f=0;i--;)a[i]-=f,f=a[i]<n[i]?1:0,a[i]=f*o+a[i]-n[i];for(;!a[0]&&a.length>1;)a.shift()}return function(a,n,i,o,f,l){var u,s,c,m,v,h,p,g,y,N,d,w,x,b,E,A,S,D,T,B,I=a.constructor,P=a.s==n.s?1:-1,R=a.d,M=n.d;if(!R||!R[0]||!M||!M[0])return new I(!a.s||!n.s||(R?M&&R[0]==M[0]:!M)?NaN:R&&R[0]==0||!M?P*0:P/0);for(l?(v=1,s=a.e-n.e):(l=gt,v=He,s=Gr(a.e/v)-Gr(n.e/v)),T=M.length,S=R.length,y=new I(P),N=y.d=[],c=0;M[c]==(R[c]||0);c++);if(M[c]>(R[c]||0)&&s--,i==null?(b=i=I.precision,o=I.rounding):f?b=i+(a.e-n.e)+1:b=i,b<0)N.push(1),h=!0;else{if(b=b/v+2|0,c=0,T==1){for(m=0,M=M[0],b++;(c<S||m)&&b--;c++)E=m*l+(R[c]||0),N[c]=E/M|0,m=E%M|0;h=m||c<S}else{for(m=l/(M[0]+1)|0,m>1&&(M=r(M,m,l),R=r(R,m,l),T=M.length,S=R.length),A=T,d=R.slice(0,T),w=d.length;w<T;)d[w++]=0;B=M.slice(),B.unshift(0),D=M[0],M[1]>=l/2&&++D;do m=0,u=e(M,d,T,w),u<0?(x=d[0],T!=w&&(x=x*l+(d[1]||0)),m=x/D|0,m>1?(m>=l&&(m=l-1),p=r(M,m,l),g=p.length,w=d.length,u=e(p,d,g,w),u==1&&(m--,t(p,T<g?B:M,g,l))):(m==0&&(u=m=1),p=M.slice()),g=p.length,g<w&&p.unshift(0),t(d,p,w,l),u==-1&&(w=d.length,u=e(M,d,T,w),u<1&&(m++,t(d,T<w?B:M,w,l))),w=d.length):u===0&&(m++,d=[0]),N[c++]=m,u&&d[0]?d[w++]=R[A]||0:(d=[R[A]],w=1);while((A++<S||d[0]!==void 0)&&b--);h=d[0]!==void 0}N[0]||N.shift()}if(v==1)y.e=s,Bl=h;else{for(c=1,m=N[0];m>=10;m/=10)c++;y.e=c+s*v-1,Pe(y,f?i+y.e+1:i,o,h)}return y}}();function Pe(r,e,t,a){var n,i,o,f,l,u,s,c,m,v=r.constructor;e:if(e!=null){if(c=r.d,!c)return r;for(n=1,f=c[0];f>=10;f/=10)n++;if(i=e-n,i<0)i+=He,o=e,s=c[m=0],l=s/Or(10,n-o-1)%10|0;else if(m=Math.ceil((i+1)/He),f=c.length,m>=f)if(a){for(;f++<=m;)c.push(0);s=l=0,n=1,i%=He,o=i-He+1}else break e;else{for(s=f=c[m],n=1;f>=10;f/=10)n++;i%=He,o=i-He+n,l=o<0?0:s/Or(10,n-o-1)%10|0}if(a=a||e<0||c[m+1]!==void 0||(o<0?s:s%Or(10,n-o-1)),u=t<4?(l||a)&&(t==0||t==(r.s<0?3:2)):l>5||l==5&&(t==4||a||t==6&&(i>0?o>0?s/Or(10,n-o):0:c[m-1])%10&1||t==(r.s<0?8:7)),e<1||!c[0])return c.length=0,u?(e-=r.e+1,c[0]=Or(10,(He-e%He)%He),r.e=-e||0):c[0]=r.e=0,r;if(i==0?(c.length=m,f=1,m--):(c.length=m+1,f=Or(10,He-i),c[m]=o>0?(s/Or(10,n-o)%Or(10,o)|0)*f:0),u)for(;;)if(m==0){for(i=1,o=c[0];o>=10;o/=10)i++;for(o=c[0]+=f,f=1;o>=10;o/=10)f++;i!=f&&(r.e++,c[0]==gt&&(c[0]=1));break}else{if(c[m]+=f,c[m]!=gt)break;c[m--]=0,f=1}for(i=c.length;c[--i]===0;)c.pop()}return Xe&&(r.e>v.maxE?(r.d=null,r.e=NaN):r.e<v.minE&&(r.e=0,r.d=[0])),r}function Tt(r,e,t){if(!r.isFinite())return Ul(r);var a,n=r.e,i=Pr(r.d),o=i.length;return e?(t&&(a=t-o)>0?i=i.charAt(0)+"."+i.slice(1)+un(a):o>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(r.e<0?"e":"e+")+r.e):n<0?(i="0."+un(-n-1)+i,t&&(a=t-o)>0&&(i+=un(a))):n>=o?(i+=un(n+1-o),t&&(a=t-n-1)>0&&(i=i+"."+un(a))):((a=n+1)<o&&(i=i.slice(0,a)+"."+i.slice(a)),t&&(a=t-o)>0&&(n+1===o&&(i+="."),i+=un(a))),i}function Di(r,e){var t=r[0];for(e*=He;t>=10;t/=10)e++;return e}function Ai(r,e,t){if(e>Ug)throw Xe=!0,t&&(r.precision=t),Error($l);return Pe(new r(bi),e,1,!0)}function yt(r,e,t){if(e>ts)throw Error($l);return Pe(new r(xi),e,t,!0)}function _l(r){var e=r.length-1,t=e*He+1;if(e=r[e],e){for(;e%10==0;e/=10)t--;for(e=r[0];e>=10;e/=10)t++}return t}function un(r){for(var e="";r--;)e+="0";return e}function ql(r,e,t,a){var n,i=new r(1),o=Math.ceil(a/He+4);for(Xe=!1;;){if(t%2&&(i=i.times(e),kl(i.d,o)&&(n=!0)),t=Gr(t/2),t===0){t=i.d.length-1,n&&i.d[t]===0&&++i.d[t];break}e=e.times(e),kl(e.d,o)}return Xe=!0,i}function zl(r){return r.d[r.d.length-1]&1}function Pl(r,e,t){for(var a,n=new r(e[0]),i=0;++i<e.length;)if(a=new r(e[i]),a.s)n[t](a)&&(n=a);else{n=a;break}return n}function ns(r,e){var t,a,n,i,o,f,l,u=0,s=0,c=0,m=r.constructor,v=m.rounding,h=m.precision;if(!r.d||!r.d[0]||r.e>17)return new m(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:0/0);for(e==null?(Xe=!1,l=h):l=e,f=new m(.03125);r.e>-2;)r=r.times(f),c+=5;for(a=Math.log(Or(2,c))/Math.LN10*2+5|0,l+=a,t=i=o=new m(1),m.precision=l;;){if(i=Pe(i.times(r),l,1),t=t.times(++s),f=o.plus(gr(i,t,l,1)),Pr(f.d).slice(0,l)===Pr(o.d).slice(0,l)){for(n=c;n--;)o=Pe(o.times(o),l,1);if(e==null)if(u<3&&ka(o.d,l-a,v,u))m.precision=l+=10,t=i=f=new m(1),s=0,u++;else return Pe(o,m.precision=h,v,Xe=!0);else return m.precision=h,o}o=f}}function ln(r,e){var t,a,n,i,o,f,l,u,s,c,m,v=1,h=10,p=r,g=p.d,y=p.constructor,N=y.rounding,d=y.precision;if(p.s<0||!g||!g[0]||!p.e&&g[0]==1&&g.length==1)return new y(g&&!g[0]?-1/0:p.s!=1?NaN:g?0:p);if(e==null?(Xe=!1,s=d):s=e,y.precision=s+=h,t=Pr(g),a=t.charAt(0),Math.abs(i=p.e)<15e14){for(;a<7&&a!=1||a==1&&t.charAt(1)>3;)p=p.times(r),t=Pr(p.d),a=t.charAt(0),v++;i=p.e,a>1?(p=new y("0."+t),i++):p=new y(a+"."+t.slice(1))}else return u=Ai(y,s+2,d).times(i+""),p=ln(new y(a+"."+t.slice(1)),s-h).plus(u),y.precision=d,e==null?Pe(p,d,N,Xe=!0):p;for(c=p,l=o=p=gr(p.minus(1),p.plus(1),s,1),m=Pe(p.times(p),s,1),n=3;;){if(o=Pe(o.times(m),s,1),u=l.plus(gr(o,new y(n),s,1)),Pr(u.d).slice(0,s)===Pr(l.d).slice(0,s))if(l=l.times(2),i!==0&&(l=l.plus(Ai(y,s+2,d).times(i+""))),l=gr(l,new y(v),s,1),e==null)if(ka(l.d,s-h,N,f))y.precision=s+=h,u=o=p=gr(c.minus(1),c.plus(1),s,1),m=Pe(p.times(p),s,1),n=f=1;else return Pe(l,y.precision=d,N,Xe=!0);else return y.precision=d,l;l=u,n+=2}}function Ul(r){return String(r.s*r.s/0)}function as(r,e){var t,a,n;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(a=e.search(/e/i))>0?(t<0&&(t=a),t+=+e.slice(a+1),e=e.substring(0,a)):t<0&&(t=e.length),a=0;e.charCodeAt(a)===48;a++);for(n=e.length;e.charCodeAt(n-1)===48;--n);if(e=e.slice(a,n),e){if(n-=a,r.e=t=t-a-1,r.d=[],a=(t+1)%He,t<0&&(a+=He),a<n){for(a&&r.d.push(+e.slice(0,a)),n-=He;a<n;)r.d.push(+e.slice(a,a+=He));e=e.slice(a),a=He-e.length}else a-=n;for(;a--;)e+="0";r.d.push(+e),Xe&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}function kg(r,e){var t,a,n,i,o,f,l,u,s;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Rl.test(e))return as(r,e)}else if(e==="Infinity"||e==="NaN")return+e||(r.s=NaN),r.e=NaN,r.d=null,r;if(qg.test(e))t=16,e=e.toLowerCase();else if(_g.test(e))t=2;else if(zg.test(e))t=8;else throw Error(sn+e);for(i=e.search(/p/i),i>0?(l=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),o=i>=0,a=r.constructor,o&&(e=e.replace(".",""),f=e.length,i=f-i,n=ql(a,new a(t),i,i*2)),u=Ni(e,t,gt),s=u.length-1,i=s;u[i]===0;--i)u.pop();return i<0?new a(r.s*0):(r.e=Di(u,s),r.d=u,Xe=!1,o&&(r=gr(r,n,f*4)),l&&(r=r.times(Math.abs(l)<54?Or(2,l):cn.pow(2,l))),Xe=!0,r)}function Vg(r,e){var t,a=e.d.length;if(a<3)return e.isZero()?e:na(r,2,e,e);t=1.4*Math.sqrt(a),t=t>16?16:t|0,e=e.times(1/Ei(5,t)),e=na(r,2,e,e);for(var n,i=new r(5),o=new r(16),f=new r(20);t--;)n=e.times(e),e=e.times(i.plus(n.times(o.times(n).minus(f))));return e}function na(r,e,t,a,n){var i,o,f,l,u=r.precision,s=Math.ceil(u/He);for(Xe=!1,l=t.times(t),f=new r(a);;){if(o=gr(f.times(l),new r(e++*e++),u,1),f=n?a.plus(o):a.minus(o),a=gr(o.times(l),new r(e++*e++),u,1),o=f.plus(a),o.d[s]!==void 0){for(i=s;o.d[i]===f.d[i]&&i--;);if(i==-1)break}i=f,f=a,a=o,o=i}return Xe=!0,o.d.length=s+1,o}function Ei(r,e){for(var t=r;--e;)t*=r;return t}function Ll(r,e){var t,a=e.s<0,n=yt(r,r.precision,1),i=n.times(.5);if(e=e.abs(),e.lte(i))return Zt=a?4:1,e;if(t=e.divToInt(n),t.isZero())Zt=a?3:2;else{if(e=e.minus(t.times(n)),e.lte(i))return Zt=zl(t)?a?2:3:a?4:1,e;Zt=zl(t)?a?1:4:a?3:2}return e.minus(n).abs()}function is(r,e,t,a){var n,i,o,f,l,u,s,c,m,v=r.constructor,h=t!==void 0;if(h?(et(t,1,on),a===void 0?a=v.rounding:et(a,0,8)):(t=v.precision,a=v.rounding),!r.isFinite())s=Ul(r);else{for(s=Tt(r),o=s.indexOf("."),h?(n=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):n=e,o>=0&&(s=s.replace(".",""),m=new v(1),m.e=s.length-o,m.d=Ni(Tt(m),10,n),m.e=m.d.length),c=Ni(s,10,n),i=l=c.length;c[--l]==0;)c.pop();if(!c[0])s=h?"0p+0":"0";else{if(o<0?i--:(r=new v(r),r.d=c,r.e=i,r=gr(r,m,t,a,0,n),c=r.d,i=r.e,u=Bl),o=c[t],f=n/2,u=u||c[t+1]!==void 0,u=a<4?(o!==void 0||u)&&(a===0||a===(r.s<0?3:2)):o>f||o===f&&(a===4||u||a===6&&c[t-1]&1||a===(r.s<0?8:7)),c.length=t,u)for(;++c[--t]>n-1;)c[t]=0,t||(++i,c.unshift(1));for(l=c.length;!c[l-1];--l);for(o=0,s="";o<l;o++)s+=es.charAt(c[o]);if(h){if(l>1)if(e==16||e==8){for(o=e==16?4:3,--l;l%o;l++)s+="0";for(c=Ni(s,n,e),l=c.length;!c[l-1];--l);for(o=1,s="1.";o<l;o++)s+=es.charAt(c[o])}else s=s.charAt(0)+"."+s.slice(1);s=s+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)s="0"+s;s="0."+s}else if(++i>l)for(i-=l;i--;)s+="0";else i<l&&(s=s.slice(0,i)+"."+s.slice(i))}s=(e==16?"0x":e==2?"0b":e==8?"0o":"")+s}return r.s<0?"-"+s:s}function kl(r,e){if(r.length>e)return r.length=e,!0}function Gg(r){return new this(r).abs()}function Hg(r){return new this(r).acos()}function Zg(r){return new this(r).acosh()}function Jg(r,e){return new this(r).plus(e)}function Xg(r){return new this(r).asin()}function Wg(r){return new this(r).asinh()}function Yg(r){return new this(r).atan()}function Qg(r){return new this(r).atanh()}function Kg(r,e){r=new this(r),e=new this(e);var t,a=this.precision,n=this.rounding,i=a+4;return!r.s||!e.s?t=new this(NaN):!r.d&&!e.d?(t=yt(this,i,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?yt(this,a,n):new this(0),t.s=r.s):!r.d||e.isZero()?(t=yt(this,i,1).times(.5),t.s=r.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(gr(r,e,i,1)),e=yt(this,i,1),this.precision=a,this.rounding=n,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(gr(r,e,i,1)),t}function jg(r){return new this(r).cbrt()}function e1(r){return Pe(r=new this(r),r.e+1,2)}function r1(r,e,t){return new this(r).clamp(e,t)}function t1(r){if(!r||typeof r!="object")throw Error(wi+"Object expected");var e,t,a,n=r.defaults===!0,i=["precision",1,on,"rounding",0,8,"toExpNeg",-ta,0,"toExpPos",0,ta,"maxE",0,ta,"minE",-ta,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],n&&(this[t]=rs[t]),(a=r[t])!==void 0)if(Gr(a)===a&&a>=i[e+1]&&a<=i[e+2])this[t]=a;else throw Error(sn+t+": "+a);if(t="crypto",n&&(this[t]=rs[t]),(a=r[t])!==void 0)if(a===!0||a===!1||a===0||a===1)if(a)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Ol);else this[t]=!1;else throw Error(sn+t+": "+a);return this}function n1(r){return new this(r).cos()}function a1(r){return new this(r).cosh()}function Vl(r){var e,t,a;function n(i){var o,f,l,u=this;if(!(u instanceof n))return new n(i);if(u.constructor=n,Gl(i)){u.s=i.s,Xe?!i.d||i.e>n.maxE?(u.e=NaN,u.d=null):i.e<n.minE?(u.e=0,u.d=[0]):(u.e=i.e,u.d=i.d.slice()):(u.e=i.e,u.d=i.d?i.d.slice():i.d);return}if(l=typeof i,l==="number"){if(i===0){u.s=1/i<0?-1:1,u.e=0,u.d=[0];return}if(i<0?(i=-i,u.s=-1):u.s=1,i===~~i&&i<1e7){for(o=0,f=i;f>=10;f/=10)o++;Xe?o>n.maxE?(u.e=NaN,u.d=null):o<n.minE?(u.e=0,u.d=[0]):(u.e=o,u.d=[i]):(u.e=o,u.d=[i]);return}else if(i*0!==0){i||(u.s=NaN),u.e=NaN,u.d=null;return}return as(u,i.toString())}else if(l!=="string")throw Error(sn+i);return(f=i.charCodeAt(0))===45?(i=i.slice(1),u.s=-1):(f===43&&(i=i.slice(1)),u.s=1),Rl.test(i)?as(u,i):kg(u,i)}if(n.prototype=xe,n.ROUND_UP=0,n.ROUND_DOWN=1,n.ROUND_CEIL=2,n.ROUND_FLOOR=3,n.ROUND_HALF_UP=4,n.ROUND_HALF_DOWN=5,n.ROUND_HALF_EVEN=6,n.ROUND_HALF_CEIL=7,n.ROUND_HALF_FLOOR=8,n.EUCLID=9,n.config=n.set=t1,n.clone=Vl,n.isDecimal=Gl,n.abs=Gg,n.acos=Hg,n.acosh=Zg,n.add=Jg,n.asin=Xg,n.asinh=Wg,n.atan=Yg,n.atanh=Qg,n.atan2=Kg,n.cbrt=jg,n.ceil=e1,n.clamp=r1,n.cos=n1,n.cosh=a1,n.div=i1,n.exp=o1,n.floor=s1,n.hypot=u1,n.ln=l1,n.log=c1,n.log10=m1,n.log2=f1,n.max=v1,n.min=p1,n.mod=h1,n.mul=d1,n.pow=g1,n.random=y1,n.round=b1,n.sign=x1,n.sin=w1,n.sinh=N1,n.sqrt=D1,n.sub=A1,n.sum=E1,n.tan=S1,n.tanh=C1,n.trunc=M1,r===void 0&&(r={}),r&&r.defaults!==!0)for(a=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<a.length;)r.hasOwnProperty(t=a[e++])||(r[t]=this[t]);return n.config(r),n}function i1(r,e){return new this(r).div(e)}function o1(r){return new this(r).exp()}function s1(r){return Pe(r=new this(r),r.e+1,3)}function u1(){var r,e,t=new this(0);for(Xe=!1,r=0;r<arguments.length;)if(e=new this(arguments[r++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return Xe=!0,new this(1/0);t=e}return Xe=!0,t.sqrt()}function Gl(r){return r instanceof cn||r&&r.toStringTag===Il||!1}function l1(r){return new this(r).ln()}function c1(r,e){return new this(r).log(e)}function f1(r){return new this(r).log(2)}function m1(r){return new this(r).log(10)}function v1(){return Pl(this,arguments,"lt")}function p1(){return Pl(this,arguments,"gt")}function h1(r,e){return new this(r).mod(e)}function d1(r,e){return new this(r).mul(e)}function g1(r,e){return new this(r).pow(e)}function y1(r){var e,t,a,n,i=0,o=new this(1),f=[];if(r===void 0?r=this.precision:et(r,1,on),a=Math.ceil(r/He),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(a));i<a;)n=e[i],n>=429e7?e[i]=crypto.getRandomValues(new Uint32Array(1))[0]:f[i++]=n%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(a*=4);i<a;)n=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+((e[i+3]&127)<<24),n>=214e7?crypto.randomBytes(4).copy(e,i):(f.push(n%1e7),i+=4);i=a/4}else throw Error(Ol);else for(;i<a;)f[i++]=Math.random()*1e7|0;for(a=f[--i],r%=He,a&&r&&(n=Or(10,He-r),f[i]=(a/n|0)*n);f[i]===0;i--)f.pop();if(i<0)t=0,f=[0];else{for(t=-1;f[0]===0;t-=He)f.shift();for(a=1,n=f[0];n>=10;n/=10)a++;a<He&&(t-=He-a)}return o.e=t,o.d=f,o}function b1(r){return Pe(r=new this(r),r.e+1,this.rounding)}function x1(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function w1(r){return new this(r).sin()}function N1(r){return new this(r).sinh()}function D1(r){return new this(r).sqrt()}function A1(r,e){return new this(r).sub(e)}function E1(){var r=0,e=arguments,t=new this(e[r]);for(Xe=!1;t.s&&++r<e.length;)t=t.plus(e[r]);return Xe=!0,Pe(t,this.precision,this.rounding)}function S1(r){return new this(r).tan()}function C1(r){return new this(r).tanh()}function M1(r){return Pe(r=new this(r),r.e+1,1)}xe[Symbol.for("nodejs.util.inspect.custom")]=xe.toString,xe[Symbol.toStringTag]="Decimal";var cn=xe.constructor=Vl(rs);bi=new cn(bi),xi=new cn(xi);var F1="BigNumber",T1=["?on","config"],B1=q(F1,T1,r=>{var{on:e,config:t}=r,a=cn.clone({precision:t.precision,modulo:cn.EUCLID});return a.prototype=Object.create(a.prototype),a.prototype.type="BigNumber",a.prototype.isBigNumber=!0,a.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},a.fromJSON=function(n){return new a(n.value)},e&&e("config",function(n,i){n.precision!==i.precision&&a.config({precision:n.precision})}),a},{isClass:!0}),Mn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Hl(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function $1(r){var e=r.default;if(typeof e=="function"){var t=function(){return e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(a){var n=Object.getOwnPropertyDescriptor(r,a);Object.defineProperty(t,a,n.get?n:{enumerable:!0,get:function(){return r[a]}})}),t}var Zl={exports:{}};/**
|
|
16
16
|
* @license Complex.js v2.1.1 12/05/2020
|
|
17
17
|
*
|
|
18
18
|
* Copyright (c) 2020, Robert Eisele (robert@xarg.org)
|
|
19
19
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
20
20
|
**/(function(r,e){(function(t){var a=Math.cosh||function(c){return Math.abs(c)<1e-9?1-c:(Math.exp(c)+Math.exp(-c))*.5},n=Math.sinh||function(c){return Math.abs(c)<1e-9?c:(Math.exp(c)-Math.exp(-c))*.5},i=function(c){var m=Math.PI/4;if(-m>c||c>m)return Math.cos(c)-1;var v=c*c;return v*(v*(v*(v*(v*(v*(v*(v/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},o=function(c,m){var v=Math.abs(c),h=Math.abs(m);return v<3e3&&h<3e3?Math.sqrt(v*v+h*h):(v<h?(v=h,h=c/m):h=m/c,v*Math.sqrt(1+h*h))},f=function(){throw SyntaxError("Invalid Param")};function l(c,m){var v=Math.abs(c),h=Math.abs(m);return c===0?Math.log(h):m===0?Math.log(v):v<3e3&&h<3e3?Math.log(c*c+m*m)*.5:(c=c/2,m=m/2,.5*Math.log(c*c+m*m)+Math.LN2)}var u=function(c,m){var v={re:0,im:0};if(c==null)v.re=v.im=0;else if(m!==void 0)v.re=c,v.im=m;else switch(typeof c){case"object":if("im"in c&&"re"in c)v.re=c.re,v.im=c.im;else if("abs"in c&&"arg"in c){if(!Number.isFinite(c.abs)&&Number.isFinite(c.arg))return s.INFINITY;v.re=c.abs*Math.cos(c.arg),v.im=c.abs*Math.sin(c.arg)}else if("r"in c&&"phi"in c){if(!Number.isFinite(c.r)&&Number.isFinite(c.phi))return s.INFINITY;v.re=c.r*Math.cos(c.phi),v.im=c.r*Math.sin(c.phi)}else c.length===2?(v.re=c[0],v.im=c[1]):f();break;case"string":v.im=v.re=0;var h=c.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),p=1,g=0;h===null&&f();for(var y=0;y<h.length;y++){var N=h[y];N===" "||N===" "||N===`
|
|
21
|
-
`||(N==="+"?p++:N==="-"?g++:N==="i"||N==="I"?(p+g===0&&f(),h[y+1]!==" "&&!isNaN(h[y+1])?(v.im+=parseFloat((g%2?"-":"")+h[y+1]),y++):v.im+=parseFloat((g%2?"-":"")+"1"),p=g=0):((p+g===0||isNaN(N))&&f(),h[y+1]==="i"||h[y+1]==="I"?(v.im+=parseFloat((g%2?"-":"")+N),y++):v.re+=parseFloat((g%2?"-":"")+N),p=g=0))}p+g>0&&f();break;case"number":v.im=0,v.re=c;break;default:f()}return isNaN(v.re)||isNaN(v.im),v};function s(c,m){if(!(this instanceof s))return new s(c,m);var v=u(c,m);this.re=v.re,this.im=v.im}s.prototype={re:0,im:0,sign:function(){var c=this.abs();return new s(this.re/c,this.im/c)},add:function(c,m){var v=new s(c,m);return this.isInfinite()&&v.isInfinite()?s.NAN:this.isInfinite()||v.isInfinite()?s.INFINITY:new s(this.re+v.re,this.im+v.im)},sub:function(c,m){var v=new s(c,m);return this.isInfinite()&&v.isInfinite()?s.NAN:this.isInfinite()||v.isInfinite()?s.INFINITY:new s(this.re-v.re,this.im-v.im)},mul:function(c,m){var v=new s(c,m);return this.isInfinite()&&v.isZero()||this.isZero()&&v.isInfinite()?s.NAN:this.isInfinite()||v.isInfinite()?s.INFINITY:v.im===0&&this.im===0?new s(this.re*v.re,0):new s(this.re*v.re-this.im*v.im,this.re*v.im+this.im*v.re)},div:function(c,m){var v=new s(c,m);if(this.isZero()&&v.isZero()||this.isInfinite()&&v.isInfinite())return s.NAN;if(this.isInfinite()||v.isZero())return s.INFINITY;if(this.isZero()||v.isInfinite())return s.ZERO;c=this.re,m=this.im;var h=v.re,p=v.im,g,y;return p===0?new s(c/h,m/h):Math.abs(h)<Math.abs(p)?(y=h/p,g=h*y+p,new s((c*y+m)/g,(m*y-c)/g)):(y=p/h,g=p*y+h,new s((c+m*y)/g,(m-c*y)/g))},pow:function(c,m){var v=new s(c,m);if(c=this.re,m=this.im,v.isZero())return s.ONE;if(v.im===0){if(m===0&&c>0)return new s(Math.pow(c,v.re),0);if(c===0)switch((v.re%4+4)%4){case 0:return new s(Math.pow(m,v.re),0);case 1:return new s(0,Math.pow(m,v.re));case 2:return new s(-Math.pow(m,v.re),0);case 3:return new s(0,-Math.pow(m,v.re))}}if(c===0&&m===0&&v.re>0&&v.im>=0)return s.ZERO;var h=Math.atan2(m,c),p=l(c,m);return c=Math.exp(v.re*p-v.im*h),m=v.im*p+v.re*h,new s(c*Math.cos(m),c*Math.sin(m))},sqrt:function(){var c=this.re,m=this.im,v=this.abs(),h,p;if(c>=0){if(m===0)return new s(Math.sqrt(c),0);h=.5*Math.sqrt(2*(v+c))}else h=Math.abs(m)/Math.sqrt(2*(v-c));return c<=0?p=.5*Math.sqrt(2*(v-c)):p=Math.abs(m)/Math.sqrt(2*(v+c)),new s(h,m<0?-p:p)},exp:function(){var c=Math.exp(this.re);return this.im,new s(c*Math.cos(this.im),c*Math.sin(this.im))},expm1:function(){var c=this.re,m=this.im;return new s(Math.expm1(c)*Math.cos(m)+i(m),Math.exp(c)*Math.sin(m))},log:function(){var c=this.re,m=this.im;return new s(l(c,m),Math.atan2(m,c))},abs:function(){return o(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var c=this.re,m=this.im;return new s(Math.sin(c)*a(m),Math.cos(c)*n(m))},cos:function(){var c=this.re,m=this.im;return new s(Math.cos(c)*a(m),-Math.sin(c)*n(m))},tan:function(){var c=2*this.re,m=2*this.im,v=Math.cos(c)+a(m);return new s(Math.sin(c)/v,n(m)/v)},cot:function(){var c=2*this.re,m=2*this.im,v=Math.cos(c)-a(m);return new s(-Math.sin(c)/v,n(m)/v)},sec:function(){var c=this.re,m=this.im,v=.5*a(2*m)+.5*Math.cos(2*c);return new s(Math.cos(c)*a(m)/v,Math.sin(c)*n(m)/v)},csc:function(){var c=this.re,m=this.im,v=.5*a(2*m)-.5*Math.cos(2*c);return new s(Math.sin(c)*a(m)/v,-Math.cos(c)*n(m)/v)},asin:function(){var c=this.re,m=this.im,v=new s(m*m-c*c+1,-2*c*m).sqrt(),h=new s(v.re-m,v.im+c).log();return new s(h.im,-h.re)},acos:function(){var c=this.re,m=this.im,v=new s(m*m-c*c+1,-2*c*m).sqrt(),h=new s(v.re-m,v.im+c).log();return new s(Math.PI/2-h.im,h.re)},atan:function(){var c=this.re,m=this.im;if(c===0){if(m===1)return new s(0,1/0);if(m===-1)return new s(0,-1/0)}var v=c*c+(1-m)*(1-m),h=new s((1-m*m-c*c)/v,-2*c/v).log();return new s(-.5*h.im,.5*h.re)},acot:function(){var c=this.re,m=this.im;if(m===0)return new s(Math.atan2(1,c),0);var v=c*c+m*m;return v!==0?new s(c/v,-m/v).atan():new s(c!==0?c/0:0,m!==0?-m/0:0).atan()},asec:function(){var c=this.re,m=this.im;if(c===0&&m===0)return new s(0,1/0);var v=c*c+m*m;return v!==0?new s(c/v,-m/v).acos():new s(c!==0?c/0:0,m!==0?-m/0:0).acos()},acsc:function(){var c=this.re,m=this.im;if(c===0&&m===0)return new s(Math.PI/2,1/0);var v=c*c+m*m;return v!==0?new s(c/v,-m/v).asin():new s(c!==0?c/0:0,m!==0?-m/0:0).asin()},sinh:function(){var c=this.re,m=this.im;return new s(n(c)*Math.cos(m),a(c)*Math.sin(m))},cosh:function(){var c=this.re,m=this.im;return new s(a(c)*Math.cos(m),n(c)*Math.sin(m))},tanh:function(){var c=2*this.re,m=2*this.im,v=a(c)+Math.cos(m);return new s(n(c)/v,Math.sin(m)/v)},coth:function(){var c=2*this.re,m=2*this.im,v=a(c)-Math.cos(m);return new s(n(c)/v,-Math.sin(m)/v)},csch:function(){var c=this.re,m=this.im,v=Math.cos(2*m)-a(2*c);return new s(-2*n(c)*Math.cos(m)/v,2*a(c)*Math.sin(m)/v)},sech:function(){var c=this.re,m=this.im,v=Math.cos(2*m)+a(2*c);return new s(2*a(c)*Math.cos(m)/v,-2*n(c)*Math.sin(m)/v)},asinh:function(){var c=this.im;this.im=-this.re,this.re=c;var m=this.asin();return this.re=-this.im,this.im=c,c=m.re,m.re=-m.im,m.im=c,m},acosh:function(){var c=this.acos();if(c.im<=0){var m=c.re;c.re=-c.im,c.im=m}else{var m=c.im;c.im=-c.re,c.re=m}return c},atanh:function(){var c=this.re,m=this.im,v=c>1&&m===0,h=1-c,p=1+c,g=h*h+m*m,y=g!==0?new s((p*h-m*m)/g,(m*h+p*m)/g):new s(c!==-1?c/0:0,m!==0?m/0:0),N=y.re;return y.re=l(y.re,y.im)/2,y.im=Math.atan2(y.im,N)/2,v&&(y.im=-y.im),y},acoth:function(){var c=this.re,m=this.im;if(c===0&&m===0)return new s(0,Math.PI/2);var v=c*c+m*m;return v!==0?new s(c/v,-m/v).atanh():new s(c!==0?c/0:0,m!==0?-m/0:0).atanh()},acsch:function(){var c=this.re,m=this.im;if(m===0)return new s(c!==0?Math.log(c+Math.sqrt(c*c+1)):1/0,0);var v=c*c+m*m;return v!==0?new s(c/v,-m/v).asinh():new s(c!==0?c/0:0,m!==0?-m/0:0).asinh()},asech:function(){var c=this.re,m=this.im;if(this.isZero())return s.INFINITY;var v=c*c+m*m;return v!==0?new s(c/v,-m/v).acosh():new s(c!==0?c/0:0,m!==0?-m/0:0).acosh()},inverse:function(){if(this.isZero())return s.INFINITY;if(this.isInfinite())return s.ZERO;var c=this.re,m=this.im,v=c*c+m*m;return new s(c/v,-m/v)},conjugate:function(){return new s(this.re,-this.im)},neg:function(){return new s(-this.re,-this.im)},ceil:function(c){return c=Math.pow(10,c||0),new s(Math.ceil(this.re*c)/c,Math.ceil(this.im*c)/c)},floor:function(c){return c=Math.pow(10,c||0),new s(Math.floor(this.re*c)/c,Math.floor(this.im*c)/c)},round:function(c){return c=Math.pow(10,c||0),new s(Math.round(this.re*c)/c,Math.round(this.im*c)/c)},equals:function(c,m){var v=new s(c,m);return Math.abs(v.re-this.re)<=s.EPSILON&&Math.abs(v.im-this.im)<=s.EPSILON},clone:function(){return new s(this.re,this.im)},toString:function(){var c=this.re,m=this.im,v="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(c)<s.EPSILON&&(c=0),Math.abs(m)<s.EPSILON&&(m=0),m===0?v+c:(c!==0?(v+=c,v+=" ",m<0?(m=-m,v+="-"):v+="+",v+=" "):m<0&&(m=-m,v+="-"),m!==1&&(v+=m),v+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return this.im===0?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return this.im===0&&this.re===0},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!(this.isNaN()||this.isFinite())}},s.ZERO=new s(0,0),s.ONE=new s(1,0),s.I=new s(0,1),s.PI=new s(Math.PI,0),s.E=new s(Math.E,0),s.INFINITY=new s(1/0,1/0),s.NAN=new s(NaN,NaN),s.EPSILON=1e-15,Object.defineProperty(s,"__esModule",{value:!0}),s.default=s,s.Complex=s,r.exports=s})()})(
|
|
21
|
+
`||(N==="+"?p++:N==="-"?g++:N==="i"||N==="I"?(p+g===0&&f(),h[y+1]!==" "&&!isNaN(h[y+1])?(v.im+=parseFloat((g%2?"-":"")+h[y+1]),y++):v.im+=parseFloat((g%2?"-":"")+"1"),p=g=0):((p+g===0||isNaN(N))&&f(),h[y+1]==="i"||h[y+1]==="I"?(v.im+=parseFloat((g%2?"-":"")+N),y++):v.re+=parseFloat((g%2?"-":"")+N),p=g=0))}p+g>0&&f();break;case"number":v.im=0,v.re=c;break;default:f()}return isNaN(v.re)||isNaN(v.im),v};function s(c,m){if(!(this instanceof s))return new s(c,m);var v=u(c,m);this.re=v.re,this.im=v.im}s.prototype={re:0,im:0,sign:function(){var c=this.abs();return new s(this.re/c,this.im/c)},add:function(c,m){var v=new s(c,m);return this.isInfinite()&&v.isInfinite()?s.NAN:this.isInfinite()||v.isInfinite()?s.INFINITY:new s(this.re+v.re,this.im+v.im)},sub:function(c,m){var v=new s(c,m);return this.isInfinite()&&v.isInfinite()?s.NAN:this.isInfinite()||v.isInfinite()?s.INFINITY:new s(this.re-v.re,this.im-v.im)},mul:function(c,m){var v=new s(c,m);return this.isInfinite()&&v.isZero()||this.isZero()&&v.isInfinite()?s.NAN:this.isInfinite()||v.isInfinite()?s.INFINITY:v.im===0&&this.im===0?new s(this.re*v.re,0):new s(this.re*v.re-this.im*v.im,this.re*v.im+this.im*v.re)},div:function(c,m){var v=new s(c,m);if(this.isZero()&&v.isZero()||this.isInfinite()&&v.isInfinite())return s.NAN;if(this.isInfinite()||v.isZero())return s.INFINITY;if(this.isZero()||v.isInfinite())return s.ZERO;c=this.re,m=this.im;var h=v.re,p=v.im,g,y;return p===0?new s(c/h,m/h):Math.abs(h)<Math.abs(p)?(y=h/p,g=h*y+p,new s((c*y+m)/g,(m*y-c)/g)):(y=p/h,g=p*y+h,new s((c+m*y)/g,(m-c*y)/g))},pow:function(c,m){var v=new s(c,m);if(c=this.re,m=this.im,v.isZero())return s.ONE;if(v.im===0){if(m===0&&c>0)return new s(Math.pow(c,v.re),0);if(c===0)switch((v.re%4+4)%4){case 0:return new s(Math.pow(m,v.re),0);case 1:return new s(0,Math.pow(m,v.re));case 2:return new s(-Math.pow(m,v.re),0);case 3:return new s(0,-Math.pow(m,v.re))}}if(c===0&&m===0&&v.re>0&&v.im>=0)return s.ZERO;var h=Math.atan2(m,c),p=l(c,m);return c=Math.exp(v.re*p-v.im*h),m=v.im*p+v.re*h,new s(c*Math.cos(m),c*Math.sin(m))},sqrt:function(){var c=this.re,m=this.im,v=this.abs(),h,p;if(c>=0){if(m===0)return new s(Math.sqrt(c),0);h=.5*Math.sqrt(2*(v+c))}else h=Math.abs(m)/Math.sqrt(2*(v-c));return c<=0?p=.5*Math.sqrt(2*(v-c)):p=Math.abs(m)/Math.sqrt(2*(v+c)),new s(h,m<0?-p:p)},exp:function(){var c=Math.exp(this.re);return this.im,new s(c*Math.cos(this.im),c*Math.sin(this.im))},expm1:function(){var c=this.re,m=this.im;return new s(Math.expm1(c)*Math.cos(m)+i(m),Math.exp(c)*Math.sin(m))},log:function(){var c=this.re,m=this.im;return new s(l(c,m),Math.atan2(m,c))},abs:function(){return o(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var c=this.re,m=this.im;return new s(Math.sin(c)*a(m),Math.cos(c)*n(m))},cos:function(){var c=this.re,m=this.im;return new s(Math.cos(c)*a(m),-Math.sin(c)*n(m))},tan:function(){var c=2*this.re,m=2*this.im,v=Math.cos(c)+a(m);return new s(Math.sin(c)/v,n(m)/v)},cot:function(){var c=2*this.re,m=2*this.im,v=Math.cos(c)-a(m);return new s(-Math.sin(c)/v,n(m)/v)},sec:function(){var c=this.re,m=this.im,v=.5*a(2*m)+.5*Math.cos(2*c);return new s(Math.cos(c)*a(m)/v,Math.sin(c)*n(m)/v)},csc:function(){var c=this.re,m=this.im,v=.5*a(2*m)-.5*Math.cos(2*c);return new s(Math.sin(c)*a(m)/v,-Math.cos(c)*n(m)/v)},asin:function(){var c=this.re,m=this.im,v=new s(m*m-c*c+1,-2*c*m).sqrt(),h=new s(v.re-m,v.im+c).log();return new s(h.im,-h.re)},acos:function(){var c=this.re,m=this.im,v=new s(m*m-c*c+1,-2*c*m).sqrt(),h=new s(v.re-m,v.im+c).log();return new s(Math.PI/2-h.im,h.re)},atan:function(){var c=this.re,m=this.im;if(c===0){if(m===1)return new s(0,1/0);if(m===-1)return new s(0,-1/0)}var v=c*c+(1-m)*(1-m),h=new s((1-m*m-c*c)/v,-2*c/v).log();return new s(-.5*h.im,.5*h.re)},acot:function(){var c=this.re,m=this.im;if(m===0)return new s(Math.atan2(1,c),0);var v=c*c+m*m;return v!==0?new s(c/v,-m/v).atan():new s(c!==0?c/0:0,m!==0?-m/0:0).atan()},asec:function(){var c=this.re,m=this.im;if(c===0&&m===0)return new s(0,1/0);var v=c*c+m*m;return v!==0?new s(c/v,-m/v).acos():new s(c!==0?c/0:0,m!==0?-m/0:0).acos()},acsc:function(){var c=this.re,m=this.im;if(c===0&&m===0)return new s(Math.PI/2,1/0);var v=c*c+m*m;return v!==0?new s(c/v,-m/v).asin():new s(c!==0?c/0:0,m!==0?-m/0:0).asin()},sinh:function(){var c=this.re,m=this.im;return new s(n(c)*Math.cos(m),a(c)*Math.sin(m))},cosh:function(){var c=this.re,m=this.im;return new s(a(c)*Math.cos(m),n(c)*Math.sin(m))},tanh:function(){var c=2*this.re,m=2*this.im,v=a(c)+Math.cos(m);return new s(n(c)/v,Math.sin(m)/v)},coth:function(){var c=2*this.re,m=2*this.im,v=a(c)-Math.cos(m);return new s(n(c)/v,-Math.sin(m)/v)},csch:function(){var c=this.re,m=this.im,v=Math.cos(2*m)-a(2*c);return new s(-2*n(c)*Math.cos(m)/v,2*a(c)*Math.sin(m)/v)},sech:function(){var c=this.re,m=this.im,v=Math.cos(2*m)+a(2*c);return new s(2*a(c)*Math.cos(m)/v,-2*n(c)*Math.sin(m)/v)},asinh:function(){var c=this.im;this.im=-this.re,this.re=c;var m=this.asin();return this.re=-this.im,this.im=c,c=m.re,m.re=-m.im,m.im=c,m},acosh:function(){var c=this.acos();if(c.im<=0){var m=c.re;c.re=-c.im,c.im=m}else{var m=c.im;c.im=-c.re,c.re=m}return c},atanh:function(){var c=this.re,m=this.im,v=c>1&&m===0,h=1-c,p=1+c,g=h*h+m*m,y=g!==0?new s((p*h-m*m)/g,(m*h+p*m)/g):new s(c!==-1?c/0:0,m!==0?m/0:0),N=y.re;return y.re=l(y.re,y.im)/2,y.im=Math.atan2(y.im,N)/2,v&&(y.im=-y.im),y},acoth:function(){var c=this.re,m=this.im;if(c===0&&m===0)return new s(0,Math.PI/2);var v=c*c+m*m;return v!==0?new s(c/v,-m/v).atanh():new s(c!==0?c/0:0,m!==0?-m/0:0).atanh()},acsch:function(){var c=this.re,m=this.im;if(m===0)return new s(c!==0?Math.log(c+Math.sqrt(c*c+1)):1/0,0);var v=c*c+m*m;return v!==0?new s(c/v,-m/v).asinh():new s(c!==0?c/0:0,m!==0?-m/0:0).asinh()},asech:function(){var c=this.re,m=this.im;if(this.isZero())return s.INFINITY;var v=c*c+m*m;return v!==0?new s(c/v,-m/v).acosh():new s(c!==0?c/0:0,m!==0?-m/0:0).acosh()},inverse:function(){if(this.isZero())return s.INFINITY;if(this.isInfinite())return s.ZERO;var c=this.re,m=this.im,v=c*c+m*m;return new s(c/v,-m/v)},conjugate:function(){return new s(this.re,-this.im)},neg:function(){return new s(-this.re,-this.im)},ceil:function(c){return c=Math.pow(10,c||0),new s(Math.ceil(this.re*c)/c,Math.ceil(this.im*c)/c)},floor:function(c){return c=Math.pow(10,c||0),new s(Math.floor(this.re*c)/c,Math.floor(this.im*c)/c)},round:function(c){return c=Math.pow(10,c||0),new s(Math.round(this.re*c)/c,Math.round(this.im*c)/c)},equals:function(c,m){var v=new s(c,m);return Math.abs(v.re-this.re)<=s.EPSILON&&Math.abs(v.im-this.im)<=s.EPSILON},clone:function(){return new s(this.re,this.im)},toString:function(){var c=this.re,m=this.im,v="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(c)<s.EPSILON&&(c=0),Math.abs(m)<s.EPSILON&&(m=0),m===0?v+c:(c!==0?(v+=c,v+=" ",m<0?(m=-m,v+="-"):v+="+",v+=" "):m<0&&(m=-m,v+="-"),m!==1&&(v+=m),v+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return this.im===0?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return this.im===0&&this.re===0},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!(this.isNaN()||this.isFinite())}},s.ZERO=new s(0,0),s.ONE=new s(1,0),s.I=new s(0,1),s.PI=new s(Math.PI,0),s.E=new s(Math.E,0),s.INFINITY=new s(1/0,1/0),s.NAN=new s(NaN,NaN),s.EPSILON=1e-15,Object.defineProperty(s,"__esModule",{value:!0}),s.default=s,s.Complex=s,r.exports=s})()})(Zl);const Ur=Hl(Zl.exports);var O1="Complex",I1=[],R1=q(O1,I1,()=>(Object.defineProperty(Ur,"name",{value:"Complex"}),Ur.prototype.constructor=Ur,Ur.prototype.type="Complex",Ur.prototype.isComplex=!0,Ur.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Ur.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Ur.prototype.format=function(r){var e="",t=this.im,a=this.re,n=Cn(this.re,r),i=Cn(this.im,r),o=tr(r)?r:r?r.precision:null;if(o!==null){var f=Math.pow(10,-o);Math.abs(a/t)<f&&(a=0),Math.abs(t/a)<f&&(t=0)}return t===0?e=n:a===0?t===1?e="i":t===-1?e="-i":e=i+"i":t<0?t===-1?e=n+" - i":e=n+" - "+i.substring(1)+"i":t===1?e=n+" + i":e=n+" + "+i+"i",e},Ur.fromPolar=function(r){switch(arguments.length){case 1:{var e=arguments[0];if(typeof e=="object")return Ur(e);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var t=arguments[0],a=arguments[1];if(tr(t)){if(Vt(a)&&a.hasBase("ANGLE")&&(a=a.toNumber("rad")),tr(a))return new Ur({r:t,phi:a});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")}},Ur.prototype.valueOf=Ur.prototype.toString,Ur.fromJSON=function(r){return new Ur(r)},Ur.compare=function(r,e){return r.re>e.re?1:r.re<e.re?-1:r.im>e.im?1:r.im<e.im?-1:0},Ur),{isClass:!0}),Jl={exports:{}};/**
|
|
22
22
|
* @license Fraction.js v4.2.0 05/03/2022
|
|
23
23
|
* https://www.xarg.org/2014/03/rational-numbers-in-javascript/
|
|
24
24
|
*
|
|
25
25
|
* Copyright (c) 2021, Robert Eisele (robert@xarg.org)
|
|
26
26
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
27
|
-
**/(function(r,e){(function(t){var a=2e3,n={s:1,n:0,d:1};function i(h,p){if(isNaN(h=parseInt(h,10)))throw v.InvalidParameter;return h*p}function o(h,p){if(p===0)throw v.DivisionByZero;var g=Object.create(v.prototype);g.s=h<0?-1:1,h=h<0?-h:h;var y=m(h,p);return g.n=h/y,g.d=p/y,g}function f(h){for(var p={},g=h,y=2,N=4;N<=g;){for(;g%y===0;)g/=y,p[y]=(p[y]||0)+1;N+=1+2*y++}return g!==h?g>1&&(p[g]=(p[g]||0)+1):p[h]=(p[h]||0)+1,p}var l=function(h,p){var g=0,y=1,N=1,d=0,w=0,x=0,b=1,E=1,A=0,S=1,D=1,T=1,B=1e7,I;if(h!=null)if(p!==void 0){if(g=h,y=p,N=g*y,g%1!==0||y%1!==0)throw v.NonIntegerParameter}else switch(typeof h){case"object":{if("d"in h&&"n"in h)g=h.n,y=h.d,"s"in h&&(g*=h.s);else if(0 in h)g=h[0],1 in h&&(y=h[1]);else throw v.InvalidParameter;N=g*y;break}case"number":{if(h<0&&(N=h,h=-h),h%1===0)g=h;else if(h>0){for(h>=1&&(E=Math.pow(10,Math.floor(1+Math.log(h)/Math.LN10)),h/=E);S<=B&&T<=B;)if(I=(A+D)/(S+T),h===I){S+T<=B?(g=A+D,y=S+T):T>S?(g=D,y=T):(g=A,y=S);break}else h>I?(A+=D,S+=T):(D+=A,T+=S),S>B?(g=D,y=T):(g=A,y=S);g*=E}else(isNaN(h)||isNaN(p))&&(y=g=NaN);break}case"string":{if(S=h.match(/\d+|./g),S===null)throw v.InvalidParameter;if(S[A]==="-"?(N=-1,A++):S[A]==="+"&&A++,S.length===A+1?w=i(S[A++],N):S[A+1]==="."||S[A]==="."?(S[A]!=="."&&(d=i(S[A++],N)),A++,(A+1===S.length||S[A+1]==="("&&S[A+3]===")"||S[A+1]==="'"&&S[A+3]==="'")&&(w=i(S[A],N),b=Math.pow(10,S[A].length),A++),(S[A]==="("&&S[A+2]===")"||S[A]==="'"&&S[A+2]==="'")&&(x=i(S[A+1],N),E=Math.pow(10,S[A+1].length)-1,A+=3)):S[A+1]==="/"||S[A+1]===":"?(w=i(S[A],N),b=i(S[A+2],1),A+=3):S[A+3]==="/"&&S[A+1]===" "&&(d=i(S[A],N),w=i(S[A+2],N),b=i(S[A+4],1),A+=5),S.length<=A){y=b*E,N=g=x+y*d+E*w;break}}default:throw v.InvalidParameter}if(y===0)throw v.DivisionByZero;n.s=N<0?-1:1,n.n=Math.abs(g),n.d=Math.abs(y)};function u(h,p,g){for(var y=1;p>0;h=h*h%g,p>>=1)p&1&&(y=y*h%g);return y}function s(h,p){for(;p%2===0;p/=2);for(;p%5===0;p/=5);if(p===1)return 0;for(var g=10%p,y=1;g!==1;y++)if(g=g*10%p,y>a)return 0;return y}function c(h,p,g){for(var y=1,N=u(10,g,p),d=0;d<300;d++){if(y===N)return d;y=y*10%p,N=N*10%p}return 0}function m(h,p){if(!h)return p;if(!p)return h;for(;;){if(h%=p,!h)return p;if(p%=h,!p)return h}}function v(h,p){if(l(h,p),this instanceof v)h=m(n.d,n.n),this.s=n.s,this.n=n.n/h,this.d=n.d/h;else return o(n.s*n.n,n.d)}v.DivisionByZero=new Error("Division by Zero"),v.InvalidParameter=new Error("Invalid argument"),v.NonIntegerParameter=new Error("Parameters must be integer"),v.prototype={s:1,n:0,d:1,abs:function(){return o(this.n,this.d)},neg:function(){return o(-this.s*this.n,this.d)},add:function(h,p){return l(h,p),o(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(h,p){return l(h,p),o(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(h,p){return l(h,p),o(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(h,p){return l(h,p),o(this.s*n.s*this.n*n.d,this.d*n.n)},clone:function(){return o(this.s*this.n,this.d)},mod:function(h,p){if(isNaN(this.n)||isNaN(this.d))return new v(NaN);if(h===void 0)return o(this.s*this.n%this.d,1);if(l(h,p),n.n===0&&this.d===0)throw v.DivisionByZero;return o(this.s*(n.d*this.n)%(n.n*this.d),n.d*this.d)},gcd:function(h,p){return l(h,p),o(m(n.n,this.n)*m(n.d,this.d),n.d*this.d)},lcm:function(h,p){return l(h,p),n.n===0&&this.n===0?o(0,1):o(n.n*this.n,m(n.n,this.n)*m(n.d,this.d))},ceil:function(h){return h=Math.pow(10,h||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):o(Math.ceil(h*this.s*this.n/this.d),h)},floor:function(h){return h=Math.pow(10,h||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):o(Math.floor(h*this.s*this.n/this.d),h)},round:function(h){return h=Math.pow(10,h||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):o(Math.round(h*this.s*this.n/this.d),h)},inverse:function(){return o(this.s*this.d,this.n)},pow:function(h,p){if(l(h,p),n.d===1)return n.s<0?o(Math.pow(this.s*this.d,n.n),Math.pow(this.n,n.n)):o(Math.pow(this.s*this.n,n.n),Math.pow(this.d,n.n));if(this.s<0)return null;var g=f(this.n),y=f(this.d),N=1,d=1;for(var w in g)if(w!=="1"){if(w==="0"){N=0;break}if(g[w]*=n.n,g[w]%n.d===0)g[w]/=n.d;else return null;N*=Math.pow(w,g[w])}for(var w in y)if(w!=="1"){if(y[w]*=n.n,y[w]%n.d===0)y[w]/=n.d;else return null;d*=Math.pow(w,y[w])}return n.s<0?o(d,N):o(N,d)},equals:function(h,p){return l(h,p),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(h,p){l(h,p);var g=this.s*this.n*n.d-n.s*n.n*this.d;return(0<g)-(g<0)},simplify:function(h){if(isNaN(this.n)||isNaN(this.d))return this;h=h||.001;for(var p=this.abs(),g=p.toContinued(),y=1;y<g.length;y++){for(var N=o(g[y-1],1),d=y-2;d>=0;d--)N=N.inverse().add(g[d]);if(N.sub(p).abs().valueOf()<h)return N.mul(this.s)}return this},divisible:function(h,p){return l(h,p),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(h){var p,g="",y=this.n,N=this.d;return this.s<0&&(g+="-"),N===1?g+=y:(h&&(p=Math.floor(y/N))>0&&(g+=p,g+=" ",y%=N),g+=y,g+="/",g+=N),g},toLatex:function(h){var p,g="",y=this.n,N=this.d;return this.s<0&&(g+="-"),N===1?g+=y:(h&&(p=Math.floor(y/N))>0&&(g+=p,y%=N),g+="\\frac{",g+=y,g+="}{",g+=N,g+="}"),g},toContinued:function(){var h,p=this.n,g=this.d,y=[];if(isNaN(p)||isNaN(g))return y;do y.push(Math.floor(p/g)),h=p%g,p=g,g=h;while(p!==1);return y},toString:function(h){var p=this.n,g=this.d;if(isNaN(p)||isNaN(g))return"NaN";h=h||15;var y=s(p,g),N=c(p,g,y),d=this.s<0?"-":"";if(d+=p/g|0,p%=g,p*=10,p&&(d+="."),y){for(var w=N;w--;)d+=p/g|0,p%=g,p*=10;d+="(";for(var w=y;w--;)d+=p/g|0,p%=g,p*=10;d+=")"}else for(var w=h;p&&w--;)d+=p/g|0,p%=g,p*=10;return d}},Object.defineProperty(v,"__esModule",{value:!0}),v.default=v,v.Fraction=v,r.exports=v})()})(Hl);const Zt=Vl(Hl.exports);var M1="Fraction",F1=[],T1=q(M1,F1,()=>(Object.defineProperty(Zt,"name",{value:"Fraction"}),Zt.prototype.constructor=Zt,Zt.prototype.type="Fraction",Zt.prototype.isFraction=!0,Zt.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},Zt.fromJSON=function(r){return new Zt(r)},Zt),{isClass:!0}),B1="Range",$1=[],O1=q(B1,$1,()=>{function r(e,t,a){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");var n=e!=null,i=t!=null,o=a!=null;if(n){if(rr(e))e=e.toNumber();else if(typeof e!="number")throw new TypeError("Parameter start must be a number")}if(i){if(rr(t))t=t.toNumber();else if(typeof t!="number")throw new TypeError("Parameter end must be a number")}if(o){if(rr(a))a=a.toNumber();else if(typeof a!="number")throw new TypeError("Parameter step must be a number")}this.start=n?parseFloat(e):0,this.end=i?parseFloat(t):0,this.step=o?parseFloat(a):1}return r.prototype.type="Range",r.prototype.isRange=!0,r.parse=function(e){if(typeof e!="string")return null;var t=e.split(":"),a=t.map(function(i){return parseFloat(i)}),n=a.some(function(i){return isNaN(i)});if(n)return null;switch(a.length){case 2:return new r(a[0],a[1]);case 3:return new r(a[0],a[2],a[1]);default:return null}},r.prototype.clone=function(){return new r(this.start,this.end,this.step)},r.prototype.size=function(){var e=0,t=this.start,a=this.step,n=this.end,i=n-t;return tn(a)===tn(i)?e=Math.ceil(i/a):i===0&&(e=0),isNaN(e)&&(e=0),[e]},r.prototype.min=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start:this.start+(e-1)*this.step},r.prototype.max=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start+(e-1)*this.step:this.start},r.prototype.forEach=function(e){var t=this.start,a=this.step,n=this.end,i=0;if(a>0)for(;t<n;)e(t,[i],this),t+=a,i++;else if(a<0)for(;t>n;)e(t,[i],this),t+=a,i++},r.prototype.map=function(e){var t=[];return this.forEach(function(a,n,i){t[n[0]]=e(a,n,i)}),t},r.prototype.toArray=function(){var e=[];return this.forEach(function(t,a){e[a[0]]=t}),e},r.prototype.valueOf=function(){return this.toArray()},r.prototype.format=function(e){var t=Sn(this.start,e);return this.step!==1&&(t+=":"+Sn(this.step,e)),t+=":"+Sn(this.end,e),t},r.prototype.toString=function(){return this.format()},r.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},r.fromJSON=function(e){return new r(e.start,e.end,e.step)},r},{isClass:!0}),I1="Matrix",R1=[],_1=q(I1,R1,()=>{function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator")}return r.prototype.type="Matrix",r.prototype.isMatrix=!0,r.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},r.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},r.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},r.prototype.subset=function(e,t,a){throw new Error("Cannot invoke subset on a Matrix interface")},r.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},r.prototype.set=function(e,t,a){throw new Error("Cannot invoke set on a Matrix interface")},r.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},r.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},r.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},r.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},r.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},r.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},r.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},r.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},r.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},r.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},r.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},r},{isClass:!0});function q1(r){var e=0,t=1,a=Object.create(null),n=Object.create(null),i=0,o=function(l){var u=n[l];if(!!u&&(delete a[u],delete n[l],--e,t===u)){if(!e){i=0,t=1;return}for(;!hasOwnProperty.call(a,++t););}};return r=Math.abs(r),{hit:function(l){var u=n[l],s=++i;if(a[s]=l,n[l]=s,!u)return++e,e<=r?void 0:(l=a[t],o(l),l);if(delete a[u],t===u)for(;!hasOwnProperty.call(a,++t););},delete:o,clear:function(){e=i=0,t=1,a=Object.create(null),n=Object.create(null)}}}function ka(r){var{hasher:e,limit:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return t=t==null?Number.POSITIVE_INFINITY:t,e=e==null?JSON.stringify:e,function a(){typeof a.cache!="object"&&(a.cache={values:new Map,lru:q1(t||Number.POSITIVE_INFINITY)});for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=e(n);if(a.cache.values.has(o))return a.cache.lru.hit(o),a.cache.values.get(o);var f=r.apply(r,n);return a.cache.values.set(o,f),a.cache.values.delete(a.cache.lru.hit(o)),f}}function ln(r){return Object.keys(r.signatures||{}).reduce(function(e,t){var a=(t.match(/,/g)||[]).length+1;return Math.max(e,a)},-1)}var z1="DenseMatrix",P1=["Matrix"],U1=q(z1,P1,r=>{var{Matrix:e}=r;function t(s,c){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(c&&!Wr(c))throw new Error("Invalid datatype: "+c);if(Ve(s))s.type==="DenseMatrix"?(this._data=Ge(s._data),this._size=Ge(s._size),this._datatype=c||s._datatype):(this._data=s.toArray(),this._size=s.size(),this._datatype=c||s._datatype);else if(s&&cr(s.data)&&cr(s.size))this._data=s.data,this._size=s.size,yl(this._data,this._size),this._datatype=c||s.datatype;else if(cr(s))this._data=u(s),this._size=er(this._data),yl(this._data,this._size),this._datatype=c;else{if(s)throw new TypeError("Unsupported type of data ("+br(s)+")");this._data=[],this._size=[0],this._datatype=c}}t.prototype=new e,t.prototype.createDenseMatrix=function(s,c){return new t(s,c)},Object.defineProperty(t,"name",{value:"DenseMatrix"}),t.prototype.constructor=t,t.prototype.type="DenseMatrix",t.prototype.isDenseMatrix=!0,t.prototype.getDataType=function(){return Ua(this._data,br)},t.prototype.storage=function(){return"dense"},t.prototype.datatype=function(){return this._datatype},t.prototype.create=function(s,c){return new t(s,c)},t.prototype.subset=function(s,c,m){switch(arguments.length){case 1:return a(this,s);case 2:case 3:return i(this,s,c,m);default:throw new SyntaxError("Wrong number of arguments")}},t.prototype.get=function(s){if(!cr(s))throw new TypeError("Array expected");if(s.length!==this._size.length)throw new Ke(s.length,this._size.length);for(var c=0;c<s.length;c++)vr(s[c],this._size[c]);for(var m=this._data,v=0,h=s.length;v<h;v++){var p=s[v];vr(p,m.length),m=m[p]}return m},t.prototype.set=function(s,c,m){if(!cr(s))throw new TypeError("Array expected");if(s.length<this._size.length)throw new Ke(s.length,this._size.length,"<");var v,h,p,g=s.map(function(N){return N+1});l(this,g,m);var y=this._data;for(v=0,h=s.length-1;v<h;v++)p=s[v],vr(p,y.length),y=y[p];return p=s[s.length-1],vr(p,y.length),y[p]=c,this};function a(s,c){if(!li(c))throw new TypeError("Invalid index");var m=c.isScalar();if(m)return s.get(c.min());var v=c.size();if(v.length!==s._size.length)throw new Ke(v.length,s._size.length);for(var h=c.min(),p=c.max(),g=0,y=s._size.length;g<y;g++)vr(h[g],s._size[g]),vr(p[g],s._size[g]);return new t(n(s._data,c,v.length,0),s._datatype)}function n(s,c,m,v){var h=v===m-1,p=c.dimension(v);return h?p.map(function(g){return vr(g,s.length),s[g]}).valueOf():p.map(function(g){vr(g,s.length);var y=s[g];return n(y,c,m,v+1)}).valueOf()}function i(s,c,m,v){if(!c||c.isIndex!==!0)throw new TypeError("Invalid index");var h=c.size(),p=c.isScalar(),g;if(Ve(m)?(g=m.size(),m=m.valueOf()):g=er(m),p){if(g.length!==0)throw new TypeError("Scalar expected");s.set(c.min(),m,v)}else{if(h.length<s._size.length)throw new Ke(h.length,s._size.length,"<");if(g.length<h.length){for(var y=0,N=0;h[y]===1&&g[y]===1;)y++;for(;h[y]===1;)N++,y++;m=Nl(m,h.length,N,g)}if(!Pa(h,g))throw new Ke(h,g,">");var d=c.max().map(function(b){return b+1});l(s,d,v);var w=h.length,x=0;o(s._data,c,m,w,x)}return s}function o(s,c,m,v,h){var p=h===v-1,g=c.dimension(h);p?g.forEach(function(y,N){vr(y),s[y]=m[N[0]]}):g.forEach(function(y,N){vr(y),o(s[y],c,m[N[0]],v,h+1)})}t.prototype.resize=function(s,c,m){if(!Mt(s))throw new TypeError("Array or Matrix expected");var v=s.valueOf().map(p=>Array.isArray(p)&&p.length===1?p[0]:p),h=m?this.clone():this;return f(h,v,c)};function f(s,c,m){if(c.length===0){for(var v=s._data;cr(v);)v=v[0];return v}return s._size=c.slice(0),s._data=Yn(s._data,s._size,m),s}t.prototype.reshape=function(s,c){var m=c?this.clone():this;m._data=bl(m._data,s);var v=m._size.reduce((h,p)=>h*p);return m._size=Jo(s,v),m};function l(s,c,m){for(var v=s._size.slice(0),h=!1;v.length<c.length;)v.push(0),h=!0;for(var p=0,g=c.length;p<g;p++)c[p]>v[p]&&(v[p]=c[p],h=!0);h&&f(s,v,m)}t.prototype.clone=function(){var s=new t({data:Ge(this._data),size:Ge(this._size),datatype:this._datatype});return s},t.prototype.size=function(){return this._size.slice(0)},t.prototype.map=function(s){var c=this,m=ln(s),v=function g(y,N){return cr(y)?y.map(function(d,w){return g(d,N.concat(w))}):m===1?s(y):m===2?s(y,N):s(y,N,c)},h=v(this._data,[]),p=this._datatype!==void 0?Ua(h,br):void 0;return new t(h,p)},t.prototype.forEach=function(s){var c=this,m=function v(h,p){cr(h)?h.forEach(function(g,y){v(g,p.concat(y))}):s(h,p,c)};m(this._data,[])},t.prototype[Symbol.iterator]=function*(){var s=function*c(m,v){if(cr(m))for(var h=0;h<m.length;h++)yield*c(m[h],v.concat(h));else yield{value:m,index:v}};yield*s(this._data,[])},t.prototype.rows=function(){var s=[],c=this.size();if(c.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var m=this._data;for(var v of m)s.push(new t([v],this._datatype));return s},t.prototype.columns=function(){var s=this,c=[],m=this.size();if(m.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var v=this._data,h=function(y){var N=v.map(d=>[d[y]]);c.push(new t(N,s._datatype))},p=0;p<m[1];p++)h(p);return c},t.prototype.toArray=function(){return Ge(this._data)},t.prototype.valueOf=function(){return this._data},t.prototype.format=function(s){return Ye(this._data,s)},t.prototype.toString=function(){return Ye(this._data)},t.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},t.prototype.diagonal=function(s){if(s){if(rr(s)&&(s=s.toNumber()),!tr(s)||!qe(s))throw new TypeError("The parameter k must be an integer number")}else s=0;for(var c=s>0?s:0,m=s<0?-s:0,v=this._size[0],h=this._size[1],p=Math.min(v-m,h-c),g=[],y=0;y<p;y++)g[y]=this._data[y+m][y+c];return new t({data:g,size:[p],datatype:this._datatype})},t.diagonal=function(s,c,m,v){if(!cr(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(E){if(rr(E)&&(E=E.toNumber()),!tr(E)||!qe(E)||E<1)throw new Error("Size values must be positive integers");return E}),m){if(rr(m)&&(m=m.toNumber()),!tr(m)||!qe(m))throw new TypeError("The parameter k must be an integer number")}else m=0;var h=m>0?m:0,p=m<0?-m:0,g=s[0],y=s[1],N=Math.min(g-p,y-h),d;if(cr(c)){if(c.length!==N)throw new Error("Invalid value array length");d=function(A){return c[A]}}else if(Ve(c)){var w=c.size();if(w.length!==1||w[0]!==N)throw new Error("Invalid matrix length");d=function(A){return c.get([A])}}else d=function(){return c};v||(v=rr(d(0))?d(0).mul(0):0);var x=[];if(s.length>0){x=Yn(x,s,v);for(var b=0;b<N;b++)x[b+p][b+h]=d(b)}return new t({data:x,size:[g,y]})},t.fromJSON=function(s){return new t(s)},t.prototype.swapRows=function(s,c){if(!tr(s)||!qe(s)||!tr(c)||!qe(c))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return vr(s,this._size[0]),vr(c,this._size[0]),t._swapRows(s,c,this._data),this},t._swapRows=function(s,c,m){var v=m[s];m[s]=m[c],m[c]=v};function u(s){for(var c=0,m=s.length;c<m;c++){var v=s[c];cr(v)?s[c]=u(v):v&&v.isMatrix===!0&&(s[c]=u(v.valueOf()))}return s}return t},{isClass:!0}),Zl="clone",L1=["typed"],k1=q(Zl,L1,r=>{var{typed:e}=r;return e(Zl,{any:Ge})});function Jl(r){var e=r.length,t=r[0].length,a,n,i=[];for(n=0;n<t;n++){var o=[];for(a=0;a<e;a++)o.push(r[a][n]);i.push(o)}return i}function na(r){for(var e=0;e<r.length;e++)if(Mt(r[e]))return!0;return!1}function Jt(r,e){Ve(r)&&(r=r.valueOf());for(var t=0,a=r.length;t<a;t++){var n=r[t];Array.isArray(n)?Jt(n,e):e(n)}}function je(r,e,t){return r&&typeof r.map=="function"?r.map(function(a){return je(a,e)}):e(r)}function Si(r,e,t){var a=Array.isArray(r)?er(r):r.size();if(e<0||e>=a.length)throw new ht(e,a.length);return Ve(r)?r.create(Ci(r.valueOf(),e,t)):Ci(r,e,t)}function Ci(r,e,t){var a,n,i,o;if(e<=0)if(Array.isArray(r[0])){for(o=Jl(r),n=[],a=0;a<o.length;a++)n[a]=Ci(o[a],e-1,t);return n}else{for(i=r[0],a=1;a<r.length;a++)i=t(i,r[a]);return i}else{for(n=[],a=0;a<r.length;a++)n[a]=Ci(r[a],e-1,t);return n}}function Xl(r,e,t,a,n,i,o,f,l,u,s){var c=r._values,m=r._index,v=r._ptr,h,p,g,y;if(a)for(p=v[e],g=v[e+1],h=p;h<g;h++)y=m[h],t[y]!==i?(t[y]=i,o.push(y),u?(a[y]=l?f(c[h],s):f(s,c[h]),n[y]=i):a[y]=c[h]):(a[y]=l?f(c[h],a[y]):f(a[y],c[h]),n[y]=i);else for(p=v[e],g=v[e+1],h=p;h<g;h++)y=m[h],t[y]!==i?(t[y]=i,o.push(y)):n[y]=i}var Wl="isInteger",V1=["typed"],G1=q(Wl,V1,r=>{var{typed:e}=r;return e(Wl,{number:qe,BigNumber:function(a){return a.isInt()},Fraction:function(a){return a.d===1&&isFinite(a.n)},"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),yt="number",Mn="number, number";function Yl(r){return Math.abs(r)}Yl.signature=yt;function Ql(r,e){return r+e}Ql.signature=Mn;function Kl(r,e){return r*e}Kl.signature=Mn;function jl(r){return-r}jl.signature=yt;function ec(r){return r}ec.signature=yt;function Va(r){return X0(r)}Va.signature=yt;function rc(r){return r*r*r}rc.signature=yt;function tc(r){return Math.exp(r)}tc.signature=yt;function nc(r){return W0(r)}nc.signature=yt;function ac(r,e){if(!qe(r)||!qe(e))throw new Error("Parameters in function gcd must be integer numbers");for(var t;e!==0;)t=r%e,r=e,e=t;return r<0?-r:r}ac.signature=Mn;function ic(r,e){if(!qe(r)||!qe(e))throw new Error("Parameters in function lcm must be integer numbers");if(r===0||e===0)return 0;for(var t,a=r*e;e!==0;)t=e,e=r%t,r=t;return Math.abs(a/r)}ic.signature=Mn;function H1(r,e){return e?Math.log(r)/Math.log(e):Math.log(r)}function oc(r){return Z0(r)}oc.signature=yt;function sc(r){return H0(r)}sc.signature=yt;function uc(r,e){if(e>0)return r-e*Math.floor(r/e);if(e===0)return r;throw new Error("Cannot calculate mod for a negative divisor")}uc.signature=Mn;function lc(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,t=e<0;if(t&&(e=-e),e===0)throw new Error("Root must be non-zero");if(r<0&&Math.abs(e)%2!==1)throw new Error("Root must be odd when a is negative.");if(r===0)return t?1/0:0;if(!isFinite(r))return t?0:r;var a=Math.pow(Math.abs(r),1/e);return a=r<0?-a:a,t?1/a:a}function os(r){return tn(r)}os.signature=yt;function cc(r){return r*r}cc.signature=yt;function fc(r,e){var t,a,n,i=0,o=1,f=1,l=0;if(!qe(r)||!qe(e))throw new Error("Parameters in function xgcd must be integer numbers");for(;e;)a=Math.floor(r/e),n=r-a*e,t=i,i=o-a*i,o=t,t=f,f=l-a*f,l=t,r=e,e=n;var u;return r<0?u=[-r,-o,-l]:u=[r,r?o:0,l],u}fc.signature=Mn;function mc(r,e){return r*r<1&&e===1/0||r*r>1&&e===-1/0?0:Math.pow(r,e)}mc.signature=Mn;function vc(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!qe(e)||e<0||e>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(vl(r,e))}var Z1="number",aa="number, number";function pc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitAnd");return r&e}pc.signature=aa;function hc(r){if(!qe(r))throw new Error("Integer expected in function bitNot");return~r}hc.signature=Z1;function dc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitOr");return r|e}dc.signature=aa;function gc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitXor");return r^e}gc.signature=aa;function yc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function leftShift");return r<<e}yc.signature=aa;function bc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function rightArithShift");return r>>e}bc.signature=aa;function xc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function rightLogShift");return r>>>e}xc.signature=aa;function Xt(r,e){if(e<r)return 1;if(e===r)return e;var t=e+r>>1;return Xt(r,t)*Xt(t+1,e)}function wc(r,e){if(!qe(r)||r<0)throw new TypeError("Positive integer value expected in function combinations");if(!qe(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(e>r)throw new TypeError("k must be less than or equal to n");for(var t=r-e,a=1,n=e<t?t+1:e+1,i=2,o=e<t?e:t,f=n;f<=r;++f)for(a*=f;i<=o&&a%i===0;)a/=i,++i;return i<=o&&(a/=Xt(i,o)),a}wc.signature="number, number";var J1=Math.PI,X1=2*Math.PI,W1=Math.E,Y1=1.618033988749895,Q1="number",ss="number, number";function Nc(r){return!r}Nc.signature=Q1;function Dc(r,e){return!!(r||e)}Dc.signature=ss;function Ac(r,e){return!!r!=!!e}Ac.signature=ss;function Ec(r,e){return!!(r&&e)}Ec.signature=ss;function Mi(r){var e;if(qe(r))return r<=0?isFinite(r)?1/0:NaN:r>171?1/0:Xt(1,r-1);if(r<.5)return Math.PI/(Math.sin(Math.PI*r)*Mi(1-r));if(r>=171.35)return 1/0;if(r>85){var t=r*r,a=t*r,n=a*r,i=n*r;return Math.sqrt(2*Math.PI/r)*Math.pow(r/Math.E,r)*(1+1/(12*r)+1/(288*t)-139/(51840*a)-571/(2488320*n)+163879/(209018880*i)+5246819/(75246796800*i*r))}--r,e=ia[0];for(var o=1;o<ia.length;++o)e+=ia[o]/(r+o);var f=r+Sc+.5;return Math.sqrt(2*Math.PI)*Math.pow(f,r+.5)*Math.exp(-f)*e}Mi.signature="number";var Sc=4.7421875,ia=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],Cc=.9189385332046728,K1=5,j1=7,Mc=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function Fi(r){if(r<0)return NaN;if(r===0)return 1/0;if(!isFinite(r))return r;if(r<.5)return Math.log(Math.PI/Math.sin(Math.PI*r))-Fi(1-r);r=r-1;for(var e=r+K1+.5,t=Mc[0],a=j1-1;a>=1;a--)t+=Mc[a]/(r+a);return Cc+(r+.5)*Math.log(e)-e+Math.log(t)}Fi.signature="number";var Hr="number";function Fc(r){return eg(r)}Fc.signature=Hr;function Tc(r){return Math.atan(1/r)}Tc.signature=Hr;function Bc(r){return isFinite(r)?(Math.log((r+1)/r)+Math.log(r/(r-1)))/2:0}Bc.signature=Hr;function $c(r){return Math.asin(1/r)}$c.signature=Hr;function Oc(r){var e=1/r;return Math.log(e+Math.sqrt(e*e+1))}Oc.signature=Hr;function Ic(r){return Math.acos(1/r)}Ic.signature=Hr;function Rc(r){var e=1/r,t=Math.sqrt(e*e-1);return Math.log(t+e)}Rc.signature=Hr;function _c(r){return rg(r)}_c.signature=Hr;function qc(r){return tg(r)}qc.signature=Hr;function zc(r){return 1/Math.tan(r)}zc.signature=Hr;function Pc(r){var e=Math.exp(2*r);return(e+1)/(e-1)}Pc.signature=Hr;function Uc(r){return 1/Math.sin(r)}Uc.signature=Hr;function Lc(r){return r===0?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(r)-Math.exp(-r)))*tn(r)}Lc.signature=Hr;function kc(r){return 1/Math.cos(r)}kc.signature=Hr;function Vc(r){return 2/(Math.exp(r)+Math.exp(-r))}Vc.signature=Hr;function Gc(r){return ag(r)}Gc.signature=Hr;var Ti="number";function Hc(r){return r<0}Hc.signature=Ti;function Zc(r){return r>0}Zc.signature=Ti;function Jc(r){return r===0}Jc.signature=Ti;function Xc(r){return Number.isNaN(r)}Xc.signature=Ti;var Wc="isNegative",ey=["typed"],ry=q(Wc,ey,r=>{var{typed:e}=r;return e(Wc,{number:Hc,BigNumber:function(a){return a.isNeg()&&!a.isZero()&&!a.isNaN()},Fraction:function(a){return a.s<0},Unit:e.referToSelf(t=>a=>e.find(t,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Yc="isNumeric",ty=["typed"],ny=q(Yc,ty,r=>{var{typed:e}=r;return e(Yc,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Qc="hasNumericValue",ay=["typed","isNumeric"],iy=q(Qc,ay,r=>{var{typed:e,isNumeric:t}=r;return e(Qc,{boolean:()=>!0,string:function(n){return n.trim().length>0&&!isNaN(Number(n))},any:function(n){return t(n)}})}),Kc="isPositive",oy=["typed"],sy=q(Kc,oy,r=>{var{typed:e}=r;return e(Kc,{number:Zc,BigNumber:function(a){return!a.isNeg()&&!a.isZero()&&!a.isNaN()},Fraction:function(a){return a.s>0&&a.n>0},Unit:e.referToSelf(t=>a=>e.find(t,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),jc="isZero",uy=["typed"],ly=q(jc,uy,r=>{var{typed:e}=r;return e(jc,{number:Jc,BigNumber:function(a){return a.isZero()},Complex:function(a){return a.re===0&&a.im===0},Fraction:function(a){return a.d===1&&a.n===0},Unit:e.referToSelf(t=>a=>e.find(t,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),ef="isNaN",cy=["typed"],fy=q(ef,cy,r=>{var{typed:e}=r;return e(ef,{number:Xc,BigNumber:function(a){return a.isNaN()},Fraction:function(a){return!1},Complex:function(a){return a.isNaN()},Unit:function(a){return Number.isNaN(a.value)},"Array | Matrix":function(a){return je(a,Number.isNaN)}})}),rf="typeOf",my=["typed"],vy=q(rf,my,r=>{var{typed:e}=r;return e(rf,{any:br})});function Tt(r,e,t){if(t==null)return r.eq(e);if(r.eq(e))return!0;if(r.isNaN()||e.isNaN())return!1;if(r.isFinite()&&e.isFinite()){var a=r.minus(e).abs();if(a.isZero())return!0;var n=r.constructor.max(r.abs(),e.abs());return a.lte(n.times(t))}return!1}function py(r,e,t){return tt(r.re,e.re,t)&&tt(r.im,e.im,t)}var oa=q("compareUnits",["typed"],r=>{var{typed:e}=r;return{"Unit, Unit":e.referToSelf(t=>(a,n)=>{if(!a.equalBase(n))throw new Error("Cannot compare units with different base");return e.find(t,[a.valueType(),n.valueType()])(a.value,n.value)})}}),Bi="equalScalar",hy=["typed","config"],dy=q(Bi,hy,r=>{var{typed:e,config:t}=r,a=oa({typed:e});return e(Bi,{"boolean, boolean":function(i,o){return i===o},"number, number":function(i,o){return tt(i,o,t.epsilon)},"BigNumber, BigNumber":function(i,o){return i.eq(o)||Tt(i,o,t.epsilon)},"Fraction, Fraction":function(i,o){return i.equals(o)},"Complex, Complex":function(i,o){return py(i,o,t.epsilon)}},a)});q(Bi,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Bi,{"number, number":function(n,i){return tt(n,i,t.epsilon)}})});var gy="SparseMatrix",yy=["typed","equalScalar","Matrix"],by=q(gy,yy,r=>{var{typed:e,equalScalar:t,Matrix:a}=r;function n(p,g){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(g&&!Wr(g))throw new Error("Invalid datatype: "+g);if(Ve(p))i(this,p,g);else if(p&&cr(p.index)&&cr(p.ptr)&&cr(p.size))this._values=p.values,this._index=p.index,this._ptr=p.ptr,this._size=p.size,this._datatype=g||p.datatype;else if(cr(p))o(this,p,g);else{if(p)throw new TypeError("Unsupported type of data ("+br(p)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=g}}function i(p,g,y){g.type==="SparseMatrix"?(p._values=g._values?Ge(g._values):void 0,p._index=Ge(g._index),p._ptr=Ge(g._ptr),p._size=Ge(g._size),p._datatype=y||g._datatype):o(p,g.valueOf(),y||g._datatype)}function o(p,g,y){p._values=[],p._index=[],p._ptr=[],p._datatype=y;var N=g.length,d=0,w=t,x=0;if(Wr(y)&&(w=e.find(t,[y,y])||t,x=e.convert(0,y)),N>0){var b=0;do{p._ptr.push(p._index.length);for(var E=0;E<N;E++){var A=g[E];if(cr(A)){if(b===0&&d<A.length&&(d=A.length),b<A.length){var S=A[b];w(S,x)||(p._values.push(S),p._index.push(E))}}else b===0&&d<1&&(d=1),w(A,x)||(p._values.push(A),p._index.push(E))}b++}while(b<d)}p._ptr.push(p._index.length),p._size=[N,d]}n.prototype=new a,n.prototype.createSparseMatrix=function(p,g){return new n(p,g)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return Ua(this._values,br)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(p,g){return new n(p,g)},n.prototype.density=function(){var p=this._size[0],g=this._size[1];return p!==0&&g!==0?this._index.length/(p*g):0},n.prototype.subset=function(p,g,y){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return f(this,p);case 2:case 3:return l(this,p,g,y);default:throw new SyntaxError("Wrong number of arguments")}};function f(p,g){if(!li(g))throw new TypeError("Invalid index");var y=g.isScalar();if(y)return p.get(g.min());var N=g.size();if(N.length!==p._size.length)throw new Ke(N.length,p._size.length);var d,w,x,b,E=g.min(),A=g.max();for(d=0,w=p._size.length;d<w;d++)vr(E[d],p._size[d]),vr(A[d],p._size[d]);var S=p._values,D=p._index,T=p._ptr,B=g.dimension(0),I=g.dimension(1),P=[],R=[];B.forEach(function($,k){R[$]=k[0],P[$]=!0});var M=S?[]:void 0,F=[],H=[];return I.forEach(function($){for(H.push(F.length),x=T[$],b=T[$+1];x<b;x++)d=D[x],P[d]===!0&&(F.push(R[d]),M&&M.push(S[x]))}),H.push(F.length),new n({values:M,index:F,ptr:H,size:N,datatype:p._datatype})}function l(p,g,y,N){if(!g||g.isIndex!==!0)throw new TypeError("Invalid index");var d=g.size(),w=g.isScalar(),x;if(Ve(y)?(x=y.size(),y=y.toArray()):x=er(y),w){if(x.length!==0)throw new TypeError("Scalar expected");p.set(g.min(),y,N)}else{if(d.length!==1&&d.length!==2)throw new Ke(d.length,p._size.length,"<");if(x.length<d.length){for(var b=0,E=0;d[b]===1&&x[b]===1;)b++;for(;d[b]===1;)E++,b++;y=Nl(y,d.length,E,x)}if(!Pa(d,x))throw new Ke(d,x,">");if(d.length===1){var A=g.dimension(0);A.forEach(function(T,B){vr(T),p.set([T,0],y[B[0]],N)})}else{var S=g.dimension(0),D=g.dimension(1);S.forEach(function(T,B){vr(T),D.forEach(function(I,P){vr(I),p.set([T,I],y[B[0]][P[0]],N)})})}}return p}n.prototype.get=function(p){if(!cr(p))throw new TypeError("Array expected");if(p.length!==this._size.length)throw new Ke(p.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var g=p[0],y=p[1];vr(g,this._size[0]),vr(y,this._size[1]);var N=u(g,this._ptr[y],this._ptr[y+1],this._index);return N<this._ptr[y+1]&&this._index[N]===g?this._values[N]:0},n.prototype.set=function(p,g,y){if(!cr(p))throw new TypeError("Array expected");if(p.length!==this._size.length)throw new Ke(p.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var N=p[0],d=p[1],w=this._size[0],x=this._size[1],b=t,E=0;Wr(this._datatype)&&(b=e.find(t,[this._datatype,this._datatype])||t,E=e.convert(0,this._datatype)),(N>w-1||d>x-1)&&(m(this,Math.max(N+1,w),Math.max(d+1,x),y),w=this._size[0],x=this._size[1]),vr(N,w),vr(d,x);var A=u(N,this._ptr[d],this._ptr[d+1],this._index);return A<this._ptr[d+1]&&this._index[A]===N?b(g,E)?s(A,d,this._values,this._index,this._ptr):this._values[A]=g:b(g,E)||c(A,N,d,g,this._values,this._index,this._ptr),this};function u(p,g,y,N){if(y-g===0)return y;for(var d=g;d<y;d++)if(N[d]===p)return d;return g}function s(p,g,y,N,d){y.splice(p,1),N.splice(p,1);for(var w=g+1;w<d.length;w++)d[w]--}function c(p,g,y,N,d,w,x){d.splice(p,0,N),w.splice(p,0,g);for(var b=y+1;b<x.length;b++)x[b]++}n.prototype.resize=function(p,g,y){if(!Mt(p))throw new TypeError("Array or Matrix expected");var N=p.valueOf().map(w=>Array.isArray(w)&&w.length===1?w[0]:w);if(N.length!==2)throw new Error("Only two dimensions matrix are supported");N.forEach(function(w){if(!tr(w)||!qe(w)||w<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Ye(N)+")")});var d=y?this.clone():this;return m(d,N[0],N[1],g)};function m(p,g,y,N){var d=N||0,w=t,x=0;Wr(p._datatype)&&(w=e.find(t,[p._datatype,p._datatype])||t,x=e.convert(0,p._datatype),d=e.convert(d,p._datatype));var b=!w(d,x),E=p._size[0],A=p._size[1],S,D,T;if(y>A){for(D=A;D<y;D++)if(p._ptr[D]=p._values.length,b)for(S=0;S<E;S++)p._values.push(d),p._index.push(S);p._ptr[y]=p._values.length}else y<A&&(p._ptr.splice(y+1,A-y),p._values.splice(p._ptr[y],p._values.length),p._index.splice(p._ptr[y],p._index.length));if(A=y,g>E){if(b){var B=0;for(D=0;D<A;D++){p._ptr[D]=p._ptr[D]+B,T=p._ptr[D+1]+B;var I=0;for(S=E;S<g;S++,I++)p._values.splice(T+I,0,d),p._index.splice(T+I,0,S),B++}p._ptr[A]=p._values.length}}else if(g<E){var P=0;for(D=0;D<A;D++){p._ptr[D]=p._ptr[D]-P;var R=p._ptr[D],M=p._ptr[D+1]-P;for(T=R;T<M;T++)S=p._index[T],S>g-1&&(p._values.splice(T,1),p._index.splice(T,1),P++)}p._ptr[D]=p._values.length}return p._size[0]=g,p._size[1]=y,p}n.prototype.reshape=function(p,g){if(!cr(p))throw new TypeError("Array expected");if(p.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");p.forEach(function($){if(!tr($)||!qe($)||$<=-2||$===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Ye(p)+")")});var y=this._size[0]*this._size[1];p=Jo(p,y);var N=p[0]*p[1];if(y!==N)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var d=g?this.clone():this;if(this._size[0]===p[0]&&this._size[1]===p[1])return d;for(var w=[],x=0;x<d._ptr.length;x++)for(var b=0;b<d._ptr[x+1]-d._ptr[x];b++)w.push(x);for(var E=d._values.slice(),A=d._index.slice(),S=0;S<d._index.length;S++){var D=A[S],T=w[S],B=D*d._size[1]+T;w[S]=B%p[1],A[S]=Math.floor(B/p[1])}d._values.length=0,d._index.length=0,d._ptr.length=p[1]+1,d._size=p.slice();for(var I=0;I<d._ptr.length;I++)d._ptr[I]=0;for(var P=0;P<E.length;P++){var R=A[P],M=w[P],F=E[P],H=u(R,d._ptr[M],d._ptr[M+1],d._index);c(H,R,M,F,d._values,d._index,d._ptr)}return d},n.prototype.clone=function(){var p=new n({values:this._values?Ge(this._values):void 0,index:Ge(this._index),ptr:Ge(this._ptr),size:Ge(this._size),datatype:this._datatype});return p},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(p,g){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var y=this,N=this._size[0],d=this._size[1],w=ln(p),x=function(E,A,S){return w===1?p(E):w===2?p(E,[A,S]):p(E,[A,S],y)};return v(this,0,N-1,0,d-1,x,g)};function v(p,g,y,N,d,w,x){var b=[],E=[],A=[],S=t,D=0;Wr(p._datatype)&&(S=e.find(t,[p._datatype,p._datatype])||t,D=e.convert(0,p._datatype));for(var T=function(L,j,ae){L=w(L,j,ae),S(L,D)||(b.push(L),E.push(j))},B=N;B<=d;B++){A.push(b.length);var I=p._ptr[B],P=p._ptr[B+1];if(x)for(var R=I;R<P;R++){var M=p._index[R];M>=g&&M<=y&&T(p._values[R],M-g,B-N)}else{for(var F={},H=I;H<P;H++){var $=p._index[H];F[$]=p._values[H]}for(var k=g;k<=y;k++){var Q=k in F?F[k]:0;T(Q,k-g,B-N)}}}return A.push(b.length),new n({values:b,index:E,ptr:A,size:[y-g+1,d-N+1]})}n.prototype.forEach=function(p,g){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var y=this,N=this._size[0],d=this._size[1],w=0;w<d;w++){var x=this._ptr[w],b=this._ptr[w+1];if(g)for(var E=x;E<b;E++){var A=this._index[E];p(this._values[E],[A,w],y)}else{for(var S={},D=x;D<b;D++){var T=this._index[D];S[T]=this._values[D]}for(var B=0;B<N;B++){var I=B in S?S[B]:0;p(I,[B,w],y)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var p=this._size[1],g=0;g<p;g++)for(var y=this._ptr[g],N=this._ptr[g+1],d=y;d<N;d++){var w=this._index[d];yield{value:this._values[d],index:[w,g]}}},n.prototype.toArray=function(){return h(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return h(this._values,this._index,this._ptr,this._size,!1)};function h(p,g,y,N,d){var w=N[0],x=N[1],b=[],E,A;for(E=0;E<w;E++)for(b[E]=[],A=0;A<x;A++)b[E][A]=0;for(A=0;A<x;A++)for(var S=y[A],D=y[A+1],T=S;T<D;T++)E=g[T],b[E][A]=p?d?Ge(p[T]):p[T]:1;return b}return n.prototype.format=function(p){for(var g=this._size[0],y=this._size[1],N=this.density(),d="Sparse Matrix ["+Ye(g,p)+" x "+Ye(y,p)+"] density: "+Ye(N,p)+`
|
|
27
|
+
**/(function(r,e){(function(t){var a=2e3,n={s:1,n:0,d:1};function i(h,p){if(isNaN(h=parseInt(h,10)))throw v.InvalidParameter;return h*p}function o(h,p){if(p===0)throw v.DivisionByZero;var g=Object.create(v.prototype);g.s=h<0?-1:1,h=h<0?-h:h;var y=m(h,p);return g.n=h/y,g.d=p/y,g}function f(h){for(var p={},g=h,y=2,N=4;N<=g;){for(;g%y===0;)g/=y,p[y]=(p[y]||0)+1;N+=1+2*y++}return g!==h?g>1&&(p[g]=(p[g]||0)+1):p[h]=(p[h]||0)+1,p}var l=function(h,p){var g=0,y=1,N=1,d=0,w=0,x=0,b=1,E=1,A=0,S=1,D=1,T=1,B=1e7,I;if(h!=null)if(p!==void 0){if(g=h,y=p,N=g*y,g%1!==0||y%1!==0)throw v.NonIntegerParameter}else switch(typeof h){case"object":{if("d"in h&&"n"in h)g=h.n,y=h.d,"s"in h&&(g*=h.s);else if(0 in h)g=h[0],1 in h&&(y=h[1]);else throw v.InvalidParameter;N=g*y;break}case"number":{if(h<0&&(N=h,h=-h),h%1===0)g=h;else if(h>0){for(h>=1&&(E=Math.pow(10,Math.floor(1+Math.log(h)/Math.LN10)),h/=E);S<=B&&T<=B;)if(I=(A+D)/(S+T),h===I){S+T<=B?(g=A+D,y=S+T):T>S?(g=D,y=T):(g=A,y=S);break}else h>I?(A+=D,S+=T):(D+=A,T+=S),S>B?(g=D,y=T):(g=A,y=S);g*=E}else(isNaN(h)||isNaN(p))&&(y=g=NaN);break}case"string":{if(S=h.match(/\d+|./g),S===null)throw v.InvalidParameter;if(S[A]==="-"?(N=-1,A++):S[A]==="+"&&A++,S.length===A+1?w=i(S[A++],N):S[A+1]==="."||S[A]==="."?(S[A]!=="."&&(d=i(S[A++],N)),A++,(A+1===S.length||S[A+1]==="("&&S[A+3]===")"||S[A+1]==="'"&&S[A+3]==="'")&&(w=i(S[A],N),b=Math.pow(10,S[A].length),A++),(S[A]==="("&&S[A+2]===")"||S[A]==="'"&&S[A+2]==="'")&&(x=i(S[A+1],N),E=Math.pow(10,S[A+1].length)-1,A+=3)):S[A+1]==="/"||S[A+1]===":"?(w=i(S[A],N),b=i(S[A+2],1),A+=3):S[A+3]==="/"&&S[A+1]===" "&&(d=i(S[A],N),w=i(S[A+2],N),b=i(S[A+4],1),A+=5),S.length<=A){y=b*E,N=g=x+y*d+E*w;break}}default:throw v.InvalidParameter}if(y===0)throw v.DivisionByZero;n.s=N<0?-1:1,n.n=Math.abs(g),n.d=Math.abs(y)};function u(h,p,g){for(var y=1;p>0;h=h*h%g,p>>=1)p&1&&(y=y*h%g);return y}function s(h,p){for(;p%2===0;p/=2);for(;p%5===0;p/=5);if(p===1)return 0;for(var g=10%p,y=1;g!==1;y++)if(g=g*10%p,y>a)return 0;return y}function c(h,p,g){for(var y=1,N=u(10,g,p),d=0;d<300;d++){if(y===N)return d;y=y*10%p,N=N*10%p}return 0}function m(h,p){if(!h)return p;if(!p)return h;for(;;){if(h%=p,!h)return p;if(p%=h,!p)return h}}function v(h,p){if(l(h,p),this instanceof v)h=m(n.d,n.n),this.s=n.s,this.n=n.n/h,this.d=n.d/h;else return o(n.s*n.n,n.d)}v.DivisionByZero=new Error("Division by Zero"),v.InvalidParameter=new Error("Invalid argument"),v.NonIntegerParameter=new Error("Parameters must be integer"),v.prototype={s:1,n:0,d:1,abs:function(){return o(this.n,this.d)},neg:function(){return o(-this.s*this.n,this.d)},add:function(h,p){return l(h,p),o(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(h,p){return l(h,p),o(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(h,p){return l(h,p),o(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(h,p){return l(h,p),o(this.s*n.s*this.n*n.d,this.d*n.n)},clone:function(){return o(this.s*this.n,this.d)},mod:function(h,p){if(isNaN(this.n)||isNaN(this.d))return new v(NaN);if(h===void 0)return o(this.s*this.n%this.d,1);if(l(h,p),n.n===0&&this.d===0)throw v.DivisionByZero;return o(this.s*(n.d*this.n)%(n.n*this.d),n.d*this.d)},gcd:function(h,p){return l(h,p),o(m(n.n,this.n)*m(n.d,this.d),n.d*this.d)},lcm:function(h,p){return l(h,p),n.n===0&&this.n===0?o(0,1):o(n.n*this.n,m(n.n,this.n)*m(n.d,this.d))},ceil:function(h){return h=Math.pow(10,h||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):o(Math.ceil(h*this.s*this.n/this.d),h)},floor:function(h){return h=Math.pow(10,h||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):o(Math.floor(h*this.s*this.n/this.d),h)},round:function(h){return h=Math.pow(10,h||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):o(Math.round(h*this.s*this.n/this.d),h)},inverse:function(){return o(this.s*this.d,this.n)},pow:function(h,p){if(l(h,p),n.d===1)return n.s<0?o(Math.pow(this.s*this.d,n.n),Math.pow(this.n,n.n)):o(Math.pow(this.s*this.n,n.n),Math.pow(this.d,n.n));if(this.s<0)return null;var g=f(this.n),y=f(this.d),N=1,d=1;for(var w in g)if(w!=="1"){if(w==="0"){N=0;break}if(g[w]*=n.n,g[w]%n.d===0)g[w]/=n.d;else return null;N*=Math.pow(w,g[w])}for(var w in y)if(w!=="1"){if(y[w]*=n.n,y[w]%n.d===0)y[w]/=n.d;else return null;d*=Math.pow(w,y[w])}return n.s<0?o(d,N):o(N,d)},equals:function(h,p){return l(h,p),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(h,p){l(h,p);var g=this.s*this.n*n.d-n.s*n.n*this.d;return(0<g)-(g<0)},simplify:function(h){if(isNaN(this.n)||isNaN(this.d))return this;h=h||.001;for(var p=this.abs(),g=p.toContinued(),y=1;y<g.length;y++){for(var N=o(g[y-1],1),d=y-2;d>=0;d--)N=N.inverse().add(g[d]);if(N.sub(p).abs().valueOf()<h)return N.mul(this.s)}return this},divisible:function(h,p){return l(h,p),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(h){var p,g="",y=this.n,N=this.d;return this.s<0&&(g+="-"),N===1?g+=y:(h&&(p=Math.floor(y/N))>0&&(g+=p,g+=" ",y%=N),g+=y,g+="/",g+=N),g},toLatex:function(h){var p,g="",y=this.n,N=this.d;return this.s<0&&(g+="-"),N===1?g+=y:(h&&(p=Math.floor(y/N))>0&&(g+=p,y%=N),g+="\\frac{",g+=y,g+="}{",g+=N,g+="}"),g},toContinued:function(){var h,p=this.n,g=this.d,y=[];if(isNaN(p)||isNaN(g))return y;do y.push(Math.floor(p/g)),h=p%g,p=g,g=h;while(p!==1);return y},toString:function(h){var p=this.n,g=this.d;if(isNaN(p)||isNaN(g))return"NaN";h=h||15;var y=s(p,g),N=c(p,g,y),d=this.s<0?"-":"";if(d+=p/g|0,p%=g,p*=10,p&&(d+="."),y){for(var w=N;w--;)d+=p/g|0,p%=g,p*=10;d+="(";for(var w=y;w--;)d+=p/g|0,p%=g,p*=10;d+=")"}else for(var w=h;p&&w--;)d+=p/g|0,p%=g,p*=10;return d}},Object.defineProperty(v,"__esModule",{value:!0}),v.default=v,v.Fraction=v,r.exports=v})()})(Jl);const Jt=Hl(Jl.exports);var _1="Fraction",q1=[],z1=q(_1,q1,()=>(Object.defineProperty(Jt,"name",{value:"Fraction"}),Jt.prototype.constructor=Jt,Jt.prototype.type="Fraction",Jt.prototype.isFraction=!0,Jt.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},Jt.fromJSON=function(r){return new Jt(r)},Jt),{isClass:!0}),P1="Range",U1=[],L1=q(P1,U1,()=>{function r(e,t,a){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");var n=e!=null,i=t!=null,o=a!=null;if(n){if(rr(e))e=e.toNumber();else if(typeof e!="number")throw new TypeError("Parameter start must be a number")}if(i){if(rr(t))t=t.toNumber();else if(typeof t!="number")throw new TypeError("Parameter end must be a number")}if(o){if(rr(a))a=a.toNumber();else if(typeof a!="number")throw new TypeError("Parameter step must be a number")}this.start=n?parseFloat(e):0,this.end=i?parseFloat(t):0,this.step=o?parseFloat(a):1}return r.prototype.type="Range",r.prototype.isRange=!0,r.parse=function(e){if(typeof e!="string")return null;var t=e.split(":"),a=t.map(function(i){return parseFloat(i)}),n=a.some(function(i){return isNaN(i)});if(n)return null;switch(a.length){case 2:return new r(a[0],a[1]);case 3:return new r(a[0],a[2],a[1]);default:return null}},r.prototype.clone=function(){return new r(this.start,this.end,this.step)},r.prototype.size=function(){var e=0,t=this.start,a=this.step,n=this.end,i=n-t;return an(a)===an(i)?e=Math.ceil(i/a):i===0&&(e=0),isNaN(e)&&(e=0),[e]},r.prototype.min=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start:this.start+(e-1)*this.step},r.prototype.max=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start+(e-1)*this.step:this.start},r.prototype.forEach=function(e){var t=this.start,a=this.step,n=this.end,i=0;if(a>0)for(;t<n;)e(t,[i],this),t+=a,i++;else if(a<0)for(;t>n;)e(t,[i],this),t+=a,i++},r.prototype.map=function(e){var t=[];return this.forEach(function(a,n,i){t[n[0]]=e(a,n,i)}),t},r.prototype.toArray=function(){var e=[];return this.forEach(function(t,a){e[a[0]]=t}),e},r.prototype.valueOf=function(){return this.toArray()},r.prototype.format=function(e){var t=Cn(this.start,e);return this.step!==1&&(t+=":"+Cn(this.step,e)),t+=":"+Cn(this.end,e),t},r.prototype.toString=function(){return this.format()},r.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},r.fromJSON=function(e){return new r(e.start,e.end,e.step)},r},{isClass:!0}),k1="Matrix",V1=[],G1=q(k1,V1,()=>{function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator")}return r.prototype.type="Matrix",r.prototype.isMatrix=!0,r.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},r.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},r.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},r.prototype.subset=function(e,t,a){throw new Error("Cannot invoke subset on a Matrix interface")},r.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},r.prototype.set=function(e,t,a){throw new Error("Cannot invoke set on a Matrix interface")},r.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},r.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},r.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},r.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},r.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},r.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},r.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},r.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},r.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},r.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},r.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},r},{isClass:!0});function H1(r){var e=0,t=1,a=Object.create(null),n=Object.create(null),i=0,o=function(l){var u=n[l];if(!!u&&(delete a[u],delete n[l],--e,t===u)){if(!e){i=0,t=1;return}for(;!hasOwnProperty.call(a,++t););}};return r=Math.abs(r),{hit:function(l){var u=n[l],s=++i;if(a[s]=l,n[l]=s,!u)return++e,e<=r?void 0:(l=a[t],o(l),l);if(delete a[u],t===u)for(;!hasOwnProperty.call(a,++t););},delete:o,clear:function(){e=i=0,t=1,a=Object.create(null),n=Object.create(null)}}}function Va(r){var{hasher:e,limit:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return t=t==null?Number.POSITIVE_INFINITY:t,e=e==null?JSON.stringify:e,function a(){typeof a.cache!="object"&&(a.cache={values:new Map,lru:H1(t||Number.POSITIVE_INFINITY)});for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=e(n);if(a.cache.values.has(o))return a.cache.lru.hit(o),a.cache.values.get(o);var f=r.apply(r,n);return a.cache.values.set(o,f),a.cache.values.delete(a.cache.lru.hit(o)),f}}function fn(r){return Object.keys(r.signatures||{}).reduce(function(e,t){var a=(t.match(/,/g)||[]).length+1;return Math.max(e,a)},-1)}var Z1="DenseMatrix",J1=["Matrix"],X1=q(Z1,J1,r=>{var{Matrix:e}=r;function t(s,c){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(c&&!Wr(c))throw new Error("Invalid datatype: "+c);if(Ve(s))s.type==="DenseMatrix"?(this._data=Ge(s._data),this._size=Ge(s._size),this._datatype=c||s._datatype):(this._data=s.toArray(),this._size=s.size(),this._datatype=c||s._datatype);else if(s&&cr(s.data)&&cr(s.size))this._data=s.data,this._size=s.size,xl(this._data,this._size),this._datatype=c||s.datatype;else if(cr(s))this._data=u(s),this._size=er(this._data),xl(this._data,this._size),this._datatype=c;else{if(s)throw new TypeError("Unsupported type of data ("+br(s)+")");this._data=[],this._size=[0],this._datatype=c}}t.prototype=new e,t.prototype.createDenseMatrix=function(s,c){return new t(s,c)},Object.defineProperty(t,"name",{value:"DenseMatrix"}),t.prototype.constructor=t,t.prototype.type="DenseMatrix",t.prototype.isDenseMatrix=!0,t.prototype.getDataType=function(){return La(this._data,br)},t.prototype.storage=function(){return"dense"},t.prototype.datatype=function(){return this._datatype},t.prototype.create=function(s,c){return new t(s,c)},t.prototype.subset=function(s,c,m){switch(arguments.length){case 1:return a(this,s);case 2:case 3:return i(this,s,c,m);default:throw new SyntaxError("Wrong number of arguments")}},t.prototype.get=function(s){if(!cr(s))throw new TypeError("Array expected");if(s.length!==this._size.length)throw new Ke(s.length,this._size.length);for(var c=0;c<s.length;c++)vr(s[c],this._size[c]);for(var m=this._data,v=0,h=s.length;v<h;v++){var p=s[v];vr(p,m.length),m=m[p]}return m},t.prototype.set=function(s,c,m){if(!cr(s))throw new TypeError("Array expected");if(s.length<this._size.length)throw new Ke(s.length,this._size.length,"<");var v,h,p,g=s.map(function(N){return N+1});l(this,g,m);var y=this._data;for(v=0,h=s.length-1;v<h;v++)p=s[v],vr(p,y.length),y=y[p];return p=s[s.length-1],vr(p,y.length),y[p]=c,this};function a(s,c){if(!li(c))throw new TypeError("Invalid index");var m=c.isScalar();if(m)return s.get(c.min());var v=c.size();if(v.length!==s._size.length)throw new Ke(v.length,s._size.length);for(var h=c.min(),p=c.max(),g=0,y=s._size.length;g<y;g++)vr(h[g],s._size[g]),vr(p[g],s._size[g]);return new t(n(s._data,c,v.length,0),s._datatype)}function n(s,c,m,v){var h=v===m-1,p=c.dimension(v);return h?p.map(function(g){return vr(g,s.length),s[g]}).valueOf():p.map(function(g){vr(g,s.length);var y=s[g];return n(y,c,m,v+1)}).valueOf()}function i(s,c,m,v){if(!c||c.isIndex!==!0)throw new TypeError("Invalid index");var h=c.size(),p=c.isScalar(),g;if(Ve(m)?(g=m.size(),m=m.valueOf()):g=er(m),p){if(g.length!==0)throw new TypeError("Scalar expected");s.set(c.min(),m,v)}else{if(h.length<s._size.length)throw new Ke(h.length,s._size.length,"<");if(g.length<h.length){for(var y=0,N=0;h[y]===1&&g[y]===1;)y++;for(;h[y]===1;)N++,y++;m=Al(m,h.length,N,g)}if(!Ua(h,g))throw new Ke(h,g,">");var d=c.max().map(function(b){return b+1});l(s,d,v);var w=h.length,x=0;o(s._data,c,m,w,x)}return s}function o(s,c,m,v,h){var p=h===v-1,g=c.dimension(h);p?g.forEach(function(y,N){vr(y),s[y]=m[N[0]]}):g.forEach(function(y,N){vr(y),o(s[y],c,m[N[0]],v,h+1)})}t.prototype.resize=function(s,c,m){if(!Ft(s))throw new TypeError("Array or Matrix expected");var v=s.valueOf().map(p=>Array.isArray(p)&&p.length===1?p[0]:p),h=m?this.clone():this;return f(h,v,c)};function f(s,c,m){if(c.length===0){for(var v=s._data;cr(v);)v=v[0];return v}return s._size=c.slice(0),s._data=Qn(s._data,s._size,m),s}t.prototype.reshape=function(s,c){var m=c?this.clone():this;m._data=wl(m._data,s);var v=m._size.reduce((h,p)=>h*p);return m._size=Jo(s,v),m};function l(s,c,m){for(var v=s._size.slice(0),h=!1;v.length<c.length;)v.push(0),h=!0;for(var p=0,g=c.length;p<g;p++)c[p]>v[p]&&(v[p]=c[p],h=!0);h&&f(s,v,m)}t.prototype.clone=function(){var s=new t({data:Ge(this._data),size:Ge(this._size),datatype:this._datatype});return s},t.prototype.size=function(){return this._size.slice(0)},t.prototype.map=function(s){var c=this,m=fn(s),v=function g(y,N){return cr(y)?y.map(function(d,w){return g(d,N.concat(w))}):m===1?s(y):m===2?s(y,N):s(y,N,c)},h=v(this._data,[]),p=this._datatype!==void 0?La(h,br):void 0;return new t(h,p)},t.prototype.forEach=function(s){var c=this,m=function v(h,p){cr(h)?h.forEach(function(g,y){v(g,p.concat(y))}):s(h,p,c)};m(this._data,[])},t.prototype[Symbol.iterator]=function*(){var s=function*c(m,v){if(cr(m))for(var h=0;h<m.length;h++)yield*c(m[h],v.concat(h));else yield{value:m,index:v}};yield*s(this._data,[])},t.prototype.rows=function(){var s=[],c=this.size();if(c.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var m=this._data;for(var v of m)s.push(new t([v],this._datatype));return s},t.prototype.columns=function(){var s=this,c=[],m=this.size();if(m.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var v=this._data,h=function(y){var N=v.map(d=>[d[y]]);c.push(new t(N,s._datatype))},p=0;p<m[1];p++)h(p);return c},t.prototype.toArray=function(){return Ge(this._data)},t.prototype.valueOf=function(){return this._data},t.prototype.format=function(s){return Ye(this._data,s)},t.prototype.toString=function(){return Ye(this._data)},t.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},t.prototype.diagonal=function(s){if(s){if(rr(s)&&(s=s.toNumber()),!tr(s)||!qe(s))throw new TypeError("The parameter k must be an integer number")}else s=0;for(var c=s>0?s:0,m=s<0?-s:0,v=this._size[0],h=this._size[1],p=Math.min(v-m,h-c),g=[],y=0;y<p;y++)g[y]=this._data[y+m][y+c];return new t({data:g,size:[p],datatype:this._datatype})},t.diagonal=function(s,c,m,v){if(!cr(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(E){if(rr(E)&&(E=E.toNumber()),!tr(E)||!qe(E)||E<1)throw new Error("Size values must be positive integers");return E}),m){if(rr(m)&&(m=m.toNumber()),!tr(m)||!qe(m))throw new TypeError("The parameter k must be an integer number")}else m=0;var h=m>0?m:0,p=m<0?-m:0,g=s[0],y=s[1],N=Math.min(g-p,y-h),d;if(cr(c)){if(c.length!==N)throw new Error("Invalid value array length");d=function(A){return c[A]}}else if(Ve(c)){var w=c.size();if(w.length!==1||w[0]!==N)throw new Error("Invalid matrix length");d=function(A){return c.get([A])}}else d=function(){return c};v||(v=rr(d(0))?d(0).mul(0):0);var x=[];if(s.length>0){x=Qn(x,s,v);for(var b=0;b<N;b++)x[b+p][b+h]=d(b)}return new t({data:x,size:[g,y]})},t.fromJSON=function(s){return new t(s)},t.prototype.swapRows=function(s,c){if(!tr(s)||!qe(s)||!tr(c)||!qe(c))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return vr(s,this._size[0]),vr(c,this._size[0]),t._swapRows(s,c,this._data),this},t._swapRows=function(s,c,m){var v=m[s];m[s]=m[c],m[c]=v};function u(s){for(var c=0,m=s.length;c<m;c++){var v=s[c];cr(v)?s[c]=u(v):v&&v.isMatrix===!0&&(s[c]=u(v.valueOf()))}return s}return t},{isClass:!0}),Xl="clone",W1=["typed"],Y1=q(Xl,W1,r=>{var{typed:e}=r;return e(Xl,{any:Ge})});function Wl(r){var e=r.length,t=r[0].length,a,n,i=[];for(n=0;n<t;n++){var o=[];for(a=0;a<e;a++)o.push(r[a][n]);i.push(o)}return i}function aa(r){for(var e=0;e<r.length;e++)if(Ft(r[e]))return!0;return!1}function Xt(r,e){Ve(r)&&(r=r.valueOf());for(var t=0,a=r.length;t<a;t++){var n=r[t];Array.isArray(n)?Xt(n,e):e(n)}}function je(r,e,t){return r&&typeof r.map=="function"?r.map(function(a){return je(a,e)}):e(r)}function Si(r,e,t){var a=Array.isArray(r)?er(r):r.size();if(e<0||e>=a.length)throw new dt(e,a.length);return Ve(r)?r.create(Ci(r.valueOf(),e,t)):Ci(r,e,t)}function Ci(r,e,t){var a,n,i,o;if(e<=0)if(Array.isArray(r[0])){for(o=Wl(r),n=[],a=0;a<o.length;a++)n[a]=Ci(o[a],e-1,t);return n}else{for(i=r[0],a=1;a<r.length;a++)i=t(i,r[a]);return i}else{for(n=[],a=0;a<r.length;a++)n[a]=Ci(r[a],e-1,t);return n}}function Yl(r,e,t,a,n,i,o,f,l,u,s){var c=r._values,m=r._index,v=r._ptr,h,p,g,y;if(a)for(p=v[e],g=v[e+1],h=p;h<g;h++)y=m[h],t[y]!==i?(t[y]=i,o.push(y),u?(a[y]=l?f(c[h],s):f(s,c[h]),n[y]=i):a[y]=c[h]):(a[y]=l?f(c[h],a[y]):f(a[y],c[h]),n[y]=i);else for(p=v[e],g=v[e+1],h=p;h<g;h++)y=m[h],t[y]!==i?(t[y]=i,o.push(y)):n[y]=i}var Ql="isInteger",Q1=["typed"],K1=q(Ql,Q1,r=>{var{typed:e}=r;return e(Ql,{number:qe,BigNumber:function(a){return a.isInt()},Fraction:function(a){return a.d===1&&isFinite(a.n)},"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),bt="number",Fn="number, number";function Kl(r){return Math.abs(r)}Kl.signature=bt;function jl(r,e){return r+e}jl.signature=Fn;function ec(r,e){return r*e}ec.signature=Fn;function rc(r){return-r}rc.signature=bt;function tc(r){return r}tc.signature=bt;function Ga(r){return tg(r)}Ga.signature=bt;function nc(r){return r*r*r}nc.signature=bt;function ac(r){return Math.exp(r)}ac.signature=bt;function ic(r){return ng(r)}ic.signature=bt;function oc(r,e){if(!qe(r)||!qe(e))throw new Error("Parameters in function gcd must be integer numbers");for(var t;e!==0;)t=r%e,r=e,e=t;return r<0?-r:r}oc.signature=Fn;function sc(r,e){if(!qe(r)||!qe(e))throw new Error("Parameters in function lcm must be integer numbers");if(r===0||e===0)return 0;for(var t,a=r*e;e!==0;)t=e,e=r%t,r=t;return Math.abs(a/r)}sc.signature=Fn;function j1(r,e){return e?Math.log(r)/Math.log(e):Math.log(r)}function uc(r){return eg(r)}uc.signature=bt;function lc(r){return j0(r)}lc.signature=bt;function cc(r,e){if(e>0)return r-e*Math.floor(r/e);if(e===0)return r;throw new Error("Cannot calculate mod for a negative divisor")}cc.signature=Fn;function fc(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,t=e<0;if(t&&(e=-e),e===0)throw new Error("Root must be non-zero");if(r<0&&Math.abs(e)%2!==1)throw new Error("Root must be odd when a is negative.");if(r===0)return t?1/0:0;if(!isFinite(r))return t?0:r;var a=Math.pow(Math.abs(r),1/e);return a=r<0?-a:a,t?1/a:a}function os(r){return an(r)}os.signature=bt;function mc(r){return r*r}mc.signature=bt;function vc(r,e){var t,a,n,i=0,o=1,f=1,l=0;if(!qe(r)||!qe(e))throw new Error("Parameters in function xgcd must be integer numbers");for(;e;)a=Math.floor(r/e),n=r-a*e,t=i,i=o-a*i,o=t,t=f,f=l-a*f,l=t,r=e,e=n;var u;return r<0?u=[-r,-o,-l]:u=[r,r?o:0,l],u}vc.signature=Fn;function pc(r,e){return r*r<1&&e===1/0||r*r>1&&e===-1/0?0:Math.pow(r,e)}pc.signature=Fn;function hc(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!qe(e)||e<0||e>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(hl(r,e))}var ey="number",ia="number, number";function dc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitAnd");return r&e}dc.signature=ia;function gc(r){if(!qe(r))throw new Error("Integer expected in function bitNot");return~r}gc.signature=ey;function yc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitOr");return r|e}yc.signature=ia;function bc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitXor");return r^e}bc.signature=ia;function xc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function leftShift");return r<<e}xc.signature=ia;function wc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function rightArithShift");return r>>e}wc.signature=ia;function Nc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function rightLogShift");return r>>>e}Nc.signature=ia;function Wt(r,e){if(e<r)return 1;if(e===r)return e;var t=e+r>>1;return Wt(r,t)*Wt(t+1,e)}function Dc(r,e){if(!qe(r)||r<0)throw new TypeError("Positive integer value expected in function combinations");if(!qe(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(e>r)throw new TypeError("k must be less than or equal to n");for(var t=r-e,a=1,n=e<t?t+1:e+1,i=2,o=e<t?e:t,f=n;f<=r;++f)for(a*=f;i<=o&&a%i===0;)a/=i,++i;return i<=o&&(a/=Wt(i,o)),a}Dc.signature="number, number";var ry=Math.PI,ty=2*Math.PI,ny=Math.E,ay=1.618033988749895,iy="number",ss="number, number";function Ac(r){return!r}Ac.signature=iy;function Ec(r,e){return!!(r||e)}Ec.signature=ss;function Sc(r,e){return!!r!=!!e}Sc.signature=ss;function Cc(r,e){return!!(r&&e)}Cc.signature=ss;function Mi(r){var e;if(qe(r))return r<=0?isFinite(r)?1/0:NaN:r>171?1/0:Wt(1,r-1);if(r<.5)return Math.PI/(Math.sin(Math.PI*r)*Mi(1-r));if(r>=171.35)return 1/0;if(r>85){var t=r*r,a=t*r,n=a*r,i=n*r;return Math.sqrt(2*Math.PI/r)*Math.pow(r/Math.E,r)*(1+1/(12*r)+1/(288*t)-139/(51840*a)-571/(2488320*n)+163879/(209018880*i)+5246819/(75246796800*i*r))}--r,e=oa[0];for(var o=1;o<oa.length;++o)e+=oa[o]/(r+o);var f=r+Mc+.5;return Math.sqrt(2*Math.PI)*Math.pow(f,r+.5)*Math.exp(-f)*e}Mi.signature="number";var Mc=4.7421875,oa=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],Fc=.9189385332046728,oy=5,sy=7,Tc=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function Fi(r){if(r<0)return NaN;if(r===0)return 1/0;if(!isFinite(r))return r;if(r<.5)return Math.log(Math.PI/Math.sin(Math.PI*r))-Fi(1-r);r=r-1;for(var e=r+oy+.5,t=Tc[0],a=sy-1;a>=1;a--)t+=Tc[a]/(r+a);return Fc+(r+.5)*Math.log(e)-e+Math.log(t)}Fi.signature="number";var Hr="number";function Bc(r){return ug(r)}Bc.signature=Hr;function $c(r){return Math.atan(1/r)}$c.signature=Hr;function Oc(r){return isFinite(r)?(Math.log((r+1)/r)+Math.log(r/(r-1)))/2:0}Oc.signature=Hr;function Ic(r){return Math.asin(1/r)}Ic.signature=Hr;function Rc(r){var e=1/r;return Math.log(e+Math.sqrt(e*e+1))}Rc.signature=Hr;function _c(r){return Math.acos(1/r)}_c.signature=Hr;function qc(r){var e=1/r,t=Math.sqrt(e*e-1);return Math.log(t+e)}qc.signature=Hr;function zc(r){return lg(r)}zc.signature=Hr;function Pc(r){return cg(r)}Pc.signature=Hr;function Uc(r){return 1/Math.tan(r)}Uc.signature=Hr;function Lc(r){var e=Math.exp(2*r);return(e+1)/(e-1)}Lc.signature=Hr;function kc(r){return 1/Math.sin(r)}kc.signature=Hr;function Vc(r){return r===0?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(r)-Math.exp(-r)))*an(r)}Vc.signature=Hr;function Gc(r){return 1/Math.cos(r)}Gc.signature=Hr;function Hc(r){return 2/(Math.exp(r)+Math.exp(-r))}Hc.signature=Hr;function Zc(r){return mg(r)}Zc.signature=Hr;var Ti="number";function Jc(r){return r<0}Jc.signature=Ti;function Xc(r){return r>0}Xc.signature=Ti;function Wc(r){return r===0}Wc.signature=Ti;function Yc(r){return Number.isNaN(r)}Yc.signature=Ti;var Qc="isNegative",uy=["typed"],ly=q(Qc,uy,r=>{var{typed:e}=r;return e(Qc,{number:Jc,BigNumber:function(a){return a.isNeg()&&!a.isZero()&&!a.isNaN()},Fraction:function(a){return a.s<0},Unit:e.referToSelf(t=>a=>e.find(t,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Kc="isNumeric",cy=["typed"],fy=q(Kc,cy,r=>{var{typed:e}=r;return e(Kc,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),jc="hasNumericValue",my=["typed","isNumeric"],vy=q(jc,my,r=>{var{typed:e,isNumeric:t}=r;return e(jc,{boolean:()=>!0,string:function(n){return n.trim().length>0&&!isNaN(Number(n))},any:function(n){return t(n)}})}),ef="isPositive",py=["typed"],hy=q(ef,py,r=>{var{typed:e}=r;return e(ef,{number:Xc,BigNumber:function(a){return!a.isNeg()&&!a.isZero()&&!a.isNaN()},Fraction:function(a){return a.s>0&&a.n>0},Unit:e.referToSelf(t=>a=>e.find(t,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),rf="isZero",dy=["typed"],gy=q(rf,dy,r=>{var{typed:e}=r;return e(rf,{number:Wc,BigNumber:function(a){return a.isZero()},Complex:function(a){return a.re===0&&a.im===0},Fraction:function(a){return a.d===1&&a.n===0},Unit:e.referToSelf(t=>a=>e.find(t,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),tf="isNaN",yy=["typed"],by=q(tf,yy,r=>{var{typed:e}=r;return e(tf,{number:Yc,BigNumber:function(a){return a.isNaN()},Fraction:function(a){return!1},Complex:function(a){return a.isNaN()},Unit:function(a){return Number.isNaN(a.value)},"Array | Matrix":function(a){return je(a,Number.isNaN)}})}),nf="typeOf",xy=["typed"],wy=q(nf,xy,r=>{var{typed:e}=r;return e(nf,{any:br})});function Bt(r,e,t){if(t==null)return r.eq(e);if(r.eq(e))return!0;if(r.isNaN()||e.isNaN())return!1;if(r.isFinite()&&e.isFinite()){var a=r.minus(e).abs();if(a.isZero())return!0;var n=r.constructor.max(r.abs(),e.abs());return a.lte(n.times(t))}return!1}function Ny(r,e,t){return nt(r.re,e.re,t)&&nt(r.im,e.im,t)}var sa=q("compareUnits",["typed"],r=>{var{typed:e}=r;return{"Unit, Unit":e.referToSelf(t=>(a,n)=>{if(!a.equalBase(n))throw new Error("Cannot compare units with different base");return e.find(t,[a.valueType(),n.valueType()])(a.value,n.value)})}}),Bi="equalScalar",Dy=["typed","config"],Ay=q(Bi,Dy,r=>{var{typed:e,config:t}=r,a=sa({typed:e});return e(Bi,{"boolean, boolean":function(i,o){return i===o},"number, number":function(i,o){return nt(i,o,t.epsilon)},"BigNumber, BigNumber":function(i,o){return i.eq(o)||Bt(i,o,t.epsilon)},"Fraction, Fraction":function(i,o){return i.equals(o)},"Complex, Complex":function(i,o){return Ny(i,o,t.epsilon)}},a)});q(Bi,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Bi,{"number, number":function(n,i){return nt(n,i,t.epsilon)}})});var Ey="SparseMatrix",Sy=["typed","equalScalar","Matrix"],Cy=q(Ey,Sy,r=>{var{typed:e,equalScalar:t,Matrix:a}=r;function n(p,g){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(g&&!Wr(g))throw new Error("Invalid datatype: "+g);if(Ve(p))i(this,p,g);else if(p&&cr(p.index)&&cr(p.ptr)&&cr(p.size))this._values=p.values,this._index=p.index,this._ptr=p.ptr,this._size=p.size,this._datatype=g||p.datatype;else if(cr(p))o(this,p,g);else{if(p)throw new TypeError("Unsupported type of data ("+br(p)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=g}}function i(p,g,y){g.type==="SparseMatrix"?(p._values=g._values?Ge(g._values):void 0,p._index=Ge(g._index),p._ptr=Ge(g._ptr),p._size=Ge(g._size),p._datatype=y||g._datatype):o(p,g.valueOf(),y||g._datatype)}function o(p,g,y){p._values=[],p._index=[],p._ptr=[],p._datatype=y;var N=g.length,d=0,w=t,x=0;if(Wr(y)&&(w=e.find(t,[y,y])||t,x=e.convert(0,y)),N>0){var b=0;do{p._ptr.push(p._index.length);for(var E=0;E<N;E++){var A=g[E];if(cr(A)){if(b===0&&d<A.length&&(d=A.length),b<A.length){var S=A[b];w(S,x)||(p._values.push(S),p._index.push(E))}}else b===0&&d<1&&(d=1),w(A,x)||(p._values.push(A),p._index.push(E))}b++}while(b<d)}p._ptr.push(p._index.length),p._size=[N,d]}n.prototype=new a,n.prototype.createSparseMatrix=function(p,g){return new n(p,g)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return La(this._values,br)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(p,g){return new n(p,g)},n.prototype.density=function(){var p=this._size[0],g=this._size[1];return p!==0&&g!==0?this._index.length/(p*g):0},n.prototype.subset=function(p,g,y){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return f(this,p);case 2:case 3:return l(this,p,g,y);default:throw new SyntaxError("Wrong number of arguments")}};function f(p,g){if(!li(g))throw new TypeError("Invalid index");var y=g.isScalar();if(y)return p.get(g.min());var N=g.size();if(N.length!==p._size.length)throw new Ke(N.length,p._size.length);var d,w,x,b,E=g.min(),A=g.max();for(d=0,w=p._size.length;d<w;d++)vr(E[d],p._size[d]),vr(A[d],p._size[d]);var S=p._values,D=p._index,T=p._ptr,B=g.dimension(0),I=g.dimension(1),P=[],R=[];B.forEach(function($,k){R[$]=k[0],P[$]=!0});var M=S?[]:void 0,F=[],H=[];return I.forEach(function($){for(H.push(F.length),x=T[$],b=T[$+1];x<b;x++)d=D[x],P[d]===!0&&(F.push(R[d]),M&&M.push(S[x]))}),H.push(F.length),new n({values:M,index:F,ptr:H,size:N,datatype:p._datatype})}function l(p,g,y,N){if(!g||g.isIndex!==!0)throw new TypeError("Invalid index");var d=g.size(),w=g.isScalar(),x;if(Ve(y)?(x=y.size(),y=y.toArray()):x=er(y),w){if(x.length!==0)throw new TypeError("Scalar expected");p.set(g.min(),y,N)}else{if(d.length!==1&&d.length!==2)throw new Ke(d.length,p._size.length,"<");if(x.length<d.length){for(var b=0,E=0;d[b]===1&&x[b]===1;)b++;for(;d[b]===1;)E++,b++;y=Al(y,d.length,E,x)}if(!Ua(d,x))throw new Ke(d,x,">");if(d.length===1){var A=g.dimension(0);A.forEach(function(T,B){vr(T),p.set([T,0],y[B[0]],N)})}else{var S=g.dimension(0),D=g.dimension(1);S.forEach(function(T,B){vr(T),D.forEach(function(I,P){vr(I),p.set([T,I],y[B[0]][P[0]],N)})})}}return p}n.prototype.get=function(p){if(!cr(p))throw new TypeError("Array expected");if(p.length!==this._size.length)throw new Ke(p.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var g=p[0],y=p[1];vr(g,this._size[0]),vr(y,this._size[1]);var N=u(g,this._ptr[y],this._ptr[y+1],this._index);return N<this._ptr[y+1]&&this._index[N]===g?this._values[N]:0},n.prototype.set=function(p,g,y){if(!cr(p))throw new TypeError("Array expected");if(p.length!==this._size.length)throw new Ke(p.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var N=p[0],d=p[1],w=this._size[0],x=this._size[1],b=t,E=0;Wr(this._datatype)&&(b=e.find(t,[this._datatype,this._datatype])||t,E=e.convert(0,this._datatype)),(N>w-1||d>x-1)&&(m(this,Math.max(N+1,w),Math.max(d+1,x),y),w=this._size[0],x=this._size[1]),vr(N,w),vr(d,x);var A=u(N,this._ptr[d],this._ptr[d+1],this._index);return A<this._ptr[d+1]&&this._index[A]===N?b(g,E)?s(A,d,this._values,this._index,this._ptr):this._values[A]=g:b(g,E)||c(A,N,d,g,this._values,this._index,this._ptr),this};function u(p,g,y,N){if(y-g===0)return y;for(var d=g;d<y;d++)if(N[d]===p)return d;return g}function s(p,g,y,N,d){y.splice(p,1),N.splice(p,1);for(var w=g+1;w<d.length;w++)d[w]--}function c(p,g,y,N,d,w,x){d.splice(p,0,N),w.splice(p,0,g);for(var b=y+1;b<x.length;b++)x[b]++}n.prototype.resize=function(p,g,y){if(!Ft(p))throw new TypeError("Array or Matrix expected");var N=p.valueOf().map(w=>Array.isArray(w)&&w.length===1?w[0]:w);if(N.length!==2)throw new Error("Only two dimensions matrix are supported");N.forEach(function(w){if(!tr(w)||!qe(w)||w<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Ye(N)+")")});var d=y?this.clone():this;return m(d,N[0],N[1],g)};function m(p,g,y,N){var d=N||0,w=t,x=0;Wr(p._datatype)&&(w=e.find(t,[p._datatype,p._datatype])||t,x=e.convert(0,p._datatype),d=e.convert(d,p._datatype));var b=!w(d,x),E=p._size[0],A=p._size[1],S,D,T;if(y>A){for(D=A;D<y;D++)if(p._ptr[D]=p._values.length,b)for(S=0;S<E;S++)p._values.push(d),p._index.push(S);p._ptr[y]=p._values.length}else y<A&&(p._ptr.splice(y+1,A-y),p._values.splice(p._ptr[y],p._values.length),p._index.splice(p._ptr[y],p._index.length));if(A=y,g>E){if(b){var B=0;for(D=0;D<A;D++){p._ptr[D]=p._ptr[D]+B,T=p._ptr[D+1]+B;var I=0;for(S=E;S<g;S++,I++)p._values.splice(T+I,0,d),p._index.splice(T+I,0,S),B++}p._ptr[A]=p._values.length}}else if(g<E){var P=0;for(D=0;D<A;D++){p._ptr[D]=p._ptr[D]-P;var R=p._ptr[D],M=p._ptr[D+1]-P;for(T=R;T<M;T++)S=p._index[T],S>g-1&&(p._values.splice(T,1),p._index.splice(T,1),P++)}p._ptr[D]=p._values.length}return p._size[0]=g,p._size[1]=y,p}n.prototype.reshape=function(p,g){if(!cr(p))throw new TypeError("Array expected");if(p.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");p.forEach(function($){if(!tr($)||!qe($)||$<=-2||$===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Ye(p)+")")});var y=this._size[0]*this._size[1];p=Jo(p,y);var N=p[0]*p[1];if(y!==N)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var d=g?this.clone():this;if(this._size[0]===p[0]&&this._size[1]===p[1])return d;for(var w=[],x=0;x<d._ptr.length;x++)for(var b=0;b<d._ptr[x+1]-d._ptr[x];b++)w.push(x);for(var E=d._values.slice(),A=d._index.slice(),S=0;S<d._index.length;S++){var D=A[S],T=w[S],B=D*d._size[1]+T;w[S]=B%p[1],A[S]=Math.floor(B/p[1])}d._values.length=0,d._index.length=0,d._ptr.length=p[1]+1,d._size=p.slice();for(var I=0;I<d._ptr.length;I++)d._ptr[I]=0;for(var P=0;P<E.length;P++){var R=A[P],M=w[P],F=E[P],H=u(R,d._ptr[M],d._ptr[M+1],d._index);c(H,R,M,F,d._values,d._index,d._ptr)}return d},n.prototype.clone=function(){var p=new n({values:this._values?Ge(this._values):void 0,index:Ge(this._index),ptr:Ge(this._ptr),size:Ge(this._size),datatype:this._datatype});return p},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(p,g){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var y=this,N=this._size[0],d=this._size[1],w=fn(p),x=function(E,A,S){return w===1?p(E):w===2?p(E,[A,S]):p(E,[A,S],y)};return v(this,0,N-1,0,d-1,x,g)};function v(p,g,y,N,d,w,x){var b=[],E=[],A=[],S=t,D=0;Wr(p._datatype)&&(S=e.find(t,[p._datatype,p._datatype])||t,D=e.convert(0,p._datatype));for(var T=function(L,j,ae){L=w(L,j,ae),S(L,D)||(b.push(L),E.push(j))},B=N;B<=d;B++){A.push(b.length);var I=p._ptr[B],P=p._ptr[B+1];if(x)for(var R=I;R<P;R++){var M=p._index[R];M>=g&&M<=y&&T(p._values[R],M-g,B-N)}else{for(var F={},H=I;H<P;H++){var $=p._index[H];F[$]=p._values[H]}for(var k=g;k<=y;k++){var Q=k in F?F[k]:0;T(Q,k-g,B-N)}}}return A.push(b.length),new n({values:b,index:E,ptr:A,size:[y-g+1,d-N+1]})}n.prototype.forEach=function(p,g){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var y=this,N=this._size[0],d=this._size[1],w=0;w<d;w++){var x=this._ptr[w],b=this._ptr[w+1];if(g)for(var E=x;E<b;E++){var A=this._index[E];p(this._values[E],[A,w],y)}else{for(var S={},D=x;D<b;D++){var T=this._index[D];S[T]=this._values[D]}for(var B=0;B<N;B++){var I=B in S?S[B]:0;p(I,[B,w],y)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var p=this._size[1],g=0;g<p;g++)for(var y=this._ptr[g],N=this._ptr[g+1],d=y;d<N;d++){var w=this._index[d];yield{value:this._values[d],index:[w,g]}}},n.prototype.toArray=function(){return h(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return h(this._values,this._index,this._ptr,this._size,!1)};function h(p,g,y,N,d){var w=N[0],x=N[1],b=[],E,A;for(E=0;E<w;E++)for(b[E]=[],A=0;A<x;A++)b[E][A]=0;for(A=0;A<x;A++)for(var S=y[A],D=y[A+1],T=S;T<D;T++)E=g[T],b[E][A]=p?d?Ge(p[T]):p[T]:1;return b}return n.prototype.format=function(p){for(var g=this._size[0],y=this._size[1],N=this.density(),d="Sparse Matrix ["+Ye(g,p)+" x "+Ye(y,p)+"] density: "+Ye(N,p)+`
|
|
28
28
|
`,w=0;w<y;w++)for(var x=this._ptr[w],b=this._ptr[w+1],E=x;E<b;E++){var A=this._index[E];d+=`
|
|
29
|
-
(`+Ye(A,p)+", "+Ye(w,p)+") ==> "+(this._values?Ye(this._values[E],p):"X")}return d},n.prototype.toString=function(){return Ye(this.toArray())},n.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(p){if(p){if(rr(p)&&(p=p.toNumber()),!tr(p)||!qe(p))throw new TypeError("The parameter k must be an integer number")}else p=0;var g=p>0?p:0,y=p<0?-p:0,N=this._size[0],d=this._size[1],w=Math.min(N-y,d-g),x=[],b=[],E=[];E[0]=0;for(var A=g;A<d&&x.length<w;A++)for(var S=this._ptr[A],D=this._ptr[A+1],T=S;T<D;T++){var B=this._index[T];if(B===A-g+y){x.push(this._values[T]),b[x.length-1]=B-y;break}}return E.push(x.length),new n({values:x,index:b,ptr:E,size:[w,1]})},n.fromJSON=function(p){return new n(p)},n.diagonal=function(p,g,y,N,d){if(!cr(p))throw new TypeError("Array expected, size parameter");if(p.length!==2)throw new Error("Only two dimensions matrix are supported");if(p=p.map(function($){if(rr($)&&($=$.toNumber()),!tr($)||!qe($)||$<1)throw new Error("Size values must be positive integers");return $}),y){if(rr(y)&&(y=y.toNumber()),!tr(y)||!qe(y))throw new TypeError("The parameter k must be an integer number")}else y=0;var w=t,x=0;Wr(d)&&(w=e.find(t,[d,d])||t,x=e.convert(0,d));var b=y>0?y:0,E=y<0?-y:0,A=p[0],S=p[1],D=Math.min(A-E,S-b),T;if(cr(g)){if(g.length!==D)throw new Error("Invalid value array length");T=function(k){return g[k]}}else if(Ve(g)){var B=g.size();if(B.length!==1||B[0]!==D)throw new Error("Invalid matrix length");T=function(k){return g.get([k])}}else T=function(){return g};for(var I=[],P=[],R=[],M=0;M<S;M++){R.push(I.length);var F=M-b;if(F>=0&&F<D){var H=T(F);w(H,x)||(P.push(F+E),I.push(H))}}return R.push(I.length),new n({values:I,index:P,ptr:R,size:[A,S]})},n.prototype.swapRows=function(p,g){if(!tr(p)||!qe(p)||!tr(g)||!qe(g))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return vr(p,this._size[0]),vr(g,this._size[0]),n._swapRows(p,g,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(p,g,y,N,d){for(var w=N[p],x=N[p+1],b=w;b<x;b++)d(y[b],g[b])},n._swapRows=function(p,g,y,N,d,w){for(var x=0;x<y;x++){var b=w[x],E=w[x+1],A=u(p,b,E,d),S=u(g,b,E,d);if(A<E&&S<E&&d[A]===p&&d[S]===g){if(N){var D=N[A];N[A]=N[S],N[S]=D}continue}if(A<E&&d[A]===p&&(S>=E||d[S]!==g)){var T=N?N[A]:void 0;d.splice(S,0,g),N&&N.splice(S,0,T),d.splice(S<=A?A+1:A,1),N&&N.splice(S<=A?A+1:A,1);continue}if(S<E&&d[S]===g&&(A>=E||d[A]!==p)){var B=N?N[S]:void 0;d.splice(A,0,p),N&&N.splice(A,0,B),d.splice(A<=S?S+1:S,1),N&&N.splice(A<=S?S+1:S,1)}}},n},{isClass:!0}),xy="number",wy=["typed"];function Ny(r){var e=r.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(e){var t={"0b":2,"0o":8,"0x":16}[e[1]],a=e[2],n=e[3];return{input:r,radix:t,integerPart:a,fractionalPart:n}}else return null}function Dy(r){for(var e=parseInt(r.integerPart,r.radix),t=0,a=0;a<r.fractionalPart.length;a++){var n=parseInt(r.fractionalPart[a],r.radix);t+=n/Math.pow(r.radix,a+1)}var i=e+t;if(isNaN(i))throw new SyntaxError('String "'+r.input+'" is no valid number');return i}var Ay=q(xy,wy,r=>{var{typed:e}=r,t=e("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var i=Ny(n);if(i)return Dy(i);var o=0,f=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);f&&(o=Number(f[2]),n=f[1]);var l=Number(n);if(isNaN(l))throw new SyntaxError('String "'+n+'" is no valid number');if(f){if(l>2**o-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));l>=2**(o-1)&&(l=l-2**o)}return l},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:function(n){throw new Error("Second argument with valueless unit expected")},null:function(n){return 0},"Unit, string | Unit":function(n,i){return n.toNumber(i)},"Array | Matrix":e.referToSelf(a=>n=>je(n,a))});return t.fromJSON=function(a){return parseFloat(a.value)},t}),tf="string",Ey=["typed"],Sy=q(tf,Ey,r=>{var{typed:e}=r;return e(tf,{"":function(){return""},number:Sn,null:function(a){return"null"},boolean:function(a){return a+""},string:function(a){return a},"Array | Matrix":e.referToSelf(t=>a=>je(a,t)),any:function(a){return String(a)}})}),nf="boolean",Cy=["typed"],My=q(nf,Cy,r=>{var{typed:e}=r;return e(nf,{"":function(){return!1},boolean:function(a){return a},number:function(a){return!!a},null:function(a){return!1},BigNumber:function(a){return!a.isZero()},string:function(a){var n=a.toLowerCase();if(n==="true")return!0;if(n==="false")return!1;var i=Number(a);if(a!==""&&!isNaN(i))return!!i;throw new Error('Cannot convert "'+a+'" to a boolean')},"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Fy="bignumber",Ty=["typed","BigNumber"],By=q(Fy,Ty,r=>{var{typed:e,BigNumber:t}=r;return e("bignumber",{"":function(){return new t(0)},number:function(n){return new t(n+"")},string:function(n){var i=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(i){var o=i[2],f=t(i[1]),l=new t(2).pow(Number(o));if(f.gt(l.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var u=new t(2).pow(Number(o)-1);return f.gte(u)?f.sub(l):f}return new t(n)},BigNumber:function(n){return n},Fraction:function(n){return new t(n.n).div(n.d).times(n.s)},null:function(n){return new t(0)},"Array | Matrix":e.referToSelf(a=>n=>je(n,a))})}),$y="complex",Oy=["typed","Complex"],Iy=q($y,Oy,r=>{var{typed:e,Complex:t}=r;return e("complex",{"":function(){return t.ZERO},number:function(n){return new t(n,0)},"number, number":function(n,i){return new t(n,i)},"BigNumber, BigNumber":function(n,i){return new t(n.toNumber(),i.toNumber())},Fraction:function(n){return new t(n.valueOf(),0)},Complex:function(n){return n.clone()},string:function(n){return t(n)},null:function(n){return t(0)},Object:function(n){if("re"in n&&"im"in n)return new t(n.re,n.im);if("r"in n&&"phi"in n||"abs"in n&&"arg"in n)return new t(n);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":e.referToSelf(a=>n=>je(n,a))})}),Ry="fraction",_y=["typed","Fraction"],qy=q(Ry,_y,r=>{var{typed:e,Fraction:t}=r;return e("fraction",{number:function(n){if(!isFinite(n)||isNaN(n))throw new Error(n+" cannot be represented as a fraction");return new t(n)},string:function(n){return new t(n)},"number, number":function(n,i){return new t(n,i)},null:function(n){return new t(0)},BigNumber:function(n){return new t(n.toString())},Fraction:function(n){return n},Object:function(n){return new t(n)},"Array | Matrix":e.referToSelf(a=>n=>je(n,a))})}),af="matrix",zy=["typed","Matrix","DenseMatrix","SparseMatrix"],Py=q(af,zy,r=>{var{typed:e,Matrix:t,DenseMatrix:a,SparseMatrix:n}=r;return e(af,{"":function(){return i([])},string:function(f){return i([],f)},"string, string":function(f,l){return i([],f,l)},Array:function(f){return i(f)},Matrix:function(f){return i(f,f.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(o,f,l){if(f==="dense"||f==="default"||f===void 0)return new a(o,l);if(f==="sparse")return new n(o,l);throw new TypeError("Unknown matrix type "+JSON.stringify(f)+".")}}),of="matrixFromFunction",Uy=["typed","matrix","isZero"],Ly=q(of,Uy,r=>{var{typed:e,matrix:t,isZero:a}=r;return e(of,{"Array | Matrix, function, string, string":function(o,f,l,u){return n(o,f,l,u)},"Array | Matrix, function, string":function(o,f,l){return n(o,f,l)},"Matrix, function":function(o,f){return n(o,f,"dense")},"Array, function":function(o,f){return n(o,f,"dense").toArray()},"Array | Matrix, string, function":function(o,f,l){return n(o,l,f)},"Array | Matrix, string, string, function":function(o,f,l,u){return n(o,u,f,l)}});function n(i,o,f,l){var u;return l!==void 0?u=t(f,l):u=t(f),u.resize(i),u.forEach(function(s,c){var m=o(c);a(m)||u.set(c,m)}),u}}),sf="matrixFromRows",ky=["typed","matrix","flatten","size"],Vy=q(sf,ky,r=>{var{typed:e,matrix:t,flatten:a,size:n}=r;return e(sf,{"...Array":function(l){return i(l)},"...Matrix":function(l){return t(i(l.map(u=>u.toArray())))}});function i(f){if(f.length===0)throw new TypeError("At least one row is needed to construct a matrix.");var l=o(f[0]),u=[];for(var s of f){var c=o(s);if(c!==l)throw new TypeError("The vectors had different length: "+(l|0)+" \u2260 "+(c|0));u.push(a(s))}return u}function o(f){var l=n(f);if(l.length===1)return l[0];if(l.length===2){if(l[0]===1)return l[1];if(l[1]===1)return l[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),uf="matrixFromColumns",Gy=["typed","matrix","flatten","size"],Hy=q(uf,Gy,r=>{var{typed:e,matrix:t,flatten:a,size:n}=r;return e(uf,{"...Array":function(l){return i(l)},"...Matrix":function(l){return t(i(l.map(u=>u.toArray())))}});function i(f){if(f.length===0)throw new TypeError("At least one column is needed to construct a matrix.");for(var l=o(f[0]),u=[],s=0;s<l;s++)u[s]=[];for(var c of f){var m=o(c);if(m!==l)throw new TypeError("The vectors had different length: "+(l|0)+" \u2260 "+(m|0));for(var v=a(c),h=0;h<l;h++)u[h].push(v[h])}return u}function o(f){var l=n(f);if(l.length===1)return l[0];if(l.length===2){if(l[0]===1)return l[1];if(l[1]===1)return l[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),lf="splitUnit",Zy=["typed"],Jy=q(lf,Zy,r=>{var{typed:e}=r;return e(lf,{"Unit, Array":function(a,n){return a.splitUnit(n)}})}),cf="unaryMinus",Xy=["typed"],Wy=q(cf,Xy,r=>{var{typed:e}=r;return e(cf,{number:jl,"Complex | BigNumber | Fraction":t=>t.neg(),Unit:e.referToSelf(t=>a=>{var n=a.clone();return n.value=e.find(t,n.valueType())(a.value),n}),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),ff="unaryPlus",Yy=["typed","config","BigNumber"],Qy=q(ff,Yy,r=>{var{typed:e,config:t,BigNumber:a}=r;return e(ff,{number:ec,Complex:function(i){return i},BigNumber:function(i){return i},Fraction:function(i){return i},Unit:function(i){return i.clone()},"Array | Matrix":e.referToSelf(n=>i=>je(i,n)),"boolean | string":function(i){return t.number==="BigNumber"?new a(+i):+i}})}),mf="abs",Ky=["typed"],jy=q(mf,Ky,r=>{var{typed:e}=r;return e(mf,{number:Yl,"Complex | BigNumber | Fraction | Unit":t=>t.abs(),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),vf="apply",eb=["typed","isInteger"],pf=q(vf,eb,r=>{var{typed:e,isInteger:t}=r;return e(vf,{"Array | Matrix, number | BigNumber, function":function(n,i,o){if(!t(i))throw new TypeError("Integer number expected for dimension");var f=Array.isArray(n)?er(n):n.size();if(i<0||i>=f.length)throw new ht(i,f.length);return Ve(n)?n.create($i(n.valueOf(),i,o)):$i(n,i,o)}})});function $i(r,e,t){var a,n,i;if(e<=0)if(Array.isArray(r[0])){for(i=rb(r),n=[],a=0;a<i.length;a++)n[a]=$i(i[a],e-1,t);return n}else return t(r);else{for(n=[],a=0;a<r.length;a++)n[a]=$i(r[a],e-1,t);return n}}function rb(r){var e=r.length,t=r[0].length,a,n,i=[];for(n=0;n<t;n++){var o=[];for(a=0;a<e;a++)o.push(r[a][n]);i.push(o)}return i}var hf="addScalar",tb=["typed"],nb=q(hf,tb,r=>{var{typed:e}=r;return e(hf,{"number, number":Ql,"Complex, Complex":function(a,n){return a.add(n)},"BigNumber, BigNumber":function(a,n){return a.plus(n)},"Fraction, Fraction":function(a,n){return a.add(n)},"Unit, Unit":e.referToSelf(t=>(a,n)=>{if(a.value===null||a.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!a.equalBase(n))throw new Error("Units do not match");var i=a.clone();return i.value=e.find(t,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i})})}),df="cbrt",ab=["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],ib=q(df,ab,r=>{var{config:e,typed:t,isNegative:a,unaryMinus:n,matrix:i,Complex:o,BigNumber:f,Fraction:l}=r;return t(df,{number:Va,Complex:u,"Complex, boolean":u,BigNumber:function(m){return m.cbrt()},Unit:s});function u(c,m){var v=c.arg()/3,h=c.abs(),p=new o(Va(h),0).mul(new o(0,v).exp());if(m){var g=[p,new o(Va(h),0).mul(new o(0,v+Math.PI*2/3).exp()),new o(Va(h),0).mul(new o(0,v-Math.PI*2/3).exp())];return e.matrix==="Array"?g:i(g)}else return p}function s(c){if(c.value&&Lt(c.value)){var m=c.clone();return m.value=1,m=m.pow(1/3),m.value=u(c.value),m}else{var v=a(c.value);v&&(c.value=n(c.value));var h;rr(c.value)?h=new f(1).div(3):qa(c.value)?h=new l(1,3):h=1/3;var p=c.pow(h);return v&&(p.value=n(p.value)),p}}}),ob="matAlgo11xS0s",sb=["typed","equalScalar"],Lr=q(ob,sb,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o,f){var l=n._values,u=n._index,s=n._ptr,c=n._size,m=n._datatype;if(!l)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=c[0],h=c[1],p,g=t,y=0,N=o;typeof m=="string"&&(p=m,g=e.find(t,[p,p]),y=e.convert(0,p),i=e.convert(i,p),N=e.find(o,[p,p]));for(var d=[],w=[],x=[],b=0;b<h;b++){x[b]=w.length;for(var E=s[b],A=s[b+1],S=E;S<A;S++){var D=u[S],T=f?N(i,l[S]):N(l[S],i);g(T,y)||(w.push(D),d.push(T))}}return x[h]=w.length,n.createSparseMatrix({values:d,index:w,ptr:x,size:[v,h],datatype:p})}}),ub="matAlgo12xSfs",lb=["typed","DenseMatrix"],Ir=q(ub,lb,r=>{var{typed:e,DenseMatrix:t}=r;return function(n,i,o,f){var l=n._values,u=n._index,s=n._ptr,c=n._size,m=n._datatype;if(!l)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=c[0],h=c[1],p,g=o;typeof m=="string"&&(p=m,i=e.convert(i,p),g=e.find(o,[p,p]));for(var y=[],N=[],d=[],w=0;w<h;w++){for(var x=w+1,b=s[w],E=s[w+1],A=b;A<E;A++){var S=u[A];N[S]=l[A],d[S]=x}for(var D=0;D<v;D++)w===0&&(y[D]=[]),d[D]===x?y[D][w]=f?g(i,N[D]):g(N[D],i):y[D][w]=f?g(i,0):g(0,i)}return new t({data:y,size:[v,h],datatype:p})}}),cb="matAlgo14xDs",fb=["typed"],bt=q(cb,fb,r=>{var{typed:e}=r;return function(n,i,o,f){var l=n._data,u=n._size,s=n._datatype,c,m=o;typeof s=="string"&&(c=s,i=e.convert(i,c),m=e.find(o,[c,c]));var v=u.length>0?t(m,0,u,u[0],l,i,f):[];return n.createDenseMatrix({data:v,size:Ge(u),datatype:c})};function t(a,n,i,o,f,l,u){var s=[];if(n===i.length-1)for(var c=0;c<o;c++)s[c]=u?a(l,f[c]):a(f[c],l);else for(var m=0;m<o;m++)s[m]=t(a,n+1,i,i[n+1],f[m],l,u);return s}}),us="ceil",mb=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],vb=q(us,["typed","config","round"],r=>{var{typed:e,config:t,round:a}=r;return e(us,{number:function(i){return tt(i,a(i),t.epsilon)?a(i):Math.ceil(i)},"number, number":function(i,o){if(tt(i,a(i,o),t.epsilon))return a(i,o);var[f,l]="".concat(i,"e").split("e"),u=Math.ceil(Number("".concat(f,"e").concat(Number(l)+o)));return[f,l]="".concat(u,"e").split("e"),Number("".concat(f,"e").concat(Number(l)-o))}})}),pb=q(us,mb,r=>{var{typed:e,config:t,round:a,matrix:n,equalScalar:i,zeros:o,DenseMatrix:f}=r,l=Lr({typed:e,equalScalar:i}),u=Ir({typed:e,DenseMatrix:f}),s=bt({typed:e}),c=vb({typed:e,config:t,round:a});return e("ceil",{number:c.signatures.number,"number,number":c.signatures["number,number"],Complex:function(v){return v.ceil()},"Complex, number":function(v,h){return v.ceil(h)},"Complex, BigNumber":function(v,h){return v.ceil(h.toNumber())},BigNumber:function(v){return Tt(v,a(v),t.epsilon)?a(v):v.ceil()},"BigNumber, BigNumber":function(v,h){return Tt(v,a(v,h),t.epsilon)?a(v,h):v.toDecimalPlaces(h.toNumber(),un.ROUND_CEIL)},Fraction:function(v){return v.ceil()},"Fraction, number":function(v,h){return v.ceil(h)},"Fraction, BigNumber":function(v,h){return v.ceil(h.toNumber())},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array, number | BigNumber":e.referToSelf(m=>(v,h)=>je(v,p=>m(p,h))),"SparseMatrix, number | BigNumber":e.referToSelf(m=>(v,h)=>l(v,h,m,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(m=>(v,h)=>s(v,h,m,!1)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,h)=>s(n(h),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,h)=>i(v,0)?o(h.size(),h.storage()):h.storage()==="dense"?s(h,v,m,!0):u(h,v,m,!0))})}),gf="cube",hb=["typed"],db=q(gf,hb,r=>{var{typed:e}=r;return e(gf,{number:rc,Complex:function(a){return a.mul(a).mul(a)},BigNumber:function(a){return a.times(a).times(a)},Fraction:function(a){return a.pow(3)},Unit:function(a){return a.pow(3)}})}),yf="exp",gb=["typed"],yb=q(yf,gb,r=>{var{typed:e}=r;return e(yf,{number:tc,Complex:function(a){return a.exp()},BigNumber:function(a){return a.exp()}})}),bf="expm1",bb=["typed","Complex"],xb=q(bf,bb,r=>{var{typed:e,Complex:t}=r;return e(bf,{number:nc,Complex:function(n){var i=Math.exp(n.re);return new t(i*Math.cos(n.im)-1,i*Math.sin(n.im))},BigNumber:function(n){return n.exp().minus(1)}})}),ls="fix",wb=["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],Nb=q(ls,["typed","ceil","floor"],r=>{var{typed:e,ceil:t,floor:a}=r;return e(ls,{number:function(i){return i>0?a(i):t(i)},"number, number":function(i,o){return i>0?a(i,o):t(i,o)}})}),Db=q(ls,wb,r=>{var{typed:e,Complex:t,matrix:a,ceil:n,floor:i,equalScalar:o,zeros:f,DenseMatrix:l}=r,u=Ir({typed:e,DenseMatrix:l}),s=bt({typed:e}),c=Nb({typed:e,ceil:n,floor:i});return e("fix",{number:c.signatures.number,"number, number | BigNumber":c.signatures["number,number"],Complex:function(v){return new t(v.re>0?Math.floor(v.re):Math.ceil(v.re),v.im>0?Math.floor(v.im):Math.ceil(v.im))},"Complex, number":function(v,h){return new t(v.re>0?i(v.re,h):n(v.re,h),v.im>0?i(v.im,h):n(v.im,h))},"Complex, BigNumber":function(v,h){var p=h.toNumber();return new t(v.re>0?i(v.re,p):n(v.re,p),v.im>0?i(v.im,p):n(v.im,p))},BigNumber:function(v){return v.isNegative()?n(v):i(v)},"BigNumber, number | BigNumber":function(v,h){return v.isNegative()?n(v,h):i(v,h)},Fraction:function(v){return v.s<0?v.ceil():v.floor()},"Fraction, number | BigNumber":function(v,h){return v.s<0?n(v,h):i(v,h)},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array | Matrix, number | BigNumber":e.referToSelf(m=>(v,h)=>je(v,p=>m(p,h))),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,h)=>s(a(h),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,h)=>o(v,0)?f(h.size(),h.storage()):h.storage()==="dense"?s(h,v,m,!0):u(h,v,m,!0))})}),cs="floor",Ab=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],Eb=q(cs,["typed","config","round"],r=>{var{typed:e,config:t,round:a}=r;return e(cs,{number:function(i){return tt(i,a(i),t.epsilon)?a(i):Math.floor(i)},"number, number":function(i,o){if(tt(i,a(i,o),t.epsilon))return a(i,o);var[f,l]="".concat(i,"e").split("e"),u=Math.floor(Number("".concat(f,"e").concat(Number(l)+o)));return[f,l]="".concat(u,"e").split("e"),Number("".concat(f,"e").concat(Number(l)-o))}})}),Sb=q(cs,Ab,r=>{var{typed:e,config:t,round:a,matrix:n,equalScalar:i,zeros:o,DenseMatrix:f}=r,l=Lr({typed:e,equalScalar:i}),u=Ir({typed:e,DenseMatrix:f}),s=bt({typed:e}),c=Eb({typed:e,config:t,round:a});return e("floor",{number:c.signatures.number,"number,number":c.signatures["number,number"],Complex:function(v){return v.floor()},"Complex, number":function(v,h){return v.floor(h)},"Complex, BigNumber":function(v,h){return v.floor(h.toNumber())},BigNumber:function(v){return Tt(v,a(v),t.epsilon)?a(v):v.floor()},"BigNumber, BigNumber":function(v,h){return Tt(v,a(v,h),t.epsilon)?a(v,h):v.toDecimalPlaces(h.toNumber(),un.ROUND_FLOOR)},Fraction:function(v){return v.floor()},"Fraction, number":function(v,h){return v.floor(h)},"Fraction, BigNumber":function(v,h){return v.floor(h.toNumber())},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array, number | BigNumber":e.referToSelf(m=>(v,h)=>je(v,p=>m(p,h))),"SparseMatrix, number | BigNumber":e.referToSelf(m=>(v,h)=>l(v,h,m,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(m=>(v,h)=>s(v,h,m,!1)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,h)=>s(n(h),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,h)=>i(v,0)?o(h.size(),h.storage()):h.storage()==="dense"?s(h,v,m,!0):u(h,v,m,!0))})}),Cb="matAlgo01xDSid",Mb=["typed"],cn=q(Cb,Mb,r=>{var{typed:e}=r;return function(a,n,i,o){var f=a._data,l=a._size,u=a._datatype,s=n._values,c=n._index,m=n._ptr,v=n._size,h=n._datatype;if(l.length!==v.length)throw new Ke(l.length,v.length);if(l[0]!==v[0]||l[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+v+")");if(!s)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var p=l[0],g=l[1],y=typeof u=="string"&&u===h?u:void 0,N=y?e.find(i,[y,y]):i,d,w,x=[];for(d=0;d<p;d++)x[d]=[];var b=[],E=[];for(w=0;w<g;w++){for(var A=w+1,S=m[w],D=m[w+1],T=S;T<D;T++)d=c[T],b[d]=o?N(s[T],f[d][w]):N(f[d][w],s[T]),E[d]=A;for(d=0;d<p;d++)E[d]===A?x[d][w]=b[d]:x[d][w]=f[d][w]}return a.createDenseMatrix({data:x,size:[p,g],datatype:y})}}),Fb="matAlgo04xSidSid",Tb=["typed","equalScalar"],fs=q(Fb,Tb,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o){var f=n._values,l=n._index,u=n._ptr,s=n._size,c=n._datatype,m=i._values,v=i._index,h=i._ptr,p=i._size,g=i._datatype;if(s.length!==p.length)throw new Ke(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");var y=s[0],N=s[1],d,w=t,x=0,b=o;typeof c=="string"&&c===g&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),b=e.find(o,[d,d]));var E=f&&m?[]:void 0,A=[],S=[],D=f&&m?[]:void 0,T=f&&m?[]:void 0,B=[],I=[],P,R,M,F,H;for(R=0;R<N;R++){S[R]=A.length;var $=R+1;for(F=u[R],H=u[R+1],M=F;M<H;M++)P=l[M],A.push(P),B[P]=$,D&&(D[P]=f[M]);for(F=h[R],H=h[R+1],M=F;M<H;M++)if(P=v[M],B[P]===$){if(D){var k=b(D[P],m[M]);w(k,x)?B[P]=null:D[P]=k}}else A.push(P),I[P]=$,T&&(T[P]=m[M]);if(D&&T)for(M=S[R];M<A.length;)P=A[M],B[P]===$?(E[M]=D[P],M++):I[P]===$?(E[M]=T[P],M++):A.splice(M,1)}return S[N]=A.length,n.createSparseMatrix({values:E,index:A,ptr:S,size:[y,N],datatype:d})}}),Bb="matAlgo10xSids",$b=["typed","DenseMatrix"],Fn=q(Bb,$b,r=>{var{typed:e,DenseMatrix:t}=r;return function(n,i,o,f){var l=n._values,u=n._index,s=n._ptr,c=n._size,m=n._datatype;if(!l)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=c[0],h=c[1],p,g=o;typeof m=="string"&&(p=m,i=e.convert(i,p),g=e.find(o,[p,p]));for(var y=[],N=[],d=[],w=0;w<h;w++){for(var x=w+1,b=s[w],E=s[w+1],A=b;A<E;A++){var S=u[A];N[S]=l[A],d[S]=x}for(var D=0;D<v;D++)w===0&&(y[D]=[]),d[D]===x?y[D][w]=f?g(i,N[D]):g(N[D],i):y[D][w]=i}return new t({data:y,size:[v,h],datatype:p})}}),Ob="matAlgo13xDD",Ib=["typed"],Rb=q(Ob,Ib,r=>{var{typed:e}=r;return function(n,i,o){var f=n._data,l=n._size,u=n._datatype,s=i._data,c=i._size,m=i._datatype,v=[];if(l.length!==c.length)throw new Ke(l.length,c.length);for(var h=0;h<l.length;h++){if(l[h]!==c[h])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+c+")");v[h]=l[h]}var p,g=o;typeof u=="string"&&u===m&&(p=u,g=e.find(o,[p,p]));var y=v.length>0?t(g,0,v,v[0],f,s):[];return n.createDenseMatrix({data:y,size:v,datatype:p})};function t(a,n,i,o,f,l){var u=[];if(n===i.length-1)for(var s=0;s<o;s++)u[s]=a(f[s],l[s]);else for(var c=0;c<o;c++)u[c]=t(a,n+1,i,i[n+1],f[c],l[c]);return u}}),_b="broadcast",qb=["concat"],zb=q(_b,qb,r=>{var{concat:e}=r;return function(i,o){var f=Math.max(i._size.length,o._size.length);if(i._size.length===o._size.length&&i._size.every((g,y)=>g===o._size[y]))return[i,o];for(var l=t(i._size,f,0),u=t(o._size,f,0),s=[],c=0;c<f;c++)s[c]=Math.max(l[c],u[c]);for(var m=0;m<f;m++)n(l,s,m),n(u,s,m);var v=i.clone(),h=o.clone();v._size.length<f?v.reshape(t(v._size,f,1)):h._size.length<f&&h.reshape(t(h._size,f,1));for(var p=0;p<f;p++)v._size[p]<s[p]&&(v=a(v,s[p],p)),h._size[p]<s[p]&&(h=a(h,s[p],p));return[v,h]};function t(i,o,f){return[...Array(o-i.length).fill(f),...i]}function a(i,o,f){return e(...Array(o).fill(i),f)}function n(i,o,f){if(i[f]<o[f]&i[f]>1)throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(i,") not possible to broadcast dimension ").concat(f," with size ").concat(i[f]," to size ").concat(o[f]))}}),Pb="matrixAlgorithmSuite",Ub=["typed","matrix","concat"],dr=q(Pb,Ub,r=>{var{typed:e,matrix:t,concat:a}=r,n=Rb({typed:e}),i=bt({typed:e}),o=zb({concat:a});return function(l){var u=l.elop,s=l.SD||l.DS,c;u?(c={"DenseMatrix, DenseMatrix":(p,g)=>n(...o(p,g),u),"Array, Array":(p,g)=>n(...o(t(p),t(g)),u).valueOf(),"Array, DenseMatrix":(p,g)=>n(...o(t(p),g),u),"DenseMatrix, Array":(p,g)=>n(...o(p,t(g)),u)},l.SS&&(c["SparseMatrix, SparseMatrix"]=(p,g)=>l.SS(...o(p,g),u,!1)),l.DS&&(c["DenseMatrix, SparseMatrix"]=(p,g)=>l.DS(...o(p,g),u,!1),c["Array, SparseMatrix"]=(p,g)=>l.DS(...o(t(p),g),u,!1)),s&&(c["SparseMatrix, DenseMatrix"]=(p,g)=>s(...o(g,p),u,!0),c["SparseMatrix, Array"]=(p,g)=>s(...o(t(g),p),u,!0))):(c={"DenseMatrix, DenseMatrix":e.referToSelf(p=>(g,y)=>n(...o(g,y),p)),"Array, Array":e.referToSelf(p=>(g,y)=>n(...o(t(g),t(y)),p).valueOf()),"Array, DenseMatrix":e.referToSelf(p=>(g,y)=>n(...o(t(g),y),p)),"DenseMatrix, Array":e.referToSelf(p=>(g,y)=>n(...o(g,t(y)),p))},l.SS&&(c["SparseMatrix, SparseMatrix"]=e.referToSelf(p=>(g,y)=>l.SS(...o(g,y),p,!1))),l.DS&&(c["DenseMatrix, SparseMatrix"]=e.referToSelf(p=>(g,y)=>l.DS(...o(g,y),p,!1)),c["Array, SparseMatrix"]=e.referToSelf(p=>(g,y)=>l.DS(...o(t(g),y),p,!1))),s&&(c["SparseMatrix, DenseMatrix"]=e.referToSelf(p=>(g,y)=>s(...o(y,g),p,!0)),c["SparseMatrix, Array"]=e.referToSelf(p=>(g,y)=>s(...o(t(y),g),p,!0))));var m=l.scalar||"any",v=l.Ds||l.Ss;v&&(u?(c["DenseMatrix,"+m]=(p,g)=>i(p,g,u,!1),c[m+", DenseMatrix"]=(p,g)=>i(g,p,u,!0),c["Array,"+m]=(p,g)=>i(t(p),g,u,!1).valueOf(),c[m+", Array"]=(p,g)=>i(t(g),p,u,!0).valueOf()):(c["DenseMatrix,"+m]=e.referToSelf(p=>(g,y)=>i(g,y,p,!1)),c[m+", DenseMatrix"]=e.referToSelf(p=>(g,y)=>i(y,g,p,!0)),c["Array,"+m]=e.referToSelf(p=>(g,y)=>i(t(g),y,p,!1).valueOf()),c[m+", Array"]=e.referToSelf(p=>(g,y)=>i(t(y),g,p,!0).valueOf())));var h=l.sS!==void 0?l.sS:l.Ss;return u?(l.Ss&&(c["SparseMatrix,"+m]=(p,g)=>l.Ss(p,g,u,!1)),h&&(c[m+", SparseMatrix"]=(p,g)=>h(g,p,u,!0))):(l.Ss&&(c["SparseMatrix,"+m]=e.referToSelf(p=>(g,y)=>l.Ss(g,y,p,!1))),h&&(c[m+", SparseMatrix"]=e.referToSelf(p=>(g,y)=>h(y,g,p,!0)))),u&&u.signatures&&sl(c,u.signatures),c}});function Tn(r,e,t,a){if(!(this instanceof Tn))throw new SyntaxError("Constructor must be called with the new operator");this.fn=r,this.count=e,this.min=t,this.max=a,this.message="Wrong number of arguments in function "+r+" ("+e+" provided, "+t+(a!=null?"-"+a:"")+" expected)",this.stack=new Error().stack}Tn.prototype=new Error,Tn.prototype.constructor=Error,Tn.prototype.name="ArgumentsError",Tn.prototype.isArgumentsError=!0;var xf="gcd",Lb=["typed","matrix","equalScalar","BigNumber","DenseMatrix","concat"],ms="number | BigNumber | Fraction | Matrix | Array",kb="".concat(ms,", ").concat(ms,", ...").concat(ms);function wf(r){return!r.some(e=>Array.isArray(e))}var Vb=q(xf,Lb,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n,DenseMatrix:i,concat:o}=r,f=cn({typed:e}),l=fs({typed:e,equalScalar:a}),u=Fn({typed:e,DenseMatrix:i}),s=dr({typed:e,matrix:t,concat:o});return e(xf,{"number, number":ac,"BigNumber, BigNumber":c,"Fraction, Fraction":(m,v)=>m.gcd(v)},s({SS:l,DS:f,Ss:u}),{[kb]:e.referToSelf(m=>(v,h,p)=>{for(var g=m(v,h),y=0;y<p.length;y++)g=m(g,p[y]);return g}),Array:e.referToSelf(m=>v=>{if(v.length===1&&Array.isArray(v[0])&&wf(v[0]))return m(...v[0]);if(wf(v))return m(...v);throw new Tn("gcd() supports only 1d matrices!")}),Matrix:e.referToSelf(m=>v=>m(v.toArray()))});function c(m,v){if(!m.isInt()||!v.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var h=new n(0);!v.isZero();){var p=m.mod(v);m=v,v=p}return m.lt(h)?m.neg():m}}),Gb="matAlgo02xDS0",Hb=["typed","equalScalar"],xt=q(Gb,Hb,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o,f){var l=n._data,u=n._size,s=n._datatype,c=i._values,m=i._index,v=i._ptr,h=i._size,p=i._datatype;if(u.length!==h.length)throw new Ke(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var g=u[0],y=u[1],N,d=t,w=0,x=o;typeof s=="string"&&s===p&&(N=s,d=e.find(t,[N,N]),w=e.convert(0,N),x=e.find(o,[N,N]));for(var b=[],E=[],A=[],S=0;S<y;S++){A[S]=E.length;for(var D=v[S],T=v[S+1],B=D;B<T;B++){var I=m[B],P=f?x(c[B],l[I][S]):x(l[I][S],c[B]);d(P,w)||(E.push(I),b.push(P))}}return A[y]=E.length,i.createSparseMatrix({values:b,index:E,ptr:A,size:[g,y],datatype:N})}}),Zb="matAlgo06xS0S0",Jb=["typed","equalScalar"],Oi=q(Zb,Jb,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o){var f=n._values,l=n._size,u=n._datatype,s=i._values,c=i._size,m=i._datatype;if(l.length!==c.length)throw new Ke(l.length,c.length);if(l[0]!==c[0]||l[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+c+")");var v=l[0],h=l[1],p,g=t,y=0,N=o;typeof u=="string"&&u===m&&(p=u,g=e.find(t,[p,p]),y=e.convert(0,p),N=e.find(o,[p,p]));for(var d=f&&s?[]:void 0,w=[],x=[],b=d?[]:void 0,E=[],A=[],S=0;S<h;S++){x[S]=w.length;var D=S+1;if(Xl(n,S,E,b,A,D,w,N),Xl(i,S,E,b,A,D,w,N),b)for(var T=x[S];T<w.length;){var B=w[T];if(A[B]===D){var I=b[B];g(I,y)?w.splice(T,1):(d.push(I),T++)}else w.splice(T,1)}else for(var P=x[S];P<w.length;){var R=w[P];A[R]!==D?w.splice(P,1):P++}}return x[h]=w.length,n.createSparseMatrix({values:d,index:w,ptr:x,size:[v,h],datatype:p})}}),Nf="lcm",Xb=["typed","matrix","equalScalar","concat"],Wb=q(Nf,Xb,r=>{var{typed:e,matrix:t,equalScalar:a,concat:n}=r,i=xt({typed:e,equalScalar:a}),o=Oi({typed:e,equalScalar:a}),f=Lr({typed:e,equalScalar:a}),l=dr({typed:e,matrix:t,concat:n}),u="number | BigNumber | Fraction | Matrix | Array",s={};return s["".concat(u,", ").concat(u,", ...").concat(u)]=e.referToSelf(m=>(v,h,p)=>{for(var g=m(v,h),y=0;y<p.length;y++)g=m(g,p[y]);return g}),e(Nf,{"number, number":ic,"BigNumber, BigNumber":c,"Fraction, Fraction":(m,v)=>m.lcm(v)},l({SS:o,DS:i,Ss:f}),s);function c(m,v){if(!m.isInt()||!v.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(m.isZero())return m;if(v.isZero())return v;for(var h=m.times(v);!v.isZero();){var p=v;v=m.mod(p),m=p}return h.div(m).abs()}}),Df="log10",Yb=["typed","config","Complex"],Qb=q(Df,Yb,r=>{var{typed:e,config:t,Complex:a}=r;return e(Df,{number:function(i){return i>=0||t.predictable?oc(i):new a(i,0).log().div(Math.LN10)},Complex:function(i){return new a(i).log().div(Math.LN10)},BigNumber:function(i){return!i.isNegative()||t.predictable?i.log():new a(i.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":e.referToSelf(n=>i=>je(i,n))})}),Af="log2",Kb=["typed","config","Complex"],jb=q(Af,Kb,r=>{var{typed:e,config:t,Complex:a}=r;return e(Af,{number:function(o){return o>=0||t.predictable?sc(o):n(new a(o,0))},Complex:n,BigNumber:function(o){return!o.isNegative()||t.predictable?o.log(2):n(new a(o.toNumber(),0))},"Array | Matrix":e.referToSelf(i=>o=>je(o,i))});function n(i){var o=Math.sqrt(i.re*i.re+i.im*i.im);return new a(Math.log2?Math.log2(o):Math.log(o)/Math.LN2,Math.atan2(i.im,i.re)/Math.LN2)}}),ex="matAlgo03xDSf",rx=["typed"],Yr=q(ex,rx,r=>{var{typed:e}=r;return function(a,n,i,o){var f=a._data,l=a._size,u=a._datatype,s=n._values,c=n._index,m=n._ptr,v=n._size,h=n._datatype;if(l.length!==v.length)throw new Ke(l.length,v.length);if(l[0]!==v[0]||l[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+v+")");if(!s)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var p=l[0],g=l[1],y,N=0,d=i;typeof u=="string"&&u===h&&(y=u,N=e.convert(0,y),d=e.find(i,[y,y]));for(var w=[],x=0;x<p;x++)w[x]=[];for(var b=[],E=[],A=0;A<g;A++){for(var S=A+1,D=m[A],T=m[A+1],B=D;B<T;B++){var I=c[B];b[I]=o?d(s[B],f[I][A]):d(f[I][A],s[B]),E[I]=S}for(var P=0;P<p;P++)E[P]===S?w[P][A]=b[P]:w[P][A]=o?d(N,f[P][A]):d(f[P][A],N)}return a.createDenseMatrix({data:w,size:[p,g],datatype:y})}}),tx="matAlgo05xSfSf",nx=["typed","equalScalar"],Ii=q(tx,nx,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o){var f=n._values,l=n._index,u=n._ptr,s=n._size,c=n._datatype,m=i._values,v=i._index,h=i._ptr,p=i._size,g=i._datatype;if(s.length!==p.length)throw new Ke(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");var y=s[0],N=s[1],d,w=t,x=0,b=o;typeof c=="string"&&c===g&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),b=e.find(o,[d,d]));var E=f&&m?[]:void 0,A=[],S=[],D=E?[]:void 0,T=E?[]:void 0,B=[],I=[],P,R,M,F;for(R=0;R<N;R++){S[R]=A.length;var H=R+1;for(M=u[R],F=u[R+1];M<F;M++)P=l[M],A.push(P),B[P]=H,D&&(D[P]=f[M]);for(M=h[R],F=h[R+1];M<F;M++)P=v[M],B[P]!==H&&A.push(P),I[P]=H,T&&(T[P]=m[M]);if(E)for(M=S[R];M<A.length;){P=A[M];var $=B[P],k=I[P];if($===H||k===H){var Q=$===H?D[P]:x,K=k===H?T[P]:x,L=b(Q,K);w(L,x)?A.splice(M,1):(E.push(L),M++)}}}return S[N]=A.length,n.createSparseMatrix({values:E,index:A,ptr:S,size:[y,N],datatype:d})}}),Ef="mod",ax=["typed","matrix","equalScalar","DenseMatrix","concat"],ix=q(Ef,ax,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n,concat:i}=r,o=xt({typed:e,equalScalar:a}),f=Yr({typed:e}),l=Ii({typed:e,equalScalar:a}),u=Lr({typed:e,equalScalar:a}),s=Ir({typed:e,DenseMatrix:n}),c=dr({typed:e,matrix:t,concat:i});return e(Ef,{"number, number":uc,"BigNumber, BigNumber":function(v,h){if(h.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return h.isZero()?v:v.mod(h)},"Fraction, Fraction":function(v,h){if(h.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return v.compare(0)>=0?v.mod(h):v.mod(h).add(h).mod(h)}},c({SS:l,DS:f,SD:o,Ss:u,sS:s}))}),ox="multiplyScalar",sx=["typed"],ux=q(ox,sx,r=>{var{typed:e}=r;return e("multiplyScalar",{"number, number":Kl,"Complex, Complex":function(a,n){return a.mul(n)},"BigNumber, BigNumber":function(a,n){return a.times(n)},"Fraction, Fraction":function(a,n){return a.mul(n)},"number | Fraction | BigNumber | Complex, Unit":(t,a)=>a.multiply(t),"Unit, number | Fraction | BigNumber | Complex | Unit":(t,a)=>t.multiply(a)})}),Sf="multiply",lx=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],cx=q(Sf,lx,r=>{var{typed:e,matrix:t,addScalar:a,multiplyScalar:n,equalScalar:i,dot:o}=r,f=Lr({typed:e,equalScalar:i}),l=bt({typed:e});function u(x,b){switch(x.length){case 1:switch(b.length){case 1:if(x[0]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(x[0]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+x[0]+") must match Matrix rows ("+b[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+b.length+" dimensions)")}break;case 2:switch(b.length){case 1:if(x[1]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+x[1]+") must match Vector length ("+b[0]+")");break;case 2:if(x[1]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+x[1]+") must match Matrix B rows ("+b[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+b.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+x.length+" dimensions)")}}function s(x,b,E){if(E===0)throw new Error("Cannot multiply two empty vectors");return o(x,b)}function c(x,b){if(b.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return m(x,b)}function m(x,b){var E=x._data,A=x._size,S=x._datatype,D=b._data,T=b._size,B=b._datatype,I=A[0],P=T[1],R,M=a,F=n;S&&B&&S===B&&typeof S=="string"&&(R=S,M=e.find(a,[R,R]),F=e.find(n,[R,R]));for(var H=[],$=0;$<P;$++){for(var k=F(E[0],D[0][$]),Q=1;Q<I;Q++)k=M(k,F(E[Q],D[Q][$]));H[$]=k}return x.createDenseMatrix({data:H,size:[P],datatype:R})}var v=e("_multiplyMatrixVector",{"DenseMatrix, any":p,"SparseMatrix, any":N}),h=e("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":g,"DenseMatrix, SparseMatrix":y,"SparseMatrix, DenseMatrix":d,"SparseMatrix, SparseMatrix":w});function p(x,b){var E=x._data,A=x._size,S=x._datatype,D=b._data,T=b._datatype,B=A[0],I=A[1],P,R=a,M=n;S&&T&&S===T&&typeof S=="string"&&(P=S,R=e.find(a,[P,P]),M=e.find(n,[P,P]));for(var F=[],H=0;H<B;H++){for(var $=E[H],k=M($[0],D[0]),Q=1;Q<I;Q++)k=R(k,M($[Q],D[Q]));F[H]=k}return x.createDenseMatrix({data:F,size:[B],datatype:P})}function g(x,b){var E=x._data,A=x._size,S=x._datatype,D=b._data,T=b._size,B=b._datatype,I=A[0],P=A[1],R=T[1],M,F=a,H=n;S&&B&&S===B&&typeof S=="string"&&(M=S,F=e.find(a,[M,M]),H=e.find(n,[M,M]));for(var $=[],k=0;k<I;k++){var Q=E[k];$[k]=[];for(var K=0;K<R;K++){for(var L=H(Q[0],D[0][K]),j=1;j<P;j++)L=F(L,H(Q[j],D[j][K]));$[k][K]=L}}return x.createDenseMatrix({data:$,size:[I,R],datatype:M})}function y(x,b){var E=x._data,A=x._size,S=x._datatype,D=b._values,T=b._index,B=b._ptr,I=b._size,P=b._datatype;if(!D)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var R=A[0],M=I[1],F,H=a,$=n,k=i,Q=0;S&&P&&S===P&&typeof S=="string"&&(F=S,H=e.find(a,[F,F]),$=e.find(n,[F,F]),k=e.find(i,[F,F]),Q=e.convert(0,F));for(var K=[],L=[],j=[],ae=b.createSparseMatrix({values:K,index:L,ptr:j,size:[R,M],datatype:F}),re=0;re<M;re++){j[re]=L.length;var fe=B[re],he=B[re+1];if(he>fe)for(var ce=0,ie=0;ie<R;ie++){for(var Ae=ie+1,Oe=void 0,Ce=fe;Ce<he;Ce++){var $e=T[Ce];ce!==Ae?(Oe=$(E[ie][$e],D[Ce]),ce=Ae):Oe=H(Oe,$(E[ie][$e],D[Ce]))}ce===Ae&&!k(Oe,Q)&&(L.push(ie),K.push(Oe))}}return j[M]=L.length,ae}function N(x,b){var E=x._values,A=x._index,S=x._ptr,D=x._datatype;if(!E)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var T=b._data,B=b._datatype,I=x._size[0],P=b._size[0],R=[],M=[],F=[],H,$=a,k=n,Q=i,K=0;D&&B&&D===B&&typeof D=="string"&&(H=D,$=e.find(a,[H,H]),k=e.find(n,[H,H]),Q=e.find(i,[H,H]),K=e.convert(0,H));var L=[],j=[];F[0]=0;for(var ae=0;ae<P;ae++){var re=T[ae];if(!Q(re,K))for(var fe=S[ae],he=S[ae+1],ce=fe;ce<he;ce++){var ie=A[ce];j[ie]?L[ie]=$(L[ie],k(re,E[ce])):(j[ie]=!0,M.push(ie),L[ie]=k(re,E[ce]))}}for(var Ae=M.length,Oe=0;Oe<Ae;Oe++){var Ce=M[Oe];R[Oe]=L[Ce]}return F[1]=M.length,x.createSparseMatrix({values:R,index:M,ptr:F,size:[I,1],datatype:H})}function d(x,b){var E=x._values,A=x._index,S=x._ptr,D=x._datatype;if(!E)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var T=b._data,B=b._datatype,I=x._size[0],P=b._size[0],R=b._size[1],M,F=a,H=n,$=i,k=0;D&&B&&D===B&&typeof D=="string"&&(M=D,F=e.find(a,[M,M]),H=e.find(n,[M,M]),$=e.find(i,[M,M]),k=e.convert(0,M));for(var Q=[],K=[],L=[],j=x.createSparseMatrix({values:Q,index:K,ptr:L,size:[I,R],datatype:M}),ae=[],re=[],fe=0;fe<R;fe++){L[fe]=K.length;for(var he=fe+1,ce=0;ce<P;ce++){var ie=T[ce][fe];if(!$(ie,k))for(var Ae=S[ce],Oe=S[ce+1],Ce=Ae;Ce<Oe;Ce++){var $e=A[Ce];re[$e]!==he?(re[$e]=he,K.push($e),ae[$e]=H(ie,E[Ce])):ae[$e]=F(ae[$e],H(ie,E[Ce]))}}for(var V=L[fe],X=K.length,oe=V;oe<X;oe++){var G=K[oe];Q[oe]=ae[G]}}return L[R]=K.length,j}function w(x,b){var E=x._values,A=x._index,S=x._ptr,D=x._datatype,T=b._values,B=b._index,I=b._ptr,P=b._datatype,R=x._size[0],M=b._size[1],F=E&&T,H,$=a,k=n;D&&P&&D===P&&typeof D=="string"&&(H=D,$=e.find(a,[H,H]),k=e.find(n,[H,H]));for(var Q=F?[]:void 0,K=[],L=[],j=x.createSparseMatrix({values:Q,index:K,ptr:L,size:[R,M],datatype:H}),ae=F?[]:void 0,re=[],fe,he,ce,ie,Ae,Oe,Ce,$e,V=0;V<M;V++){L[V]=K.length;var X=V+1;for(Ae=I[V],Oe=I[V+1],ie=Ae;ie<Oe;ie++)if($e=B[ie],F)for(he=S[$e],ce=S[$e+1],fe=he;fe<ce;fe++)Ce=A[fe],re[Ce]!==X?(re[Ce]=X,K.push(Ce),ae[Ce]=k(T[ie],E[fe])):ae[Ce]=$(ae[Ce],k(T[ie],E[fe]));else for(he=S[$e],ce=S[$e+1],fe=he;fe<ce;fe++)Ce=A[fe],re[Ce]!==X&&(re[Ce]=X,K.push(Ce));if(F)for(var oe=L[V],G=K.length,Y=oe;Y<G;Y++){var te=K[Y];Q[Y]=ae[te]}}return L[M]=K.length,j}return e(Sf,n,{"Array, Array":e.referTo("Matrix, Matrix",x=>(b,E)=>{u(er(b),er(E));var A=x(t(b),t(E));return Ve(A)?A.valueOf():A}),"Matrix, Matrix":function(b,E){var A=b.size(),S=E.size();return u(A,S),A.length===1?S.length===1?s(b,E,A[0]):c(b,E):S.length===1?v(b,E):h(b,E)},"Matrix, Array":e.referTo("Matrix,Matrix",x=>(b,E)=>x(b,t(E))),"Array, Matrix":e.referToSelf(x=>(b,E)=>x(t(b,E.storage()),E)),"SparseMatrix, any":function(b,E){return f(b,E,n,!1)},"DenseMatrix, any":function(b,E){return l(b,E,n,!1)},"any, SparseMatrix":function(b,E){return f(E,b,n,!0)},"any, DenseMatrix":function(b,E){return l(E,b,n,!0)},"Array, any":function(b,E){return l(t(b),E,n,!1).valueOf()},"any, Array":function(b,E){return l(t(E),b,n,!0).valueOf()},"any, any":n,"any, any, ...any":e.referToSelf(x=>(b,E,A)=>{for(var S=x(b,E),D=0;D<A.length;D++)S=x(S,A[D]);return S})})}),Cf="nthRoot",fx=["typed","matrix","equalScalar","BigNumber","concat"],mx=q(Cf,fx,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n,concat:i}=r,o=cn({typed:e}),f=xt({typed:e,equalScalar:a}),l=Oi({typed:e,equalScalar:a}),u=Lr({typed:e,equalScalar:a}),s=dr({typed:e,matrix:t,concat:i});function c(){throw new Error("Complex number not supported in function nthRoot. Use nthRoots instead.")}return e(Cf,{number:lc,"number, number":lc,BigNumber:v=>m(v,new n(2)),"BigNumber, BigNumber":m,Complex:c,"Complex, number":c,Array:e.referTo("DenseMatrix,number",v=>h=>v(t(h),2).valueOf()),DenseMatrix:e.referTo("DenseMatrix,number",v=>h=>v(h,2)),SparseMatrix:e.referTo("SparseMatrix,number",v=>h=>v(h,2)),"SparseMatrix, SparseMatrix":e.referToSelf(v=>(h,p)=>{if(p.density()===1)return l(h,p,v);throw new Error("Root must be non-zero")}),"DenseMatrix, SparseMatrix":e.referToSelf(v=>(h,p)=>{if(p.density()===1)return o(h,p,v,!1);throw new Error("Root must be non-zero")}),"Array, SparseMatrix":e.referTo("DenseMatrix,SparseMatrix",v=>(h,p)=>v(t(h),p)),"number | BigNumber, SparseMatrix":e.referToSelf(v=>(h,p)=>{if(p.density()===1)return u(p,h,v,!0);throw new Error("Root must be non-zero")})},s({scalar:"number | BigNumber",SD:f,Ss:u,sS:!1}));function m(v,h){var p=n.precision,g=n.clone({precision:p+2}),y=new n(0),N=new g(1),d=h.isNegative();if(d&&(h=h.neg()),h.isZero())throw new Error("Root must be non-zero");if(v.isNegative()&&!h.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(v.isZero())return d?new g(1/0):0;if(!v.isFinite())return d?y:v;var w=v.abs().pow(N.div(h));return w=v.isNeg()?w.neg():w,new n((d?N.div(w):w).toPrecision(p))}}),Mf="sign",vx=["typed","BigNumber","Fraction","complex"],px=q(Mf,vx,r=>{var{typed:e,BigNumber:t,complex:a,Fraction:n}=r;return e(Mf,{number:os,Complex:function(o){return o.im===0?a(os(o.re)):o.sign()},BigNumber:function(o){return new t(o.cmp(0))},Fraction:function(o){return new n(o.s,1)},"Array | Matrix":e.referToSelf(i=>o=>je(o,i)),Unit:e.referToSelf(i=>o=>{if(!o._isDerived()&&o.units[0].unit.offset!==0)throw new TypeError("sign is ambiguous for units with offset");return e.find(i,o.valueType())(o.value)})})}),hx="sqrt",dx=["config","typed","Complex"],gx=q(hx,dx,r=>{var{config:e,typed:t,Complex:a}=r;return t("sqrt",{number:n,Complex:function(o){return o.sqrt()},BigNumber:function(o){return!o.isNegative()||e.predictable?o.sqrt():n(o.toNumber())},Unit:function(o){return o.pow(.5)}});function n(i){return isNaN(i)?NaN:i>=0||e.predictable?Math.sqrt(i):new a(i,0).sqrt()}}),Ff="square",yx=["typed"],bx=q(Ff,yx,r=>{var{typed:e}=r;return e(Ff,{number:cc,Complex:function(a){return a.mul(a)},BigNumber:function(a){return a.times(a)},Fraction:function(a){return a.mul(a)},Unit:function(a){return a.pow(2)}})}),Tf="subtract",xx=["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix","concat"],wx=q(Tf,xx,r=>{var{typed:e,matrix:t,equalScalar:a,addScalar:n,unaryMinus:i,DenseMatrix:o,concat:f}=r,l=cn({typed:e}),u=Yr({typed:e}),s=Ii({typed:e,equalScalar:a}),c=Fn({typed:e,DenseMatrix:o}),m=Ir({typed:e,DenseMatrix:o}),v=dr({typed:e,matrix:t,concat:f});return e(Tf,{"number, number":(h,p)=>h-p,"Complex, Complex":(h,p)=>h.sub(p),"BigNumber, BigNumber":(h,p)=>h.minus(p),"Fraction, Fraction":(h,p)=>h.sub(p),"Unit, Unit":e.referToSelf(h=>(p,g)=>{if(p.value===null)throw new Error("Parameter x contains a unit with undefined value");if(g.value===null)throw new Error("Parameter y contains a unit with undefined value");if(!p.equalBase(g))throw new Error("Units do not match");var y=p.clone();return y.value=e.find(h,[y.valueType(),g.valueType()])(y.value,g.value),y.fixPrefix=!1,y})},v({SS:s,DS:l,SD:u,Ss:m,sS:c}))}),Bf="xgcd",Nx=["typed","config","matrix","BigNumber"],Dx=q(Bf,Nx,r=>{var{typed:e,config:t,matrix:a,BigNumber:n}=r;return e(Bf,{"number, number":function(f,l){var u=fc(f,l);return t.matrix==="Array"?u:a(u)},"BigNumber, BigNumber":i});function i(o,f){var l,u,s,c=new n(0),m=new n(1),v=c,h=m,p=m,g=c;if(!o.isInt()||!f.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!f.isZero();)u=o.div(f).floor(),s=o.mod(f),l=v,v=h.minus(u.times(v)),h=l,l=p,p=g.minus(u.times(p)),g=l,o=f,f=s;var y;return o.lt(c)?y=[o.neg(),h.neg(),g.neg()]:y=[o,o.isZero()?0:h,g],t.matrix==="Array"?y:a(y)}}),$f="invmod",Ax=["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],Ex=q($f,Ax,r=>{var{typed:e,config:t,BigNumber:a,xgcd:n,equal:i,smaller:o,mod:f,add:l,isInteger:u}=r;return e($f,{"number, number":s,"BigNumber, BigNumber":s});function s(c,m){if(!u(c)||!u(m))throw new Error("Parameters in function invmod must be integer numbers");if(c=f(c,m),i(m,0))throw new Error("Divisor must be non zero");var v=n(c,m);v=v.valueOf();var[h,p]=v;return i(h,a(1))?(p=f(p,m),o(p,a(0))&&(p=l(p,m)),p):NaN}}),Sx="matAlgo09xS0Sf",Cx=["typed","equalScalar"],Of=q(Sx,Cx,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o){var f=n._values,l=n._index,u=n._ptr,s=n._size,c=n._datatype,m=i._values,v=i._index,h=i._ptr,p=i._size,g=i._datatype;if(s.length!==p.length)throw new Ke(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");var y=s[0],N=s[1],d,w=t,x=0,b=o;typeof c=="string"&&c===g&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),b=e.find(o,[d,d]));var E=f&&m?[]:void 0,A=[],S=[],D=E?[]:void 0,T=[],B,I,P,R,M;for(I=0;I<N;I++){S[I]=A.length;var F=I+1;if(D)for(R=h[I],M=h[I+1],P=R;P<M;P++)B=v[P],T[B]=F,D[B]=m[P];for(R=u[I],M=u[I+1],P=R;P<M;P++)if(B=l[P],D){var H=T[B]===F?D[B]:x,$=b(f[P],H);w($,x)||(A.push(B),E.push($))}else A.push(B)}return S[N]=A.length,n.createSparseMatrix({values:E,index:A,ptr:S,size:[y,N],datatype:d})}}),If="dotMultiply",Mx=["typed","matrix","equalScalar","multiplyScalar","concat"],Fx=q(If,Mx,r=>{var{typed:e,matrix:t,equalScalar:a,multiplyScalar:n,concat:i}=r,o=xt({typed:e,equalScalar:a}),f=Of({typed:e,equalScalar:a}),l=Lr({typed:e,equalScalar:a}),u=dr({typed:e,matrix:t,concat:i});return e(If,u({elop:n,SS:f,DS:o,Ss:l}))});function Tx(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function bitAnd");var t=r.constructor;if(r.isNaN()||e.isNaN())return new t(NaN);if(r.isZero()||e.eq(-1)||r.eq(e))return r;if(e.isZero()||r.eq(-1))return e;if(!r.isFinite()||!e.isFinite()){if(!r.isFinite()&&!e.isFinite())return r.isNegative()===e.isNegative()?r:new t(0);if(!r.isFinite())return e.isNegative()?r:r.isNegative()?new t(0):e;if(!e.isFinite())return r.isNegative()?e:e.isNegative()?new t(0):r}return vs(r,e,function(a,n){return a&n})}function Ga(r){if(r.isFinite()&&!r.isInteger())throw new Error("Integer expected in function bitNot");var e=r.constructor,t=e.precision;e.config({precision:1e9});var a=r.plus(new e(1));return a.s=-a.s||null,e.config({precision:t}),a}function Bx(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function bitOr");var t=r.constructor;if(r.isNaN()||e.isNaN())return new t(NaN);var a=new t(-1);return r.isZero()||e.eq(a)||r.eq(e)?e:e.isZero()||r.eq(a)?r:!r.isFinite()||!e.isFinite()?!r.isFinite()&&!r.isNegative()&&e.isNegative()||r.isNegative()&&!e.isNegative()&&!e.isFinite()?a:r.isNegative()&&e.isNegative()?r.isFinite()?r:e:r.isFinite()?e:r:vs(r,e,function(n,i){return n|i})}function vs(r,e,t){var a=r.constructor,n,i,o=+(r.s<0),f=+(e.s<0);if(o){n=Ri(Ga(r));for(var l=0;l<n.length;++l)n[l]^=1}else n=Ri(r);if(f){i=Ri(Ga(e));for(var u=0;u<i.length;++u)i[u]^=1}else i=Ri(e);var s,c,m;n.length<=i.length?(s=n,c=i,m=o):(s=i,c=n,m=f);var v=s.length,h=c.length,p=t(o,f)^1,g=new a(p^1),y=new a(1),N=new a(2),d=a.precision;for(a.config({precision:1e9});v>0;)t(s[--v],c[--h])===p&&(g=g.plus(y)),y=y.times(N);for(;h>0;)t(m,c[--h])===p&&(g=g.plus(y)),y=y.times(N);return a.config({precision:d}),p===0&&(g.s=-g.s),g}function Ri(r){for(var e=r.d,t=e[0]+"",a=1;a<e.length;++a){for(var n=e[a]+"",i=7-n.length;i--;)n="0"+n;t+=n}for(var o=t.length;t.charAt(o)==="0";)o--;var f=r.e,l=t.slice(0,o+1||1),u=l.length;if(f>0)if(++f>u)for(f-=u;f--;)l+="0";else f<u&&(l=l.slice(0,f)+"."+l.slice(f));for(var s=[0],c=0;c<l.length;){for(var m=s.length;m--;)s[m]*=10;s[0]+=parseInt(l.charAt(c++));for(var v=0;v<s.length;++v)s[v]>1&&((s[v+1]===null||s[v+1]===void 0)&&(s[v+1]=0),s[v+1]+=s[v]>>1,s[v]&=1)}return s.reverse()}function $x(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function bitXor");var t=r.constructor;if(r.isNaN()||e.isNaN())return new t(NaN);if(r.isZero())return e;if(e.isZero())return r;if(r.eq(e))return new t(0);var a=new t(-1);return r.eq(a)?Ga(e):e.eq(a)?Ga(r):!r.isFinite()||!e.isFinite()?!r.isFinite()&&!e.isFinite()?a:new t(r.isNegative()===e.isNegative()?1/0:-1/0):vs(r,e,function(n,i){return n^i})}function Ox(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function leftShift");var t=r.constructor;return r.isNaN()||e.isNaN()||e.isNegative()&&!e.isZero()?new t(NaN):r.isZero()||e.isZero()?r:!r.isFinite()&&!e.isFinite()?new t(NaN):e.lt(55)?r.times(Math.pow(2,e.toNumber())+""):r.times(new t(2).pow(e))}function Ix(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function rightArithShift");var t=r.constructor;return r.isNaN()||e.isNaN()||e.isNegative()&&!e.isZero()?new t(NaN):r.isZero()||e.isZero()?r:e.isFinite()?e.lt(55)?r.div(Math.pow(2,e.toNumber())+"").floor():r.div(new t(2).pow(e)).floor():r.isNegative()?new t(-1):r.isFinite()?new t(0):new t(NaN)}var Rf="bitAnd",Rx=["typed","matrix","equalScalar","concat"],_x=q(Rf,Rx,r=>{var{typed:e,matrix:t,equalScalar:a,concat:n}=r,i=xt({typed:e,equalScalar:a}),o=Oi({typed:e,equalScalar:a}),f=Lr({typed:e,equalScalar:a}),l=dr({typed:e,matrix:t,concat:n});return e(Rf,{"number, number":pc,"BigNumber, BigNumber":Tx},l({SS:o,DS:i,Ss:f}))}),_f="bitNot",qx=["typed"],zx=q(_f,qx,r=>{var{typed:e}=r;return e(_f,{number:hc,BigNumber:Ga,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),qf="bitOr",Px=["typed","matrix","equalScalar","DenseMatrix","concat"],Ux=q(qf,Px,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n,concat:i}=r,o=cn({typed:e}),f=fs({typed:e,equalScalar:a}),l=Fn({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:t,concat:i});return e(qf,{"number, number":dc,"BigNumber, BigNumber":Bx},u({SS:f,DS:o,Ss:l}))}),Lx="matAlgo07xSSf",kx=["typed","DenseMatrix"],Bt=q(Lx,kx,r=>{var{typed:e,DenseMatrix:t}=r;return function(i,o,f){var l=i._size,u=i._datatype,s=o._size,c=o._datatype;if(l.length!==s.length)throw new Ke(l.length,s.length);if(l[0]!==s[0]||l[1]!==s[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+s+")");var m=l[0],v=l[1],h,p=0,g=f;typeof u=="string"&&u===c&&(h=u,p=e.convert(0,h),g=e.find(f,[h,h]));var y,N,d=[];for(y=0;y<m;y++)d[y]=[];var w=[],x=[],b=[],E=[];for(N=0;N<v;N++){var A=N+1;for(a(i,N,b,w,A),a(o,N,E,x,A),y=0;y<m;y++){var S=b[y]===A?w[y]:p,D=E[y]===A?x[y]:p;d[y][N]=g(S,D)}}return new t({data:d,size:[m,v],datatype:h})};function a(n,i,o,f,l){for(var u=n._values,s=n._index,c=n._ptr,m=c[i],v=c[i+1];m<v;m++){var h=s[m];o[h]=l,f[h]=u[m]}}}),zf="bitXor",Vx=["typed","matrix","DenseMatrix","concat"],Gx=q(zf,Vx,r=>{var{typed:e,matrix:t,DenseMatrix:a,concat:n}=r,i=Yr({typed:e}),o=Bt({typed:e,DenseMatrix:a}),f=Ir({typed:e,DenseMatrix:a}),l=dr({typed:e,matrix:t,concat:n});return e(zf,{"number, number":gc,"BigNumber, BigNumber":$x},l({SS:o,DS:i,Ss:f}))}),Pf="arg",Hx=["typed"],Zx=q(Pf,Hx,r=>{var{typed:e}=r;return e(Pf,{number:function(a){return Math.atan2(0,a)},BigNumber:function(a){return a.constructor.atan2(0,a)},Complex:function(a){return a.arg()},"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Uf="conj",Jx=["typed"],Xx=q(Uf,Jx,r=>{var{typed:e}=r;return e(Uf,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.conjugate(),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Lf="im",Wx=["typed"],Yx=q(Lf,Wx,r=>{var{typed:e}=r;return e(Lf,{number:()=>0,"BigNumber | Fraction":t=>t.mul(0),Complex:t=>t.im,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),kf="re",Qx=["typed"],Kx=q(kf,Qx,r=>{var{typed:e}=r;return e(kf,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.re,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Vf="not",jx=["typed"],ew=q(Vf,jx,r=>{var{typed:e}=r;return e(Vf,{"null | undefined":()=>!0,number:Nc,Complex:function(a){return a.re===0&&a.im===0},BigNumber:function(a){return a.isZero()||a.isNaN()},Unit:e.referToSelf(t=>a=>e.find(t,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Gf="or",rw=["typed","matrix","equalScalar","DenseMatrix","concat"],tw=q(Gf,rw,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n,concat:i}=r,o=Yr({typed:e}),f=Ii({typed:e,equalScalar:a}),l=Ir({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:t,concat:i});return e(Gf,{"number, number":Dc,"Complex, Complex":function(c,m){return c.re!==0||c.im!==0||m.re!==0||m.im!==0},"BigNumber, BigNumber":function(c,m){return!c.isZero()&&!c.isNaN()||!m.isZero()&&!m.isNaN()},"Unit, Unit":e.referToSelf(s=>(c,m)=>s(c.value||0,m.value||0))},u({SS:f,DS:o,Ss:l}))}),Hf="xor",nw=["typed","matrix","DenseMatrix","concat"],aw=q(Hf,nw,r=>{var{typed:e,matrix:t,DenseMatrix:a,concat:n}=r,i=Yr({typed:e}),o=Bt({typed:e,DenseMatrix:a}),f=Ir({typed:e,DenseMatrix:a}),l=dr({typed:e,matrix:t,concat:n});return e(Hf,{"number, number":Ac,"Complex, Complex":function(s,c){return(s.re!==0||s.im!==0)!=(c.re!==0||c.im!==0)},"BigNumber, BigNumber":function(s,c){return(!s.isZero()&&!s.isNaN())!=(!c.isZero()&&!c.isNaN())},"Unit, Unit":e.referToSelf(u=>(s,c)=>u(s.value||0,c.value||0))},l({SS:o,DS:i,Ss:f}))}),Zf="concat",iw=["typed","matrix","isInteger"],Jf=q(Zf,iw,r=>{var{typed:e,matrix:t,isInteger:a}=r;return e(Zf,{"...Array | Matrix | number | BigNumber":function(i){var o,f=i.length,l=-1,u,s=!1,c=[];for(o=0;o<f;o++){var m=i[o];if(Ve(m)&&(s=!0),tr(m)||rr(m)){if(o!==f-1)throw new Error("Dimension must be specified as last argument");if(u=l,l=m.valueOf(),!a(l))throw new TypeError("Integer number expected for dimension");if(l<0||o>0&&l>u)throw new ht(l,u+1)}else{var v=Ge(m).valueOf(),h=er(v);if(c[o]=v,u=l,l=h.length-1,o>0&&l!==u)throw new Ke(u+1,l+1)}}if(c.length===0)throw new SyntaxError("At least one matrix expected");for(var p=c.shift();c.length;)p=Xf(p,c.shift(),l,0);return s?t(p):p},"...string":function(i){return i.join("")}})});function Xf(r,e,t,a){if(a<t){if(r.length!==e.length)throw new Ke(r.length,e.length);for(var n=[],i=0;i<r.length;i++)n[i]=Xf(r[i],e[i],t,a+1);return n}else return r.concat(e)}var Wf="column",ow=["typed","Index","matrix","range"],Yf=q(Wf,ow,r=>{var{typed:e,Index:t,matrix:a,range:n}=r;return e(Wf,{"Matrix, number":i,"Array, number":function(f,l){return i(a(Ge(f)),l).valueOf()}});function i(o,f){if(o.size().length!==2)throw new Error("Only two dimensional matrix is supported");vr(f,o.size()[1]);var l=n(0,o.size()[0]),u=new t(l,f),s=o.subset(u);return Ve(s)?s:a([[s]])}}),Qf="count",sw=["typed","size","prod"],uw=q(Qf,sw,r=>{var{typed:e,size:t,prod:a}=r;return e(Qf,{string:function(i){return i.length},"Matrix | Array":function(i){return a(t(i))}})}),Kf="cross",lw=["typed","matrix","subtract","multiply"],cw=q(Kf,lw,r=>{var{typed:e,matrix:t,subtract:a,multiply:n}=r;return e(Kf,{"Matrix, Matrix":function(f,l){return t(i(f.toArray(),l.toArray()))},"Matrix, Array":function(f,l){return t(i(f.toArray(),l))},"Array, Matrix":function(f,l){return t(i(f,l.toArray()))},"Array, Array":i});function i(o,f){var l=Math.max(er(o).length,er(f).length);o=pi(o),f=pi(f);var u=er(o),s=er(f);if(u.length!==1||s.length!==1||u[0]!==3||s[0]!==3)throw new RangeError("Vectors with length 3 expected (Size A = ["+u.join(", ")+"], B = ["+s.join(", ")+"])");var c=[a(n(o[1],f[2]),n(o[2],f[1])),a(n(o[2],f[0]),n(o[0],f[2])),a(n(o[0],f[1]),n(o[1],f[0]))];return l>1?[c]:c}}),jf="diag",fw=["typed","matrix","DenseMatrix","SparseMatrix"],mw=q(jf,fw,r=>{var{typed:e,matrix:t,DenseMatrix:a,SparseMatrix:n}=r;return e(jf,{Array:function(u){return i(u,0,er(u),null)},"Array, number":function(u,s){return i(u,s,er(u),null)},"Array, BigNumber":function(u,s){return i(u,s.toNumber(),er(u),null)},"Array, string":function(u,s){return i(u,0,er(u),s)},"Array, number, string":function(u,s,c){return i(u,s,er(u),c)},"Array, BigNumber, string":function(u,s,c){return i(u,s.toNumber(),er(u),c)},Matrix:function(u){return i(u,0,u.size(),u.storage())},"Matrix, number":function(u,s){return i(u,s,u.size(),u.storage())},"Matrix, BigNumber":function(u,s){return i(u,s.toNumber(),u.size(),u.storage())},"Matrix, string":function(u,s){return i(u,0,u.size(),s)},"Matrix, number, string":function(u,s,c){return i(u,s,u.size(),c)},"Matrix, BigNumber, string":function(u,s,c){return i(u,s.toNumber(),u.size(),c)}});function i(l,u,s,c){if(!qe(u))throw new TypeError("Second parameter in function diag must be an integer");var m=u>0?u:0,v=u<0?-u:0;switch(s.length){case 1:return o(l,u,c,s[0],v,m);case 2:return f(l,u,c,s,v,m)}throw new RangeError("Matrix for function diag must be 2 dimensional")}function o(l,u,s,c,m,v){var h=[c+m,c+v];if(s&&s!=="sparse"&&s!=="dense")throw new TypeError("Unknown matrix type ".concat(s,'"'));var p=s==="sparse"?n.diagonal(h,l,u):a.diagonal(h,l,u);return s!==null?p:p.valueOf()}function f(l,u,s,c,m,v){if(Ve(l)){var h=l.diagonal(u);return s!==null?s!==h.storage()?t(h,s):h:h.valueOf()}for(var p=Math.min(c[0]-m,c[1]-v),g=[],y=0;y<p;y++)g[y]=l[y+m][y+v];return s!==null?t(g):g}}),vw="filter",pw=["typed"],hw=q(vw,pw,r=>{var{typed:e}=r;return e("filter",{"Array, function":em,"Matrix, function":function(a,n){return a.create(em(a.toArray(),n))},"Array, RegExp":di,"Matrix, RegExp":function(a,n){return a.create(di(a.toArray(),n))}})});function em(r,e){var t=ln(e);return Al(r,function(a,n,i){return t===1?e(a):t===2?e(a,[n]):e(a,[n],i)})}var rm="flatten",dw=["typed","matrix"],gw=q(rm,dw,r=>{var{typed:e,matrix:t}=r;return e(rm,{Array:function(n){return or(n)},Matrix:function(n){var i=or(n.toArray());return t(i)}})}),tm="forEach",yw=["typed"],bw=q(tm,yw,r=>{var{typed:e}=r;return e(tm,{"Array, function":xw,"Matrix, function":function(a,n){a.forEach(n)}})});function xw(r,e){var t=ln(e),a=function n(i,o){Array.isArray(i)?hi(i,function(f,l){n(f,o.concat(l))}):t===1?e(i):t===2?e(i,o):e(i,o,r)};a(r,[])}var nm="getMatrixDataType",ww=["typed"],Nw=q(nm,ww,r=>{var{typed:e}=r;return e(nm,{Array:function(a){return Ua(a,br)},Matrix:function(a){return a.getDataType()}})}),am="identity",Dw=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],Aw=q(am,Dw,r=>{var{typed:e,config:t,matrix:a,BigNumber:n,DenseMatrix:i,SparseMatrix:o}=r;return e(am,{"":function(){return t.matrix==="Matrix"?a([]):[]},string:function(s){return a(s)},"number | BigNumber":function(s){return l(s,s,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(s,c){return l(s,s,c)},"number | BigNumber, number | BigNumber":function(s,c){return l(s,c,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(s,c,m){return l(s,c,m)},Array:function(s){return f(s)},"Array, string":function(s,c){return f(s,c)},Matrix:function(s){return f(s.valueOf(),s.storage())},"Matrix, string":function(s,c){return f(s.valueOf(),c)}});function f(u,s){switch(u.length){case 0:return s?a(s):[];case 1:return l(u[0],u[0],s);case 2:return l(u[0],u[1],s);default:throw new Error("Vector containing two values expected")}}function l(u,s,c){var m=rr(u)||rr(s)?n:null;if(rr(u)&&(u=u.toNumber()),rr(s)&&(s=s.toNumber()),!qe(u)||u<1)throw new Error("Parameters in function identity must be positive integers");if(!qe(s)||s<1)throw new Error("Parameters in function identity must be positive integers");var v=m?new n(1):1,h=m?new m(0):0,p=[u,s];if(c){if(c==="sparse")return o.diagonal(p,v,0,h);if(c==="dense")return i.diagonal(p,v,0,h);throw new TypeError('Unknown matrix type "'.concat(c,'"'))}for(var g=Yn([],p,h),y=u<s?u:s,N=0;N<y;N++)g[N][N]=v;return g}}),im="kron",Ew=["typed","matrix","multiplyScalar"],Sw=q(im,Ew,r=>{var{typed:e,matrix:t,multiplyScalar:a}=r;return e(im,{"Matrix, Matrix":function(o,f){return t(n(o.toArray(),f.toArray()))},"Matrix, Array":function(o,f){return t(n(o.toArray(),f))},"Array, Matrix":function(o,f){return t(n(o,f.toArray()))},"Array, Array":n});function n(i,o){if(er(i).length===1&&(i=[i]),er(o).length===1&&(o=[o]),er(i).length>2||er(o).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(i.length)+", y = "+JSON.stringify(o.length)+")");var f=[],l=[];return i.map(function(u){return o.map(function(s){return l=[],f.push(l),u.map(function(c){return s.map(function(m){return l.push(a(c,m))})})})})&&f}}),om="map",Cw=["typed"],Mw=q(om,Cw,r=>{var{typed:e}=r;return e(om,{"Array, function":Fw,"Matrix, function":function(a,n){return a.map(n)}})});function Fw(r,e){var t=ln(e),a=function n(i,o){if(Array.isArray(i))return i.map(function(u,s){return n(u,o.concat(s))});try{return t===1?e(i):t===2?e(i,o):e(i,o,r)}catch(u){if(u instanceof TypeError&&"data"in u&&u.data.category==="wrongType"){var f="map attempted to call '".concat(u.data.fn,"(").concat(i),l=JSON.stringify(o);throw t===2?f+=","+l:t!==1&&(f+=",".concat(l,",").concat(r)),f+=")' but argument ".concat(u.data.index+1," of type "),f+="".concat(u.data.actual," does not match expected type "),f+=u.data.expected.join(" or "),new TypeError(f)}throw u}};return a(r,[])}var sm="diff",Tw=["typed","matrix","subtract","number"],um=q(sm,Tw,r=>{var{typed:e,matrix:t,subtract:a,number:n}=r;return e(sm,{"Array | Matrix":function(s){return Ve(s)?t(o(s.toArray())):o(s)},"Array | Matrix, number":function(s,c){if(!qe(c))throw new RangeError("Dimension must be a whole number");return Ve(s)?t(i(s.toArray(),c)):i(s,c)},"Array, BigNumber":e.referTo("Array,number",u=>(s,c)=>u(s,n(c))),"Matrix, BigNumber":e.referTo("Matrix,number",u=>(s,c)=>u(s,n(c)))});function i(u,s){if(Ve(u)&&(u=u.toArray()),!Array.isArray(u))throw RangeError("Array/Matrix does not have that many dimensions");if(s>0){var c=[];return u.forEach(m=>{c.push(i(m,s-1))}),c}else{if(s===0)return o(u);throw RangeError("Cannot have negative dimension")}}function o(u){for(var s=[],c=u.length,m=1;m<c;m++)s.push(f(u[m-1],u[m]));return s}function f(u,s){Ve(u)&&(u=u.toArray()),Ve(s)&&(s=s.toArray());var c=Array.isArray(u),m=Array.isArray(s);if(c&&m)return l(u,s);if(!c&&!m)return a(s,u);throw TypeError("Cannot calculate difference between 1 array and 1 non-array")}function l(u,s){if(u.length!==s.length)throw RangeError("Not all sub-arrays have the same length");for(var c=[],m=u.length,v=0;v<m;v++)c.push(f(u[v],s[v]));return c}}),Bw="ones",$w=["typed","config","matrix","BigNumber"],Ow=q(Bw,$w,r=>{var{typed:e,config:t,matrix:a,BigNumber:n}=r;return e("ones",{"":function(){return t.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(u){var s=u[u.length-1];if(typeof s=="string"){var c=u.pop();return i(u,c)}else return t.matrix==="Array"?i(u):i(u,"default")},Array:i,Matrix:function(u){var s=u.storage();return i(u.valueOf(),s)},"Array | Matrix, string":function(u,s){return i(u.valueOf(),s)}});function i(l,u){var s=o(l),c=s?new n(1):1;if(f(l),u){var m=a(u);return l.length>0?m.resize(l,c):m}else{var v=[];return l.length>0?Yn(v,l,c):v}}function o(l){var u=!1;return l.forEach(function(s,c,m){rr(s)&&(u=!0,m[c]=s.toNumber())}),u}function f(l){l.forEach(function(u){if(typeof u!="number"||!qe(u)||u<0)throw new Error("Parameters in function ones must be positive integers")})}});function ps(){throw new Error('No "bignumber" implementation available')}function lm(){throw new Error('No "fraction" implementation available')}function cm(){throw new Error('No "matrix" implementation available')}var fm="range",Iw=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],mm=q(fm,Iw,r=>{var{typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:o,larger:f,largerEq:l}=r;return e(fm,{string:s,"string, boolean":s,"number, number":function(y,N){return u(c(y,N,1))},"number, number, number":function(y,N,d){return u(c(y,N,d))},"number, number, boolean":function(y,N,d){return u(d?m(y,N,1):c(y,N,1))},"number, number, number, boolean":function(y,N,d,w){return u(w?m(y,N,d):c(y,N,d))},"BigNumber, BigNumber":function(y,N){var d=y.constructor;return u(v(y,N,new d(1)))},"BigNumber, BigNumber, BigNumber":function(y,N,d){return u(v(y,N,d))},"BigNumber, BigNumber, boolean":function(y,N,d){var w=y.constructor;return u(d?h(y,N,new w(1)):v(y,N,new w(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(y,N,d,w){return u(w?h(y,N,d):v(y,N,d))}});function u(g){return t.matrix==="Matrix"?a?a(g):cm():g}function s(g,y){var N=p(g);if(!N)throw new SyntaxError('String "'+g+'" is no valid range');var d;return t.number==="BigNumber"?(n===void 0&&ps(),d=y?h:v,u(d(n(N.start),n(N.end),n(N.step)))):(d=y?m:c,u(d(N.start,N.end,N.step)))}function c(g,y,N){var d=[],w=g;if(N>0)for(;i(w,y);)d.push(w),w+=N;else if(N<0)for(;f(w,y);)d.push(w),w+=N;return d}function m(g,y,N){var d=[],w=g;if(N>0)for(;o(w,y);)d.push(w),w+=N;else if(N<0)for(;l(w,y);)d.push(w),w+=N;return d}function v(g,y,N){var d=n(0),w=[],x=g;if(N.gt(d))for(;i(x,y);)w.push(x),x=x.plus(N);else if(N.lt(d))for(;f(x,y);)w.push(x),x=x.plus(N);return w}function h(g,y,N){var d=n(0),w=[],x=g;if(N.gt(d))for(;o(x,y);)w.push(x),x=x.plus(N);else if(N.lt(d))for(;l(x,y);)w.push(x),x=x.plus(N);return w}function p(g){var y=g.split(":"),N=y.map(function(w){return Number(w)}),d=N.some(function(w){return isNaN(w)});if(d)return null;switch(N.length){case 2:return{start:N[0],end:N[1],step:1};case 3:return{start:N[0],end:N[2],step:N[1]};default:return null}}}),vm="reshape",Rw=["typed","isInteger","matrix"],_w=q(vm,Rw,r=>{var{typed:e,isInteger:t}=r;return e(vm,{"Matrix, Array":function(n,i){return n.reshape(i,!0)},"Array, Array":function(n,i){return i.forEach(function(o){if(!t(o))throw new TypeError("Invalid size for dimension: "+o)}),bl(n,i)}})}),qw="resize",zw=["config","matrix"],Pw=q(qw,zw,r=>{var{config:e,matrix:t}=r;return function(i,o,f){if(arguments.length!==2&&arguments.length!==3)throw new Tn("resize",arguments.length,2,3);if(Ve(o)&&(o=o.valueOf()),rr(o[0])&&(o=o.map(function(s){return rr(s)?s.toNumber():s})),Ve(i))return i.resize(o,f,!0);if(typeof i=="string")return a(i,o,f);var l=Array.isArray(i)?!1:e.matrix!=="Array";if(o.length===0){for(;Array.isArray(i);)i=i[0];return Ge(i)}else{Array.isArray(i)||(i=[i]),i=Ge(i);var u=Yn(i,o,f);return l?t(u):u}};function a(n,i,o){if(o!==void 0){if(typeof o!="string"||o.length!==1)throw new TypeError("Single character expected as defaultValue")}else o=" ";if(i.length!==1)throw new Ke(i.length,1);var f=i[0];if(typeof f!="number"||!qe(f))throw new TypeError("Invalid size, must contain positive integers (size: "+Ye(i)+")");if(n.length>f)return n.substring(0,f);if(n.length<f){for(var l=n,u=0,s=f-n.length;u<s;u++)l+=o;return l}else return n}}),pm="rotate",Uw=["typed","multiply","rotationMatrix"],Lw=q(pm,Uw,r=>{var{typed:e,multiply:t,rotationMatrix:a}=r;return e(pm,{"Array , number | BigNumber | Complex | Unit":function(o,f){n(o,2);var l=t(a(f),o);return l.toArray()},"Matrix , number | BigNumber | Complex | Unit":function(o,f){return n(o,2),t(a(f),o)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(o,f,l){n(o,3);var u=t(a(f,l),o);return u},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(o,f,l){return n(o,3),t(a(f,l),o)}});function n(i,o){var f=Array.isArray(i)?er(i):i.size();if(f.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(o));if(f.length===2&&f[1]!==1)throw new RangeError("Vector must be of dimensions 1x".concat(o));if(f[0]!==o)throw new RangeError("Vector must be of dimensions 1x".concat(o))}}),hm="rotationMatrix",kw=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],Vw=q(hm,kw,r=>{var{typed:e,config:t,multiplyScalar:a,addScalar:n,unaryMinus:i,norm:o,BigNumber:f,matrix:l,DenseMatrix:u,SparseMatrix:s,cos:c,sin:m}=r;return e(hm,{"":function(){return t.matrix==="Matrix"?l([]):[]},string:function(d){return l(d)},"number | BigNumber | Complex | Unit":function(d){return v(d,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(d,w){return v(d,w)},"number | BigNumber | Complex | Unit, Array":function(d,w){var x=l(w);return h(x),y(d,x,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(d,w){h(w);var x=w.storage()||(t.matrix==="Matrix"?"dense":void 0);return y(d,w,x)},"number | BigNumber | Complex | Unit, Array, string":function(d,w,x){var b=l(w);return h(b),y(d,b,x)},"number | BigNumber | Complex | Unit, Matrix, string":function(d,w,x){return h(w),y(d,w,x)}});function v(N,d){var w=rr(N),x=w?new f(-1):-1,b=c(N),E=m(N),A=[[b,a(x,E)],[E,b]];return g(A,d)}function h(N){var d=N.size();if(d.length<1||d[0]!==3)throw new RangeError("Vector must be of dimensions 1x3")}function p(N){return N.reduce((d,w)=>a(d,w))}function g(N,d){if(d){if(d==="sparse")return new s(N);if(d==="dense")return new u(N);throw new TypeError('Unknown matrix type "'.concat(d,'"'))}return N}function y(N,d,w){var x=o(d);if(x===0)throw new RangeError("Rotation around zero vector");var b=rr(N)?f:null,E=b?new b(1):1,A=b?new b(-1):-1,S=b?new b(d.get([0])/x):d.get([0])/x,D=b?new b(d.get([1])/x):d.get([1])/x,T=b?new b(d.get([2])/x):d.get([2])/x,B=c(N),I=n(E,i(B)),P=m(N),R=n(B,p([S,S,I])),M=n(p([S,D,I]),p([A,T,P])),F=n(p([S,T,I]),p([D,P])),H=n(p([S,D,I]),p([T,P])),$=n(B,p([D,D,I])),k=n(p([D,T,I]),p([A,S,P])),Q=n(p([S,T,I]),p([A,D,P])),K=n(p([D,T,I]),p([S,P])),L=n(B,p([T,T,I])),j=[[R,M,F],[H,$,k],[Q,K,L]];return g(j,w)}}),dm="row",Gw=["typed","Index","matrix","range"],gm=q(dm,Gw,r=>{var{typed:e,Index:t,matrix:a,range:n}=r;return e(dm,{"Matrix, number":i,"Array, number":function(f,l){return i(a(Ge(f)),l).valueOf()}});function i(o,f){if(o.size().length!==2)throw new Error("Only two dimensional matrix is supported");vr(f,o.size()[0]);var l=n(0,o.size()[1]),u=new t(f,l),s=o.subset(u);return Ve(s)?s:a([[s]])}}),ym="size",Hw=["typed","config","?matrix"],Zw=q(ym,Hw,r=>{var{typed:e,config:t,matrix:a}=r;return e(ym,{Matrix:function(i){return i.create(i.size())},Array:er,string:function(i){return t.matrix==="Array"?[i.length]:a([i.length])},"number | Complex | BigNumber | Unit | boolean | null":function(i){return t.matrix==="Array"?[]:a?a([]):cm()}})}),bm="squeeze",Jw=["typed","matrix"],Xw=q(bm,Jw,r=>{var{typed:e,matrix:t}=r;return e(bm,{Array:function(n){return pi(Ge(n))},Matrix:function(n){var i=pi(n.toArray());return Array.isArray(i)?t(i):i},any:function(n){return Ge(n)}})}),xm="subset",Ww=["typed","matrix"],wm=q(xm,Ww,r=>{var{typed:e,matrix:t}=r;return e(xm,{"Array, Index":function(n,i){var o=t(n),f=o.subset(i);return i.isScalar()?f:f.valueOf()},"Matrix, Index":function(n,i){return n.subset(i)},"Object, Index":Qw,"string, Index":Yw,"Array, Index, any":function(n,i,o){return t(Ge(n)).subset(i,o,void 0).valueOf()},"Array, Index, any, any":function(n,i,o,f){return t(Ge(n)).subset(i,o,f).valueOf()},"Matrix, Index, any":function(n,i,o){return n.clone().subset(i,o)},"Matrix, Index, any, any":function(n,i,o,f){return n.clone().subset(i,o,f)},"string, Index, string":Nm,"string, Index, string, string":Nm,"Object, Index, any":Kw})});function Yw(r,e){if(!li(e))throw new TypeError("Index expected");if(e.size().length!==1)throw new Ke(e.size().length,1);var t=r.length;vr(e.min()[0],t),vr(e.max()[0],t);var a=e.dimension(0),n="";return a.forEach(function(i){n+=r.charAt(i)}),n}function Nm(r,e,t,a){if(!e||e.isIndex!==!0)throw new TypeError("Index expected");if(e.size().length!==1)throw new Ke(e.size().length,1);if(a!==void 0){if(typeof a!="string"||a.length!==1)throw new TypeError("Single character expected as defaultValue")}else a=" ";var n=e.dimension(0),i=n.size()[0];if(i!==t.length)throw new Ke(n.size()[0],t.length);var o=r.length;vr(e.min()[0]),vr(e.max()[0]);for(var f=[],l=0;l<o;l++)f[l]=r.charAt(l);if(n.forEach(function(c,m){f[c]=t.charAt(m[0])}),f.length>o)for(var u=o-1,s=f.length;u<s;u++)f[u]||(f[u]=a);return f.join("")}function Qw(r,e){if(e.size().length!==1)throw new Ke(e.size(),1);var t=e.dimension(0);if(typeof t!="string")throw new TypeError("String expected as index to retrieve an object property");return ut(r,t)}function Kw(r,e,t){if(e.size().length!==1)throw new Ke(e.size(),1);var a=e.dimension(0);if(typeof a!="string")throw new TypeError("String expected as index to retrieve an object property");var n=Ge(r);return Kn(n,a,t),n}var Dm="transpose",jw=["typed","matrix"],eN=q(Dm,jw,r=>{var{typed:e,matrix:t}=r;return e(Dm,{Array:o=>a(t(o)).valueOf(),Matrix:a,any:Ge});function a(o){var f=o.size(),l;switch(f.length){case 1:l=o.clone();break;case 2:{var u=f[0],s=f[1];if(s===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+Ye(f)+")");switch(o.storage()){case"dense":l=n(o,u,s);break;case"sparse":l=i(o,u,s);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+Ye(f)+")")}return l}function n(o,f,l){for(var u=o._data,s=[],c,m=0;m<l;m++){c=s[m]=[];for(var v=0;v<f;v++)c[v]=Ge(u[v][m])}return o.createDenseMatrix({data:s,size:[l,f],datatype:o._datatype})}function i(o,f,l){for(var u=o._values,s=o._index,c=o._ptr,m=u?[]:void 0,v=[],h=[],p=[],g=0;g<f;g++)p[g]=0;var y,N,d;for(y=0,N=s.length;y<N;y++)p[s[y]]++;for(var w=0,x=0;x<f;x++)h.push(w),w+=p[x],p[x]=h[x];for(h.push(w),d=0;d<l;d++)for(var b=c[d],E=c[d+1],A=b;A<E;A++){var S=p[s[A]]++;v[S]=d,u&&(m[S]=Ge(u[A]))}return o.createSparseMatrix({values:m,index:v,ptr:h,size:[l,f],datatype:o._datatype})}}),Am="ctranspose",rN=["typed","transpose","conj"],tN=q(Am,rN,r=>{var{typed:e,transpose:t,conj:a}=r;return e(Am,{any:function(i){return a(t(i))}})}),Em="zeros",nN=["typed","config","matrix","BigNumber"],aN=q(Em,nN,r=>{var{typed:e,config:t,matrix:a,BigNumber:n}=r;return e(Em,{"":function(){return t.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(u){var s=u[u.length-1];if(typeof s=="string"){var c=u.pop();return i(u,c)}else return t.matrix==="Array"?i(u):i(u,"default")},Array:i,Matrix:function(u){var s=u.storage();return i(u.valueOf(),s)},"Array | Matrix, string":function(u,s){return i(u.valueOf(),s)}});function i(l,u){var s=o(l),c=s?new n(0):0;if(f(l),u){var m=a(u);return l.length>0?m.resize(l,c):m}else{var v=[];return l.length>0?Yn(v,l,c):v}}function o(l){var u=!1;return l.forEach(function(s,c,m){rr(s)&&(u=!0,m[c]=s.toNumber())}),u}function f(l){l.forEach(function(u){if(typeof u!="number"||!qe(u)||u<0)throw new Error("Parameters in function zeros must be positive integers")})}}),Sm="fft",iN=["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i","dotDivide","conj","pow","ceil","log2"],oN=q(Sm,iN,r=>{var{typed:e,matrix:t,addScalar:a,multiplyScalar:n,divideScalar:i,exp:o,tau:f,i:l,dotDivide:u,conj:s,pow:c,ceil:m,log2:v}=r;return e(Sm,{Array:h,Matrix:function(d){return d.create(h(d.toArray()))}});function h(N){var d=er(N);return d.length===1?y(N,d[0]):p(N.map(w=>h(w,d.slice(1))),0)}function p(N,d){var w=er(N);if(d!==0)return new Array(w[0]).fill(0).map((b,E)=>p(N[E],d-1));if(w.length===1)return y(N);function x(b){var E=er(b);return new Array(E[1]).fill(0).map((A,S)=>new Array(E[0]).fill(0).map((D,T)=>b[T][S]))}return x(p(x(N),1))}function g(N){for(var d=N.length,w=o(i(n(-1,n(l,f)),d)),x=[],b=1-d;b<d;b++)x.push(c(w,i(c(b,2),2)));for(var E=c(2,m(v(d+d-1))),A=[...new Array(d).fill(0).map((M,F)=>n(N[F],x[d-1+F])),...new Array(E-d).fill(0)],S=[...new Array(d+d-1).fill(0).map((M,F)=>i(1,x[F])),...new Array(E-(d+d-1)).fill(0)],D=y(A),T=y(S),B=new Array(E).fill(0).map((M,F)=>n(D[F],T[F])),I=u(s(h(s(B))),E),P=[],R=d-1;R<d+d-1;R++)P.push(n(I[R],x[R]));return P}function y(N){var d=N.length;if(d===1)return[N[0]];if(d%2===0){for(var w=[...y(N.filter((A,S)=>S%2===0)),...y(N.filter((A,S)=>S%2===1))],x=0;x<d/2;x++){var b=w[x],E=n(w[x+d/2],o(n(n(f,l),i(-x,d))));w[x]=a(b,E),w[x+d/2]=a(b,n(-1,E))}return w}else return g(N)}}),Cm="ifft",sN=["typed","fft","dotDivide","conj"],uN=q(Cm,sN,r=>{var{typed:e,fft:t,dotDivide:a,conj:n}=r;return e(Cm,{"Array | Matrix":function(o){var f=Ve(o)?o.size():er(o);return a(n(t(n(o))),f.reduce((l,u)=>l*u,1))}})}),lN="erf",cN=["typed"],fN=q(lN,cN,r=>{var{typed:e}=r;return e("name",{number:function(o){var f=Math.abs(o);return f>=pN?tn(o):f<=mN?tn(o)*t(f):f<=4?tn(o)*(1-a(f)):tn(o)*(1-n(f))},"Array | Matrix":e.referToSelf(i=>o=>je(o,i))});function t(i){var o=i*i,f=Wt[0][4]*o,l=o,u;for(u=0;u<3;u+=1)f=(f+Wt[0][u])*o,l=(l+sa[0][u])*o;return i*(f+Wt[0][3])/(l+sa[0][3])}function a(i){var o=Wt[1][8]*i,f=i,l;for(l=0;l<7;l+=1)o=(o+Wt[1][l])*i,f=(f+sa[1][l])*i;var u=(o+Wt[1][7])/(f+sa[1][7]),s=parseInt(i*16)/16,c=(i-s)*(i+s);return Math.exp(-s*s)*Math.exp(-c)*u}function n(i){var o=1/(i*i),f=Wt[2][5]*o,l=o,u;for(u=0;u<4;u+=1)f=(f+Wt[2][u])*o,l=(l+sa[2][u])*o;var s=o*(f+Wt[2][4])/(l+sa[2][4]);s=(vN-s)/i,o=parseInt(i*16)/16;var c=(i-o)*(i+o);return Math.exp(-o*o)*Math.exp(-c)*s}}),mN=.46875,vN=.5641895835477563,Wt=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,21531153547440383e-24],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],sa=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],pN=Math.pow(2,53),Mm="mode",hN=["typed","isNaN","isNumeric"],dN=q(Mm,hN,r=>{var{typed:e,isNaN:t,isNumeric:a}=r;return e(Mm,{"Array | Matrix":n,"...":function(o){return n(o)}});function n(i){i=or(i.valueOf());var o=i.length;if(o===0)throw new Error("Cannot calculate mode of an empty array");for(var f={},l=[],u=0,s=0;s<i.length;s++){var c=i[s];if(a(c)&&t(c))throw new Error("Cannot calculate mode of an array containing NaN values");c in f||(f[c]=0),f[c]++,f[c]===u?l.push(c):f[c]>u&&(u=f[c],l=[c])}return l}});function Qr(r,e,t){var a;return String(r).indexOf("Unexpected type")!==-1?(a=arguments.length>2?" (type: "+br(t)+", value: "+JSON.stringify(t)+")":" (type: "+r.data.actual+")",new TypeError("Cannot calculate "+e+", unexpected type of argument"+a)):String(r).indexOf("complex numbers")!==-1?(a=arguments.length>2?" (type: "+br(t)+", value: "+JSON.stringify(t)+")":"",new TypeError("Cannot calculate "+e+", no ordering relation is defined for complex numbers"+a)):r}var Fm="prod",gN=["typed","config","multiplyScalar","numeric"],yN=q(Fm,gN,r=>{var{typed:e,config:t,multiplyScalar:a,numeric:n}=r;return e(Fm,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(f,l){throw new Error("prod(A, dim) is not yet supported")},"...":function(f){return i(f)}});function i(o){var f;if(Jt(o,function(l){try{f=f===void 0?l:a(f,l)}catch(u){throw Qr(u,"prod",l)}}),typeof f=="string"&&(f=n(f,t.number)),f===void 0)throw new Error("Cannot calculate prod of an empty array");return f}}),Tm="format",bN=["typed"],xN=q(Tm,bN,r=>{var{typed:e}=r;return e(Tm,{any:Ye,"any, Object | function | number":Ye})}),Bm="bin",wN=["typed","format"],NN=q(Bm,wN,r=>{var{typed:e,format:t}=r;return e(Bm,{"number | BigNumber":function(n){return t(n,{notation:"bin"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"bin",wordSize:i})}})}),$m="oct",DN=["typed","format"],AN=q($m,DN,r=>{var{typed:e,format:t}=r;return e($m,{"number | BigNumber":function(n){return t(n,{notation:"oct"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"oct",wordSize:i})}})}),Om="hex",EN=["typed","format"],SN=q(Om,EN,r=>{var{typed:e,format:t}=r;return e(Om,{"number | BigNumber":function(n){return t(n,{notation:"hex"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"hex",wordSize:i})}})}),Im="print",CN=["typed"],MN=q(Im,CN,r=>{var{typed:e}=r;return e(Im,{"string, Object | Array":Rm,"string, Object | Array, number | Object":Rm})});function Rm(r,e,t){return r.replace(/\$([\w.]+)/g,function(a,n){for(var i=n.split("."),o=e[i.shift()];i.length&&o!==void 0;){var f=i.shift();o=f?o[f]:o+"."}return o!==void 0?Wr(o)?o:Ye(o,t):a})}var _m="to",FN=["typed","matrix","concat"],TN=q(_m,FN,r=>{var{typed:e,matrix:t,concat:a}=r,n=dr({typed:e,matrix:t,concat:a});return e(_m,{"Unit, Unit | string":(i,o)=>i.to(o)},n({Ds:!0}))}),qm="isPrime",BN=["typed"],$N=q(qm,BN,r=>{var{typed:e}=r;return e(qm,{number:function(a){if(a*0!==0)return!1;if(a<=3)return a>1;if(a%2===0||a%3===0)return!1;for(var n=5;n*n<=a;n+=6)if(a%n===0||a%(n+2)===0)return!1;return!0},BigNumber:function(a){if(a.toNumber()*0!==0)return!1;if(a.lte(3))return a.gt(1);if(a.mod(2).eq(0)||a.mod(3).eq(0))return!1;if(a.lt(Math.pow(2,32))){for(var n=a.toNumber(),i=5;i*i<=n;i+=6)if(n%i===0||n%(i+2)===0)return!1;return!0}function o(N,d,w){for(var x=1;!d.eq(0);)d.mod(2).eq(0)?(d=d.div(2),N=N.mul(N).mod(w)):(d=d.sub(1),x=N.mul(x).mod(w));return x}var f=a.constructor.clone({precision:a.toFixed(0).length*2});a=new f(a);for(var l=0,u=a.sub(1);u.mod(2).eq(0);)u=u.div(2),l+=1;var s=null;if(a.lt("3317044064679887385961981"))s=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter(N=>N<a);else{var c=Math.min(a.toNumber()-2,Math.floor(2*Math.pow(a.toFixed(0).length*Math.log(10),2)));s=[];for(var m=2;m<=c;m+=1)s.push(c)}for(var v=0;v<s.length;v+=1){var h=s[v],p=o(a.sub(a).add(h),u,a);if(!p.eq(1)){for(var g=0,y=p;!y.eq(a.sub(1));g+=1,y=y.mul(y).mod(a))if(g===l-1)return!1}}return!0},"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),ON="numeric",IN=["number","?bignumber","?fraction"],RN=q(ON,IN,r=>{var{number:e,bignumber:t,fraction:a}=r,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:o=>e(o),BigNumber:t?o=>t(o):ps,Fraction:a?o=>a(o):lm};return function(f){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",u=arguments.length>2?arguments[2]:void 0;if(u!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var s=br(f);if(!(s in n))throw new TypeError("Cannot convert "+f+' of type "'+s+'"; valid input types are '+Object.keys(n).join(", "));if(!(l in i))throw new TypeError("Cannot convert "+f+' to type "'+l+'"; valid output types are '+Object.keys(i).join(", "));return l===s?f:i[l](f)}}),zm="divideScalar",_N=["typed","numeric"],qN=q(zm,_N,r=>{var{typed:e,numeric:t}=r;return e(zm,{"number, number":function(n,i){return n/i},"Complex, Complex":function(n,i){return n.div(i)},"BigNumber, BigNumber":function(n,i){return n.div(i)},"Fraction, Fraction":function(n,i){return n.div(i)},"Unit, number | Complex | Fraction | BigNumber | Unit":(a,n)=>a.divide(n),"number | Fraction | Complex | BigNumber, Unit":(a,n)=>n.divideInto(a)})}),Pm="pow",zN=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],PN=q(Pm,zN,r=>{var{typed:e,config:t,identity:a,multiply:n,matrix:i,inv:o,number:f,fraction:l,Complex:u}=r;return e(Pm,{"number, number":s,"Complex, Complex":function(h,p){return h.pow(p)},"BigNumber, BigNumber":function(h,p){return p.isInteger()||h>=0||t.predictable?h.pow(p):new u(h.toNumber(),0).pow(p.toNumber(),0)},"Fraction, Fraction":function(h,p){var g=h.pow(p);if(g!=null)return g;if(t.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return s(h.valueOf(),p.valueOf())},"Array, number":c,"Array, BigNumber":function(h,p){return c(h,p.toNumber())},"Matrix, number":m,"Matrix, BigNumber":function(h,p){return m(h,p.toNumber())},"Unit, number | BigNumber":function(h,p){return h.pow(p)}});function s(v,h){if(t.predictable&&!qe(h)&&v<0)try{var p=l(h),g=f(p);if((h===g||Math.abs((h-g)/h)<1e-14)&&p.d%2===1)return(p.n%2===0?1:-1)*Math.pow(-v,h)}catch{}return t.predictable&&(v<-1&&h===1/0||v>-1&&v<0&&h===-1/0)?NaN:qe(h)||v>=0||t.predictable?mc(v,h):v*v<1&&h===1/0||v*v>1&&h===-1/0?0:new u(v,0).pow(h,0)}function c(v,h){if(!qe(h))throw new TypeError("For A^b, b must be an integer (value is "+h+")");var p=er(v);if(p.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+p.length+" dimensions)");if(p[0]!==p[1])throw new Error("For A^b, A must be square (size is "+p[0]+"x"+p[1]+")");if(h<0)try{return c(o(v),-h)}catch(N){throw N.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+h+")"):N}for(var g=a(p[0]).valueOf(),y=v;h>=1;)(h&1)===1&&(g=n(y,g)),h>>=1,y=n(y,y);return g}function m(v,h){return i(c(v.valueOf(),h))}}),ua="Number of decimals in function round must be an integer",Um="round",UN=["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],LN=q(Um,UN,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,BigNumber:i,DenseMatrix:o}=r,f=Lr({typed:e,equalScalar:a}),l=Ir({typed:e,DenseMatrix:o}),u=bt({typed:e});return e(Um,{number:vc,"number, number":vc,"number, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(ua);return new i(c).toDecimalPlaces(m.toNumber())},Complex:function(c){return c.round()},"Complex, number":function(c,m){if(m%1)throw new TypeError(ua);return c.round(m)},"Complex, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(ua);var v=m.toNumber();return c.round(v)},BigNumber:function(c){return c.toDecimalPlaces(0)},"BigNumber, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(ua);return c.toDecimalPlaces(m.toNumber())},Fraction:function(c){return c.round()},"Fraction, number":function(c,m){if(m%1)throw new TypeError(ua);return c.round(m)},"Fraction, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(ua);return c.round(m.toNumber())},"Array | Matrix":e.referToSelf(s=>c=>je(c,s)),"SparseMatrix, number | BigNumber":e.referToSelf(s=>(c,m)=>f(c,m,s,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(s=>(c,m)=>u(c,m,s,!1)),"Array, number | BigNumber":e.referToSelf(s=>(c,m)=>u(t(c),m,s,!1).valueOf()),"number | Complex | BigNumber | Fraction, SparseMatrix":e.referToSelf(s=>(c,m)=>a(c,0)?n(m.size(),m.storage()):l(m,c,s,!0)),"number | Complex | BigNumber | Fraction, DenseMatrix":e.referToSelf(s=>(c,m)=>a(c,0)?n(m.size(),m.storage()):u(m,c,s,!0)),"number | Complex | BigNumber | Fraction, Array":e.referToSelf(s=>(c,m)=>u(t(m),c,s,!0).valueOf())})}),Lm="log",kN=["config","typed","divideScalar","Complex"],VN=q(Lm,kN,r=>{var{typed:e,config:t,divideScalar:a,Complex:n}=r;return e(Lm,{number:function(o){return o>=0||t.predictable?H1(o):new n(o,0).log()},Complex:function(o){return o.log()},BigNumber:function(o){return!o.isNegative()||t.predictable?o.ln():new n(o.toNumber(),0).log()},"any, any":e.referToSelf(i=>(o,f)=>a(i(o),i(f)))})}),km="log1p",GN=["typed","config","divideScalar","log","Complex"],HN=q(km,GN,r=>{var{typed:e,config:t,divideScalar:a,log:n,Complex:i}=r;return e(km,{number:function(l){return l>=-1||t.predictable?J0(l):o(new i(l,0))},Complex:o,BigNumber:function(l){var u=l.plus(1);return!u.isNegative()||t.predictable?u.ln():o(new i(l.toNumber(),0))},"Array | Matrix":e.referToSelf(f=>l=>je(l,f)),"any, any":e.referToSelf(f=>(l,u)=>a(f(l),n(u)))});function o(f){var l=f.re+1;return new i(Math.log(Math.sqrt(l*l+f.im*f.im)),Math.atan2(f.im,l))}}),Vm="nthRoots",ZN=["config","typed","divideScalar","Complex"],JN=q(Vm,ZN,r=>{var{typed:e,config:t,divideScalar:a,Complex:n}=r,i=[function(l){return new n(l,0)},function(l){return new n(0,l)},function(l){return new n(-l,0)},function(l){return new n(0,-l)}];function o(f,l){if(l<0)throw new Error("Root must be greater than zero");if(l===0)throw new Error("Root must be non-zero");if(l%1!==0)throw new Error("Root must be an integer");if(f===0||f.abs()===0)return[new n(0,0)];var u=typeof f=="number",s;(u||f.re===0||f.im===0)&&(u?s=2*+(f<0):f.im===0?s=2*+(f.re<0):s=2*+(f.im<0)+1);for(var c=f.arg(),m=f.abs(),v=[],h=Math.pow(m,1/l),p=0;p<l;p++){var g=(s+4*p)/l;if(g===Math.round(g)){v.push(i[g%4](h));continue}v.push(new n({r:h,phi:(c+2*Math.PI*p)/l}))}return v}return e(Vm,{Complex:function(l){return o(l,2)},"Complex, number":o})}),Gm="dotPow",XN=["typed","equalScalar","matrix","pow","DenseMatrix","concat"],WN=q(Gm,XN,r=>{var{typed:e,equalScalar:t,matrix:a,pow:n,DenseMatrix:i,concat:o}=r,f=Yr({typed:e}),l=Bt({typed:e,DenseMatrix:i}),u=Lr({typed:e,equalScalar:t}),s=Ir({typed:e,DenseMatrix:i}),c=dr({typed:e,matrix:a,concat:o}),m={};for(var v in n.signatures)Object.prototype.hasOwnProperty.call(n.signatures,v)&&!v.includes("Matrix")&&!v.includes("Array")&&(m[v]=n.signatures[v]);var h=e(m);return e(Gm,c({elop:h,SS:l,DS:f,Ss:u,sS:s}))}),Hm="dotDivide",YN=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],QN=q(Hm,YN,r=>{var{typed:e,matrix:t,equalScalar:a,divideScalar:n,DenseMatrix:i,concat:o}=r,f=xt({typed:e,equalScalar:a}),l=Yr({typed:e}),u=Bt({typed:e,DenseMatrix:i}),s=Lr({typed:e,equalScalar:a}),c=Ir({typed:e,DenseMatrix:i}),m=dr({typed:e,matrix:t,concat:o});return e(Hm,m({elop:n,SS:u,DS:l,SD:f,Ss:s,sS:c}))});function Ha(r){var{DenseMatrix:e}=r;return function(a,n,i){var o=a.size();if(o.length!==2)throw new RangeError("Matrix must be two dimensional (size: "+Ye(o)+")");var f=o[0],l=o[1];if(f!==l)throw new RangeError("Matrix must be square (size: "+Ye(o)+")");var u=[];if(Ve(n)){var s=n.size(),c=n._data;if(s.length===1){if(s[0]!==f)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var m=0;m<f;m++)u[m]=[c[m]];return new e({data:u,size:[f,1],datatype:n._datatype})}if(s.length===2){if(s[0]!==f||s[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");if(ui(n)){if(i){u=[];for(var v=0;v<f;v++)u[v]=[c[v][0]];return new e({data:u,size:[f,1],datatype:n._datatype})}return n}if(An(n)){for(var h=0;h<f;h++)u[h]=[0];for(var p=n._values,g=n._index,y=n._ptr,N=y[1],d=y[0];d<N;d++){var w=g[d];u[w][0]=p[d]}return new e({data:u,size:[f,1],datatype:n._datatype})}}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}if(cr(n)){var x=er(n);if(x.length===1){if(x[0]!==f)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var b=0;b<f;b++)u[b]=[n[b]];return new e({data:u,size:[f,1]})}if(x.length===2){if(x[0]!==f||x[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var E=0;E<f;E++)u[E]=[n[E][0]];return new e({data:u,size:[f,1]})}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}}}var Zm="lsolve",KN=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],jN=q(Zm,KN,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:o,DenseMatrix:f}=r,l=Ha({DenseMatrix:f});return e(Zm,{"SparseMatrix, Array | Matrix":function(m,v){return s(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var h=t(m),p=u(h,v);return p.valueOf()}});function u(c,m){m=l(c,m,!0);for(var v=m._data,h=c._size[0],p=c._size[1],g=[],y=c._data,N=0;N<p;N++){var d=v[N][0]||0,w=void 0;if(o(d,0))w=0;else{var x=y[N][N];if(o(x,0))throw new Error("Linear system cannot be solved since matrix is singular");w=a(d,x);for(var b=N+1;b<h;b++)v[b]=[i(v[b][0]||0,n(w,y[b][N]))]}g[N]=[w]}return new f({data:g,size:[h,1]})}function s(c,m){m=l(c,m,!0);for(var v=m._data,h=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,d=[],w=0;w<p;w++){var x=v[w][0]||0;if(o(x,0))d[w]=[0];else{for(var b=0,E=[],A=[],S=N[w],D=N[w+1],T=S;T<D;T++){var B=y[T];B===w?b=g[T]:B>w&&(E.push(g[T]),A.push(B))}if(o(b,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var I=a(x,b),P=0,R=A.length;P<R;P++){var M=A[P];v[M]=[i(v[M][0]||0,n(I,E[P]))]}d[w]=[I]}}return new f({data:d,size:[h,1]})}}),Jm="usolve",e2=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],r2=q(Jm,e2,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:o,DenseMatrix:f}=r,l=Ha({DenseMatrix:f});return e(Jm,{"SparseMatrix, Array | Matrix":function(m,v){return s(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var h=t(m),p=u(h,v);return p.valueOf()}});function u(c,m){m=l(c,m,!0);for(var v=m._data,h=c._size[0],p=c._size[1],g=[],y=c._data,N=p-1;N>=0;N--){var d=v[N][0]||0,w=void 0;if(o(d,0))w=0;else{var x=y[N][N];if(o(x,0))throw new Error("Linear system cannot be solved since matrix is singular");w=a(d,x);for(var b=N-1;b>=0;b--)v[b]=[i(v[b][0]||0,n(w,y[b][N]))]}g[N]=[w]}return new f({data:g,size:[h,1]})}function s(c,m){m=l(c,m,!0);for(var v=m._data,h=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,d=[],w=p-1;w>=0;w--){var x=v[w][0]||0;if(o(x,0))d[w]=[0];else{for(var b=0,E=[],A=[],S=N[w],D=N[w+1],T=D-1;T>=S;T--){var B=y[T];B===w?b=g[T]:B<w&&(E.push(g[T]),A.push(B))}if(o(b,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var I=a(x,b),P=0,R=A.length;P<R;P++){var M=A[P];v[M]=[i(v[M][0],n(I,E[P]))]}d[w]=[I]}}return new f({data:d,size:[h,1]})}}),Xm="lsolveAll",t2=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],n2=q(Xm,t2,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:o,DenseMatrix:f}=r,l=Ha({DenseMatrix:f});return e(Xm,{"SparseMatrix, Array | Matrix":function(m,v){return s(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var h=t(m),p=u(h,v);return p.map(g=>g.valueOf())}});function u(c,m){for(var v=[l(c,m,!0)._data.map(A=>A[0])],h=c._data,p=c._size[0],g=c._size[1],y=0;y<g;y++)for(var N=v.length,d=0;d<N;d++){var w=v[d];if(o(h[y][y],0))if(o(w[y],0)){if(d===0){var b=[...w];b[y]=1;for(var E=y+1;E<g;E++)b[E]=i(b[E],h[E][y]);v.push(b)}}else{if(d===0)return[];v.splice(d,1),d-=1,N-=1}else{w[y]=a(w[y],h[y][y]);for(var x=y+1;x<g;x++)w[x]=i(w[x],n(w[y],h[x][y]))}}return v.map(A=>new f({data:A.map(S=>[S]),size:[p,1]}))}function s(c,m){for(var v=[l(c,m,!0)._data.map(Q=>Q[0])],h=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,d=0;d<p;d++)for(var w=v.length,x=0;x<w;x++){for(var b=v[x],E=[],A=[],S=N[d],D=N[d+1],T=0,B=S;B<D;B++){var I=y[B];I===d?T=g[B]:I>d&&(E.push(g[B]),A.push(I))}if(o(T,0))if(o(b[d],0)){if(x===0){var F=[...b];F[d]=1;for(var H=0,$=A.length;H<$;H++){var k=A[H];F[k]=i(F[k],E[H])}v.push(F)}}else{if(x===0)return[];v.splice(x,1),x-=1,w-=1}else{b[d]=a(b[d],T);for(var P=0,R=A.length;P<R;P++){var M=A[P];b[M]=i(b[M],n(b[d],E[P]))}}}return v.map(Q=>new f({data:Q.map(K=>[K]),size:[h,1]}))}}),Wm="usolveAll",a2=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],i2=q(Wm,a2,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:o,DenseMatrix:f}=r,l=Ha({DenseMatrix:f});return e(Wm,{"SparseMatrix, Array | Matrix":function(m,v){return s(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var h=t(m),p=u(h,v);return p.map(g=>g.valueOf())}});function u(c,m){for(var v=[l(c,m,!0)._data.map(A=>A[0])],h=c._data,p=c._size[0],g=c._size[1],y=g-1;y>=0;y--)for(var N=v.length,d=0;d<N;d++){var w=v[d];if(o(h[y][y],0))if(o(w[y],0)){if(d===0){var b=[...w];b[y]=1;for(var E=y-1;E>=0;E--)b[E]=i(b[E],h[E][y]);v.push(b)}}else{if(d===0)return[];v.splice(d,1),d-=1,N-=1}else{w[y]=a(w[y],h[y][y]);for(var x=y-1;x>=0;x--)w[x]=i(w[x],n(w[y],h[x][y]))}}return v.map(A=>new f({data:A.map(S=>[S]),size:[p,1]}))}function s(c,m){for(var v=[l(c,m,!0)._data.map(Q=>Q[0])],h=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,d=p-1;d>=0;d--)for(var w=v.length,x=0;x<w;x++){for(var b=v[x],E=[],A=[],S=N[d],D=N[d+1],T=0,B=D-1;B>=S;B--){var I=y[B];I===d?T=g[B]:I<d&&(E.push(g[B]),A.push(I))}if(o(T,0))if(o(b[d],0)){if(x===0){var F=[...b];F[d]=1;for(var H=0,$=A.length;H<$;H++){var k=A[H];F[k]=i(F[k],E[H])}v.push(F)}}else{if(x===0)return[];v.splice(x,1),x-=1,w-=1}else{b[d]=a(b[d],T);for(var P=0,R=A.length;P<R;P++){var M=A[P];b[M]=i(b[M],n(b[d],E[P]))}}}return v.map(Q=>new f({data:Q.map(K=>[K]),size:[h,1]}))}}),o2="matAlgo08xS0Sid",s2=["typed","equalScalar"],hs=q(o2,s2,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o){var f=n._values,l=n._index,u=n._ptr,s=n._size,c=n._datatype,m=i._values,v=i._index,h=i._ptr,p=i._size,g=i._datatype;if(s.length!==p.length)throw new Ke(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!f||!m)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var y=s[0],N=s[1],d,w=t,x=0,b=o;typeof c=="string"&&c===g&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),b=e.find(o,[d,d]));for(var E=[],A=[],S=[],D=[],T=[],B,I,P,R,M=0;M<N;M++){S[M]=A.length;var F=M+1;for(I=u[M],P=u[M+1],B=I;B<P;B++)R=l[B],T[R]=F,D[R]=f[B],A.push(R);for(I=h[M],P=h[M+1],B=I;B<P;B++)R=v[B],T[R]===F&&(D[R]=b(D[R],m[B]));for(B=S[M];B<A.length;){R=A[B];var H=D[R];w(H,x)?A.splice(B,1):(E.push(H),B++)}}return S[N]=A.length,n.createSparseMatrix({values:E,index:A,ptr:S,size:[y,N],datatype:d})}}),ds=q("useMatrixForArrayScalar",["typed","matrix"],r=>{var{typed:e,matrix:t}=r;return{"Array, number":e.referTo("DenseMatrix, number",a=>(n,i)=>a(t(n),i).valueOf()),"Array, BigNumber":e.referTo("DenseMatrix, BigNumber",a=>(n,i)=>a(t(n),i).valueOf()),"number, Array":e.referTo("number, DenseMatrix",a=>(n,i)=>a(n,t(i)).valueOf()),"BigNumber, Array":e.referTo("BigNumber, DenseMatrix",a=>(n,i)=>a(n,t(i)).valueOf())}}),Ym="leftShift",u2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],l2=q(Ym,u2,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,DenseMatrix:i,concat:o}=r,f=cn({typed:e}),l=xt({typed:e,equalScalar:a}),u=hs({typed:e,equalScalar:a}),s=Fn({typed:e,DenseMatrix:i}),c=Lr({typed:e,equalScalar:a}),m=bt({typed:e}),v=dr({typed:e,matrix:t,concat:o}),h=ds({typed:e,matrix:t});return e(Ym,{"number, number":yc,"BigNumber, BigNumber":Ox,"SparseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>a(y,0)?g.clone():c(g,y,p,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>a(y,0)?g.clone():m(g,y,p,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(p=>(g,y)=>a(g,0)?n(y.size(),y.storage()):s(y,g,p,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(p=>(g,y)=>a(g,0)?n(y.size(),y.storage()):m(y,g,p,!0))},h,v({SS:u,DS:f,SD:l}))}),Qm="rightArithShift",c2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],f2=q(Qm,c2,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,DenseMatrix:i,concat:o}=r,f=cn({typed:e}),l=xt({typed:e,equalScalar:a}),u=hs({typed:e,equalScalar:a}),s=Fn({typed:e,DenseMatrix:i}),c=Lr({typed:e,equalScalar:a}),m=bt({typed:e}),v=dr({typed:e,matrix:t,concat:o}),h=ds({typed:e,matrix:t});return e(Qm,{"number, number":bc,"BigNumber, BigNumber":Ix,"SparseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>a(y,0)?g.clone():c(g,y,p,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>a(y,0)?g.clone():m(g,y,p,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(p=>(g,y)=>a(g,0)?n(y.size(),y.storage()):s(y,g,p,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(p=>(g,y)=>a(g,0)?n(y.size(),y.storage()):m(y,g,p,!0))},h,v({SS:u,DS:f,SD:l}))}),Km="rightLogShift",m2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],v2=q(Km,m2,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,DenseMatrix:i,concat:o}=r,f=cn({typed:e}),l=xt({typed:e,equalScalar:a}),u=hs({typed:e,equalScalar:a}),s=Fn({typed:e,DenseMatrix:i}),c=Lr({typed:e,equalScalar:a}),m=bt({typed:e}),v=dr({typed:e,matrix:t,concat:o}),h=ds({typed:e,matrix:t});return e(Km,{"number, number":xc,"SparseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>a(y,0)?g.clone():c(g,y,p,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>a(y,0)?g.clone():m(g,y,p,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(p=>(g,y)=>a(g,0)?n(y.size(),y.storage()):s(y,g,p,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(p=>(g,y)=>a(g,0)?n(y.size(),y.storage()):m(y,g,p,!0))},h,v({SS:u,DS:f,SD:l}))}),jm="and",p2=["typed","matrix","equalScalar","zeros","not","concat"],h2=q(jm,p2,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,not:i,concat:o}=r,f=xt({typed:e,equalScalar:a}),l=Oi({typed:e,equalScalar:a}),u=Lr({typed:e,equalScalar:a}),s=bt({typed:e}),c=dr({typed:e,matrix:t,concat:o});return e(jm,{"number, number":Ec,"Complex, Complex":function(v,h){return(v.re!==0||v.im!==0)&&(h.re!==0||h.im!==0)},"BigNumber, BigNumber":function(v,h){return!v.isZero()&&!h.isZero()&&!v.isNaN()&&!h.isNaN()},"Unit, Unit":e.referToSelf(m=>(v,h)=>m(v.value||0,h.value||0)),"SparseMatrix, any":e.referToSelf(m=>(v,h)=>i(h)?n(v.size(),v.storage()):u(v,h,m,!1)),"DenseMatrix, any":e.referToSelf(m=>(v,h)=>i(h)?n(v.size(),v.storage()):s(v,h,m,!1)),"any, SparseMatrix":e.referToSelf(m=>(v,h)=>i(v)?n(v.size(),v.storage()):u(h,v,m,!0)),"any, DenseMatrix":e.referToSelf(m=>(v,h)=>i(v)?n(v.size(),v.storage()):s(h,v,m,!0)),"Array, any":e.referToSelf(m=>(v,h)=>m(t(v),h).valueOf()),"any, Array":e.referToSelf(m=>(v,h)=>m(v,t(h)).valueOf())},c({SS:l,DS:f}))}),_i="compare",d2=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],g2=q(_i,d2,r=>{var{typed:e,config:t,equalScalar:a,matrix:n,BigNumber:i,Fraction:o,DenseMatrix:f,concat:l}=r,u=Yr({typed:e}),s=Ii({typed:e,equalScalar:a}),c=Ir({typed:e,DenseMatrix:f}),m=dr({typed:e,matrix:n,concat:l}),v=oa({typed:e});return e(_i,y2({typed:e,config:t}),{"boolean, boolean":function(p,g){return p===g?0:p>g?1:-1},"BigNumber, BigNumber":function(p,g){return Tt(p,g,t.epsilon)?new i(0):new i(p.cmp(g))},"Fraction, Fraction":function(p,g){return new o(p.compare(g))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},v,m({SS:s,DS:u,Ss:c}))}),y2=q(_i,["typed","config"],r=>{var{typed:e,config:t}=r;return e(_i,{"number, number":function(n,i){return tt(n,i,t.epsilon)?0:n>i?1:-1}})}),la=function r(e,t){var a=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,n=/(^[ ]*|[ ]*$)/g,i=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,o=/^0x[0-9a-f]+$/i,f=/^0/,l=function(d){return r.insensitive&&(""+d).toLowerCase()||""+d},u=l(e).replace(n,"")||"",s=l(t).replace(n,"")||"",c=u.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),m=s.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),v=parseInt(u.match(o),16)||c.length!==1&&u.match(i)&&Date.parse(u),h=parseInt(s.match(o),16)||v&&s.match(i)&&Date.parse(s)||null,p,g;if(h){if(v<h)return-1;if(v>h)return 1}for(var y=0,N=Math.max(c.length,m.length);y<N;y++){if(p=!(c[y]||"").match(f)&&parseFloat(c[y])||c[y]||0,g=!(m[y]||"").match(f)&&parseFloat(m[y])||m[y]||0,isNaN(p)!==isNaN(g))return isNaN(p)?1:-1;if(typeof p!=typeof g&&(p+="",g+=""),p<g)return-1;if(p>g)return 1}return 0},ev="compareNatural",b2=["typed","compare"],x2=q(ev,b2,r=>{var{typed:e,compare:t}=r,a=t.signatures["boolean,boolean"];return e(ev,{"any, any":n});function n(l,u){var s=br(l),c=br(u),m;if((s==="number"||s==="BigNumber"||s==="Fraction")&&(c==="number"||c==="BigNumber"||c==="Fraction"))return m=t(l,u),m.toString()!=="0"?m>0?1:-1:la(s,c);var v=["Array","DenseMatrix","SparseMatrix"];if(v.includes(s)||v.includes(c))return m=i(n,l,u),m!==0?m:la(s,c);if(s!==c)return la(s,c);if(s==="Complex")return w2(l,u);if(s==="Unit")return l.equalBase(u)?n(l.value,u.value):o(n,l.formatUnits(),u.formatUnits());if(s==="boolean")return a(l,u);if(s==="string")return la(l,u);if(s==="Object")return f(n,l,u);if(s==="null"||s==="undefined")return 0;throw new TypeError('Unsupported type of value "'+s+'"')}function i(l,u,s){return An(u)&&An(s)?o(l,u.toJSON().values,s.toJSON().values):An(u)?i(l,u.toArray(),s):An(s)?i(l,u,s.toArray()):ui(u)?i(l,u.toJSON().data,s):ui(s)?i(l,u,s.toJSON().data):Array.isArray(u)?Array.isArray(s)?o(l,u,s):i(l,u,[s]):i(l,[u],s)}function o(l,u,s){for(var c=0,m=Math.min(u.length,s.length);c<m;c++){var v=l(u[c],s[c]);if(v!==0)return v}return u.length>s.length?1:u.length<s.length?-1:0}function f(l,u,s){var c=Object.keys(u),m=Object.keys(s);c.sort(la),m.sort(la);var v=o(l,c,m);if(v!==0)return v;for(var h=0;h<c.length;h++){var p=l(u[c[h]],s[m[h]]);if(p!==0)return p}return 0}});function w2(r,e){return r.re>e.re?1:r.re<e.re?-1:r.im>e.im?1:r.im<e.im?-1:0}var rv="compareText",N2=["typed","matrix","concat"];Ho.signature="any, any";var D2=q(rv,N2,r=>{var{typed:e,matrix:t,concat:a}=r,n=dr({typed:e,matrix:t,concat:a});return e(rv,Ho,n({elop:Ho,Ds:!0}))}),qi="equal",A2=["typed","matrix","equalScalar","DenseMatrix","concat"],E2=q(qi,A2,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n,concat:i}=r,o=Yr({typed:e}),f=Bt({typed:e,DenseMatrix:n}),l=Ir({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:t,concat:i});return e(qi,S2({typed:e,equalScalar:a}),u({elop:a,SS:f,DS:o,Ss:l}))}),S2=q(qi,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e(qi,{"any, any":function(n,i){return n===null?i===null:i===null?n===null:n===void 0?i===void 0:i===void 0?n===void 0:t(n,i)}})}),tv="equalText",C2=["typed","compareText","isZero"],M2=q(tv,C2,r=>{var{typed:e,compareText:t,isZero:a}=r;return e(tv,{"any, any":function(i,o){return a(t(i,o))}})}),zi="smaller",F2=["typed","config","matrix","DenseMatrix","concat"],T2=q(zi,F2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n,concat:i}=r,o=Yr({typed:e}),f=Bt({typed:e,DenseMatrix:n}),l=Ir({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:a,concat:i}),s=oa({typed:e});return e(zi,B2({typed:e,config:t}),{"boolean, boolean":(c,m)=>c<m,"BigNumber, BigNumber":function(m,v){return m.lt(v)&&!Tt(m,v,t.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)===-1,"Complex, Complex":function(m,v){throw new TypeError("No ordering relation is defined for complex numbers")}},s,u({SS:f,DS:o,Ss:l}))}),B2=q(zi,["typed","config"],r=>{var{typed:e,config:t}=r;return e(zi,{"number, number":function(n,i){return n<i&&!tt(n,i,t.epsilon)}})}),Pi="smallerEq",$2=["typed","config","matrix","DenseMatrix","concat"],O2=q(Pi,$2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n,concat:i}=r,o=Yr({typed:e}),f=Bt({typed:e,DenseMatrix:n}),l=Ir({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:a,concat:i}),s=oa({typed:e});return e(Pi,I2({typed:e,config:t}),{"boolean, boolean":(c,m)=>c<=m,"BigNumber, BigNumber":function(m,v){return m.lte(v)||Tt(m,v,t.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)!==1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},s,u({SS:f,DS:o,Ss:l}))}),I2=q(Pi,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Pi,{"number, number":function(n,i){return n<=i||tt(n,i,t.epsilon)}})}),Ui="larger",R2=["typed","config","matrix","DenseMatrix","concat"],_2=q(Ui,R2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n,concat:i}=r,o=Yr({typed:e}),f=Bt({typed:e,DenseMatrix:n}),l=Ir({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:a,concat:i}),s=oa({typed:e});return e(Ui,q2({typed:e,config:t}),{"boolean, boolean":(c,m)=>c>m,"BigNumber, BigNumber":function(m,v){return m.gt(v)&&!Tt(m,v,t.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},s,u({SS:f,DS:o,Ss:l}))}),q2=q(Ui,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Ui,{"number, number":function(n,i){return n>i&&!tt(n,i,t.epsilon)}})}),Li="largerEq",z2=["typed","config","matrix","DenseMatrix","concat"],P2=q(Li,z2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n,concat:i}=r,o=Yr({typed:e}),f=Bt({typed:e,DenseMatrix:n}),l=Ir({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:a,concat:i}),s=oa({typed:e});return e(Li,U2({typed:e,config:t}),{"boolean, boolean":(c,m)=>c>=m,"BigNumber, BigNumber":function(m,v){return m.gte(v)||Tt(m,v,t.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)!==-1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},s,u({SS:f,DS:o,Ss:l}))}),U2=q(Li,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Li,{"number, number":function(n,i){return n>=i||tt(n,i,t.epsilon)}})}),nv="deepEqual",L2=["typed","equal"],k2=q(nv,L2,r=>{var{typed:e,equal:t}=r;return e(nv,{"any, any":function(i,o){return a(i.valueOf(),o.valueOf())}});function a(n,i){if(Array.isArray(n))if(Array.isArray(i)){var o=n.length;if(o!==i.length)return!1;for(var f=0;f<o;f++)if(!a(n[f],i[f]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:t(n,i)}}),ki="unequal",V2=["typed","config","equalScalar","matrix","DenseMatrix","concat"],G2=q(ki,V2,r=>{var{typed:e,config:t,equalScalar:a,matrix:n,DenseMatrix:i,concat:o}=r,f=Yr({typed:e}),l=Bt({typed:e,DenseMatrix:i}),u=Ir({typed:e,DenseMatrix:i}),s=dr({typed:e,matrix:n,concat:o});return e(ki,H2({typed:e,equalScalar:a}),s({elop:c,SS:l,DS:f,Ss:u}));function c(m,v){return!a(m,v)}}),H2=q(ki,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e(ki,{"any, any":function(n,i){return n===null?i!==null:i===null?n!==null:n===void 0?i!==void 0:i===void 0?n!==void 0:!t(n,i)}})}),av="partitionSelect",Z2=["typed","isNumeric","isNaN","compare"],J2=q(av,Z2,r=>{var{typed:e,isNumeric:t,isNaN:a,compare:n}=r,i=n,o=(u,s)=>-n(u,s);return e(av,{"Array | Matrix, number":function(s,c){return f(s,c,i)},"Array | Matrix, number, string":function(s,c,m){if(m==="asc")return f(s,c,i);if(m==="desc")return f(s,c,o);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":f});function f(u,s,c){if(!qe(s)||s<0)throw new Error("k must be a non-negative integer");if(Ve(u)){var m=u.size();if(m.length>1)throw new Error("Only one dimensional matrices supported");return l(u.valueOf(),s,c)}if(Array.isArray(u))return l(u,s,c)}function l(u,s,c){if(s>=u.length)throw new Error("k out of bounds");for(var m=0;m<u.length;m++)if(t(u[m])&&a(u[m]))return u[m];for(var v=0,h=u.length-1;v<h;){for(var p=v,g=h,y=u[Math.floor(Math.random()*(h-v+1))+v];p<g;)if(c(u[p],y)>=0){var N=u[g];u[g]=u[p],u[p]=N,--g}else++p;c(u[p],y)>0&&--p,s<=p?h=p:v=p+1}return u[s]}}),iv="sort",X2=["typed","matrix","compare","compareNatural"],W2=q(iv,X2,r=>{var{typed:e,matrix:t,compare:a,compareNatural:n}=r,i=a,o=(s,c)=>-a(s,c);return e(iv,{Array:function(c){return l(c),c.sort(i)},Matrix:function(c){return u(c),t(c.toArray().sort(i),c.storage())},"Array, function":function(c,m){return l(c),c.sort(m)},"Matrix, function":function(c,m){return u(c),t(c.toArray().sort(m),c.storage())},"Array, string":function(c,m){return l(c),c.sort(f(m))},"Matrix, string":function(c,m){return u(c),t(c.toArray().sort(f(m)),c.storage())}});function f(s){if(s==="asc")return i;if(s==="desc")return o;if(s==="natural")return n;throw new Error('String "asc", "desc", or "natural" expected')}function l(s){if(er(s).length!==1)throw new Error("One dimensional array expected")}function u(s){if(s.size().length!==1)throw new Error("One dimensional matrix expected")}}),ov="max",Y2=["typed","config","numeric","larger"],sv=q(ov,Y2,r=>{var{typed:e,config:t,numeric:a,larger:n}=r;return e(ov,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(l,u){return Si(l,u.valueOf(),i)},"...":function(l){if(na(l))throw new TypeError("Scalar values expected in function max");return o(l)}});function i(f,l){try{return n(f,l)?f:l}catch(u){throw Qr(u,"max",l)}}function o(f){var l;if(Jt(f,function(u){try{isNaN(u)&&typeof u=="number"?l=NaN:(l===void 0||n(u,l))&&(l=u)}catch(s){throw Qr(s,"max",u)}}),l===void 0)throw new Error("Cannot calculate max of an empty array");return typeof l=="string"&&(l=a(l,t.number)),l}}),uv="min",Q2=["typed","config","numeric","smaller"],lv=q(uv,Q2,r=>{var{typed:e,config:t,numeric:a,smaller:n}=r;return e(uv,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(l,u){return Si(l,u.valueOf(),i)},"...":function(l){if(na(l))throw new TypeError("Scalar values expected in function min");return o(l)}});function i(f,l){try{return n(f,l)?f:l}catch(u){throw Qr(u,"min",l)}}function o(f){var l;if(Jt(f,function(u){try{isNaN(u)&&typeof u=="number"?l=NaN:(l===void 0||n(u,l))&&(l=u)}catch(s){throw Qr(s,"min",u)}}),l===void 0)throw new Error("Cannot calculate min of an empty array");return typeof l=="string"&&(l=a(l,t.number)),l}}),K2="ImmutableDenseMatrix",j2=["smaller","DenseMatrix"],eD=q(K2,j2,r=>{var{smaller:e,DenseMatrix:t}=r;function a(n,i){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(i&&!Wr(i))throw new Error("Invalid datatype: "+i);if(Ve(n)||cr(n)){var o=new t(n,i);this._data=o._data,this._size=o._size,this._datatype=o._datatype,this._min=null,this._max=null}else if(n&&cr(n.data)&&cr(n.size))this._data=n.data,this._size=n.size,this._datatype=n.datatype,this._min=typeof n.min<"u"?n.min:null,this._max=typeof n.max<"u"?n.max:null;else{if(n)throw new TypeError("Unsupported type of data ("+br(n)+")");this._data=[],this._size=[0],this._datatype=i,this._min=null,this._max=null}}return a.prototype=new t,a.prototype.type="ImmutableDenseMatrix",a.prototype.isImmutableDenseMatrix=!0,a.prototype.subset=function(n){switch(arguments.length){case 1:{var i=t.prototype.subset.call(this,n);return Ve(i)?new a({data:i._data,size:i._size,datatype:i._datatype}):i}case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},a.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},a.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},a.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},a.prototype.clone=function(){return new a({data:Ge(this._data),size:Ge(this._size),datatype:this._datatype})},a.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},a.fromJSON=function(n){return new a(n)},a.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},a.prototype.min=function(){if(this._min===null){var n=null;this.forEach(function(i){(n===null||e(i,n))&&(n=i)}),this._min=n!==null?n:void 0}return this._min},a.prototype.max=function(){if(this._max===null){var n=null;this.forEach(function(i){(n===null||e(n,i))&&(n=i)}),this._max=n!==null?n:void 0}return this._max},a},{isClass:!0}),rD="Index",tD=["ImmutableDenseMatrix"],nD=q(rD,tD,r=>{var{ImmutableDenseMatrix:e}=r;function t(n){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var i=0,o=arguments.length;i<o;i++){var f=arguments[i];if(Uo(f))this._dimensions.push(f),this._isScalar=!1;else if(Array.isArray(f)||Ve(f)){var l=a(f.valueOf());this._dimensions.push(l);var u=l.size();(u.length!==1||u[0]!==1)&&(this._isScalar=!1)}else if(typeof f=="number")this._dimensions.push(a([f]));else if(typeof f=="string")this._dimensions.push(f);else throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range")}}t.prototype.type="Index",t.prototype.isIndex=!0;function a(n){for(var i=0,o=n.length;i<o;i++)if(typeof n[i]!="number"||!qe(n[i]))throw new TypeError("Index parameters must be positive integer numbers");return new e(n)}return t.prototype.clone=function(){var n=new t;return n._dimensions=Ge(this._dimensions),n._isScalar=this._isScalar,n},t.create=function(n){var i=new t;return t.apply(i,n),i},t.prototype.size=function(){for(var n=[],i=0,o=this._dimensions.length;i<o;i++){var f=this._dimensions[i];n[i]=typeof f=="string"?1:f.size()[0]}return n},t.prototype.max=function(){for(var n=[],i=0,o=this._dimensions.length;i<o;i++){var f=this._dimensions[i];n[i]=typeof f=="string"?f:f.max()}return n},t.prototype.min=function(){for(var n=[],i=0,o=this._dimensions.length;i<o;i++){var f=this._dimensions[i];n[i]=typeof f=="string"?f:f.min()}return n},t.prototype.forEach=function(n){for(var i=0,o=this._dimensions.length;i<o;i++)n(this._dimensions[i],i,this)},t.prototype.dimension=function(n){return this._dimensions[n]||null},t.prototype.isObjectProperty=function(){return this._dimensions.length===1&&typeof this._dimensions[0]=="string"},t.prototype.getObjectProperty=function(){return this.isObjectProperty()?this._dimensions[0]:null},t.prototype.isScalar=function(){return this._isScalar},t.prototype.toArray=function(){for(var n=[],i=0,o=this._dimensions.length;i<o;i++){var f=this._dimensions[i];n.push(typeof f=="string"?f:f.toArray())}return n},t.prototype.valueOf=t.prototype.toArray,t.prototype.toString=function(){for(var n=[],i=0,o=this._dimensions.length;i<o;i++){var f=this._dimensions[i];typeof f=="string"?n.push(JSON.stringify(f)):n.push(f.toString())}return"["+n.join(", ")+"]"},t.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},t.fromJSON=function(n){return t.create(n.dimensions)},t},{isClass:!0}),aD="FibonacciHeap",iD=["smaller","larger"],oD=q(aD,iD,r=>{var{smaller:e,larger:t}=r,a=1/Math.log((1+Math.sqrt(5))/2);function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}n.prototype.type="FibonacciHeap",n.prototype.isFibonacciHeap=!0,n.prototype.insert=function(s,c){var m={key:s,value:c,degree:0};if(this._minimum){var v=this._minimum;m.left=v,m.right=v.right,v.right=m,m.right.left=m,e(s,v.key)&&(this._minimum=m)}else m.left=m,m.right=m,this._minimum=m;return this._size++,m},n.prototype.size=function(){return this._size},n.prototype.clear=function(){this._minimum=null,this._size=0},n.prototype.isEmpty=function(){return this._size===0},n.prototype.extractMinimum=function(){var s=this._minimum;if(s===null)return s;for(var c=this._minimum,m=s.degree,v=s.child;m>0;){var h=v.right;v.left.right=v.right,v.right.left=v.left,v.left=c,v.right=c.right,c.right=v,v.right.left=v,v.parent=null,v=h,m--}return s.left.right=s.right,s.right.left=s.left,s===s.right?c=null:(c=s.right,c=u(c,this._size)),this._size--,this._minimum=c,s},n.prototype.remove=function(s){this._minimum=i(this._minimum,s,-1),this.extractMinimum()};function i(s,c,m){c.key=m;var v=c.parent;return v&&e(c.key,v.key)&&(o(s,c,v),f(s,v)),e(c.key,s.key)&&(s=c),s}function o(s,c,m){c.left.right=c.right,c.right.left=c.left,m.degree--,m.child===c&&(m.child=c.right),m.degree===0&&(m.child=null),c.left=s,c.right=s.right,s.right=c,c.right.left=c,c.parent=null,c.mark=!1}function f(s,c){var m=c.parent;!m||(c.mark?(o(s,c,m),f(m)):c.mark=!0)}var l=function(c,m){c.left.right=c.right,c.right.left=c.left,c.parent=m,m.child?(c.left=m.child,c.right=m.child.right,m.child.right=c,c.right.left=c):(m.child=c,c.right=c,c.left=c),m.degree++,c.mark=!1};function u(s,c){var m=Math.floor(Math.log(c)*a)+1,v=new Array(m),h=0,p=s;if(p)for(h++,p=p.right;p!==s;)h++,p=p.right;for(var g;h>0;){for(var y=p.degree,N=p.right;g=v[y],!!g;){if(t(p.key,g.key)){var d=g;g=p,p=d}l(g,p),v[y]=null,y++}v[y]=p,p=N,h--}s=null;for(var w=0;w<m;w++)g=v[w],g&&(s?(g.left.right=g.right,g.right.left=g.left,g.left=s,g.right=s.right,s.right=g,g.right.left=g,e(g.key,s.key)&&(s=g)):s=g);return s}return n},{isClass:!0}),sD="Spa",uD=["addScalar","equalScalar","FibonacciHeap"],lD=q(sD,uD,r=>{var{addScalar:e,equalScalar:t,FibonacciHeap:a}=r;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new a}return n.prototype.type="Spa",n.prototype.isSpa=!0,n.prototype.set=function(i,o){if(this._values[i])this._values[i].value=o;else{var f=this._heap.insert(i,o);this._values[i]=f}},n.prototype.get=function(i){var o=this._values[i];return o?o.value:0},n.prototype.accumulate=function(i,o){var f=this._values[i];f?f.value=e(f.value,o):(f=this._heap.insert(i,o),this._values[i]=f)},n.prototype.forEach=function(i,o,f){var l=this._heap,u=this._values,s=[],c=l.extractMinimum();for(c&&s.push(c);c&&c.key<=o;)c.key>=i&&(t(c.value,0)||f(c.key,c.value,this)),c=l.extractMinimum(),c&&s.push(c);for(var m=0;m<s.length;m++){var v=s[m];c=l.insert(v.key,v.value),u[c.key]=c}},n.prototype.swap=function(i,o){var f=this._values[i],l=this._values[o];if(!f&&l)f=this._heap.insert(i,l.value),this._heap.remove(l),this._values[i]=f,this._values[o]=void 0;else if(f&&!l)l=this._heap.insert(o,f.value),this._heap.remove(f),this._values[o]=l,this._values[i]=void 0;else if(f&&l){var u=f.value;f.value=l.value,l.value=u}},n},{isClass:!0});function Za(r){return Za=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Za(r)}function cD(r,e){if(Za(r)!=="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var a=t.call(r,e||"default");if(Za(a)!=="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function fD(r){var e=cD(r,"string");return Za(e)==="symbol"?e:String(e)}function zr(r,e,t){return e=fD(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var mD=ka(function(r){return new r(1).exp()},{hasher:Vi}),vD=ka(function(r){return new r(1).plus(new r(5).sqrt()).div(2)},{hasher:Vi}),gs=ka(function(r){return r.acos(-1)},{hasher:Vi}),pD=ka(function(r){return gs(r).times(2)},{hasher:Vi});function Vi(r){return r[0].precision}function cv(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);e&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,a)}return t}function ys(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?cv(Object(t),!0).forEach(function(a){zr(r,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):cv(Object(t)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(t,a))})}return r}var hD="Unit",dD=["?on","config","addScalar","subtract","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","number","Complex","BigNumber","Fraction"],gD=q(hD,dD,r=>{var{on:e,config:t,addScalar:a,subtract:n,multiplyScalar:i,divideScalar:o,pow:f,abs:l,fix:u,round:s,equal:c,isNumeric:m,format:v,number:h,Complex:p,BigNumber:g,Fraction:y}=r,N=h;function d(V,X){if(!(this instanceof d))throw new Error("Constructor must be called with the new operator");if(!(V==null||m(V)||Lt(V)))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(this.fixPrefix=!1,this.skipAutomaticSimplification=!0,X===void 0)this.units=[],this.dimensions=H.map(G=>0);else if(typeof X=="string"){var oe=d.parse(X);this.units=oe.units,this.dimensions=oe.dimensions}else if(kt(X)&&X.value===null)this.fixPrefix=X.fixPrefix,this.skipAutomaticSimplification=X.skipAutomaticSimplification,this.dimensions=X.dimensions.slice(0),this.units=X.units.map(G=>Sr({},G));else throw new TypeError("Second parameter in Unit constructor must be a string or valueless Unit");this.value=this._normalize(V)}Object.defineProperty(d,"name",{value:"Unit"}),d.prototype.constructor=d,d.prototype.type="Unit",d.prototype.isUnit=!0;var w,x,b;function E(){for(;b===" "||b===" ";)D()}function A(V){return V>="0"&&V<="9"||V==="."}function S(V){return V>="0"&&V<="9"}function D(){x++,b=w.charAt(x)}function T(V){x=V,b=w.charAt(x)}function B(){var V="",X=x;if(b==="+"?D():b==="-"&&(V+=b,D()),!A(b))return T(X),null;if(b==="."){if(V+=b,D(),!S(b))return T(X),null}else{for(;S(b);)V+=b,D();b==="."&&(V+=b,D())}for(;S(b);)V+=b,D();if(b==="E"||b==="e"){var oe="",G=x;if(oe+=b,D(),(b==="+"||b==="-")&&(oe+=b,D()),!S(b))return T(G),V;for(V=V+oe;S(b);)V+=b,D()}return V}function I(){for(var V="";S(b)||d.isValidAlpha(b);)V+=b,D();var X=V.charAt(0);return d.isValidAlpha(X)?V:null}function P(V){return b===V?(D(),V):null}d.parse=function(V,X){if(X=X||{},w=V,x=-1,b="",typeof w!="string")throw new TypeError("Invalid argument in Unit.parse, string expected");var oe=new d;oe.units=[];var G=1,Y=!1;D(),E();var te=B(),ye=null;if(te){if(t.number==="BigNumber")ye=new g(te);else if(t.number==="Fraction")try{ye=new y(te)}catch{ye=parseFloat(te)}else ye=parseFloat(te);E(),P("*")?(G=1,Y=!0):P("/")&&(G=-1,Y=!0)}for(var me=[],z=1;;){for(E();b==="(";)me.push(G),z*=G,G=1,D(),E();var U=void 0;if(b){var ee=b;if(U=I(),U===null)throw new SyntaxError('Unexpected "'+ee+'" in "'+w+'" at index '+x.toString())}else break;var ue=R(U);if(ue===null)throw new SyntaxError('Unit "'+U+'" not found.');var ve=G*z;if(E(),P("^")){E();var de=B();if(de===null)throw new SyntaxError('In "'+V+'", "^" must be followed by a floating-point number');ve*=de}oe.units.push({unit:ue.unit,prefix:ue.prefix,power:ve});for(var be=0;be<H.length;be++)oe.dimensions[be]+=(ue.unit.dimensions[be]||0)*ve;for(E();b===")";){if(me.length===0)throw new SyntaxError('Unmatched ")" in "'+w+'" at index '+x.toString());z/=me.pop(),D(),E()}if(Y=!1,P("*")?(G=1,Y=!0):P("/")?(G=-1,Y=!0):G=1,ue.unit.base){var pe=ue.unit.base.key;re.auto[pe]={unit:ue.unit,prefix:ue.prefix}}}if(E(),b)throw new SyntaxError('Could not parse: "'+V+'"');if(Y)throw new SyntaxError('Trailing characters: "'+V+'"');if(me.length!==0)throw new SyntaxError('Unmatched "(" in "'+w+'"');if(oe.units.length===0&&!X.allowNoUnits)throw new SyntaxError('"'+V+'" contains no units');return oe.value=ye!==void 0?oe._normalize(ye):null,oe},d.prototype.clone=function(){var V=new d;V.fixPrefix=this.fixPrefix,V.skipAutomaticSimplification=this.skipAutomaticSimplification,V.value=Ge(this.value),V.dimensions=this.dimensions.slice(0),V.units=[];for(var X=0;X<this.units.length;X++){V.units[X]={};for(var oe in this.units[X])Re(this.units[X],oe)&&(V.units[X][oe]=this.units[X][oe])}return V},d.prototype.valueType=function(){return br(this.value)},d.prototype._isDerived=function(){return this.units.length===0?!1:this.units.length>1||Math.abs(this.units[0].power-1)>1e-15},d.prototype._normalize=function(V){if(V==null||this.units.length===0)return V;for(var X=V,oe=d._getNumberConverter(br(V)),G=0;G<this.units.length;G++){var Y=oe(this.units[G].unit.value),te=oe(this.units[G].prefix.value),ye=oe(this.units[G].power);X=i(X,f(i(Y,te),ye))}return X},d.prototype._denormalize=function(V,X){if(V==null||this.units.length===0)return V;for(var oe=V,G=d._getNumberConverter(br(V)),Y=0;Y<this.units.length;Y++){var te=G(this.units[Y].unit.value),ye=G(this.units[Y].prefix.value),me=G(this.units[Y].power);oe=o(oe,f(i(te,ye),me))}return oe};var R=ka(V=>{if(Re(L,V)){var X=L[V],oe=X.prefixes[""];return{unit:X,prefix:oe}}for(var G in L)if(Re(L,G)&&cg(V,G)){var Y=L[G],te=V.length-G.length,ye=V.substring(0,te),me=Re(Y.prefixes,ye)?Y.prefixes[ye]:void 0;if(me!==void 0)return{unit:Y,prefix:me}}return null},{hasher:V=>V[0],limit:100});d.isValuelessUnit=function(V){return R(V)!==null},d.prototype.hasBase=function(V){if(typeof V=="string"&&(V=$[V]),!V)return!1;for(var X=0;X<H.length;X++)if(Math.abs((this.dimensions[X]||0)-(V.dimensions[X]||0))>1e-12)return!1;return!0},d.prototype.equalBase=function(V){for(var X=0;X<H.length;X++)if(Math.abs((this.dimensions[X]||0)-(V.dimensions[X]||0))>1e-12)return!1;return!0},d.prototype.equals=function(V){return this.equalBase(V)&&c(this.value,V.value)},d.prototype.multiply=function(V){for(var X=this.clone(),oe=kt(V)?V:new d(V),G=0;G<H.length;G++)X.dimensions[G]=(this.dimensions[G]||0)+(oe.dimensions[G]||0);for(var Y=0;Y<oe.units.length;Y++){var te=ys({},oe.units[Y]);X.units.push(te)}if(this.value!==null||oe.value!==null){var ye=this.value===null?this._normalize(1):this.value,me=oe.value===null?oe._normalize(1):oe.value;X.value=i(ye,me)}else X.value=null;return kt(V)&&(X.skipAutomaticSimplification=!1),M(X)},d.prototype.divideInto=function(V){return new d(V).divide(this)},d.prototype.divide=function(V){for(var X=this.clone(),oe=kt(V)?V:new d(V),G=0;G<H.length;G++)X.dimensions[G]=(this.dimensions[G]||0)-(oe.dimensions[G]||0);for(var Y=0;Y<oe.units.length;Y++){var te=ys(ys({},oe.units[Y]),{},{power:-oe.units[Y].power});X.units.push(te)}if(this.value!==null||oe.value!==null){var ye=this.value===null?this._normalize(1):this.value,me=oe.value===null?oe._normalize(1):oe.value;X.value=o(ye,me)}else X.value=null;return kt(V)&&(X.skipAutomaticSimplification=!1),M(X)},d.prototype.pow=function(V){for(var X=this.clone(),oe=0;oe<H.length;oe++)X.dimensions[oe]=(this.dimensions[oe]||0)*V;for(var G=0;G<X.units.length;G++)X.units[G].power*=V;return X.value!==null?X.value=f(X.value,V):X.value=null,X.skipAutomaticSimplification=!1,M(X)};function M(V){return V.equalBase($.NONE)&&V.value!==null&&!t.predictable?V.value:V}d.prototype.abs=function(){var V=this.clone();if(V.value!==null)if(V._isDerived()||V.units[0].unit.offset===0)V.value=l(V.value);else{var X=V._numberConverter(),oe=X(V.units[0].unit.value),G=X(V.units[0].unit.offset),Y=i(oe,G);V.value=n(l(a(V.value,Y)),Y)}for(var te in V.units)(V.units[te].unit.name==="VA"||V.units[te].unit.name==="VAR")&&(V.units[te].unit=L.W);return V},d.prototype.to=function(V){var X=this.value===null?this._normalize(1):this.value,oe;if(typeof V=="string")oe=d.parse(V);else if(kt(V))oe=V.clone();else throw new Error("String or Unit expected as parameter");if(!this.equalBase(oe))throw new Error("Units do not match ('".concat(oe.toString(),"' != '").concat(this.toString(),"')"));if(oe.value!==null)throw new Error("Cannot convert to a unit with a value");if(this.value===null||this._isDerived()||this.units[0].unit.offset===oe.units[0].unit.offset)oe.value=Ge(X);else{var G=d._getNumberConverter(br(X)),Y=G(this.units[0].unit.value),te=G(this.units[0].unit.offset),ye=i(Y,te),me=G(oe.units[0].unit.value),z=G(oe.units[0].unit.offset),U=i(me,z);oe.value=n(a(X,ye),U)}return oe.fixPrefix=!0,oe.skipAutomaticSimplification=!0,oe},d.prototype.toNumber=function(V){return N(this.toNumeric(V))},d.prototype.toNumeric=function(V){var X;return V?X=this.to(V):X=this.clone(),X._isDerived()||X.units.length===0?X._denormalize(X.value):X._denormalize(X.value,X.units[0].prefix.value)},d.prototype.toString=function(){return this.format()},d.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.formatUnits(),fixPrefix:this.fixPrefix}},d.fromJSON=function(V){var X=new d(V.value,V.unit);return X.fixPrefix=V.fixPrefix||!1,X},d.prototype.valueOf=d.prototype.toString,d.prototype.simplify=function(){var V=this.clone(),X=[],oe;for(var G in fe)if(Re(fe,G)&&V.hasBase($[G])){oe=G;break}if(oe==="NONE")V.units=[];else{var Y;if(oe&&Re(fe,oe)&&(Y=fe[oe]),Y)V.units=[{unit:Y.unit,prefix:Y.prefix,power:1}];else{for(var te=!1,ye=0;ye<H.length;ye++){var me=H[ye];Math.abs(V.dimensions[ye]||0)>1e-12&&(Re(fe,me)?X.push({unit:fe[me].unit,prefix:fe[me].prefix,power:V.dimensions[ye]||0}):te=!0)}X.length<V.units.length&&!te&&(V.units=X)}}return V},d.prototype.toSI=function(){for(var V=this.clone(),X=[],oe=0;oe<H.length;oe++){var G=H[oe];if(Math.abs(V.dimensions[oe]||0)>1e-12)if(Re(re.si,G))X.push({unit:re.si[G].unit,prefix:re.si[G].prefix,power:V.dimensions[oe]||0});else throw new Error("Cannot express custom unit "+G+" in SI units")}return V.units=X,V.fixPrefix=!0,V.skipAutomaticSimplification=!0,V},d.prototype.formatUnits=function(){for(var V="",X="",oe=0,G=0,Y=0;Y<this.units.length;Y++)this.units[Y].power>0?(oe++,V+=" "+this.units[Y].prefix.name+this.units[Y].unit.name,Math.abs(this.units[Y].power-1)>1e-15&&(V+="^"+this.units[Y].power)):this.units[Y].power<0&&G++;if(G>0)for(var te=0;te<this.units.length;te++)this.units[te].power<0&&(oe>0?(X+=" "+this.units[te].prefix.name+this.units[te].unit.name,Math.abs(this.units[te].power+1)>1e-15&&(X+="^"+-this.units[te].power)):(X+=" "+this.units[te].prefix.name+this.units[te].unit.name,X+="^"+this.units[te].power));V=V.substr(1),X=X.substr(1),oe>1&&G>0&&(V="("+V+")"),G>1&&oe>0&&(X="("+X+")");var ye=V;return oe>0&&G>0&&(ye+=" / "),ye+=X,ye},d.prototype.format=function(V){var X=this.skipAutomaticSimplification||this.value===null?this.clone():this.simplify(),oe=!1;typeof X.value<"u"&&X.value!==null&&Lt(X.value)&&(oe=Math.abs(X.value.re)<1e-14);for(var G in X.units)Re(X.units,G)&&X.units[G].unit&&(X.units[G].unit.name==="VA"&&oe?X.units[G].unit=L.VAR:X.units[G].unit.name==="VAR"&&!oe&&(X.units[G].unit=L.VA));X.units.length===1&&!X.fixPrefix&&Math.abs(X.units[0].power-Math.round(X.units[0].power))<1e-14&&(X.units[0].prefix=X._bestPrefix());var Y=X._denormalize(X.value),te=X.value!==null?v(Y,V||{}):"",ye=X.formatUnits();return X.value&&Lt(X.value)&&(te="("+te+")"),ye.length>0&&te.length>0&&(te+=" "),te+=ye,te},d.prototype._bestPrefix=function(){if(this.units.length!==1)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var V=this.value!==null?l(this.value):0,X=l(this.units[0].unit.value),oe=this.units[0].prefix;if(V===0)return oe;var G=this.units[0].power,Y=Math.log(V/Math.pow(oe.value*X,G))/Math.LN10-1.2;if(Y>-2.200001&&Y<1.800001)return oe;Y=Math.abs(Y);var te=this.units[0].unit.prefixes;for(var ye in te)if(Re(te,ye)){var me=te[ye];if(me.scientific){var z=Math.abs(Math.log(V/Math.pow(me.value*X,G))/Math.LN10-1.2);(z<Y||z===Y&&me.name.length<oe.name.length)&&(oe=me,Y=z)}}return oe},d.prototype.splitUnit=function(V){for(var X=this.clone(),oe=[],G=0;G<V.length&&(X=X.to(V[G]),G!==V.length-1);G++){var Y=X.toNumeric(),te=s(Y),ye=void 0,me=c(te,Y);me?ye=te:ye=u(X.toNumeric());var z=new d(ye,V[G].toString());oe.push(z),X=n(X,z)}for(var U=0,ee=0;ee<oe.length;ee++)U=a(U,oe[ee].value);return c(U,this.value)&&(X.value=0),oe.push(X),oe};var F={NONE:{"":{name:"",value:1,scientific:!0}},SHORT:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:10,scientific:!1},h:{name:"h",value:100,scientific:!1},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0},d:{name:"d",value:.1,scientific:!1},c:{name:"c",value:.01,scientific:!1},m:{name:"m",value:.001,scientific:!0},u:{name:"u",value:1e-6,scientific:!0},n:{name:"n",value:1e-9,scientific:!0},p:{name:"p",value:1e-12,scientific:!0},f:{name:"f",value:1e-15,scientific:!0},a:{name:"a",value:1e-18,scientific:!0},z:{name:"z",value:1e-21,scientific:!0},y:{name:"y",value:1e-24,scientific:!0}},LONG:{"":{name:"",value:1,scientific:!0},deca:{name:"deca",value:10,scientific:!1},hecto:{name:"hecto",value:100,scientific:!1},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0},deci:{name:"deci",value:.1,scientific:!1},centi:{name:"centi",value:.01,scientific:!1},milli:{name:"milli",value:.001,scientific:!0},micro:{name:"micro",value:1e-6,scientific:!0},nano:{name:"nano",value:1e-9,scientific:!0},pico:{name:"pico",value:1e-12,scientific:!0},femto:{name:"femto",value:1e-15,scientific:!0},atto:{name:"atto",value:1e-18,scientific:!0},zepto:{name:"zepto",value:1e-21,scientific:!0},yocto:{name:"yocto",value:1e-24,scientific:!0}},SQUARED:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:100,scientific:!1},h:{name:"h",value:1e4,scientific:!1},k:{name:"k",value:1e6,scientific:!0},M:{name:"M",value:1e12,scientific:!0},G:{name:"G",value:1e18,scientific:!0},T:{name:"T",value:1e24,scientific:!0},P:{name:"P",value:1e30,scientific:!0},E:{name:"E",value:1e36,scientific:!0},Z:{name:"Z",value:1e42,scientific:!0},Y:{name:"Y",value:1e48,scientific:!0},d:{name:"d",value:.01,scientific:!1},c:{name:"c",value:1e-4,scientific:!1},m:{name:"m",value:1e-6,scientific:!0},u:{name:"u",value:1e-12,scientific:!0},n:{name:"n",value:1e-18,scientific:!0},p:{name:"p",value:1e-24,scientific:!0},f:{name:"f",value:1e-30,scientific:!0},a:{name:"a",value:1e-36,scientific:!0},z:{name:"z",value:1e-42,scientific:!0},y:{name:"y",value:1e-48,scientific:!0}},CUBIC:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:1e3,scientific:!1},h:{name:"h",value:1e6,scientific:!1},k:{name:"k",value:1e9,scientific:!0},M:{name:"M",value:1e18,scientific:!0},G:{name:"G",value:1e27,scientific:!0},T:{name:"T",value:1e36,scientific:!0},P:{name:"P",value:1e45,scientific:!0},E:{name:"E",value:1e54,scientific:!0},Z:{name:"Z",value:1e63,scientific:!0},Y:{name:"Y",value:1e72,scientific:!0},d:{name:"d",value:.001,scientific:!1},c:{name:"c",value:1e-6,scientific:!1},m:{name:"m",value:1e-9,scientific:!0},u:{name:"u",value:1e-18,scientific:!0},n:{name:"n",value:1e-27,scientific:!0},p:{name:"p",value:1e-36,scientific:!0},f:{name:"f",value:1e-45,scientific:!0},a:{name:"a",value:1e-54,scientific:!0},z:{name:"z",value:1e-63,scientific:!0},y:{name:"y",value:1e-72,scientific:!0}},BINARY_SHORT_SI:{"":{name:"",value:1,scientific:!0},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0}},BINARY_SHORT_IEC:{"":{name:"",value:1,scientific:!0},Ki:{name:"Ki",value:1024,scientific:!0},Mi:{name:"Mi",value:Math.pow(1024,2),scientific:!0},Gi:{name:"Gi",value:Math.pow(1024,3),scientific:!0},Ti:{name:"Ti",value:Math.pow(1024,4),scientific:!0},Pi:{name:"Pi",value:Math.pow(1024,5),scientific:!0},Ei:{name:"Ei",value:Math.pow(1024,6),scientific:!0},Zi:{name:"Zi",value:Math.pow(1024,7),scientific:!0},Yi:{name:"Yi",value:Math.pow(1024,8),scientific:!0}},BINARY_LONG_SI:{"":{name:"",value:1,scientific:!0},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0}},BINARY_LONG_IEC:{"":{name:"",value:1,scientific:!0},kibi:{name:"kibi",value:1024,scientific:!0},mebi:{name:"mebi",value:Math.pow(1024,2),scientific:!0},gibi:{name:"gibi",value:Math.pow(1024,3),scientific:!0},tebi:{name:"tebi",value:Math.pow(1024,4),scientific:!0},pebi:{name:"pebi",value:Math.pow(1024,5),scientific:!0},exi:{name:"exi",value:Math.pow(1024,6),scientific:!0},zebi:{name:"zebi",value:Math.pow(1024,7),scientific:!0},yobi:{name:"yobi",value:Math.pow(1024,8),scientific:!0}},BTU:{"":{name:"",value:1,scientific:!0},MM:{name:"MM",value:1e6,scientific:!0}}};F.SHORTLONG=Sr({},F.SHORT,F.LONG),F.BINARY_SHORT=Sr({},F.BINARY_SHORT_SI,F.BINARY_SHORT_IEC),F.BINARY_LONG=Sr({},F.BINARY_LONG_SI,F.BINARY_LONG_IEC);var H=["MASS","LENGTH","TIME","CURRENT","TEMPERATURE","LUMINOUS_INTENSITY","AMOUNT_OF_SUBSTANCE","ANGLE","BIT"],$={NONE:{dimensions:[0,0,0,0,0,0,0,0,0]},MASS:{dimensions:[1,0,0,0,0,0,0,0,0]},LENGTH:{dimensions:[0,1,0,0,0,0,0,0,0]},TIME:{dimensions:[0,0,1,0,0,0,0,0,0]},CURRENT:{dimensions:[0,0,0,1,0,0,0,0,0]},TEMPERATURE:{dimensions:[0,0,0,0,1,0,0,0,0]},LUMINOUS_INTENSITY:{dimensions:[0,0,0,0,0,1,0,0,0]},AMOUNT_OF_SUBSTANCE:{dimensions:[0,0,0,0,0,0,1,0,0]},FORCE:{dimensions:[1,1,-2,0,0,0,0,0,0]},SURFACE:{dimensions:[0,2,0,0,0,0,0,0,0]},VOLUME:{dimensions:[0,3,0,0,0,0,0,0,0]},ENERGY:{dimensions:[1,2,-2,0,0,0,0,0,0]},POWER:{dimensions:[1,2,-3,0,0,0,0,0,0]},PRESSURE:{dimensions:[1,-1,-2,0,0,0,0,0,0]},ELECTRIC_CHARGE:{dimensions:[0,0,1,1,0,0,0,0,0]},ELECTRIC_CAPACITANCE:{dimensions:[-1,-2,4,2,0,0,0,0,0]},ELECTRIC_POTENTIAL:{dimensions:[1,2,-3,-1,0,0,0,0,0]},ELECTRIC_RESISTANCE:{dimensions:[1,2,-3,-2,0,0,0,0,0]},ELECTRIC_INDUCTANCE:{dimensions:[1,2,-2,-2,0,0,0,0,0]},ELECTRIC_CONDUCTANCE:{dimensions:[-1,-2,3,2,0,0,0,0,0]},MAGNETIC_FLUX:{dimensions:[1,2,-2,-1,0,0,0,0,0]},MAGNETIC_FLUX_DENSITY:{dimensions:[1,0,-2,-1,0,0,0,0,0]},FREQUENCY:{dimensions:[0,0,-1,0,0,0,0,0,0]},ANGLE:{dimensions:[0,0,0,0,0,0,0,1,0]},BIT:{dimensions:[0,0,0,0,0,0,0,0,1]}};for(var k in $)Re($,k)&&($[k].key=k);var Q={},K={name:"",base:Q,value:1,offset:0,dimensions:H.map(V=>0)},L={meter:{name:"meter",base:$.LENGTH,prefixes:F.LONG,value:1,offset:0},inch:{name:"inch",base:$.LENGTH,prefixes:F.NONE,value:.0254,offset:0},foot:{name:"foot",base:$.LENGTH,prefixes:F.NONE,value:.3048,offset:0},yard:{name:"yard",base:$.LENGTH,prefixes:F.NONE,value:.9144,offset:0},mile:{name:"mile",base:$.LENGTH,prefixes:F.NONE,value:1609.344,offset:0},link:{name:"link",base:$.LENGTH,prefixes:F.NONE,value:.201168,offset:0},rod:{name:"rod",base:$.LENGTH,prefixes:F.NONE,value:5.0292,offset:0},chain:{name:"chain",base:$.LENGTH,prefixes:F.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:$.LENGTH,prefixes:F.NONE,value:1e-10,offset:0},m:{name:"m",base:$.LENGTH,prefixes:F.SHORT,value:1,offset:0},in:{name:"in",base:$.LENGTH,prefixes:F.NONE,value:.0254,offset:0},ft:{name:"ft",base:$.LENGTH,prefixes:F.NONE,value:.3048,offset:0},yd:{name:"yd",base:$.LENGTH,prefixes:F.NONE,value:.9144,offset:0},mi:{name:"mi",base:$.LENGTH,prefixes:F.NONE,value:1609.344,offset:0},li:{name:"li",base:$.LENGTH,prefixes:F.NONE,value:.201168,offset:0},rd:{name:"rd",base:$.LENGTH,prefixes:F.NONE,value:5.02921,offset:0},ch:{name:"ch",base:$.LENGTH,prefixes:F.NONE,value:20.1168,offset:0},mil:{name:"mil",base:$.LENGTH,prefixes:F.NONE,value:254e-7,offset:0},m2:{name:"m2",base:$.SURFACE,prefixes:F.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:$.SURFACE,prefixes:F.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:$.SURFACE,prefixes:F.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:$.SURFACE,prefixes:F.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:$.SURFACE,prefixes:F.NONE,value:2589988110336e-6,offset:0},sqrd:{name:"sqrd",base:$.SURFACE,prefixes:F.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:$.SURFACE,prefixes:F.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:$.SURFACE,prefixes:F.NONE,value:64516e-14,offset:0},acre:{name:"acre",base:$.SURFACE,prefixes:F.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:$.SURFACE,prefixes:F.NONE,value:1e4,offset:0},m3:{name:"m3",base:$.VOLUME,prefixes:F.CUBIC,value:1,offset:0},L:{name:"L",base:$.VOLUME,prefixes:F.SHORT,value:.001,offset:0},l:{name:"l",base:$.VOLUME,prefixes:F.SHORT,value:.001,offset:0},litre:{name:"litre",base:$.VOLUME,prefixes:F.LONG,value:.001,offset:0},cuin:{name:"cuin",base:$.VOLUME,prefixes:F.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:$.VOLUME,prefixes:F.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:$.VOLUME,prefixes:F.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:$.VOLUME,prefixes:F.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:$.VOLUME,prefixes:F.NONE,value:15e-6,offset:0},drop:{name:"drop",base:$.VOLUME,prefixes:F.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:$.VOLUME,prefixes:F.NONE,value:5e-8,offset:0},minim:{name:"minim",base:$.VOLUME,prefixes:F.NONE,value:6161152e-14,offset:0},fluiddram:{name:"fluiddram",base:$.VOLUME,prefixes:F.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:$.VOLUME,prefixes:F.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:$.VOLUME,prefixes:F.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:$.VOLUME,prefixes:F.NONE,value:1e-6,offset:0},cup:{name:"cup",base:$.VOLUME,prefixes:F.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:$.VOLUME,prefixes:F.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:$.VOLUME,prefixes:F.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:$.VOLUME,prefixes:F.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:$.VOLUME,prefixes:F.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:$.VOLUME,prefixes:F.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:$.VOLUME,prefixes:F.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:$.VOLUME,prefixes:F.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:$.VOLUME,prefixes:F.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:$.VOLUME,prefixes:F.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:$.VOLUME,prefixes:F.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:$.VOLUME,prefixes:F.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:$.VOLUME,prefixes:F.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:$.VOLUME,prefixes:F.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:$.VOLUME,prefixes:F.NONE,value:.1173478,offset:0},obl:{name:"obl",base:$.VOLUME,prefixes:F.NONE,value:.1589873,offset:0},g:{name:"g",base:$.MASS,prefixes:F.SHORT,value:.001,offset:0},gram:{name:"gram",base:$.MASS,prefixes:F.LONG,value:.001,offset:0},ton:{name:"ton",base:$.MASS,prefixes:F.SHORT,value:907.18474,offset:0},t:{name:"t",base:$.MASS,prefixes:F.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:$.MASS,prefixes:F.LONG,value:1e3,offset:0},grain:{name:"grain",base:$.MASS,prefixes:F.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:$.MASS,prefixes:F.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:$.MASS,prefixes:F.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:$.MASS,prefixes:F.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:$.MASS,prefixes:F.NONE,value:45.359237,offset:0},stick:{name:"stick",base:$.MASS,prefixes:F.NONE,value:.115,offset:0},stone:{name:"stone",base:$.MASS,prefixes:F.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:$.MASS,prefixes:F.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:$.MASS,prefixes:F.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:$.MASS,prefixes:F.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:$.MASS,prefixes:F.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:$.MASS,prefixes:F.NONE,value:45.359237,offset:0},s:{name:"s",base:$.TIME,prefixes:F.SHORT,value:1,offset:0},min:{name:"min",base:$.TIME,prefixes:F.NONE,value:60,offset:0},h:{name:"h",base:$.TIME,prefixes:F.NONE,value:3600,offset:0},second:{name:"second",base:$.TIME,prefixes:F.LONG,value:1,offset:0},sec:{name:"sec",base:$.TIME,prefixes:F.LONG,value:1,offset:0},minute:{name:"minute",base:$.TIME,prefixes:F.NONE,value:60,offset:0},hour:{name:"hour",base:$.TIME,prefixes:F.NONE,value:3600,offset:0},day:{name:"day",base:$.TIME,prefixes:F.NONE,value:86400,offset:0},week:{name:"week",base:$.TIME,prefixes:F.NONE,value:7*86400,offset:0},month:{name:"month",base:$.TIME,prefixes:F.NONE,value:2629800,offset:0},year:{name:"year",base:$.TIME,prefixes:F.NONE,value:31557600,offset:0},decade:{name:"decade",base:$.TIME,prefixes:F.NONE,value:315576e3,offset:0},century:{name:"century",base:$.TIME,prefixes:F.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:$.TIME,prefixes:F.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:$.FREQUENCY,prefixes:F.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:$.FREQUENCY,prefixes:F.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:$.ANGLE,prefixes:F.SHORT,value:1,offset:0},radian:{name:"radian",base:$.ANGLE,prefixes:F.LONG,value:1,offset:0},deg:{name:"deg",base:$.ANGLE,prefixes:F.SHORT,value:null,offset:0},degree:{name:"degree",base:$.ANGLE,prefixes:F.LONG,value:null,offset:0},grad:{name:"grad",base:$.ANGLE,prefixes:F.SHORT,value:null,offset:0},gradian:{name:"gradian",base:$.ANGLE,prefixes:F.LONG,value:null,offset:0},cycle:{name:"cycle",base:$.ANGLE,prefixes:F.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:$.ANGLE,prefixes:F.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:$.ANGLE,prefixes:F.NONE,value:null,offset:0},A:{name:"A",base:$.CURRENT,prefixes:F.SHORT,value:1,offset:0},ampere:{name:"ampere",base:$.CURRENT,prefixes:F.LONG,value:1,offset:0},K:{name:"K",base:$.TEMPERATURE,prefixes:F.SHORT,value:1,offset:0},degC:{name:"degC",base:$.TEMPERATURE,prefixes:F.SHORT,value:1,offset:273.15},degF:{name:"degF",base:$.TEMPERATURE,prefixes:F.SHORT,value:1/1.8,offset:459.67},degR:{name:"degR",base:$.TEMPERATURE,prefixes:F.SHORT,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:$.TEMPERATURE,prefixes:F.LONG,value:1,offset:0},celsius:{name:"celsius",base:$.TEMPERATURE,prefixes:F.LONG,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:$.TEMPERATURE,prefixes:F.LONG,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:$.TEMPERATURE,prefixes:F.LONG,value:1/1.8,offset:0},mol:{name:"mol",base:$.AMOUNT_OF_SUBSTANCE,prefixes:F.SHORT,value:1,offset:0},mole:{name:"mole",base:$.AMOUNT_OF_SUBSTANCE,prefixes:F.LONG,value:1,offset:0},cd:{name:"cd",base:$.LUMINOUS_INTENSITY,prefixes:F.SHORT,value:1,offset:0},candela:{name:"candela",base:$.LUMINOUS_INTENSITY,prefixes:F.LONG,value:1,offset:0},N:{name:"N",base:$.FORCE,prefixes:F.SHORT,value:1,offset:0},newton:{name:"newton",base:$.FORCE,prefixes:F.LONG,value:1,offset:0},dyn:{name:"dyn",base:$.FORCE,prefixes:F.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:$.FORCE,prefixes:F.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:$.FORCE,prefixes:F.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:$.FORCE,prefixes:F.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:$.FORCE,prefixes:F.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:$.FORCE,prefixes:F.NONE,value:9.80665,offset:0},J:{name:"J",base:$.ENERGY,prefixes:F.SHORT,value:1,offset:0},joule:{name:"joule",base:$.ENERGY,prefixes:F.SHORT,value:1,offset:0},erg:{name:"erg",base:$.ENERGY,prefixes:F.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:$.ENERGY,prefixes:F.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:$.ENERGY,prefixes:F.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:$.ENERGY,prefixes:F.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:$.ENERGY,prefixes:F.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:$.POWER,prefixes:F.SHORT,value:1,offset:0},watt:{name:"watt",base:$.POWER,prefixes:F.LONG,value:1,offset:0},hp:{name:"hp",base:$.POWER,prefixes:F.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:$.POWER,prefixes:F.SHORT,value:p.I,offset:0},VA:{name:"VA",base:$.POWER,prefixes:F.SHORT,value:1,offset:0},Pa:{name:"Pa",base:$.PRESSURE,prefixes:F.SHORT,value:1,offset:0},psi:{name:"psi",base:$.PRESSURE,prefixes:F.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:$.PRESSURE,prefixes:F.NONE,value:101325,offset:0},bar:{name:"bar",base:$.PRESSURE,prefixes:F.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:$.PRESSURE,prefixes:F.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:$.PRESSURE,prefixes:F.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:$.PRESSURE,prefixes:F.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:$.PRESSURE,prefixes:F.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:$.ELECTRIC_CHARGE,prefixes:F.LONG,value:1,offset:0},C:{name:"C",base:$.ELECTRIC_CHARGE,prefixes:F.SHORT,value:1,offset:0},farad:{name:"farad",base:$.ELECTRIC_CAPACITANCE,prefixes:F.LONG,value:1,offset:0},F:{name:"F",base:$.ELECTRIC_CAPACITANCE,prefixes:F.SHORT,value:1,offset:0},volt:{name:"volt",base:$.ELECTRIC_POTENTIAL,prefixes:F.LONG,value:1,offset:0},V:{name:"V",base:$.ELECTRIC_POTENTIAL,prefixes:F.SHORT,value:1,offset:0},ohm:{name:"ohm",base:$.ELECTRIC_RESISTANCE,prefixes:F.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:$.ELECTRIC_INDUCTANCE,prefixes:F.LONG,value:1,offset:0},H:{name:"H",base:$.ELECTRIC_INDUCTANCE,prefixes:F.SHORT,value:1,offset:0},siemens:{name:"siemens",base:$.ELECTRIC_CONDUCTANCE,prefixes:F.LONG,value:1,offset:0},S:{name:"S",base:$.ELECTRIC_CONDUCTANCE,prefixes:F.SHORT,value:1,offset:0},weber:{name:"weber",base:$.MAGNETIC_FLUX,prefixes:F.LONG,value:1,offset:0},Wb:{name:"Wb",base:$.MAGNETIC_FLUX,prefixes:F.SHORT,value:1,offset:0},tesla:{name:"tesla",base:$.MAGNETIC_FLUX_DENSITY,prefixes:F.LONG,value:1,offset:0},T:{name:"T",base:$.MAGNETIC_FLUX_DENSITY,prefixes:F.SHORT,value:1,offset:0},b:{name:"b",base:$.BIT,prefixes:F.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:$.BIT,prefixes:F.BINARY_LONG,value:1,offset:0},B:{name:"B",base:$.BIT,prefixes:F.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:$.BIT,prefixes:F.BINARY_LONG,value:8,offset:0}},j={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",amps:"ampere",amp:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function ae(V){if(V.number==="BigNumber"){var X=gs(g);L.rad.value=new g(1),L.deg.value=X.div(180),L.grad.value=X.div(200),L.cycle.value=X.times(2),L.arcsec.value=X.div(648e3),L.arcmin.value=X.div(10800)}else L.rad.value=1,L.deg.value=Math.PI/180,L.grad.value=Math.PI/200,L.cycle.value=Math.PI*2,L.arcsec.value=Math.PI/648e3,L.arcmin.value=Math.PI/10800;L.radian.value=L.rad.value,L.degree.value=L.deg.value,L.gradian.value=L.grad.value}ae(t),e&&e("config",function(V,X){V.number!==X.number&&ae(V)});var re={si:{NONE:{unit:K,prefix:F.NONE[""]},LENGTH:{unit:L.m,prefix:F.SHORT[""]},MASS:{unit:L.g,prefix:F.SHORT.k},TIME:{unit:L.s,prefix:F.SHORT[""]},CURRENT:{unit:L.A,prefix:F.SHORT[""]},TEMPERATURE:{unit:L.K,prefix:F.SHORT[""]},LUMINOUS_INTENSITY:{unit:L.cd,prefix:F.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:L.mol,prefix:F.SHORT[""]},ANGLE:{unit:L.rad,prefix:F.SHORT[""]},BIT:{unit:L.bits,prefix:F.SHORT[""]},FORCE:{unit:L.N,prefix:F.SHORT[""]},ENERGY:{unit:L.J,prefix:F.SHORT[""]},POWER:{unit:L.W,prefix:F.SHORT[""]},PRESSURE:{unit:L.Pa,prefix:F.SHORT[""]},ELECTRIC_CHARGE:{unit:L.C,prefix:F.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:L.F,prefix:F.SHORT[""]},ELECTRIC_POTENTIAL:{unit:L.V,prefix:F.SHORT[""]},ELECTRIC_RESISTANCE:{unit:L.ohm,prefix:F.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:L.H,prefix:F.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:L.S,prefix:F.SHORT[""]},MAGNETIC_FLUX:{unit:L.Wb,prefix:F.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:L.T,prefix:F.SHORT[""]},FREQUENCY:{unit:L.Hz,prefix:F.SHORT[""]}}};re.cgs=JSON.parse(JSON.stringify(re.si)),re.cgs.LENGTH={unit:L.m,prefix:F.SHORT.c},re.cgs.MASS={unit:L.g,prefix:F.SHORT[""]},re.cgs.FORCE={unit:L.dyn,prefix:F.SHORT[""]},re.cgs.ENERGY={unit:L.erg,prefix:F.NONE[""]},re.us=JSON.parse(JSON.stringify(re.si)),re.us.LENGTH={unit:L.ft,prefix:F.NONE[""]},re.us.MASS={unit:L.lbm,prefix:F.NONE[""]},re.us.TEMPERATURE={unit:L.degF,prefix:F.NONE[""]},re.us.FORCE={unit:L.lbf,prefix:F.NONE[""]},re.us.ENERGY={unit:L.BTU,prefix:F.BTU[""]},re.us.POWER={unit:L.hp,prefix:F.NONE[""]},re.us.PRESSURE={unit:L.psi,prefix:F.NONE[""]},re.auto=JSON.parse(JSON.stringify(re.si));var fe=re.auto;d.setUnitSystem=function(V){if(Re(re,V))fe=re[V];else throw new Error("Unit system "+V+" does not exist. Choices are: "+Object.keys(re).join(", "))},d.getUnitSystem=function(){for(var V in re)if(Re(re,V)&&re[V]===fe)return V},d.typeConverters={BigNumber:function(X){return new g(X+"")},Fraction:function(X){return new y(X)},Complex:function(X){return X},number:function(X){return X}},d.prototype._numberConverter=function(){var V=d.typeConverters[this.valueType()];if(V)return V;throw new TypeError('Unsupported Unit value type "'+this.valueType()+'"')},d._getNumberConverter=function(V){if(!d.typeConverters[V])throw new TypeError('Unsupported type "'+V+'"');return d.typeConverters[V]};for(var he in L)if(Re(L,he)){var ce=L[he];ce.dimensions=ce.base.dimensions}for(var ie in j)if(Re(j,ie)){var Ae=L[j[ie]],Oe={};for(var Ce in Ae)Re(Ae,Ce)&&(Oe[Ce]=Ae[Ce]);Oe.name=ie,L[ie]=Oe}d.isValidAlpha=function(X){return/^[a-zA-Z]$/.test(X)};function $e(V){for(var X=0;X<V.length;X++){if(b=V.charAt(X),X===0&&!d.isValidAlpha(b))throw new Error('Invalid unit name (must begin with alpha character): "'+V+'"');if(X>0&&!(d.isValidAlpha(b)||S(b)))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+V+'"')}}return d.createUnit=function(V,X){if(typeof V!="object")throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(X&&X.override){for(var oe in V)if(Re(V,oe)&&d.deleteUnit(oe),V[oe].aliases)for(var G=0;G<V[oe].aliases.length;G++)d.deleteUnit(V[oe].aliases[G])}var Y;for(var te in V)Re(V,te)&&(Y=d.createUnitSingle(te,V[te]));return Y},d.createUnitSingle=function(V,X){if((typeof X>"u"||X===null)&&(X={}),typeof V!="string")throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");if(Re(L,V))throw new Error('Cannot create unit "'+V+'": a unit with that name already exists');$e(V);var oe=null,G=[],Y=0,te,ye,me;if(X&&X.type==="Unit")oe=X.clone();else if(typeof X=="string")X!==""&&(te=X);else if(typeof X=="object")te=X.definition,ye=X.prefixes,Y=X.offset,me=X.baseName,X.aliases&&(G=X.aliases.valueOf());else throw new TypeError('Cannot create unit "'+V+'" from "'+X.toString()+'": expecting "string" or "Unit" or "Object"');if(G){for(var z=0;z<G.length;z++)if(Re(L,G[z]))throw new Error('Cannot create alias "'+G[z]+'": a unit with that name already exists')}if(te&&typeof te=="string"&&!oe)try{oe=d.parse(te,{allowNoUnits:!0})}catch(mr){throw mr.message='Could not create unit "'+V+'" from "'+te+'": '+mr.message,mr}else te&&te.type==="Unit"&&(oe=te.clone());G=G||[],Y=Y||0,ye&&ye.toUpperCase?ye=F[ye.toUpperCase()]||F.NONE:ye=F.NONE;var U={};if(oe){U={name:V,value:oe.value,dimensions:oe.dimensions.slice(0),prefixes:ye,offset:Y};var de=!1;for(var be in $)if(Re($,be)){for(var pe=!0,we=0;we<H.length;we++)if(Math.abs((U.dimensions[we]||0)-($[be].dimensions[we]||0))>1e-12){pe=!1;break}if(pe){de=!0,U.base=$[be];break}}if(!de){me=me||V+"_STUFF";var _e={dimensions:oe.dimensions.slice(0)};_e.key=me,$[me]=_e,fe[me]={unit:U,prefix:F.NONE[""]},U.base=$[me]}}else{if(me=me||V+"_STUFF",H.indexOf(me)>=0)throw new Error('Cannot create new base unit "'+V+'": a base unit with that name already exists (and cannot be overridden)');H.push(me);for(var ee in $)Re($,ee)&&($[ee].dimensions[H.length-1]=0);for(var ue={dimensions:[]},ve=0;ve<H.length;ve++)ue.dimensions[ve]=0;ue.dimensions[H.length-1]=1,ue.key=me,$[me]=ue,U={name:V,value:1,dimensions:$[me].dimensions.slice(0),prefixes:ye,offset:Y,base:$[me]},fe[me]={unit:U,prefix:F.NONE[""]}}d.UNITS[V]=U;for(var Le=0;Le<G.length;Le++){var Be=G[Le],ar={};for(var Je in U)Re(U,Je)&&(ar[Je]=U[Je]);ar.name=Be,d.UNITS[Be]=ar}return delete R.cache,new d(null,V)},d.deleteUnit=function(V){delete d.UNITS[V]},d.PREFIXES=F,d.BASE_DIMENSIONS=H,d.BASE_UNITS=$,d.UNIT_SYSTEMS=re,d.UNITS=L,d},{isClass:!0}),fv="unit",yD=["typed","Unit"],bD=q(fv,yD,r=>{var{typed:e,Unit:t}=r;return e(fv,{Unit:function(n){return n.clone()},string:function(n){return t.isValuelessUnit(n)?new t(null,n):t.parse(n,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string | Unit":function(n,i){return new t(n,i)},"number | BigNumber | Fraction":function(n){return new t(n)},"Array | Matrix":e.referToSelf(a=>n=>je(n,a))})}),mv="sparse",xD=["typed","SparseMatrix"],wD=q(mv,xD,r=>{var{typed:e,SparseMatrix:t}=r;return e(mv,{"":function(){return new t([])},string:function(n){return new t([],n)},"Array | Matrix":function(n){return new t(n)},"Array | Matrix, string":function(n,i){return new t(n,i)}})}),vv="createUnit",ND=["typed","Unit"],DD=q(vv,ND,r=>{var{typed:e,Unit:t}=r;return e(vv,{"Object, Object":function(n,i){return t.createUnit(n,i)},Object:function(n){return t.createUnit(n,{})},"string, Unit | string | Object, Object":function(n,i,o){var f={};return f[n]=i,t.createUnit(f,o)},"string, Unit | string | Object":function(n,i){var o={};return o[n]=i,t.createUnit(o,{})},string:function(n){var i={};return i[n]={},t.createUnit(i,{})}})}),pv="acos",AD=["typed","config","Complex"],ED=q(pv,AD,r=>{var{typed:e,config:t,Complex:a}=r;return e(pv,{number:function(i){return i>=-1&&i<=1||t.predictable?Math.acos(i):new a(i,0).acos()},Complex:function(i){return i.acos()},BigNumber:function(i){return i.acos()}})}),hv="acosh",SD=["typed","config","Complex"],CD=q(hv,SD,r=>{var{typed:e,config:t,Complex:a}=r;return e(hv,{number:function(i){return i>=1||t.predictable?Fc(i):i<=-1?new a(Math.log(Math.sqrt(i*i-1)-i),Math.PI):new a(i,0).acosh()},Complex:function(i){return i.acosh()},BigNumber:function(i){return i.acosh()}})}),dv="acot",MD=["typed","BigNumber"],FD=q(dv,MD,r=>{var{typed:e,BigNumber:t}=r;return e(dv,{number:Tc,Complex:function(n){return n.acot()},BigNumber:function(n){return new t(1).div(n).atan()}})}),gv="acoth",TD=["typed","config","Complex","BigNumber"],BD=q(gv,TD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(gv,{number:function(o){return o>=1||o<=-1||t.predictable?Bc(o):new a(o,0).acoth()},Complex:function(o){return o.acoth()},BigNumber:function(o){return new n(1).div(o).atanh()}})}),yv="acsc",$D=["typed","config","Complex","BigNumber"],OD=q(yv,$D,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(yv,{number:function(o){return o<=-1||o>=1||t.predictable?$c(o):new a(o,0).acsc()},Complex:function(o){return o.acsc()},BigNumber:function(o){return new n(1).div(o).asin()}})}),bv="acsch",ID=["typed","BigNumber"],RD=q(bv,ID,r=>{var{typed:e,BigNumber:t}=r;return e(bv,{number:Oc,Complex:function(n){return n.acsch()},BigNumber:function(n){return new t(1).div(n).asinh()}})}),xv="asec",_D=["typed","config","Complex","BigNumber"],qD=q(xv,_D,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(xv,{number:function(o){return o<=-1||o>=1||t.predictable?Ic(o):new a(o,0).asec()},Complex:function(o){return o.asec()},BigNumber:function(o){return new n(1).div(o).acos()}})}),wv="asech",zD=["typed","config","Complex","BigNumber"],PD=q(wv,zD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(wv,{number:function(o){if(o<=1&&o>=-1||t.predictable){var f=1/o;if(f>0||t.predictable)return Rc(o);var l=Math.sqrt(f*f-1);return new a(Math.log(l-f),Math.PI)}return new a(o,0).asech()},Complex:function(o){return o.asech()},BigNumber:function(o){return new n(1).div(o).acosh()}})}),Nv="asin",UD=["typed","config","Complex"],LD=q(Nv,UD,r=>{var{typed:e,config:t,Complex:a}=r;return e(Nv,{number:function(i){return i>=-1&&i<=1||t.predictable?Math.asin(i):new a(i,0).asin()},Complex:function(i){return i.asin()},BigNumber:function(i){return i.asin()}})}),kD="asinh",VD=["typed"],GD=q(kD,VD,r=>{var{typed:e}=r;return e("asinh",{number:_c,Complex:function(a){return a.asinh()},BigNumber:function(a){return a.asinh()}})}),HD="atan",ZD=["typed"],JD=q(HD,ZD,r=>{var{typed:e}=r;return e("atan",{number:function(a){return Math.atan(a)},Complex:function(a){return a.atan()},BigNumber:function(a){return a.atan()}})}),Dv="atan2",XD=["typed","matrix","equalScalar","BigNumber","DenseMatrix","concat"],WD=q(Dv,XD,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n,DenseMatrix:i,concat:o}=r,f=xt({typed:e,equalScalar:a}),l=Yr({typed:e}),u=Of({typed:e,equalScalar:a}),s=Lr({typed:e,equalScalar:a}),c=Ir({typed:e,DenseMatrix:i}),m=dr({typed:e,matrix:t,concat:o});return e(Dv,{"number, number":Math.atan2,"BigNumber, BigNumber":(v,h)=>n.atan2(v,h)},m({scalar:"number | BigNumber",SS:u,DS:l,SD:f,Ss:s,sS:c}))}),Av="atanh",YD=["typed","config","Complex"],QD=q(Av,YD,r=>{var{typed:e,config:t,Complex:a}=r;return e(Av,{number:function(i){return i<=1&&i>=-1||t.predictable?qc(i):new a(i,0).atanh()},Complex:function(i){return i.atanh()},BigNumber:function(i){return i.atanh()}})}),ca=q("trigUnit",["typed"],r=>{var{typed:e}=r;return{Unit:e.referToSelf(t=>a=>{if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return e.find(t,a.valueType())(a.value)})}}),Ev="cos",KD=["typed"],jD=q(Ev,KD,r=>{var{typed:e}=r,t=ca({typed:e});return e(Ev,{number:Math.cos,"Complex | BigNumber":a=>a.cos()},t)}),Sv="cosh",eA=["typed"],rA=q(Sv,eA,r=>{var{typed:e}=r;return e(Sv,{number:ng,"Complex | BigNumber":t=>t.cosh()})}),Cv="cot",tA=["typed","BigNumber"],nA=q(Cv,tA,r=>{var{typed:e,BigNumber:t}=r,a=ca({typed:e});return e(Cv,{number:zc,Complex:n=>n.cot(),BigNumber:n=>new t(1).div(n.tan())},a)}),Mv="coth",aA=["typed","BigNumber"],iA=q(Mv,aA,r=>{var{typed:e,BigNumber:t}=r;return e(Mv,{number:Pc,Complex:a=>a.coth(),BigNumber:a=>new t(1).div(a.tanh())})}),Fv="csc",oA=["typed","BigNumber"],sA=q(Fv,oA,r=>{var{typed:e,BigNumber:t}=r,a=ca({typed:e});return e(Fv,{number:Uc,Complex:n=>n.csc(),BigNumber:n=>new t(1).div(n.sin())},a)}),Tv="csch",uA=["typed","BigNumber"],lA=q(Tv,uA,r=>{var{typed:e,BigNumber:t}=r;return e(Tv,{number:Lc,Complex:a=>a.csch(),BigNumber:a=>new t(1).div(a.sinh())})}),Bv="sec",cA=["typed","BigNumber"],fA=q(Bv,cA,r=>{var{typed:e,BigNumber:t}=r,a=ca({typed:e});return e(Bv,{number:kc,Complex:n=>n.sec(),BigNumber:n=>new t(1).div(n.cos())},a)}),$v="sech",mA=["typed","BigNumber"],vA=q($v,mA,r=>{var{typed:e,BigNumber:t}=r;return e($v,{number:Vc,Complex:a=>a.sech(),BigNumber:a=>new t(1).div(a.cosh())})}),Ov="sin",pA=["typed"],hA=q(Ov,pA,r=>{var{typed:e}=r,t=ca({typed:e});return e(Ov,{number:Math.sin,"Complex | BigNumber":a=>a.sin()},t)}),Iv="sinh",dA=["typed"],gA=q(Iv,dA,r=>{var{typed:e}=r;return e(Iv,{number:Gc,"Complex | BigNumber":t=>t.sinh()})}),Rv="tan",yA=["typed"],bA=q(Rv,yA,r=>{var{typed:e}=r,t=ca({typed:e});return e(Rv,{number:Math.tan,"Complex | BigNumber":a=>a.tan()},t)}),xA="tanh",wA=["typed"],NA=q(xA,wA,r=>{var{typed:e}=r;return e("tanh",{number:ig,"Complex | BigNumber":t=>t.tanh()})}),_v="setCartesian",DA=["typed","size","subset","compareNatural","Index","DenseMatrix"],AA=q(_v,DA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:o}=r;return e(_v,{"Array | Matrix, Array | Matrix":function(l,u){var s=[];if(a(t(l),new i(0))!==0&&a(t(u),new i(0))!==0){var c=or(Array.isArray(l)?l:l.toArray()).sort(n),m=or(Array.isArray(u)?u:u.toArray()).sort(n);s=[];for(var v=0;v<c.length;v++)for(var h=0;h<m.length;h++)s.push([c[v],m[h]])}return Array.isArray(l)&&Array.isArray(u)?s:new o(s)}})}),qv="setDifference",EA=["typed","size","subset","compareNatural","Index","DenseMatrix"],SA=q(qv,EA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:o}=r;return e(qv,{"Array | Matrix, Array | Matrix":function(l,u){var s;if(a(t(l),new i(0))===0)s=[];else{if(a(t(u),new i(0))===0)return or(l.toArray());var c=Qn(or(Array.isArray(l)?l:l.toArray()).sort(n)),m=Qn(or(Array.isArray(u)?u:u.toArray()).sort(n));s=[];for(var v,h=0;h<c.length;h++){v=!1;for(var p=0;p<m.length;p++)if(n(c[h].value,m[p].value)===0&&c[h].identifier===m[p].identifier){v=!0;break}v||s.push(c[h])}}return Array.isArray(l)&&Array.isArray(u)?gi(s):new o(gi(s))}})}),zv="setDistinct",CA=["typed","size","subset","compareNatural","Index","DenseMatrix"],MA=q(zv,CA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:o}=r;return e(zv,{"Array | Matrix":function(l){var u;if(a(t(l),new i(0))===0)u=[];else{var s=or(Array.isArray(l)?l:l.toArray()).sort(n);u=[],u.push(s[0]);for(var c=1;c<s.length;c++)n(s[c],s[c-1])!==0&&u.push(s[c])}return Array.isArray(l)?u:new o(u)}})}),Pv="setIntersect",FA=["typed","size","subset","compareNatural","Index","DenseMatrix"],TA=q(Pv,FA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:o}=r;return e(Pv,{"Array | Matrix, Array | Matrix":function(l,u){var s;if(a(t(l),new i(0))===0||a(t(u),new i(0))===0)s=[];else{var c=Qn(or(Array.isArray(l)?l:l.toArray()).sort(n)),m=Qn(or(Array.isArray(u)?u:u.toArray()).sort(n));s=[];for(var v=0;v<c.length;v++)for(var h=0;h<m.length;h++)if(n(c[v].value,m[h].value)===0&&c[v].identifier===m[h].identifier){s.push(c[v]);break}}return Array.isArray(l)&&Array.isArray(u)?gi(s):new o(gi(s))}})}),Uv="setIsSubset",BA=["typed","size","subset","compareNatural","Index"],$A=q(Uv,BA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(Uv,{"Array | Matrix, Array | Matrix":function(f,l){if(a(t(f),new i(0))===0)return!0;if(a(t(l),new i(0))===0)return!1;for(var u=Qn(or(Array.isArray(f)?f:f.toArray()).sort(n)),s=Qn(or(Array.isArray(l)?l:l.toArray()).sort(n)),c,m=0;m<u.length;m++){c=!1;for(var v=0;v<s.length;v++)if(n(u[m].value,s[v].value)===0&&u[m].identifier===s[v].identifier){c=!0;break}if(c===!1)return!1}return!0}})}),Lv="setMultiplicity",OA=["typed","size","subset","compareNatural","Index"],IA=q(Lv,OA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(Lv,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(f,l){if(a(t(l),new i(0))===0)return 0;for(var u=or(Array.isArray(l)?l:l.toArray()),s=0,c=0;c<u.length;c++)n(u[c],f)===0&&s++;return s}})}),kv="setPowerset",RA=["typed","size","subset","compareNatural","Index"],_A=q(kv,RA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(kv,{"Array | Matrix":function(u){if(a(t(u),new i(0))===0)return[];for(var s=or(Array.isArray(u)?u:u.toArray()).sort(n),c=[],m=0;m.toString(2).length<=s.length;)c.push(o(s,m.toString(2).split("").reverse())),m++;return f(c)}});function o(l,u){for(var s=[],c=0;c<u.length;c++)u[c]==="1"&&s.push(l[c]);return s}function f(l){for(var u=[],s=l.length-1;s>0;s--)for(var c=0;c<s;c++)l[c].length>l[c+1].length&&(u=l[c],l[c]=l[c+1],l[c+1]=u);return l}}),Vv="setSize",qA=["typed","compareNatural"],zA=q(Vv,qA,r=>{var{typed:e,compareNatural:t}=r;return e(Vv,{"Array | Matrix":function(n){return Array.isArray(n)?or(n).length:or(n.toArray()).length},"Array | Matrix, boolean":function(n,i){if(i===!1||n.length===0)return Array.isArray(n)?or(n).length:or(n.toArray()).length;for(var o=or(Array.isArray(n)?n:n.toArray()).sort(t),f=1,l=1;l<o.length;l++)t(o[l],o[l-1])!==0&&f++;return f}})}),Gv="setSymDifference",PA=["typed","size","concat","subset","setDifference","Index"],UA=q(Gv,PA,r=>{var{typed:e,size:t,concat:a,subset:n,setDifference:i,Index:o}=r;return e(Gv,{"Array | Matrix, Array | Matrix":function(l,u){if(n(t(l),new o(0))===0)return or(u);if(n(t(u),new o(0))===0)return or(l);var s=or(l),c=or(u);return a(i(s,c),i(c,s))}})}),Hv="setUnion",LA=["typed","size","concat","subset","setIntersect","setSymDifference","Index"],kA=q(Hv,LA,r=>{var{typed:e,size:t,concat:a,subset:n,setIntersect:i,setSymDifference:o,Index:f}=r;return e(Hv,{"Array | Matrix, Array | Matrix":function(u,s){if(n(t(u),new f(0))===0)return or(s);if(n(t(s),new f(0))===0)return or(u);var c=or(u),m=or(s);return a(o(c,m),i(c,m))}})}),Zv="add",VA=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],GA=q(Zv,VA,r=>{var{typed:e,matrix:t,addScalar:a,equalScalar:n,DenseMatrix:i,SparseMatrix:o,concat:f}=r,l=cn({typed:e}),u=fs({typed:e,equalScalar:n}),s=Fn({typed:e,DenseMatrix:i}),c=dr({typed:e,matrix:t,concat:f});return e(Zv,{"any, any":a,"any, any, ...any":e.referToSelf(m=>(v,h,p)=>{for(var g=m(v,h),y=0;y<p.length;y++)g=m(g,p[y]);return g})},c({elop:a,DS:l,SS:u,Ss:s}))}),Jv="hypot",HA=["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],ZA=q(Jv,HA,r=>{var{typed:e,abs:t,addScalar:a,divideScalar:n,multiplyScalar:i,sqrt:o,smaller:f,isPositive:l}=r;return e(Jv,{"... number | BigNumber":u,Array:u,Matrix:s=>u(or(s.toArray()))});function u(s){for(var c=0,m=0,v=0;v<s.length;v++){if(Lt(s[v]))throw new TypeError("Unexpected type of argument to hypot");var h=t(s[v]);f(m,h)?(c=i(c,i(n(m,h),n(m,h))),c=a(c,1),m=h):c=a(c,l(h)?i(n(h,m),n(h,m)):h)}return i(m,o(c))}}),Xv="norm",JA=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],XA=q(Xv,JA,r=>{var{typed:e,abs:t,add:a,pow:n,conj:i,sqrt:o,multiply:f,equalScalar:l,larger:u,smaller:s,matrix:c,ctranspose:m,eigs:v}=r;return e(Xv,{number:Math.abs,Complex:function(A){return A.abs()},BigNumber:function(A){return A.abs()},boolean:function(A){return Math.abs(A)},Array:function(A){return b(c(A),2)},Matrix:function(A){return b(A,2)},"Array, number | BigNumber | string":function(A,S){return b(c(A),S)},"Matrix, number | BigNumber | string":function(A,S){return b(A,S)}});function h(E){var A=0;return E.forEach(function(S){var D=t(S);u(D,A)&&(A=D)},!0),A}function p(E){var A;return E.forEach(function(S){var D=t(S);(!A||s(D,A))&&(A=D)},!0),A||0}function g(E,A){if(A===Number.POSITIVE_INFINITY||A==="inf")return h(E);if(A===Number.NEGATIVE_INFINITY||A==="-inf")return p(E);if(A==="fro")return b(E,2);if(typeof A=="number"&&!isNaN(A)){if(!l(A,0)){var S=0;return E.forEach(function(D){S=a(n(t(D),A),S)},!0),n(S,1/A)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}function y(E){var A=0;return E.forEach(function(S,D){A=a(A,f(S,i(S)))}),t(o(A))}function N(E){var A=[],S=0;return E.forEach(function(D,T){var B=T[1],I=a(A[B]||0,t(D));u(I,S)&&(S=I),A[B]=I},!0),S}function d(E){var A=E.size();if(A[0]!==A[1])throw new RangeError("Invalid matrix dimensions");var S=m(E),D=f(S,E),T=v(D).values.toArray(),B=T[T.length-1];return t(o(B))}function w(E){var A=[],S=0;return E.forEach(function(D,T){var B=T[0],I=a(A[B]||0,t(D));u(I,S)&&(S=I),A[B]=I},!0),S}function x(E,A){if(A===1)return N(E);if(A===Number.POSITIVE_INFINITY||A==="inf")return w(E);if(A==="fro")return y(E);if(A===2)return d(E);throw new Error("Unsupported parameter value "+A)}function b(E,A){var S=E.size();if(S.length===1)return g(E,A);if(S.length===2){if(S[0]&&S[1])return x(E,A);throw new RangeError("Invalid matrix dimensions")}}}),Wv="dot",WA=["typed","addScalar","multiplyScalar","conj","size"],YA=q(Wv,WA,r=>{var{typed:e,addScalar:t,multiplyScalar:a,conj:n,size:i}=r;return e(Wv,{"Array | DenseMatrix, Array | DenseMatrix":f,"SparseMatrix, SparseMatrix":l});function o(s,c){var m=u(s),v=u(c),h,p;if(m.length===1)h=m[0];else if(m.length===2&&m[1]===1)h=m[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+m.join(", ")+")");if(v.length===1)p=v[0];else if(v.length===2&&v[1]===1)p=v[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+v.join(", ")+")");if(h!==p)throw new RangeError("Vectors must have equal length ("+h+" != "+p+")");if(h===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return h}function f(s,c){var m=o(s,c),v=Ve(s)?s._data:s,h=Ve(s)?s._datatype:void 0,p=Ve(c)?c._data:c,g=Ve(c)?c._datatype:void 0,y=u(s).length===2,N=u(c).length===2,d=t,w=a;if(h&&g&&h===g&&typeof h=="string"){var x=h;d=e.find(t,[x,x]),w=e.find(a,[x,x])}if(!y&&!N){for(var b=w(n(v[0]),p[0]),E=1;E<m;E++)b=d(b,w(n(v[E]),p[E]));return b}if(!y&&N){for(var A=w(n(v[0]),p[0][0]),S=1;S<m;S++)A=d(A,w(n(v[S]),p[S][0]));return A}if(y&&!N){for(var D=w(n(v[0][0]),p[0]),T=1;T<m;T++)D=d(D,w(n(v[T][0]),p[T]));return D}if(y&&N){for(var B=w(n(v[0][0]),p[0][0]),I=1;I<m;I++)B=d(B,w(n(v[I][0]),p[I][0]));return B}}function l(s,c){o(s,c);for(var m=s._index,v=s._values,h=c._index,p=c._values,g=0,y=t,N=a,d=0,w=0;d<m.length&&w<h.length;){var x=m[d],b=h[w];if(x<b){d++;continue}if(x>b){w++;continue}x===b&&(g=y(g,N(v[d],p[w])),d++,w++)}return g}function u(s){return Ve(s)?s.size():i(s)}}),QA="trace",KA=["typed","matrix","add"],jA=q(QA,KA,r=>{var{typed:e,matrix:t,add:a}=r;return e("trace",{Array:function(f){return n(t(f))},SparseMatrix:i,DenseMatrix:n,any:Ge});function n(o){var f=o._size,l=o._data;switch(f.length){case 1:if(f[0]===1)return Ge(l[0]);throw new RangeError("Matrix must be square (size: "+Ye(f)+")");case 2:{var u=f[0],s=f[1];if(u===s){for(var c=0,m=0;m<u;m++)c=a(c,l[m][m]);return c}else throw new RangeError("Matrix must be square (size: "+Ye(f)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Ye(f)+")")}}function i(o){var f=o._values,l=o._index,u=o._ptr,s=o._size,c=s[0],m=s[1];if(c===m){var v=0;if(f.length>0)for(var h=0;h<m;h++)for(var p=u[h],g=u[h+1],y=p;y<g;y++){var N=l[y];if(N===h){v=a(v,f[y]);break}if(N>h)break}return v}throw new RangeError("Matrix must be square (size: "+Ye(s)+")")}}),Yv="index",eE=["typed","Index"],rE=q(Yv,eE,r=>{var{typed:e,Index:t}=r;return e(Yv,{"...number | string | BigNumber | Range | Array | Matrix":function(n){var i=n.map(function(f){return rr(f)?f.toNumber():Array.isArray(f)||Ve(f)?f.map(function(l){return rr(l)?l.toNumber():l}):f}),o=new t;return t.apply(o,i),o}})}),Qv=new Set(["end"]),tE="Node",nE=["mathWithTransform"],aE=q(tE,nE,r=>{var{mathWithTransform:e}=r;function t(n){for(var i of[...Qv])if(n.has(i))throw new Error('Scope contains an illegal symbol, "'+i+'" is a reserved keyword')}class a{get type(){return"Node"}get isNode(){return!0}evaluate(i){return this.compile().evaluate(i)}compile(){var i=this._compile(e,{}),o={},f=null;function l(u){var s=ea(u);return t(s),i(s,o,f)}return{evaluate:l}}_compile(i,o){throw new Error("Method _compile must be implemented by type "+this.type)}forEach(i){throw new Error("Cannot run forEach on a Node interface")}map(i){throw new Error("Cannot run map on a Node interface")}_ifNode(i){if(!fr(i))throw new TypeError("Callback function must return a Node");return i}traverse(i){i(this,null,null);function o(f,l){f.forEach(function(u,s,c){l(u,s,c),o(u,l)})}o(this,i)}transform(i){function o(f,l,u){var s=i(f,l,u);return s!==f?s:f.map(o)}return o(this,null,null)}filter(i){var o=[];return this.traverse(function(f,l,u){i(f,l,u)&&o.push(f)}),o}clone(){throw new Error("Cannot clone a Node interface")}cloneDeep(){return this.map(function(i){return i.cloneDeep()})}equals(i){return i?this.type===i.type&&Pa(this,i):!1}toString(i){var o=this._getCustomString(i);return typeof o<"u"?o:this._toString(i)}toJSON(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)}toHTML(i){var o=this._getCustomString(i);return typeof o<"u"?o:this.toHTML(i)}_toString(){throw new Error("_toString not implemented for "+this.type)}toTex(i){var o=this._getCustomString(i);return typeof o<"u"?o:this._toTex(i)}_toTex(i){throw new Error("_toTex not implemented for "+this.type)}_getCustomString(i){if(i&&typeof i=="object")switch(typeof i.handler){case"object":case"undefined":return;case"function":return i.handler(this,i);default:throw new TypeError("Object or function expected as callback")}}getIdentifier(){return this.type}getContent(){return this}}return a},{isClass:!0,isNode:!0});function Kr(r){return r&&r.isIndexError?new ht(r.index+1,r.min+1,r.max!==void 0?r.max+1:void 0):r}function Kv(r){var{subset:e}=r;return function(a,n){try{if(Array.isArray(a))return e(a,n);if(a&&typeof a.subset=="function")return a.subset(n);if(typeof a=="string")return e(a,n);if(typeof a=="object"){if(!n.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return ut(a,n.getObjectProperty())}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(i){throw Kr(i)}}}var Gi="AccessorNode",iE=["subset","Node"],oE=q(Gi,iE,r=>{var{subset:e,Node:t}=r,a=Kv({subset:e});function n(o){return!(En(o)||it(o)||ir(o)||rn(o)||ci(o)||Vt(o)||qr(o))}class i extends t{constructor(f,l){if(super(),!fr(f))throw new TypeError('Node expected for parameter "object"');if(!Zn(l))throw new TypeError('IndexNode expected for parameter "index"');this.object=f,this.index=l}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return Gi}get isAccessorNode(){return!0}_compile(f,l){var u=this.object._compile(f,l),s=this.index._compile(f,l);if(this.index.isObjectProperty()){var c=this.index.getObjectProperty();return function(v,h,p){return ut(u(v,h,p),c)}}else return function(v,h,p){var g=u(v,h,p),y=s(v,h,g);return a(g,y)}}forEach(f){f(this.object,"object",this),f(this.index,"index",this)}map(f){return new i(this._ifNode(f(this.object,"object",this)),this._ifNode(f(this.index,"index",this)))}clone(){return new i(this.object,this.index)}_toString(f){var l=this.object.toString(f);return n(this.object)&&(l="("+l+")"),l+this.index.toString(f)}toHTML(f){var l=this.object.toHTML(f);return n(this.object)&&(l='<span class="math-parenthesis math-round-parenthesis">(</span>'+l+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+this.index.toHTML(f)}_toTex(f){var l=this.object.toTex(f);return n(this.object)&&(l="\\left(' + object + '\\right)"),l+this.index.toTex(f)}toJSON(){return{mathjs:Gi,object:this.object,index:this.index}}static fromJSON(f){return new i(f.object,f.index)}}return zr(i,"name",Gi),i},{isClass:!0,isNode:!0}),Hi="ArrayNode",sE=["Node"],uE=q(Hi,sE,r=>{var{Node:e}=r;class t extends e{constructor(n){if(super(),this.items=n||[],!Array.isArray(this.items)||!this.items.every(fr))throw new TypeError("Array containing Nodes expected")}get type(){return Hi}get isArrayNode(){return!0}_compile(n,i){var o=Gt(this.items,function(u){return u._compile(n,i)}),f=n.config.matrix!=="Array";if(f){var l=n.matrix;return function(s,c,m){return l(Gt(o,function(v){return v(s,c,m)}))}}else return function(s,c,m){return Gt(o,function(v){return v(s,c,m)})}}forEach(n){for(var i=0;i<this.items.length;i++){var o=this.items[i];n(o,"items["+i+"]",this)}}map(n){for(var i=[],o=0;o<this.items.length;o++)i[o]=this._ifNode(n(this.items[o],"items["+o+"]",this));return new t(i)}clone(){return new t(this.items.slice(0))}_toString(n){var i=this.items.map(function(o){return o.toString(n)});return"["+i.join(", ")+"]"}toJSON(){return{mathjs:Hi,items:this.items}}static fromJSON(n){return new t(n.items)}toHTML(n){var i=this.items.map(function(o){return o.toHTML(n)});return'<span class="math-parenthesis math-square-parenthesis">[</span>'+i.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(n){function i(o,f){var l=o.some(it)&&!o.every(it),u=f||l,s=u?"&":"\\\\",c=o.map(function(m){return m.items?i(m.items,!f):m.toTex(n)}).join(s);return l||!u||u&&!f?"\\begin{bmatrix}"+c+"\\end{bmatrix}":c}return i(this.items,!1)}}return zr(t,"name",Hi),t},{isClass:!0,isNode:!0});function lE(r){var{subset:e,matrix:t}=r;return function(n,i,o){try{if(Array.isArray(n))return t(n).subset(i,o).valueOf();if(n&&typeof n.subset=="function")return n.subset(i,o);if(typeof n=="string")return e(n,i,o);if(typeof n=="object"){if(!i.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return Kn(n,i.getObjectProperty(),o),n}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(f){throw Kr(f)}}}var wt=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{op:"or",associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{op:"xor",associativity:"left",associativeWith:[]}},{"OperatorNode:and":{op:"and",associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{op:"|",associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{op:"^|",associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{op:"&",associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{op:"==",associativity:"left",associativeWith:[]},"OperatorNode:unequal":{op:"!=",associativity:"left",associativeWith:[]},"OperatorNode:smaller":{op:"<",associativity:"left",associativeWith:[]},"OperatorNode:larger":{op:">",associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{op:"<=",associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{op:">=",associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{op:"<<",associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{op:">>",associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{op:">>>",associativity:"left",associativeWith:[]}},{"OperatorNode:to":{op:"to",associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{op:"+",associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{op:"-",associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{op:"*",associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{op:"/",associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{op:".*",associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{op:"./",associativity:"left",associativeWith:[]},"OperatorNode:mod":{op:"mod",associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]}},{"OperatorNode:unaryPlus":{op:"+",associativity:"right"},"OperatorNode:unaryMinus":{op:"-",associativity:"right"},"OperatorNode:bitNot":{op:"~",associativity:"right"},"OperatorNode:not":{op:"not",associativity:"right"}},{"OperatorNode:pow":{op:"^",associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{op:".^",associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{op:"!",associativity:"left"}},{"OperatorNode:ctranspose":{op:"'",associativity:"left"}}];function Zi(r,e){if(!e||e!=="auto")return r;for(var t=r;Vt(t);)t=t.content;return t}function pr(r,e,t,a){var n=r;e!=="keep"&&(n=r.getContent());for(var i=n.getIdentifier(),o=null,f=0;f<wt.length;f++)if(i in wt[f]){o=f;break}if(i==="OperatorNode:multiply"&&n.implicit&&t!=="show"){var l=Zi(n.args[0],e);!(ir(l)&&a&&a.getIdentifier()==="OperatorNode:divide"&&ko(Zi(a.args[0],e)))&&!(l.getIdentifier()==="OperatorNode:divide"&&ko(Zi(l.args[0],e))&&ir(Zi(l.args[1])))&&(o+=1)}return o}function Ja(r,e){var t=r;e!=="keep"&&(t=r.getContent());var a=t.getIdentifier(),n=pr(t,e);if(n===null)return null;var i=wt[n][a];if(Re(i,"associativity")){if(i.associativity==="left")return"left";if(i.associativity==="right")return"right";throw Error("'"+a+"' has the invalid associativity '"+i.associativity+"'.")}return null}function bs(r,e,t){var a=t!=="keep"?r.getContent():r,n=t!=="keep"?r.getContent():e,i=a.getIdentifier(),o=n.getIdentifier(),f=pr(a,t);if(f===null)return null;var l=wt[f][i];if(Re(l,"associativeWith")&&l.associativeWith instanceof Array){for(var u=0;u<l.associativeWith.length;u++)if(l.associativeWith[u]===o)return!0;return!1}return null}function cE(r){var e="OperatorNode:"+r;for(var t of wt)if(e in t)return t[e].op;return null}var Ji="AssignmentNode",fE=["subset","?matrix","Node"],mE=q(Ji,fE,r=>{var{subset:e,matrix:t,Node:a}=r,n=Kv({subset:e}),i=lE({subset:e,matrix:t});function o(l,u,s){u||(u="keep");var c=pr(l,u,s),m=pr(l.value,u,s);return u==="all"||m!==null&&m<=c}class f extends a{constructor(u,s,c){if(super(),this.object=u,this.index=c?s:null,this.value=c||s,!qr(u)&&!En(u))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(qr(u)&&u.name==="end")throw new Error('Cannot assign to symbol "end"');if(this.index&&!Zn(this.index))throw new TypeError('IndexNode expected as "index"');if(!fr(this.value))throw new TypeError('Node expected as "value"')}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return Ji}get isAssignmentNode(){return!0}_compile(u,s){var c=this.object._compile(u,s),m=this.index?this.index._compile(u,s):null,v=this.value._compile(u,s),h=this.object.name;if(this.index)if(this.index.isObjectProperty()){var p=this.index.getObjectProperty();return function(w,x,b){var E=c(w,x,b),A=v(w,x,b);return Kn(E,p,A),A}}else{if(qr(this.object))return function(w,x,b){var E=c(w,x,b),A=v(w,x,b),S=m(w,x,E);return w.set(h,i(E,S,A)),A};var g=this.object.object._compile(u,s);if(this.object.index.isObjectProperty()){var y=this.object.index.getObjectProperty();return function(w,x,b){var E=g(w,x,b),A=ut(E,y),S=m(w,x,A),D=v(w,x,b);return Kn(E,y,i(A,S,D)),D}}else{var N=this.object.index._compile(u,s);return function(w,x,b){var E=g(w,x,b),A=N(w,x,E),S=n(E,A),D=m(w,x,S),T=v(w,x,b);return i(E,A,i(S,D,T)),T}}}else{if(!qr(this.object))throw new TypeError("SymbolNode expected as object");return function(w,x,b){var E=v(w,x,b);return w.set(h,E),E}}}forEach(u){u(this.object,"object",this),this.index&&u(this.index,"index",this),u(this.value,"value",this)}map(u){var s=this._ifNode(u(this.object,"object",this)),c=this.index?this._ifNode(u(this.index,"index",this)):null,m=this._ifNode(u(this.value,"value",this));return new f(s,c,m)}clone(){return new f(this.object,this.index,this.value)}_toString(u){var s=this.object.toString(u),c=this.index?this.index.toString(u):"",m=this.value.toString(u);return o(this,u&&u.parenthesis,u&&u.implicit)&&(m="("+m+")"),s+c+" = "+m}toJSON(){return{mathjs:Ji,object:this.object,index:this.index,value:this.value}}static fromJSON(u){return new f(u.object,u.index,u.value)}toHTML(u){var s=this.object.toHTML(u),c=this.index?this.index.toHTML(u):"",m=this.value.toHTML(u);return o(this,u&&u.parenthesis,u&&u.implicit)&&(m='<span class="math-paranthesis math-round-parenthesis">(</span>'+m+'<span class="math-paranthesis math-round-parenthesis">)</span>'),s+c+'<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+m}_toTex(u){var s=this.object.toTex(u),c=this.index?this.index.toTex(u):"",m=this.value.toTex(u);return o(this,u&&u.parenthesis,u&&u.implicit)&&(m="\\left(".concat(m,"\\right)")),s+c+":="+m}}return zr(f,"name",Ji),f},{isClass:!0,isNode:!0}),Xi="BlockNode",vE=["ResultSet","Node"],pE=q(Xi,vE,r=>{var{ResultSet:e,Node:t}=r;class a extends t{constructor(i){if(super(),!Array.isArray(i))throw new Error("Array expected");this.blocks=i.map(function(o){var f=o&&o.node,l=o&&o.visible!==void 0?o.visible:!0;if(!fr(f))throw new TypeError('Property "node" must be a Node');if(typeof l!="boolean")throw new TypeError('Property "visible" must be a boolean');return{node:f,visible:l}})}get type(){return Xi}get isBlockNode(){return!0}_compile(i,o){var f=Gt(this.blocks,function(l){return{evaluate:l.node._compile(i,o),visible:l.visible}});return function(u,s,c){var m=[];return hi(f,function(h){var p=h.evaluate(u,s,c);h.visible&&m.push(p)}),new e(m)}}forEach(i){for(var o=0;o<this.blocks.length;o++)i(this.blocks[o].node,"blocks["+o+"].node",this)}map(i){for(var o=[],f=0;f<this.blocks.length;f++){var l=this.blocks[f],u=this._ifNode(i(l.node,"blocks["+f+"].node",this));o[f]={node:u,visible:l.visible}}return new a(o)}clone(){var i=this.blocks.map(function(o){return{node:o.node,visible:o.visible}});return new a(i)}_toString(i){return this.blocks.map(function(o){return o.node.toString(i)+(o.visible?"":";")}).join(`
|
|
29
|
+
(`+Ye(A,p)+", "+Ye(w,p)+") ==> "+(this._values?Ye(this._values[E],p):"X")}return d},n.prototype.toString=function(){return Ye(this.toArray())},n.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(p){if(p){if(rr(p)&&(p=p.toNumber()),!tr(p)||!qe(p))throw new TypeError("The parameter k must be an integer number")}else p=0;var g=p>0?p:0,y=p<0?-p:0,N=this._size[0],d=this._size[1],w=Math.min(N-y,d-g),x=[],b=[],E=[];E[0]=0;for(var A=g;A<d&&x.length<w;A++)for(var S=this._ptr[A],D=this._ptr[A+1],T=S;T<D;T++){var B=this._index[T];if(B===A-g+y){x.push(this._values[T]),b[x.length-1]=B-y;break}}return E.push(x.length),new n({values:x,index:b,ptr:E,size:[w,1]})},n.fromJSON=function(p){return new n(p)},n.diagonal=function(p,g,y,N,d){if(!cr(p))throw new TypeError("Array expected, size parameter");if(p.length!==2)throw new Error("Only two dimensions matrix are supported");if(p=p.map(function($){if(rr($)&&($=$.toNumber()),!tr($)||!qe($)||$<1)throw new Error("Size values must be positive integers");return $}),y){if(rr(y)&&(y=y.toNumber()),!tr(y)||!qe(y))throw new TypeError("The parameter k must be an integer number")}else y=0;var w=t,x=0;Wr(d)&&(w=e.find(t,[d,d])||t,x=e.convert(0,d));var b=y>0?y:0,E=y<0?-y:0,A=p[0],S=p[1],D=Math.min(A-E,S-b),T;if(cr(g)){if(g.length!==D)throw new Error("Invalid value array length");T=function(k){return g[k]}}else if(Ve(g)){var B=g.size();if(B.length!==1||B[0]!==D)throw new Error("Invalid matrix length");T=function(k){return g.get([k])}}else T=function(){return g};for(var I=[],P=[],R=[],M=0;M<S;M++){R.push(I.length);var F=M-b;if(F>=0&&F<D){var H=T(F);w(H,x)||(P.push(F+E),I.push(H))}}return R.push(I.length),new n({values:I,index:P,ptr:R,size:[A,S]})},n.prototype.swapRows=function(p,g){if(!tr(p)||!qe(p)||!tr(g)||!qe(g))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return vr(p,this._size[0]),vr(g,this._size[0]),n._swapRows(p,g,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(p,g,y,N,d){for(var w=N[p],x=N[p+1],b=w;b<x;b++)d(y[b],g[b])},n._swapRows=function(p,g,y,N,d,w){for(var x=0;x<y;x++){var b=w[x],E=w[x+1],A=u(p,b,E,d),S=u(g,b,E,d);if(A<E&&S<E&&d[A]===p&&d[S]===g){if(N){var D=N[A];N[A]=N[S],N[S]=D}continue}if(A<E&&d[A]===p&&(S>=E||d[S]!==g)){var T=N?N[A]:void 0;d.splice(S,0,g),N&&N.splice(S,0,T),d.splice(S<=A?A+1:A,1),N&&N.splice(S<=A?A+1:A,1);continue}if(S<E&&d[S]===g&&(A>=E||d[A]!==p)){var B=N?N[S]:void 0;d.splice(A,0,p),N&&N.splice(A,0,B),d.splice(A<=S?S+1:S,1),N&&N.splice(A<=S?S+1:S,1)}}},n},{isClass:!0}),My="number",Fy=["typed"];function Ty(r){var e=r.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(e){var t={"0b":2,"0o":8,"0x":16}[e[1]],a=e[2],n=e[3];return{input:r,radix:t,integerPart:a,fractionalPart:n}}else return null}function By(r){for(var e=parseInt(r.integerPart,r.radix),t=0,a=0;a<r.fractionalPart.length;a++){var n=parseInt(r.fractionalPart[a],r.radix);t+=n/Math.pow(r.radix,a+1)}var i=e+t;if(isNaN(i))throw new SyntaxError('String "'+r.input+'" is no valid number');return i}var $y=q(My,Fy,r=>{var{typed:e}=r,t=e("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var i=Ty(n);if(i)return By(i);var o=0,f=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);f&&(o=Number(f[2]),n=f[1]);var l=Number(n);if(isNaN(l))throw new SyntaxError('String "'+n+'" is no valid number');if(f){if(l>2**o-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));l>=2**(o-1)&&(l=l-2**o)}return l},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:function(n){throw new Error("Second argument with valueless unit expected")},null:function(n){return 0},"Unit, string | Unit":function(n,i){return n.toNumber(i)},"Array | Matrix":e.referToSelf(a=>n=>je(n,a))});return t.fromJSON=function(a){return parseFloat(a.value)},t}),af="string",Oy=["typed"],Iy=q(af,Oy,r=>{var{typed:e}=r;return e(af,{"":function(){return""},number:Cn,null:function(a){return"null"},boolean:function(a){return a+""},string:function(a){return a},"Array | Matrix":e.referToSelf(t=>a=>je(a,t)),any:function(a){return String(a)}})}),of="boolean",Ry=["typed"],_y=q(of,Ry,r=>{var{typed:e}=r;return e(of,{"":function(){return!1},boolean:function(a){return a},number:function(a){return!!a},null:function(a){return!1},BigNumber:function(a){return!a.isZero()},string:function(a){var n=a.toLowerCase();if(n==="true")return!0;if(n==="false")return!1;var i=Number(a);if(a!==""&&!isNaN(i))return!!i;throw new Error('Cannot convert "'+a+'" to a boolean')},"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),qy="bignumber",zy=["typed","BigNumber"],Py=q(qy,zy,r=>{var{typed:e,BigNumber:t}=r;return e("bignumber",{"":function(){return new t(0)},number:function(n){return new t(n+"")},string:function(n){var i=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(i){var o=i[2],f=t(i[1]),l=new t(2).pow(Number(o));if(f.gt(l.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var u=new t(2).pow(Number(o)-1);return f.gte(u)?f.sub(l):f}return new t(n)},BigNumber:function(n){return n},Fraction:function(n){return new t(n.n).div(n.d).times(n.s)},null:function(n){return new t(0)},"Array | Matrix":e.referToSelf(a=>n=>je(n,a))})}),Uy="complex",Ly=["typed","Complex"],ky=q(Uy,Ly,r=>{var{typed:e,Complex:t}=r;return e("complex",{"":function(){return t.ZERO},number:function(n){return new t(n,0)},"number, number":function(n,i){return new t(n,i)},"BigNumber, BigNumber":function(n,i){return new t(n.toNumber(),i.toNumber())},Fraction:function(n){return new t(n.valueOf(),0)},Complex:function(n){return n.clone()},string:function(n){return t(n)},null:function(n){return t(0)},Object:function(n){if("re"in n&&"im"in n)return new t(n.re,n.im);if("r"in n&&"phi"in n||"abs"in n&&"arg"in n)return new t(n);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":e.referToSelf(a=>n=>je(n,a))})}),Vy="fraction",Gy=["typed","Fraction"],Hy=q(Vy,Gy,r=>{var{typed:e,Fraction:t}=r;return e("fraction",{number:function(n){if(!isFinite(n)||isNaN(n))throw new Error(n+" cannot be represented as a fraction");return new t(n)},string:function(n){return new t(n)},"number, number":function(n,i){return new t(n,i)},null:function(n){return new t(0)},BigNumber:function(n){return new t(n.toString())},Fraction:function(n){return n},Object:function(n){return new t(n)},"Array | Matrix":e.referToSelf(a=>n=>je(n,a))})}),sf="matrix",Zy=["typed","Matrix","DenseMatrix","SparseMatrix"],Jy=q(sf,Zy,r=>{var{typed:e,Matrix:t,DenseMatrix:a,SparseMatrix:n}=r;return e(sf,{"":function(){return i([])},string:function(f){return i([],f)},"string, string":function(f,l){return i([],f,l)},Array:function(f){return i(f)},Matrix:function(f){return i(f,f.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(o,f,l){if(f==="dense"||f==="default"||f===void 0)return new a(o,l);if(f==="sparse")return new n(o,l);throw new TypeError("Unknown matrix type "+JSON.stringify(f)+".")}}),uf="matrixFromFunction",Xy=["typed","matrix","isZero"],Wy=q(uf,Xy,r=>{var{typed:e,matrix:t,isZero:a}=r;return e(uf,{"Array | Matrix, function, string, string":function(o,f,l,u){return n(o,f,l,u)},"Array | Matrix, function, string":function(o,f,l){return n(o,f,l)},"Matrix, function":function(o,f){return n(o,f,"dense")},"Array, function":function(o,f){return n(o,f,"dense").toArray()},"Array | Matrix, string, function":function(o,f,l){return n(o,l,f)},"Array | Matrix, string, string, function":function(o,f,l,u){return n(o,u,f,l)}});function n(i,o,f,l){var u;return l!==void 0?u=t(f,l):u=t(f),u.resize(i),u.forEach(function(s,c){var m=o(c);a(m)||u.set(c,m)}),u}}),lf="matrixFromRows",Yy=["typed","matrix","flatten","size"],Qy=q(lf,Yy,r=>{var{typed:e,matrix:t,flatten:a,size:n}=r;return e(lf,{"...Array":function(l){return i(l)},"...Matrix":function(l){return t(i(l.map(u=>u.toArray())))}});function i(f){if(f.length===0)throw new TypeError("At least one row is needed to construct a matrix.");var l=o(f[0]),u=[];for(var s of f){var c=o(s);if(c!==l)throw new TypeError("The vectors had different length: "+(l|0)+" \u2260 "+(c|0));u.push(a(s))}return u}function o(f){var l=n(f);if(l.length===1)return l[0];if(l.length===2){if(l[0]===1)return l[1];if(l[1]===1)return l[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),cf="matrixFromColumns",Ky=["typed","matrix","flatten","size"],jy=q(cf,Ky,r=>{var{typed:e,matrix:t,flatten:a,size:n}=r;return e(cf,{"...Array":function(l){return i(l)},"...Matrix":function(l){return t(i(l.map(u=>u.toArray())))}});function i(f){if(f.length===0)throw new TypeError("At least one column is needed to construct a matrix.");for(var l=o(f[0]),u=[],s=0;s<l;s++)u[s]=[];for(var c of f){var m=o(c);if(m!==l)throw new TypeError("The vectors had different length: "+(l|0)+" \u2260 "+(m|0));for(var v=a(c),h=0;h<l;h++)u[h].push(v[h])}return u}function o(f){var l=n(f);if(l.length===1)return l[0];if(l.length===2){if(l[0]===1)return l[1];if(l[1]===1)return l[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),ff="splitUnit",eb=["typed"],rb=q(ff,eb,r=>{var{typed:e}=r;return e(ff,{"Unit, Array":function(a,n){return a.splitUnit(n)}})}),mf="unaryMinus",tb=["typed"],nb=q(mf,tb,r=>{var{typed:e}=r;return e(mf,{number:rc,"Complex | BigNumber | Fraction":t=>t.neg(),Unit:e.referToSelf(t=>a=>{var n=a.clone();return n.value=e.find(t,n.valueType())(a.value),n}),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),vf="unaryPlus",ab=["typed","config","BigNumber"],ib=q(vf,ab,r=>{var{typed:e,config:t,BigNumber:a}=r;return e(vf,{number:tc,Complex:function(i){return i},BigNumber:function(i){return i},Fraction:function(i){return i},Unit:function(i){return i.clone()},"Array | Matrix":e.referToSelf(n=>i=>je(i,n)),"boolean | string":function(i){return t.number==="BigNumber"?new a(+i):+i}})}),pf="abs",ob=["typed"],sb=q(pf,ob,r=>{var{typed:e}=r;return e(pf,{number:Kl,"Complex | BigNumber | Fraction | Unit":t=>t.abs(),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),hf="apply",ub=["typed","isInteger"],df=q(hf,ub,r=>{var{typed:e,isInteger:t}=r;return e(hf,{"Array | Matrix, number | BigNumber, function":function(n,i,o){if(!t(i))throw new TypeError("Integer number expected for dimension");var f=Array.isArray(n)?er(n):n.size();if(i<0||i>=f.length)throw new dt(i,f.length);return Ve(n)?n.create($i(n.valueOf(),i,o)):$i(n,i,o)}})});function $i(r,e,t){var a,n,i;if(e<=0)if(Array.isArray(r[0])){for(i=lb(r),n=[],a=0;a<i.length;a++)n[a]=$i(i[a],e-1,t);return n}else return t(r);else{for(n=[],a=0;a<r.length;a++)n[a]=$i(r[a],e-1,t);return n}}function lb(r){var e=r.length,t=r[0].length,a,n,i=[];for(n=0;n<t;n++){var o=[];for(a=0;a<e;a++)o.push(r[a][n]);i.push(o)}return i}var gf="addScalar",cb=["typed"],fb=q(gf,cb,r=>{var{typed:e}=r;return e(gf,{"number, number":jl,"Complex, Complex":function(a,n){return a.add(n)},"BigNumber, BigNumber":function(a,n){return a.plus(n)},"Fraction, Fraction":function(a,n){return a.add(n)},"Unit, Unit":e.referToSelf(t=>(a,n)=>{if(a.value===null||a.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!a.equalBase(n))throw new Error("Units do not match");var i=a.clone();return i.value=e.find(t,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i})})}),yf="cbrt",mb=["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],vb=q(yf,mb,r=>{var{config:e,typed:t,isNegative:a,unaryMinus:n,matrix:i,Complex:o,BigNumber:f,Fraction:l}=r;return t(yf,{number:Ga,Complex:u,"Complex, boolean":u,BigNumber:function(m){return m.cbrt()},Unit:s});function u(c,m){var v=c.arg()/3,h=c.abs(),p=new o(Ga(h),0).mul(new o(0,v).exp());if(m){var g=[p,new o(Ga(h),0).mul(new o(0,v+Math.PI*2/3).exp()),new o(Ga(h),0).mul(new o(0,v-Math.PI*2/3).exp())];return e.matrix==="Array"?g:i(g)}else return p}function s(c){if(c.value&&kt(c.value)){var m=c.clone();return m.value=1,m=m.pow(1/3),m.value=u(c.value),m}else{var v=a(c.value);v&&(c.value=n(c.value));var h;rr(c.value)?h=new f(1).div(3):za(c.value)?h=new l(1,3):h=1/3;var p=c.pow(h);return v&&(p.value=n(p.value)),p}}}),pb="matAlgo11xS0s",hb=["typed","equalScalar"],Lr=q(pb,hb,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o,f){var l=n._values,u=n._index,s=n._ptr,c=n._size,m=n._datatype;if(!l)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=c[0],h=c[1],p,g=t,y=0,N=o;typeof m=="string"&&(p=m,g=e.find(t,[p,p]),y=e.convert(0,p),i=e.convert(i,p),N=e.find(o,[p,p]));for(var d=[],w=[],x=[],b=0;b<h;b++){x[b]=w.length;for(var E=s[b],A=s[b+1],S=E;S<A;S++){var D=u[S],T=f?N(i,l[S]):N(l[S],i);g(T,y)||(w.push(D),d.push(T))}}return x[h]=w.length,n.createSparseMatrix({values:d,index:w,ptr:x,size:[v,h],datatype:p})}}),db="matAlgo12xSfs",gb=["typed","DenseMatrix"],Ir=q(db,gb,r=>{var{typed:e,DenseMatrix:t}=r;return function(n,i,o,f){var l=n._values,u=n._index,s=n._ptr,c=n._size,m=n._datatype;if(!l)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=c[0],h=c[1],p,g=o;typeof m=="string"&&(p=m,i=e.convert(i,p),g=e.find(o,[p,p]));for(var y=[],N=[],d=[],w=0;w<h;w++){for(var x=w+1,b=s[w],E=s[w+1],A=b;A<E;A++){var S=u[A];N[S]=l[A],d[S]=x}for(var D=0;D<v;D++)w===0&&(y[D]=[]),d[D]===x?y[D][w]=f?g(i,N[D]):g(N[D],i):y[D][w]=f?g(i,0):g(0,i)}return new t({data:y,size:[v,h],datatype:p})}}),yb="matAlgo14xDs",bb=["typed"],xt=q(yb,bb,r=>{var{typed:e}=r;return function(n,i,o,f){var l=n._data,u=n._size,s=n._datatype,c,m=o;typeof s=="string"&&(c=s,i=e.convert(i,c),m=e.find(o,[c,c]));var v=u.length>0?t(m,0,u,u[0],l,i,f):[];return n.createDenseMatrix({data:v,size:Ge(u),datatype:c})};function t(a,n,i,o,f,l,u){var s=[];if(n===i.length-1)for(var c=0;c<o;c++)s[c]=u?a(l,f[c]):a(f[c],l);else for(var m=0;m<o;m++)s[m]=t(a,n+1,i,i[n+1],f[m],l,u);return s}}),us="ceil",xb=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],wb=q(us,["typed","config","round"],r=>{var{typed:e,config:t,round:a}=r;return e(us,{number:function(i){return nt(i,a(i),t.epsilon)?a(i):Math.ceil(i)},"number, number":function(i,o){if(nt(i,a(i,o),t.epsilon))return a(i,o);var[f,l]="".concat(i,"e").split("e"),u=Math.ceil(Number("".concat(f,"e").concat(Number(l)+o)));return[f,l]="".concat(u,"e").split("e"),Number("".concat(f,"e").concat(Number(l)-o))}})}),Nb=q(us,xb,r=>{var{typed:e,config:t,round:a,matrix:n,equalScalar:i,zeros:o,DenseMatrix:f}=r,l=Lr({typed:e,equalScalar:i}),u=Ir({typed:e,DenseMatrix:f}),s=xt({typed:e}),c=wb({typed:e,config:t,round:a});return e("ceil",{number:c.signatures.number,"number,number":c.signatures["number,number"],Complex:function(v){return v.ceil()},"Complex, number":function(v,h){return v.ceil(h)},"Complex, BigNumber":function(v,h){return v.ceil(h.toNumber())},BigNumber:function(v){return Bt(v,a(v),t.epsilon)?a(v):v.ceil()},"BigNumber, BigNumber":function(v,h){return Bt(v,a(v,h),t.epsilon)?a(v,h):v.toDecimalPlaces(h.toNumber(),cn.ROUND_CEIL)},Fraction:function(v){return v.ceil()},"Fraction, number":function(v,h){return v.ceil(h)},"Fraction, BigNumber":function(v,h){return v.ceil(h.toNumber())},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array, number | BigNumber":e.referToSelf(m=>(v,h)=>je(v,p=>m(p,h))),"SparseMatrix, number | BigNumber":e.referToSelf(m=>(v,h)=>l(v,h,m,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(m=>(v,h)=>s(v,h,m,!1)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,h)=>s(n(h),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,h)=>i(v,0)?o(h.size(),h.storage()):h.storage()==="dense"?s(h,v,m,!0):u(h,v,m,!0))})}),bf="cube",Db=["typed"],Ab=q(bf,Db,r=>{var{typed:e}=r;return e(bf,{number:nc,Complex:function(a){return a.mul(a).mul(a)},BigNumber:function(a){return a.times(a).times(a)},Fraction:function(a){return a.pow(3)},Unit:function(a){return a.pow(3)}})}),xf="exp",Eb=["typed"],Sb=q(xf,Eb,r=>{var{typed:e}=r;return e(xf,{number:ac,Complex:function(a){return a.exp()},BigNumber:function(a){return a.exp()}})}),wf="expm1",Cb=["typed","Complex"],Mb=q(wf,Cb,r=>{var{typed:e,Complex:t}=r;return e(wf,{number:ic,Complex:function(n){var i=Math.exp(n.re);return new t(i*Math.cos(n.im)-1,i*Math.sin(n.im))},BigNumber:function(n){return n.exp().minus(1)}})}),ls="fix",Fb=["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],Tb=q(ls,["typed","ceil","floor"],r=>{var{typed:e,ceil:t,floor:a}=r;return e(ls,{number:function(i){return i>0?a(i):t(i)},"number, number":function(i,o){return i>0?a(i,o):t(i,o)}})}),Bb=q(ls,Fb,r=>{var{typed:e,Complex:t,matrix:a,ceil:n,floor:i,equalScalar:o,zeros:f,DenseMatrix:l}=r,u=Ir({typed:e,DenseMatrix:l}),s=xt({typed:e}),c=Tb({typed:e,ceil:n,floor:i});return e("fix",{number:c.signatures.number,"number, number | BigNumber":c.signatures["number,number"],Complex:function(v){return new t(v.re>0?Math.floor(v.re):Math.ceil(v.re),v.im>0?Math.floor(v.im):Math.ceil(v.im))},"Complex, number":function(v,h){return new t(v.re>0?i(v.re,h):n(v.re,h),v.im>0?i(v.im,h):n(v.im,h))},"Complex, BigNumber":function(v,h){var p=h.toNumber();return new t(v.re>0?i(v.re,p):n(v.re,p),v.im>0?i(v.im,p):n(v.im,p))},BigNumber:function(v){return v.isNegative()?n(v):i(v)},"BigNumber, number | BigNumber":function(v,h){return v.isNegative()?n(v,h):i(v,h)},Fraction:function(v){return v.s<0?v.ceil():v.floor()},"Fraction, number | BigNumber":function(v,h){return v.s<0?n(v,h):i(v,h)},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array | Matrix, number | BigNumber":e.referToSelf(m=>(v,h)=>je(v,p=>m(p,h))),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,h)=>s(a(h),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,h)=>o(v,0)?f(h.size(),h.storage()):h.storage()==="dense"?s(h,v,m,!0):u(h,v,m,!0))})}),cs="floor",$b=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],Ob=q(cs,["typed","config","round"],r=>{var{typed:e,config:t,round:a}=r;return e(cs,{number:function(i){return nt(i,a(i),t.epsilon)?a(i):Math.floor(i)},"number, number":function(i,o){if(nt(i,a(i,o),t.epsilon))return a(i,o);var[f,l]="".concat(i,"e").split("e"),u=Math.floor(Number("".concat(f,"e").concat(Number(l)+o)));return[f,l]="".concat(u,"e").split("e"),Number("".concat(f,"e").concat(Number(l)-o))}})}),Ib=q(cs,$b,r=>{var{typed:e,config:t,round:a,matrix:n,equalScalar:i,zeros:o,DenseMatrix:f}=r,l=Lr({typed:e,equalScalar:i}),u=Ir({typed:e,DenseMatrix:f}),s=xt({typed:e}),c=Ob({typed:e,config:t,round:a});return e("floor",{number:c.signatures.number,"number,number":c.signatures["number,number"],Complex:function(v){return v.floor()},"Complex, number":function(v,h){return v.floor(h)},"Complex, BigNumber":function(v,h){return v.floor(h.toNumber())},BigNumber:function(v){return Bt(v,a(v),t.epsilon)?a(v):v.floor()},"BigNumber, BigNumber":function(v,h){return Bt(v,a(v,h),t.epsilon)?a(v,h):v.toDecimalPlaces(h.toNumber(),cn.ROUND_FLOOR)},Fraction:function(v){return v.floor()},"Fraction, number":function(v,h){return v.floor(h)},"Fraction, BigNumber":function(v,h){return v.floor(h.toNumber())},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array, number | BigNumber":e.referToSelf(m=>(v,h)=>je(v,p=>m(p,h))),"SparseMatrix, number | BigNumber":e.referToSelf(m=>(v,h)=>l(v,h,m,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(m=>(v,h)=>s(v,h,m,!1)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,h)=>s(n(h),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,h)=>i(v,0)?o(h.size(),h.storage()):h.storage()==="dense"?s(h,v,m,!0):u(h,v,m,!0))})}),Rb="matAlgo01xDSid",_b=["typed"],mn=q(Rb,_b,r=>{var{typed:e}=r;return function(a,n,i,o){var f=a._data,l=a._size,u=a._datatype,s=n._values,c=n._index,m=n._ptr,v=n._size,h=n._datatype;if(l.length!==v.length)throw new Ke(l.length,v.length);if(l[0]!==v[0]||l[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+v+")");if(!s)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var p=l[0],g=l[1],y=typeof u=="string"&&u===h?u:void 0,N=y?e.find(i,[y,y]):i,d,w,x=[];for(d=0;d<p;d++)x[d]=[];var b=[],E=[];for(w=0;w<g;w++){for(var A=w+1,S=m[w],D=m[w+1],T=S;T<D;T++)d=c[T],b[d]=o?N(s[T],f[d][w]):N(f[d][w],s[T]),E[d]=A;for(d=0;d<p;d++)E[d]===A?x[d][w]=b[d]:x[d][w]=f[d][w]}return a.createDenseMatrix({data:x,size:[p,g],datatype:y})}}),qb="matAlgo04xSidSid",zb=["typed","equalScalar"],fs=q(qb,zb,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o){var f=n._values,l=n._index,u=n._ptr,s=n._size,c=n._datatype,m=i._values,v=i._index,h=i._ptr,p=i._size,g=i._datatype;if(s.length!==p.length)throw new Ke(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");var y=s[0],N=s[1],d,w=t,x=0,b=o;typeof c=="string"&&c===g&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),b=e.find(o,[d,d]));var E=f&&m?[]:void 0,A=[],S=[],D=f&&m?[]:void 0,T=f&&m?[]:void 0,B=[],I=[],P,R,M,F,H;for(R=0;R<N;R++){S[R]=A.length;var $=R+1;for(F=u[R],H=u[R+1],M=F;M<H;M++)P=l[M],A.push(P),B[P]=$,D&&(D[P]=f[M]);for(F=h[R],H=h[R+1],M=F;M<H;M++)if(P=v[M],B[P]===$){if(D){var k=b(D[P],m[M]);w(k,x)?B[P]=null:D[P]=k}}else A.push(P),I[P]=$,T&&(T[P]=m[M]);if(D&&T)for(M=S[R];M<A.length;)P=A[M],B[P]===$?(E[M]=D[P],M++):I[P]===$?(E[M]=T[P],M++):A.splice(M,1)}return S[N]=A.length,n.createSparseMatrix({values:E,index:A,ptr:S,size:[y,N],datatype:d})}}),Pb="matAlgo10xSids",Ub=["typed","DenseMatrix"],Tn=q(Pb,Ub,r=>{var{typed:e,DenseMatrix:t}=r;return function(n,i,o,f){var l=n._values,u=n._index,s=n._ptr,c=n._size,m=n._datatype;if(!l)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=c[0],h=c[1],p,g=o;typeof m=="string"&&(p=m,i=e.convert(i,p),g=e.find(o,[p,p]));for(var y=[],N=[],d=[],w=0;w<h;w++){for(var x=w+1,b=s[w],E=s[w+1],A=b;A<E;A++){var S=u[A];N[S]=l[A],d[S]=x}for(var D=0;D<v;D++)w===0&&(y[D]=[]),d[D]===x?y[D][w]=f?g(i,N[D]):g(N[D],i):y[D][w]=i}return new t({data:y,size:[v,h],datatype:p})}}),Lb="matAlgo13xDD",kb=["typed"],Vb=q(Lb,kb,r=>{var{typed:e}=r;return function(n,i,o){var f=n._data,l=n._size,u=n._datatype,s=i._data,c=i._size,m=i._datatype,v=[];if(l.length!==c.length)throw new Ke(l.length,c.length);for(var h=0;h<l.length;h++){if(l[h]!==c[h])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+c+")");v[h]=l[h]}var p,g=o;typeof u=="string"&&u===m&&(p=u,g=e.find(o,[p,p]));var y=v.length>0?t(g,0,v,v[0],f,s):[];return n.createDenseMatrix({data:y,size:v,datatype:p})};function t(a,n,i,o,f,l){var u=[];if(n===i.length-1)for(var s=0;s<o;s++)u[s]=a(f[s],l[s]);else for(var c=0;c<o;c++)u[c]=t(a,n+1,i,i[n+1],f[c],l[c]);return u}}),Gb="broadcast",Hb=["concat"],Zb=q(Gb,Hb,r=>{var{concat:e}=r;return function(i,o){var f=Math.max(i._size.length,o._size.length);if(i._size.length===o._size.length&&i._size.every((g,y)=>g===o._size[y]))return[i,o];for(var l=t(i._size,f,0),u=t(o._size,f,0),s=[],c=0;c<f;c++)s[c]=Math.max(l[c],u[c]);for(var m=0;m<f;m++)n(l,s,m),n(u,s,m);var v=i.clone(),h=o.clone();v._size.length<f?v.reshape(t(v._size,f,1)):h._size.length<f&&h.reshape(t(h._size,f,1));for(var p=0;p<f;p++)v._size[p]<s[p]&&(v=a(v,s[p],p)),h._size[p]<s[p]&&(h=a(h,s[p],p));return[v,h]};function t(i,o,f){return[...Array(o-i.length).fill(f),...i]}function a(i,o,f){return e(...Array(o).fill(i),f)}function n(i,o,f){if(i[f]<o[f]&i[f]>1)throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(i,") not possible to broadcast dimension ").concat(f," with size ").concat(i[f]," to size ").concat(o[f]))}}),Jb="matrixAlgorithmSuite",Xb=["typed","matrix","concat"],dr=q(Jb,Xb,r=>{var{typed:e,matrix:t,concat:a}=r,n=Vb({typed:e}),i=xt({typed:e}),o=Zb({concat:a});return function(l){var u=l.elop,s=l.SD||l.DS,c;u?(c={"DenseMatrix, DenseMatrix":(p,g)=>n(...o(p,g),u),"Array, Array":(p,g)=>n(...o(t(p),t(g)),u).valueOf(),"Array, DenseMatrix":(p,g)=>n(...o(t(p),g),u),"DenseMatrix, Array":(p,g)=>n(...o(p,t(g)),u)},l.SS&&(c["SparseMatrix, SparseMatrix"]=(p,g)=>l.SS(...o(p,g),u,!1)),l.DS&&(c["DenseMatrix, SparseMatrix"]=(p,g)=>l.DS(...o(p,g),u,!1),c["Array, SparseMatrix"]=(p,g)=>l.DS(...o(t(p),g),u,!1)),s&&(c["SparseMatrix, DenseMatrix"]=(p,g)=>s(...o(g,p),u,!0),c["SparseMatrix, Array"]=(p,g)=>s(...o(t(g),p),u,!0))):(c={"DenseMatrix, DenseMatrix":e.referToSelf(p=>(g,y)=>n(...o(g,y),p)),"Array, Array":e.referToSelf(p=>(g,y)=>n(...o(t(g),t(y)),p).valueOf()),"Array, DenseMatrix":e.referToSelf(p=>(g,y)=>n(...o(t(g),y),p)),"DenseMatrix, Array":e.referToSelf(p=>(g,y)=>n(...o(g,t(y)),p))},l.SS&&(c["SparseMatrix, SparseMatrix"]=e.referToSelf(p=>(g,y)=>l.SS(...o(g,y),p,!1))),l.DS&&(c["DenseMatrix, SparseMatrix"]=e.referToSelf(p=>(g,y)=>l.DS(...o(g,y),p,!1)),c["Array, SparseMatrix"]=e.referToSelf(p=>(g,y)=>l.DS(...o(t(g),y),p,!1))),s&&(c["SparseMatrix, DenseMatrix"]=e.referToSelf(p=>(g,y)=>s(...o(y,g),p,!0)),c["SparseMatrix, Array"]=e.referToSelf(p=>(g,y)=>s(...o(t(y),g),p,!0))));var m=l.scalar||"any",v=l.Ds||l.Ss;v&&(u?(c["DenseMatrix,"+m]=(p,g)=>i(p,g,u,!1),c[m+", DenseMatrix"]=(p,g)=>i(g,p,u,!0),c["Array,"+m]=(p,g)=>i(t(p),g,u,!1).valueOf(),c[m+", Array"]=(p,g)=>i(t(g),p,u,!0).valueOf()):(c["DenseMatrix,"+m]=e.referToSelf(p=>(g,y)=>i(g,y,p,!1)),c[m+", DenseMatrix"]=e.referToSelf(p=>(g,y)=>i(y,g,p,!0)),c["Array,"+m]=e.referToSelf(p=>(g,y)=>i(t(g),y,p,!1).valueOf()),c[m+", Array"]=e.referToSelf(p=>(g,y)=>i(t(y),g,p,!0).valueOf())));var h=l.sS!==void 0?l.sS:l.Ss;return u?(l.Ss&&(c["SparseMatrix,"+m]=(p,g)=>l.Ss(p,g,u,!1)),h&&(c[m+", SparseMatrix"]=(p,g)=>h(g,p,u,!0))):(l.Ss&&(c["SparseMatrix,"+m]=e.referToSelf(p=>(g,y)=>l.Ss(g,y,p,!1))),h&&(c[m+", SparseMatrix"]=e.referToSelf(p=>(g,y)=>h(y,g,p,!0)))),u&&u.signatures&&ll(c,u.signatures),c}});function Bn(r,e,t,a){if(!(this instanceof Bn))throw new SyntaxError("Constructor must be called with the new operator");this.fn=r,this.count=e,this.min=t,this.max=a,this.message="Wrong number of arguments in function "+r+" ("+e+" provided, "+t+(a!=null?"-"+a:"")+" expected)",this.stack=new Error().stack}Bn.prototype=new Error,Bn.prototype.constructor=Error,Bn.prototype.name="ArgumentsError",Bn.prototype.isArgumentsError=!0;var Nf="gcd",Wb=["typed","matrix","equalScalar","BigNumber","DenseMatrix","concat"],ms="number | BigNumber | Fraction | Matrix | Array",Yb="".concat(ms,", ").concat(ms,", ...").concat(ms);function Df(r){return!r.some(e=>Array.isArray(e))}var Qb=q(Nf,Wb,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n,DenseMatrix:i,concat:o}=r,f=mn({typed:e}),l=fs({typed:e,equalScalar:a}),u=Tn({typed:e,DenseMatrix:i}),s=dr({typed:e,matrix:t,concat:o});return e(Nf,{"number, number":oc,"BigNumber, BigNumber":c,"Fraction, Fraction":(m,v)=>m.gcd(v)},s({SS:l,DS:f,Ss:u}),{[Yb]:e.referToSelf(m=>(v,h,p)=>{for(var g=m(v,h),y=0;y<p.length;y++)g=m(g,p[y]);return g}),Array:e.referToSelf(m=>v=>{if(v.length===1&&Array.isArray(v[0])&&Df(v[0]))return m(...v[0]);if(Df(v))return m(...v);throw new Bn("gcd() supports only 1d matrices!")}),Matrix:e.referToSelf(m=>v=>m(v.toArray()))});function c(m,v){if(!m.isInt()||!v.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var h=new n(0);!v.isZero();){var p=m.mod(v);m=v,v=p}return m.lt(h)?m.neg():m}}),Kb="matAlgo02xDS0",jb=["typed","equalScalar"],wt=q(Kb,jb,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o,f){var l=n._data,u=n._size,s=n._datatype,c=i._values,m=i._index,v=i._ptr,h=i._size,p=i._datatype;if(u.length!==h.length)throw new Ke(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var g=u[0],y=u[1],N,d=t,w=0,x=o;typeof s=="string"&&s===p&&(N=s,d=e.find(t,[N,N]),w=e.convert(0,N),x=e.find(o,[N,N]));for(var b=[],E=[],A=[],S=0;S<y;S++){A[S]=E.length;for(var D=v[S],T=v[S+1],B=D;B<T;B++){var I=m[B],P=f?x(c[B],l[I][S]):x(l[I][S],c[B]);d(P,w)||(E.push(I),b.push(P))}}return A[y]=E.length,i.createSparseMatrix({values:b,index:E,ptr:A,size:[g,y],datatype:N})}}),ex="matAlgo06xS0S0",rx=["typed","equalScalar"],Oi=q(ex,rx,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o){var f=n._values,l=n._size,u=n._datatype,s=i._values,c=i._size,m=i._datatype;if(l.length!==c.length)throw new Ke(l.length,c.length);if(l[0]!==c[0]||l[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+c+")");var v=l[0],h=l[1],p,g=t,y=0,N=o;typeof u=="string"&&u===m&&(p=u,g=e.find(t,[p,p]),y=e.convert(0,p),N=e.find(o,[p,p]));for(var d=f&&s?[]:void 0,w=[],x=[],b=d?[]:void 0,E=[],A=[],S=0;S<h;S++){x[S]=w.length;var D=S+1;if(Yl(n,S,E,b,A,D,w,N),Yl(i,S,E,b,A,D,w,N),b)for(var T=x[S];T<w.length;){var B=w[T];if(A[B]===D){var I=b[B];g(I,y)?w.splice(T,1):(d.push(I),T++)}else w.splice(T,1)}else for(var P=x[S];P<w.length;){var R=w[P];A[R]!==D?w.splice(P,1):P++}}return x[h]=w.length,n.createSparseMatrix({values:d,index:w,ptr:x,size:[v,h],datatype:p})}}),Af="lcm",tx=["typed","matrix","equalScalar","concat"],nx=q(Af,tx,r=>{var{typed:e,matrix:t,equalScalar:a,concat:n}=r,i=wt({typed:e,equalScalar:a}),o=Oi({typed:e,equalScalar:a}),f=Lr({typed:e,equalScalar:a}),l=dr({typed:e,matrix:t,concat:n}),u="number | BigNumber | Fraction | Matrix | Array",s={};return s["".concat(u,", ").concat(u,", ...").concat(u)]=e.referToSelf(m=>(v,h,p)=>{for(var g=m(v,h),y=0;y<p.length;y++)g=m(g,p[y]);return g}),e(Af,{"number, number":sc,"BigNumber, BigNumber":c,"Fraction, Fraction":(m,v)=>m.lcm(v)},l({SS:o,DS:i,Ss:f}),s);function c(m,v){if(!m.isInt()||!v.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(m.isZero())return m;if(v.isZero())return v;for(var h=m.times(v);!v.isZero();){var p=v;v=m.mod(p),m=p}return h.div(m).abs()}}),Ef="log10",ax=["typed","config","Complex"],ix=q(Ef,ax,r=>{var{typed:e,config:t,Complex:a}=r;return e(Ef,{number:function(i){return i>=0||t.predictable?uc(i):new a(i,0).log().div(Math.LN10)},Complex:function(i){return new a(i).log().div(Math.LN10)},BigNumber:function(i){return!i.isNegative()||t.predictable?i.log():new a(i.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":e.referToSelf(n=>i=>je(i,n))})}),Sf="log2",ox=["typed","config","Complex"],sx=q(Sf,ox,r=>{var{typed:e,config:t,Complex:a}=r;return e(Sf,{number:function(o){return o>=0||t.predictable?lc(o):n(new a(o,0))},Complex:n,BigNumber:function(o){return!o.isNegative()||t.predictable?o.log(2):n(new a(o.toNumber(),0))},"Array | Matrix":e.referToSelf(i=>o=>je(o,i))});function n(i){var o=Math.sqrt(i.re*i.re+i.im*i.im);return new a(Math.log2?Math.log2(o):Math.log(o)/Math.LN2,Math.atan2(i.im,i.re)/Math.LN2)}}),ux="matAlgo03xDSf",lx=["typed"],Yr=q(ux,lx,r=>{var{typed:e}=r;return function(a,n,i,o){var f=a._data,l=a._size,u=a._datatype,s=n._values,c=n._index,m=n._ptr,v=n._size,h=n._datatype;if(l.length!==v.length)throw new Ke(l.length,v.length);if(l[0]!==v[0]||l[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+v+")");if(!s)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var p=l[0],g=l[1],y,N=0,d=i;typeof u=="string"&&u===h&&(y=u,N=e.convert(0,y),d=e.find(i,[y,y]));for(var w=[],x=0;x<p;x++)w[x]=[];for(var b=[],E=[],A=0;A<g;A++){for(var S=A+1,D=m[A],T=m[A+1],B=D;B<T;B++){var I=c[B];b[I]=o?d(s[B],f[I][A]):d(f[I][A],s[B]),E[I]=S}for(var P=0;P<p;P++)E[P]===S?w[P][A]=b[P]:w[P][A]=o?d(N,f[P][A]):d(f[P][A],N)}return a.createDenseMatrix({data:w,size:[p,g],datatype:y})}}),cx="matAlgo05xSfSf",fx=["typed","equalScalar"],Ii=q(cx,fx,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o){var f=n._values,l=n._index,u=n._ptr,s=n._size,c=n._datatype,m=i._values,v=i._index,h=i._ptr,p=i._size,g=i._datatype;if(s.length!==p.length)throw new Ke(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");var y=s[0],N=s[1],d,w=t,x=0,b=o;typeof c=="string"&&c===g&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),b=e.find(o,[d,d]));var E=f&&m?[]:void 0,A=[],S=[],D=E?[]:void 0,T=E?[]:void 0,B=[],I=[],P,R,M,F;for(R=0;R<N;R++){S[R]=A.length;var H=R+1;for(M=u[R],F=u[R+1];M<F;M++)P=l[M],A.push(P),B[P]=H,D&&(D[P]=f[M]);for(M=h[R],F=h[R+1];M<F;M++)P=v[M],B[P]!==H&&A.push(P),I[P]=H,T&&(T[P]=m[M]);if(E)for(M=S[R];M<A.length;){P=A[M];var $=B[P],k=I[P];if($===H||k===H){var Q=$===H?D[P]:x,K=k===H?T[P]:x,L=b(Q,K);w(L,x)?A.splice(M,1):(E.push(L),M++)}}}return S[N]=A.length,n.createSparseMatrix({values:E,index:A,ptr:S,size:[y,N],datatype:d})}}),Cf="mod",mx=["typed","matrix","equalScalar","DenseMatrix","concat"],vx=q(Cf,mx,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n,concat:i}=r,o=wt({typed:e,equalScalar:a}),f=Yr({typed:e}),l=Ii({typed:e,equalScalar:a}),u=Lr({typed:e,equalScalar:a}),s=Ir({typed:e,DenseMatrix:n}),c=dr({typed:e,matrix:t,concat:i});return e(Cf,{"number, number":cc,"BigNumber, BigNumber":function(v,h){if(h.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return h.isZero()?v:v.mod(h)},"Fraction, Fraction":function(v,h){if(h.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return v.compare(0)>=0?v.mod(h):v.mod(h).add(h).mod(h)}},c({SS:l,DS:f,SD:o,Ss:u,sS:s}))}),px="multiplyScalar",hx=["typed"],dx=q(px,hx,r=>{var{typed:e}=r;return e("multiplyScalar",{"number, number":ec,"Complex, Complex":function(a,n){return a.mul(n)},"BigNumber, BigNumber":function(a,n){return a.times(n)},"Fraction, Fraction":function(a,n){return a.mul(n)},"number | Fraction | BigNumber | Complex, Unit":(t,a)=>a.multiply(t),"Unit, number | Fraction | BigNumber | Complex | Unit":(t,a)=>t.multiply(a)})}),Mf="multiply",gx=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],yx=q(Mf,gx,r=>{var{typed:e,matrix:t,addScalar:a,multiplyScalar:n,equalScalar:i,dot:o}=r,f=Lr({typed:e,equalScalar:i}),l=xt({typed:e});function u(x,b){switch(x.length){case 1:switch(b.length){case 1:if(x[0]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(x[0]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+x[0]+") must match Matrix rows ("+b[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+b.length+" dimensions)")}break;case 2:switch(b.length){case 1:if(x[1]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+x[1]+") must match Vector length ("+b[0]+")");break;case 2:if(x[1]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+x[1]+") must match Matrix B rows ("+b[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+b.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+x.length+" dimensions)")}}function s(x,b,E){if(E===0)throw new Error("Cannot multiply two empty vectors");return o(x,b)}function c(x,b){if(b.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return m(x,b)}function m(x,b){var E=x._data,A=x._size,S=x._datatype,D=b._data,T=b._size,B=b._datatype,I=A[0],P=T[1],R,M=a,F=n;S&&B&&S===B&&typeof S=="string"&&(R=S,M=e.find(a,[R,R]),F=e.find(n,[R,R]));for(var H=[],$=0;$<P;$++){for(var k=F(E[0],D[0][$]),Q=1;Q<I;Q++)k=M(k,F(E[Q],D[Q][$]));H[$]=k}return x.createDenseMatrix({data:H,size:[P],datatype:R})}var v=e("_multiplyMatrixVector",{"DenseMatrix, any":p,"SparseMatrix, any":N}),h=e("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":g,"DenseMatrix, SparseMatrix":y,"SparseMatrix, DenseMatrix":d,"SparseMatrix, SparseMatrix":w});function p(x,b){var E=x._data,A=x._size,S=x._datatype,D=b._data,T=b._datatype,B=A[0],I=A[1],P,R=a,M=n;S&&T&&S===T&&typeof S=="string"&&(P=S,R=e.find(a,[P,P]),M=e.find(n,[P,P]));for(var F=[],H=0;H<B;H++){for(var $=E[H],k=M($[0],D[0]),Q=1;Q<I;Q++)k=R(k,M($[Q],D[Q]));F[H]=k}return x.createDenseMatrix({data:F,size:[B],datatype:P})}function g(x,b){var E=x._data,A=x._size,S=x._datatype,D=b._data,T=b._size,B=b._datatype,I=A[0],P=A[1],R=T[1],M,F=a,H=n;S&&B&&S===B&&typeof S=="string"&&(M=S,F=e.find(a,[M,M]),H=e.find(n,[M,M]));for(var $=[],k=0;k<I;k++){var Q=E[k];$[k]=[];for(var K=0;K<R;K++){for(var L=H(Q[0],D[0][K]),j=1;j<P;j++)L=F(L,H(Q[j],D[j][K]));$[k][K]=L}}return x.createDenseMatrix({data:$,size:[I,R],datatype:M})}function y(x,b){var E=x._data,A=x._size,S=x._datatype,D=b._values,T=b._index,B=b._ptr,I=b._size,P=b._datatype;if(!D)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var R=A[0],M=I[1],F,H=a,$=n,k=i,Q=0;S&&P&&S===P&&typeof S=="string"&&(F=S,H=e.find(a,[F,F]),$=e.find(n,[F,F]),k=e.find(i,[F,F]),Q=e.convert(0,F));for(var K=[],L=[],j=[],ae=b.createSparseMatrix({values:K,index:L,ptr:j,size:[R,M],datatype:F}),re=0;re<M;re++){j[re]=L.length;var fe=B[re],he=B[re+1];if(he>fe)for(var ce=0,ie=0;ie<R;ie++){for(var Ae=ie+1,Oe=void 0,Ce=fe;Ce<he;Ce++){var $e=T[Ce];ce!==Ae?(Oe=$(E[ie][$e],D[Ce]),ce=Ae):Oe=H(Oe,$(E[ie][$e],D[Ce]))}ce===Ae&&!k(Oe,Q)&&(L.push(ie),K.push(Oe))}}return j[M]=L.length,ae}function N(x,b){var E=x._values,A=x._index,S=x._ptr,D=x._datatype;if(!E)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var T=b._data,B=b._datatype,I=x._size[0],P=b._size[0],R=[],M=[],F=[],H,$=a,k=n,Q=i,K=0;D&&B&&D===B&&typeof D=="string"&&(H=D,$=e.find(a,[H,H]),k=e.find(n,[H,H]),Q=e.find(i,[H,H]),K=e.convert(0,H));var L=[],j=[];F[0]=0;for(var ae=0;ae<P;ae++){var re=T[ae];if(!Q(re,K))for(var fe=S[ae],he=S[ae+1],ce=fe;ce<he;ce++){var ie=A[ce];j[ie]?L[ie]=$(L[ie],k(re,E[ce])):(j[ie]=!0,M.push(ie),L[ie]=k(re,E[ce]))}}for(var Ae=M.length,Oe=0;Oe<Ae;Oe++){var Ce=M[Oe];R[Oe]=L[Ce]}return F[1]=M.length,x.createSparseMatrix({values:R,index:M,ptr:F,size:[I,1],datatype:H})}function d(x,b){var E=x._values,A=x._index,S=x._ptr,D=x._datatype;if(!E)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var T=b._data,B=b._datatype,I=x._size[0],P=b._size[0],R=b._size[1],M,F=a,H=n,$=i,k=0;D&&B&&D===B&&typeof D=="string"&&(M=D,F=e.find(a,[M,M]),H=e.find(n,[M,M]),$=e.find(i,[M,M]),k=e.convert(0,M));for(var Q=[],K=[],L=[],j=x.createSparseMatrix({values:Q,index:K,ptr:L,size:[I,R],datatype:M}),ae=[],re=[],fe=0;fe<R;fe++){L[fe]=K.length;for(var he=fe+1,ce=0;ce<P;ce++){var ie=T[ce][fe];if(!$(ie,k))for(var Ae=S[ce],Oe=S[ce+1],Ce=Ae;Ce<Oe;Ce++){var $e=A[Ce];re[$e]!==he?(re[$e]=he,K.push($e),ae[$e]=H(ie,E[Ce])):ae[$e]=F(ae[$e],H(ie,E[Ce]))}}for(var V=L[fe],X=K.length,oe=V;oe<X;oe++){var G=K[oe];Q[oe]=ae[G]}}return L[R]=K.length,j}function w(x,b){var E=x._values,A=x._index,S=x._ptr,D=x._datatype,T=b._values,B=b._index,I=b._ptr,P=b._datatype,R=x._size[0],M=b._size[1],F=E&&T,H,$=a,k=n;D&&P&&D===P&&typeof D=="string"&&(H=D,$=e.find(a,[H,H]),k=e.find(n,[H,H]));for(var Q=F?[]:void 0,K=[],L=[],j=x.createSparseMatrix({values:Q,index:K,ptr:L,size:[R,M],datatype:H}),ae=F?[]:void 0,re=[],fe,he,ce,ie,Ae,Oe,Ce,$e,V=0;V<M;V++){L[V]=K.length;var X=V+1;for(Ae=I[V],Oe=I[V+1],ie=Ae;ie<Oe;ie++)if($e=B[ie],F)for(he=S[$e],ce=S[$e+1],fe=he;fe<ce;fe++)Ce=A[fe],re[Ce]!==X?(re[Ce]=X,K.push(Ce),ae[Ce]=k(T[ie],E[fe])):ae[Ce]=$(ae[Ce],k(T[ie],E[fe]));else for(he=S[$e],ce=S[$e+1],fe=he;fe<ce;fe++)Ce=A[fe],re[Ce]!==X&&(re[Ce]=X,K.push(Ce));if(F)for(var oe=L[V],G=K.length,Y=oe;Y<G;Y++){var te=K[Y];Q[Y]=ae[te]}}return L[M]=K.length,j}return e(Mf,n,{"Array, Array":e.referTo("Matrix, Matrix",x=>(b,E)=>{u(er(b),er(E));var A=x(t(b),t(E));return Ve(A)?A.valueOf():A}),"Matrix, Matrix":function(b,E){var A=b.size(),S=E.size();return u(A,S),A.length===1?S.length===1?s(b,E,A[0]):c(b,E):S.length===1?v(b,E):h(b,E)},"Matrix, Array":e.referTo("Matrix,Matrix",x=>(b,E)=>x(b,t(E))),"Array, Matrix":e.referToSelf(x=>(b,E)=>x(t(b,E.storage()),E)),"SparseMatrix, any":function(b,E){return f(b,E,n,!1)},"DenseMatrix, any":function(b,E){return l(b,E,n,!1)},"any, SparseMatrix":function(b,E){return f(E,b,n,!0)},"any, DenseMatrix":function(b,E){return l(E,b,n,!0)},"Array, any":function(b,E){return l(t(b),E,n,!1).valueOf()},"any, Array":function(b,E){return l(t(E),b,n,!0).valueOf()},"any, any":n,"any, any, ...any":e.referToSelf(x=>(b,E,A)=>{for(var S=x(b,E),D=0;D<A.length;D++)S=x(S,A[D]);return S})})}),Ff="nthRoot",bx=["typed","matrix","equalScalar","BigNumber","concat"],xx=q(Ff,bx,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n,concat:i}=r,o=mn({typed:e}),f=wt({typed:e,equalScalar:a}),l=Oi({typed:e,equalScalar:a}),u=Lr({typed:e,equalScalar:a}),s=dr({typed:e,matrix:t,concat:i});function c(){throw new Error("Complex number not supported in function nthRoot. Use nthRoots instead.")}return e(Ff,{number:fc,"number, number":fc,BigNumber:v=>m(v,new n(2)),"BigNumber, BigNumber":m,Complex:c,"Complex, number":c,Array:e.referTo("DenseMatrix,number",v=>h=>v(t(h),2).valueOf()),DenseMatrix:e.referTo("DenseMatrix,number",v=>h=>v(h,2)),SparseMatrix:e.referTo("SparseMatrix,number",v=>h=>v(h,2)),"SparseMatrix, SparseMatrix":e.referToSelf(v=>(h,p)=>{if(p.density()===1)return l(h,p,v);throw new Error("Root must be non-zero")}),"DenseMatrix, SparseMatrix":e.referToSelf(v=>(h,p)=>{if(p.density()===1)return o(h,p,v,!1);throw new Error("Root must be non-zero")}),"Array, SparseMatrix":e.referTo("DenseMatrix,SparseMatrix",v=>(h,p)=>v(t(h),p)),"number | BigNumber, SparseMatrix":e.referToSelf(v=>(h,p)=>{if(p.density()===1)return u(p,h,v,!0);throw new Error("Root must be non-zero")})},s({scalar:"number | BigNumber",SD:f,Ss:u,sS:!1}));function m(v,h){var p=n.precision,g=n.clone({precision:p+2}),y=new n(0),N=new g(1),d=h.isNegative();if(d&&(h=h.neg()),h.isZero())throw new Error("Root must be non-zero");if(v.isNegative()&&!h.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(v.isZero())return d?new g(1/0):0;if(!v.isFinite())return d?y:v;var w=v.abs().pow(N.div(h));return w=v.isNeg()?w.neg():w,new n((d?N.div(w):w).toPrecision(p))}}),Tf="sign",wx=["typed","BigNumber","Fraction","complex"],Nx=q(Tf,wx,r=>{var{typed:e,BigNumber:t,complex:a,Fraction:n}=r;return e(Tf,{number:os,Complex:function(o){return o.im===0?a(os(o.re)):o.sign()},BigNumber:function(o){return new t(o.cmp(0))},Fraction:function(o){return new n(o.s,1)},"Array | Matrix":e.referToSelf(i=>o=>je(o,i)),Unit:e.referToSelf(i=>o=>{if(!o._isDerived()&&o.units[0].unit.offset!==0)throw new TypeError("sign is ambiguous for units with offset");return e.find(i,o.valueType())(o.value)})})}),Dx="sqrt",Ax=["config","typed","Complex"],Ex=q(Dx,Ax,r=>{var{config:e,typed:t,Complex:a}=r;return t("sqrt",{number:n,Complex:function(o){return o.sqrt()},BigNumber:function(o){return!o.isNegative()||e.predictable?o.sqrt():n(o.toNumber())},Unit:function(o){return o.pow(.5)}});function n(i){return isNaN(i)?NaN:i>=0||e.predictable?Math.sqrt(i):new a(i,0).sqrt()}}),Bf="square",Sx=["typed"],Cx=q(Bf,Sx,r=>{var{typed:e}=r;return e(Bf,{number:mc,Complex:function(a){return a.mul(a)},BigNumber:function(a){return a.times(a)},Fraction:function(a){return a.mul(a)},Unit:function(a){return a.pow(2)}})}),$f="subtract",Mx=["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix","concat"],Fx=q($f,Mx,r=>{var{typed:e,matrix:t,equalScalar:a,addScalar:n,unaryMinus:i,DenseMatrix:o,concat:f}=r,l=mn({typed:e}),u=Yr({typed:e}),s=Ii({typed:e,equalScalar:a}),c=Tn({typed:e,DenseMatrix:o}),m=Ir({typed:e,DenseMatrix:o}),v=dr({typed:e,matrix:t,concat:f});return e($f,{"number, number":(h,p)=>h-p,"Complex, Complex":(h,p)=>h.sub(p),"BigNumber, BigNumber":(h,p)=>h.minus(p),"Fraction, Fraction":(h,p)=>h.sub(p),"Unit, Unit":e.referToSelf(h=>(p,g)=>{if(p.value===null)throw new Error("Parameter x contains a unit with undefined value");if(g.value===null)throw new Error("Parameter y contains a unit with undefined value");if(!p.equalBase(g))throw new Error("Units do not match");var y=p.clone();return y.value=e.find(h,[y.valueType(),g.valueType()])(y.value,g.value),y.fixPrefix=!1,y})},v({SS:s,DS:l,SD:u,Ss:m,sS:c}))}),Of="xgcd",Tx=["typed","config","matrix","BigNumber"],Bx=q(Of,Tx,r=>{var{typed:e,config:t,matrix:a,BigNumber:n}=r;return e(Of,{"number, number":function(f,l){var u=vc(f,l);return t.matrix==="Array"?u:a(u)},"BigNumber, BigNumber":i});function i(o,f){var l,u,s,c=new n(0),m=new n(1),v=c,h=m,p=m,g=c;if(!o.isInt()||!f.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!f.isZero();)u=o.div(f).floor(),s=o.mod(f),l=v,v=h.minus(u.times(v)),h=l,l=p,p=g.minus(u.times(p)),g=l,o=f,f=s;var y;return o.lt(c)?y=[o.neg(),h.neg(),g.neg()]:y=[o,o.isZero()?0:h,g],t.matrix==="Array"?y:a(y)}}),If="invmod",$x=["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],Ox=q(If,$x,r=>{var{typed:e,config:t,BigNumber:a,xgcd:n,equal:i,smaller:o,mod:f,add:l,isInteger:u}=r;return e(If,{"number, number":s,"BigNumber, BigNumber":s});function s(c,m){if(!u(c)||!u(m))throw new Error("Parameters in function invmod must be integer numbers");if(c=f(c,m),i(m,0))throw new Error("Divisor must be non zero");var v=n(c,m);v=v.valueOf();var[h,p]=v;return i(h,a(1))?(p=f(p,m),o(p,a(0))&&(p=l(p,m)),p):NaN}}),Ix="matAlgo09xS0Sf",Rx=["typed","equalScalar"],Rf=q(Ix,Rx,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o){var f=n._values,l=n._index,u=n._ptr,s=n._size,c=n._datatype,m=i._values,v=i._index,h=i._ptr,p=i._size,g=i._datatype;if(s.length!==p.length)throw new Ke(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");var y=s[0],N=s[1],d,w=t,x=0,b=o;typeof c=="string"&&c===g&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),b=e.find(o,[d,d]));var E=f&&m?[]:void 0,A=[],S=[],D=E?[]:void 0,T=[],B,I,P,R,M;for(I=0;I<N;I++){S[I]=A.length;var F=I+1;if(D)for(R=h[I],M=h[I+1],P=R;P<M;P++)B=v[P],T[B]=F,D[B]=m[P];for(R=u[I],M=u[I+1],P=R;P<M;P++)if(B=l[P],D){var H=T[B]===F?D[B]:x,$=b(f[P],H);w($,x)||(A.push(B),E.push($))}else A.push(B)}return S[N]=A.length,n.createSparseMatrix({values:E,index:A,ptr:S,size:[y,N],datatype:d})}}),_f="dotMultiply",_x=["typed","matrix","equalScalar","multiplyScalar","concat"],qx=q(_f,_x,r=>{var{typed:e,matrix:t,equalScalar:a,multiplyScalar:n,concat:i}=r,o=wt({typed:e,equalScalar:a}),f=Rf({typed:e,equalScalar:a}),l=Lr({typed:e,equalScalar:a}),u=dr({typed:e,matrix:t,concat:i});return e(_f,u({elop:n,SS:f,DS:o,Ss:l}))});function zx(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function bitAnd");var t=r.constructor;if(r.isNaN()||e.isNaN())return new t(NaN);if(r.isZero()||e.eq(-1)||r.eq(e))return r;if(e.isZero()||r.eq(-1))return e;if(!r.isFinite()||!e.isFinite()){if(!r.isFinite()&&!e.isFinite())return r.isNegative()===e.isNegative()?r:new t(0);if(!r.isFinite())return e.isNegative()?r:r.isNegative()?new t(0):e;if(!e.isFinite())return r.isNegative()?e:e.isNegative()?new t(0):r}return vs(r,e,function(a,n){return a&n})}function Ha(r){if(r.isFinite()&&!r.isInteger())throw new Error("Integer expected in function bitNot");var e=r.constructor,t=e.precision;e.config({precision:1e9});var a=r.plus(new e(1));return a.s=-a.s||null,e.config({precision:t}),a}function Px(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function bitOr");var t=r.constructor;if(r.isNaN()||e.isNaN())return new t(NaN);var a=new t(-1);return r.isZero()||e.eq(a)||r.eq(e)?e:e.isZero()||r.eq(a)?r:!r.isFinite()||!e.isFinite()?!r.isFinite()&&!r.isNegative()&&e.isNegative()||r.isNegative()&&!e.isNegative()&&!e.isFinite()?a:r.isNegative()&&e.isNegative()?r.isFinite()?r:e:r.isFinite()?e:r:vs(r,e,function(n,i){return n|i})}function vs(r,e,t){var a=r.constructor,n,i,o=+(r.s<0),f=+(e.s<0);if(o){n=Ri(Ha(r));for(var l=0;l<n.length;++l)n[l]^=1}else n=Ri(r);if(f){i=Ri(Ha(e));for(var u=0;u<i.length;++u)i[u]^=1}else i=Ri(e);var s,c,m;n.length<=i.length?(s=n,c=i,m=o):(s=i,c=n,m=f);var v=s.length,h=c.length,p=t(o,f)^1,g=new a(p^1),y=new a(1),N=new a(2),d=a.precision;for(a.config({precision:1e9});v>0;)t(s[--v],c[--h])===p&&(g=g.plus(y)),y=y.times(N);for(;h>0;)t(m,c[--h])===p&&(g=g.plus(y)),y=y.times(N);return a.config({precision:d}),p===0&&(g.s=-g.s),g}function Ri(r){for(var e=r.d,t=e[0]+"",a=1;a<e.length;++a){for(var n=e[a]+"",i=7-n.length;i--;)n="0"+n;t+=n}for(var o=t.length;t.charAt(o)==="0";)o--;var f=r.e,l=t.slice(0,o+1||1),u=l.length;if(f>0)if(++f>u)for(f-=u;f--;)l+="0";else f<u&&(l=l.slice(0,f)+"."+l.slice(f));for(var s=[0],c=0;c<l.length;){for(var m=s.length;m--;)s[m]*=10;s[0]+=parseInt(l.charAt(c++));for(var v=0;v<s.length;++v)s[v]>1&&((s[v+1]===null||s[v+1]===void 0)&&(s[v+1]=0),s[v+1]+=s[v]>>1,s[v]&=1)}return s.reverse()}function Ux(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function bitXor");var t=r.constructor;if(r.isNaN()||e.isNaN())return new t(NaN);if(r.isZero())return e;if(e.isZero())return r;if(r.eq(e))return new t(0);var a=new t(-1);return r.eq(a)?Ha(e):e.eq(a)?Ha(r):!r.isFinite()||!e.isFinite()?!r.isFinite()&&!e.isFinite()?a:new t(r.isNegative()===e.isNegative()?1/0:-1/0):vs(r,e,function(n,i){return n^i})}function Lx(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function leftShift");var t=r.constructor;return r.isNaN()||e.isNaN()||e.isNegative()&&!e.isZero()?new t(NaN):r.isZero()||e.isZero()?r:!r.isFinite()&&!e.isFinite()?new t(NaN):e.lt(55)?r.times(Math.pow(2,e.toNumber())+""):r.times(new t(2).pow(e))}function kx(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function rightArithShift");var t=r.constructor;return r.isNaN()||e.isNaN()||e.isNegative()&&!e.isZero()?new t(NaN):r.isZero()||e.isZero()?r:e.isFinite()?e.lt(55)?r.div(Math.pow(2,e.toNumber())+"").floor():r.div(new t(2).pow(e)).floor():r.isNegative()?new t(-1):r.isFinite()?new t(0):new t(NaN)}var qf="bitAnd",Vx=["typed","matrix","equalScalar","concat"],Gx=q(qf,Vx,r=>{var{typed:e,matrix:t,equalScalar:a,concat:n}=r,i=wt({typed:e,equalScalar:a}),o=Oi({typed:e,equalScalar:a}),f=Lr({typed:e,equalScalar:a}),l=dr({typed:e,matrix:t,concat:n});return e(qf,{"number, number":dc,"BigNumber, BigNumber":zx},l({SS:o,DS:i,Ss:f}))}),zf="bitNot",Hx=["typed"],Zx=q(zf,Hx,r=>{var{typed:e}=r;return e(zf,{number:gc,BigNumber:Ha,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Pf="bitOr",Jx=["typed","matrix","equalScalar","DenseMatrix","concat"],Xx=q(Pf,Jx,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n,concat:i}=r,o=mn({typed:e}),f=fs({typed:e,equalScalar:a}),l=Tn({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:t,concat:i});return e(Pf,{"number, number":yc,"BigNumber, BigNumber":Px},u({SS:f,DS:o,Ss:l}))}),Wx="matAlgo07xSSf",Yx=["typed","DenseMatrix"],$t=q(Wx,Yx,r=>{var{typed:e,DenseMatrix:t}=r;return function(i,o,f){var l=i._size,u=i._datatype,s=o._size,c=o._datatype;if(l.length!==s.length)throw new Ke(l.length,s.length);if(l[0]!==s[0]||l[1]!==s[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+s+")");var m=l[0],v=l[1],h,p=0,g=f;typeof u=="string"&&u===c&&(h=u,p=e.convert(0,h),g=e.find(f,[h,h]));var y,N,d=[];for(y=0;y<m;y++)d[y]=[];var w=[],x=[],b=[],E=[];for(N=0;N<v;N++){var A=N+1;for(a(i,N,b,w,A),a(o,N,E,x,A),y=0;y<m;y++){var S=b[y]===A?w[y]:p,D=E[y]===A?x[y]:p;d[y][N]=g(S,D)}}return new t({data:d,size:[m,v],datatype:h})};function a(n,i,o,f,l){for(var u=n._values,s=n._index,c=n._ptr,m=c[i],v=c[i+1];m<v;m++){var h=s[m];o[h]=l,f[h]=u[m]}}}),Uf="bitXor",Qx=["typed","matrix","DenseMatrix","concat"],Kx=q(Uf,Qx,r=>{var{typed:e,matrix:t,DenseMatrix:a,concat:n}=r,i=Yr({typed:e}),o=$t({typed:e,DenseMatrix:a}),f=Ir({typed:e,DenseMatrix:a}),l=dr({typed:e,matrix:t,concat:n});return e(Uf,{"number, number":bc,"BigNumber, BigNumber":Ux},l({SS:o,DS:i,Ss:f}))}),Lf="arg",jx=["typed"],ew=q(Lf,jx,r=>{var{typed:e}=r;return e(Lf,{number:function(a){return Math.atan2(0,a)},BigNumber:function(a){return a.constructor.atan2(0,a)},Complex:function(a){return a.arg()},"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),kf="conj",rw=["typed"],tw=q(kf,rw,r=>{var{typed:e}=r;return e(kf,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.conjugate(),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Vf="im",nw=["typed"],aw=q(Vf,nw,r=>{var{typed:e}=r;return e(Vf,{number:()=>0,"BigNumber | Fraction":t=>t.mul(0),Complex:t=>t.im,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Gf="re",iw=["typed"],ow=q(Gf,iw,r=>{var{typed:e}=r;return e(Gf,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.re,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Hf="not",sw=["typed"],uw=q(Hf,sw,r=>{var{typed:e}=r;return e(Hf,{"null | undefined":()=>!0,number:Ac,Complex:function(a){return a.re===0&&a.im===0},BigNumber:function(a){return a.isZero()||a.isNaN()},Unit:e.referToSelf(t=>a=>e.find(t,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Zf="or",lw=["typed","matrix","equalScalar","DenseMatrix","concat"],cw=q(Zf,lw,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n,concat:i}=r,o=Yr({typed:e}),f=Ii({typed:e,equalScalar:a}),l=Ir({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:t,concat:i});return e(Zf,{"number, number":Ec,"Complex, Complex":function(c,m){return c.re!==0||c.im!==0||m.re!==0||m.im!==0},"BigNumber, BigNumber":function(c,m){return!c.isZero()&&!c.isNaN()||!m.isZero()&&!m.isNaN()},"Unit, Unit":e.referToSelf(s=>(c,m)=>s(c.value||0,m.value||0))},u({SS:f,DS:o,Ss:l}))}),Jf="xor",fw=["typed","matrix","DenseMatrix","concat"],mw=q(Jf,fw,r=>{var{typed:e,matrix:t,DenseMatrix:a,concat:n}=r,i=Yr({typed:e}),o=$t({typed:e,DenseMatrix:a}),f=Ir({typed:e,DenseMatrix:a}),l=dr({typed:e,matrix:t,concat:n});return e(Jf,{"number, number":Sc,"Complex, Complex":function(s,c){return(s.re!==0||s.im!==0)!=(c.re!==0||c.im!==0)},"BigNumber, BigNumber":function(s,c){return(!s.isZero()&&!s.isNaN())!=(!c.isZero()&&!c.isNaN())},"Unit, Unit":e.referToSelf(u=>(s,c)=>u(s.value||0,c.value||0))},l({SS:o,DS:i,Ss:f}))}),Xf="concat",vw=["typed","matrix","isInteger"],Wf=q(Xf,vw,r=>{var{typed:e,matrix:t,isInteger:a}=r;return e(Xf,{"...Array | Matrix | number | BigNumber":function(i){var o,f=i.length,l=-1,u,s=!1,c=[];for(o=0;o<f;o++){var m=i[o];if(Ve(m)&&(s=!0),tr(m)||rr(m)){if(o!==f-1)throw new Error("Dimension must be specified as last argument");if(u=l,l=m.valueOf(),!a(l))throw new TypeError("Integer number expected for dimension");if(l<0||o>0&&l>u)throw new dt(l,u+1)}else{var v=Ge(m).valueOf(),h=er(v);if(c[o]=v,u=l,l=h.length-1,o>0&&l!==u)throw new Ke(u+1,l+1)}}if(c.length===0)throw new SyntaxError("At least one matrix expected");for(var p=c.shift();c.length;)p=Yf(p,c.shift(),l,0);return s?t(p):p},"...string":function(i){return i.join("")}})});function Yf(r,e,t,a){if(a<t){if(r.length!==e.length)throw new Ke(r.length,e.length);for(var n=[],i=0;i<r.length;i++)n[i]=Yf(r[i],e[i],t,a+1);return n}else return r.concat(e)}var Qf="column",pw=["typed","Index","matrix","range"],Kf=q(Qf,pw,r=>{var{typed:e,Index:t,matrix:a,range:n}=r;return e(Qf,{"Matrix, number":i,"Array, number":function(f,l){return i(a(Ge(f)),l).valueOf()}});function i(o,f){if(o.size().length!==2)throw new Error("Only two dimensional matrix is supported");vr(f,o.size()[1]);var l=n(0,o.size()[0]),u=new t(l,f),s=o.subset(u);return Ve(s)?s:a([[s]])}}),jf="count",hw=["typed","size","prod"],dw=q(jf,hw,r=>{var{typed:e,size:t,prod:a}=r;return e(jf,{string:function(i){return i.length},"Matrix | Array":function(i){return a(t(i))}})}),em="cross",gw=["typed","matrix","subtract","multiply"],yw=q(em,gw,r=>{var{typed:e,matrix:t,subtract:a,multiply:n}=r;return e(em,{"Matrix, Matrix":function(f,l){return t(i(f.toArray(),l.toArray()))},"Matrix, Array":function(f,l){return t(i(f.toArray(),l))},"Array, Matrix":function(f,l){return t(i(f,l.toArray()))},"Array, Array":i});function i(o,f){var l=Math.max(er(o).length,er(f).length);o=pi(o),f=pi(f);var u=er(o),s=er(f);if(u.length!==1||s.length!==1||u[0]!==3||s[0]!==3)throw new RangeError("Vectors with length 3 expected (Size A = ["+u.join(", ")+"], B = ["+s.join(", ")+"])");var c=[a(n(o[1],f[2]),n(o[2],f[1])),a(n(o[2],f[0]),n(o[0],f[2])),a(n(o[0],f[1]),n(o[1],f[0]))];return l>1?[c]:c}}),rm="diag",bw=["typed","matrix","DenseMatrix","SparseMatrix"],xw=q(rm,bw,r=>{var{typed:e,matrix:t,DenseMatrix:a,SparseMatrix:n}=r;return e(rm,{Array:function(u){return i(u,0,er(u),null)},"Array, number":function(u,s){return i(u,s,er(u),null)},"Array, BigNumber":function(u,s){return i(u,s.toNumber(),er(u),null)},"Array, string":function(u,s){return i(u,0,er(u),s)},"Array, number, string":function(u,s,c){return i(u,s,er(u),c)},"Array, BigNumber, string":function(u,s,c){return i(u,s.toNumber(),er(u),c)},Matrix:function(u){return i(u,0,u.size(),u.storage())},"Matrix, number":function(u,s){return i(u,s,u.size(),u.storage())},"Matrix, BigNumber":function(u,s){return i(u,s.toNumber(),u.size(),u.storage())},"Matrix, string":function(u,s){return i(u,0,u.size(),s)},"Matrix, number, string":function(u,s,c){return i(u,s,u.size(),c)},"Matrix, BigNumber, string":function(u,s,c){return i(u,s.toNumber(),u.size(),c)}});function i(l,u,s,c){if(!qe(u))throw new TypeError("Second parameter in function diag must be an integer");var m=u>0?u:0,v=u<0?-u:0;switch(s.length){case 1:return o(l,u,c,s[0],v,m);case 2:return f(l,u,c,s,v,m)}throw new RangeError("Matrix for function diag must be 2 dimensional")}function o(l,u,s,c,m,v){var h=[c+m,c+v];if(s&&s!=="sparse"&&s!=="dense")throw new TypeError("Unknown matrix type ".concat(s,'"'));var p=s==="sparse"?n.diagonal(h,l,u):a.diagonal(h,l,u);return s!==null?p:p.valueOf()}function f(l,u,s,c,m,v){if(Ve(l)){var h=l.diagonal(u);return s!==null?s!==h.storage()?t(h,s):h:h.valueOf()}for(var p=Math.min(c[0]-m,c[1]-v),g=[],y=0;y<p;y++)g[y]=l[y+m][y+v];return s!==null?t(g):g}}),ww="filter",Nw=["typed"],Dw=q(ww,Nw,r=>{var{typed:e}=r;return e("filter",{"Array, function":tm,"Matrix, function":function(a,n){return a.create(tm(a.toArray(),n))},"Array, RegExp":di,"Matrix, RegExp":function(a,n){return a.create(di(a.toArray(),n))}})});function tm(r,e){var t=fn(e);return Sl(r,function(a,n,i){return t===1?e(a):t===2?e(a,[n]):e(a,[n],i)})}var nm="flatten",Aw=["typed","matrix"],Ew=q(nm,Aw,r=>{var{typed:e,matrix:t}=r;return e(nm,{Array:function(n){return or(n)},Matrix:function(n){var i=or(n.toArray());return t(i)}})}),am="forEach",Sw=["typed"],Cw=q(am,Sw,r=>{var{typed:e}=r;return e(am,{"Array, function":Mw,"Matrix, function":function(a,n){a.forEach(n)}})});function Mw(r,e){var t=fn(e),a=function n(i,o){Array.isArray(i)?hi(i,function(f,l){n(f,o.concat(l))}):t===1?e(i):t===2?e(i,o):e(i,o,r)};a(r,[])}var im="getMatrixDataType",Fw=["typed"],Tw=q(im,Fw,r=>{var{typed:e}=r;return e(im,{Array:function(a){return La(a,br)},Matrix:function(a){return a.getDataType()}})}),om="identity",Bw=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],$w=q(om,Bw,r=>{var{typed:e,config:t,matrix:a,BigNumber:n,DenseMatrix:i,SparseMatrix:o}=r;return e(om,{"":function(){return t.matrix==="Matrix"?a([]):[]},string:function(s){return a(s)},"number | BigNumber":function(s){return l(s,s,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(s,c){return l(s,s,c)},"number | BigNumber, number | BigNumber":function(s,c){return l(s,c,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(s,c,m){return l(s,c,m)},Array:function(s){return f(s)},"Array, string":function(s,c){return f(s,c)},Matrix:function(s){return f(s.valueOf(),s.storage())},"Matrix, string":function(s,c){return f(s.valueOf(),c)}});function f(u,s){switch(u.length){case 0:return s?a(s):[];case 1:return l(u[0],u[0],s);case 2:return l(u[0],u[1],s);default:throw new Error("Vector containing two values expected")}}function l(u,s,c){var m=rr(u)||rr(s)?n:null;if(rr(u)&&(u=u.toNumber()),rr(s)&&(s=s.toNumber()),!qe(u)||u<1)throw new Error("Parameters in function identity must be positive integers");if(!qe(s)||s<1)throw new Error("Parameters in function identity must be positive integers");var v=m?new n(1):1,h=m?new m(0):0,p=[u,s];if(c){if(c==="sparse")return o.diagonal(p,v,0,h);if(c==="dense")return i.diagonal(p,v,0,h);throw new TypeError('Unknown matrix type "'.concat(c,'"'))}for(var g=Qn([],p,h),y=u<s?u:s,N=0;N<y;N++)g[N][N]=v;return g}}),sm="kron",Ow=["typed","matrix","multiplyScalar"],Iw=q(sm,Ow,r=>{var{typed:e,matrix:t,multiplyScalar:a}=r;return e(sm,{"Matrix, Matrix":function(o,f){return t(n(o.toArray(),f.toArray()))},"Matrix, Array":function(o,f){return t(n(o.toArray(),f))},"Array, Matrix":function(o,f){return t(n(o,f.toArray()))},"Array, Array":n});function n(i,o){if(er(i).length===1&&(i=[i]),er(o).length===1&&(o=[o]),er(i).length>2||er(o).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(i.length)+", y = "+JSON.stringify(o.length)+")");var f=[],l=[];return i.map(function(u){return o.map(function(s){return l=[],f.push(l),u.map(function(c){return s.map(function(m){return l.push(a(c,m))})})})})&&f}}),um="map",Rw=["typed"],_w=q(um,Rw,r=>{var{typed:e}=r;return e(um,{"Array, function":qw,"Matrix, function":function(a,n){return a.map(n)}})});function qw(r,e){var t=fn(e),a=function n(i,o){if(Array.isArray(i))return i.map(function(u,s){return n(u,o.concat(s))});try{return t===1?e(i):t===2?e(i,o):e(i,o,r)}catch(u){if(u instanceof TypeError&&"data"in u&&u.data.category==="wrongType"){var f="map attempted to call '".concat(u.data.fn,"(").concat(i),l=JSON.stringify(o);throw t===2?f+=","+l:t!==1&&(f+=",".concat(l,",").concat(r)),f+=")' but argument ".concat(u.data.index+1," of type "),f+="".concat(u.data.actual," does not match expected type "),f+=u.data.expected.join(" or "),new TypeError(f)}throw u}};return a(r,[])}var lm="diff",zw=["typed","matrix","subtract","number"],cm=q(lm,zw,r=>{var{typed:e,matrix:t,subtract:a,number:n}=r;return e(lm,{"Array | Matrix":function(s){return Ve(s)?t(o(s.toArray())):o(s)},"Array | Matrix, number":function(s,c){if(!qe(c))throw new RangeError("Dimension must be a whole number");return Ve(s)?t(i(s.toArray(),c)):i(s,c)},"Array, BigNumber":e.referTo("Array,number",u=>(s,c)=>u(s,n(c))),"Matrix, BigNumber":e.referTo("Matrix,number",u=>(s,c)=>u(s,n(c)))});function i(u,s){if(Ve(u)&&(u=u.toArray()),!Array.isArray(u))throw RangeError("Array/Matrix does not have that many dimensions");if(s>0){var c=[];return u.forEach(m=>{c.push(i(m,s-1))}),c}else{if(s===0)return o(u);throw RangeError("Cannot have negative dimension")}}function o(u){for(var s=[],c=u.length,m=1;m<c;m++)s.push(f(u[m-1],u[m]));return s}function f(u,s){Ve(u)&&(u=u.toArray()),Ve(s)&&(s=s.toArray());var c=Array.isArray(u),m=Array.isArray(s);if(c&&m)return l(u,s);if(!c&&!m)return a(s,u);throw TypeError("Cannot calculate difference between 1 array and 1 non-array")}function l(u,s){if(u.length!==s.length)throw RangeError("Not all sub-arrays have the same length");for(var c=[],m=u.length,v=0;v<m;v++)c.push(f(u[v],s[v]));return c}}),Pw="ones",Uw=["typed","config","matrix","BigNumber"],Lw=q(Pw,Uw,r=>{var{typed:e,config:t,matrix:a,BigNumber:n}=r;return e("ones",{"":function(){return t.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(u){var s=u[u.length-1];if(typeof s=="string"){var c=u.pop();return i(u,c)}else return t.matrix==="Array"?i(u):i(u,"default")},Array:i,Matrix:function(u){var s=u.storage();return i(u.valueOf(),s)},"Array | Matrix, string":function(u,s){return i(u.valueOf(),s)}});function i(l,u){var s=o(l),c=s?new n(1):1;if(f(l),u){var m=a(u);return l.length>0?m.resize(l,c):m}else{var v=[];return l.length>0?Qn(v,l,c):v}}function o(l){var u=!1;return l.forEach(function(s,c,m){rr(s)&&(u=!0,m[c]=s.toNumber())}),u}function f(l){l.forEach(function(u){if(typeof u!="number"||!qe(u)||u<0)throw new Error("Parameters in function ones must be positive integers")})}});function ps(){throw new Error('No "bignumber" implementation available')}function fm(){throw new Error('No "fraction" implementation available')}function mm(){throw new Error('No "matrix" implementation available')}var vm="range",kw=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],pm=q(vm,kw,r=>{var{typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:o,larger:f,largerEq:l}=r;return e(vm,{string:s,"string, boolean":s,"number, number":function(y,N){return u(c(y,N,1))},"number, number, number":function(y,N,d){return u(c(y,N,d))},"number, number, boolean":function(y,N,d){return u(d?m(y,N,1):c(y,N,1))},"number, number, number, boolean":function(y,N,d,w){return u(w?m(y,N,d):c(y,N,d))},"BigNumber, BigNumber":function(y,N){var d=y.constructor;return u(v(y,N,new d(1)))},"BigNumber, BigNumber, BigNumber":function(y,N,d){return u(v(y,N,d))},"BigNumber, BigNumber, boolean":function(y,N,d){var w=y.constructor;return u(d?h(y,N,new w(1)):v(y,N,new w(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(y,N,d,w){return u(w?h(y,N,d):v(y,N,d))}});function u(g){return t.matrix==="Matrix"?a?a(g):mm():g}function s(g,y){var N=p(g);if(!N)throw new SyntaxError('String "'+g+'" is no valid range');var d;return t.number==="BigNumber"?(n===void 0&&ps(),d=y?h:v,u(d(n(N.start),n(N.end),n(N.step)))):(d=y?m:c,u(d(N.start,N.end,N.step)))}function c(g,y,N){var d=[],w=g;if(N>0)for(;i(w,y);)d.push(w),w+=N;else if(N<0)for(;f(w,y);)d.push(w),w+=N;return d}function m(g,y,N){var d=[],w=g;if(N>0)for(;o(w,y);)d.push(w),w+=N;else if(N<0)for(;l(w,y);)d.push(w),w+=N;return d}function v(g,y,N){var d=n(0),w=[],x=g;if(N.gt(d))for(;i(x,y);)w.push(x),x=x.plus(N);else if(N.lt(d))for(;f(x,y);)w.push(x),x=x.plus(N);return w}function h(g,y,N){var d=n(0),w=[],x=g;if(N.gt(d))for(;o(x,y);)w.push(x),x=x.plus(N);else if(N.lt(d))for(;l(x,y);)w.push(x),x=x.plus(N);return w}function p(g){var y=g.split(":"),N=y.map(function(w){return Number(w)}),d=N.some(function(w){return isNaN(w)});if(d)return null;switch(N.length){case 2:return{start:N[0],end:N[1],step:1};case 3:return{start:N[0],end:N[2],step:N[1]};default:return null}}}),hm="reshape",Vw=["typed","isInteger","matrix"],Gw=q(hm,Vw,r=>{var{typed:e,isInteger:t}=r;return e(hm,{"Matrix, Array":function(n,i){return n.reshape(i,!0)},"Array, Array":function(n,i){return i.forEach(function(o){if(!t(o))throw new TypeError("Invalid size for dimension: "+o)}),wl(n,i)}})}),Hw="resize",Zw=["config","matrix"],Jw=q(Hw,Zw,r=>{var{config:e,matrix:t}=r;return function(i,o,f){if(arguments.length!==2&&arguments.length!==3)throw new Bn("resize",arguments.length,2,3);if(Ve(o)&&(o=o.valueOf()),rr(o[0])&&(o=o.map(function(s){return rr(s)?s.toNumber():s})),Ve(i))return i.resize(o,f,!0);if(typeof i=="string")return a(i,o,f);var l=Array.isArray(i)?!1:e.matrix!=="Array";if(o.length===0){for(;Array.isArray(i);)i=i[0];return Ge(i)}else{Array.isArray(i)||(i=[i]),i=Ge(i);var u=Qn(i,o,f);return l?t(u):u}};function a(n,i,o){if(o!==void 0){if(typeof o!="string"||o.length!==1)throw new TypeError("Single character expected as defaultValue")}else o=" ";if(i.length!==1)throw new Ke(i.length,1);var f=i[0];if(typeof f!="number"||!qe(f))throw new TypeError("Invalid size, must contain positive integers (size: "+Ye(i)+")");if(n.length>f)return n.substring(0,f);if(n.length<f){for(var l=n,u=0,s=f-n.length;u<s;u++)l+=o;return l}else return n}}),dm="rotate",Xw=["typed","multiply","rotationMatrix"],Ww=q(dm,Xw,r=>{var{typed:e,multiply:t,rotationMatrix:a}=r;return e(dm,{"Array , number | BigNumber | Complex | Unit":function(o,f){n(o,2);var l=t(a(f),o);return l.toArray()},"Matrix , number | BigNumber | Complex | Unit":function(o,f){return n(o,2),t(a(f),o)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(o,f,l){n(o,3);var u=t(a(f,l),o);return u},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(o,f,l){return n(o,3),t(a(f,l),o)}});function n(i,o){var f=Array.isArray(i)?er(i):i.size();if(f.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(o));if(f.length===2&&f[1]!==1)throw new RangeError("Vector must be of dimensions 1x".concat(o));if(f[0]!==o)throw new RangeError("Vector must be of dimensions 1x".concat(o))}}),gm="rotationMatrix",Yw=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],Qw=q(gm,Yw,r=>{var{typed:e,config:t,multiplyScalar:a,addScalar:n,unaryMinus:i,norm:o,BigNumber:f,matrix:l,DenseMatrix:u,SparseMatrix:s,cos:c,sin:m}=r;return e(gm,{"":function(){return t.matrix==="Matrix"?l([]):[]},string:function(d){return l(d)},"number | BigNumber | Complex | Unit":function(d){return v(d,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(d,w){return v(d,w)},"number | BigNumber | Complex | Unit, Array":function(d,w){var x=l(w);return h(x),y(d,x,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(d,w){h(w);var x=w.storage()||(t.matrix==="Matrix"?"dense":void 0);return y(d,w,x)},"number | BigNumber | Complex | Unit, Array, string":function(d,w,x){var b=l(w);return h(b),y(d,b,x)},"number | BigNumber | Complex | Unit, Matrix, string":function(d,w,x){return h(w),y(d,w,x)}});function v(N,d){var w=rr(N),x=w?new f(-1):-1,b=c(N),E=m(N),A=[[b,a(x,E)],[E,b]];return g(A,d)}function h(N){var d=N.size();if(d.length<1||d[0]!==3)throw new RangeError("Vector must be of dimensions 1x3")}function p(N){return N.reduce((d,w)=>a(d,w))}function g(N,d){if(d){if(d==="sparse")return new s(N);if(d==="dense")return new u(N);throw new TypeError('Unknown matrix type "'.concat(d,'"'))}return N}function y(N,d,w){var x=o(d);if(x===0)throw new RangeError("Rotation around zero vector");var b=rr(N)?f:null,E=b?new b(1):1,A=b?new b(-1):-1,S=b?new b(d.get([0])/x):d.get([0])/x,D=b?new b(d.get([1])/x):d.get([1])/x,T=b?new b(d.get([2])/x):d.get([2])/x,B=c(N),I=n(E,i(B)),P=m(N),R=n(B,p([S,S,I])),M=n(p([S,D,I]),p([A,T,P])),F=n(p([S,T,I]),p([D,P])),H=n(p([S,D,I]),p([T,P])),$=n(B,p([D,D,I])),k=n(p([D,T,I]),p([A,S,P])),Q=n(p([S,T,I]),p([A,D,P])),K=n(p([D,T,I]),p([S,P])),L=n(B,p([T,T,I])),j=[[R,M,F],[H,$,k],[Q,K,L]];return g(j,w)}}),ym="row",Kw=["typed","Index","matrix","range"],bm=q(ym,Kw,r=>{var{typed:e,Index:t,matrix:a,range:n}=r;return e(ym,{"Matrix, number":i,"Array, number":function(f,l){return i(a(Ge(f)),l).valueOf()}});function i(o,f){if(o.size().length!==2)throw new Error("Only two dimensional matrix is supported");vr(f,o.size()[0]);var l=n(0,o.size()[1]),u=new t(f,l),s=o.subset(u);return Ve(s)?s:a([[s]])}}),xm="size",jw=["typed","config","?matrix"],eN=q(xm,jw,r=>{var{typed:e,config:t,matrix:a}=r;return e(xm,{Matrix:function(i){return i.create(i.size())},Array:er,string:function(i){return t.matrix==="Array"?[i.length]:a([i.length])},"number | Complex | BigNumber | Unit | boolean | null":function(i){return t.matrix==="Array"?[]:a?a([]):mm()}})}),wm="squeeze",rN=["typed","matrix"],tN=q(wm,rN,r=>{var{typed:e,matrix:t}=r;return e(wm,{Array:function(n){return pi(Ge(n))},Matrix:function(n){var i=pi(n.toArray());return Array.isArray(i)?t(i):i},any:function(n){return Ge(n)}})}),Nm="subset",nN=["typed","matrix"],Dm=q(Nm,nN,r=>{var{typed:e,matrix:t}=r;return e(Nm,{"Array, Index":function(n,i){var o=t(n),f=o.subset(i);return i.isScalar()?f:f.valueOf()},"Matrix, Index":function(n,i){return n.subset(i)},"Object, Index":iN,"string, Index":aN,"Array, Index, any":function(n,i,o){return t(Ge(n)).subset(i,o,void 0).valueOf()},"Array, Index, any, any":function(n,i,o,f){return t(Ge(n)).subset(i,o,f).valueOf()},"Matrix, Index, any":function(n,i,o){return n.clone().subset(i,o)},"Matrix, Index, any, any":function(n,i,o,f){return n.clone().subset(i,o,f)},"string, Index, string":Am,"string, Index, string, string":Am,"Object, Index, any":oN})});function aN(r,e){if(!li(e))throw new TypeError("Index expected");if(e.size().length!==1)throw new Ke(e.size().length,1);var t=r.length;vr(e.min()[0],t),vr(e.max()[0],t);var a=e.dimension(0),n="";return a.forEach(function(i){n+=r.charAt(i)}),n}function Am(r,e,t,a){if(!e||e.isIndex!==!0)throw new TypeError("Index expected");if(e.size().length!==1)throw new Ke(e.size().length,1);if(a!==void 0){if(typeof a!="string"||a.length!==1)throw new TypeError("Single character expected as defaultValue")}else a=" ";var n=e.dimension(0),i=n.size()[0];if(i!==t.length)throw new Ke(n.size()[0],t.length);var o=r.length;vr(e.min()[0]),vr(e.max()[0]);for(var f=[],l=0;l<o;l++)f[l]=r.charAt(l);if(n.forEach(function(c,m){f[c]=t.charAt(m[0])}),f.length>o)for(var u=o-1,s=f.length;u<s;u++)f[u]||(f[u]=a);return f.join("")}function iN(r,e){if(e.size().length!==1)throw new Ke(e.size(),1);var t=e.dimension(0);if(typeof t!="string")throw new TypeError("String expected as index to retrieve an object property");return lt(r,t)}function oN(r,e,t){if(e.size().length!==1)throw new Ke(e.size(),1);var a=e.dimension(0);if(typeof a!="string")throw new TypeError("String expected as index to retrieve an object property");var n=Ge(r);return jn(n,a,t),n}var Em="transpose",sN=["typed","matrix"],uN=q(Em,sN,r=>{var{typed:e,matrix:t}=r;return e(Em,{Array:o=>a(t(o)).valueOf(),Matrix:a,any:Ge});function a(o){var f=o.size(),l;switch(f.length){case 1:l=o.clone();break;case 2:{var u=f[0],s=f[1];if(s===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+Ye(f)+")");switch(o.storage()){case"dense":l=n(o,u,s);break;case"sparse":l=i(o,u,s);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+Ye(f)+")")}return l}function n(o,f,l){for(var u=o._data,s=[],c,m=0;m<l;m++){c=s[m]=[];for(var v=0;v<f;v++)c[v]=Ge(u[v][m])}return o.createDenseMatrix({data:s,size:[l,f],datatype:o._datatype})}function i(o,f,l){for(var u=o._values,s=o._index,c=o._ptr,m=u?[]:void 0,v=[],h=[],p=[],g=0;g<f;g++)p[g]=0;var y,N,d;for(y=0,N=s.length;y<N;y++)p[s[y]]++;for(var w=0,x=0;x<f;x++)h.push(w),w+=p[x],p[x]=h[x];for(h.push(w),d=0;d<l;d++)for(var b=c[d],E=c[d+1],A=b;A<E;A++){var S=p[s[A]]++;v[S]=d,u&&(m[S]=Ge(u[A]))}return o.createSparseMatrix({values:m,index:v,ptr:h,size:[l,f],datatype:o._datatype})}}),Sm="ctranspose",lN=["typed","transpose","conj"],cN=q(Sm,lN,r=>{var{typed:e,transpose:t,conj:a}=r;return e(Sm,{any:function(i){return a(t(i))}})}),Cm="zeros",fN=["typed","config","matrix","BigNumber"],mN=q(Cm,fN,r=>{var{typed:e,config:t,matrix:a,BigNumber:n}=r;return e(Cm,{"":function(){return t.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(u){var s=u[u.length-1];if(typeof s=="string"){var c=u.pop();return i(u,c)}else return t.matrix==="Array"?i(u):i(u,"default")},Array:i,Matrix:function(u){var s=u.storage();return i(u.valueOf(),s)},"Array | Matrix, string":function(u,s){return i(u.valueOf(),s)}});function i(l,u){var s=o(l),c=s?new n(0):0;if(f(l),u){var m=a(u);return l.length>0?m.resize(l,c):m}else{var v=[];return l.length>0?Qn(v,l,c):v}}function o(l){var u=!1;return l.forEach(function(s,c,m){rr(s)&&(u=!0,m[c]=s.toNumber())}),u}function f(l){l.forEach(function(u){if(typeof u!="number"||!qe(u)||u<0)throw new Error("Parameters in function zeros must be positive integers")})}}),Mm="fft",vN=["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i","dotDivide","conj","pow","ceil","log2"],pN=q(Mm,vN,r=>{var{typed:e,matrix:t,addScalar:a,multiplyScalar:n,divideScalar:i,exp:o,tau:f,i:l,dotDivide:u,conj:s,pow:c,ceil:m,log2:v}=r;return e(Mm,{Array:h,Matrix:function(d){return d.create(h(d.toArray()))}});function h(N){var d=er(N);return d.length===1?y(N,d[0]):p(N.map(w=>h(w,d.slice(1))),0)}function p(N,d){var w=er(N);if(d!==0)return new Array(w[0]).fill(0).map((b,E)=>p(N[E],d-1));if(w.length===1)return y(N);function x(b){var E=er(b);return new Array(E[1]).fill(0).map((A,S)=>new Array(E[0]).fill(0).map((D,T)=>b[T][S]))}return x(p(x(N),1))}function g(N){for(var d=N.length,w=o(i(n(-1,n(l,f)),d)),x=[],b=1-d;b<d;b++)x.push(c(w,i(c(b,2),2)));for(var E=c(2,m(v(d+d-1))),A=[...new Array(d).fill(0).map((M,F)=>n(N[F],x[d-1+F])),...new Array(E-d).fill(0)],S=[...new Array(d+d-1).fill(0).map((M,F)=>i(1,x[F])),...new Array(E-(d+d-1)).fill(0)],D=y(A),T=y(S),B=new Array(E).fill(0).map((M,F)=>n(D[F],T[F])),I=u(s(h(s(B))),E),P=[],R=d-1;R<d+d-1;R++)P.push(n(I[R],x[R]));return P}function y(N){var d=N.length;if(d===1)return[N[0]];if(d%2===0){for(var w=[...y(N.filter((A,S)=>S%2===0)),...y(N.filter((A,S)=>S%2===1))],x=0;x<d/2;x++){var b=w[x],E=n(w[x+d/2],o(n(n(f,l),i(-x,d))));w[x]=a(b,E),w[x+d/2]=a(b,n(-1,E))}return w}else return g(N)}}),Fm="ifft",hN=["typed","fft","dotDivide","conj"],dN=q(Fm,hN,r=>{var{typed:e,fft:t,dotDivide:a,conj:n}=r;return e(Fm,{"Array | Matrix":function(o){var f=Ve(o)?o.size():er(o);return a(n(t(n(o))),f.reduce((l,u)=>l*u,1))}})}),gN="erf",yN=["typed"],bN=q(gN,yN,r=>{var{typed:e}=r;return e("name",{number:function(o){var f=Math.abs(o);return f>=NN?an(o):f<=xN?an(o)*t(f):f<=4?an(o)*(1-a(f)):an(o)*(1-n(f))},"Array | Matrix":e.referToSelf(i=>o=>je(o,i))});function t(i){var o=i*i,f=Yt[0][4]*o,l=o,u;for(u=0;u<3;u+=1)f=(f+Yt[0][u])*o,l=(l+ua[0][u])*o;return i*(f+Yt[0][3])/(l+ua[0][3])}function a(i){var o=Yt[1][8]*i,f=i,l;for(l=0;l<7;l+=1)o=(o+Yt[1][l])*i,f=(f+ua[1][l])*i;var u=(o+Yt[1][7])/(f+ua[1][7]),s=parseInt(i*16)/16,c=(i-s)*(i+s);return Math.exp(-s*s)*Math.exp(-c)*u}function n(i){var o=1/(i*i),f=Yt[2][5]*o,l=o,u;for(u=0;u<4;u+=1)f=(f+Yt[2][u])*o,l=(l+ua[2][u])*o;var s=o*(f+Yt[2][4])/(l+ua[2][4]);s=(wN-s)/i,o=parseInt(i*16)/16;var c=(i-o)*(i+o);return Math.exp(-o*o)*Math.exp(-c)*s}}),xN=.46875,wN=.5641895835477563,Yt=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,21531153547440383e-24],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],ua=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],NN=Math.pow(2,53),Tm="mode",DN=["typed","isNaN","isNumeric"],AN=q(Tm,DN,r=>{var{typed:e,isNaN:t,isNumeric:a}=r;return e(Tm,{"Array | Matrix":n,"...":function(o){return n(o)}});function n(i){i=or(i.valueOf());var o=i.length;if(o===0)throw new Error("Cannot calculate mode of an empty array");for(var f={},l=[],u=0,s=0;s<i.length;s++){var c=i[s];if(a(c)&&t(c))throw new Error("Cannot calculate mode of an array containing NaN values");c in f||(f[c]=0),f[c]++,f[c]===u?l.push(c):f[c]>u&&(u=f[c],l=[c])}return l}});function Qr(r,e,t){var a;return String(r).indexOf("Unexpected type")!==-1?(a=arguments.length>2?" (type: "+br(t)+", value: "+JSON.stringify(t)+")":" (type: "+r.data.actual+")",new TypeError("Cannot calculate "+e+", unexpected type of argument"+a)):String(r).indexOf("complex numbers")!==-1?(a=arguments.length>2?" (type: "+br(t)+", value: "+JSON.stringify(t)+")":"",new TypeError("Cannot calculate "+e+", no ordering relation is defined for complex numbers"+a)):r}var Bm="prod",EN=["typed","config","multiplyScalar","numeric"],SN=q(Bm,EN,r=>{var{typed:e,config:t,multiplyScalar:a,numeric:n}=r;return e(Bm,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(f,l){throw new Error("prod(A, dim) is not yet supported")},"...":function(f){return i(f)}});function i(o){var f;if(Xt(o,function(l){try{f=f===void 0?l:a(f,l)}catch(u){throw Qr(u,"prod",l)}}),typeof f=="string"&&(f=n(f,t.number)),f===void 0)throw new Error("Cannot calculate prod of an empty array");return f}}),$m="format",CN=["typed"],MN=q($m,CN,r=>{var{typed:e}=r;return e($m,{any:Ye,"any, Object | function | number":Ye})}),Om="bin",FN=["typed","format"],TN=q(Om,FN,r=>{var{typed:e,format:t}=r;return e(Om,{"number | BigNumber":function(n){return t(n,{notation:"bin"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"bin",wordSize:i})}})}),Im="oct",BN=["typed","format"],$N=q(Im,BN,r=>{var{typed:e,format:t}=r;return e(Im,{"number | BigNumber":function(n){return t(n,{notation:"oct"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"oct",wordSize:i})}})}),Rm="hex",ON=["typed","format"],IN=q(Rm,ON,r=>{var{typed:e,format:t}=r;return e(Rm,{"number | BigNumber":function(n){return t(n,{notation:"hex"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"hex",wordSize:i})}})}),_m="print",RN=["typed"],_N=q(_m,RN,r=>{var{typed:e}=r;return e(_m,{"string, Object | Array":qm,"string, Object | Array, number | Object":qm})});function qm(r,e,t){return r.replace(/\$([\w.]+)/g,function(a,n){for(var i=n.split("."),o=e[i.shift()];i.length&&o!==void 0;){var f=i.shift();o=f?o[f]:o+"."}return o!==void 0?Wr(o)?o:Ye(o,t):a})}var zm="to",qN=["typed","matrix","concat"],zN=q(zm,qN,r=>{var{typed:e,matrix:t,concat:a}=r,n=dr({typed:e,matrix:t,concat:a});return e(zm,{"Unit, Unit | string":(i,o)=>i.to(o)},n({Ds:!0}))}),Pm="isPrime",PN=["typed"],UN=q(Pm,PN,r=>{var{typed:e}=r;return e(Pm,{number:function(a){if(a*0!==0)return!1;if(a<=3)return a>1;if(a%2===0||a%3===0)return!1;for(var n=5;n*n<=a;n+=6)if(a%n===0||a%(n+2)===0)return!1;return!0},BigNumber:function(a){if(a.toNumber()*0!==0)return!1;if(a.lte(3))return a.gt(1);if(a.mod(2).eq(0)||a.mod(3).eq(0))return!1;if(a.lt(Math.pow(2,32))){for(var n=a.toNumber(),i=5;i*i<=n;i+=6)if(n%i===0||n%(i+2)===0)return!1;return!0}function o(N,d,w){for(var x=1;!d.eq(0);)d.mod(2).eq(0)?(d=d.div(2),N=N.mul(N).mod(w)):(d=d.sub(1),x=N.mul(x).mod(w));return x}var f=a.constructor.clone({precision:a.toFixed(0).length*2});a=new f(a);for(var l=0,u=a.sub(1);u.mod(2).eq(0);)u=u.div(2),l+=1;var s=null;if(a.lt("3317044064679887385961981"))s=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter(N=>N<a);else{var c=Math.min(a.toNumber()-2,Math.floor(2*Math.pow(a.toFixed(0).length*Math.log(10),2)));s=[];for(var m=2;m<=c;m+=1)s.push(c)}for(var v=0;v<s.length;v+=1){var h=s[v],p=o(a.sub(a).add(h),u,a);if(!p.eq(1)){for(var g=0,y=p;!y.eq(a.sub(1));g+=1,y=y.mul(y).mod(a))if(g===l-1)return!1}}return!0},"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),LN="numeric",kN=["number","?bignumber","?fraction"],VN=q(LN,kN,r=>{var{number:e,bignumber:t,fraction:a}=r,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:o=>e(o),BigNumber:t?o=>t(o):ps,Fraction:a?o=>a(o):fm};return function(f){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",u=arguments.length>2?arguments[2]:void 0;if(u!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var s=br(f);if(!(s in n))throw new TypeError("Cannot convert "+f+' of type "'+s+'"; valid input types are '+Object.keys(n).join(", "));if(!(l in i))throw new TypeError("Cannot convert "+f+' to type "'+l+'"; valid output types are '+Object.keys(i).join(", "));return l===s?f:i[l](f)}}),Um="divideScalar",GN=["typed","numeric"],HN=q(Um,GN,r=>{var{typed:e,numeric:t}=r;return e(Um,{"number, number":function(n,i){return n/i},"Complex, Complex":function(n,i){return n.div(i)},"BigNumber, BigNumber":function(n,i){return n.div(i)},"Fraction, Fraction":function(n,i){return n.div(i)},"Unit, number | Complex | Fraction | BigNumber | Unit":(a,n)=>a.divide(n),"number | Fraction | Complex | BigNumber, Unit":(a,n)=>n.divideInto(a)})}),Lm="pow",ZN=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],JN=q(Lm,ZN,r=>{var{typed:e,config:t,identity:a,multiply:n,matrix:i,inv:o,number:f,fraction:l,Complex:u}=r;return e(Lm,{"number, number":s,"Complex, Complex":function(h,p){return h.pow(p)},"BigNumber, BigNumber":function(h,p){return p.isInteger()||h>=0||t.predictable?h.pow(p):new u(h.toNumber(),0).pow(p.toNumber(),0)},"Fraction, Fraction":function(h,p){var g=h.pow(p);if(g!=null)return g;if(t.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return s(h.valueOf(),p.valueOf())},"Array, number":c,"Array, BigNumber":function(h,p){return c(h,p.toNumber())},"Matrix, number":m,"Matrix, BigNumber":function(h,p){return m(h,p.toNumber())},"Unit, number | BigNumber":function(h,p){return h.pow(p)}});function s(v,h){if(t.predictable&&!qe(h)&&v<0)try{var p=l(h),g=f(p);if((h===g||Math.abs((h-g)/h)<1e-14)&&p.d%2===1)return(p.n%2===0?1:-1)*Math.pow(-v,h)}catch{}return t.predictable&&(v<-1&&h===1/0||v>-1&&v<0&&h===-1/0)?NaN:qe(h)||v>=0||t.predictable?pc(v,h):v*v<1&&h===1/0||v*v>1&&h===-1/0?0:new u(v,0).pow(h,0)}function c(v,h){if(!qe(h))throw new TypeError("For A^b, b must be an integer (value is "+h+")");var p=er(v);if(p.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+p.length+" dimensions)");if(p[0]!==p[1])throw new Error("For A^b, A must be square (size is "+p[0]+"x"+p[1]+")");if(h<0)try{return c(o(v),-h)}catch(N){throw N.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+h+")"):N}for(var g=a(p[0]).valueOf(),y=v;h>=1;)(h&1)===1&&(g=n(y,g)),h>>=1,y=n(y,y);return g}function m(v,h){return i(c(v.valueOf(),h))}}),la="Number of decimals in function round must be an integer",km="round",XN=["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],WN=q(km,XN,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,BigNumber:i,DenseMatrix:o}=r,f=Lr({typed:e,equalScalar:a}),l=Ir({typed:e,DenseMatrix:o}),u=xt({typed:e});return e(km,{number:hc,"number, number":hc,"number, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(la);return new i(c).toDecimalPlaces(m.toNumber())},Complex:function(c){return c.round()},"Complex, number":function(c,m){if(m%1)throw new TypeError(la);return c.round(m)},"Complex, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(la);var v=m.toNumber();return c.round(v)},BigNumber:function(c){return c.toDecimalPlaces(0)},"BigNumber, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(la);return c.toDecimalPlaces(m.toNumber())},Fraction:function(c){return c.round()},"Fraction, number":function(c,m){if(m%1)throw new TypeError(la);return c.round(m)},"Fraction, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(la);return c.round(m.toNumber())},"Array | Matrix":e.referToSelf(s=>c=>je(c,s)),"SparseMatrix, number | BigNumber":e.referToSelf(s=>(c,m)=>f(c,m,s,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(s=>(c,m)=>u(c,m,s,!1)),"Array, number | BigNumber":e.referToSelf(s=>(c,m)=>u(t(c),m,s,!1).valueOf()),"number | Complex | BigNumber | Fraction, SparseMatrix":e.referToSelf(s=>(c,m)=>a(c,0)?n(m.size(),m.storage()):l(m,c,s,!0)),"number | Complex | BigNumber | Fraction, DenseMatrix":e.referToSelf(s=>(c,m)=>a(c,0)?n(m.size(),m.storage()):u(m,c,s,!0)),"number | Complex | BigNumber | Fraction, Array":e.referToSelf(s=>(c,m)=>u(t(m),c,s,!0).valueOf())})}),Vm="log",YN=["config","typed","divideScalar","Complex"],QN=q(Vm,YN,r=>{var{typed:e,config:t,divideScalar:a,Complex:n}=r;return e(Vm,{number:function(o){return o>=0||t.predictable?j1(o):new n(o,0).log()},Complex:function(o){return o.log()},BigNumber:function(o){return!o.isNegative()||t.predictable?o.ln():new n(o.toNumber(),0).log()},"any, any":e.referToSelf(i=>(o,f)=>a(i(o),i(f)))})}),Gm="log1p",KN=["typed","config","divideScalar","log","Complex"],jN=q(Gm,KN,r=>{var{typed:e,config:t,divideScalar:a,log:n,Complex:i}=r;return e(Gm,{number:function(l){return l>=-1||t.predictable?rg(l):o(new i(l,0))},Complex:o,BigNumber:function(l){var u=l.plus(1);return!u.isNegative()||t.predictable?u.ln():o(new i(l.toNumber(),0))},"Array | Matrix":e.referToSelf(f=>l=>je(l,f)),"any, any":e.referToSelf(f=>(l,u)=>a(f(l),n(u)))});function o(f){var l=f.re+1;return new i(Math.log(Math.sqrt(l*l+f.im*f.im)),Math.atan2(f.im,l))}}),Hm="nthRoots",e2=["config","typed","divideScalar","Complex"],r2=q(Hm,e2,r=>{var{typed:e,config:t,divideScalar:a,Complex:n}=r,i=[function(l){return new n(l,0)},function(l){return new n(0,l)},function(l){return new n(-l,0)},function(l){return new n(0,-l)}];function o(f,l){if(l<0)throw new Error("Root must be greater than zero");if(l===0)throw new Error("Root must be non-zero");if(l%1!==0)throw new Error("Root must be an integer");if(f===0||f.abs()===0)return[new n(0,0)];var u=typeof f=="number",s;(u||f.re===0||f.im===0)&&(u?s=2*+(f<0):f.im===0?s=2*+(f.re<0):s=2*+(f.im<0)+1);for(var c=f.arg(),m=f.abs(),v=[],h=Math.pow(m,1/l),p=0;p<l;p++){var g=(s+4*p)/l;if(g===Math.round(g)){v.push(i[g%4](h));continue}v.push(new n({r:h,phi:(c+2*Math.PI*p)/l}))}return v}return e(Hm,{Complex:function(l){return o(l,2)},"Complex, number":o})}),Zm="dotPow",t2=["typed","equalScalar","matrix","pow","DenseMatrix","concat"],n2=q(Zm,t2,r=>{var{typed:e,equalScalar:t,matrix:a,pow:n,DenseMatrix:i,concat:o}=r,f=Yr({typed:e}),l=$t({typed:e,DenseMatrix:i}),u=Lr({typed:e,equalScalar:t}),s=Ir({typed:e,DenseMatrix:i}),c=dr({typed:e,matrix:a,concat:o}),m={};for(var v in n.signatures)Object.prototype.hasOwnProperty.call(n.signatures,v)&&!v.includes("Matrix")&&!v.includes("Array")&&(m[v]=n.signatures[v]);var h=e(m);return e(Zm,c({elop:h,SS:l,DS:f,Ss:u,sS:s}))}),Jm="dotDivide",a2=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],i2=q(Jm,a2,r=>{var{typed:e,matrix:t,equalScalar:a,divideScalar:n,DenseMatrix:i,concat:o}=r,f=wt({typed:e,equalScalar:a}),l=Yr({typed:e}),u=$t({typed:e,DenseMatrix:i}),s=Lr({typed:e,equalScalar:a}),c=Ir({typed:e,DenseMatrix:i}),m=dr({typed:e,matrix:t,concat:o});return e(Jm,m({elop:n,SS:u,DS:l,SD:f,Ss:s,sS:c}))});function Za(r){var{DenseMatrix:e}=r;return function(a,n,i){var o=a.size();if(o.length!==2)throw new RangeError("Matrix must be two dimensional (size: "+Ye(o)+")");var f=o[0],l=o[1];if(f!==l)throw new RangeError("Matrix must be square (size: "+Ye(o)+")");var u=[];if(Ve(n)){var s=n.size(),c=n._data;if(s.length===1){if(s[0]!==f)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var m=0;m<f;m++)u[m]=[c[m]];return new e({data:u,size:[f,1],datatype:n._datatype})}if(s.length===2){if(s[0]!==f||s[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");if(ui(n)){if(i){u=[];for(var v=0;v<f;v++)u[v]=[c[v][0]];return new e({data:u,size:[f,1],datatype:n._datatype})}return n}if(En(n)){for(var h=0;h<f;h++)u[h]=[0];for(var p=n._values,g=n._index,y=n._ptr,N=y[1],d=y[0];d<N;d++){var w=g[d];u[w][0]=p[d]}return new e({data:u,size:[f,1],datatype:n._datatype})}}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}if(cr(n)){var x=er(n);if(x.length===1){if(x[0]!==f)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var b=0;b<f;b++)u[b]=[n[b]];return new e({data:u,size:[f,1]})}if(x.length===2){if(x[0]!==f||x[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var E=0;E<f;E++)u[E]=[n[E][0]];return new e({data:u,size:[f,1]})}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}}}var Xm="lsolve",o2=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],s2=q(Xm,o2,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:o,DenseMatrix:f}=r,l=Za({DenseMatrix:f});return e(Xm,{"SparseMatrix, Array | Matrix":function(m,v){return s(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var h=t(m),p=u(h,v);return p.valueOf()}});function u(c,m){m=l(c,m,!0);for(var v=m._data,h=c._size[0],p=c._size[1],g=[],y=c._data,N=0;N<p;N++){var d=v[N][0]||0,w=void 0;if(o(d,0))w=0;else{var x=y[N][N];if(o(x,0))throw new Error("Linear system cannot be solved since matrix is singular");w=a(d,x);for(var b=N+1;b<h;b++)v[b]=[i(v[b][0]||0,n(w,y[b][N]))]}g[N]=[w]}return new f({data:g,size:[h,1]})}function s(c,m){m=l(c,m,!0);for(var v=m._data,h=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,d=[],w=0;w<p;w++){var x=v[w][0]||0;if(o(x,0))d[w]=[0];else{for(var b=0,E=[],A=[],S=N[w],D=N[w+1],T=S;T<D;T++){var B=y[T];B===w?b=g[T]:B>w&&(E.push(g[T]),A.push(B))}if(o(b,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var I=a(x,b),P=0,R=A.length;P<R;P++){var M=A[P];v[M]=[i(v[M][0]||0,n(I,E[P]))]}d[w]=[I]}}return new f({data:d,size:[h,1]})}}),Wm="usolve",u2=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],l2=q(Wm,u2,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:o,DenseMatrix:f}=r,l=Za({DenseMatrix:f});return e(Wm,{"SparseMatrix, Array | Matrix":function(m,v){return s(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var h=t(m),p=u(h,v);return p.valueOf()}});function u(c,m){m=l(c,m,!0);for(var v=m._data,h=c._size[0],p=c._size[1],g=[],y=c._data,N=p-1;N>=0;N--){var d=v[N][0]||0,w=void 0;if(o(d,0))w=0;else{var x=y[N][N];if(o(x,0))throw new Error("Linear system cannot be solved since matrix is singular");w=a(d,x);for(var b=N-1;b>=0;b--)v[b]=[i(v[b][0]||0,n(w,y[b][N]))]}g[N]=[w]}return new f({data:g,size:[h,1]})}function s(c,m){m=l(c,m,!0);for(var v=m._data,h=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,d=[],w=p-1;w>=0;w--){var x=v[w][0]||0;if(o(x,0))d[w]=[0];else{for(var b=0,E=[],A=[],S=N[w],D=N[w+1],T=D-1;T>=S;T--){var B=y[T];B===w?b=g[T]:B<w&&(E.push(g[T]),A.push(B))}if(o(b,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var I=a(x,b),P=0,R=A.length;P<R;P++){var M=A[P];v[M]=[i(v[M][0],n(I,E[P]))]}d[w]=[I]}}return new f({data:d,size:[h,1]})}}),Ym="lsolveAll",c2=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],f2=q(Ym,c2,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:o,DenseMatrix:f}=r,l=Za({DenseMatrix:f});return e(Ym,{"SparseMatrix, Array | Matrix":function(m,v){return s(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var h=t(m),p=u(h,v);return p.map(g=>g.valueOf())}});function u(c,m){for(var v=[l(c,m,!0)._data.map(A=>A[0])],h=c._data,p=c._size[0],g=c._size[1],y=0;y<g;y++)for(var N=v.length,d=0;d<N;d++){var w=v[d];if(o(h[y][y],0))if(o(w[y],0)){if(d===0){var b=[...w];b[y]=1;for(var E=y+1;E<g;E++)b[E]=i(b[E],h[E][y]);v.push(b)}}else{if(d===0)return[];v.splice(d,1),d-=1,N-=1}else{w[y]=a(w[y],h[y][y]);for(var x=y+1;x<g;x++)w[x]=i(w[x],n(w[y],h[x][y]))}}return v.map(A=>new f({data:A.map(S=>[S]),size:[p,1]}))}function s(c,m){for(var v=[l(c,m,!0)._data.map(Q=>Q[0])],h=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,d=0;d<p;d++)for(var w=v.length,x=0;x<w;x++){for(var b=v[x],E=[],A=[],S=N[d],D=N[d+1],T=0,B=S;B<D;B++){var I=y[B];I===d?T=g[B]:I>d&&(E.push(g[B]),A.push(I))}if(o(T,0))if(o(b[d],0)){if(x===0){var F=[...b];F[d]=1;for(var H=0,$=A.length;H<$;H++){var k=A[H];F[k]=i(F[k],E[H])}v.push(F)}}else{if(x===0)return[];v.splice(x,1),x-=1,w-=1}else{b[d]=a(b[d],T);for(var P=0,R=A.length;P<R;P++){var M=A[P];b[M]=i(b[M],n(b[d],E[P]))}}}return v.map(Q=>new f({data:Q.map(K=>[K]),size:[h,1]}))}}),Qm="usolveAll",m2=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],v2=q(Qm,m2,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:o,DenseMatrix:f}=r,l=Za({DenseMatrix:f});return e(Qm,{"SparseMatrix, Array | Matrix":function(m,v){return s(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var h=t(m),p=u(h,v);return p.map(g=>g.valueOf())}});function u(c,m){for(var v=[l(c,m,!0)._data.map(A=>A[0])],h=c._data,p=c._size[0],g=c._size[1],y=g-1;y>=0;y--)for(var N=v.length,d=0;d<N;d++){var w=v[d];if(o(h[y][y],0))if(o(w[y],0)){if(d===0){var b=[...w];b[y]=1;for(var E=y-1;E>=0;E--)b[E]=i(b[E],h[E][y]);v.push(b)}}else{if(d===0)return[];v.splice(d,1),d-=1,N-=1}else{w[y]=a(w[y],h[y][y]);for(var x=y-1;x>=0;x--)w[x]=i(w[x],n(w[y],h[x][y]))}}return v.map(A=>new f({data:A.map(S=>[S]),size:[p,1]}))}function s(c,m){for(var v=[l(c,m,!0)._data.map(Q=>Q[0])],h=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,d=p-1;d>=0;d--)for(var w=v.length,x=0;x<w;x++){for(var b=v[x],E=[],A=[],S=N[d],D=N[d+1],T=0,B=D-1;B>=S;B--){var I=y[B];I===d?T=g[B]:I<d&&(E.push(g[B]),A.push(I))}if(o(T,0))if(o(b[d],0)){if(x===0){var F=[...b];F[d]=1;for(var H=0,$=A.length;H<$;H++){var k=A[H];F[k]=i(F[k],E[H])}v.push(F)}}else{if(x===0)return[];v.splice(x,1),x-=1,w-=1}else{b[d]=a(b[d],T);for(var P=0,R=A.length;P<R;P++){var M=A[P];b[M]=i(b[M],n(b[d],E[P]))}}}return v.map(Q=>new f({data:Q.map(K=>[K]),size:[h,1]}))}}),p2="matAlgo08xS0Sid",h2=["typed","equalScalar"],hs=q(p2,h2,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o){var f=n._values,l=n._index,u=n._ptr,s=n._size,c=n._datatype,m=i._values,v=i._index,h=i._ptr,p=i._size,g=i._datatype;if(s.length!==p.length)throw new Ke(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!f||!m)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var y=s[0],N=s[1],d,w=t,x=0,b=o;typeof c=="string"&&c===g&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),b=e.find(o,[d,d]));for(var E=[],A=[],S=[],D=[],T=[],B,I,P,R,M=0;M<N;M++){S[M]=A.length;var F=M+1;for(I=u[M],P=u[M+1],B=I;B<P;B++)R=l[B],T[R]=F,D[R]=f[B],A.push(R);for(I=h[M],P=h[M+1],B=I;B<P;B++)R=v[B],T[R]===F&&(D[R]=b(D[R],m[B]));for(B=S[M];B<A.length;){R=A[B];var H=D[R];w(H,x)?A.splice(B,1):(E.push(H),B++)}}return S[N]=A.length,n.createSparseMatrix({values:E,index:A,ptr:S,size:[y,N],datatype:d})}}),ds=q("useMatrixForArrayScalar",["typed","matrix"],r=>{var{typed:e,matrix:t}=r;return{"Array, number":e.referTo("DenseMatrix, number",a=>(n,i)=>a(t(n),i).valueOf()),"Array, BigNumber":e.referTo("DenseMatrix, BigNumber",a=>(n,i)=>a(t(n),i).valueOf()),"number, Array":e.referTo("number, DenseMatrix",a=>(n,i)=>a(n,t(i)).valueOf()),"BigNumber, Array":e.referTo("BigNumber, DenseMatrix",a=>(n,i)=>a(n,t(i)).valueOf())}}),Km="leftShift",d2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],g2=q(Km,d2,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,DenseMatrix:i,concat:o}=r,f=mn({typed:e}),l=wt({typed:e,equalScalar:a}),u=hs({typed:e,equalScalar:a}),s=Tn({typed:e,DenseMatrix:i}),c=Lr({typed:e,equalScalar:a}),m=xt({typed:e}),v=dr({typed:e,matrix:t,concat:o}),h=ds({typed:e,matrix:t});return e(Km,{"number, number":xc,"BigNumber, BigNumber":Lx,"SparseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>a(y,0)?g.clone():c(g,y,p,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>a(y,0)?g.clone():m(g,y,p,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(p=>(g,y)=>a(g,0)?n(y.size(),y.storage()):s(y,g,p,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(p=>(g,y)=>a(g,0)?n(y.size(),y.storage()):m(y,g,p,!0))},h,v({SS:u,DS:f,SD:l}))}),jm="rightArithShift",y2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],b2=q(jm,y2,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,DenseMatrix:i,concat:o}=r,f=mn({typed:e}),l=wt({typed:e,equalScalar:a}),u=hs({typed:e,equalScalar:a}),s=Tn({typed:e,DenseMatrix:i}),c=Lr({typed:e,equalScalar:a}),m=xt({typed:e}),v=dr({typed:e,matrix:t,concat:o}),h=ds({typed:e,matrix:t});return e(jm,{"number, number":wc,"BigNumber, BigNumber":kx,"SparseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>a(y,0)?g.clone():c(g,y,p,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>a(y,0)?g.clone():m(g,y,p,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(p=>(g,y)=>a(g,0)?n(y.size(),y.storage()):s(y,g,p,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(p=>(g,y)=>a(g,0)?n(y.size(),y.storage()):m(y,g,p,!0))},h,v({SS:u,DS:f,SD:l}))}),ev="rightLogShift",x2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],w2=q(ev,x2,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,DenseMatrix:i,concat:o}=r,f=mn({typed:e}),l=wt({typed:e,equalScalar:a}),u=hs({typed:e,equalScalar:a}),s=Tn({typed:e,DenseMatrix:i}),c=Lr({typed:e,equalScalar:a}),m=xt({typed:e}),v=dr({typed:e,matrix:t,concat:o}),h=ds({typed:e,matrix:t});return e(ev,{"number, number":Nc,"SparseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>a(y,0)?g.clone():c(g,y,p,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>a(y,0)?g.clone():m(g,y,p,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(p=>(g,y)=>a(g,0)?n(y.size(),y.storage()):s(y,g,p,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(p=>(g,y)=>a(g,0)?n(y.size(),y.storage()):m(y,g,p,!0))},h,v({SS:u,DS:f,SD:l}))}),rv="and",N2=["typed","matrix","equalScalar","zeros","not","concat"],D2=q(rv,N2,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,not:i,concat:o}=r,f=wt({typed:e,equalScalar:a}),l=Oi({typed:e,equalScalar:a}),u=Lr({typed:e,equalScalar:a}),s=xt({typed:e}),c=dr({typed:e,matrix:t,concat:o});return e(rv,{"number, number":Cc,"Complex, Complex":function(v,h){return(v.re!==0||v.im!==0)&&(h.re!==0||h.im!==0)},"BigNumber, BigNumber":function(v,h){return!v.isZero()&&!h.isZero()&&!v.isNaN()&&!h.isNaN()},"Unit, Unit":e.referToSelf(m=>(v,h)=>m(v.value||0,h.value||0)),"SparseMatrix, any":e.referToSelf(m=>(v,h)=>i(h)?n(v.size(),v.storage()):u(v,h,m,!1)),"DenseMatrix, any":e.referToSelf(m=>(v,h)=>i(h)?n(v.size(),v.storage()):s(v,h,m,!1)),"any, SparseMatrix":e.referToSelf(m=>(v,h)=>i(v)?n(v.size(),v.storage()):u(h,v,m,!0)),"any, DenseMatrix":e.referToSelf(m=>(v,h)=>i(v)?n(v.size(),v.storage()):s(h,v,m,!0)),"Array, any":e.referToSelf(m=>(v,h)=>m(t(v),h).valueOf()),"any, Array":e.referToSelf(m=>(v,h)=>m(v,t(h)).valueOf())},c({SS:l,DS:f}))}),_i="compare",A2=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],E2=q(_i,A2,r=>{var{typed:e,config:t,equalScalar:a,matrix:n,BigNumber:i,Fraction:o,DenseMatrix:f,concat:l}=r,u=Yr({typed:e}),s=Ii({typed:e,equalScalar:a}),c=Ir({typed:e,DenseMatrix:f}),m=dr({typed:e,matrix:n,concat:l}),v=sa({typed:e});return e(_i,S2({typed:e,config:t}),{"boolean, boolean":function(p,g){return p===g?0:p>g?1:-1},"BigNumber, BigNumber":function(p,g){return Bt(p,g,t.epsilon)?new i(0):new i(p.cmp(g))},"Fraction, Fraction":function(p,g){return new o(p.compare(g))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},v,m({SS:s,DS:u,Ss:c}))}),S2=q(_i,["typed","config"],r=>{var{typed:e,config:t}=r;return e(_i,{"number, number":function(n,i){return nt(n,i,t.epsilon)?0:n>i?1:-1}})}),ca=function r(e,t){var a=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,n=/(^[ ]*|[ ]*$)/g,i=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,o=/^0x[0-9a-f]+$/i,f=/^0/,l=function(d){return r.insensitive&&(""+d).toLowerCase()||""+d},u=l(e).replace(n,"")||"",s=l(t).replace(n,"")||"",c=u.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),m=s.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),v=parseInt(u.match(o),16)||c.length!==1&&u.match(i)&&Date.parse(u),h=parseInt(s.match(o),16)||v&&s.match(i)&&Date.parse(s)||null,p,g;if(h){if(v<h)return-1;if(v>h)return 1}for(var y=0,N=Math.max(c.length,m.length);y<N;y++){if(p=!(c[y]||"").match(f)&&parseFloat(c[y])||c[y]||0,g=!(m[y]||"").match(f)&&parseFloat(m[y])||m[y]||0,isNaN(p)!==isNaN(g))return isNaN(p)?1:-1;if(typeof p!=typeof g&&(p+="",g+=""),p<g)return-1;if(p>g)return 1}return 0},tv="compareNatural",C2=["typed","compare"],M2=q(tv,C2,r=>{var{typed:e,compare:t}=r,a=t.signatures["boolean,boolean"];return e(tv,{"any, any":n});function n(l,u){var s=br(l),c=br(u),m;if((s==="number"||s==="BigNumber"||s==="Fraction")&&(c==="number"||c==="BigNumber"||c==="Fraction"))return m=t(l,u),m.toString()!=="0"?m>0?1:-1:ca(s,c);var v=["Array","DenseMatrix","SparseMatrix"];if(v.includes(s)||v.includes(c))return m=i(n,l,u),m!==0?m:ca(s,c);if(s!==c)return ca(s,c);if(s==="Complex")return F2(l,u);if(s==="Unit")return l.equalBase(u)?n(l.value,u.value):o(n,l.formatUnits(),u.formatUnits());if(s==="boolean")return a(l,u);if(s==="string")return ca(l,u);if(s==="Object")return f(n,l,u);if(s==="null"||s==="undefined")return 0;throw new TypeError('Unsupported type of value "'+s+'"')}function i(l,u,s){return En(u)&&En(s)?o(l,u.toJSON().values,s.toJSON().values):En(u)?i(l,u.toArray(),s):En(s)?i(l,u,s.toArray()):ui(u)?i(l,u.toJSON().data,s):ui(s)?i(l,u,s.toJSON().data):Array.isArray(u)?Array.isArray(s)?o(l,u,s):i(l,u,[s]):i(l,[u],s)}function o(l,u,s){for(var c=0,m=Math.min(u.length,s.length);c<m;c++){var v=l(u[c],s[c]);if(v!==0)return v}return u.length>s.length?1:u.length<s.length?-1:0}function f(l,u,s){var c=Object.keys(u),m=Object.keys(s);c.sort(ca),m.sort(ca);var v=o(l,c,m);if(v!==0)return v;for(var h=0;h<c.length;h++){var p=l(u[c[h]],s[m[h]]);if(p!==0)return p}return 0}});function F2(r,e){return r.re>e.re?1:r.re<e.re?-1:r.im>e.im?1:r.im<e.im?-1:0}var nv="compareText",T2=["typed","matrix","concat"];Ho.signature="any, any";var B2=q(nv,T2,r=>{var{typed:e,matrix:t,concat:a}=r,n=dr({typed:e,matrix:t,concat:a});return e(nv,Ho,n({elop:Ho,Ds:!0}))}),qi="equal",$2=["typed","matrix","equalScalar","DenseMatrix","concat"],O2=q(qi,$2,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n,concat:i}=r,o=Yr({typed:e}),f=$t({typed:e,DenseMatrix:n}),l=Ir({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:t,concat:i});return e(qi,I2({typed:e,equalScalar:a}),u({elop:a,SS:f,DS:o,Ss:l}))}),I2=q(qi,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e(qi,{"any, any":function(n,i){return n===null?i===null:i===null?n===null:n===void 0?i===void 0:i===void 0?n===void 0:t(n,i)}})}),av="equalText",R2=["typed","compareText","isZero"],_2=q(av,R2,r=>{var{typed:e,compareText:t,isZero:a}=r;return e(av,{"any, any":function(i,o){return a(t(i,o))}})}),zi="smaller",q2=["typed","config","matrix","DenseMatrix","concat"],z2=q(zi,q2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n,concat:i}=r,o=Yr({typed:e}),f=$t({typed:e,DenseMatrix:n}),l=Ir({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:a,concat:i}),s=sa({typed:e});return e(zi,P2({typed:e,config:t}),{"boolean, boolean":(c,m)=>c<m,"BigNumber, BigNumber":function(m,v){return m.lt(v)&&!Bt(m,v,t.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)===-1,"Complex, Complex":function(m,v){throw new TypeError("No ordering relation is defined for complex numbers")}},s,u({SS:f,DS:o,Ss:l}))}),P2=q(zi,["typed","config"],r=>{var{typed:e,config:t}=r;return e(zi,{"number, number":function(n,i){return n<i&&!nt(n,i,t.epsilon)}})}),Pi="smallerEq",U2=["typed","config","matrix","DenseMatrix","concat"],L2=q(Pi,U2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n,concat:i}=r,o=Yr({typed:e}),f=$t({typed:e,DenseMatrix:n}),l=Ir({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:a,concat:i}),s=sa({typed:e});return e(Pi,k2({typed:e,config:t}),{"boolean, boolean":(c,m)=>c<=m,"BigNumber, BigNumber":function(m,v){return m.lte(v)||Bt(m,v,t.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)!==1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},s,u({SS:f,DS:o,Ss:l}))}),k2=q(Pi,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Pi,{"number, number":function(n,i){return n<=i||nt(n,i,t.epsilon)}})}),Ui="larger",V2=["typed","config","matrix","DenseMatrix","concat"],G2=q(Ui,V2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n,concat:i}=r,o=Yr({typed:e}),f=$t({typed:e,DenseMatrix:n}),l=Ir({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:a,concat:i}),s=sa({typed:e});return e(Ui,H2({typed:e,config:t}),{"boolean, boolean":(c,m)=>c>m,"BigNumber, BigNumber":function(m,v){return m.gt(v)&&!Bt(m,v,t.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},s,u({SS:f,DS:o,Ss:l}))}),H2=q(Ui,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Ui,{"number, number":function(n,i){return n>i&&!nt(n,i,t.epsilon)}})}),Li="largerEq",Z2=["typed","config","matrix","DenseMatrix","concat"],J2=q(Li,Z2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n,concat:i}=r,o=Yr({typed:e}),f=$t({typed:e,DenseMatrix:n}),l=Ir({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:a,concat:i}),s=sa({typed:e});return e(Li,X2({typed:e,config:t}),{"boolean, boolean":(c,m)=>c>=m,"BigNumber, BigNumber":function(m,v){return m.gte(v)||Bt(m,v,t.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)!==-1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},s,u({SS:f,DS:o,Ss:l}))}),X2=q(Li,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Li,{"number, number":function(n,i){return n>=i||nt(n,i,t.epsilon)}})}),iv="deepEqual",W2=["typed","equal"],Y2=q(iv,W2,r=>{var{typed:e,equal:t}=r;return e(iv,{"any, any":function(i,o){return a(i.valueOf(),o.valueOf())}});function a(n,i){if(Array.isArray(n))if(Array.isArray(i)){var o=n.length;if(o!==i.length)return!1;for(var f=0;f<o;f++)if(!a(n[f],i[f]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:t(n,i)}}),ki="unequal",Q2=["typed","config","equalScalar","matrix","DenseMatrix","concat"],K2=q(ki,Q2,r=>{var{typed:e,config:t,equalScalar:a,matrix:n,DenseMatrix:i,concat:o}=r,f=Yr({typed:e}),l=$t({typed:e,DenseMatrix:i}),u=Ir({typed:e,DenseMatrix:i}),s=dr({typed:e,matrix:n,concat:o});return e(ki,j2({typed:e,equalScalar:a}),s({elop:c,SS:l,DS:f,Ss:u}));function c(m,v){return!a(m,v)}}),j2=q(ki,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e(ki,{"any, any":function(n,i){return n===null?i!==null:i===null?n!==null:n===void 0?i!==void 0:i===void 0?n!==void 0:!t(n,i)}})}),ov="partitionSelect",eD=["typed","isNumeric","isNaN","compare"],rD=q(ov,eD,r=>{var{typed:e,isNumeric:t,isNaN:a,compare:n}=r,i=n,o=(u,s)=>-n(u,s);return e(ov,{"Array | Matrix, number":function(s,c){return f(s,c,i)},"Array | Matrix, number, string":function(s,c,m){if(m==="asc")return f(s,c,i);if(m==="desc")return f(s,c,o);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":f});function f(u,s,c){if(!qe(s)||s<0)throw new Error("k must be a non-negative integer");if(Ve(u)){var m=u.size();if(m.length>1)throw new Error("Only one dimensional matrices supported");return l(u.valueOf(),s,c)}if(Array.isArray(u))return l(u,s,c)}function l(u,s,c){if(s>=u.length)throw new Error("k out of bounds");for(var m=0;m<u.length;m++)if(t(u[m])&&a(u[m]))return u[m];for(var v=0,h=u.length-1;v<h;){for(var p=v,g=h,y=u[Math.floor(Math.random()*(h-v+1))+v];p<g;)if(c(u[p],y)>=0){var N=u[g];u[g]=u[p],u[p]=N,--g}else++p;c(u[p],y)>0&&--p,s<=p?h=p:v=p+1}return u[s]}}),sv="sort",tD=["typed","matrix","compare","compareNatural"],nD=q(sv,tD,r=>{var{typed:e,matrix:t,compare:a,compareNatural:n}=r,i=a,o=(s,c)=>-a(s,c);return e(sv,{Array:function(c){return l(c),c.sort(i)},Matrix:function(c){return u(c),t(c.toArray().sort(i),c.storage())},"Array, function":function(c,m){return l(c),c.sort(m)},"Matrix, function":function(c,m){return u(c),t(c.toArray().sort(m),c.storage())},"Array, string":function(c,m){return l(c),c.sort(f(m))},"Matrix, string":function(c,m){return u(c),t(c.toArray().sort(f(m)),c.storage())}});function f(s){if(s==="asc")return i;if(s==="desc")return o;if(s==="natural")return n;throw new Error('String "asc", "desc", or "natural" expected')}function l(s){if(er(s).length!==1)throw new Error("One dimensional array expected")}function u(s){if(s.size().length!==1)throw new Error("One dimensional matrix expected")}}),uv="max",aD=["typed","config","numeric","larger"],lv=q(uv,aD,r=>{var{typed:e,config:t,numeric:a,larger:n}=r;return e(uv,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(l,u){return Si(l,u.valueOf(),i)},"...":function(l){if(aa(l))throw new TypeError("Scalar values expected in function max");return o(l)}});function i(f,l){try{return n(f,l)?f:l}catch(u){throw Qr(u,"max",l)}}function o(f){var l;if(Xt(f,function(u){try{isNaN(u)&&typeof u=="number"?l=NaN:(l===void 0||n(u,l))&&(l=u)}catch(s){throw Qr(s,"max",u)}}),l===void 0)throw new Error("Cannot calculate max of an empty array");return typeof l=="string"&&(l=a(l,t.number)),l}}),cv="min",iD=["typed","config","numeric","smaller"],fv=q(cv,iD,r=>{var{typed:e,config:t,numeric:a,smaller:n}=r;return e(cv,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(l,u){return Si(l,u.valueOf(),i)},"...":function(l){if(aa(l))throw new TypeError("Scalar values expected in function min");return o(l)}});function i(f,l){try{return n(f,l)?f:l}catch(u){throw Qr(u,"min",l)}}function o(f){var l;if(Xt(f,function(u){try{isNaN(u)&&typeof u=="number"?l=NaN:(l===void 0||n(u,l))&&(l=u)}catch(s){throw Qr(s,"min",u)}}),l===void 0)throw new Error("Cannot calculate min of an empty array");return typeof l=="string"&&(l=a(l,t.number)),l}}),oD="ImmutableDenseMatrix",sD=["smaller","DenseMatrix"],uD=q(oD,sD,r=>{var{smaller:e,DenseMatrix:t}=r;function a(n,i){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(i&&!Wr(i))throw new Error("Invalid datatype: "+i);if(Ve(n)||cr(n)){var o=new t(n,i);this._data=o._data,this._size=o._size,this._datatype=o._datatype,this._min=null,this._max=null}else if(n&&cr(n.data)&&cr(n.size))this._data=n.data,this._size=n.size,this._datatype=n.datatype,this._min=typeof n.min<"u"?n.min:null,this._max=typeof n.max<"u"?n.max:null;else{if(n)throw new TypeError("Unsupported type of data ("+br(n)+")");this._data=[],this._size=[0],this._datatype=i,this._min=null,this._max=null}}return a.prototype=new t,a.prototype.type="ImmutableDenseMatrix",a.prototype.isImmutableDenseMatrix=!0,a.prototype.subset=function(n){switch(arguments.length){case 1:{var i=t.prototype.subset.call(this,n);return Ve(i)?new a({data:i._data,size:i._size,datatype:i._datatype}):i}case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},a.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},a.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},a.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},a.prototype.clone=function(){return new a({data:Ge(this._data),size:Ge(this._size),datatype:this._datatype})},a.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},a.fromJSON=function(n){return new a(n)},a.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},a.prototype.min=function(){if(this._min===null){var n=null;this.forEach(function(i){(n===null||e(i,n))&&(n=i)}),this._min=n!==null?n:void 0}return this._min},a.prototype.max=function(){if(this._max===null){var n=null;this.forEach(function(i){(n===null||e(n,i))&&(n=i)}),this._max=n!==null?n:void 0}return this._max},a},{isClass:!0}),lD="Index",cD=["ImmutableDenseMatrix"],fD=q(lD,cD,r=>{var{ImmutableDenseMatrix:e}=r;function t(n){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var i=0,o=arguments.length;i<o;i++){var f=arguments[i];if(Uo(f))this._dimensions.push(f),this._isScalar=!1;else if(Array.isArray(f)||Ve(f)){var l=a(f.valueOf());this._dimensions.push(l);var u=l.size();(u.length!==1||u[0]!==1)&&(this._isScalar=!1)}else if(typeof f=="number")this._dimensions.push(a([f]));else if(typeof f=="string")this._dimensions.push(f);else throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range")}}t.prototype.type="Index",t.prototype.isIndex=!0;function a(n){for(var i=0,o=n.length;i<o;i++)if(typeof n[i]!="number"||!qe(n[i]))throw new TypeError("Index parameters must be positive integer numbers");return new e(n)}return t.prototype.clone=function(){var n=new t;return n._dimensions=Ge(this._dimensions),n._isScalar=this._isScalar,n},t.create=function(n){var i=new t;return t.apply(i,n),i},t.prototype.size=function(){for(var n=[],i=0,o=this._dimensions.length;i<o;i++){var f=this._dimensions[i];n[i]=typeof f=="string"?1:f.size()[0]}return n},t.prototype.max=function(){for(var n=[],i=0,o=this._dimensions.length;i<o;i++){var f=this._dimensions[i];n[i]=typeof f=="string"?f:f.max()}return n},t.prototype.min=function(){for(var n=[],i=0,o=this._dimensions.length;i<o;i++){var f=this._dimensions[i];n[i]=typeof f=="string"?f:f.min()}return n},t.prototype.forEach=function(n){for(var i=0,o=this._dimensions.length;i<o;i++)n(this._dimensions[i],i,this)},t.prototype.dimension=function(n){return this._dimensions[n]||null},t.prototype.isObjectProperty=function(){return this._dimensions.length===1&&typeof this._dimensions[0]=="string"},t.prototype.getObjectProperty=function(){return this.isObjectProperty()?this._dimensions[0]:null},t.prototype.isScalar=function(){return this._isScalar},t.prototype.toArray=function(){for(var n=[],i=0,o=this._dimensions.length;i<o;i++){var f=this._dimensions[i];n.push(typeof f=="string"?f:f.toArray())}return n},t.prototype.valueOf=t.prototype.toArray,t.prototype.toString=function(){for(var n=[],i=0,o=this._dimensions.length;i<o;i++){var f=this._dimensions[i];typeof f=="string"?n.push(JSON.stringify(f)):n.push(f.toString())}return"["+n.join(", ")+"]"},t.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},t.fromJSON=function(n){return t.create(n.dimensions)},t},{isClass:!0}),mD="FibonacciHeap",vD=["smaller","larger"],pD=q(mD,vD,r=>{var{smaller:e,larger:t}=r,a=1/Math.log((1+Math.sqrt(5))/2);function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}n.prototype.type="FibonacciHeap",n.prototype.isFibonacciHeap=!0,n.prototype.insert=function(s,c){var m={key:s,value:c,degree:0};if(this._minimum){var v=this._minimum;m.left=v,m.right=v.right,v.right=m,m.right.left=m,e(s,v.key)&&(this._minimum=m)}else m.left=m,m.right=m,this._minimum=m;return this._size++,m},n.prototype.size=function(){return this._size},n.prototype.clear=function(){this._minimum=null,this._size=0},n.prototype.isEmpty=function(){return this._size===0},n.prototype.extractMinimum=function(){var s=this._minimum;if(s===null)return s;for(var c=this._minimum,m=s.degree,v=s.child;m>0;){var h=v.right;v.left.right=v.right,v.right.left=v.left,v.left=c,v.right=c.right,c.right=v,v.right.left=v,v.parent=null,v=h,m--}return s.left.right=s.right,s.right.left=s.left,s===s.right?c=null:(c=s.right,c=u(c,this._size)),this._size--,this._minimum=c,s},n.prototype.remove=function(s){this._minimum=i(this._minimum,s,-1),this.extractMinimum()};function i(s,c,m){c.key=m;var v=c.parent;return v&&e(c.key,v.key)&&(o(s,c,v),f(s,v)),e(c.key,s.key)&&(s=c),s}function o(s,c,m){c.left.right=c.right,c.right.left=c.left,m.degree--,m.child===c&&(m.child=c.right),m.degree===0&&(m.child=null),c.left=s,c.right=s.right,s.right=c,c.right.left=c,c.parent=null,c.mark=!1}function f(s,c){var m=c.parent;!m||(c.mark?(o(s,c,m),f(m)):c.mark=!0)}var l=function(c,m){c.left.right=c.right,c.right.left=c.left,c.parent=m,m.child?(c.left=m.child,c.right=m.child.right,m.child.right=c,c.right.left=c):(m.child=c,c.right=c,c.left=c),m.degree++,c.mark=!1};function u(s,c){var m=Math.floor(Math.log(c)*a)+1,v=new Array(m),h=0,p=s;if(p)for(h++,p=p.right;p!==s;)h++,p=p.right;for(var g;h>0;){for(var y=p.degree,N=p.right;g=v[y],!!g;){if(t(p.key,g.key)){var d=g;g=p,p=d}l(g,p),v[y]=null,y++}v[y]=p,p=N,h--}s=null;for(var w=0;w<m;w++)g=v[w],g&&(s?(g.left.right=g.right,g.right.left=g.left,g.left=s,g.right=s.right,s.right=g,g.right.left=g,e(g.key,s.key)&&(s=g)):s=g);return s}return n},{isClass:!0}),hD="Spa",dD=["addScalar","equalScalar","FibonacciHeap"],gD=q(hD,dD,r=>{var{addScalar:e,equalScalar:t,FibonacciHeap:a}=r;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new a}return n.prototype.type="Spa",n.prototype.isSpa=!0,n.prototype.set=function(i,o){if(this._values[i])this._values[i].value=o;else{var f=this._heap.insert(i,o);this._values[i]=f}},n.prototype.get=function(i){var o=this._values[i];return o?o.value:0},n.prototype.accumulate=function(i,o){var f=this._values[i];f?f.value=e(f.value,o):(f=this._heap.insert(i,o),this._values[i]=f)},n.prototype.forEach=function(i,o,f){var l=this._heap,u=this._values,s=[],c=l.extractMinimum();for(c&&s.push(c);c&&c.key<=o;)c.key>=i&&(t(c.value,0)||f(c.key,c.value,this)),c=l.extractMinimum(),c&&s.push(c);for(var m=0;m<s.length;m++){var v=s[m];c=l.insert(v.key,v.value),u[c.key]=c}},n.prototype.swap=function(i,o){var f=this._values[i],l=this._values[o];if(!f&&l)f=this._heap.insert(i,l.value),this._heap.remove(l),this._values[i]=f,this._values[o]=void 0;else if(f&&!l)l=this._heap.insert(o,f.value),this._heap.remove(f),this._values[o]=l,this._values[i]=void 0;else if(f&&l){var u=f.value;f.value=l.value,l.value=u}},n},{isClass:!0});function Ja(r){return Ja=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ja(r)}function yD(r,e){if(Ja(r)!=="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var a=t.call(r,e||"default");if(Ja(a)!=="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function bD(r){var e=yD(r,"string");return Ja(e)==="symbol"?e:String(e)}function zr(r,e,t){return e=bD(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var xD=Va(function(r){return new r(1).exp()},{hasher:Vi}),wD=Va(function(r){return new r(1).plus(new r(5).sqrt()).div(2)},{hasher:Vi}),gs=Va(function(r){return r.acos(-1)},{hasher:Vi}),ND=Va(function(r){return gs(r).times(2)},{hasher:Vi});function Vi(r){return r[0].precision}function mv(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);e&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,a)}return t}function ys(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?mv(Object(t),!0).forEach(function(a){zr(r,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):mv(Object(t)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(t,a))})}return r}var DD="Unit",AD=["?on","config","addScalar","subtract","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","number","Complex","BigNumber","Fraction"],ED=q(DD,AD,r=>{var{on:e,config:t,addScalar:a,subtract:n,multiplyScalar:i,divideScalar:o,pow:f,abs:l,fix:u,round:s,equal:c,isNumeric:m,format:v,number:h,Complex:p,BigNumber:g,Fraction:y}=r,N=h;function d(V,X){if(!(this instanceof d))throw new Error("Constructor must be called with the new operator");if(!(V==null||m(V)||kt(V)))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(this.fixPrefix=!1,this.skipAutomaticSimplification=!0,X===void 0)this.units=[],this.dimensions=H.map(G=>0);else if(typeof X=="string"){var oe=d.parse(X);this.units=oe.units,this.dimensions=oe.dimensions}else if(Vt(X)&&X.value===null)this.fixPrefix=X.fixPrefix,this.skipAutomaticSimplification=X.skipAutomaticSimplification,this.dimensions=X.dimensions.slice(0),this.units=X.units.map(G=>Sr({},G));else throw new TypeError("Second parameter in Unit constructor must be a string or valueless Unit");this.value=this._normalize(V)}Object.defineProperty(d,"name",{value:"Unit"}),d.prototype.constructor=d,d.prototype.type="Unit",d.prototype.isUnit=!0;var w,x,b;function E(){for(;b===" "||b===" ";)D()}function A(V){return V>="0"&&V<="9"||V==="."}function S(V){return V>="0"&&V<="9"}function D(){x++,b=w.charAt(x)}function T(V){x=V,b=w.charAt(x)}function B(){var V="",X=x;if(b==="+"?D():b==="-"&&(V+=b,D()),!A(b))return T(X),null;if(b==="."){if(V+=b,D(),!S(b))return T(X),null}else{for(;S(b);)V+=b,D();b==="."&&(V+=b,D())}for(;S(b);)V+=b,D();if(b==="E"||b==="e"){var oe="",G=x;if(oe+=b,D(),(b==="+"||b==="-")&&(oe+=b,D()),!S(b))return T(G),V;for(V=V+oe;S(b);)V+=b,D()}return V}function I(){for(var V="";S(b)||d.isValidAlpha(b);)V+=b,D();var X=V.charAt(0);return d.isValidAlpha(X)?V:null}function P(V){return b===V?(D(),V):null}d.parse=function(V,X){if(X=X||{},w=V,x=-1,b="",typeof w!="string")throw new TypeError("Invalid argument in Unit.parse, string expected");var oe=new d;oe.units=[];var G=1,Y=!1;D(),E();var te=B(),ye=null;if(te){if(t.number==="BigNumber")ye=new g(te);else if(t.number==="Fraction")try{ye=new y(te)}catch{ye=parseFloat(te)}else ye=parseFloat(te);E(),P("*")?(G=1,Y=!0):P("/")&&(G=-1,Y=!0)}for(var me=[],z=1;;){for(E();b==="(";)me.push(G),z*=G,G=1,D(),E();var U=void 0;if(b){var ee=b;if(U=I(),U===null)throw new SyntaxError('Unexpected "'+ee+'" in "'+w+'" at index '+x.toString())}else break;var ue=R(U);if(ue===null)throw new SyntaxError('Unit "'+U+'" not found.');var ve=G*z;if(E(),P("^")){E();var de=B();if(de===null)throw new SyntaxError('In "'+V+'", "^" must be followed by a floating-point number');ve*=de}oe.units.push({unit:ue.unit,prefix:ue.prefix,power:ve});for(var be=0;be<H.length;be++)oe.dimensions[be]+=(ue.unit.dimensions[be]||0)*ve;for(E();b===")";){if(me.length===0)throw new SyntaxError('Unmatched ")" in "'+w+'" at index '+x.toString());z/=me.pop(),D(),E()}if(Y=!1,P("*")?(G=1,Y=!0):P("/")?(G=-1,Y=!0):G=1,ue.unit.base){var pe=ue.unit.base.key;re.auto[pe]={unit:ue.unit,prefix:ue.prefix}}}if(E(),b)throw new SyntaxError('Could not parse: "'+V+'"');if(Y)throw new SyntaxError('Trailing characters: "'+V+'"');if(me.length!==0)throw new SyntaxError('Unmatched "(" in "'+w+'"');if(oe.units.length===0&&!X.allowNoUnits)throw new SyntaxError('"'+V+'" contains no units');return oe.value=ye!==void 0?oe._normalize(ye):null,oe},d.prototype.clone=function(){var V=new d;V.fixPrefix=this.fixPrefix,V.skipAutomaticSimplification=this.skipAutomaticSimplification,V.value=Ge(this.value),V.dimensions=this.dimensions.slice(0),V.units=[];for(var X=0;X<this.units.length;X++){V.units[X]={};for(var oe in this.units[X])Re(this.units[X],oe)&&(V.units[X][oe]=this.units[X][oe])}return V},d.prototype.valueType=function(){return br(this.value)},d.prototype._isDerived=function(){return this.units.length===0?!1:this.units.length>1||Math.abs(this.units[0].power-1)>1e-15},d.prototype._normalize=function(V){if(V==null||this.units.length===0)return V;for(var X=V,oe=d._getNumberConverter(br(V)),G=0;G<this.units.length;G++){var Y=oe(this.units[G].unit.value),te=oe(this.units[G].prefix.value),ye=oe(this.units[G].power);X=i(X,f(i(Y,te),ye))}return X},d.prototype._denormalize=function(V,X){if(V==null||this.units.length===0)return V;for(var oe=V,G=d._getNumberConverter(br(V)),Y=0;Y<this.units.length;Y++){var te=G(this.units[Y].unit.value),ye=G(this.units[Y].prefix.value),me=G(this.units[Y].power);oe=o(oe,f(i(te,ye),me))}return oe};var R=Va(V=>{if(Re(L,V)){var X=L[V],oe=X.prefixes[""];return{unit:X,prefix:oe}}for(var G in L)if(Re(L,G)&&yg(V,G)){var Y=L[G],te=V.length-G.length,ye=V.substring(0,te),me=Re(Y.prefixes,ye)?Y.prefixes[ye]:void 0;if(me!==void 0)return{unit:Y,prefix:me}}return null},{hasher:V=>V[0],limit:100});d.isValuelessUnit=function(V){return R(V)!==null},d.prototype.hasBase=function(V){if(typeof V=="string"&&(V=$[V]),!V)return!1;for(var X=0;X<H.length;X++)if(Math.abs((this.dimensions[X]||0)-(V.dimensions[X]||0))>1e-12)return!1;return!0},d.prototype.equalBase=function(V){for(var X=0;X<H.length;X++)if(Math.abs((this.dimensions[X]||0)-(V.dimensions[X]||0))>1e-12)return!1;return!0},d.prototype.equals=function(V){return this.equalBase(V)&&c(this.value,V.value)},d.prototype.multiply=function(V){for(var X=this.clone(),oe=Vt(V)?V:new d(V),G=0;G<H.length;G++)X.dimensions[G]=(this.dimensions[G]||0)+(oe.dimensions[G]||0);for(var Y=0;Y<oe.units.length;Y++){var te=ys({},oe.units[Y]);X.units.push(te)}if(this.value!==null||oe.value!==null){var ye=this.value===null?this._normalize(1):this.value,me=oe.value===null?oe._normalize(1):oe.value;X.value=i(ye,me)}else X.value=null;return Vt(V)&&(X.skipAutomaticSimplification=!1),M(X)},d.prototype.divideInto=function(V){return new d(V).divide(this)},d.prototype.divide=function(V){for(var X=this.clone(),oe=Vt(V)?V:new d(V),G=0;G<H.length;G++)X.dimensions[G]=(this.dimensions[G]||0)-(oe.dimensions[G]||0);for(var Y=0;Y<oe.units.length;Y++){var te=ys(ys({},oe.units[Y]),{},{power:-oe.units[Y].power});X.units.push(te)}if(this.value!==null||oe.value!==null){var ye=this.value===null?this._normalize(1):this.value,me=oe.value===null?oe._normalize(1):oe.value;X.value=o(ye,me)}else X.value=null;return Vt(V)&&(X.skipAutomaticSimplification=!1),M(X)},d.prototype.pow=function(V){for(var X=this.clone(),oe=0;oe<H.length;oe++)X.dimensions[oe]=(this.dimensions[oe]||0)*V;for(var G=0;G<X.units.length;G++)X.units[G].power*=V;return X.value!==null?X.value=f(X.value,V):X.value=null,X.skipAutomaticSimplification=!1,M(X)};function M(V){return V.equalBase($.NONE)&&V.value!==null&&!t.predictable?V.value:V}d.prototype.abs=function(){var V=this.clone();if(V.value!==null)if(V._isDerived()||V.units[0].unit.offset===0)V.value=l(V.value);else{var X=V._numberConverter(),oe=X(V.units[0].unit.value),G=X(V.units[0].unit.offset),Y=i(oe,G);V.value=n(l(a(V.value,Y)),Y)}for(var te in V.units)(V.units[te].unit.name==="VA"||V.units[te].unit.name==="VAR")&&(V.units[te].unit=L.W);return V},d.prototype.to=function(V){var X=this.value===null?this._normalize(1):this.value,oe;if(typeof V=="string")oe=d.parse(V);else if(Vt(V))oe=V.clone();else throw new Error("String or Unit expected as parameter");if(!this.equalBase(oe))throw new Error("Units do not match ('".concat(oe.toString(),"' != '").concat(this.toString(),"')"));if(oe.value!==null)throw new Error("Cannot convert to a unit with a value");if(this.value===null||this._isDerived()||this.units[0].unit.offset===oe.units[0].unit.offset)oe.value=Ge(X);else{var G=d._getNumberConverter(br(X)),Y=G(this.units[0].unit.value),te=G(this.units[0].unit.offset),ye=i(Y,te),me=G(oe.units[0].unit.value),z=G(oe.units[0].unit.offset),U=i(me,z);oe.value=n(a(X,ye),U)}return oe.fixPrefix=!0,oe.skipAutomaticSimplification=!0,oe},d.prototype.toNumber=function(V){return N(this.toNumeric(V))},d.prototype.toNumeric=function(V){var X;return V?X=this.to(V):X=this.clone(),X._isDerived()||X.units.length===0?X._denormalize(X.value):X._denormalize(X.value,X.units[0].prefix.value)},d.prototype.toString=function(){return this.format()},d.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.formatUnits(),fixPrefix:this.fixPrefix}},d.fromJSON=function(V){var X=new d(V.value,V.unit);return X.fixPrefix=V.fixPrefix||!1,X},d.prototype.valueOf=d.prototype.toString,d.prototype.simplify=function(){var V=this.clone(),X=[],oe;for(var G in fe)if(Re(fe,G)&&V.hasBase($[G])){oe=G;break}if(oe==="NONE")V.units=[];else{var Y;if(oe&&Re(fe,oe)&&(Y=fe[oe]),Y)V.units=[{unit:Y.unit,prefix:Y.prefix,power:1}];else{for(var te=!1,ye=0;ye<H.length;ye++){var me=H[ye];Math.abs(V.dimensions[ye]||0)>1e-12&&(Re(fe,me)?X.push({unit:fe[me].unit,prefix:fe[me].prefix,power:V.dimensions[ye]||0}):te=!0)}X.length<V.units.length&&!te&&(V.units=X)}}return V},d.prototype.toSI=function(){for(var V=this.clone(),X=[],oe=0;oe<H.length;oe++){var G=H[oe];if(Math.abs(V.dimensions[oe]||0)>1e-12)if(Re(re.si,G))X.push({unit:re.si[G].unit,prefix:re.si[G].prefix,power:V.dimensions[oe]||0});else throw new Error("Cannot express custom unit "+G+" in SI units")}return V.units=X,V.fixPrefix=!0,V.skipAutomaticSimplification=!0,V},d.prototype.formatUnits=function(){for(var V="",X="",oe=0,G=0,Y=0;Y<this.units.length;Y++)this.units[Y].power>0?(oe++,V+=" "+this.units[Y].prefix.name+this.units[Y].unit.name,Math.abs(this.units[Y].power-1)>1e-15&&(V+="^"+this.units[Y].power)):this.units[Y].power<0&&G++;if(G>0)for(var te=0;te<this.units.length;te++)this.units[te].power<0&&(oe>0?(X+=" "+this.units[te].prefix.name+this.units[te].unit.name,Math.abs(this.units[te].power+1)>1e-15&&(X+="^"+-this.units[te].power)):(X+=" "+this.units[te].prefix.name+this.units[te].unit.name,X+="^"+this.units[te].power));V=V.substr(1),X=X.substr(1),oe>1&&G>0&&(V="("+V+")"),G>1&&oe>0&&(X="("+X+")");var ye=V;return oe>0&&G>0&&(ye+=" / "),ye+=X,ye},d.prototype.format=function(V){var X=this.skipAutomaticSimplification||this.value===null?this.clone():this.simplify(),oe=!1;typeof X.value<"u"&&X.value!==null&&kt(X.value)&&(oe=Math.abs(X.value.re)<1e-14);for(var G in X.units)Re(X.units,G)&&X.units[G].unit&&(X.units[G].unit.name==="VA"&&oe?X.units[G].unit=L.VAR:X.units[G].unit.name==="VAR"&&!oe&&(X.units[G].unit=L.VA));X.units.length===1&&!X.fixPrefix&&Math.abs(X.units[0].power-Math.round(X.units[0].power))<1e-14&&(X.units[0].prefix=X._bestPrefix());var Y=X._denormalize(X.value),te=X.value!==null?v(Y,V||{}):"",ye=X.formatUnits();return X.value&&kt(X.value)&&(te="("+te+")"),ye.length>0&&te.length>0&&(te+=" "),te+=ye,te},d.prototype._bestPrefix=function(){if(this.units.length!==1)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var V=this.value!==null?l(this.value):0,X=l(this.units[0].unit.value),oe=this.units[0].prefix;if(V===0)return oe;var G=this.units[0].power,Y=Math.log(V/Math.pow(oe.value*X,G))/Math.LN10-1.2;if(Y>-2.200001&&Y<1.800001)return oe;Y=Math.abs(Y);var te=this.units[0].unit.prefixes;for(var ye in te)if(Re(te,ye)){var me=te[ye];if(me.scientific){var z=Math.abs(Math.log(V/Math.pow(me.value*X,G))/Math.LN10-1.2);(z<Y||z===Y&&me.name.length<oe.name.length)&&(oe=me,Y=z)}}return oe},d.prototype.splitUnit=function(V){for(var X=this.clone(),oe=[],G=0;G<V.length&&(X=X.to(V[G]),G!==V.length-1);G++){var Y=X.toNumeric(),te=s(Y),ye=void 0,me=c(te,Y);me?ye=te:ye=u(X.toNumeric());var z=new d(ye,V[G].toString());oe.push(z),X=n(X,z)}for(var U=0,ee=0;ee<oe.length;ee++)U=a(U,oe[ee].value);return c(U,this.value)&&(X.value=0),oe.push(X),oe};var F={NONE:{"":{name:"",value:1,scientific:!0}},SHORT:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:10,scientific:!1},h:{name:"h",value:100,scientific:!1},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0},d:{name:"d",value:.1,scientific:!1},c:{name:"c",value:.01,scientific:!1},m:{name:"m",value:.001,scientific:!0},u:{name:"u",value:1e-6,scientific:!0},n:{name:"n",value:1e-9,scientific:!0},p:{name:"p",value:1e-12,scientific:!0},f:{name:"f",value:1e-15,scientific:!0},a:{name:"a",value:1e-18,scientific:!0},z:{name:"z",value:1e-21,scientific:!0},y:{name:"y",value:1e-24,scientific:!0}},LONG:{"":{name:"",value:1,scientific:!0},deca:{name:"deca",value:10,scientific:!1},hecto:{name:"hecto",value:100,scientific:!1},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0},deci:{name:"deci",value:.1,scientific:!1},centi:{name:"centi",value:.01,scientific:!1},milli:{name:"milli",value:.001,scientific:!0},micro:{name:"micro",value:1e-6,scientific:!0},nano:{name:"nano",value:1e-9,scientific:!0},pico:{name:"pico",value:1e-12,scientific:!0},femto:{name:"femto",value:1e-15,scientific:!0},atto:{name:"atto",value:1e-18,scientific:!0},zepto:{name:"zepto",value:1e-21,scientific:!0},yocto:{name:"yocto",value:1e-24,scientific:!0}},SQUARED:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:100,scientific:!1},h:{name:"h",value:1e4,scientific:!1},k:{name:"k",value:1e6,scientific:!0},M:{name:"M",value:1e12,scientific:!0},G:{name:"G",value:1e18,scientific:!0},T:{name:"T",value:1e24,scientific:!0},P:{name:"P",value:1e30,scientific:!0},E:{name:"E",value:1e36,scientific:!0},Z:{name:"Z",value:1e42,scientific:!0},Y:{name:"Y",value:1e48,scientific:!0},d:{name:"d",value:.01,scientific:!1},c:{name:"c",value:1e-4,scientific:!1},m:{name:"m",value:1e-6,scientific:!0},u:{name:"u",value:1e-12,scientific:!0},n:{name:"n",value:1e-18,scientific:!0},p:{name:"p",value:1e-24,scientific:!0},f:{name:"f",value:1e-30,scientific:!0},a:{name:"a",value:1e-36,scientific:!0},z:{name:"z",value:1e-42,scientific:!0},y:{name:"y",value:1e-48,scientific:!0}},CUBIC:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:1e3,scientific:!1},h:{name:"h",value:1e6,scientific:!1},k:{name:"k",value:1e9,scientific:!0},M:{name:"M",value:1e18,scientific:!0},G:{name:"G",value:1e27,scientific:!0},T:{name:"T",value:1e36,scientific:!0},P:{name:"P",value:1e45,scientific:!0},E:{name:"E",value:1e54,scientific:!0},Z:{name:"Z",value:1e63,scientific:!0},Y:{name:"Y",value:1e72,scientific:!0},d:{name:"d",value:.001,scientific:!1},c:{name:"c",value:1e-6,scientific:!1},m:{name:"m",value:1e-9,scientific:!0},u:{name:"u",value:1e-18,scientific:!0},n:{name:"n",value:1e-27,scientific:!0},p:{name:"p",value:1e-36,scientific:!0},f:{name:"f",value:1e-45,scientific:!0},a:{name:"a",value:1e-54,scientific:!0},z:{name:"z",value:1e-63,scientific:!0},y:{name:"y",value:1e-72,scientific:!0}},BINARY_SHORT_SI:{"":{name:"",value:1,scientific:!0},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0}},BINARY_SHORT_IEC:{"":{name:"",value:1,scientific:!0},Ki:{name:"Ki",value:1024,scientific:!0},Mi:{name:"Mi",value:Math.pow(1024,2),scientific:!0},Gi:{name:"Gi",value:Math.pow(1024,3),scientific:!0},Ti:{name:"Ti",value:Math.pow(1024,4),scientific:!0},Pi:{name:"Pi",value:Math.pow(1024,5),scientific:!0},Ei:{name:"Ei",value:Math.pow(1024,6),scientific:!0},Zi:{name:"Zi",value:Math.pow(1024,7),scientific:!0},Yi:{name:"Yi",value:Math.pow(1024,8),scientific:!0}},BINARY_LONG_SI:{"":{name:"",value:1,scientific:!0},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0}},BINARY_LONG_IEC:{"":{name:"",value:1,scientific:!0},kibi:{name:"kibi",value:1024,scientific:!0},mebi:{name:"mebi",value:Math.pow(1024,2),scientific:!0},gibi:{name:"gibi",value:Math.pow(1024,3),scientific:!0},tebi:{name:"tebi",value:Math.pow(1024,4),scientific:!0},pebi:{name:"pebi",value:Math.pow(1024,5),scientific:!0},exi:{name:"exi",value:Math.pow(1024,6),scientific:!0},zebi:{name:"zebi",value:Math.pow(1024,7),scientific:!0},yobi:{name:"yobi",value:Math.pow(1024,8),scientific:!0}},BTU:{"":{name:"",value:1,scientific:!0},MM:{name:"MM",value:1e6,scientific:!0}}};F.SHORTLONG=Sr({},F.SHORT,F.LONG),F.BINARY_SHORT=Sr({},F.BINARY_SHORT_SI,F.BINARY_SHORT_IEC),F.BINARY_LONG=Sr({},F.BINARY_LONG_SI,F.BINARY_LONG_IEC);var H=["MASS","LENGTH","TIME","CURRENT","TEMPERATURE","LUMINOUS_INTENSITY","AMOUNT_OF_SUBSTANCE","ANGLE","BIT"],$={NONE:{dimensions:[0,0,0,0,0,0,0,0,0]},MASS:{dimensions:[1,0,0,0,0,0,0,0,0]},LENGTH:{dimensions:[0,1,0,0,0,0,0,0,0]},TIME:{dimensions:[0,0,1,0,0,0,0,0,0]},CURRENT:{dimensions:[0,0,0,1,0,0,0,0,0]},TEMPERATURE:{dimensions:[0,0,0,0,1,0,0,0,0]},LUMINOUS_INTENSITY:{dimensions:[0,0,0,0,0,1,0,0,0]},AMOUNT_OF_SUBSTANCE:{dimensions:[0,0,0,0,0,0,1,0,0]},FORCE:{dimensions:[1,1,-2,0,0,0,0,0,0]},SURFACE:{dimensions:[0,2,0,0,0,0,0,0,0]},VOLUME:{dimensions:[0,3,0,0,0,0,0,0,0]},ENERGY:{dimensions:[1,2,-2,0,0,0,0,0,0]},POWER:{dimensions:[1,2,-3,0,0,0,0,0,0]},PRESSURE:{dimensions:[1,-1,-2,0,0,0,0,0,0]},ELECTRIC_CHARGE:{dimensions:[0,0,1,1,0,0,0,0,0]},ELECTRIC_CAPACITANCE:{dimensions:[-1,-2,4,2,0,0,0,0,0]},ELECTRIC_POTENTIAL:{dimensions:[1,2,-3,-1,0,0,0,0,0]},ELECTRIC_RESISTANCE:{dimensions:[1,2,-3,-2,0,0,0,0,0]},ELECTRIC_INDUCTANCE:{dimensions:[1,2,-2,-2,0,0,0,0,0]},ELECTRIC_CONDUCTANCE:{dimensions:[-1,-2,3,2,0,0,0,0,0]},MAGNETIC_FLUX:{dimensions:[1,2,-2,-1,0,0,0,0,0]},MAGNETIC_FLUX_DENSITY:{dimensions:[1,0,-2,-1,0,0,0,0,0]},FREQUENCY:{dimensions:[0,0,-1,0,0,0,0,0,0]},ANGLE:{dimensions:[0,0,0,0,0,0,0,1,0]},BIT:{dimensions:[0,0,0,0,0,0,0,0,1]}};for(var k in $)Re($,k)&&($[k].key=k);var Q={},K={name:"",base:Q,value:1,offset:0,dimensions:H.map(V=>0)},L={meter:{name:"meter",base:$.LENGTH,prefixes:F.LONG,value:1,offset:0},inch:{name:"inch",base:$.LENGTH,prefixes:F.NONE,value:.0254,offset:0},foot:{name:"foot",base:$.LENGTH,prefixes:F.NONE,value:.3048,offset:0},yard:{name:"yard",base:$.LENGTH,prefixes:F.NONE,value:.9144,offset:0},mile:{name:"mile",base:$.LENGTH,prefixes:F.NONE,value:1609.344,offset:0},link:{name:"link",base:$.LENGTH,prefixes:F.NONE,value:.201168,offset:0},rod:{name:"rod",base:$.LENGTH,prefixes:F.NONE,value:5.0292,offset:0},chain:{name:"chain",base:$.LENGTH,prefixes:F.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:$.LENGTH,prefixes:F.NONE,value:1e-10,offset:0},m:{name:"m",base:$.LENGTH,prefixes:F.SHORT,value:1,offset:0},in:{name:"in",base:$.LENGTH,prefixes:F.NONE,value:.0254,offset:0},ft:{name:"ft",base:$.LENGTH,prefixes:F.NONE,value:.3048,offset:0},yd:{name:"yd",base:$.LENGTH,prefixes:F.NONE,value:.9144,offset:0},mi:{name:"mi",base:$.LENGTH,prefixes:F.NONE,value:1609.344,offset:0},li:{name:"li",base:$.LENGTH,prefixes:F.NONE,value:.201168,offset:0},rd:{name:"rd",base:$.LENGTH,prefixes:F.NONE,value:5.02921,offset:0},ch:{name:"ch",base:$.LENGTH,prefixes:F.NONE,value:20.1168,offset:0},mil:{name:"mil",base:$.LENGTH,prefixes:F.NONE,value:254e-7,offset:0},m2:{name:"m2",base:$.SURFACE,prefixes:F.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:$.SURFACE,prefixes:F.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:$.SURFACE,prefixes:F.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:$.SURFACE,prefixes:F.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:$.SURFACE,prefixes:F.NONE,value:2589988110336e-6,offset:0},sqrd:{name:"sqrd",base:$.SURFACE,prefixes:F.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:$.SURFACE,prefixes:F.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:$.SURFACE,prefixes:F.NONE,value:64516e-14,offset:0},acre:{name:"acre",base:$.SURFACE,prefixes:F.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:$.SURFACE,prefixes:F.NONE,value:1e4,offset:0},m3:{name:"m3",base:$.VOLUME,prefixes:F.CUBIC,value:1,offset:0},L:{name:"L",base:$.VOLUME,prefixes:F.SHORT,value:.001,offset:0},l:{name:"l",base:$.VOLUME,prefixes:F.SHORT,value:.001,offset:0},litre:{name:"litre",base:$.VOLUME,prefixes:F.LONG,value:.001,offset:0},cuin:{name:"cuin",base:$.VOLUME,prefixes:F.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:$.VOLUME,prefixes:F.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:$.VOLUME,prefixes:F.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:$.VOLUME,prefixes:F.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:$.VOLUME,prefixes:F.NONE,value:15e-6,offset:0},drop:{name:"drop",base:$.VOLUME,prefixes:F.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:$.VOLUME,prefixes:F.NONE,value:5e-8,offset:0},minim:{name:"minim",base:$.VOLUME,prefixes:F.NONE,value:6161152e-14,offset:0},fluiddram:{name:"fluiddram",base:$.VOLUME,prefixes:F.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:$.VOLUME,prefixes:F.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:$.VOLUME,prefixes:F.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:$.VOLUME,prefixes:F.NONE,value:1e-6,offset:0},cup:{name:"cup",base:$.VOLUME,prefixes:F.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:$.VOLUME,prefixes:F.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:$.VOLUME,prefixes:F.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:$.VOLUME,prefixes:F.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:$.VOLUME,prefixes:F.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:$.VOLUME,prefixes:F.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:$.VOLUME,prefixes:F.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:$.VOLUME,prefixes:F.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:$.VOLUME,prefixes:F.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:$.VOLUME,prefixes:F.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:$.VOLUME,prefixes:F.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:$.VOLUME,prefixes:F.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:$.VOLUME,prefixes:F.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:$.VOLUME,prefixes:F.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:$.VOLUME,prefixes:F.NONE,value:.1173478,offset:0},obl:{name:"obl",base:$.VOLUME,prefixes:F.NONE,value:.1589873,offset:0},g:{name:"g",base:$.MASS,prefixes:F.SHORT,value:.001,offset:0},gram:{name:"gram",base:$.MASS,prefixes:F.LONG,value:.001,offset:0},ton:{name:"ton",base:$.MASS,prefixes:F.SHORT,value:907.18474,offset:0},t:{name:"t",base:$.MASS,prefixes:F.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:$.MASS,prefixes:F.LONG,value:1e3,offset:0},grain:{name:"grain",base:$.MASS,prefixes:F.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:$.MASS,prefixes:F.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:$.MASS,prefixes:F.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:$.MASS,prefixes:F.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:$.MASS,prefixes:F.NONE,value:45.359237,offset:0},stick:{name:"stick",base:$.MASS,prefixes:F.NONE,value:.115,offset:0},stone:{name:"stone",base:$.MASS,prefixes:F.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:$.MASS,prefixes:F.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:$.MASS,prefixes:F.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:$.MASS,prefixes:F.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:$.MASS,prefixes:F.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:$.MASS,prefixes:F.NONE,value:45.359237,offset:0},s:{name:"s",base:$.TIME,prefixes:F.SHORT,value:1,offset:0},min:{name:"min",base:$.TIME,prefixes:F.NONE,value:60,offset:0},h:{name:"h",base:$.TIME,prefixes:F.NONE,value:3600,offset:0},second:{name:"second",base:$.TIME,prefixes:F.LONG,value:1,offset:0},sec:{name:"sec",base:$.TIME,prefixes:F.LONG,value:1,offset:0},minute:{name:"minute",base:$.TIME,prefixes:F.NONE,value:60,offset:0},hour:{name:"hour",base:$.TIME,prefixes:F.NONE,value:3600,offset:0},day:{name:"day",base:$.TIME,prefixes:F.NONE,value:86400,offset:0},week:{name:"week",base:$.TIME,prefixes:F.NONE,value:7*86400,offset:0},month:{name:"month",base:$.TIME,prefixes:F.NONE,value:2629800,offset:0},year:{name:"year",base:$.TIME,prefixes:F.NONE,value:31557600,offset:0},decade:{name:"decade",base:$.TIME,prefixes:F.NONE,value:315576e3,offset:0},century:{name:"century",base:$.TIME,prefixes:F.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:$.TIME,prefixes:F.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:$.FREQUENCY,prefixes:F.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:$.FREQUENCY,prefixes:F.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:$.ANGLE,prefixes:F.SHORT,value:1,offset:0},radian:{name:"radian",base:$.ANGLE,prefixes:F.LONG,value:1,offset:0},deg:{name:"deg",base:$.ANGLE,prefixes:F.SHORT,value:null,offset:0},degree:{name:"degree",base:$.ANGLE,prefixes:F.LONG,value:null,offset:0},grad:{name:"grad",base:$.ANGLE,prefixes:F.SHORT,value:null,offset:0},gradian:{name:"gradian",base:$.ANGLE,prefixes:F.LONG,value:null,offset:0},cycle:{name:"cycle",base:$.ANGLE,prefixes:F.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:$.ANGLE,prefixes:F.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:$.ANGLE,prefixes:F.NONE,value:null,offset:0},A:{name:"A",base:$.CURRENT,prefixes:F.SHORT,value:1,offset:0},ampere:{name:"ampere",base:$.CURRENT,prefixes:F.LONG,value:1,offset:0},K:{name:"K",base:$.TEMPERATURE,prefixes:F.SHORT,value:1,offset:0},degC:{name:"degC",base:$.TEMPERATURE,prefixes:F.SHORT,value:1,offset:273.15},degF:{name:"degF",base:$.TEMPERATURE,prefixes:F.SHORT,value:1/1.8,offset:459.67},degR:{name:"degR",base:$.TEMPERATURE,prefixes:F.SHORT,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:$.TEMPERATURE,prefixes:F.LONG,value:1,offset:0},celsius:{name:"celsius",base:$.TEMPERATURE,prefixes:F.LONG,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:$.TEMPERATURE,prefixes:F.LONG,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:$.TEMPERATURE,prefixes:F.LONG,value:1/1.8,offset:0},mol:{name:"mol",base:$.AMOUNT_OF_SUBSTANCE,prefixes:F.SHORT,value:1,offset:0},mole:{name:"mole",base:$.AMOUNT_OF_SUBSTANCE,prefixes:F.LONG,value:1,offset:0},cd:{name:"cd",base:$.LUMINOUS_INTENSITY,prefixes:F.SHORT,value:1,offset:0},candela:{name:"candela",base:$.LUMINOUS_INTENSITY,prefixes:F.LONG,value:1,offset:0},N:{name:"N",base:$.FORCE,prefixes:F.SHORT,value:1,offset:0},newton:{name:"newton",base:$.FORCE,prefixes:F.LONG,value:1,offset:0},dyn:{name:"dyn",base:$.FORCE,prefixes:F.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:$.FORCE,prefixes:F.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:$.FORCE,prefixes:F.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:$.FORCE,prefixes:F.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:$.FORCE,prefixes:F.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:$.FORCE,prefixes:F.NONE,value:9.80665,offset:0},J:{name:"J",base:$.ENERGY,prefixes:F.SHORT,value:1,offset:0},joule:{name:"joule",base:$.ENERGY,prefixes:F.SHORT,value:1,offset:0},erg:{name:"erg",base:$.ENERGY,prefixes:F.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:$.ENERGY,prefixes:F.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:$.ENERGY,prefixes:F.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:$.ENERGY,prefixes:F.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:$.ENERGY,prefixes:F.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:$.POWER,prefixes:F.SHORT,value:1,offset:0},watt:{name:"watt",base:$.POWER,prefixes:F.LONG,value:1,offset:0},hp:{name:"hp",base:$.POWER,prefixes:F.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:$.POWER,prefixes:F.SHORT,value:p.I,offset:0},VA:{name:"VA",base:$.POWER,prefixes:F.SHORT,value:1,offset:0},Pa:{name:"Pa",base:$.PRESSURE,prefixes:F.SHORT,value:1,offset:0},psi:{name:"psi",base:$.PRESSURE,prefixes:F.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:$.PRESSURE,prefixes:F.NONE,value:101325,offset:0},bar:{name:"bar",base:$.PRESSURE,prefixes:F.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:$.PRESSURE,prefixes:F.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:$.PRESSURE,prefixes:F.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:$.PRESSURE,prefixes:F.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:$.PRESSURE,prefixes:F.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:$.ELECTRIC_CHARGE,prefixes:F.LONG,value:1,offset:0},C:{name:"C",base:$.ELECTRIC_CHARGE,prefixes:F.SHORT,value:1,offset:0},farad:{name:"farad",base:$.ELECTRIC_CAPACITANCE,prefixes:F.LONG,value:1,offset:0},F:{name:"F",base:$.ELECTRIC_CAPACITANCE,prefixes:F.SHORT,value:1,offset:0},volt:{name:"volt",base:$.ELECTRIC_POTENTIAL,prefixes:F.LONG,value:1,offset:0},V:{name:"V",base:$.ELECTRIC_POTENTIAL,prefixes:F.SHORT,value:1,offset:0},ohm:{name:"ohm",base:$.ELECTRIC_RESISTANCE,prefixes:F.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:$.ELECTRIC_INDUCTANCE,prefixes:F.LONG,value:1,offset:0},H:{name:"H",base:$.ELECTRIC_INDUCTANCE,prefixes:F.SHORT,value:1,offset:0},siemens:{name:"siemens",base:$.ELECTRIC_CONDUCTANCE,prefixes:F.LONG,value:1,offset:0},S:{name:"S",base:$.ELECTRIC_CONDUCTANCE,prefixes:F.SHORT,value:1,offset:0},weber:{name:"weber",base:$.MAGNETIC_FLUX,prefixes:F.LONG,value:1,offset:0},Wb:{name:"Wb",base:$.MAGNETIC_FLUX,prefixes:F.SHORT,value:1,offset:0},tesla:{name:"tesla",base:$.MAGNETIC_FLUX_DENSITY,prefixes:F.LONG,value:1,offset:0},T:{name:"T",base:$.MAGNETIC_FLUX_DENSITY,prefixes:F.SHORT,value:1,offset:0},b:{name:"b",base:$.BIT,prefixes:F.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:$.BIT,prefixes:F.BINARY_LONG,value:1,offset:0},B:{name:"B",base:$.BIT,prefixes:F.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:$.BIT,prefixes:F.BINARY_LONG,value:8,offset:0}},j={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",amps:"ampere",amp:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function ae(V){if(V.number==="BigNumber"){var X=gs(g);L.rad.value=new g(1),L.deg.value=X.div(180),L.grad.value=X.div(200),L.cycle.value=X.times(2),L.arcsec.value=X.div(648e3),L.arcmin.value=X.div(10800)}else L.rad.value=1,L.deg.value=Math.PI/180,L.grad.value=Math.PI/200,L.cycle.value=Math.PI*2,L.arcsec.value=Math.PI/648e3,L.arcmin.value=Math.PI/10800;L.radian.value=L.rad.value,L.degree.value=L.deg.value,L.gradian.value=L.grad.value}ae(t),e&&e("config",function(V,X){V.number!==X.number&&ae(V)});var re={si:{NONE:{unit:K,prefix:F.NONE[""]},LENGTH:{unit:L.m,prefix:F.SHORT[""]},MASS:{unit:L.g,prefix:F.SHORT.k},TIME:{unit:L.s,prefix:F.SHORT[""]},CURRENT:{unit:L.A,prefix:F.SHORT[""]},TEMPERATURE:{unit:L.K,prefix:F.SHORT[""]},LUMINOUS_INTENSITY:{unit:L.cd,prefix:F.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:L.mol,prefix:F.SHORT[""]},ANGLE:{unit:L.rad,prefix:F.SHORT[""]},BIT:{unit:L.bits,prefix:F.SHORT[""]},FORCE:{unit:L.N,prefix:F.SHORT[""]},ENERGY:{unit:L.J,prefix:F.SHORT[""]},POWER:{unit:L.W,prefix:F.SHORT[""]},PRESSURE:{unit:L.Pa,prefix:F.SHORT[""]},ELECTRIC_CHARGE:{unit:L.C,prefix:F.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:L.F,prefix:F.SHORT[""]},ELECTRIC_POTENTIAL:{unit:L.V,prefix:F.SHORT[""]},ELECTRIC_RESISTANCE:{unit:L.ohm,prefix:F.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:L.H,prefix:F.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:L.S,prefix:F.SHORT[""]},MAGNETIC_FLUX:{unit:L.Wb,prefix:F.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:L.T,prefix:F.SHORT[""]},FREQUENCY:{unit:L.Hz,prefix:F.SHORT[""]}}};re.cgs=JSON.parse(JSON.stringify(re.si)),re.cgs.LENGTH={unit:L.m,prefix:F.SHORT.c},re.cgs.MASS={unit:L.g,prefix:F.SHORT[""]},re.cgs.FORCE={unit:L.dyn,prefix:F.SHORT[""]},re.cgs.ENERGY={unit:L.erg,prefix:F.NONE[""]},re.us=JSON.parse(JSON.stringify(re.si)),re.us.LENGTH={unit:L.ft,prefix:F.NONE[""]},re.us.MASS={unit:L.lbm,prefix:F.NONE[""]},re.us.TEMPERATURE={unit:L.degF,prefix:F.NONE[""]},re.us.FORCE={unit:L.lbf,prefix:F.NONE[""]},re.us.ENERGY={unit:L.BTU,prefix:F.BTU[""]},re.us.POWER={unit:L.hp,prefix:F.NONE[""]},re.us.PRESSURE={unit:L.psi,prefix:F.NONE[""]},re.auto=JSON.parse(JSON.stringify(re.si));var fe=re.auto;d.setUnitSystem=function(V){if(Re(re,V))fe=re[V];else throw new Error("Unit system "+V+" does not exist. Choices are: "+Object.keys(re).join(", "))},d.getUnitSystem=function(){for(var V in re)if(Re(re,V)&&re[V]===fe)return V},d.typeConverters={BigNumber:function(X){return new g(X+"")},Fraction:function(X){return new y(X)},Complex:function(X){return X},number:function(X){return X}},d.prototype._numberConverter=function(){var V=d.typeConverters[this.valueType()];if(V)return V;throw new TypeError('Unsupported Unit value type "'+this.valueType()+'"')},d._getNumberConverter=function(V){if(!d.typeConverters[V])throw new TypeError('Unsupported type "'+V+'"');return d.typeConverters[V]};for(var he in L)if(Re(L,he)){var ce=L[he];ce.dimensions=ce.base.dimensions}for(var ie in j)if(Re(j,ie)){var Ae=L[j[ie]],Oe={};for(var Ce in Ae)Re(Ae,Ce)&&(Oe[Ce]=Ae[Ce]);Oe.name=ie,L[ie]=Oe}d.isValidAlpha=function(X){return/^[a-zA-Z]$/.test(X)};function $e(V){for(var X=0;X<V.length;X++){if(b=V.charAt(X),X===0&&!d.isValidAlpha(b))throw new Error('Invalid unit name (must begin with alpha character): "'+V+'"');if(X>0&&!(d.isValidAlpha(b)||S(b)))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+V+'"')}}return d.createUnit=function(V,X){if(typeof V!="object")throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(X&&X.override){for(var oe in V)if(Re(V,oe)&&d.deleteUnit(oe),V[oe].aliases)for(var G=0;G<V[oe].aliases.length;G++)d.deleteUnit(V[oe].aliases[G])}var Y;for(var te in V)Re(V,te)&&(Y=d.createUnitSingle(te,V[te]));return Y},d.createUnitSingle=function(V,X){if((typeof X>"u"||X===null)&&(X={}),typeof V!="string")throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");if(Re(L,V))throw new Error('Cannot create unit "'+V+'": a unit with that name already exists');$e(V);var oe=null,G=[],Y=0,te,ye,me;if(X&&X.type==="Unit")oe=X.clone();else if(typeof X=="string")X!==""&&(te=X);else if(typeof X=="object")te=X.definition,ye=X.prefixes,Y=X.offset,me=X.baseName,X.aliases&&(G=X.aliases.valueOf());else throw new TypeError('Cannot create unit "'+V+'" from "'+X.toString()+'": expecting "string" or "Unit" or "Object"');if(G){for(var z=0;z<G.length;z++)if(Re(L,G[z]))throw new Error('Cannot create alias "'+G[z]+'": a unit with that name already exists')}if(te&&typeof te=="string"&&!oe)try{oe=d.parse(te,{allowNoUnits:!0})}catch(mr){throw mr.message='Could not create unit "'+V+'" from "'+te+'": '+mr.message,mr}else te&&te.type==="Unit"&&(oe=te.clone());G=G||[],Y=Y||0,ye&&ye.toUpperCase?ye=F[ye.toUpperCase()]||F.NONE:ye=F.NONE;var U={};if(oe){U={name:V,value:oe.value,dimensions:oe.dimensions.slice(0),prefixes:ye,offset:Y};var de=!1;for(var be in $)if(Re($,be)){for(var pe=!0,we=0;we<H.length;we++)if(Math.abs((U.dimensions[we]||0)-($[be].dimensions[we]||0))>1e-12){pe=!1;break}if(pe){de=!0,U.base=$[be];break}}if(!de){me=me||V+"_STUFF";var _e={dimensions:oe.dimensions.slice(0)};_e.key=me,$[me]=_e,fe[me]={unit:U,prefix:F.NONE[""]},U.base=$[me]}}else{if(me=me||V+"_STUFF",H.indexOf(me)>=0)throw new Error('Cannot create new base unit "'+V+'": a base unit with that name already exists (and cannot be overridden)');H.push(me);for(var ee in $)Re($,ee)&&($[ee].dimensions[H.length-1]=0);for(var ue={dimensions:[]},ve=0;ve<H.length;ve++)ue.dimensions[ve]=0;ue.dimensions[H.length-1]=1,ue.key=me,$[me]=ue,U={name:V,value:1,dimensions:$[me].dimensions.slice(0),prefixes:ye,offset:Y,base:$[me]},fe[me]={unit:U,prefix:F.NONE[""]}}d.UNITS[V]=U;for(var Le=0;Le<G.length;Le++){var Be=G[Le],ar={};for(var Je in U)Re(U,Je)&&(ar[Je]=U[Je]);ar.name=Be,d.UNITS[Be]=ar}return delete R.cache,new d(null,V)},d.deleteUnit=function(V){delete d.UNITS[V]},d.PREFIXES=F,d.BASE_DIMENSIONS=H,d.BASE_UNITS=$,d.UNIT_SYSTEMS=re,d.UNITS=L,d},{isClass:!0}),vv="unit",SD=["typed","Unit"],CD=q(vv,SD,r=>{var{typed:e,Unit:t}=r;return e(vv,{Unit:function(n){return n.clone()},string:function(n){return t.isValuelessUnit(n)?new t(null,n):t.parse(n,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string | Unit":function(n,i){return new t(n,i)},"number | BigNumber | Fraction":function(n){return new t(n)},"Array | Matrix":e.referToSelf(a=>n=>je(n,a))})}),pv="sparse",MD=["typed","SparseMatrix"],FD=q(pv,MD,r=>{var{typed:e,SparseMatrix:t}=r;return e(pv,{"":function(){return new t([])},string:function(n){return new t([],n)},"Array | Matrix":function(n){return new t(n)},"Array | Matrix, string":function(n,i){return new t(n,i)}})}),hv="createUnit",TD=["typed","Unit"],BD=q(hv,TD,r=>{var{typed:e,Unit:t}=r;return e(hv,{"Object, Object":function(n,i){return t.createUnit(n,i)},Object:function(n){return t.createUnit(n,{})},"string, Unit | string | Object, Object":function(n,i,o){var f={};return f[n]=i,t.createUnit(f,o)},"string, Unit | string | Object":function(n,i){var o={};return o[n]=i,t.createUnit(o,{})},string:function(n){var i={};return i[n]={},t.createUnit(i,{})}})}),dv="acos",$D=["typed","config","Complex"],OD=q(dv,$D,r=>{var{typed:e,config:t,Complex:a}=r;return e(dv,{number:function(i){return i>=-1&&i<=1||t.predictable?Math.acos(i):new a(i,0).acos()},Complex:function(i){return i.acos()},BigNumber:function(i){return i.acos()}})}),gv="acosh",ID=["typed","config","Complex"],RD=q(gv,ID,r=>{var{typed:e,config:t,Complex:a}=r;return e(gv,{number:function(i){return i>=1||t.predictable?Bc(i):i<=-1?new a(Math.log(Math.sqrt(i*i-1)-i),Math.PI):new a(i,0).acosh()},Complex:function(i){return i.acosh()},BigNumber:function(i){return i.acosh()}})}),yv="acot",_D=["typed","BigNumber"],qD=q(yv,_D,r=>{var{typed:e,BigNumber:t}=r;return e(yv,{number:$c,Complex:function(n){return n.acot()},BigNumber:function(n){return new t(1).div(n).atan()}})}),bv="acoth",zD=["typed","config","Complex","BigNumber"],PD=q(bv,zD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(bv,{number:function(o){return o>=1||o<=-1||t.predictable?Oc(o):new a(o,0).acoth()},Complex:function(o){return o.acoth()},BigNumber:function(o){return new n(1).div(o).atanh()}})}),xv="acsc",UD=["typed","config","Complex","BigNumber"],LD=q(xv,UD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(xv,{number:function(o){return o<=-1||o>=1||t.predictable?Ic(o):new a(o,0).acsc()},Complex:function(o){return o.acsc()},BigNumber:function(o){return new n(1).div(o).asin()}})}),wv="acsch",kD=["typed","BigNumber"],VD=q(wv,kD,r=>{var{typed:e,BigNumber:t}=r;return e(wv,{number:Rc,Complex:function(n){return n.acsch()},BigNumber:function(n){return new t(1).div(n).asinh()}})}),Nv="asec",GD=["typed","config","Complex","BigNumber"],HD=q(Nv,GD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(Nv,{number:function(o){return o<=-1||o>=1||t.predictable?_c(o):new a(o,0).asec()},Complex:function(o){return o.asec()},BigNumber:function(o){return new n(1).div(o).acos()}})}),Dv="asech",ZD=["typed","config","Complex","BigNumber"],JD=q(Dv,ZD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(Dv,{number:function(o){if(o<=1&&o>=-1||t.predictable){var f=1/o;if(f>0||t.predictable)return qc(o);var l=Math.sqrt(f*f-1);return new a(Math.log(l-f),Math.PI)}return new a(o,0).asech()},Complex:function(o){return o.asech()},BigNumber:function(o){return new n(1).div(o).acosh()}})}),Av="asin",XD=["typed","config","Complex"],WD=q(Av,XD,r=>{var{typed:e,config:t,Complex:a}=r;return e(Av,{number:function(i){return i>=-1&&i<=1||t.predictable?Math.asin(i):new a(i,0).asin()},Complex:function(i){return i.asin()},BigNumber:function(i){return i.asin()}})}),YD="asinh",QD=["typed"],KD=q(YD,QD,r=>{var{typed:e}=r;return e("asinh",{number:zc,Complex:function(a){return a.asinh()},BigNumber:function(a){return a.asinh()}})}),jD="atan",eA=["typed"],rA=q(jD,eA,r=>{var{typed:e}=r;return e("atan",{number:function(a){return Math.atan(a)},Complex:function(a){return a.atan()},BigNumber:function(a){return a.atan()}})}),Ev="atan2",tA=["typed","matrix","equalScalar","BigNumber","DenseMatrix","concat"],nA=q(Ev,tA,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n,DenseMatrix:i,concat:o}=r,f=wt({typed:e,equalScalar:a}),l=Yr({typed:e}),u=Rf({typed:e,equalScalar:a}),s=Lr({typed:e,equalScalar:a}),c=Ir({typed:e,DenseMatrix:i}),m=dr({typed:e,matrix:t,concat:o});return e(Ev,{"number, number":Math.atan2,"BigNumber, BigNumber":(v,h)=>n.atan2(v,h)},m({scalar:"number | BigNumber",SS:u,DS:l,SD:f,Ss:s,sS:c}))}),Sv="atanh",aA=["typed","config","Complex"],iA=q(Sv,aA,r=>{var{typed:e,config:t,Complex:a}=r;return e(Sv,{number:function(i){return i<=1&&i>=-1||t.predictable?Pc(i):new a(i,0).atanh()},Complex:function(i){return i.atanh()},BigNumber:function(i){return i.atanh()}})}),fa=q("trigUnit",["typed"],r=>{var{typed:e}=r;return{Unit:e.referToSelf(t=>a=>{if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return e.find(t,a.valueType())(a.value)})}}),Cv="cos",oA=["typed"],sA=q(Cv,oA,r=>{var{typed:e}=r,t=fa({typed:e});return e(Cv,{number:Math.cos,"Complex | BigNumber":a=>a.cos()},t)}),Mv="cosh",uA=["typed"],lA=q(Mv,uA,r=>{var{typed:e}=r;return e(Mv,{number:fg,"Complex | BigNumber":t=>t.cosh()})}),Fv="cot",cA=["typed","BigNumber"],fA=q(Fv,cA,r=>{var{typed:e,BigNumber:t}=r,a=fa({typed:e});return e(Fv,{number:Uc,Complex:n=>n.cot(),BigNumber:n=>new t(1).div(n.tan())},a)}),Tv="coth",mA=["typed","BigNumber"],vA=q(Tv,mA,r=>{var{typed:e,BigNumber:t}=r;return e(Tv,{number:Lc,Complex:a=>a.coth(),BigNumber:a=>new t(1).div(a.tanh())})}),Bv="csc",pA=["typed","BigNumber"],hA=q(Bv,pA,r=>{var{typed:e,BigNumber:t}=r,a=fa({typed:e});return e(Bv,{number:kc,Complex:n=>n.csc(),BigNumber:n=>new t(1).div(n.sin())},a)}),$v="csch",dA=["typed","BigNumber"],gA=q($v,dA,r=>{var{typed:e,BigNumber:t}=r;return e($v,{number:Vc,Complex:a=>a.csch(),BigNumber:a=>new t(1).div(a.sinh())})}),Ov="sec",yA=["typed","BigNumber"],bA=q(Ov,yA,r=>{var{typed:e,BigNumber:t}=r,a=fa({typed:e});return e(Ov,{number:Gc,Complex:n=>n.sec(),BigNumber:n=>new t(1).div(n.cos())},a)}),Iv="sech",xA=["typed","BigNumber"],wA=q(Iv,xA,r=>{var{typed:e,BigNumber:t}=r;return e(Iv,{number:Hc,Complex:a=>a.sech(),BigNumber:a=>new t(1).div(a.cosh())})}),Rv="sin",NA=["typed"],DA=q(Rv,NA,r=>{var{typed:e}=r,t=fa({typed:e});return e(Rv,{number:Math.sin,"Complex | BigNumber":a=>a.sin()},t)}),_v="sinh",AA=["typed"],EA=q(_v,AA,r=>{var{typed:e}=r;return e(_v,{number:Zc,"Complex | BigNumber":t=>t.sinh()})}),qv="tan",SA=["typed"],CA=q(qv,SA,r=>{var{typed:e}=r,t=fa({typed:e});return e(qv,{number:Math.tan,"Complex | BigNumber":a=>a.tan()},t)}),MA="tanh",FA=["typed"],TA=q(MA,FA,r=>{var{typed:e}=r;return e("tanh",{number:vg,"Complex | BigNumber":t=>t.tanh()})}),zv="setCartesian",BA=["typed","size","subset","compareNatural","Index","DenseMatrix"],$A=q(zv,BA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:o}=r;return e(zv,{"Array | Matrix, Array | Matrix":function(l,u){var s=[];if(a(t(l),new i(0))!==0&&a(t(u),new i(0))!==0){var c=or(Array.isArray(l)?l:l.toArray()).sort(n),m=or(Array.isArray(u)?u:u.toArray()).sort(n);s=[];for(var v=0;v<c.length;v++)for(var h=0;h<m.length;h++)s.push([c[v],m[h]])}return Array.isArray(l)&&Array.isArray(u)?s:new o(s)}})}),Pv="setDifference",OA=["typed","size","subset","compareNatural","Index","DenseMatrix"],IA=q(Pv,OA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:o}=r;return e(Pv,{"Array | Matrix, Array | Matrix":function(l,u){var s;if(a(t(l),new i(0))===0)s=[];else{if(a(t(u),new i(0))===0)return or(l.toArray());var c=Kn(or(Array.isArray(l)?l:l.toArray()).sort(n)),m=Kn(or(Array.isArray(u)?u:u.toArray()).sort(n));s=[];for(var v,h=0;h<c.length;h++){v=!1;for(var p=0;p<m.length;p++)if(n(c[h].value,m[p].value)===0&&c[h].identifier===m[p].identifier){v=!0;break}v||s.push(c[h])}}return Array.isArray(l)&&Array.isArray(u)?gi(s):new o(gi(s))}})}),Uv="setDistinct",RA=["typed","size","subset","compareNatural","Index","DenseMatrix"],_A=q(Uv,RA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:o}=r;return e(Uv,{"Array | Matrix":function(l){var u;if(a(t(l),new i(0))===0)u=[];else{var s=or(Array.isArray(l)?l:l.toArray()).sort(n);u=[],u.push(s[0]);for(var c=1;c<s.length;c++)n(s[c],s[c-1])!==0&&u.push(s[c])}return Array.isArray(l)?u:new o(u)}})}),Lv="setIntersect",qA=["typed","size","subset","compareNatural","Index","DenseMatrix"],zA=q(Lv,qA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:o}=r;return e(Lv,{"Array | Matrix, Array | Matrix":function(l,u){var s;if(a(t(l),new i(0))===0||a(t(u),new i(0))===0)s=[];else{var c=Kn(or(Array.isArray(l)?l:l.toArray()).sort(n)),m=Kn(or(Array.isArray(u)?u:u.toArray()).sort(n));s=[];for(var v=0;v<c.length;v++)for(var h=0;h<m.length;h++)if(n(c[v].value,m[h].value)===0&&c[v].identifier===m[h].identifier){s.push(c[v]);break}}return Array.isArray(l)&&Array.isArray(u)?gi(s):new o(gi(s))}})}),kv="setIsSubset",PA=["typed","size","subset","compareNatural","Index"],UA=q(kv,PA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(kv,{"Array | Matrix, Array | Matrix":function(f,l){if(a(t(f),new i(0))===0)return!0;if(a(t(l),new i(0))===0)return!1;for(var u=Kn(or(Array.isArray(f)?f:f.toArray()).sort(n)),s=Kn(or(Array.isArray(l)?l:l.toArray()).sort(n)),c,m=0;m<u.length;m++){c=!1;for(var v=0;v<s.length;v++)if(n(u[m].value,s[v].value)===0&&u[m].identifier===s[v].identifier){c=!0;break}if(c===!1)return!1}return!0}})}),Vv="setMultiplicity",LA=["typed","size","subset","compareNatural","Index"],kA=q(Vv,LA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(Vv,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(f,l){if(a(t(l),new i(0))===0)return 0;for(var u=or(Array.isArray(l)?l:l.toArray()),s=0,c=0;c<u.length;c++)n(u[c],f)===0&&s++;return s}})}),Gv="setPowerset",VA=["typed","size","subset","compareNatural","Index"],GA=q(Gv,VA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(Gv,{"Array | Matrix":function(u){if(a(t(u),new i(0))===0)return[];for(var s=or(Array.isArray(u)?u:u.toArray()).sort(n),c=[],m=0;m.toString(2).length<=s.length;)c.push(o(s,m.toString(2).split("").reverse())),m++;return f(c)}});function o(l,u){for(var s=[],c=0;c<u.length;c++)u[c]==="1"&&s.push(l[c]);return s}function f(l){for(var u=[],s=l.length-1;s>0;s--)for(var c=0;c<s;c++)l[c].length>l[c+1].length&&(u=l[c],l[c]=l[c+1],l[c+1]=u);return l}}),Hv="setSize",HA=["typed","compareNatural"],ZA=q(Hv,HA,r=>{var{typed:e,compareNatural:t}=r;return e(Hv,{"Array | Matrix":function(n){return Array.isArray(n)?or(n).length:or(n.toArray()).length},"Array | Matrix, boolean":function(n,i){if(i===!1||n.length===0)return Array.isArray(n)?or(n).length:or(n.toArray()).length;for(var o=or(Array.isArray(n)?n:n.toArray()).sort(t),f=1,l=1;l<o.length;l++)t(o[l],o[l-1])!==0&&f++;return f}})}),Zv="setSymDifference",JA=["typed","size","concat","subset","setDifference","Index"],XA=q(Zv,JA,r=>{var{typed:e,size:t,concat:a,subset:n,setDifference:i,Index:o}=r;return e(Zv,{"Array | Matrix, Array | Matrix":function(l,u){if(n(t(l),new o(0))===0)return or(u);if(n(t(u),new o(0))===0)return or(l);var s=or(l),c=or(u);return a(i(s,c),i(c,s))}})}),Jv="setUnion",WA=["typed","size","concat","subset","setIntersect","setSymDifference","Index"],YA=q(Jv,WA,r=>{var{typed:e,size:t,concat:a,subset:n,setIntersect:i,setSymDifference:o,Index:f}=r;return e(Jv,{"Array | Matrix, Array | Matrix":function(u,s){if(n(t(u),new f(0))===0)return or(s);if(n(t(s),new f(0))===0)return or(u);var c=or(u),m=or(s);return a(o(c,m),i(c,m))}})}),Xv="add",QA=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],KA=q(Xv,QA,r=>{var{typed:e,matrix:t,addScalar:a,equalScalar:n,DenseMatrix:i,SparseMatrix:o,concat:f}=r,l=mn({typed:e}),u=fs({typed:e,equalScalar:n}),s=Tn({typed:e,DenseMatrix:i}),c=dr({typed:e,matrix:t,concat:f});return e(Xv,{"any, any":a,"any, any, ...any":e.referToSelf(m=>(v,h,p)=>{for(var g=m(v,h),y=0;y<p.length;y++)g=m(g,p[y]);return g})},c({elop:a,DS:l,SS:u,Ss:s}))}),Wv="hypot",jA=["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],eE=q(Wv,jA,r=>{var{typed:e,abs:t,addScalar:a,divideScalar:n,multiplyScalar:i,sqrt:o,smaller:f,isPositive:l}=r;return e(Wv,{"... number | BigNumber":u,Array:u,Matrix:s=>u(or(s.toArray()))});function u(s){for(var c=0,m=0,v=0;v<s.length;v++){if(kt(s[v]))throw new TypeError("Unexpected type of argument to hypot");var h=t(s[v]);f(m,h)?(c=i(c,i(n(m,h),n(m,h))),c=a(c,1),m=h):c=a(c,l(h)?i(n(h,m),n(h,m)):h)}return i(m,o(c))}}),Yv="norm",rE=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],tE=q(Yv,rE,r=>{var{typed:e,abs:t,add:a,pow:n,conj:i,sqrt:o,multiply:f,equalScalar:l,larger:u,smaller:s,matrix:c,ctranspose:m,eigs:v}=r;return e(Yv,{number:Math.abs,Complex:function(A){return A.abs()},BigNumber:function(A){return A.abs()},boolean:function(A){return Math.abs(A)},Array:function(A){return b(c(A),2)},Matrix:function(A){return b(A,2)},"Array, number | BigNumber | string":function(A,S){return b(c(A),S)},"Matrix, number | BigNumber | string":function(A,S){return b(A,S)}});function h(E){var A=0;return E.forEach(function(S){var D=t(S);u(D,A)&&(A=D)},!0),A}function p(E){var A;return E.forEach(function(S){var D=t(S);(!A||s(D,A))&&(A=D)},!0),A||0}function g(E,A){if(A===Number.POSITIVE_INFINITY||A==="inf")return h(E);if(A===Number.NEGATIVE_INFINITY||A==="-inf")return p(E);if(A==="fro")return b(E,2);if(typeof A=="number"&&!isNaN(A)){if(!l(A,0)){var S=0;return E.forEach(function(D){S=a(n(t(D),A),S)},!0),n(S,1/A)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}function y(E){var A=0;return E.forEach(function(S,D){A=a(A,f(S,i(S)))}),t(o(A))}function N(E){var A=[],S=0;return E.forEach(function(D,T){var B=T[1],I=a(A[B]||0,t(D));u(I,S)&&(S=I),A[B]=I},!0),S}function d(E){var A=E.size();if(A[0]!==A[1])throw new RangeError("Invalid matrix dimensions");var S=m(E),D=f(S,E),T=v(D).values.toArray(),B=T[T.length-1];return t(o(B))}function w(E){var A=[],S=0;return E.forEach(function(D,T){var B=T[0],I=a(A[B]||0,t(D));u(I,S)&&(S=I),A[B]=I},!0),S}function x(E,A){if(A===1)return N(E);if(A===Number.POSITIVE_INFINITY||A==="inf")return w(E);if(A==="fro")return y(E);if(A===2)return d(E);throw new Error("Unsupported parameter value "+A)}function b(E,A){var S=E.size();if(S.length===1)return g(E,A);if(S.length===2){if(S[0]&&S[1])return x(E,A);throw new RangeError("Invalid matrix dimensions")}}}),Qv="dot",nE=["typed","addScalar","multiplyScalar","conj","size"],aE=q(Qv,nE,r=>{var{typed:e,addScalar:t,multiplyScalar:a,conj:n,size:i}=r;return e(Qv,{"Array | DenseMatrix, Array | DenseMatrix":f,"SparseMatrix, SparseMatrix":l});function o(s,c){var m=u(s),v=u(c),h,p;if(m.length===1)h=m[0];else if(m.length===2&&m[1]===1)h=m[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+m.join(", ")+")");if(v.length===1)p=v[0];else if(v.length===2&&v[1]===1)p=v[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+v.join(", ")+")");if(h!==p)throw new RangeError("Vectors must have equal length ("+h+" != "+p+")");if(h===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return h}function f(s,c){var m=o(s,c),v=Ve(s)?s._data:s,h=Ve(s)?s._datatype:void 0,p=Ve(c)?c._data:c,g=Ve(c)?c._datatype:void 0,y=u(s).length===2,N=u(c).length===2,d=t,w=a;if(h&&g&&h===g&&typeof h=="string"){var x=h;d=e.find(t,[x,x]),w=e.find(a,[x,x])}if(!y&&!N){for(var b=w(n(v[0]),p[0]),E=1;E<m;E++)b=d(b,w(n(v[E]),p[E]));return b}if(!y&&N){for(var A=w(n(v[0]),p[0][0]),S=1;S<m;S++)A=d(A,w(n(v[S]),p[S][0]));return A}if(y&&!N){for(var D=w(n(v[0][0]),p[0]),T=1;T<m;T++)D=d(D,w(n(v[T][0]),p[T]));return D}if(y&&N){for(var B=w(n(v[0][0]),p[0][0]),I=1;I<m;I++)B=d(B,w(n(v[I][0]),p[I][0]));return B}}function l(s,c){o(s,c);for(var m=s._index,v=s._values,h=c._index,p=c._values,g=0,y=t,N=a,d=0,w=0;d<m.length&&w<h.length;){var x=m[d],b=h[w];if(x<b){d++;continue}if(x>b){w++;continue}x===b&&(g=y(g,N(v[d],p[w])),d++,w++)}return g}function u(s){return Ve(s)?s.size():i(s)}}),iE="trace",oE=["typed","matrix","add"],sE=q(iE,oE,r=>{var{typed:e,matrix:t,add:a}=r;return e("trace",{Array:function(f){return n(t(f))},SparseMatrix:i,DenseMatrix:n,any:Ge});function n(o){var f=o._size,l=o._data;switch(f.length){case 1:if(f[0]===1)return Ge(l[0]);throw new RangeError("Matrix must be square (size: "+Ye(f)+")");case 2:{var u=f[0],s=f[1];if(u===s){for(var c=0,m=0;m<u;m++)c=a(c,l[m][m]);return c}else throw new RangeError("Matrix must be square (size: "+Ye(f)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Ye(f)+")")}}function i(o){var f=o._values,l=o._index,u=o._ptr,s=o._size,c=s[0],m=s[1];if(c===m){var v=0;if(f.length>0)for(var h=0;h<m;h++)for(var p=u[h],g=u[h+1],y=p;y<g;y++){var N=l[y];if(N===h){v=a(v,f[y]);break}if(N>h)break}return v}throw new RangeError("Matrix must be square (size: "+Ye(s)+")")}}),Kv="index",uE=["typed","Index"],lE=q(Kv,uE,r=>{var{typed:e,Index:t}=r;return e(Kv,{"...number | string | BigNumber | Range | Array | Matrix":function(n){var i=n.map(function(f){return rr(f)?f.toNumber():Array.isArray(f)||Ve(f)?f.map(function(l){return rr(l)?l.toNumber():l}):f}),o=new t;return t.apply(o,i),o}})}),jv=new Set(["end"]),cE="Node",fE=["mathWithTransform"],mE=q(cE,fE,r=>{var{mathWithTransform:e}=r;function t(n){for(var i of[...jv])if(n.has(i))throw new Error('Scope contains an illegal symbol, "'+i+'" is a reserved keyword')}class a{get type(){return"Node"}get isNode(){return!0}evaluate(i){return this.compile().evaluate(i)}compile(){var i=this._compile(e,{}),o={},f=null;function l(u){var s=ra(u);return t(s),i(s,o,f)}return{evaluate:l}}_compile(i,o){throw new Error("Method _compile must be implemented by type "+this.type)}forEach(i){throw new Error("Cannot run forEach on a Node interface")}map(i){throw new Error("Cannot run map on a Node interface")}_ifNode(i){if(!fr(i))throw new TypeError("Callback function must return a Node");return i}traverse(i){i(this,null,null);function o(f,l){f.forEach(function(u,s,c){l(u,s,c),o(u,l)})}o(this,i)}transform(i){function o(f,l,u){var s=i(f,l,u);return s!==f?s:f.map(o)}return o(this,null,null)}filter(i){var o=[];return this.traverse(function(f,l,u){i(f,l,u)&&o.push(f)}),o}clone(){throw new Error("Cannot clone a Node interface")}cloneDeep(){return this.map(function(i){return i.cloneDeep()})}equals(i){return i?this.type===i.type&&Ua(this,i):!1}toString(i){var o=this._getCustomString(i);return typeof o<"u"?o:this._toString(i)}toJSON(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)}toHTML(i){var o=this._getCustomString(i);return typeof o<"u"?o:this.toHTML(i)}_toString(){throw new Error("_toString not implemented for "+this.type)}toTex(i){var o=this._getCustomString(i);return typeof o<"u"?o:this._toTex(i)}_toTex(i){throw new Error("_toTex not implemented for "+this.type)}_getCustomString(i){if(i&&typeof i=="object")switch(typeof i.handler){case"object":case"undefined":return;case"function":return i.handler(this,i);default:throw new TypeError("Object or function expected as callback")}}getIdentifier(){return this.type}getContent(){return this}}return a},{isClass:!0,isNode:!0});function Kr(r){return r&&r.isIndexError?new dt(r.index+1,r.min+1,r.max!==void 0?r.max+1:void 0):r}function ep(r){var{subset:e}=r;return function(a,n){try{if(Array.isArray(a))return e(a,n);if(a&&typeof a.subset=="function")return a.subset(n);if(typeof a=="string")return e(a,n);if(typeof a=="object"){if(!n.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return lt(a,n.getObjectProperty())}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(i){throw Kr(i)}}}var Gi="AccessorNode",vE=["subset","Node"],pE=q(Gi,vE,r=>{var{subset:e,Node:t}=r,a=ep({subset:e});function n(o){return!(Sn(o)||ot(o)||ir(o)||nn(o)||ci(o)||Gt(o)||qr(o))}class i extends t{constructor(f,l){if(super(),!fr(f))throw new TypeError('Node expected for parameter "object"');if(!Jn(l))throw new TypeError('IndexNode expected for parameter "index"');this.object=f,this.index=l}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return Gi}get isAccessorNode(){return!0}_compile(f,l){var u=this.object._compile(f,l),s=this.index._compile(f,l);if(this.index.isObjectProperty()){var c=this.index.getObjectProperty();return function(v,h,p){return lt(u(v,h,p),c)}}else return function(v,h,p){var g=u(v,h,p),y=s(v,h,g);return a(g,y)}}forEach(f){f(this.object,"object",this),f(this.index,"index",this)}map(f){return new i(this._ifNode(f(this.object,"object",this)),this._ifNode(f(this.index,"index",this)))}clone(){return new i(this.object,this.index)}_toString(f){var l=this.object.toString(f);return n(this.object)&&(l="("+l+")"),l+this.index.toString(f)}toHTML(f){var l=this.object.toHTML(f);return n(this.object)&&(l='<span class="math-parenthesis math-round-parenthesis">(</span>'+l+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+this.index.toHTML(f)}_toTex(f){var l=this.object.toTex(f);return n(this.object)&&(l="\\left(' + object + '\\right)"),l+this.index.toTex(f)}toJSON(){return{mathjs:Gi,object:this.object,index:this.index}}static fromJSON(f){return new i(f.object,f.index)}}return zr(i,"name",Gi),i},{isClass:!0,isNode:!0}),Hi="ArrayNode",hE=["Node"],dE=q(Hi,hE,r=>{var{Node:e}=r;class t extends e{constructor(n){if(super(),this.items=n||[],!Array.isArray(this.items)||!this.items.every(fr))throw new TypeError("Array containing Nodes expected")}get type(){return Hi}get isArrayNode(){return!0}_compile(n,i){var o=Ht(this.items,function(u){return u._compile(n,i)}),f=n.config.matrix!=="Array";if(f){var l=n.matrix;return function(s,c,m){return l(Ht(o,function(v){return v(s,c,m)}))}}else return function(s,c,m){return Ht(o,function(v){return v(s,c,m)})}}forEach(n){for(var i=0;i<this.items.length;i++){var o=this.items[i];n(o,"items["+i+"]",this)}}map(n){for(var i=[],o=0;o<this.items.length;o++)i[o]=this._ifNode(n(this.items[o],"items["+o+"]",this));return new t(i)}clone(){return new t(this.items.slice(0))}_toString(n){var i=this.items.map(function(o){return o.toString(n)});return"["+i.join(", ")+"]"}toJSON(){return{mathjs:Hi,items:this.items}}static fromJSON(n){return new t(n.items)}toHTML(n){var i=this.items.map(function(o){return o.toHTML(n)});return'<span class="math-parenthesis math-square-parenthesis">[</span>'+i.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(n){function i(o,f){var l=o.some(ot)&&!o.every(ot),u=f||l,s=u?"&":"\\\\",c=o.map(function(m){return m.items?i(m.items,!f):m.toTex(n)}).join(s);return l||!u||u&&!f?"\\begin{bmatrix}"+c+"\\end{bmatrix}":c}return i(this.items,!1)}}return zr(t,"name",Hi),t},{isClass:!0,isNode:!0});function gE(r){var{subset:e,matrix:t}=r;return function(n,i,o){try{if(Array.isArray(n))return t(n).subset(i,o).valueOf();if(n&&typeof n.subset=="function")return n.subset(i,o);if(typeof n=="string")return e(n,i,o);if(typeof n=="object"){if(!i.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return jn(n,i.getObjectProperty(),o),n}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(f){throw Kr(f)}}}var Nt=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{op:"or",associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{op:"xor",associativity:"left",associativeWith:[]}},{"OperatorNode:and":{op:"and",associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{op:"|",associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{op:"^|",associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{op:"&",associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{op:"==",associativity:"left",associativeWith:[]},"OperatorNode:unequal":{op:"!=",associativity:"left",associativeWith:[]},"OperatorNode:smaller":{op:"<",associativity:"left",associativeWith:[]},"OperatorNode:larger":{op:">",associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{op:"<=",associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{op:">=",associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{op:"<<",associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{op:">>",associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{op:">>>",associativity:"left",associativeWith:[]}},{"OperatorNode:to":{op:"to",associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{op:"+",associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{op:"-",associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{op:"*",associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{op:"/",associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{op:".*",associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{op:"./",associativity:"left",associativeWith:[]},"OperatorNode:mod":{op:"mod",associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]}},{"OperatorNode:unaryPlus":{op:"+",associativity:"right"},"OperatorNode:unaryMinus":{op:"-",associativity:"right"},"OperatorNode:bitNot":{op:"~",associativity:"right"},"OperatorNode:not":{op:"not",associativity:"right"}},{"OperatorNode:pow":{op:"^",associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{op:".^",associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{op:"!",associativity:"left"}},{"OperatorNode:ctranspose":{op:"'",associativity:"left"}}];function Zi(r,e){if(!e||e!=="auto")return r;for(var t=r;Gt(t);)t=t.content;return t}function pr(r,e,t,a){var n=r;e!=="keep"&&(n=r.getContent());for(var i=n.getIdentifier(),o=null,f=0;f<Nt.length;f++)if(i in Nt[f]){o=f;break}if(i==="OperatorNode:multiply"&&n.implicit&&t!=="show"){var l=Zi(n.args[0],e);!(ir(l)&&a&&a.getIdentifier()==="OperatorNode:divide"&&ko(Zi(a.args[0],e)))&&!(l.getIdentifier()==="OperatorNode:divide"&&ko(Zi(l.args[0],e))&&ir(Zi(l.args[1])))&&(o+=1)}return o}function Xa(r,e){var t=r;e!=="keep"&&(t=r.getContent());var a=t.getIdentifier(),n=pr(t,e);if(n===null)return null;var i=Nt[n][a];if(Re(i,"associativity")){if(i.associativity==="left")return"left";if(i.associativity==="right")return"right";throw Error("'"+a+"' has the invalid associativity '"+i.associativity+"'.")}return null}function bs(r,e,t){var a=t!=="keep"?r.getContent():r,n=t!=="keep"?r.getContent():e,i=a.getIdentifier(),o=n.getIdentifier(),f=pr(a,t);if(f===null)return null;var l=Nt[f][i];if(Re(l,"associativeWith")&&l.associativeWith instanceof Array){for(var u=0;u<l.associativeWith.length;u++)if(l.associativeWith[u]===o)return!0;return!1}return null}function yE(r){var e="OperatorNode:"+r;for(var t of Nt)if(e in t)return t[e].op;return null}var Ji="AssignmentNode",bE=["subset","?matrix","Node"],xE=q(Ji,bE,r=>{var{subset:e,matrix:t,Node:a}=r,n=ep({subset:e}),i=gE({subset:e,matrix:t});function o(l,u,s){u||(u="keep");var c=pr(l,u,s),m=pr(l.value,u,s);return u==="all"||m!==null&&m<=c}class f extends a{constructor(u,s,c){if(super(),this.object=u,this.index=c?s:null,this.value=c||s,!qr(u)&&!Sn(u))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(qr(u)&&u.name==="end")throw new Error('Cannot assign to symbol "end"');if(this.index&&!Jn(this.index))throw new TypeError('IndexNode expected as "index"');if(!fr(this.value))throw new TypeError('Node expected as "value"')}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return Ji}get isAssignmentNode(){return!0}_compile(u,s){var c=this.object._compile(u,s),m=this.index?this.index._compile(u,s):null,v=this.value._compile(u,s),h=this.object.name;if(this.index)if(this.index.isObjectProperty()){var p=this.index.getObjectProperty();return function(w,x,b){var E=c(w,x,b),A=v(w,x,b);return jn(E,p,A),A}}else{if(qr(this.object))return function(w,x,b){var E=c(w,x,b),A=v(w,x,b),S=m(w,x,E);return w.set(h,i(E,S,A)),A};var g=this.object.object._compile(u,s);if(this.object.index.isObjectProperty()){var y=this.object.index.getObjectProperty();return function(w,x,b){var E=g(w,x,b),A=lt(E,y),S=m(w,x,A),D=v(w,x,b);return jn(E,y,i(A,S,D)),D}}else{var N=this.object.index._compile(u,s);return function(w,x,b){var E=g(w,x,b),A=N(w,x,E),S=n(E,A),D=m(w,x,S),T=v(w,x,b);return i(E,A,i(S,D,T)),T}}}else{if(!qr(this.object))throw new TypeError("SymbolNode expected as object");return function(w,x,b){var E=v(w,x,b);return w.set(h,E),E}}}forEach(u){u(this.object,"object",this),this.index&&u(this.index,"index",this),u(this.value,"value",this)}map(u){var s=this._ifNode(u(this.object,"object",this)),c=this.index?this._ifNode(u(this.index,"index",this)):null,m=this._ifNode(u(this.value,"value",this));return new f(s,c,m)}clone(){return new f(this.object,this.index,this.value)}_toString(u){var s=this.object.toString(u),c=this.index?this.index.toString(u):"",m=this.value.toString(u);return o(this,u&&u.parenthesis,u&&u.implicit)&&(m="("+m+")"),s+c+" = "+m}toJSON(){return{mathjs:Ji,object:this.object,index:this.index,value:this.value}}static fromJSON(u){return new f(u.object,u.index,u.value)}toHTML(u){var s=this.object.toHTML(u),c=this.index?this.index.toHTML(u):"",m=this.value.toHTML(u);return o(this,u&&u.parenthesis,u&&u.implicit)&&(m='<span class="math-paranthesis math-round-parenthesis">(</span>'+m+'<span class="math-paranthesis math-round-parenthesis">)</span>'),s+c+'<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+m}_toTex(u){var s=this.object.toTex(u),c=this.index?this.index.toTex(u):"",m=this.value.toTex(u);return o(this,u&&u.parenthesis,u&&u.implicit)&&(m="\\left(".concat(m,"\\right)")),s+c+":="+m}}return zr(f,"name",Ji),f},{isClass:!0,isNode:!0}),Xi="BlockNode",wE=["ResultSet","Node"],NE=q(Xi,wE,r=>{var{ResultSet:e,Node:t}=r;class a extends t{constructor(i){if(super(),!Array.isArray(i))throw new Error("Array expected");this.blocks=i.map(function(o){var f=o&&o.node,l=o&&o.visible!==void 0?o.visible:!0;if(!fr(f))throw new TypeError('Property "node" must be a Node');if(typeof l!="boolean")throw new TypeError('Property "visible" must be a boolean');return{node:f,visible:l}})}get type(){return Xi}get isBlockNode(){return!0}_compile(i,o){var f=Ht(this.blocks,function(l){return{evaluate:l.node._compile(i,o),visible:l.visible}});return function(u,s,c){var m=[];return hi(f,function(h){var p=h.evaluate(u,s,c);h.visible&&m.push(p)}),new e(m)}}forEach(i){for(var o=0;o<this.blocks.length;o++)i(this.blocks[o].node,"blocks["+o+"].node",this)}map(i){for(var o=[],f=0;f<this.blocks.length;f++){var l=this.blocks[f],u=this._ifNode(i(l.node,"blocks["+f+"].node",this));o[f]={node:u,visible:l.visible}}return new a(o)}clone(){var i=this.blocks.map(function(o){return{node:o.node,visible:o.visible}});return new a(i)}_toString(i){return this.blocks.map(function(o){return o.node.toString(i)+(o.visible?"":";")}).join(`
|
|
30
30
|
`)}toJSON(){return{mathjs:Xi,blocks:this.blocks}}static fromJSON(i){return new a(i.blocks)}toHTML(i){return this.blocks.map(function(o){return o.node.toHTML(i)+(o.visible?"":'<span class="math-separator">;</span>')}).join('<span class="math-separator"><br /></span>')}_toTex(i){return this.blocks.map(function(o){return o.node.toTex(i)+(o.visible?"":";")}).join(`\\;\\;
|
|
31
|
-
`)}}return zr(a,"name",Xi),a},{isClass:!0,isNode:!0}),Wi="ConditionalNode",hE=["Node"],dE=q(Wi,hE,r=>{var{Node:e}=r;function t(n){if(typeof n=="number"||typeof n=="boolean"||typeof n=="string")return!!n;if(n){if(rr(n))return!n.isZero();if(Lt(n))return!!(n.re||n.im);if(kt(n))return!!n.value}if(n==null)return!1;throw new TypeError('Unsupported type of condition "'+br(n)+'"')}class a extends e{constructor(i,o,f){if(super(),!fr(i))throw new TypeError("Parameter condition must be a Node");if(!fr(o))throw new TypeError("Parameter trueExpr must be a Node");if(!fr(f))throw new TypeError("Parameter falseExpr must be a Node");this.condition=i,this.trueExpr=o,this.falseExpr=f}get type(){return Wi}get isConditionalNode(){return!0}_compile(i,o){var f=this.condition._compile(i,o),l=this.trueExpr._compile(i,o),u=this.falseExpr._compile(i,o);return function(c,m,v){return t(f(c,m,v))?l(c,m,v):u(c,m,v)}}forEach(i){i(this.condition,"condition",this),i(this.trueExpr,"trueExpr",this),i(this.falseExpr,"falseExpr",this)}map(i){return new a(this._ifNode(i(this.condition,"condition",this)),this._ifNode(i(this.trueExpr,"trueExpr",this)),this._ifNode(i(this.falseExpr,"falseExpr",this)))}clone(){return new a(this.condition,this.trueExpr,this.falseExpr)}_toString(i){var o=i&&i.parenthesis?i.parenthesis:"keep",f=pr(this,o,i&&i.implicit),l=this.condition.toString(i),u=pr(this.condition,o,i&&i.implicit);(o==="all"||this.condition.type==="OperatorNode"||u!==null&&u<=f)&&(l="("+l+")");var s=this.trueExpr.toString(i),c=pr(this.trueExpr,o,i&&i.implicit);(o==="all"||this.trueExpr.type==="OperatorNode"||c!==null&&c<=f)&&(s="("+s+")");var m=this.falseExpr.toString(i),v=pr(this.falseExpr,o,i&&i.implicit);return(o==="all"||this.falseExpr.type==="OperatorNode"||v!==null&&v<=f)&&(m="("+m+")"),l+" ? "+s+" : "+m}toJSON(){return{mathjs:Wi,condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}}static fromJSON(i){return new a(i.condition,i.trueExpr,i.falseExpr)}toHTML(i){var o=i&&i.parenthesis?i.parenthesis:"keep",f=pr(this,o,i&&i.implicit),l=this.condition.toHTML(i),u=pr(this.condition,o,i&&i.implicit);(o==="all"||this.condition.type==="OperatorNode"||u!==null&&u<=f)&&(l='<span class="math-parenthesis math-round-parenthesis">(</span>'+l+'<span class="math-parenthesis math-round-parenthesis">)</span>');var s=this.trueExpr.toHTML(i),c=pr(this.trueExpr,o,i&&i.implicit);(o==="all"||this.trueExpr.type==="OperatorNode"||c!==null&&c<=f)&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>');var m=this.falseExpr.toHTML(i),v=pr(this.falseExpr,o,i&&i.implicit);return(o==="all"||this.falseExpr.type==="OperatorNode"||v!==null&&v<=f)&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+'<span class="math-operator math-conditional-operator">?</span>'+s+'<span class="math-operator math-conditional-operator">:</span>'+m}_toTex(i){return"\\begin{cases} {"+this.trueExpr.toTex(i)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(i)+"}\\\\{"+this.falseExpr.toTex(i)+"}, &\\quad{\\text{otherwise}}\\end{cases}"}}return zr(a,"name",Wi),a},{isClass:!0,isNode:!0}),xs=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=t[a])}return r},gE={"{":"\\{","}":"\\}","\\":"\\textbackslash{}","#":"\\#",$:"\\$","%":"\\%","&":"\\&","^":"\\textasciicircum{}",_:"\\_","~":"\\textasciitilde{}"},yE={"\u2013":"\\--","\u2014":"\\---"," ":"~"," ":"\\qquad{}","\r\n":"\\newline{}","\n":"\\newline{}"},bE=function(e,t){return xs({},e,t)},xE=function(r){for(var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.preserveFormatting,a=t===void 0?!1:t,n=e.escapeMapFn,i=n===void 0?bE:n,o=String(r),f="",l=i(xs({},gE),a?xs({},yE):{}),u=Object.keys(l),s=function(){var m=!1;u.forEach(function(v,h){m||o.length>=v.length&&o.slice(0,v.length)===v&&(f+=l[u[h]],o=o.slice(v.length,o.length),m=!0)}),m||(f+=o.slice(0,1),o=o.slice(1,o.length))};o;)s();return f};const wE=xE;var ws={Alpha:"A",alpha:"\\alpha",Beta:"B",beta:"\\beta",Gamma:"\\Gamma",gamma:"\\gamma",Delta:"\\Delta",delta:"\\delta",Epsilon:"E",epsilon:"\\epsilon",varepsilon:"\\varepsilon",Zeta:"Z",zeta:"\\zeta",Eta:"H",eta:"\\eta",Theta:"\\Theta",theta:"\\theta",vartheta:"\\vartheta",Iota:"I",iota:"\\iota",Kappa:"K",kappa:"\\kappa",varkappa:"\\varkappa",Lambda:"\\Lambda",lambda:"\\lambda",Mu:"M",mu:"\\mu",Nu:"N",nu:"\\nu",Xi:"\\Xi",xi:"\\xi",Omicron:"O",omicron:"o",Pi:"\\Pi",pi:"\\pi",varpi:"\\varpi",Rho:"P",rho:"\\rho",varrho:"\\varrho",Sigma:"\\Sigma",sigma:"\\sigma",varsigma:"\\varsigma",Tau:"T",tau:"\\tau",Upsilon:"\\Upsilon",upsilon:"\\upsilon",Phi:"\\Phi",phi:"\\phi",varphi:"\\varphi",Chi:"X",chi:"\\chi",Psi:"\\Psi",psi:"\\psi",Omega:"\\Omega",omega:"\\omega",true:"\\mathrm{True}",false:"\\mathrm{False}",i:"i",inf:"\\infty",Inf:"\\infty",infinity:"\\infty",Infinity:"\\infty",oo:"\\infty",lim:"\\lim",undefined:"\\mathbf{?}"},sr={transpose:"^\\top",ctranspose:"^H",factorial:"!",pow:"^",dotPow:".^\\wedge",unaryPlus:"+",unaryMinus:"-",bitNot:"\\~",not:"\\neg",multiply:"\\cdot",divide:"\\frac",dotMultiply:".\\cdot",dotDivide:".:",mod:"\\mod",add:"+",subtract:"-",to:"\\rightarrow",leftShift:"<<",rightArithShift:">>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},jv={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(sr.add,"${args[1]}\\right)")},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:"\\left(${args[0]}".concat(sr.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(sr.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(sr.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(sr.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:"\\left(${args[0]}".concat(sr.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(sr.multiply,"${args[1]}\\right)")},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : $y^{args[1]} = {${args[0]}}\\}"},pow:{2:"\\left(${args[0]}\\right)".concat(sr.pow,"{${args[1]}}")},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:"\\left(${args[0]}".concat(sr.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(sr.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(sr.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(sr.bitAnd,"${args[1]}\\right)")},bitNot:{1:sr.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(sr.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(sr.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(sr.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(sr.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(sr.rightLogShift,"${args[1]}\\right)")},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:"\\left(${args[0]}".concat(sr.and,"${args[1]}\\right)")},not:{1:sr.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(sr.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(sr.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(sr.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},pinv:{1:"\\left(${args[0]}\\right)^{+}"},sqrtm:{1:"{${args[0]}}".concat(sr.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(sr.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(sr.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(sr.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(sr.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(sr.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(sr.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(sr.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(sr.unequal,"${args[1]}\\right)")},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:"\\left(${args[0]}".concat(sr.to,"${args[1]}\\right)")},numeric:function(e,t){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(ws.i,"\\cdot\\left(${args[1]}\\right)\\right)")},matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},NE="\\mathrm{${name}}\\left(${args}\\right)",ep={deg:"^\\circ"};function Ns(r){return wE(r,{preserveFormatting:!0})}function rp(r,e){return e=typeof e>"u"?!1:e,e?Re(ep,r)?ep[r]:"\\mathrm{"+Ns(r)+"}":Re(ws,r)?ws[r]:Ns(r)}var Yi="ConstantNode",DE=["Node"],AE=q(Yi,DE,r=>{var{Node:e}=r;class t extends e{constructor(n){super(),this.value=n}get type(){return Yi}get isConstantNode(){return!0}_compile(n,i){var o=this.value;return function(){return o}}forEach(n){}map(n){return this.clone()}clone(){return new t(this.value)}_toString(n){return Ye(this.value,n)}toHTML(n){var i=this._toString(n);switch(br(this.value)){case"number":case"BigNumber":case"Fraction":return'<span class="math-number">'+i+"</span>";case"string":return'<span class="math-string">'+i+"</span>";case"boolean":return'<span class="math-boolean">'+i+"</span>";case"null":return'<span class="math-null-symbol">'+i+"</span>";case"undefined":return'<span class="math-undefined">'+i+"</span>";default:return'<span class="math-symbol">'+i+"</span>"}}toJSON(){return{mathjs:Yi,value:this.value}}static fromJSON(n){return new t(n.value)}_toTex(n){var i=this._toString(n);switch(br(this.value)){case"string":return"\\mathtt{"+Ns(i)+"}";case"number":case"BigNumber":{if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var o=i.toLowerCase().indexOf("e");if(o!==-1)return i.substring(0,o)+"\\cdot10^{"+i.substring(o+1)+"}"}return i;case"Fraction":return this.value.toLatex();default:return i}}}return zr(t,"name",Yi),t},{isClass:!0,isNode:!0}),Qi="FunctionAssignmentNode",EE=["typed","Node"],SE=q(Qi,EE,r=>{var{typed:e,Node:t}=r;function a(i,o,f){var l=pr(i,o,f),u=pr(i.expr,o,f);return o==="all"||u!==null&&u<=l}class n extends t{constructor(o,f,l){if(super(),typeof o!="string")throw new TypeError('String expected for parameter "name"');if(!Array.isArray(f))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!fr(l))throw new TypeError('Node expected for parameter "expr"');if(Qv.has(o))throw new Error('Illegal function name, "'+o+'" is a reserved keyword');var u=new Set;for(var s of f){var c=typeof s=="string"?s:s.name;if(u.has(c))throw new Error('Duplicate parameter name "'.concat(c,'"'));u.add(c)}this.name=o,this.params=f.map(function(m){return m&&m.name||m}),this.types=f.map(function(m){return m&&m.type||"any"}),this.expr=l}get type(){return Qi}get isFunctionAssignmentNode(){return!0}_compile(o,f){var l=Object.create(f);hi(this.params,function(h){l[h]=!0});var u=this.expr._compile(o,l),s=this.name,c=this.params,m=El(this.types,","),v=s+"("+El(this.params,", ")+")";return function(p,g,y){var N={};N[m]=function(){for(var w=Object.create(g),x=0;x<c.length;x++)w[c[x]]=arguments[x];return u(p,w,y)};var d=e(s,N);return d.syntax=v,p.set(s,d),d}}forEach(o){o(this.expr,"expr",this)}map(o){var f=this._ifNode(o(this.expr,"expr",this));return new n(this.name,this.params.slice(0),f)}clone(){return new n(this.name,this.params.slice(0),this.expr)}_toString(o){var f=o&&o.parenthesis?o.parenthesis:"keep",l=this.expr.toString(o);return a(this,f,o&&o.implicit)&&(l="("+l+")"),this.name+"("+this.params.join(", ")+") = "+l}toJSON(){var o=this.types;return{mathjs:Qi,name:this.name,params:this.params.map(function(f,l){return{name:f,type:o[l]}}),expr:this.expr}}static fromJSON(o){return new n(o.name,o.params,o.expr)}toHTML(o){for(var f=o&&o.parenthesis?o.parenthesis:"keep",l=[],u=0;u<this.params.length;u++)l.push('<span class="math-symbol math-parameter">'+st(this.params[u])+"</span>");var s=this.expr.toHTML(o);return a(this,f,o&&o.implicit)&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),'<span class="math-function">'+st(this.name)+'</span><span class="math-parenthesis math-round-parenthesis">(</span>'+l.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-round-parenthesis">)</span><span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+s}_toTex(o){var f=o&&o.parenthesis?o.parenthesis:"keep",l=this.expr.toTex(o);return a(this,f,o&&o.implicit)&&(l="\\left(".concat(l,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(rp).join(",")+"\\right):="+l}}return zr(n,"name",Qi),n},{isClass:!0,isNode:!0}),Ki="IndexNode",CE=["Node","size"],ME=q(Ki,CE,r=>{var{Node:e,size:t}=r;class a extends e{constructor(i,o){if(super(),this.dimensions=i,this.dotNotation=o||!1,!Array.isArray(i)||!i.every(fr))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}get type(){return Ki}get isIndexNode(){return!0}_compile(i,o){var f=Gt(this.dimensions,function(u,s){var c=u.filter(h=>h.isSymbolNode&&h.name==="end").length>0;if(c){var m=Object.create(o);m.end=!0;var v=u._compile(i,m);return function(p,g,y){if(!Ve(y)&&!cr(y)&&!Wr(y))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+br(y));var N=t(y).valueOf(),d=Object.create(g);return d.end=N[s],v(p,d,y)}}else return u._compile(i,o)}),l=ut(i,"index");return function(s,c,m){var v=Gt(f,function(h){return h(s,c,m)});return l(...v)}}forEach(i){for(var o=0;o<this.dimensions.length;o++)i(this.dimensions[o],"dimensions["+o+"]",this)}map(i){for(var o=[],f=0;f<this.dimensions.length;f++)o[f]=this._ifNode(i(this.dimensions[f],"dimensions["+f+"]",this));return new a(o,this.dotNotation)}clone(){return new a(this.dimensions.slice(0),this.dotNotation)}isObjectProperty(){return this.dimensions.length===1&&ir(this.dimensions[0])&&typeof this.dimensions[0].value=="string"}getObjectProperty(){return this.isObjectProperty()?this.dimensions[0].value:null}_toString(i){return this.dotNotation?"."+this.getObjectProperty():"["+this.dimensions.join(", ")+"]"}toJSON(){return{mathjs:Ki,dimensions:this.dimensions,dotNotation:this.dotNotation}}static fromJSON(i){return new a(i.dimensions,i.dotNotation)}toHTML(i){for(var o=[],f=0;f<this.dimensions.length;f++)o[f]=this.dimensions[f].toHTML();return this.dotNotation?'<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">'+st(this.getObjectProperty())+"</span>":'<span class="math-parenthesis math-square-parenthesis">[</span>'+o.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(i){var o=this.dimensions.map(function(f){return f.toTex(i)});return this.dotNotation?"."+this.getObjectProperty():"_{"+o.join(",")+"}"}}return zr(a,"name",Ki),a},{isClass:!0,isNode:!0}),ji="ObjectNode",FE=["Node"],TE=q(ji,FE,r=>{var{Node:e}=r;class t extends e{constructor(n){if(super(),this.properties=n||{},n&&(typeof n!="object"||!Object.keys(n).every(function(i){return fr(n[i])})))throw new TypeError("Object containing Nodes expected")}get type(){return ji}get isObjectNode(){return!0}_compile(n,i){var o={};for(var f in this.properties)if(Re(this.properties,f)){var l=vi(f),u=JSON.parse(l);if(!Xo(this.properties,u))throw new Error('No access to property "'+u+'"');o[u]=this.properties[f]._compile(n,i)}return function(c,m,v){var h={};for(var p in o)Re(o,p)&&(h[p]=o[p](c,m,v));return h}}forEach(n){for(var i in this.properties)Re(this.properties,i)&&n(this.properties[i],"properties["+vi(i)+"]",this)}map(n){var i={};for(var o in this.properties)Re(this.properties,o)&&(i[o]=this._ifNode(n(this.properties[o],"properties["+vi(o)+"]",this)));return new t(i)}clone(){var n={};for(var i in this.properties)Re(this.properties,i)&&(n[i]=this.properties[i]);return new t(n)}_toString(n){var i=[];for(var o in this.properties)Re(this.properties,o)&&i.push(vi(o)+": "+this.properties[o].toString(n));return"{"+i.join(", ")+"}"}toJSON(){return{mathjs:ji,properties:this.properties}}static fromJSON(n){return new t(n.properties)}toHTML(n){var i=[];for(var o in this.properties)Re(this.properties,o)&&i.push('<span class="math-symbol math-property">'+st(o)+'</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>'+this.properties[o].toHTML(n));return'<span class="math-parenthesis math-curly-parenthesis">{</span>'+i.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-curly-parenthesis">}</span>'}_toTex(n){var i=[];for(var o in this.properties)Re(this.properties,o)&&i.push("\\mathbf{"+o+":} & "+this.properties[o].toTex(n)+"\\\\");var f="\\left\\{\\begin{array}{ll}"+i.join(`
|
|
32
|
-
`)+"\\end{array}\\right\\}";return f}}return zr(t,"name",ji),t},{isClass:!0,isNode:!0}),eo="OperatorNode",BE=["Node"],$E=q(eo,BE,r=>{var{Node:e}=r;function t(i,o){var f=i;if(o==="auto")for(;Vt(f);)f=f.content;return ir(f)?!0:Br(f)?t(f.args[0],o):!1}function a(i,o,f,l,u){var s=pr(i,o,f),c=Ja(i,o);if(o==="all"||l.length>2&&i.getIdentifier()!=="OperatorNode:add"&&i.getIdentifier()!=="OperatorNode:multiply")return l.map(function(D){switch(D.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}});var m;switch(l.length){case 0:m=[];break;case 1:{var v=pr(l[0],o,f,i);if(u&&v!==null){var h,p;if(o==="keep"?(h=l[0].getIdentifier(),p=i.getIdentifier()):(h=l[0].getContent().getIdentifier(),p=i.getContent().getIdentifier()),wt[s][p].latexLeftParens===!1){m=[!1];break}if(wt[v][h].latexParens===!1){m=[!1];break}}if(v===null){m=[!1];break}if(v<=s){m=[!0];break}m=[!1]}break;case 2:{var g,y=pr(l[0],o,f,i),N=bs(i,l[0],o);y===null?g=!1:y===s&&c==="right"&&!N||y<s?g=!0:g=!1;var d,w=pr(l[1],o,f,i),x=bs(i,l[1],o);if(w===null?d=!1:w===s&&c==="left"&&!x||w<s?d=!0:d=!1,u){var b,E,A;o==="keep"?(b=i.getIdentifier(),E=i.args[0].getIdentifier(),A=i.args[1].getIdentifier()):(b=i.getContent().getIdentifier(),E=i.args[0].getContent().getIdentifier(),A=i.args[1].getContent().getIdentifier()),y!==null&&(wt[s][b].latexLeftParens===!1&&(g=!1),wt[y][E].latexParens===!1&&(g=!1)),w!==null&&(wt[s][b].latexRightParens===!1&&(d=!1),wt[w][A].latexParens===!1&&(d=!1))}m=[g,d]}break;default:(i.getIdentifier()==="OperatorNode:add"||i.getIdentifier()==="OperatorNode:multiply")&&(m=l.map(function(D){var T=pr(D,o,f,i),B=bs(i,D,o),I=Ja(D,o);return T===null?!1:s===T&&c===I&&!B?!0:T<s}));break}if(l.length>=2&&i.getIdentifier()==="OperatorNode:multiply"&&i.implicit&&o!=="all"&&f==="hide")for(var S=1;S<m.length;++S)t(l[S],o)&&!m[S-1]&&(o!=="keep"||!Vt(l[S-1]))&&(m[S]=!0);return m}class n extends e{constructor(o,f,l,u,s){if(super(),typeof o!="string")throw new TypeError('string expected for parameter "op"');if(typeof f!="string")throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(l)||!l.every(fr))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=u===!0,this.isPercentage=s===!0,this.op=o,this.fn=f,this.args=l||[]}get type(){return eo}get isOperatorNode(){return!0}_compile(o,f){if(typeof this.fn!="string"||!Wo(o,this.fn))throw o[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var l=ut(o,this.fn),u=Gt(this.args,function(v){return v._compile(o,f)});if(u.length===1){var s=u[0];return function(h,p,g){return l(s(h,p,g))}}else if(u.length===2){var c=u[0],m=u[1];return function(h,p,g){return l(c(h,p,g),m(h,p,g))}}else return function(h,p,g){return l.apply(null,Gt(u,function(y){return y(h,p,g)}))}}forEach(o){for(var f=0;f<this.args.length;f++)o(this.args[f],"args["+f+"]",this)}map(o){for(var f=[],l=0;l<this.args.length;l++)f[l]=this._ifNode(o(this.args[l],"args["+l+"]",this));return new n(this.op,this.fn,f,this.implicit,this.isPercentage)}clone(){return new n(this.op,this.fn,this.args.slice(0),this.implicit,this.isPercentage)}isUnary(){return this.args.length===1}isBinary(){return this.args.length===2}_toString(o){var f=o&&o.parenthesis?o.parenthesis:"keep",l=o&&o.implicit?o.implicit:"hide",u=this.args,s=a(this,f,l,u,!1);if(u.length===1){var c=Ja(this,f),m=u[0].toString(o);s[0]&&(m="("+m+")");var v=/[a-zA-Z]+/.test(this.op);return c==="right"?this.op+(v?" ":"")+m:c==="left"?m+(v?" ":"")+this.op:m+this.op}else if(u.length===2){var h=u[0].toString(o),p=u[1].toString(o);return s[0]&&(h="("+h+")"),s[1]&&(p="("+p+")"),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?h+" "+p:h+" "+this.op+" "+p}else if(u.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var g=u.map(function(y,N){return y=y.toString(o),s[N]&&(y="("+y+")"),y});return this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?g.join(" "):g.join(" "+this.op+" ")}else return this.fn+"("+this.args.join(", ")+")"}toJSON(){return{mathjs:eo,op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}}static fromJSON(o){return new n(o.op,o.fn,o.args,o.implicit,o.isPercentage)}toHTML(o){var f=o&&o.parenthesis?o.parenthesis:"keep",l=o&&o.implicit?o.implicit:"hide",u=this.args,s=a(this,f,l,u,!1);if(u.length===1){var c=Ja(this,f),m=u[0].toHTML(o);return s[0]&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>'),c==="right"?'<span class="math-operator math-unary-operator math-lefthand-unary-operator">'+st(this.op)+"</span>"+m:m+'<span class="math-operator math-unary-operator math-righthand-unary-operator">'+st(this.op)+"</span>"}else if(u.length===2){var v=u[0].toHTML(o),h=u[1].toHTML(o);return s[0]&&(v='<span class="math-parenthesis math-round-parenthesis">(</span>'+v+'<span class="math-parenthesis math-round-parenthesis">)</span>'),s[1]&&(h='<span class="math-parenthesis math-round-parenthesis">(</span>'+h+'<span class="math-parenthesis math-round-parenthesis">)</span>'),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?v+'<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'+h:v+'<span class="math-operator math-binary-operator math-explicit-binary-operator">'+st(this.op)+"</span>"+h}else{var p=u.map(function(g,y){return g=g.toHTML(o),s[y]&&(g='<span class="math-parenthesis math-round-parenthesis">(</span>'+g+'<span class="math-parenthesis math-round-parenthesis">)</span>'),g});return u.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")?this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?p.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'):p.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">'+st(this.op)+"</span>"):'<span class="math-function">'+st(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+p.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}}_toTex(o){var f=o&&o.parenthesis?o.parenthesis:"keep",l=o&&o.implicit?o.implicit:"hide",u=this.args,s=a(this,f,l,u,!0),c=sr[this.fn];if(c=typeof c>"u"?this.op:c,u.length===1){var m=Ja(this,f),v=u[0].toTex(o);return s[0]&&(v="\\left(".concat(v,"\\right)")),m==="right"?c+v:v+c}else if(u.length===2){var h=u[0],p=h.toTex(o);s[0]&&(p="\\left(".concat(p,"\\right)"));var g=u[1],y=g.toTex(o);s[1]&&(y="\\left(".concat(y,"\\right)"));var N;switch(f==="keep"?N=h.getIdentifier():N=h.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return c+"{"+p+"}{"+y+"}";case"OperatorNode:pow":switch(p="{"+p+"}",y="{"+y+"}",N){case"ConditionalNode":case"OperatorNode:divide":p="\\left(".concat(p,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&l==="hide")return p+"~"+y}return p+c+y}else if(u.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var d=u.map(function(w,x){return w=w.toTex(o),s[x]&&(w="\\left(".concat(w,"\\right)")),w});return this.getIdentifier()==="OperatorNode:multiply"&&this.implicit&&l==="hide"?d.join("~"):d.join(c)}else return"\\mathrm{"+this.fn+"}\\left("+u.map(function(w){return w.toTex(o)}).join(",")+"\\right)"}getIdentifier(){return this.type+":"+this.fn}}return zr(n,"name",eo),n},{isClass:!0,isNode:!0}),ro="ParenthesisNode",OE=["Node"],IE=q(ro,OE,r=>{var{Node:e}=r;class t extends e{constructor(n){if(super(),!fr(n))throw new TypeError('Node expected for parameter "content"');this.content=n}get type(){return ro}get isParenthesisNode(){return!0}_compile(n,i){return this.content._compile(n,i)}getContent(){return this.content.getContent()}forEach(n){n(this.content,"content",this)}map(n){var i=n(this.content,"content",this);return new t(i)}clone(){return new t(this.content)}_toString(n){return!n||n&&!n.parenthesis||n&&n.parenthesis==="keep"?"("+this.content.toString(n)+")":this.content.toString(n)}toJSON(){return{mathjs:ro,content:this.content}}static fromJSON(n){return new t(n.content)}toHTML(n){return!n||n&&!n.parenthesis||n&&n.parenthesis==="keep"?'<span class="math-parenthesis math-round-parenthesis">(</span>'+this.content.toHTML(n)+'<span class="math-parenthesis math-round-parenthesis">)</span>':this.content.toHTML(n)}_toTex(n){return!n||n&&!n.parenthesis||n&&n.parenthesis==="keep"?"\\left(".concat(this.content.toTex(n),"\\right)"):this.content.toTex(n)}}return zr(t,"name",ro),t},{isClass:!0,isNode:!0}),to="RangeNode",RE=["Node"],_E=q(to,RE,r=>{var{Node:e}=r;function t(n,i,o){var f=pr(n,i,o),l={},u=pr(n.start,i,o);if(l.start=u!==null&&u<=f||i==="all",n.step){var s=pr(n.step,i,o);l.step=s!==null&&s<=f||i==="all"}var c=pr(n.end,i,o);return l.end=c!==null&&c<=f||i==="all",l}class a extends e{constructor(i,o,f){if(super(),!fr(i))throw new TypeError("Node expected");if(!fr(o))throw new TypeError("Node expected");if(f&&!fr(f))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=i,this.end=o,this.step=f||null}get type(){return to}get isRangeNode(){return!0}needsEnd(){var i=this.filter(function(o){return qr(o)&&o.name==="end"});return i.length>0}_compile(i,o){var f=i.range,l=this.start._compile(i,o),u=this.end._compile(i,o);if(this.step){var s=this.step._compile(i,o);return function(m,v,h){return f(l(m,v,h),u(m,v,h),s(m,v,h))}}else return function(m,v,h){return f(l(m,v,h),u(m,v,h))}}forEach(i){i(this.start,"start",this),i(this.end,"end",this),this.step&&i(this.step,"step",this)}map(i){return new a(this._ifNode(i(this.start,"start",this)),this._ifNode(i(this.end,"end",this)),this.step&&this._ifNode(i(this.step,"step",this)))}clone(){return new a(this.start,this.end,this.step&&this.step)}_toString(i){var o=i&&i.parenthesis?i.parenthesis:"keep",f=t(this,o,i&&i.implicit),l,u=this.start.toString(i);if(f.start&&(u="("+u+")"),l=u,this.step){var s=this.step.toString(i);f.step&&(s="("+s+")"),l+=":"+s}var c=this.end.toString(i);return f.end&&(c="("+c+")"),l+=":"+c,l}toJSON(){return{mathjs:to,start:this.start,end:this.end,step:this.step}}static fromJSON(i){return new a(i.start,i.end,i.step)}toHTML(i){var o=i&&i.parenthesis?i.parenthesis:"keep",f=t(this,o,i&&i.implicit),l,u=this.start.toHTML(i);if(f.start&&(u='<span class="math-parenthesis math-round-parenthesis">(</span>'+u+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l=u,this.step){var s=this.step.toHTML(i);f.step&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+='<span class="math-operator math-range-operator">:</span>'+s}var c=this.end.toHTML(i);return f.end&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+='<span class="math-operator math-range-operator">:</span>'+c,l}_toTex(i){var o=i&&i.parenthesis?i.parenthesis:"keep",f=t(this,o,i&&i.implicit),l=this.start.toTex(i);if(f.start&&(l="\\left(".concat(l,"\\right)")),this.step){var u=this.step.toTex(i);f.step&&(u="\\left(".concat(u,"\\right)")),l+=":"+u}var s=this.end.toTex(i);return f.end&&(s="\\left(".concat(s,"\\right)")),l+=":"+s,l}}return zr(a,"name",to),a},{isClass:!0,isNode:!0}),no="RelationalNode",qE=["Node"],zE=q(no,qE,r=>{var{Node:e}=r,t={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="};class a extends e{constructor(i,o){if(super(),!Array.isArray(i))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(o))throw new TypeError("Parameter params must be an array");if(i.length!==o.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=i,this.params=o}get type(){return no}get isRelationalNode(){return!0}_compile(i,o){var f=this,l=this.params.map(u=>u._compile(i,o));return function(s,c,m){for(var v,h=l[0](s,c,m),p=0;p<f.conditionals.length;p++){v=h,h=l[p+1](s,c,m);var g=ut(i,f.conditionals[p]);if(!g(v,h))return!1}return!0}}forEach(i){this.params.forEach((o,f)=>i(o,"params["+f+"]",this),this)}map(i){return new a(this.conditionals.slice(),this.params.map((o,f)=>this._ifNode(i(o,"params["+f+"]",this)),this))}clone(){return new a(this.conditionals,this.params)}_toString(i){for(var o=i&&i.parenthesis?i.parenthesis:"keep",f=pr(this,o,i&&i.implicit),l=this.params.map(function(c,m){var v=pr(c,o,i&&i.implicit);return o==="all"||v!==null&&v<=f?"("+c.toString(i)+")":c.toString(i)}),u=l[0],s=0;s<this.conditionals.length;s++)u+=" "+t[this.conditionals[s]],u+=" "+l[s+1];return u}toJSON(){return{mathjs:no,conditionals:this.conditionals,params:this.params}}static fromJSON(i){return new a(i.conditionals,i.params)}toHTML(i){for(var o=i&&i.parenthesis?i.parenthesis:"keep",f=pr(this,o,i&&i.implicit),l=this.params.map(function(c,m){var v=pr(c,o,i&&i.implicit);return o==="all"||v!==null&&v<=f?'<span class="math-parenthesis math-round-parenthesis">(</span>'+c.toHTML(i)+'<span class="math-parenthesis math-round-parenthesis">)</span>':c.toHTML(i)}),u=l[0],s=0;s<this.conditionals.length;s++)u+='<span class="math-operator math-binary-operator math-explicit-binary-operator">'+st(t[this.conditionals[s]])+"</span>"+l[s+1];return u}_toTex(i){for(var o=i&&i.parenthesis?i.parenthesis:"keep",f=pr(this,o,i&&i.implicit),l=this.params.map(function(c,m){var v=pr(c,o,i&&i.implicit);return o==="all"||v!==null&&v<=f?"\\left("+c.toTex(i)+"\right)":c.toTex(i)}),u=l[0],s=0;s<this.conditionals.length;s++)u+=sr[this.conditionals[s]]+l[s+1];return u}}return zr(a,"name",no),a},{isClass:!0,isNode:!0}),PE="SymbolNode",UE=["math","?Unit","Node"],LE=q(PE,UE,r=>{var{math:e,Unit:t,Node:a}=r;function n(o){return t?t.isValuelessUnit(o):!1}class i extends a{constructor(f){if(super(),typeof f!="string")throw new TypeError('String expected for parameter "name"');this.name=f}get type(){return"SymbolNode"}get isSymbolNode(){return!0}_compile(f,l){var u=this.name;if(l[u]===!0)return function(c,m,v){return m[u]};if(u in f)return function(c,m,v){return c.has(u)?c.get(u):ut(f,u)};var s=n(u);return function(c,m,v){return c.has(u)?c.get(u):s?new t(null,u):i.onUndefinedSymbol(u)}}forEach(f){}map(f){return this.clone()}static onUndefinedSymbol(f){throw new Error("Undefined symbol "+f)}clone(){return new i(this.name)}_toString(f){return this.name}toHTML(f){var l=st(this.name);return l==="true"||l==="false"?'<span class="math-symbol math-boolean">'+l+"</span>":l==="i"?'<span class="math-symbol math-imaginary-symbol">'+l+"</span>":l==="Infinity"?'<span class="math-symbol math-infinity-symbol">'+l+"</span>":l==="NaN"?'<span class="math-symbol math-nan-symbol">'+l+"</span>":l==="null"?'<span class="math-symbol math-null-symbol">'+l+"</span>":l==="undefined"?'<span class="math-symbol math-undefined-symbol">'+l+"</span>":'<span class="math-symbol">'+l+"</span>"}toJSON(){return{mathjs:"SymbolNode",name:this.name}}static fromJSON(f){return new i(f.name)}_toTex(f){var l=!1;typeof e[this.name]>"u"&&n(this.name)&&(l=!0);var u=rp(this.name,l);return u[0]==="\\"?u:" "+u}}return i},{isClass:!0,isNode:!0});function Xa(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),a=1;a<e;a++)t[a-1]=arguments[a];return typeof r.createSubScope=="function"?Cl(r.createSubScope(),...t):Cl(jn(),r,...t)}var ao="FunctionNode",kE=["math","Node","SymbolNode"],VE=q(ao,kE,r=>{var{math:e,Node:t,SymbolNode:a}=r,n=f=>Ye(f,{truncate:78});function i(f,l,u){for(var s="",c=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,m=0,v;(v=c.exec(f))!==null;)if(s+=f.substring(m,v.index),m=v.index,v[0]==="$$")s+="$",m++;else{m+=v[0].length;var h=l[v[1]];if(!h)throw new ReferenceError("Template: Property "+v[1]+" does not exist.");if(v[2]===void 0)switch(typeof h){case"string":s+=h;break;case"object":if(fr(h))s+=h.toTex(u);else if(Array.isArray(h))s+=h.map(function(p,g){if(fr(p))return p.toTex(u);throw new TypeError("Template: "+v[1]+"["+g+"] is not a Node.")}).join(",");else throw new TypeError("Template: "+v[1]+" has to be a Node, String or array of Nodes");break;default:throw new TypeError("Template: "+v[1]+" has to be a Node, String or array of Nodes")}else if(fr(h[v[2]]&&h[v[2]]))s+=h[v[2]].toTex(u);else throw new TypeError("Template: "+v[1]+"["+v[2]+"] is not a Node.")}return s+=f.slice(m),s}class o extends t{constructor(l,u){if(super(),typeof l=="string"&&(l=new a(l)),!fr(l))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(u)||!u.every(fr))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=l,this.args=u||[]}get name(){return this.fn.name||""}get type(){return ao}get isFunctionNode(){return!0}_compile(l,u){var s=this.args.map(E=>E._compile(l,u));if(qr(this.fn)){var c=this.fn.name;if(u[c]){var g=this.args;return function(A,S,D){var T=S[c];if(typeof T!="function")throw new TypeError("Argument '".concat(c,"' was not a function; received: ").concat(n(T)));if(T.rawArgs)return T(g,l,Xa(A,S),A);var B=s.map(I=>I(A,S,D));return T.apply(T,B)}}else{var m=c in l?ut(l,c):void 0,v=typeof m=="function"&&m.rawArgs===!0,h=E=>{var A;if(E.has(c))A=E.get(c);else if(c in l)A=ut(l,c);else return o.onUndefinedFunction(c);if(typeof A=="function")return A;throw new TypeError("'".concat(c,`' is not a function; its value is:
|
|
33
|
-
`).concat(n(A)))};if(v){var p=this.args;return function(A,S,D){var T=h(A);return T(p,l,
|
|
34
|
-
`.concat(n(T)));if(T.rawArgs)return T(b,l,
|
|
31
|
+
`)}}return zr(a,"name",Xi),a},{isClass:!0,isNode:!0}),Wi="ConditionalNode",DE=["Node"],AE=q(Wi,DE,r=>{var{Node:e}=r;function t(n){if(typeof n=="number"||typeof n=="boolean"||typeof n=="string")return!!n;if(n){if(rr(n))return!n.isZero();if(kt(n))return!!(n.re||n.im);if(Vt(n))return!!n.value}if(n==null)return!1;throw new TypeError('Unsupported type of condition "'+br(n)+'"')}class a extends e{constructor(i,o,f){if(super(),!fr(i))throw new TypeError("Parameter condition must be a Node");if(!fr(o))throw new TypeError("Parameter trueExpr must be a Node");if(!fr(f))throw new TypeError("Parameter falseExpr must be a Node");this.condition=i,this.trueExpr=o,this.falseExpr=f}get type(){return Wi}get isConditionalNode(){return!0}_compile(i,o){var f=this.condition._compile(i,o),l=this.trueExpr._compile(i,o),u=this.falseExpr._compile(i,o);return function(c,m,v){return t(f(c,m,v))?l(c,m,v):u(c,m,v)}}forEach(i){i(this.condition,"condition",this),i(this.trueExpr,"trueExpr",this),i(this.falseExpr,"falseExpr",this)}map(i){return new a(this._ifNode(i(this.condition,"condition",this)),this._ifNode(i(this.trueExpr,"trueExpr",this)),this._ifNode(i(this.falseExpr,"falseExpr",this)))}clone(){return new a(this.condition,this.trueExpr,this.falseExpr)}_toString(i){var o=i&&i.parenthesis?i.parenthesis:"keep",f=pr(this,o,i&&i.implicit),l=this.condition.toString(i),u=pr(this.condition,o,i&&i.implicit);(o==="all"||this.condition.type==="OperatorNode"||u!==null&&u<=f)&&(l="("+l+")");var s=this.trueExpr.toString(i),c=pr(this.trueExpr,o,i&&i.implicit);(o==="all"||this.trueExpr.type==="OperatorNode"||c!==null&&c<=f)&&(s="("+s+")");var m=this.falseExpr.toString(i),v=pr(this.falseExpr,o,i&&i.implicit);return(o==="all"||this.falseExpr.type==="OperatorNode"||v!==null&&v<=f)&&(m="("+m+")"),l+" ? "+s+" : "+m}toJSON(){return{mathjs:Wi,condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}}static fromJSON(i){return new a(i.condition,i.trueExpr,i.falseExpr)}toHTML(i){var o=i&&i.parenthesis?i.parenthesis:"keep",f=pr(this,o,i&&i.implicit),l=this.condition.toHTML(i),u=pr(this.condition,o,i&&i.implicit);(o==="all"||this.condition.type==="OperatorNode"||u!==null&&u<=f)&&(l='<span class="math-parenthesis math-round-parenthesis">(</span>'+l+'<span class="math-parenthesis math-round-parenthesis">)</span>');var s=this.trueExpr.toHTML(i),c=pr(this.trueExpr,o,i&&i.implicit);(o==="all"||this.trueExpr.type==="OperatorNode"||c!==null&&c<=f)&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>');var m=this.falseExpr.toHTML(i),v=pr(this.falseExpr,o,i&&i.implicit);return(o==="all"||this.falseExpr.type==="OperatorNode"||v!==null&&v<=f)&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+'<span class="math-operator math-conditional-operator">?</span>'+s+'<span class="math-operator math-conditional-operator">:</span>'+m}_toTex(i){return"\\begin{cases} {"+this.trueExpr.toTex(i)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(i)+"}\\\\{"+this.falseExpr.toTex(i)+"}, &\\quad{\\text{otherwise}}\\end{cases}"}}return zr(a,"name",Wi),a},{isClass:!0,isNode:!0}),xs=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=t[a])}return r},EE={"{":"\\{","}":"\\}","\\":"\\textbackslash{}","#":"\\#",$:"\\$","%":"\\%","&":"\\&","^":"\\textasciicircum{}",_:"\\_","~":"\\textasciitilde{}"},SE={"\u2013":"\\--","\u2014":"\\---"," ":"~"," ":"\\qquad{}","\r\n":"\\newline{}","\n":"\\newline{}"},CE=function(e,t){return xs({},e,t)},ME=function(r){for(var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.preserveFormatting,a=t===void 0?!1:t,n=e.escapeMapFn,i=n===void 0?CE:n,o=String(r),f="",l=i(xs({},EE),a?xs({},SE):{}),u=Object.keys(l),s=function(){var m=!1;u.forEach(function(v,h){m||o.length>=v.length&&o.slice(0,v.length)===v&&(f+=l[u[h]],o=o.slice(v.length,o.length),m=!0)}),m||(f+=o.slice(0,1),o=o.slice(1,o.length))};o;)s();return f};const FE=ME;var ws={Alpha:"A",alpha:"\\alpha",Beta:"B",beta:"\\beta",Gamma:"\\Gamma",gamma:"\\gamma",Delta:"\\Delta",delta:"\\delta",Epsilon:"E",epsilon:"\\epsilon",varepsilon:"\\varepsilon",Zeta:"Z",zeta:"\\zeta",Eta:"H",eta:"\\eta",Theta:"\\Theta",theta:"\\theta",vartheta:"\\vartheta",Iota:"I",iota:"\\iota",Kappa:"K",kappa:"\\kappa",varkappa:"\\varkappa",Lambda:"\\Lambda",lambda:"\\lambda",Mu:"M",mu:"\\mu",Nu:"N",nu:"\\nu",Xi:"\\Xi",xi:"\\xi",Omicron:"O",omicron:"o",Pi:"\\Pi",pi:"\\pi",varpi:"\\varpi",Rho:"P",rho:"\\rho",varrho:"\\varrho",Sigma:"\\Sigma",sigma:"\\sigma",varsigma:"\\varsigma",Tau:"T",tau:"\\tau",Upsilon:"\\Upsilon",upsilon:"\\upsilon",Phi:"\\Phi",phi:"\\phi",varphi:"\\varphi",Chi:"X",chi:"\\chi",Psi:"\\Psi",psi:"\\psi",Omega:"\\Omega",omega:"\\omega",true:"\\mathrm{True}",false:"\\mathrm{False}",i:"i",inf:"\\infty",Inf:"\\infty",infinity:"\\infty",Infinity:"\\infty",oo:"\\infty",lim:"\\lim",undefined:"\\mathbf{?}"},sr={transpose:"^\\top",ctranspose:"^H",factorial:"!",pow:"^",dotPow:".^\\wedge",unaryPlus:"+",unaryMinus:"-",bitNot:"\\~",not:"\\neg",multiply:"\\cdot",divide:"\\frac",dotMultiply:".\\cdot",dotDivide:".:",mod:"\\mod",add:"+",subtract:"-",to:"\\rightarrow",leftShift:"<<",rightArithShift:">>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},rp={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(sr.add,"${args[1]}\\right)")},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:"\\left(${args[0]}".concat(sr.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(sr.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(sr.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(sr.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:"\\left(${args[0]}".concat(sr.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(sr.multiply,"${args[1]}\\right)")},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : $y^{args[1]} = {${args[0]}}\\}"},pow:{2:"\\left(${args[0]}\\right)".concat(sr.pow,"{${args[1]}}")},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:"\\left(${args[0]}".concat(sr.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(sr.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(sr.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(sr.bitAnd,"${args[1]}\\right)")},bitNot:{1:sr.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(sr.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(sr.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(sr.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(sr.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(sr.rightLogShift,"${args[1]}\\right)")},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:"\\left(${args[0]}".concat(sr.and,"${args[1]}\\right)")},not:{1:sr.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(sr.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(sr.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(sr.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},pinv:{1:"\\left(${args[0]}\\right)^{+}"},sqrtm:{1:"{${args[0]}}".concat(sr.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(sr.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(sr.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(sr.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(sr.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(sr.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(sr.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(sr.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(sr.unequal,"${args[1]}\\right)")},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:"\\left(${args[0]}".concat(sr.to,"${args[1]}\\right)")},numeric:function(e,t){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(ws.i,"\\cdot\\left(${args[1]}\\right)\\right)")},matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},TE="\\mathrm{${name}}\\left(${args}\\right)",tp={deg:"^\\circ"};function Ns(r){return FE(r,{preserveFormatting:!0})}function np(r,e){return e=typeof e>"u"?!1:e,e?Re(tp,r)?tp[r]:"\\mathrm{"+Ns(r)+"}":Re(ws,r)?ws[r]:Ns(r)}var Yi="ConstantNode",BE=["Node"],$E=q(Yi,BE,r=>{var{Node:e}=r;class t extends e{constructor(n){super(),this.value=n}get type(){return Yi}get isConstantNode(){return!0}_compile(n,i){var o=this.value;return function(){return o}}forEach(n){}map(n){return this.clone()}clone(){return new t(this.value)}_toString(n){return Ye(this.value,n)}toHTML(n){var i=this._toString(n);switch(br(this.value)){case"number":case"BigNumber":case"Fraction":return'<span class="math-number">'+i+"</span>";case"string":return'<span class="math-string">'+i+"</span>";case"boolean":return'<span class="math-boolean">'+i+"</span>";case"null":return'<span class="math-null-symbol">'+i+"</span>";case"undefined":return'<span class="math-undefined">'+i+"</span>";default:return'<span class="math-symbol">'+i+"</span>"}}toJSON(){return{mathjs:Yi,value:this.value}}static fromJSON(n){return new t(n.value)}_toTex(n){var i=this._toString(n);switch(br(this.value)){case"string":return"\\mathtt{"+Ns(i)+"}";case"number":case"BigNumber":{if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var o=i.toLowerCase().indexOf("e");if(o!==-1)return i.substring(0,o)+"\\cdot10^{"+i.substring(o+1)+"}"}return i;case"Fraction":return this.value.toLatex();default:return i}}}return zr(t,"name",Yi),t},{isClass:!0,isNode:!0}),Qi="FunctionAssignmentNode",OE=["typed","Node"],IE=q(Qi,OE,r=>{var{typed:e,Node:t}=r;function a(i,o,f){var l=pr(i,o,f),u=pr(i.expr,o,f);return o==="all"||u!==null&&u<=l}class n extends t{constructor(o,f,l){if(super(),typeof o!="string")throw new TypeError('String expected for parameter "name"');if(!Array.isArray(f))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!fr(l))throw new TypeError('Node expected for parameter "expr"');if(jv.has(o))throw new Error('Illegal function name, "'+o+'" is a reserved keyword');var u=new Set;for(var s of f){var c=typeof s=="string"?s:s.name;if(u.has(c))throw new Error('Duplicate parameter name "'.concat(c,'"'));u.add(c)}this.name=o,this.params=f.map(function(m){return m&&m.name||m}),this.types=f.map(function(m){return m&&m.type||"any"}),this.expr=l}get type(){return Qi}get isFunctionAssignmentNode(){return!0}_compile(o,f){var l=Object.create(f);hi(this.params,function(h){l[h]=!0});var u=this.expr._compile(o,l),s=this.name,c=this.params,m=Cl(this.types,","),v=s+"("+Cl(this.params,", ")+")";return function(p,g,y){var N={};N[m]=function(){for(var w=Object.create(g),x=0;x<c.length;x++)w[c[x]]=arguments[x];return u(p,w,y)};var d=e(s,N);return d.syntax=v,p.set(s,d),d}}forEach(o){o(this.expr,"expr",this)}map(o){var f=this._ifNode(o(this.expr,"expr",this));return new n(this.name,this.params.slice(0),f)}clone(){return new n(this.name,this.params.slice(0),this.expr)}_toString(o){var f=o&&o.parenthesis?o.parenthesis:"keep",l=this.expr.toString(o);return a(this,f,o&&o.implicit)&&(l="("+l+")"),this.name+"("+this.params.join(", ")+") = "+l}toJSON(){var o=this.types;return{mathjs:Qi,name:this.name,params:this.params.map(function(f,l){return{name:f,type:o[l]}}),expr:this.expr}}static fromJSON(o){return new n(o.name,o.params,o.expr)}toHTML(o){for(var f=o&&o.parenthesis?o.parenthesis:"keep",l=[],u=0;u<this.params.length;u++)l.push('<span class="math-symbol math-parameter">'+ut(this.params[u])+"</span>");var s=this.expr.toHTML(o);return a(this,f,o&&o.implicit)&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),'<span class="math-function">'+ut(this.name)+'</span><span class="math-parenthesis math-round-parenthesis">(</span>'+l.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-round-parenthesis">)</span><span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+s}_toTex(o){var f=o&&o.parenthesis?o.parenthesis:"keep",l=this.expr.toTex(o);return a(this,f,o&&o.implicit)&&(l="\\left(".concat(l,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(np).join(",")+"\\right):="+l}}return zr(n,"name",Qi),n},{isClass:!0,isNode:!0}),Ki="IndexNode",RE=["Node","size"],_E=q(Ki,RE,r=>{var{Node:e,size:t}=r;class a extends e{constructor(i,o){if(super(),this.dimensions=i,this.dotNotation=o||!1,!Array.isArray(i)||!i.every(fr))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}get type(){return Ki}get isIndexNode(){return!0}_compile(i,o){var f=Ht(this.dimensions,function(u,s){var c=u.filter(h=>h.isSymbolNode&&h.name==="end").length>0;if(c){var m=Object.create(o);m.end=!0;var v=u._compile(i,m);return function(p,g,y){if(!Ve(y)&&!cr(y)&&!Wr(y))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+br(y));var N=t(y).valueOf(),d=Object.create(g);return d.end=N[s],v(p,d,y)}}else return u._compile(i,o)}),l=lt(i,"index");return function(s,c,m){var v=Ht(f,function(h){return h(s,c,m)});return l(...v)}}forEach(i){for(var o=0;o<this.dimensions.length;o++)i(this.dimensions[o],"dimensions["+o+"]",this)}map(i){for(var o=[],f=0;f<this.dimensions.length;f++)o[f]=this._ifNode(i(this.dimensions[f],"dimensions["+f+"]",this));return new a(o,this.dotNotation)}clone(){return new a(this.dimensions.slice(0),this.dotNotation)}isObjectProperty(){return this.dimensions.length===1&&ir(this.dimensions[0])&&typeof this.dimensions[0].value=="string"}getObjectProperty(){return this.isObjectProperty()?this.dimensions[0].value:null}_toString(i){return this.dotNotation?"."+this.getObjectProperty():"["+this.dimensions.join(", ")+"]"}toJSON(){return{mathjs:Ki,dimensions:this.dimensions,dotNotation:this.dotNotation}}static fromJSON(i){return new a(i.dimensions,i.dotNotation)}toHTML(i){for(var o=[],f=0;f<this.dimensions.length;f++)o[f]=this.dimensions[f].toHTML();return this.dotNotation?'<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">'+ut(this.getObjectProperty())+"</span>":'<span class="math-parenthesis math-square-parenthesis">[</span>'+o.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(i){var o=this.dimensions.map(function(f){return f.toTex(i)});return this.dotNotation?"."+this.getObjectProperty():"_{"+o.join(",")+"}"}}return zr(a,"name",Ki),a},{isClass:!0,isNode:!0}),ji="ObjectNode",qE=["Node"],zE=q(ji,qE,r=>{var{Node:e}=r;class t extends e{constructor(n){if(super(),this.properties=n||{},n&&(typeof n!="object"||!Object.keys(n).every(function(i){return fr(n[i])})))throw new TypeError("Object containing Nodes expected")}get type(){return ji}get isObjectNode(){return!0}_compile(n,i){var o={};for(var f in this.properties)if(Re(this.properties,f)){var l=vi(f),u=JSON.parse(l);if(!Xo(this.properties,u))throw new Error('No access to property "'+u+'"');o[u]=this.properties[f]._compile(n,i)}return function(c,m,v){var h={};for(var p in o)Re(o,p)&&(h[p]=o[p](c,m,v));return h}}forEach(n){for(var i in this.properties)Re(this.properties,i)&&n(this.properties[i],"properties["+vi(i)+"]",this)}map(n){var i={};for(var o in this.properties)Re(this.properties,o)&&(i[o]=this._ifNode(n(this.properties[o],"properties["+vi(o)+"]",this)));return new t(i)}clone(){var n={};for(var i in this.properties)Re(this.properties,i)&&(n[i]=this.properties[i]);return new t(n)}_toString(n){var i=[];for(var o in this.properties)Re(this.properties,o)&&i.push(vi(o)+": "+this.properties[o].toString(n));return"{"+i.join(", ")+"}"}toJSON(){return{mathjs:ji,properties:this.properties}}static fromJSON(n){return new t(n.properties)}toHTML(n){var i=[];for(var o in this.properties)Re(this.properties,o)&&i.push('<span class="math-symbol math-property">'+ut(o)+'</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>'+this.properties[o].toHTML(n));return'<span class="math-parenthesis math-curly-parenthesis">{</span>'+i.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-curly-parenthesis">}</span>'}_toTex(n){var i=[];for(var o in this.properties)Re(this.properties,o)&&i.push("\\mathbf{"+o+":} & "+this.properties[o].toTex(n)+"\\\\");var f="\\left\\{\\begin{array}{ll}"+i.join(`
|
|
32
|
+
`)+"\\end{array}\\right\\}";return f}}return zr(t,"name",ji),t},{isClass:!0,isNode:!0}),eo="OperatorNode",PE=["Node"],UE=q(eo,PE,r=>{var{Node:e}=r;function t(i,o){var f=i;if(o==="auto")for(;Gt(f);)f=f.content;return ir(f)?!0:Br(f)?t(f.args[0],o):!1}function a(i,o,f,l,u){var s=pr(i,o,f),c=Xa(i,o);if(o==="all"||l.length>2&&i.getIdentifier()!=="OperatorNode:add"&&i.getIdentifier()!=="OperatorNode:multiply")return l.map(function(D){switch(D.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}});var m;switch(l.length){case 0:m=[];break;case 1:{var v=pr(l[0],o,f,i);if(u&&v!==null){var h,p;if(o==="keep"?(h=l[0].getIdentifier(),p=i.getIdentifier()):(h=l[0].getContent().getIdentifier(),p=i.getContent().getIdentifier()),Nt[s][p].latexLeftParens===!1){m=[!1];break}if(Nt[v][h].latexParens===!1){m=[!1];break}}if(v===null){m=[!1];break}if(v<=s){m=[!0];break}m=[!1]}break;case 2:{var g,y=pr(l[0],o,f,i),N=bs(i,l[0],o);y===null?g=!1:y===s&&c==="right"&&!N||y<s?g=!0:g=!1;var d,w=pr(l[1],o,f,i),x=bs(i,l[1],o);if(w===null?d=!1:w===s&&c==="left"&&!x||w<s?d=!0:d=!1,u){var b,E,A;o==="keep"?(b=i.getIdentifier(),E=i.args[0].getIdentifier(),A=i.args[1].getIdentifier()):(b=i.getContent().getIdentifier(),E=i.args[0].getContent().getIdentifier(),A=i.args[1].getContent().getIdentifier()),y!==null&&(Nt[s][b].latexLeftParens===!1&&(g=!1),Nt[y][E].latexParens===!1&&(g=!1)),w!==null&&(Nt[s][b].latexRightParens===!1&&(d=!1),Nt[w][A].latexParens===!1&&(d=!1))}m=[g,d]}break;default:(i.getIdentifier()==="OperatorNode:add"||i.getIdentifier()==="OperatorNode:multiply")&&(m=l.map(function(D){var T=pr(D,o,f,i),B=bs(i,D,o),I=Xa(D,o);return T===null?!1:s===T&&c===I&&!B?!0:T<s}));break}if(l.length>=2&&i.getIdentifier()==="OperatorNode:multiply"&&i.implicit&&o!=="all"&&f==="hide")for(var S=1;S<m.length;++S)t(l[S],o)&&!m[S-1]&&(o!=="keep"||!Gt(l[S-1]))&&(m[S]=!0);return m}class n extends e{constructor(o,f,l,u,s){if(super(),typeof o!="string")throw new TypeError('string expected for parameter "op"');if(typeof f!="string")throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(l)||!l.every(fr))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=u===!0,this.isPercentage=s===!0,this.op=o,this.fn=f,this.args=l||[]}get type(){return eo}get isOperatorNode(){return!0}_compile(o,f){if(typeof this.fn!="string"||!Wo(o,this.fn))throw o[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var l=lt(o,this.fn),u=Ht(this.args,function(v){return v._compile(o,f)});if(u.length===1){var s=u[0];return function(h,p,g){return l(s(h,p,g))}}else if(u.length===2){var c=u[0],m=u[1];return function(h,p,g){return l(c(h,p,g),m(h,p,g))}}else return function(h,p,g){return l.apply(null,Ht(u,function(y){return y(h,p,g)}))}}forEach(o){for(var f=0;f<this.args.length;f++)o(this.args[f],"args["+f+"]",this)}map(o){for(var f=[],l=0;l<this.args.length;l++)f[l]=this._ifNode(o(this.args[l],"args["+l+"]",this));return new n(this.op,this.fn,f,this.implicit,this.isPercentage)}clone(){return new n(this.op,this.fn,this.args.slice(0),this.implicit,this.isPercentage)}isUnary(){return this.args.length===1}isBinary(){return this.args.length===2}_toString(o){var f=o&&o.parenthesis?o.parenthesis:"keep",l=o&&o.implicit?o.implicit:"hide",u=this.args,s=a(this,f,l,u,!1);if(u.length===1){var c=Xa(this,f),m=u[0].toString(o);s[0]&&(m="("+m+")");var v=/[a-zA-Z]+/.test(this.op);return c==="right"?this.op+(v?" ":"")+m:c==="left"?m+(v?" ":"")+this.op:m+this.op}else if(u.length===2){var h=u[0].toString(o),p=u[1].toString(o);return s[0]&&(h="("+h+")"),s[1]&&(p="("+p+")"),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?h+" "+p:h+" "+this.op+" "+p}else if(u.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var g=u.map(function(y,N){return y=y.toString(o),s[N]&&(y="("+y+")"),y});return this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?g.join(" "):g.join(" "+this.op+" ")}else return this.fn+"("+this.args.join(", ")+")"}toJSON(){return{mathjs:eo,op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}}static fromJSON(o){return new n(o.op,o.fn,o.args,o.implicit,o.isPercentage)}toHTML(o){var f=o&&o.parenthesis?o.parenthesis:"keep",l=o&&o.implicit?o.implicit:"hide",u=this.args,s=a(this,f,l,u,!1);if(u.length===1){var c=Xa(this,f),m=u[0].toHTML(o);return s[0]&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>'),c==="right"?'<span class="math-operator math-unary-operator math-lefthand-unary-operator">'+ut(this.op)+"</span>"+m:m+'<span class="math-operator math-unary-operator math-righthand-unary-operator">'+ut(this.op)+"</span>"}else if(u.length===2){var v=u[0].toHTML(o),h=u[1].toHTML(o);return s[0]&&(v='<span class="math-parenthesis math-round-parenthesis">(</span>'+v+'<span class="math-parenthesis math-round-parenthesis">)</span>'),s[1]&&(h='<span class="math-parenthesis math-round-parenthesis">(</span>'+h+'<span class="math-parenthesis math-round-parenthesis">)</span>'),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?v+'<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'+h:v+'<span class="math-operator math-binary-operator math-explicit-binary-operator">'+ut(this.op)+"</span>"+h}else{var p=u.map(function(g,y){return g=g.toHTML(o),s[y]&&(g='<span class="math-parenthesis math-round-parenthesis">(</span>'+g+'<span class="math-parenthesis math-round-parenthesis">)</span>'),g});return u.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")?this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?p.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'):p.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">'+ut(this.op)+"</span>"):'<span class="math-function">'+ut(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+p.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}}_toTex(o){var f=o&&o.parenthesis?o.parenthesis:"keep",l=o&&o.implicit?o.implicit:"hide",u=this.args,s=a(this,f,l,u,!0),c=sr[this.fn];if(c=typeof c>"u"?this.op:c,u.length===1){var m=Xa(this,f),v=u[0].toTex(o);return s[0]&&(v="\\left(".concat(v,"\\right)")),m==="right"?c+v:v+c}else if(u.length===2){var h=u[0],p=h.toTex(o);s[0]&&(p="\\left(".concat(p,"\\right)"));var g=u[1],y=g.toTex(o);s[1]&&(y="\\left(".concat(y,"\\right)"));var N;switch(f==="keep"?N=h.getIdentifier():N=h.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return c+"{"+p+"}{"+y+"}";case"OperatorNode:pow":switch(p="{"+p+"}",y="{"+y+"}",N){case"ConditionalNode":case"OperatorNode:divide":p="\\left(".concat(p,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&l==="hide")return p+"~"+y}return p+c+y}else if(u.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var d=u.map(function(w,x){return w=w.toTex(o),s[x]&&(w="\\left(".concat(w,"\\right)")),w});return this.getIdentifier()==="OperatorNode:multiply"&&this.implicit&&l==="hide"?d.join("~"):d.join(c)}else return"\\mathrm{"+this.fn+"}\\left("+u.map(function(w){return w.toTex(o)}).join(",")+"\\right)"}getIdentifier(){return this.type+":"+this.fn}}return zr(n,"name",eo),n},{isClass:!0,isNode:!0}),ro="ParenthesisNode",LE=["Node"],kE=q(ro,LE,r=>{var{Node:e}=r;class t extends e{constructor(n){if(super(),!fr(n))throw new TypeError('Node expected for parameter "content"');this.content=n}get type(){return ro}get isParenthesisNode(){return!0}_compile(n,i){return this.content._compile(n,i)}getContent(){return this.content.getContent()}forEach(n){n(this.content,"content",this)}map(n){var i=n(this.content,"content",this);return new t(i)}clone(){return new t(this.content)}_toString(n){return!n||n&&!n.parenthesis||n&&n.parenthesis==="keep"?"("+this.content.toString(n)+")":this.content.toString(n)}toJSON(){return{mathjs:ro,content:this.content}}static fromJSON(n){return new t(n.content)}toHTML(n){return!n||n&&!n.parenthesis||n&&n.parenthesis==="keep"?'<span class="math-parenthesis math-round-parenthesis">(</span>'+this.content.toHTML(n)+'<span class="math-parenthesis math-round-parenthesis">)</span>':this.content.toHTML(n)}_toTex(n){return!n||n&&!n.parenthesis||n&&n.parenthesis==="keep"?"\\left(".concat(this.content.toTex(n),"\\right)"):this.content.toTex(n)}}return zr(t,"name",ro),t},{isClass:!0,isNode:!0}),to="RangeNode",VE=["Node"],GE=q(to,VE,r=>{var{Node:e}=r;function t(n,i,o){var f=pr(n,i,o),l={},u=pr(n.start,i,o);if(l.start=u!==null&&u<=f||i==="all",n.step){var s=pr(n.step,i,o);l.step=s!==null&&s<=f||i==="all"}var c=pr(n.end,i,o);return l.end=c!==null&&c<=f||i==="all",l}class a extends e{constructor(i,o,f){if(super(),!fr(i))throw new TypeError("Node expected");if(!fr(o))throw new TypeError("Node expected");if(f&&!fr(f))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=i,this.end=o,this.step=f||null}get type(){return to}get isRangeNode(){return!0}needsEnd(){var i=this.filter(function(o){return qr(o)&&o.name==="end"});return i.length>0}_compile(i,o){var f=i.range,l=this.start._compile(i,o),u=this.end._compile(i,o);if(this.step){var s=this.step._compile(i,o);return function(m,v,h){return f(l(m,v,h),u(m,v,h),s(m,v,h))}}else return function(m,v,h){return f(l(m,v,h),u(m,v,h))}}forEach(i){i(this.start,"start",this),i(this.end,"end",this),this.step&&i(this.step,"step",this)}map(i){return new a(this._ifNode(i(this.start,"start",this)),this._ifNode(i(this.end,"end",this)),this.step&&this._ifNode(i(this.step,"step",this)))}clone(){return new a(this.start,this.end,this.step&&this.step)}_toString(i){var o=i&&i.parenthesis?i.parenthesis:"keep",f=t(this,o,i&&i.implicit),l,u=this.start.toString(i);if(f.start&&(u="("+u+")"),l=u,this.step){var s=this.step.toString(i);f.step&&(s="("+s+")"),l+=":"+s}var c=this.end.toString(i);return f.end&&(c="("+c+")"),l+=":"+c,l}toJSON(){return{mathjs:to,start:this.start,end:this.end,step:this.step}}static fromJSON(i){return new a(i.start,i.end,i.step)}toHTML(i){var o=i&&i.parenthesis?i.parenthesis:"keep",f=t(this,o,i&&i.implicit),l,u=this.start.toHTML(i);if(f.start&&(u='<span class="math-parenthesis math-round-parenthesis">(</span>'+u+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l=u,this.step){var s=this.step.toHTML(i);f.step&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+='<span class="math-operator math-range-operator">:</span>'+s}var c=this.end.toHTML(i);return f.end&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+='<span class="math-operator math-range-operator">:</span>'+c,l}_toTex(i){var o=i&&i.parenthesis?i.parenthesis:"keep",f=t(this,o,i&&i.implicit),l=this.start.toTex(i);if(f.start&&(l="\\left(".concat(l,"\\right)")),this.step){var u=this.step.toTex(i);f.step&&(u="\\left(".concat(u,"\\right)")),l+=":"+u}var s=this.end.toTex(i);return f.end&&(s="\\left(".concat(s,"\\right)")),l+=":"+s,l}}return zr(a,"name",to),a},{isClass:!0,isNode:!0}),no="RelationalNode",HE=["Node"],ZE=q(no,HE,r=>{var{Node:e}=r,t={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="};class a extends e{constructor(i,o){if(super(),!Array.isArray(i))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(o))throw new TypeError("Parameter params must be an array");if(i.length!==o.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=i,this.params=o}get type(){return no}get isRelationalNode(){return!0}_compile(i,o){var f=this,l=this.params.map(u=>u._compile(i,o));return function(s,c,m){for(var v,h=l[0](s,c,m),p=0;p<f.conditionals.length;p++){v=h,h=l[p+1](s,c,m);var g=lt(i,f.conditionals[p]);if(!g(v,h))return!1}return!0}}forEach(i){this.params.forEach((o,f)=>i(o,"params["+f+"]",this),this)}map(i){return new a(this.conditionals.slice(),this.params.map((o,f)=>this._ifNode(i(o,"params["+f+"]",this)),this))}clone(){return new a(this.conditionals,this.params)}_toString(i){for(var o=i&&i.parenthesis?i.parenthesis:"keep",f=pr(this,o,i&&i.implicit),l=this.params.map(function(c,m){var v=pr(c,o,i&&i.implicit);return o==="all"||v!==null&&v<=f?"("+c.toString(i)+")":c.toString(i)}),u=l[0],s=0;s<this.conditionals.length;s++)u+=" "+t[this.conditionals[s]],u+=" "+l[s+1];return u}toJSON(){return{mathjs:no,conditionals:this.conditionals,params:this.params}}static fromJSON(i){return new a(i.conditionals,i.params)}toHTML(i){for(var o=i&&i.parenthesis?i.parenthesis:"keep",f=pr(this,o,i&&i.implicit),l=this.params.map(function(c,m){var v=pr(c,o,i&&i.implicit);return o==="all"||v!==null&&v<=f?'<span class="math-parenthesis math-round-parenthesis">(</span>'+c.toHTML(i)+'<span class="math-parenthesis math-round-parenthesis">)</span>':c.toHTML(i)}),u=l[0],s=0;s<this.conditionals.length;s++)u+='<span class="math-operator math-binary-operator math-explicit-binary-operator">'+ut(t[this.conditionals[s]])+"</span>"+l[s+1];return u}_toTex(i){for(var o=i&&i.parenthesis?i.parenthesis:"keep",f=pr(this,o,i&&i.implicit),l=this.params.map(function(c,m){var v=pr(c,o,i&&i.implicit);return o==="all"||v!==null&&v<=f?"\\left("+c.toTex(i)+"\right)":c.toTex(i)}),u=l[0],s=0;s<this.conditionals.length;s++)u+=sr[this.conditionals[s]]+l[s+1];return u}}return zr(a,"name",no),a},{isClass:!0,isNode:!0}),JE="SymbolNode",XE=["math","?Unit","Node"],WE=q(JE,XE,r=>{var{math:e,Unit:t,Node:a}=r;function n(o){return t?t.isValuelessUnit(o):!1}class i extends a{constructor(f){if(super(),typeof f!="string")throw new TypeError('String expected for parameter "name"');this.name=f}get type(){return"SymbolNode"}get isSymbolNode(){return!0}_compile(f,l){var u=this.name;if(l[u]===!0)return function(c,m,v){return m[u]};if(u in f)return function(c,m,v){return c.has(u)?c.get(u):lt(f,u)};var s=n(u);return function(c,m,v){return c.has(u)?c.get(u):s?new t(null,u):i.onUndefinedSymbol(u)}}forEach(f){}map(f){return this.clone()}static onUndefinedSymbol(f){throw new Error("Undefined symbol "+f)}clone(){return new i(this.name)}_toString(f){return this.name}toHTML(f){var l=ut(this.name);return l==="true"||l==="false"?'<span class="math-symbol math-boolean">'+l+"</span>":l==="i"?'<span class="math-symbol math-imaginary-symbol">'+l+"</span>":l==="Infinity"?'<span class="math-symbol math-infinity-symbol">'+l+"</span>":l==="NaN"?'<span class="math-symbol math-nan-symbol">'+l+"</span>":l==="null"?'<span class="math-symbol math-null-symbol">'+l+"</span>":l==="undefined"?'<span class="math-symbol math-undefined-symbol">'+l+"</span>":'<span class="math-symbol">'+l+"</span>"}toJSON(){return{mathjs:"SymbolNode",name:this.name}}static fromJSON(f){return new i(f.name)}_toTex(f){var l=!1;typeof e[this.name]>"u"&&n(this.name)&&(l=!0);var u=np(this.name,l);return u[0]==="\\"?u:" "+u}}return i},{isClass:!0,isNode:!0});function Wa(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),a=1;a<e;a++)t[a-1]=arguments[a];return typeof r.createSubScope=="function"?Fl(r.createSubScope(),...t):Fl(ea(),r,...t)}var ao="FunctionNode",YE=["math","Node","SymbolNode"],QE=q(ao,YE,r=>{var{math:e,Node:t,SymbolNode:a}=r,n=f=>Ye(f,{truncate:78});function i(f,l,u){for(var s="",c=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,m=0,v;(v=c.exec(f))!==null;)if(s+=f.substring(m,v.index),m=v.index,v[0]==="$$")s+="$",m++;else{m+=v[0].length;var h=l[v[1]];if(!h)throw new ReferenceError("Template: Property "+v[1]+" does not exist.");if(v[2]===void 0)switch(typeof h){case"string":s+=h;break;case"object":if(fr(h))s+=h.toTex(u);else if(Array.isArray(h))s+=h.map(function(p,g){if(fr(p))return p.toTex(u);throw new TypeError("Template: "+v[1]+"["+g+"] is not a Node.")}).join(",");else throw new TypeError("Template: "+v[1]+" has to be a Node, String or array of Nodes");break;default:throw new TypeError("Template: "+v[1]+" has to be a Node, String or array of Nodes")}else if(fr(h[v[2]]&&h[v[2]]))s+=h[v[2]].toTex(u);else throw new TypeError("Template: "+v[1]+"["+v[2]+"] is not a Node.")}return s+=f.slice(m),s}class o extends t{constructor(l,u){if(super(),typeof l=="string"&&(l=new a(l)),!fr(l))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(u)||!u.every(fr))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=l,this.args=u||[]}get name(){return this.fn.name||""}get type(){return ao}get isFunctionNode(){return!0}_compile(l,u){var s=this.args.map(E=>E._compile(l,u));if(qr(this.fn)){var c=this.fn.name;if(u[c]){var g=this.args;return function(A,S,D){var T=S[c];if(typeof T!="function")throw new TypeError("Argument '".concat(c,"' was not a function; received: ").concat(n(T)));if(T.rawArgs)return T(g,l,Wa(A,S),A);var B=s.map(I=>I(A,S,D));return T.apply(T,B)}}else{var m=c in l?lt(l,c):void 0,v=typeof m=="function"&&m.rawArgs===!0,h=E=>{var A;if(E.has(c))A=E.get(c);else if(c in l)A=lt(l,c);else return o.onUndefinedFunction(c);if(typeof A=="function")return A;throw new TypeError("'".concat(c,`' is not a function; its value is:
|
|
33
|
+
`).concat(n(A)))};if(v){var p=this.args;return function(A,S,D){var T=h(A);return T(p,l,Wa(A,S),A)}}else switch(s.length){case 0:return function(A,S,D){var T=h(A);return T()};case 1:return function(A,S,D){var T=h(A),B=s[0];return T(B(A,S,D))};case 2:return function(A,S,D){var T=h(A),B=s[0],I=s[1];return T(B(A,S,D),I(A,S,D))};default:return function(A,S,D){var T=h(A),B=s.map(I=>I(A,S,D));return T(...B)}}}}else if(Sn(this.fn)&&Jn(this.fn.index)&&this.fn.index.isObjectProperty()){var y=this.fn.object._compile(l,u),N=this.fn.index.getObjectProperty(),d=this.args;return function(A,S,D){var T=y(A,S,D);Sg(T,N);var B=T[N]&&T[N].rawArgs;if(B)return T[N](d,l,Wa(A,S),A);var I=s.map(P=>P(A,S,D));return T[N].apply(T,I)}}else{var w=this.fn.toString(),x=this.fn._compile(l,u),b=this.args;return function(A,S,D){var T=x(A,S,D);if(typeof T!="function")throw new TypeError("Expression '".concat(w,"' did not evaluate to a function; value is:")+`
|
|
34
|
+
`.concat(n(T)));if(T.rawArgs)return T(b,l,Wa(A,S),A);var B=s.map(I=>I(A,S,D));return T.apply(T,B)}}}forEach(l){l(this.fn,"fn",this);for(var u=0;u<this.args.length;u++)l(this.args[u],"args["+u+"]",this)}map(l){for(var u=this._ifNode(l(this.fn,"fn",this)),s=[],c=0;c<this.args.length;c++)s[c]=this._ifNode(l(this.args[c],"args["+c+"]",this));return new o(u,s)}clone(){return new o(this.fn,this.args.slice(0))}toString(l){var u,s=this.fn.toString(l);return l&&typeof l.handler=="object"&&Re(l.handler,s)&&(u=l.handler[s](this,l)),typeof u<"u"?u:super.toString(l)}_toString(l){var u=this.args.map(function(c){return c.toString(l)}),s=Pa(this.fn)?"("+this.fn.toString(l)+")":this.fn.toString(l);return s+"("+u.join(", ")+")"}toJSON(){return{mathjs:ao,fn:this.fn,args:this.args}}toHTML(l){var u=this.args.map(function(s){return s.toHTML(l)});return'<span class="math-function">'+ut(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+u.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}toTex(l){var u;return l&&typeof l.handler=="object"&&Re(l.handler,this.name)&&(u=l.handler[this.name](this,l)),typeof u<"u"?u:super.toTex(l)}_toTex(l){var u=this.args.map(function(m){return m.toTex(l)}),s;rp[this.name]&&(s=rp[this.name]),e[this.name]&&(typeof e[this.name].toTex=="function"||typeof e[this.name].toTex=="object"||typeof e[this.name].toTex=="string")&&(s=e[this.name].toTex);var c;switch(typeof s){case"function":c=s(this,l);break;case"string":c=i(s,this,l);break;case"object":switch(typeof s[u.length]){case"function":c=s[u.length](this,l);break;case"string":c=i(s[u.length],this,l);break}}return typeof c<"u"?c:i(TE,this,l)}getIdentifier(){return this.type+":"+this.name}}return zr(o,"name",ao),zr(o,"onUndefinedFunction",function(f){throw new Error("Undefined function "+f)}),zr(o,"fromJSON",function(f){return new o(f.fn,f.args)}),o},{isClass:!0,isNode:!0}),ap="parse",KE=["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],jE=q(ap,KE,r=>{var{typed:e,numeric:t,config:a,AccessorNode:n,ArrayNode:i,AssignmentNode:o,BlockNode:f,ConditionalNode:l,ConstantNode:u,FunctionAssignmentNode:s,FunctionNode:c,IndexNode:m,ObjectNode:v,OperatorNode:h,ParenthesisNode:p,RangeNode:g,RelationalNode:y,SymbolNode:N}=r,d=e(ap,{string:function(Z){return k(Z,{})},"Array | Matrix":function(Z){return w(Z,{})},"string, Object":function(Z,se){var Ee=se.nodes!==void 0?se.nodes:{};return k(Z,Ee)},"Array | Matrix, Object":w});function w(C){var Z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},se=Z.nodes!==void 0?Z.nodes:{};return je(C,function(Ee){if(typeof Ee!="string")throw new TypeError("String expected");return k(Ee,se)})}var x={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},b={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},E={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},A={true:!0,false:!1,null:null,undefined:void 0},S=["NaN","Infinity"];function D(){return{extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:x.NULL,nestingLevel:0,conditionalLevel:null}}function T(C,Z){return C.expression.substr(C.index,Z)}function B(C){return T(C,1)}function I(C){C.index++}function P(C){return C.expression.charAt(C.index-1)}function R(C){return C.expression.charAt(C.index+1)}function M(C){for(C.tokenType=x.NULL,C.token="",C.comment="";;){if(B(C)==="#")for(;B(C)!==`
|
|
35
35
|
`&&B(C)!=="";)C.comment+=B(C),I(C);if(d.isWhitespace(B(C),C.nestingLevel))I(C);else break}if(B(C)===""){C.tokenType=x.DELIMITER;return}if(B(C)===`
|
|
36
36
|
`&&!C.nestingLevel){C.tokenType=x.DELIMITER,C.token=B(C),I(C);return}var Z=B(C),se=T(C,2),Ee=T(C,3);if(Ee.length===3&&b[Ee]){C.tokenType=x.DELIMITER,C.token=Ee,I(C),I(C),I(C);return}if(se.length===2&&b[se]){C.tokenType=x.DELIMITER,C.token=se,I(C),I(C);return}if(b[Z]){C.tokenType=x.DELIMITER,C.token=Z,I(C);return}if(d.isDigitDot(Z)){C.tokenType=x.NUMBER;var ze=T(C,2);if(ze==="0b"||ze==="0o"||ze==="0x"){for(C.token+=B(C),I(C),C.token+=B(C),I(C);d.isHexDigit(B(C));)C.token+=B(C),I(C);if(B(C)===".")for(C.token+=".",I(C);d.isHexDigit(B(C));)C.token+=B(C),I(C);else if(B(C)==="i")for(C.token+="i",I(C);d.isDigit(B(C));)C.token+=B(C),I(C);return}if(B(C)==="."){if(C.token+=B(C),I(C),!d.isDigit(B(C))){C.tokenType=x.DELIMITER;return}}else{for(;d.isDigit(B(C));)C.token+=B(C),I(C);d.isDecimalMark(B(C),R(C))&&(C.token+=B(C),I(C))}for(;d.isDigit(B(C));)C.token+=B(C),I(C);if(B(C)==="E"||B(C)==="e"){if(d.isDigit(R(C))||R(C)==="-"||R(C)==="+"){if(C.token+=B(C),I(C),(B(C)==="+"||B(C)==="-")&&(C.token+=B(C),I(C)),!d.isDigit(B(C)))throw Je(C,'Digit expected, got "'+B(C)+'"');for(;d.isDigit(B(C));)C.token+=B(C),I(C);if(d.isDecimalMark(B(C),R(C)))throw Je(C,'Digit expected, got "'+B(C)+'"')}else if(R(C)===".")throw I(C),Je(C,'Digit expected, got "'+B(C)+'"')}return}if(d.isAlpha(B(C),P(C),R(C))){for(;d.isAlpha(B(C),P(C),R(C))||d.isDigit(B(C));)C.token+=B(C),I(C);Re(E,C.token)?C.tokenType=x.DELIMITER:C.tokenType=x.SYMBOL;return}for(C.tokenType=x.UNKNOWN;B(C)!=="";)C.token+=B(C),I(C);throw Je(C,'Syntax error in part "'+C.token+'"')}function F(C){do M(C);while(C.token===`
|
|
37
37
|
`)}function H(C){C.nestingLevel++}function $(C){C.nestingLevel--}d.isAlpha=function(Z,se,Ee){return d.isValidLatinOrGreek(Z)||d.isValidMathSymbol(Z,Ee)||d.isValidMathSymbol(se,Z)},d.isValidLatinOrGreek=function(Z){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(Z)},d.isValidMathSymbol=function(Z,se){return/^[\uD835]$/.test(Z)&&/^[\uDC00-\uDFFF]$/.test(se)&&/^[^\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDFCC\uDFCD]$/.test(se)},d.isWhitespace=function(Z,se){return Z===" "||Z===" "||Z===`
|
|
38
38
|
`&&se>0},d.isDecimalMark=function(Z,se){return Z==="."&&se!=="/"&&se!=="*"&&se!=="^"},d.isDigitDot=function(Z){return Z>="0"&&Z<="9"||Z==="."},d.isDigit=function(Z){return Z>="0"&&Z<="9"},d.isHexDigit=function(Z){return Z>="0"&&Z<="9"||Z>="a"&&Z<="f"||Z>="A"&&Z<="F"};function k(C,Z){var se=D();Sr(se,{expression:C,extraNodes:Z}),M(se);var Ee=Q(se);if(se.token!=="")throw se.tokenType===x.DELIMITER?mr(se,"Unexpected operator "+se.token):Je(se,'Unexpected part "'+se.token+'"');return Ee}function Q(C){var Z,se=[],Ee;for(C.token!==""&&C.token!==`
|
|
39
39
|
`&&C.token!==";"&&(Z=K(C),C.comment&&(Z.comment=C.comment));C.token===`
|
|
40
40
|
`||C.token===";";)se.length===0&&Z&&(Ee=C.token!==";",se.push({node:Z,visible:Ee})),M(C),C.token!==`
|
|
41
|
-
`&&C.token!==";"&&C.token!==""&&(Z=K(C),C.comment&&(Z.comment=C.comment),Ee=C.token!==";",se.push({node:Z,visible:Ee}));return se.length>0?new f(se):(Z||(Z=new u(void 0),C.comment&&(Z.comment=C.comment)),Z)}function K(C){var Z,se,Ee,ze,ke=L(C);if(C.token==="="){if(qr(ke))return Z=ke.name,F(C),Ee=K(C),new o(new N(Z),Ee);if(En(ke))return F(C),Ee=K(C),new o(ke.object,ke.index,Ee);if(rn(ke)&&qr(ke.fn)&&(ze=!0,se=[],Z=ke.name,ke.args.forEach(function(Fr,_r){qr(Fr)?se[_r]=Fr.name:ze=!1}),ze))return F(C),Ee=K(C),new s(Z,se,Ee);throw Je(C,"Invalid left hand side of assignment operator =")}return ke}function L(C){for(var Z=j(C);C.token==="?";){var se=C.conditionalLevel;C.conditionalLevel=C.nestingLevel,F(C);var Ee=Z,ze=K(C);if(C.token!==":")throw Je(C,"False part of conditional expression expected");C.conditionalLevel=null,F(C);var ke=K(C);Z=new l(Ee,ze,ke),C.conditionalLevel=se}return Z}function j(C){for(var Z=ae(C);C.token==="or";)F(C),Z=new h("or","or",[Z,ae(C)]);return Z}function ae(C){for(var Z=re(C);C.token==="xor";)F(C),Z=new h("xor","xor",[Z,re(C)]);return Z}function re(C){for(var Z=fe(C);C.token==="and";)F(C),Z=new h("and","and",[Z,fe(C)]);return Z}function fe(C){for(var Z=he(C);C.token==="|";)F(C),Z=new h("|","bitOr",[Z,he(C)]);return Z}function he(C){for(var Z=ce(C);C.token==="^|";)F(C),Z=new h("^|","bitXor",[Z,ce(C)]);return Z}function ce(C){for(var Z=ie(C);C.token==="&";)F(C),Z=new h("&","bitAnd",[Z,ie(C)]);return Z}function ie(C){for(var Z=[Ae(C)],se=[],Ee={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};Re(Ee,C.token);){var ze={name:C.token,fn:Ee[C.token]};se.push(ze),F(C),Z.push(Ae(C))}return Z.length===1?Z[0]:Z.length===2?new h(se[0].name,se[0].fn,Z):new y(se.map(ke=>ke.fn),Z)}function Ae(C){var Z,se,Ee,ze;Z=Oe(C);for(var ke={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Re(ke,C.token);)se=C.token,Ee=ke[se],F(C),ze=[Z,Oe(C)],Z=new h(se,Ee,ze);return Z}function Oe(C){var Z,se,Ee,ze;Z=Ce(C);for(var ke={to:"to",in:"to"};Re(ke,C.token);)se=C.token,Ee=ke[se],F(C),se==="in"&&C.token===""?Z=new h("*","multiply",[Z,new N("in")],!0):(ze=[Z,Ce(C)],Z=new h(se,Ee,ze));return Z}function Ce(C){var Z,se=[];if(C.token===":"?Z=new u(1):Z=$e(C),C.token===":"&&C.conditionalLevel!==C.nestingLevel){for(se.push(Z);C.token===":"&&se.length<3;)F(C),C.token===")"||C.token==="]"||C.token===","||C.token===""?se.push(new N("end")):se.push($e(C));se.length===3?Z=new g(se[0],se[2],se[1]):Z=new g(se[0],se[1])}return Z}function $e(C){var Z,se,Ee,ze;Z=V(C);for(var ke={"+":"add","-":"subtract"};Re(ke,C.token);){se=C.token,Ee=ke[se],F(C);var Fr=V(C);Fr.isPercentage?ze=[Z,new h("*","multiply",[Z,Fr])]:ze=[Z,Fr],Z=new h(se,Ee,ze)}return Z}function V(C){var Z,se,Ee,ze;Z=X(C),se=Z;for(var ke={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};Re(ke,C.token);)Ee=C.token,ze=ke[Ee],F(C),se=X(C),Z=new h(Ee,ze,[Z,se]);return Z}function X(C){var Z,se;for(Z=oe(C),se=Z;C.tokenType===x.SYMBOL||C.token==="in"&&ir(Z)||C.tokenType===x.NUMBER&&!ir(se)&&(!Br(se)||se.op==="!")||C.token==="(";)se=oe(C),Z=new h("*","multiply",[Z,se],!0);return Z}function oe(C){for(var Z=G(C),se=Z,Ee=[];C.token==="/"&&ko(se);)if(Ee.push(Sr({},C)),F(C),C.tokenType===x.NUMBER)if(Ee.push(Sr({},C)),F(C),C.tokenType===x.SYMBOL||C.token==="(")Sr(C,Ee.pop()),Ee.pop(),se=G(C),Z=new h("/","divide",[Z,se]);else{Ee.pop(),Sr(C,Ee.pop());break}else{Sr(C,Ee.pop());break}return Z}function G(C){var Z,se,Ee,ze;Z=Y(C);for(var ke={"%":"mod",mod:"mod"};Re(ke,C.token);)se=C.token,Ee=ke[se],F(C),se==="%"&&C.tokenType===x.DELIMITER&&C.token!=="("?Z=new h("/","divide",[Z,new u(100)],!1,!0):(ze=[Z,Y(C)],Z=new h(se,Ee,ze));return Z}function Y(C){var Z,se,Ee,ze={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Re(ze,C.token)?(Ee=ze[C.token],Z=C.token,F(C),se=[Y(C)],new h(Z,Ee,se)):te(C)}function te(C){var Z,se,Ee,ze;return Z=ye(C),(C.token==="^"||C.token===".^")&&(se=C.token,Ee=se==="^"?"pow":"dotPow",F(C),ze=[Z,Y(C)],Z=new h(se,Ee,ze)),Z}function ye(C){var Z,se,Ee,ze;Z=me(C);for(var ke={"!":"factorial","'":"ctranspose"};Re(ke,C.token);)se=C.token,Ee=ke[se],M(C),ze=[Z],Z=new h(se,Ee,ze),Z=U(C,Z);return Z}function me(C){var Z=[];if(C.tokenType===x.SYMBOL&&Re(C.extraNodes,C.token)){var se=C.extraNodes[C.token];if(M(C),C.token==="("){if(Z=[],H(C),M(C),C.token!==")")for(Z.push(K(C));C.token===",";)M(C),Z.push(K(C));if(C.token!==")")throw Je(C,"Parenthesis ) expected");$(C),M(C)}return new se(Z)}return z(C)}function z(C){var Z,se;return C.tokenType===x.SYMBOL||C.tokenType===x.DELIMITER&&C.token in E?(se=C.token,M(C),Re(A,se)?Z=new u(A[se]):S.indexOf(se)!==-1?Z=new u(t(se,"number")):Z=new N(se),Z=U(C,Z),Z):ee(C)}function U(C,Z,se){for(var Ee;(C.token==="("||C.token==="["||C.token===".")&&(!se||se.indexOf(C.token)!==-1);)if(Ee=[],C.token==="(")if(qr(Z)||En(Z)){if(H(C),M(C),C.token!==")")for(Ee.push(K(C));C.token===",";)M(C),Ee.push(K(C));if(C.token!==")")throw Je(C,"Parenthesis ) expected");$(C),M(C),Z=new c(Z,Ee)}else return Z;else if(C.token==="["){if(H(C),M(C),C.token!=="]")for(Ee.push(K(C));C.token===",";)M(C),Ee.push(K(C));if(C.token!=="]")throw Je(C,"Parenthesis ] expected");$(C),M(C),Z=new n(Z,new m(Ee))}else{if(M(C),C.tokenType!==x.SYMBOL)throw Je(C,"Property name expected after dot");Ee.push(new u(C.token)),M(C);var ze=!0;Z=new n(Z,new m(Ee,ze))}return Z}function ee(C){var Z,se;return C.token==='"'?(se=ue(C),Z=new u(se),Z=U(C,Z),Z):ve(C)}function ue(C){for(var Z="";B(C)!==""&&B(C)!=='"';)B(C)==="\\"&&(Z+=B(C),I(C)),Z+=B(C),I(C);if(M(C),C.token!=='"')throw Je(C,'End of string " expected');return M(C),JSON.parse('"'+Z+'"')}function ve(C){var Z,se;return C.token==="'"?(se=de(C),Z=new u(se),Z=U(C,Z),Z):be(C)}function de(C){for(var Z="";B(C)!==""&&B(C)!=="'";)B(C)==="\\"&&(Z+=B(C),I(C)),Z+=B(C),I(C);if(M(C),C.token!=="'")throw Je(C,"End of string ' expected");return M(C),JSON.parse('"'+Z+'"')}function be(C){var Z,se,Ee,ze;if(C.token==="["){if(H(C),M(C),C.token!=="]"){var ke=pe(C);if(C.token===";"){for(Ee=1,se=[ke];C.token===";";)M(C),se[Ee]=pe(C),Ee++;if(C.token!=="]")throw Je(C,"End of matrix ] expected");$(C),M(C),ze=se[0].items.length;for(var Fr=1;Fr<Ee;Fr++)if(se[Fr].items.length!==ze)throw mr(C,"Column dimensions mismatch ("+se[Fr].items.length+" !== "+ze+")");Z=new i(se)}else{if(C.token!=="]")throw Je(C,"End of matrix ] expected");$(C),M(C),Z=ke}}else $(C),M(C),Z=new i([]);return U(C,Z)}return we(C)}function pe(C){for(var Z=[K(C)],se=1;C.token===",";)M(C),Z[se]=K(C),se++;return new i(Z)}function we(C){if(C.token==="{"){H(C);var Z,se={};do if(M(C),C.token!=="}"){if(C.token==='"')Z=ue(C);else if(C.token==="'")Z=de(C);else if(C.tokenType===x.SYMBOL||C.tokenType===x.DELIMITER&&C.token in E)Z=C.token,M(C);else throw Je(C,"Symbol or string expected as object key");if(C.token!==":")throw Je(C,"Colon : expected after object key");M(C),se[Z]=K(C)}while(C.token===",");if(C.token!=="}")throw Je(C,"Comma , or bracket } expected after object value");$(C),M(C);var Ee=new v(se);return Ee=U(C,Ee),Ee}return _e(C)}function _e(C){var Z;return C.tokenType===x.NUMBER?(Z=C.token,M(C),new u(t(Z,a.number))):Le(C)}function Le(C){var Z;if(C.token==="("){if(H(C),M(C),Z=K(C),C.token!==")")throw Je(C,"Parenthesis ) expected");return $(C),M(C),Z=new p(Z),Z=U(C,Z),Z}return Be(C)}function Be(C){throw C.token===""?Je(C,"Unexpected end of expression"):Je(C,"Value expected")}function ar(C){return C.index-C.token.length+1}function Je(C,Z){var se=ar(C),Ee=new SyntaxError(Z+" (char "+se+")");return Ee.char=se,Ee}function mr(C,Z){var se=ar(C),Ee=new SyntaxError(Z+" (char "+se+")");return Ee.char=se,Ee}return e.addConversion({from:"string",to:"Node",convert:d}),d}),np="compile",ZE=["typed","parse"],JE=q(np,ZE,r=>{var{typed:e,parse:t}=r;return e(np,{string:function(n){return t(n).compile()},"Array | Matrix":function(n){return je(n,function(i){return t(i).compile()})}})}),ap="evaluate",XE=["typed","parse"],WE=q(ap,XE,r=>{var{typed:e,parse:t}=r;return e(ap,{string:function(n){var i=jn();return t(n).compile().evaluate(i)},"string, Map | Object":function(n,i){return t(n).compile().evaluate(i)},"Array | Matrix":function(n){var i=jn();return je(n,function(o){return t(o).compile().evaluate(i)})},"Array | Matrix, Map | Object":function(n,i){return je(n,function(o){return t(o).compile().evaluate(i)})}})}),YE="Parser",QE=["evaluate"],KE=q(YE,QE,r=>{var{evaluate:e}=r;function t(){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:jn(),writable:!1})}return t.prototype.type="Parser",t.prototype.isParser=!0,t.prototype.evaluate=function(a){return e(a,this.scope)},t.prototype.get=function(a){if(this.scope.has(a))return this.scope.get(a)},t.prototype.getAll=function(){return wg(this.scope)},t.prototype.getAllAsMap=function(){return this.scope},t.prototype.set=function(a,n){return this.scope.set(a,n),n},t.prototype.remove=function(a){this.scope.delete(a)},t.prototype.clear=function(){this.scope.clear()},t},{isClass:!0}),ip="parser",jE=["typed","Parser"],eS=q(ip,jE,r=>{var{typed:e,Parser:t}=r;return e(ip,{"":function(){return new t}})}),op="lup",rS=["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],tS=q(op,rS,r=>{var{typed:e,matrix:t,abs:a,addScalar:n,divideScalar:i,multiplyScalar:o,subtract:f,larger:l,equalScalar:u,unaryMinus:s,DenseMatrix:c,SparseMatrix:m,Spa:v}=r;return e(op,{DenseMatrix:function(y){return h(y)},SparseMatrix:function(y){return p(y)},Array:function(y){var N=t(y),d=h(N);return{L:d.L.valueOf(),U:d.U.valueOf(),p:d.p}}});function h(g){var y=g._size[0],N=g._size[1],d=Math.min(y,N),w=Ge(g._data),x=[],b=[y,d],E=[],A=[d,N],S,D,T,B=[];for(S=0;S<y;S++)B[S]=S;for(D=0;D<N;D++){if(D>0)for(S=0;S<y;S++){var I=Math.min(S,D),P=0;for(T=0;T<I;T++)P=n(P,o(w[S][T],w[T][D]));w[S][D]=f(w[S][D],P)}var R=D,M=0,F=0;for(S=D;S<y;S++){var H=w[S][D],$=a(H);l($,M)&&(R=S,M=$,F=H)}if(D!==R&&(B[D]=[B[R],B[R]=B[D]][0],c._swapRows(D,R,w)),D<y)for(S=D+1;S<y;S++){var k=w[S][D];u(k,0)||(w[S][D]=i(w[S][D],F))}}for(D=0;D<N;D++)for(S=0;S<y;S++){if(D===0&&(S<N&&(E[S]=[]),x[S]=[]),S<D){S<N&&(E[S][D]=w[S][D]),D<y&&(x[S][D]=0);continue}if(S===D){S<N&&(E[S][D]=w[S][D]),D<y&&(x[S][D]=1);continue}S<N&&(E[S][D]=0),D<y&&(x[S][D]=w[S][D])}var Q=new c({data:x,size:b}),K=new c({data:E,size:A}),L=[];for(S=0,d=B.length;S<d;S++)L[B[S]]=S;return{L:Q,U:K,p:L,toString:function(){return"L: "+this.L.toString()+`
|
|
41
|
+
`&&C.token!==";"&&C.token!==""&&(Z=K(C),C.comment&&(Z.comment=C.comment),Ee=C.token!==";",se.push({node:Z,visible:Ee}));return se.length>0?new f(se):(Z||(Z=new u(void 0),C.comment&&(Z.comment=C.comment)),Z)}function K(C){var Z,se,Ee,ze,ke=L(C);if(C.token==="="){if(qr(ke))return Z=ke.name,F(C),Ee=K(C),new o(new N(Z),Ee);if(Sn(ke))return F(C),Ee=K(C),new o(ke.object,ke.index,Ee);if(nn(ke)&&qr(ke.fn)&&(ze=!0,se=[],Z=ke.name,ke.args.forEach(function(Fr,_r){qr(Fr)?se[_r]=Fr.name:ze=!1}),ze))return F(C),Ee=K(C),new s(Z,se,Ee);throw Je(C,"Invalid left hand side of assignment operator =")}return ke}function L(C){for(var Z=j(C);C.token==="?";){var se=C.conditionalLevel;C.conditionalLevel=C.nestingLevel,F(C);var Ee=Z,ze=K(C);if(C.token!==":")throw Je(C,"False part of conditional expression expected");C.conditionalLevel=null,F(C);var ke=K(C);Z=new l(Ee,ze,ke),C.conditionalLevel=se}return Z}function j(C){for(var Z=ae(C);C.token==="or";)F(C),Z=new h("or","or",[Z,ae(C)]);return Z}function ae(C){for(var Z=re(C);C.token==="xor";)F(C),Z=new h("xor","xor",[Z,re(C)]);return Z}function re(C){for(var Z=fe(C);C.token==="and";)F(C),Z=new h("and","and",[Z,fe(C)]);return Z}function fe(C){for(var Z=he(C);C.token==="|";)F(C),Z=new h("|","bitOr",[Z,he(C)]);return Z}function he(C){for(var Z=ce(C);C.token==="^|";)F(C),Z=new h("^|","bitXor",[Z,ce(C)]);return Z}function ce(C){for(var Z=ie(C);C.token==="&";)F(C),Z=new h("&","bitAnd",[Z,ie(C)]);return Z}function ie(C){for(var Z=[Ae(C)],se=[],Ee={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};Re(Ee,C.token);){var ze={name:C.token,fn:Ee[C.token]};se.push(ze),F(C),Z.push(Ae(C))}return Z.length===1?Z[0]:Z.length===2?new h(se[0].name,se[0].fn,Z):new y(se.map(ke=>ke.fn),Z)}function Ae(C){var Z,se,Ee,ze;Z=Oe(C);for(var ke={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Re(ke,C.token);)se=C.token,Ee=ke[se],F(C),ze=[Z,Oe(C)],Z=new h(se,Ee,ze);return Z}function Oe(C){var Z,se,Ee,ze;Z=Ce(C);for(var ke={to:"to",in:"to"};Re(ke,C.token);)se=C.token,Ee=ke[se],F(C),se==="in"&&C.token===""?Z=new h("*","multiply",[Z,new N("in")],!0):(ze=[Z,Ce(C)],Z=new h(se,Ee,ze));return Z}function Ce(C){var Z,se=[];if(C.token===":"?Z=new u(1):Z=$e(C),C.token===":"&&C.conditionalLevel!==C.nestingLevel){for(se.push(Z);C.token===":"&&se.length<3;)F(C),C.token===")"||C.token==="]"||C.token===","||C.token===""?se.push(new N("end")):se.push($e(C));se.length===3?Z=new g(se[0],se[2],se[1]):Z=new g(se[0],se[1])}return Z}function $e(C){var Z,se,Ee,ze;Z=V(C);for(var ke={"+":"add","-":"subtract"};Re(ke,C.token);){se=C.token,Ee=ke[se],F(C);var Fr=V(C);Fr.isPercentage?ze=[Z,new h("*","multiply",[Z,Fr])]:ze=[Z,Fr],Z=new h(se,Ee,ze)}return Z}function V(C){var Z,se,Ee,ze;Z=X(C),se=Z;for(var ke={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};Re(ke,C.token);)Ee=C.token,ze=ke[Ee],F(C),se=X(C),Z=new h(Ee,ze,[Z,se]);return Z}function X(C){var Z,se;for(Z=oe(C),se=Z;C.tokenType===x.SYMBOL||C.token==="in"&&ir(Z)||C.tokenType===x.NUMBER&&!ir(se)&&(!Br(se)||se.op==="!")||C.token==="(";)se=oe(C),Z=new h("*","multiply",[Z,se],!0);return Z}function oe(C){for(var Z=G(C),se=Z,Ee=[];C.token==="/"&&ko(se);)if(Ee.push(Sr({},C)),F(C),C.tokenType===x.NUMBER)if(Ee.push(Sr({},C)),F(C),C.tokenType===x.SYMBOL||C.token==="(")Sr(C,Ee.pop()),Ee.pop(),se=G(C),Z=new h("/","divide",[Z,se]);else{Ee.pop(),Sr(C,Ee.pop());break}else{Sr(C,Ee.pop());break}return Z}function G(C){var Z,se,Ee,ze;Z=Y(C);for(var ke={"%":"mod",mod:"mod"};Re(ke,C.token);)se=C.token,Ee=ke[se],F(C),se==="%"&&C.tokenType===x.DELIMITER&&C.token!=="("?Z=new h("/","divide",[Z,new u(100)],!1,!0):(ze=[Z,Y(C)],Z=new h(se,Ee,ze));return Z}function Y(C){var Z,se,Ee,ze={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Re(ze,C.token)?(Ee=ze[C.token],Z=C.token,F(C),se=[Y(C)],new h(Z,Ee,se)):te(C)}function te(C){var Z,se,Ee,ze;return Z=ye(C),(C.token==="^"||C.token===".^")&&(se=C.token,Ee=se==="^"?"pow":"dotPow",F(C),ze=[Z,Y(C)],Z=new h(se,Ee,ze)),Z}function ye(C){var Z,se,Ee,ze;Z=me(C);for(var ke={"!":"factorial","'":"ctranspose"};Re(ke,C.token);)se=C.token,Ee=ke[se],M(C),ze=[Z],Z=new h(se,Ee,ze),Z=U(C,Z);return Z}function me(C){var Z=[];if(C.tokenType===x.SYMBOL&&Re(C.extraNodes,C.token)){var se=C.extraNodes[C.token];if(M(C),C.token==="("){if(Z=[],H(C),M(C),C.token!==")")for(Z.push(K(C));C.token===",";)M(C),Z.push(K(C));if(C.token!==")")throw Je(C,"Parenthesis ) expected");$(C),M(C)}return new se(Z)}return z(C)}function z(C){var Z,se;return C.tokenType===x.SYMBOL||C.tokenType===x.DELIMITER&&C.token in E?(se=C.token,M(C),Re(A,se)?Z=new u(A[se]):S.indexOf(se)!==-1?Z=new u(t(se,"number")):Z=new N(se),Z=U(C,Z),Z):ee(C)}function U(C,Z,se){for(var Ee;(C.token==="("||C.token==="["||C.token===".")&&(!se||se.indexOf(C.token)!==-1);)if(Ee=[],C.token==="(")if(qr(Z)||Sn(Z)){if(H(C),M(C),C.token!==")")for(Ee.push(K(C));C.token===",";)M(C),Ee.push(K(C));if(C.token!==")")throw Je(C,"Parenthesis ) expected");$(C),M(C),Z=new c(Z,Ee)}else return Z;else if(C.token==="["){if(H(C),M(C),C.token!=="]")for(Ee.push(K(C));C.token===",";)M(C),Ee.push(K(C));if(C.token!=="]")throw Je(C,"Parenthesis ] expected");$(C),M(C),Z=new n(Z,new m(Ee))}else{if(M(C),C.tokenType!==x.SYMBOL)throw Je(C,"Property name expected after dot");Ee.push(new u(C.token)),M(C);var ze=!0;Z=new n(Z,new m(Ee,ze))}return Z}function ee(C){var Z,se;return C.token==='"'?(se=ue(C),Z=new u(se),Z=U(C,Z),Z):ve(C)}function ue(C){for(var Z="";B(C)!==""&&B(C)!=='"';)B(C)==="\\"&&(Z+=B(C),I(C)),Z+=B(C),I(C);if(M(C),C.token!=='"')throw Je(C,'End of string " expected');return M(C),JSON.parse('"'+Z+'"')}function ve(C){var Z,se;return C.token==="'"?(se=de(C),Z=new u(se),Z=U(C,Z),Z):be(C)}function de(C){for(var Z="";B(C)!==""&&B(C)!=="'";)B(C)==="\\"&&(Z+=B(C),I(C)),Z+=B(C),I(C);if(M(C),C.token!=="'")throw Je(C,"End of string ' expected");return M(C),JSON.parse('"'+Z+'"')}function be(C){var Z,se,Ee,ze;if(C.token==="["){if(H(C),M(C),C.token!=="]"){var ke=pe(C);if(C.token===";"){for(Ee=1,se=[ke];C.token===";";)M(C),se[Ee]=pe(C),Ee++;if(C.token!=="]")throw Je(C,"End of matrix ] expected");$(C),M(C),ze=se[0].items.length;for(var Fr=1;Fr<Ee;Fr++)if(se[Fr].items.length!==ze)throw mr(C,"Column dimensions mismatch ("+se[Fr].items.length+" !== "+ze+")");Z=new i(se)}else{if(C.token!=="]")throw Je(C,"End of matrix ] expected");$(C),M(C),Z=ke}}else $(C),M(C),Z=new i([]);return U(C,Z)}return we(C)}function pe(C){for(var Z=[K(C)],se=1;C.token===",";)M(C),Z[se]=K(C),se++;return new i(Z)}function we(C){if(C.token==="{"){H(C);var Z,se={};do if(M(C),C.token!=="}"){if(C.token==='"')Z=ue(C);else if(C.token==="'")Z=de(C);else if(C.tokenType===x.SYMBOL||C.tokenType===x.DELIMITER&&C.token in E)Z=C.token,M(C);else throw Je(C,"Symbol or string expected as object key");if(C.token!==":")throw Je(C,"Colon : expected after object key");M(C),se[Z]=K(C)}while(C.token===",");if(C.token!=="}")throw Je(C,"Comma , or bracket } expected after object value");$(C),M(C);var Ee=new v(se);return Ee=U(C,Ee),Ee}return _e(C)}function _e(C){var Z;return C.tokenType===x.NUMBER?(Z=C.token,M(C),new u(t(Z,a.number))):Le(C)}function Le(C){var Z;if(C.token==="("){if(H(C),M(C),Z=K(C),C.token!==")")throw Je(C,"Parenthesis ) expected");return $(C),M(C),Z=new p(Z),Z=U(C,Z),Z}return Be(C)}function Be(C){throw C.token===""?Je(C,"Unexpected end of expression"):Je(C,"Value expected")}function ar(C){return C.index-C.token.length+1}function Je(C,Z){var se=ar(C),Ee=new SyntaxError(Z+" (char "+se+")");return Ee.char=se,Ee}function mr(C,Z){var se=ar(C),Ee=new SyntaxError(Z+" (char "+se+")");return Ee.char=se,Ee}return e.addConversion({from:"string",to:"Node",convert:d}),d}),ip="compile",eS=["typed","parse"],rS=q(ip,eS,r=>{var{typed:e,parse:t}=r;return e(ip,{string:function(n){return t(n).compile()},"Array | Matrix":function(n){return je(n,function(i){return t(i).compile()})}})}),op="evaluate",tS=["typed","parse"],nS=q(op,tS,r=>{var{typed:e,parse:t}=r;return e(op,{string:function(n){var i=ea();return t(n).compile().evaluate(i)},"string, Map | Object":function(n,i){return t(n).compile().evaluate(i)},"Array | Matrix":function(n){var i=ea();return je(n,function(o){return t(o).compile().evaluate(i)})},"Array | Matrix, Map | Object":function(n,i){return je(n,function(o){return t(o).compile().evaluate(i)})}})}),aS="Parser",iS=["evaluate"],oS=q(aS,iS,r=>{var{evaluate:e}=r;function t(){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:ea(),writable:!1})}return t.prototype.type="Parser",t.prototype.isParser=!0,t.prototype.evaluate=function(a){return e(a,this.scope)},t.prototype.get=function(a){if(this.scope.has(a))return this.scope.get(a)},t.prototype.getAll=function(){return Fg(this.scope)},t.prototype.getAllAsMap=function(){return this.scope},t.prototype.set=function(a,n){return this.scope.set(a,n),n},t.prototype.remove=function(a){this.scope.delete(a)},t.prototype.clear=function(){this.scope.clear()},t},{isClass:!0}),sp="parser",sS=["typed","Parser"],uS=q(sp,sS,r=>{var{typed:e,Parser:t}=r;return e(sp,{"":function(){return new t}})}),up="lup",lS=["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],cS=q(up,lS,r=>{var{typed:e,matrix:t,abs:a,addScalar:n,divideScalar:i,multiplyScalar:o,subtract:f,larger:l,equalScalar:u,unaryMinus:s,DenseMatrix:c,SparseMatrix:m,Spa:v}=r;return e(up,{DenseMatrix:function(y){return h(y)},SparseMatrix:function(y){return p(y)},Array:function(y){var N=t(y),d=h(N);return{L:d.L.valueOf(),U:d.U.valueOf(),p:d.p}}});function h(g){var y=g._size[0],N=g._size[1],d=Math.min(y,N),w=Ge(g._data),x=[],b=[y,d],E=[],A=[d,N],S,D,T,B=[];for(S=0;S<y;S++)B[S]=S;for(D=0;D<N;D++){if(D>0)for(S=0;S<y;S++){var I=Math.min(S,D),P=0;for(T=0;T<I;T++)P=n(P,o(w[S][T],w[T][D]));w[S][D]=f(w[S][D],P)}var R=D,M=0,F=0;for(S=D;S<y;S++){var H=w[S][D],$=a(H);l($,M)&&(R=S,M=$,F=H)}if(D!==R&&(B[D]=[B[R],B[R]=B[D]][0],c._swapRows(D,R,w)),D<y)for(S=D+1;S<y;S++){var k=w[S][D];u(k,0)||(w[S][D]=i(w[S][D],F))}}for(D=0;D<N;D++)for(S=0;S<y;S++){if(D===0&&(S<N&&(E[S]=[]),x[S]=[]),S<D){S<N&&(E[S][D]=w[S][D]),D<y&&(x[S][D]=0);continue}if(S===D){S<N&&(E[S][D]=w[S][D]),D<y&&(x[S][D]=1);continue}S<N&&(E[S][D]=0),D<y&&(x[S][D]=w[S][D])}var Q=new c({data:x,size:b}),K=new c({data:E,size:A}),L=[];for(S=0,d=B.length;S<d;S++)L[B[S]]=S;return{L:Q,U:K,p:L,toString:function(){return"L: "+this.L.toString()+`
|
|
42
42
|
U: `+this.U.toString()+`
|
|
43
43
|
P: `+this.p}}}function p(g){var y=g._size[0],N=g._size[1],d=Math.min(y,N),w=g._values,x=g._index,b=g._ptr,E=[],A=[],S=[],D=[y,d],T=[],B=[],I=[],P=[d,N],R,M,F,H=[],$=[];for(R=0;R<y;R++)H[R]=R,$[R]=R;var k=function(L,j){var ae=$[L],re=$[j];H[ae]=j,H[re]=L,$[L]=re,$[j]=ae},Q=function(){var L=new v;M<y&&(S.push(E.length),E.push(1),A.push(M)),I.push(T.length);var j=b[M],ae=b[M+1];for(F=j;F<ae;F++)R=x[F],L.set(H[R],w[F]);M>0&&L.forEach(0,M-1,function(ce,ie){m._forEachRow(ce,E,A,S,function(Ae,Oe){Ae>ce&&L.accumulate(Ae,s(o(Oe,ie)))})});var re=M,fe=L.get(M),he=a(fe);L.forEach(M+1,y-1,function(ce,ie){var Ae=a(ie);l(Ae,he)&&(re=ce,he=Ae,fe=ie)}),M!==re&&(m._swapRows(M,re,D[1],E,A,S),m._swapRows(M,re,P[1],T,B,I),L.swap(M,re),k(M,re)),L.forEach(0,y-1,function(ce,ie){ce<=M?(T.push(ie),B.push(ce)):(ie=i(ie,fe),u(ie,0)||(E.push(ie),A.push(ce)))})};for(M=0;M<N;M++)Q();return I.push(T.length),S.push(E.length),{L:new m({values:E,index:A,ptr:S,size:D}),U:new m({values:T,index:B,ptr:I,size:P}),p:H,toString:function(){return"L: "+this.L.toString()+`
|
|
44
44
|
U: `+this.U.toString()+`
|
|
45
|
-
P: `+this.p}}}}),
|
|
46
|
-
R: `+this.R.toString()}}}function y(d){var w=g(d),x=w.R._data;if(d._data.length>0)for(var b=x[0][0].type==="Complex"?p(0):0,E=0;E<x.length;++E)for(var A=0;A<E&&A<(x[0]||[]).length;++A)x[E][A]=b;return w}function N(d){throw new Error("qr not implemented for sparse matrices yet")}});function
|
|
45
|
+
P: `+this.p}}}}),lp="qr",fS=["typed","matrix","zeros","identity","isZero","equal","sign","sqrt","conj","unaryMinus","addScalar","divideScalar","multiplyScalar","subtract","complex"],mS=q(lp,fS,r=>{var{typed:e,matrix:t,zeros:a,identity:n,isZero:i,equal:o,sign:f,sqrt:l,conj:u,unaryMinus:s,addScalar:c,divideScalar:m,multiplyScalar:v,subtract:h,complex:p}=r;return Sr(e(lp,{DenseMatrix:function(w){return y(w)},SparseMatrix:function(w){return N()},Array:function(w){var x=t(w),b=y(x);return{Q:b.Q.valueOf(),R:b.R.valueOf()}}}),{_denseQRimpl:g});function g(d){var w=d._size[0],x=d._size[1],b=n([w],"dense"),E=b._data,A=d.clone(),S=A._data,D,T,B,I=a([w],"");for(B=0;B<Math.min(x,w);++B){var P=S[B][B],R=s(o(P,0)?1:f(P)),M=u(R),F=0;for(D=B;D<w;D++)F=c(F,v(S[D][B],u(S[D][B])));var H=v(R,l(F));if(!i(H)){var $=h(P,H);for(I[B]=1,D=B+1;D<w;D++)I[D]=m(S[D][B],$);var k=s(u(m($,H))),Q=void 0;for(T=B;T<x;T++){for(Q=0,D=B;D<w;D++)Q=c(Q,v(u(I[D]),S[D][T]));for(Q=v(Q,k),D=B;D<w;D++)S[D][T]=v(h(S[D][T],v(I[D],Q)),M)}for(D=0;D<w;D++){for(Q=0,T=B;T<w;T++)Q=c(Q,v(E[D][T],I[T]));for(Q=v(Q,k),T=B;T<w;++T)E[D][T]=m(h(E[D][T],v(Q,u(I[T]))),M)}}}return{Q:b,R:A,toString:function(){return"Q: "+this.Q.toString()+`
|
|
46
|
+
R: `+this.R.toString()}}}function y(d){var w=g(d),x=w.R._data;if(d._data.length>0)for(var b=x[0][0].type==="Complex"?p(0):0,E=0;E<x.length;++E)for(var A=0;A<E&&A<(x[0]||[]).length;++A)x[E][A]=b;return w}function N(d){throw new Error("qr not implemented for sparse matrices yet")}});function vS(r,e,t,a){for(var n=r._values,i=r._index,o=r._ptr,f=r._size,l=r._datatype,u=f[0],s=f[1],c=a&&r._values?[]:null,m=[],v=[],h=0,p=0;p<s;p++){v[p]=h;for(var g=t?t[p]:p,y=o[g],N=o[g+1],d=y;d<N;d++){var w=e?e[i[d]]:i[d];m[h]=w,c&&(c[h]=n[d]),h++}}return v[s]=h,r.createSparseMatrix({values:c,index:m,ptr:v,size:[u,s],datatype:l})}function cp(r,e,t,a,n,i,o){var f=0;for(t[o]=r;f>=0;){var l=t[o+f],u=t[a+l];u===-1?(f--,i[e++]=l):(t[a+l]=t[n+u],++f,t[o+f]=u)}return e}function pS(r,e){if(!r)return null;var t=0,a,n=[],i=[],o=0,f=e,l=2*e;for(a=0;a<e;a++)i[o+a]=-1;for(a=e-1;a>=0;a--)r[a]!==-1&&(i[f+a]=i[o+r[a]],i[o+r[a]]=a);for(a=0;a<e;a++)r[a]===-1&&(t=cp(a,t,i,o,f,n,l));return n}function hS(r,e){if(!r)return null;var t=r._index,a=r._ptr,n=r._size,i=n[0],o=n[1],f=[],l=[],u=0,s=o,c,m;if(e)for(c=0;c<i;c++)l[s+c]=-1;for(var v=0;v<o;v++){f[v]=-1,l[u+v]=-1;for(var h=a[v],p=a[v+1],g=h;g<p;g++){var y=t[g];for(c=e?l[s+y]:y;c!==-1&&c<v;c=m)m=l[u+c],l[u+c]=v,m===-1&&(f[c]=v);e&&(l[s+y]=v)}}return f}function dS(r,e,t){for(var a=r._values,n=r._index,i=r._ptr,o=r._size,f=o[1],l=0,u=0;u<f;u++){var s=i[u];for(i[u]=l;s<i[u+1];s++)e(n[s],u,a?a[s]:1,t)&&(n[l]=n[s],a&&(a[l]=a[s]),l++)}return i[f]=l,n.splice(l,n.length-l),a&&a.splice(l,a.length-l),l}function vn(r){return-r-2}var gS="csAmd",yS=["add","multiply","transpose"],bS=q(gS,yS,r=>{var{add:e,multiply:t,transpose:a}=r;return function(s,c){if(!c||s<=0||s>3)return null;var m=c._size,v=m[0],h=m[1],p=0,g=Math.max(16,10*Math.sqrt(h));g=Math.min(h-2,g);var y=n(s,c,v,h,g);dS(y,l,null);for(var N=y._index,d=y._ptr,w=d[h],x=[],b=[],E=0,A=h+1,S=2*(h+1),D=3*(h+1),T=4*(h+1),B=5*(h+1),I=6*(h+1),P=7*(h+1),R=x,M=i(h,d,b,E,D,R,S,P,A,I,T,B),F=o(h,d,b,B,T,I,g,A,D,R,S),H=0,$,k,Q,K,L,j,ae,re,fe,he,ce,ie,Ae,Oe,Ce,$e;F<h;){for(Q=-1;H<h&&(Q=b[D+H])===-1;H++);b[S+Q]!==-1&&(R[b[S+Q]]=-1),b[D+H]=b[S+Q];var V=b[T+Q],X=b[A+Q];F+=X;var oe=0;b[A+Q]=-X;var G=d[Q],Y=V===0?G:w,te=Y;for(K=1;K<=V+1;K++){for(K>V?(j=Q,ae=G,re=b[E+Q]-V):(j=N[G++],ae=d[j],re=b[E+j]),L=1;L<=re;L++)$=N[ae++],!((fe=b[A+$])<=0)&&(oe+=fe,b[A+$]=-fe,N[te++]=$,b[S+$]!==-1&&(R[b[S+$]]=R[$]),R[$]!==-1?b[S+R[$]]=b[S+$]:b[D+b[B+$]]=b[S+$]);j!==Q&&(d[j]=vn(Q),b[I+j]=0)}for(V!==0&&(w=te),b[B+Q]=oe,d[Q]=Y,b[E+Q]=te-Y,b[T+Q]=-2,M=f(M,p,b,I,h),he=Y;he<te;he++)if($=N[he],!((ce=b[T+$])<=0)){fe=-b[A+$];var ye=M-fe;for(G=d[$],ie=d[$]+ce-1;G<=ie;G++)j=N[G],b[I+j]>=M?b[I+j]-=fe:b[I+j]!==0&&(b[I+j]=b[B+j]+ye)}for(he=Y;he<te;he++){for($=N[he],ie=d[$],Ae=ie+b[T+$]-1,Oe=ie,Ce=0,$e=0,G=ie;G<=Ae;G++)if(j=N[G],b[I+j]!==0){var me=b[I+j]-M;me>0?($e+=me,N[Oe++]=j,Ce+=j):(d[j]=vn(Q),b[I+j]=0)}b[T+$]=Oe-ie+1;var z=Oe,U=ie+b[E+$];for(G=Ae+1;G<U;G++){k=N[G];var ee=b[A+k];ee<=0||($e+=ee,N[Oe++]=k,Ce+=k)}$e===0?(d[$]=vn(Q),fe=-b[A+$],oe-=fe,X+=fe,F+=fe,b[A+$]=0,b[T+$]=-1):(b[B+$]=Math.min(b[B+$],$e),N[Oe]=N[z],N[z]=N[ie],N[ie]=Q,b[E+$]=Oe-ie+1,Ce=(Ce<0?-Ce:Ce)%h,b[S+$]=b[P+Ce],b[P+Ce]=$,R[$]=Ce)}for(b[B+Q]=oe,p=Math.max(p,oe),M=f(M+p,p,b,I,h),he=Y;he<te;he++)if($=N[he],!(b[A+$]>=0))for(Ce=R[$],$=b[P+Ce],b[P+Ce]=-1;$!==-1&&b[S+$]!==-1;$=b[S+$],M++){for(re=b[E+$],ce=b[T+$],G=d[$]+1;G<=d[$]+re-1;G++)b[I+N[G]]=M;var ue=$;for(k=b[S+$];k!==-1;){var ve=b[E+k]===re&&b[T+k]===ce;for(G=d[k]+1;ve&&G<=d[k]+re-1;G++)b[I+N[G]]!==M&&(ve=0);ve?(d[k]=vn($),b[A+$]+=b[A+k],b[A+k]=0,b[T+k]=-1,k=b[S+k],b[S+ue]=k):(ue=k,k=b[S+k])}}for(G=Y,he=Y;he<te;he++)$=N[he],!((fe=-b[A+$])<=0)&&(b[A+$]=fe,$e=b[B+$]+oe-fe,$e=Math.min($e,h-F-fe),b[D+$e]!==-1&&(R[b[D+$e]]=$),b[S+$]=b[D+$e],R[$]=-1,b[D+$e]=$,H=Math.min(H,$e),b[B+$]=$e,N[G++]=$);b[A+Q]=X,(b[E+Q]=G-Y)===0&&(d[Q]=-1,b[I+Q]=0),V!==0&&(w=G)}for($=0;$<h;$++)d[$]=vn(d[$]);for(k=0;k<=h;k++)b[D+k]=-1;for(k=h;k>=0;k--)b[A+k]>0||(b[S+k]=b[D+d[k]],b[D+d[k]]=k);for(j=h;j>=0;j--)b[A+j]<=0||d[j]!==-1&&(b[S+j]=b[D+d[j]],b[D+d[j]]=j);for(Q=0,$=0;$<=h;$++)d[$]===-1&&(Q=cp($,Q,b,D,S,x,I));return x.splice(x.length-1,1),x};function n(u,s,c,m,v){var h=a(s);if(u===1&&m===c)return e(s,h);if(u===2){for(var p=h._index,g=h._ptr,y=0,N=0;N<c;N++){var d=g[N];if(g[N]=y,!(g[N+1]-d>v))for(var w=g[N+1];d<w;d++)p[y++]=p[d]}return g[c]=y,s=a(h),t(h,s)}return t(h,s)}function i(u,s,c,m,v,h,p,g,y,N,d,w){for(var x=0;x<u;x++)c[m+x]=s[x+1]-s[x];c[m+u]=0;for(var b=0;b<=u;b++)c[v+b]=-1,h[b]=-1,c[p+b]=-1,c[g+b]=-1,c[y+b]=1,c[N+b]=1,c[d+b]=0,c[w+b]=c[m+b];var E=f(0,0,c,N,u);return c[d+u]=-2,s[u]=-1,c[N+u]=0,E}function o(u,s,c,m,v,h,p,g,y,N,d){for(var w=0,x=0;x<u;x++){var b=c[m+x];if(b===0)c[v+x]=-2,w++,s[x]=-1,c[h+x]=0;else if(b>p)c[g+x]=0,c[v+x]=-1,w++,s[x]=vn(u),c[g+u]++;else{var E=c[y+b];E!==-1&&(N[E]=x),c[d+x]=c[y+b],c[y+b]=x}}return w}function f(u,s,c,m,v){if(u<2||u+s<0){for(var h=0;h<v;h++)c[m+h]!==0&&(c[m+h]=1);u=2}return u}function l(u,s){return u!==s}});function xS(r,e,t,a,n,i,o){var f,l,u=0,s;if(r<=e||t[a+e]<=t[n+r])return-1;t[n+r]=t[a+e];var c=t[i+r];if(t[i+r]=e,c===-1)u=1,s=r;else{for(u=2,s=c;s!==t[o+s];s=t[o+s]);for(f=c;f!==s;f=l)l=t[o+f],t[o+f]=s}return{jleaf:u,q:s}}var wS="csCounts",NS=["transpose"],DS=q(wS,NS,r=>{var{transpose:e}=r;return function(t,a,n,i){if(!t||!a||!n)return null;var o=t._size,f=o[0],l=o[1],u,s,c,m,v,h,p,g=4*l+(i?l+f+1:0),y=[],N=0,d=l,w=2*l,x=3*l,b=4*l,E=5*l+1;for(c=0;c<g;c++)y[c]=-1;var A=[],S=e(t),D=S._index,T=S._ptr;for(c=0;c<l;c++)for(s=n[c],A[s]=y[x+s]===-1?1:0;s!==-1&&y[x+s]===-1;s=a[s])y[x+s]=c;if(i){for(c=0;c<l;c++)y[n[c]]=c;for(u=0;u<f;u++){for(c=l,h=T[u],p=T[u+1],v=h;v<p;v++)c=Math.min(c,y[D[v]]);y[E+u]=y[b+c],y[b+c]=u}}for(u=0;u<l;u++)y[N+u]=u;for(c=0;c<l;c++){for(s=n[c],a[s]!==-1&&A[a[s]]--,m=i?y[b+c]:s;m!==-1;m=i?y[E+m]:-1)for(v=T[m];v<T[m+1];v++){u=D[v];var B=xS(u,s,y,x,d,w,N);B.jleaf>=1&&A[s]++,B.jleaf===2&&A[B.q]--}a[s]!==-1&&(y[N+s]=a[s])}for(s=0;s<l;s++)a[s]!==-1&&(A[a[s]]+=A[s]);return A}}),AS="csSqr",ES=["add","multiply","transpose"],SS=q(AS,ES,r=>{var{add:e,multiply:t,transpose:a}=r,n=bS({add:e,multiply:t,transpose:a}),i=DS({transpose:a});return function(l,u,s){var c=u._ptr,m=u._size,v=m[1],h,p={};if(p.q=n(l,u),l&&!p.q)return null;if(s){var g=l?vS(u,null,p.q,0):u;p.parent=hS(g,1);var y=pS(p.parent,v);if(p.cp=i(g,p.parent,y,1),g&&p.parent&&p.cp&&o(g,p))for(p.unz=0,h=0;h<v;h++)p.unz+=p.cp[h]}else p.unz=4*c[v]+v,p.lnz=p.unz;return p};function o(f,l){var u=f._ptr,s=f._index,c=f._size,m=c[0],v=c[1];l.pinv=[],l.leftmost=[];var h=l.parent,p=l.pinv,g=l.leftmost,y=[],N=0,d=m,w=m+v,x=m+2*v,b,E,A,S,D;for(E=0;E<v;E++)y[d+E]=-1,y[w+E]=-1,y[x+E]=0;for(b=0;b<m;b++)g[b]=-1;for(E=v-1;E>=0;E--)for(S=u[E],D=u[E+1],A=S;A<D;A++)g[s[A]]=E;for(b=m-1;b>=0;b--)p[b]=-1,E=g[b],E!==-1&&(y[x+E]++===0&&(y[w+E]=b),y[N+b]=y[d+E],y[d+E]=b);for(l.lnz=0,l.m2=m,E=0;E<v;E++)if(b=y[d+E],l.lnz++,b<0&&(b=l.m2++),p[b]=E,!(--x[E]<=0)){l.lnz+=y[x+E];var T=h[E];T!==-1&&(y[x+T]===0&&(y[w+T]=y[w+E]),y[N+y[w+E]]=y[d+T],y[d+T]=y[N+b],y[x+T]+=y[x+E])}for(b=0;b<m;b++)p[b]<0&&(p[b]=E++);return!0}});function Ds(r,e){return r[e]<0}function fp(r,e){r[e]=vn(r[e])}function mp(r){return r<0?vn(r):r}function CS(r,e,t,a,n){var i=e._index,o=e._ptr,f=e._size,l=f[1],u,s,c,m=0;for(a[0]=r;m>=0;){r=a[m];var v=n?n[r]:r;Ds(o,r)||(fp(o,r),a[l+m]=v<0?0:mp(o[v]));var h=1;for(s=a[l+m],c=v<0?0:mp(o[v+1]);s<c;s++)if(u=i[s],!Ds(o,u)){a[l+m]=s,a[++m]=u,h=0;break}h&&(m--,a[--t]=r)}return t}function MS(r,e,t,a,n){var i=r._ptr,o=r._size,f=e._index,l=e._ptr,u=o[1],s,c,m,v=u;for(c=l[t],m=l[t+1],s=c;s<m;s++){var h=f[s];Ds(i,h)||(v=CS(h,r,v,a,n))}for(s=v;s<u;s++)fp(i,a[s]);return v}var FS="csSpsolve",TS=["divideScalar","multiply","subtract"],BS=q(FS,TS,r=>{var{divideScalar:e,multiply:t,subtract:a}=r;return function(i,o,f,l,u,s,c){var m=i._values,v=i._index,h=i._ptr,p=i._size,g=p[1],y=o._values,N=o._index,d=o._ptr,w,x,b,E,A=MS(i,o,f,l,s);for(w=A;w<g;w++)u[l[w]]=0;for(x=d[f],b=d[f+1],w=x;w<b;w++)u[N[w]]=y[w];for(var S=A;S<g;S++){var D=l[S],T=s?s[D]:D;if(!(T<0))for(x=h[T],b=h[T+1],u[D]=e(u[D],m[c?x:b-1]),w=c?x+1:x,E=c?b:b-1;w<E;w++){var B=v[w];u[B]=a(u[B],t(m[w],u[D]))}}return A}}),$S="csLu",OS=["abs","divideScalar","multiply","subtract","larger","largerEq","SparseMatrix"],IS=q($S,OS,r=>{var{abs:e,divideScalar:t,multiply:a,subtract:n,larger:i,largerEq:o,SparseMatrix:f}=r,l=BS({divideScalar:t,multiply:a,subtract:n});return function(s,c,m){if(!s)return null;var v=s._size,h=v[1],p,g=100,y=100;c&&(p=c.q,g=c.lnz||g,y=c.unz||y);var N=[],d=[],w=[],x=new f({values:N,index:d,ptr:w,size:[h,h]}),b=[],E=[],A=[],S=new f({values:b,index:E,ptr:A,size:[h,h]}),D=[],T,B,I=[],P=[];for(T=0;T<h;T++)I[T]=0,D[T]=-1,w[T+1]=0;g=0,y=0;for(var R=0;R<h;R++){w[R]=g,A[R]=y;var M=p?p[R]:R,F=l(x,s,M,P,I,D,1),H=-1,$=-1;for(B=F;B<h;B++)if(T=P[B],D[T]<0){var k=e(I[T]);i(k,$)&&($=k,H=T)}else E[y]=D[T],b[y++]=I[T];if(H===-1||$<=0)return null;D[M]<0&&o(e(I[M]),a($,m))&&(H=M);var Q=I[H];for(E[y]=R,b[y++]=Q,D[H]=R,d[g]=H,N[g++]=1,B=F;B<h;B++)T=P[B],D[T]<0&&(d[g]=T,N[g++]=t(I[T],Q)),I[T]=0}for(w[h]=g,A[h]=y,B=0;B<g;B++)d[B]=D[d[B]];return N.splice(g,N.length-g),d.splice(g,d.length-g),b.splice(y,b.length-y),E.splice(y,E.length-y),{L:x,U:S,pinv:D}}}),vp="slu",RS=["typed","abs","add","multiply","transpose","divideScalar","subtract","larger","largerEq","SparseMatrix"],_S=q(vp,RS,r=>{var{typed:e,abs:t,add:a,multiply:n,transpose:i,divideScalar:o,subtract:f,larger:l,largerEq:u,SparseMatrix:s}=r,c=SS({add:a,multiply:n,transpose:i}),m=IS({abs:t,divideScalar:o,multiply:n,subtract:f,larger:l,largerEq:u,SparseMatrix:s});return e(vp,{"SparseMatrix, number, number":function(h,p,g){if(!qe(p)||p<0||p>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(g<0||g>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var y=c(p,h,!1),N=m(h,y,g);return{L:N.L,U:N.U,p:N.pinv,q:y.q,toString:function(){return"L: "+this.L.toString()+`
|
|
47
47
|
U: `+this.U.toString()+`
|
|
48
48
|
p: `+this.p.toString()+(this.q?`
|
|
49
49
|
q: `+this.q.toString():"")+`
|
|
50
|
-
`}}}})});function
|
|
50
|
+
`}}}})});function pp(r,e){var t,a=e.length,n=[];if(r)for(t=0;t<a;t++)n[r[t]]=e[t];else for(t=0;t<a;t++)n[t]=e[t];return n}var hp="lusolve",qS=["typed","matrix","lup","slu","usolve","lsolve","DenseMatrix"],zS=q(hp,qS,r=>{var{typed:e,matrix:t,lup:a,slu:n,usolve:i,lsolve:o,DenseMatrix:f}=r,l=Za({DenseMatrix:f});return e(hp,{"Array, Array | Matrix":function(m,v){m=t(m);var h=a(m),p=s(h.L,h.U,h.p,null,v);return p.valueOf()},"DenseMatrix, Array | Matrix":function(m,v){var h=a(m);return s(h.L,h.U,h.p,null,v)},"SparseMatrix, Array | Matrix":function(m,v){var h=a(m);return s(h.L,h.U,h.p,null,v)},"SparseMatrix, Array | Matrix, number, number":function(m,v,h,p){var g=n(m,h,p);return s(g.L,g.U,g.p,g.q,v)},"Object, Array | Matrix":function(m,v){return s(m.L,m.U,m.p,m.q,v)}});function u(c){if(Ve(c))return c;if(cr(c))return t(c);throw new TypeError("Invalid Matrix LU decomposition")}function s(c,m,v,h,p){c=u(c),m=u(m),v&&(p=l(c,p,!0),p._data=pp(v,p._data));var g=o(c,p),y=i(m,g);return h&&(y._data=pp(h,y._data)),y}}),dp="polynomialRoot",PS=["typed","isZero","equalScalar","add","subtract","multiply","divide","sqrt","unaryMinus","cbrt","typeOf","im","re"],US=q(dp,PS,r=>{var{typed:e,isZero:t,equalScalar:a,add:n,subtract:i,multiply:o,divide:f,sqrt:l,unaryMinus:u,cbrt:s,typeOf:c,im:m,re:v}=r;return e(dp,{"number|Complex, ...number|Complex":(h,p)=>{for(var g=[h,...p];g.length>0&&t(g[g.length-1]);)g.pop();if(g.length<2)throw new RangeError("Polynomial [".concat(h,", ").concat(p,"] must have a non-zero non-constant coefficient"));switch(g.length){case 2:return[u(f(g[0],g[1]))];case 3:{var[y,N,d]=g,w=o(2,d),x=o(N,N),b=o(4,d,y);if(a(x,b))return[f(u(N),w)];var E=l(i(x,b));return[f(i(E,N),w),f(i(u(E),N),w)]}case 4:{var[A,S,D,T]=g,B=u(o(3,T)),I=o(D,D),P=o(3,T,S),R=n(o(2,D,D,D),o(27,T,T,A)),M=o(9,T,D,S);if(a(I,P)&&a(R,M))return[f(D,B)];var F=i(I,P),H=i(R,M),$=n(o(18,T,D,S,A),o(D,D,S,S)),k=n(o(4,D,D,D,A),o(4,T,S,S,S),o(27,T,T,A,A));if(a($,k))return[f(i(o(4,T,D,S),n(o(9,T,T,A),o(D,D,D))),o(T,F)),f(i(o(9,T,A),o(D,S)),o(2,F))];var Q;a(I,P)?Q=H:Q=f(n(H,l(i(o(H,H),o(4,F,F,F)))),2);var K=!0,L=s(Q,K).toArray().map(j=>f(n(D,j,f(F,j)),B));return L.map(j=>c(j)==="Complex"&&a(v(j),v(j)+m(j))?v(j):j)}default:throw new RangeError("only implemented for cubic or lower-order polynomials, not ".concat(g))}}})}),LS="Help",kS=["parse"],VS=q(LS,kS,r=>{var{parse:e}=r;function t(a){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(!a)throw new Error('Argument "doc" missing');this.doc=a}return t.prototype.type="Help",t.prototype.isHelp=!0,t.prototype.toString=function(){var a=this.doc||{},n=`
|
|
51
51
|
`;if(a.name&&(n+="Name: "+a.name+`
|
|
52
52
|
|
|
53
53
|
`),a.category&&(n+="Category: "+a.category+`
|
|
@@ -61,25 +61,25 @@ q: `+this.q.toString():"")+`
|
|
|
61
61
|
|
|
62
62
|
`),a.examples){n+=`Examples:
|
|
63
63
|
`;for(var i={},o=0;o<a.examples.length;o++){var f=a.examples[o];n+=" "+f+`
|
|
64
|
-
`;var l=void 0;try{l=e(f).compile().evaluate(i)}catch(u){l=u}l!==void 0&&!
|
|
64
|
+
`;var l=void 0;try{l=e(f).compile().evaluate(i)}catch(u){l=u}l!==void 0&&!sl(l)&&(n+=" "+Ye(l,{precision:14})+`
|
|
65
65
|
`)}n+=`
|
|
66
66
|
`}return a.mayThrow&&a.mayThrow.length&&(n+="Throws: "+a.mayThrow.join(", ")+`
|
|
67
67
|
|
|
68
68
|
`),a.seealso&&a.seealso.length&&(n+="See also: "+a.seealso.join(", ")+`
|
|
69
|
-
`),n},t.prototype.toJSON=function(){var a=Ge(this.doc);return a.mathjs="Help",a},t.fromJSON=function(a){var n={};return Object.keys(a).filter(i=>i!=="mathjs").forEach(i=>{n[i]=a[i]}),new t(n)},t.prototype.valueOf=t.prototype.toString,t},{isClass:!0}),_S="Chain",qS=["?on","math","typed"],zS=q(_S,qS,r=>{var{on:e,math:t,typed:a}=r;function n(u){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");ol(u)?this.value=u.value:this.value=u}n.prototype.type="Chain",n.prototype.isChain=!0,n.prototype.done=function(){return this.value},n.prototype.valueOf=function(){return this.value},n.prototype.toString=function(){return Ye(this.value)},n.prototype.toJSON=function(){return{mathjs:"Chain",value:this.value}},n.fromJSON=function(u){return new n(u.value)};function i(u,s){typeof s=="function"&&(n.prototype[u]=f(s))}function o(u,s){U0(n.prototype,u,function(){var m=s();if(typeof m=="function")return f(m)})}function f(u){return function(){if(arguments.length===0)return new n(u(this.value));for(var s=[this.value],c=0;c<arguments.length;c++)s[c+1]=arguments[c];if(a.isTypedFunction(u)){var m=a.resolve(u,s);if(m.params.length===1)throw new Error("chain function "+u.name+" cannot match rest parameter between chain value and additional arguments.");return new n(m.implementation.apply(u,s))}return new n(u.apply(u,s))}}n.createProxy=function(u,s){if(typeof u=="string")i(u,s);else{var c=function(h){Re(u,h)&&l[h]===void 0&&o(h,()=>u[h])};for(var m in u)c(m)}};var l={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return n.createProxy(t),e&&e("import",function(u,s,c){c||o(u,s)}),n},{isClass:!0}),hp={name:"e",category:"Constants",syntax:["e"],description:"Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",examples:["e","e ^ 2","exp(2)","log(e)"],seealso:["exp"]},PS={name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},US={name:"i",category:"Constants",syntax:["i"],description:"Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",examples:["i","i * i","sqrt(-1)"],seealso:[]},LS={name:"Infinity",category:"Constants",syntax:["Infinity"],description:"Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",examples:["Infinity","1 / 0"],seealso:[]},kS={name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},VS={name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},GS={name:"LOG10E",category:"Constants",syntax:["LOG10E"],description:"Returns the base-10 logarithm of E, approximately equal to 0.434",examples:["LOG10E","log(e, 10)"],seealso:[]},HS={name:"LOG2E",category:"Constants",syntax:["LOG2E"],description:"Returns the base-2 logarithm of E, approximately equal to 1.442",examples:["LOG2E","log(e, 2)"],seealso:[]},ZS={name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},JS={name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},XS={name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["phi"],seealso:[]},dp={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]},WS={name:"SQRT1_2",category:"Constants",syntax:["SQRT1_2"],description:"Returns the square root of 1/2, approximately equal to 0.707",examples:["SQRT1_2","sqrt(1/2)"],seealso:[]},YS={name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},QS={name:"tau",category:"Constants",syntax:["tau"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]},KS={name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},jS={name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},eC={name:"bignumber",category:"Construction",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","complex","fraction","index","matrix","string","unit"]},rC={name:"boolean",category:"Construction",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]},tC={name:"complex",category:"Construction",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]},nC={name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.",examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]},aC={name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(matrix)","fraction(num,den)","fraction({n: num, d: den})"],description:"Create a fraction from a number or from integer numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)","fraction({n: 333, d: 53})","fraction([sqrt(9), sqrt(10), sqrt(11)])"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},iC={name:"index",category:"Construction",syntax:["[start]","[start:end]","[start:step:end]","[start1, start 2, ...]","[start1:end1, start2:end2, ...]","[start1:step1:end1, start2:step2:end2, ...]"],description:"Create an index to get or replace a subset of a matrix",examples:["[1, 2, 3]","A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[1:2, 1:2] = ones(2, 2)"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]},oC={name:"matrix",category:"Construction",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()",'matrix("dense")',"matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])",'matrix([3, 4; 5, 6], "sparse")','matrix([3, 4; 5, 6], "sparse", "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","sparse"]},sC={name:"number",category:"Construction",syntax:["x","number(x)","number(unit, valuelessUnit)"],description:"Create a number or convert a string or boolean into a number.",examples:["2","2e3","4.05","number(2)",'number("7.2")',"number(true)","number([true, false, true, true])",'number(unit("52cm"), "m")'],seealso:["bignumber","boolean","complex","fraction","index","matrix","string","unit"]},uC={name:"sparse",category:"Construction",syntax:["sparse()","sparse([a1, b1, ...; a1, b2, ...])",'sparse([a1, b1, ...; a1, b2, ...], "number")'],description:"Create a sparse matrix.",examples:["sparse()","sparse([3, 4; 5, 6])",'sparse([3, 0; 5, 0], "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","matrix"]},lC={name:"splitUnit",category:"Construction",syntax:["splitUnit(unit: Unit, parts: Unit[])"],description:"Split a unit in an array of units whose sum is equal to the original unit.",examples:['splitUnit(1 m, ["feet", "inch"])'],seealso:["unit","createUnit"]},cC={name:"string",category:"Construction",syntax:['"text"',"string(x)"],description:"Create a string or convert a value to a string",examples:['"Hello World!"',"string(4.2)","string(3 + 2i)"],seealso:["bignumber","boolean","complex","index","matrix","number","unit"]},fC={name:"unit",category:"Construction",syntax:["value unit","unit(value, unit)","unit(string)"],description:"Create a unit.",examples:["5.5 mm","3 inch",'unit(7.1, "kilogram")','unit("23 deg")'],seealso:["bignumber","boolean","complex","index","matrix","number","string"]},mC={name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},vC={name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},pC={name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},hC={name:"derivative",category:"Algebra",syntax:["derivative(expr, variable)","derivative(expr, variable, {simplify: boolean})"],description:"Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",examples:['derivative("2x^3", "x")','derivative("2x^3", "x", {simplify: false})','derivative("2x^2 + 3x + 4", "x")','derivative("sin(2x)", "x")','f = parse("x^2 + x")','x = parse("x")',"df = derivative(f, x)","df.evaluate({x: 3})"],seealso:["simplify","parse","evaluate"]},dC={name:"leafCount",category:"Algebra",syntax:["leafCount(expr)"],description:"Computes the number of leaves in the parse tree of the given expression",examples:['leafCount("e^(i*pi)-1")','leafCount(parse("{a: 22/7, b: 10^(1/2)}"))'],seealso:["simplify"]},gC={name:"lsolve",category:"Algebra",syntax:["x=lsolve(L, b)"],description:"Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolveAll","lup","lusolve","usolve","matrix","sparse"]},yC={name:"lsolveAll",category:"Algebra",syntax:["x=lsolveAll(L, b)"],description:"Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolve","lup","lusolve","usolve","matrix","sparse"]},bC={name:"lup",category:"Algebra",syntax:["lup(m)"],description:"Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",examples:["lup([[2, 1], [1, 4]])","lup(matrix([[2, 1], [1, 4]]))","lup(sparse([[2, 1], [1, 4]]))"],seealso:["lusolve","lsolve","usolve","matrix","sparse","slu","qr"]},xC={name:"lusolve",category:"Algebra",syntax:["x=lusolve(A, b)","x=lusolve(lu, b)"],description:"Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lusolve(a, b)"],seealso:["lup","slu","lsolve","usolve","matrix","sparse"]},wC={name:"polynomialRoot",category:"Algebra",syntax:["x=polynomialRoot(-6, 3)","x=polynomialRoot(4, -4, 1)","x=polynomialRoot(-8, 12, -6, 1)"],description:"Finds the roots of a univariate polynomial given by its coefficients starting from constant, linear, and so on, increasing in degree.",examples:["a = polynomialRoot(-6, 11, -6 1)"],seealso:["cbrt","sqrt"]},NC={name:"qr",category:"Algebra",syntax:["qr(A)"],description:"Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",examples:["qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])"],seealso:["lup","slu","matrix"]},DC={name:"rationalize",category:"Algebra",syntax:["rationalize(expr)","rationalize(expr, scope)","rationalize(expr, scope, detailed)"],description:"Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",examples:['rationalize("2x/y - y/(x+1)")','rationalize("2x/y - y/(x+1)", true)'],seealso:["simplify"]},AC={name:"resolve",category:"Algebra",syntax:["resolve(node, scope)"],description:"Recursively substitute variables in an expression tree.",examples:['resolve(parse("1 + x"), { x: 7 })','resolve(parse("size(text)"), { text: "Hello World" })','resolve(parse("x + y"), { x: parse("3z") })','resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })'],seealso:["simplify","evaluate"],mayThrow:["ReferenceError"]},EC={name:"simplify",category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["simplifyCore","derivative","evaluate","parse","rationalize","resolve"]},SC={name:"simplifyConstant",category:"Algebra",syntax:["simplifyConstant(expr)","simplifyConstant(expr, options)"],description:"Replace constant subexpressions of node with their values.",examples:['simplifyConatant("(3-3)*x")','simplifyConstant(parse("z-cos(tau/8)"))'],seealso:["simplify","simplifyCore","evaluate"]},CC={name:"simplifyCore",category:"Algebra",syntax:["simplifyCore(node)"],description:"Perform simple one-pass simplifications on an expression tree.",examples:['simplifyCore(parse("0*x"))','simplifyCore(parse("(x+0)*2"))'],seealso:["simplify","simplifyConstant","evaluate"]},MC={name:"slu",category:"Algebra",syntax:["slu(A, order, threshold)"],description:"Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",examples:["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],seealso:["lusolve","lsolve","usolve","matrix","sparse","lup","qr"]},FC={name:"symbolicEqual",category:"Algebra",syntax:["symbolicEqual(expr1, expr2)","symbolicEqual(expr1, expr2, options)"],description:"Returns true if the difference of the expressions simplifies to 0",examples:['symbolicEqual("x*y","y*x")','symbolicEqual("abs(x^2)", "x^2")','symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})'],seealso:["simplify","evaluate"]},TC={name:"usolve",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolveAll","lup","lusolve","lsolve","matrix","sparse"]},BC={name:"usolveAll",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolve","lup","lusolve","lsolve","matrix","sparse"]},$C={name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},OC={name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i","3 cm + 2 inch",'"2.3" + "4"'],seealso:["subtract"]},IC={name:"cbrt",category:"Arithmetic",syntax:["cbrt(x)","cbrt(x, allRoots)"],description:"Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",examples:["cbrt(64)","cube(4)","cbrt(-8)","cbrt(2 + 3i)","cbrt(8i)","cbrt(8i, true)","cbrt(27 m^3)"],seealso:["square","sqrt","cube","multiply"]},RC={name:"ceil",category:"Arithmetic",syntax:["ceil(x)"],description:"Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)"],seealso:["floor","fix","round"]},_C={name:"cube",category:"Arithmetic",syntax:["cube(x)"],description:"Compute the cube of a value. The cube of x is x * x * x.",examples:["cube(2)","2^3","2 * 2 * 2"],seealso:["multiply","square","pow"]},qC={name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["a = 2 / 3","a * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]},zC={name:"dotDivide",category:"Operators",syntax:["x ./ y","dotDivide(x, y)"],description:"Divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","dotMultiply","divide"]},PC={name:"dotMultiply",category:"Operators",syntax:["x .* y","dotMultiply(x, y)"],description:"Multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","dotDivide"]},UC={name:"dotPow",category:"Operators",syntax:["x .^ y","dotPow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]},LC={name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["expm","expm1","pow","log"]},kC={name:"expm",category:"Arithmetic",syntax:["exp(x)"],description:"Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",examples:["expm([[0,2],[0,0]])"],seealso:["exp"]},VC={name:"expm1",category:"Arithmetic",syntax:["expm1(x)"],description:"Calculate the value of subtracting 1 from the exponential value.",examples:["expm1(2)","pow(e, 2) - 1","log(expm1(2) + 1)"],seealso:["exp","pow","log"]},GC={name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]},HC={name:"floor",category:"Arithmetic",syntax:["floor(x)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)"],seealso:["ceil","fix","round"]},ZC={name:"gcd",category:"Arithmetic",syntax:["gcd(a, b)","gcd(a, b, c, ...)"],description:"Compute the greatest common divisor.",examples:["gcd(8, 12)","gcd(-4, 6)","gcd(25, 15, -10)"],seealso:["lcm","xgcd"]},JC={name:"hypot",category:"Arithmetic",syntax:["hypot(a, b, c, ...)","hypot([a, b, c, ...])"],description:"Calculate the hypotenusa of a list with values. ",examples:["hypot(3, 4)","sqrt(3^2 + 4^2)","hypot(-2)","hypot([3, 4, 5])"],seealso:["abs","norm"]},XC={name:"invmod",category:"Arithmetic",syntax:["invmod(a, b)"],description:"Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax \u2263 1 (mod b)",examples:["invmod(8, 12)=NaN","invmod(7, 13)=2","invmod(15151, 15122)=10429"],seealso:["gcd","xgcd"]},WC={name:"lcm",category:"Arithmetic",syntax:["lcm(x, y)"],description:"Compute the least common multiple.",examples:["lcm(4, 6)","lcm(6, 21)","lcm(6, 21, 5)"],seealso:["gcd"]},YC={name:"log",category:"Arithmetic",syntax:["log(x)","log(x, base)"],description:"Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",examples:["log(3.5)","a = log(2.4)","exp(a)","10 ^ 4","log(10000, 10)","log(10000) / log(10)","b = log(1024, 2)","2 ^ b"],seealso:["exp","log1p","log2","log10"]},QC={name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(0.00001)","log10(10000)","10 ^ 4","log(10000) / log(10)","log(10000, 10)"],seealso:["exp","log"]},KC={name:"log1p",category:"Arithmetic",syntax:["log1p(x)","log1p(x, base)"],description:"Calculate the logarithm of a `value+1`",examples:["log1p(2.5)","exp(log1p(1.4))","pow(10, 4)","log1p(9999, 10)","log1p(9999) / log(10)"],seealso:["exp","log","log2","log10"]},jC={name:"log2",category:"Arithmetic",syntax:["log2(x)"],description:"Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",examples:["log2(0.03125)","log2(16)","log2(16) / log2(2)","pow(2, 4)"],seealso:["exp","log1p","log","log10"]},eM={name:"mod",category:"Operators",syntax:["x % y","x mod y","mod(x, y)"],description:"Calculates the modulus, the remainder of an integer division.",examples:["7 % 3","11 % 2","10 mod 4","isOdd(x) = x % 2","isOdd(2)","isOdd(3)"],seealso:["divide"]},rM={name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["a = 2.1 * 3.4","a / 3.4","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]},tM={name:"norm",category:"Arithmetic",syntax:["norm(x)","norm(x, p)"],description:"Calculate the norm of a number, vector or matrix.",examples:["abs(-3.5)","norm(-3.5)","norm(3 - 4i)","norm([1, 2, -3], Infinity)","norm([1, 2, -3], -Infinity)","norm([3, 4], 2)","norm([[1, 2], [3, 4]], 1)",'norm([[1, 2], [3, 4]], "inf")','norm([[1, 2], [3, 4]], "fro")']},nM={name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["nthRoots","pow","sqrt"]},aM={name:"nthRoots",category:"Arithmetic",syntax:["nthRoots(A)","nthRoots(A, root)"],description:'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',examples:["nthRoots(1)","nthRoots(1, 3)"],seealso:["sqrt","pow","nthRoot"]},iM={name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3","2*2*2","1 + e ^ (pi * i)","pow([[1, 2], [4, 3]], 2)","pow([[1, 2], [4, 3]], -1)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},oM={name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)"],seealso:["ceil","floor","fix"]},sM={name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},uM={name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},lM={name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[33, 24], [48, 57]])"],seealso:["sqrt","abs","square","multiply"]},cM={name:"sylvester",category:"Matrix",syntax:["sylvester(A,B,C)"],description:"Solves the real-valued Sylvester equation AX+XB=C for X",examples:["sylvester([[-1, -2], [1, 1]], [[-2, 1], [-1, 2]], [[-3, 2], [3, 0]])","sylvester(A,B,C)"],seealso:["schur","lyap"]},fM={name:"schur",category:"Matrix",syntax:["schur(A)"],description:"Performs a real Schur decomposition of the real matrix A = UTU'",examples:["schur([[1, 0], [-4, 3]])","schur(A)"],seealso:["lyap","sylvester"]},mM={name:"lyap",category:"Matrix",syntax:["lyap(A,Q)"],description:"Solves the Continuous-time Lyapunov equation AP+PA'+Q=0 for P",examples:["lyap([[-2, 0], [1, -4]], [[3, 1], [1, 3]])","lyap(A,Q)"],seealso:["schur","sylvester"]},vM={name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},pM={name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},hM={name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},dM={name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},gM={name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},yM={name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bM={name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},xM={name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},wM={name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},NM={name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},DM={name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},AM={name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},EM={name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},SM={name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},CM={name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},MM={name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},FM={name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},TM={name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},BM={name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},$M={name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},OM={name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(" + 4 + ")")'],seealso:[]},IM={name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},RM={name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])","distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},_M={name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},qM={name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},zM={name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},PM={name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},UM={name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},LM={name:"column",category:"Matrix",syntax:["column(x, index)"],description:"Return a column from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","column(A, 1)","column(A, 2)"],seealso:["row","matrixFromColumns"]},kM={name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},VM={name:"count",category:"Matrix",syntax:["count(x)"],description:"Count the number of elements of a matrix, array or string.",examples:["a = [1, 2; 3, 4; 5, 6]","count(a)","size(a)",'count("hello world")'],seealso:["size"]},GM={name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},HM={name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},ZM={name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},JM={name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},XM={name:"diff",category:"Matrix",syntax:["diff(arr)","diff(arr, dim)"],description:["Create a new matrix or array with the difference of the passed matrix or array.","Dim parameter is optional and used to indicant the dimension of the array/matrix to apply the difference","If no dimension parameter is passed it is assumed as dimension 0","Dimension is zero-based in javascript and one-based in the parser","Arrays must be 'rectangular' meaning arrays like [1, 2]","If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],examples:["diff([1, 2, 4, 7, 0])","diff([1, 2, 4, 7, 0], 0)","diff(matrix([1, 2, 4, 7, 0]))","diff([[1, 2], [3, 4]])","diff([[1, 2], [3, 4]], 0)","diff([[1, 2], [3, 4]], 1)","diff([[1, 2], [3, 4]], bignumber(1))","diff(matrix([[1, 2], [3, 4]]), 1)","diff([[1, 2], matrix([3, 4])], 1)"],seealso:["subtract","partitionSelect"]},WM={name:"dot",category:"Matrix",syntax:["dot(A, B)","A * B"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]},YM={name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and eigenvectors of a real symmetric matrix",examples:["eigs([[5, 2.3], [2.3, 1]])"],seealso:["inv"]},QM={name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},KM={name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]},jM={name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["numberOfPets = {}","addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;",'forEach(["Dog","Cat","Cat"], addPet)',"numberOfPets"],seealso:["map","sort","filter"]},e3={name:"getMatrixDataType",category:"Matrix",syntax:["getMatrixDataType(x)"],description:'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',examples:["getMatrixDataType([1, 2, 3])","getMatrixDataType([[5 cm], [2 inch]])",'getMatrixDataType([1, "text"])',"getMatrixDataType([1, bignumber(4)])"],seealso:["matrix","sparse","typeOf"]},r3={name:"identity",category:"Matrix",syntax:["identity(n)","identity(m, n)","identity([m, n])"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["identity(3)","identity(3, 5)","a = [1, 2, 3; 4, 5, 6]","identity(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},t3={name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","identity","ones","range","size","squeeze","subset","trace","transpose","zeros"]},n3={name:"pinv",category:"Matrix",syntax:["pinv(x)"],description:"Calculate the Moore\u2013Penrose inverse of a matrix",examples:["pinv([1, 2; 3, 4])","pinv([[1, 0], [0, 1], [0, 1]])","pinv(4)"],seealso:["inv"]},a3={name:"kron",category:"Matrix",syntax:["kron(x, y)"],description:"Calculates the kronecker product of 2 matrices or vectors.",examples:["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])","kron([1,1], [2,3,4])"],seealso:["multiply","dot","cross"]},i3={name:"map",category:"Matrix",syntax:["map(x, callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",examples:["map([1, 2, 3], square)"],seealso:["filter","forEach"]},o3={name:"matrixFromColumns",category:"Matrix",syntax:["matrixFromColumns(...arr)","matrixFromColumns(row1, row2)","matrixFromColumns(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual columns.",examples:["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromRows","matrixFromFunction","zeros"]},s3={name:"matrixFromFunction",category:"Matrix",syntax:["matrixFromFunction(size, fn)","matrixFromFunction(size, fn, format)","matrixFromFunction(size, fn, format, datatype)","matrixFromFunction(size, format, fn)","matrixFromFunction(size, format, datatype, fn)"],description:"Create a matrix by evaluating a generating function at each index.",examples:["f(I) = I[1] - I[2]","matrixFromFunction([3,3], f)","g(I) = I[1] - I[2] == 1 ? 4 : 0",'matrixFromFunction([100, 100], "sparse", g)',"matrixFromFunction([5], random)"],seealso:["matrix","matrixFromRows","matrixFromColumns","zeros"]},u3={name:"matrixFromRows",category:"Matrix",syntax:["matrixFromRows(...arr)","matrixFromRows(row1, row2)","matrixFromRows(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual rows.",examples:["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromColumns","matrixFromFunction","zeros"]},l3={name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","identity","inv","range","size","squeeze","subset","trace","transpose","zeros"]},c3={name:"partitionSelect",category:"Matrix",syntax:["partitionSelect(x, k)","partitionSelect(x, k, compare)"],description:"Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",examples:["partitionSelect([5, 10, 1], 2)",'partitionSelect(["C", "B", "A", "D"], 1, compareText)',"arr = [5, 2, 1]","partitionSelect(arr, 0) # returns 1, arr is now: [1, 2, 5]","arr","partitionSelect(arr, 1, 'desc') # returns 2, arr is now: [5, 2, 1]","arr"],seealso:["sort"]},f3={name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","identity","inv","ones","size","squeeze","subset","trace","transpose","zeros"]},m3={name:"reshape",category:"Matrix",syntax:["reshape(x, sizes)"],description:"Reshape a multi dimensional array to fit the specified dimensions.",examples:["reshape([1, 2, 3, 4, 5, 6], [2, 3])","reshape([[1, 2], [3, 4]], [1, 4])","reshape([[1, 2], [3, 4]], [4])","reshape([1, 2, 3, 4], [-1, 2])"],seealso:["size","squeeze","resize"]},v3={name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze","reshape"]},p3={name:"rotate",category:"Matrix",syntax:["rotate(w, theta)","rotate(w, theta, v)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotate([1, 0], pi / 2)",'rotate(matrix([1, 0]), unit("35deg"))','rotate([1, 0, 0], unit("90deg"), [0, 0, 1])','rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],seealso:["matrix","rotationMatrix"]},h3={name:"rotationMatrix",category:"Matrix",syntax:["rotationMatrix(theta)","rotationMatrix(theta, v)","rotationMatrix(theta, v, format)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotationMatrix(pi / 2)",'rotationMatrix(unit("45deg"), [0, 0, 1])','rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],seealso:["cos","sin"]},d3={name:"row",category:"Matrix",syntax:["row(x, index)"],description:"Return a row from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","row(A, 1)","row(A, 2)"],seealso:["column","matrixFromRows"]},g3={name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","count","det","diag","identity","inv","ones","range","squeeze","subset","trace","transpose","zeros"]},y3={name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"], "natural")',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},b3={name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","identity","inv","ones","range","size","subset","trace","transpose","zeros"]},x3={name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation `l:u`. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]","f[[1,2], [1,3]] = [9, 10; 11, 12]","f"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},w3={name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","transpose","zeros"]},N3={name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},D3={name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose"]},A3={name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},E3={name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},S3={name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},C3={name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"],seealso:["combinations","permutations","factorial"]},M3={name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},F3={name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},T3={name:"lgamma",category:"Probability",syntax:["lgamma(n)"],description:"Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.",examples:["lgamma(4)","lgamma(1/2)","lgamma(i)","lgamma(complex(1.1, 2))"],seealso:["gamma"]},B3={name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},$3={name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},O3={name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},I3={name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)","pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])","pickRandom([1, 3, 1, 6], 2)","pickRandom([1, 3, 1, 6], [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],seealso:["random","randomInt"]},R3={name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]},_3={name:"randomInt",category:"Probability",syntax:["randomInt(max)","randomInt(min, max)","randomInt(size)","randomInt(size, max)","randomInt(size, min, max)"],description:"Return a random integer number",examples:["randomInt(10, 20)","randomInt([2, 3], 10)"],seealso:["pickRandom","random"]},q3={name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compareNatural","compareText"]},z3={name:"compareNatural",category:"Relational",syntax:["compareNatural(x, y)"],description:"Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compareNatural(2, 3)","compareNatural(3, 2)","compareNatural(2, 2)","compareNatural(5cm, 40mm)",'compareNatural("2", "10")',"compareNatural(2 + 3i, 2 + 4i)","compareNatural([1, 2, 4], [1, 2, 3])","compareNatural([1, 5], [1, 2, 3])","compareNatural([1, 2], [1, 2])","compareNatural({a: 2}, {a: 4})"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare","compareText"]},P3={name:"compareText",category:"Relational",syntax:["compareText(x, y)"],description:"Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:['compareText("B", "A")','compareText("A", "B")','compareText("A", "A")','compareText("2", "10")','compare("2", "10")',"compare(2, 10)",'compareNatural("2", "10")','compareText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural"]},U3={name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["deepEqual([1,3,4], [1,3,4])","deepEqual([1,3,4], [1,3])"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]},L3={name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual","equalText"]},k3={name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},V3={name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},G3={name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},H3={name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},Z3={name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 <= 1+1","2 < 1+1","a = 3.2","b = 6-2.8","(a <= b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]},J3={name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]},X3={name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays and the values will be sorted in ascending order before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},W3={name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},Y3={name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},Q3={name:"setIntersect",category:"Set",syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},K3={name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},j3={name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]},eF={name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},rF={name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},tF={name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setDifference"]},nF={name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},aF={name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},iF={name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},oF={name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dimension)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},sF={name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dimension)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},uF={name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},lF={name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dimension)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},cF={name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},fF={name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},mF={name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:`Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber.
|
|
69
|
+
`),n},t.prototype.toJSON=function(){var a=Ge(this.doc);return a.mathjs="Help",a},t.fromJSON=function(a){var n={};return Object.keys(a).filter(i=>i!=="mathjs").forEach(i=>{n[i]=a[i]}),new t(n)},t.prototype.valueOf=t.prototype.toString,t},{isClass:!0}),GS="Chain",HS=["?on","math","typed"],ZS=q(GS,HS,r=>{var{on:e,math:t,typed:a}=r;function n(u){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");ul(u)?this.value=u.value:this.value=u}n.prototype.type="Chain",n.prototype.isChain=!0,n.prototype.done=function(){return this.value},n.prototype.valueOf=function(){return this.value},n.prototype.toString=function(){return Ye(this.value)},n.prototype.toJSON=function(){return{mathjs:"Chain",value:this.value}},n.fromJSON=function(u){return new n(u.value)};function i(u,s){typeof s=="function"&&(n.prototype[u]=f(s))}function o(u,s){X0(n.prototype,u,function(){var m=s();if(typeof m=="function")return f(m)})}function f(u){return function(){if(arguments.length===0)return new n(u(this.value));for(var s=[this.value],c=0;c<arguments.length;c++)s[c+1]=arguments[c];if(a.isTypedFunction(u)){var m=a.resolve(u,s);if(m.params.length===1)throw new Error("chain function "+u.name+" cannot match rest parameter between chain value and additional arguments.");return new n(m.implementation.apply(u,s))}return new n(u.apply(u,s))}}n.createProxy=function(u,s){if(typeof u=="string")i(u,s);else{var c=function(h){Re(u,h)&&l[h]===void 0&&o(h,()=>u[h])};for(var m in u)c(m)}};var l={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return n.createProxy(t),e&&e("import",function(u,s,c){c||o(u,s)}),n},{isClass:!0}),gp={name:"e",category:"Constants",syntax:["e"],description:"Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",examples:["e","e ^ 2","exp(2)","log(e)"],seealso:["exp"]},JS={name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},XS={name:"i",category:"Constants",syntax:["i"],description:"Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",examples:["i","i * i","sqrt(-1)"],seealso:[]},WS={name:"Infinity",category:"Constants",syntax:["Infinity"],description:"Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",examples:["Infinity","1 / 0"],seealso:[]},YS={name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},QS={name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},KS={name:"LOG10E",category:"Constants",syntax:["LOG10E"],description:"Returns the base-10 logarithm of E, approximately equal to 0.434",examples:["LOG10E","log(e, 10)"],seealso:[]},jS={name:"LOG2E",category:"Constants",syntax:["LOG2E"],description:"Returns the base-2 logarithm of E, approximately equal to 1.442",examples:["LOG2E","log(e, 2)"],seealso:[]},eC={name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},rC={name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},tC={name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["phi"],seealso:[]},yp={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]},nC={name:"SQRT1_2",category:"Constants",syntax:["SQRT1_2"],description:"Returns the square root of 1/2, approximately equal to 0.707",examples:["SQRT1_2","sqrt(1/2)"],seealso:[]},aC={name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},iC={name:"tau",category:"Constants",syntax:["tau"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]},oC={name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},sC={name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},uC={name:"bignumber",category:"Construction",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","complex","fraction","index","matrix","string","unit"]},lC={name:"boolean",category:"Construction",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]},cC={name:"complex",category:"Construction",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]},fC={name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.",examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]},mC={name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(matrix)","fraction(num,den)","fraction({n: num, d: den})"],description:"Create a fraction from a number or from integer numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)","fraction({n: 333, d: 53})","fraction([sqrt(9), sqrt(10), sqrt(11)])"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},vC={name:"index",category:"Construction",syntax:["[start]","[start:end]","[start:step:end]","[start1, start 2, ...]","[start1:end1, start2:end2, ...]","[start1:step1:end1, start2:step2:end2, ...]"],description:"Create an index to get or replace a subset of a matrix",examples:["[1, 2, 3]","A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[1:2, 1:2] = ones(2, 2)"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]},pC={name:"matrix",category:"Construction",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()",'matrix("dense")',"matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])",'matrix([3, 4; 5, 6], "sparse")','matrix([3, 4; 5, 6], "sparse", "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","sparse"]},hC={name:"number",category:"Construction",syntax:["x","number(x)","number(unit, valuelessUnit)"],description:"Create a number or convert a string or boolean into a number.",examples:["2","2e3","4.05","number(2)",'number("7.2")',"number(true)","number([true, false, true, true])",'number(unit("52cm"), "m")'],seealso:["bignumber","boolean","complex","fraction","index","matrix","string","unit"]},dC={name:"sparse",category:"Construction",syntax:["sparse()","sparse([a1, b1, ...; a1, b2, ...])",'sparse([a1, b1, ...; a1, b2, ...], "number")'],description:"Create a sparse matrix.",examples:["sparse()","sparse([3, 4; 5, 6])",'sparse([3, 0; 5, 0], "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","matrix"]},gC={name:"splitUnit",category:"Construction",syntax:["splitUnit(unit: Unit, parts: Unit[])"],description:"Split a unit in an array of units whose sum is equal to the original unit.",examples:['splitUnit(1 m, ["feet", "inch"])'],seealso:["unit","createUnit"]},yC={name:"string",category:"Construction",syntax:['"text"',"string(x)"],description:"Create a string or convert a value to a string",examples:['"Hello World!"',"string(4.2)","string(3 + 2i)"],seealso:["bignumber","boolean","complex","index","matrix","number","unit"]},bC={name:"unit",category:"Construction",syntax:["value unit","unit(value, unit)","unit(string)"],description:"Create a unit.",examples:["5.5 mm","3 inch",'unit(7.1, "kilogram")','unit("23 deg")'],seealso:["bignumber","boolean","complex","index","matrix","number","string"]},xC={name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},wC={name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},NC={name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},DC={name:"derivative",category:"Algebra",syntax:["derivative(expr, variable)","derivative(expr, variable, {simplify: boolean})"],description:"Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",examples:['derivative("2x^3", "x")','derivative("2x^3", "x", {simplify: false})','derivative("2x^2 + 3x + 4", "x")','derivative("sin(2x)", "x")','f = parse("x^2 + x")','x = parse("x")',"df = derivative(f, x)","df.evaluate({x: 3})"],seealso:["simplify","parse","evaluate"]},AC={name:"leafCount",category:"Algebra",syntax:["leafCount(expr)"],description:"Computes the number of leaves in the parse tree of the given expression",examples:['leafCount("e^(i*pi)-1")','leafCount(parse("{a: 22/7, b: 10^(1/2)}"))'],seealso:["simplify"]},EC={name:"lsolve",category:"Algebra",syntax:["x=lsolve(L, b)"],description:"Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolveAll","lup","lusolve","usolve","matrix","sparse"]},SC={name:"lsolveAll",category:"Algebra",syntax:["x=lsolveAll(L, b)"],description:"Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolve","lup","lusolve","usolve","matrix","sparse"]},CC={name:"lup",category:"Algebra",syntax:["lup(m)"],description:"Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",examples:["lup([[2, 1], [1, 4]])","lup(matrix([[2, 1], [1, 4]]))","lup(sparse([[2, 1], [1, 4]]))"],seealso:["lusolve","lsolve","usolve","matrix","sparse","slu","qr"]},MC={name:"lusolve",category:"Algebra",syntax:["x=lusolve(A, b)","x=lusolve(lu, b)"],description:"Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lusolve(a, b)"],seealso:["lup","slu","lsolve","usolve","matrix","sparse"]},FC={name:"polynomialRoot",category:"Algebra",syntax:["x=polynomialRoot(-6, 3)","x=polynomialRoot(4, -4, 1)","x=polynomialRoot(-8, 12, -6, 1)"],description:"Finds the roots of a univariate polynomial given by its coefficients starting from constant, linear, and so on, increasing in degree.",examples:["a = polynomialRoot(-6, 11, -6 1)"],seealso:["cbrt","sqrt"]},TC={name:"qr",category:"Algebra",syntax:["qr(A)"],description:"Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",examples:["qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])"],seealso:["lup","slu","matrix"]},BC={name:"rationalize",category:"Algebra",syntax:["rationalize(expr)","rationalize(expr, scope)","rationalize(expr, scope, detailed)"],description:"Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",examples:['rationalize("2x/y - y/(x+1)")','rationalize("2x/y - y/(x+1)", true)'],seealso:["simplify"]},$C={name:"resolve",category:"Algebra",syntax:["resolve(node, scope)"],description:"Recursively substitute variables in an expression tree.",examples:['resolve(parse("1 + x"), { x: 7 })','resolve(parse("size(text)"), { text: "Hello World" })','resolve(parse("x + y"), { x: parse("3z") })','resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })'],seealso:["simplify","evaluate"],mayThrow:["ReferenceError"]},OC={name:"simplify",category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["simplifyCore","derivative","evaluate","parse","rationalize","resolve"]},IC={name:"simplifyConstant",category:"Algebra",syntax:["simplifyConstant(expr)","simplifyConstant(expr, options)"],description:"Replace constant subexpressions of node with their values.",examples:['simplifyConatant("(3-3)*x")','simplifyConstant(parse("z-cos(tau/8)"))'],seealso:["simplify","simplifyCore","evaluate"]},RC={name:"simplifyCore",category:"Algebra",syntax:["simplifyCore(node)"],description:"Perform simple one-pass simplifications on an expression tree.",examples:['simplifyCore(parse("0*x"))','simplifyCore(parse("(x+0)*2"))'],seealso:["simplify","simplifyConstant","evaluate"]},_C={name:"slu",category:"Algebra",syntax:["slu(A, order, threshold)"],description:"Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",examples:["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],seealso:["lusolve","lsolve","usolve","matrix","sparse","lup","qr"]},qC={name:"symbolicEqual",category:"Algebra",syntax:["symbolicEqual(expr1, expr2)","symbolicEqual(expr1, expr2, options)"],description:"Returns true if the difference of the expressions simplifies to 0",examples:['symbolicEqual("x*y","y*x")','symbolicEqual("abs(x^2)", "x^2")','symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})'],seealso:["simplify","evaluate"]},zC={name:"usolve",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolveAll","lup","lusolve","lsolve","matrix","sparse"]},PC={name:"usolveAll",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolve","lup","lusolve","lsolve","matrix","sparse"]},UC={name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},LC={name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i","3 cm + 2 inch",'"2.3" + "4"'],seealso:["subtract"]},kC={name:"cbrt",category:"Arithmetic",syntax:["cbrt(x)","cbrt(x, allRoots)"],description:"Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",examples:["cbrt(64)","cube(4)","cbrt(-8)","cbrt(2 + 3i)","cbrt(8i)","cbrt(8i, true)","cbrt(27 m^3)"],seealso:["square","sqrt","cube","multiply"]},VC={name:"ceil",category:"Arithmetic",syntax:["ceil(x)"],description:"Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)"],seealso:["floor","fix","round"]},GC={name:"cube",category:"Arithmetic",syntax:["cube(x)"],description:"Compute the cube of a value. The cube of x is x * x * x.",examples:["cube(2)","2^3","2 * 2 * 2"],seealso:["multiply","square","pow"]},HC={name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["a = 2 / 3","a * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]},ZC={name:"dotDivide",category:"Operators",syntax:["x ./ y","dotDivide(x, y)"],description:"Divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","dotMultiply","divide"]},JC={name:"dotMultiply",category:"Operators",syntax:["x .* y","dotMultiply(x, y)"],description:"Multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","dotDivide"]},XC={name:"dotPow",category:"Operators",syntax:["x .^ y","dotPow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]},WC={name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["expm","expm1","pow","log"]},YC={name:"expm",category:"Arithmetic",syntax:["exp(x)"],description:"Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",examples:["expm([[0,2],[0,0]])"],seealso:["exp"]},QC={name:"expm1",category:"Arithmetic",syntax:["expm1(x)"],description:"Calculate the value of subtracting 1 from the exponential value.",examples:["expm1(2)","pow(e, 2) - 1","log(expm1(2) + 1)"],seealso:["exp","pow","log"]},KC={name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]},jC={name:"floor",category:"Arithmetic",syntax:["floor(x)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)"],seealso:["ceil","fix","round"]},eM={name:"gcd",category:"Arithmetic",syntax:["gcd(a, b)","gcd(a, b, c, ...)"],description:"Compute the greatest common divisor.",examples:["gcd(8, 12)","gcd(-4, 6)","gcd(25, 15, -10)"],seealso:["lcm","xgcd"]},rM={name:"hypot",category:"Arithmetic",syntax:["hypot(a, b, c, ...)","hypot([a, b, c, ...])"],description:"Calculate the hypotenusa of a list with values. ",examples:["hypot(3, 4)","sqrt(3^2 + 4^2)","hypot(-2)","hypot([3, 4, 5])"],seealso:["abs","norm"]},tM={name:"invmod",category:"Arithmetic",syntax:["invmod(a, b)"],description:"Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax \u2263 1 (mod b)",examples:["invmod(8, 12)=NaN","invmod(7, 13)=2","invmod(15151, 15122)=10429"],seealso:["gcd","xgcd"]},nM={name:"lcm",category:"Arithmetic",syntax:["lcm(x, y)"],description:"Compute the least common multiple.",examples:["lcm(4, 6)","lcm(6, 21)","lcm(6, 21, 5)"],seealso:["gcd"]},aM={name:"log",category:"Arithmetic",syntax:["log(x)","log(x, base)"],description:"Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",examples:["log(3.5)","a = log(2.4)","exp(a)","10 ^ 4","log(10000, 10)","log(10000) / log(10)","b = log(1024, 2)","2 ^ b"],seealso:["exp","log1p","log2","log10"]},iM={name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(0.00001)","log10(10000)","10 ^ 4","log(10000) / log(10)","log(10000, 10)"],seealso:["exp","log"]},oM={name:"log1p",category:"Arithmetic",syntax:["log1p(x)","log1p(x, base)"],description:"Calculate the logarithm of a `value+1`",examples:["log1p(2.5)","exp(log1p(1.4))","pow(10, 4)","log1p(9999, 10)","log1p(9999) / log(10)"],seealso:["exp","log","log2","log10"]},sM={name:"log2",category:"Arithmetic",syntax:["log2(x)"],description:"Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",examples:["log2(0.03125)","log2(16)","log2(16) / log2(2)","pow(2, 4)"],seealso:["exp","log1p","log","log10"]},uM={name:"mod",category:"Operators",syntax:["x % y","x mod y","mod(x, y)"],description:"Calculates the modulus, the remainder of an integer division.",examples:["7 % 3","11 % 2","10 mod 4","isOdd(x) = x % 2","isOdd(2)","isOdd(3)"],seealso:["divide"]},lM={name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["a = 2.1 * 3.4","a / 3.4","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]},cM={name:"norm",category:"Arithmetic",syntax:["norm(x)","norm(x, p)"],description:"Calculate the norm of a number, vector or matrix.",examples:["abs(-3.5)","norm(-3.5)","norm(3 - 4i)","norm([1, 2, -3], Infinity)","norm([1, 2, -3], -Infinity)","norm([3, 4], 2)","norm([[1, 2], [3, 4]], 1)",'norm([[1, 2], [3, 4]], "inf")','norm([[1, 2], [3, 4]], "fro")']},fM={name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["nthRoots","pow","sqrt"]},mM={name:"nthRoots",category:"Arithmetic",syntax:["nthRoots(A)","nthRoots(A, root)"],description:'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',examples:["nthRoots(1)","nthRoots(1, 3)"],seealso:["sqrt","pow","nthRoot"]},vM={name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3","2*2*2","1 + e ^ (pi * i)","pow([[1, 2], [4, 3]], 2)","pow([[1, 2], [4, 3]], -1)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},pM={name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)"],seealso:["ceil","floor","fix"]},hM={name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},dM={name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},gM={name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[33, 24], [48, 57]])"],seealso:["sqrt","abs","square","multiply"]},yM={name:"sylvester",category:"Matrix",syntax:["sylvester(A,B,C)"],description:"Solves the real-valued Sylvester equation AX+XB=C for X",examples:["sylvester([[-1, -2], [1, 1]], [[-2, 1], [-1, 2]], [[-3, 2], [3, 0]])","sylvester(A,B,C)"],seealso:["schur","lyap"]},bM={name:"schur",category:"Matrix",syntax:["schur(A)"],description:"Performs a real Schur decomposition of the real matrix A = UTU'",examples:["schur([[1, 0], [-4, 3]])","schur(A)"],seealso:["lyap","sylvester"]},xM={name:"lyap",category:"Matrix",syntax:["lyap(A,Q)"],description:"Solves the Continuous-time Lyapunov equation AP+PA'+Q=0 for P",examples:["lyap([[-2, 0], [1, -4]], [[3, 1], [1, 3]])","lyap(A,Q)"],seealso:["schur","sylvester"]},wM={name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},NM={name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},DM={name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},AM={name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},EM={name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},SM={name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},CM={name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},MM={name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},FM={name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},TM={name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},BM={name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},$M={name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},OM={name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},IM={name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},RM={name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},_M={name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},qM={name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},zM={name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},PM={name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},UM={name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},LM={name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(" + 4 + ")")'],seealso:[]},kM={name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},VM={name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])","distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},GM={name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},HM={name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},ZM={name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},JM={name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},XM={name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},WM={name:"column",category:"Matrix",syntax:["column(x, index)"],description:"Return a column from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","column(A, 1)","column(A, 2)"],seealso:["row","matrixFromColumns"]},YM={name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},QM={name:"count",category:"Matrix",syntax:["count(x)"],description:"Count the number of elements of a matrix, array or string.",examples:["a = [1, 2; 3, 4; 5, 6]","count(a)","size(a)",'count("hello world")'],seealso:["size"]},KM={name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},jM={name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},e3={name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},r3={name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},t3={name:"diff",category:"Matrix",syntax:["diff(arr)","diff(arr, dim)"],description:["Create a new matrix or array with the difference of the passed matrix or array.","Dim parameter is optional and used to indicant the dimension of the array/matrix to apply the difference","If no dimension parameter is passed it is assumed as dimension 0","Dimension is zero-based in javascript and one-based in the parser","Arrays must be 'rectangular' meaning arrays like [1, 2]","If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],examples:["diff([1, 2, 4, 7, 0])","diff([1, 2, 4, 7, 0], 0)","diff(matrix([1, 2, 4, 7, 0]))","diff([[1, 2], [3, 4]])","diff([[1, 2], [3, 4]], 0)","diff([[1, 2], [3, 4]], 1)","diff([[1, 2], [3, 4]], bignumber(1))","diff(matrix([[1, 2], [3, 4]]), 1)","diff([[1, 2], matrix([3, 4])], 1)"],seealso:["subtract","partitionSelect"]},n3={name:"dot",category:"Matrix",syntax:["dot(A, B)","A * B"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]},a3={name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and eigenvectors of a real symmetric matrix",examples:["eigs([[5, 2.3], [2.3, 1]])"],seealso:["inv"]},i3={name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},o3={name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]},s3={name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["numberOfPets = {}","addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;",'forEach(["Dog","Cat","Cat"], addPet)',"numberOfPets"],seealso:["map","sort","filter"]},u3={name:"getMatrixDataType",category:"Matrix",syntax:["getMatrixDataType(x)"],description:'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',examples:["getMatrixDataType([1, 2, 3])","getMatrixDataType([[5 cm], [2 inch]])",'getMatrixDataType([1, "text"])',"getMatrixDataType([1, bignumber(4)])"],seealso:["matrix","sparse","typeOf"]},l3={name:"identity",category:"Matrix",syntax:["identity(n)","identity(m, n)","identity([m, n])"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["identity(3)","identity(3, 5)","a = [1, 2, 3; 4, 5, 6]","identity(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},c3={name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","identity","ones","range","size","squeeze","subset","trace","transpose","zeros"]},f3={name:"pinv",category:"Matrix",syntax:["pinv(x)"],description:"Calculate the Moore\u2013Penrose inverse of a matrix",examples:["pinv([1, 2; 3, 4])","pinv([[1, 0], [0, 1], [0, 1]])","pinv(4)"],seealso:["inv"]},m3={name:"kron",category:"Matrix",syntax:["kron(x, y)"],description:"Calculates the kronecker product of 2 matrices or vectors.",examples:["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])","kron([1,1], [2,3,4])"],seealso:["multiply","dot","cross"]},v3={name:"map",category:"Matrix",syntax:["map(x, callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",examples:["map([1, 2, 3], square)"],seealso:["filter","forEach"]},p3={name:"matrixFromColumns",category:"Matrix",syntax:["matrixFromColumns(...arr)","matrixFromColumns(row1, row2)","matrixFromColumns(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual columns.",examples:["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromRows","matrixFromFunction","zeros"]},h3={name:"matrixFromFunction",category:"Matrix",syntax:["matrixFromFunction(size, fn)","matrixFromFunction(size, fn, format)","matrixFromFunction(size, fn, format, datatype)","matrixFromFunction(size, format, fn)","matrixFromFunction(size, format, datatype, fn)"],description:"Create a matrix by evaluating a generating function at each index.",examples:["f(I) = I[1] - I[2]","matrixFromFunction([3,3], f)","g(I) = I[1] - I[2] == 1 ? 4 : 0",'matrixFromFunction([100, 100], "sparse", g)',"matrixFromFunction([5], random)"],seealso:["matrix","matrixFromRows","matrixFromColumns","zeros"]},d3={name:"matrixFromRows",category:"Matrix",syntax:["matrixFromRows(...arr)","matrixFromRows(row1, row2)","matrixFromRows(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual rows.",examples:["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromColumns","matrixFromFunction","zeros"]},g3={name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","identity","inv","range","size","squeeze","subset","trace","transpose","zeros"]},y3={name:"partitionSelect",category:"Matrix",syntax:["partitionSelect(x, k)","partitionSelect(x, k, compare)"],description:"Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",examples:["partitionSelect([5, 10, 1], 2)",'partitionSelect(["C", "B", "A", "D"], 1, compareText)',"arr = [5, 2, 1]","partitionSelect(arr, 0) # returns 1, arr is now: [1, 2, 5]","arr","partitionSelect(arr, 1, 'desc') # returns 2, arr is now: [5, 2, 1]","arr"],seealso:["sort"]},b3={name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","identity","inv","ones","size","squeeze","subset","trace","transpose","zeros"]},x3={name:"reshape",category:"Matrix",syntax:["reshape(x, sizes)"],description:"Reshape a multi dimensional array to fit the specified dimensions.",examples:["reshape([1, 2, 3, 4, 5, 6], [2, 3])","reshape([[1, 2], [3, 4]], [1, 4])","reshape([[1, 2], [3, 4]], [4])","reshape([1, 2, 3, 4], [-1, 2])"],seealso:["size","squeeze","resize"]},w3={name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze","reshape"]},N3={name:"rotate",category:"Matrix",syntax:["rotate(w, theta)","rotate(w, theta, v)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotate([1, 0], pi / 2)",'rotate(matrix([1, 0]), unit("35deg"))','rotate([1, 0, 0], unit("90deg"), [0, 0, 1])','rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],seealso:["matrix","rotationMatrix"]},D3={name:"rotationMatrix",category:"Matrix",syntax:["rotationMatrix(theta)","rotationMatrix(theta, v)","rotationMatrix(theta, v, format)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotationMatrix(pi / 2)",'rotationMatrix(unit("45deg"), [0, 0, 1])','rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],seealso:["cos","sin"]},A3={name:"row",category:"Matrix",syntax:["row(x, index)"],description:"Return a row from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","row(A, 1)","row(A, 2)"],seealso:["column","matrixFromRows"]},E3={name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","count","det","diag","identity","inv","ones","range","squeeze","subset","trace","transpose","zeros"]},S3={name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"], "natural")',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},C3={name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","identity","inv","ones","range","size","subset","trace","transpose","zeros"]},M3={name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation `l:u`. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]","f[[1,2], [1,3]] = [9, 10; 11, 12]","f"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},F3={name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","transpose","zeros"]},T3={name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},B3={name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose"]},$3={name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},O3={name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},I3={name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},R3={name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"],seealso:["combinations","permutations","factorial"]},_3={name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},q3={name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},z3={name:"lgamma",category:"Probability",syntax:["lgamma(n)"],description:"Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.",examples:["lgamma(4)","lgamma(1/2)","lgamma(i)","lgamma(complex(1.1, 2))"],seealso:["gamma"]},P3={name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},U3={name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},L3={name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},k3={name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)","pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])","pickRandom([1, 3, 1, 6], 2)","pickRandom([1, 3, 1, 6], [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],seealso:["random","randomInt"]},V3={name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]},G3={name:"randomInt",category:"Probability",syntax:["randomInt(max)","randomInt(min, max)","randomInt(size)","randomInt(size, max)","randomInt(size, min, max)"],description:"Return a random integer number",examples:["randomInt(10, 20)","randomInt([2, 3], 10)"],seealso:["pickRandom","random"]},H3={name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compareNatural","compareText"]},Z3={name:"compareNatural",category:"Relational",syntax:["compareNatural(x, y)"],description:"Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compareNatural(2, 3)","compareNatural(3, 2)","compareNatural(2, 2)","compareNatural(5cm, 40mm)",'compareNatural("2", "10")',"compareNatural(2 + 3i, 2 + 4i)","compareNatural([1, 2, 4], [1, 2, 3])","compareNatural([1, 5], [1, 2, 3])","compareNatural([1, 2], [1, 2])","compareNatural({a: 2}, {a: 4})"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare","compareText"]},J3={name:"compareText",category:"Relational",syntax:["compareText(x, y)"],description:"Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:['compareText("B", "A")','compareText("A", "B")','compareText("A", "A")','compareText("2", "10")','compare("2", "10")',"compare(2, 10)",'compareNatural("2", "10")','compareText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural"]},X3={name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["deepEqual([1,3,4], [1,3,4])","deepEqual([1,3,4], [1,3])"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]},W3={name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual","equalText"]},Y3={name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},Q3={name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},K3={name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},j3={name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},eF={name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 <= 1+1","2 < 1+1","a = 3.2","b = 6-2.8","(a <= b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]},rF={name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]},tF={name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays and the values will be sorted in ascending order before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},nF={name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},aF={name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},iF={name:"setIntersect",category:"Set",syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},oF={name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},sF={name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]},uF={name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},lF={name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},cF={name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setDifference"]},fF={name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},mF={name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},vF={name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},pF={name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dimension)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},hF={name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dimension)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},dF={name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},gF={name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dimension)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},yF={name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},bF={name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},xF={name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:`Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber.
|
|
70
70
|
|
|
71
|
-
In case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.`,examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},vF={name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, dimension)","std(A, normalization)","std(A, dimension, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},pF={name:"cumsum",category:"Statistics",syntax:["cumsum(a, b, c, ...)","cumsum(A)"],description:"Compute the cumulative sum of all values.",examples:["cumsum(2, 3, 4, 1)","cumsum([2, 3, 4, 1])","cumsum([1, 2; 3, 4])","cumsum([1, 2; 3, 4], 1)","cumsum([1, 2; 3, 4], 2)"],seealso:["max","mean","median","min","prod","std","sum","variance"]},hF={name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)","sum(A, dimension)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},dF={name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, dimension)","variance(A, normalization)","variance(A, dimension, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},gF={name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},yF={name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},bF={name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},xF={name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},wF={name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},NF={name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},DF={name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},AF={name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},EF={name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},SF={name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},CF={name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},MF={name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},FF={name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},TF={name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},BF={name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},$F={name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},OF={name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},IF={name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},RF={name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},_F={name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},qF={name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},zF={name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},PF={name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},UF={name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},LF={name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},kF={name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},VF={name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},GF={name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},HF={name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},ZF={name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},JF={name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},XF={name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},WF={name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},YF={name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},QF={name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},KF={name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},jF={name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},e4={name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},r4={name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "BigNumber")','numeric("4", "Fraction)','numeric(4, "Fraction")','numeric(fraction(2, 5), "number)'],seealso:["number","fraction","bignumber","string","format"]},t4={name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},n4={name:"print",category:"Utils",syntax:["print(template, values)","print(template, values, precision)"],description:"Interpolate values into a string template.",examples:['print("Lucy is $age years old", {age: 5})','print("The value of pi is $pi", {pi: pi}, 3)','print("Hello, $user.name!", {user: {name: "John"}})','print("Values: $0, $1, $2", [6, 9, 4])'],seealso:["format"]},a4={name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},i4={bignumber:eC,boolean:rC,complex:tC,createUnit:nC,fraction:aC,index:iC,matrix:oC,number:sC,sparse:uC,splitUnit:lC,string:cC,unit:fC,e:hp,E:hp,false:PS,i:US,Infinity:LS,LN2:VS,LN10:kS,LOG2E:HS,LOG10E:GS,NaN:ZS,null:JS,pi:dp,PI:dp,phi:XS,SQRT1_2:WS,SQRT2:YS,tau:QS,true:KS,version:jS,speedOfLight:{description:"Speed of light in vacuum",examples:["speedOfLight"]},gravitationConstant:{description:"Newtonian constant of gravitation",examples:["gravitationConstant"]},planckConstant:{description:"Planck constant",examples:["planckConstant"]},reducedPlanckConstant:{description:"Reduced Planck constant",examples:["reducedPlanckConstant"]},magneticConstant:{description:"Magnetic constant (vacuum permeability)",examples:["magneticConstant"]},electricConstant:{description:"Electric constant (vacuum permeability)",examples:["electricConstant"]},vacuumImpedance:{description:"Characteristic impedance of vacuum",examples:["vacuumImpedance"]},coulomb:{description:"Coulomb's constant",examples:["coulomb"]},elementaryCharge:{description:"Elementary charge",examples:["elementaryCharge"]},bohrMagneton:{description:"Borh magneton",examples:["bohrMagneton"]},conductanceQuantum:{description:"Conductance quantum",examples:["conductanceQuantum"]},inverseConductanceQuantum:{description:"Inverse conductance quantum",examples:["inverseConductanceQuantum"]},magneticFluxQuantum:{description:"Magnetic flux quantum",examples:["magneticFluxQuantum"]},nuclearMagneton:{description:"Nuclear magneton",examples:["nuclearMagneton"]},klitzing:{description:"Von Klitzing constant",examples:["klitzing"]},bohrRadius:{description:"Borh radius",examples:["bohrRadius"]},classicalElectronRadius:{description:"Classical electron radius",examples:["classicalElectronRadius"]},electronMass:{description:"Electron mass",examples:["electronMass"]},fermiCoupling:{description:"Fermi coupling constant",examples:["fermiCoupling"]},fineStructure:{description:"Fine-structure constant",examples:["fineStructure"]},hartreeEnergy:{description:"Hartree energy",examples:["hartreeEnergy"]},protonMass:{description:"Proton mass",examples:["protonMass"]},deuteronMass:{description:"Deuteron Mass",examples:["deuteronMass"]},neutronMass:{description:"Neutron mass",examples:["neutronMass"]},quantumOfCirculation:{description:"Quantum of circulation",examples:["quantumOfCirculation"]},rydberg:{description:"Rydberg constant",examples:["rydberg"]},thomsonCrossSection:{description:"Thomson cross section",examples:["thomsonCrossSection"]},weakMixingAngle:{description:"Weak mixing angle",examples:["weakMixingAngle"]},efimovFactor:{description:"Efimov factor",examples:["efimovFactor"]},atomicMass:{description:"Atomic mass constant",examples:["atomicMass"]},avogadro:{description:"Avogadro's number",examples:["avogadro"]},boltzmann:{description:"Boltzmann constant",examples:["boltzmann"]},faraday:{description:"Faraday constant",examples:["faraday"]},firstRadiation:{description:"First radiation constant",examples:["firstRadiation"]},loschmidt:{description:"Loschmidt constant at T=273.15 K and p=101.325 kPa",examples:["loschmidt"]},gasConstant:{description:"Gas constant",examples:["gasConstant"]},molarPlanckConstant:{description:"Molar Planck constant",examples:["molarPlanckConstant"]},molarVolume:{description:"Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",examples:["molarVolume"]},sackurTetrode:{description:"Sackur-Tetrode constant at T=1 K and p=101.325 kPa",examples:["sackurTetrode"]},secondRadiation:{description:"Second radiation constant",examples:["secondRadiation"]},stefanBoltzmann:{description:"Stefan-Boltzmann constant",examples:["stefanBoltzmann"]},wienDisplacement:{description:"Wien displacement law constant",examples:["wienDisplacement"]},molarMass:{description:"Molar mass constant",examples:["molarMass"]},molarMassC12:{description:"Molar mass constant of carbon-12",examples:["molarMassC12"]},gravity:{description:"Standard acceleration of gravity (standard acceleration of free-fall on Earth)",examples:["gravity"]},planckLength:{description:"Planck length",examples:["planckLength"]},planckMass:{description:"Planck mass",examples:["planckMass"]},planckTime:{description:"Planck time",examples:["planckTime"]},planckCharge:{description:"Planck charge",examples:["planckCharge"]},planckTemperature:{description:"Planck temperature",examples:["planckTemperature"]},derivative:hC,lsolve:gC,lsolveAll:yC,lup:bC,lusolve:xC,leafCount:dC,polynomialRoot:wC,resolve:AC,simplify:EC,simplifyConstant:SC,simplifyCore:CC,symbolicEqual:FC,rationalize:DC,slu:MC,usolve:TC,usolveAll:BC,qr:NC,abs:$C,add:OC,cbrt:IC,ceil:RC,cube:_C,divide:qC,dotDivide:zC,dotMultiply:PC,dotPow:UC,exp:LC,expm:kC,expm1:VC,fix:GC,floor:HC,gcd:ZC,hypot:JC,lcm:WC,log:YC,log2:jC,log1p:KC,log10:QC,mod:eM,multiply:rM,norm:tM,nthRoot:nM,nthRoots:aM,pow:iM,round:oM,sign:sM,sqrt:uM,sqrtm:lM,square:vM,subtract:pM,unaryMinus:hM,unaryPlus:dM,xgcd:gM,invmod:XC,bitAnd:yM,bitNot:bM,bitOr:xM,bitXor:wM,leftShift:NM,rightArithShift:DM,rightLogShift:AM,bellNumbers:EM,catalan:SM,composition:CM,stirlingS2:MM,config:mC,import:vC,typed:pC,arg:FM,conj:TM,re:$M,im:BM,evaluate:OM,help:IM,distance:RM,intersect:_M,and:qM,not:zM,or:PM,xor:UM,concat:kM,count:VM,cross:GM,column:LM,ctranspose:HM,det:ZM,diag:JM,diff:XM,dot:WM,getMatrixDataType:e3,identity:r3,filter:QM,flatten:KM,forEach:jM,inv:t3,pinv:n3,eigs:YM,kron:a3,matrixFromFunction:s3,matrixFromRows:u3,matrixFromColumns:o3,map:i3,ones:l3,partitionSelect:c3,range:f3,resize:v3,reshape:m3,rotate:p3,rotationMatrix:h3,row:d3,size:g3,sort:y3,squeeze:b3,subset:x3,trace:w3,transpose:N3,zeros:D3,fft:A3,ifft:E3,sylvester:cM,schur:fM,lyap:mM,combinations:S3,combinationsWithRep:C3,factorial:M3,gamma:F3,kldivergence:B3,lgamma:T3,multinomial:$3,permutations:O3,pickRandom:I3,random:R3,randomInt:_3,compare:q3,compareNatural:z3,compareText:P3,deepEqual:U3,equal:L3,equalText:k3,larger:V3,largerEq:G3,smaller:H3,smallerEq:Z3,unequal:J3,setCartesian:X3,setDifference:W3,setDistinct:Y3,setIntersect:Q3,setIsSubset:K3,setMultiplicity:j3,setPowerset:eF,setSize:rF,setSymDifference:tF,setUnion:nF,erf:aF,cumsum:pF,mad:iF,max:oF,mean:sF,median:uF,min:lF,mode:cF,prod:fF,quantileSeq:mF,std:vF,sum:hF,variance:dF,acos:gF,acosh:yF,acot:bF,acoth:xF,acsc:wF,acsch:NF,asec:DF,asech:AF,asin:EF,asinh:SF,atan:CF,atanh:FF,atan2:MF,cos:TF,cosh:BF,cot:$F,coth:OF,csc:IF,csch:RF,sec:_F,sech:qF,sin:zF,sinh:PF,tan:UF,tanh:LF,to:kF,clone:GF,format:HF,bin:VF,oct:t4,hex:JF,isNaN:WF,isInteger:XF,isNegative:YF,isNumeric:QF,hasNumericValue:ZF,isPositive:KF,isPrime:jF,isZero:e4,print:n4,typeOf:a4,numeric:r4},gp="help",o4=["typed","mathWithTransform","Help"],s4=q(gp,o4,r=>{var{typed:e,mathWithTransform:t,Help:a}=r;return e(gp,{any:function(i){var o,f=i;if(typeof i!="string"){for(o in t)if(Re(t,o)&&i===t[o]){f=o;break}}var l=ut(i4,f);if(!l){var u=typeof f=="function"?f.name:f;throw new Error('No documentation found on "'+u+'"')}return new a(l)}})}),yp="chain",u4=["typed","Chain"],l4=q(yp,u4,r=>{var{typed:e,Chain:t}=r;return e(yp,{"":function(){return new t},any:function(n){return new t(n)}})}),bp="det",c4=["typed","matrix","subtract","multiply","divideScalar","isZero","unaryMinus"],f4=q(bp,c4,r=>{var{typed:e,matrix:t,subtract:a,multiply:n,divideScalar:i,isZero:o,unaryMinus:f}=r;return e(bp,{any:function(s){return Ge(s)},"Array | Matrix":function(s){var c;switch(Ve(s)?c=s.size():Array.isArray(s)?(s=t(s),c=s.size()):c=[],c.length){case 0:return Ge(s);case 1:if(c[0]===1)return Ge(s.valueOf()[0]);if(c[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+Ye(c)+")");case 2:{var m=c[0],v=c[1];if(m===v)return l(s.clone().valueOf(),m);if(v===0)return 1;throw new RangeError("Matrix must be square (size: "+Ye(c)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Ye(c)+")")}}});function l(u,s,c){if(s===1)return Ge(u[0][0]);if(s===2)return a(n(u[0][0],u[1][1]),n(u[1][0],u[0][1]));for(var m=!1,v=new Array(s).fill(0).map((E,A)=>A),h=0;h<s;h++){var p=v[h];if(o(u[p][h])){var g=void 0;for(g=h+1;g<s;g++)if(!o(u[v[g]][h])){p=v[g],v[g]=v[h],v[h]=p,m=!m;break}if(g===s)return u[p][h]}for(var y=u[p][h],N=h===0?1:u[v[h-1]][h-1],d=h+1;d<s;d++)for(var w=v[d],x=h+1;x<s;x++)u[w][x]=i(a(n(u[w][x],y),n(u[w][h],u[p][x])),N)}var b=u[v[s-1]][s-1];return m?f(b):b}}),xp="inv",m4=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],v4=q(xp,m4,r=>{var{typed:e,matrix:t,divideScalar:a,addScalar:n,multiply:i,unaryMinus:o,det:f,identity:l,abs:u}=r;return e(xp,{"Array | Matrix":function(m){var v=Ve(m)?m.size():er(m);switch(v.length){case 1:if(v[0]===1)return Ve(m)?t([a(1,m.valueOf()[0])]):[a(1,m[0])];throw new RangeError("Matrix must be square (size: "+Ye(v)+")");case 2:{var h=v[0],p=v[1];if(h===p)return Ve(m)?t(s(m.valueOf(),h,p),m.storage()):s(m,h,p);throw new RangeError("Matrix must be square (size: "+Ye(v)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Ye(v)+")")}},any:function(m){return a(1,m)}});function s(c,m,v){var h,p,g,y,N;if(m===1){if(y=c[0][0],y===0)throw Error("Cannot calculate inverse, determinant is zero");return[[a(1,y)]]}else if(m===2){var d=f(c);if(d===0)throw Error("Cannot calculate inverse, determinant is zero");return[[a(c[1][1],d),a(o(c[0][1]),d)],[a(o(c[1][0]),d),a(c[0][0],d)]]}else{var w=c.concat();for(h=0;h<m;h++)w[h]=w[h].concat();for(var x=l(m).valueOf(),b=0;b<v;b++){var E=u(w[b][b]),A=b;for(h=b+1;h<m;)u(w[h][b])>E&&(E=u(w[h][b]),A=h),h++;if(E===0)throw Error("Cannot calculate inverse, determinant is zero");h=A,h!==b&&(N=w[b],w[b]=w[h],w[h]=N,N=x[b],x[b]=x[h],x[h]=N);var S=w[b],D=x[b];for(h=0;h<m;h++){var T=w[h],B=x[h];if(h!==b){if(T[b]!==0){for(g=a(o(T[b]),S[b]),p=b;p<v;p++)T[p]=n(T[p],i(g,S[p]));for(p=0;p<v;p++)B[p]=n(B[p],i(g,D[p]))}}else{for(g=S[b],p=b;p<v;p++)T[p]=a(T[p],g);for(p=0;p<v;p++)B[p]=a(B[p],g)}}}return x}}}),wp="pinv",p4=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],h4=q(wp,p4,r=>{var{typed:e,matrix:t,inv:a,deepEqual:n,equal:i,dotDivide:o,dot:f,ctranspose:l,divideScalar:u,multiply:s,add:c,Complex:m}=r;return e(wp,{"Array | Matrix":function(d){var w=Ve(d)?d.size():er(d);switch(w.length){case 1:return y(d)?l(d):w[0]===1?a(d):o(l(d),f(d,d));case 2:{if(y(d))return l(d);var x=w[0],b=w[1];if(x===b)try{return a(d)}catch(E){if(!(E instanceof Error&&E.message.match(/Cannot calculate inverse, determinant is zero/)))throw E}return Ve(d)?t(v(d.valueOf(),x,b),d.storage()):v(d,x,b)}default:throw new RangeError("Matrix must be two dimensional (size: "+Ye(w)+")")}},any:function(d){return i(d,0)?Ge(d):u(1,d)}});function v(N,d,w){var{C:x,F:b}=p(N,d,w),E=s(a(s(l(x),x)),l(x)),A=s(l(b),a(s(b,l(b))));return s(A,E)}function h(N,d,w){for(var x=Ge(N),b=0,E=0;E<d;E++){if(w<=b)return x;for(var A=E;g(x[A][b]);)if(A++,d===A&&(A=E,b++,w===b))return x;[x[A],x[E]]=[x[E],x[A]];for(var S=x[E][b],D=0;D<w;D++)x[E][D]=o(x[E][D],S);for(var T=0;T<d;T++)if(T!==E){S=x[T][b];for(var B=0;B<w;B++)x[T][B]=c(x[T][B],s(-1,s(S,x[E][B])))}b++}return x}function p(N,d,w){var x=h(N,d,w),b=N.map((A,S)=>A.filter((D,T)=>T<d&&!g(f(x[T],x[T])))),E=x.filter((A,S)=>!g(f(x[S],x[S])));return{C:b,F:E}}function g(N){return i(c(N,m(1,1)),c(0,m(1,1)))}function y(N){return n(c(N,m(1,1)),c(s(N,0),m(1,1)))}});function d4(r){var{addScalar:e,subtract:t,flatten:a,multiply:n,multiplyScalar:i,divideScalar:o,sqrt:f,abs:l,bignumber:u,diag:s,inv:c,qr:m,usolve:v,usolveAll:h,equal:p,complex:g,larger:y,smaller:N,matrixFromColumns:d,dot:w}=r;function x(k,Q,K,L,j){j===void 0&&(j=!0);var ae=b(k,Q,K,L,j);E(k,Q,K,L,j,ae);var{values:re,C:fe}=A(k,Q,K,L,j),he;return j&&(he=S(k,Q,fe,ae,re,K,L),he=d(...he)),{values:re,vectors:he}}function b(k,Q,K,L,j){var ae=L==="BigNumber",re=L==="Complex",fe=ae?u(0):0,he=ae?u(1):re?g(1):1,ce=ae?u(1):1,ie=ae?u(10):2,Ae=i(ie,ie),Oe;j&&(Oe=Array(Q).fill(he));for(var Ce=!1;!Ce;){Ce=!0;for(var $e=0;$e<Q;$e++){for(var V=fe,X=fe,oe=0;oe<Q;oe++)if($e!==oe){var G=l(k[$e][oe]);V=e(V,G),X=e(X,G)}if(!p(V,0)&&!p(X,0)){for(var Y=ce,te=V,ye=o(X,ie),me=i(X,ie);N(te,ye);)te=i(te,Ae),Y=i(Y,ie);for(;y(te,me);)te=o(te,Ae),Y=o(Y,ie);var z=N(o(e(te,X),Y),i(e(V,X),.95));if(z){Ce=!1;for(var U=o(1,Y),ee=0;ee<Q;ee++)$e!==ee&&(k[$e][ee]=i(k[$e][ee],Y),k[ee][$e]=i(k[ee][$e],U));j&&(Oe[$e]=i(Oe[$e],Y))}}}}return s(Oe)}function E(k,Q,K,L,j,ae){var re=L==="BigNumber",fe=L==="Complex",he=re?u(0):fe?g(0):0;re&&(K=u(K));for(var ce=0;ce<Q-2;ce++){for(var ie=0,Ae=he,Oe=ce+1;Oe<Q;Oe++){var Ce=k[Oe][ce];N(l(Ae),l(Ce))&&(Ae=Ce,ie=Oe)}if(!N(l(Ae),K)){if(ie!==ce+1){var $e=k[ie];k[ie]=k[ce+1],k[ce+1]=$e;for(var V=0;V<Q;V++){var X=k[V][ie];k[V][ie]=k[V][ce+1],k[V][ce+1]=X}if(j){var oe=ae[ie];ae[ie]=ae[ce+1],ae[ce+1]=oe}}for(var G=ce+2;G<Q;G++){var Y=o(k[G][ce],Ae);if(Y!==0){for(var te=0;te<Q;te++)k[G][te]=t(k[G][te],i(Y,k[ce+1][te]));for(var ye=0;ye<Q;ye++)k[ye][ce+1]=e(k[ye][ce+1],i(Y,k[ye][G]));if(j)for(var me=0;me<Q;me++)ae[G][me]=t(ae[G][me],i(Y,ae[ce+1][me]))}}}}return ae}function A(k,Q,K,L,j){var ae=L==="BigNumber",re=L==="Complex",fe=ae?u(1):re?g(1):1;ae&&(K=u(K));for(var he=Ge(k),ce=[],ie=Q,Ae=[],Oe=j?s(Array(Q).fill(fe)):void 0,Ce=j?s(Array(ie).fill(fe)):void 0,$e=0;$e<=100;){$e+=1;for(var V=0,X=0;X<ie;X++)he[X][X]=t(he[X][X],V);var{Q:oe,R:G}=m(he);he=n(G,oe);for(var Y=0;Y<ie;Y++)he[Y][Y]=e(he[Y][Y],V);if(j&&(Ce=n(Ce,oe)),ie===1||N(l(he[ie-1][ie-2]),K)){$e=0,ce.push(he[ie-1][ie-1]),j&&(Ae.unshift([[1]]),B(Ce,Q),Oe=n(Oe,Ce),ie>1&&(Ce=s(Array(ie-1).fill(fe)))),ie-=1,he.pop();for(var te=0;te<ie;te++)he[te].pop()}else if(ie===2||N(l(he[ie-2][ie-3]),K)){$e=0;var ye=D(he[ie-2][ie-2],he[ie-2][ie-1],he[ie-1][ie-2],he[ie-1][ie-1]);ce.push(...ye),j&&(Ae.unshift(T(he[ie-2][ie-2],he[ie-2][ie-1],he[ie-1][ie-2],he[ie-1][ie-1],ye[0],ye[1],K,L)),B(Ce,Q),Oe=n(Oe,Ce),ie>2&&(Ce=s(Array(ie-2).fill(fe)))),ie-=2,he.pop(),he.pop();for(var me=0;me<ie;me++)he[me].pop(),he[me].pop()}if(ie===0)break}if(ce.sort((ee,ue)=>+t(l(ee),l(ue))),$e>100){var z=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+ce.join(", "));throw z.values=ce,z.vectors=[],z}var U=j?n(Oe,I(Ae,Q)):void 0;return{values:ce,C:U}}function S(k,Q,K,L,j,ae,re){var fe=c(K),he=n(fe,k,K),ce=re==="BigNumber",ie=re==="Complex",Ae=ce?u(0):ie?g(0):0,Oe=ce?u(1):ie?g(1):1,Ce=[],$e=[];for(var V of j){var X=P(Ce,V,p);X===-1?(Ce.push(V),$e.push(1)):$e[X]+=1}for(var oe=[],G=Ce.length,Y=Array(Q).fill(Ae),te=s(Array(Q).fill(Oe)),ye=[],me=function(){var ue=Ce[z],ve=t(he,n(ue,te)),de=h(ve,Y);for(de.shift();de.length<$e[z];){var be=R(ve,Q,de,ae,re);if(be==null){ye.push(ue);break}de.push(be)}var pe=n(c(L),K);de=de.map(we=>n(pe,we)),oe.push(...de.map(we=>a(we)))},z=0;z<G;z++)me();if(ye.length!==0){var U=new Error("Failed to find eigenvectors for the following eigenvalues: "+ye.join(", "));throw U.values=j,U.vectors=oe,U}return oe}function D(k,Q,K,L){var j=e(k,L),ae=t(i(k,L),i(Q,K)),re=i(j,.5),fe=i(f(t(i(j,j),i(4,ae))),.5);return[e(re,fe),t(re,fe)]}function T(k,Q,K,L,j,ae,re,fe){var he=fe==="BigNumber",ce=fe==="Complex",ie=he?u(0):ce?g(0):0,Ae=he?u(1):ce?g(1):1;if(N(l(K),re))return[[Ae,ie],[ie,Ae]];if(y(l(t(j,ae)),re))return[[t(j,L),t(ae,L)],[K,K]];var Oe=t(k,j),Ce=t(Q,j),$e=t(K,j),V=t(L,j);return N(l(Ce),re)?[[Oe,Ae],[$e,ie]]:[[Ce,ie],[V,Ae]]}function B(k,Q){for(var K=0;K<k.length;K++)k[K].push(...Array(Q-k[K].length).fill(0));for(var L=k.length;L<Q;L++)k.push(Array(Q).fill(0)),k[L][L]=1;return k}function I(k,Q){for(var K=[],L=0;L<Q;L++)K[L]=Array(Q).fill(0);var j=0;for(var ae of k){for(var re=ae.length,fe=0;fe<re;fe++)for(var he=0;he<re;he++)K[j+fe][j+he]=ae[fe][he];j+=re}return K}function P(k,Q,K){for(var L=0;L<k.length;L++)if(K(k[L],Q))return L;return-1}function R(k,Q,K,L,j){for(var ae=j==="BigNumber"?u(1e3):1e3,re,fe=0;re=M(Q,K,j),re=v(k,re),!y(H(re),ae);)if(++fe>=5)return null;for(fe=0;;){var he=v(k,re);if(N(H(F(re,[he])),L))break;if(++fe>=10)return null;re=$(he)}return re}function M(k,Q,K){var L=K==="BigNumber",j=K==="Complex",ae=Array(k).fill(0).map(re=>2*Math.random()-1);return L&&(ae=ae.map(re=>u(re))),j&&(ae=ae.map(re=>g(re))),ae=F(ae,Q),$(ae,K)}function F(k,Q){for(var K of Q)k=t(k,n(o(w(K,k),w(K,K)),K));return k}function H(k){return l(f(w(k,k)))}function $(k,Q){var K=Q==="BigNumber",L=Q==="Complex",j=K?u(1):L?g(1):1;return n(o(j,H(k)),k)}return x}function g4(r){var{config:e,addScalar:t,subtract:a,abs:n,atan:i,cos:o,sin:f,multiplyScalar:l,inv:u,bignumber:s,multiply:c,add:m}=r;function v(D,T){var B=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.epsilon,I=arguments.length>3?arguments[3]:void 0;if(I==="number")return h(D,B);if(I==="BigNumber")return p(D,B);throw TypeError("Unsupported data type: "+I)}function h(D,T){for(var B=D.length,I=Math.abs(T/B),P,R=new Array(B),M=0;M<B;M++)R[M]=S(B,0),R[M][M]=1;for(var F=b(D);Math.abs(F[1])>=Math.abs(I);){var H=F[0][0],$=F[0][1];P=g(D[H][H],D[$][$],D[H][$]),D=x(D,P,H,$),R=N(R,P,H,$),F=b(D)}for(var k=S(B,0),Q=0;Q<B;Q++)k[Q]=D[Q][Q];return A(Ge(k),Ge(R))}function p(D,T){for(var B=D.length,I=n(T/B),P,R=new Array(B),M=0;M<B;M++)R[M]=S(B,0),R[M][M]=1;for(var F=E(D);n(F[1])>=n(I);){var H=F[0][0],$=F[0][1];P=y(D[H][H],D[$][$],D[H][$]),D=w(D,P,H,$),R=d(R,P,H,$),F=E(D)}for(var k=S(B,0),Q=0;Q<B;Q++)k[Q]=D[Q][Q];return A(Ge(k),Ge(R))}function g(D,T,B){var I=T-D;return Math.abs(I)<=e.epsilon?Math.PI/4:.5*Math.atan(2*B/(T-D))}function y(D,T,B){var I=a(T,D);return n(I)<=e.epsilon?s(-1).acos().div(4):l(.5,i(c(2,B,u(I))))}function N(D,T,B,I){for(var P=D.length,R=Math.cos(T),M=Math.sin(T),F=S(P,0),H=S(P,0),$=0;$<P;$++)F[$]=R*D[$][B]-M*D[$][I],H[$]=M*D[$][B]+R*D[$][I];for(var k=0;k<P;k++)D[k][B]=F[k],D[k][I]=H[k];return D}function d(D,T,B,I){for(var P=D.length,R=o(T),M=f(T),F=S(P,s(0)),H=S(P,s(0)),$=0;$<P;$++)F[$]=a(l(R,D[$][B]),l(M,D[$][I])),H[$]=t(l(M,D[$][B]),l(R,D[$][I]));for(var k=0;k<P;k++)D[k][B]=F[k],D[k][I]=H[k];return D}function w(D,T,B,I){for(var P=D.length,R=s(o(T)),M=s(f(T)),F=l(R,R),H=l(M,M),$=S(P,s(0)),k=S(P,s(0)),Q=c(s(2),R,M,D[B][I]),K=t(a(l(F,D[B][B]),Q),l(H,D[I][I])),L=m(l(H,D[B][B]),Q,l(F,D[I][I])),j=0;j<P;j++)$[j]=a(l(R,D[B][j]),l(M,D[I][j])),k[j]=t(l(M,D[B][j]),l(R,D[I][j]));D[B][B]=K,D[I][I]=L,D[B][I]=s(0),D[I][B]=s(0);for(var ae=0;ae<P;ae++)ae!==B&&ae!==I&&(D[B][ae]=$[ae],D[ae][B]=$[ae],D[I][ae]=k[ae],D[ae][I]=k[ae]);return D}function x(D,T,B,I){for(var P=D.length,R=Math.cos(T),M=Math.sin(T),F=R*R,H=M*M,$=S(P,0),k=S(P,0),Q=F*D[B][B]-2*R*M*D[B][I]+H*D[I][I],K=H*D[B][B]+2*R*M*D[B][I]+F*D[I][I],L=0;L<P;L++)$[L]=R*D[B][L]-M*D[I][L],k[L]=M*D[B][L]+R*D[I][L];D[B][B]=Q,D[I][I]=K,D[B][I]=0,D[I][B]=0;for(var j=0;j<P;j++)j!==B&&j!==I&&(D[B][j]=$[j],D[j][B]=$[j],D[I][j]=k[j],D[j][I]=k[j]);return D}function b(D){for(var T=D.length,B=0,I=[0,1],P=0;P<T;P++)for(var R=P+1;R<T;R++)Math.abs(B)<Math.abs(D[P][R])&&(B=Math.abs(D[P][R]),I=[P,R]);return[I,B]}function E(D){for(var T=D.length,B=0,I=[0,1],P=0;P<T;P++)for(var R=P+1;R<T;R++)n(B)<n(D[P][R])&&(B=n(D[P][R]),I=[P,R]);return[I,B]}function A(D,T){for(var B=D.length,I=Array(B),P=Array(B),R=0;R<B;R++)P[R]=Array(B);for(var M=0;M<B;M++){for(var F=0,H=D[0],$=0;$<D.length;$++)n(D[$])<n(H)&&(F=$,H=D[F]);I[M]=D.splice(F,1)[0];for(var k=0;k<B;k++)P[k][M]=T[k][F],T[k].splice(F,1)}return{values:I,vectors:P}}function S(D,T){for(var B=new Array(D),I=0;I<D;I++)B[I]=T;return B}return v}var y4="eigs",b4=["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","divideScalar","inv","bignumber","multiply","add","larger","column","flatten","number","complex","sqrt","diag","qr","usolve","usolveAll","im","re","smaller","matrixFromColumns","dot"],x4=q(y4,b4,r=>{var{config:e,typed:t,matrix:a,addScalar:n,subtract:i,equal:o,abs:f,atan:l,cos:u,sin:s,multiplyScalar:c,divideScalar:m,inv:v,bignumber:h,multiply:p,add:g,larger:y,column:N,flatten:d,number:w,complex:x,sqrt:b,diag:E,qr:A,usolve:S,usolveAll:D,im:T,re:B,smaller:I,matrixFromColumns:P,dot:R}=r,M=g4({config:e,addScalar:n,subtract:i,column:N,flatten:d,equal:o,abs:f,atan:l,cos:u,sin:s,multiplyScalar:c,inv:v,bignumber:h,complex:x,multiply:p,add:g}),F=d4({config:e,addScalar:n,subtract:i,multiply:p,multiplyScalar:c,flatten:d,divideScalar:m,sqrt:b,abs:f,bignumber:h,diag:E,qr:A,inv:v,usolve:S,usolveAll:D,equal:o,complex:x,larger:y,smaller:I,matrixFromColumns:P,dot:R});return t("eigs",{Array:function(j){var ae=a(j);return H(ae)},"Array, number|BigNumber":function(j,ae){var re=a(j);return H(re,ae)},Matrix:function(j){var{values:ae,vectors:re}=H(j);return{values:a(ae),vectors:a(re)}},"Matrix, number|BigNumber":function(j,ae){var{values:re,vectors:fe}=H(j,ae);return{values:a(re),vectors:a(fe)}}});function H(L,j){j===void 0&&(j=e.epsilon);var ae=L.size();if(ae.length!==2||ae[0]!==ae[1])throw new RangeError("Matrix must be square (size: "+Ye(ae)+")");var re=L.toArray(),fe=ae[0];if(k(re,fe,j)&&(Q(re,fe),$(re,fe,j))){var he=K(L,re,fe);return M(re,fe,j,he)}var ce=K(L,re,fe);return F(re,fe,j,ce)}function $(L,j,ae){for(var re=0;re<j;re++)for(var fe=re;fe<j;fe++)if(y(h(f(i(L[re][fe],L[fe][re]))),ae))return!1;return!0}function k(L,j,ae){for(var re=0;re<j;re++)for(var fe=0;fe<j;fe++)if(y(h(f(T(L[re][fe]))),ae))return!1;return!0}function Q(L,j){for(var ae=0;ae<j;ae++)for(var re=0;re<j;re++)L[ae][re]=B(L[ae][re])}function K(L,j,ae){var re=L.datatype();if(re==="number"||re==="BigNumber"||re==="Complex")return re;for(var fe=!1,he=!1,ce=!1,ie=0;ie<ae;ie++)for(var Ae=0;Ae<ae;Ae++){var Oe=j[ie][Ae];if(tr(Oe)||qa(Oe))fe=!0;else if(rr(Oe))he=!0;else if(Lt(Oe))ce=!0;else throw TypeError("Unsupported type in Matrix: "+br(Oe))}if(he&&ce&&console.warn("Complex BigNumbers not supported, this operation will lose precission."),ce){for(var Ce=0;Ce<ae;Ce++)for(var $e=0;$e<ae;$e++)j[Ce][$e]=x(j[Ce][$e]);return"Complex"}if(he){for(var V=0;V<ae;V++)for(var X=0;X<ae;X++)j[V][X]=h(j[V][X]);return"BigNumber"}if(fe){for(var oe=0;oe<ae;oe++)for(var G=0;G<ae;G++)j[oe][G]=w(j[oe][G]);return"number"}else throw TypeError("Matrix contains unsupported types only.")}}),Np="expm",w4=["typed","abs","add","identity","inv","multiply"],N4=q(Np,w4,r=>{var{typed:e,abs:t,add:a,identity:n,inv:i,multiply:o}=r;return e(Np,{Matrix:function(c){var m=c.size();if(m.length!==2||m[0]!==m[1])throw new RangeError("Matrix must be square (size: "+Ye(m)+")");for(var v=m[0],h=1e-15,p=f(c),g=l(p,h),y=g.q,N=g.j,d=o(c,Math.pow(2,-N)),w=n(v),x=n(v),b=1,E=d,A=-1,S=1;S<=y;S++)S>1&&(E=o(E,d),A=-A),b=b*(y-S+1)/((2*y-S+1)*S),w=a(w,o(b,E)),x=a(x,o(b*A,E));for(var D=o(i(x),w),T=0;T<N;T++)D=o(D,D);return An(c)?c.createSparseMatrix(D):D}});function f(s){for(var c=s.size()[0],m=0,v=0;v<c;v++){for(var h=0,p=0;p<c;p++)h+=t(s.get([v,p]));m=Math.max(h,m)}return m}function l(s,c){for(var m=30,v=0;v<m;v++)for(var h=0;h<=v;h++){var p=v-h;if(u(s,h,p)<c)return{q:h,j:p}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}function u(s,c,m){for(var v=1,h=2;h<=c;h++)v*=h;for(var p=v,g=c+1;g<=2*c;g++)p*=g;var y=p*(2*c+1);return 8*Math.pow(s/Math.pow(2,m),2*c)*v*v/(p*y)}}),Dp="sqrtm",D4=["typed","abs","add","multiply","map","sqrt","subtract","inv","size","max","identity"],A4=q(Dp,D4,r=>{var{typed:e,abs:t,add:a,multiply:n,map:i,sqrt:o,subtract:f,inv:l,size:u,max:s,identity:c}=r,m=1e3,v=1e-6;function h(p){var g,y=0,N=p,d=c(u(p));do{var w=N;if(N=n(.5,a(w,l(d))),d=n(.5,a(d,l(w))),g=s(t(f(N,w))),g>v&&++y>m)throw new Error("computing square root of matrix: iterative method could not converge")}while(g>v);return N}return e(Dp,{"Array | Matrix":function(g){var y=Ve(g)?g.size():er(g);switch(y.length){case 1:if(y[0]===1)return i(g,o);throw new RangeError("Matrix must be square (size: "+Ye(y)+")");case 2:{var N=y[0],d=y[1];if(N===d)return h(g);throw new RangeError("Matrix must be square (size: "+Ye(y)+")")}default:throw new RangeError("Matrix must be at most two dimensional (size: "+Ye(y)+")")}}})}),Ap="sylvester",E4=["typed","schur","matrixFromColumns","matrix","multiply","range","concat","transpose","index","subset","add","subtract","identity","lusolve","abs"],S4=q(Ap,E4,r=>{var{typed:e,schur:t,matrixFromColumns:a,matrix:n,multiply:i,range:o,concat:f,transpose:l,index:u,subset:s,add:c,subtract:m,identity:v,lusolve:h,abs:p}=r;return e(Ap,{"Matrix, Matrix, Matrix":g,"Array, Matrix, Matrix":function(N,d,w){return g(n(N),d,w)},"Array, Array, Matrix":function(N,d,w){return g(n(N),n(d),w)},"Array, Matrix, Array":function(N,d,w){return g(n(N),d,n(w))},"Matrix, Array, Matrix":function(N,d,w){return g(N,n(d),w)},"Matrix, Array, Array":function(N,d,w){return g(N,n(d),n(w))},"Matrix, Matrix, Array":function(N,d,w){return g(N,d,n(w))},"Array, Array, Array":function(N,d,w){return g(n(N),n(d),n(w)).toArray()}});function g(y,N,d){for(var w=N.size()[0],x=y.size()[0],b=t(y),E=b.T,A=b.U,S=t(i(-1,N)),D=S.T,T=S.U,B=i(i(l(A),d),T),I=o(0,x),P=[],R=(Oe,Ce)=>f(Oe,Ce,1),M=(Oe,Ce)=>f(Oe,Ce,0),F=0;F<w;F++)if(F<w-1&&p(s(D,u(F+1,F)))>1e-5){for(var H=M(s(B,u(I,F)),s(B,u(I,F+1))),$=0;$<F;$++)H=c(H,M(i(P[$],s(D,u($,F))),i(P[$],s(D,u($,F+1)))));var k=i(v(x),i(-1,s(D,u(F,F)))),Q=i(v(x),i(-1,s(D,u(F+1,F)))),K=i(v(x),i(-1,s(D,u(F,F+1)))),L=i(v(x),i(-1,s(D,u(F+1,F+1)))),j=M(R(c(E,k),Q),R(K,c(E,L))),ae=h(j,H);P[F]=ae.subset(u(o(0,x),0)),P[F+1]=ae.subset(u(o(x,2*x),0)),F++}else{for(var re=s(B,u(I,F)),fe=0;fe<F;fe++)re=c(re,i(P[fe],s(D,u(fe,F))));var he=s(D,u(F,F)),ce=m(E,i(he,v(x)));P[F]=h(ce,re)}var ie=n(a(...P)),Ae=i(A,i(ie,l(T)));return Ae}}),Ep="schur",C4=["typed","matrix","identity","multiply","qr","norm","subtract"],M4=q(Ep,C4,r=>{var{typed:e,matrix:t,identity:a,multiply:n,qr:i,norm:o,subtract:f}=r;return e(Ep,{Array:function(s){var c=l(t(s));return{U:c.U.valueOf(),T:c.T.valueOf()}},Matrix:function(s){return l(s)}});function l(u){var s=u.size()[0],c=u,m=a(s),v=0,h;do{h=c;var p=i(c),g=p.Q,y=p.R;if(c=n(y,g),m=n(m,g),v++>100)break}while(o(f(c,h))>1e-4);return{U:m,T:c}}}),Sp="lyap",F4=["typed","matrix","sylvester","multiply","transpose"],T4=q(Sp,F4,r=>{var{typed:e,matrix:t,sylvester:a,multiply:n,transpose:i}=r;return e(Sp,{"Matrix, Matrix":function(f,l){return a(f,i(f),n(-1,l))},"Array, Matrix":function(f,l){return a(t(f),i(t(f)),n(-1,l))},"Matrix, Array":function(f,l){return a(f,i(t(f)),t(n(-1,l)))},"Array, Array":function(f,l){return a(t(f),i(t(f)),t(n(-1,l))).toArray()}})}),B4="divide",$4=["typed","matrix","multiply","equalScalar","divideScalar","inv"],O4=q(B4,$4,r=>{var{typed:e,matrix:t,multiply:a,equalScalar:n,divideScalar:i,inv:o}=r,f=Lr({typed:e,equalScalar:n}),l=bt({typed:e});return e("divide",sl({"Array | Matrix, Array | Matrix":function(s,c){return a(s,o(c))},"DenseMatrix, any":function(s,c){return l(s,c,i,!1)},"SparseMatrix, any":function(s,c){return f(s,c,i,!1)},"Array, any":function(s,c){return l(t(s),c,i,!1).valueOf()},"any, Array | Matrix":function(s,c){return a(s,o(c))}},i.signatures))}),Cp="distance",I4=["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],R4=q(Cp,I4,r=>{var{typed:e,addScalar:t,subtract:a,multiplyScalar:n,divideScalar:i,unaryMinus:o,sqrt:f,abs:l}=r;return e(Cp,{"Array, Array, Array":function(x,b,E){if(x.length===2&&b.length===2&&E.length===2){if(!s(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!s(b))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!s(E))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var A=i(a(E[1],E[0]),a(b[1],b[0])),S=n(n(A,A),b[0]),D=o(n(A,b[0])),T=x[1];return g(x[0],x[1],S,D,T)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(x,b,E){if(Object.keys(x).length===2&&Object.keys(b).length===2&&Object.keys(E).length===2){if(!s(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!s(b))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!s(E))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"lineOnePtX"in b&&"lineOnePtY"in b&&"lineTwoPtX"in E&&"lineTwoPtY"in E){var A=i(a(E.lineTwoPtY,E.lineTwoPtX),a(b.lineOnePtY,b.lineOnePtX)),S=n(n(A,A),b.lineOnePtX),D=o(n(A,b.lineOnePtX)),T=x.pointX;return g(x.pointX,x.pointY,S,D,T)}else throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(x,b){if(x.length===2&&b.length===3){if(!s(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!c(b))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return g(x[0],x[1],b[0],b[1],b[2])}else if(x.length===3&&b.length===6){if(!c(x))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!v(b))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return y(x[0],x[1],x[2],b[0],b[1],b[2],b[3],b[4],b[5])}else if(x.length===b.length&&x.length>0){if(!m(x))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!m(b))throw new TypeError("All values of an array should be numbers or BigNumbers");return N(x,b)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(x,b){if(Object.keys(x).length===2&&Object.keys(b).length===3){if(!s(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!c(b))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"xCoeffLine"in b&&"yCoeffLine"in b&&"constant"in b)return g(x.pointX,x.pointY,b.xCoeffLine,b.yCoeffLine,b.constant);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===3&&Object.keys(b).length===6){if(!c(x))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!v(b))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"x0"in b&&"y0"in b&&"z0"in b&&"a"in b&&"b"in b&&"c"in b)return y(x.pointX,x.pointY,x.pointZ,b.x0,b.y0,b.z0,b.a,b.b,b.c);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===2&&Object.keys(b).length===2){if(!s(x))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!s(b))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in x&&"pointOneY"in x&&"pointTwoX"in b&&"pointTwoY"in b)return N([x.pointOneX,x.pointOneY],[b.pointTwoX,b.pointTwoY]);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===3&&Object.keys(b).length===3){if(!c(x))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!c(b))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in x&&"pointOneY"in x&&"pointOneZ"in x&&"pointTwoX"in b&&"pointTwoY"in b&&"pointTwoZ"in b)return N([x.pointOneX,x.pointOneY,x.pointOneZ],[b.pointTwoX,b.pointTwoY,b.pointTwoZ]);throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},Array:function(x){if(!p(x))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return d(x)}});function u(w){return typeof w=="number"||rr(w)}function s(w){return w.constructor!==Array&&(w=h(w)),u(w[0])&&u(w[1])}function c(w){return w.constructor!==Array&&(w=h(w)),u(w[0])&&u(w[1])&&u(w[2])}function m(w){return Array.isArray(w)||(w=h(w)),w.every(u)}function v(w){return w.constructor!==Array&&(w=h(w)),u(w[0])&&u(w[1])&&u(w[2])&&u(w[3])&&u(w[4])&&u(w[5])}function h(w){for(var x=Object.keys(w),b=[],E=0;E<x.length;E++)b.push(w[x[E]]);return b}function p(w){if(w[0].length===2&&u(w[0][0])&&u(w[0][1])){if(w.some(x=>x.length!==2||!u(x[0])||!u(x[1])))return!1}else if(w[0].length===3&&u(w[0][0])&&u(w[0][1])&&u(w[0][2])){if(w.some(x=>x.length!==3||!u(x[0])||!u(x[1])||!u(x[2])))return!1}else return!1;return!0}function g(w,x,b,E,A){var S=l(t(t(n(b,w),n(E,x)),A)),D=f(t(n(b,b),n(E,E)));return i(S,D)}function y(w,x,b,E,A,S,D,T,B){var I=[a(n(a(A,x),B),n(a(S,b),T)),a(n(a(S,b),D),n(a(E,w),B)),a(n(a(E,w),T),n(a(A,x),D))];I=f(t(t(n(I[0],I[0]),n(I[1],I[1])),n(I[2],I[2])));var P=f(t(t(n(D,D),n(T,T)),n(B,B)));return i(I,P)}function N(w,x){for(var b=w.length,E=0,A=0,S=0;S<b;S++)A=a(w[S],x[S]),E=t(n(A,A),E);return f(E)}function d(w){for(var x=[],b=[],E=[],A=0;A<w.length-1;A++)for(var S=A+1;S<w.length;S++)w[0].length===2?(b=[w[A][0],w[A][1]],E=[w[S][0],w[S][1]]):w[0].length===3&&(b=[w[A][0],w[A][1],w[A][2]],E=[w[S][0],w[S][1],w[S][2]]),x.push(N(b,E));return x}}),_4="intersect",q4=["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],z4=q(_4,q4,r=>{var{typed:e,config:t,abs:a,add:n,addScalar:i,matrix:o,multiply:f,multiplyScalar:l,divideScalar:u,subtract:s,smaller:c,equalScalar:m,flatten:v,isZero:h,isNumeric:p}=r;return e("intersect",{"Array, Array, Array":g,"Array, Array, Array, Array":y,"Matrix, Matrix, Matrix":function(T,B,I){var P=g(T.valueOf(),B.valueOf(),I.valueOf());return P===null?null:o(P)},"Matrix, Matrix, Matrix, Matrix":function(T,B,I,P){var R=y(T.valueOf(),B.valueOf(),I.valueOf(),P.valueOf());return R===null?null:o(R)}});function g(D,T,B){if(D=N(D),T=N(T),B=N(B),!w(D))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!w(T))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!x(B))throw new TypeError("Array with 4 numbers expected as third argument");return S(D[0],D[1],D[2],T[0],T[1],T[2],B[0],B[1],B[2],B[3])}function y(D,T,B,I){if(D=N(D),T=N(T),B=N(B),I=N(I),D.length===2){if(!d(D))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!d(T))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!d(B))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!d(I))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return b(D,T,B,I)}else if(D.length===3){if(!w(D))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!w(T))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!w(B))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!w(I))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return A(D[0],D[1],D[2],T[0],T[1],T[2],B[0],B[1],B[2],I[0],I[1],I[2])}else throw new TypeError("Arrays with two or thee dimensional points expected")}function N(D){return D.length===1?D[0]:D.length>1&&Array.isArray(D[0])&&D.every(T=>Array.isArray(T)&&T.length===1)?v(D):D}function d(D){return D.length===2&&p(D[0])&&p(D[1])}function w(D){return D.length===3&&p(D[0])&&p(D[1])&&p(D[2])}function x(D){return D.length===4&&p(D[0])&&p(D[1])&&p(D[2])&&p(D[3])}function b(D,T,B,I){var P=D,R=B,M=s(P,T),F=s(R,I),H=s(l(M[0],F[1]),l(F[0],M[1]));if(h(H)||c(a(H),t.epsilon))return null;var $=l(F[0],P[1]),k=l(F[1],P[0]),Q=l(F[0],R[1]),K=l(F[1],R[0]),L=u(i(s(s($,k),Q),K),H);return n(f(M,L),P)}function E(D,T,B,I,P,R,M,F,H,$,k,Q){var K=l(s(D,T),s(B,I)),L=l(s(P,R),s(M,F)),j=l(s(H,$),s(k,Q));return i(i(K,L),j)}function A(D,T,B,I,P,R,M,F,H,$,k,Q){var K=E(D,M,$,M,T,F,k,F,B,H,Q,H),L=E($,M,I,D,k,F,P,T,Q,H,R,B),j=E(D,M,I,D,T,F,P,T,B,H,R,B),ae=E($,M,$,M,k,F,k,F,Q,H,Q,H),re=E(I,D,I,D,P,T,P,T,R,B,R,B),fe=s(l(K,L),l(j,ae)),he=s(l(re,ae),l(L,L));if(h(he))return null;var ce=u(fe,he),ie=u(i(K,l(ce,L)),ae),Ae=i(D,l(ce,s(I,D))),Oe=i(T,l(ce,s(P,T))),Ce=i(B,l(ce,s(R,B))),$e=i(M,l(ie,s($,M))),V=i(F,l(ie,s(k,F))),X=i(H,l(ie,s(Q,H)));return m(Ae,$e)&&m(Oe,V)&&m(Ce,X)?[Ae,Oe,Ce]:null}function S(D,T,B,I,P,R,M,F,H,$){var k=l(D,M),Q=l(I,M),K=l(T,F),L=l(P,F),j=l(B,H),ae=l(R,H),re=s(s(s($,k),K),j),fe=s(s(s(i(i(Q,L),ae),k),K),j),he=u(re,fe),ce=i(D,l(he,s(I,D))),ie=i(T,l(he,s(P,T))),Ae=i(B,l(he,s(R,B)));return[ce,ie,Ae]}}),Mp="sum",P4=["typed","config","add","numeric"],Fp=q(Mp,P4,r=>{var{typed:e,config:t,add:a,numeric:n}=r;return e(Mp,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":o,"...":function(l){if(na(l))throw new TypeError("Scalar values expected in function sum");return i(l)}});function i(f){var l;return Jt(f,function(u){try{l=l===void 0?u:a(l,u)}catch(s){throw Qr(s,"sum",u)}}),l===void 0&&(l=n(0,t.number)),typeof l=="string"&&(l=n(l,t.number)),l}function o(f,l){try{var u=Si(f,l,a);return u}catch(s){throw Qr(s,"sum")}}}),io="cumsum",U4=["typed","add","unaryPlus"],Tp=q(io,U4,r=>{var{typed:e,add:t,unaryPlus:a}=r;return e(io,{Array:n,Matrix:function(u){return u.create(n(u.valueOf()))},"Array, number | BigNumber":o,"Matrix, number | BigNumber":function(u,s){return u.create(o(u.valueOf(),s))},"...":function(u){if(na(u))throw new TypeError("All values expected to be scalar in function cumsum");return n(u)}});function n(l){try{return i(l)}catch(u){throw Qr(u,io)}}function i(l){if(l.length===0)return[];for(var u=[a(l[0])],s=1;s<l.length;++s)u.push(t(u[s-1],l[s]));return u}function o(l,u){var s=er(l);if(u<0||u>=s.length)throw new ht(u,s.length);try{return f(l,u)}catch(c){throw Qr(c,io)}}function f(l,u){var s,c,m;if(u<=0){var v=l[0][0];if(Array.isArray(v)){for(m=Jl(l),c=[],s=0;s<m.length;s++)c[s]=f(m[s],u-1);return c}else return i(l)}else{for(c=[],s=0;s<l.length;s++)c[s]=f(l[s],u-1);return c}}}),Bp="mean",L4=["typed","add","divide"],$p=q(Bp,L4,r=>{var{typed:e,add:t,divide:a}=r;return e(Bp,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":n,"...":function(f){if(na(f))throw new TypeError("Scalar values expected in function mean");return i(f)}});function n(o,f){try{var l=Si(o,f,t),u=Array.isArray(o)?er(o):o.size();return a(l,u[f])}catch(s){throw Qr(s,"mean")}}function i(o){var f,l=0;if(Jt(o,function(u){try{f=f===void 0?u:t(f,u),l++}catch(s){throw Qr(s,"mean",u)}}),l===0)throw new Error("Cannot calculate the mean of an empty array");return a(f,l)}}),Op="median",k4=["typed","add","divide","compare","partitionSelect"],V4=q(Op,k4,r=>{var{typed:e,add:t,divide:a,compare:n,partitionSelect:i}=r;function o(u){try{u=or(u.valueOf());var s=u.length;if(s===0)throw new Error("Cannot calculate median of an empty array");if(s%2===0){for(var c=s/2-1,m=i(u,c+1),v=u[c],h=0;h<c;++h)n(u[h],v)>0&&(v=u[h]);return l(v,m)}else{var p=i(u,(s-1)/2);return f(p)}}catch(g){throw Qr(g,"median")}}var f=e({"number | BigNumber | Complex | Unit":function(s){return s}}),l=e({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(s,c){return a(t(s,c),2)}});return e(Op,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(s,c){throw new Error("median(A, dim) is not yet supported")},"...":function(s){if(na(s))throw new TypeError("Scalar values expected in function median");return o(s)}})}),Ip="mad",G4=["typed","abs","map","median","subtract"],H4=q(Ip,G4,r=>{var{typed:e,abs:t,map:a,median:n,subtract:i}=r;return e(Ip,{"Array | Matrix":o,"...":function(l){return o(l)}});function o(f){if(f=or(f.valueOf()),f.length===0)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var l=n(f);return n(a(f,function(u){return t(i(u,l))}))}catch(u){throw u instanceof TypeError&&u.message.indexOf("median")!==-1?new TypeError(u.message.replace("median","mad")):Qr(u,"mad")}}}),As="unbiased",Rp="variance",Z4=["typed","add","subtract","multiply","divide","apply","isNaN"],_p=q(Rp,Z4,r=>{var{typed:e,add:t,subtract:a,multiply:n,divide:i,apply:o,isNaN:f}=r;return e(Rp,{"Array | Matrix":function(c){return l(c,As)},"Array | Matrix, string":l,"Array | Matrix, number | BigNumber":function(c,m){return u(c,m,As)},"Array | Matrix, number | BigNumber, string":u,"...":function(c){return l(c,As)}});function l(s,c){var m,v=0;if(s.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Jt(s,function(g){try{m=m===void 0?g:t(m,g),v++}catch(y){throw Qr(y,"variance",g)}}),v===0)throw new Error("Cannot calculate variance of an empty array");var h=i(m,v);if(m=void 0,Jt(s,function(g){var y=a(g,h);m=m===void 0?n(y,y):t(m,n(y,y))}),f(m))return m;switch(c){case"uncorrected":return i(m,v);case"biased":return i(m,v+1);case"unbiased":{var p=rr(m)?m.mul(0):0;return v===1?p:i(m,v-1)}default:throw new Error('Unknown normalization "'+c+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function u(s,c,m){try{if(s.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return o(s,c,v=>l(v,m))}catch(v){throw Qr(v,"variance")}}}),J4="quantileSeq",X4=["typed","add","multiply","partitionSelect","compare"],W4=q(J4,X4,r=>{var{typed:e,add:t,multiply:a,partitionSelect:n,compare:i}=r;function o(u,s,c){var m,v,h;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(Mt(u)){if(c=c||!1,typeof c=="boolean"){if(v=u.valueOf(),tr(s)){if(s<0)throw new Error("N/prob must be non-negative");if(s<=1)return f(v,s,c);if(s>1){if(!qe(s))throw new Error("N must be a positive integer");var p=s+1;m=new Array(s);for(var g=0;g<s;)m[g]=f(v,++g/p,c);return m}}if(rr(s)){var y=s.constructor;if(s.isNegative())throw new Error("N/prob must be non-negative");if(h=new y(1),s.lte(h))return new y(f(v,s,c));if(s.gt(h)){if(!s.isInteger())throw new Error("N must be a positive integer");var N=s.toNumber();if(N>4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var d=new y(N+1);m=new Array(N);for(var w=0;w<N;)m[w]=new y(f(v,new y(++w).div(d),c));return m}}if(Mt(s)){var x=s.valueOf();m=new Array(x.length);for(var b=0;b<m.length;++b){var E=x[b];if(tr(E)){if(E<0||E>1)throw new Error("Probability must be between 0 and 1, inclusive")}else if(rr(E)){if(h=new E.constructor(1),E.isNegative()||E.gt(h))throw new Error("Probability must be between 0 and 1, inclusive")}else throw new TypeError("Unexpected type of argument in function quantileSeq");m[b]=f(v,E,c)}return m}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}function f(u,s,c){var m=or(u),v=m.length;if(v===0)throw new Error("Cannot calculate quantile of an empty sequence");if(tr(s)){var h=s*(v-1),p=h%1;if(p===0){var g=c?m[h]:n(m,h);return l(g),g}var y=Math.floor(h),N,d;if(c)N=m[y],d=m[y+1];else{d=n(m,y+1),N=m[y];for(var w=0;w<y;++w)i(m[w],N)>0&&(N=m[w])}return l(N),l(d),t(a(N,1-p),a(d,p))}var x=s.times(v-1);if(x.isInteger()){x=x.toNumber();var b=c?m[x]:n(m,x);return l(b),b}var E=x.floor(),A=x.minus(E),S=E.toNumber(),D,T;if(c)D=m[S],T=m[S+1];else{T=n(m,S+1),D=m[S];for(var B=0;B<S;++B)i(m[B],D)>0&&(D=m[B])}l(D),l(T);var I=new A.constructor(1);return t(a(D,I.minus(A)),a(T,A))}var l=e({"number | BigNumber | Unit":function(s){return s}});return o}),qp="std",Y4=["typed","map","sqrt","variance"],zp=q(qp,Y4,r=>{var{typed:e,map:t,sqrt:a,variance:n}=r;return e(qp,{"Array | Matrix":i,"Array | Matrix, string":i,"Array | Matrix, number | BigNumber":i,"Array | Matrix, number | BigNumber, string":i,"...":function(f){return i(f)}});function i(o,f){if(o.length===0)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{var l=n.apply(null,arguments);return Mt(l)?t(l,a):a(l)}catch(u){throw u instanceof TypeError&&u.message.indexOf(" variance")!==-1?new TypeError(u.message.replace(" variance"," std")):u}}}),Pp="combinations",Q4=["typed"],K4=q(Pp,Q4,r=>{var{typed:e}=r;return e(Pp,{"number, number":wc,"BigNumber, BigNumber":function(a,n){var i=a.constructor,o,f,l=a.minus(n),u=new i(1);if(!Up(a)||!Up(n))throw new TypeError("Positive integer value expected in function combinations");if(n.gt(a))throw new TypeError("k must be less than n in function combinations");if(o=u,n.lt(l))for(f=u;f.lte(l);f=f.plus(u))o=o.times(n.plus(f)).dividedBy(f);else for(f=u;f.lte(n);f=f.plus(u))o=o.times(l.plus(f)).dividedBy(f);return o}})});function Up(r){return r.isInteger()&&r.gte(0)}var Lp="combinationsWithRep",j4=["typed"],eT=q(Lp,j4,r=>{var{typed:e}=r;return e(Lp,{"number, number":function(a,n){if(!qe(a)||a<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!qe(n)||n<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(a<1)throw new TypeError("k must be less than or equal to n + k - 1");if(n<a-1){var i=Xt(a,a+n-1);return i/Xt(1,n)}var o=Xt(n+1,a+n-1);return o/Xt(1,a-1)},"BigNumber, BigNumber":function(a,n){var i=a.constructor,o,f,l=new i(1),u=a.minus(l);if(!kp(a)||!kp(n))throw new TypeError("Positive integer value expected in function combinationsWithRep");if(a.lt(l))throw new TypeError("k must be less than or equal to n + k - 1 in function combinationsWithRep");if(o=l,n.lt(u))for(f=l;f.lte(u);f=f.plus(l))o=o.times(n.plus(f)).dividedBy(f);else for(f=l;f.lte(n);f=f.plus(l))o=o.times(u.plus(f)).dividedBy(f);return o}})});function kp(r){return r.isInteger()&&r.gte(0)}var Vp="gamma",rT=["typed","config","multiplyScalar","pow","BigNumber","Complex"],tT=q(Vp,rT,r=>{var{typed:e,config:t,multiplyScalar:a,pow:n,BigNumber:i,Complex:o}=r;function f(u){if(u.im===0)return Mi(u.re);if(u.re<.5){var s=new o(1-u.re,-u.im),c=new o(Math.PI*u.re,Math.PI*u.im);return new o(Math.PI).div(c.sin()).div(f(s))}u=new o(u.re-1,u.im);for(var m=new o(ia[0],0),v=1;v<ia.length;++v){var h=new o(ia[v],0);m=m.add(h.div(u.add(v)))}var p=new o(u.re+Sc+.5,u.im),g=Math.sqrt(2*Math.PI),y=p.pow(u.add(.5)),N=p.neg().exp();return m.mul(g).mul(y).mul(N)}return e(Vp,{number:Mi,Complex:f,BigNumber:function(s){if(s.isInteger())return s.isNegative()||s.isZero()?new i(1/0):l(s.minus(1));if(!s.isFinite())return new i(s.isNegative()?NaN:1/0);throw new Error("Integer BigNumber expected")}});function l(u){if(u<8)return new i([1,1,2,6,24,120,720,5040][u]);var s=t.precision+(Math.log(u.toNumber())|0),c=i.clone({precision:s});if(u%2===1)return u.times(l(new i(u-1)));for(var m=u,v=new c(u),h=u.toNumber();m>2;)m-=2,h+=m,v=v.times(h);return new i(v.toPrecision(i.precision))}}),Gp="lgamma",nT=["Complex","typed"],aT=q(Gp,nT,r=>{var{Complex:e,typed:t}=r,a=7,n=7,i=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return t(Gp,{number:Fi,Complex:o,BigNumber:function(){throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function o(u){var s=6.283185307179586,c=1.1447298858494002,m=.1;if(u.isNaN())return new e(NaN,NaN);if(u.im===0)return new e(Fi(u.re),0);if(u.re>=a||Math.abs(u.im)>=n)return f(u);if(u.re<=m){var v=og(s,u.im)*Math.floor(.5*u.re+.25),h=u.mul(Math.PI).sin().log(),p=o(new e(1-u.re,-u.im));return new e(c,v).sub(h).sub(p)}else return u.im>=0?l(u):l(u.conjugate()).conjugate()}function f(u){for(var s=u.sub(.5).mul(u.log()).sub(u).add(Cc),c=new e(1,0).div(u),m=c.div(u),v=i[0],h=i[1],p=2*m.re,g=m.re*m.re+m.im*m.im,y=2;y<8;y++){var N=h;h=-g*v+i[y],v=p*v+N}var d=c.mul(m.mul(v).add(h));return s.add(d)}function l(u){var s=0,c=0,m=u;for(u=u.add(1);u.re<=a;){m=m.mul(u);var v=m.im<0?1:0;v!==0&&c===0&&s++,c=v,u=u.add(1)}return f(u).sub(m.log()).sub(new e(0,s*2*Math.PI*1))}}),Hp="factorial",iT=["typed","gamma"],oT=q(Hp,iT,r=>{var{typed:e,gamma:t}=r;return e(Hp,{number:function(n){if(n<0)throw new Error("Value must be non-negative");return t(n+1)},BigNumber:function(n){if(n.isNegative())throw new Error("Value must be non-negative");return t(n.plus(1))},"Array | Matrix":e.referToSelf(a=>n=>je(n,a))})}),Zp="kldivergence",sT=["typed","matrix","divide","sum","multiply","map","dotDivide","log","isNumeric"],uT=q(Zp,sT,r=>{var{typed:e,matrix:t,divide:a,sum:n,multiply:i,map:o,dotDivide:f,log:l,isNumeric:u}=r;return e(Zp,{"Array, Array":function(m,v){return s(t(m),t(v))},"Matrix, Array":function(m,v){return s(m,t(v))},"Array, Matrix":function(m,v){return s(t(m),v)},"Matrix, Matrix":function(m,v){return s(m,v)}});function s(c,m){var v=m.size().length,h=c.size().length;if(v>1)throw new Error("first object must be one dimensional");if(h>1)throw new Error("second object must be one dimensional");if(v!==h)throw new Error("Length of two vectors must be equal");var p=n(c);if(p===0)throw new Error("Sum of elements in first object must be non zero");var g=n(m);if(g===0)throw new Error("Sum of elements in second object must be non zero");var y=a(c,n(c)),N=a(m,n(m)),d=n(i(y,o(f(y,N),w=>l(w))));return u(d)?d:Number.NaN}}),Jp="multinomial",lT=["typed","add","divide","multiply","factorial","isInteger","isPositive"],cT=q(Jp,lT,r=>{var{typed:e,add:t,divide:a,multiply:n,factorial:i,isInteger:o,isPositive:f}=r;return e(Jp,{"Array | Matrix":function(u){var s=0,c=1;return Jt(u,function(m){if(!o(m)||!f(m))throw new TypeError("Positive integer value expected in function multinomial");s=t(s,m),c=n(c,i(m))}),a(i(s),c)}})}),Xp="permutations",fT=["typed","factorial"],mT=q(Xp,fT,r=>{var{typed:e,factorial:t}=r;return e(Xp,{"number | BigNumber":t,"number, number":function(n,i){if(!qe(n)||n<0)throw new TypeError("Positive integer value expected in function permutations");if(!qe(i)||i<0)throw new TypeError("Positive integer value expected in function permutations");if(i>n)throw new TypeError("second argument k must be less than or equal to first argument n");return Xt(n-i+1,n)},"BigNumber, BigNumber":function(n,i){var o,f;if(!Wp(n)||!Wp(i))throw new TypeError("Positive integer value expected in function permutations");if(i.gt(n))throw new TypeError("second argument k must be less than or equal to first argument n");var l=n.mul(0).add(1);for(o=l,f=n.minus(i).plus(1);f.lte(n);f=f.plus(1))o=o.times(f);return o}})});function Wp(r){return r.isInteger()&&r.gte(0)}var Yp={exports:{}};(function(r){(function(e,t,a){function n(l){var u=this,s=f();u.next=function(){var c=2091639*u.s0+u.c*23283064365386963e-26;return u.s0=u.s1,u.s1=u.s2,u.s2=c-(u.c=c|0)},u.c=1,u.s0=s(" "),u.s1=s(" "),u.s2=s(" "),u.s0-=s(l),u.s0<0&&(u.s0+=1),u.s1-=s(l),u.s1<0&&(u.s1+=1),u.s2-=s(l),u.s2<0&&(u.s2+=1),s=null}function i(l,u){return u.c=l.c,u.s0=l.s0,u.s1=l.s1,u.s2=l.s2,u}function o(l,u){var s=new n(l),c=u&&u.state,m=s.next;return m.int32=function(){return s.next()*4294967296|0},m.double=function(){return m()+(m()*2097152|0)*11102230246251565e-32},m.quick=m,c&&(typeof c=="object"&&i(c,s),m.state=function(){return i(s,{})}),m}function f(){var l=4022871197,u=function(s){s=String(s);for(var c=0;c<s.length;c++){l+=s.charCodeAt(c);var m=.02519603282416938*l;l=m>>>0,m-=l,m*=l,l=m>>>0,m-=l,l+=m*4294967296}return(l>>>0)*23283064365386963e-26};return u}t&&t.exports?t.exports=o:a&&a.amd?a(function(){return o}):this.alea=o})(Cn,r,!1)})(Yp);var Qp={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this,u="";l.x=0,l.y=0,l.z=0,l.w=0,l.next=function(){var c=l.x^l.x<<11;return l.x=l.y,l.y=l.z,l.z=l.w,l.w^=l.w>>>19^c^c>>>8},f===(f|0)?l.x=f:u+=f;for(var s=0;s<u.length+64;s++)l.x^=u.charCodeAt(s)|0,l.next()}function i(f,l){return l.x=f.x,l.y=f.y,l.z=f.z,l.w=f.w,l}function o(f,l){var u=new n(f),s=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,h=(m+v)/(1<<21);while(h===0);return h},c.int32=u.next,c.quick=c,s&&(typeof s=="object"&&i(s,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=o:a&&a.amd?a(function(){return o}):this.xor128=o})(Cn,r,!1)})(Qp);var Kp={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this,u="";l.next=function(){var c=l.x^l.x>>>2;return l.x=l.y,l.y=l.z,l.z=l.w,l.w=l.v,(l.d=l.d+362437|0)+(l.v=l.v^l.v<<4^(c^c<<1))|0},l.x=0,l.y=0,l.z=0,l.w=0,l.v=0,f===(f|0)?l.x=f:u+=f;for(var s=0;s<u.length+64;s++)l.x^=u.charCodeAt(s)|0,s==u.length&&(l.d=l.x<<10^l.x>>>4),l.next()}function i(f,l){return l.x=f.x,l.y=f.y,l.z=f.z,l.w=f.w,l.v=f.v,l.d=f.d,l}function o(f,l){var u=new n(f),s=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,h=(m+v)/(1<<21);while(h===0);return h},c.int32=u.next,c.quick=c,s&&(typeof s=="object"&&i(s,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=o:a&&a.amd?a(function(){return o}):this.xorwow=o})(Cn,r,!1)})(Kp);var jp={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this;l.next=function(){var s=l.x,c=l.i,m,v;return m=s[c],m^=m>>>7,v=m^m<<24,m=s[c+1&7],v^=m^m>>>10,m=s[c+3&7],v^=m^m>>>3,m=s[c+4&7],v^=m^m<<7,m=s[c+7&7],m=m^m<<13,v^=m^m<<9,s[c]=v,l.i=c+1&7,v};function u(s,c){var m,v=[];if(c===(c|0))v[0]=c;else for(c=""+c,m=0;m<c.length;++m)v[m&7]=v[m&7]<<15^c.charCodeAt(m)+v[m+1&7]<<13;for(;v.length<8;)v.push(0);for(m=0;m<8&&v[m]===0;++m);for(m==8?v[7]=-1:v[m],s.x=v,s.i=0,m=256;m>0;--m)s.next()}u(l,f)}function i(f,l){return l.x=f.x.slice(),l.i=f.i,l}function o(f,l){f==null&&(f=+new Date);var u=new n(f),s=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,h=(m+v)/(1<<21);while(h===0);return h},c.int32=u.next,c.quick=c,s&&(s.x&&i(s,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=o:a&&a.amd?a(function(){return o}):this.xorshift7=o})(Cn,r,!1)})(jp);var eh={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this;l.next=function(){var s=l.w,c=l.X,m=l.i,v,h;return l.w=s=s+1640531527|0,h=c[m+34&127],v=c[m=m+1&127],h^=h<<13,v^=v<<17,h^=h>>>15,v^=v>>>12,h=c[m]=h^v,l.i=m,h+(s^s>>>16)|0};function u(s,c){var m,v,h,p,g,y=[],N=128;for(c===(c|0)?(v=c,c=null):(c=c+"\0",v=0,N=Math.max(N,c.length)),h=0,p=-32;p<N;++p)c&&(v^=c.charCodeAt((p+32)%c.length)),p===0&&(g=v),v^=v<<10,v^=v>>>15,v^=v<<4,v^=v>>>13,p>=0&&(g=g+1640531527|0,m=y[p&127]^=v+g,h=m==0?h+1:0);for(h>=128&&(y[(c&&c.length||0)&127]=-1),h=127,p=4*128;p>0;--p)v=y[h+34&127],m=y[h=h+1&127],v^=v<<13,m^=m<<17,v^=v>>>15,m^=m>>>12,y[h]=v^m;s.w=g,s.X=y,s.i=h}u(l,f)}function i(f,l){return l.i=f.i,l.w=f.w,l.X=f.X.slice(),l}function o(f,l){f==null&&(f=+new Date);var u=new n(f),s=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,h=(m+v)/(1<<21);while(h===0);return h},c.int32=u.next,c.quick=c,s&&(s.X&&i(s,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=o:a&&a.amd?a(function(){return o}):this.xor4096=o})(Cn,r,!1)})(eh);var rh={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this,u="";l.next=function(){var c=l.b,m=l.c,v=l.d,h=l.a;return c=c<<25^c>>>7^m,m=m-v|0,v=v<<24^v>>>8^h,h=h-c|0,l.b=c=c<<20^c>>>12^m,l.c=m=m-v|0,l.d=v<<16^m>>>16^h,l.a=h-c|0},l.a=0,l.b=0,l.c=-1640531527,l.d=1367130551,f===Math.floor(f)?(l.a=f/4294967296|0,l.b=f|0):u+=f;for(var s=0;s<u.length+20;s++)l.b^=u.charCodeAt(s)|0,l.next()}function i(f,l){return l.a=f.a,l.b=f.b,l.c=f.c,l.d=f.d,l}function o(f,l){var u=new n(f),s=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,h=(m+v)/(1<<21);while(h===0);return h},c.int32=u.next,c.quick=c,s&&(typeof s=="object"&&i(s,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=o:a&&a.amd?a(function(){return o}):this.tychei=o})(Cn,r,!1)})(rh);var th={exports:{}};const vT=A1(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(r){(function(e,t,a){var n=256,i=6,o=52,f="random",l=a.pow(n,i),u=a.pow(2,o),s=u*2,c=n-1,m;function v(w,x,b){var E=[];x=x==!0?{entropy:!0}:x||{};var A=y(g(x.entropy?[w,d(t)]:w==null?N():w,3),E),S=new h(E),D=function(){for(var T=S.g(i),B=l,I=0;T<u;)T=(T+I)*n,B*=n,I=S.g(1);for(;T>=s;)T/=2,B/=2,I>>>=1;return(T+I)/B};return D.int32=function(){return S.g(4)|0},D.quick=function(){return S.g(4)/4294967296},D.double=D,y(d(S.S),t),(x.pass||b||function(T,B,I,P){return P&&(P.S&&p(P,S),T.state=function(){return p(S,{})}),I?(a[f]=T,B):T})(D,A,"global"in x?x.global:this==a,x.state)}function h(w){var x,b=w.length,E=this,A=0,S=E.i=E.j=0,D=E.S=[];for(b||(w=[b++]);A<n;)D[A]=A++;for(A=0;A<n;A++)D[A]=D[S=c&S+w[A%b]+(x=D[A])],D[S]=x;(E.g=function(T){for(var B,I=0,P=E.i,R=E.j,M=E.S;T--;)B=M[P=c&P+1],I=I*n+M[c&(M[P]=M[R=c&R+B])+(M[R]=B)];return E.i=P,E.j=R,I})(n)}function p(w,x){return x.i=w.i,x.j=w.j,x.S=w.S.slice(),x}function g(w,x){var b=[],E=typeof w,A;if(x&&E=="object")for(A in w)try{b.push(g(w[A],x-1))}catch{}return b.length?b:E=="string"?w:w+"\0"}function y(w,x){for(var b=w+"",E,A=0;A<b.length;)x[c&A]=c&(E^=x[c&A]*19)+b.charCodeAt(A++);return d(x)}function N(){try{var w;return m&&(w=m.randomBytes)?w=w(n):(w=new Uint8Array(n),(e.crypto||e.msCrypto).getRandomValues(w)),d(w)}catch{var x=e.navigator,b=x&&x.plugins;return[+new Date,e,b,e.screen,d(t)]}}function d(w){return String.fromCharCode.apply(0,w)}if(y(a.random(),t),r.exports){r.exports=v;try{m=vT}catch{}}else a["seed"+f]=v})(typeof self<"u"?self:Cn,[],Math)})(th);var pT=Yp.exports,hT=Qp.exports,dT=Kp.exports,gT=jp.exports,yT=eh.exports,bT=rh.exports,Bn=th.exports;Bn.alea=pT,Bn.xor128=hT,Bn.xorwow=dT,Bn.xorshift7=gT,Bn.xor4096=yT,Bn.tychei=bT;var nh=Bn,xT=nh(Date.now());function fa(r){var e;function t(n){e=n===null?xT:nh(String(n))}t(r);function a(){return e()}return a}var ah="pickRandom",wT=["typed","config","?on"],NT=q(ah,wT,r=>{var{typed:e,config:t,on:a}=r,n=fa(t.randomSeed);return a&&a("config",function(o,f){o.randomSeed!==f.randomSeed&&(n=fa(o.randomSeed))}),e(ah,{"Array | Matrix":function(f){return i(f,{})},"Array | Matrix, Object":function(f,l){return i(f,l)},"Array | Matrix, number":function(f,l){return i(f,{number:l})},"Array | Matrix, Array | Matrix":function(f,l){return i(f,{weights:l})},"Array | Matrix, Array | Matrix, number":function(f,l,u){return i(f,{number:u,weights:l})},"Array | Matrix, number, Array | Matrix":function(f,l,u){return i(f,{number:l,weights:u})}});function i(o,f){var{number:l,weights:u,elementWise:s=!0}=f,c=typeof l>"u";c&&(l=1);var m=Ve(o)?o.create:Ve(u)?u.create:null;o=o.valueOf(),u&&(u=u.valueOf()),s===!0&&(o=or(o),u=or(u));var v=0;if(typeof u<"u"){if(u.length!==o.length)throw new Error("Weights must have the same length as possibles");for(var h=0,p=u.length;h<p;h++){if(!tr(u[h])||u[h]<0)throw new Error("Weights must be an array of positive numbers");v+=u[h]}}for(var g=o.length,y=[],N;y.length<l;){if(typeof u>"u")N=o[Math.floor(n()*g)];else for(var d=n()*v,w=0,x=o.length;w<x;w++)if(d-=u[w],d<0){N=o[w];break}y.push(N)}return c?y[0]:m?m(y):y}});function Es(r,e){var t=[];if(r=r.slice(0),r.length>1)for(var a=0,n=r.shift();a<n;a++)t.push(Es(r,e));else for(var i=0,o=r.shift();i<o;i++)t.push(e());return t}var ih="random",DT=["typed","config","?on"],AT=q(ih,DT,r=>{var{typed:e,config:t,on:a}=r,n=fa(t.randomSeed);return a&&a("config",function(f,l){f.randomSeed!==l.randomSeed&&(n=fa(f.randomSeed))}),e(ih,{"":()=>o(0,1),number:f=>o(0,f),"number, number":(f,l)=>o(f,l),"Array | Matrix":f=>i(f,0,1),"Array | Matrix, number":(f,l)=>i(f,0,l),"Array | Matrix, number, number":(f,l,u)=>i(f,l,u)});function i(f,l,u){var s=Es(f.valueOf(),()=>o(l,u));return Ve(f)?f.create(s):s}function o(f,l){return f+n()*(l-f)}}),oh="randomInt",ET=["typed","config","?on"],ST=q(oh,ET,r=>{var{typed:e,config:t,on:a}=r,n=fa(t.randomSeed);return a&&a("config",function(f,l){f.randomSeed!==l.randomSeed&&(n=fa(f.randomSeed))}),e(oh,{"":()=>o(0,1),number:f=>o(0,f),"number, number":(f,l)=>o(f,l),"Array | Matrix":f=>i(f,0,1),"Array | Matrix, number":(f,l)=>i(f,0,l),"Array | Matrix, number, number":(f,l,u)=>i(f,l,u)});function i(f,l,u){var s=Es(f.valueOf(),()=>o(l,u));return Ve(f)?f.create(s):s}function o(f,l){return Math.floor(f+n()*(l-f))}}),sh="stirlingS2",CT=["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],MT=q(sh,CT,r=>{var{typed:e,addScalar:t,subtract:a,multiplyScalar:n,divideScalar:i,pow:o,factorial:f,combinations:l,isNegative:u,isInteger:s,number:c,bignumber:m,larger:v}=r,h=[],p=[];return e(sh,{"number | BigNumber, number | BigNumber":function(y,N){if(!s(y)||u(y)||!s(N)||u(N))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(v(N,y))throw new TypeError("k must be less than or equal to n in function stirlingS2");var d=!(tr(y)&&tr(N)),w=d?p:h,x=d?m:c,b=c(y),E=c(N);if(w[b]&&w[b].length>E)return w[b][E];for(var A=0;A<=b;++A)if(w[A]||(w[A]=[x(A===0?1:0)]),A!==0)for(var S=w[A],D=w[A-1],T=S.length;T<=A&&T<=E;++T)T===A?S[T]=1:S[T]=t(n(x(T),D[T]),D[T-1]);return w[b][E]}})}),uh="bellNumbers",FT=["typed","addScalar","isNegative","isInteger","stirlingS2"],TT=q(uh,FT,r=>{var{typed:e,addScalar:t,isNegative:a,isInteger:n,stirlingS2:i}=r;return e(uh,{"number | BigNumber":function(f){if(!n(f)||a(f))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var l=0,u=0;u<=f;u++)l=t(l,i(f,u));return l}})}),lh="catalan",BT=["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],$T=q(lh,BT,r=>{var{typed:e,addScalar:t,divideScalar:a,multiplyScalar:n,combinations:i,isNegative:o,isInteger:f}=r;return e(lh,{"number | BigNumber":function(u){if(!f(u)||o(u))throw new TypeError("Non-negative integer value expected in function catalan");return a(i(n(u,2),u),t(u,1))}})}),ch="composition",OT=["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],IT=q(ch,OT,r=>{var{typed:e,addScalar:t,combinations:a,isPositive:n,isNegative:i,isInteger:o,larger:f}=r;return e(ch,{"number | BigNumber, number | BigNumber":function(u,s){if(!o(u)||!n(u)||!o(s)||!n(s))throw new TypeError("Positive integer value expected in function composition");if(f(s,u))throw new TypeError("k must be less than or equal to n in function composition");return a(t(u,-1),t(s,-1))}})}),fh="leafCount",RT=["parse","typed"],_T=q(fh,RT,r=>{var{parse:e,typed:t}=r;function a(n){var i=0;return n.forEach(o=>{i+=a(o)}),i||1}return t(fh,{Node:function(i){return a(i)}})});function mh(r){return ir(r)||Br(r)&&r.isUnary()&&ir(r.args[0])}function oo(r){return!!(ir(r)||(rn(r)||Br(r))&&r.args.every(oo)||Vt(r)&&oo(r.content))}function vh(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);e&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,a)}return t}function Ss(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?vh(Object(t),!0).forEach(function(a){zr(r,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):vh(Object(t)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(t,a))})}return r}var qT="simplifyUtil",zT=["FunctionNode","OperatorNode","SymbolNode"],Cs=q(qT,zT,r=>{var{FunctionNode:e,OperatorNode:t,SymbolNode:a}=r,n=!0,i=!1,o="defaultF",f={add:{trivial:n,total:n,commutative:n,associative:n},unaryPlus:{trivial:n,total:n,commutative:n,associative:n},subtract:{trivial:i,total:n,commutative:i,associative:i},multiply:{trivial:n,total:n,commutative:n,associative:n},divide:{trivial:i,total:n,commutative:i,associative:i},paren:{trivial:n,total:n,commutative:n,associative:i},defaultF:{trivial:i,total:n,commutative:i,associative:i}},l={divide:{total:i},log:{total:i}},u={subtract:{total:i},abs:{trivial:n},log:{total:n}};function s(d,w){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:f,b=o;if(typeof d=="string"?b=d:Br(d)?b=d.fn.toString():rn(d)?b=d.name:Vt(d)&&(b="paren"),Re(x,b)){var E=x[b];if(Re(E,w))return E[w];if(Re(f,b))return f[b][w]}if(Re(x,o)){var A=x[o];return Re(A,w)?A[w]:f[o][w]}if(Re(f,b)){var S=f[b];if(Re(S,w))return S[w]}return f[o][w]}function c(d){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f;return s(d,"commutative",w)}function m(d){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f;return s(d,"associative",w)}function v(d,w){var x=Ss({},d);for(var b in w)Re(d,b)?x[b]=Ss(Ss({},w[b]),d[b]):x[b]=w[b];return x}function h(d,w){if(!d.args||d.args.length===0)return d;d.args=p(d,w);for(var x=0;x<d.args.length;x++)h(d.args[x],w)}function p(d,w){var x,b=[],E=function A(S){for(var D=0;D<S.args.length;D++){var T=S.args[D];Br(T)&&x===T.op?A(T):b.push(T)}};return m(d,w)?(x=d.op,E(d),b):d.args}function g(d,w){if(!(!d.args||d.args.length===0)){for(var x=N(d),b=d.args.length,E=0;E<b;E++)g(d.args[E],w);if(b>2&&m(d,w)){for(var A=d.args.pop();d.args.length>0;)A=x([d.args.pop(),A]);d.args=A.args}}}function y(d,w){if(!(!d.args||d.args.length===0)){for(var x=N(d),b=d.args.length,E=0;E<b;E++)y(d.args[E],w);if(b>2&&m(d,w)){for(var A=d.args.shift();d.args.length>0;)A=x([A,d.args.shift()]);d.args=A.args}}}function N(d){return Br(d)?function(w){try{return new t(d.op,d.fn,w,d.implicit)}catch(x){return console.error(x),[]}}:function(w){return new e(new a(d.name),w)}}return{createMakeNodeFunction:N,hasProperty:s,isCommutative:c,isAssociative:m,mergeContext:v,flatten:h,allChildren:p,unflattenr:g,unflattenl:y,defaultContext:f,realContext:l,positiveContext:u}}),PT="simplify",UT=["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","resolve","simplifyConstant","simplifyCore","?fraction","?bignumber","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],LT=q(PT,UT,r=>{var{config:e,typed:t,parse:a,add:n,subtract:i,multiply:o,divide:f,pow:l,isZero:u,equal:s,resolve:c,simplifyConstant:m,simplifyCore:v,fraction:h,bignumber:p,mathWithTransform:g,matrix:y,AccessorNode:N,ArrayNode:d,ConstantNode:w,FunctionNode:x,IndexNode:b,ObjectNode:E,OperatorNode:A,ParenthesisNode:S,SymbolNode:D}=r,{hasProperty:T,isCommutative:B,isAssociative:I,mergeContext:P,flatten:R,unflattenr:M,unflattenl:F,createMakeNodeFunction:H,defaultContext:$,realContext:k,positiveContext:Q}=Cs({FunctionNode:x,OperatorNode:A,SymbolNode:D});t.addConversion({from:"Object",to:"Map",convert:ea});var K=t("simplify",{Node:ce,"Node, Map":(G,Y)=>ce(G,!1,Y),"Node, Map, Object":(G,Y,te)=>ce(G,!1,Y,te),"Node, Array":ce,"Node, Array, Map":ce,"Node, Array, Map, Object":ce});t.removeConversion({from:"Object",to:"Map",convert:ea}),K.defaultContext=$,K.realContext=k,K.positiveContext=Q;function L(G){return G.transform(function(Y,te,ye){return Vt(Y)?L(Y.content):Y})}var j={true:!0,false:!0,e:!0,i:!0,Infinity:!0,LN2:!0,LN10:!0,LOG2E:!0,LOG10E:!0,NaN:!0,phi:!0,pi:!0,SQRT1_2:!0,SQRT2:!0,tau:!0};K.rules=[v,{l:"log(e)",r:"1"},{s:"n-n1 -> n+-n1",assuming:{subtract:{total:!0}}},{s:"n-n -> 0",assuming:{subtract:{total:!1}}},{s:"-(cl*v) -> v * (-cl)",assuming:{multiply:{commutative:!0},subtract:{total:!0}}},{s:"-(cl*v) -> (-cl) * v",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{s:"-(v*cl) -> v * (-cl)",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{l:"-(n1/n2)",r:"-n1/n2"},{l:"-v",r:"v * (-1)"},{l:"(n1 + n2)*(-1)",r:"n1*(-1) + n2*(-1)",repeat:!0},{l:"n/n1^n2",r:"n*n1^-n2"},{l:"n/n1",r:"n*n1^-1"},{s:"(n1*n2)^n3 -> n1^n3 * n2^n3",assuming:{multiply:{commutative:!0}}},{s:"(n1*n2)^(-1) -> n2^(-1) * n1^(-1)",assuming:{multiply:{commutative:!1}}},{s:"(n ^ n1) ^ n2 -> n ^ (n1 * n2)",assuming:{divide:{total:!0}}},{l:" vd * ( vd * n1 + n2)",r:"vd^2 * n1 + vd * n2"},{s:" vd * (vd^n4 * n1 + n2) -> vd^(1+n4) * n1 + vd * n2",assuming:{divide:{total:!0}}},{s:"vd^n3 * ( vd * n1 + n2) -> vd^(n3+1) * n1 + vd^n3 * n2",assuming:{divide:{total:!0}}},{s:"vd^n3 * (vd^n4 * n1 + n2) -> vd^(n3+n4) * n1 + vd^n3 * n2",assuming:{divide:{total:!0}}},{l:"n*n",r:"n^2"},{s:"n * n^n1 -> n^(n1+1)",assuming:{divide:{total:!0}}},{s:"n^n1 * n^n2 -> n^(n1+n2)",assuming:{divide:{total:!0}}},m,{s:"n+n -> 2*n",assuming:{add:{total:!0}}},{l:"n+-n",r:"0"},{l:"vd*n + vd",r:"vd*(n+1)"},{l:"n3*n1 + n3*n2",r:"n3*(n1+n2)"},{l:"n3^(-n4)*n1 + n3 * n2",r:"n3^(-n4)*(n1 + n3^(n4+1) *n2)"},{l:"n3^(-n4)*n1 + n3^n5 * n2",r:"n3^(-n4)*(n1 + n3^(n4+n5)*n2)"},{s:"n*vd + vd -> (n+1)*vd",assuming:{multiply:{commutative:!1}}},{s:"vd + n*vd -> (1+n)*vd",assuming:{multiply:{commutative:!1}}},{s:"n1*n3 + n2*n3 -> (n1+n2)*n3",assuming:{multiply:{commutative:!1}}},{s:"n^n1 * n -> n^(n1+1)",assuming:{divide:{total:!0},multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3 -> (n1 + n2*n3^(n4 + 1))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3^n5 -> (n1 + n2*n3^(n4 + n5))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{l:"n*cd + cd",r:"(n+1)*cd"},{s:"cd*n + cd -> cd*(n+1)",assuming:{multiply:{commutative:!1}}},{s:"cd + cd*n -> cd*(1+n)",assuming:{multiply:{commutative:!1}}},m,{s:"(-n)*n1 -> -(n*n1)",assuming:{subtract:{total:!0}}},{s:"n1*(-n) -> -(n1*n)",assuming:{subtract:{total:!0},multiply:{commutative:!1}}},{s:"ce+ve -> ve+ce",assuming:{add:{commutative:!0}},imposeContext:{add:{commutative:!1}}},{s:"vd*cd -> cd*vd",assuming:{multiply:{commutative:!0}},imposeContext:{multiply:{commutative:!1}}},{l:"n+-n1",r:"n-n1"},{s:"n*(n1^-1) -> n/n1",assuming:{multiply:{commutative:!0}}},{s:"n*n1^-n2 -> n/n1^n2",assuming:{multiply:{commutative:!0}}},{s:"n^-1 -> 1/n",assuming:{multiply:{commutative:!0}}},{l:"n^1",r:"n"},{s:"n*(n1/n2) -> (n*n1)/n2",assuming:{multiply:{associative:!0}}},{s:"n-(n1+n2) -> n-n1-n2",assuming:{addition:{associative:!0,commutative:!0}}},{l:"1*n",r:"n",imposeContext:{multiply:{commutative:!0}}},{s:"n1/(n2/n3) -> (n1*n3)/n2",assuming:{multiply:{associative:!0}}},{l:"n1/(-n2)",r:"-n1/n2"}];function ae(G,Y){var te={};if(G.s){var ye=G.s.split("->");if(ye.length===2)te.l=ye[0],te.r=ye[1];else throw SyntaxError("Could not parse rule: "+G.s)}else te.l=G.l,te.r=G.r;te.l=L(a(te.l)),te.r=L(a(te.r));for(var me of["imposeContext","repeat","assuming"])me in G&&(te[me]=G[me]);if(G.evaluate&&(te.evaluate=a(G.evaluate)),I(te.l,Y)){var z=!B(te.l,Y),U;z&&(U=he());var ee=H(te.l),ue=he();te.expanded={},te.expanded.l=ee([te.l,ue]),R(te.expanded.l,Y),M(te.expanded.l,Y),te.expanded.r=ee([te.r,ue]),z&&(te.expandedNC1={},te.expandedNC1.l=ee([U,te.l]),te.expandedNC1.r=ee([U,te.r]),te.expandedNC2={},te.expandedNC2.l=ee([U,te.expanded.l]),te.expandedNC2.r=ee([U,te.expanded.r]))}return te}function re(G,Y){for(var te=[],ye=0;ye<G.length;ye++){var me=G[ye],z=void 0,U=typeof me;switch(U){case"string":me={s:me};case"object":z=ae(me,Y);break;case"function":z=me;break;default:throw TypeError("Unsupported type of rule: "+U)}te.push(z)}return te}var fe=0;function he(){return new D("_p"+fe++)}function ce(G,Y){var te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:jn(),ye=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},me=ye.consoleDebug;Y=re(Y||K.rules,ye.context);var z=c(G,te);z=L(z);for(var U={},ee=z.toString({parenthesis:"all"});!U[ee];){U[ee]=!0,fe=0;var ue=ee;me&&console.log("Working on: ",ee);for(var ve=0;ve<Y.length;ve++){var de="";if(typeof Y[ve]=="function"?(z=Y[ve](z,ye),me&&(de=Y[ve].name)):(R(z,ye.context),z=Ae(z,Y[ve],ye.context),me&&(de="".concat(Y[ve].l.toString()," -> ").concat(Y[ve].r.toString()))),me){var be=z.toString({parenthesis:"all"});be!==ue&&(console.log("Applying",de,"produced",be),ue=be)}F(z,ye.context)}ee=z.toString({parenthesis:"all"})}return z}function ie(G,Y,te){var ye=G;if(G)for(var me=0;me<G.length;++me){var z=Ae(G[me],Y,te);z!==G[me]&&(ye===G&&(ye=G.slice()),ye[me]=z)}return ye}function Ae(G,Y,te){if(Y.assuming){for(var ye in Y.assuming)for(var me in Y.assuming[ye])if(T(ye,me,te)!==Y.assuming[ye][me])return G}var z=P(Y.imposeContext,te),U=G;if(U instanceof A||U instanceof x){var ee=ie(U.args,Y,te);ee!==U.args&&(U=U.clone(),U.args=ee)}else if(U instanceof S){if(U.content){var ue=Ae(U.content,Y,te);ue!==U.content&&(U=new S(ue))}}else if(U instanceof d){var ve=ie(U.items,Y,te);ve!==U.items&&(U=new d(ve))}else if(U instanceof N){var de=U.object;U.object&&(de=Ae(U.object,Y,te));var be=U.index;U.index&&(be=Ae(U.index,Y,te)),(de!==U.object||be!==U.index)&&(U=new N(de,be))}else if(U instanceof b){var pe=ie(U.dimensions,Y,te);pe!==U.dimensions&&(U=new b(pe))}else if(U instanceof E){var we=!1,_e={};for(var Le in U.properties)_e[Le]=Ae(U.properties[Le],Y,te),_e[Le]!==U.properties[Le]&&(we=!0);we&&(U=new E(_e))}var Be=Y.r,ar=X(Y.l,U,z)[0];if(!ar&&Y.expanded&&(Be=Y.expanded.r,ar=X(Y.expanded.l,U,z)[0]),!ar&&Y.expandedNC1&&(Be=Y.expandedNC1.r,ar=X(Y.expandedNC1.l,U,z)[0],ar||(Be=Y.expandedNC2.r,ar=X(Y.expandedNC2.l,U,z)[0])),ar){var Je=U.implicit;U=Be.clone(),Je&&"implicit"in Be&&(U.implicit=!0),U=U.transform(function(mr){return mr.isSymbolNode&&Re(ar.placeholders,mr.name)?ar.placeholders[mr.name].clone():mr})}return Y.repeat&&U!==G&&(U=Ae(U,Y,te)),U}function Oe(G,Y){var te=[],ye,me,z=H(G);if(B(G,Y))for(var U=0;U<G.args.length;U++)me=G.args.slice(0),me.splice(U,1),ye=me.length===1?me[0]:z(me),te.push(z([G.args[U],ye]));else for(var ee=1;ee<G.args.length;ee++){var ue=G.args[0];ee>1&&(ue=z(G.args.slice(0,ee))),me=G.args.slice(ee),ye=me.length===1?me[0]:z(me),te.push(z([ue,ye]))}return te}function Ce(G,Y){var te={placeholders:{}};if(!G.placeholders&&!Y.placeholders)return te;if(G.placeholders){if(!Y.placeholders)return G}else return Y;for(var ye in G.placeholders)if(Re(G.placeholders,ye)&&(te.placeholders[ye]=G.placeholders[ye],Re(Y.placeholders,ye)&&!oe(G.placeholders[ye],Y.placeholders[ye])))return null;for(var me in Y.placeholders)Re(Y.placeholders,me)&&(te.placeholders[me]=Y.placeholders[me]);return te}function $e(G,Y){var te=[];if(G.length===0||Y.length===0)return te;for(var ye,me=0;me<G.length;me++)for(var z=0;z<Y.length;z++)ye=Ce(G[me],Y[z]),ye&&te.push(ye);return te}function V(G){if(G.length===0)return G;for(var Y=G.reduce($e),te=[],ye={},me=0;me<Y.length;me++){var z=JSON.stringify(Y[me]);ye[z]||(ye[z]=!0,te.push(Y[me]))}return te}function X(G,Y,te,ye){var me=[{placeholders:{}}];if(G instanceof A&&Y instanceof A||G instanceof x&&Y instanceof x){if(G instanceof A){if(G.op!==Y.op||G.fn!==Y.fn)return[]}else if(G instanceof x&&G.name!==Y.name)return[];if(Y.args.length===1&&G.args.length===1||!I(Y,te)&&Y.args.length===G.args.length||ye){for(var z=[],U=0;U<G.args.length;U++){var ee=X(G.args[U],Y.args[U],te);if(ee.length===0)break;z.push(ee)}if(z.length!==G.args.length){if(!B(Y,te)||G.args.length===1)return[];if(G.args.length>2)throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");var ue=X(G.args[0],Y.args[1],te);if(ue.length===0)return[];var ve=X(G.args[1],Y.args[0],te);if(ve.length===0)return[];z=[ue,ve]}me=V(z)}else if(Y.args.length>=2&&G.args.length===2){for(var de=Oe(Y,te),be=[],pe=0;pe<de.length;pe++){var we=X(G,de[pe],te,!0);be=be.concat(we)}return be}else{if(G.args.length>2)throw Error("Unexpected non-binary associative function: "+G.toString());return[]}}else if(G instanceof D){if(G.name.length===0)throw new Error("Symbol in rule has 0 length...!?");if(j[G.name]){if(G.name!==Y.name)return[]}else switch(G.name[1]>="a"&&G.name[1]<="z"?G.name.substring(0,2):G.name[0]){case"n":case"_p":me[0].placeholders[G.name]=Y;break;case"c":case"cl":if(ir(Y))me[0].placeholders[G.name]=Y;else return[];break;case"v":if(!ir(Y))me[0].placeholders[G.name]=Y;else return[];break;case"vl":if(qr(Y))me[0].placeholders[G.name]=Y;else return[];break;case"cd":if(mh(Y))me[0].placeholders[G.name]=Y;else return[];break;case"vd":if(!mh(Y))me[0].placeholders[G.name]=Y;else return[];break;case"ce":if(oo(Y))me[0].placeholders[G.name]=Y;else return[];break;case"ve":if(!oo(Y))me[0].placeholders[G.name]=Y;else return[];break;default:throw new Error("Invalid symbol in rule: "+G.name)}}else if(G instanceof w){if(!s(G.value,Y.value))return[]}else return[];return me}function oe(G,Y){if(G instanceof w&&Y instanceof w){if(!s(G.value,Y.value))return!1}else if(G instanceof D&&Y instanceof D){if(G.name!==Y.name)return!1}else if(G instanceof A&&Y instanceof A||G instanceof x&&Y instanceof x){if(G instanceof A){if(G.op!==Y.op||G.fn!==Y.fn)return!1}else if(G instanceof x&&G.name!==Y.name)return!1;if(G.args.length!==Y.args.length)return!1;for(var te=0;te<G.args.length;te++)if(!oe(G.args[te],Y.args[te]))return!1}else return!1;return!0}return K}),kT="simplifyConstant",VT=["typed","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],GT=q(kT,VT,r=>{var{typed:e,config:t,mathWithTransform:a,matrix:n,fraction:i,bignumber:o,AccessorNode:f,ArrayNode:l,ConstantNode:u,FunctionNode:s,IndexNode:c,ObjectNode:m,OperatorNode:v,SymbolNode:h}=r,{isCommutative:p,isAssociative:g,allChildren:y,createMakeNodeFunction:N}=Cs({FunctionNode:s,OperatorNode:v,SymbolNode:h}),d=e("simplifyConstant",{Node:R=>E(P(R,{})),"Node, Object":function(M,F){return E(P(M,F))}});function w(R){return qa(R)?R.valueOf():R instanceof Array?R.map(w):Ve(R)?n(w(R.valueOf())):R}function x(R,M,F){try{return a[R].apply(null,M)}catch{return M=M.map(w),S(a[R].apply(null,M),F)}}var b=e({Fraction:T,number:function(M){return M<0?D(new u(-M)):new u(M)},BigNumber:function(M){return M<0?D(new u(-M)):new u(M)},Complex:function(M){throw new Error("Cannot convert Complex number to Node")},string:function(M){return new u(M)},Matrix:function(M){return new l(M.valueOf().map(F=>b(F)))}});function E(R){return fr(R)?R:b(R)}function A(R,M){var F=M&&M.exactFractions!==!1;if(F&&isFinite(R)&&i){var H=i(R),$=M&&typeof M.fractionsLimit=="number"?M.fractionsLimit:1/0;if(H.valueOf()===R&&H.n<$&&H.d<$)return H}return R}var S=e({"string, Object":function(M,F){if(t.number==="BigNumber")return o===void 0&&ps(),o(M);if(t.number==="Fraction")return i===void 0&&lm(),i(M);var H=parseFloat(M);return A(H,F)},"Fraction, Object":function(M,F){return M},"BigNumber, Object":function(M,F){return M},"number, Object":function(M,F){return A(M,F)},"Complex, Object":function(M,F){return M.im!==0?M:A(M.re,F)},"Matrix, Object":function(M,F){return n(A(M.valueOf()))},"Array, Object":function(M,F){return M.map(A)}});function D(R){return new v("-","unaryMinus",[R])}function T(R){var M,F=R.s*R.n;return F<0?M=new v("-","unaryMinus",[new u(-F)]):M=new u(F),R.d===1?M:new v("/","divide",[M,new u(R.d)])}function B(R,M,F){if(!Zn(M))return new f(E(R),E(M));if(it(R)||Ve(R)){for(var H=Array.from(M.dimensions);H.length>0;)if(ir(H[0])&&typeof H[0].value!="string"){var $=S(H.shift().value,F);it(R)?R=R.items[$-1]:(R=R.valueOf()[$-1],R instanceof Array&&(R=n(R)))}else if(H.length>1&&ir(H[1])&&typeof H[1].value!="string"){var k=S(H[1].value,F),Q=[],K=it(R)?R.items:R.valueOf();for(var L of K)if(it(L))Q.push(L.items[k-1]);else if(Ve(R))Q.push(L[k-1]);else break;if(Q.length===K.length)it(R)?R=new l(Q):R=n(Q),H.splice(1,1);else break}else break;return H.length===M.dimensions.length?new f(E(R),M):H.length>0?(M=new c(H),new f(E(R),M)):R}if(ci(R)&&M.dimensions.length===1&&ir(M.dimensions[0])){var j=M.dimensions[0].value;return j in R.properties?R.properties[j]:new u}return new f(E(R),M)}function I(R,M,F,H){var $=M.shift(),k=M.reduce((Q,K)=>{if(!fr(K)){var L=Q.pop();if(fr(L))return[L,K];try{return Q.push(x(R,[L,K],H)),Q}catch{Q.push(L)}}Q.push(E(Q.pop()));var j=Q.length===1?Q[0]:F(Q);return[F([j,E(K)])]},[$]);return k.length===1?k[0]:F([k[0],b(k[1])])}function P(R,M){switch(R.type){case"SymbolNode":return R;case"ConstantNode":switch(typeof R.value){case"number":return S(R.value,M);case"string":return R.value;default:if(!isNaN(R.value))return S(R.value,M)}return R;case"FunctionNode":if(a[R.name]&&a[R.name].rawArgs)return R;{var F=["add","multiply"];if(F.indexOf(R.name)===-1){var H=R.args.map(Ae=>P(Ae,M));if(!H.some(fr))try{return x(R.name,H,M)}catch{}if(R.name==="size"&&H.length===1&&it(H[0])){for(var $=[],k=H[0];it(k);)$.push(k.items.length),k=k.items[0];return n($)}return new s(R.name,H.map(E))}}case"OperatorNode":{var Q=R.fn.toString(),K,L,j=N(R);if(Br(R)&&R.isUnary())K=[P(R.args[0],M)],fr(K[0])?L=j(K):L=x(Q,K,M);else if(g(R,M.context))if(K=y(R,M.context),K=K.map(Ae=>P(Ae,M)),p(Q,M.context)){for(var ae=[],re=[],fe=0;fe<K.length;fe++)fr(K[fe])?re.push(K[fe]):ae.push(K[fe]);ae.length>1?(L=I(Q,ae,j,M),re.unshift(L),L=I(Q,re,j,M)):L=I(Q,K,j,M)}else L=I(Q,K,j,M);else K=R.args.map(Ae=>P(Ae,M)),L=I(Q,K,j,M);return L}case"ParenthesisNode":return P(R.content,M);case"AccessorNode":return B(P(R.object,M),P(R.index,M),M);case"ArrayNode":{var he=R.items.map(Ae=>P(Ae,M));return he.some(fr)?new l(he.map(E)):n(he)}case"IndexNode":return new c(R.dimensions.map(Ae=>d(Ae,M)));case"ObjectNode":{var ce={};for(var ie in R.properties)ce[ie]=d(R.properties[ie],M);return new m(ce)}case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"RangeNode":case"ConditionalNode":default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(R.type))}}return d}),ph="simplifyCore",HT=["typed","parse","equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],ZT=q(ph,HT,r=>{var{typed:e,parse:t,equal:a,isZero:n,add:i,subtract:o,multiply:f,divide:l,pow:u,AccessorNode:s,ArrayNode:c,ConstantNode:m,FunctionNode:v,IndexNode:h,ObjectNode:p,OperatorNode:g,ParenthesisNode:y,SymbolNode:N}=r,d=new m(0),w=new m(1),x=new m(!0),b=new m(!1);function E(T){return Br(T)&&["and","not","or"].includes(T.op)}var{hasProperty:A,isCommutative:S}=Cs({FunctionNode:v,OperatorNode:g,SymbolNode:N});function D(T){var B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},I=B?B.context:void 0;if(A(T,"trivial",I)){if(rn(T)&&T.args.length===1)return D(T.args[0],B);var P=!1,R=0;if(T.forEach(re=>{++R,R===1&&(P=D(re,B))}),R===1)return P}var M=T;if(rn(M)){var F=cE(M.name);if(F){if(M.args.length>2&&A(M,"associative",I))for(;M.args.length>2;){var H=M.args.pop(),$=M.args.pop();M.args.push(new g(F,M.name,[H,$]))}M=new g(F,M.name,M.args)}else return new v(D(M.fn),M.args.map(re=>D(re,B)))}if(Br(M)&&M.isUnary()){var k=D(M.args[0],B);if(M.op==="~"&&Br(k)&&k.isUnary()&&k.op==="~"||M.op==="not"&&Br(k)&&k.isUnary()&&k.op==="not"&&E(k.args[0]))return k.args[0];var Q=!0;if(M.op==="-"&&Br(k)&&(k.isBinary()&&k.fn==="subtract"&&(M=new g("-","subtract",[k.args[1],k.args[0]]),Q=!1),k.isUnary()&&k.op==="-"))return k.args[0];if(Q)return new g(M.op,M.fn,[k])}if(Br(M)&&M.isBinary()){var K=D(M.args[0],B),L=D(M.args[1],B);if(M.op==="+"){if(ir(K)&&n(K.value))return L;if(ir(L)&&n(L.value))return K;Br(L)&&L.isUnary()&&L.op==="-"&&(L=L.args[0],M=new g("-","subtract",[K,L]))}if(M.op==="-")return Br(L)&&L.isUnary()&&L.op==="-"?D(new g("+","add",[K,L.args[0]]),B):ir(K)&&n(K.value)?D(new g("-","unaryMinus",[L])):ir(L)&&n(L.value)?K:new g(M.op,M.fn,[K,L]);if(M.op==="*"){if(ir(K)){if(n(K.value))return d;if(a(K.value,1))return L}if(ir(L)){if(n(L.value))return d;if(a(L.value,1))return K;if(S(M,I))return new g(M.op,M.fn,[L,K],M.implicit)}return new g(M.op,M.fn,[K,L],M.implicit)}if(M.op==="/")return ir(K)&&n(K.value)?d:ir(L)&&a(L.value,1)?K:new g(M.op,M.fn,[K,L]);if(M.op==="^"&&ir(L)){if(n(L.value))return w;if(a(L.value,1))return K}if(M.op==="and"){if(ir(K))if(K.value){if(E(L))return L}else return b;if(ir(L))if(L.value){if(E(K))return K}else return b}if(M.op==="or"){if(ir(K)){if(K.value)return x;if(E(L))return L}if(ir(L)){if(L.value)return x;if(E(K))return K}}return new g(M.op,M.fn,[K,L])}if(Br(M))return new g(M.op,M.fn,M.args.map(re=>D(re,B)));if(it(M))return new c(M.items.map(re=>D(re,B)));if(En(M))return new s(D(M.object,B),D(M.index,B));if(Zn(M))return new h(M.dimensions.map(re=>D(re,B)));if(ci(M)){var j={};for(var ae in M.properties)j[ae]=D(M.properties[ae],B);return new p(j)}return M}return e(ph,{Node:D,"Node,Object":D})}),JT="resolve",XT=["typed","parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],WT=q(JT,XT,r=>{var{typed:e,parse:t,ConstantNode:a,FunctionNode:n,OperatorNode:i,ParenthesisNode:o}=r;function f(l,u){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;if(!u)return l;if(qr(l)){if(s.has(l.name)){var c=Array.from(s).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(c,"}"))}var m=u.get(l.name);if(fr(m)){var v=new Set(s);return v.add(l.name),f(m,u,v)}else return typeof m=="number"?t(String(m)):m!==void 0?new a(m):l}else if(Br(l)){var h=l.args.map(function(g){return f(g,u,s)});return new i(l.op,l.fn,h,l.implicit)}else{if(Vt(l))return new o(f(l.content,u,s));if(rn(l)){var p=l.args.map(function(g){return f(g,u,s)});return new n(l.name,p)}}return l.map(g=>f(g,u,s))}return e("resolve",{Node:f,"Node, Map | null | undefined":f,"Node, Object":(l,u)=>f(l,ea(u)),"Array | Matrix":e.referToSelf(l=>u=>u.map(s=>l(s))),"Array | Matrix, null | undefined":e.referToSelf(l=>u=>u.map(s=>l(s))),"Array, Object":e.referTo("Array,Map",l=>(u,s)=>l(u,ea(s))),"Matrix, Object":e.referTo("Matrix,Map",l=>(u,s)=>l(u,ea(s))),"Array | Matrix, Map":e.referToSelf(l=>(u,s)=>u.map(c=>l(c,s)))})}),hh="symbolicEqual",YT=["parse","simplify","typed","OperatorNode"],QT=q(hh,YT,r=>{var{parse:e,simplify:t,typed:a,OperatorNode:n}=r;function i(o,f){var l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},u=new n("-","subtract",[o,f]),s=t(u,{},l);return ir(s)&&!s.value}return a(hh,{"Node, Node":i,"Node, Node, Object":i})}),dh="derivative",KT=["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],jT=q(dh,KT,r=>{var{typed:e,config:t,parse:a,simplify:n,equal:i,isZero:o,numeric:f,ConstantNode:l,FunctionNode:u,OperatorNode:s,ParenthesisNode:c,SymbolNode:m}=r;function v(w,x){var b=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{simplify:!0},E={};g(E,w,x.name);var A=y(w,E);return b.simplify?n(A):A}e.addConversion({from:"identifier",to:"SymbolNode",convert:a});var h=e(dh,{"Node, SymbolNode":v,"Node, SymbolNode, Object":v});e.removeConversion({from:"identifier",to:"SymbolNode",convert:a}),h._simplify=!0,h.toTex=function(w){return p.apply(null,w.args)};var p=e("_derivTex",{"Node, SymbolNode":function(x,b){return ir(x)&&br(x.value)==="string"?p(a(x.value).toString(),b.toString(),1):p(x.toTex(),b.toString(),1)},"Node, ConstantNode":function(x,b){if(br(b.value)==="string")return p(x,a(b.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(x,b,E){return p(x.toString(),b.name,E.value)},"string, string, number":function(x,b,E){var A;return E===1?A="{d\\over d"+b+"}":A="{d^{"+E+"}\\over d"+b+"^{"+E+"}}",A+"\\left[".concat(x,"\\right]")}}),g=e("constTag",{"Object, ConstantNode, string":function(x,b){return x[b]=!0,!0},"Object, SymbolNode, string":function(x,b,E){return b.name!==E?(x[b]=!0,!0):!1},"Object, ParenthesisNode, string":function(x,b,E){return g(x,b.content,E)},"Object, FunctionAssignmentNode, string":function(x,b,E){return b.params.indexOf(E)===-1?(x[b]=!0,!0):g(x,b.expr,E)},"Object, FunctionNode | OperatorNode, string":function(x,b,E){if(b.args.length>0){for(var A=g(x,b.args[0],E),S=1;S<b.args.length;++S)A=g(x,b.args[S],E)&&A;if(A)return x[b]=!0,!0}return!1}}),y=e("_derivative",{"ConstantNode, Object":function(x){return d(0)},"SymbolNode, Object":function(x,b){return b[x]!==void 0?d(0):d(1)},"ParenthesisNode, Object":function(x,b){return new c(y(x.content,b))},"FunctionAssignmentNode, Object":function(x,b){return b[x]!==void 0?d(0):y(x.expr,b)},"FunctionNode, Object":function(x,b){if(x.args.length!==1&&N(x),b[x]!==void 0)return d(0);var E=x.args[0],A,S=!1,D=!1,T;switch(x.name){case"cbrt":S=!0,T=new s("*","multiply",[d(3),new s("^","pow",[E,new s("/","divide",[d(2),d(3)])])]);break;case"sqrt":case"nthRoot":if(x.args.length===1)S=!0,T=new s("*","multiply",[d(2),new u("sqrt",[E])]);else if(x.args.length===2)return A=new s("/","divide",[d(1),x.args[1]]),b[A]=b[x.args[1]],y(new s("^","pow",[E,A]),b);break;case"log10":A=d(10);case"log":if(!A&&x.args.length===1)T=E.clone(),S=!0;else if(x.args.length===1&&A||x.args.length===2&&b[x.args[1]]!==void 0)T=new s("*","multiply",[E.clone(),new u("log",[A||x.args[1]])]),S=!0;else if(x.args.length===2)return y(new s("/","divide",[new u("log",[E]),new u("log",[x.args[1]])]),b);break;case"pow":return b[A]=b[x.args[1]],y(new s("^","pow",[E,x.args[1]]),b);case"exp":T=new u("exp",[E.clone()]);break;case"sin":T=new u("cos",[E.clone()]);break;case"cos":T=new s("-","unaryMinus",[new u("sin",[E.clone()])]);break;case"tan":T=new s("^","pow",[new u("sec",[E.clone()]),d(2)]);break;case"sec":T=new s("*","multiply",[x,new u("tan",[E.clone()])]);break;case"csc":D=!0,T=new s("*","multiply",[x,new u("cot",[E.clone()])]);break;case"cot":D=!0,T=new s("^","pow",[new u("csc",[E.clone()]),d(2)]);break;case"asin":S=!0,T=new u("sqrt",[new s("-","subtract",[d(1),new s("^","pow",[E.clone(),d(2)])])]);break;case"acos":S=!0,D=!0,T=new u("sqrt",[new s("-","subtract",[d(1),new s("^","pow",[E.clone(),d(2)])])]);break;case"atan":S=!0,T=new s("+","add",[new s("^","pow",[E.clone(),d(2)]),d(1)]);break;case"asec":S=!0,T=new s("*","multiply",[new u("abs",[E.clone()]),new u("sqrt",[new s("-","subtract",[new s("^","pow",[E.clone(),d(2)]),d(1)])])]);break;case"acsc":S=!0,D=!0,T=new s("*","multiply",[new u("abs",[E.clone()]),new u("sqrt",[new s("-","subtract",[new s("^","pow",[E.clone(),d(2)]),d(1)])])]);break;case"acot":S=!0,D=!0,T=new s("+","add",[new s("^","pow",[E.clone(),d(2)]),d(1)]);break;case"sinh":T=new u("cosh",[E.clone()]);break;case"cosh":T=new u("sinh",[E.clone()]);break;case"tanh":T=new s("^","pow",[new u("sech",[E.clone()]),d(2)]);break;case"sech":D=!0,T=new s("*","multiply",[x,new u("tanh",[E.clone()])]);break;case"csch":D=!0,T=new s("*","multiply",[x,new u("coth",[E.clone()])]);break;case"coth":D=!0,T=new s("^","pow",[new u("csch",[E.clone()]),d(2)]);break;case"asinh":S=!0,T=new u("sqrt",[new s("+","add",[new s("^","pow",[E.clone(),d(2)]),d(1)])]);break;case"acosh":S=!0,T=new u("sqrt",[new s("-","subtract",[new s("^","pow",[E.clone(),d(2)]),d(1)])]);break;case"atanh":S=!0,T=new s("-","subtract",[d(1),new s("^","pow",[E.clone(),d(2)])]);break;case"asech":S=!0,D=!0,T=new s("*","multiply",[E.clone(),new u("sqrt",[new s("-","subtract",[d(1),new s("^","pow",[E.clone(),d(2)])])])]);break;case"acsch":S=!0,D=!0,T=new s("*","multiply",[new u("abs",[E.clone()]),new u("sqrt",[new s("+","add",[new s("^","pow",[E.clone(),d(2)]),d(1)])])]);break;case"acoth":S=!0,D=!0,T=new s("-","subtract",[d(1),new s("^","pow",[E.clone(),d(2)])]);break;case"abs":T=new s("/","divide",[new u(new m("abs"),[E.clone()]),E.clone()]);break;case"gamma":default:throw new Error('Function "'+x.name+'" is not supported by derivative, or a wrong number of arguments is passed')}var B,I;S?(B="/",I="divide"):(B="*",I="multiply");var P=y(E,b);return D&&(P=new s("-","unaryMinus",[P])),new s(B,I,[P,T])},"OperatorNode, Object":function(x,b){if(b[x]!==void 0)return d(0);if(x.op==="+")return new s(x.op,x.fn,x.args.map(function(M){return y(M,b)}));if(x.op==="-"){if(x.isUnary())return new s(x.op,x.fn,[y(x.args[0],b)]);if(x.isBinary())return new s(x.op,x.fn,[y(x.args[0],b),y(x.args[1],b)])}if(x.op==="*"){var E=x.args.filter(function(M){return b[M]!==void 0});if(E.length>0){var A=x.args.filter(function(M){return b[M]===void 0}),S=A.length===1?A[0]:new s("*","multiply",A),D=E.concat(y(S,b));return new s("*","multiply",D)}return new s("+","add",x.args.map(function(M){return new s("*","multiply",x.args.map(function(F){return F===M?y(F,b):F.clone()}))}))}if(x.op==="/"&&x.isBinary()){var T=x.args[0],B=x.args[1];return b[B]!==void 0?new s("/","divide",[y(T,b),B]):b[T]!==void 0?new s("*","multiply",[new s("-","unaryMinus",[T]),new s("/","divide",[y(B,b),new s("^","pow",[B.clone(),d(2)])])]):new s("/","divide",[new s("-","subtract",[new s("*","multiply",[y(T,b),B.clone()]),new s("*","multiply",[T.clone(),y(B,b)])]),new s("^","pow",[B.clone(),d(2)])])}if(x.op==="^"&&x.isBinary()){var I=x.args[0],P=x.args[1];if(b[I]!==void 0)return ir(I)&&(o(I.value)||i(I.value,1))?d(0):new s("*","multiply",[x,new s("*","multiply",[new u("log",[I.clone()]),y(P.clone(),b)])]);if(b[P]!==void 0){if(ir(P)){if(o(P.value))return d(0);if(i(P.value,1))return y(I,b)}var R=new s("^","pow",[I.clone(),new s("-","subtract",[P,d(1)])]);return new s("*","multiply",[P.clone(),new s("*","multiply",[y(I,b),R])])}return new s("*","multiply",[new s("^","pow",[I.clone(),P.clone()]),new s("+","add",[new s("*","multiply",[y(I,b),new s("/","divide",[P.clone(),I.clone()])]),new s("*","multiply",[y(P,b),new u("log",[I.clone()])])])])}throw new Error('Operator "'+x.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function N(w){if(!((w.name==="log"||w.name==="nthRoot"||w.name==="pow")&&w.args.length===2)){for(var x=0;x<w.args.length;++x)w.args[x]=d(0);throw w.compile().evaluate(),new Error("Expected TypeError, but none found")}}function d(w,x){return new l(f(w,x||t.number))}return h}),gh="rationalize",eB=["config","typed","equal","isZero","add","subtract","multiply","divide","pow","parse","simplifyConstant","simplifyCore","simplify","?bignumber","?fraction","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode","ParenthesisNode"],rB=q(gh,eB,r=>{var{config:e,typed:t,equal:a,isZero:n,add:i,subtract:o,multiply:f,divide:l,pow:u,parse:s,simplifyConstant:c,simplifyCore:m,simplify:v,fraction:h,bignumber:p,mathWithTransform:g,matrix:y,AccessorNode:N,ArrayNode:d,ConstantNode:w,FunctionNode:x,IndexNode:b,ObjectNode:E,OperatorNode:A,SymbolNode:S,ParenthesisNode:D}=r;function T(M){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},H=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,$=I(),k=B(M,F,!0,$.firstRules),Q=k.variables.length,K={exactFractions:!1},L={exactFractions:!0};if(M=k.expression,Q>=1){M=P(M);var j,ae,re=!0,fe=!1;M=v(M,$.firstRules,{},K);for(var he;ae=re?$.distrDivRules:$.sucDivRules,M=v(M,ae,{},L),re=!re,he=M.toString(),he!==j;)fe=!0,j=he;fe&&(M=v(M,$.firstRulesAgain,{},K)),M=v(M,$.finalRules,{},K)}var ce=[],ie={};return M.type==="OperatorNode"&&M.isBinary()&&M.op==="/"?(Q===1&&(M.args[0]=R(M.args[0],ce),M.args[1]=R(M.args[1])),H&&(ie.numerator=M.args[0],ie.denominator=M.args[1])):(Q===1&&(M=R(M,ce)),H&&(ie.numerator=M,ie.denominator=null)),H?(ie.coefficients=ce,ie.variables=k.variables,ie.expression=M,ie):M}return t(gh,{Node:T,"Node, boolean":(M,F)=>T(M,{},F),"Node, Object":T,"Node, Object, boolean":T});function B(M,F,H,$){var k=[],Q=v(M,$,F,{exactFractions:!1});H=!!H;var K="+-*"+(H?"/":"");j(Q);var L={};return L.expression=Q,L.variables=k,L;function j(ae){var re=ae.type;if(re==="FunctionNode")throw new Error("There is an unsolved function call");if(re==="OperatorNode")if(ae.op==="^"){if(ae.args[1].type!=="ConstantNode"||!qe(parseFloat(ae.args[1].value)))throw new Error("There is a non-integer exponent");j(ae.args[0])}else{if(K.indexOf(ae.op)===-1)throw new Error("Operator "+ae.op+" invalid in polynomial expression");for(var fe=0;fe<ae.args.length;fe++)j(ae.args[fe])}else if(re==="SymbolNode"){var he=ae.name,ce=k.indexOf(he);ce===-1&&k.push(he)}else if(re==="ParenthesisNode")j(ae.content);else if(re!=="ConstantNode")throw new Error("type "+re+" is not allowed in polynomial expression")}}function I(){var M=[m,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},c,{l:"n*(n1^-1)",r:"n/n1"},{l:"n*n1^-n2",r:"n/n1^n2"},{l:"n1^-1",r:"1/n1"},{l:"n*(n1/n2)",r:"(n*n1)/n2"},{l:"1*n",r:"n"}],F=[{l:"(-n1)/(-n2)",r:"n1/n2"},{l:"(-n1)*(-n2)",r:"n1*n2"},{l:"n1--n2",r:"n1+n2"},{l:"n1-n2",r:"n1+(-n2)"},{l:"(n1+n2)*n3",r:"(n1*n3 + n2*n3)"},{l:"n1*(n2+n3)",r:"(n1*n2+n1*n3)"},{l:"c1*n + c2*n",r:"(c1+c2)*n"},{l:"c1*n + n",r:"(c1+1)*n"},{l:"c1*n - c2*n",r:"(c1-c2)*n"},{l:"c1*n - n",r:"(c1-1)*n"},{l:"v/c",r:"(1/c)*v"},{l:"v/-c",r:"-(1/c)*v"},{l:"-v*-c",r:"c*v"},{l:"-v*c",r:"-c*v"},{l:"v*-c",r:"-c*v"},{l:"v*c",r:"c*v"},{l:"-(-n1*n2)",r:"(n1*n2)"},{l:"-(n1*n2)",r:"(-n1*n2)"},{l:"-(-n1+n2)",r:"(n1-n2)"},{l:"-(n1+n2)",r:"(-n1-n2)"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"},{l:"-(-n1/n2)",r:"(n1/n2)"},{l:"-(n1/n2)",r:"(-n1/n2)"}],H=[{l:"(n1/n2 + n3/n4)",r:"((n1*n4 + n3*n2)/(n2*n4))"},{l:"(n1/n2 + n3)",r:"((n1 + n3*n2)/n2)"},{l:"(n1 + n2/n3)",r:"((n1*n3 + n2)/n3)"}],$=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],k={};return k.firstRules=M.concat(F,$),k.distrDivRules=H,k.sucDivRules=$,k.firstRulesAgain=M.concat(F),k.finalRules=[m,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},c,{l:"n*-n^n1",r:"-n^(n1+1)"},{l:"n*n^n1",r:"n^(n1+1)"},{l:"n^n1*-n^n2",r:"-n^(n1+n2)"},{l:"n^n1*n^n2",r:"n^(n1+n2)"},{l:"n^n1*-n",r:"-n^(n1+1)"},{l:"n^n1*n",r:"n^(n1+1)"},{l:"n^n1/-n",r:"-n^(n1-1)"},{l:"n^n1/n",r:"n^(n1-1)"},{l:"n/-n^n1",r:"-n^(1-n1)"},{l:"n/n^n1",r:"n^(1-n1)"},{l:"n^n1/-n^n2",r:"n^(n1-n2)"},{l:"n^n1/n^n2",r:"n^(n1-n2)"},{l:"n1+(-n2*n3)",r:"n1-n2*n3"},{l:"v*(-c)",r:"-c*v"},{l:"n1+-n2",r:"n1-n2"},{l:"v*c",r:"c*v"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"}],k}function P(M,F,H){var $=M.type,k=arguments.length>1;if($==="OperatorNode"&&M.isBinary()){var Q=!1,K;if(M.op==="^"&&(M.args[0].type==="ParenthesisNode"||M.args[0].type==="OperatorNode")&&M.args[1].type==="ConstantNode"&&(K=parseFloat(M.args[1].value),Q=K>=2&&qe(K)),Q){if(K>2){var L=M.args[0],j=new A("^","pow",[M.args[0].cloneDeep(),new w(K-1)]);M=new A("*","multiply",[L,j])}else M=new A("*","multiply",[M.args[0],M.args[0].cloneDeep()]);k&&(H==="content"?F.content=M:F.args[H]=M)}}if($==="ParenthesisNode")P(M.content,M,"content");else if($!=="ConstantNode"&&$!=="SymbolNode")for(var ae=0;ae<M.args.length;ae++)P(M.args[ae],M,ae);if(!k)return M}function R(M,F){F===void 0&&(F=[]),F[0]=0;var H={};H.cte=1,H.oper="+",H.fire="";var $=0,k="";he(M,null,H),$=F.length-1;for(var Q=!0,K,L=$;L>=0;L--)if(F[L]!==0){var j=new w(Q?F[L]:Math.abs(F[L])),ae=F[L]<0?"-":"+";if(L>0){var re=new S(k);if(L>1){var fe=new w(L);re=new A("^","pow",[re,fe])}F[L]===-1&&Q?j=new A("-","unaryMinus",[re]):Math.abs(F[L])===1?j=re:j=new A("*","multiply",[j,re])}Q?K=j:ae==="+"?K=new A("+","add",[K,j]):K=new A("-","subtract",[K,j]),Q=!1}if(Q)return new w(0);return K;function he(ce,ie,Ae){var Oe=ce.type;if(Oe==="FunctionNode")throw new Error("There is an unsolved function call");if(Oe==="OperatorNode"){if("+-*^".indexOf(ce.op)===-1)throw new Error("Operator "+ce.op+" invalid");if(ie!==null){if((ce.fn==="unaryMinus"||ce.fn==="pow")&&ie.fn!=="add"&&ie.fn!=="subtract"&&ie.fn!=="multiply")throw new Error("Invalid "+ce.op+" placing");if((ce.fn==="subtract"||ce.fn==="add"||ce.fn==="multiply")&&ie.fn!=="add"&&ie.fn!=="subtract")throw new Error("Invalid "+ce.op+" placing");if((ce.fn==="subtract"||ce.fn==="add"||ce.fn==="unaryMinus")&&Ae.noFil!==0)throw new Error("Invalid "+ce.op+" placing")}(ce.op==="^"||ce.op==="*")&&(Ae.fire=ce.op);for(var Ce=0;Ce<ce.args.length;Ce++)ce.fn==="unaryMinus"&&(Ae.oper="-"),(ce.op==="+"||ce.fn==="subtract")&&(Ae.fire="",Ae.cte=1,Ae.oper=Ce===0?"+":ce.op),Ae.noFil=Ce,he(ce.args[Ce],ce,Ae)}else if(Oe==="SymbolNode"){if(ce.name!==k&&k!=="")throw new Error("There is more than one variable");if(k=ce.name,ie===null){F[1]=1;return}if(ie.op==="^"&&Ae.noFil!==0)throw new Error("In power the variable should be the first parameter");if(ie.op==="*"&&Ae.noFil!==1)throw new Error("In multiply the variable should be the second parameter");(Ae.fire===""||Ae.fire==="*")&&($<1&&(F[1]=0),F[1]+=Ae.cte*(Ae.oper==="+"?1:-1),$=Math.max(1,$))}else if(Oe==="ConstantNode"){var $e=parseFloat(ce.value);if(ie===null){F[0]=$e;return}if(ie.op==="^"){if(Ae.noFil!==1)throw new Error("Constant cannot be powered");if(!qe($e)||$e<=0)throw new Error("Non-integer exponent is not allowed");for(var V=$+1;V<$e;V++)F[V]=0;$e>$&&(F[$e]=0),F[$e]+=Ae.cte*(Ae.oper==="+"?1:-1),$=Math.max($e,$);return}Ae.cte=$e,Ae.fire===""&&(F[0]+=Ae.cte*(Ae.oper==="+"?1:-1))}else throw new Error("Type "+Oe+" is not allowed")}}}),tB="reviver",nB=["classes"],aB=q(tB,nB,r=>{var{classes:e}=r;return function(a,n){var i=e[n&&n.mathjs];return i&&typeof i.fromJSON=="function"?i.fromJSON(n):n}}),iB="replacer",oB=[],sB=q(iB,oB,()=>function(e,t){return typeof t=="number"&&(!isFinite(t)||isNaN(t))?{mathjs:"number",value:String(t)}:t}),uB="11.8.0",lB=q("true",[],()=>!0),cB=q("false",[],()=>!1),fB=q("null",[],()=>null),mB=nt("Infinity",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1/0):1/0}),vB=nt("NaN",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(NaN):NaN}),pB=nt("pi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?gs(t):J1}),hB=nt("tau",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?pD(t):X1}),dB=nt("e",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?mD(t):W1}),gB=nt("phi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?vD(t):Y1}),yB=nt("LN2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).ln():Math.LN2}),bB=nt("LN10",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(10).ln():Math.LN10}),xB=nt("LOG2E",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1).div(new t(2).ln()):Math.LOG2E}),wB=nt("LOG10E",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1).div(new t(10).ln()):Math.LOG10E}),NB=nt("SQRT1_2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t("0.5").sqrt():Math.SQRT1_2}),DB=nt("SQRT2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).sqrt():Math.SQRT2}),AB=nt("i",["Complex"],r=>{var{Complex:e}=r;return e.I}),EB=q("version",[],()=>uB);function nt(r,e,t){return q(r,e,t,{recreateOnConfigChange:!0})}var SB=We("speedOfLight","299792458","m s^-1"),CB=We("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),MB=We("planckConstant","6.62607015e-34","J s"),FB=We("reducedPlanckConstant","1.0545718176461565e-34","J s"),TB=We("magneticConstant","1.25663706212e-6","N A^-2"),BB=We("electricConstant","8.8541878128e-12","F m^-1"),$B=We("vacuumImpedance","376.730313667","ohm"),OB=We("coulomb","8.987551792261171e9","N m^2 C^-2"),IB=We("elementaryCharge","1.602176634e-19","C"),RB=We("bohrMagneton","9.2740100783e-24","J T^-1"),_B=We("conductanceQuantum","7.748091729863649e-5","S"),qB=We("inverseConductanceQuantum","12906.403729652257","ohm"),zB=We("magneticFluxQuantum","2.0678338484619295e-15","Wb"),PB=We("nuclearMagneton","5.0507837461e-27","J T^-1"),UB=We("klitzing","25812.807459304513","ohm"),LB=We("bohrRadius","5.29177210903e-11","m"),kB=We("classicalElectronRadius","2.8179403262e-15","m"),VB=We("electronMass","9.1093837015e-31","kg"),GB=We("fermiCoupling","1.1663787e-5","GeV^-2"),HB=so("fineStructure",.0072973525693),ZB=We("hartreeEnergy","4.3597447222071e-18","J"),JB=We("protonMass","1.67262192369e-27","kg"),XB=We("deuteronMass","3.3435830926e-27","kg"),WB=We("neutronMass","1.6749271613e-27","kg"),YB=We("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),QB=We("rydberg","10973731.568160","m^-1"),KB=We("thomsonCrossSection","6.6524587321e-29","m^2"),jB=so("weakMixingAngle",.2229),e$=so("efimovFactor",22.7),r$=We("atomicMass","1.66053906660e-27","kg"),t$=We("avogadro","6.02214076e23","mol^-1"),n$=We("boltzmann","1.380649e-23","J K^-1"),a$=We("faraday","96485.33212331001","C mol^-1"),i$=We("firstRadiation","3.7417718521927573e-16","W m^2"),o$=We("loschmidt","2.686780111798444e25","m^-3"),s$=We("gasConstant","8.31446261815324","J K^-1 mol^-1"),u$=We("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),l$=We("molarVolume","0.022413969545014137","m^3 mol^-1"),c$=so("sackurTetrode",-1.16487052358),f$=We("secondRadiation","0.014387768775039337","m K"),m$=We("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),v$=We("wienDisplacement","2.897771955e-3","m K"),p$=We("molarMass","0.99999999965e-3","kg mol^-1"),h$=We("molarMassC12","11.9999999958e-3","kg mol^-1"),d$=We("gravity","9.80665","m s^-2"),g$=We("planckLength","1.616255e-35","m"),y$=We("planckMass","2.176435e-8","kg"),b$=We("planckTime","5.391245e-44","s"),x$=We("planckCharge","1.87554603778e-18","C"),w$=We("planckTemperature","1.416785e+32","K");function We(r,e,t){var a=["config","Unit","BigNumber"];return q(r,a,n=>{var{config:i,Unit:o,BigNumber:f}=n,l=i.number==="BigNumber"?new f(e):parseFloat(e),u=new o(l,t);return u.fixPrefix=!0,u})}function so(r,e){var t=["config","BigNumber"];return q(r,t,a=>{var{config:n,BigNumber:i}=a;return n.number==="BigNumber"?new i(e):e})}var N$="apply",D$=["typed","isInteger"],A$=q(N$,D$,r=>{var{typed:e,isInteger:t}=r,a=pf({typed:e,isInteger:t});return e("apply",{"...any":function(i){var o=i[1];tr(o)?i[1]=o-1:rr(o)&&(i[1]=o.minus(1));try{return a.apply(null,i)}catch(f){throw Kr(f)}}})},{isTransformFunction:!0}),E$="column",S$=["typed","Index","matrix","range"],C$=q(E$,S$,r=>{var{typed:e,Index:t,matrix:a,range:n}=r,i=Yf({typed:e,Index:t,matrix:a,range:n});return e("column",{"...any":function(f){var l=f.length-1,u=f[l];tr(u)&&(f[l]=u-1);try{return i.apply(null,f)}catch(s){throw Kr(s)}}})},{isTransformFunction:!0});function Ms(r,e,t){var a=r.filter(function(f){return qr(f)&&!(f.name in e)&&!t.has(f.name)})[0];if(!a)throw new Error('No undefined variable found in inline expression "'+r+'"');var n=a.name,i=Xa(t),o=r.compile();return function(l){return i.set(n,l),o.evaluate(i)}}var M$="filter",F$=["typed"],T$=q(M$,F$,r=>{var{typed:e}=r;function t(n,i,o){var f,l;return n[0]&&(f=n[0].compile().evaluate(o)),n[1]&&(qr(n[1])||za(n[1])?l=n[1].compile().evaluate(o):l=Ms(n[1],i,o)),a(f,l)}t.rawArgs=!0;var a=e("filter",{"Array, function":yh,"Matrix, function":function(i,o){return i.create(yh(i.toArray(),o))},"Array, RegExp":di,"Matrix, RegExp":function(i,o){return i.create(di(i.toArray(),o))}});return t},{isTransformFunction:!0});function yh(r,e){var t=ln(e);return Al(r,function(a,n,i){return t===1?e(a):t===2?e(a,[n+1]):e(a,[n+1],i)})}var B$="forEach",$$=["typed"],O$=q(B$,$$,r=>{var{typed:e}=r;function t(n,i,o){var f,l;return n[0]&&(f=n[0].compile().evaluate(o)),n[1]&&(qr(n[1])||za(n[1])?l=n[1].compile().evaluate(o):l=Ms(n[1],i,o)),a(f,l)}t.rawArgs=!0;var a=e("forEach",{"Array | Matrix, function":function(i,o){var f=ln(o),l=function u(s,c){Array.isArray(s)?hi(s,function(m,v){u(m,c.concat(v+1))}):f===1?o(s):f===2?o(s,c):o(s,c,i)};l(i.valueOf(),[])}});return t},{isTransformFunction:!0}),I$="index",R$=["Index"],_$=q(I$,R$,r=>{var{Index:e}=r;return function(){for(var a=[],n=0,i=arguments.length;n<i;n++){var o=arguments[n];if(Uo(o))o.start--,o.end-=o.step>0?0:2;else if(o&&o.isSet===!0)o=o.map(function(l){return l-1});else if(cr(o)||Ve(o))o=o.map(function(l){return l-1});else if(tr(o))o--;else if(rr(o))o=o.toNumber()-1;else if(typeof o!="string")throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");a[n]=o}var f=new e;return e.apply(f,a),f}},{isTransformFunction:!0}),q$="map",z$=["typed"],P$=q(q$,z$,r=>{var{typed:e}=r;function t(n,i,o){var f,l;return n[0]&&(f=n[0].compile().evaluate(o)),n[1]&&(qr(n[1])||za(n[1])?l=n[1].compile().evaluate(o):l=Ms(n[1],i,o)),a(f,l)}t.rawArgs=!0;var a=e("map",{"Array, function":function(i,o){return bh(i,o,i)},"Matrix, function":function(i,o){return i.create(bh(i.valueOf(),o,i))}});return t},{isTransformFunction:!0});function bh(r,e,t){var a=ln(e);function n(i,o){return Array.isArray(i)?Gt(i,function(f,l){return n(f,o.concat(l+1))}):a===1?e(i):a===2?e(i,o):e(i,o,t)}return n(r,[])}function $n(r){if(r.length===2&&Mt(r[0])){r=r.slice();var e=r[1];tr(e)?r[1]=e-1:rr(e)&&(r[1]=e.minus(1))}return r}var U$="max",L$=["typed","config","numeric","larger"],k$=q(U$,L$,r=>{var{typed:e,config:t,numeric:a,larger:n}=r,i=sv({typed:e,config:t,numeric:a,larger:n});return e("max",{"...any":function(f){f=$n(f);try{return i.apply(null,f)}catch(l){throw Kr(l)}}})},{isTransformFunction:!0}),V$="mean",G$=["typed","add","divide"],H$=q(V$,G$,r=>{var{typed:e,add:t,divide:a}=r,n=$p({typed:e,add:t,divide:a});return e("mean",{"...any":function(o){o=$n(o);try{return n.apply(null,o)}catch(f){throw Kr(f)}}})},{isTransformFunction:!0}),Z$="min",J$=["typed","config","numeric","smaller"],X$=q(Z$,J$,r=>{var{typed:e,config:t,numeric:a,smaller:n}=r,i=lv({typed:e,config:t,numeric:a,smaller:n});return e("min",{"...any":function(f){f=$n(f);try{return i.apply(null,f)}catch(l){throw Kr(l)}}})},{isTransformFunction:!0}),W$="range",Y$=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],Q$=q(W$,Y$,r=>{var{typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:o,larger:f,largerEq:l}=r,u=mm({typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:o,larger:f,largerEq:l});return e("range",{"...any":function(c){var m=c.length-1,v=c[m];return typeof v!="boolean"&&c.push(!0),u.apply(null,c)}})},{isTransformFunction:!0}),K$="row",j$=["typed","Index","matrix","range"],eO=q(K$,j$,r=>{var{typed:e,Index:t,matrix:a,range:n}=r,i=gm({typed:e,Index:t,matrix:a,range:n});return e("row",{"...any":function(f){var l=f.length-1,u=f[l];tr(u)&&(f[l]=u-1);try{return i.apply(null,f)}catch(s){throw Kr(s)}}})},{isTransformFunction:!0}),rO="subset",tO=["typed","matrix"],nO=q(rO,tO,r=>{var{typed:e,matrix:t}=r,a=wm({typed:e,matrix:t});return e("subset",{"...any":function(i){try{return a.apply(null,i)}catch(o){throw Kr(o)}}})},{isTransformFunction:!0}),aO="concat",iO=["typed","matrix","isInteger"],oO=q(aO,iO,r=>{var{typed:e,matrix:t,isInteger:a}=r,n=Jf({typed:e,matrix:t,isInteger:a});return e("concat",{"...any":function(o){var f=o.length-1,l=o[f];tr(l)?o[f]=l-1:rr(l)&&(o[f]=l.minus(1));try{return n.apply(null,o)}catch(u){throw Kr(u)}}})},{isTransformFunction:!0}),xh="diff",sO=["typed","matrix","subtract","number","bignumber"],uO=q(xh,sO,r=>{var{typed:e,matrix:t,subtract:a,number:n,bignumber:i}=r,o=um({typed:e,matrix:t,subtract:a,number:n,bignumber:i});return e(xh,{"...any":function(l){l=$n(l);try{return o.apply(null,l)}catch(u){throw Kr(u)}}})},{isTransformFunction:!0}),lO="std",cO=["typed","map","sqrt","variance"],fO=q(lO,cO,r=>{var{typed:e,map:t,sqrt:a,variance:n}=r,i=zp({typed:e,map:t,sqrt:a,variance:n});return e("std",{"...any":function(f){f=$n(f);try{return i.apply(null,f)}catch(l){throw Kr(l)}}})},{isTransformFunction:!0}),wh="sum",mO=["typed","config","add","numeric"],vO=q(wh,mO,r=>{var{typed:e,config:t,add:a,numeric:n}=r,i=Fp({typed:e,config:t,add:a,numeric:n});return e(wh,{"...any":function(f){f=$n(f);try{return i.apply(null,f)}catch(l){throw Kr(l)}}})},{isTransformFunction:!0}),Nh="cumsum",pO=["typed","add","unaryPlus"],hO=q(Nh,pO,r=>{var{typed:e,add:t,unaryPlus:a}=r,n=Tp({typed:e,add:t,unaryPlus:a});return e(Nh,{"...any":function(o){if(o.length===2&&Mt(o[0])){var f=o[1];tr(f)?o[1]=f-1:rr(f)&&(o[1]=f.minus(1))}try{return n.apply(null,o)}catch(l){throw Kr(l)}}})},{isTransformFunction:!0}),Dh="variance",dO=["typed","add","subtract","multiply","divide","apply","isNaN"],gO=q(Dh,dO,r=>{var{typed:e,add:t,subtract:a,multiply:n,divide:i,apply:o,isNaN:f}=r,l=_p({typed:e,add:t,subtract:a,multiply:n,divide:i,apply:o,isNaN:f});return e(Dh,{"...any":function(s){s=$n(s);try{return l.apply(null,s)}catch(c){throw Kr(c)}}})},{isTransformFunction:!0}),Me=D1({config:ge}),xr=C1({}),Ah=dB({BigNumber:Me,config:ge}),yO=cB({}),bO=HB({BigNumber:Me,config:ge}),On=T1({}),Eh=AB({Complex:xr}),xO=mB({BigNumber:Me,config:ge}),wO=bB({BigNumber:Me,config:ge}),NO=wB({BigNumber:Me,config:ge}),uo=_1({}),DO=vB({BigNumber:Me,config:ge}),AO=fB({}),EO=gB({BigNumber:Me,config:ge}),SO=O1({}),Sh=Cg({}),CO=NB({BigNumber:Me,config:ge}),MO=c$({BigNumber:Me,config:ge}),Ch=hB({BigNumber:Me,config:ge}),FO=lB({}),TO=EB({}),Qe=U1({Matrix:uo}),BO=e$({BigNumber:Me,config:ge}),$O=yB({BigNumber:Me,config:ge}),Mh=pB({BigNumber:Me,config:ge}),OO=sB({}),IO=DB({BigNumber:Me,config:ge}),J=Dg({BigNumber:Me,Complex:xr,DenseMatrix:Qe,Fraction:On}),Fs=Qy({BigNumber:Me,config:ge,typed:J}),RO=jB({BigNumber:Me,config:ge}),rt=jy({typed:J}),_O=ED({Complex:xr,config:ge,typed:J}),qO=FD({BigNumber:Me,typed:J}),zO=OD({BigNumber:Me,Complex:xr,config:ge,typed:J}),$r=nb({typed:J}),PO=Zx({typed:J}),UO=PD({BigNumber:Me,Complex:xr,config:ge,typed:J}),LO=GD({typed:J}),Fh=JD({typed:J}),kO=QD({Complex:xr,config:ge,typed:J}),$t=By({BigNumber:Me,typed:J}),VO=zx({typed:J}),GO=My({typed:J}),HO=k1({typed:J}),lo=K4({typed:J}),co=Iy({Complex:xr,typed:J}),In=Xx({typed:J}),ZO=rA({typed:J}),JO=iA({BigNumber:Me,typed:J}),XO=sA({BigNumber:Me,typed:J}),WO=db({typed:J}),nr=dy({config:ge,typed:J}),YO=fN({typed:J}),Th=yb({typed:J}),QO=xb({Complex:xr,typed:J}),KO=hw({typed:J}),jO=bw({typed:J}),Wa=xN({typed:J}),e5=Nw({typed:J}),r5=SN({format:Wa,typed:J}),Ts=Yx({typed:J}),lt=G1({typed:J}),ma=ry({typed:J}),fo=sy({typed:J}),Nt=ly({typed:J}),t5=xB({BigNumber:Me,config:ge}),n5=aT({Complex:xr,typed:J}),a5=Qb({Complex:xr,config:ge,typed:J}),Bh=jb({Complex:xr,config:ge,typed:J}),va=Mw({typed:J}),Cr=ux({typed:J}),$h=ew({typed:J}),mn=Ay({typed:J}),i5=AN({format:Wa,typed:J}),o5=NT({config:ge,typed:J}),s5=MN({typed:J}),u5=AT({config:ge,typed:J}),Bs=Kx({typed:J}),l5=fA({BigNumber:Me,typed:J}),Oh=px({BigNumber:Me,Fraction:On,complex:co,typed:J}),$s=hA({typed:J}),Yt=by({Matrix:uo,equalScalar:nr,typed:J}),c5=Jy({typed:J}),f5=bx({typed:J}),m5=Sy({typed:J}),v5=bA({typed:J}),Ih=vy({typed:J}),p5=CD({Complex:xr,config:ge,typed:J}),h5=RD({BigNumber:Me,typed:J}),Os=pf({isInteger:lt,typed:J}),d5=qD({BigNumber:Me,Complex:xr,config:ge,typed:J}),g5=NN({format:Wa,typed:J}),y5=eT({typed:J}),Is=jD({typed:J}),b5=lA({BigNumber:Me,typed:J}),Ya=fy({typed:J}),x5=$N({typed:J}),w5=ST({config:ge,typed:J}),N5=vA({BigNumber:Me,typed:J}),D5=gA({typed:J}),A5=wD({SparseMatrix:Yt,typed:J}),Ot=gx({Complex:xr,config:ge,typed:J}),E5=NA({typed:J}),It=Wy({typed:J}),S5=BD({BigNumber:Me,Complex:xr,config:ge,typed:J}),C5=nA({BigNumber:Me,typed:J}),pa=qy({Fraction:On,typed:J}),Rn=ny({typed:J}),Te=Py({DenseMatrix:Qe,Matrix:uo,SparseMatrix:Yt,typed:J}),M5=Ly({isZero:Nt,matrix:Te,typed:J}),F5=dN({isNaN:Ya,isNumeric:Rn,typed:J}),Dt=RN({bignumber:$t,fraction:pa,number:mn}),Rh=yN({config:ge,multiplyScalar:Cr,numeric:Dt,typed:J}),T5=_w({isInteger:lt,matrix:Te,typed:J}),Zr=Zw({matrix:Te,config:ge,typed:J}),B5=Xw({matrix:Te,typed:J}),at=wm({matrix:Te,typed:J}),Qa=eN({matrix:Te,typed:J}),_h=Dx({BigNumber:Me,config:ge,matrix:Te,typed:J}),Rt=aN({BigNumber:Me,config:ge,matrix:Te,typed:J}),$5=LD({Complex:xr,config:ge,typed:J}),qh=ib({BigNumber:Me,Complex:xr,Fraction:On,config:ge,isNegative:ma,matrix:Te,typed:J,unaryMinus:It}),ur=Jf({isInteger:lt,matrix:Te,typed:J}),O5=uw({prod:Rh,size:Zr,typed:J}),Rs=tN({conj:In,transpose:Qa,typed:J}),zh=mw({DenseMatrix:Qe,SparseMatrix:Yt,matrix:Te,typed:J}),Dr=qN({numeric:Dt,typed:J}),Ka=QN({DenseMatrix:Qe,concat:ur,divideScalar:Dr,equalScalar:nr,matrix:Te,typed:J}),At=E2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),ja=gw({matrix:Te,typed:J}),I5=Vb({BigNumber:Me,DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),R5=iy({isNumeric:Rn,typed:J}),vn=Aw({BigNumber:Me,DenseMatrix:Qe,SparseMatrix:Yt,config:ge,matrix:Te,typed:J}),_5=Sw({matrix:Te,multiplyScalar:Cr,typed:J}),mo=P2({DenseMatrix:Qe,concat:ur,config:ge,matrix:Te,typed:J}),q5=l2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J,zeros:Rt}),_s=Hy({flatten:ja,matrix:Te,size:Zr,typed:J}),Ph=ix({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),z5=mx({BigNumber:Me,concat:ur,equalScalar:nr,matrix:Te,typed:J}),P5=Ow({BigNumber:Me,config:ge,matrix:Te,typed:J}),U5=Pw({config:ge,matrix:Te}),L5=f2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J,zeros:Rt}),vo=LN({BigNumber:Me,DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J,zeros:Rt}),ct=T2({DenseMatrix:Qe,concat:ur,config:ge,matrix:Te,typed:J}),k5=TN({concat:ur,matrix:Te,typed:J}),V5=G2({DenseMatrix:Qe,concat:ur,config:ge,equalScalar:nr,matrix:Te,typed:J}),G5=aw({DenseMatrix:Qe,concat:ur,matrix:Te,typed:J}),wr=GA({DenseMatrix:Qe,SparseMatrix:Yt,addScalar:$r,concat:ur,equalScalar:nr,matrix:Te,typed:J}),H5=_x({concat:ur,equalScalar:nr,matrix:Te,typed:J}),Z5=Gx({DenseMatrix:Qe,concat:ur,matrix:Te,typed:J}),J5=$T({addScalar:$r,combinations:lo,divideScalar:Dr,isInteger:lt,isNegative:ma,multiplyScalar:Cr,typed:J}),ha=g2({BigNumber:Me,DenseMatrix:Qe,Fraction:On,concat:ur,config:ge,equalScalar:nr,matrix:Te,typed:J}),Uh=D2({concat:ur,matrix:Te,typed:J}),X5=Tp({add:wr,typed:J,unaryPlus:Fs}),Lh=k2({equal:At,typed:J}),po=YA({addScalar:$r,conj:In,multiplyScalar:Cr,size:Zr,typed:J}),W5=M2({compareText:Uh,isZero:Nt,typed:J}),kh=Sb({DenseMatrix:Qe,config:ge,equalScalar:nr,matrix:Te,round:vo,typed:J,zeros:Rt}),Y5=ZA({abs:rt,addScalar:$r,divideScalar:Dr,isPositive:fo,multiplyScalar:Cr,smaller:ct,sqrt:Ot,typed:J}),Vh=eD({DenseMatrix:Qe,smaller:ct}),Jr=nD({ImmutableDenseMatrix:Vh}),Q5=Ex({BigNumber:Me,add:wr,config:ge,equal:At,isInteger:lt,mod:Ph,smaller:ct,typed:J,xgcd:_h}),ft=_2({DenseMatrix:Qe,concat:ur,config:ge,matrix:Te,typed:J}),qs=VN({Complex:xr,config:ge,divideScalar:Dr,typed:J}),K5=Vy({flatten:ja,matrix:Te,size:Zr,typed:J}),j5=lv({config:ge,numeric:Dt,smaller:ct,typed:J}),Nr=cx({addScalar:$r,dot:po,equalScalar:nr,matrix:Te,multiplyScalar:Cr,typed:J}),e8=JN({Complex:xr,config:ge,divideScalar:Dr,typed:J}),r8=tw({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),zs=J2({compare:ha,isNaN:Ya,isNumeric:Rn,typed:J}),t8=W4({add:wr,compare:ha,multiply:Nr,partitionSelect:zs,typed:J}),n8=v2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J,zeros:Rt}),Ps=O2({DenseMatrix:Qe,concat:ur,config:ge,matrix:Te,typed:J}),yr=wx({DenseMatrix:Qe,addScalar:$r,concat:ur,equalScalar:nr,matrix:Te,typed:J,unaryMinus:It}),a8=jA({add:wr,matrix:Te,typed:J}),Us=r2({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J}),i8=h2({concat:ur,equalScalar:nr,matrix:Te,not:$h,typed:J,zeros:Rt}),o8=Ux({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),Ls=pb({DenseMatrix:Qe,config:ge,equalScalar:nr,matrix:Te,round:vo,typed:J,zeros:Rt}),_t=x2({compare:ha,typed:J}),s8=IT({addScalar:$r,combinations:lo,isInteger:lt,isNegative:ma,isPositive:fo,larger:ft,typed:J}),u8=cw({matrix:Te,multiply:Nr,subtract:yr,typed:J}),Gh=f4({divideScalar:Dr,isZero:Nt,matrix:Te,multiply:Nr,subtract:yr,typed:J,unaryMinus:It}),l8=um({matrix:Te,number:mn,subtract:yr,typed:J}),c8=R4({abs:rt,addScalar:$r,divideScalar:Dr,multiplyScalar:Cr,sqrt:Ot,subtract:yr,typed:J,unaryMinus:It}),f8=Fx({concat:ur,equalScalar:nr,matrix:Te,multiplyScalar:Cr,typed:J}),Hh=oD({larger:ft,smaller:ct}),Zh=Db({Complex:xr,DenseMatrix:Qe,ceil:Ls,equalScalar:nr,floor:kh,matrix:Te,typed:J,zeros:Rt}),Jh=rE({Index:Jr,typed:J}),m8=z4({abs:rt,add:wr,addScalar:$r,config:ge,divideScalar:Dr,equalScalar:nr,flatten:ja,isNumeric:Rn,isZero:Nt,matrix:Te,multiply:Nr,multiplyScalar:Cr,smaller:ct,subtract:yr,typed:J}),v8=Wb({concat:ur,equalScalar:nr,matrix:Te,typed:J}),p8=HN({Complex:xr,config:ge,divideScalar:Dr,log:qs,typed:J}),Xh=jN({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J}),Wh=sv({config:ge,larger:ft,numeric:Dt,typed:J}),ks=aS({addScalar:$r,complex:co,conj:In,divideScalar:Dr,equal:At,identity:vn,isZero:Nt,matrix:Te,multiplyScalar:Cr,sign:Oh,sqrt:Ot,subtract:yr,typed:J,unaryMinus:It,zeros:Rt}),da=mm({bignumber:$t,matrix:Te,config:ge,larger:ft,largerEq:mo,smaller:ct,smallerEq:Ps,typed:J}),h8=gm({Index:Jr,matrix:Te,range:da,typed:J}),d8=AA({DenseMatrix:Qe,Index:Jr,compareNatural:_t,size:Zr,subset:at,typed:J}),g8=MA({DenseMatrix:Qe,Index:Jr,compareNatural:_t,size:Zr,subset:at,typed:J}),y8=$A({Index:Jr,compareNatural:_t,size:Zr,subset:at,typed:J}),b8=_A({Index:Jr,compareNatural:_t,size:Zr,subset:at,typed:J}),Yh=MS({SparseMatrix:Yt,abs:rt,add:wr,divideScalar:Dr,larger:ft,largerEq:mo,multiply:Nr,subtract:yr,transpose:Qa,typed:J}),Qh=lD({FibonacciHeap:Hh,addScalar:$r,equalScalar:nr}),Kh=Fp({add:wr,config:ge,numeric:Dt,typed:J}),jh=i2({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J}),x8=WD({BigNumber:Me,DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),ed=Yf({Index:Jr,matrix:Te,range:da,typed:J}),w8=n2({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J}),rd=SA({DenseMatrix:Qe,Index:Jr,compareNatural:_t,size:Zr,subset:at,typed:J}),N8=IA({Index:Jr,compareNatural:_t,size:Zr,subset:at,typed:J}),td=UA({Index:Jr,concat:ur,setDifference:rd,size:Zr,subset:at,typed:J}),D8=W2({compare:ha,compareNatural:_t,matrix:Te,typed:J}),_n=v4({abs:rt,addScalar:$r,det:Gh,divideScalar:Dr,identity:vn,matrix:Te,multiply:Nr,typed:J,unaryMinus:It}),nd=tS({DenseMatrix:Qe,Spa:Qh,SparseMatrix:Yt,abs:rt,addScalar:$r,divideScalar:Dr,equalScalar:nr,larger:ft,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J,unaryMinus:It}),A8=h4({Complex:xr,add:wr,ctranspose:Rs,deepEqual:Lh,divideScalar:Dr,dot:po,dotDivide:Ka,equal:At,inv:_n,matrix:Te,multiply:Nr,typed:J}),qt=PN({Complex:xr,config:ge,fraction:pa,identity:vn,inv:_n,matrix:Te,multiply:Nr,number:mn,typed:J}),ad=TA({DenseMatrix:Qe,Index:Jr,compareNatural:_t,size:Zr,subset:at,typed:J}),E8=kA({Index:Jr,concat:ur,setIntersect:ad,setSymDifference:td,size:Zr,subset:at,typed:J}),S8=A4({abs:rt,add:wr,identity:vn,inv:_n,map:va,max:Wh,multiply:Nr,size:Zr,sqrt:Ot,subtract:yr,typed:J}),Ze=gD({BigNumber:Me,Complex:xr,Fraction:On,abs:rt,addScalar:$r,config:ge,divideScalar:Dr,equal:At,fix:Zh,format:Wa,isNumeric:Rn,multiplyScalar:Cr,number:mn,pow:qt,round:vo,subtract:yr}),C8=$B({BigNumber:Me,Unit:Ze,config:ge}),M8=v$({BigNumber:Me,Unit:Ze,config:ge}),F8=r$({BigNumber:Me,Unit:Ze,config:ge}),T8=RB({BigNumber:Me,Unit:Ze,config:ge}),B8=n$({BigNumber:Me,Unit:Ze,config:ge}),$8=_B({BigNumber:Me,Unit:Ze,config:ge}),O8=DD({Unit:Ze,typed:J}),I8=XB({BigNumber:Me,Unit:Ze,config:ge}),R8=WN({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,pow:qt,typed:J}),_8=BB({BigNumber:Me,Unit:Ze,config:ge}),q8=IB({BigNumber:Me,Unit:Ze,config:ge}),z8=N4({abs:rt,add:wr,identity:vn,inv:_n,multiply:Nr,typed:J}),P8=a$({BigNumber:Me,Unit:Ze,config:ge}),id=oN({addScalar:$r,ceil:Ls,conj:In,divideScalar:Dr,dotDivide:Ka,exp:Th,i:Eh,log2:Bh,matrix:Te,multiplyScalar:Cr,pow:qt,tau:Ch,typed:J}),od=tT({BigNumber:Me,Complex:xr,config:ge,multiplyScalar:Cr,pow:qt,typed:J}),U8=CB({BigNumber:Me,Unit:Ze,config:ge}),L8=ZB({BigNumber:Me,Unit:Ze,config:ge}),k8=uN({conj:In,dotDivide:Ka,fft:id,typed:J}),V8=UB({BigNumber:Me,Unit:Ze,config:ge}),G8=o$({BigNumber:Me,Unit:Ze,config:ge}),H8=TB({BigNumber:Me,Unit:Ze,config:ge}),Z8=p$({BigNumber:Me,Unit:Ze,config:ge}),J8=u$({BigNumber:Me,Unit:Ze,config:ge}),X8=WB({BigNumber:Me,Unit:Ze,config:ge}),W8=PB({BigNumber:Me,Unit:Ze,config:ge}),Y8=x$({BigNumber:Me,Unit:Ze,config:ge}),Q8=g$({BigNumber:Me,Unit:Ze,config:ge}),K8=w$({BigNumber:Me,Unit:Ze,config:ge}),j8=JB({BigNumber:Me,Unit:Ze,config:ge}),e6=FB({BigNumber:Me,Unit:Ze,config:ge}),r6=QB({BigNumber:Me,Unit:Ze,config:ge}),t6=f$({BigNumber:Me,Unit:Ze,config:ge}),n6=SB({BigNumber:Me,Unit:Ze,config:ge}),a6=m$({BigNumber:Me,Unit:Ze,config:ge}),i6=KB({BigNumber:Me,Unit:Ze,config:ge}),o6=t$({BigNumber:Me,Unit:Ze,config:ge}),s6=LB({BigNumber:Me,Unit:Ze,config:ge}),u6=OB({BigNumber:Me,Unit:Ze,config:ge}),mt=O4({divideScalar:Dr,equalScalar:nr,inv:_n,matrix:Te,multiply:Nr,typed:J}),l6=VB({BigNumber:Me,Unit:Ze,config:ge}),ho=oT({gamma:od,typed:J}),c6=i$({BigNumber:Me,Unit:Ze,config:ge}),f6=s$({BigNumber:Me,Unit:Ze,config:ge}),m6=qB({BigNumber:Me,Unit:Ze,config:ge}),sd=TS({DenseMatrix:Qe,lsolve:Xh,lup:nd,matrix:Te,slu:Yh,typed:J,usolve:Us}),v6=zB({BigNumber:Me,Unit:Ze,config:ge}),p6=h$({BigNumber:Me,Unit:Ze,config:ge}),h6=cT({add:wr,divide:mt,factorial:ho,isInteger:lt,isPositive:fo,multiply:Nr,typed:J}),d6=mT({factorial:ho,typed:J}),g6=y$({BigNumber:Me,Unit:Ze,config:ge}),y6=$S({add:wr,cbrt:qh,divide:mt,equalScalar:nr,im:Ts,isZero:Nt,multiply:Nr,re:Bs,sqrt:Ot,subtract:yr,typeOf:Ih,typed:J,unaryMinus:It}),b6=zA({compareNatural:_t,typed:J}),ud=MT({bignumber:$t,addScalar:$r,combinations:lo,divideScalar:Dr,factorial:ho,isInteger:lt,isNegative:ma,larger:ft,multiplyScalar:Cr,number:mn,pow:qt,subtract:yr,typed:J}),x6=bD({Unit:Ze,typed:J}),w6=TT({addScalar:$r,isInteger:lt,isNegative:ma,stirlingS2:ud,typed:J}),ld=x4({abs:rt,add:wr,addScalar:$r,atan:Fh,bignumber:$t,column:ed,complex:co,config:ge,cos:Is,diag:zh,divideScalar:Dr,dot:po,equal:At,flatten:ja,im:Ts,inv:_n,larger:ft,matrix:Te,matrixFromColumns:_s,multiply:Nr,multiplyScalar:Cr,number:mn,qr:ks,re:Bs,sin:$s,smaller:ct,sqrt:Ot,subtract:yr,typed:J,usolve:Us,usolveAll:jh}),N6=GB({BigNumber:Me,Unit:Ze,config:ge}),D6=d$({BigNumber:Me,Unit:Ze,config:ge}),A6=uT({divide:mt,dotDivide:Ka,isNumeric:Rn,log:qs,map:va,matrix:Te,multiply:Nr,sum:Kh,typed:J}),E6=$p({add:wr,divide:mt,typed:J}),S6=l$({BigNumber:Me,Unit:Ze,config:ge}),C6=MB({BigNumber:Me,Unit:Ze,config:ge}),M6=YB({BigNumber:Me,Unit:Ze,config:ge}),Vs=_p({add:wr,apply:Os,divide:mt,isNaN:Ya,multiply:Nr,subtract:yr,typed:J}),F6=kB({BigNumber:Me,Unit:Ze,config:ge}),cd=V4({add:wr,compare:ha,divide:mt,partitionSelect:zs,typed:J}),T6=b$({BigNumber:Me,Unit:Ze,config:ge}),B6=zp({map:va,sqrt:Ot,typed:J,variance:Vs}),$6=H4({abs:rt,map:va,median:cd,subtract:yr,typed:J}),Gs=XA({abs:rt,add:wr,conj:In,ctranspose:Rs,eigs:ld,equalScalar:nr,larger:ft,matrix:Te,multiply:Nr,pow:qt,smaller:ct,sqrt:Ot,typed:J}),fd=Vw({BigNumber:Me,DenseMatrix:Qe,SparseMatrix:Yt,addScalar:$r,config:ge,cos:Is,matrix:Te,multiplyScalar:Cr,norm:Gs,sin:$s,typed:J,unaryMinus:It}),O6=Lw({multiply:Nr,rotationMatrix:fd,typed:J}),md=M4({identity:vn,matrix:Te,multiply:Nr,norm:Gs,qr:ks,subtract:yr,typed:J}),vd=S4({abs:rt,add:wr,concat:ur,identity:vn,index:Jh,lusolve:sd,matrix:Te,matrixFromColumns:_s,multiply:Nr,range:da,schur:md,subset:at,subtract:yr,transpose:Qa,typed:J}),I6=T4({matrix:Te,multiply:Nr,sylvester:vd,transpose:Qa,typed:J}),ga={},ya={},pd={},Xr=aE({mathWithTransform:ya}),ba=TE({Node:Xr}),Qt=$E({Node:Xr}),qn=IE({Node:Xr}),hd=zE({Node:Xr}),xa=uE({Node:Xr}),dd=pE({Node:Xr,ResultSet:Sh}),gd=dE({Node:Xr}),pn=AE({Node:Xr}),yd=_E({Node:Xr}),R6=aB({classes:pd}),Hs=zS({math:ga,typed:J}),bd=SE({Node:Xr,typed:J}),_6=l4({Chain:Hs,typed:J}),wa=oE({Node:Xr,subset:at}),Na=ME({Node:Xr,size:Zr}),xd=mE({matrix:Te,Node:Xr,subset:at}),hn=LE({Unit:Ze,Node:Xr,math:ga}),dn=VE({Node:Xr,SymbolNode:hn,math:ga}),Et=HE({AccessorNode:wa,ArrayNode:xa,AssignmentNode:xd,BlockNode:dd,ConditionalNode:gd,ConstantNode:pn,FunctionAssignmentNode:bd,FunctionNode:dn,IndexNode:Na,ObjectNode:ba,OperatorNode:Qt,ParenthesisNode:qn,RangeNode:yd,RelationalNode:hd,SymbolNode:hn,config:ge,numeric:Dt,typed:J}),wd=WT({ConstantNode:pn,FunctionNode:dn,OperatorNode:Qt,ParenthesisNode:qn,parse:Et,typed:J}),Zs=GT({bignumber:$t,fraction:pa,AccessorNode:wa,ArrayNode:xa,ConstantNode:pn,FunctionNode:dn,IndexNode:Na,ObjectNode:ba,OperatorNode:Qt,SymbolNode:hn,config:ge,mathWithTransform:ya,matrix:Te,typed:J}),q6=JE({parse:Et,typed:J}),Js=WE({parse:Et,typed:J}),Nd=RS({parse:Et}),Dd=KE({evaluate:Js}),Xs=ZT({AccessorNode:wa,ArrayNode:xa,ConstantNode:pn,FunctionNode:dn,IndexNode:Na,ObjectNode:ba,OperatorNode:Qt,ParenthesisNode:qn,SymbolNode:hn,add:wr,divide:mt,equal:At,isZero:Nt,multiply:Nr,parse:Et,pow:qt,subtract:yr,typed:J}),z6=s4({Help:Nd,mathWithTransform:ya,typed:J}),go=LT({bignumber:$t,fraction:pa,AccessorNode:wa,ArrayNode:xa,ConstantNode:pn,FunctionNode:dn,IndexNode:Na,ObjectNode:ba,OperatorNode:Qt,ParenthesisNode:qn,SymbolNode:hn,add:wr,config:ge,divide:mt,equal:At,isZero:Nt,mathWithTransform:ya,matrix:Te,multiply:Nr,parse:Et,pow:qt,resolve:wd,simplifyConstant:Zs,simplifyCore:Xs,subtract:yr,typed:J}),P6=QT({OperatorNode:Qt,parse:Et,simplify:go,typed:J}),U6=jT({ConstantNode:pn,FunctionNode:dn,OperatorNode:Qt,ParenthesisNode:qn,SymbolNode:hn,config:ge,equal:At,isZero:Nt,numeric:Dt,parse:Et,simplify:go,typed:J}),L6=eS({Parser:Dd,typed:J}),k6=_T({parse:Et,typed:J}),V6=rB({bignumber:$t,fraction:pa,AccessorNode:wa,ArrayNode:xa,ConstantNode:pn,FunctionNode:dn,IndexNode:Na,ObjectNode:ba,OperatorNode:Qt,ParenthesisNode:qn,SymbolNode:hn,add:wr,config:ge,divide:mt,equal:At,isZero:Nt,mathWithTransform:ya,matrix:Te,multiply:Nr,parse:Et,pow:qt,simplify:go,simplifyConstant:Zs,simplifyCore:Xs,subtract:yr,typed:J});Sr(ga,{e:Ah,false:yO,fineStructure:bO,i:Eh,Infinity:xO,LN10:wO,LOG10E:NO,NaN:DO,null:AO,phi:EO,SQRT1_2:CO,sackurTetrode:MO,tau:Ch,true:FO,E:Ah,version:TO,efimovFactor:BO,LN2:$O,pi:Mh,replacer:OO,reviver:R6,SQRT2:IO,typed:J,unaryPlus:Fs,PI:Mh,weakMixingAngle:RO,abs:rt,acos:_O,acot:qO,acsc:zO,addScalar:$r,arg:PO,asech:UO,asinh:LO,atan:Fh,atanh:kO,bignumber:$t,bitNot:VO,boolean:GO,clone:HO,combinations:lo,complex:co,conj:In,cosh:ZO,coth:JO,csc:XO,cube:WO,equalScalar:nr,erf:YO,exp:Th,expm1:QO,filter:KO,forEach:jO,format:Wa,getMatrixDataType:e5,hex:r5,im:Ts,isInteger:lt,isNegative:ma,isPositive:fo,isZero:Nt,LOG2E:t5,lgamma:n5,log10:a5,log2:Bh,map:va,multiplyScalar:Cr,not:$h,number:mn,oct:i5,pickRandom:o5,print:s5,random:u5,re:Bs,sec:l5,sign:Oh,sin:$s,splitUnit:c5,square:f5,string:m5,tan:v5,typeOf:Ih,acosh:p5,acsch:h5,apply:Os,asec:d5,bin:g5,chain:_6,combinationsWithRep:y5,cos:Is,csch:b5,isNaN:Ya,isPrime:x5,randomInt:w5,sech:N5,sinh:D5,sparse:A5,sqrt:Ot,tanh:E5,unaryMinus:It,acoth:S5,cot:C5,fraction:pa,isNumeric:Rn,matrix:Te,matrixFromFunction:M5,mode:F5,numeric:Dt,prod:Rh,reshape:T5,size:Zr,squeeze:B5,subset:at,transpose:Qa,xgcd:_h,zeros:Rt,asin:$5,cbrt:qh,concat:ur,count:O5,ctranspose:Rs,diag:zh,divideScalar:Dr,dotDivide:Ka,equal:At,flatten:ja,gcd:I5,hasNumericValue:R5,identity:vn,kron:_5,largerEq:mo,leftShift:q5,matrixFromColumns:_s,mod:Ph,nthRoot:z5,ones:P5,resize:U5,rightArithShift:L5,round:vo,smaller:ct,to:k5,unequal:V5,xor:G5,add:wr,bitAnd:H5,bitXor:Z5,catalan:J5,compare:ha,compareText:Uh,cumsum:X5,deepEqual:Lh,dot:po,equalText:W5,floor:kh,hypot:Y5,invmod:Q5,larger:ft,log:qs,matrixFromRows:K5,min:j5,multiply:Nr,nthRoots:e8,or:r8,partitionSelect:zs,quantileSeq:t8,rightLogShift:n8,smallerEq:Ps,subtract:yr,trace:a8,usolve:Us,and:i8,bitOr:o8,ceil:Ls,compareNatural:_t,composition:s8,cross:u8,det:Gh,diff:l8,distance:c8,dotMultiply:f8,fix:Zh,index:Jh,intersect:m8,lcm:v8,log1p:p8,lsolve:Xh,max:Wh,qr:ks,range:da,row:h8,setCartesian:d8,setDistinct:g8,setIsSubset:y8,setPowerset:b8,slu:Yh,sum:Kh,usolveAll:jh,atan2:x8,column:ed,lsolveAll:w8,setDifference:rd,setMultiplicity:N8,setSymDifference:td,sort:D8,inv:_n,lup:nd,pinv:A8,pow:qt,setIntersect:ad,setUnion:E8,sqrtm:S8,vacuumImpedance:C8,wienDisplacement:M8,atomicMass:F8,bohrMagneton:T8,boltzmann:B8,conductanceQuantum:$8,createUnit:O8,deuteronMass:I8,dotPow:R8,electricConstant:_8,elementaryCharge:q8,expm:z8,faraday:P8,fft:id,gamma:od,gravitationConstant:U8,hartreeEnergy:L8,ifft:k8,klitzing:V8,loschmidt:G8,magneticConstant:H8,molarMass:Z8,molarPlanckConstant:J8,neutronMass:X8,nuclearMagneton:W8,planckCharge:Y8,planckLength:Q8,planckTemperature:K8,protonMass:j8,reducedPlanckConstant:e6,rydberg:r6,secondRadiation:t6,speedOfLight:n6,stefanBoltzmann:a6,thomsonCrossSection:i6,avogadro:o6,bohrRadius:s6,coulomb:u6,divide:mt,electronMass:l6,factorial:ho,firstRadiation:c6,gasConstant:f6,inverseConductanceQuantum:m6,lusolve:sd,magneticFluxQuantum:v6,molarMassC12:p6,multinomial:h6,permutations:d6,planckMass:g6,polynomialRoot:y6,setSize:b6,stirlingS2:ud,unit:x6,bellNumbers:w6,eigs:ld,fermiCoupling:N6,gravity:D6,kldivergence:A6,mean:E6,molarVolume:S6,planckConstant:C6,quantumOfCirculation:M6,variance:Vs,classicalElectronRadius:F6,median:cd,parse:Et,planckTime:T6,resolve:wd,simplifyConstant:Zs,std:B6,compile:q6,evaluate:Js,mad:$6,simplifyCore:Xs,help:z6,norm:Gs,rotationMatrix:fd,simplify:go,symbolicEqual:P6,derivative:U6,parser:L6,rotate:O6,leafCount:k6,rationalize:V6,schur:md,sylvester:vd,lyap:I6,config:ge}),Sr(ya,ga,{filter:T$({typed:J}),forEach:O$({typed:J}),map:P$({typed:J}),apply:A$({isInteger:lt,typed:J}),subset:nO({matrix:Te,typed:J}),concat:oO({isInteger:lt,matrix:Te,typed:J}),max:k$({config:ge,larger:ft,numeric:Dt,typed:J}),sum:vO({add:wr,config:ge,numeric:Dt,typed:J}),min:X$({config:ge,numeric:Dt,smaller:ct,typed:J}),cumsum:hO({add:wr,typed:J,unaryPlus:Fs}),diff:uO({bignumber:$t,matrix:Te,number:mn,subtract:yr,typed:J}),index:_$({Index:Jr}),range:Q$({bignumber:$t,matrix:Te,config:ge,larger:ft,largerEq:mo,smaller:ct,smallerEq:Ps,typed:J}),row:eO({Index:Jr,matrix:Te,range:da,typed:J}),column:C$({Index:Jr,matrix:Te,range:da,typed:J}),mean:H$({add:wr,divide:mt,typed:J}),variance:gO({add:wr,apply:Os,divide:mt,isNaN:Ya,multiply:Nr,subtract:yr,typed:J}),std:fO({map:va,sqrt:Ot,typed:J,variance:Vs})}),Sr(pd,{BigNumber:Me,Complex:xr,Fraction:On,Matrix:uo,Node:Xr,ObjectNode:ba,OperatorNode:Qt,ParenthesisNode:qn,Range:SO,RelationalNode:hd,ResultSet:Sh,ArrayNode:xa,BlockNode:dd,ConditionalNode:gd,ConstantNode:pn,DenseMatrix:Qe,RangeNode:yd,Chain:Hs,FunctionAssignmentNode:bd,SparseMatrix:Yt,AccessorNode:wa,IndexNode:Na,AssignmentNode:xd,ImmutableDenseMatrix:Vh,Index:Jr,FibonacciHeap:Hh,Spa:Qh,Unit:Ze,SymbolNode:hn,FunctionNode:dn,Help:Nd,Parser:Dd}),Hs.createProxy(ga);/**
|
|
71
|
+
In case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.`,examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},wF={name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, dimension)","std(A, normalization)","std(A, dimension, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},NF={name:"cumsum",category:"Statistics",syntax:["cumsum(a, b, c, ...)","cumsum(A)"],description:"Compute the cumulative sum of all values.",examples:["cumsum(2, 3, 4, 1)","cumsum([2, 3, 4, 1])","cumsum([1, 2; 3, 4])","cumsum([1, 2; 3, 4], 1)","cumsum([1, 2; 3, 4], 2)"],seealso:["max","mean","median","min","prod","std","sum","variance"]},DF={name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)","sum(A, dimension)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},AF={name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, dimension)","variance(A, normalization)","variance(A, dimension, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},EF={name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},SF={name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},CF={name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},MF={name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},FF={name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},TF={name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},BF={name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},$F={name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},OF={name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},IF={name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},RF={name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},_F={name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},qF={name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},zF={name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},PF={name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},UF={name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},LF={name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},kF={name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},VF={name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},GF={name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},HF={name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},ZF={name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},JF={name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},XF={name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},WF={name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},YF={name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},QF={name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},KF={name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},jF={name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},e4={name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},r4={name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},t4={name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},n4={name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},a4={name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},i4={name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},o4={name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},s4={name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},u4={name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},l4={name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "BigNumber")','numeric("4", "Fraction)','numeric(4, "Fraction")','numeric(fraction(2, 5), "number)'],seealso:["number","fraction","bignumber","string","format"]},c4={name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},f4={name:"print",category:"Utils",syntax:["print(template, values)","print(template, values, precision)"],description:"Interpolate values into a string template.",examples:['print("Lucy is $age years old", {age: 5})','print("The value of pi is $pi", {pi: pi}, 3)','print("Hello, $user.name!", {user: {name: "John"}})','print("Values: $0, $1, $2", [6, 9, 4])'],seealso:["format"]},m4={name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},v4={bignumber:uC,boolean:lC,complex:cC,createUnit:fC,fraction:mC,index:vC,matrix:pC,number:hC,sparse:dC,splitUnit:gC,string:yC,unit:bC,e:gp,E:gp,false:JS,i:XS,Infinity:WS,LN2:QS,LN10:YS,LOG2E:jS,LOG10E:KS,NaN:eC,null:rC,pi:yp,PI:yp,phi:tC,SQRT1_2:nC,SQRT2:aC,tau:iC,true:oC,version:sC,speedOfLight:{description:"Speed of light in vacuum",examples:["speedOfLight"]},gravitationConstant:{description:"Newtonian constant of gravitation",examples:["gravitationConstant"]},planckConstant:{description:"Planck constant",examples:["planckConstant"]},reducedPlanckConstant:{description:"Reduced Planck constant",examples:["reducedPlanckConstant"]},magneticConstant:{description:"Magnetic constant (vacuum permeability)",examples:["magneticConstant"]},electricConstant:{description:"Electric constant (vacuum permeability)",examples:["electricConstant"]},vacuumImpedance:{description:"Characteristic impedance of vacuum",examples:["vacuumImpedance"]},coulomb:{description:"Coulomb's constant",examples:["coulomb"]},elementaryCharge:{description:"Elementary charge",examples:["elementaryCharge"]},bohrMagneton:{description:"Borh magneton",examples:["bohrMagneton"]},conductanceQuantum:{description:"Conductance quantum",examples:["conductanceQuantum"]},inverseConductanceQuantum:{description:"Inverse conductance quantum",examples:["inverseConductanceQuantum"]},magneticFluxQuantum:{description:"Magnetic flux quantum",examples:["magneticFluxQuantum"]},nuclearMagneton:{description:"Nuclear magneton",examples:["nuclearMagneton"]},klitzing:{description:"Von Klitzing constant",examples:["klitzing"]},bohrRadius:{description:"Borh radius",examples:["bohrRadius"]},classicalElectronRadius:{description:"Classical electron radius",examples:["classicalElectronRadius"]},electronMass:{description:"Electron mass",examples:["electronMass"]},fermiCoupling:{description:"Fermi coupling constant",examples:["fermiCoupling"]},fineStructure:{description:"Fine-structure constant",examples:["fineStructure"]},hartreeEnergy:{description:"Hartree energy",examples:["hartreeEnergy"]},protonMass:{description:"Proton mass",examples:["protonMass"]},deuteronMass:{description:"Deuteron Mass",examples:["deuteronMass"]},neutronMass:{description:"Neutron mass",examples:["neutronMass"]},quantumOfCirculation:{description:"Quantum of circulation",examples:["quantumOfCirculation"]},rydberg:{description:"Rydberg constant",examples:["rydberg"]},thomsonCrossSection:{description:"Thomson cross section",examples:["thomsonCrossSection"]},weakMixingAngle:{description:"Weak mixing angle",examples:["weakMixingAngle"]},efimovFactor:{description:"Efimov factor",examples:["efimovFactor"]},atomicMass:{description:"Atomic mass constant",examples:["atomicMass"]},avogadro:{description:"Avogadro's number",examples:["avogadro"]},boltzmann:{description:"Boltzmann constant",examples:["boltzmann"]},faraday:{description:"Faraday constant",examples:["faraday"]},firstRadiation:{description:"First radiation constant",examples:["firstRadiation"]},loschmidt:{description:"Loschmidt constant at T=273.15 K and p=101.325 kPa",examples:["loschmidt"]},gasConstant:{description:"Gas constant",examples:["gasConstant"]},molarPlanckConstant:{description:"Molar Planck constant",examples:["molarPlanckConstant"]},molarVolume:{description:"Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",examples:["molarVolume"]},sackurTetrode:{description:"Sackur-Tetrode constant at T=1 K and p=101.325 kPa",examples:["sackurTetrode"]},secondRadiation:{description:"Second radiation constant",examples:["secondRadiation"]},stefanBoltzmann:{description:"Stefan-Boltzmann constant",examples:["stefanBoltzmann"]},wienDisplacement:{description:"Wien displacement law constant",examples:["wienDisplacement"]},molarMass:{description:"Molar mass constant",examples:["molarMass"]},molarMassC12:{description:"Molar mass constant of carbon-12",examples:["molarMassC12"]},gravity:{description:"Standard acceleration of gravity (standard acceleration of free-fall on Earth)",examples:["gravity"]},planckLength:{description:"Planck length",examples:["planckLength"]},planckMass:{description:"Planck mass",examples:["planckMass"]},planckTime:{description:"Planck time",examples:["planckTime"]},planckCharge:{description:"Planck charge",examples:["planckCharge"]},planckTemperature:{description:"Planck temperature",examples:["planckTemperature"]},derivative:DC,lsolve:EC,lsolveAll:SC,lup:CC,lusolve:MC,leafCount:AC,polynomialRoot:FC,resolve:$C,simplify:OC,simplifyConstant:IC,simplifyCore:RC,symbolicEqual:qC,rationalize:BC,slu:_C,usolve:zC,usolveAll:PC,qr:TC,abs:UC,add:LC,cbrt:kC,ceil:VC,cube:GC,divide:HC,dotDivide:ZC,dotMultiply:JC,dotPow:XC,exp:WC,expm:YC,expm1:QC,fix:KC,floor:jC,gcd:eM,hypot:rM,lcm:nM,log:aM,log2:sM,log1p:oM,log10:iM,mod:uM,multiply:lM,norm:cM,nthRoot:fM,nthRoots:mM,pow:vM,round:pM,sign:hM,sqrt:dM,sqrtm:gM,square:wM,subtract:NM,unaryMinus:DM,unaryPlus:AM,xgcd:EM,invmod:tM,bitAnd:SM,bitNot:CM,bitOr:MM,bitXor:FM,leftShift:TM,rightArithShift:BM,rightLogShift:$M,bellNumbers:OM,catalan:IM,composition:RM,stirlingS2:_M,config:xC,import:wC,typed:NC,arg:qM,conj:zM,re:UM,im:PM,evaluate:LM,help:kM,distance:VM,intersect:GM,and:HM,not:ZM,or:JM,xor:XM,concat:YM,count:QM,cross:KM,column:WM,ctranspose:jM,det:e3,diag:r3,diff:t3,dot:n3,getMatrixDataType:u3,identity:l3,filter:i3,flatten:o3,forEach:s3,inv:c3,pinv:f3,eigs:a3,kron:m3,matrixFromFunction:h3,matrixFromRows:d3,matrixFromColumns:p3,map:v3,ones:g3,partitionSelect:y3,range:b3,resize:w3,reshape:x3,rotate:N3,rotationMatrix:D3,row:A3,size:E3,sort:S3,squeeze:C3,subset:M3,trace:F3,transpose:T3,zeros:B3,fft:$3,ifft:O3,sylvester:yM,schur:bM,lyap:xM,combinations:I3,combinationsWithRep:R3,factorial:_3,gamma:q3,kldivergence:P3,lgamma:z3,multinomial:U3,permutations:L3,pickRandom:k3,random:V3,randomInt:G3,compare:H3,compareNatural:Z3,compareText:J3,deepEqual:X3,equal:W3,equalText:Y3,larger:Q3,largerEq:K3,smaller:j3,smallerEq:eF,unequal:rF,setCartesian:tF,setDifference:nF,setDistinct:aF,setIntersect:iF,setIsSubset:oF,setMultiplicity:sF,setPowerset:uF,setSize:lF,setSymDifference:cF,setUnion:fF,erf:mF,cumsum:NF,mad:vF,max:pF,mean:hF,median:dF,min:gF,mode:yF,prod:bF,quantileSeq:xF,std:wF,sum:DF,variance:AF,acos:EF,acosh:SF,acot:CF,acoth:MF,acsc:FF,acsch:TF,asec:BF,asech:$F,asin:OF,asinh:IF,atan:RF,atanh:qF,atan2:_F,cos:zF,cosh:PF,cot:UF,coth:LF,csc:kF,csch:VF,sec:GF,sech:HF,sin:ZF,sinh:JF,tan:XF,tanh:WF,to:YF,clone:KF,format:jF,bin:QF,oct:c4,hex:r4,isNaN:n4,isInteger:t4,isNegative:a4,isNumeric:i4,hasNumericValue:e4,isPositive:o4,isPrime:s4,isZero:u4,print:f4,typeOf:m4,numeric:l4},bp="help",p4=["typed","mathWithTransform","Help"],h4=q(bp,p4,r=>{var{typed:e,mathWithTransform:t,Help:a}=r;return e(bp,{any:function(i){var o,f=i;if(typeof i!="string"){for(o in t)if(Re(t,o)&&i===t[o]){f=o;break}}var l=lt(v4,f);if(!l){var u=typeof f=="function"?f.name:f;throw new Error('No documentation found on "'+u+'"')}return new a(l)}})}),xp="chain",d4=["typed","Chain"],g4=q(xp,d4,r=>{var{typed:e,Chain:t}=r;return e(xp,{"":function(){return new t},any:function(n){return new t(n)}})}),wp="det",y4=["typed","matrix","subtract","multiply","divideScalar","isZero","unaryMinus"],b4=q(wp,y4,r=>{var{typed:e,matrix:t,subtract:a,multiply:n,divideScalar:i,isZero:o,unaryMinus:f}=r;return e(wp,{any:function(s){return Ge(s)},"Array | Matrix":function(s){var c;switch(Ve(s)?c=s.size():Array.isArray(s)?(s=t(s),c=s.size()):c=[],c.length){case 0:return Ge(s);case 1:if(c[0]===1)return Ge(s.valueOf()[0]);if(c[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+Ye(c)+")");case 2:{var m=c[0],v=c[1];if(m===v)return l(s.clone().valueOf(),m);if(v===0)return 1;throw new RangeError("Matrix must be square (size: "+Ye(c)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Ye(c)+")")}}});function l(u,s,c){if(s===1)return Ge(u[0][0]);if(s===2)return a(n(u[0][0],u[1][1]),n(u[1][0],u[0][1]));for(var m=!1,v=new Array(s).fill(0).map((E,A)=>A),h=0;h<s;h++){var p=v[h];if(o(u[p][h])){var g=void 0;for(g=h+1;g<s;g++)if(!o(u[v[g]][h])){p=v[g],v[g]=v[h],v[h]=p,m=!m;break}if(g===s)return u[p][h]}for(var y=u[p][h],N=h===0?1:u[v[h-1]][h-1],d=h+1;d<s;d++)for(var w=v[d],x=h+1;x<s;x++)u[w][x]=i(a(n(u[w][x],y),n(u[w][h],u[p][x])),N)}var b=u[v[s-1]][s-1];return m?f(b):b}}),Np="inv",x4=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],w4=q(Np,x4,r=>{var{typed:e,matrix:t,divideScalar:a,addScalar:n,multiply:i,unaryMinus:o,det:f,identity:l,abs:u}=r;return e(Np,{"Array | Matrix":function(m){var v=Ve(m)?m.size():er(m);switch(v.length){case 1:if(v[0]===1)return Ve(m)?t([a(1,m.valueOf()[0])]):[a(1,m[0])];throw new RangeError("Matrix must be square (size: "+Ye(v)+")");case 2:{var h=v[0],p=v[1];if(h===p)return Ve(m)?t(s(m.valueOf(),h,p),m.storage()):s(m,h,p);throw new RangeError("Matrix must be square (size: "+Ye(v)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Ye(v)+")")}},any:function(m){return a(1,m)}});function s(c,m,v){var h,p,g,y,N;if(m===1){if(y=c[0][0],y===0)throw Error("Cannot calculate inverse, determinant is zero");return[[a(1,y)]]}else if(m===2){var d=f(c);if(d===0)throw Error("Cannot calculate inverse, determinant is zero");return[[a(c[1][1],d),a(o(c[0][1]),d)],[a(o(c[1][0]),d),a(c[0][0],d)]]}else{var w=c.concat();for(h=0;h<m;h++)w[h]=w[h].concat();for(var x=l(m).valueOf(),b=0;b<v;b++){var E=u(w[b][b]),A=b;for(h=b+1;h<m;)u(w[h][b])>E&&(E=u(w[h][b]),A=h),h++;if(E===0)throw Error("Cannot calculate inverse, determinant is zero");h=A,h!==b&&(N=w[b],w[b]=w[h],w[h]=N,N=x[b],x[b]=x[h],x[h]=N);var S=w[b],D=x[b];for(h=0;h<m;h++){var T=w[h],B=x[h];if(h!==b){if(T[b]!==0){for(g=a(o(T[b]),S[b]),p=b;p<v;p++)T[p]=n(T[p],i(g,S[p]));for(p=0;p<v;p++)B[p]=n(B[p],i(g,D[p]))}}else{for(g=S[b],p=b;p<v;p++)T[p]=a(T[p],g);for(p=0;p<v;p++)B[p]=a(B[p],g)}}}return x}}}),Dp="pinv",N4=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],D4=q(Dp,N4,r=>{var{typed:e,matrix:t,inv:a,deepEqual:n,equal:i,dotDivide:o,dot:f,ctranspose:l,divideScalar:u,multiply:s,add:c,Complex:m}=r;return e(Dp,{"Array | Matrix":function(d){var w=Ve(d)?d.size():er(d);switch(w.length){case 1:return y(d)?l(d):w[0]===1?a(d):o(l(d),f(d,d));case 2:{if(y(d))return l(d);var x=w[0],b=w[1];if(x===b)try{return a(d)}catch(E){if(!(E instanceof Error&&E.message.match(/Cannot calculate inverse, determinant is zero/)))throw E}return Ve(d)?t(v(d.valueOf(),x,b),d.storage()):v(d,x,b)}default:throw new RangeError("Matrix must be two dimensional (size: "+Ye(w)+")")}},any:function(d){return i(d,0)?Ge(d):u(1,d)}});function v(N,d,w){var{C:x,F:b}=p(N,d,w),E=s(a(s(l(x),x)),l(x)),A=s(l(b),a(s(b,l(b))));return s(A,E)}function h(N,d,w){for(var x=Ge(N),b=0,E=0;E<d;E++){if(w<=b)return x;for(var A=E;g(x[A][b]);)if(A++,d===A&&(A=E,b++,w===b))return x;[x[A],x[E]]=[x[E],x[A]];for(var S=x[E][b],D=0;D<w;D++)x[E][D]=o(x[E][D],S);for(var T=0;T<d;T++)if(T!==E){S=x[T][b];for(var B=0;B<w;B++)x[T][B]=c(x[T][B],s(-1,s(S,x[E][B])))}b++}return x}function p(N,d,w){var x=h(N,d,w),b=N.map((A,S)=>A.filter((D,T)=>T<d&&!g(f(x[T],x[T])))),E=x.filter((A,S)=>!g(f(x[S],x[S])));return{C:b,F:E}}function g(N){return i(c(N,m(1,1)),c(0,m(1,1)))}function y(N){return n(c(N,m(1,1)),c(s(N,0),m(1,1)))}});function A4(r){var{addScalar:e,subtract:t,flatten:a,multiply:n,multiplyScalar:i,divideScalar:o,sqrt:f,abs:l,bignumber:u,diag:s,inv:c,qr:m,usolve:v,usolveAll:h,equal:p,complex:g,larger:y,smaller:N,matrixFromColumns:d,dot:w}=r;function x(k,Q,K,L,j){j===void 0&&(j=!0);var ae=b(k,Q,K,L,j);E(k,Q,K,L,j,ae);var{values:re,C:fe}=A(k,Q,K,L,j),he;return j&&(he=S(k,Q,fe,ae,re,K,L),he=d(...he)),{values:re,vectors:he}}function b(k,Q,K,L,j){var ae=L==="BigNumber",re=L==="Complex",fe=ae?u(0):0,he=ae?u(1):re?g(1):1,ce=ae?u(1):1,ie=ae?u(10):2,Ae=i(ie,ie),Oe;j&&(Oe=Array(Q).fill(he));for(var Ce=!1;!Ce;){Ce=!0;for(var $e=0;$e<Q;$e++){for(var V=fe,X=fe,oe=0;oe<Q;oe++)if($e!==oe){var G=l(k[$e][oe]);V=e(V,G),X=e(X,G)}if(!p(V,0)&&!p(X,0)){for(var Y=ce,te=V,ye=o(X,ie),me=i(X,ie);N(te,ye);)te=i(te,Ae),Y=i(Y,ie);for(;y(te,me);)te=o(te,Ae),Y=o(Y,ie);var z=N(o(e(te,X),Y),i(e(V,X),.95));if(z){Ce=!1;for(var U=o(1,Y),ee=0;ee<Q;ee++)$e!==ee&&(k[$e][ee]=i(k[$e][ee],Y),k[ee][$e]=i(k[ee][$e],U));j&&(Oe[$e]=i(Oe[$e],Y))}}}}return s(Oe)}function E(k,Q,K,L,j,ae){var re=L==="BigNumber",fe=L==="Complex",he=re?u(0):fe?g(0):0;re&&(K=u(K));for(var ce=0;ce<Q-2;ce++){for(var ie=0,Ae=he,Oe=ce+1;Oe<Q;Oe++){var Ce=k[Oe][ce];N(l(Ae),l(Ce))&&(Ae=Ce,ie=Oe)}if(!N(l(Ae),K)){if(ie!==ce+1){var $e=k[ie];k[ie]=k[ce+1],k[ce+1]=$e;for(var V=0;V<Q;V++){var X=k[V][ie];k[V][ie]=k[V][ce+1],k[V][ce+1]=X}if(j){var oe=ae[ie];ae[ie]=ae[ce+1],ae[ce+1]=oe}}for(var G=ce+2;G<Q;G++){var Y=o(k[G][ce],Ae);if(Y!==0){for(var te=0;te<Q;te++)k[G][te]=t(k[G][te],i(Y,k[ce+1][te]));for(var ye=0;ye<Q;ye++)k[ye][ce+1]=e(k[ye][ce+1],i(Y,k[ye][G]));if(j)for(var me=0;me<Q;me++)ae[G][me]=t(ae[G][me],i(Y,ae[ce+1][me]))}}}}return ae}function A(k,Q,K,L,j){var ae=L==="BigNumber",re=L==="Complex",fe=ae?u(1):re?g(1):1;ae&&(K=u(K));for(var he=Ge(k),ce=[],ie=Q,Ae=[],Oe=j?s(Array(Q).fill(fe)):void 0,Ce=j?s(Array(ie).fill(fe)):void 0,$e=0;$e<=100;){$e+=1;for(var V=0,X=0;X<ie;X++)he[X][X]=t(he[X][X],V);var{Q:oe,R:G}=m(he);he=n(G,oe);for(var Y=0;Y<ie;Y++)he[Y][Y]=e(he[Y][Y],V);if(j&&(Ce=n(Ce,oe)),ie===1||N(l(he[ie-1][ie-2]),K)){$e=0,ce.push(he[ie-1][ie-1]),j&&(Ae.unshift([[1]]),B(Ce,Q),Oe=n(Oe,Ce),ie>1&&(Ce=s(Array(ie-1).fill(fe)))),ie-=1,he.pop();for(var te=0;te<ie;te++)he[te].pop()}else if(ie===2||N(l(he[ie-2][ie-3]),K)){$e=0;var ye=D(he[ie-2][ie-2],he[ie-2][ie-1],he[ie-1][ie-2],he[ie-1][ie-1]);ce.push(...ye),j&&(Ae.unshift(T(he[ie-2][ie-2],he[ie-2][ie-1],he[ie-1][ie-2],he[ie-1][ie-1],ye[0],ye[1],K,L)),B(Ce,Q),Oe=n(Oe,Ce),ie>2&&(Ce=s(Array(ie-2).fill(fe)))),ie-=2,he.pop(),he.pop();for(var me=0;me<ie;me++)he[me].pop(),he[me].pop()}if(ie===0)break}if(ce.sort((ee,ue)=>+t(l(ee),l(ue))),$e>100){var z=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+ce.join(", "));throw z.values=ce,z.vectors=[],z}var U=j?n(Oe,I(Ae,Q)):void 0;return{values:ce,C:U}}function S(k,Q,K,L,j,ae,re){var fe=c(K),he=n(fe,k,K),ce=re==="BigNumber",ie=re==="Complex",Ae=ce?u(0):ie?g(0):0,Oe=ce?u(1):ie?g(1):1,Ce=[],$e=[];for(var V of j){var X=P(Ce,V,p);X===-1?(Ce.push(V),$e.push(1)):$e[X]+=1}for(var oe=[],G=Ce.length,Y=Array(Q).fill(Ae),te=s(Array(Q).fill(Oe)),ye=[],me=function(){var ue=Ce[z],ve=t(he,n(ue,te)),de=h(ve,Y);for(de.shift();de.length<$e[z];){var be=R(ve,Q,de,ae,re);if(be==null){ye.push(ue);break}de.push(be)}var pe=n(c(L),K);de=de.map(we=>n(pe,we)),oe.push(...de.map(we=>a(we)))},z=0;z<G;z++)me();if(ye.length!==0){var U=new Error("Failed to find eigenvectors for the following eigenvalues: "+ye.join(", "));throw U.values=j,U.vectors=oe,U}return oe}function D(k,Q,K,L){var j=e(k,L),ae=t(i(k,L),i(Q,K)),re=i(j,.5),fe=i(f(t(i(j,j),i(4,ae))),.5);return[e(re,fe),t(re,fe)]}function T(k,Q,K,L,j,ae,re,fe){var he=fe==="BigNumber",ce=fe==="Complex",ie=he?u(0):ce?g(0):0,Ae=he?u(1):ce?g(1):1;if(N(l(K),re))return[[Ae,ie],[ie,Ae]];if(y(l(t(j,ae)),re))return[[t(j,L),t(ae,L)],[K,K]];var Oe=t(k,j),Ce=t(Q,j),$e=t(K,j),V=t(L,j);return N(l(Ce),re)?[[Oe,Ae],[$e,ie]]:[[Ce,ie],[V,Ae]]}function B(k,Q){for(var K=0;K<k.length;K++)k[K].push(...Array(Q-k[K].length).fill(0));for(var L=k.length;L<Q;L++)k.push(Array(Q).fill(0)),k[L][L]=1;return k}function I(k,Q){for(var K=[],L=0;L<Q;L++)K[L]=Array(Q).fill(0);var j=0;for(var ae of k){for(var re=ae.length,fe=0;fe<re;fe++)for(var he=0;he<re;he++)K[j+fe][j+he]=ae[fe][he];j+=re}return K}function P(k,Q,K){for(var L=0;L<k.length;L++)if(K(k[L],Q))return L;return-1}function R(k,Q,K,L,j){for(var ae=j==="BigNumber"?u(1e3):1e3,re,fe=0;re=M(Q,K,j),re=v(k,re),!y(H(re),ae);)if(++fe>=5)return null;for(fe=0;;){var he=v(k,re);if(N(H(F(re,[he])),L))break;if(++fe>=10)return null;re=$(he)}return re}function M(k,Q,K){var L=K==="BigNumber",j=K==="Complex",ae=Array(k).fill(0).map(re=>2*Math.random()-1);return L&&(ae=ae.map(re=>u(re))),j&&(ae=ae.map(re=>g(re))),ae=F(ae,Q),$(ae,K)}function F(k,Q){for(var K of Q)k=t(k,n(o(w(K,k),w(K,K)),K));return k}function H(k){return l(f(w(k,k)))}function $(k,Q){var K=Q==="BigNumber",L=Q==="Complex",j=K?u(1):L?g(1):1;return n(o(j,H(k)),k)}return x}function E4(r){var{config:e,addScalar:t,subtract:a,abs:n,atan:i,cos:o,sin:f,multiplyScalar:l,inv:u,bignumber:s,multiply:c,add:m}=r;function v(D,T){var B=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.epsilon,I=arguments.length>3?arguments[3]:void 0;if(I==="number")return h(D,B);if(I==="BigNumber")return p(D,B);throw TypeError("Unsupported data type: "+I)}function h(D,T){for(var B=D.length,I=Math.abs(T/B),P,R=new Array(B),M=0;M<B;M++)R[M]=S(B,0),R[M][M]=1;for(var F=b(D);Math.abs(F[1])>=Math.abs(I);){var H=F[0][0],$=F[0][1];P=g(D[H][H],D[$][$],D[H][$]),D=x(D,P,H,$),R=N(R,P,H,$),F=b(D)}for(var k=S(B,0),Q=0;Q<B;Q++)k[Q]=D[Q][Q];return A(Ge(k),Ge(R))}function p(D,T){for(var B=D.length,I=n(T/B),P,R=new Array(B),M=0;M<B;M++)R[M]=S(B,0),R[M][M]=1;for(var F=E(D);n(F[1])>=n(I);){var H=F[0][0],$=F[0][1];P=y(D[H][H],D[$][$],D[H][$]),D=w(D,P,H,$),R=d(R,P,H,$),F=E(D)}for(var k=S(B,0),Q=0;Q<B;Q++)k[Q]=D[Q][Q];return A(Ge(k),Ge(R))}function g(D,T,B){var I=T-D;return Math.abs(I)<=e.epsilon?Math.PI/4:.5*Math.atan(2*B/(T-D))}function y(D,T,B){var I=a(T,D);return n(I)<=e.epsilon?s(-1).acos().div(4):l(.5,i(c(2,B,u(I))))}function N(D,T,B,I){for(var P=D.length,R=Math.cos(T),M=Math.sin(T),F=S(P,0),H=S(P,0),$=0;$<P;$++)F[$]=R*D[$][B]-M*D[$][I],H[$]=M*D[$][B]+R*D[$][I];for(var k=0;k<P;k++)D[k][B]=F[k],D[k][I]=H[k];return D}function d(D,T,B,I){for(var P=D.length,R=o(T),M=f(T),F=S(P,s(0)),H=S(P,s(0)),$=0;$<P;$++)F[$]=a(l(R,D[$][B]),l(M,D[$][I])),H[$]=t(l(M,D[$][B]),l(R,D[$][I]));for(var k=0;k<P;k++)D[k][B]=F[k],D[k][I]=H[k];return D}function w(D,T,B,I){for(var P=D.length,R=s(o(T)),M=s(f(T)),F=l(R,R),H=l(M,M),$=S(P,s(0)),k=S(P,s(0)),Q=c(s(2),R,M,D[B][I]),K=t(a(l(F,D[B][B]),Q),l(H,D[I][I])),L=m(l(H,D[B][B]),Q,l(F,D[I][I])),j=0;j<P;j++)$[j]=a(l(R,D[B][j]),l(M,D[I][j])),k[j]=t(l(M,D[B][j]),l(R,D[I][j]));D[B][B]=K,D[I][I]=L,D[B][I]=s(0),D[I][B]=s(0);for(var ae=0;ae<P;ae++)ae!==B&&ae!==I&&(D[B][ae]=$[ae],D[ae][B]=$[ae],D[I][ae]=k[ae],D[ae][I]=k[ae]);return D}function x(D,T,B,I){for(var P=D.length,R=Math.cos(T),M=Math.sin(T),F=R*R,H=M*M,$=S(P,0),k=S(P,0),Q=F*D[B][B]-2*R*M*D[B][I]+H*D[I][I],K=H*D[B][B]+2*R*M*D[B][I]+F*D[I][I],L=0;L<P;L++)$[L]=R*D[B][L]-M*D[I][L],k[L]=M*D[B][L]+R*D[I][L];D[B][B]=Q,D[I][I]=K,D[B][I]=0,D[I][B]=0;for(var j=0;j<P;j++)j!==B&&j!==I&&(D[B][j]=$[j],D[j][B]=$[j],D[I][j]=k[j],D[j][I]=k[j]);return D}function b(D){for(var T=D.length,B=0,I=[0,1],P=0;P<T;P++)for(var R=P+1;R<T;R++)Math.abs(B)<Math.abs(D[P][R])&&(B=Math.abs(D[P][R]),I=[P,R]);return[I,B]}function E(D){for(var T=D.length,B=0,I=[0,1],P=0;P<T;P++)for(var R=P+1;R<T;R++)n(B)<n(D[P][R])&&(B=n(D[P][R]),I=[P,R]);return[I,B]}function A(D,T){for(var B=D.length,I=Array(B),P=Array(B),R=0;R<B;R++)P[R]=Array(B);for(var M=0;M<B;M++){for(var F=0,H=D[0],$=0;$<D.length;$++)n(D[$])<n(H)&&(F=$,H=D[F]);I[M]=D.splice(F,1)[0];for(var k=0;k<B;k++)P[k][M]=T[k][F],T[k].splice(F,1)}return{values:I,vectors:P}}function S(D,T){for(var B=new Array(D),I=0;I<D;I++)B[I]=T;return B}return v}var S4="eigs",C4=["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","divideScalar","inv","bignumber","multiply","add","larger","column","flatten","number","complex","sqrt","diag","qr","usolve","usolveAll","im","re","smaller","matrixFromColumns","dot"],M4=q(S4,C4,r=>{var{config:e,typed:t,matrix:a,addScalar:n,subtract:i,equal:o,abs:f,atan:l,cos:u,sin:s,multiplyScalar:c,divideScalar:m,inv:v,bignumber:h,multiply:p,add:g,larger:y,column:N,flatten:d,number:w,complex:x,sqrt:b,diag:E,qr:A,usolve:S,usolveAll:D,im:T,re:B,smaller:I,matrixFromColumns:P,dot:R}=r,M=E4({config:e,addScalar:n,subtract:i,column:N,flatten:d,equal:o,abs:f,atan:l,cos:u,sin:s,multiplyScalar:c,inv:v,bignumber:h,complex:x,multiply:p,add:g}),F=A4({config:e,addScalar:n,subtract:i,multiply:p,multiplyScalar:c,flatten:d,divideScalar:m,sqrt:b,abs:f,bignumber:h,diag:E,qr:A,inv:v,usolve:S,usolveAll:D,equal:o,complex:x,larger:y,smaller:I,matrixFromColumns:P,dot:R});return t("eigs",{Array:function(j){var ae=a(j);return H(ae)},"Array, number|BigNumber":function(j,ae){var re=a(j);return H(re,ae)},Matrix:function(j){var{values:ae,vectors:re}=H(j);return{values:a(ae),vectors:a(re)}},"Matrix, number|BigNumber":function(j,ae){var{values:re,vectors:fe}=H(j,ae);return{values:a(re),vectors:a(fe)}}});function H(L,j){j===void 0&&(j=e.epsilon);var ae=L.size();if(ae.length!==2||ae[0]!==ae[1])throw new RangeError("Matrix must be square (size: "+Ye(ae)+")");var re=L.toArray(),fe=ae[0];if(k(re,fe,j)&&(Q(re,fe),$(re,fe,j))){var he=K(L,re,fe);return M(re,fe,j,he)}var ce=K(L,re,fe);return F(re,fe,j,ce)}function $(L,j,ae){for(var re=0;re<j;re++)for(var fe=re;fe<j;fe++)if(y(h(f(i(L[re][fe],L[fe][re]))),ae))return!1;return!0}function k(L,j,ae){for(var re=0;re<j;re++)for(var fe=0;fe<j;fe++)if(y(h(f(T(L[re][fe]))),ae))return!1;return!0}function Q(L,j){for(var ae=0;ae<j;ae++)for(var re=0;re<j;re++)L[ae][re]=B(L[ae][re])}function K(L,j,ae){var re=L.datatype();if(re==="number"||re==="BigNumber"||re==="Complex")return re;for(var fe=!1,he=!1,ce=!1,ie=0;ie<ae;ie++)for(var Ae=0;Ae<ae;Ae++){var Oe=j[ie][Ae];if(tr(Oe)||za(Oe))fe=!0;else if(rr(Oe))he=!0;else if(kt(Oe))ce=!0;else throw TypeError("Unsupported type in Matrix: "+br(Oe))}if(he&&ce&&console.warn("Complex BigNumbers not supported, this operation will lose precission."),ce){for(var Ce=0;Ce<ae;Ce++)for(var $e=0;$e<ae;$e++)j[Ce][$e]=x(j[Ce][$e]);return"Complex"}if(he){for(var V=0;V<ae;V++)for(var X=0;X<ae;X++)j[V][X]=h(j[V][X]);return"BigNumber"}if(fe){for(var oe=0;oe<ae;oe++)for(var G=0;G<ae;G++)j[oe][G]=w(j[oe][G]);return"number"}else throw TypeError("Matrix contains unsupported types only.")}}),Ap="expm",F4=["typed","abs","add","identity","inv","multiply"],T4=q(Ap,F4,r=>{var{typed:e,abs:t,add:a,identity:n,inv:i,multiply:o}=r;return e(Ap,{Matrix:function(c){var m=c.size();if(m.length!==2||m[0]!==m[1])throw new RangeError("Matrix must be square (size: "+Ye(m)+")");for(var v=m[0],h=1e-15,p=f(c),g=l(p,h),y=g.q,N=g.j,d=o(c,Math.pow(2,-N)),w=n(v),x=n(v),b=1,E=d,A=-1,S=1;S<=y;S++)S>1&&(E=o(E,d),A=-A),b=b*(y-S+1)/((2*y-S+1)*S),w=a(w,o(b,E)),x=a(x,o(b*A,E));for(var D=o(i(x),w),T=0;T<N;T++)D=o(D,D);return En(c)?c.createSparseMatrix(D):D}});function f(s){for(var c=s.size()[0],m=0,v=0;v<c;v++){for(var h=0,p=0;p<c;p++)h+=t(s.get([v,p]));m=Math.max(h,m)}return m}function l(s,c){for(var m=30,v=0;v<m;v++)for(var h=0;h<=v;h++){var p=v-h;if(u(s,h,p)<c)return{q:h,j:p}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}function u(s,c,m){for(var v=1,h=2;h<=c;h++)v*=h;for(var p=v,g=c+1;g<=2*c;g++)p*=g;var y=p*(2*c+1);return 8*Math.pow(s/Math.pow(2,m),2*c)*v*v/(p*y)}}),Ep="sqrtm",B4=["typed","abs","add","multiply","map","sqrt","subtract","inv","size","max","identity"],$4=q(Ep,B4,r=>{var{typed:e,abs:t,add:a,multiply:n,map:i,sqrt:o,subtract:f,inv:l,size:u,max:s,identity:c}=r,m=1e3,v=1e-6;function h(p){var g,y=0,N=p,d=c(u(p));do{var w=N;if(N=n(.5,a(w,l(d))),d=n(.5,a(d,l(w))),g=s(t(f(N,w))),g>v&&++y>m)throw new Error("computing square root of matrix: iterative method could not converge")}while(g>v);return N}return e(Ep,{"Array | Matrix":function(g){var y=Ve(g)?g.size():er(g);switch(y.length){case 1:if(y[0]===1)return i(g,o);throw new RangeError("Matrix must be square (size: "+Ye(y)+")");case 2:{var N=y[0],d=y[1];if(N===d)return h(g);throw new RangeError("Matrix must be square (size: "+Ye(y)+")")}default:throw new RangeError("Matrix must be at most two dimensional (size: "+Ye(y)+")")}}})}),Sp="sylvester",O4=["typed","schur","matrixFromColumns","matrix","multiply","range","concat","transpose","index","subset","add","subtract","identity","lusolve","abs"],I4=q(Sp,O4,r=>{var{typed:e,schur:t,matrixFromColumns:a,matrix:n,multiply:i,range:o,concat:f,transpose:l,index:u,subset:s,add:c,subtract:m,identity:v,lusolve:h,abs:p}=r;return e(Sp,{"Matrix, Matrix, Matrix":g,"Array, Matrix, Matrix":function(N,d,w){return g(n(N),d,w)},"Array, Array, Matrix":function(N,d,w){return g(n(N),n(d),w)},"Array, Matrix, Array":function(N,d,w){return g(n(N),d,n(w))},"Matrix, Array, Matrix":function(N,d,w){return g(N,n(d),w)},"Matrix, Array, Array":function(N,d,w){return g(N,n(d),n(w))},"Matrix, Matrix, Array":function(N,d,w){return g(N,d,n(w))},"Array, Array, Array":function(N,d,w){return g(n(N),n(d),n(w)).toArray()}});function g(y,N,d){for(var w=N.size()[0],x=y.size()[0],b=t(y),E=b.T,A=b.U,S=t(i(-1,N)),D=S.T,T=S.U,B=i(i(l(A),d),T),I=o(0,x),P=[],R=(Oe,Ce)=>f(Oe,Ce,1),M=(Oe,Ce)=>f(Oe,Ce,0),F=0;F<w;F++)if(F<w-1&&p(s(D,u(F+1,F)))>1e-5){for(var H=M(s(B,u(I,F)),s(B,u(I,F+1))),$=0;$<F;$++)H=c(H,M(i(P[$],s(D,u($,F))),i(P[$],s(D,u($,F+1)))));var k=i(v(x),i(-1,s(D,u(F,F)))),Q=i(v(x),i(-1,s(D,u(F+1,F)))),K=i(v(x),i(-1,s(D,u(F,F+1)))),L=i(v(x),i(-1,s(D,u(F+1,F+1)))),j=M(R(c(E,k),Q),R(K,c(E,L))),ae=h(j,H);P[F]=ae.subset(u(o(0,x),0)),P[F+1]=ae.subset(u(o(x,2*x),0)),F++}else{for(var re=s(B,u(I,F)),fe=0;fe<F;fe++)re=c(re,i(P[fe],s(D,u(fe,F))));var he=s(D,u(F,F)),ce=m(E,i(he,v(x)));P[F]=h(ce,re)}var ie=n(a(...P)),Ae=i(A,i(ie,l(T)));return Ae}}),Cp="schur",R4=["typed","matrix","identity","multiply","qr","norm","subtract"],_4=q(Cp,R4,r=>{var{typed:e,matrix:t,identity:a,multiply:n,qr:i,norm:o,subtract:f}=r;return e(Cp,{Array:function(s){var c=l(t(s));return{U:c.U.valueOf(),T:c.T.valueOf()}},Matrix:function(s){return l(s)}});function l(u){var s=u.size()[0],c=u,m=a(s),v=0,h;do{h=c;var p=i(c),g=p.Q,y=p.R;if(c=n(y,g),m=n(m,g),v++>100)break}while(o(f(c,h))>1e-4);return{U:m,T:c}}}),Mp="lyap",q4=["typed","matrix","sylvester","multiply","transpose"],z4=q(Mp,q4,r=>{var{typed:e,matrix:t,sylvester:a,multiply:n,transpose:i}=r;return e(Mp,{"Matrix, Matrix":function(f,l){return a(f,i(f),n(-1,l))},"Array, Matrix":function(f,l){return a(t(f),i(t(f)),n(-1,l))},"Matrix, Array":function(f,l){return a(f,i(t(f)),t(n(-1,l)))},"Array, Array":function(f,l){return a(t(f),i(t(f)),t(n(-1,l))).toArray()}})}),P4="divide",U4=["typed","matrix","multiply","equalScalar","divideScalar","inv"],L4=q(P4,U4,r=>{var{typed:e,matrix:t,multiply:a,equalScalar:n,divideScalar:i,inv:o}=r,f=Lr({typed:e,equalScalar:n}),l=xt({typed:e});return e("divide",ll({"Array | Matrix, Array | Matrix":function(s,c){return a(s,o(c))},"DenseMatrix, any":function(s,c){return l(s,c,i,!1)},"SparseMatrix, any":function(s,c){return f(s,c,i,!1)},"Array, any":function(s,c){return l(t(s),c,i,!1).valueOf()},"any, Array | Matrix":function(s,c){return a(s,o(c))}},i.signatures))}),Fp="distance",k4=["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],V4=q(Fp,k4,r=>{var{typed:e,addScalar:t,subtract:a,multiplyScalar:n,divideScalar:i,unaryMinus:o,sqrt:f,abs:l}=r;return e(Fp,{"Array, Array, Array":function(x,b,E){if(x.length===2&&b.length===2&&E.length===2){if(!s(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!s(b))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!s(E))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var A=i(a(E[1],E[0]),a(b[1],b[0])),S=n(n(A,A),b[0]),D=o(n(A,b[0])),T=x[1];return g(x[0],x[1],S,D,T)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(x,b,E){if(Object.keys(x).length===2&&Object.keys(b).length===2&&Object.keys(E).length===2){if(!s(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!s(b))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!s(E))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"lineOnePtX"in b&&"lineOnePtY"in b&&"lineTwoPtX"in E&&"lineTwoPtY"in E){var A=i(a(E.lineTwoPtY,E.lineTwoPtX),a(b.lineOnePtY,b.lineOnePtX)),S=n(n(A,A),b.lineOnePtX),D=o(n(A,b.lineOnePtX)),T=x.pointX;return g(x.pointX,x.pointY,S,D,T)}else throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(x,b){if(x.length===2&&b.length===3){if(!s(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!c(b))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return g(x[0],x[1],b[0],b[1],b[2])}else if(x.length===3&&b.length===6){if(!c(x))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!v(b))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return y(x[0],x[1],x[2],b[0],b[1],b[2],b[3],b[4],b[5])}else if(x.length===b.length&&x.length>0){if(!m(x))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!m(b))throw new TypeError("All values of an array should be numbers or BigNumbers");return N(x,b)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(x,b){if(Object.keys(x).length===2&&Object.keys(b).length===3){if(!s(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!c(b))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"xCoeffLine"in b&&"yCoeffLine"in b&&"constant"in b)return g(x.pointX,x.pointY,b.xCoeffLine,b.yCoeffLine,b.constant);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===3&&Object.keys(b).length===6){if(!c(x))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!v(b))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"x0"in b&&"y0"in b&&"z0"in b&&"a"in b&&"b"in b&&"c"in b)return y(x.pointX,x.pointY,x.pointZ,b.x0,b.y0,b.z0,b.a,b.b,b.c);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===2&&Object.keys(b).length===2){if(!s(x))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!s(b))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in x&&"pointOneY"in x&&"pointTwoX"in b&&"pointTwoY"in b)return N([x.pointOneX,x.pointOneY],[b.pointTwoX,b.pointTwoY]);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===3&&Object.keys(b).length===3){if(!c(x))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!c(b))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in x&&"pointOneY"in x&&"pointOneZ"in x&&"pointTwoX"in b&&"pointTwoY"in b&&"pointTwoZ"in b)return N([x.pointOneX,x.pointOneY,x.pointOneZ],[b.pointTwoX,b.pointTwoY,b.pointTwoZ]);throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},Array:function(x){if(!p(x))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return d(x)}});function u(w){return typeof w=="number"||rr(w)}function s(w){return w.constructor!==Array&&(w=h(w)),u(w[0])&&u(w[1])}function c(w){return w.constructor!==Array&&(w=h(w)),u(w[0])&&u(w[1])&&u(w[2])}function m(w){return Array.isArray(w)||(w=h(w)),w.every(u)}function v(w){return w.constructor!==Array&&(w=h(w)),u(w[0])&&u(w[1])&&u(w[2])&&u(w[3])&&u(w[4])&&u(w[5])}function h(w){for(var x=Object.keys(w),b=[],E=0;E<x.length;E++)b.push(w[x[E]]);return b}function p(w){if(w[0].length===2&&u(w[0][0])&&u(w[0][1])){if(w.some(x=>x.length!==2||!u(x[0])||!u(x[1])))return!1}else if(w[0].length===3&&u(w[0][0])&&u(w[0][1])&&u(w[0][2])){if(w.some(x=>x.length!==3||!u(x[0])||!u(x[1])||!u(x[2])))return!1}else return!1;return!0}function g(w,x,b,E,A){var S=l(t(t(n(b,w),n(E,x)),A)),D=f(t(n(b,b),n(E,E)));return i(S,D)}function y(w,x,b,E,A,S,D,T,B){var I=[a(n(a(A,x),B),n(a(S,b),T)),a(n(a(S,b),D),n(a(E,w),B)),a(n(a(E,w),T),n(a(A,x),D))];I=f(t(t(n(I[0],I[0]),n(I[1],I[1])),n(I[2],I[2])));var P=f(t(t(n(D,D),n(T,T)),n(B,B)));return i(I,P)}function N(w,x){for(var b=w.length,E=0,A=0,S=0;S<b;S++)A=a(w[S],x[S]),E=t(n(A,A),E);return f(E)}function d(w){for(var x=[],b=[],E=[],A=0;A<w.length-1;A++)for(var S=A+1;S<w.length;S++)w[0].length===2?(b=[w[A][0],w[A][1]],E=[w[S][0],w[S][1]]):w[0].length===3&&(b=[w[A][0],w[A][1],w[A][2]],E=[w[S][0],w[S][1],w[S][2]]),x.push(N(b,E));return x}}),G4="intersect",H4=["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],Z4=q(G4,H4,r=>{var{typed:e,config:t,abs:a,add:n,addScalar:i,matrix:o,multiply:f,multiplyScalar:l,divideScalar:u,subtract:s,smaller:c,equalScalar:m,flatten:v,isZero:h,isNumeric:p}=r;return e("intersect",{"Array, Array, Array":g,"Array, Array, Array, Array":y,"Matrix, Matrix, Matrix":function(T,B,I){var P=g(T.valueOf(),B.valueOf(),I.valueOf());return P===null?null:o(P)},"Matrix, Matrix, Matrix, Matrix":function(T,B,I,P){var R=y(T.valueOf(),B.valueOf(),I.valueOf(),P.valueOf());return R===null?null:o(R)}});function g(D,T,B){if(D=N(D),T=N(T),B=N(B),!w(D))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!w(T))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!x(B))throw new TypeError("Array with 4 numbers expected as third argument");return S(D[0],D[1],D[2],T[0],T[1],T[2],B[0],B[1],B[2],B[3])}function y(D,T,B,I){if(D=N(D),T=N(T),B=N(B),I=N(I),D.length===2){if(!d(D))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!d(T))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!d(B))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!d(I))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return b(D,T,B,I)}else if(D.length===3){if(!w(D))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!w(T))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!w(B))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!w(I))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return A(D[0],D[1],D[2],T[0],T[1],T[2],B[0],B[1],B[2],I[0],I[1],I[2])}else throw new TypeError("Arrays with two or thee dimensional points expected")}function N(D){return D.length===1?D[0]:D.length>1&&Array.isArray(D[0])&&D.every(T=>Array.isArray(T)&&T.length===1)?v(D):D}function d(D){return D.length===2&&p(D[0])&&p(D[1])}function w(D){return D.length===3&&p(D[0])&&p(D[1])&&p(D[2])}function x(D){return D.length===4&&p(D[0])&&p(D[1])&&p(D[2])&&p(D[3])}function b(D,T,B,I){var P=D,R=B,M=s(P,T),F=s(R,I),H=s(l(M[0],F[1]),l(F[0],M[1]));if(h(H)||c(a(H),t.epsilon))return null;var $=l(F[0],P[1]),k=l(F[1],P[0]),Q=l(F[0],R[1]),K=l(F[1],R[0]),L=u(i(s(s($,k),Q),K),H);return n(f(M,L),P)}function E(D,T,B,I,P,R,M,F,H,$,k,Q){var K=l(s(D,T),s(B,I)),L=l(s(P,R),s(M,F)),j=l(s(H,$),s(k,Q));return i(i(K,L),j)}function A(D,T,B,I,P,R,M,F,H,$,k,Q){var K=E(D,M,$,M,T,F,k,F,B,H,Q,H),L=E($,M,I,D,k,F,P,T,Q,H,R,B),j=E(D,M,I,D,T,F,P,T,B,H,R,B),ae=E($,M,$,M,k,F,k,F,Q,H,Q,H),re=E(I,D,I,D,P,T,P,T,R,B,R,B),fe=s(l(K,L),l(j,ae)),he=s(l(re,ae),l(L,L));if(h(he))return null;var ce=u(fe,he),ie=u(i(K,l(ce,L)),ae),Ae=i(D,l(ce,s(I,D))),Oe=i(T,l(ce,s(P,T))),Ce=i(B,l(ce,s(R,B))),$e=i(M,l(ie,s($,M))),V=i(F,l(ie,s(k,F))),X=i(H,l(ie,s(Q,H)));return m(Ae,$e)&&m(Oe,V)&&m(Ce,X)?[Ae,Oe,Ce]:null}function S(D,T,B,I,P,R,M,F,H,$){var k=l(D,M),Q=l(I,M),K=l(T,F),L=l(P,F),j=l(B,H),ae=l(R,H),re=s(s(s($,k),K),j),fe=s(s(s(i(i(Q,L),ae),k),K),j),he=u(re,fe),ce=i(D,l(he,s(I,D))),ie=i(T,l(he,s(P,T))),Ae=i(B,l(he,s(R,B)));return[ce,ie,Ae]}}),Tp="sum",J4=["typed","config","add","numeric"],Bp=q(Tp,J4,r=>{var{typed:e,config:t,add:a,numeric:n}=r;return e(Tp,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":o,"...":function(l){if(aa(l))throw new TypeError("Scalar values expected in function sum");return i(l)}});function i(f){var l;return Xt(f,function(u){try{l=l===void 0?u:a(l,u)}catch(s){throw Qr(s,"sum",u)}}),l===void 0&&(l=n(0,t.number)),typeof l=="string"&&(l=n(l,t.number)),l}function o(f,l){try{var u=Si(f,l,a);return u}catch(s){throw Qr(s,"sum")}}}),io="cumsum",X4=["typed","add","unaryPlus"],$p=q(io,X4,r=>{var{typed:e,add:t,unaryPlus:a}=r;return e(io,{Array:n,Matrix:function(u){return u.create(n(u.valueOf()))},"Array, number | BigNumber":o,"Matrix, number | BigNumber":function(u,s){return u.create(o(u.valueOf(),s))},"...":function(u){if(aa(u))throw new TypeError("All values expected to be scalar in function cumsum");return n(u)}});function n(l){try{return i(l)}catch(u){throw Qr(u,io)}}function i(l){if(l.length===0)return[];for(var u=[a(l[0])],s=1;s<l.length;++s)u.push(t(u[s-1],l[s]));return u}function o(l,u){var s=er(l);if(u<0||u>=s.length)throw new dt(u,s.length);try{return f(l,u)}catch(c){throw Qr(c,io)}}function f(l,u){var s,c,m;if(u<=0){var v=l[0][0];if(Array.isArray(v)){for(m=Wl(l),c=[],s=0;s<m.length;s++)c[s]=f(m[s],u-1);return c}else return i(l)}else{for(c=[],s=0;s<l.length;s++)c[s]=f(l[s],u-1);return c}}}),Op="mean",W4=["typed","add","divide"],Ip=q(Op,W4,r=>{var{typed:e,add:t,divide:a}=r;return e(Op,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":n,"...":function(f){if(aa(f))throw new TypeError("Scalar values expected in function mean");return i(f)}});function n(o,f){try{var l=Si(o,f,t),u=Array.isArray(o)?er(o):o.size();return a(l,u[f])}catch(s){throw Qr(s,"mean")}}function i(o){var f,l=0;if(Xt(o,function(u){try{f=f===void 0?u:t(f,u),l++}catch(s){throw Qr(s,"mean",u)}}),l===0)throw new Error("Cannot calculate the mean of an empty array");return a(f,l)}}),Rp="median",Y4=["typed","add","divide","compare","partitionSelect"],Q4=q(Rp,Y4,r=>{var{typed:e,add:t,divide:a,compare:n,partitionSelect:i}=r;function o(u){try{u=or(u.valueOf());var s=u.length;if(s===0)throw new Error("Cannot calculate median of an empty array");if(s%2===0){for(var c=s/2-1,m=i(u,c+1),v=u[c],h=0;h<c;++h)n(u[h],v)>0&&(v=u[h]);return l(v,m)}else{var p=i(u,(s-1)/2);return f(p)}}catch(g){throw Qr(g,"median")}}var f=e({"number | BigNumber | Complex | Unit":function(s){return s}}),l=e({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(s,c){return a(t(s,c),2)}});return e(Rp,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(s,c){throw new Error("median(A, dim) is not yet supported")},"...":function(s){if(aa(s))throw new TypeError("Scalar values expected in function median");return o(s)}})}),_p="mad",K4=["typed","abs","map","median","subtract"],j4=q(_p,K4,r=>{var{typed:e,abs:t,map:a,median:n,subtract:i}=r;return e(_p,{"Array | Matrix":o,"...":function(l){return o(l)}});function o(f){if(f=or(f.valueOf()),f.length===0)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var l=n(f);return n(a(f,function(u){return t(i(u,l))}))}catch(u){throw u instanceof TypeError&&u.message.indexOf("median")!==-1?new TypeError(u.message.replace("median","mad")):Qr(u,"mad")}}}),As="unbiased",qp="variance",eT=["typed","add","subtract","multiply","divide","apply","isNaN"],zp=q(qp,eT,r=>{var{typed:e,add:t,subtract:a,multiply:n,divide:i,apply:o,isNaN:f}=r;return e(qp,{"Array | Matrix":function(c){return l(c,As)},"Array | Matrix, string":l,"Array | Matrix, number | BigNumber":function(c,m){return u(c,m,As)},"Array | Matrix, number | BigNumber, string":u,"...":function(c){return l(c,As)}});function l(s,c){var m,v=0;if(s.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Xt(s,function(g){try{m=m===void 0?g:t(m,g),v++}catch(y){throw Qr(y,"variance",g)}}),v===0)throw new Error("Cannot calculate variance of an empty array");var h=i(m,v);if(m=void 0,Xt(s,function(g){var y=a(g,h);m=m===void 0?n(y,y):t(m,n(y,y))}),f(m))return m;switch(c){case"uncorrected":return i(m,v);case"biased":return i(m,v+1);case"unbiased":{var p=rr(m)?m.mul(0):0;return v===1?p:i(m,v-1)}default:throw new Error('Unknown normalization "'+c+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function u(s,c,m){try{if(s.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return o(s,c,v=>l(v,m))}catch(v){throw Qr(v,"variance")}}}),rT="quantileSeq",tT=["typed","add","multiply","partitionSelect","compare"],nT=q(rT,tT,r=>{var{typed:e,add:t,multiply:a,partitionSelect:n,compare:i}=r;function o(u,s,c){var m,v,h;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(Ft(u)){if(c=c||!1,typeof c=="boolean"){if(v=u.valueOf(),tr(s)){if(s<0)throw new Error("N/prob must be non-negative");if(s<=1)return f(v,s,c);if(s>1){if(!qe(s))throw new Error("N must be a positive integer");var p=s+1;m=new Array(s);for(var g=0;g<s;)m[g]=f(v,++g/p,c);return m}}if(rr(s)){var y=s.constructor;if(s.isNegative())throw new Error("N/prob must be non-negative");if(h=new y(1),s.lte(h))return new y(f(v,s,c));if(s.gt(h)){if(!s.isInteger())throw new Error("N must be a positive integer");var N=s.toNumber();if(N>4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var d=new y(N+1);m=new Array(N);for(var w=0;w<N;)m[w]=new y(f(v,new y(++w).div(d),c));return m}}if(Ft(s)){var x=s.valueOf();m=new Array(x.length);for(var b=0;b<m.length;++b){var E=x[b];if(tr(E)){if(E<0||E>1)throw new Error("Probability must be between 0 and 1, inclusive")}else if(rr(E)){if(h=new E.constructor(1),E.isNegative()||E.gt(h))throw new Error("Probability must be between 0 and 1, inclusive")}else throw new TypeError("Unexpected type of argument in function quantileSeq");m[b]=f(v,E,c)}return m}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}function f(u,s,c){var m=or(u),v=m.length;if(v===0)throw new Error("Cannot calculate quantile of an empty sequence");if(tr(s)){var h=s*(v-1),p=h%1;if(p===0){var g=c?m[h]:n(m,h);return l(g),g}var y=Math.floor(h),N,d;if(c)N=m[y],d=m[y+1];else{d=n(m,y+1),N=m[y];for(var w=0;w<y;++w)i(m[w],N)>0&&(N=m[w])}return l(N),l(d),t(a(N,1-p),a(d,p))}var x=s.times(v-1);if(x.isInteger()){x=x.toNumber();var b=c?m[x]:n(m,x);return l(b),b}var E=x.floor(),A=x.minus(E),S=E.toNumber(),D,T;if(c)D=m[S],T=m[S+1];else{T=n(m,S+1),D=m[S];for(var B=0;B<S;++B)i(m[B],D)>0&&(D=m[B])}l(D),l(T);var I=new A.constructor(1);return t(a(D,I.minus(A)),a(T,A))}var l=e({"number | BigNumber | Unit":function(s){return s}});return o}),Pp="std",aT=["typed","map","sqrt","variance"],Up=q(Pp,aT,r=>{var{typed:e,map:t,sqrt:a,variance:n}=r;return e(Pp,{"Array | Matrix":i,"Array | Matrix, string":i,"Array | Matrix, number | BigNumber":i,"Array | Matrix, number | BigNumber, string":i,"...":function(f){return i(f)}});function i(o,f){if(o.length===0)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{var l=n.apply(null,arguments);return Ft(l)?t(l,a):a(l)}catch(u){throw u instanceof TypeError&&u.message.indexOf(" variance")!==-1?new TypeError(u.message.replace(" variance"," std")):u}}}),Lp="combinations",iT=["typed"],oT=q(Lp,iT,r=>{var{typed:e}=r;return e(Lp,{"number, number":Dc,"BigNumber, BigNumber":function(a,n){var i=a.constructor,o,f,l=a.minus(n),u=new i(1);if(!kp(a)||!kp(n))throw new TypeError("Positive integer value expected in function combinations");if(n.gt(a))throw new TypeError("k must be less than n in function combinations");if(o=u,n.lt(l))for(f=u;f.lte(l);f=f.plus(u))o=o.times(n.plus(f)).dividedBy(f);else for(f=u;f.lte(n);f=f.plus(u))o=o.times(l.plus(f)).dividedBy(f);return o}})});function kp(r){return r.isInteger()&&r.gte(0)}var Vp="combinationsWithRep",sT=["typed"],uT=q(Vp,sT,r=>{var{typed:e}=r;return e(Vp,{"number, number":function(a,n){if(!qe(a)||a<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!qe(n)||n<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(a<1)throw new TypeError("k must be less than or equal to n + k - 1");if(n<a-1){var i=Wt(a,a+n-1);return i/Wt(1,n)}var o=Wt(n+1,a+n-1);return o/Wt(1,a-1)},"BigNumber, BigNumber":function(a,n){var i=a.constructor,o,f,l=new i(1),u=a.minus(l);if(!Gp(a)||!Gp(n))throw new TypeError("Positive integer value expected in function combinationsWithRep");if(a.lt(l))throw new TypeError("k must be less than or equal to n + k - 1 in function combinationsWithRep");if(o=l,n.lt(u))for(f=l;f.lte(u);f=f.plus(l))o=o.times(n.plus(f)).dividedBy(f);else for(f=l;f.lte(n);f=f.plus(l))o=o.times(u.plus(f)).dividedBy(f);return o}})});function Gp(r){return r.isInteger()&&r.gte(0)}var Hp="gamma",lT=["typed","config","multiplyScalar","pow","BigNumber","Complex"],cT=q(Hp,lT,r=>{var{typed:e,config:t,multiplyScalar:a,pow:n,BigNumber:i,Complex:o}=r;function f(u){if(u.im===0)return Mi(u.re);if(u.re<.5){var s=new o(1-u.re,-u.im),c=new o(Math.PI*u.re,Math.PI*u.im);return new o(Math.PI).div(c.sin()).div(f(s))}u=new o(u.re-1,u.im);for(var m=new o(oa[0],0),v=1;v<oa.length;++v){var h=new o(oa[v],0);m=m.add(h.div(u.add(v)))}var p=new o(u.re+Mc+.5,u.im),g=Math.sqrt(2*Math.PI),y=p.pow(u.add(.5)),N=p.neg().exp();return m.mul(g).mul(y).mul(N)}return e(Hp,{number:Mi,Complex:f,BigNumber:function(s){if(s.isInteger())return s.isNegative()||s.isZero()?new i(1/0):l(s.minus(1));if(!s.isFinite())return new i(s.isNegative()?NaN:1/0);throw new Error("Integer BigNumber expected")}});function l(u){if(u<8)return new i([1,1,2,6,24,120,720,5040][u]);var s=t.precision+(Math.log(u.toNumber())|0),c=i.clone({precision:s});if(u%2===1)return u.times(l(new i(u-1)));for(var m=u,v=new c(u),h=u.toNumber();m>2;)m-=2,h+=m,v=v.times(h);return new i(v.toPrecision(i.precision))}}),Zp="lgamma",fT=["Complex","typed"],mT=q(Zp,fT,r=>{var{Complex:e,typed:t}=r,a=7,n=7,i=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return t(Zp,{number:Fi,Complex:o,BigNumber:function(){throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function o(u){var s=6.283185307179586,c=1.1447298858494002,m=.1;if(u.isNaN())return new e(NaN,NaN);if(u.im===0)return new e(Fi(u.re),0);if(u.re>=a||Math.abs(u.im)>=n)return f(u);if(u.re<=m){var v=pg(s,u.im)*Math.floor(.5*u.re+.25),h=u.mul(Math.PI).sin().log(),p=o(new e(1-u.re,-u.im));return new e(c,v).sub(h).sub(p)}else return u.im>=0?l(u):l(u.conjugate()).conjugate()}function f(u){for(var s=u.sub(.5).mul(u.log()).sub(u).add(Fc),c=new e(1,0).div(u),m=c.div(u),v=i[0],h=i[1],p=2*m.re,g=m.re*m.re+m.im*m.im,y=2;y<8;y++){var N=h;h=-g*v+i[y],v=p*v+N}var d=c.mul(m.mul(v).add(h));return s.add(d)}function l(u){var s=0,c=0,m=u;for(u=u.add(1);u.re<=a;){m=m.mul(u);var v=m.im<0?1:0;v!==0&&c===0&&s++,c=v,u=u.add(1)}return f(u).sub(m.log()).sub(new e(0,s*2*Math.PI*1))}}),Jp="factorial",vT=["typed","gamma"],pT=q(Jp,vT,r=>{var{typed:e,gamma:t}=r;return e(Jp,{number:function(n){if(n<0)throw new Error("Value must be non-negative");return t(n+1)},BigNumber:function(n){if(n.isNegative())throw new Error("Value must be non-negative");return t(n.plus(1))},"Array | Matrix":e.referToSelf(a=>n=>je(n,a))})}),Xp="kldivergence",hT=["typed","matrix","divide","sum","multiply","map","dotDivide","log","isNumeric"],dT=q(Xp,hT,r=>{var{typed:e,matrix:t,divide:a,sum:n,multiply:i,map:o,dotDivide:f,log:l,isNumeric:u}=r;return e(Xp,{"Array, Array":function(m,v){return s(t(m),t(v))},"Matrix, Array":function(m,v){return s(m,t(v))},"Array, Matrix":function(m,v){return s(t(m),v)},"Matrix, Matrix":function(m,v){return s(m,v)}});function s(c,m){var v=m.size().length,h=c.size().length;if(v>1)throw new Error("first object must be one dimensional");if(h>1)throw new Error("second object must be one dimensional");if(v!==h)throw new Error("Length of two vectors must be equal");var p=n(c);if(p===0)throw new Error("Sum of elements in first object must be non zero");var g=n(m);if(g===0)throw new Error("Sum of elements in second object must be non zero");var y=a(c,n(c)),N=a(m,n(m)),d=n(i(y,o(f(y,N),w=>l(w))));return u(d)?d:Number.NaN}}),Wp="multinomial",gT=["typed","add","divide","multiply","factorial","isInteger","isPositive"],yT=q(Wp,gT,r=>{var{typed:e,add:t,divide:a,multiply:n,factorial:i,isInteger:o,isPositive:f}=r;return e(Wp,{"Array | Matrix":function(u){var s=0,c=1;return Xt(u,function(m){if(!o(m)||!f(m))throw new TypeError("Positive integer value expected in function multinomial");s=t(s,m),c=n(c,i(m))}),a(i(s),c)}})}),Yp="permutations",bT=["typed","factorial"],xT=q(Yp,bT,r=>{var{typed:e,factorial:t}=r;return e(Yp,{"number | BigNumber":t,"number, number":function(n,i){if(!qe(n)||n<0)throw new TypeError("Positive integer value expected in function permutations");if(!qe(i)||i<0)throw new TypeError("Positive integer value expected in function permutations");if(i>n)throw new TypeError("second argument k must be less than or equal to first argument n");return Wt(n-i+1,n)},"BigNumber, BigNumber":function(n,i){var o,f;if(!Qp(n)||!Qp(i))throw new TypeError("Positive integer value expected in function permutations");if(i.gt(n))throw new TypeError("second argument k must be less than or equal to first argument n");var l=n.mul(0).add(1);for(o=l,f=n.minus(i).plus(1);f.lte(n);f=f.plus(1))o=o.times(f);return o}})});function Qp(r){return r.isInteger()&&r.gte(0)}var Kp={exports:{}};(function(r){(function(e,t,a){function n(l){var u=this,s=f();u.next=function(){var c=2091639*u.s0+u.c*23283064365386963e-26;return u.s0=u.s1,u.s1=u.s2,u.s2=c-(u.c=c|0)},u.c=1,u.s0=s(" "),u.s1=s(" "),u.s2=s(" "),u.s0-=s(l),u.s0<0&&(u.s0+=1),u.s1-=s(l),u.s1<0&&(u.s1+=1),u.s2-=s(l),u.s2<0&&(u.s2+=1),s=null}function i(l,u){return u.c=l.c,u.s0=l.s0,u.s1=l.s1,u.s2=l.s2,u}function o(l,u){var s=new n(l),c=u&&u.state,m=s.next;return m.int32=function(){return s.next()*4294967296|0},m.double=function(){return m()+(m()*2097152|0)*11102230246251565e-32},m.quick=m,c&&(typeof c=="object"&&i(c,s),m.state=function(){return i(s,{})}),m}function f(){var l=4022871197,u=function(s){s=String(s);for(var c=0;c<s.length;c++){l+=s.charCodeAt(c);var m=.02519603282416938*l;l=m>>>0,m-=l,m*=l,l=m>>>0,m-=l,l+=m*4294967296}return(l>>>0)*23283064365386963e-26};return u}t&&t.exports?t.exports=o:a&&a.amd?a(function(){return o}):this.alea=o})(Mn,r,!1)})(Kp);var jp={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this,u="";l.x=0,l.y=0,l.z=0,l.w=0,l.next=function(){var c=l.x^l.x<<11;return l.x=l.y,l.y=l.z,l.z=l.w,l.w^=l.w>>>19^c^c>>>8},f===(f|0)?l.x=f:u+=f;for(var s=0;s<u.length+64;s++)l.x^=u.charCodeAt(s)|0,l.next()}function i(f,l){return l.x=f.x,l.y=f.y,l.z=f.z,l.w=f.w,l}function o(f,l){var u=new n(f),s=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,h=(m+v)/(1<<21);while(h===0);return h},c.int32=u.next,c.quick=c,s&&(typeof s=="object"&&i(s,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=o:a&&a.amd?a(function(){return o}):this.xor128=o})(Mn,r,!1)})(jp);var eh={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this,u="";l.next=function(){var c=l.x^l.x>>>2;return l.x=l.y,l.y=l.z,l.z=l.w,l.w=l.v,(l.d=l.d+362437|0)+(l.v=l.v^l.v<<4^(c^c<<1))|0},l.x=0,l.y=0,l.z=0,l.w=0,l.v=0,f===(f|0)?l.x=f:u+=f;for(var s=0;s<u.length+64;s++)l.x^=u.charCodeAt(s)|0,s==u.length&&(l.d=l.x<<10^l.x>>>4),l.next()}function i(f,l){return l.x=f.x,l.y=f.y,l.z=f.z,l.w=f.w,l.v=f.v,l.d=f.d,l}function o(f,l){var u=new n(f),s=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,h=(m+v)/(1<<21);while(h===0);return h},c.int32=u.next,c.quick=c,s&&(typeof s=="object"&&i(s,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=o:a&&a.amd?a(function(){return o}):this.xorwow=o})(Mn,r,!1)})(eh);var rh={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this;l.next=function(){var s=l.x,c=l.i,m,v;return m=s[c],m^=m>>>7,v=m^m<<24,m=s[c+1&7],v^=m^m>>>10,m=s[c+3&7],v^=m^m>>>3,m=s[c+4&7],v^=m^m<<7,m=s[c+7&7],m=m^m<<13,v^=m^m<<9,s[c]=v,l.i=c+1&7,v};function u(s,c){var m,v=[];if(c===(c|0))v[0]=c;else for(c=""+c,m=0;m<c.length;++m)v[m&7]=v[m&7]<<15^c.charCodeAt(m)+v[m+1&7]<<13;for(;v.length<8;)v.push(0);for(m=0;m<8&&v[m]===0;++m);for(m==8?v[7]=-1:v[m],s.x=v,s.i=0,m=256;m>0;--m)s.next()}u(l,f)}function i(f,l){return l.x=f.x.slice(),l.i=f.i,l}function o(f,l){f==null&&(f=+new Date);var u=new n(f),s=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,h=(m+v)/(1<<21);while(h===0);return h},c.int32=u.next,c.quick=c,s&&(s.x&&i(s,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=o:a&&a.amd?a(function(){return o}):this.xorshift7=o})(Mn,r,!1)})(rh);var th={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this;l.next=function(){var s=l.w,c=l.X,m=l.i,v,h;return l.w=s=s+1640531527|0,h=c[m+34&127],v=c[m=m+1&127],h^=h<<13,v^=v<<17,h^=h>>>15,v^=v>>>12,h=c[m]=h^v,l.i=m,h+(s^s>>>16)|0};function u(s,c){var m,v,h,p,g,y=[],N=128;for(c===(c|0)?(v=c,c=null):(c=c+"\0",v=0,N=Math.max(N,c.length)),h=0,p=-32;p<N;++p)c&&(v^=c.charCodeAt((p+32)%c.length)),p===0&&(g=v),v^=v<<10,v^=v>>>15,v^=v<<4,v^=v>>>13,p>=0&&(g=g+1640531527|0,m=y[p&127]^=v+g,h=m==0?h+1:0);for(h>=128&&(y[(c&&c.length||0)&127]=-1),h=127,p=4*128;p>0;--p)v=y[h+34&127],m=y[h=h+1&127],v^=v<<13,m^=m<<17,v^=v>>>15,m^=m>>>12,y[h]=v^m;s.w=g,s.X=y,s.i=h}u(l,f)}function i(f,l){return l.i=f.i,l.w=f.w,l.X=f.X.slice(),l}function o(f,l){f==null&&(f=+new Date);var u=new n(f),s=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,h=(m+v)/(1<<21);while(h===0);return h},c.int32=u.next,c.quick=c,s&&(s.X&&i(s,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=o:a&&a.amd?a(function(){return o}):this.xor4096=o})(Mn,r,!1)})(th);var nh={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this,u="";l.next=function(){var c=l.b,m=l.c,v=l.d,h=l.a;return c=c<<25^c>>>7^m,m=m-v|0,v=v<<24^v>>>8^h,h=h-c|0,l.b=c=c<<20^c>>>12^m,l.c=m=m-v|0,l.d=v<<16^m>>>16^h,l.a=h-c|0},l.a=0,l.b=0,l.c=-1640531527,l.d=1367130551,f===Math.floor(f)?(l.a=f/4294967296|0,l.b=f|0):u+=f;for(var s=0;s<u.length+20;s++)l.b^=u.charCodeAt(s)|0,l.next()}function i(f,l){return l.a=f.a,l.b=f.b,l.c=f.c,l.d=f.d,l}function o(f,l){var u=new n(f),s=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,h=(m+v)/(1<<21);while(h===0);return h},c.int32=u.next,c.quick=c,s&&(typeof s=="object"&&i(s,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=o:a&&a.amd?a(function(){return o}):this.tychei=o})(Mn,r,!1)})(nh);var ah={exports:{}};const wT=$1(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(r){(function(e,t,a){var n=256,i=6,o=52,f="random",l=a.pow(n,i),u=a.pow(2,o),s=u*2,c=n-1,m;function v(w,x,b){var E=[];x=x==!0?{entropy:!0}:x||{};var A=y(g(x.entropy?[w,d(t)]:w==null?N():w,3),E),S=new h(E),D=function(){for(var T=S.g(i),B=l,I=0;T<u;)T=(T+I)*n,B*=n,I=S.g(1);for(;T>=s;)T/=2,B/=2,I>>>=1;return(T+I)/B};return D.int32=function(){return S.g(4)|0},D.quick=function(){return S.g(4)/4294967296},D.double=D,y(d(S.S),t),(x.pass||b||function(T,B,I,P){return P&&(P.S&&p(P,S),T.state=function(){return p(S,{})}),I?(a[f]=T,B):T})(D,A,"global"in x?x.global:this==a,x.state)}function h(w){var x,b=w.length,E=this,A=0,S=E.i=E.j=0,D=E.S=[];for(b||(w=[b++]);A<n;)D[A]=A++;for(A=0;A<n;A++)D[A]=D[S=c&S+w[A%b]+(x=D[A])],D[S]=x;(E.g=function(T){for(var B,I=0,P=E.i,R=E.j,M=E.S;T--;)B=M[P=c&P+1],I=I*n+M[c&(M[P]=M[R=c&R+B])+(M[R]=B)];return E.i=P,E.j=R,I})(n)}function p(w,x){return x.i=w.i,x.j=w.j,x.S=w.S.slice(),x}function g(w,x){var b=[],E=typeof w,A;if(x&&E=="object")for(A in w)try{b.push(g(w[A],x-1))}catch{}return b.length?b:E=="string"?w:w+"\0"}function y(w,x){for(var b=w+"",E,A=0;A<b.length;)x[c&A]=c&(E^=x[c&A]*19)+b.charCodeAt(A++);return d(x)}function N(){try{var w;return m&&(w=m.randomBytes)?w=w(n):(w=new Uint8Array(n),(e.crypto||e.msCrypto).getRandomValues(w)),d(w)}catch{var x=e.navigator,b=x&&x.plugins;return[+new Date,e,b,e.screen,d(t)]}}function d(w){return String.fromCharCode.apply(0,w)}if(y(a.random(),t),r.exports){r.exports=v;try{m=wT}catch{}}else a["seed"+f]=v})(typeof self<"u"?self:Mn,[],Math)})(ah);var NT=Kp.exports,DT=jp.exports,AT=eh.exports,ET=rh.exports,ST=th.exports,CT=nh.exports,$n=ah.exports;$n.alea=NT,$n.xor128=DT,$n.xorwow=AT,$n.xorshift7=ET,$n.xor4096=ST,$n.tychei=CT;var ih=$n,MT=ih(Date.now());function ma(r){var e;function t(n){e=n===null?MT:ih(String(n))}t(r);function a(){return e()}return a}var oh="pickRandom",FT=["typed","config","?on"],TT=q(oh,FT,r=>{var{typed:e,config:t,on:a}=r,n=ma(t.randomSeed);return a&&a("config",function(o,f){o.randomSeed!==f.randomSeed&&(n=ma(o.randomSeed))}),e(oh,{"Array | Matrix":function(f){return i(f,{})},"Array | Matrix, Object":function(f,l){return i(f,l)},"Array | Matrix, number":function(f,l){return i(f,{number:l})},"Array | Matrix, Array | Matrix":function(f,l){return i(f,{weights:l})},"Array | Matrix, Array | Matrix, number":function(f,l,u){return i(f,{number:u,weights:l})},"Array | Matrix, number, Array | Matrix":function(f,l,u){return i(f,{number:l,weights:u})}});function i(o,f){var{number:l,weights:u,elementWise:s=!0}=f,c=typeof l>"u";c&&(l=1);var m=Ve(o)?o.create:Ve(u)?u.create:null;o=o.valueOf(),u&&(u=u.valueOf()),s===!0&&(o=or(o),u=or(u));var v=0;if(typeof u<"u"){if(u.length!==o.length)throw new Error("Weights must have the same length as possibles");for(var h=0,p=u.length;h<p;h++){if(!tr(u[h])||u[h]<0)throw new Error("Weights must be an array of positive numbers");v+=u[h]}}for(var g=o.length,y=[],N;y.length<l;){if(typeof u>"u")N=o[Math.floor(n()*g)];else for(var d=n()*v,w=0,x=o.length;w<x;w++)if(d-=u[w],d<0){N=o[w];break}y.push(N)}return c?y[0]:m?m(y):y}});function Es(r,e){var t=[];if(r=r.slice(0),r.length>1)for(var a=0,n=r.shift();a<n;a++)t.push(Es(r,e));else for(var i=0,o=r.shift();i<o;i++)t.push(e());return t}var sh="random",BT=["typed","config","?on"],$T=q(sh,BT,r=>{var{typed:e,config:t,on:a}=r,n=ma(t.randomSeed);return a&&a("config",function(f,l){f.randomSeed!==l.randomSeed&&(n=ma(f.randomSeed))}),e(sh,{"":()=>o(0,1),number:f=>o(0,f),"number, number":(f,l)=>o(f,l),"Array | Matrix":f=>i(f,0,1),"Array | Matrix, number":(f,l)=>i(f,0,l),"Array | Matrix, number, number":(f,l,u)=>i(f,l,u)});function i(f,l,u){var s=Es(f.valueOf(),()=>o(l,u));return Ve(f)?f.create(s):s}function o(f,l){return f+n()*(l-f)}}),uh="randomInt",OT=["typed","config","?on"],IT=q(uh,OT,r=>{var{typed:e,config:t,on:a}=r,n=ma(t.randomSeed);return a&&a("config",function(f,l){f.randomSeed!==l.randomSeed&&(n=ma(f.randomSeed))}),e(uh,{"":()=>o(0,1),number:f=>o(0,f),"number, number":(f,l)=>o(f,l),"Array | Matrix":f=>i(f,0,1),"Array | Matrix, number":(f,l)=>i(f,0,l),"Array | Matrix, number, number":(f,l,u)=>i(f,l,u)});function i(f,l,u){var s=Es(f.valueOf(),()=>o(l,u));return Ve(f)?f.create(s):s}function o(f,l){return Math.floor(f+n()*(l-f))}}),lh="stirlingS2",RT=["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],_T=q(lh,RT,r=>{var{typed:e,addScalar:t,subtract:a,multiplyScalar:n,divideScalar:i,pow:o,factorial:f,combinations:l,isNegative:u,isInteger:s,number:c,bignumber:m,larger:v}=r,h=[],p=[];return e(lh,{"number | BigNumber, number | BigNumber":function(y,N){if(!s(y)||u(y)||!s(N)||u(N))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(v(N,y))throw new TypeError("k must be less than or equal to n in function stirlingS2");var d=!(tr(y)&&tr(N)),w=d?p:h,x=d?m:c,b=c(y),E=c(N);if(w[b]&&w[b].length>E)return w[b][E];for(var A=0;A<=b;++A)if(w[A]||(w[A]=[x(A===0?1:0)]),A!==0)for(var S=w[A],D=w[A-1],T=S.length;T<=A&&T<=E;++T)T===A?S[T]=1:S[T]=t(n(x(T),D[T]),D[T-1]);return w[b][E]}})}),ch="bellNumbers",qT=["typed","addScalar","isNegative","isInteger","stirlingS2"],zT=q(ch,qT,r=>{var{typed:e,addScalar:t,isNegative:a,isInteger:n,stirlingS2:i}=r;return e(ch,{"number | BigNumber":function(f){if(!n(f)||a(f))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var l=0,u=0;u<=f;u++)l=t(l,i(f,u));return l}})}),fh="catalan",PT=["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],UT=q(fh,PT,r=>{var{typed:e,addScalar:t,divideScalar:a,multiplyScalar:n,combinations:i,isNegative:o,isInteger:f}=r;return e(fh,{"number | BigNumber":function(u){if(!f(u)||o(u))throw new TypeError("Non-negative integer value expected in function catalan");return a(i(n(u,2),u),t(u,1))}})}),mh="composition",LT=["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],kT=q(mh,LT,r=>{var{typed:e,addScalar:t,combinations:a,isPositive:n,isNegative:i,isInteger:o,larger:f}=r;return e(mh,{"number | BigNumber, number | BigNumber":function(u,s){if(!o(u)||!n(u)||!o(s)||!n(s))throw new TypeError("Positive integer value expected in function composition");if(f(s,u))throw new TypeError("k must be less than or equal to n in function composition");return a(t(u,-1),t(s,-1))}})}),vh="leafCount",VT=["parse","typed"],GT=q(vh,VT,r=>{var{parse:e,typed:t}=r;function a(n){var i=0;return n.forEach(o=>{i+=a(o)}),i||1}return t(vh,{Node:function(i){return a(i)}})});function ph(r){return ir(r)||Br(r)&&r.isUnary()&&ir(r.args[0])}function oo(r){return!!(ir(r)||(nn(r)||Br(r))&&r.args.every(oo)||Gt(r)&&oo(r.content))}function hh(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);e&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,a)}return t}function Ss(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?hh(Object(t),!0).forEach(function(a){zr(r,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):hh(Object(t)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(t,a))})}return r}var HT="simplifyUtil",ZT=["FunctionNode","OperatorNode","SymbolNode"],Cs=q(HT,ZT,r=>{var{FunctionNode:e,OperatorNode:t,SymbolNode:a}=r,n=!0,i=!1,o="defaultF",f={add:{trivial:n,total:n,commutative:n,associative:n},unaryPlus:{trivial:n,total:n,commutative:n,associative:n},subtract:{trivial:i,total:n,commutative:i,associative:i},multiply:{trivial:n,total:n,commutative:n,associative:n},divide:{trivial:i,total:n,commutative:i,associative:i},paren:{trivial:n,total:n,commutative:n,associative:i},defaultF:{trivial:i,total:n,commutative:i,associative:i}},l={divide:{total:i},log:{total:i}},u={subtract:{total:i},abs:{trivial:n},log:{total:n}};function s(d,w){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:f,b=o;if(typeof d=="string"?b=d:Br(d)?b=d.fn.toString():nn(d)?b=d.name:Gt(d)&&(b="paren"),Re(x,b)){var E=x[b];if(Re(E,w))return E[w];if(Re(f,b))return f[b][w]}if(Re(x,o)){var A=x[o];return Re(A,w)?A[w]:f[o][w]}if(Re(f,b)){var S=f[b];if(Re(S,w))return S[w]}return f[o][w]}function c(d){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f;return s(d,"commutative",w)}function m(d){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f;return s(d,"associative",w)}function v(d,w){var x=Ss({},d);for(var b in w)Re(d,b)?x[b]=Ss(Ss({},w[b]),d[b]):x[b]=w[b];return x}function h(d,w){if(!d.args||d.args.length===0)return d;d.args=p(d,w);for(var x=0;x<d.args.length;x++)h(d.args[x],w)}function p(d,w){var x,b=[],E=function A(S){for(var D=0;D<S.args.length;D++){var T=S.args[D];Br(T)&&x===T.op?A(T):b.push(T)}};return m(d,w)?(x=d.op,E(d),b):d.args}function g(d,w){if(!(!d.args||d.args.length===0)){for(var x=N(d),b=d.args.length,E=0;E<b;E++)g(d.args[E],w);if(b>2&&m(d,w)){for(var A=d.args.pop();d.args.length>0;)A=x([d.args.pop(),A]);d.args=A.args}}}function y(d,w){if(!(!d.args||d.args.length===0)){for(var x=N(d),b=d.args.length,E=0;E<b;E++)y(d.args[E],w);if(b>2&&m(d,w)){for(var A=d.args.shift();d.args.length>0;)A=x([A,d.args.shift()]);d.args=A.args}}}function N(d){return Br(d)?function(w){try{return new t(d.op,d.fn,w,d.implicit)}catch(x){return console.error(x),[]}}:function(w){return new e(new a(d.name),w)}}return{createMakeNodeFunction:N,hasProperty:s,isCommutative:c,isAssociative:m,mergeContext:v,flatten:h,allChildren:p,unflattenr:g,unflattenl:y,defaultContext:f,realContext:l,positiveContext:u}}),JT="simplify",XT=["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","resolve","simplifyConstant","simplifyCore","?fraction","?bignumber","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],WT=q(JT,XT,r=>{var{config:e,typed:t,parse:a,add:n,subtract:i,multiply:o,divide:f,pow:l,isZero:u,equal:s,resolve:c,simplifyConstant:m,simplifyCore:v,fraction:h,bignumber:p,mathWithTransform:g,matrix:y,AccessorNode:N,ArrayNode:d,ConstantNode:w,FunctionNode:x,IndexNode:b,ObjectNode:E,OperatorNode:A,ParenthesisNode:S,SymbolNode:D}=r,{hasProperty:T,isCommutative:B,isAssociative:I,mergeContext:P,flatten:R,unflattenr:M,unflattenl:F,createMakeNodeFunction:H,defaultContext:$,realContext:k,positiveContext:Q}=Cs({FunctionNode:x,OperatorNode:A,SymbolNode:D});t.addConversion({from:"Object",to:"Map",convert:ra});var K=t("simplify",{Node:ce,"Node, Map":(G,Y)=>ce(G,!1,Y),"Node, Map, Object":(G,Y,te)=>ce(G,!1,Y,te),"Node, Array":ce,"Node, Array, Map":ce,"Node, Array, Map, Object":ce});t.removeConversion({from:"Object",to:"Map",convert:ra}),K.defaultContext=$,K.realContext=k,K.positiveContext=Q;function L(G){return G.transform(function(Y,te,ye){return Gt(Y)?L(Y.content):Y})}var j={true:!0,false:!0,e:!0,i:!0,Infinity:!0,LN2:!0,LN10:!0,LOG2E:!0,LOG10E:!0,NaN:!0,phi:!0,pi:!0,SQRT1_2:!0,SQRT2:!0,tau:!0};K.rules=[v,{l:"log(e)",r:"1"},{s:"n-n1 -> n+-n1",assuming:{subtract:{total:!0}}},{s:"n-n -> 0",assuming:{subtract:{total:!1}}},{s:"-(cl*v) -> v * (-cl)",assuming:{multiply:{commutative:!0},subtract:{total:!0}}},{s:"-(cl*v) -> (-cl) * v",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{s:"-(v*cl) -> v * (-cl)",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{l:"-(n1/n2)",r:"-n1/n2"},{l:"-v",r:"v * (-1)"},{l:"(n1 + n2)*(-1)",r:"n1*(-1) + n2*(-1)",repeat:!0},{l:"n/n1^n2",r:"n*n1^-n2"},{l:"n/n1",r:"n*n1^-1"},{s:"(n1*n2)^n3 -> n1^n3 * n2^n3",assuming:{multiply:{commutative:!0}}},{s:"(n1*n2)^(-1) -> n2^(-1) * n1^(-1)",assuming:{multiply:{commutative:!1}}},{s:"(n ^ n1) ^ n2 -> n ^ (n1 * n2)",assuming:{divide:{total:!0}}},{l:" vd * ( vd * n1 + n2)",r:"vd^2 * n1 + vd * n2"},{s:" vd * (vd^n4 * n1 + n2) -> vd^(1+n4) * n1 + vd * n2",assuming:{divide:{total:!0}}},{s:"vd^n3 * ( vd * n1 + n2) -> vd^(n3+1) * n1 + vd^n3 * n2",assuming:{divide:{total:!0}}},{s:"vd^n3 * (vd^n4 * n1 + n2) -> vd^(n3+n4) * n1 + vd^n3 * n2",assuming:{divide:{total:!0}}},{l:"n*n",r:"n^2"},{s:"n * n^n1 -> n^(n1+1)",assuming:{divide:{total:!0}}},{s:"n^n1 * n^n2 -> n^(n1+n2)",assuming:{divide:{total:!0}}},m,{s:"n+n -> 2*n",assuming:{add:{total:!0}}},{l:"n+-n",r:"0"},{l:"vd*n + vd",r:"vd*(n+1)"},{l:"n3*n1 + n3*n2",r:"n3*(n1+n2)"},{l:"n3^(-n4)*n1 + n3 * n2",r:"n3^(-n4)*(n1 + n3^(n4+1) *n2)"},{l:"n3^(-n4)*n1 + n3^n5 * n2",r:"n3^(-n4)*(n1 + n3^(n4+n5)*n2)"},{s:"n*vd + vd -> (n+1)*vd",assuming:{multiply:{commutative:!1}}},{s:"vd + n*vd -> (1+n)*vd",assuming:{multiply:{commutative:!1}}},{s:"n1*n3 + n2*n3 -> (n1+n2)*n3",assuming:{multiply:{commutative:!1}}},{s:"n^n1 * n -> n^(n1+1)",assuming:{divide:{total:!0},multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3 -> (n1 + n2*n3^(n4 + 1))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3^n5 -> (n1 + n2*n3^(n4 + n5))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{l:"n*cd + cd",r:"(n+1)*cd"},{s:"cd*n + cd -> cd*(n+1)",assuming:{multiply:{commutative:!1}}},{s:"cd + cd*n -> cd*(1+n)",assuming:{multiply:{commutative:!1}}},m,{s:"(-n)*n1 -> -(n*n1)",assuming:{subtract:{total:!0}}},{s:"n1*(-n) -> -(n1*n)",assuming:{subtract:{total:!0},multiply:{commutative:!1}}},{s:"ce+ve -> ve+ce",assuming:{add:{commutative:!0}},imposeContext:{add:{commutative:!1}}},{s:"vd*cd -> cd*vd",assuming:{multiply:{commutative:!0}},imposeContext:{multiply:{commutative:!1}}},{l:"n+-n1",r:"n-n1"},{s:"n*(n1^-1) -> n/n1",assuming:{multiply:{commutative:!0}}},{s:"n*n1^-n2 -> n/n1^n2",assuming:{multiply:{commutative:!0}}},{s:"n^-1 -> 1/n",assuming:{multiply:{commutative:!0}}},{l:"n^1",r:"n"},{s:"n*(n1/n2) -> (n*n1)/n2",assuming:{multiply:{associative:!0}}},{s:"n-(n1+n2) -> n-n1-n2",assuming:{addition:{associative:!0,commutative:!0}}},{l:"1*n",r:"n",imposeContext:{multiply:{commutative:!0}}},{s:"n1/(n2/n3) -> (n1*n3)/n2",assuming:{multiply:{associative:!0}}},{l:"n1/(-n2)",r:"-n1/n2"}];function ae(G,Y){var te={};if(G.s){var ye=G.s.split("->");if(ye.length===2)te.l=ye[0],te.r=ye[1];else throw SyntaxError("Could not parse rule: "+G.s)}else te.l=G.l,te.r=G.r;te.l=L(a(te.l)),te.r=L(a(te.r));for(var me of["imposeContext","repeat","assuming"])me in G&&(te[me]=G[me]);if(G.evaluate&&(te.evaluate=a(G.evaluate)),I(te.l,Y)){var z=!B(te.l,Y),U;z&&(U=he());var ee=H(te.l),ue=he();te.expanded={},te.expanded.l=ee([te.l,ue]),R(te.expanded.l,Y),M(te.expanded.l,Y),te.expanded.r=ee([te.r,ue]),z&&(te.expandedNC1={},te.expandedNC1.l=ee([U,te.l]),te.expandedNC1.r=ee([U,te.r]),te.expandedNC2={},te.expandedNC2.l=ee([U,te.expanded.l]),te.expandedNC2.r=ee([U,te.expanded.r]))}return te}function re(G,Y){for(var te=[],ye=0;ye<G.length;ye++){var me=G[ye],z=void 0,U=typeof me;switch(U){case"string":me={s:me};case"object":z=ae(me,Y);break;case"function":z=me;break;default:throw TypeError("Unsupported type of rule: "+U)}te.push(z)}return te}var fe=0;function he(){return new D("_p"+fe++)}function ce(G,Y){var te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ea(),ye=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},me=ye.consoleDebug;Y=re(Y||K.rules,ye.context);var z=c(G,te);z=L(z);for(var U={},ee=z.toString({parenthesis:"all"});!U[ee];){U[ee]=!0,fe=0;var ue=ee;me&&console.log("Working on: ",ee);for(var ve=0;ve<Y.length;ve++){var de="";if(typeof Y[ve]=="function"?(z=Y[ve](z,ye),me&&(de=Y[ve].name)):(R(z,ye.context),z=Ae(z,Y[ve],ye.context),me&&(de="".concat(Y[ve].l.toString()," -> ").concat(Y[ve].r.toString()))),me){var be=z.toString({parenthesis:"all"});be!==ue&&(console.log("Applying",de,"produced",be),ue=be)}F(z,ye.context)}ee=z.toString({parenthesis:"all"})}return z}function ie(G,Y,te){var ye=G;if(G)for(var me=0;me<G.length;++me){var z=Ae(G[me],Y,te);z!==G[me]&&(ye===G&&(ye=G.slice()),ye[me]=z)}return ye}function Ae(G,Y,te){if(Y.assuming){for(var ye in Y.assuming)for(var me in Y.assuming[ye])if(T(ye,me,te)!==Y.assuming[ye][me])return G}var z=P(Y.imposeContext,te),U=G;if(U instanceof A||U instanceof x){var ee=ie(U.args,Y,te);ee!==U.args&&(U=U.clone(),U.args=ee)}else if(U instanceof S){if(U.content){var ue=Ae(U.content,Y,te);ue!==U.content&&(U=new S(ue))}}else if(U instanceof d){var ve=ie(U.items,Y,te);ve!==U.items&&(U=new d(ve))}else if(U instanceof N){var de=U.object;U.object&&(de=Ae(U.object,Y,te));var be=U.index;U.index&&(be=Ae(U.index,Y,te)),(de!==U.object||be!==U.index)&&(U=new N(de,be))}else if(U instanceof b){var pe=ie(U.dimensions,Y,te);pe!==U.dimensions&&(U=new b(pe))}else if(U instanceof E){var we=!1,_e={};for(var Le in U.properties)_e[Le]=Ae(U.properties[Le],Y,te),_e[Le]!==U.properties[Le]&&(we=!0);we&&(U=new E(_e))}var Be=Y.r,ar=X(Y.l,U,z)[0];if(!ar&&Y.expanded&&(Be=Y.expanded.r,ar=X(Y.expanded.l,U,z)[0]),!ar&&Y.expandedNC1&&(Be=Y.expandedNC1.r,ar=X(Y.expandedNC1.l,U,z)[0],ar||(Be=Y.expandedNC2.r,ar=X(Y.expandedNC2.l,U,z)[0])),ar){var Je=U.implicit;U=Be.clone(),Je&&"implicit"in Be&&(U.implicit=!0),U=U.transform(function(mr){return mr.isSymbolNode&&Re(ar.placeholders,mr.name)?ar.placeholders[mr.name].clone():mr})}return Y.repeat&&U!==G&&(U=Ae(U,Y,te)),U}function Oe(G,Y){var te=[],ye,me,z=H(G);if(B(G,Y))for(var U=0;U<G.args.length;U++)me=G.args.slice(0),me.splice(U,1),ye=me.length===1?me[0]:z(me),te.push(z([G.args[U],ye]));else for(var ee=1;ee<G.args.length;ee++){var ue=G.args[0];ee>1&&(ue=z(G.args.slice(0,ee))),me=G.args.slice(ee),ye=me.length===1?me[0]:z(me),te.push(z([ue,ye]))}return te}function Ce(G,Y){var te={placeholders:{}};if(!G.placeholders&&!Y.placeholders)return te;if(G.placeholders){if(!Y.placeholders)return G}else return Y;for(var ye in G.placeholders)if(Re(G.placeholders,ye)&&(te.placeholders[ye]=G.placeholders[ye],Re(Y.placeholders,ye)&&!oe(G.placeholders[ye],Y.placeholders[ye])))return null;for(var me in Y.placeholders)Re(Y.placeholders,me)&&(te.placeholders[me]=Y.placeholders[me]);return te}function $e(G,Y){var te=[];if(G.length===0||Y.length===0)return te;for(var ye,me=0;me<G.length;me++)for(var z=0;z<Y.length;z++)ye=Ce(G[me],Y[z]),ye&&te.push(ye);return te}function V(G){if(G.length===0)return G;for(var Y=G.reduce($e),te=[],ye={},me=0;me<Y.length;me++){var z=JSON.stringify(Y[me]);ye[z]||(ye[z]=!0,te.push(Y[me]))}return te}function X(G,Y,te,ye){var me=[{placeholders:{}}];if(G instanceof A&&Y instanceof A||G instanceof x&&Y instanceof x){if(G instanceof A){if(G.op!==Y.op||G.fn!==Y.fn)return[]}else if(G instanceof x&&G.name!==Y.name)return[];if(Y.args.length===1&&G.args.length===1||!I(Y,te)&&Y.args.length===G.args.length||ye){for(var z=[],U=0;U<G.args.length;U++){var ee=X(G.args[U],Y.args[U],te);if(ee.length===0)break;z.push(ee)}if(z.length!==G.args.length){if(!B(Y,te)||G.args.length===1)return[];if(G.args.length>2)throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");var ue=X(G.args[0],Y.args[1],te);if(ue.length===0)return[];var ve=X(G.args[1],Y.args[0],te);if(ve.length===0)return[];z=[ue,ve]}me=V(z)}else if(Y.args.length>=2&&G.args.length===2){for(var de=Oe(Y,te),be=[],pe=0;pe<de.length;pe++){var we=X(G,de[pe],te,!0);be=be.concat(we)}return be}else{if(G.args.length>2)throw Error("Unexpected non-binary associative function: "+G.toString());return[]}}else if(G instanceof D){if(G.name.length===0)throw new Error("Symbol in rule has 0 length...!?");if(j[G.name]){if(G.name!==Y.name)return[]}else switch(G.name[1]>="a"&&G.name[1]<="z"?G.name.substring(0,2):G.name[0]){case"n":case"_p":me[0].placeholders[G.name]=Y;break;case"c":case"cl":if(ir(Y))me[0].placeholders[G.name]=Y;else return[];break;case"v":if(!ir(Y))me[0].placeholders[G.name]=Y;else return[];break;case"vl":if(qr(Y))me[0].placeholders[G.name]=Y;else return[];break;case"cd":if(ph(Y))me[0].placeholders[G.name]=Y;else return[];break;case"vd":if(!ph(Y))me[0].placeholders[G.name]=Y;else return[];break;case"ce":if(oo(Y))me[0].placeholders[G.name]=Y;else return[];break;case"ve":if(!oo(Y))me[0].placeholders[G.name]=Y;else return[];break;default:throw new Error("Invalid symbol in rule: "+G.name)}}else if(G instanceof w){if(!s(G.value,Y.value))return[]}else return[];return me}function oe(G,Y){if(G instanceof w&&Y instanceof w){if(!s(G.value,Y.value))return!1}else if(G instanceof D&&Y instanceof D){if(G.name!==Y.name)return!1}else if(G instanceof A&&Y instanceof A||G instanceof x&&Y instanceof x){if(G instanceof A){if(G.op!==Y.op||G.fn!==Y.fn)return!1}else if(G instanceof x&&G.name!==Y.name)return!1;if(G.args.length!==Y.args.length)return!1;for(var te=0;te<G.args.length;te++)if(!oe(G.args[te],Y.args[te]))return!1}else return!1;return!0}return K}),YT="simplifyConstant",QT=["typed","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],KT=q(YT,QT,r=>{var{typed:e,config:t,mathWithTransform:a,matrix:n,fraction:i,bignumber:o,AccessorNode:f,ArrayNode:l,ConstantNode:u,FunctionNode:s,IndexNode:c,ObjectNode:m,OperatorNode:v,SymbolNode:h}=r,{isCommutative:p,isAssociative:g,allChildren:y,createMakeNodeFunction:N}=Cs({FunctionNode:s,OperatorNode:v,SymbolNode:h}),d=e("simplifyConstant",{Node:R=>E(P(R,{})),"Node, Object":function(M,F){return E(P(M,F))}});function w(R){return za(R)?R.valueOf():R instanceof Array?R.map(w):Ve(R)?n(w(R.valueOf())):R}function x(R,M,F){try{return a[R].apply(null,M)}catch{return M=M.map(w),S(a[R].apply(null,M),F)}}var b=e({Fraction:T,number:function(M){return M<0?D(new u(-M)):new u(M)},BigNumber:function(M){return M<0?D(new u(-M)):new u(M)},Complex:function(M){throw new Error("Cannot convert Complex number to Node")},string:function(M){return new u(M)},Matrix:function(M){return new l(M.valueOf().map(F=>b(F)))}});function E(R){return fr(R)?R:b(R)}function A(R,M){var F=M&&M.exactFractions!==!1;if(F&&isFinite(R)&&i){var H=i(R),$=M&&typeof M.fractionsLimit=="number"?M.fractionsLimit:1/0;if(H.valueOf()===R&&H.n<$&&H.d<$)return H}return R}var S=e({"string, Object":function(M,F){if(t.number==="BigNumber")return o===void 0&&ps(),o(M);if(t.number==="Fraction")return i===void 0&&fm(),i(M);var H=parseFloat(M);return A(H,F)},"Fraction, Object":function(M,F){return M},"BigNumber, Object":function(M,F){return M},"number, Object":function(M,F){return A(M,F)},"Complex, Object":function(M,F){return M.im!==0?M:A(M.re,F)},"Matrix, Object":function(M,F){return n(A(M.valueOf()))},"Array, Object":function(M,F){return M.map(A)}});function D(R){return new v("-","unaryMinus",[R])}function T(R){var M,F=R.s*R.n;return F<0?M=new v("-","unaryMinus",[new u(-F)]):M=new u(F),R.d===1?M:new v("/","divide",[M,new u(R.d)])}function B(R,M,F){if(!Jn(M))return new f(E(R),E(M));if(ot(R)||Ve(R)){for(var H=Array.from(M.dimensions);H.length>0;)if(ir(H[0])&&typeof H[0].value!="string"){var $=S(H.shift().value,F);ot(R)?R=R.items[$-1]:(R=R.valueOf()[$-1],R instanceof Array&&(R=n(R)))}else if(H.length>1&&ir(H[1])&&typeof H[1].value!="string"){var k=S(H[1].value,F),Q=[],K=ot(R)?R.items:R.valueOf();for(var L of K)if(ot(L))Q.push(L.items[k-1]);else if(Ve(R))Q.push(L[k-1]);else break;if(Q.length===K.length)ot(R)?R=new l(Q):R=n(Q),H.splice(1,1);else break}else break;return H.length===M.dimensions.length?new f(E(R),M):H.length>0?(M=new c(H),new f(E(R),M)):R}if(ci(R)&&M.dimensions.length===1&&ir(M.dimensions[0])){var j=M.dimensions[0].value;return j in R.properties?R.properties[j]:new u}return new f(E(R),M)}function I(R,M,F,H){var $=M.shift(),k=M.reduce((Q,K)=>{if(!fr(K)){var L=Q.pop();if(fr(L))return[L,K];try{return Q.push(x(R,[L,K],H)),Q}catch{Q.push(L)}}Q.push(E(Q.pop()));var j=Q.length===1?Q[0]:F(Q);return[F([j,E(K)])]},[$]);return k.length===1?k[0]:F([k[0],b(k[1])])}function P(R,M){switch(R.type){case"SymbolNode":return R;case"ConstantNode":switch(typeof R.value){case"number":return S(R.value,M);case"string":return R.value;default:if(!isNaN(R.value))return S(R.value,M)}return R;case"FunctionNode":if(a[R.name]&&a[R.name].rawArgs)return R;{var F=["add","multiply"];if(F.indexOf(R.name)===-1){var H=R.args.map(Ae=>P(Ae,M));if(!H.some(fr))try{return x(R.name,H,M)}catch{}if(R.name==="size"&&H.length===1&&ot(H[0])){for(var $=[],k=H[0];ot(k);)$.push(k.items.length),k=k.items[0];return n($)}return new s(R.name,H.map(E))}}case"OperatorNode":{var Q=R.fn.toString(),K,L,j=N(R);if(Br(R)&&R.isUnary())K=[P(R.args[0],M)],fr(K[0])?L=j(K):L=x(Q,K,M);else if(g(R,M.context))if(K=y(R,M.context),K=K.map(Ae=>P(Ae,M)),p(Q,M.context)){for(var ae=[],re=[],fe=0;fe<K.length;fe++)fr(K[fe])?re.push(K[fe]):ae.push(K[fe]);ae.length>1?(L=I(Q,ae,j,M),re.unshift(L),L=I(Q,re,j,M)):L=I(Q,K,j,M)}else L=I(Q,K,j,M);else K=R.args.map(Ae=>P(Ae,M)),L=I(Q,K,j,M);return L}case"ParenthesisNode":return P(R.content,M);case"AccessorNode":return B(P(R.object,M),P(R.index,M),M);case"ArrayNode":{var he=R.items.map(Ae=>P(Ae,M));return he.some(fr)?new l(he.map(E)):n(he)}case"IndexNode":return new c(R.dimensions.map(Ae=>d(Ae,M)));case"ObjectNode":{var ce={};for(var ie in R.properties)ce[ie]=d(R.properties[ie],M);return new m(ce)}case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"RangeNode":case"ConditionalNode":default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(R.type))}}return d}),dh="simplifyCore",jT=["typed","parse","equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],eB=q(dh,jT,r=>{var{typed:e,parse:t,equal:a,isZero:n,add:i,subtract:o,multiply:f,divide:l,pow:u,AccessorNode:s,ArrayNode:c,ConstantNode:m,FunctionNode:v,IndexNode:h,ObjectNode:p,OperatorNode:g,ParenthesisNode:y,SymbolNode:N}=r,d=new m(0),w=new m(1),x=new m(!0),b=new m(!1);function E(T){return Br(T)&&["and","not","or"].includes(T.op)}var{hasProperty:A,isCommutative:S}=Cs({FunctionNode:v,OperatorNode:g,SymbolNode:N});function D(T){var B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},I=B?B.context:void 0;if(A(T,"trivial",I)){if(nn(T)&&T.args.length===1)return D(T.args[0],B);var P=!1,R=0;if(T.forEach(re=>{++R,R===1&&(P=D(re,B))}),R===1)return P}var M=T;if(nn(M)){var F=yE(M.name);if(F){if(M.args.length>2&&A(M,"associative",I))for(;M.args.length>2;){var H=M.args.pop(),$=M.args.pop();M.args.push(new g(F,M.name,[H,$]))}M=new g(F,M.name,M.args)}else return new v(D(M.fn),M.args.map(re=>D(re,B)))}if(Br(M)&&M.isUnary()){var k=D(M.args[0],B);if(M.op==="~"&&Br(k)&&k.isUnary()&&k.op==="~"||M.op==="not"&&Br(k)&&k.isUnary()&&k.op==="not"&&E(k.args[0]))return k.args[0];var Q=!0;if(M.op==="-"&&Br(k)&&(k.isBinary()&&k.fn==="subtract"&&(M=new g("-","subtract",[k.args[1],k.args[0]]),Q=!1),k.isUnary()&&k.op==="-"))return k.args[0];if(Q)return new g(M.op,M.fn,[k])}if(Br(M)&&M.isBinary()){var K=D(M.args[0],B),L=D(M.args[1],B);if(M.op==="+"){if(ir(K)&&n(K.value))return L;if(ir(L)&&n(L.value))return K;Br(L)&&L.isUnary()&&L.op==="-"&&(L=L.args[0],M=new g("-","subtract",[K,L]))}if(M.op==="-")return Br(L)&&L.isUnary()&&L.op==="-"?D(new g("+","add",[K,L.args[0]]),B):ir(K)&&n(K.value)?D(new g("-","unaryMinus",[L])):ir(L)&&n(L.value)?K:new g(M.op,M.fn,[K,L]);if(M.op==="*"){if(ir(K)){if(n(K.value))return d;if(a(K.value,1))return L}if(ir(L)){if(n(L.value))return d;if(a(L.value,1))return K;if(S(M,I))return new g(M.op,M.fn,[L,K],M.implicit)}return new g(M.op,M.fn,[K,L],M.implicit)}if(M.op==="/")return ir(K)&&n(K.value)?d:ir(L)&&a(L.value,1)?K:new g(M.op,M.fn,[K,L]);if(M.op==="^"&&ir(L)){if(n(L.value))return w;if(a(L.value,1))return K}if(M.op==="and"){if(ir(K))if(K.value){if(E(L))return L}else return b;if(ir(L))if(L.value){if(E(K))return K}else return b}if(M.op==="or"){if(ir(K)){if(K.value)return x;if(E(L))return L}if(ir(L)){if(L.value)return x;if(E(K))return K}}return new g(M.op,M.fn,[K,L])}if(Br(M))return new g(M.op,M.fn,M.args.map(re=>D(re,B)));if(ot(M))return new c(M.items.map(re=>D(re,B)));if(Sn(M))return new s(D(M.object,B),D(M.index,B));if(Jn(M))return new h(M.dimensions.map(re=>D(re,B)));if(ci(M)){var j={};for(var ae in M.properties)j[ae]=D(M.properties[ae],B);return new p(j)}return M}return e(dh,{Node:D,"Node,Object":D})}),rB="resolve",tB=["typed","parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],nB=q(rB,tB,r=>{var{typed:e,parse:t,ConstantNode:a,FunctionNode:n,OperatorNode:i,ParenthesisNode:o}=r;function f(l,u){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;if(!u)return l;if(qr(l)){if(s.has(l.name)){var c=Array.from(s).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(c,"}"))}var m=u.get(l.name);if(fr(m)){var v=new Set(s);return v.add(l.name),f(m,u,v)}else return typeof m=="number"?t(String(m)):m!==void 0?new a(m):l}else if(Br(l)){var h=l.args.map(function(g){return f(g,u,s)});return new i(l.op,l.fn,h,l.implicit)}else{if(Gt(l))return new o(f(l.content,u,s));if(nn(l)){var p=l.args.map(function(g){return f(g,u,s)});return new n(l.name,p)}}return l.map(g=>f(g,u,s))}return e("resolve",{Node:f,"Node, Map | null | undefined":f,"Node, Object":(l,u)=>f(l,ra(u)),"Array | Matrix":e.referToSelf(l=>u=>u.map(s=>l(s))),"Array | Matrix, null | undefined":e.referToSelf(l=>u=>u.map(s=>l(s))),"Array, Object":e.referTo("Array,Map",l=>(u,s)=>l(u,ra(s))),"Matrix, Object":e.referTo("Matrix,Map",l=>(u,s)=>l(u,ra(s))),"Array | Matrix, Map":e.referToSelf(l=>(u,s)=>u.map(c=>l(c,s)))})}),gh="symbolicEqual",aB=["parse","simplify","typed","OperatorNode"],iB=q(gh,aB,r=>{var{parse:e,simplify:t,typed:a,OperatorNode:n}=r;function i(o,f){var l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},u=new n("-","subtract",[o,f]),s=t(u,{},l);return ir(s)&&!s.value}return a(gh,{"Node, Node":i,"Node, Node, Object":i})}),yh="derivative",oB=["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],sB=q(yh,oB,r=>{var{typed:e,config:t,parse:a,simplify:n,equal:i,isZero:o,numeric:f,ConstantNode:l,FunctionNode:u,OperatorNode:s,ParenthesisNode:c,SymbolNode:m}=r;function v(w,x){var b=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{simplify:!0},E={};g(E,w,x.name);var A=y(w,E);return b.simplify?n(A):A}e.addConversion({from:"identifier",to:"SymbolNode",convert:a});var h=e(yh,{"Node, SymbolNode":v,"Node, SymbolNode, Object":v});e.removeConversion({from:"identifier",to:"SymbolNode",convert:a}),h._simplify=!0,h.toTex=function(w){return p.apply(null,w.args)};var p=e("_derivTex",{"Node, SymbolNode":function(x,b){return ir(x)&&br(x.value)==="string"?p(a(x.value).toString(),b.toString(),1):p(x.toTex(),b.toString(),1)},"Node, ConstantNode":function(x,b){if(br(b.value)==="string")return p(x,a(b.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(x,b,E){return p(x.toString(),b.name,E.value)},"string, string, number":function(x,b,E){var A;return E===1?A="{d\\over d"+b+"}":A="{d^{"+E+"}\\over d"+b+"^{"+E+"}}",A+"\\left[".concat(x,"\\right]")}}),g=e("constTag",{"Object, ConstantNode, string":function(x,b){return x[b]=!0,!0},"Object, SymbolNode, string":function(x,b,E){return b.name!==E?(x[b]=!0,!0):!1},"Object, ParenthesisNode, string":function(x,b,E){return g(x,b.content,E)},"Object, FunctionAssignmentNode, string":function(x,b,E){return b.params.indexOf(E)===-1?(x[b]=!0,!0):g(x,b.expr,E)},"Object, FunctionNode | OperatorNode, string":function(x,b,E){if(b.args.length>0){for(var A=g(x,b.args[0],E),S=1;S<b.args.length;++S)A=g(x,b.args[S],E)&&A;if(A)return x[b]=!0,!0}return!1}}),y=e("_derivative",{"ConstantNode, Object":function(x){return d(0)},"SymbolNode, Object":function(x,b){return b[x]!==void 0?d(0):d(1)},"ParenthesisNode, Object":function(x,b){return new c(y(x.content,b))},"FunctionAssignmentNode, Object":function(x,b){return b[x]!==void 0?d(0):y(x.expr,b)},"FunctionNode, Object":function(x,b){if(x.args.length!==1&&N(x),b[x]!==void 0)return d(0);var E=x.args[0],A,S=!1,D=!1,T;switch(x.name){case"cbrt":S=!0,T=new s("*","multiply",[d(3),new s("^","pow",[E,new s("/","divide",[d(2),d(3)])])]);break;case"sqrt":case"nthRoot":if(x.args.length===1)S=!0,T=new s("*","multiply",[d(2),new u("sqrt",[E])]);else if(x.args.length===2)return A=new s("/","divide",[d(1),x.args[1]]),b[A]=b[x.args[1]],y(new s("^","pow",[E,A]),b);break;case"log10":A=d(10);case"log":if(!A&&x.args.length===1)T=E.clone(),S=!0;else if(x.args.length===1&&A||x.args.length===2&&b[x.args[1]]!==void 0)T=new s("*","multiply",[E.clone(),new u("log",[A||x.args[1]])]),S=!0;else if(x.args.length===2)return y(new s("/","divide",[new u("log",[E]),new u("log",[x.args[1]])]),b);break;case"pow":return b[A]=b[x.args[1]],y(new s("^","pow",[E,x.args[1]]),b);case"exp":T=new u("exp",[E.clone()]);break;case"sin":T=new u("cos",[E.clone()]);break;case"cos":T=new s("-","unaryMinus",[new u("sin",[E.clone()])]);break;case"tan":T=new s("^","pow",[new u("sec",[E.clone()]),d(2)]);break;case"sec":T=new s("*","multiply",[x,new u("tan",[E.clone()])]);break;case"csc":D=!0,T=new s("*","multiply",[x,new u("cot",[E.clone()])]);break;case"cot":D=!0,T=new s("^","pow",[new u("csc",[E.clone()]),d(2)]);break;case"asin":S=!0,T=new u("sqrt",[new s("-","subtract",[d(1),new s("^","pow",[E.clone(),d(2)])])]);break;case"acos":S=!0,D=!0,T=new u("sqrt",[new s("-","subtract",[d(1),new s("^","pow",[E.clone(),d(2)])])]);break;case"atan":S=!0,T=new s("+","add",[new s("^","pow",[E.clone(),d(2)]),d(1)]);break;case"asec":S=!0,T=new s("*","multiply",[new u("abs",[E.clone()]),new u("sqrt",[new s("-","subtract",[new s("^","pow",[E.clone(),d(2)]),d(1)])])]);break;case"acsc":S=!0,D=!0,T=new s("*","multiply",[new u("abs",[E.clone()]),new u("sqrt",[new s("-","subtract",[new s("^","pow",[E.clone(),d(2)]),d(1)])])]);break;case"acot":S=!0,D=!0,T=new s("+","add",[new s("^","pow",[E.clone(),d(2)]),d(1)]);break;case"sinh":T=new u("cosh",[E.clone()]);break;case"cosh":T=new u("sinh",[E.clone()]);break;case"tanh":T=new s("^","pow",[new u("sech",[E.clone()]),d(2)]);break;case"sech":D=!0,T=new s("*","multiply",[x,new u("tanh",[E.clone()])]);break;case"csch":D=!0,T=new s("*","multiply",[x,new u("coth",[E.clone()])]);break;case"coth":D=!0,T=new s("^","pow",[new u("csch",[E.clone()]),d(2)]);break;case"asinh":S=!0,T=new u("sqrt",[new s("+","add",[new s("^","pow",[E.clone(),d(2)]),d(1)])]);break;case"acosh":S=!0,T=new u("sqrt",[new s("-","subtract",[new s("^","pow",[E.clone(),d(2)]),d(1)])]);break;case"atanh":S=!0,T=new s("-","subtract",[d(1),new s("^","pow",[E.clone(),d(2)])]);break;case"asech":S=!0,D=!0,T=new s("*","multiply",[E.clone(),new u("sqrt",[new s("-","subtract",[d(1),new s("^","pow",[E.clone(),d(2)])])])]);break;case"acsch":S=!0,D=!0,T=new s("*","multiply",[new u("abs",[E.clone()]),new u("sqrt",[new s("+","add",[new s("^","pow",[E.clone(),d(2)]),d(1)])])]);break;case"acoth":S=!0,D=!0,T=new s("-","subtract",[d(1),new s("^","pow",[E.clone(),d(2)])]);break;case"abs":T=new s("/","divide",[new u(new m("abs"),[E.clone()]),E.clone()]);break;case"gamma":default:throw new Error('Function "'+x.name+'" is not supported by derivative, or a wrong number of arguments is passed')}var B,I;S?(B="/",I="divide"):(B="*",I="multiply");var P=y(E,b);return D&&(P=new s("-","unaryMinus",[P])),new s(B,I,[P,T])},"OperatorNode, Object":function(x,b){if(b[x]!==void 0)return d(0);if(x.op==="+")return new s(x.op,x.fn,x.args.map(function(M){return y(M,b)}));if(x.op==="-"){if(x.isUnary())return new s(x.op,x.fn,[y(x.args[0],b)]);if(x.isBinary())return new s(x.op,x.fn,[y(x.args[0],b),y(x.args[1],b)])}if(x.op==="*"){var E=x.args.filter(function(M){return b[M]!==void 0});if(E.length>0){var A=x.args.filter(function(M){return b[M]===void 0}),S=A.length===1?A[0]:new s("*","multiply",A),D=E.concat(y(S,b));return new s("*","multiply",D)}return new s("+","add",x.args.map(function(M){return new s("*","multiply",x.args.map(function(F){return F===M?y(F,b):F.clone()}))}))}if(x.op==="/"&&x.isBinary()){var T=x.args[0],B=x.args[1];return b[B]!==void 0?new s("/","divide",[y(T,b),B]):b[T]!==void 0?new s("*","multiply",[new s("-","unaryMinus",[T]),new s("/","divide",[y(B,b),new s("^","pow",[B.clone(),d(2)])])]):new s("/","divide",[new s("-","subtract",[new s("*","multiply",[y(T,b),B.clone()]),new s("*","multiply",[T.clone(),y(B,b)])]),new s("^","pow",[B.clone(),d(2)])])}if(x.op==="^"&&x.isBinary()){var I=x.args[0],P=x.args[1];if(b[I]!==void 0)return ir(I)&&(o(I.value)||i(I.value,1))?d(0):new s("*","multiply",[x,new s("*","multiply",[new u("log",[I.clone()]),y(P.clone(),b)])]);if(b[P]!==void 0){if(ir(P)){if(o(P.value))return d(0);if(i(P.value,1))return y(I,b)}var R=new s("^","pow",[I.clone(),new s("-","subtract",[P,d(1)])]);return new s("*","multiply",[P.clone(),new s("*","multiply",[y(I,b),R])])}return new s("*","multiply",[new s("^","pow",[I.clone(),P.clone()]),new s("+","add",[new s("*","multiply",[y(I,b),new s("/","divide",[P.clone(),I.clone()])]),new s("*","multiply",[y(P,b),new u("log",[I.clone()])])])])}throw new Error('Operator "'+x.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function N(w){if(!((w.name==="log"||w.name==="nthRoot"||w.name==="pow")&&w.args.length===2)){for(var x=0;x<w.args.length;++x)w.args[x]=d(0);throw w.compile().evaluate(),new Error("Expected TypeError, but none found")}}function d(w,x){return new l(f(w,x||t.number))}return h}),bh="rationalize",uB=["config","typed","equal","isZero","add","subtract","multiply","divide","pow","parse","simplifyConstant","simplifyCore","simplify","?bignumber","?fraction","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode","ParenthesisNode"],lB=q(bh,uB,r=>{var{config:e,typed:t,equal:a,isZero:n,add:i,subtract:o,multiply:f,divide:l,pow:u,parse:s,simplifyConstant:c,simplifyCore:m,simplify:v,fraction:h,bignumber:p,mathWithTransform:g,matrix:y,AccessorNode:N,ArrayNode:d,ConstantNode:w,FunctionNode:x,IndexNode:b,ObjectNode:E,OperatorNode:A,SymbolNode:S,ParenthesisNode:D}=r;function T(M){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},H=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,$=I(),k=B(M,F,!0,$.firstRules),Q=k.variables.length,K={exactFractions:!1},L={exactFractions:!0};if(M=k.expression,Q>=1){M=P(M);var j,ae,re=!0,fe=!1;M=v(M,$.firstRules,{},K);for(var he;ae=re?$.distrDivRules:$.sucDivRules,M=v(M,ae,{},L),re=!re,he=M.toString(),he!==j;)fe=!0,j=he;fe&&(M=v(M,$.firstRulesAgain,{},K)),M=v(M,$.finalRules,{},K)}var ce=[],ie={};return M.type==="OperatorNode"&&M.isBinary()&&M.op==="/"?(Q===1&&(M.args[0]=R(M.args[0],ce),M.args[1]=R(M.args[1])),H&&(ie.numerator=M.args[0],ie.denominator=M.args[1])):(Q===1&&(M=R(M,ce)),H&&(ie.numerator=M,ie.denominator=null)),H?(ie.coefficients=ce,ie.variables=k.variables,ie.expression=M,ie):M}return t(bh,{Node:T,"Node, boolean":(M,F)=>T(M,{},F),"Node, Object":T,"Node, Object, boolean":T});function B(M,F,H,$){var k=[],Q=v(M,$,F,{exactFractions:!1});H=!!H;var K="+-*"+(H?"/":"");j(Q);var L={};return L.expression=Q,L.variables=k,L;function j(ae){var re=ae.type;if(re==="FunctionNode")throw new Error("There is an unsolved function call");if(re==="OperatorNode")if(ae.op==="^"){if(ae.args[1].type!=="ConstantNode"||!qe(parseFloat(ae.args[1].value)))throw new Error("There is a non-integer exponent");j(ae.args[0])}else{if(K.indexOf(ae.op)===-1)throw new Error("Operator "+ae.op+" invalid in polynomial expression");for(var fe=0;fe<ae.args.length;fe++)j(ae.args[fe])}else if(re==="SymbolNode"){var he=ae.name,ce=k.indexOf(he);ce===-1&&k.push(he)}else if(re==="ParenthesisNode")j(ae.content);else if(re!=="ConstantNode")throw new Error("type "+re+" is not allowed in polynomial expression")}}function I(){var M=[m,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},c,{l:"n*(n1^-1)",r:"n/n1"},{l:"n*n1^-n2",r:"n/n1^n2"},{l:"n1^-1",r:"1/n1"},{l:"n*(n1/n2)",r:"(n*n1)/n2"},{l:"1*n",r:"n"}],F=[{l:"(-n1)/(-n2)",r:"n1/n2"},{l:"(-n1)*(-n2)",r:"n1*n2"},{l:"n1--n2",r:"n1+n2"},{l:"n1-n2",r:"n1+(-n2)"},{l:"(n1+n2)*n3",r:"(n1*n3 + n2*n3)"},{l:"n1*(n2+n3)",r:"(n1*n2+n1*n3)"},{l:"c1*n + c2*n",r:"(c1+c2)*n"},{l:"c1*n + n",r:"(c1+1)*n"},{l:"c1*n - c2*n",r:"(c1-c2)*n"},{l:"c1*n - n",r:"(c1-1)*n"},{l:"v/c",r:"(1/c)*v"},{l:"v/-c",r:"-(1/c)*v"},{l:"-v*-c",r:"c*v"},{l:"-v*c",r:"-c*v"},{l:"v*-c",r:"-c*v"},{l:"v*c",r:"c*v"},{l:"-(-n1*n2)",r:"(n1*n2)"},{l:"-(n1*n2)",r:"(-n1*n2)"},{l:"-(-n1+n2)",r:"(n1-n2)"},{l:"-(n1+n2)",r:"(-n1-n2)"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"},{l:"-(-n1/n2)",r:"(n1/n2)"},{l:"-(n1/n2)",r:"(-n1/n2)"}],H=[{l:"(n1/n2 + n3/n4)",r:"((n1*n4 + n3*n2)/(n2*n4))"},{l:"(n1/n2 + n3)",r:"((n1 + n3*n2)/n2)"},{l:"(n1 + n2/n3)",r:"((n1*n3 + n2)/n3)"}],$=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],k={};return k.firstRules=M.concat(F,$),k.distrDivRules=H,k.sucDivRules=$,k.firstRulesAgain=M.concat(F),k.finalRules=[m,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},c,{l:"n*-n^n1",r:"-n^(n1+1)"},{l:"n*n^n1",r:"n^(n1+1)"},{l:"n^n1*-n^n2",r:"-n^(n1+n2)"},{l:"n^n1*n^n2",r:"n^(n1+n2)"},{l:"n^n1*-n",r:"-n^(n1+1)"},{l:"n^n1*n",r:"n^(n1+1)"},{l:"n^n1/-n",r:"-n^(n1-1)"},{l:"n^n1/n",r:"n^(n1-1)"},{l:"n/-n^n1",r:"-n^(1-n1)"},{l:"n/n^n1",r:"n^(1-n1)"},{l:"n^n1/-n^n2",r:"n^(n1-n2)"},{l:"n^n1/n^n2",r:"n^(n1-n2)"},{l:"n1+(-n2*n3)",r:"n1-n2*n3"},{l:"v*(-c)",r:"-c*v"},{l:"n1+-n2",r:"n1-n2"},{l:"v*c",r:"c*v"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"}],k}function P(M,F,H){var $=M.type,k=arguments.length>1;if($==="OperatorNode"&&M.isBinary()){var Q=!1,K;if(M.op==="^"&&(M.args[0].type==="ParenthesisNode"||M.args[0].type==="OperatorNode")&&M.args[1].type==="ConstantNode"&&(K=parseFloat(M.args[1].value),Q=K>=2&&qe(K)),Q){if(K>2){var L=M.args[0],j=new A("^","pow",[M.args[0].cloneDeep(),new w(K-1)]);M=new A("*","multiply",[L,j])}else M=new A("*","multiply",[M.args[0],M.args[0].cloneDeep()]);k&&(H==="content"?F.content=M:F.args[H]=M)}}if($==="ParenthesisNode")P(M.content,M,"content");else if($!=="ConstantNode"&&$!=="SymbolNode")for(var ae=0;ae<M.args.length;ae++)P(M.args[ae],M,ae);if(!k)return M}function R(M,F){F===void 0&&(F=[]),F[0]=0;var H={};H.cte=1,H.oper="+",H.fire="";var $=0,k="";he(M,null,H),$=F.length-1;for(var Q=!0,K,L=$;L>=0;L--)if(F[L]!==0){var j=new w(Q?F[L]:Math.abs(F[L])),ae=F[L]<0?"-":"+";if(L>0){var re=new S(k);if(L>1){var fe=new w(L);re=new A("^","pow",[re,fe])}F[L]===-1&&Q?j=new A("-","unaryMinus",[re]):Math.abs(F[L])===1?j=re:j=new A("*","multiply",[j,re])}Q?K=j:ae==="+"?K=new A("+","add",[K,j]):K=new A("-","subtract",[K,j]),Q=!1}if(Q)return new w(0);return K;function he(ce,ie,Ae){var Oe=ce.type;if(Oe==="FunctionNode")throw new Error("There is an unsolved function call");if(Oe==="OperatorNode"){if("+-*^".indexOf(ce.op)===-1)throw new Error("Operator "+ce.op+" invalid");if(ie!==null){if((ce.fn==="unaryMinus"||ce.fn==="pow")&&ie.fn!=="add"&&ie.fn!=="subtract"&&ie.fn!=="multiply")throw new Error("Invalid "+ce.op+" placing");if((ce.fn==="subtract"||ce.fn==="add"||ce.fn==="multiply")&&ie.fn!=="add"&&ie.fn!=="subtract")throw new Error("Invalid "+ce.op+" placing");if((ce.fn==="subtract"||ce.fn==="add"||ce.fn==="unaryMinus")&&Ae.noFil!==0)throw new Error("Invalid "+ce.op+" placing")}(ce.op==="^"||ce.op==="*")&&(Ae.fire=ce.op);for(var Ce=0;Ce<ce.args.length;Ce++)ce.fn==="unaryMinus"&&(Ae.oper="-"),(ce.op==="+"||ce.fn==="subtract")&&(Ae.fire="",Ae.cte=1,Ae.oper=Ce===0?"+":ce.op),Ae.noFil=Ce,he(ce.args[Ce],ce,Ae)}else if(Oe==="SymbolNode"){if(ce.name!==k&&k!=="")throw new Error("There is more than one variable");if(k=ce.name,ie===null){F[1]=1;return}if(ie.op==="^"&&Ae.noFil!==0)throw new Error("In power the variable should be the first parameter");if(ie.op==="*"&&Ae.noFil!==1)throw new Error("In multiply the variable should be the second parameter");(Ae.fire===""||Ae.fire==="*")&&($<1&&(F[1]=0),F[1]+=Ae.cte*(Ae.oper==="+"?1:-1),$=Math.max(1,$))}else if(Oe==="ConstantNode"){var $e=parseFloat(ce.value);if(ie===null){F[0]=$e;return}if(ie.op==="^"){if(Ae.noFil!==1)throw new Error("Constant cannot be powered");if(!qe($e)||$e<=0)throw new Error("Non-integer exponent is not allowed");for(var V=$+1;V<$e;V++)F[V]=0;$e>$&&(F[$e]=0),F[$e]+=Ae.cte*(Ae.oper==="+"?1:-1),$=Math.max($e,$);return}Ae.cte=$e,Ae.fire===""&&(F[0]+=Ae.cte*(Ae.oper==="+"?1:-1))}else throw new Error("Type "+Oe+" is not allowed")}}}),cB="reviver",fB=["classes"],mB=q(cB,fB,r=>{var{classes:e}=r;return function(a,n){var i=e[n&&n.mathjs];return i&&typeof i.fromJSON=="function"?i.fromJSON(n):n}}),vB="replacer",pB=[],hB=q(vB,pB,()=>function(e,t){return typeof t=="number"&&(!isFinite(t)||isNaN(t))?{mathjs:"number",value:String(t)}:t}),dB="11.8.0",gB=q("true",[],()=>!0),yB=q("false",[],()=>!1),bB=q("null",[],()=>null),xB=at("Infinity",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1/0):1/0}),wB=at("NaN",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(NaN):NaN}),NB=at("pi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?gs(t):ry}),DB=at("tau",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?ND(t):ty}),AB=at("e",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?xD(t):ny}),EB=at("phi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?wD(t):ay}),SB=at("LN2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).ln():Math.LN2}),CB=at("LN10",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(10).ln():Math.LN10}),MB=at("LOG2E",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1).div(new t(2).ln()):Math.LOG2E}),FB=at("LOG10E",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1).div(new t(10).ln()):Math.LOG10E}),TB=at("SQRT1_2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t("0.5").sqrt():Math.SQRT1_2}),BB=at("SQRT2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).sqrt():Math.SQRT2}),$B=at("i",["Complex"],r=>{var{Complex:e}=r;return e.I}),OB=q("version",[],()=>dB);function at(r,e,t){return q(r,e,t,{recreateOnConfigChange:!0})}var IB=We("speedOfLight","299792458","m s^-1"),RB=We("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),_B=We("planckConstant","6.62607015e-34","J s"),qB=We("reducedPlanckConstant","1.0545718176461565e-34","J s"),zB=We("magneticConstant","1.25663706212e-6","N A^-2"),PB=We("electricConstant","8.8541878128e-12","F m^-1"),UB=We("vacuumImpedance","376.730313667","ohm"),LB=We("coulomb","8.987551792261171e9","N m^2 C^-2"),kB=We("elementaryCharge","1.602176634e-19","C"),VB=We("bohrMagneton","9.2740100783e-24","J T^-1"),GB=We("conductanceQuantum","7.748091729863649e-5","S"),HB=We("inverseConductanceQuantum","12906.403729652257","ohm"),ZB=We("magneticFluxQuantum","2.0678338484619295e-15","Wb"),JB=We("nuclearMagneton","5.0507837461e-27","J T^-1"),XB=We("klitzing","25812.807459304513","ohm"),WB=We("bohrRadius","5.29177210903e-11","m"),YB=We("classicalElectronRadius","2.8179403262e-15","m"),QB=We("electronMass","9.1093837015e-31","kg"),KB=We("fermiCoupling","1.1663787e-5","GeV^-2"),jB=so("fineStructure",.0072973525693),e$=We("hartreeEnergy","4.3597447222071e-18","J"),r$=We("protonMass","1.67262192369e-27","kg"),t$=We("deuteronMass","3.3435830926e-27","kg"),n$=We("neutronMass","1.6749271613e-27","kg"),a$=We("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),i$=We("rydberg","10973731.568160","m^-1"),o$=We("thomsonCrossSection","6.6524587321e-29","m^2"),s$=so("weakMixingAngle",.2229),u$=so("efimovFactor",22.7),l$=We("atomicMass","1.66053906660e-27","kg"),c$=We("avogadro","6.02214076e23","mol^-1"),f$=We("boltzmann","1.380649e-23","J K^-1"),m$=We("faraday","96485.33212331001","C mol^-1"),v$=We("firstRadiation","3.7417718521927573e-16","W m^2"),p$=We("loschmidt","2.686780111798444e25","m^-3"),h$=We("gasConstant","8.31446261815324","J K^-1 mol^-1"),d$=We("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),g$=We("molarVolume","0.022413969545014137","m^3 mol^-1"),y$=so("sackurTetrode",-1.16487052358),b$=We("secondRadiation","0.014387768775039337","m K"),x$=We("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),w$=We("wienDisplacement","2.897771955e-3","m K"),N$=We("molarMass","0.99999999965e-3","kg mol^-1"),D$=We("molarMassC12","11.9999999958e-3","kg mol^-1"),A$=We("gravity","9.80665","m s^-2"),E$=We("planckLength","1.616255e-35","m"),S$=We("planckMass","2.176435e-8","kg"),C$=We("planckTime","5.391245e-44","s"),M$=We("planckCharge","1.87554603778e-18","C"),F$=We("planckTemperature","1.416785e+32","K");function We(r,e,t){var a=["config","Unit","BigNumber"];return q(r,a,n=>{var{config:i,Unit:o,BigNumber:f}=n,l=i.number==="BigNumber"?new f(e):parseFloat(e),u=new o(l,t);return u.fixPrefix=!0,u})}function so(r,e){var t=["config","BigNumber"];return q(r,t,a=>{var{config:n,BigNumber:i}=a;return n.number==="BigNumber"?new i(e):e})}var T$="apply",B$=["typed","isInteger"],$$=q(T$,B$,r=>{var{typed:e,isInteger:t}=r,a=df({typed:e,isInteger:t});return e("apply",{"...any":function(i){var o=i[1];tr(o)?i[1]=o-1:rr(o)&&(i[1]=o.minus(1));try{return a.apply(null,i)}catch(f){throw Kr(f)}}})},{isTransformFunction:!0}),O$="column",I$=["typed","Index","matrix","range"],R$=q(O$,I$,r=>{var{typed:e,Index:t,matrix:a,range:n}=r,i=Kf({typed:e,Index:t,matrix:a,range:n});return e("column",{"...any":function(f){var l=f.length-1,u=f[l];tr(u)&&(f[l]=u-1);try{return i.apply(null,f)}catch(s){throw Kr(s)}}})},{isTransformFunction:!0});function Ms(r,e,t){var a=r.filter(function(f){return qr(f)&&!(f.name in e)&&!t.has(f.name)})[0];if(!a)throw new Error('No undefined variable found in inline expression "'+r+'"');var n=a.name,i=Wa(t),o=r.compile();return function(l){return i.set(n,l),o.evaluate(i)}}var _$="filter",q$=["typed"],z$=q(_$,q$,r=>{var{typed:e}=r;function t(n,i,o){var f,l;return n[0]&&(f=n[0].compile().evaluate(o)),n[1]&&(qr(n[1])||Pa(n[1])?l=n[1].compile().evaluate(o):l=Ms(n[1],i,o)),a(f,l)}t.rawArgs=!0;var a=e("filter",{"Array, function":xh,"Matrix, function":function(i,o){return i.create(xh(i.toArray(),o))},"Array, RegExp":di,"Matrix, RegExp":function(i,o){return i.create(di(i.toArray(),o))}});return t},{isTransformFunction:!0});function xh(r,e){var t=fn(e);return Sl(r,function(a,n,i){return t===1?e(a):t===2?e(a,[n+1]):e(a,[n+1],i)})}var P$="forEach",U$=["typed"],L$=q(P$,U$,r=>{var{typed:e}=r;function t(n,i,o){var f,l;return n[0]&&(f=n[0].compile().evaluate(o)),n[1]&&(qr(n[1])||Pa(n[1])?l=n[1].compile().evaluate(o):l=Ms(n[1],i,o)),a(f,l)}t.rawArgs=!0;var a=e("forEach",{"Array | Matrix, function":function(i,o){var f=fn(o),l=function u(s,c){Array.isArray(s)?hi(s,function(m,v){u(m,c.concat(v+1))}):f===1?o(s):f===2?o(s,c):o(s,c,i)};l(i.valueOf(),[])}});return t},{isTransformFunction:!0}),k$="index",V$=["Index"],G$=q(k$,V$,r=>{var{Index:e}=r;return function(){for(var a=[],n=0,i=arguments.length;n<i;n++){var o=arguments[n];if(Uo(o))o.start--,o.end-=o.step>0?0:2;else if(o&&o.isSet===!0)o=o.map(function(l){return l-1});else if(cr(o)||Ve(o))o=o.map(function(l){return l-1});else if(tr(o))o--;else if(rr(o))o=o.toNumber()-1;else if(typeof o!="string")throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");a[n]=o}var f=new e;return e.apply(f,a),f}},{isTransformFunction:!0}),H$="map",Z$=["typed"],J$=q(H$,Z$,r=>{var{typed:e}=r;function t(n,i,o){var f,l;return n[0]&&(f=n[0].compile().evaluate(o)),n[1]&&(qr(n[1])||Pa(n[1])?l=n[1].compile().evaluate(o):l=Ms(n[1],i,o)),a(f,l)}t.rawArgs=!0;var a=e("map",{"Array, function":function(i,o){return wh(i,o,i)},"Matrix, function":function(i,o){return i.create(wh(i.valueOf(),o,i))}});return t},{isTransformFunction:!0});function wh(r,e,t){var a=fn(e);function n(i,o){return Array.isArray(i)?Ht(i,function(f,l){return n(f,o.concat(l+1))}):a===1?e(i):a===2?e(i,o):e(i,o,t)}return n(r,[])}function On(r){if(r.length===2&&Ft(r[0])){r=r.slice();var e=r[1];tr(e)?r[1]=e-1:rr(e)&&(r[1]=e.minus(1))}return r}var X$="max",W$=["typed","config","numeric","larger"],Y$=q(X$,W$,r=>{var{typed:e,config:t,numeric:a,larger:n}=r,i=lv({typed:e,config:t,numeric:a,larger:n});return e("max",{"...any":function(f){f=On(f);try{return i.apply(null,f)}catch(l){throw Kr(l)}}})},{isTransformFunction:!0}),Q$="mean",K$=["typed","add","divide"],j$=q(Q$,K$,r=>{var{typed:e,add:t,divide:a}=r,n=Ip({typed:e,add:t,divide:a});return e("mean",{"...any":function(o){o=On(o);try{return n.apply(null,o)}catch(f){throw Kr(f)}}})},{isTransformFunction:!0}),eO="min",rO=["typed","config","numeric","smaller"],tO=q(eO,rO,r=>{var{typed:e,config:t,numeric:a,smaller:n}=r,i=fv({typed:e,config:t,numeric:a,smaller:n});return e("min",{"...any":function(f){f=On(f);try{return i.apply(null,f)}catch(l){throw Kr(l)}}})},{isTransformFunction:!0}),nO="range",aO=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],iO=q(nO,aO,r=>{var{typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:o,larger:f,largerEq:l}=r,u=pm({typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:o,larger:f,largerEq:l});return e("range",{"...any":function(c){var m=c.length-1,v=c[m];return typeof v!="boolean"&&c.push(!0),u.apply(null,c)}})},{isTransformFunction:!0}),oO="row",sO=["typed","Index","matrix","range"],uO=q(oO,sO,r=>{var{typed:e,Index:t,matrix:a,range:n}=r,i=bm({typed:e,Index:t,matrix:a,range:n});return e("row",{"...any":function(f){var l=f.length-1,u=f[l];tr(u)&&(f[l]=u-1);try{return i.apply(null,f)}catch(s){throw Kr(s)}}})},{isTransformFunction:!0}),lO="subset",cO=["typed","matrix"],fO=q(lO,cO,r=>{var{typed:e,matrix:t}=r,a=Dm({typed:e,matrix:t});return e("subset",{"...any":function(i){try{return a.apply(null,i)}catch(o){throw Kr(o)}}})},{isTransformFunction:!0}),mO="concat",vO=["typed","matrix","isInteger"],pO=q(mO,vO,r=>{var{typed:e,matrix:t,isInteger:a}=r,n=Wf({typed:e,matrix:t,isInteger:a});return e("concat",{"...any":function(o){var f=o.length-1,l=o[f];tr(l)?o[f]=l-1:rr(l)&&(o[f]=l.minus(1));try{return n.apply(null,o)}catch(u){throw Kr(u)}}})},{isTransformFunction:!0}),Nh="diff",hO=["typed","matrix","subtract","number","bignumber"],dO=q(Nh,hO,r=>{var{typed:e,matrix:t,subtract:a,number:n,bignumber:i}=r,o=cm({typed:e,matrix:t,subtract:a,number:n,bignumber:i});return e(Nh,{"...any":function(l){l=On(l);try{return o.apply(null,l)}catch(u){throw Kr(u)}}})},{isTransformFunction:!0}),gO="std",yO=["typed","map","sqrt","variance"],bO=q(gO,yO,r=>{var{typed:e,map:t,sqrt:a,variance:n}=r,i=Up({typed:e,map:t,sqrt:a,variance:n});return e("std",{"...any":function(f){f=On(f);try{return i.apply(null,f)}catch(l){throw Kr(l)}}})},{isTransformFunction:!0}),Dh="sum",xO=["typed","config","add","numeric"],wO=q(Dh,xO,r=>{var{typed:e,config:t,add:a,numeric:n}=r,i=Bp({typed:e,config:t,add:a,numeric:n});return e(Dh,{"...any":function(f){f=On(f);try{return i.apply(null,f)}catch(l){throw Kr(l)}}})},{isTransformFunction:!0}),Ah="cumsum",NO=["typed","add","unaryPlus"],DO=q(Ah,NO,r=>{var{typed:e,add:t,unaryPlus:a}=r,n=$p({typed:e,add:t,unaryPlus:a});return e(Ah,{"...any":function(o){if(o.length===2&&Ft(o[0])){var f=o[1];tr(f)?o[1]=f-1:rr(f)&&(o[1]=f.minus(1))}try{return n.apply(null,o)}catch(l){throw Kr(l)}}})},{isTransformFunction:!0}),Eh="variance",AO=["typed","add","subtract","multiply","divide","apply","isNaN"],EO=q(Eh,AO,r=>{var{typed:e,add:t,subtract:a,multiply:n,divide:i,apply:o,isNaN:f}=r,l=zp({typed:e,add:t,subtract:a,multiply:n,divide:i,apply:o,isNaN:f});return e(Eh,{"...any":function(s){s=On(s);try{return l.apply(null,s)}catch(c){throw Kr(c)}}})},{isTransformFunction:!0}),Me=B1({config:ge}),xr=R1({}),Sh=AB({BigNumber:Me,config:ge}),SO=yB({}),CO=jB({BigNumber:Me,config:ge}),In=z1({}),Ch=$B({Complex:xr}),MO=xB({BigNumber:Me,config:ge}),FO=CB({BigNumber:Me,config:ge}),TO=FB({BigNumber:Me,config:ge}),uo=G1({}),BO=wB({BigNumber:Me,config:ge}),$O=bB({}),OO=EB({BigNumber:Me,config:ge}),IO=L1({}),Mh=Rg({}),RO=TB({BigNumber:Me,config:ge}),_O=y$({BigNumber:Me,config:ge}),Fh=DB({BigNumber:Me,config:ge}),qO=gB({}),zO=OB({}),Qe=X1({Matrix:uo}),PO=u$({BigNumber:Me,config:ge}),UO=SB({BigNumber:Me,config:ge}),Th=NB({BigNumber:Me,config:ge}),LO=hB({}),kO=BB({BigNumber:Me,config:ge}),J=Bg({BigNumber:Me,Complex:xr,DenseMatrix:Qe,Fraction:In}),Fs=ib({BigNumber:Me,config:ge,typed:J}),VO=s$({BigNumber:Me,config:ge}),rt=sb({typed:J}),GO=OD({Complex:xr,config:ge,typed:J}),HO=qD({BigNumber:Me,typed:J}),ZO=LD({BigNumber:Me,Complex:xr,config:ge,typed:J}),$r=fb({typed:J}),JO=ew({typed:J}),XO=JD({BigNumber:Me,Complex:xr,config:ge,typed:J}),WO=KD({typed:J}),Bh=rA({typed:J}),YO=iA({Complex:xr,config:ge,typed:J}),Ot=Py({BigNumber:Me,typed:J}),QO=Zx({typed:J}),KO=_y({typed:J}),jO=Y1({typed:J}),lo=oT({typed:J}),co=ky({Complex:xr,typed:J}),Rn=tw({typed:J}),e5=lA({typed:J}),r5=vA({BigNumber:Me,typed:J}),t5=hA({BigNumber:Me,typed:J}),n5=Ab({typed:J}),nr=Ay({config:ge,typed:J}),a5=bN({typed:J}),$h=Sb({typed:J}),i5=Mb({Complex:xr,typed:J}),o5=Dw({typed:J}),s5=Cw({typed:J}),Ya=MN({typed:J}),u5=Tw({typed:J}),l5=IN({format:Ya,typed:J}),Ts=aw({typed:J}),ct=K1({typed:J}),va=ly({typed:J}),fo=hy({typed:J}),Dt=gy({typed:J}),c5=MB({BigNumber:Me,config:ge}),f5=mT({Complex:xr,typed:J}),m5=ix({Complex:xr,config:ge,typed:J}),Oh=sx({Complex:xr,config:ge,typed:J}),pa=_w({typed:J}),Cr=dx({typed:J}),Ih=uw({typed:J}),pn=$y({typed:J}),v5=$N({format:Ya,typed:J}),p5=TT({config:ge,typed:J}),h5=_N({typed:J}),d5=$T({config:ge,typed:J}),Bs=ow({typed:J}),g5=bA({BigNumber:Me,typed:J}),Rh=Nx({BigNumber:Me,Fraction:In,complex:co,typed:J}),$s=DA({typed:J}),Qt=Cy({Matrix:uo,equalScalar:nr,typed:J}),y5=rb({typed:J}),b5=Cx({typed:J}),x5=Iy({typed:J}),w5=CA({typed:J}),_h=wy({typed:J}),N5=RD({Complex:xr,config:ge,typed:J}),D5=VD({BigNumber:Me,typed:J}),Os=df({isInteger:ct,typed:J}),A5=HD({BigNumber:Me,Complex:xr,config:ge,typed:J}),E5=TN({format:Ya,typed:J}),S5=uT({typed:J}),Is=sA({typed:J}),C5=gA({BigNumber:Me,typed:J}),Qa=by({typed:J}),M5=UN({typed:J}),F5=IT({config:ge,typed:J}),T5=wA({BigNumber:Me,typed:J}),B5=EA({typed:J}),$5=FD({SparseMatrix:Qt,typed:J}),It=Ex({Complex:xr,config:ge,typed:J}),O5=TA({typed:J}),Rt=nb({typed:J}),I5=PD({BigNumber:Me,Complex:xr,config:ge,typed:J}),R5=fA({BigNumber:Me,typed:J}),ha=Hy({Fraction:In,typed:J}),_n=fy({typed:J}),Te=Jy({DenseMatrix:Qe,Matrix:uo,SparseMatrix:Qt,typed:J}),_5=Wy({isZero:Dt,matrix:Te,typed:J}),q5=AN({isNaN:Qa,isNumeric:_n,typed:J}),At=VN({bignumber:Ot,fraction:ha,number:pn}),qh=SN({config:ge,multiplyScalar:Cr,numeric:At,typed:J}),z5=Gw({isInteger:ct,matrix:Te,typed:J}),Zr=eN({matrix:Te,config:ge,typed:J}),P5=tN({matrix:Te,typed:J}),it=Dm({matrix:Te,typed:J}),Ka=uN({matrix:Te,typed:J}),zh=Bx({BigNumber:Me,config:ge,matrix:Te,typed:J}),_t=mN({BigNumber:Me,config:ge,matrix:Te,typed:J}),U5=WD({Complex:xr,config:ge,typed:J}),Ph=vb({BigNumber:Me,Complex:xr,Fraction:In,config:ge,isNegative:va,matrix:Te,typed:J,unaryMinus:Rt}),ur=Wf({isInteger:ct,matrix:Te,typed:J}),L5=dw({prod:qh,size:Zr,typed:J}),Rs=cN({conj:Rn,transpose:Ka,typed:J}),Uh=xw({DenseMatrix:Qe,SparseMatrix:Qt,matrix:Te,typed:J}),Dr=HN({numeric:At,typed:J}),ja=i2({DenseMatrix:Qe,concat:ur,divideScalar:Dr,equalScalar:nr,matrix:Te,typed:J}),Et=O2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),ei=Ew({matrix:Te,typed:J}),k5=Qb({BigNumber:Me,DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),V5=vy({isNumeric:_n,typed:J}),hn=$w({BigNumber:Me,DenseMatrix:Qe,SparseMatrix:Qt,config:ge,matrix:Te,typed:J}),G5=Iw({matrix:Te,multiplyScalar:Cr,typed:J}),mo=J2({DenseMatrix:Qe,concat:ur,config:ge,matrix:Te,typed:J}),H5=g2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J,zeros:_t}),_s=jy({flatten:ei,matrix:Te,size:Zr,typed:J}),Lh=vx({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),Z5=xx({BigNumber:Me,concat:ur,equalScalar:nr,matrix:Te,typed:J}),J5=Lw({BigNumber:Me,config:ge,matrix:Te,typed:J}),X5=Jw({config:ge,matrix:Te}),W5=b2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J,zeros:_t}),vo=WN({BigNumber:Me,DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J,zeros:_t}),ft=z2({DenseMatrix:Qe,concat:ur,config:ge,matrix:Te,typed:J}),Y5=zN({concat:ur,matrix:Te,typed:J}),Q5=K2({DenseMatrix:Qe,concat:ur,config:ge,equalScalar:nr,matrix:Te,typed:J}),K5=mw({DenseMatrix:Qe,concat:ur,matrix:Te,typed:J}),wr=KA({DenseMatrix:Qe,SparseMatrix:Qt,addScalar:$r,concat:ur,equalScalar:nr,matrix:Te,typed:J}),j5=Gx({concat:ur,equalScalar:nr,matrix:Te,typed:J}),e8=Kx({DenseMatrix:Qe,concat:ur,matrix:Te,typed:J}),r8=UT({addScalar:$r,combinations:lo,divideScalar:Dr,isInteger:ct,isNegative:va,multiplyScalar:Cr,typed:J}),da=E2({BigNumber:Me,DenseMatrix:Qe,Fraction:In,concat:ur,config:ge,equalScalar:nr,matrix:Te,typed:J}),kh=B2({concat:ur,matrix:Te,typed:J}),t8=$p({add:wr,typed:J,unaryPlus:Fs}),Vh=Y2({equal:Et,typed:J}),po=aE({addScalar:$r,conj:Rn,multiplyScalar:Cr,size:Zr,typed:J}),n8=_2({compareText:kh,isZero:Dt,typed:J}),Gh=Ib({DenseMatrix:Qe,config:ge,equalScalar:nr,matrix:Te,round:vo,typed:J,zeros:_t}),a8=eE({abs:rt,addScalar:$r,divideScalar:Dr,isPositive:fo,multiplyScalar:Cr,smaller:ft,sqrt:It,typed:J}),Hh=uD({DenseMatrix:Qe,smaller:ft}),Jr=fD({ImmutableDenseMatrix:Hh}),i8=Ox({BigNumber:Me,add:wr,config:ge,equal:Et,isInteger:ct,mod:Lh,smaller:ft,typed:J,xgcd:zh}),mt=G2({DenseMatrix:Qe,concat:ur,config:ge,matrix:Te,typed:J}),qs=QN({Complex:xr,config:ge,divideScalar:Dr,typed:J}),o8=Qy({flatten:ei,matrix:Te,size:Zr,typed:J}),s8=fv({config:ge,numeric:At,smaller:ft,typed:J}),Nr=yx({addScalar:$r,dot:po,equalScalar:nr,matrix:Te,multiplyScalar:Cr,typed:J}),u8=r2({Complex:xr,config:ge,divideScalar:Dr,typed:J}),l8=cw({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),zs=rD({compare:da,isNaN:Qa,isNumeric:_n,typed:J}),c8=nT({add:wr,compare:da,multiply:Nr,partitionSelect:zs,typed:J}),f8=w2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J,zeros:_t}),Ps=L2({DenseMatrix:Qe,concat:ur,config:ge,matrix:Te,typed:J}),yr=Fx({DenseMatrix:Qe,addScalar:$r,concat:ur,equalScalar:nr,matrix:Te,typed:J,unaryMinus:Rt}),m8=sE({add:wr,matrix:Te,typed:J}),Us=l2({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J}),v8=D2({concat:ur,equalScalar:nr,matrix:Te,not:Ih,typed:J,zeros:_t}),p8=Xx({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),Ls=Nb({DenseMatrix:Qe,config:ge,equalScalar:nr,matrix:Te,round:vo,typed:J,zeros:_t}),qt=M2({compare:da,typed:J}),h8=kT({addScalar:$r,combinations:lo,isInteger:ct,isNegative:va,isPositive:fo,larger:mt,typed:J}),d8=yw({matrix:Te,multiply:Nr,subtract:yr,typed:J}),Zh=b4({divideScalar:Dr,isZero:Dt,matrix:Te,multiply:Nr,subtract:yr,typed:J,unaryMinus:Rt}),g8=cm({matrix:Te,number:pn,subtract:yr,typed:J}),y8=V4({abs:rt,addScalar:$r,divideScalar:Dr,multiplyScalar:Cr,sqrt:It,subtract:yr,typed:J,unaryMinus:Rt}),b8=qx({concat:ur,equalScalar:nr,matrix:Te,multiplyScalar:Cr,typed:J}),Jh=pD({larger:mt,smaller:ft}),Xh=Bb({Complex:xr,DenseMatrix:Qe,ceil:Ls,equalScalar:nr,floor:Gh,matrix:Te,typed:J,zeros:_t}),Wh=lE({Index:Jr,typed:J}),x8=Z4({abs:rt,add:wr,addScalar:$r,config:ge,divideScalar:Dr,equalScalar:nr,flatten:ei,isNumeric:_n,isZero:Dt,matrix:Te,multiply:Nr,multiplyScalar:Cr,smaller:ft,subtract:yr,typed:J}),w8=nx({concat:ur,equalScalar:nr,matrix:Te,typed:J}),N8=jN({Complex:xr,config:ge,divideScalar:Dr,log:qs,typed:J}),Yh=s2({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J}),Qh=lv({config:ge,larger:mt,numeric:At,typed:J}),ks=mS({addScalar:$r,complex:co,conj:Rn,divideScalar:Dr,equal:Et,identity:hn,isZero:Dt,matrix:Te,multiplyScalar:Cr,sign:Rh,sqrt:It,subtract:yr,typed:J,unaryMinus:Rt,zeros:_t}),ga=pm({bignumber:Ot,matrix:Te,config:ge,larger:mt,largerEq:mo,smaller:ft,smallerEq:Ps,typed:J}),D8=bm({Index:Jr,matrix:Te,range:ga,typed:J}),A8=$A({DenseMatrix:Qe,Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),E8=_A({DenseMatrix:Qe,Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),S8=UA({Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),C8=GA({Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),Kh=_S({SparseMatrix:Qt,abs:rt,add:wr,divideScalar:Dr,larger:mt,largerEq:mo,multiply:Nr,subtract:yr,transpose:Ka,typed:J}),jh=gD({FibonacciHeap:Jh,addScalar:$r,equalScalar:nr}),ed=Bp({add:wr,config:ge,numeric:At,typed:J}),rd=v2({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J}),M8=nA({BigNumber:Me,DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),td=Kf({Index:Jr,matrix:Te,range:ga,typed:J}),F8=f2({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J}),nd=IA({DenseMatrix:Qe,Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),T8=kA({Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),ad=XA({Index:Jr,concat:ur,setDifference:nd,size:Zr,subset:it,typed:J}),B8=nD({compare:da,compareNatural:qt,matrix:Te,typed:J}),qn=w4({abs:rt,addScalar:$r,det:Zh,divideScalar:Dr,identity:hn,matrix:Te,multiply:Nr,typed:J,unaryMinus:Rt}),id=cS({DenseMatrix:Qe,Spa:jh,SparseMatrix:Qt,abs:rt,addScalar:$r,divideScalar:Dr,equalScalar:nr,larger:mt,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J,unaryMinus:Rt}),$8=D4({Complex:xr,add:wr,ctranspose:Rs,deepEqual:Vh,divideScalar:Dr,dot:po,dotDivide:ja,equal:Et,inv:qn,matrix:Te,multiply:Nr,typed:J}),zt=JN({Complex:xr,config:ge,fraction:ha,identity:hn,inv:qn,matrix:Te,multiply:Nr,number:pn,typed:J}),od=zA({DenseMatrix:Qe,Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),O8=YA({Index:Jr,concat:ur,setIntersect:od,setSymDifference:ad,size:Zr,subset:it,typed:J}),I8=$4({abs:rt,add:wr,identity:hn,inv:qn,map:pa,max:Qh,multiply:Nr,size:Zr,sqrt:It,subtract:yr,typed:J}),Ze=ED({BigNumber:Me,Complex:xr,Fraction:In,abs:rt,addScalar:$r,config:ge,divideScalar:Dr,equal:Et,fix:Xh,format:Ya,isNumeric:_n,multiplyScalar:Cr,number:pn,pow:zt,round:vo,subtract:yr}),R8=UB({BigNumber:Me,Unit:Ze,config:ge}),_8=w$({BigNumber:Me,Unit:Ze,config:ge}),q8=l$({BigNumber:Me,Unit:Ze,config:ge}),z8=VB({BigNumber:Me,Unit:Ze,config:ge}),P8=f$({BigNumber:Me,Unit:Ze,config:ge}),U8=GB({BigNumber:Me,Unit:Ze,config:ge}),L8=BD({Unit:Ze,typed:J}),k8=t$({BigNumber:Me,Unit:Ze,config:ge}),V8=n2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,pow:zt,typed:J}),G8=PB({BigNumber:Me,Unit:Ze,config:ge}),H8=kB({BigNumber:Me,Unit:Ze,config:ge}),Z8=T4({abs:rt,add:wr,identity:hn,inv:qn,multiply:Nr,typed:J}),J8=m$({BigNumber:Me,Unit:Ze,config:ge}),sd=pN({addScalar:$r,ceil:Ls,conj:Rn,divideScalar:Dr,dotDivide:ja,exp:$h,i:Ch,log2:Oh,matrix:Te,multiplyScalar:Cr,pow:zt,tau:Fh,typed:J}),ud=cT({BigNumber:Me,Complex:xr,config:ge,multiplyScalar:Cr,pow:zt,typed:J}),X8=RB({BigNumber:Me,Unit:Ze,config:ge}),W8=e$({BigNumber:Me,Unit:Ze,config:ge}),Y8=dN({conj:Rn,dotDivide:ja,fft:sd,typed:J}),Q8=XB({BigNumber:Me,Unit:Ze,config:ge}),K8=p$({BigNumber:Me,Unit:Ze,config:ge}),j8=zB({BigNumber:Me,Unit:Ze,config:ge}),e6=N$({BigNumber:Me,Unit:Ze,config:ge}),r6=d$({BigNumber:Me,Unit:Ze,config:ge}),t6=n$({BigNumber:Me,Unit:Ze,config:ge}),n6=JB({BigNumber:Me,Unit:Ze,config:ge}),a6=M$({BigNumber:Me,Unit:Ze,config:ge}),i6=E$({BigNumber:Me,Unit:Ze,config:ge}),o6=F$({BigNumber:Me,Unit:Ze,config:ge}),s6=r$({BigNumber:Me,Unit:Ze,config:ge}),u6=qB({BigNumber:Me,Unit:Ze,config:ge}),l6=i$({BigNumber:Me,Unit:Ze,config:ge}),c6=b$({BigNumber:Me,Unit:Ze,config:ge}),f6=IB({BigNumber:Me,Unit:Ze,config:ge}),m6=x$({BigNumber:Me,Unit:Ze,config:ge}),v6=o$({BigNumber:Me,Unit:Ze,config:ge}),p6=c$({BigNumber:Me,Unit:Ze,config:ge}),h6=WB({BigNumber:Me,Unit:Ze,config:ge}),d6=LB({BigNumber:Me,Unit:Ze,config:ge}),vt=L4({divideScalar:Dr,equalScalar:nr,inv:qn,matrix:Te,multiply:Nr,typed:J}),g6=QB({BigNumber:Me,Unit:Ze,config:ge}),ho=pT({gamma:ud,typed:J}),y6=v$({BigNumber:Me,Unit:Ze,config:ge}),b6=h$({BigNumber:Me,Unit:Ze,config:ge}),x6=HB({BigNumber:Me,Unit:Ze,config:ge}),ld=zS({DenseMatrix:Qe,lsolve:Yh,lup:id,matrix:Te,slu:Kh,typed:J,usolve:Us}),w6=ZB({BigNumber:Me,Unit:Ze,config:ge}),N6=D$({BigNumber:Me,Unit:Ze,config:ge}),D6=yT({add:wr,divide:vt,factorial:ho,isInteger:ct,isPositive:fo,multiply:Nr,typed:J}),A6=xT({factorial:ho,typed:J}),E6=S$({BigNumber:Me,Unit:Ze,config:ge}),S6=US({add:wr,cbrt:Ph,divide:vt,equalScalar:nr,im:Ts,isZero:Dt,multiply:Nr,re:Bs,sqrt:It,subtract:yr,typeOf:_h,typed:J,unaryMinus:Rt}),C6=ZA({compareNatural:qt,typed:J}),cd=_T({bignumber:Ot,addScalar:$r,combinations:lo,divideScalar:Dr,factorial:ho,isInteger:ct,isNegative:va,larger:mt,multiplyScalar:Cr,number:pn,pow:zt,subtract:yr,typed:J}),M6=CD({Unit:Ze,typed:J}),F6=zT({addScalar:$r,isInteger:ct,isNegative:va,stirlingS2:cd,typed:J}),fd=M4({abs:rt,add:wr,addScalar:$r,atan:Bh,bignumber:Ot,column:td,complex:co,config:ge,cos:Is,diag:Uh,divideScalar:Dr,dot:po,equal:Et,flatten:ei,im:Ts,inv:qn,larger:mt,matrix:Te,matrixFromColumns:_s,multiply:Nr,multiplyScalar:Cr,number:pn,qr:ks,re:Bs,sin:$s,smaller:ft,sqrt:It,subtract:yr,typed:J,usolve:Us,usolveAll:rd}),T6=KB({BigNumber:Me,Unit:Ze,config:ge}),B6=A$({BigNumber:Me,Unit:Ze,config:ge}),$6=dT({divide:vt,dotDivide:ja,isNumeric:_n,log:qs,map:pa,matrix:Te,multiply:Nr,sum:ed,typed:J}),O6=Ip({add:wr,divide:vt,typed:J}),I6=g$({BigNumber:Me,Unit:Ze,config:ge}),R6=_B({BigNumber:Me,Unit:Ze,config:ge}),_6=a$({BigNumber:Me,Unit:Ze,config:ge}),Vs=zp({add:wr,apply:Os,divide:vt,isNaN:Qa,multiply:Nr,subtract:yr,typed:J}),q6=YB({BigNumber:Me,Unit:Ze,config:ge}),md=Q4({add:wr,compare:da,divide:vt,partitionSelect:zs,typed:J}),z6=C$({BigNumber:Me,Unit:Ze,config:ge}),P6=Up({map:pa,sqrt:It,typed:J,variance:Vs}),U6=j4({abs:rt,map:pa,median:md,subtract:yr,typed:J}),Gs=tE({abs:rt,add:wr,conj:Rn,ctranspose:Rs,eigs:fd,equalScalar:nr,larger:mt,matrix:Te,multiply:Nr,pow:zt,smaller:ft,sqrt:It,typed:J}),vd=Qw({BigNumber:Me,DenseMatrix:Qe,SparseMatrix:Qt,addScalar:$r,config:ge,cos:Is,matrix:Te,multiplyScalar:Cr,norm:Gs,sin:$s,typed:J,unaryMinus:Rt}),L6=Ww({multiply:Nr,rotationMatrix:vd,typed:J}),pd=_4({identity:hn,matrix:Te,multiply:Nr,norm:Gs,qr:ks,subtract:yr,typed:J}),hd=I4({abs:rt,add:wr,concat:ur,identity:hn,index:Wh,lusolve:ld,matrix:Te,matrixFromColumns:_s,multiply:Nr,range:ga,schur:pd,subset:it,subtract:yr,transpose:Ka,typed:J}),k6=z4({matrix:Te,multiply:Nr,sylvester:hd,transpose:Ka,typed:J}),ya={},ba={},dd={},Xr=mE({mathWithTransform:ba}),xa=zE({Node:Xr}),Kt=UE({Node:Xr}),zn=kE({Node:Xr}),gd=ZE({Node:Xr}),wa=dE({Node:Xr}),yd=NE({Node:Xr,ResultSet:Mh}),bd=AE({Node:Xr}),dn=$E({Node:Xr}),xd=GE({Node:Xr}),V6=mB({classes:dd}),Hs=ZS({math:ya,typed:J}),wd=IE({Node:Xr,typed:J}),G6=g4({Chain:Hs,typed:J}),Na=pE({Node:Xr,subset:it}),Da=_E({Node:Xr,size:Zr}),Nd=xE({matrix:Te,Node:Xr,subset:it}),gn=WE({Unit:Ze,Node:Xr,math:ya}),yn=QE({Node:Xr,SymbolNode:gn,math:ya}),St=jE({AccessorNode:Na,ArrayNode:wa,AssignmentNode:Nd,BlockNode:yd,ConditionalNode:bd,ConstantNode:dn,FunctionAssignmentNode:wd,FunctionNode:yn,IndexNode:Da,ObjectNode:xa,OperatorNode:Kt,ParenthesisNode:zn,RangeNode:xd,RelationalNode:gd,SymbolNode:gn,config:ge,numeric:At,typed:J}),Dd=nB({ConstantNode:dn,FunctionNode:yn,OperatorNode:Kt,ParenthesisNode:zn,parse:St,typed:J}),Zs=KT({bignumber:Ot,fraction:ha,AccessorNode:Na,ArrayNode:wa,ConstantNode:dn,FunctionNode:yn,IndexNode:Da,ObjectNode:xa,OperatorNode:Kt,SymbolNode:gn,config:ge,mathWithTransform:ba,matrix:Te,typed:J}),H6=rS({parse:St,typed:J}),Js=nS({parse:St,typed:J}),Ad=VS({parse:St}),Ed=oS({evaluate:Js}),Xs=eB({AccessorNode:Na,ArrayNode:wa,ConstantNode:dn,FunctionNode:yn,IndexNode:Da,ObjectNode:xa,OperatorNode:Kt,ParenthesisNode:zn,SymbolNode:gn,add:wr,divide:vt,equal:Et,isZero:Dt,multiply:Nr,parse:St,pow:zt,subtract:yr,typed:J}),Z6=h4({Help:Ad,mathWithTransform:ba,typed:J}),go=WT({bignumber:Ot,fraction:ha,AccessorNode:Na,ArrayNode:wa,ConstantNode:dn,FunctionNode:yn,IndexNode:Da,ObjectNode:xa,OperatorNode:Kt,ParenthesisNode:zn,SymbolNode:gn,add:wr,config:ge,divide:vt,equal:Et,isZero:Dt,mathWithTransform:ba,matrix:Te,multiply:Nr,parse:St,pow:zt,resolve:Dd,simplifyConstant:Zs,simplifyCore:Xs,subtract:yr,typed:J}),J6=iB({OperatorNode:Kt,parse:St,simplify:go,typed:J}),X6=sB({ConstantNode:dn,FunctionNode:yn,OperatorNode:Kt,ParenthesisNode:zn,SymbolNode:gn,config:ge,equal:Et,isZero:Dt,numeric:At,parse:St,simplify:go,typed:J}),W6=uS({Parser:Ed,typed:J}),Y6=GT({parse:St,typed:J}),Q6=lB({bignumber:Ot,fraction:ha,AccessorNode:Na,ArrayNode:wa,ConstantNode:dn,FunctionNode:yn,IndexNode:Da,ObjectNode:xa,OperatorNode:Kt,ParenthesisNode:zn,SymbolNode:gn,add:wr,config:ge,divide:vt,equal:Et,isZero:Dt,mathWithTransform:ba,matrix:Te,multiply:Nr,parse:St,pow:zt,simplify:go,simplifyConstant:Zs,simplifyCore:Xs,subtract:yr,typed:J});Sr(ya,{e:Sh,false:SO,fineStructure:CO,i:Ch,Infinity:MO,LN10:FO,LOG10E:TO,NaN:BO,null:$O,phi:OO,SQRT1_2:RO,sackurTetrode:_O,tau:Fh,true:qO,E:Sh,version:zO,efimovFactor:PO,LN2:UO,pi:Th,replacer:LO,reviver:V6,SQRT2:kO,typed:J,unaryPlus:Fs,PI:Th,weakMixingAngle:VO,abs:rt,acos:GO,acot:HO,acsc:ZO,addScalar:$r,arg:JO,asech:XO,asinh:WO,atan:Bh,atanh:YO,bignumber:Ot,bitNot:QO,boolean:KO,clone:jO,combinations:lo,complex:co,conj:Rn,cosh:e5,coth:r5,csc:t5,cube:n5,equalScalar:nr,erf:a5,exp:$h,expm1:i5,filter:o5,forEach:s5,format:Ya,getMatrixDataType:u5,hex:l5,im:Ts,isInteger:ct,isNegative:va,isPositive:fo,isZero:Dt,LOG2E:c5,lgamma:f5,log10:m5,log2:Oh,map:pa,multiplyScalar:Cr,not:Ih,number:pn,oct:v5,pickRandom:p5,print:h5,random:d5,re:Bs,sec:g5,sign:Rh,sin:$s,splitUnit:y5,square:b5,string:x5,tan:w5,typeOf:_h,acosh:N5,acsch:D5,apply:Os,asec:A5,bin:E5,chain:G6,combinationsWithRep:S5,cos:Is,csch:C5,isNaN:Qa,isPrime:M5,randomInt:F5,sech:T5,sinh:B5,sparse:$5,sqrt:It,tanh:O5,unaryMinus:Rt,acoth:I5,cot:R5,fraction:ha,isNumeric:_n,matrix:Te,matrixFromFunction:_5,mode:q5,numeric:At,prod:qh,reshape:z5,size:Zr,squeeze:P5,subset:it,transpose:Ka,xgcd:zh,zeros:_t,asin:U5,cbrt:Ph,concat:ur,count:L5,ctranspose:Rs,diag:Uh,divideScalar:Dr,dotDivide:ja,equal:Et,flatten:ei,gcd:k5,hasNumericValue:V5,identity:hn,kron:G5,largerEq:mo,leftShift:H5,matrixFromColumns:_s,mod:Lh,nthRoot:Z5,ones:J5,resize:X5,rightArithShift:W5,round:vo,smaller:ft,to:Y5,unequal:Q5,xor:K5,add:wr,bitAnd:j5,bitXor:e8,catalan:r8,compare:da,compareText:kh,cumsum:t8,deepEqual:Vh,dot:po,equalText:n8,floor:Gh,hypot:a8,invmod:i8,larger:mt,log:qs,matrixFromRows:o8,min:s8,multiply:Nr,nthRoots:u8,or:l8,partitionSelect:zs,quantileSeq:c8,rightLogShift:f8,smallerEq:Ps,subtract:yr,trace:m8,usolve:Us,and:v8,bitOr:p8,ceil:Ls,compareNatural:qt,composition:h8,cross:d8,det:Zh,diff:g8,distance:y8,dotMultiply:b8,fix:Xh,index:Wh,intersect:x8,lcm:w8,log1p:N8,lsolve:Yh,max:Qh,qr:ks,range:ga,row:D8,setCartesian:A8,setDistinct:E8,setIsSubset:S8,setPowerset:C8,slu:Kh,sum:ed,usolveAll:rd,atan2:M8,column:td,lsolveAll:F8,setDifference:nd,setMultiplicity:T8,setSymDifference:ad,sort:B8,inv:qn,lup:id,pinv:$8,pow:zt,setIntersect:od,setUnion:O8,sqrtm:I8,vacuumImpedance:R8,wienDisplacement:_8,atomicMass:q8,bohrMagneton:z8,boltzmann:P8,conductanceQuantum:U8,createUnit:L8,deuteronMass:k8,dotPow:V8,electricConstant:G8,elementaryCharge:H8,expm:Z8,faraday:J8,fft:sd,gamma:ud,gravitationConstant:X8,hartreeEnergy:W8,ifft:Y8,klitzing:Q8,loschmidt:K8,magneticConstant:j8,molarMass:e6,molarPlanckConstant:r6,neutronMass:t6,nuclearMagneton:n6,planckCharge:a6,planckLength:i6,planckTemperature:o6,protonMass:s6,reducedPlanckConstant:u6,rydberg:l6,secondRadiation:c6,speedOfLight:f6,stefanBoltzmann:m6,thomsonCrossSection:v6,avogadro:p6,bohrRadius:h6,coulomb:d6,divide:vt,electronMass:g6,factorial:ho,firstRadiation:y6,gasConstant:b6,inverseConductanceQuantum:x6,lusolve:ld,magneticFluxQuantum:w6,molarMassC12:N6,multinomial:D6,permutations:A6,planckMass:E6,polynomialRoot:S6,setSize:C6,stirlingS2:cd,unit:M6,bellNumbers:F6,eigs:fd,fermiCoupling:T6,gravity:B6,kldivergence:$6,mean:O6,molarVolume:I6,planckConstant:R6,quantumOfCirculation:_6,variance:Vs,classicalElectronRadius:q6,median:md,parse:St,planckTime:z6,resolve:Dd,simplifyConstant:Zs,std:P6,compile:H6,evaluate:Js,mad:U6,simplifyCore:Xs,help:Z6,norm:Gs,rotationMatrix:vd,simplify:go,symbolicEqual:J6,derivative:X6,parser:W6,rotate:L6,leafCount:Y6,rationalize:Q6,schur:pd,sylvester:hd,lyap:k6,config:ge}),Sr(ba,ya,{filter:z$({typed:J}),forEach:L$({typed:J}),map:J$({typed:J}),apply:$$({isInteger:ct,typed:J}),subset:fO({matrix:Te,typed:J}),concat:pO({isInteger:ct,matrix:Te,typed:J}),max:Y$({config:ge,larger:mt,numeric:At,typed:J}),sum:wO({add:wr,config:ge,numeric:At,typed:J}),min:tO({config:ge,numeric:At,smaller:ft,typed:J}),cumsum:DO({add:wr,typed:J,unaryPlus:Fs}),diff:dO({bignumber:Ot,matrix:Te,number:pn,subtract:yr,typed:J}),index:G$({Index:Jr}),range:iO({bignumber:Ot,matrix:Te,config:ge,larger:mt,largerEq:mo,smaller:ft,smallerEq:Ps,typed:J}),row:uO({Index:Jr,matrix:Te,range:ga,typed:J}),column:R$({Index:Jr,matrix:Te,range:ga,typed:J}),mean:j$({add:wr,divide:vt,typed:J}),variance:EO({add:wr,apply:Os,divide:vt,isNaN:Qa,multiply:Nr,subtract:yr,typed:J}),std:bO({map:pa,sqrt:It,typed:J,variance:Vs})}),Sr(dd,{BigNumber:Me,Complex:xr,Fraction:In,Matrix:uo,Node:Xr,ObjectNode:xa,OperatorNode:Kt,ParenthesisNode:zn,Range:IO,RelationalNode:gd,ResultSet:Mh,ArrayNode:wa,BlockNode:yd,ConditionalNode:bd,ConstantNode:dn,DenseMatrix:Qe,RangeNode:xd,Chain:Hs,FunctionAssignmentNode:wd,SparseMatrix:Qt,AccessorNode:Na,IndexNode:Da,AssignmentNode:Nd,ImmutableDenseMatrix:Hh,Index:Jr,FibonacciHeap:Jh,Spa:jh,Unit:Ze,SymbolNode:gn,FunctionNode:yn,Help:Ad,Parser:Ed}),Hs.createProxy(ya);/**
|
|
72
72
|
* @dice-roller/rpg-dice-roller - An advanced JS based dice roller that can roll various types of dice and modifiers, along with mathematical equations.
|
|
73
73
|
*
|
|
74
|
-
* @version 5.
|
|
74
|
+
* @version 5.5.0
|
|
75
75
|
* @license MIT
|
|
76
|
-
* @author GreenImp Media <info@greenimp.co.uk> (
|
|
76
|
+
* @author GreenImp Media <info@greenimp.co.uk> (https://greenimp.co.uk)
|
|
77
77
|
* @link https://dice-roller.github.io/documentation
|
|
78
|
-
*/class Ws extends TypeError{constructor(e){super(`Operator "${e}" is invalid`),TypeError.captureStackTrace&&TypeError.captureStackTrace(this,Ws),this.name="CompareOperatorError",this.operator=e}}class Ys extends Error{constructor(e){super(`Invalid data format: ${e}`),Error.captureStackTrace&&Error.captureStackTrace(this,Ys),this.name="ImportError",this.data=e}}class ei extends Error{constructor(e,t=null){super(`Die "${e}" must have more than 1 possible value to ${t||"do this action"}`),Error.captureStackTrace&&Error.captureStackTrace(this,ei),this.name="DieActionValueError",this.action=t,this.die=e}}class yo extends Error{constructor(e){super(`Notation "${e}" is invalid`),Error.captureStackTrace&&Error.captureStackTrace(this,yo),this.name="NotationError",this.notation=e}}class zt extends Error{constructor(e=null){super(`Missing argument${e?` "${e}"`:""}`),Error.captureStackTrace&&Error.captureStackTrace(this,zt),this.argumentName=e}}const G6=(r,e,t)=>{const a=Number(r),n=Number(e);let i;if(Number.isNaN(a)||Number.isNaN(n))return!1;switch(t){case"=":case"==":i=a===n;break;case"<":i=a<n;break;case">":i=a>n;break;case"<=":i=a<=n;break;case">=":i=a>=n;break;case"!":case"!=":case"<>":i=a!==n;break;default:i=!1;break}return i},Ad=r=>Js(r),Mr=r=>typeof r!="number"&&typeof r!="string"?!1:!Number.isNaN(r)&&Number.isFinite(Number(r)),Qs=r=>{if(!Mr(r))return!1;const e=Number(r);return e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER},H6=r=>Array.isArray(r)?r.reduce((e,t)=>e+(Mr(t)?parseFloat(`${t}`):0),0):0,Z6=(r,e=0)=>parseFloat(parseFloat(`${r}`).toFixed(e||0)),Rr=9007199254740992,ri=Rr-1,bo=-1>>>0,vt=bo+1,Kt=vt/2,Ks=Kt-1,ti=1<<21,zn=ti-1;function js(r){return r.next()|0}function gn(r,e){return e===0?r:t=>r(t)+e}function eu(r){const e=r.next()|0,t=r.next()>>>0;return(e&zn)*vt+t+(e&ti?-Rr:0)}function Ed(r){for(;;){const e=r.next()|0;if(e&4194304){if((e&8388607)===4194304&&(r.next()|0)===0)return Rr}else{const t=r.next()>>>0;return(e&zn)*vt+t+(e&ti?-Rr:0)}}}function Sd(r){return r.next()>>>0}function xo(r){const e=r.next()&zn,t=r.next()>>>0;return e*vt+t}function ru(r){for(;;){const e=r.next()|0;if(e&ti){if((e&zn)===0&&(r.next()|0)===0)return Rr}else{const t=r.next()>>>0;return(e&zn)*vt+t}}}function Cd(r){return(r+1&r)===0}function J6(r){return e=>e.next()&r}function X6(r){const e=r+1,t=e*Math.floor(vt/e);return a=>{let n=0;do n=a.next()>>>0;while(n>=t);return n%e}}function W6(r){return Cd(r)?J6(r):X6(r)}function Y6(r){return(r|0)===0}function Q6(r){return e=>{const t=e.next()&r,a=e.next()>>>0;return t*vt+a}}function K6(r){const e=r*Math.floor(Rr/r);return t=>{let a=0;do{const n=t.next()&zn,i=t.next()>>>0;a=n*vt+i}while(a>=e);return a%r}}function j6(r){const e=r+1;if(Y6(e)){const t=(e/vt|0)-1;if(Cd(t))return Q6(t)}return K6(e)}function Md(r,e){return t=>{let a=0;do{const n=t.next()|0,i=t.next()>>>0;a=(n&zn)*vt+i+(n&ti?-Rr:0)}while(a<r||a>e);return a}}function Pn(r,e){if(r=Math.floor(r),e=Math.floor(e),r<-Rr||!isFinite(r))throw new RangeError(`Expected min to be at least ${-Rr}`);if(e>Rr||!isFinite(e))throw new RangeError(`Expected max to be at most ${Rr}`);const t=e-r;return t<=0||!isFinite(t)?()=>r:t===bo?r===0?Sd:gn(js,r+Kt):t<bo?gn(W6(t),r):t===ri?gn(xo,r):t<ri?gn(j6(t),r):e-1-r===ri?gn(ru,r):r===-Rr&&e===Rr?Ed:r===-Rr&&e===ri?eu:r===-ri&&e===Rr?gn(eu,1):e===Rr?gn(Md(r-1,e-1),1):Md(r,e)}function e9(r){return(r.next()&1)===1}function tu(r,e){return t=>r(t)<e}function r9(r){if(r<=0)return()=>!1;if(r>=1)return()=>!0;{const e=r*vt;return e%1===0?tu(js,e-Kt|0):tu(xo,Math.round(r*Rr))}}function t9(r,e){return e==null?r==null?e9:r9(r):r<=0?()=>!1:r>=e?()=>!0:tu(Pn(0,e-1),r)}function n9(r,e){const t=Pn(+r,+e);return a=>new Date(t(a))}function Fd(r){return Pn(1,r)}function a9(r,e){const t=Fd(r);return a=>{const n=[];for(let i=0;i<e;++i)n.push(t(a));return n}}const i9="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-";function nu(r=i9){const e=r.length;if(!e)throw new Error("Expected pool not to be an empty string");const t=Pn(0,e-1);return(a,n)=>{let i="";for(let o=0;o<n;++o){const f=t(a);i+=r.charAt(f)}return i}}const Td="0123456789abcdef",o9=nu(Td),s9=nu(Td.toUpperCase());function u9(r){return r?s9:o9}function Bd(r,e){return r<0?Math.max(r+e,0):Math.min(r,e)}function $d(r){const e=+r;return e<0?Math.ceil(e):Math.floor(e)}function l9(r,e,t,a){const n=e.length;if(n===0)throw new RangeError("Cannot pick from an empty array");const i=t==null?0:Bd($d(t),n),o=a===void 0?n:Bd($d(a),n);if(i>=o)throw new RangeError(`Cannot pick between bounds ${i} and ${o}`);const f=Pn(i,o-1);return e[f(r)]}function c9(r,e){return e===1?r:e===0?()=>0:t=>r(t)*e}function Od(r){return xo(r)/Rr}function Id(r){return ru(r)/Rr}function f9(r,e,t=!1){if(isFinite(r)){if(!isFinite(e))throw new RangeError("Expected max to be a finite number")}else throw new RangeError("Expected min to be a finite number");return gn(c9(t?Id:Od,e-r),r)}const m9=Array.prototype.slice;function au(r,e,t=0){const a=e.length;if(a)for(let n=a-1>>>0;n>t;--n){const o=Pn(0,n)(r);if(n!==o){const f=e[n];e[n]=e[o],e[o]=f}}return e}function v9(r,e,t){if(t<0||t>e.length||!isFinite(t))throw new RangeError("Expected sampleSize to be within 0 and the length of the population");if(t===0)return[];const a=m9.call(e),n=a.length;if(n===t)return au(r,a,0);const i=n-t;return au(r,a,i-1).slice(i)}const p9=(()=>{try{if("x".repeat(3)==="xxx")return(r,e)=>r.repeat(e)}catch{}return(r,e)=>{let t="";for(;e>0;)e&1&&(t+=r),e>>=1,r+=r;return t}})();function Da(r,e){return p9("0",e-r.length)+r}function h9(r){const e=r.next()>>>0,t=r.next()|0,a=r.next()|0,n=r.next()>>>0;return Da(e.toString(16),8)+"-"+Da((t&65535).toString(16),4)+"-"+Da((t>>4&4095|16384).toString(16),4)+"-"+Da((a&16383|32768).toString(16),4)+"-"+Da((a>>4&65535).toString(16),4)+Da(n.toString(16),8)}const Aa={next(){return Math.random()*vt|0}};class d9{constructor(e=Aa){this.engine=e}int32(){return js(this.engine)}uint32(){return Sd(this.engine)}uint53(){return xo(this.engine)}uint53Full(){return ru(this.engine)}int53(){return eu(this.engine)}int53Full(){return Ed(this.engine)}integer(e,t){return Pn(e,t)(this.engine)}realZeroToOneInclusive(){return Id(this.engine)}realZeroToOneExclusive(){return Od(this.engine)}real(e,t,a=!1){return f9(e,t,a)(this.engine)}bool(e,t){return t9(e,t)(this.engine)}pick(e,t,a){return l9(this.engine,e,t,a)}shuffle(e){return au(this.engine,e)}sample(e,t){return v9(this.engine,e,t)}die(e){return Fd(e)(this.engine)}dice(e,t){return a9(e,t)(this.engine)}uuid4(){return h9(this.engine)}string(e,t){return nu(t)(this.engine,e)}hex(e,t){return u9(t)(this.engine,e)}date(e,t){return n9(e,t)(this.engine)}}const Rd=(()=>{try{const r=new ArrayBuffer(4),e=new Int32Array(r);if(e[0]=Kt,e[0]===-Kt)return Int32Array}catch{}return Array})();let wo=null;const iu=128;let ou=iu;const g9={next(){return ou>=iu&&(wo===null&&(wo=new Rd(iu)),crypto.getRandomValues(wo),ou=0),wo[ou++]|0}};function y9(r=Aa,e=16){const t=[];t.push(new Date().getTime()|0);for(let a=1;a<e;++a)t[a]=r.next()|0;return t}const su=(()=>{try{if(Math.imul(bo,5)===-5)return Math.imul}catch{}const r=65535;return(e,t)=>{const a=e>>>16&r,n=e&r,i=t>>>16&r,o=t&r;return n*o+(a*o+n*i<<16>>>0)|0}})(),Pt=624,yn=Pt-1,uu=397,_d=Pt-uu,lu=2567483615;class ni{constructor(){this.data=new Rd(Pt),this.index=0,this.uses=0}static seed(e){return new ni().seed(e)}static seedWithArray(e){return new ni().seedWithArray(e)}static autoSeed(){return ni.seedWithArray(y9())}next(){(this.index|0)>=Pt&&(cu(this.data),this.index=0);const e=this.data[this.index];return this.index=this.index+1|0,this.uses+=1,b9(e)|0}getUseCount(){return this.uses}discard(e){if(e<=0)return this;for(this.uses+=e,(this.index|0)>=Pt&&(cu(this.data),this.index=0);e+this.index>Pt;)e-=Pt-this.index,cu(this.data),this.index=0;return this.index=this.index+e|0,this}seed(e){let t=0;this.data[0]=t=e|0;for(let a=1;a<Pt;a=a+1|0)this.data[a]=t=su(t^t>>>30,1812433253)+a|0;return this.index=Pt,this.uses=0,this}seedWithArray(e){return this.seed(19650218),x9(this.data,e),this}}function cu(r){let e=0,t=0;for(;(e|0)<_d;e=e+1|0)t=r[e]&Kt|r[e+1|0]&Ks,r[e]=r[e+uu|0]^t>>>1^(t&1?lu:0);for(;(e|0)<yn;e=e+1|0)t=r[e]&Kt|r[e+1|0]&Ks,r[e]=r[e-_d|0]^t>>>1^(t&1?lu:0);t=r[yn]&Kt|r[0]&Ks,r[yn]=r[uu-1]^t>>>1^(t&1?lu:0)}function b9(r){return r^=r>>>11,r^=r<<7&2636928640,r^=r<<15&4022730752,r^r>>>18}function x9(r,e){let t=1,a=0;const n=e.length;let i=Math.max(n,Pt)|0,o=r[0]|0;for(;(i|0)>0;--i)r[t]=o=(r[t]^su(o^o>>>30,1664525))+(e[a]|0)+(a|0)|0,t=t+1|0,++a,(t|0)>yn&&(r[0]=r[yn],t=1),a>=n&&(a=0);for(i=yn;(i|0)>0;--i)r[t]=o=(r[t]^su(o^o>>>30,1566083941))-t|0,t=t+1|0,(t|0)>yn&&(r[0]=r[yn],t=1);r[0]=Kt}let qd=null;const fu=128;let mu=fu;const w9={next(){return mu>=fu&&(qd=new Int32Array(new Int8Array(require("crypto").randomBytes(4*fu)).buffer),mu=0),qd[mu++]|0}},ai=Symbol("engine"),vu=Symbol("random"),zd={browserCrypto:g9,nodeCrypto:w9,MersenneTwister19937:ni,nativeMath:Aa,min:{next(){return 0}},max:{range:[],next(){return this.range[1]-this.range[0]}}};class N9{constructor(e=Aa){this.engine=e||Aa}get engine(){return this[ai]}set engine(e){if(e&&typeof e.next!="function")throw new TypeError("engine must have function `next()`");this[ai]=e||Aa,this[vu]=new d9(this[ai])}integer(e,t){return this[ai].range=[e,t],this[vu].integer(e,t)}real(e,t,a=!1){return this[ai].range=[e,t],this[vu].real(e,t,a)}}const Ea=new N9,Pd=Symbol("operator"),Ud=Symbol("value");class ii{constructor(e,t){if(e){if(!t&&t!==0)throw new zt("value")}else throw new zt("operator");this.operator=e,this.value=t}static isValidOperator(e){return typeof e=="string"&&/^(?:[<>!]?=|[<>]|<>)$/.test(e)}set operator(e){if(!this.constructor.isValidOperator(e))throw new Ws(e);this[Pd]=e}get operator(){return this[Pd]}set value(e){if(!Mr(e))throw new TypeError("value must be a finite number");this[Ud]=Number(e)}get value(){return this[Ud]}isMatch(e){return G6(e,this.value,this.operator)}toJSON(){const{operator:e,value:t}=this;return{operator:e,type:"compare-point",value:t}}toString(){return`${this.operator}${this.value}`}}class bn{constructor(){this.order=999}get name(){return"modifier"}get notation(){return""}get maxIterations(){return 1e3}run(e,t){return e}toJSON(){const{notation:e,name:t}=this;return{name:t,notation:e,type:"modifier"}}toString(){return this.notation}}const Ld=Symbol("compare-point");class Sa extends bn{constructor(e){super(),e&&(this.comparePoint=e)}get comparePoint(){return this[Ld]}set comparePoint(e){if(!(e instanceof ii))throw new TypeError("comparePoint must be instance of ComparePoint");this[Ld]=e}get name(){return"comparison"}get notation(){return`${this.comparePoint||""}`}isComparePoint(e){return this.comparePoint?this.comparePoint.isMatch(e):!1}toJSON(){const{comparePoint:e}=this;return Object.assign(super.toJSON(),{comparePoint:e})}}const kd=Symbol("compound"),Vd=Symbol("penetrate");class Gd extends Sa{constructor(e=null,t=!1,a=!1){super(e),this[kd]=!!t,this[Vd]=!!a,this.order=3}get compound(){return this[kd]}get name(){return"explode"}get notation(){return`!${this.compound?"!":""}${this.penetrate?"p":""}${super.notation}`}get penetrate(){return this[Vd]}run(e,t){if(t.min===t.max)throw new ei(t,"explode");const a=e;return a.rolls=e.rolls.map(n=>{const i=[n];let o=n.value;for(let f=0;f<this.maxIterations&&this.isComparePoint(o);f++){const l=i[i.length-1],u=t.rollOnce();o=u.value,l.modifiers.add("explode"),this.penetrate&&(l.modifiers.add("penetrate"),u.value-=1),i.push(u)}return this.compound&&i.length>1?(n.value=H6(i.map(f=>f.value)),n.modifiers=["explode","compound"],this.penetrate&&n.modifiers.add("penetrate"),n):i}).flat(),a}toJSON(){const{compound:e,penetrate:t}=this;return Object.assign(super.toJSON(),{compound:e,penetrate:t})}}const Hd=Symbol("text"),Zd=Symbol("type");class St{constructor(e,t=this.constructor.types.INLINE){this.text=e,this.type=t}get text(){return this[Hd]}set text(e){if(typeof e=="object")throw new TypeError("Description text is invalid");if(!e&&e!==0||`${e}`.trim()==="")throw new TypeError("Description text cannot be empty");this[Hd]=`${e}`.trim()}get type(){return this[Zd]}set type(e){const t=Object.values(this.constructor.types);if(typeof e!="string")throw new TypeError("Description type must be a string");if(!t.includes(e))throw new RangeError(`Description type must be one of; ${t.join(", ")}`);this[Zd]=e}toJSON(){const{text:e,type:t}=this;return{text:e,type:t}}toString(){return this.type===this.constructor.types.INLINE?`# ${this.text}`:`[${this.text}]`}}S0(St,"types",{MULTILINE:"multiline",INLINE:"inline"});const No=Symbol("description");class Jd{constructor(e=null){this.description=e}get description(){return this[No]||null}set description(e){if(!e&&e!==0)this[No]=null;else if(e instanceof St)this[No]=e;else if(typeof e=="string")this[No]=new St(e);else throw new TypeError(`description must be of type Description, string or null. Received ${typeof e}`)}toJSON(){const{description:e}=this;return{description:e}}toString(){return this.description?`${this.description}`:""}}const D9={compound:"!",explode:"!","critical-failure":"__","critical-success":"**",drop:"d",max:"v",min:"^",penetrate:"p","re-roll":"r","re-roll-once":"ro","target-failure":"_","target-success":"*",unique:"u","unique-once":"uo"},Xd=(...r)=>[...r].reduce((e,t)=>{let a;return t instanceof bn?a=t.name:a=t,e+(D9[a]||a)},""),pu=Symbol("calculation-value"),hu=Symbol("modifiers"),oi=Symbol("initial-value"),Wd=Symbol("use-in-total"),du=Symbol("value");class Do{constructor(e,t=[],a=!0){if(Mr(e))this[oi]=Number(e),this.modifiers=t||[],this.useInTotal=a;else if(e&&typeof e=="object"&&!Array.isArray(e)){const n=Mr(e.initialValue)?e.initialValue:e.value;if(!Mr(n))throw new TypeError(`Result value is invalid: ${n}`);this[oi]=Number(n),Mr(e.value)&&Number(e.value)!==this[oi]&&(this.value=e.value),Mr(e.calculationValue)&&parseFloat(`${e.calculationValue}`)!==this.value&&(this.calculationValue=e.calculationValue),this.modifiers=e.modifiers||t||[],this.useInTotal=typeof e.useInTotal=="boolean"?e.useInTotal:a||!1}else throw e===1/0?new RangeError("Result value must be a finite number"):new TypeError(`Result value is invalid: ${e}`)}get calculationValue(){return Mr(this[pu])?parseFloat(this[pu]):this.value}set calculationValue(e){const t=Mr(e);if(e===1/0)throw new RangeError("Result calculation value must be a finite number");if(e&&!t)throw new TypeError(`Result calculation value is invalid: ${e}`);this[pu]=t?parseFloat(`${e}`):null}get initialValue(){return this[oi]}get modifierFlags(){return Xd(...this.modifiers)}get modifiers(){return this[hu]}set modifiers(e){if((Array.isArray(e)||e instanceof Set)&&[...e].every(t=>typeof t=="string")){this[hu]=new Set([...e]);return}if(!e&&e!==0){this[hu]=new Set;return}throw new TypeError(`modifiers must be a Set or array of modifier names: ${e}`)}get useInTotal(){return!!this[Wd]}set useInTotal(e){this[Wd]=!!e}get value(){return Mr(this[du])?this[du]:this[oi]}set value(e){if(e===1/0)throw new RangeError("Result value must be a finite number");if(!Mr(e))throw new TypeError(`Result value is invalid: ${e}`);this[du]=Number(e)}toJSON(){const{calculationValue:e,initialValue:t,modifierFlags:a,modifiers:n,useInTotal:i,value:o}=this;return{calculationValue:e,initialValue:t,modifierFlags:a,modifiers:[...n],type:"result",useInTotal:i,value:o}}toString(){return this.value+this.modifierFlags}}const gu=Symbol("rolls");class jt{constructor(e=[]){this.rolls=e}get length(){return this.rolls.length||0}get rolls(){return[...this[gu]]}set rolls(e){if(!e||!Array.isArray(e))throw new TypeError(`rolls must be an array: ${e}`);this[gu]=[],e.forEach(t=>{this.addRoll(t)})}get value(){return this.rolls.reduce((e,t)=>e+(t.useInTotal?t.calculationValue:0),0)}addRoll(e){const t=e instanceof Do?e:new Do(e);this[gu].push(t)}toJSON(){const{rolls:e,value:t}=this;return{rolls:e,type:"roll-results",value:t}}toString(){return`[${this.rolls.join(", ")}]`}}const Yd=Symbol("once");class Qd extends Sa{constructor(e=!1,t=null){super(t),this.once=!!e,this.order=4}get name(){return"re-roll"}get notation(){return`r${this.once?"o":""}${super.notation}`}get once(){return!!this[Yd]}set once(e){this[Yd]=!!e}run(e,t){if(t.min===t.max)throw new ei(t,"re-roll");return e.rolls.map(a=>{for(let n=0;n<this.maxIterations&&this.isComparePoint(a.value);n++){const i=t.rollOnce();if(a.value=i.value,a.modifiers.add(`re-roll${this.once?"-once":""}`),this.once)break}return a}),e}toJSON(){const{once:e}=this;return Object.assign(super.toJSON(),{once:e})}}const Ao=Symbol("modifiers"),Kd=Symbol("qty"),jd=Symbol("sides"),e0=Symbol("min-value"),r0=Symbol("max-value");class Ca extends Jd{constructor(e,t=1,a=null,n=1,i=null,o=null){if(super(o),!e&&e!==0)throw new zt("sides");if(e===1/0)throw new RangeError("numerical sides must be finite number");if(Mr(e)){if(e<1||!Qs(e))throw new RangeError("numerical sides must be a positive finite number")}else if(typeof e!="string")throw new TypeError("non-numerical sides must be a string");if(Mr(t)){if(t<1||t>999)throw new RangeError("qty must be between 1 and 999")}else throw new TypeError("qty must be a positive finite integer");let f=n;if(f==null)f=1;else if(Mr(f)){if(!Qs(f))throw new RangeError("min must a finite number")}else throw new TypeError("min must a finite number");if(i&&!Mr(i))throw new TypeError("max must a finite number");if(i&&!Qs(i))throw new RangeError("max must a finite number");this[Kd]=parseInt(`${t}`,10),this[jd]=e,a&&(this.modifiers=a),this[e0]=parseInt(f,10),this[r0]=i?parseInt(`${i}`,10):e}get average(){return(this.min+this.max)/2}get modifiers(){return this[Ao]?new Map([...this[Ao]].sort((e,t)=>e[1].order-t[1].order)):null}set modifiers(e){let t;if(e instanceof Map)t=e;else if(Array.isArray(e))t=new Map(e.map(a=>[a.name,a]));else if(typeof e=="object")t=new Map(Object.entries(e));else throw new TypeError("modifiers should be a Map, array, or an Object containing Modifiers");if(t.size&&[...t.entries()].some(a=>!(a[1]instanceof bn)))throw new TypeError("modifiers must only contain Modifier instances");this[Ao]=t,this[Ao].forEach(a=>{a instanceof Gd&&!a.comparePoint?a.comparePoint=new ii("=",this.max):a instanceof Qd&&!a.comparePoint&&(a.comparePoint=new ii("=",this.min))})}get max(){return this[r0]}get min(){return this[e0]}get name(){return"standard"}get notation(){let e=`${this.qty}d${this.sides}`;return this.modifiers&&this.modifiers.size&&(e+=[...this.modifiers.values()].reduce((t,a)=>t+a.notation,"")),e}get qty(){return this[Kd]}get sides(){return this[jd]}roll(){const e=new jt;for(let t=0;t<this.qty;t++)e.addRoll(this.rollOnce());return(this.modifiers||[]).forEach(t=>{t.run(e,this)}),e}rollOnce(){return new Do(Ea.integer(this.min,this.max))}toJSON(){const{average:e,max:t,min:a,modifiers:n,name:i,notation:o,qty:f,sides:l}=this;return Object.assign(super.toJSON(),{average:e,max:t,min:a,modifiers:n,name:i,notation:o,qty:f,sides:l,type:"die"})}toString(){return`${this.notation}${this.description?` ${this.description}`:""}`}}class A9 extends Ca{constructor(e=2,t=1,a=null,n=null){let i=e;if(!i&&i!==0)i=2;else if(i!==1&&i!==2)throw new RangeError("nonBlanks must be 1 or 2");super(i,t,a,-1,1,n)}get name(){return"fudge"}get nonBlanks(){return super.sides}get sides(){return`F.${this.nonBlanks}`}rollOnce(){let e=0;if(this.nonBlanks===2)e=Ea.integer(1,3)-2;else if(this.nonBlanks===1){const t=Ea.integer(1,6);t===1?e=-1:t===6&&(e=1)}return new Do(e)}}class E9 extends Ca{constructor(e=1,t=null,a=!1,n=null){super(100,e,t,null,null,n),this.sidesAsNumber=!!a}get name(){return"percentile"}get sides(){return this.sidesAsNumber?super.sides:"%"}}class S9 extends Sa{constructor(e){super(e),this.order=10}get name(){return"critical-failure"}get notation(){return`cf${super.notation}`}run(e,t){return e.rolls.forEach(a=>(this.isComparePoint(a.value)&&a.modifiers.add("critical-failure"),a)),e}}class C9 extends Sa{constructor(e){super(e),this.order=9}get name(){return"critical-success"}get notation(){return`cs${super.notation}`}run(e,t){return e.rolls.forEach(a=>(this.isComparePoint(a.value)&&a.modifiers.add("critical-success"),a)),e}}const yu=Symbol("calculation-value"),t0=Symbol("is-roll-group"),bu=Symbol("modifiers"),xu=Symbol("results"),n0=Symbol("use-in-total");class kr{constructor(e=[],t=[],a=!1,n=!0){this.isRollGroup=a,this.modifiers=t,this.results=e,this.useInTotal=n}get calculationValue(){return Mr(this[yu])?parseFloat(this[yu]):this.value}set calculationValue(e){const t=Mr(e);if(e===1/0)throw new RangeError("Results calculation value must be a finite number");if(e&&!t)throw new TypeError(`Results calculation value is invalid: ${e}`);this[yu]=t?parseFloat(`${e}`):null}get isRollGroup(){return this[t0]}set isRollGroup(e){this[t0]=!!e}get length(){return this.results.length||0}get modifierFlags(){return Xd(...this.modifiers)}get modifiers(){return this[bu]}set modifiers(e){if((Array.isArray(e)||e instanceof Set)&&[...e].every(t=>typeof t=="string"))this[bu]=new Set([...e]);else if(!e&&e!==0)this[bu]=new Set;else throw new TypeError(`modifiers must be a Set or array of modifier names: ${e}`)}get results(){return[...this[xu]]}set results(e){if(!e||!Array.isArray(e))throw new TypeError(`results must be an array: ${e}`);this[xu]=[],e.forEach(t=>{this.addResult(t)})}get useInTotal(){return!!this[n0]}set useInTotal(e){this[n0]=!!e}get value(){if(!this.results.length)return 0;const e=this.results.reduce((t,a)=>{let n=a;return a instanceof kr?n=a.useInTotal?a.calculationValue:0:a instanceof jt&&(n=a.value),t+n},typeof this.results[0]=="string"?"":0);return typeof e=="string"?Ad(e):e}addResult(e){let t;if(e instanceof kr||e instanceof jt)t=e;else if(typeof e=="string"||Mr(e))t=e;else throw new TypeError("value must be one of ResultGroup, RollResults, string, or number");this[xu].push(t)}toJSON(){const{calculationValue:e,isRollGroup:t,modifierFlags:a,modifiers:n,results:i,useInTotal:o,value:f}=this;return{calculationValue:e,isRollGroup:t,modifierFlags:a,modifiers:[...n],results:i,type:"result-group",useInTotal:o,value:f}}toString(){let e;return this.isRollGroup?e=`{${this.results.join(", ")}}`:e=this.results.join(""),this.modifierFlags&&(e=`(${e})${this.modifierFlags}`),e}}const a0=Symbol("end"),i0=Symbol("qty");class o0 extends bn{constructor(e="h",t=1){super(),this.end=e,this.qty=t,this.order=6}get end(){return this[a0]}set end(e){if(e!=="h"&&e!=="l")throw new RangeError('End must be "h" or "l"');this[a0]=e}get name(){return`keep-${this.end}`}get notation(){return`k${this.end}${this.qty}`}get qty(){return this[i0]}set qty(e){if(e===1/0)throw new RangeError("qty must be a finite number");if(!Mr(e)||e<1)throw new TypeError("qty must be a positive finite integer");this[i0]=Math.floor(e)}rangeToDrop(e){return this.end==="h"?[0,e.length-this.qty]:[this.qty,e.length]}run(e,t){let a,n;return e instanceof kr?(a=e.results,a.length===1&&a[0]instanceof kr?n=a[0].results.map((i,o)=>i instanceof jt?i.rolls.map((f,l)=>({value:f.value,index:[o,l]})):null).flat().filter(Boolean):n=[...a].map((i,o)=>({value:i.value,index:o}))):(a=e.rolls,n=[...a].map((i,o)=>({value:i.value,index:o}))),n=n.sort((i,o)=>i.value-o.value).map(i=>i.index).slice(...this.rangeToDrop(n)),n.forEach(i=>{let o;Array.isArray(i)?o=a[0].results[i[0]].rolls[i[1]]:o=a[i],o.modifiers.add("drop"),o.useInTotal=!1}),e}toJSON(){const{end:e,qty:t}=this;return Object.assign(super.toJSON(),{end:e,qty:t})}}class M9 extends o0{constructor(e="l",t=1){super(e,t),this.order=7}get name(){return`drop-${this.end}`}get notation(){return`d${this.end}${this.qty}`}rangeToDrop(e){return this.end==="h"?[e.length-this.qty,e.length]:[0,this.qty]}}const s0=Symbol("max");class F9 extends bn{constructor(e){super(),this.max=e,this.order=2}get max(){return this[s0]}set max(e){if(!Mr(e))throw new TypeError("max must be a number");this[s0]=parseFloat(`${e}`)}get name(){return"max"}get notation(){return`max${this.max}`}run(e,t){const a=e;return a.rolls=e.rolls.map(n=>{const i=n;return n.value>this.max&&(i.value=this.max,i.modifiers.add("max")),i}),a}toJSON(){const{max:e}=this;return Object.assign(super.toJSON(),{max:e})}}const u0=Symbol("min");class T9 extends bn{constructor(e){super(),this.min=e,this.order=1}get min(){return this[u0]}set min(e){if(!Mr(e))throw new TypeError("min must be a number");this[u0]=parseFloat(`${e}`)}get name(){return"min"}get notation(){return`min${this.min}`}run(e,t){const a=e;return a.rolls=e.rolls.map(n=>{const i=n;return n.value<this.min&&(i.value=this.min,i.modifiers.add("min")),i}),a}toJSON(){const{min:e}=this;return Object.assign(super.toJSON(),{min:e})}}const l0=Symbol("direction");class B9 extends bn{constructor(e="a"){super(),this.direction=e,this.order=11}get direction(){return this[l0]}set direction(e){if(e!=="a"&&e!=="d")throw new RangeError('Direction must be "a" (Ascending) or "d" (Descending)');this[l0]=e}get name(){return"sorting"}get notation(){return`s${this.direction}`}run(e,t){let a;return e instanceof kr?a="results":a="rolls",e[a]=e[a].sort((n,i)=>this.direction==="d"?i.value-n.value:n.value-i.value),e instanceof kr&&(e[a]=e[a].map(n=>n instanceof kr||n instanceof jt?this.run(n,t):n)),e}toJSON(){const{direction:e}=this;return Object.assign(super.toJSON(),{direction:e})}}const c0=Symbol("failure-cp");class $9 extends Sa{constructor(e,t=null){super(e),this.failureComparePoint=t,this.order=8}get failureComparePoint(){return this[c0]}set failureComparePoint(e){if(e&&!(e instanceof ii))throw new TypeError("failure comparePoint must be instance of ComparePoint or null");this[c0]=e||null}get name(){return"target"}get notation(){return`${super.notation}${this.failureComparePoint?`f${this.failureComparePoint}`:""}`}get successComparePoint(){return this.comparePoint}set successComparePoint(e){super.comparePoint=e}getStateValue(e){return this.isSuccess(e)?1:this.isFailure(e)?-1:0}isFailure(e){return this.failureComparePoint?this.failureComparePoint.isMatch(e):!1}isNeutral(e){return!this.isSuccess(e)&&!this.isFailure(e)}isSuccess(e){return this.isComparePoint(e)}run(e,t){let a;return e instanceof kr?a=e.results:a=e.rolls,a.forEach(n=>{this.isSuccess(n.value)?n.modifiers.add("target-success"):this.isFailure(n.value)&&n.modifiers.add("target-failure"),n.calculationValue=this.getStateValue(n.value)}),e}toJSON(){const{failureComparePoint:e,successComparePoint:t}=this,a=super.toJSON();return delete a.comparePoint,Object.assign(a,{failureComparePoint:e,successComparePoint:t})}}const f0=Symbol("once"),O9=(r,e,t,a=!1)=>{const n=t.map(i=>i.value).indexOf(r.value);return a?n<e:n!==e};class I9 extends Sa{constructor(e=!1,t=null){super(t),this.once=!!e,this.order=5}get name(){return"unique"}get notation(){return`u${this.once?"o":""}${super.notation}`}get once(){return!!this[f0]}set once(e){this[f0]=!!e}run(e,t){if(t.min===t.max)throw new ei(t,"re-roll");return e.rolls.forEach((a,n,i)=>{if(n!==0)for(let o=0;o<this.maxIterations&&(!this.comparePoint||this.isComparePoint(a.value))&&O9(a,n,i,!0);o++){const f=t.rollOnce();if(a.value=f.value,a.modifiers.add(`unique${this.once?"-once":""}`),this.once)break}}),e}toJSON(){const{once:e}=this;return Object.assign(super.toJSON(),{once:e})}}const R9=r=>{try{return!!(r&&btoa(atob(r))===r)}catch{return!1}},_9=r=>{try{const e=r?JSON.parse(r):!1;return!!(e&&typeof e=="object")}catch{return!1}},wu=Symbol("expressions"),Nu=Symbol("modifiers");class m0 extends Jd{constructor(e=[],t=[],a=null){super(a),this.expressions=e,this.modifiers=t}get expressions(){return[...this[wu]||[]]}set expressions(e){if(!e)throw new zt("expressions");if(!Array.isArray(e))throw new TypeError(`expressions must be an array: ${e}`);this[wu]=[],e.forEach(t=>{if(!t||!Array.isArray(t))throw new TypeError(`Expressions must be an array of arrays: ${e}`);if(t.length===0)throw new TypeError(`Sub expressions cannot be empty: ${e}`);if(!t.every(a=>a instanceof Ca||typeof a=="string"||typeof a=="number"))throw new TypeError("Sub expression items must be Dice, numbers, or strings");this[wu].push(t)})}get modifiers(){return this[Nu]?new Map([...this[Nu]].sort((e,t)=>e[1].order-t[1].order)):null}set modifiers(e){let t;if(e instanceof Map)t=e;else if(Array.isArray(e))t=new Map(e.map(a=>[a.name,a]));else if(typeof e=="object")t=new Map(Object.entries(e));else throw new TypeError("modifiers should be a Map, array, or an Object containing Modifiers");if(t.size&&[...t.entries()].some(a=>!(a[1]instanceof bn)))throw new TypeError("modifiers must only contain Modifier instances");this[Nu]=t}get notation(){let e=this.expressions.map(t=>t.reduce((a,n)=>a+n,"")).join(", ");return e=`{${e}}`,this.modifiers&&this.modifiers.size&&(e+=[...this.modifiers.values()].reduce((t,a)=>t+a.notation,"")),e}roll(){const e=new kr(this.expressions.map(t=>{const a=t.map(n=>n instanceof Ca?n.roll():n);return new kr(a)}));return e.isRollGroup=!0,(this.modifiers||[]).forEach(t=>{t.run(e,this)}),e}toJSON(){const{modifiers:e,notation:t,expressions:a}=this;return Object.assign(super.toJSON(),{expressions:a,modifiers:e,notation:t,type:"group"})}toString(){return`${this.notation}${this.description?` ${this.description}`:""}`}}function q9(r,e){function t(){this.constructor=r}t.prototype=e.prototype,r.prototype=new t}function Ma(r,e,t,a){var n=Error.call(this,r);return Object.setPrototypeOf&&Object.setPrototypeOf(n,Ma.prototype),n.expected=e,n.found=t,n.location=a,n.name="SyntaxError",n}q9(Ma,Error);function Du(r,e,t){return t=t||" ",r.length>e?r:(e-=r.length,t+=t.repeat(e),r+t.slice(0,e))}Ma.prototype.format=function(r){var e="Error: "+this.message;if(this.location){var t=null,a;for(a=0;a<r.length;a++)if(r[a].source===this.location.source){t=r[a].text.split(/\r\n|\n|\r/g);break}var n=this.location.start,i=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(n):n,o=this.location.source+":"+i.line+":"+i.column;if(t){var f=this.location.end,l=Du("",i.line.toString().length," "),u=t[n.line-1],s=n.line===f.line?f.column:u.length+1,c=s-n.column||1;e+=`
|
|
78
|
+
*/class Ws extends TypeError{constructor(e){super(`Operator "${e}" is invalid`),TypeError.captureStackTrace&&TypeError.captureStackTrace(this,Ws),this.name="CompareOperatorError",this.operator=e}}class Ys extends Error{constructor(e){super(`Invalid data format: ${e}`),Error.captureStackTrace&&Error.captureStackTrace(this,Ys),this.name="ImportError",this.data=e}}class ri extends Error{constructor(e,t=null){super(`Die "${e}" must have more than 1 possible value to ${t||"do this action"}`),Error.captureStackTrace&&Error.captureStackTrace(this,ri),this.name="DieActionValueError",this.action=t,this.die=e}}class yo extends Error{constructor(e){super(`Notation "${e}" is invalid`),Error.captureStackTrace&&Error.captureStackTrace(this,yo),this.name="NotationError",this.notation=e}}class Pt extends Error{constructor(e=null){super(`Missing argument${e?` "${e}"`:""}`),Error.captureStackTrace&&Error.captureStackTrace(this,Pt),this.argumentName=e}}const K6=(r,e,t)=>{const a=Number(r),n=Number(e);let i;if(Number.isNaN(a)||Number.isNaN(n))return!1;switch(t){case"=":case"==":i=a===n;break;case"<":i=a<n;break;case">":i=a>n;break;case"<=":i=a<=n;break;case">=":i=a>=n;break;case"!":case"!=":case"<>":i=a!==n;break;default:i=!1;break}return i},Sd=r=>Js(r),Mr=r=>typeof r!="number"&&typeof r!="string"?!1:!Number.isNaN(r)&&Number.isFinite(Number(r)),Qs=r=>{if(!Mr(r))return!1;const e=Number(r);return e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER},j6=r=>Array.isArray(r)?r.reduce((e,t)=>e+(Mr(t)?parseFloat(`${t}`):0),0):0,e9=(r,e=0)=>parseFloat(parseFloat(`${r}`).toFixed(e||0)),Rr=9007199254740992,ti=Rr-1,bo=-1>>>0,pt=bo+1,jt=pt/2,Ks=jt-1,ni=1<<21,Pn=ni-1;function js(r){return r.next()|0}function bn(r,e){return e===0?r:t=>r(t)+e}function eu(r){const e=r.next()|0,t=r.next()>>>0;return(e&Pn)*pt+t+(e&ni?-Rr:0)}function Cd(r){for(;;){const e=r.next()|0;if(e&4194304){if((e&8388607)===4194304&&(r.next()|0)===0)return Rr}else{const t=r.next()>>>0;return(e&Pn)*pt+t+(e&ni?-Rr:0)}}}function Md(r){return r.next()>>>0}function xo(r){const e=r.next()&Pn,t=r.next()>>>0;return e*pt+t}function ru(r){for(;;){const e=r.next()|0;if(e&ni){if((e&Pn)===0&&(r.next()|0)===0)return Rr}else{const t=r.next()>>>0;return(e&Pn)*pt+t}}}function Fd(r){return(r+1&r)===0}function r9(r){return e=>e.next()&r}function t9(r){const e=r+1,t=e*Math.floor(pt/e);return a=>{let n=0;do n=a.next()>>>0;while(n>=t);return n%e}}function n9(r){return Fd(r)?r9(r):t9(r)}function a9(r){return(r|0)===0}function i9(r){return e=>{const t=e.next()&r,a=e.next()>>>0;return t*pt+a}}function o9(r){const e=r*Math.floor(Rr/r);return t=>{let a=0;do{const n=t.next()&Pn,i=t.next()>>>0;a=n*pt+i}while(a>=e);return a%r}}function s9(r){const e=r+1;if(a9(e)){const t=(e/pt|0)-1;if(Fd(t))return i9(t)}return o9(e)}function Td(r,e){return t=>{let a=0;do{const n=t.next()|0,i=t.next()>>>0;a=(n&Pn)*pt+i+(n&ni?-Rr:0)}while(a<r||a>e);return a}}function Un(r,e){if(r=Math.floor(r),e=Math.floor(e),r<-Rr||!isFinite(r))throw new RangeError(`Expected min to be at least ${-Rr}`);if(e>Rr||!isFinite(e))throw new RangeError(`Expected max to be at most ${Rr}`);const t=e-r;return t<=0||!isFinite(t)?()=>r:t===bo?r===0?Md:bn(js,r+jt):t<bo?bn(n9(t),r):t===ti?bn(xo,r):t<ti?bn(s9(t),r):e-1-r===ti?bn(ru,r):r===-Rr&&e===Rr?Cd:r===-Rr&&e===ti?eu:r===-ti&&e===Rr?bn(eu,1):e===Rr?bn(Td(r-1,e-1),1):Td(r,e)}function u9(r){return(r.next()&1)===1}function tu(r,e){return t=>r(t)<e}function l9(r){if(r<=0)return()=>!1;if(r>=1)return()=>!0;{const e=r*pt;return e%1===0?tu(js,e-jt|0):tu(xo,Math.round(r*Rr))}}function c9(r,e){return e==null?r==null?u9:l9(r):r<=0?()=>!1:r>=e?()=>!0:tu(Un(0,e-1),r)}function f9(r,e){const t=Un(+r,+e);return a=>new Date(t(a))}function Bd(r){return Un(1,r)}function m9(r,e){const t=Bd(r);return a=>{const n=[];for(let i=0;i<e;++i)n.push(t(a));return n}}const v9="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-";function nu(r=v9){const e=r.length;if(!e)throw new Error("Expected pool not to be an empty string");const t=Un(0,e-1);return(a,n)=>{let i="";for(let o=0;o<n;++o){const f=t(a);i+=r.charAt(f)}return i}}const $d="0123456789abcdef",p9=nu($d),h9=nu($d.toUpperCase());function d9(r){return r?h9:p9}function Od(r,e){return r<0?Math.max(r+e,0):Math.min(r,e)}function Id(r){const e=+r;return e<0?Math.ceil(e):Math.floor(e)}function g9(r,e,t,a){const n=e.length;if(n===0)throw new RangeError("Cannot pick from an empty array");const i=t==null?0:Od(Id(t),n),o=a===void 0?n:Od(Id(a),n);if(i>=o)throw new RangeError(`Cannot pick between bounds ${i} and ${o}`);const f=Un(i,o-1);return e[f(r)]}function y9(r,e){return e===1?r:e===0?()=>0:t=>r(t)*e}function Rd(r){return xo(r)/Rr}function _d(r){return ru(r)/Rr}function b9(r,e,t=!1){if(isFinite(r)){if(!isFinite(e))throw new RangeError("Expected max to be a finite number")}else throw new RangeError("Expected min to be a finite number");return bn(y9(t?_d:Rd,e-r),r)}const x9=Array.prototype.slice;function au(r,e,t=0){const a=e.length;if(a)for(let n=a-1>>>0;n>t;--n){const o=Un(0,n)(r);if(n!==o){const f=e[n];e[n]=e[o],e[o]=f}}return e}function w9(r,e,t){if(t<0||t>e.length||!isFinite(t))throw new RangeError("Expected sampleSize to be within 0 and the length of the population");if(t===0)return[];const a=x9.call(e),n=a.length;if(n===t)return au(r,a,0);const i=n-t;return au(r,a,i-1).slice(i)}const N9=(()=>{try{if("x".repeat(3)==="xxx")return(r,e)=>r.repeat(e)}catch{}return(r,e)=>{let t="";for(;e>0;)e&1&&(t+=r),e>>=1,r+=r;return t}})();function Aa(r,e){return N9("0",e-r.length)+r}function D9(r){const e=r.next()>>>0,t=r.next()|0,a=r.next()|0,n=r.next()>>>0;return Aa(e.toString(16),8)+"-"+Aa((t&65535).toString(16),4)+"-"+Aa((t>>4&4095|16384).toString(16),4)+"-"+Aa((a&16383|32768).toString(16),4)+"-"+Aa((a>>4&65535).toString(16),4)+Aa(n.toString(16),8)}const Ea={next(){return Math.random()*pt|0}};class A9{constructor(e=Ea){this.engine=e}int32(){return js(this.engine)}uint32(){return Md(this.engine)}uint53(){return xo(this.engine)}uint53Full(){return ru(this.engine)}int53(){return eu(this.engine)}int53Full(){return Cd(this.engine)}integer(e,t){return Un(e,t)(this.engine)}realZeroToOneInclusive(){return _d(this.engine)}realZeroToOneExclusive(){return Rd(this.engine)}real(e,t,a=!1){return b9(e,t,a)(this.engine)}bool(e,t){return c9(e,t)(this.engine)}pick(e,t,a){return g9(this.engine,e,t,a)}shuffle(e){return au(this.engine,e)}sample(e,t){return w9(this.engine,e,t)}die(e){return Bd(e)(this.engine)}dice(e,t){return m9(e,t)(this.engine)}uuid4(){return D9(this.engine)}string(e,t){return nu(t)(this.engine,e)}hex(e,t){return d9(t)(this.engine,e)}date(e,t){return f9(e,t)(this.engine)}}const qd=(()=>{try{const r=new ArrayBuffer(4),e=new Int32Array(r);if(e[0]=jt,e[0]===-jt)return Int32Array}catch{}return Array})();let wo=null;const iu=128;let ou=iu;const E9={next(){return ou>=iu&&(wo===null&&(wo=new qd(iu)),crypto.getRandomValues(wo),ou=0),wo[ou++]|0}};function S9(r=Ea,e=16){const t=[];t.push(new Date().getTime()|0);for(let a=1;a<e;++a)t[a]=r.next()|0;return t}const su=(()=>{try{if(Math.imul(bo,5)===-5)return Math.imul}catch{}const r=65535;return(e,t)=>{const a=e>>>16&r,n=e&r,i=t>>>16&r,o=t&r;return n*o+(a*o+n*i<<16>>>0)|0}})(),Ut=624,xn=Ut-1,uu=397,zd=Ut-uu,lu=2567483615;class ai{constructor(){this.data=new qd(Ut),this.index=0,this.uses=0}static seed(e){return new ai().seed(e)}static seedWithArray(e){return new ai().seedWithArray(e)}static autoSeed(){return ai.seedWithArray(S9())}next(){(this.index|0)>=Ut&&(cu(this.data),this.index=0);const e=this.data[this.index];return this.index=this.index+1|0,this.uses+=1,C9(e)|0}getUseCount(){return this.uses}discard(e){if(e<=0)return this;for(this.uses+=e,(this.index|0)>=Ut&&(cu(this.data),this.index=0);e+this.index>Ut;)e-=Ut-this.index,cu(this.data),this.index=0;return this.index=this.index+e|0,this}seed(e){let t=0;this.data[0]=t=e|0;for(let a=1;a<Ut;a=a+1|0)this.data[a]=t=su(t^t>>>30,1812433253)+a|0;return this.index=Ut,this.uses=0,this}seedWithArray(e){return this.seed(19650218),M9(this.data,e),this}}function cu(r){let e=0,t=0;for(;(e|0)<zd;e=e+1|0)t=r[e]&jt|r[e+1|0]&Ks,r[e]=r[e+uu|0]^t>>>1^(t&1?lu:0);for(;(e|0)<xn;e=e+1|0)t=r[e]&jt|r[e+1|0]&Ks,r[e]=r[e-zd|0]^t>>>1^(t&1?lu:0);t=r[xn]&jt|r[0]&Ks,r[xn]=r[uu-1]^t>>>1^(t&1?lu:0)}function C9(r){return r^=r>>>11,r^=r<<7&2636928640,r^=r<<15&4022730752,r^r>>>18}function M9(r,e){let t=1,a=0;const n=e.length;let i=Math.max(n,Ut)|0,o=r[0]|0;for(;(i|0)>0;--i)r[t]=o=(r[t]^su(o^o>>>30,1664525))+(e[a]|0)+(a|0)|0,t=t+1|0,++a,(t|0)>xn&&(r[0]=r[xn],t=1),a>=n&&(a=0);for(i=xn;(i|0)>0;--i)r[t]=o=(r[t]^su(o^o>>>30,1566083941))-t|0,t=t+1|0,(t|0)>xn&&(r[0]=r[xn],t=1);r[0]=jt}let Pd=null;const fu=128;let mu=fu;const F9={next(){return mu>=fu&&(Pd=new Int32Array(new Int8Array(require("crypto").randomBytes(4*fu)).buffer),mu=0),Pd[mu++]|0}},ii=Symbol("engine"),vu=Symbol("random"),Ud={browserCrypto:E9,nodeCrypto:F9,MersenneTwister19937:ai,nativeMath:Ea,min:{next(){return 0}},max:{range:[],next(){return this.range[1]-this.range[0]}}};class T9{constructor(e=Ea){this.engine=e||Ea}get engine(){return this[ii]}set engine(e){if(e&&typeof e.next!="function")throw new TypeError("engine must have function `next()`");this[ii]=e||Ea,this[vu]=new A9(this[ii])}integer(e,t){return this[ii].range=[e,t],this[vu].integer(e,t)}real(e,t,a=!1){return this[ii].range=[e,t],this[vu].real(e,t,a)}}const Sa=new T9,Ld=Symbol("text"),kd=Symbol("type");class Ct{constructor(e,t=this.constructor.types.INLINE){this.text=e,this.type=t}get text(){return this[Ld]}set text(e){if(typeof e=="object")throw new TypeError("Description text is invalid");if(!e&&e!==0||`${e}`.trim()==="")throw new TypeError("Description text cannot be empty");this[Ld]=`${e}`.trim()}get type(){return this[kd]}set type(e){const t=Object.values(this.constructor.types);if(typeof e!="string")throw new TypeError("Description type must be a string");if(!t.includes(e))throw new RangeError(`Description type must be one of; ${t.join(", ")}`);this[kd]=e}toJSON(){const{text:e,type:t}=this;return{text:e,type:t}}toString(){return this.type===this.constructor.types.INLINE?`# ${this.text}`:`[${this.text}]`}}tt(Ct,"types",{MULTILINE:"multiline",INLINE:"inline"});const No=Symbol("description");class Vd{constructor(e=null){this.description=e}get description(){return this[No]||null}set description(e){if(!e&&e!==0)this[No]=null;else if(e instanceof Ct)this[No]=e;else if(typeof e=="string")this[No]=new Ct(e);else throw new TypeError(`description must be of type Description, string or null. Received ${typeof e}`)}toJSON(){const{description:e}=this;return{description:e}}toString(){return this.description?`${this.description}`:""}}class en{constructor(){this.order=this.constructor.order}get name(){return"modifier"}get notation(){return""}get maxIterations(){return 1e3}defaults(e){return{}}useDefaultsIfNeeded(e){Object.entries(this.defaults(e)).forEach(([t,a])=>{typeof this[t]>"u"&&(this[t]=a)})}run(e,t){return this.useDefaultsIfNeeded(t),e}toJSON(){const{notation:e,name:t}=this;return{name:t,notation:e,type:"modifier"}}toString(){return this.notation}}tt(en,"order",999);const B9={compound:"!",explode:"!","critical-failure":"__","critical-success":"**",drop:"d",max:"v",min:"^",penetrate:"p","re-roll":"r","re-roll-once":"ro","target-failure":"_","target-success":"*",unique:"u","unique-once":"uo"},Gd=(...r)=>[...r].reduce((e,t)=>{let a;return t instanceof en?a=t.name:a=t,e+(B9[a]||a)},""),pu=Symbol("calculation-value"),hu=Symbol("modifiers"),oi=Symbol("initial-value"),Hd=Symbol("use-in-total"),du=Symbol("value");class Do{constructor(e,t=[],a=!0){if(Mr(e))this[oi]=Number(e),this.modifiers=t||[],this.useInTotal=a;else if(e&&typeof e=="object"&&!Array.isArray(e)){const n=Mr(e.initialValue)?e.initialValue:e.value;if(!Mr(n))throw new TypeError(`Result value is invalid: ${n}`);this[oi]=Number(n),Mr(e.value)&&Number(e.value)!==this[oi]&&(this.value=e.value),Mr(e.calculationValue)&&parseFloat(`${e.calculationValue}`)!==this.value&&(this.calculationValue=e.calculationValue),this.modifiers=e.modifiers||t||[],this.useInTotal=typeof e.useInTotal=="boolean"?e.useInTotal:a||!1}else throw e===1/0?new RangeError("Result value must be a finite number"):new TypeError(`Result value is invalid: ${e}`)}get calculationValue(){return Mr(this[pu])?parseFloat(this[pu]):this.value}set calculationValue(e){const t=Mr(e);if(e===1/0)throw new RangeError("Result calculation value must be a finite number");if(e&&!t)throw new TypeError(`Result calculation value is invalid: ${e}`);this[pu]=t?parseFloat(`${e}`):null}get initialValue(){return this[oi]}get modifierFlags(){return Gd(...this.modifiers)}get modifiers(){return this[hu]}set modifiers(e){if((Array.isArray(e)||e instanceof Set)&&[...e].every(t=>typeof t=="string")){this[hu]=new Set([...e]);return}if(!e&&e!==0){this[hu]=new Set;return}throw new TypeError(`modifiers must be a Set or array of modifier names: ${e}`)}get useInTotal(){return!!this[Hd]}set useInTotal(e){this[Hd]=!!e}get value(){return Mr(this[du])?this[du]:this[oi]}set value(e){if(e===1/0)throw new RangeError("Result value must be a finite number");if(!Mr(e))throw new TypeError(`Result value is invalid: ${e}`);this[du]=Number(e)}toJSON(){const{calculationValue:e,initialValue:t,modifierFlags:a,modifiers:n,useInTotal:i,value:o}=this;return{calculationValue:e,initialValue:t,modifierFlags:a,modifiers:[...n],type:"result",useInTotal:i,value:o}}toString(){return this.value+this.modifierFlags}}const gu=Symbol("rolls");class rn{constructor(e=[]){this.rolls=e}get length(){return this.rolls.length||0}get rolls(){return[...this[gu]]}set rolls(e){if(!e||!Array.isArray(e))throw new TypeError(`rolls must be an array: ${e}`);this[gu]=[],e.forEach(t=>{this.addRoll(t)})}get value(){return this.rolls.reduce((e,t)=>e+(t.useInTotal?t.calculationValue:0),0)}addRoll(e){const t=e instanceof Do?e:new Do(e);this[gu].push(t)}toJSON(){const{rolls:e,value:t}=this;return{rolls:e,type:"roll-results",value:t}}toString(){return`[${this.rolls.join(", ")}]`}}const yu=Symbol("modifiers"),Zd=Symbol("qty"),Jd=Symbol("sides"),Xd=Symbol("min-value"),Wd=Symbol("max-value");class Ca extends Vd{constructor(e,t=1,a=null,n=1,i=null,o=null){if(super(o),!e&&e!==0)throw new Pt("sides");if(e===1/0)throw new RangeError("numerical sides must be finite number");if(Mr(e)){if(e<1||!Qs(e))throw new RangeError("numerical sides must be a positive finite number")}else if(typeof e!="string")throw new TypeError("non-numerical sides must be a string");if(Mr(t)){if(t<1||t>999)throw new RangeError("qty must be between 1 and 999")}else throw new TypeError("qty must be a positive finite integer");let f=n;if(f==null)f=1;else if(Mr(f)){if(!Qs(f))throw new RangeError("min must a finite number")}else throw new TypeError("min must a finite number");if(i&&!Mr(i))throw new TypeError("max must a finite number");if(i&&!Qs(i))throw new RangeError("max must a finite number");this[Zd]=parseInt(`${t}`,10),this[Jd]=e,a&&(this.modifiers=a),this[Xd]=parseInt(f,10),this[Wd]=i?parseInt(`${i}`,10):e}get average(){return(this.min+this.max)/2}get modifiers(){return this[yu]?new Map([...this[yu]].sort((e,t)=>e[1].order-t[1].order)):null}set modifiers(e){let t;if(e instanceof Map)t=e;else if(Array.isArray(e))t=new Map(e.map(a=>[a.name,a]));else if(typeof e=="object")t=new Map(Object.entries(e));else throw new TypeError("modifiers should be a Map, array, or an Object containing Modifiers");if(t.size&&[...t.entries()].some(a=>!(a[1]instanceof en)))throw new TypeError("modifiers must only contain Modifier instances");this[yu]=t}get max(){return this[Wd]}get min(){return this[Xd]}get name(){return"standard"}get notation(){let e=`${this.qty}d${this.sides}`;return this.modifiers&&this.modifiers.size&&(e+=[...this.modifiers.values()].reduce((t,a)=>t+a.notation,"")),e}get qty(){return this[Zd]}get sides(){return this[Jd]}roll(){const e=new rn;for(let t=0;t<this.qty;t++)e.addRoll(this.rollOnce());return(this.modifiers||[]).forEach(t=>{t.run(e,this)}),e}rollOnce(){return new Do(Sa.integer(this.min,this.max))}toJSON(){const{average:e,max:t,min:a,modifiers:n,name:i,notation:o,qty:f,sides:l}=this;return Object.assign(super.toJSON(),{average:e,max:t,min:a,modifiers:n,name:i,notation:o,qty:f,sides:l,type:"die"})}toString(){return`${this.notation}${this.description?` ${this.description}`:""}`}}class $9 extends Ca{constructor(e=2,t=1,a=null,n=null){let i=e;if(!i&&i!==0)i=2;else if(i!==1&&i!==2)throw new RangeError("nonBlanks must be 1 or 2");super(i,t,a,-1,1,n)}get name(){return"fudge"}get nonBlanks(){return super.sides}get sides(){return`F.${this.nonBlanks}`}rollOnce(){let e=0;if(this.nonBlanks===2)e=Sa.integer(1,3)-2;else if(this.nonBlanks===1){const t=Sa.integer(1,6);t===1?e=-1:t===6&&(e=1)}return new Do(e)}}class O9 extends Ca{constructor(e=1,t=null,a=!1,n=null){super(100,e,t,null,null,n),this.sidesAsNumber=!!a}get name(){return"percentile"}get sides(){return this.sidesAsNumber?super.sides:"%"}}const Yd=Symbol("operator"),Qd=Symbol("value");class Ao{constructor(e,t){if(e){if(!t&&t!==0)throw new Pt("value")}else throw new Pt("operator");this.operator=e,this.value=t}static isValidOperator(e){return typeof e=="string"&&/^(?:[<>!]?=|[<>]|<>)$/.test(e)}set operator(e){if(!this.constructor.isValidOperator(e))throw new Ws(e);this[Yd]=e}get operator(){return this[Yd]}set value(e){if(!Mr(e))throw new TypeError("value must be a finite number");this[Qd]=Number(e)}get value(){return this[Qd]}isMatch(e){return K6(e,this.value,this.operator)}toJSON(){const{operator:e,value:t}=this;return{operator:e,type:"compare-point",value:t}}toString(){return`${this.operator}${this.value}`}}const Kd=Symbol("compare-point");class Ma extends en{constructor(e){super(),e&&(this.comparePoint=e)}get comparePoint(){return this[Kd]}set comparePoint(e){if(!(e instanceof Ao))throw new TypeError("comparePoint must be instance of ComparePoint");this[Kd]=e}get name(){return"comparison"}get notation(){return`${this.comparePoint||""}`}defaultComparePoint(e){return{}}defaults(e){const t=this.defaultComparePoint(e);return typeof t=="object"&&t.length===2?{comparePoint:new Ao(...t)}:{}}isComparePoint(e){return this.comparePoint?this.comparePoint.isMatch(e):!1}toJSON(){const{comparePoint:e}=this;return Object.assign(super.toJSON(),{comparePoint:e})}}class jd extends Ma{constructor(e){super(e)}get name(){return"critical-failure"}get notation(){return`cf${super.notation}`}defaultComparePoint(e){return["=",e.min]}run(e,t){return super.run(e,t),e.rolls.forEach(a=>(this.isComparePoint(a.value)&&a.modifiers.add("critical-failure"),a)),e}}tt(jd,"order",10);class e0 extends Ma{constructor(e){super(e)}get name(){return"critical-success"}get notation(){return`cs${super.notation}`}defaultComparePoint(e){return["=",e.max]}run(e,t){return super.run(e,t),e.rolls.forEach(a=>(this.isComparePoint(a.value)&&a.modifiers.add("critical-success"),a)),e}}tt(e0,"order",9);const bu=Symbol("calculation-value"),r0=Symbol("is-roll-group"),xu=Symbol("modifiers"),wu=Symbol("results"),t0=Symbol("use-in-total");class kr{constructor(e=[],t=[],a=!1,n=!0){this.isRollGroup=a,this.modifiers=t,this.results=e,this.useInTotal=n}get calculationValue(){return Mr(this[bu])?parseFloat(this[bu]):this.value}set calculationValue(e){const t=Mr(e);if(e===1/0)throw new RangeError("Results calculation value must be a finite number");if(e&&!t)throw new TypeError(`Results calculation value is invalid: ${e}`);this[bu]=t?parseFloat(`${e}`):null}get isRollGroup(){return this[r0]}set isRollGroup(e){this[r0]=!!e}get length(){return this.results.length||0}get modifierFlags(){return Gd(...this.modifiers)}get modifiers(){return this[xu]}set modifiers(e){if((Array.isArray(e)||e instanceof Set)&&[...e].every(t=>typeof t=="string"))this[xu]=new Set([...e]);else if(!e&&e!==0)this[xu]=new Set;else throw new TypeError(`modifiers must be a Set or array of modifier names: ${e}`)}get results(){return[...this[wu]]}set results(e){if(!e||!Array.isArray(e))throw new TypeError(`results must be an array: ${e}`);this[wu]=[],e.forEach(t=>{this.addResult(t)})}get useInTotal(){return!!this[t0]}set useInTotal(e){this[t0]=!!e}get value(){if(!this.results.length)return 0;const e=this.results.reduce((t,a)=>{let n=a;return a instanceof kr?n=a.useInTotal?a.calculationValue:0:a instanceof rn&&(n=a.value),t+n},typeof this.results[0]=="string"?"":0);return typeof e=="string"?Sd(e):e}addResult(e){let t;if(e instanceof kr||e instanceof rn)t=e;else if(typeof e=="string"||Mr(e))t=e;else throw new TypeError("value must be one of ResultGroup, RollResults, string, or number");this[wu].push(t)}toJSON(){const{calculationValue:e,isRollGroup:t,modifierFlags:a,modifiers:n,results:i,useInTotal:o,value:f}=this;return{calculationValue:e,isRollGroup:t,modifierFlags:a,modifiers:[...n],results:i,type:"result-group",useInTotal:o,value:f}}toString(){let e;return this.isRollGroup?e=`{${this.results.join(", ")}}`:e=this.results.join(""),this.modifierFlags&&(e=`(${e})${this.modifierFlags}`),e}}const n0=Symbol("end"),a0=Symbol("qty");class Nu extends en{constructor(e="h",t=1){super(),this.end=e,this.qty=t}get end(){return this[n0]}set end(e){if(e!=="h"&&e!=="l")throw new RangeError('End must be "h" or "l"');this[n0]=e}get name(){return`keep-${this.end}`}get notation(){return`k${this.end}${this.qty}`}get qty(){return this[a0]}set qty(e){if(e===1/0)throw new RangeError("qty must be a finite number");if(!Mr(e)||e<1)throw new TypeError("qty must be a positive finite integer");this[a0]=Math.floor(e)}rangeToDrop(e){return this.end==="h"?[0,e.length-this.qty]:[this.qty,e.length]}run(e,t){let a,n;return e instanceof kr?(a=e.results,a.length===1&&a[0]instanceof kr?n=a[0].results.map((i,o)=>i instanceof rn?i.rolls.map((f,l)=>({value:f.value,index:[o,l]})):null).flat().filter(Boolean):n=[...a].map((i,o)=>({value:i.value,index:o}))):(a=e.rolls,n=[...a].map((i,o)=>({value:i.value,index:o}))),n=n.sort((i,o)=>i.value-o.value).map(i=>i.index).slice(...this.rangeToDrop(n)),n.forEach(i=>{let o;Array.isArray(i)?o=a[0].results[i[0]].rolls[i[1]]:o=a[i],o.modifiers.add("drop"),o.useInTotal=!1}),e}toJSON(){const{end:e,qty:t}=this;return Object.assign(super.toJSON(),{end:e,qty:t})}}tt(Nu,"order",6);class i0 extends Nu{constructor(e="l",t=1){super(e,t)}get name(){return`drop-${this.end}`}get notation(){return`d${this.end}${this.qty}`}rangeToDrop(e){return this.end==="h"?[e.length-this.qty,e.length]:[0,this.qty]}}tt(i0,"order",7);const o0=Symbol("compound"),s0=Symbol("penetrate");class u0 extends Ma{constructor(e=null,t=!1,a=!1){super(e),this[o0]=!!t,this[s0]=!!a}get compound(){return this[o0]}get name(){return"explode"}get notation(){return`!${this.compound?"!":""}${this.penetrate?"p":""}${super.notation}`}get penetrate(){return this[s0]}defaultComparePoint(e){return["=",e.max]}run(e,t){if(super.run(e,t),t.min===t.max)throw new ri(t,"explode");const a=e;return a.rolls=e.rolls.map(n=>{const i=[n];let o=n.value;for(let f=0;f<this.maxIterations&&this.isComparePoint(o);f++){const l=i[i.length-1],u=t.rollOnce();o=u.value,l.modifiers.add("explode"),this.penetrate&&(l.modifiers.add("penetrate"),u.value-=1),i.push(u)}return this.compound&&i.length>1?(n.value=j6(i.map(f=>f.value)),n.modifiers=["explode","compound"],this.penetrate&&n.modifiers.add("penetrate"),n):i}).flat(),a}toJSON(){const{compound:e,penetrate:t}=this;return Object.assign(super.toJSON(),{compound:e,penetrate:t})}}tt(u0,"order",3);const l0=Symbol("max");class c0 extends en{constructor(e){super(),this.max=e}get max(){return this[l0]}set max(e){if(!Mr(e))throw new TypeError("max must be a number");this[l0]=parseFloat(`${e}`)}get name(){return"max"}get notation(){return`max${this.max}`}run(e,t){const a=e;return a.rolls=e.rolls.map(n=>{const i=n;return n.value>this.max&&(i.value=this.max,i.modifiers.add("max")),i}),a}toJSON(){const{max:e}=this;return Object.assign(super.toJSON(),{max:e})}}tt(c0,"order",2);const f0=Symbol("min");class m0 extends en{constructor(e){super(),this.min=e}get min(){return this[f0]}set min(e){if(!Mr(e))throw new TypeError("min must be a number");this[f0]=parseFloat(`${e}`)}get name(){return"min"}get notation(){return`min${this.min}`}run(e,t){const a=e;return a.rolls=e.rolls.map(n=>{const i=n;return n.value<this.min&&(i.value=this.min,i.modifiers.add("min")),i}),a}toJSON(){const{min:e}=this;return Object.assign(super.toJSON(),{min:e})}}tt(m0,"order",1);const v0=Symbol("once");class p0 extends Ma{constructor(e=!1,t=null){super(t),this.once=!!e}get name(){return"re-roll"}get notation(){return`r${this.once?"o":""}${super.notation}`}get once(){return!!this[v0]}set once(e){this[v0]=!!e}defaultComparePoint(e){return["=",e.min]}run(e,t){if(super.run(e,t),t.min===t.max)throw new ri(t,"re-roll");return e.rolls.map(a=>{for(let n=0;n<this.maxIterations&&this.isComparePoint(a.value);n++){const i=t.rollOnce();if(a.value=i.value,a.modifiers.add(`re-roll${this.once?"-once":""}`),this.once)break}return a}),e}toJSON(){const{once:e}=this;return Object.assign(super.toJSON(),{once:e})}}tt(p0,"order",4);const h0=Symbol("direction");class d0 extends en{constructor(e="a"){super(),this.direction=e}get direction(){return this[h0]}set direction(e){if(e!=="a"&&e!=="d")throw new RangeError('Direction must be "a" (Ascending) or "d" (Descending)');this[h0]=e}get name(){return"sorting"}get notation(){return`s${this.direction}`}run(e,t){let a;return e instanceof kr?a="results":a="rolls",e[a]=e[a].sort((n,i)=>this.direction==="d"?i.value-n.value:n.value-i.value),e instanceof kr&&(e[a]=e[a].map(n=>n instanceof kr||n instanceof rn?this.run(n,t):n)),e}toJSON(){const{direction:e}=this;return Object.assign(super.toJSON(),{direction:e})}}tt(d0,"order",11);const g0=Symbol("failure-cp");class y0 extends Ma{constructor(e,t=null){super(e),this.failureComparePoint=t}get failureComparePoint(){return this[g0]}set failureComparePoint(e){if(e&&!(e instanceof Ao))throw new TypeError("failure comparePoint must be instance of ComparePoint or null");this[g0]=e||null}get name(){return"target"}get notation(){return`${super.notation}${this.failureComparePoint?`f${this.failureComparePoint}`:""}`}get successComparePoint(){return this.comparePoint}set successComparePoint(e){super.comparePoint=e}getStateValue(e){return this.isSuccess(e)?1:this.isFailure(e)?-1:0}isFailure(e){return this.failureComparePoint?this.failureComparePoint.isMatch(e):!1}isNeutral(e){return!this.isSuccess(e)&&!this.isFailure(e)}isSuccess(e){return this.isComparePoint(e)}run(e,t){let a;return e instanceof kr?a=e.results:a=e.rolls,a.forEach(n=>{this.isSuccess(n.value)?n.modifiers.add("target-success"):this.isFailure(n.value)&&n.modifiers.add("target-failure"),n.calculationValue=this.getStateValue(n.value)}),e}toJSON(){const{failureComparePoint:e,successComparePoint:t}=this,a=super.toJSON();return delete a.comparePoint,Object.assign(a,{failureComparePoint:e,successComparePoint:t})}}tt(y0,"order",8);const b0=Symbol("once"),I9=(r,e,t,a=!1)=>{const n=t.map(i=>i.value).indexOf(r.value);return a?n<e:n!==e};class x0 extends Ma{constructor(e=!1,t=null){super(t),this.once=!!e}get name(){return"unique"}get notation(){return`u${this.once?"o":""}${super.notation}`}get once(){return!!this[b0]}set once(e){this[b0]=!!e}run(e,t){if(t.min===t.max)throw new ri(t,"re-roll");return e.rolls.forEach((a,n,i)=>{if(n!==0)for(let o=0;o<this.maxIterations&&(!this.comparePoint||this.isComparePoint(a.value))&&I9(a,n,i,!0);o++){const f=t.rollOnce();if(a.value=f.value,a.modifiers.add(`unique${this.once?"-once":""}`),this.once)break}}),e}toJSON(){const{once:e}=this;return Object.assign(super.toJSON(),{once:e})}}tt(x0,"order",5);const R9=r=>{try{return!!(r&&btoa(atob(r))===r)}catch{return!1}},_9=r=>{try{const e=r?JSON.parse(r):!1;return!!(e&&typeof e=="object")}catch{return!1}},Du=Symbol("expressions"),Au=Symbol("modifiers");class w0 extends Vd{constructor(e=[],t=[],a=null){super(a),this.expressions=e,this.modifiers=t}get expressions(){return[...this[Du]||[]]}set expressions(e){if(!e)throw new Pt("expressions");if(!Array.isArray(e))throw new TypeError(`expressions must be an array: ${e}`);this[Du]=[],e.forEach(t=>{if(!t||!Array.isArray(t))throw new TypeError(`Expressions must be an array of arrays: ${e}`);if(t.length===0)throw new TypeError(`Sub expressions cannot be empty: ${e}`);if(!t.every(a=>a instanceof Ca||typeof a=="string"||typeof a=="number"))throw new TypeError("Sub expression items must be Dice, numbers, or strings");this[Du].push(t)})}get modifiers(){return this[Au]?new Map([...this[Au]].sort((e,t)=>e[1].order-t[1].order)):null}set modifiers(e){let t;if(e instanceof Map)t=e;else if(Array.isArray(e))t=new Map(e.map(a=>[a.name,a]));else if(typeof e=="object")t=new Map(Object.entries(e));else throw new TypeError("modifiers should be a Map, array, or an Object containing Modifiers");if(t.size&&[...t.entries()].some(a=>!(a[1]instanceof en)))throw new TypeError("modifiers must only contain Modifier instances");this[Au]=t}get notation(){let e=this.expressions.map(t=>t.reduce((a,n)=>a+n,"")).join(", ");return e=`{${e}}`,this.modifiers&&this.modifiers.size&&(e+=[...this.modifiers.values()].reduce((t,a)=>t+a.notation,"")),e}roll(){const e=new kr(this.expressions.map(t=>{const a=t.map(n=>n instanceof Ca?n.roll():n);return new kr(a)}));return e.isRollGroup=!0,(this.modifiers||[]).forEach(t=>{t.run(e,this)}),e}toJSON(){const{modifiers:e,notation:t,expressions:a}=this;return Object.assign(super.toJSON(),{expressions:a,modifiers:e,notation:t,type:"group"})}toString(){return`${this.notation}${this.description?` ${this.description}`:""}`}}function q9(r,e){function t(){this.constructor=r}t.prototype=e.prototype,r.prototype=new t}function Fa(r,e,t,a){var n=Error.call(this,r);return Object.setPrototypeOf&&Object.setPrototypeOf(n,Fa.prototype),n.expected=e,n.found=t,n.location=a,n.name="SyntaxError",n}q9(Fa,Error);function Eu(r,e,t){return t=t||" ",r.length>e?r:(e-=r.length,t+=t.repeat(e),r+t.slice(0,e))}Fa.prototype.format=function(r){var e="Error: "+this.message;if(this.location){var t=null,a;for(a=0;a<r.length;a++)if(r[a].source===this.location.source){t=r[a].text.split(/\r\n|\n|\r/g);break}var n=this.location.start,i=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(n):n,o=this.location.source+":"+i.line+":"+i.column;if(t){var f=this.location.end,l=Eu("",i.line.toString().length," "),u=t[n.line-1],s=n.line===f.line?f.column:u.length+1,c=s-n.column||1;e+=`
|
|
79
79
|
--> `+o+`
|
|
80
80
|
`+l+` |
|
|
81
81
|
`+i.line+" | "+u+`
|
|
82
|
-
`+l+" | "+
|
|
83
|
-
at `+o}return e},
|
|
84
|
-
`,"\r","\u2028","\u2029"],!1,!1),g7=
|
|
85
|
-
`,"\r"],!1,!1),b7=rl("whitespace or comment"),x7=function(O,W,ne,le){return new m0([O,...W.map(Se=>Se[3])],Object.assign({},...ne.map(Se=>({[Se.name]:Se}))),le.find(Se=>Se instanceof St))},w7=function(O,W,ne){return O.modifiers=Object.assign({},...W.map(le=>({[le.name]:le}))),O.description=ne.find(le=>le instanceof St),O},N7=function(O,W){return new Ca(W,O||1)},D7=function(O){return new E9(O||1)},A7=function(O,W){return new A9(W?parseInt(W[1],10):2,O||1)},E7=function(O,W,ne){return new Gd(ne,!!O,!!W)},S7=function(O,W){return new $9(O,W)},C7=function(O,W){return new M9(O||"l",W)},M7=function(O,W){return new o0(O||"h",W)},F7=function(O){return new F9(O)},T7=function(O){return new T9(O)},B7=function(O,W){return new Qd(!!O,W)},$7=function(O,W){return new I9(!!O,W)},O7=function(O){return new C9(O)},I7=function(O){return new S9(O)},R7=function(O){return new B9(O||"a")},_7=function(O){return O},q7=function(O,W){return new ii(O,W)},z7=function(O,W,ne){return Ad(Ro())},P7=function(O,W){return O=Array.isArray(O)?O:[O],[...O,...W.map(([,ne,,le])=>[ne,le]).flat(2)]},U7=function(O,W,ne){return[O,...W,ne]},L7=function(O,W){return[`${O}(`,...W,")"]},k7=function(O,W,ne){return[`${O}(`,...W,",",...ne,")"]},V7=function(){return parseFloat(Ro())},G7=function(){return parseInt(Ro(),10)},H7=function(){return parseInt(Ro(),10)},Z7=function(){return"^"},J7=function(O){return new St(O.flat().join(""),St.types.MULTILINE)},X7=function(O){return new St(O.flat().join(""),St.types.MULTILINE)},W7=function(O){return new St(O.flat().join(""),St.types.INLINE)},_=0,lr=0,Oo=[{line:1,column:1}],Ut=0,el=[],De=0,Io;if("startRule"in e){if(!(e.startRule in n))throw new Error(`Can't start parsing from rule "`+e.startRule+'".');i=n[e.startRule]}function Ro(){return r.substring(lr,_)}function Ue(O,W){return{type:"literal",text:O,ignoreCase:W}}function Nn(O,W,ne){return{type:"class",parts:O,inverted:W,ignoreCase:ne}}function Y7(){return{type:"any"}}function Q7(){return{type:"end"}}function rl(O){return{type:"other",description:O}}function b0(O){var W=Oo[O],ne;if(W)return W;for(ne=O-1;!Oo[ne];)ne--;for(W=Oo[ne],W={line:W.line,column:W.column};ne<O;)r.charCodeAt(ne)===10?(W.line++,W.column=1):W.column++,ne++;return Oo[O]=W,W}function x0(O,W,ne){var le=b0(O),Se=b0(W),Ie={source:a,start:{offset:O,line:le.line,column:le.column},end:{offset:W,line:Se.line,column:Se.column}};return ne&&a&&typeof a.offset=="function"&&(Ie.start=a.offset(Ie.start),Ie.end=a.offset(Ie.end)),Ie}function Fe(O){_<Ut||(_>Ut&&(Ut=_,el=[]),el.push(O))}function K7(O,W,ne){return new Ma(Ma.buildMessage(O,W),O,W,ne)}function w0(){var O;return O=Dn(),O}function j7(){var O,W,ne,le,Se,Ie,hr,Er,Ct;if(O=_,r.charCodeAt(_)===123?(W=o,_++):(W=t,De===0&&Fe(_e)),W!==t)if(Ar(),ne=Dn(),ne!==t){for(le=[],Se=_,Ie=Ar(),r.charCodeAt(_)===44?(hr=f,_++):(hr=t,De===0&&Fe(Le)),hr!==t?(Er=Ar(),Ct=Dn(),Ct!==t?(Ie=[Ie,hr,Er,Ct],Se=Ie):(_=Se,Se=t)):(_=Se,Se=t);Se!==t;)le.push(Se),Se=_,Ie=Ar(),r.charCodeAt(_)===44?(hr=f,_++):(hr=t,De===0&&Fe(Le)),hr!==t?(Er=Ar(),Ct=Dn(),Ct!==t?(Ie=[Ie,hr,Er,Ct],Se=Ie):(_=Se,Se=t)):(_=Se,Se=t);if(Se=Ar(),r.charCodeAt(_)===125?(Ie=l,_++):(Ie=t,De===0&&Fe(Be)),Ie!==t){for(hr=[],Er=_o();Er!==t;)hr.push(Er),Er=_o();Er=E0(),lr=O,O=x7(ne,le,hr,Er)}else _=O,O=t}else _=O,O=t;else _=O,O=t;return O}function eI(){var O,W,ne,le;if(O=_,W=rI(),W===t&&(W=tI(),W===t&&(W=nI())),W!==t){for(ne=[],le=_o();le!==t;)ne.push(le),le=_o();le=E0(),lr=O,O=w7(W,ne,le)}else _=O,O=t;return O}function rI(){var O,W,ne,le;return O=_,W=qo(),W===t&&(W=null),r.charCodeAt(_)===100?(ne=u,_++):(ne=t,De===0&&Fe(ar)),ne!==t?(le=qo(),le!==t?(lr=O,O=N7(W,le)):(_=O,O=t)):(_=O,O=t),O}function tI(){var O,W,ne;return O=_,W=qo(),W===t&&(W=null),r.substr(_,2)===s?(ne=s,_+=2):(ne=t,De===0&&Fe(Je)),ne!==t?(lr=O,O=D7(W)):(_=O,O=t),O}function nI(){var O,W,ne,le,Se,Ie;return O=_,W=qo(),W===t&&(W=null),r.substr(_,2)===c?(ne=c,_+=2):(ne=t,De===0&&Fe(mr)),ne!==t?(le=_,r.charCodeAt(_)===46?(Se=m,_++):(Se=t,De===0&&Fe(C)),Se!==t?(U.test(r.charAt(_))?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe(Z)),Ie!==t?(Se=[Se,Ie],le=Se):(_=le,le=t)):(_=le,le=t),le===t&&(le=null),lr=O,O=A7(W,le)):(_=O,O=t),O}function _o(){var O;return O=aI(),O===t&&(O=iI(),O===t&&(O=oI(),O===t&&(O=sI(),O===t&&(O=cI(),O===t&&(O=fI(),O===t&&(O=mI(),O===t&&(O=vI(),O===t&&(O=pI(),O===t&&(O=uI(),O===t&&(O=lI())))))))))),O}function aI(){var O,W,ne,le,Se;return O=_,r.charCodeAt(_)===33?(W=v,_++):(W=t,De===0&&Fe(se)),W!==t?(r.charCodeAt(_)===33?(ne=v,_++):(ne=t,De===0&&Fe(se)),ne===t&&(ne=null),r.charCodeAt(_)===112?(le=h,_++):(le=t,De===0&&Fe(Ee)),le===t&&(le=null),Se=Gn(),Se===t&&(Se=null),lr=O,O=E7(ne,le,Se)):(_=O,O=t),O}function iI(){var O,W,ne;return O=_,W=Gn(),W!==t?(ne=hI(),ne===t&&(ne=null),lr=O,O=S7(W,ne)):(_=O,O=t),O}function oI(){var O,W,ne,le;return O=_,r.charCodeAt(_)===100?(W=u,_++):(W=t,De===0&&Fe(ar)),W!==t?(ee.test(r.charAt(_))?(ne=r.charAt(_),_++):(ne=t,De===0&&Fe(ze)),ne===t&&(ne=null),le=nl(),le!==t?(lr=O,O=C7(ne,le)):(_=O,O=t)):(_=O,O=t),O}function sI(){var O,W,ne,le;return O=_,r.charCodeAt(_)===107?(W=p,_++):(W=t,De===0&&Fe(ke)),W!==t?(ee.test(r.charAt(_))?(ne=r.charAt(_),_++):(ne=t,De===0&&Fe(ze)),ne===t&&(ne=null),le=nl(),le!==t?(lr=O,O=M7(ne,le)):(_=O,O=t)):(_=O,O=t),O}function uI(){var O,W,ne;return O=_,r.substr(_,3)===g?(W=g,_+=3):(W=t,De===0&&Fe(Fr)),W!==t?(ne=Hn(),ne!==t?(lr=O,O=F7(ne)):(_=O,O=t)):(_=O,O=t),O}function lI(){var O,W,ne;return O=_,r.substr(_,3)===y?(W=y,_+=3):(W=t,De===0&&Fe(_r)),W!==t?(ne=Hn(),ne!==t?(lr=O,O=T7(ne)):(_=O,O=t)):(_=O,O=t),O}function cI(){var O,W,ne,le;return O=_,r.charCodeAt(_)===114?(W=N,_++):(W=t,De===0&&Fe(en)),W!==t?(r.charCodeAt(_)===111?(ne=d,_++):(ne=t,De===0&&Fe(Un)),ne===t&&(ne=null),le=Gn(),le===t&&(le=null),lr=O,O=B7(ne,le)):(_=O,O=t),O}function fI(){var O,W,ne,le;return O=_,r.charCodeAt(_)===117?(W=w,_++):(W=t,De===0&&Fe(Ln)),W!==t?(r.charCodeAt(_)===111?(ne=d,_++):(ne=t,De===0&&Fe(Un)),ne===t&&(ne=null),le=Gn(),le===t&&(le=null),lr=O,O=$7(ne,le)):(_=O,O=t),O}function mI(){var O,W,ne;return O=_,r.substr(_,2)===x?(W=x,_+=2):(W=t,De===0&&Fe(Fu)),W!==t?(ne=Gn(),ne!==t?(lr=O,O=O7(ne)):(_=O,O=t)):(_=O,O=t),O}function vI(){var O,W,ne;return O=_,r.substr(_,2)===b?(W=b,_+=2):(W=t,De===0&&Fe(Tu)),W!==t?(ne=Gn(),ne!==t?(lr=O,O=I7(ne)):(_=O,O=t)):(_=O,O=t),O}function pI(){var O,W,ne;return O=_,r.charCodeAt(_)===115?(W=E,_++):(W=t,De===0&&Fe(Bu)),W!==t?(r.charCodeAt(_)===97?(ne=A,_++):(ne=t,De===0&&Fe($u)),ne===t&&(r.charCodeAt(_)===100?(ne=u,_++):(ne=t,De===0&&Fe(ar))),ne===t&&(ne=null),lr=O,O=R7(ne)):(_=O,O=t),O}function hI(){var O,W,ne;return O=_,r.charCodeAt(_)===102?(W=S,_++):(W=t,De===0&&Fe(Ou)),W!==t?(ne=Gn(),ne!==t?(lr=O,O=_7(ne)):(_=O,O=t)):(_=O,O=t),O}function Gn(){var O,W,ne;return O=_,W=dI(),W!==t?(ne=Hn(),ne!==t?(lr=O,O=q7(W,ne)):(_=O,O=t)):(_=O,O=t),O}function dI(){var O;return r.substr(_,2)===D?(O=D,_+=2):(O=t,De===0&&Fe(Iu)),O===t&&(r.substr(_,2)===T?(O=T,_+=2):(O=t,De===0&&Fe(Ru)),O===t&&(r.substr(_,2)===B?(O=B,_+=2):(O=t,De===0&&Fe(_u)),O===t&&(r.charCodeAt(_)===61?(O=I,_++):(O=t,De===0&&Fe(qu)),O===t&&(r.substr(_,2)===P?(O=P,_+=2):(O=t,De===0&&Fe(kn)),O===t&&(r.charCodeAt(_)===62?(O=R,_++):(O=t,De===0&&Fe(zu)),O===t&&(r.charCodeAt(_)===60?(O=M,_++):(O=t,De===0&&Fe(Pu)))))))),O}function qo(){var O,W,ne,le,Se,Ie,hr,Er,Ct,_a;if(O=nl(),O===t)if(O=_,r.charCodeAt(_)===40?(W=F,_++):(W=t,De===0&&Fe($a)),W!==t){if(Ar(),ne=_,le=Hn(),le!==t){if(Se=[],Ie=_,hr=Ar(),Er=zo(),Er!==t?(Ct=Ar(),_a=Hn(),_a!==t?(hr=[hr,Er,Ct,_a],Ie=hr):(_=Ie,Ie=t)):(_=Ie,Ie=t),Ie!==t)for(;Ie!==t;)Se.push(Ie),Ie=_,hr=Ar(),Er=zo(),Er!==t?(Ct=Ar(),_a=Hn(),_a!==t?(hr=[hr,Er,Ct,_a],Ie=hr):(_=Ie,Ie=t)):(_=Ie,Ie=t);else Se=t;Se!==t?(le=[le,Se],ne=le):(_=ne,ne=t)}else _=ne,ne=t;ne!==t?(le=Ar(),r.charCodeAt(_)===41?(Se=H,_++):(Se=t,De===0&&Fe(Oa)),Se!==t?(lr=O,O=z7()):(_=O,O=t)):(_=O,O=t)}else _=O,O=t;return O}function Dn(){var O,W,ne,le,Se,Ie,hr,Er;if(O=_,W=tl(),W!==t){for(ne=[],le=_,Se=Ar(),Ie=zo(),Ie!==t?(hr=Ar(),Er=tl(),Er!==t?(Se=[Se,Ie,hr,Er],le=Se):(_=le,le=t)):(_=le,le=t);le!==t;)ne.push(le),le=_,Se=Ar(),Ie=zo(),Ie!==t?(hr=Ar(),Er=tl(),Er!==t?(Se=[Se,Ie,hr,Er],le=Se):(_=le,le=t)):(_=le,le=t);lr=O,O=P7(W,ne)}else _=O,O=t;return O}function tl(){var O,W,ne,le;return O=gI(),O===t&&(O=eI(),O===t&&(O=Hn(),O===t&&(O=_,r.charCodeAt(_)===40?(W=F,_++):(W=t,De===0&&Fe($a)),W!==t?(Ar(),ne=Dn(),ne!==t?(Ar(),r.charCodeAt(_)===41?(le=H,_++):(le=t,De===0&&Fe(Oa)),le!==t?(lr=O,O=U7(W,ne,le)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t),O===t&&(O=j7())))),O}function gI(){var O,W,ne,le,Se,Ie,hr;return O=_,r.substr(_,3)===$?(W=$,_+=3):(W=t,De===0&&Fe(Uu)),W===t&&(r.substr(_,4)===k?(W=k,_+=4):(W=t,De===0&&Fe(Lu)),W===t&&(r.substr(_,3)===Q?(W=Q,_+=3):(W=t,De===0&&Fe(ku)),W===t&&(r.substr(_,3)===K?(W=K,_+=3):(W=t,De===0&&Fe(Vu)),W===t&&(r.substr(_,5)===L?(W=L,_+=5):(W=t,De===0&&Fe(Gu)),W===t&&(r.substr(_,3)===j?(W=j,_+=3):(W=t,De===0&&Fe(Hu)),W===t&&(r.substr(_,5)===ae?(W=ae,_+=5):(W=t,De===0&&Fe(Zu)),W===t&&(r.substr(_,4)===re?(W=re,_+=4):(W=t,De===0&&Fe(Ju)),W===t&&(r.substr(_,3)===fe?(W=fe,_+=3):(W=t,De===0&&Fe(Xu)),W===t&&(r.substr(_,4)===he?(W=he,_+=4):(W=t,De===0&&Fe(Wu)),W===t&&(r.substr(_,3)===ce?(W=ce,_+=3):(W=t,De===0&&Fe(Yu)))))))))))),W!==t?(r.charCodeAt(_)===40?(ne=F,_++):(ne=t,De===0&&Fe($a)),ne!==t?(Ar(),le=Dn(),le!==t?(Ar(),r.charCodeAt(_)===41?(Se=H,_++):(Se=t,De===0&&Fe(Oa)),Se!==t?(lr=O,O=L7(W,le)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t),O===t&&(O=_,r.substr(_,3)===ie?(W=ie,_+=3):(W=t,De===0&&Fe(Qu)),W===t&&(r.substr(_,3)===g?(W=g,_+=3):(W=t,De===0&&Fe(Fr)),W===t&&(r.substr(_,3)===y?(W=y,_+=3):(W=t,De===0&&Fe(_r)))),W!==t?(r.charCodeAt(_)===40?(ne=F,_++):(ne=t,De===0&&Fe($a)),ne!==t?(Ar(),le=Dn(),le!==t?(Ar(),r.charCodeAt(_)===44?(Se=f,_++):(Se=t,De===0&&Fe(Le)),Se!==t?(Ar(),Ie=Dn(),Ie!==t?(Ar(),r.charCodeAt(_)===41?(hr=H,_++):(hr=t,De===0&&Fe(Oa)),hr!==t?(lr=O,O=k7(W,le,Ie)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)),O}function Hn(){var O,W,ne,le,Se;return O=_,r.charCodeAt(_)===45?_++:De===0&&Fe(Mo),W=N0(),W!==t?(ne=_,ue.test(r.charAt(_))?(le=r.charAt(_),_++):(le=t,De===0&&Fe(Vn)),le!==t?(Se=N0(),Se!==t?(le=[le,Se],ne=le):(_=ne,ne=t)):(_=ne,ne=t),ne===t&&(ne=null),lr=O,O=V7()):(_=O,O=t),O}function nl(){var O,W,ne,le;if(O=_,ve.test(r.charAt(_))?(W=r.charAt(_),_++):(W=t,De===0&&Fe(jr)),W!==t){for(ne=[],de.test(r.charAt(_))?(le=r.charAt(_),_++):(le=t,De===0&&Fe(Tr));le!==t;)ne.push(le),de.test(r.charAt(_))?(le=r.charAt(_),_++):(le=t,De===0&&Fe(Tr));lr=O,O=G7()}else _=O,O=t;return O}function N0(){var O,W,ne;if(O=_,W=[],de.test(r.charAt(_))?(ne=r.charAt(_),_++):(ne=t,De===0&&Fe(Tr)),ne!==t)for(;ne!==t;)W.push(ne),de.test(r.charAt(_))?(ne=r.charAt(_),_++):(ne=t,De===0&&Fe(Tr));else W=t;return W!==t&&(lr=O,W=H7()),O=W,O}function zo(){var O,W;return O=_,r.substr(_,2)===Oe?(W=Oe,_+=2):(W=t,De===0&&Fe(Fo)),W!==t&&(lr=O,W=Z7()),O=W,O===t&&(r.charCodeAt(_)===42?(O=Ce,_++):(O=t,De===0&&Fe(Ku)),O===t&&(r.charCodeAt(_)===94?(O=$e,_++):(O=t,De===0&&Fe(Ia)),O===t&&(r.charCodeAt(_)===37?(O=V,_++):(O=t,De===0&&Fe(Ra)),O===t&&(r.charCodeAt(_)===47?(O=X,_++):(O=t,De===0&&Fe(To)),O===t&&(r.charCodeAt(_)===43?(O=oe,_++):(O=t,De===0&&Fe(Bo)),O===t&&(r.charCodeAt(_)===45?(O=Ae,_++):(O=t,De===0&&Fe(Mo)))))))),O}function D0(){var O;return De++,O=yI(),O===t&&(O=bI()),De--,O===t&&De===0&&Fe(wn),O}function yI(){var O,W,ne,le,Se,Ie;if(O=_,r.substr(_,2)===G?(W=G,_+=2):(W=t,De===0&&Fe(f7)),W!==t){for(ne=[],le=_,Se=_,De++,r.substr(_,2)===Y?(Ie=Y,_+=2):(Ie=t,De===0&&Fe(ju)),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe($o)),Ie!==t?(Se=[Se,Ie],le=Se):(_=le,le=t)):(_=le,le=t);le!==t;)ne.push(le),le=_,Se=_,De++,r.substr(_,2)===Y?(Ie=Y,_+=2):(Ie=t,De===0&&Fe(ju)),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe($o)),Ie!==t?(Se=[Se,Ie],le=Se):(_=le,le=t)):(_=le,le=t);r.substr(_,2)===Y?(le=Y,_+=2):(le=t,De===0&&Fe(ju)),le!==t?(lr=O,O=J7(ne)):(_=O,O=t)}else _=O,O=t;if(O===t)if(O=_,r.charCodeAt(_)===91?(W=te,_++):(W=t,De===0&&Fe(m7)),W!==t){for(ne=[],be.test(r.charAt(_))?(le=r.charAt(_),_++):(le=t,De===0&&Fe(y0));le!==t;)ne.push(le),be.test(r.charAt(_))?(le=r.charAt(_),_++):(le=t,De===0&&Fe(y0));r.charCodeAt(_)===93?(le=ye,_++):(le=t,De===0&&Fe(v7)),le!==t?(lr=O,O=X7(ne)):(_=O,O=t)}else _=O,O=t;return O}function bI(){var O,W,ne,le,Se,Ie;if(O=_,r.substr(_,2)===me?(W=me,_+=2):(W=t,De===0&&Fe(p7)),W===t&&(r.charCodeAt(_)===35?(W=z,_++):(W=t,De===0&&Fe(h7))),W!==t){for(ne=[],le=_,Se=_,De++,Ie=A0(),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe($o)),Ie!==t?(Se=[Se,Ie],le=Se):(_=le,le=t)):(_=le,le=t);le!==t;)ne.push(le),le=_,Se=_,De++,Ie=A0(),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe($o)),Ie!==t?(Se=[Se,Ie],le=Se):(_=le,le=t)):(_=le,le=t);lr=O,O=W7(ne)}else _=O,O=t;return O}function A0(){var O;return pe.test(r.charAt(_))?(O=r.charAt(_),_++):(O=t,De===0&&Fe(d7)),O}function Po(){var O;return De++,we.test(r.charAt(_))?(O=r.charAt(_),_++):(O=t,De===0&&Fe(y7)),De--,O===t&&De===0&&Fe(g7),O}function Ar(){var O,W;for(O=[],W=Po();W!==t;)O.push(W),W=Po();return O}function E0(){var O,W;for(De++,O=[],W=Po(),W===t&&(W=D0());W!==t;)O.push(W),W=Po(),W===t&&(W=D0());return De--,W=t,De===0&&Fe(b7),O}if(Io=i(),Io!==t&&_===r.length)return Io;throw Io!==t&&_<r.length&&Fe(Q7()),K7(el,Ut<r.length?r.charAt(Ut):null,Ut<r.length?x0(Ut,Ut+1):x0(Ut,Ut))}class v0{static parse(e){if(!e)throw new zt("notation");if(typeof e!="string")throw new TypeError("Notation must be a string");return z9(e)}}const Fa=Object.freeze({BASE_64:1,JSON:0,OBJECT:2}),Au=Symbol("notation"),Eu=Symbol("maxTotal"),Su=Symbol("minTotal"),Ta=Symbol("expressions"),Eo=Symbol("roll-method"),xn=Symbol("rolls"),p0=Symbol("set-rolls"),So=Symbol("total"),Cu=r=>Z6(r.calculationValue,2);class si{constructor(e){if(!e)throw new zt("notation");if(this[Ta]=[],e instanceof Object&&!Array.isArray(e)){if(e.notation){if(typeof e.notation!="string")throw new yo(e.notation);e.rolls&&this[p0](e.rolls)}else throw new zt("notation");this[Au]=e.notation,this[Ta]=v0.parse(this.notation),this.hasRolls()||this.roll()}else if(typeof e=="string")this[Au]=e,this[Ta]=v0.parse(this.notation),this.roll();else throw new yo(e)}get averageTotal(){return(this.maxTotal+this.minTotal)/2}get maxTotal(){if(!this.hasExpressions())return 0;if(!this[Eu]){const e=this[Eo](zd.max);this[Eu]=Cu(e)}return this[Eu]}get minTotal(){if(!this.hasExpressions())return 0;if(!this[Su]){const e=this[Eo](zd.min);this[Su]=Cu(e)}return this[Su]}get notation(){return this[Au]}get output(){let e=`${this.notation}: `;return this.hasRolls()?e+=`${this[xn]} = ${this.total}`:e+="No dice rolled",e}get rolls(){return this[xn]?this[xn].results:[]}get total(){return!this[So]&&this.hasRolls()&&(this[So]=Cu(this[xn])),this[So]||0}export(e=Fa.JSON){switch(e){case Fa.BASE_64:return btoa(this.export(Fa.JSON));case Fa.JSON:return JSON.stringify(this);case Fa.OBJECT:return JSON.parse(this.export(Fa.JSON));default:throw new TypeError(`Invalid export format "${e}"`)}}hasExpressions(){return this[Ta]&&this[Ta].length>0}hasRolls(){return this.hasExpressions()&&this.rolls.length>0}roll(){return this[So]=0,this[xn]=this[Eo](),this.rolls}toJSON(){const{averageTotal:e,maxTotal:t,minTotal:a,notation:n,output:i,rolls:o,total:f}=this;return{averageTotal:e,maxTotal:t,minTotal:a,notation:n,output:i,rolls:o,total:f,type:"dice-roll"}}toString(){return this.output}static import(e){if(e){if(_9(e))return si.import(JSON.parse(e));if(R9(e))return si.import(atob(e));if(typeof e=="object")return new si(e);throw new Ys(e)}else throw new zt("data")}[Eo](e){let t;e&&(t=Ea.engine,Ea.engine=e);const a=new kr(this[Ta].map(n=>n instanceof Ca||n instanceof m0?n.roll():n).filter(n=>!!n||n===0));return e&&(Ea.engine=t),a}[p0](e){if(e instanceof kr)this[xn]=e;else if(e instanceof jt)this[xn]=new kr([e]);else if(Array.isArray(e))this[xn]=new kr(e.map(t=>{if(t instanceof kr||t instanceof jt)return t;if(Array.isArray(t))return new jt(t);if(typeof t=="object"){if(Array.isArray(t.results))return new kr(t.results,t.modifiers||[],t.isRollGroup||!1,typeof t.useInTotal=="boolean"?t.useInTotal:!0);if(Array.isArray(t.rolls))return new jt(t.rolls)}return t}));else throw new TypeError("Rolls must be a valid result object, or an array")}}const Co={__name:"DiceRollerRenderless",props:{notation:String},emits:["notation:change","roll"],setup(r,{emit:e}){const t=r,a=Ne.ref(`${t.notation||""}`),n=Ne.ref(null),i=Ne.ref(null),o=async()=>{n.value=null;try{i.value=a.value?new si(Ne.unref(a)):null}catch(l){i.value=null,l.name==="SyntaxError"?n.value=`Invalid notation; ${l.message}`:n.value=`An error has occurred: ${l.message}`}finally{e("roll",Ne.unref(a),Ne.unref(i))}},f=l=>{a.value=l,e("notation:change",l)};return(l,u)=>Ne.renderSlot(l.$slots,"default",{currentNotation:a.value,error:n.value,output:i.value,roll:o,bind:{value:a.value},on:{input:s=>f(s.target.value),change:s=>f(s.target.value),keyup:s=>s.keyCode===13?o():void 0}})}},P9=()=>typeof crypto<"u"&&crypto&&crypto.randomUUID,U9=()=>P9()?crypto.randomUUID():`${Date.now().toString(32)}-${Math.random().toString(36).substring(2)}`;function Mu(r){const e=Ne.ref(null);return e.value=`${r}${U9()}`,{id:e}}const L9=["id"],k9=["for"],V9=["for"],G9=["id","placeholder"],H9=["onClick"],Z9={__name:"DiceRoller",props:{btnLabel:{type:String,default:"Roll"},className:{type:String,default:"dice-roller"},id:String,notation:String},emits:["notation:change","roll"],setup(r){const e=r,{id:t}=Mu(`${e.id||"dice-roller"}-`);return(a,n)=>(Ne.openBlock(),Ne.createBlock(Co,{notation:r.notation,"onNotation:change":n[0]||(n[0]=i=>a.$emit("notation:change",i)),onRoll:n[1]||(n[1]=i=>a.$emit("roll",i))},{default:Ne.withCtx(({error:i,output:o,roll:f,on:l,bind:u})=>[Ne.createElementVNode("section",{id:r.id,class:Ne.normalizeClass(r.className)},[o?(Ne.openBlock(),Ne.createElementBlock("output",{key:0,name:"output",for:Ne.unref(t),class:Ne.normalizeClass(`${r.className}-output`)},Ne.toDisplayString(o),11,k9)):Ne.createCommentVNode("",!0),Ne.createElementVNode("div",{class:Ne.normalizeClass(`${r.className}-input-group`)},[Ne.createElementVNode("label",{for:Ne.unref(t),class:Ne.normalizeClass(`${r.className}-label`)}," Notation ",10,V9),Ne.createElementVNode("input",Ne.mergeProps({type:"text",name:"notation",id:Ne.unref(t),placeholder:`e.g. ${r.notation||"4d6"}`,class:[`${r.className}-input`,i?`${r.className}-input-invalid`:null]},Ne.toHandlers(l,!0),u),null,16,G9),Ne.createElementVNode("button",{type:"button",class:Ne.normalizeClass(`${r.className}-button`),onClick:f},[Ne.renderSlot(a.$slots,"button",{},()=>[Ne.createTextVNode(Ne.toDisplayString(r.btnLabel),1)])],10,H9)],2),i?(Ne.openBlock(),Ne.createElementBlock("span",{key:1,class:Ne.normalizeClass(`${r.className}-error`)},Ne.toDisplayString(i),3)):Ne.createCommentVNode("",!0)],10,L9)]),_:3},8,["notation"]))}},J9=["id"],X9=["for"],W9={class:"flex flex-col sm:flex-row gap-y-4"},Y9=["for"],Q9=["id","placeholder"],K9=["onClick"],j9={key:1,class:"block mt-4 text-red-600 text-sm dark:text-red-200"},e7={__name:"DiceRollerTailwind",props:{btnLabel:{type:String,default:"Roll"},id:String,notation:String},emits:["notation:change","roll"],setup(r){const e=r,{id:t}=Mu(`${e.id||"dice-roller"}-`);return(a,n)=>(Ne.openBlock(),Ne.createBlock(Co,{notation:r.notation,"onNotation:change":n[0]||(n[0]=i=>a.$emit("notation:change",i)),onRoll:n[1]||(n[1]=i=>a.$emit("roll",i))},{default:Ne.withCtx(({error:i,output:o,roll:f,on:l,bind:u})=>[Ne.createElementVNode("div",{id:r.id,class:"dice-roller p-4 rounded bg-slate-100 text-gray-800 dark:bg-gray-600 dark:text-gray-200"},[o?(Ne.openBlock(),Ne.createElementBlock("output",{key:0,name:"output",for:Ne.unref(t),class:"block mb-8 p-4 text-2xl rounded bg-white text-black dark:bg-gray-300 dark:text-gray-800 border-l-8 border-[#d4f4c6]"},Ne.toDisplayString(o),9,X9)):Ne.createCommentVNode("",!0),Ne.createElementVNode("div",W9,[Ne.createElementVNode("label",{for:Ne.unref(t),class:"sr-only"}," Notation ",8,Y9),Ne.createElementVNode("input",Ne.mergeProps({type:"text",name:"notation",id:Ne.unref(t),placeholder:`e.g. ${r.notation||"4d6"}`,class:["flex-auto block w-full h-11 py-2 px-4 text-base border shadow-sm rounded placeholder-gray-500 focus:ring-[#d4f4c6] focus:border-[#d4f4c6] focus:outline-none focus:placeholder-gray-400 dark:focus:placeholder-gray-400 invalid:text-red-600 invalid:border-red-200 invalid:bg-red-50 sm:border-r-0 sm:rounded-r-none",i?"text-red-600 border-red-200 bg-red-50":"bg-white text-gray-900 border-gray-300 dark:text-gray-600 dark:bg-gray-50 dark:border-gray-700"]},Ne.toHandlers(l,!0),u),null,16,Q9),Ne.createElementVNode("button",{type:"button",class:"block px-8 h-11 font-bold text-gray-600 bg-gradient-to-br from-[#eda18b] to-[#d4f4c6] border border-l-0 border-gray-300 rounded transition dark:border-gray-700 focus:from-[#e88c71] focus:to-[#bbf0a3] focus:text-gray-800 focus:ring-[#d4f4c6] focus:border-[#d4f4c6] focus:outline-none hover:from-[#e88c71] hover:to-[#bbf0a3] hover:text-gray-800 sm:rounded-l-none",onClick:f},[Ne.renderSlot(a.$slots,"button",{},()=>[Ne.createTextVNode(Ne.toDisplayString(r.btnLabel),1)])],8,K9)]),i?(Ne.openBlock(),Ne.createElementBlock("span",j9,Ne.toDisplayString(i),1)):Ne.createCommentVNode("",!0)],8,J9)]),_:3},8,["notation"]))}},r7=["id"],t7={class:"card-body"},n7=["for"],a7=["for"],i7={class:"input-group"},o7=["id","placeholder"],s7=["onClick"],u7={key:1,class:"d-block mt-3 invalid-feedback"},Ba=["primary","secondary","success","danger","warning","info","light","dark"],h0=[...Ba,"body","white","transparent"],d0=[...Ba,"body","muted","white","black-50","white-50"],l7=[...Ba,"link","outline-primary","outline-secondary","outline-success","outline-danger","outline-warning","outline-info","outline-light","outline-dark"],g0=[...Ba,"white"],c7={__name:"DiceRollerBootstrap",props:{bgVariant:{type:String,validator(r){return h0.includes(r)}},borderVariant:{type:String,validator(r){return g0.includes(r)}},btnLabel:{type:String,default:"Roll"},btnVariant:{type:String,default:"primary",validator(r){return l7.includes(r)}},id:String,notation:String,outputBgVariant:{type:String,validator(r){return h0.includes(r)}},outputBorderVariant:{type:String,validator(r){return g0.includes(r)}},outputTextVariant:{type:String,validator(r){return d0.includes(r)}},outputVariant:{type:String,validator(r){return Ba.includes(r)}},textVariant:{type:String,validator(r){return d0.includes(r)}},variant:{type:String,validator(r){return Ba.includes(r)}}},emits:["notation:change","roll"],setup(r){const e=r,t=Ne.computed(()=>({[`text-bg-${e.variant}`]:e.variant,[`bg-${e.bgVariant}`]:e.bgVariant,[`text-${e.textVariant}`]:e.textVariant,[`border-${e.borderVariant}`]:e.borderVariant})),a=Ne.computed(()=>({[`text-bg-${e.outputVariant}`]:e.outputVariant,[`bg-${e.outputBgVariant}`]:e.outputBgVariant,[`text-${e.outputTextVariant}`]:e.outputTextVariant,[`border-${e.outputBorderVariant}`]:e.outputBorderVariant})),n=Ne.computed(()=>`btn-${e.btnVariant||"primary"}`),{id:i}=Mu(`${e.id||"dice-roller"}-`);return(o,f)=>(Ne.openBlock(),Ne.createBlock(Co,{notation:r.notation,"onNotation:change":f[0]||(f[0]=l=>o.$emit("notation:change",l)),onRoll:f[1]||(f[1]=l=>o.$emit("roll",l))},{default:Ne.withCtx(({error:l,output:u,roll:s,on:c,bind:m})=>[Ne.createElementVNode("div",{id:r.id,class:Ne.normalizeClass(["dice-roller card",t.value])},[Ne.createElementVNode("div",t7,[u?(Ne.openBlock(),Ne.createElementBlock("output",{key:0,name:"output",for:Ne.unref(i),class:Ne.normalizeClass(["d-block mb-4 p-3 fs-4 rounded border",a.value])},Ne.toDisplayString(u),11,n7)):Ne.createCommentVNode("",!0),Ne.createElementVNode("label",{for:Ne.unref(i),class:"form-label visually-hidden"}," Notation ",8,a7),Ne.createElementVNode("div",i7,[Ne.createElementVNode("input",Ne.mergeProps({type:"text",name:"notation",id:Ne.unref(i),placeholder:`e.g. ${r.notation||"4d6"}`,class:["form-control",l?"is-invalid":""]},Ne.toHandlers(c,!0),m),null,16,o7),Ne.createElementVNode("button",{type:"button",class:Ne.normalizeClass(["btn",n.value]),onClick:s},[Ne.renderSlot(o.$slots,"button",{},()=>[Ne.createTextVNode(Ne.toDisplayString(r.btnLabel),1)])],10,s7)]),l?(Ne.openBlock(),Ne.createElementBlock("span",u7,Ne.toDisplayString(l),1)):Ne.createCommentVNode("",!0)])],10,r7)]),_:3},8,["notation"]))}};Vr.DiceRoller=Z9,Vr.DiceRollerBootstrap=c7,Vr.DiceRollerRenderless=Co,Vr.DiceRollerTailwind=e7,Object.defineProperties(Vr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
82
|
+
`+l+" | "+Eu("",n.column-1," ")+Eu("",c,"^")}else e+=`
|
|
83
|
+
at `+o}return e},Fa.buildMessage=function(r,e){var t={literal:function(u){return'"'+n(u.text)+'"'},class:function(u){var s=u.parts.map(function(c){return Array.isArray(c)?i(c[0])+"-"+i(c[1]):i(c)});return"["+(u.inverted?"^":"")+s.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(u){return u.description}};function a(u){return u.charCodeAt(0).toString(16).toUpperCase()}function n(u){return u.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(s){return"\\x0"+a(s)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(s){return"\\x"+a(s)})}function i(u){return u.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(s){return"\\x0"+a(s)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(s){return"\\x"+a(s)})}function o(u){return t[u.type](u)}function f(u){var s=u.map(o),c,m;if(s.sort(),s.length>0){for(c=1,m=1;c<s.length;c++)s[c-1]!==s[c]&&(s[m]=s[c],m++);s.length=m}switch(s.length){case 1:return s[0];case 2:return s[0]+" or "+s[1];default:return s.slice(0,-1).join(", ")+", or "+s[s.length-1]}}function l(u){return u?'"'+n(u)+'"':"end of input"}return"Expected "+f(r)+" but "+l(e)+" found."};function z9(r,e){e=e!==void 0?e:{};var t={},a=e.grammarSource,n={Main:T0},i=T0,o="{",f=",",l="}",u="d",s="d%",c="dF",m=".",v="!",h="p",p="k",g="max",y="min",N="r",d="o",w="u",x="cs",b="cf",E="s",A="a",S="f",D="!=",T="<=",B=">=",I="=",P="<>",R=">",M="<",F="(",H=")",$="abs",k="ceil",Q="cos",K="exp",L="floor",j="log",ae="round",re="sign",fe="sin",he="sqrt",ce="tan",ie="pow",Ae="-",Oe="**",Ce="*",$e="^",V="%",X="/",oe="+",G="/*",Y="*/",te="[",ye="]",me="//",z="#",U=/^[12]/,ee=/^[lh]/,ue=/^[.]/,ve=/^[1-9]/,de=/^[0-9]/,be=/^[^\]]/,pe=/^[\n\r\u2028\u2029]/,we=/^[ \t\n\r]/,_e=Ue("{",!1),Le=Ue(",",!1),Be=Ue("}",!1),ar=Ue("d",!1),Je=Ue("d%",!1),mr=Ue("dF",!1),C=Ue(".",!1),Z=Dn(["1","2"],!1,!1),se=Ue("!",!1),Ee=Ue("p",!1),ze=Dn(["l","h"],!1,!1),ke=Ue("k",!1),Fr=Ue("max",!1),_r=Ue("min",!1),tn=Ue("r",!1),Ln=Ue("o",!1),kn=Ue("u",!1),Bu=Ue("cs",!1),$u=Ue("cf",!1),Ou=Ue("s",!1),Iu=Ue("a",!1),Ru=Ue("f",!1),_u=Ue("!=",!1),qu=Ue("<=",!1),zu=Ue(">=",!1),Pu=Ue("=",!1),Vn=Ue("<>",!1),Uu=Ue(">",!1),Lu=Ue("<",!1),Oa=Ue("(",!1),Ia=Ue(")",!1),ku=Ue("abs",!1),Vu=Ue("ceil",!1),Gu=Ue("cos",!1),Hu=Ue("exp",!1),Zu=Ue("floor",!1),Ju=Ue("log",!1),Xu=Ue("round",!1),Wu=Ue("sign",!1),Yu=Ue("sin",!1),Qu=Ue("sqrt",!1),Ku=Ue("tan",!1),ju=Ue("pow",!1),Mo=Ue("-",!1),Gn=Dn(["."],!1,!1),jr=Dn([["1","9"]],!1,!1),Tr=Dn([["0","9"]],!1,!1),Fo=Ue("**",!1),el=Ue("*",!1),Ra=Ue("^",!1),_a=Ue("%",!1),To=Ue("/",!1),Bo=Ue("+",!1),Nn=nl("comment"),f7=Ue("/*",!1),rl=Ue("*/",!1),$o=Y7(),m7=Ue("[",!1),C0=Dn(["]"],!0,!1),v7=Ue("]",!1),p7=Ue("//",!1),h7=Ue("#",!1),d7=Dn([`
|
|
84
|
+
`,"\r","\u2028","\u2029"],!1,!1),g7=nl("whitespace"),y7=Dn([" "," ",`
|
|
85
|
+
`,"\r"],!1,!1),b7=nl("whitespace or comment"),x7=function(O,W,ne,le){return new w0([O,...W.map(Se=>Se[3])],Object.assign({},...ne.map(Se=>({[Se.name]:Se}))),le.find(Se=>Se instanceof Ct))},w7=function(O,W,ne){return O.modifiers=Object.assign({},...W.map(le=>({[le.name]:le}))),O.description=ne.find(le=>le instanceof Ct),O},N7=function(O,W){return new Ca(W,O||1)},D7=function(O){return new O9(O||1)},A7=function(O,W){return new $9(W?parseInt(W[1],10):2,O||1)},E7=function(O,W,ne){return new u0(ne,!!O,!!W)},S7=function(O,W){return new y0(O,W)},C7=function(O,W){return new i0(O||"l",W)},M7=function(O,W){return new Nu(O||"h",W)},F7=function(O){return new c0(O)},T7=function(O){return new m0(O)},B7=function(O,W){return new p0(!!O,W)},$7=function(O,W){return new x0(!!O,W)},O7=function(O){return new e0(O)},I7=function(O){return new jd(O)},R7=function(O){return new d0(O||"a")},_7=function(O){return O},q7=function(O,W){return new Ao(O,W)},z7=function(O,W,ne){return Sd(Ro())},P7=function(O,W){return O=Array.isArray(O)?O:[O],[...O,...W.map(([,ne,,le])=>[ne,le]).flat(2)]},U7=function(O,W,ne){return[O,...W,ne]},L7=function(O,W){return[`${O}(`,...W,")"]},k7=function(O,W,ne){return[`${O}(`,...W,",",...ne,")"]},V7=function(){return parseFloat(Ro())},G7=function(){return parseInt(Ro(),10)},H7=function(){return parseInt(Ro(),10)},Z7=function(){return"^"},J7=function(O){return new Ct(O.flat().join(""),Ct.types.MULTILINE)},X7=function(O){return new Ct(O.flat().join(""),Ct.types.MULTILINE)},W7=function(O){return new Ct(O.flat().join(""),Ct.types.INLINE)},_=0,lr=0,Oo=[{line:1,column:1}],Lt=0,tl=[],De=0,Io;if("startRule"in e){if(!(e.startRule in n))throw new Error(`Can't start parsing from rule "`+e.startRule+'".');i=n[e.startRule]}function Ro(){return r.substring(lr,_)}function Ue(O,W){return{type:"literal",text:O,ignoreCase:W}}function Dn(O,W,ne){return{type:"class",parts:O,inverted:W,ignoreCase:ne}}function Y7(){return{type:"any"}}function Q7(){return{type:"end"}}function nl(O){return{type:"other",description:O}}function M0(O){var W=Oo[O],ne;if(W)return W;for(ne=O-1;!Oo[ne];)ne--;for(W=Oo[ne],W={line:W.line,column:W.column};ne<O;)r.charCodeAt(ne)===10?(W.line++,W.column=1):W.column++,ne++;return Oo[O]=W,W}function F0(O,W,ne){var le=M0(O),Se=M0(W),Ie={source:a,start:{offset:O,line:le.line,column:le.column},end:{offset:W,line:Se.line,column:Se.column}};return ne&&a&&typeof a.offset=="function"&&(Ie.start=a.offset(Ie.start),Ie.end=a.offset(Ie.end)),Ie}function Fe(O){_<Lt||(_>Lt&&(Lt=_,tl=[]),tl.push(O))}function K7(O,W,ne){return new Fa(Fa.buildMessage(O,W),O,W,ne)}function T0(){var O;return O=An(),O}function j7(){var O,W,ne,le,Se,Ie,hr,Er,Mt;if(O=_,r.charCodeAt(_)===123?(W=o,_++):(W=t,De===0&&Fe(_e)),W!==t)if(Ar(),ne=An(),ne!==t){for(le=[],Se=_,Ie=Ar(),r.charCodeAt(_)===44?(hr=f,_++):(hr=t,De===0&&Fe(Le)),hr!==t?(Er=Ar(),Mt=An(),Mt!==t?(Ie=[Ie,hr,Er,Mt],Se=Ie):(_=Se,Se=t)):(_=Se,Se=t);Se!==t;)le.push(Se),Se=_,Ie=Ar(),r.charCodeAt(_)===44?(hr=f,_++):(hr=t,De===0&&Fe(Le)),hr!==t?(Er=Ar(),Mt=An(),Mt!==t?(Ie=[Ie,hr,Er,Mt],Se=Ie):(_=Se,Se=t)):(_=Se,Se=t);if(Se=Ar(),r.charCodeAt(_)===125?(Ie=l,_++):(Ie=t,De===0&&Fe(Be)),Ie!==t){for(hr=[],Er=_o();Er!==t;)hr.push(Er),Er=_o();Er=I0(),lr=O,O=x7(ne,le,hr,Er)}else _=O,O=t}else _=O,O=t;else _=O,O=t;return O}function eI(){var O,W,ne,le;if(O=_,W=rI(),W===t&&(W=tI(),W===t&&(W=nI())),W!==t){for(ne=[],le=_o();le!==t;)ne.push(le),le=_o();le=I0(),lr=O,O=w7(W,ne,le)}else _=O,O=t;return O}function rI(){var O,W,ne,le;return O=_,W=qo(),W===t&&(W=null),r.charCodeAt(_)===100?(ne=u,_++):(ne=t,De===0&&Fe(ar)),ne!==t?(le=qo(),le!==t?(lr=O,O=N7(W,le)):(_=O,O=t)):(_=O,O=t),O}function tI(){var O,W,ne;return O=_,W=qo(),W===t&&(W=null),r.substr(_,2)===s?(ne=s,_+=2):(ne=t,De===0&&Fe(Je)),ne!==t?(lr=O,O=D7(W)):(_=O,O=t),O}function nI(){var O,W,ne,le,Se,Ie;return O=_,W=qo(),W===t&&(W=null),r.substr(_,2)===c?(ne=c,_+=2):(ne=t,De===0&&Fe(mr)),ne!==t?(le=_,r.charCodeAt(_)===46?(Se=m,_++):(Se=t,De===0&&Fe(C)),Se!==t?(U.test(r.charAt(_))?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe(Z)),Ie!==t?(Se=[Se,Ie],le=Se):(_=le,le=t)):(_=le,le=t),le===t&&(le=null),lr=O,O=A7(W,le)):(_=O,O=t),O}function _o(){var O;return O=aI(),O===t&&(O=iI(),O===t&&(O=oI(),O===t&&(O=sI(),O===t&&(O=cI(),O===t&&(O=fI(),O===t&&(O=mI(),O===t&&(O=vI(),O===t&&(O=pI(),O===t&&(O=uI(),O===t&&(O=lI())))))))))),O}function aI(){var O,W,ne,le,Se;return O=_,r.charCodeAt(_)===33?(W=v,_++):(W=t,De===0&&Fe(se)),W!==t?(r.charCodeAt(_)===33?(ne=v,_++):(ne=t,De===0&&Fe(se)),ne===t&&(ne=null),r.charCodeAt(_)===112?(le=h,_++):(le=t,De===0&&Fe(Ee)),le===t&&(le=null),Se=Hn(),Se===t&&(Se=null),lr=O,O=E7(ne,le,Se)):(_=O,O=t),O}function iI(){var O,W,ne;return O=_,W=Hn(),W!==t?(ne=hI(),ne===t&&(ne=null),lr=O,O=S7(W,ne)):(_=O,O=t),O}function oI(){var O,W,ne,le;return O=_,r.charCodeAt(_)===100?(W=u,_++):(W=t,De===0&&Fe(ar)),W!==t?(ee.test(r.charAt(_))?(ne=r.charAt(_),_++):(ne=t,De===0&&Fe(ze)),ne===t&&(ne=null),le=il(),le!==t?(lr=O,O=C7(ne,le)):(_=O,O=t)):(_=O,O=t),O}function sI(){var O,W,ne,le;return O=_,r.charCodeAt(_)===107?(W=p,_++):(W=t,De===0&&Fe(ke)),W!==t?(ee.test(r.charAt(_))?(ne=r.charAt(_),_++):(ne=t,De===0&&Fe(ze)),ne===t&&(ne=null),le=il(),le!==t?(lr=O,O=M7(ne,le)):(_=O,O=t)):(_=O,O=t),O}function uI(){var O,W,ne;return O=_,r.substr(_,3)===g?(W=g,_+=3):(W=t,De===0&&Fe(Fr)),W!==t?(ne=Zn(),ne!==t?(lr=O,O=F7(ne)):(_=O,O=t)):(_=O,O=t),O}function lI(){var O,W,ne;return O=_,r.substr(_,3)===y?(W=y,_+=3):(W=t,De===0&&Fe(_r)),W!==t?(ne=Zn(),ne!==t?(lr=O,O=T7(ne)):(_=O,O=t)):(_=O,O=t),O}function cI(){var O,W,ne,le;return O=_,r.charCodeAt(_)===114?(W=N,_++):(W=t,De===0&&Fe(tn)),W!==t?(r.charCodeAt(_)===111?(ne=d,_++):(ne=t,De===0&&Fe(Ln)),ne===t&&(ne=null),le=Hn(),le===t&&(le=null),lr=O,O=B7(ne,le)):(_=O,O=t),O}function fI(){var O,W,ne,le;return O=_,r.charCodeAt(_)===117?(W=w,_++):(W=t,De===0&&Fe(kn)),W!==t?(r.charCodeAt(_)===111?(ne=d,_++):(ne=t,De===0&&Fe(Ln)),ne===t&&(ne=null),le=Hn(),le===t&&(le=null),lr=O,O=$7(ne,le)):(_=O,O=t),O}function mI(){var O,W,ne;return O=_,r.substr(_,2)===x?(W=x,_+=2):(W=t,De===0&&Fe(Bu)),W!==t?(ne=Hn(),ne===t&&(ne=null),lr=O,O=O7(ne)):(_=O,O=t),O}function vI(){var O,W,ne;return O=_,r.substr(_,2)===b?(W=b,_+=2):(W=t,De===0&&Fe($u)),W!==t?(ne=Hn(),ne===t&&(ne=null),lr=O,O=I7(ne)):(_=O,O=t),O}function pI(){var O,W,ne;return O=_,r.charCodeAt(_)===115?(W=E,_++):(W=t,De===0&&Fe(Ou)),W!==t?(r.charCodeAt(_)===97?(ne=A,_++):(ne=t,De===0&&Fe(Iu)),ne===t&&(r.charCodeAt(_)===100?(ne=u,_++):(ne=t,De===0&&Fe(ar))),ne===t&&(ne=null),lr=O,O=R7(ne)):(_=O,O=t),O}function hI(){var O,W,ne;return O=_,r.charCodeAt(_)===102?(W=S,_++):(W=t,De===0&&Fe(Ru)),W!==t?(ne=Hn(),ne!==t?(lr=O,O=_7(ne)):(_=O,O=t)):(_=O,O=t),O}function Hn(){var O,W,ne;return O=_,W=dI(),W!==t?(ne=Zn(),ne!==t?(lr=O,O=q7(W,ne)):(_=O,O=t)):(_=O,O=t),O}function dI(){var O;return r.substr(_,2)===D?(O=D,_+=2):(O=t,De===0&&Fe(_u)),O===t&&(r.substr(_,2)===T?(O=T,_+=2):(O=t,De===0&&Fe(qu)),O===t&&(r.substr(_,2)===B?(O=B,_+=2):(O=t,De===0&&Fe(zu)),O===t&&(r.charCodeAt(_)===61?(O=I,_++):(O=t,De===0&&Fe(Pu)),O===t&&(r.substr(_,2)===P?(O=P,_+=2):(O=t,De===0&&Fe(Vn)),O===t&&(r.charCodeAt(_)===62?(O=R,_++):(O=t,De===0&&Fe(Uu)),O===t&&(r.charCodeAt(_)===60?(O=M,_++):(O=t,De===0&&Fe(Lu)))))))),O}function qo(){var O,W,ne,le,Se,Ie,hr,Er,Mt,qa;if(O=il(),O===t)if(O=_,r.charCodeAt(_)===40?(W=F,_++):(W=t,De===0&&Fe(Oa)),W!==t){if(Ar(),ne=_,le=Zn(),le!==t){if(Se=[],Ie=_,hr=Ar(),Er=zo(),Er!==t?(Mt=Ar(),qa=Zn(),qa!==t?(hr=[hr,Er,Mt,qa],Ie=hr):(_=Ie,Ie=t)):(_=Ie,Ie=t),Ie!==t)for(;Ie!==t;)Se.push(Ie),Ie=_,hr=Ar(),Er=zo(),Er!==t?(Mt=Ar(),qa=Zn(),qa!==t?(hr=[hr,Er,Mt,qa],Ie=hr):(_=Ie,Ie=t)):(_=Ie,Ie=t);else Se=t;Se!==t?(le=[le,Se],ne=le):(_=ne,ne=t)}else _=ne,ne=t;ne!==t?(le=Ar(),r.charCodeAt(_)===41?(Se=H,_++):(Se=t,De===0&&Fe(Ia)),Se!==t?(lr=O,O=z7()):(_=O,O=t)):(_=O,O=t)}else _=O,O=t;return O}function An(){var O,W,ne,le,Se,Ie,hr,Er;if(O=_,W=al(),W!==t){for(ne=[],le=_,Se=Ar(),Ie=zo(),Ie!==t?(hr=Ar(),Er=al(),Er!==t?(Se=[Se,Ie,hr,Er],le=Se):(_=le,le=t)):(_=le,le=t);le!==t;)ne.push(le),le=_,Se=Ar(),Ie=zo(),Ie!==t?(hr=Ar(),Er=al(),Er!==t?(Se=[Se,Ie,hr,Er],le=Se):(_=le,le=t)):(_=le,le=t);lr=O,O=P7(W,ne)}else _=O,O=t;return O}function al(){var O,W,ne,le;return O=gI(),O===t&&(O=eI(),O===t&&(O=Zn(),O===t&&(O=_,r.charCodeAt(_)===40?(W=F,_++):(W=t,De===0&&Fe(Oa)),W!==t?(Ar(),ne=An(),ne!==t?(Ar(),r.charCodeAt(_)===41?(le=H,_++):(le=t,De===0&&Fe(Ia)),le!==t?(lr=O,O=U7(W,ne,le)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t),O===t&&(O=j7())))),O}function gI(){var O,W,ne,le,Se,Ie,hr;return O=_,r.substr(_,3)===$?(W=$,_+=3):(W=t,De===0&&Fe(ku)),W===t&&(r.substr(_,4)===k?(W=k,_+=4):(W=t,De===0&&Fe(Vu)),W===t&&(r.substr(_,3)===Q?(W=Q,_+=3):(W=t,De===0&&Fe(Gu)),W===t&&(r.substr(_,3)===K?(W=K,_+=3):(W=t,De===0&&Fe(Hu)),W===t&&(r.substr(_,5)===L?(W=L,_+=5):(W=t,De===0&&Fe(Zu)),W===t&&(r.substr(_,3)===j?(W=j,_+=3):(W=t,De===0&&Fe(Ju)),W===t&&(r.substr(_,5)===ae?(W=ae,_+=5):(W=t,De===0&&Fe(Xu)),W===t&&(r.substr(_,4)===re?(W=re,_+=4):(W=t,De===0&&Fe(Wu)),W===t&&(r.substr(_,3)===fe?(W=fe,_+=3):(W=t,De===0&&Fe(Yu)),W===t&&(r.substr(_,4)===he?(W=he,_+=4):(W=t,De===0&&Fe(Qu)),W===t&&(r.substr(_,3)===ce?(W=ce,_+=3):(W=t,De===0&&Fe(Ku)))))))))))),W!==t?(r.charCodeAt(_)===40?(ne=F,_++):(ne=t,De===0&&Fe(Oa)),ne!==t?(Ar(),le=An(),le!==t?(Ar(),r.charCodeAt(_)===41?(Se=H,_++):(Se=t,De===0&&Fe(Ia)),Se!==t?(lr=O,O=L7(W,le)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t),O===t&&(O=_,r.substr(_,3)===ie?(W=ie,_+=3):(W=t,De===0&&Fe(ju)),W===t&&(r.substr(_,3)===g?(W=g,_+=3):(W=t,De===0&&Fe(Fr)),W===t&&(r.substr(_,3)===y?(W=y,_+=3):(W=t,De===0&&Fe(_r)))),W!==t?(r.charCodeAt(_)===40?(ne=F,_++):(ne=t,De===0&&Fe(Oa)),ne!==t?(Ar(),le=An(),le!==t?(Ar(),r.charCodeAt(_)===44?(Se=f,_++):(Se=t,De===0&&Fe(Le)),Se!==t?(Ar(),Ie=An(),Ie!==t?(Ar(),r.charCodeAt(_)===41?(hr=H,_++):(hr=t,De===0&&Fe(Ia)),hr!==t?(lr=O,O=k7(W,le,Ie)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)),O}function Zn(){var O,W,ne,le,Se;return O=_,r.charCodeAt(_)===45?_++:De===0&&Fe(Mo),W=B0(),W!==t?(ne=_,ue.test(r.charAt(_))?(le=r.charAt(_),_++):(le=t,De===0&&Fe(Gn)),le!==t?(Se=B0(),Se!==t?(le=[le,Se],ne=le):(_=ne,ne=t)):(_=ne,ne=t),ne===t&&(ne=null),lr=O,O=V7()):(_=O,O=t),O}function il(){var O,W,ne,le;if(O=_,ve.test(r.charAt(_))?(W=r.charAt(_),_++):(W=t,De===0&&Fe(jr)),W!==t){for(ne=[],de.test(r.charAt(_))?(le=r.charAt(_),_++):(le=t,De===0&&Fe(Tr));le!==t;)ne.push(le),de.test(r.charAt(_))?(le=r.charAt(_),_++):(le=t,De===0&&Fe(Tr));lr=O,O=G7()}else _=O,O=t;return O}function B0(){var O,W,ne;if(O=_,W=[],de.test(r.charAt(_))?(ne=r.charAt(_),_++):(ne=t,De===0&&Fe(Tr)),ne!==t)for(;ne!==t;)W.push(ne),de.test(r.charAt(_))?(ne=r.charAt(_),_++):(ne=t,De===0&&Fe(Tr));else W=t;return W!==t&&(lr=O,W=H7()),O=W,O}function zo(){var O,W;return O=_,r.substr(_,2)===Oe?(W=Oe,_+=2):(W=t,De===0&&Fe(Fo)),W!==t&&(lr=O,W=Z7()),O=W,O===t&&(r.charCodeAt(_)===42?(O=Ce,_++):(O=t,De===0&&Fe(el)),O===t&&(r.charCodeAt(_)===94?(O=$e,_++):(O=t,De===0&&Fe(Ra)),O===t&&(r.charCodeAt(_)===37?(O=V,_++):(O=t,De===0&&Fe(_a)),O===t&&(r.charCodeAt(_)===47?(O=X,_++):(O=t,De===0&&Fe(To)),O===t&&(r.charCodeAt(_)===43?(O=oe,_++):(O=t,De===0&&Fe(Bo)),O===t&&(r.charCodeAt(_)===45?(O=Ae,_++):(O=t,De===0&&Fe(Mo)))))))),O}function $0(){var O;return De++,O=yI(),O===t&&(O=bI()),De--,O===t&&De===0&&Fe(Nn),O}function yI(){var O,W,ne,le,Se,Ie;if(O=_,r.substr(_,2)===G?(W=G,_+=2):(W=t,De===0&&Fe(f7)),W!==t){for(ne=[],le=_,Se=_,De++,r.substr(_,2)===Y?(Ie=Y,_+=2):(Ie=t,De===0&&Fe(rl)),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe($o)),Ie!==t?(Se=[Se,Ie],le=Se):(_=le,le=t)):(_=le,le=t);le!==t;)ne.push(le),le=_,Se=_,De++,r.substr(_,2)===Y?(Ie=Y,_+=2):(Ie=t,De===0&&Fe(rl)),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe($o)),Ie!==t?(Se=[Se,Ie],le=Se):(_=le,le=t)):(_=le,le=t);r.substr(_,2)===Y?(le=Y,_+=2):(le=t,De===0&&Fe(rl)),le!==t?(lr=O,O=J7(ne)):(_=O,O=t)}else _=O,O=t;if(O===t)if(O=_,r.charCodeAt(_)===91?(W=te,_++):(W=t,De===0&&Fe(m7)),W!==t){for(ne=[],be.test(r.charAt(_))?(le=r.charAt(_),_++):(le=t,De===0&&Fe(C0));le!==t;)ne.push(le),be.test(r.charAt(_))?(le=r.charAt(_),_++):(le=t,De===0&&Fe(C0));r.charCodeAt(_)===93?(le=ye,_++):(le=t,De===0&&Fe(v7)),le!==t?(lr=O,O=X7(ne)):(_=O,O=t)}else _=O,O=t;return O}function bI(){var O,W,ne,le,Se,Ie;if(O=_,r.substr(_,2)===me?(W=me,_+=2):(W=t,De===0&&Fe(p7)),W===t&&(r.charCodeAt(_)===35?(W=z,_++):(W=t,De===0&&Fe(h7))),W!==t){for(ne=[],le=_,Se=_,De++,Ie=O0(),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe($o)),Ie!==t?(Se=[Se,Ie],le=Se):(_=le,le=t)):(_=le,le=t);le!==t;)ne.push(le),le=_,Se=_,De++,Ie=O0(),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe($o)),Ie!==t?(Se=[Se,Ie],le=Se):(_=le,le=t)):(_=le,le=t);lr=O,O=W7(ne)}else _=O,O=t;return O}function O0(){var O;return pe.test(r.charAt(_))?(O=r.charAt(_),_++):(O=t,De===0&&Fe(d7)),O}function Po(){var O;return De++,we.test(r.charAt(_))?(O=r.charAt(_),_++):(O=t,De===0&&Fe(y7)),De--,O===t&&De===0&&Fe(g7),O}function Ar(){var O,W;for(O=[],W=Po();W!==t;)O.push(W),W=Po();return O}function I0(){var O,W;for(De++,O=[],W=Po(),W===t&&(W=$0());W!==t;)O.push(W),W=Po(),W===t&&(W=$0());return De--,W=t,De===0&&Fe(b7),O}if(Io=i(),Io!==t&&_===r.length)return Io;throw Io!==t&&_<r.length&&Fe(Q7()),K7(tl,Lt<r.length?r.charAt(Lt):null,Lt<r.length?F0(Lt,Lt+1):F0(Lt,Lt))}class N0{static parse(e){if(!e)throw new Pt("notation");if(typeof e!="string")throw new TypeError("Notation must be a string");return z9(e)}}const Ta=Object.freeze({BASE_64:1,JSON:0,OBJECT:2}),Su=Symbol("notation"),Cu=Symbol("maxTotal"),Mu=Symbol("minTotal"),Ba=Symbol("expressions"),Eo=Symbol("roll-method"),wn=Symbol("rolls"),D0=Symbol("set-rolls"),So=Symbol("total"),Fu=r=>e9(r.calculationValue,2);class si{constructor(e){if(!e)throw new Pt("notation");if(this[Ba]=[],e instanceof Object&&!Array.isArray(e)){if(e.notation){if(typeof e.notation!="string")throw new yo(e.notation);e.rolls&&this[D0](e.rolls)}else throw new Pt("notation");this[Su]=e.notation,this[Ba]=N0.parse(this.notation),this.hasRolls()||this.roll()}else if(typeof e=="string")this[Su]=e,this[Ba]=N0.parse(this.notation),this.roll();else throw new yo(e)}get averageTotal(){return(this.maxTotal+this.minTotal)/2}get maxTotal(){if(!this.hasExpressions())return 0;if(!this[Cu]){const e=this[Eo](Ud.max);this[Cu]=Fu(e)}return this[Cu]}get minTotal(){if(!this.hasExpressions())return 0;if(!this[Mu]){const e=this[Eo](Ud.min);this[Mu]=Fu(e)}return this[Mu]}get notation(){return this[Su]}get output(){let e=`${this.notation}: `;return this.hasRolls()?e+=`${this[wn]} = ${this.total}`:e+="No dice rolled",e}get rolls(){return this[wn]?this[wn].results:[]}get total(){return!this[So]&&this.hasRolls()&&(this[So]=Fu(this[wn])),this[So]||0}export(e=Ta.JSON){switch(e){case Ta.BASE_64:return btoa(this.export(Ta.JSON));case Ta.JSON:return JSON.stringify(this);case Ta.OBJECT:return JSON.parse(this.export(Ta.JSON));default:throw new TypeError(`Invalid export format "${e}"`)}}hasExpressions(){return this[Ba]&&this[Ba].length>0}hasRolls(){return this.hasExpressions()&&this.rolls.length>0}roll(){return this[So]=0,this[wn]=this[Eo](),this.rolls}toJSON(){const{averageTotal:e,maxTotal:t,minTotal:a,notation:n,output:i,rolls:o,total:f}=this;return{averageTotal:e,maxTotal:t,minTotal:a,notation:n,output:i,rolls:o,total:f,type:"dice-roll"}}toString(){return this.output}static import(e){if(e){if(_9(e))return si.import(JSON.parse(e));if(R9(e))return si.import(atob(e));if(typeof e=="object")return new si(e);throw new Ys(e)}else throw new Pt("data")}[Eo](e){let t;e&&(t=Sa.engine,Sa.engine=e);const a=new kr(this[Ba].map(n=>n instanceof Ca||n instanceof w0?n.roll():n).filter(n=>!!n||n===0));return e&&(Sa.engine=t),a}[D0](e){if(e instanceof kr)this[wn]=e;else if(e instanceof rn)this[wn]=new kr([e]);else if(Array.isArray(e))this[wn]=new kr(e.map(t=>{if(t instanceof kr||t instanceof rn)return t;if(Array.isArray(t))return new rn(t);if(typeof t=="object"){if(Array.isArray(t.results))return new kr(t.results,t.modifiers||[],t.isRollGroup||!1,typeof t.useInTotal=="boolean"?t.useInTotal:!0);if(Array.isArray(t.rolls))return new rn(t.rolls)}return t}));else throw new TypeError("Rolls must be a valid result object, or an array")}}const Co={__name:"DiceRollerRenderless",props:{notation:String},emits:["notation:change","roll"],setup(r,{emit:e}){const t=r,a=Ne.ref(`${t.notation||""}`),n=Ne.ref(null),i=Ne.ref(null),o=async()=>{n.value=null;try{i.value=a.value?new si(Ne.unref(a)):null}catch(l){i.value=null,l.name==="SyntaxError"?n.value=`Invalid notation; ${l.message}`:n.value=`An error has occurred: ${l.message}`}finally{e("roll",Ne.unref(a),Ne.unref(i))}},f=l=>{a.value=l,e("notation:change",l)};return(l,u)=>Ne.renderSlot(l.$slots,"default",{currentNotation:a.value,error:n.value,output:i.value,roll:o,bind:{value:a.value},on:{input:s=>f(s.target.value),change:s=>f(s.target.value),keyup:s=>s.keyCode===13?o():void 0}})}},P9=()=>typeof crypto<"u"&&crypto&&crypto.randomUUID,U9=()=>P9()?crypto.randomUUID():`${Date.now().toString(32)}-${Math.random().toString(36).substring(2)}`;function Tu(r){const e=Ne.ref(null);return e.value=`${r}${U9()}`,{id:e}}const L9=["id"],k9=["for"],V9=["for"],G9=["id","placeholder"],H9=["onClick"],Z9={__name:"DiceRoller",props:{btnLabel:{type:String,default:"Roll"},className:{type:String,default:"dice-roller"},id:String,notation:String},emits:["notation:change","roll"],setup(r){const e=r,{id:t}=Tu(`${e.id||"dice-roller"}-`);return(a,n)=>(Ne.openBlock(),Ne.createBlock(Co,{notation:r.notation,"onNotation:change":n[0]||(n[0]=i=>a.$emit("notation:change",i)),onRoll:n[1]||(n[1]=i=>a.$emit("roll",i))},{default:Ne.withCtx(({error:i,output:o,roll:f,on:l,bind:u})=>[Ne.createElementVNode("section",{id:r.id,class:Ne.normalizeClass(r.className)},[o?(Ne.openBlock(),Ne.createElementBlock("output",{key:0,name:"output",for:Ne.unref(t),class:Ne.normalizeClass(`${r.className}-output`)},Ne.toDisplayString(o),11,k9)):Ne.createCommentVNode("",!0),Ne.createElementVNode("div",{class:Ne.normalizeClass(`${r.className}-input-group`)},[Ne.createElementVNode("label",{for:Ne.unref(t),class:Ne.normalizeClass(`${r.className}-label`)}," Notation ",10,V9),Ne.createElementVNode("input",Ne.mergeProps({type:"text",name:"notation",id:Ne.unref(t),placeholder:`e.g. ${r.notation||"4d6"}`,class:[`${r.className}-input`,i?`${r.className}-input-invalid`:null]},Ne.toHandlers(l,!0),u),null,16,G9),Ne.createElementVNode("button",{type:"button",class:Ne.normalizeClass(`${r.className}-button`),onClick:f},[Ne.renderSlot(a.$slots,"button",{},()=>[Ne.createTextVNode(Ne.toDisplayString(r.btnLabel),1)])],10,H9)],2),i?(Ne.openBlock(),Ne.createElementBlock("span",{key:1,class:Ne.normalizeClass(`${r.className}-error`)},Ne.toDisplayString(i),3)):Ne.createCommentVNode("",!0)],10,L9)]),_:3},8,["notation"]))}},J9=["id"],X9=["for"],W9={class:"flex flex-col sm:flex-row gap-y-4"},Y9=["for"],Q9=["id","placeholder"],K9=["onClick"],j9={key:1,class:"block mt-4 text-red-600 text-sm dark:text-red-200"},e7={__name:"DiceRollerTailwind",props:{btnLabel:{type:String,default:"Roll"},id:String,notation:String},emits:["notation:change","roll"],setup(r){const e=r,{id:t}=Tu(`${e.id||"dice-roller"}-`);return(a,n)=>(Ne.openBlock(),Ne.createBlock(Co,{notation:r.notation,"onNotation:change":n[0]||(n[0]=i=>a.$emit("notation:change",i)),onRoll:n[1]||(n[1]=i=>a.$emit("roll",i))},{default:Ne.withCtx(({error:i,output:o,roll:f,on:l,bind:u})=>[Ne.createElementVNode("div",{id:r.id,class:"dice-roller p-4 rounded bg-slate-100 text-gray-800 dark:bg-gray-600 dark:text-gray-200"},[o?(Ne.openBlock(),Ne.createElementBlock("output",{key:0,name:"output",for:Ne.unref(t),class:"block mb-8 p-4 text-2xl rounded bg-white text-black dark:bg-gray-300 dark:text-gray-800 border-l-8 border-[#d4f4c6]"},Ne.toDisplayString(o),9,X9)):Ne.createCommentVNode("",!0),Ne.createElementVNode("div",W9,[Ne.createElementVNode("label",{for:Ne.unref(t),class:"sr-only"}," Notation ",8,Y9),Ne.createElementVNode("input",Ne.mergeProps({type:"text",name:"notation",id:Ne.unref(t),placeholder:`e.g. ${r.notation||"4d6"}`,class:["flex-auto block w-full h-11 py-2 px-4 text-base border shadow-sm rounded placeholder-gray-500 focus:ring-[#d4f4c6] focus:border-[#d4f4c6] focus:outline-none focus:placeholder-gray-400 dark:focus:placeholder-gray-400 invalid:text-red-600 invalid:border-red-200 invalid:bg-red-50 sm:border-r-0 sm:rounded-r-none",i?"text-red-600 border-red-200 bg-red-50":"bg-white text-gray-900 border-gray-300 dark:text-gray-600 dark:bg-gray-50 dark:border-gray-700"]},Ne.toHandlers(l,!0),u),null,16,Q9),Ne.createElementVNode("button",{type:"button",class:"block px-8 h-11 font-bold text-gray-600 bg-gradient-to-br from-[#eda18b] to-[#d4f4c6] border border-l-0 border-gray-300 rounded transition dark:border-gray-700 focus:from-[#e88c71] focus:to-[#bbf0a3] focus:text-gray-800 focus:ring-[#d4f4c6] focus:border-[#d4f4c6] focus:outline-none hover:from-[#e88c71] hover:to-[#bbf0a3] hover:text-gray-800 sm:rounded-l-none",onClick:f},[Ne.renderSlot(a.$slots,"button",{},()=>[Ne.createTextVNode(Ne.toDisplayString(r.btnLabel),1)])],8,K9)]),i?(Ne.openBlock(),Ne.createElementBlock("span",j9,Ne.toDisplayString(i),1)):Ne.createCommentVNode("",!0)],8,J9)]),_:3},8,["notation"]))}},r7=["id"],t7={class:"card-body"},n7=["for"],a7=["for"],i7={class:"input-group"},o7=["id","placeholder"],s7=["onClick"],u7={key:1,class:"d-block mt-3 invalid-feedback"},$a=["primary","secondary","success","danger","warning","info","light","dark"],A0=[...$a,"body","white","transparent"],E0=[...$a,"body","muted","white","black-50","white-50"],l7=[...$a,"link","outline-primary","outline-secondary","outline-success","outline-danger","outline-warning","outline-info","outline-light","outline-dark"],S0=[...$a,"white"],c7={__name:"DiceRollerBootstrap",props:{bgVariant:{type:String,validator(r){return A0.includes(r)}},borderVariant:{type:String,validator(r){return S0.includes(r)}},btnLabel:{type:String,default:"Roll"},btnVariant:{type:String,default:"primary",validator(r){return l7.includes(r)}},id:String,notation:String,outputBgVariant:{type:String,validator(r){return A0.includes(r)}},outputBorderVariant:{type:String,validator(r){return S0.includes(r)}},outputTextVariant:{type:String,validator(r){return E0.includes(r)}},outputVariant:{type:String,validator(r){return $a.includes(r)}},textVariant:{type:String,validator(r){return E0.includes(r)}},variant:{type:String,validator(r){return $a.includes(r)}}},emits:["notation:change","roll"],setup(r){const e=r,t=Ne.computed(()=>({[`text-bg-${e.variant}`]:e.variant,[`bg-${e.bgVariant}`]:e.bgVariant,[`text-${e.textVariant}`]:e.textVariant,[`border-${e.borderVariant}`]:e.borderVariant})),a=Ne.computed(()=>({[`text-bg-${e.outputVariant}`]:e.outputVariant,[`bg-${e.outputBgVariant}`]:e.outputBgVariant,[`text-${e.outputTextVariant}`]:e.outputTextVariant,[`border-${e.outputBorderVariant}`]:e.outputBorderVariant})),n=Ne.computed(()=>`btn-${e.btnVariant||"primary"}`),{id:i}=Tu(`${e.id||"dice-roller"}-`);return(o,f)=>(Ne.openBlock(),Ne.createBlock(Co,{notation:r.notation,"onNotation:change":f[0]||(f[0]=l=>o.$emit("notation:change",l)),onRoll:f[1]||(f[1]=l=>o.$emit("roll",l))},{default:Ne.withCtx(({error:l,output:u,roll:s,on:c,bind:m})=>[Ne.createElementVNode("div",{id:r.id,class:Ne.normalizeClass(["dice-roller card",t.value])},[Ne.createElementVNode("div",t7,[u?(Ne.openBlock(),Ne.createElementBlock("output",{key:0,name:"output",for:Ne.unref(i),class:Ne.normalizeClass(["d-block mb-4 p-3 fs-4 rounded border",a.value])},Ne.toDisplayString(u),11,n7)):Ne.createCommentVNode("",!0),Ne.createElementVNode("label",{for:Ne.unref(i),class:"form-label visually-hidden"}," Notation ",8,a7),Ne.createElementVNode("div",i7,[Ne.createElementVNode("input",Ne.mergeProps({type:"text",name:"notation",id:Ne.unref(i),placeholder:`e.g. ${r.notation||"4d6"}`,class:["form-control",l?"is-invalid":""]},Ne.toHandlers(c,!0),m),null,16,o7),Ne.createElementVNode("button",{type:"button",class:Ne.normalizeClass(["btn",n.value]),onClick:s},[Ne.renderSlot(o.$slots,"button",{},()=>[Ne.createTextVNode(Ne.toDisplayString(r.btnLabel),1)])],10,s7)]),l?(Ne.openBlock(),Ne.createElementBlock("span",u7,Ne.toDisplayString(l),1)):Ne.createCommentVNode("",!0)])],10,r7)]),_:3},8,["notation"]))}};Vr.DiceRoller=Z9,Vr.DiceRollerBootstrap=c7,Vr.DiceRollerRenderless=Co,Vr.DiceRollerTailwind=e7,Object.defineProperties(Vr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|