@dice-roller/vue 1.3.1 → 1.3.2

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.
Files changed (3) hide show
  1. package/dist/vue.js +12154 -8452
  2. package/dist/vue.umd.cjs +37 -61
  3. package/package.json +2 -2
package/dist/vue.umd.cjs CHANGED
@@ -1,85 +1,61 @@
1
- (function(Vr,oe){typeof exports=="object"&&typeof module<"u"?oe(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],oe):(Vr=typeof globalThis<"u"?globalThis:Vr||self,oe(Vr.DiceRollerVue={},Vr.Vue))})(this,function(Vr,oe){"use strict";var UI=Object.defineProperty;var kI=(Vr,oe,Sr)=>oe in Vr?UI(Vr,oe,{enumerable:!0,configurable:!0,writable:!0,value:Sr}):Vr[oe]=Sr;var tt=(Vr,oe,Sr)=>(kI(Vr,typeof oe!="symbol"?oe+"":oe,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 ul={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 Xr(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 li(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 ci(r){return r&&r.constructor.prototype.isIndex===!0||!1}function k0(r){return typeof r=="boolean"}function V0(r){return r&&r.constructor.prototype.isResultSet===!0||!1}function ll(r){return r&&r.constructor.prototype.isHelp===!0||!1}function G0(r){return typeof r=="function"}function H0(r){return r instanceof Date}function Z0(r){return r instanceof RegExp}function ko(r){return!!(r&&typeof r=="object"&&r.constructor===Object&&!kt(r)&&!za(r))}function J0(r){return r===null}function W0(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 X0(r){return r&&r.isAssignmentNode===!0&&r.constructor.prototype.isNode===!0||!1}function Y0(r){return r&&r.isBlockNode===!0&&r.constructor.prototype.isNode===!0||!1}function Q0(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 Vo(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 fi(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 K0(r){return r&&r.isRangeNode===!0&&r.constructor.prototype.isNode===!0||!1}function j0(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 cl(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 eg(r,Ge)}function eg(r,e){var t={};for(var a in r)Re(r,a)&&(t[a]=e(r[a]));return t}function fl(r,e){for(var t in e)Re(e,t)&&(r[t]=e[t]);return r}function La(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(!La(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)||!La(r[t],e[t]))return!1;for(t in e)if(!(t in r))return!1;return!0}else return r===e}}function rg(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 tg(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 ng=["Matrix","Array"],ag=["number","BigNumber","Fraction"],ye=function(e){if(e)throw new Error(`The global config is readonly.
1
+ (function(St,ue){typeof exports=="object"&&typeof module<"u"?ue(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],ue):(St=typeof globalThis<"u"?globalThis:St||self,ue(St.DiceRollerVue={},St.Vue))})(this,(function(St,ue){"use strict";function zr(){return zr=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=t[i])}return r},zr.apply(this,arguments)}var nl={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 Lt(r){return r&&typeof r=="object"&&Object.getPrototypeOf(r).isComplex===!0||!1}function Ba(r){return r&&typeof r=="object"&&Object.getPrototypeOf(r).isFraction===!0||!1}function Ut(r){return r&&r.constructor.prototype.isUnit===!0||!1}function Xr(r){return typeof r=="string"}var cr=Array.isArray;function Ve(r){return r&&r.constructor.prototype.isMatrix===!0||!1}function Ct(r){return Array.isArray(r)||Ve(r)}function ri(r){return r&&r.isDenseMatrix&&r.constructor.prototype.isMatrix===!0||!1}function wn(r){return r&&r.isSparseMatrix&&r.constructor.prototype.isMatrix===!0||!1}function Uo(r){return r&&r.constructor.prototype.isRange===!0||!1}function ti(r){return r&&r.constructor.prototype.isIndex===!0||!1}function C0(r){return typeof r=="boolean"}function M0(r){return r&&r.constructor.prototype.isResultSet===!0||!1}function al(r){return r&&r.constructor.prototype.isHelp===!0||!1}function F0(r){return typeof r=="function"}function T0(r){return r instanceof Date}function B0(r){return r instanceof RegExp}function ko(r){return!!(r&&typeof r=="object"&&r.constructor===Object&&!Lt(r)&&!Ba(r))}function $0(r){return r===null}function O0(r){return r===void 0}function Nn(r){return r&&r.isAccessorNode===!0&&r.constructor.prototype.isNode===!0||!1}function at(r){return r&&r.isArrayNode===!0&&r.constructor.prototype.isNode===!0||!1}function I0(r){return r&&r.isAssignmentNode===!0&&r.constructor.prototype.isNode===!0||!1}function R0(r){return r&&r.isBlockNode===!0&&r.constructor.prototype.isNode===!0||!1}function _0(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 Vo(r){return ir(r)||Tr(r)&&r.args.length===1&&ir(r.args[0])&&"-+~".includes(r.op)}function $a(r){return r&&r.isFunctionAssignmentNode===!0&&r.constructor.prototype.isNode===!0||!1}function jt(r){return r&&r.isFunctionNode===!0&&r.constructor.prototype.isNode===!0||!1}function Un(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 ni(r){return r&&r.isObjectNode===!0&&r.constructor.prototype.isNode===!0||!1}function Tr(r){return r&&r.isOperatorNode===!0&&r.constructor.prototype.isNode===!0||!1}function kt(r){return r&&r.isParenthesisNode===!0&&r.constructor.prototype.isNode===!0||!1}function q0(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 _r(r){return r&&r.isSymbolNode===!0&&r.constructor.prototype.isNode===!0||!1}function il(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 P0(r,Ge)}function P0(r,e){var t={};for(var i in r)Re(r,i)&&(t[i]=e(r[i]));return t}function ol(r,e){for(var t in e)Re(e,t)&&(r[t]=e[t]);return r}function Oa(r,e){var t,i,n;if(Array.isArray(r)){if(!Array.isArray(e)||r.length!==e.length)return!1;for(i=0,n=r.length;i<n;i++)if(!Oa(r[i],e[i]))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)||!Oa(r[t],e[t]))return!1;for(t in e)if(!(t in r))return!1;return!0}else return r===e}}function L0(r,e,t){var i=!0,n;Object.defineProperty(r,e,{get:function(){return i&&(n=t(),i=!1),n},set:function(o){n=o,i=!1},configurable:!0,enumerable:!0})}function Re(r,e){return r&&Object.hasOwnProperty.call(r,e)}function U0(r,e){for(var t={},i=0;i<e.length;i++){var n=e[i],a=r[n];a!==void 0&&(t[n]=a)}return t}var k0=["Matrix","Array"],V0=["number","BigNumber","Fraction"],ye=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(ul)};Sr(ye,ul,{MATRIX_OPTIONS:ng,NUMBER_OPTIONS:ag});function dt(r,e){var t=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=ig(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 ig(r,e){if(!!r){if(typeof r=="string")return ml(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 ml(r,e)}}function ml(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 Wn(r){return Wn=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},Wn(r)}function vl(){return!0}function st(){return!1}function Xn(){}var pl="Argument is not a typed-function.";function dl(){function r(z){return Wn(z)==="object"&&z!==null&&z.constructor===Object}var e=[{name:"number",test:function(L){return typeof L=="number"}},{name:"string",test:function(L){return typeof L=="string"}},{name:"boolean",test:function(L){return typeof L=="boolean"}},{name:"Function",test:function(L){return typeof L=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(L){return L instanceof Date}},{name:"RegExp",test:function(L){return L instanceof RegExp}},{name:"Object",test:r},{name:"null",test:function(L){return L===null}},{name:"undefined",test:function(L){return L===void 0}}],t={name:"any",test:vl,isAny:!0},a,n,i=0,o={createCount:0};function f(z){var L=a.get(z);if(L)return L;var ee='Unknown type "'+z+'"',le=z.toLowerCase(),pe,ge=dt(n),xe;try{for(ge.s();!(xe=ge.n()).done;)if(pe=xe.value,pe.toLowerCase()===le){ee+='. Did you mean "'+pe+'" ?';break}}catch(de){ge.e(de)}finally{ge.f()}throw new TypeError(ee)}function l(z){for(var L=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any",ee=L?f(L).index:n.length,le=[],pe=0;pe<z.length;++pe){if(!z[pe]||typeof z[pe].name!="string"||typeof z[pe].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");var ge=z[pe].name;if(a.has(ge))throw new TypeError('Duplicate type name "'+ge+'"');le.push(ge),a.set(ge,{name:ge,test:z[pe].test,isAny:z[pe].isAny,index:ee+pe,conversionsTo:[]})}var xe=n.slice(ee);n=n.slice(0,ee).concat(le).concat(xe);for(var de=ee+le.length;de<n.length;++de)a.get(n[de]).index=de}function u(){a=new Map,n=[],i=0,l([t],!1)}u(),l(e);function s(){var z,L=dt(n),ee;try{for(L.s();!(ee=L.n()).done;)z=ee.value,a.get(z).conversionsTo=[]}catch(le){L.e(le)}finally{L.f()}i=0}function c(z){var L=n.filter(function(ee){var le=a.get(ee);return!le.isAny&&le.test(z)});return L.length?L:["any"]}function m(z){return z&&typeof z=="function"&&"_typedFunctionData"in z}function v(z,L,ee){if(!m(z))throw new TypeError(pl);var le=ee&&ee.exact,pe=Array.isArray(L)?L.join(","):L,ge=w(pe),xe=g(ge);if(!le||xe in z.signatures){var de=z._typedFunctionData.signatureMap.get(xe);if(de)return de}var Ne=ge.length,_e;if(le){_e=[];var Ue;for(Ue in z.signatures)_e.push(z._typedFunctionData.signatureMap.get(Ue))}else _e=z._typedFunctionData.signatures;for(var Be=0;Be<Ne;++Be){var ar=ge[Be],Je=[],mr=void 0,C=dt(_e),Z;try{for(C.s();!(Z=C.n()).done;){mr=Z.value;var ue=A(mr.params,Be);if(!(!ue||ar.restParam&&!ue.restParam)){if(!ue.hasAny){var Ee=function(){var _r=h(ue);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=dt(_e),Fr;try{for(ke.s();!(Fr=ke.n()).done;)if(ze=Fr.value,ze.params.length<=Ne)return ze}catch(_r){ke.e(_r)}finally{ke.f()}throw new TypeError("Signature not found (signature: "+(z.name||"unnamed")+"("+g(ge,", ")+"))")}function d(z,L,ee){return v(z,L,ee).implementation}function p(z,L){var ee=f(L);if(ee.test(z))return z;var le=ee.conversionsTo;if(le.length===0)throw new Error("There are no conversions to "+L+" defined.");for(var pe=0;pe<le.length;pe++){var ge=f(le[pe].from);if(ge.test(z))return le[pe].convert(z)}throw new Error("Cannot convert "+z+" to "+L)}function g(z){var L=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return z.map(function(ee){return ee.name}).join(L)}function y(z){var L=z.indexOf("...")===0,ee=L?z.length>3?z.slice(3):"any":z,le=ee.split("|").map(function(de){return f(de.trim())}),pe=!1,ge=L?"...":"",xe=le.map(function(de){return pe=de.isAny||pe,ge+=de.name+"|",{name:de.name,typeIndex:de.index,test:de.test,isAny:de.isAny,conversion:null,conversionIndex:-1}});return{types:xe,name:ge.slice(0,-1),hasAny:pe,hasConversion:!1,restParam:L}}function N(z){var L=z.types.map(function(xe){return xe.name}),ee=F(L),le=z.hasAny,pe=z.name,ge=ee.map(function(xe){var de=f(xe.from);return le=de.isAny||le,pe+="|"+xe.from,{name:xe.from,typeIndex:de.index,test:de.test,isAny:de.isAny,conversion:xe,conversionIndex:xe.index}});return{types:z.types.concat(ge),name:pe,hasAny:le,hasConversion:ge.length>0,restParam:z.restParam}}function h(z){return z.typeSet||(z.typeSet=new Set,z.types.forEach(function(L){return z.typeSet.add(L.name)})),z.typeSet}function w(z){var L=[];if(typeof z!="string")throw new TypeError("Signatures must be strings");var ee=z.trim();if(ee==="")return L;for(var le=ee.split(","),pe=0;pe<le.length;++pe){var ge=y(le[pe].trim());if(ge.restParam&&pe!==le.length-1)throw new SyntaxError('Unexpected rest parameter "'+le[pe]+'": only allowed for the last parameter');if(ge.types.length===0)return null;L.push(ge)}return L}function x(z){var L=fe(z);return L?L.restParam:!1}function b(z){if(!z||z.types.length===0)return vl;if(z.types.length===1)return f(z.types[0].name).test;if(z.types.length===2){var L=f(z.types[0].name).test,ee=f(z.types[1].name).test;return function(ge){return L(ge)||ee(ge)}}else{var le=z.types.map(function(pe){return f(pe.name).test});return function(ge){for(var xe=0;xe<le.length;xe++)if(le[xe](ge))return!0;return!1}}}function E(z){var L,ee,le;if(x(z)){L=he(z).map(b);var pe=L.length,ge=b(fe(z)),xe=function(Ne){for(var _e=pe;_e<Ne.length;_e++)if(!ge(Ne[_e]))return!1;return!0};return function(Ne){for(var _e=0;_e<L.length;_e++)if(!L[_e](Ne[_e]))return!1;return xe(Ne)&&Ne.length>=pe+1}}else return z.length===0?function(Ne){return Ne.length===0}:z.length===1?(ee=b(z[0]),function(Ne){return ee(Ne[0])&&Ne.length===1}):z.length===2?(ee=b(z[0]),le=b(z[1]),function(Ne){return ee(Ne[0])&&le(Ne[1])&&Ne.length===2}):(L=z.map(b),function(Ne){for(var _e=0;_e<L.length;_e++)if(!L[_e](Ne[_e]))return!1;return Ne.length===L.length})}function A(z,L){return L<z.length?z[L]:x(z)?fe(z):null}function S(z,L){var ee=A(z,L);return ee?h(ee):new Set}function D(z){return z.conversion===null||z.conversion===void 0}function T(z,L){var ee=new Set;return z.forEach(function(le){var pe=S(le.params,L),ge,xe=dt(pe),de;try{for(xe.s();!(de=xe.n()).done;)ge=de.value,ee.add(ge)}catch(Ne){xe.e(Ne)}finally{xe.f()}}),ee.has("any")?["any"]:Array.from(ee)}function B(z,L,ee){var le,pe,ge=z||"unnamed",xe=ee,de,Ne=function(){var C=[];if(xe.forEach(function(ue){var Ee=A(ue.params,de),ze=b(Ee);(de<ue.params.length||x(ue.params))&&ze(L[de])&&C.push(ue)}),C.length===0){if(pe=T(xe,de),pe.length>0){var Z=c(L[de]);return le=new TypeError("Unexpected type of argument in function "+ge+" (expected: "+pe.join(" or ")+", actual: "+Z.join(" | ")+", index: "+de+")"),le.data={category:"wrongType",fn:ge,index:de,actual:Z,expected:pe},{v:le}}}else xe=C};for(de=0;de<L.length;de++){var _e=Ne();if(Wn(_e)==="object")return _e.v}var Ue=xe.map(function(mr){return x(mr.params)?1/0:mr.params.length});if(L.length<Math.min.apply(null,Ue))return pe=T(xe,de),le=new TypeError("Too few arguments in function "+ge+" (expected: "+pe.join(" or ")+", index: "+L.length+")"),le.data={category:"tooFewArgs",fn:ge,index:L.length,expected:pe},le;var Be=Math.max.apply(null,Ue);if(L.length>Be)return le=new TypeError("Too many arguments in function "+ge+" (expected: "+Be+", actual: "+L.length+")"),le.data={category:"tooManyArgs",fn:ge,index:L.length,expectedLength:Be},le;for(var ar=[],Je=0;Je<L.length;++Je)ar.push(c(L[Je]).join("|"));return le=new TypeError('Arguments of type "'+ar.join(", ")+'" do not match any of the defined signatures of function '+ge+"."),le.data={category:"mismatch",actual:ar},le}function I(z){for(var L=n.length+1,ee=0;ee<z.types.length;ee++)D(z.types[ee])&&(L=Math.min(L,z.types[ee].typeIndex));return L}function P(z){for(var L=i+1,ee=0;ee<z.types.length;ee++)D(z.types[ee])||(L=Math.min(L,z.types[ee].conversionIndex));return L}function R(z,L){if(z.hasAny){if(!L.hasAny)return 1}else if(L.hasAny)return-1;if(z.restParam){if(!L.restParam)return 1}else if(L.restParam)return-1;if(z.hasConversion){if(!L.hasConversion)return 1}else if(L.hasConversion)return-1;var ee=I(z)-I(L);if(ee<0)return-1;if(ee>0)return 1;var le=P(z)-P(L);return le<0?-1:le>0?1:0}function M(z,L){var ee=z.params,le=L.params,pe=fe(ee),ge=fe(le),xe=x(ee),de=x(le);if(xe&&pe.hasAny){if(!de||!ge.hasAny)return 1}else if(de&&ge.hasAny)return-1;var Ne=0,_e=0,Ue,Be=dt(ee),ar;try{for(Be.s();!(ar=Be.n()).done;)Ue=ar.value,Ue.hasAny&&++Ne,Ue.hasConversion&&++_e}catch(kn){Be.e(kn)}finally{Be.f()}var Je=0,mr=0,C=dt(le),Z;try{for(C.s();!(Z=C.n()).done;)Ue=Z.value,Ue.hasAny&&++Je,Ue.hasConversion&&++mr}catch(kn){C.e(kn)}finally{C.f()}if(Ne!==Je)return Ne-Je;if(xe&&pe.hasConversion){if(!de||!ge.hasConversion)return 1}else if(de&&ge.hasConversion)return-1;if(_e!==mr)return _e-mr;if(xe){if(!de)return 1}else if(de)return-1;var ue=(ee.length-le.length)*(xe?-1:1);if(ue!==0)return ue;for(var Ee=[],ze=0,ke=0;ke<ee.length;++ke){var Fr=R(ee[ke],le[ke]);Ee.push(Fr),ze+=Fr}if(ze!==0)return ze;for(var _r,tn=0,Un=Ee;tn<Un.length;tn++)if(_r=Un[tn],_r!==0)return _r;return 0}function F(z){if(z.length===0)return[];var L=z.map(f);z.length>1&&L.sort(function(Ne,_e){return Ne.index-_e.index});var ee=L[0].conversionsTo;if(z.length===1)return ee;ee=ee.concat([]);for(var le=new Set(z),pe=1;pe<L.length;++pe){var ge=void 0,xe=dt(L[pe].conversionsTo),de;try{for(xe.s();!(de=xe.n()).done;)ge=de.value,le.has(ge.from)||(ee.push(ge),le.add(ge.from))}catch(Ne){xe.e(Ne)}finally{xe.f()}}return ee}function H(z,L){var ee=L;if(z.some(function(de){return de.hasConversion})){var le=x(z),pe=z.map($);ee=function(){for(var Ne=[],_e=le?arguments.length-1:arguments.length,Ue=0;Ue<_e;Ue++)Ne[Ue]=pe[Ue](arguments[Ue]);return le&&(Ne[_e]=arguments[_e].map(pe[_e])),L.apply(this,Ne)}}var ge=ee;if(x(z)){var xe=z.length-1;ge=function(){return ee.apply(this,ie(arguments,0,xe).concat([ie(arguments,xe)]))}}return ge}function $(z){var L,ee,le,pe,ge=[],xe=[];switch(z.types.forEach(function(de){de.conversion&&(ge.push(f(de.conversion.from).test),xe.push(de.conversion.convert))}),xe.length){case 0:return function(Ne){return Ne};case 1:return L=ge[0],le=xe[0],function(Ne){return L(Ne)?le(Ne):Ne};case 2:return L=ge[0],ee=ge[1],le=xe[0],pe=xe[1],function(Ne){return L(Ne)?le(Ne):ee(Ne)?pe(Ne):Ne};default:return function(Ne){for(var _e=0;_e<xe.length;_e++)if(ge[_e](Ne))return xe[_e](Ne);return Ne}}}function k(z){function L(ee,le,pe){if(le<ee.length){var ge=ee[le],xe=[];if(ge.restParam){var de=ge.types.filter(D);de.length<ge.types.length&&xe.push({types:de,name:"..."+de.map(function(Ne){return Ne.name}).join("|"),hasAny:de.some(function(Ne){return Ne.isAny}),hasConversion:!1,restParam:!0}),xe.push(ge)}else xe=ge.types.map(function(Ne){return{types:[Ne],name:Ne.name,hasAny:Ne.isAny,hasConversion:Ne.conversion,restParam:!1}});return Oe(xe,function(Ne){return L(ee,le+1,pe.concat([Ne]))})}else return[pe]}return L(z,0,[])}function Q(z,L){for(var ee=Math.max(z.length,L.length),le=0;le<ee;le++){var pe=S(z,le),ge=S(L,le),xe=!1,de=void 0,Ne=dt(ge),_e;try{for(Ne.s();!(_e=Ne.n()).done;)if(de=_e.value,pe.has(de)){xe=!0;break}}catch(mr){Ne.e(mr)}finally{Ne.f()}if(!xe)return!1}var Ue=z.length,Be=L.length,ar=x(z),Je=x(L);return ar?Je?Ue===Be:Be>=Ue:Je?Ue>=Be:Ue===Be}function K(z){return z.map(function(L){return se(L)?V(L.referToSelf.callback):W(L)?$e(L.referTo.references,L.referTo.callback):L})}function U(z,L,ee){var le=[],pe,ge=dt(z),xe;try{for(ge.s();!(xe=ge.n()).done;){pe=xe.value;var de=ee[pe];if(typeof de!="number")throw new TypeError('No definition for referenced signature "'+pe+'"');if(de=L[de],typeof de!="function")return!1;le.push(de)}}catch(Ne){ge.e(Ne)}finally{ge.f()}return le}function j(z,L,ee){for(var le=K(z),pe=new Array(le.length).fill(!1),ge=!0;ge;){ge=!1;for(var xe=!0,de=0;de<le.length;++de)if(!pe[de]){var Ne=le[de];if(se(Ne))le[de]=Ne.referToSelf.callback(ee),le[de].referToSelf=Ne.referToSelf,pe[de]=!0,xe=!1;else if(W(Ne)){var _e=U(Ne.referTo.references,le,L);_e?(le[de]=Ne.referTo.callback.apply(this,_e),le[de].referTo=Ne.referTo,pe[de]=!0,xe=!1):ge=!0}}if(xe&&ge)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return le}function ae(z){var L=/\bthis(\(|\.signatures\b)/;Object.keys(z).forEach(function(ee){var le=z[ee];if(L.test(le.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,L){if(o.createCount++,Object.keys(L).length===0)throw new SyntaxError("No signatures provided");o.warnAgainstDeprecatedThis&&ae(L);var ee=[],le=[],pe={},ge=[],xe,de=function(){if(!Object.prototype.hasOwnProperty.call(L,xe))return"continue";var Tr=w(xe);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 To=le.length;le.push(L[xe]);var tl=Tr.map(N),Ra=void 0,_a=dt(k(tl)),Bo;try{for(_a.s();!(Bo=_a.n()).done;){Ra=Bo.value;var $o=g(Ra);ge.push({params:Ra,name:$o,fn:To}),Ra.every(function(Nn){return!Nn.hasConversion})&&(pe[$o]=To)}}catch(Nn){_a.e(Nn)}finally{_a.f()}};for(xe in L)var Ne=de();ge.sort(M);var _e=j(le,pe,Gn),Ue;for(Ue in pe)Object.prototype.hasOwnProperty.call(pe,Ue)&&(pe[Ue]=_e[pe[Ue]]);for(var Be=[],ar=new Map,Je=0,mr=ge;Je<mr.length;Je++)Ue=mr[Je],ar.has(Ue.name)||(Ue.fn=_e[Ue.fn],Be.push(Ue),ar.set(Ue.name,Ue));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),ue=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&&ue&&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,Un=Z?b(Be[1].params[0]):st,kn=ue?b(Be[2].params[0]):st,Ou=Ee?b(Be[3].params[0]):st,Iu=ze?b(Be[4].params[0]):st,Ru=ke?b(Be[5].params[0]):st,_u=C?b(Be[0].params[1]):st,qu=Z?b(Be[1].params[1]):st,zu=ue?b(Be[2].params[1]):st,Pu=Ee?b(Be[3].params[1]):st,Lu=ze?b(Be[4].params[1]):st,Uu=ke?b(Be[5].params[1]):st,Vn=0;Vn<Be.length;++Vn)Be[Vn].implementation=H(Be[Vn].params,Be[Vn].fn);var ku=C?Be[0].implementation:Xn,Vu=Z?Be[1].implementation:Xn,Oa=ue?Be[2].implementation:Xn,Ia=Ee?Be[3].implementation:Xn,Gu=ze?Be[4].implementation:Xn,Hu=ke?Be[5].implementation:Xn,Zu=C?Be[0].params.length:-1,Ju=Z?Be[1].params.length:-1,Wu=ue?Be[2].params.length:-1,Xu=Ee?Be[3].params.length:-1,Yu=ze?Be[4].params.length:-1,Qu=ke?Be[5].params.length:-1,Ku=Fr?6:0,ju=Be.length,el=Be.map(function(jr){return jr.test}),rl=Be.map(function(jr){return jr.implementation}),Fo=function(){for(var Tr=Ku;Tr<ju;Tr++)if(el[Tr](arguments))return rl[Tr].apply(this,arguments);return o.onMismatch(z,arguments,Be)};function Gn(jr,Tr){return arguments.length===Zu&&tn(jr)&&_u(Tr)?ku.apply(this,arguments):arguments.length===Ju&&Un(jr)&&qu(Tr)?Vu.apply(this,arguments):arguments.length===Wu&&kn(jr)&&zu(Tr)?Oa.apply(this,arguments):arguments.length===Xu&&Ou(jr)&&Pu(Tr)?Ia.apply(this,arguments):arguments.length===Yu&&Iu(jr)&&Lu(Tr)?Gu.apply(this,arguments):arguments.length===Qu&&Ru(jr)&&Uu(Tr)?Hu.apply(this,arguments):Fo.apply(this,arguments)}try{Object.defineProperty(Gn,"name",{value:z})}catch{}return Gn.signatures=pe,Gn._typedFunctionData={signatures:Be,signatureMap:ar},Gn}function me(z,L,ee){throw B(z,L,ee)}function he(z){return ie(z,0,z.length-1)}function fe(z){return z[z.length-1]}function ie(z,L,ee){return Array.prototype.slice.call(z,L,ee)}function Ae(z,L){for(var ee=0;ee<z.length;ee++)if(L(z[ee]))return z[ee]}function Oe(z,L){return Array.prototype.concat.apply([],z.map(L))}function Ce(){var z=he(arguments).map(function(ee){return g(w(ee))}),L=fe(arguments);if(typeof L!="function")throw new TypeError("Callback function expected as last argument");return $e(z,L)}function $e(z,L){return{referTo:{references:z,callback:L}}}function V(z){if(typeof z!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:z}}}function W(z){return z&&Wn(z.referTo)==="object"&&Array.isArray(z.referTo.references)&&typeof z.referTo.callback=="function"}function se(z){return z&&Wn(z.referToSelf)==="object"&&typeof z.referToSelf.callback=="function"}function G(z,L){if(!z)return L;if(L&&L!==z){var ee=new Error("Function names do not match (expected: "+z+", actual: "+L+")");throw ee.data={actual:L,expected:z},ee}return z}function Y(z){var L;for(var ee in z)Object.prototype.hasOwnProperty.call(z,ee)&&(m(z[ee])||typeof z[ee].signature=="string")&&(L=G(L,z[ee].name));return L}function te(z,L){var ee;for(ee in L)if(Object.prototype.hasOwnProperty.call(L,ee)){if(ee in z&&L[ee]!==z[ee]){var le=new Error('Signature "'+ee+'" is defined twice');throw le.data={signature:ee,sourceFunction:L[ee],destFunction:z[ee]},le}z[ee]=L[ee]}}var be=o;o=function(L){for(var ee=typeof L=="string",le=ee?1:0,pe=ee?L:"",ge={},xe=le;xe<arguments.length;++xe){var de=arguments[xe],Ne={},_e=void 0;if(typeof de=="function"?(_e=de.name,typeof de.signature=="string"?Ne[de.signature]=de:m(de)&&(Ne=de.signatures)):r(de)&&(Ne=de,ee||(_e=Y(de))),Object.keys(Ne).length===0){var Ue=new TypeError("Argument to 'typed' at index "+xe+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw Ue.data={index:xe,argument:de},Ue}ee||(pe=G(pe,_e)),te(ge,Ne)}return re(pe||"",ge)},o.create=dl,o.createCount=be.createCount,o.onMismatch=me,o.throwMismatchError=me,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=d,o.isTypedFunction=m,o.warnAgainstDeprecatedThis=!0,o.addType=function(z,L){var ee="any";L!==!1&&a.has("Object")&&(ee="Object"),o.addTypes([z],ee)};function ve(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){ve(z);var L=f(z.to);if(L.conversionsTo.every(function(ee){return ee.from!==z.from}))L.conversionsTo.push({from:z.from,convert:z.convert,index:i++});else throw new Error('There is already a conversion from "'+z.from+'" to "'+L.name+'"')},o.addConversions=function(z){z.forEach(o.addConversion)},o.removeConversion=function(z){ve(z);var L=f(z.to),ee=Ae(L.conversionsTo,function(pe){return pe.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 le=L.conversionsTo.indexOf(ee);L.conversionsTo.splice(le,1)},o.resolve=function(z,L){if(!m(z))throw new TypeError(pl);for(var ee=z._typedFunctionData.signatures,le=0;le<ee.length;++le)if(ee[le].test(L))return ee[le];return null},o}const hl=dl();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},og=Math.log2||function(e){return Math.log(e)/Math.LN2},sg=Math.log10||function(e){return Math.log(e)/Math.LN10},ug=Math.log1p||function(r){return Math.log(r+1)},lg=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},cg=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function Go(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 gl(r,a);case"exponential":return yl(r,a);case"engineering":return fg(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":return mg(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 mi(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 fg(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=mi(r),a=vi(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 gl(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=mi(r),a=typeof e=="number"?vi(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 yl(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=mi(r),a=e?vi(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 mg(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=mi(r),o=e?vi(i,e):i;if(o.exponent<a||o.exponent>=n)return yl(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 vi(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 vg(r){return r.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var pg=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<pg?!0:a<=Math.max(Math.abs(r),Math.abs(e))*t}return!1}var dg=Math.acosh||function(r){return Math.log(Math.sqrt(r*r-1)+r)},hg=Math.asinh||function(r){return Math.log(Math.sqrt(r*r+1)+r)},gg=Math.atanh||function(r){return Math.log((1+r)/(1-r))/2},yg=Math.cosh||function(r){return(Math.exp(r)+Math.exp(-r))/2},bg=Math.sinh||function(r){return(Math.exp(r)-Math.exp(-r))/2},xg=Math.tanh||function(r){var e=Math.exp(2*r);return(e-1)/(e+1)};function wg(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 Ho(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 Ng(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 Ag(r,a);case"exponential":return bl(r,a);case"engineering":return Dg(r,a);case"bin":return Ho(r,2,n);case"oct":return Ho(r,8,n);case"hex":return Ho(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=bl(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 bl(r,e){return e!==void 0?r.toExponential(e-1):r.toExponential()}function Ag(r,e){return r.toFixed(e)}function Eg(r,e){var t=r.length-e.length,a=r.length;return r.substring(t,a)===e}function Ye(r,e){var t=Sg(r,e);return e&&typeof e=="object"&&"truncate"in e&&t.length>e.truncate?t.substring(0,e.truncate-3)+"...":t}function Sg(r,e){if(typeof r=="number")return Cn(r,e);if(rr(r))return Ng(r,e);if(Cg(r))return!e||e.fraction!=="decimal"?r.s*r.n+"/"+r.d:r.toString();if(Array.isArray(r))return xl(r,e);if(Xr(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 pi(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,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),e}function xl(r,e){if(Array.isArray(r)){for(var t="[",a=r.length,n=0;n<a;n++)n!==0&&(t+=", "),t+=xl(r[n],e);return t+="]",t}else return Ye(r,e)}function Cg(r){return r&&typeof r=="object"&&typeof r.s=="number"&&typeof r.n=="number"&&typeof r.d=="number"||!1}function Zo(r,e){if(!Xr(r))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+br(r)+", index: 0)");if(!Xr(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 wl(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,"<");wl(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 Nl(r,e){var t=e.length===0;if(t){if(Array.isArray(r))throw new Ke(r.length,0)}else wl(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 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 Jo(r,e,0,a),r}function Jo(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),Jo(i,e,u,a);for(n=l;n<f;n++)i=[],r[n]=i,Jo(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 Dl(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=Wo(e,a);var n=Al(e);if(a!==n)throw new Ke(n,a,"!=");try{return Mg(t,e)}catch(i){throw i instanceof Ke?new Ke(n,a,"!="):i}}function Wo(r,e){var t=Al(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 Al(r){return r.reduce((e,t)=>e*t,1)}function Mg(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 di(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=El(r,a,0),t.length=a),r}function El(r,e,t){var a,n;if(t<e){var i=t+1;for(a=0,n=r.length;a<n;a++)r[a]=El(r[a],e,i)}else for(;Array.isArray(r);)r=r[0];return r}function Sl(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=Cl(r,e,0);n.length<e;)n.push(1);return r}function Cl(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]=Cl(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 Ml(r,e){if(er(r).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(r,e)}function gi(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 Fl(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 yi(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=tg(i,e.map(Bg));return Fg(r,e,i),t(o)}return n.isFactory=!0,n.fn=r,n.dependencies=e.slice().sort(),a&&(n.meta=a),n}function Fg(r,e,t){var a=e.filter(i=>!Tg(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 Tg(r){return r&&r[0]==="?"}function Bg(r){return r&&r[0]==="?"?r.slice(1):r}function lt(r,e){if(Tl(r)&&Xo(r,e))return r[e];throw typeof r[e]=="function"&&Yo(r,e)?new Error('Cannot access method "'+e+'" as a property'):new Error('No access to property "'+e+'"')}function jn(r,e,t){if(Tl(r)&&Xo(r,e))return r[e]=t,t;throw new Error('No access to property "'+e+'"')}function $g(r,e){return e in r}function Xo(r,e){return!r||typeof r!="object"?!1:Re(Ig,e)?!0:!(e in Object.prototype||e in Function.prototype)}function Og(r,e){if(!Yo(r,e))throw new Error('No access to method "'+e+'"')}function Yo(r,e){return r==null||typeof r[e]!="function"||Re(r,e)&&Object.getPrototypeOf&&e in Object.getPrototypeOf(r)?!1:Re(Rg,e)?!0:!(e in Object.prototype||e in Function.prototype)}function Tl(r){return typeof r=="object"&&r&&r.constructor===Object}var Ig={length:!0,name:!0},Rg={toString:!0,valueOf:!0,toLocaleString:!0};class Qo{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 $g(this.wrappedObject,e)}}function ea(){return new Map}function ra(r){if(!r)return ea();if(Ko(r))return r;if(ko(r))return new Qo(r);throw new Error("createMap can create maps from objects or Maps")}function _g(r){if(r instanceof Qo)return r.wrappedObject;var e={};for(var t of r.keys()){var a=r.get(t);jn(e,t,a)}return e}function Ko(r){return r?r instanceof Map||r instanceof Qo||typeof r.set=="function"&&typeof r.get=="function"&&typeof r.keys=="function"&&typeof r.has=="function":!1}function Bl(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(Ko(n))for(var i of n.keys())r.set(i,n.get(i));else if(ko(n))for(var o of Object.keys(n))r.set(o,n[o])}return r}var $l=function(){return $l=hl.create,hl},qg=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],zg=q("typed",qg,function(e){var{BigNumber:t,Complex:a,DenseMatrix:n,Fraction:i}=e,o=$l();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=>Xr&&/^(?:[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:Xr},{name:"Chain",test:cl},{name:"Array",test:cr},{name:"Matrix",test:Ve},{name:"DenseMatrix",test:li},{name:"SparseMatrix",test:En},{name:"Range",test:Uo},{name:"Index",test:ci},{name:"boolean",test:k0},{name:"ResultSet",test:V0},{name:"Help",test:ll},{name:"function",test:G0},{name:"Date",test:H0},{name:"RegExp",test:Z0},{name:"null",test:J0},{name:"undefined",test:W0},{name:"AccessorNode",test:Sn},{name:"ArrayNode",test:ot},{name:"AssignmentNode",test:X0},{name:"BlockNode",test:Y0},{name:"ConditionalNode",test:Q0},{name:"ConstantNode",test:ir},{name:"FunctionNode",test:nn},{name:"FunctionAssignmentNode",test:Pa},{name:"IndexNode",test:Jn},{name:"Node",test:fr},{name:"ObjectNode",test:fi},{name:"OperatorNode",test:Br},{name:"ParenthesisNode",test:Gt},{name:"RangeNode",test:K0},{name:"RelationalNode",test:j0},{name:"SymbolNode",test:qr},{name:"Map",test:Ko},{name:"Object",test:ko}]),o.addConversions([{from:"number",to:"BigNumber",convert:function(l){if(t||jo(l),vg(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||bi(l),new a(l,0)}},{from:"BigNumber",to:"Complex",convert:function(l){return a||bi(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||bi(l),new a(l.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(l){i||es(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||jo(l);try{return new t(l)}catch{throw new Error('Cannot convert "'+l+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(l){i||es(l);try{return new i(l)}catch{throw new Error('Cannot convert "'+l+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(l){a||bi(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||jo(l),new t(+l)}},{from:"boolean",to:"Fraction",convert:function(l){return i||es(l),new i(+l)}},{from:"boolean",to:"string",convert:function(l){return String(l)}},{from:"Array",to:"Matrix",convert:function(l){return n||Pg(),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 jo(r){throw new Error("Cannot convert value ".concat(r," into a BigNumber: no class 'BigNumber' provided"))}function bi(r){throw new Error("Cannot convert value ".concat(r," into a Complex number: no class 'Complex' provided"))}function Pg(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function es(r){throw new Error("Cannot convert value ".concat(r," into a Fraction, no class 'Fraction' provided."))}var Lg="ResultSet",Ug=[],kg=q(Lg,Ug,()=>{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
- * decimal.js v10.4.3
11
- * An arbitrary-precision Decimal type for JavaScript.
12
- * https://github.com/MikeMcl/decimal.js
13
- * Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
14
- * MIT Licence
15
- */var ta=9e15,on=1e9,rs="0123456789abcdef",xi="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",wi="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ts={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ta,maxE:ta,crypto:!1},Ol,Zt,We=!0,Ni="[DecimalError] ",sn=Ni+"Invalid argument: ",Il=Ni+"Precision limit exceeded",Rl=Ni+"crypto unavailable",_l="[object Decimal]",Gr=Math.floor,Or=Math.pow,Vg=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Gg=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Hg=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,ql=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,gt=1e7,He=7,Zg=9007199254740991,Jg=xi.length-1,ns=wi.length-1,we={toStringTag:_l};we.absoluteValue=we.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),Pe(r)},we.ceil=function(){return Pe(new this.constructor(this),this.e+1,2)},we.clampedTo=we.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)},we.comparedTo=we.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},we.cosine=we.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=Wg(a,Vl(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)},we.cubeRoot=we.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(We=!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 We=!0,Pe(a,r,c.rounding,e)},we.decimalPlaces=we.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},we.dividedBy=we.div=function(r){return gr(this,new this.constructor(r))},we.dividedToIntegerBy=we.divToInt=function(r){var e=this,t=e.constructor;return Pe(gr(e,new t(r),0,1,1),t.precision,t.rounding)},we.equals=we.eq=function(r){return this.cmp(r)===0},we.floor=function(){return Pe(new this.constructor(this),this.e+1,3)},we.greaterThan=we.gt=function(r){return this.cmp(r)>0},we.greaterThanOrEqualTo=we.gte=function(r){var e=this.cmp(r);return e==1||e===0},we.hyperbolicCosine=we.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/Si(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)},we.hyperbolicSine=we.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/Si(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)},we.hyperbolicTangent=we.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)},we.inverseCosine=we.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))},we.inverseHyperbolicCosine=we.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,We=!1,t=t.times(t).minus(1).sqrt().plus(t),We=!0,a.precision=r,a.rounding=e,t.ln()):new a(t)},we.inverseHyperbolicSine=we.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,We=!1,t=t.times(t).plus(1).sqrt().plus(t),We=!0,a.precision=r,a.rounding=e,t.ln())},we.inverseHyperbolicTangent=we.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)},we.inverseSine=we.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)))},we.inverseTangent=we.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<=ns)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<=ns)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(We=!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)),We=!0,Pe(o,s.precision=c,s.rounding=m,!0)},we.isFinite=function(){return!!this.d},we.isInteger=we.isInt=function(){return!!this.d&&Gr(this.e/He)>this.d.length-2},we.isNaN=function(){return!this.s},we.isNegative=we.isNeg=function(){return this.s<0},we.isPositive=we.isPos=function(){return this.s>0},we.isZero=function(){return!!this.d&&this.d[0]===0},we.lessThan=we.lt=function(r){return this.cmp(r)<0},we.lessThanOrEqualTo=we.lte=function(r){return this.cmp(r)<1},we.logarithm=we.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(We=!1,f=c+v,o=ln(u,f),a=e?Ei(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?Ei(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 We=!0,Pe(l,c,m)},we.minus=we.sub=function(r){var e,t,a,n,i,o,f,l,u,s,c,m,v=this,d=v.constructor;if(r=new d(r),!v.d||!r.d)return!v.s||!r.s?r=new d(NaN):v.d?r.s=-r.s:r=new d(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=d.precision,l=d.rounding,!u[0]||!m[0]){if(m[0])r.s=-r.s;else if(u[0])r=new d(v);else return new d(l===3?-0:0);return We?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=Ai(u,t),We?Pe(r,f,l):r):new d(l===3?-0:0)},we.modulo=we.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):(We=!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),We=!0,t.minus(e))},we.naturalExponential=we.exp=function(){return as(this)},we.naturalLogarithm=we.ln=function(){return ln(this)},we.negated=we.neg=function(){var r=new this.constructor(this);return r.s=-r.s,Pe(r)},we.plus=we.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)),We?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=Ai(u,a),We?Pe(r,f,l):r},we.precision=we.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=zl(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e},we.round=function(){var r=this,e=r.constructor;return Pe(new e(r),r.e+1,e.rounding)},we.sine=we.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=Yg(a,Vl(a,t)),a.precision=r,a.rounding=e,Pe(Zt>2?t.neg():t,r,e,!0)):new a(NaN)},we.squareRoot=we.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(We=!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 We=!0,Pe(a,l,s.rounding,r)},we.tangent=we.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)},we.times=we.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=Ai(i,t),We?Pe(r,c.precision,c.rounding):r},we.toBinary=function(r,e){return os(this,2,r,e)},we.toDecimalPlaces=we.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))},we.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},we.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},we.toFraction=function(r){var e,t,a,n,i,o,f,l,u,s,c,m,v=this,d=v.d,p=v.constructor;if(!d)return new p(v);if(u=t=new p(1),a=l=new p(0),e=new p(a),i=e.e=zl(d)-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(We=!1,f=new p(Pr(d)),s=p.precision,p.precision=i=d.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,We=!0,m},we.toHexadecimal=we.toHex=function(r,e){return os(this,16,r,e)},we.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]?(We=!1,t=gr(t,r,0,e,1).times(r),We=!0,Pe(t)):(r.s=t.s,t=r),t},we.toNumber=function(){return+this},we.toOctal=function(r,e){return os(this,8,r,e)},we.toPower=we.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)<=Zg)return n=Pl(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):(We=!1,l.rounding=f.s=1,t=Math.min(12,(e+"").length),n=as(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(as(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,We=!0,l.rounding=i,Pe(n,a,i))},we.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},we.toSignificantDigits=we.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)},we.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},we.truncated=we.trunc=function(){return Pe(new this.constructor(this),this.e+1,1)},we.valueOf=we.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 Di(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]+=rs.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 Wg(r,e){var t,a,n;if(e.isZero())return e;a=e.d.length,a<32?(t=Math.ceil(a/3),n=(1/Si(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,d,p,g,y,N,h,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),d=!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;d=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,h=R.slice(0,T),w=h.length;w<T;)h[w++]=0;B=M.slice(),B.unshift(0),D=M[0],M[1]>=l/2&&++D;do m=0,u=e(M,h,T,w),u<0?(x=h[0],T!=w&&(x=x*l+(h[1]||0)),m=x/D|0,m>1?(m>=l&&(m=l-1),p=r(M,m,l),g=p.length,w=h.length,u=e(p,h,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(h,p,w,l),u==-1&&(w=h.length,u=e(M,h,T,w),u<1&&(m++,t(h,T<w?B:M,w,l))),w=h.length):u===0&&(m++,h=[0]),N[c++]=m,u&&h[0]?h[w++]=R[A]||0:(h=[R[A]],w=1);while((A++<S||h[0]!==void 0)&&b--);d=h[0]!==void 0}N[0]||N.shift()}if(v==1)y.e=s,Ol=d;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,d)}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 We&&(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 kl(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 Ai(r,e){var t=r[0];for(e*=He;t>=10;t/=10)e++;return e}function Ei(r,e,t){if(e>Jg)throw We=!0,t&&(r.precision=t),Error(Il);return Pe(new r(xi),e,1,!0)}function yt(r,e,t){if(e>ns)throw Error(Il);return Pe(new r(wi),e,t,!0)}function zl(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 Pl(r,e,t,a){var n,i=new r(1),o=Math.ceil(a/He+4);for(We=!1;;){if(t%2&&(i=i.times(e),Gl(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),Gl(e.d,o)}return We=!0,i}function Ll(r){return r.d[r.d.length-1]&1}function Ul(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 as(r,e){var t,a,n,i,o,f,l,u=0,s=0,c=0,m=r.constructor,v=m.rounding,d=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?(We=!1,l=d):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=d,v,We=!0);else return m.precision=d,o}o=f}}function ln(r,e){var t,a,n,i,o,f,l,u,s,c,m,v=1,d=10,p=r,g=p.d,y=p.constructor,N=y.rounding,h=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?(We=!1,s=h):s=e,y.precision=s+=d,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=Ei(y,s+2,h).times(i+""),p=ln(new y(a+"."+t.slice(1)),s-d).plus(u),y.precision=h,e==null?Pe(p,h,N,We=!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(Ei(y,s+2,h).times(i+""))),l=gr(l,new y(v),s,1),e==null)if(ka(l.d,s-d,N,f))y.precision=s+=d,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=h,N,We=!0);else return y.precision=h,l;l=u,n+=2}}function kl(r){return String(r.s*r.s/0)}function is(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),We&&(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 Xg(r,e){var t,a,n,i,o,f,l,u,s;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),ql.test(e))return is(r,e)}else if(e==="Infinity"||e==="NaN")return+e||(r.s=NaN),r.e=NaN,r.d=null,r;if(Gg.test(e))t=16,e=e.toLowerCase();else if(Vg.test(e))t=2;else if(Hg.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=Pl(a,new a(t),i,i*2)),u=Di(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=Ai(u,s),r.d=u,We=!1,o&&(r=gr(r,n,f*4)),l&&(r=r.times(Math.abs(l)<54?Or(2,l):cn.pow(2,l))),We=!0,r)}function Yg(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/Si(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(We=!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 We=!0,o.d.length=s+1,o}function Si(r,e){for(var t=r;--e;)t*=r;return t}function Vl(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=Ll(t)?a?2:3:a?4:1,e;Zt=Ll(t)?a?1:4:a?3:2}return e.minus(n).abs()}function os(r,e,t,a){var n,i,o,f,l,u,s,c,m,v=r.constructor,d=t!==void 0;if(d?(et(t,1,on),a===void 0?a=v.rounding:et(a,0,8)):(t=v.precision,a=v.rounding),!r.isFinite())s=kl(r);else{for(s=Tt(r),o=s.indexOf("."),d?(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=Di(Tt(m),10,n),m.e=m.d.length),c=Di(s,10,n),i=l=c.length;c[--l]==0;)c.pop();if(!c[0])s=d?"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=Ol),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+=rs.charAt(c[o]);if(d){if(l>1)if(e==16||e==8){for(o=e==16?4:3,--l;l%o;l++)s+="0";for(c=Di(s,n,e),l=c.length;!c[l-1];--l);for(o=1,s="1.";o<l;o++)s+=rs.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 Gl(r,e){if(r.length>e)return r.length=e,!0}function Qg(r){return new this(r).abs()}function Kg(r){return new this(r).acos()}function jg(r){return new this(r).acosh()}function e1(r,e){return new this(r).plus(e)}function r1(r){return new this(r).asin()}function t1(r){return new this(r).asinh()}function n1(r){return new this(r).atan()}function a1(r){return new this(r).atanh()}function i1(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 o1(r){return new this(r).cbrt()}function s1(r){return Pe(r=new this(r),r.e+1,2)}function u1(r,e,t){return new this(r).clamp(e,t)}function l1(r){if(!r||typeof r!="object")throw Error(Ni+"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]=ts[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]=ts[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(Rl);else this[t]=!1;else throw Error(sn+t+": "+a);return this}function c1(r){return new this(r).cos()}function f1(r){return new this(r).cosh()}function Hl(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,Zl(i)){u.s=i.s,We?!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++;We?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 is(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),ql.test(i)?is(u,i):Xg(u,i)}if(n.prototype=we,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=l1,n.clone=Hl,n.isDecimal=Zl,n.abs=Qg,n.acos=Kg,n.acosh=jg,n.add=e1,n.asin=r1,n.asinh=t1,n.atan=n1,n.atanh=a1,n.atan2=i1,n.cbrt=o1,n.ceil=s1,n.clamp=u1,n.cos=c1,n.cosh=f1,n.div=m1,n.exp=v1,n.floor=p1,n.hypot=d1,n.ln=h1,n.log=g1,n.log10=b1,n.log2=y1,n.max=x1,n.min=w1,n.mod=N1,n.mul=D1,n.pow=A1,n.random=E1,n.round=S1,n.sign=C1,n.sin=M1,n.sinh=F1,n.sqrt=T1,n.sub=B1,n.sum=$1,n.tan=O1,n.tanh=I1,n.trunc=R1,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 m1(r,e){return new this(r).div(e)}function v1(r){return new this(r).exp()}function p1(r){return Pe(r=new this(r),r.e+1,3)}function d1(){var r,e,t=new this(0);for(We=!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 We=!0,new this(1/0);t=e}return We=!0,t.sqrt()}function Zl(r){return r instanceof cn||r&&r.toStringTag===_l||!1}function h1(r){return new this(r).ln()}function g1(r,e){return new this(r).log(e)}function y1(r){return new this(r).log(2)}function b1(r){return new this(r).log(10)}function x1(){return Ul(this,arguments,"lt")}function w1(){return Ul(this,arguments,"gt")}function N1(r,e){return new this(r).mod(e)}function D1(r,e){return new this(r).mul(e)}function A1(r,e){return new this(r).pow(e)}function E1(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(Rl);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 S1(r){return Pe(r=new this(r),r.e+1,this.rounding)}function C1(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function M1(r){return new this(r).sin()}function F1(r){return new this(r).sinh()}function T1(r){return new this(r).sqrt()}function B1(r,e){return new this(r).sub(e)}function $1(){var r=0,e=arguments,t=new this(e[r]);for(We=!1;t.s&&++r<e.length;)t=t.plus(e[r]);return We=!0,Pe(t,this.precision,this.rounding)}function O1(r){return new this(r).tan()}function I1(r){return new this(r).tanh()}function R1(r){return Pe(r=new this(r),r.e+1,1)}we[Symbol.for("nodejs.util.inspect.custom")]=we.toString,we[Symbol.toStringTag]="Decimal";var cn=we.constructor=Hl(ts);xi=new cn(xi),wi=new cn(wi);var _1="BigNumber",q1=["?on","config"],z1=q(_1,q1,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 Jl(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function P1(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 Wl={exports:{}};/**
16
- * @license Complex.js v2.1.1 12/05/2020
17
- *
18
- * Copyright (c) 2020, Robert Eisele (robert@xarg.org)
19
- * Dual licensed under the MIT or GPL Version 2 licenses.
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),d=Math.abs(m);return v<3e3&&d<3e3?Math.sqrt(v*v+d*d):(v<d?(v=d,d=c/m):d=m/c,v*Math.sqrt(1+d*d))},f=function(){throw SyntaxError("Invalid Param")};function l(c,m){var v=Math.abs(c),d=Math.abs(m);return c===0?Math.log(d):m===0?Math.log(v):v<3e3&&d<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 d=c.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),p=1,g=0;d===null&&f();for(var y=0;y<d.length;y++){var N=d[y];N===" "||N===" "||N===`
21
- `||(N==="+"?p++:N==="-"?g++:N==="i"||N==="I"?(p+g===0&&f(),d[y+1]!==" "&&!isNaN(d[y+1])?(v.im+=parseFloat((g%2?"-":"")+d[y+1]),y++):v.im+=parseFloat((g%2?"-":"")+"1"),p=g=0):((p+g===0||isNaN(N))&&f(),d[y+1]==="i"||d[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 d=v.re,p=v.im,g,y;return p===0?new s(c/d,m/d):Math.abs(d)<Math.abs(p)?(y=d/p,g=d*y+p,new s((c*y+m)/g,(m*y-c)/g)):(y=p/d,g=p*y+d,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 d=Math.atan2(m,c),p=l(c,m);return c=Math.exp(v.re*p-v.im*d),m=v.im*p+v.re*d,new s(c*Math.cos(m),c*Math.sin(m))},sqrt:function(){var c=this.re,m=this.im,v=this.abs(),d,p;if(c>=0){if(m===0)return new s(Math.sqrt(c),0);d=.5*Math.sqrt(2*(v+c))}else d=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(d,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(),d=new s(v.re-m,v.im+c).log();return new s(d.im,-d.re)},acos:function(){var c=this.re,m=this.im,v=new s(m*m-c*c+1,-2*c*m).sqrt(),d=new s(v.re-m,v.im+c).log();return new s(Math.PI/2-d.im,d.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),d=new s((1-m*m-c*c)/v,-2*c/v).log();return new s(-.5*d.im,.5*d.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,d=1-c,p=1+c,g=d*d+m*m,y=g!==0?new s((p*d-m*m)/g,(m*d+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})()})(Wl);const Lr=Jl(Wl.exports);var L1="Complex",U1=[],k1=q(L1,U1,()=>(Object.defineProperty(Lr,"name",{value:"Complex"}),Lr.prototype.constructor=Lr,Lr.prototype.type="Complex",Lr.prototype.isComplex=!0,Lr.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Lr.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Lr.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},Lr.fromPolar=function(r){switch(arguments.length){case 1:{var e=arguments[0];if(typeof e=="object")return Lr(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 Lr({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")}},Lr.prototype.valueOf=Lr.prototype.toString,Lr.fromJSON=function(r){return new Lr(r)},Lr.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},Lr),{isClass:!0}),Xl={exports:{}};/**
22
- * @license Fraction.js v4.2.0 05/03/2022
23
- * https://www.xarg.org/2014/03/rational-numbers-in-javascript/
24
- *
25
- * Copyright (c) 2021, Robert Eisele (robert@xarg.org)
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(d,p){if(isNaN(d=parseInt(d,10)))throw v.InvalidParameter;return d*p}function o(d,p){if(p===0)throw v.DivisionByZero;var g=Object.create(v.prototype);g.s=d<0?-1:1,d=d<0?-d:d;var y=m(d,p);return g.n=d/y,g.d=p/y,g}function f(d){for(var p={},g=d,y=2,N=4;N<=g;){for(;g%y===0;)g/=y,p[y]=(p[y]||0)+1;N+=1+2*y++}return g!==d?g>1&&(p[g]=(p[g]||0)+1):p[d]=(p[d]||0)+1,p}var l=function(d,p){var g=0,y=1,N=1,h=0,w=0,x=0,b=1,E=1,A=0,S=1,D=1,T=1,B=1e7,I;if(d!=null)if(p!==void 0){if(g=d,y=p,N=g*y,g%1!==0||y%1!==0)throw v.NonIntegerParameter}else switch(typeof d){case"object":{if("d"in d&&"n"in d)g=d.n,y=d.d,"s"in d&&(g*=d.s);else if(0 in d)g=d[0],1 in d&&(y=d[1]);else throw v.InvalidParameter;N=g*y;break}case"number":{if(d<0&&(N=d,d=-d),d%1===0)g=d;else if(d>0){for(d>=1&&(E=Math.pow(10,Math.floor(1+Math.log(d)/Math.LN10)),d/=E);S<=B&&T<=B;)if(I=(A+D)/(S+T),d===I){S+T<=B?(g=A+D,y=S+T):T>S?(g=D,y=T):(g=A,y=S);break}else d>I?(A+=D,S+=T):(D+=A,T+=S),S>B?(g=D,y=T):(g=A,y=S);g*=E}else(isNaN(d)||isNaN(p))&&(y=g=NaN);break}case"string":{if(S=d.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]!=="."&&(h=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]===" "&&(h=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*h+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(d,p,g){for(var y=1;p>0;d=d*d%g,p>>=1)p&1&&(y=y*d%g);return y}function s(d,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(d,p,g){for(var y=1,N=u(10,g,p),h=0;h<300;h++){if(y===N)return h;y=y*10%p,N=N*10%p}return 0}function m(d,p){if(!d)return p;if(!p)return d;for(;;){if(d%=p,!d)return p;if(p%=d,!p)return d}}function v(d,p){if(l(d,p),this instanceof v)d=m(n.d,n.n),this.s=n.s,this.n=n.n/d,this.d=n.d/d;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(d,p){return l(d,p),o(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(d,p){return l(d,p),o(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(d,p){return l(d,p),o(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(d,p){return l(d,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(d,p){if(isNaN(this.n)||isNaN(this.d))return new v(NaN);if(d===void 0)return o(this.s*this.n%this.d,1);if(l(d,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(d,p){return l(d,p),o(m(n.n,this.n)*m(n.d,this.d),n.d*this.d)},lcm:function(d,p){return l(d,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(d){return d=Math.pow(10,d||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):o(Math.ceil(d*this.s*this.n/this.d),d)},floor:function(d){return d=Math.pow(10,d||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):o(Math.floor(d*this.s*this.n/this.d),d)},round:function(d){return d=Math.pow(10,d||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):o(Math.round(d*this.s*this.n/this.d),d)},inverse:function(){return o(this.s*this.d,this.n)},pow:function(d,p){if(l(d,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,h=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;h*=Math.pow(w,y[w])}return n.s<0?o(h,N):o(N,h)},equals:function(d,p){return l(d,p),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(d,p){l(d,p);var g=this.s*this.n*n.d-n.s*n.n*this.d;return(0<g)-(g<0)},simplify:function(d){if(isNaN(this.n)||isNaN(this.d))return this;d=d||.001;for(var p=this.abs(),g=p.toContinued(),y=1;y<g.length;y++){for(var N=o(g[y-1],1),h=y-2;h>=0;h--)N=N.inverse().add(g[h]);if(N.sub(p).abs().valueOf()<d)return N.mul(this.s)}return this},divisible:function(d,p){return l(d,p),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(d){var p,g="",y=this.n,N=this.d;return this.s<0&&(g+="-"),N===1?g+=y:(d&&(p=Math.floor(y/N))>0&&(g+=p,g+=" ",y%=N),g+=y,g+="/",g+=N),g},toLatex:function(d){var p,g="",y=this.n,N=this.d;return this.s<0&&(g+="-"),N===1?g+=y:(d&&(p=Math.floor(y/N))>0&&(g+=p,y%=N),g+="\\frac{",g+=y,g+="}{",g+=N,g+="}"),g},toContinued:function(){var d,p=this.n,g=this.d,y=[];if(isNaN(p)||isNaN(g))return y;do y.push(Math.floor(p/g)),d=p%g,p=g,g=d;while(p!==1);return y},toString:function(d){var p=this.n,g=this.d;if(isNaN(p)||isNaN(g))return"NaN";d=d||15;var y=s(p,g),N=c(p,g,y),h=this.s<0?"-":"";if(h+=p/g|0,p%=g,p*=10,p&&(h+="."),y){for(var w=N;w--;)h+=p/g|0,p%=g,p*=10;h+="(";for(var w=y;w--;)h+=p/g|0,p%=g,p*=10;h+=")"}else for(var w=d;p&&w--;)h+=p/g|0,p%=g,p*=10;return h}},Object.defineProperty(v,"__esModule",{value:!0}),v.default=v,v.Fraction=v,r.exports=v})()})(Xl);const Jt=Jl(Xl.exports);var V1="Fraction",G1=[],H1=q(V1,G1,()=>(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}),Z1="Range",J1=[],W1=q(Z1,J1,()=>{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}),X1="Matrix",Y1=[],Q1=q(X1,Y1,()=>{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 K1(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:K1(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 j1="DenseMatrix",ey=["Matrix"],ry=q(j1,ey,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&&!Xr(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,Nl(this._data,this._size),this._datatype=c||s.datatype;else if(cr(s))this._data=u(s),this._size=er(this._data),Nl(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,d=s.length;v<d;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,d,p,g=s.map(function(N){return N+1});l(this,g,m);var y=this._data;for(v=0,d=s.length-1;v<d;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(!ci(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 d=c.min(),p=c.max(),g=0,y=s._size.length;g<y;g++)vr(d[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 d=v===m-1,p=c.dimension(v);return d?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 d=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(d.length<s._size.length)throw new Ke(d.length,s._size.length,"<");if(g.length<d.length){for(var y=0,N=0;d[y]===1&&g[y]===1;)y++;for(;d[y]===1;)N++,y++;m=Sl(m,d.length,N,g)}if(!La(d,g))throw new Ke(d,g,">");var h=c.max().map(function(b){return b+1});l(s,h,v);var w=d.length,x=0;o(s._data,c,m,w,x)}return s}function o(s,c,m,v,d){var p=d===v-1,g=c.dimension(d);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,d+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),d=m?this.clone():this;return f(d,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=Dl(m._data,s);var v=m._size.reduce((d,p)=>d*p);return m._size=Wo(s,v),m};function l(s,c,m){for(var v=s._size.slice(0),d=!1;v.length<c.length;)v.push(0),d=!0;for(var p=0,g=c.length;p<g;p++)c[p]>v[p]&&(v[p]=c[p],d=!0);d&&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(h,w){return g(h,N.concat(w))}):m===1?s(y):m===2?s(y,N):s(y,N,c)},d=v(this._data,[]),p=this._datatype!==void 0?Ua(d,br):void 0;return new t(d,p)},t.prototype.forEach=function(s){var c=this,m=function v(d,p){cr(d)?d.forEach(function(g,y){v(g,p.concat(y))}):s(d,p,c)};m(this._data,[])},t.prototype[Symbol.iterator]=function*(){var s=function*c(m,v){if(cr(m))for(var d=0;d<m.length;d++)yield*c(m[d],v.concat(d));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,d=function(y){var N=v.map(h=>[h[y]]);c.push(new t(N,s._datatype))},p=0;p<m[1];p++)d(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],d=this._size[1],p=Math.min(v-m,d-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 d=m>0?m:0,p=m<0?-m:0,g=s[0],y=s[1],N=Math.min(g-p,y-d),h;if(cr(c)){if(c.length!==N)throw new Error("Invalid value array length");h=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");h=function(A){return c.get([A])}}else h=function(){return c};v||(v=rr(h(0))?h(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+d]=h(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}),Yl="clone",ty=["typed"],ny=q(Yl,ty,r=>{var{typed:e}=r;return e(Yl,{any:Ge})});function Ql(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 Wt(r,e){Ve(r)&&(r=r.valueOf());for(var t=0,a=r.length;t<a;t++){var n=r[t];Array.isArray(n)?Wt(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 Ci(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(Mi(r.valueOf(),e,t)):Mi(r,e,t)}function Mi(r,e,t){var a,n,i,o;if(e<=0)if(Array.isArray(r[0])){for(o=Ql(r),n=[],a=0;a<o.length;a++)n[a]=Mi(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]=Mi(r[a],e-1,t);return n}}function Kl(r,e,t,a,n,i,o,f,l,u,s){var c=r._values,m=r._index,v=r._ptr,d,p,g,y;if(a)for(p=v[e],g=v[e+1],d=p;d<g;d++)y=m[d],t[y]!==i?(t[y]=i,o.push(y),u?(a[y]=l?f(c[d],s):f(s,c[d]),n[y]=i):a[y]=c[d]):(a[y]=l?f(c[d],a[y]):f(a[y],c[d]),n[y]=i);else for(p=v[e],g=v[e+1],d=p;d<g;d++)y=m[d],t[y]!==i?(t[y]=i,o.push(y)):n[y]=i}var jl="isInteger",ay=["typed"],iy=q(jl,ay,r=>{var{typed:e}=r;return e(jl,{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 ec(r){return Math.abs(r)}ec.signature=bt;function rc(r,e){return r+e}rc.signature=Fn;function tc(r,e){return r*e}tc.signature=Fn;function nc(r){return-r}nc.signature=bt;function ac(r){return r}ac.signature=bt;function Ga(r){return lg(r)}Ga.signature=bt;function ic(r){return r*r*r}ic.signature=bt;function oc(r){return Math.exp(r)}oc.signature=bt;function sc(r){return cg(r)}sc.signature=bt;function uc(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}uc.signature=Fn;function lc(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)}lc.signature=Fn;function oy(r,e){return e?Math.log(r)/Math.log(e):Math.log(r)}function cc(r){return sg(r)}cc.signature=bt;function fc(r){return og(r)}fc.signature=bt;function mc(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")}mc.signature=Fn;function vc(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 ss(r){return an(r)}ss.signature=bt;function pc(r){return r*r}pc.signature=bt;function dc(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}dc.signature=Fn;function hc(r,e){return r*r<1&&e===1/0||r*r>1&&e===-1/0?0:Math.pow(r,e)}hc.signature=Fn;function gc(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(gl(r,e))}var sy="number",ia="number, number";function yc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitAnd");return r&e}yc.signature=ia;function bc(r){if(!qe(r))throw new Error("Integer expected in function bitNot");return~r}bc.signature=sy;function xc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitOr");return r|e}xc.signature=ia;function wc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitXor");return r^e}wc.signature=ia;function Nc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function leftShift");return r<<e}Nc.signature=ia;function Dc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function rightArithShift");return r>>e}Dc.signature=ia;function Ac(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function rightLogShift");return r>>>e}Ac.signature=ia;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 Ec(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}Ec.signature="number, number";var uy=Math.PI,ly=2*Math.PI,cy=Math.E,fy=1.618033988749895,my="number",us="number, number";function Sc(r){return!r}Sc.signature=my;function Cc(r,e){return!!(r||e)}Cc.signature=us;function Mc(r,e){return!!r!=!!e}Mc.signature=us;function Fc(r,e){return!!(r&&e)}Fc.signature=us;function Fi(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)*Fi(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+Tc+.5;return Math.sqrt(2*Math.PI)*Math.pow(f,r+.5)*Math.exp(-f)*e}Fi.signature="number";var Tc=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],Bc=.9189385332046728,vy=5,py=7,$c=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function Ti(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))-Ti(1-r);r=r-1;for(var e=r+vy+.5,t=$c[0],a=py-1;a>=1;a--)t+=$c[a]/(r+a);return Bc+(r+.5)*Math.log(e)-e+Math.log(t)}Ti.signature="number";var Hr="number";function Oc(r){return dg(r)}Oc.signature=Hr;function Ic(r){return Math.atan(1/r)}Ic.signature=Hr;function Rc(r){return isFinite(r)?(Math.log((r+1)/r)+Math.log(r/(r-1)))/2:0}Rc.signature=Hr;function _c(r){return Math.asin(1/r)}_c.signature=Hr;function qc(r){var e=1/r;return Math.log(e+Math.sqrt(e*e+1))}qc.signature=Hr;function zc(r){return Math.acos(1/r)}zc.signature=Hr;function Pc(r){var e=1/r,t=Math.sqrt(e*e-1);return Math.log(t+e)}Pc.signature=Hr;function Lc(r){return hg(r)}Lc.signature=Hr;function Uc(r){return gg(r)}Uc.signature=Hr;function kc(r){return 1/Math.tan(r)}kc.signature=Hr;function Vc(r){var e=Math.exp(2*r);return(e+1)/(e-1)}Vc.signature=Hr;function Gc(r){return 1/Math.sin(r)}Gc.signature=Hr;function Hc(r){return r===0?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(r)-Math.exp(-r)))*an(r)}Hc.signature=Hr;function Zc(r){return 1/Math.cos(r)}Zc.signature=Hr;function Jc(r){return 2/(Math.exp(r)+Math.exp(-r))}Jc.signature=Hr;function Wc(r){return bg(r)}Wc.signature=Hr;var Bi="number";function Xc(r){return r<0}Xc.signature=Bi;function Yc(r){return r>0}Yc.signature=Bi;function Qc(r){return r===0}Qc.signature=Bi;function Kc(r){return Number.isNaN(r)}Kc.signature=Bi;var jc="isNegative",dy=["typed"],hy=q(jc,dy,r=>{var{typed:e}=r;return e(jc,{number:Xc,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))})}),ef="isNumeric",gy=["typed"],yy=q(ef,gy,r=>{var{typed:e}=r;return e(ef,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),rf="hasNumericValue",by=["typed","isNumeric"],xy=q(rf,by,r=>{var{typed:e,isNumeric:t}=r;return e(rf,{boolean:()=>!0,string:function(n){return n.trim().length>0&&!isNaN(Number(n))},any:function(n){return t(n)}})}),tf="isPositive",wy=["typed"],Ny=q(tf,wy,r=>{var{typed:e}=r;return e(tf,{number:Yc,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))})}),nf="isZero",Dy=["typed"],Ay=q(nf,Dy,r=>{var{typed:e}=r;return e(nf,{number:Qc,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))})}),af="isNaN",Ey=["typed"],Sy=q(af,Ey,r=>{var{typed:e}=r;return e(af,{number:Kc,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)}})}),of="typeOf",Cy=["typed"],My=q(of,Cy,r=>{var{typed:e}=r;return e(of,{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 Fy(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)})}}),$i="equalScalar",Ty=["typed","config"],By=q($i,Ty,r=>{var{typed:e,config:t}=r,a=sa({typed:e});return e($i,{"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 Fy(i,o,t.epsilon)}},a)});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)}})});var $y="SparseMatrix",Oy=["typed","equalScalar","Matrix"],Iy=q($y,Oy,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&&!Xr(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,h=0,w=t,x=0;if(Xr(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&&h<A.length&&(h=A.length),b<A.length){var S=A[b];w(S,x)||(p._values.push(S),p._index.push(E))}}else b===0&&h<1&&(h=1),w(A,x)||(p._values.push(A),p._index.push(E))}b++}while(b<h)}p._ptr.push(p._index.length),p._size=[N,h]}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(!ci(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 h,w,x,b,E=g.min(),A=g.max();for(h=0,w=p._size.length;h<w;h++)vr(E[h],p._size[h]),vr(A[h],p._size[h]);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++)h=D[x],P[h]===!0&&(F.push(R[h]),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 h=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(h.length!==1&&h.length!==2)throw new Ke(h.length,p._size.length,"<");if(x.length<h.length){for(var b=0,E=0;h[b]===1&&x[b]===1;)b++;for(;h[b]===1;)E++,b++;y=Sl(y,h.length,E,x)}if(!La(h,x))throw new Ke(h,x,">");if(h.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],h=p[1],w=this._size[0],x=this._size[1],b=t,E=0;Xr(this._datatype)&&(b=e.find(t,[this._datatype,this._datatype])||t,E=e.convert(0,this._datatype)),(N>w-1||h>x-1)&&(m(this,Math.max(N+1,w),Math.max(h+1,x),y),w=this._size[0],x=this._size[1]),vr(N,w),vr(h,x);var A=u(N,this._ptr[h],this._ptr[h+1],this._index);return A<this._ptr[h+1]&&this._index[A]===N?b(g,E)?s(A,h,this._values,this._index,this._ptr):this._values[A]=g:b(g,E)||c(A,N,h,g,this._values,this._index,this._ptr),this};function u(p,g,y,N){if(y-g===0)return y;for(var h=g;h<y;h++)if(N[h]===p)return h;return g}function s(p,g,y,N,h){y.splice(p,1),N.splice(p,1);for(var w=g+1;w<h.length;w++)h[w]--}function c(p,g,y,N,h,w,x){h.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 h=y?this.clone():this;return m(h,N[0],N[1],g)};function m(p,g,y,N){var h=N||0,w=t,x=0;Xr(p._datatype)&&(w=e.find(t,[p._datatype,p._datatype])||t,x=e.convert(0,p._datatype),h=e.convert(h,p._datatype));var b=!w(h,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(h),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,h),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=Wo(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 h=g?this.clone():this;if(this._size[0]===p[0]&&this._size[1]===p[1])return h;for(var w=[],x=0;x<h._ptr.length;x++)for(var b=0;b<h._ptr[x+1]-h._ptr[x];b++)w.push(x);for(var E=h._values.slice(),A=h._index.slice(),S=0;S<h._index.length;S++){var D=A[S],T=w[S],B=D*h._size[1]+T;w[S]=B%p[1],A[S]=Math.floor(B/p[1])}h._values.length=0,h._index.length=0,h._ptr.length=p[1]+1,h._size=p.slice();for(var I=0;I<h._ptr.length;I++)h._ptr[I]=0;for(var P=0;P<E.length;P++){var R=A[P],M=w[P],F=E[P],H=u(R,h._ptr[M],h._ptr[M+1],h._index);c(H,R,M,F,h._values,h._index,h._ptr)}return h},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],h=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,h-1,x,g)};function v(p,g,y,N,h,w,x){var b=[],E=[],A=[],S=t,D=0;Xr(p._datatype)&&(S=e.find(t,[p._datatype,p._datatype])||t,D=e.convert(0,p._datatype));for(var T=function(U,j,ae){U=w(U,j,ae),S(U,D)||(b.push(U),E.push(j))},B=N;B<=h;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,h-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],h=this._size[1],w=0;w<h;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],h=y;h<N;h++){var w=this._index[h];yield{value:this._values[h],index:[w,g]}}},n.prototype.toArray=function(){return d(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return d(this._values,this._index,this._ptr,this._size,!1)};function d(p,g,y,N,h){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?h?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(),h="Sparse Matrix ["+Ye(g,p)+" x "+Ye(y,p)+"] density: "+Ye(N,p)+`
8
+ `);return Object.freeze(nl)};zr(ye,nl,{MATRIX_OPTIONS:k0,NUMBER_OPTIONS:V0});function vt(r,e){var t=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=G0(r))||e){t&&(r=t);var i=0,n=function(){};return{s:n,n:function(){return i>=r.length?{done:!0}:{done:!1,value:r[i++]}},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 a=!0,o=!1,f;return{s:function(){t=t.call(r)},n:function(){var u=t.next();return a=u.done,u},e:function(u){o=!0,f=u},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(o)throw f}}}}function G0(r,e){if(r){if(typeof r=="string")return sl(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 sl(r,e)}}function sl(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,i=new Array(e);t<e;t++)i[t]=r[t];return i}function kn(r){"@babel/helpers - typeof";return kn=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},kn(r)}function ul(){return!0}function it(){return!1}function Vn(){}var ll="Argument is not a typed-function.";function cl(){function r(z){return kn(z)==="object"&&z!==null&&z.constructor===Object}var e=[{name:"number",test:function(L){return typeof L=="number"}},{name:"string",test:function(L){return typeof L=="string"}},{name:"boolean",test:function(L){return typeof L=="boolean"}},{name:"Function",test:function(L){return typeof L=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(L){return L instanceof Date}},{name:"RegExp",test:function(L){return L instanceof RegExp}},{name:"Object",test:r},{name:"null",test:function(L){return L===null}},{name:"undefined",test:function(L){return L===void 0}}],t={name:"any",test:ul,isAny:!0},i,n,a=0,o={createCount:0};function f(z){var L=i.get(z);if(L)return L;var ee='Unknown type "'+z+'"',le=z.toLowerCase(),pe,ge=vt(n),xe;try{for(ge.s();!(xe=ge.n()).done;)if(pe=xe.value,pe.toLowerCase()===le){ee+='. Did you mean "'+pe+'" ?';break}}catch(de){ge.e(de)}finally{ge.f()}throw new TypeError(ee)}function l(z){for(var L=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any",ee=L?f(L).index:n.length,le=[],pe=0;pe<z.length;++pe){if(!z[pe]||typeof z[pe].name!="string"||typeof z[pe].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");var ge=z[pe].name;if(i.has(ge))throw new TypeError('Duplicate type name "'+ge+'"');le.push(ge),i.set(ge,{name:ge,test:z[pe].test,isAny:z[pe].isAny,index:ee+pe,conversionsTo:[]})}var xe=n.slice(ee);n=n.slice(0,ee).concat(le).concat(xe);for(var de=ee+le.length;de<n.length;++de)i.get(n[de]).index=de}function u(){i=new Map,n=[],a=0,l([t],!1)}u(),l(e);function s(){var z,L=vt(n),ee;try{for(L.s();!(ee=L.n()).done;)z=ee.value,i.get(z).conversionsTo=[]}catch(le){L.e(le)}finally{L.f()}a=0}function c(z){var L=n.filter(function(ee){var le=i.get(ee);return!le.isAny&&le.test(z)});return L.length?L:["any"]}function m(z){return z&&typeof z=="function"&&"_typedFunctionData"in z}function v(z,L,ee){if(!m(z))throw new TypeError(ll);var le=ee&&ee.exact,pe=Array.isArray(L)?L.join(","):L,ge=w(pe),xe=g(ge);if(!le||xe in z.signatures){var de=z._typedFunctionData.signatureMap.get(xe);if(de)return de}var Ne=ge.length,_e;if(le){_e=[];var Ue;for(Ue in z.signatures)_e.push(z._typedFunctionData.signatureMap.get(Ue))}else _e=z._typedFunctionData.signatures;for(var Be=0;Be<Ne;++Be){var ar=ge[Be],Je=[],mr=void 0,C=vt(_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 Rr=h(se);if(ar.types.some(function(Kt){return!Rr.has(Kt.name)}))return"continue"})();if(Ee==="continue")continue}Je.push(mr)}}}catch(Rr){C.e(Rr)}finally{C.f()}if(_e=Je,_e.length===0)break}var ze,ke=vt(_e),Mr;try{for(ke.s();!(Mr=ke.n()).done;)if(ze=Mr.value,ze.params.length<=Ne)return ze}catch(Rr){ke.e(Rr)}finally{ke.f()}throw new TypeError("Signature not found (signature: "+(z.name||"unnamed")+"("+g(ge,", ")+"))")}function d(z,L,ee){return v(z,L,ee).implementation}function p(z,L){var ee=f(L);if(ee.test(z))return z;var le=ee.conversionsTo;if(le.length===0)throw new Error("There are no conversions to "+L+" defined.");for(var pe=0;pe<le.length;pe++){var ge=f(le[pe].from);if(ge.test(z))return le[pe].convert(z)}throw new Error("Cannot convert "+z+" to "+L)}function g(z){var L=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return z.map(function(ee){return ee.name}).join(L)}function y(z){var L=z.indexOf("...")===0,ee=L?z.length>3?z.slice(3):"any":z,le=ee.split("|").map(function(de){return f(de.trim())}),pe=!1,ge=L?"...":"",xe=le.map(function(de){return pe=de.isAny||pe,ge+=de.name+"|",{name:de.name,typeIndex:de.index,test:de.test,isAny:de.isAny,conversion:null,conversionIndex:-1}});return{types:xe,name:ge.slice(0,-1),hasAny:pe,hasConversion:!1,restParam:L}}function N(z){var L=z.types.map(function(xe){return xe.name}),ee=F(L),le=z.hasAny,pe=z.name,ge=ee.map(function(xe){var de=f(xe.from);return le=de.isAny||le,pe+="|"+xe.from,{name:xe.from,typeIndex:de.index,test:de.test,isAny:de.isAny,conversion:xe,conversionIndex:xe.index}});return{types:z.types.concat(ge),name:pe,hasAny:le,hasConversion:ge.length>0,restParam:z.restParam}}function h(z){return z.typeSet||(z.typeSet=new Set,z.types.forEach(function(L){return z.typeSet.add(L.name)})),z.typeSet}function w(z){var L=[];if(typeof z!="string")throw new TypeError("Signatures must be strings");var ee=z.trim();if(ee==="")return L;for(var le=ee.split(","),pe=0;pe<le.length;++pe){var ge=y(le[pe].trim());if(ge.restParam&&pe!==le.length-1)throw new SyntaxError('Unexpected rest parameter "'+le[pe]+'": only allowed for the last parameter');if(ge.types.length===0)return null;L.push(ge)}return L}function x(z){var L=fe(z);return L?L.restParam:!1}function b(z){if(!z||z.types.length===0)return ul;if(z.types.length===1)return f(z.types[0].name).test;if(z.types.length===2){var L=f(z.types[0].name).test,ee=f(z.types[1].name).test;return function(ge){return L(ge)||ee(ge)}}else{var le=z.types.map(function(pe){return f(pe.name).test});return function(ge){for(var xe=0;xe<le.length;xe++)if(le[xe](ge))return!0;return!1}}}function E(z){var L,ee,le;if(x(z)){L=he(z).map(b);var pe=L.length,ge=b(fe(z)),xe=function(Ne){for(var _e=pe;_e<Ne.length;_e++)if(!ge(Ne[_e]))return!1;return!0};return function(Ne){for(var _e=0;_e<L.length;_e++)if(!L[_e](Ne[_e]))return!1;return xe(Ne)&&Ne.length>=pe+1}}else return z.length===0?function(Ne){return Ne.length===0}:z.length===1?(ee=b(z[0]),function(Ne){return ee(Ne[0])&&Ne.length===1}):z.length===2?(ee=b(z[0]),le=b(z[1]),function(Ne){return ee(Ne[0])&&le(Ne[1])&&Ne.length===2}):(L=z.map(b),function(Ne){for(var _e=0;_e<L.length;_e++)if(!L[_e](Ne[_e]))return!1;return Ne.length===L.length})}function A(z,L){return L<z.length?z[L]:x(z)?fe(z):null}function S(z,L){var ee=A(z,L);return ee?h(ee):new Set}function D(z){return z.conversion===null||z.conversion===void 0}function T(z,L){var ee=new Set;return z.forEach(function(le){var pe=S(le.params,L),ge,xe=vt(pe),de;try{for(xe.s();!(de=xe.n()).done;)ge=de.value,ee.add(ge)}catch(Ne){xe.e(Ne)}finally{xe.f()}}),ee.has("any")?["any"]:Array.from(ee)}function B(z,L,ee){var le,pe,ge=z||"unnamed",xe=ee,de,Ne=function(){var C=[];if(xe.forEach(function(se){var Ee=A(se.params,de),ze=b(Ee);(de<se.params.length||x(se.params))&&ze(L[de])&&C.push(se)}),C.length===0){if(pe=T(xe,de),pe.length>0){var Z=c(L[de]);return le=new TypeError("Unexpected type of argument in function "+ge+" (expected: "+pe.join(" or ")+", actual: "+Z.join(" | ")+", index: "+de+")"),le.data={category:"wrongType",fn:ge,index:de,actual:Z,expected:pe},{v:le}}}else xe=C};for(de=0;de<L.length;de++){var _e=Ne();if(kn(_e)==="object")return _e.v}var Ue=xe.map(function(mr){return x(mr.params)?1/0:mr.params.length});if(L.length<Math.min.apply(null,Ue))return pe=T(xe,de),le=new TypeError("Too few arguments in function "+ge+" (expected: "+pe.join(" or ")+", index: "+L.length+")"),le.data={category:"tooFewArgs",fn:ge,index:L.length,expected:pe},le;var Be=Math.max.apply(null,Ue);if(L.length>Be)return le=new TypeError("Too many arguments in function "+ge+" (expected: "+Be+", actual: "+L.length+")"),le.data={category:"tooManyArgs",fn:ge,index:L.length,expectedLength:Be},le;for(var ar=[],Je=0;Je<L.length;++Je)ar.push(c(L[Je]).join("|"));return le=new TypeError('Arguments of type "'+ar.join(", ")+'" do not match any of the defined signatures of function '+ge+"."),le.data={category:"mismatch",actual:ar},le}function I(z){for(var L=n.length+1,ee=0;ee<z.types.length;ee++)D(z.types[ee])&&(L=Math.min(L,z.types[ee].typeIndex));return L}function P(z){for(var L=a+1,ee=0;ee<z.types.length;ee++)D(z.types[ee])||(L=Math.min(L,z.types[ee].conversionIndex));return L}function R(z,L){if(z.hasAny){if(!L.hasAny)return 1}else if(L.hasAny)return-1;if(z.restParam){if(!L.restParam)return 1}else if(L.restParam)return-1;if(z.hasConversion){if(!L.hasConversion)return 1}else if(L.hasConversion)return-1;var ee=I(z)-I(L);if(ee<0)return-1;if(ee>0)return 1;var le=P(z)-P(L);return le<0?-1:le>0?1:0}function M(z,L){var ee=z.params,le=L.params,pe=fe(ee),ge=fe(le),xe=x(ee),de=x(le);if(xe&&pe.hasAny){if(!de||!ge.hasAny)return 1}else if(de&&ge.hasAny)return-1;var Ne=0,_e=0,Ue,Be=vt(ee),ar;try{for(Be.s();!(ar=Be.n()).done;)Ue=ar.value,Ue.hasAny&&++Ne,Ue.hasConversion&&++_e}catch(_n){Be.e(_n)}finally{Be.f()}var Je=0,mr=0,C=vt(le),Z;try{for(C.s();!(Z=C.n()).done;)Ue=Z.value,Ue.hasAny&&++Je,Ue.hasConversion&&++mr}catch(_n){C.e(_n)}finally{C.f()}if(Ne!==Je)return Ne-Je;if(xe&&pe.hasConversion){if(!de||!ge.hasConversion)return 1}else if(de&&ge.hasConversion)return-1;if(_e!==mr)return _e-mr;if(xe){if(!de)return 1}else if(de)return-1;var se=(ee.length-le.length)*(xe?-1:1);if(se!==0)return se;for(var Ee=[],ze=0,ke=0;ke<ee.length;++ke){var Mr=R(ee[ke],le[ke]);Ee.push(Mr),ze+=Mr}if(ze!==0)return ze;for(var Rr,Kt=0,Rn=Ee;Kt<Rn.length;Kt++)if(Rr=Rn[Kt],Rr!==0)return Rr;return 0}function F(z){if(z.length===0)return[];var L=z.map(f);z.length>1&&L.sort(function(Ne,_e){return Ne.index-_e.index});var ee=L[0].conversionsTo;if(z.length===1)return ee;ee=ee.concat([]);for(var le=new Set(z),pe=1;pe<L.length;++pe){var ge=void 0,xe=vt(L[pe].conversionsTo),de;try{for(xe.s();!(de=xe.n()).done;)ge=de.value,le.has(ge.from)||(ee.push(ge),le.add(ge.from))}catch(Ne){xe.e(Ne)}finally{xe.f()}}return ee}function H(z,L){var ee=L;if(z.some(function(de){return de.hasConversion})){var le=x(z),pe=z.map($);ee=function(){for(var Ne=[],_e=le?arguments.length-1:arguments.length,Ue=0;Ue<_e;Ue++)Ne[Ue]=pe[Ue](arguments[Ue]);return le&&(Ne[_e]=arguments[_e].map(pe[_e])),L.apply(this,Ne)}}var ge=ee;if(x(z)){var xe=z.length-1;ge=function(){return ee.apply(this,ie(arguments,0,xe).concat([ie(arguments,xe)]))}}return ge}function $(z){var L,ee,le,pe,ge=[],xe=[];switch(z.types.forEach(function(de){de.conversion&&(ge.push(f(de.conversion.from).test),xe.push(de.conversion.convert))}),xe.length){case 0:return function(Ne){return Ne};case 1:return L=ge[0],le=xe[0],function(Ne){return L(Ne)?le(Ne):Ne};case 2:return L=ge[0],ee=ge[1],le=xe[0],pe=xe[1],function(Ne){return L(Ne)?le(Ne):ee(Ne)?pe(Ne):Ne};default:return function(Ne){for(var _e=0;_e<xe.length;_e++)if(ge[_e](Ne))return xe[_e](Ne);return Ne}}}function k(z){function L(ee,le,pe){if(le<ee.length){var ge=ee[le],xe=[];if(ge.restParam){var de=ge.types.filter(D);de.length<ge.types.length&&xe.push({types:de,name:"..."+de.map(function(Ne){return Ne.name}).join("|"),hasAny:de.some(function(Ne){return Ne.isAny}),hasConversion:!1,restParam:!0}),xe.push(ge)}else xe=ge.types.map(function(Ne){return{types:[Ne],name:Ne.name,hasAny:Ne.isAny,hasConversion:Ne.conversion,restParam:!1}});return Oe(xe,function(Ne){return L(ee,le+1,pe.concat([Ne]))})}else return[pe]}return L(z,0,[])}function Q(z,L){for(var ee=Math.max(z.length,L.length),le=0;le<ee;le++){var pe=S(z,le),ge=S(L,le),xe=!1,de=void 0,Ne=vt(ge),_e;try{for(Ne.s();!(_e=Ne.n()).done;)if(de=_e.value,pe.has(de)){xe=!0;break}}catch(mr){Ne.e(mr)}finally{Ne.f()}if(!xe)return!1}var Ue=z.length,Be=L.length,ar=x(z),Je=x(L);return ar?Je?Ue===Be:Be>=Ue:Je?Ue>=Be:Ue===Be}function K(z){return z.map(function(L){return oe(L)?V(L.referToSelf.callback):X(L)?$e(L.referTo.references,L.referTo.callback):L})}function U(z,L,ee){var le=[],pe,ge=vt(z),xe;try{for(ge.s();!(xe=ge.n()).done;){pe=xe.value;var de=ee[pe];if(typeof de!="number")throw new TypeError('No definition for referenced signature "'+pe+'"');if(de=L[de],typeof de!="function")return!1;le.push(de)}}catch(Ne){ge.e(Ne)}finally{ge.f()}return le}function j(z,L,ee){for(var le=K(z),pe=new Array(le.length).fill(!1),ge=!0;ge;){ge=!1;for(var xe=!0,de=0;de<le.length;++de)if(!pe[de]){var Ne=le[de];if(oe(Ne))le[de]=Ne.referToSelf.callback(ee),le[de].referToSelf=Ne.referToSelf,pe[de]=!0,xe=!1;else if(X(Ne)){var _e=U(Ne.referTo.references,le,L);_e?(le[de]=Ne.referTo.callback.apply(this,_e),le[de].referTo=Ne.referTo,pe[de]=!0,xe=!1):ge=!0}}if(xe&&ge)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return le}function ae(z){var L=/\bthis(\(|\.signatures\b)/;Object.keys(z).forEach(function(ee){var le=z[ee];if(L.test(le.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,L){if(o.createCount++,Object.keys(L).length===0)throw new SyntaxError("No signatures provided");o.warnAgainstDeprecatedThis&&ae(L);var ee=[],le=[],pe={},ge=[],xe,de=function(){if(!Object.prototype.hasOwnProperty.call(L,xe))return"continue";var Fr=w(xe);if(!Fr)return"continue";ee.forEach(function(yn){if(Q(yn,Fr))throw new TypeError('Conflicting signatures "'+g(yn)+'" and "'+g(Fr)+'".')}),ee.push(Fr);var To=le.length;le.push(L[xe]);var Qu=Fr.map(N),Ma=void 0,Fa=vt(k(Qu)),Bo;try{for(Fa.s();!(Bo=Fa.n()).done;){Ma=Bo.value;var $o=g(Ma);ge.push({params:Ma,name:$o,fn:To}),Ma.every(function(yn){return!yn.hasConversion})&&(pe[$o]=To)}}catch(yn){Fa.e(yn)}finally{Fa.f()}};for(xe in L)var Ne=de();ge.sort(M);var _e=j(le,pe,zn),Ue;for(Ue in pe)Object.prototype.hasOwnProperty.call(pe,Ue)&&(pe[Ue]=_e[pe[Ue]]);for(var Be=[],ar=new Map,Je=0,mr=ge;Je<mr.length;Je++)Ue=mr[Je],ar.has(Ue.name)||(Ue.fn=_e[Ue.fn],Be.push(Ue),ar.set(Ue.name,Ue));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),Mr=C&&Z&&se&&Ee&&ze&&ke,Rr=0;Rr<Be.length;++Rr)Be[Rr].test=E(Be[Rr].params);for(var Kt=C?b(Be[0].params[0]):it,Rn=Z?b(Be[1].params[0]):it,_n=se?b(Be[2].params[0]):it,Mu=Ee?b(Be[3].params[0]):it,Fu=ze?b(Be[4].params[0]):it,Tu=ke?b(Be[5].params[0]):it,Bu=C?b(Be[0].params[1]):it,$u=Z?b(Be[1].params[1]):it,Ou=se?b(Be[2].params[1]):it,Iu=Ee?b(Be[3].params[1]):it,Ru=ze?b(Be[4].params[1]):it,_u=ke?b(Be[5].params[1]):it,qn=0;qn<Be.length;++qn)Be[qn].implementation=H(Be[qn].params,Be[qn].fn);var qu=C?Be[0].implementation:Vn,zu=Z?Be[1].implementation:Vn,Sa=se?Be[2].implementation:Vn,Ca=Ee?Be[3].implementation:Vn,Pu=ze?Be[4].implementation:Vn,Lu=ke?Be[5].implementation:Vn,Uu=C?Be[0].params.length:-1,ku=Z?Be[1].params.length:-1,Vu=se?Be[2].params.length:-1,Gu=Ee?Be[3].params.length:-1,Hu=ze?Be[4].params.length:-1,Zu=ke?Be[5].params.length:-1,Ju=Mr?6:0,Xu=Be.length,Wu=Be.map(function(Kr){return Kr.test}),Yu=Be.map(function(Kr){return Kr.implementation}),Fo=function(){for(var Fr=Ju;Fr<Xu;Fr++)if(Wu[Fr](arguments))return Yu[Fr].apply(this,arguments);return o.onMismatch(z,arguments,Be)};function zn(Kr,Fr){return arguments.length===Uu&&Kt(Kr)&&Bu(Fr)?qu.apply(this,arguments):arguments.length===ku&&Rn(Kr)&&$u(Fr)?zu.apply(this,arguments):arguments.length===Vu&&_n(Kr)&&Ou(Fr)?Sa.apply(this,arguments):arguments.length===Gu&&Mu(Kr)&&Iu(Fr)?Ca.apply(this,arguments):arguments.length===Hu&&Fu(Kr)&&Ru(Fr)?Pu.apply(this,arguments):arguments.length===Zu&&Tu(Kr)&&_u(Fr)?Lu.apply(this,arguments):Fo.apply(this,arguments)}try{Object.defineProperty(zn,"name",{value:z})}catch{}return zn.signatures=pe,zn._typedFunctionData={signatures:Be,signatureMap:ar},zn}function me(z,L,ee){throw B(z,L,ee)}function he(z){return ie(z,0,z.length-1)}function fe(z){return z[z.length-1]}function ie(z,L,ee){return Array.prototype.slice.call(z,L,ee)}function Ae(z,L){for(var ee=0;ee<z.length;ee++)if(L(z[ee]))return z[ee]}function Oe(z,L){return Array.prototype.concat.apply([],z.map(L))}function Ce(){var z=he(arguments).map(function(ee){return g(w(ee))}),L=fe(arguments);if(typeof L!="function")throw new TypeError("Callback function expected as last argument");return $e(z,L)}function $e(z,L){return{referTo:{references:z,callback:L}}}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&&kn(z.referTo)==="object"&&Array.isArray(z.referTo.references)&&typeof z.referTo.callback=="function"}function oe(z){return z&&kn(z.referToSelf)==="object"&&typeof z.referToSelf.callback=="function"}function G(z,L){if(!z)return L;if(L&&L!==z){var ee=new Error("Function names do not match (expected: "+z+", actual: "+L+")");throw ee.data={actual:L,expected:z},ee}return z}function Y(z){var L;for(var ee in z)Object.prototype.hasOwnProperty.call(z,ee)&&(m(z[ee])||typeof z[ee].signature=="string")&&(L=G(L,z[ee].name));return L}function te(z,L){var ee;for(ee in L)if(Object.prototype.hasOwnProperty.call(L,ee)){if(ee in z&&L[ee]!==z[ee]){var le=new Error('Signature "'+ee+'" is defined twice');throw le.data={signature:ee,sourceFunction:L[ee],destFunction:z[ee]},le}z[ee]=L[ee]}}var be=o;o=function(L){for(var ee=typeof L=="string",le=ee?1:0,pe=ee?L:"",ge={},xe=le;xe<arguments.length;++xe){var de=arguments[xe],Ne={},_e=void 0;if(typeof de=="function"?(_e=de.name,typeof de.signature=="string"?Ne[de.signature]=de:m(de)&&(Ne=de.signatures)):r(de)&&(Ne=de,ee||(_e=Y(de))),Object.keys(Ne).length===0){var Ue=new TypeError("Argument to 'typed' at index "+xe+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw Ue.data={index:xe,argument:de},Ue}ee||(pe=G(pe,_e)),te(ge,Ne)}return re(pe||"",ge)},o.create=cl,o.createCount=be.createCount,o.onMismatch=me,o.throwMismatchError=me,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=d,o.isTypedFunction=m,o.warnAgainstDeprecatedThis=!0,o.addType=function(z,L){var ee="any";L!==!1&&i.has("Object")&&(ee="Object"),o.addTypes([z],ee)};function ve(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){ve(z);var L=f(z.to);if(L.conversionsTo.every(function(ee){return ee.from!==z.from}))L.conversionsTo.push({from:z.from,convert:z.convert,index:a++});else throw new Error('There is already a conversion from "'+z.from+'" to "'+L.name+'"')},o.addConversions=function(z){z.forEach(o.addConversion)},o.removeConversion=function(z){ve(z);var L=f(z.to),ee=Ae(L.conversionsTo,function(pe){return pe.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 le=L.conversionsTo.indexOf(ee);L.conversionsTo.splice(le,1)},o.resolve=function(z,L){if(!m(z))throw new TypeError(ll);for(var ee=z._typedFunctionData.signatures,le=0;le<ee.length;++le)if(ee[le].test(L))return ee[le];return null},o}const fl=cl();function qe(r){return typeof r=="boolean"?!0:isFinite(r)?r===Math.round(r):!1}var en=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,i;return t&&(e=-e),isFinite(e)?(i=Math.exp(Math.log(e)/3),i=(e/(i*i)+2*i)/3):i=e,t?-i:i},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 Go(r,e,t){var i={2:"0b",8:"0o",16:"0x"},n=i[e],a="";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),a="i".concat(t)}var o="";return r<0&&(r=-r,o="-"),"".concat(o).concat(n).concat(r.toString(e)).concat(a)}function Dn(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",i,n;if(e&&(e.notation&&(t=e.notation),tr(e)?i=e:tr(e.precision)&&(i=e.precision),e.wordSize&&(n=e.wordSize,typeof n!="number")))throw new Error('Option "wordSize" must be a number');switch(t){case"fixed":return ml(r,i);case"exponential":return vl(r,i);case"engineering":return Y0(r,i);case"bin":return Go(r,2,n);case"oct":return Go(r,8,n);case"hex":return Go(r,16,n);case"auto":return Q0(r,i,e&&e).replace(/((\.\d*?)(0+))($|e)/,function(){var a=arguments[2],o=arguments[4];return a!=="."?a+o:o});default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function ai(r){var e=String(r).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!e)throw new SyntaxError("Invalid number "+r);var t=e[1],i=e[2],n=parseFloat(e[4]||"0"),a=i.indexOf(".");n+=a!==-1?a-1:i.length-1;var o=i.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=ai(r),i=ii(t,e),n=i.exponent,a=i.coefficients,o=n%3===0?n:n<0?n-3-n%3:n-n%3;if(tr(e))for(;e>a.length||n-o+1>a.length;)a.push(0);else for(var f=Math.abs(n-o)-(a.length-1),l=0;l<f;l++)a.push(0);for(var u=Math.abs(n-o),s=1;u>0;)s++,u--;var c=a.slice(s).join(""),m=tr(e)&&c.length||c.match(/[1-9]/)?"."+c:"",v=a.slice(0,s).join("")+m+"e"+(n>=0?"+":"")+o.toString();return i.sign+v}function ml(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=ai(r),i=typeof e=="number"?ii(t,t.exponent+1+e):t,n=i.coefficients,a=i.exponent+1,o=a+(e||0);return n.length<o&&(n=n.concat(Gn(o-n.length))),a<0&&(n=Gn(-a+1).concat(n),a=1),a<n.length&&n.splice(a,0,a===0?"0.":"."),i.sign+n.join("")}function vl(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=ai(r),i=e?ii(t,e):t,n=i.coefficients,a=i.exponent;n.length<e&&(n=n.concat(Gn(e-n.length)));var o=n.shift();return i.sign+o+(n.length>0?"."+n.join(""):"")+"e"+(a>=0?"+":"")+a}function Q0(r,e,t){if(isNaN(r)||!isFinite(r))return String(r);var i=t&&t.lowerExp!==void 0?t.lowerExp:-3,n=t&&t.upperExp!==void 0?t.upperExp:5,a=ai(r),o=e?ii(a,e):a;if(o.exponent<i||o.exponent>=n)return vl(r,e);var f=o.coefficients,l=o.exponent;f.length<e&&(f=f.concat(Gn(e-f.length))),f=f.concat(Gn(l-f.length+1+(f.length<e?e-f.length:0))),f=Gn(-l).concat(f);var u=l>0?l:0;return u<f.length-1&&f.splice(u+1,0,"."),o.sign+f.join("")}function ii(r,e){for(var t={sign:r.sign,coefficients:r.coefficients,exponent:r.exponent},i=t.coefficients;e<=0;)i.unshift(0),t.exponent++,e++;if(i.length>e){var n=i.splice(e,i.length-e);if(n[0]>=5){var a=e-1;for(i[a]++;i[a]===10;)i.pop(),a===0&&(i.unshift(0),t.exponent++,a++),a--,i[a]++}}return t}function Gn(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 rt(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 i=Math.abs(r-e);return i<j0?!0:i<=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=!0,i=e>0?!0:e<0?!1:1/e===1/0;return t^i?-r:r}function Ho(r,e,t){var i=r.constructor,n=new i(2),a="";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))),a="i".concat(t)}switch(e){case 2:return"".concat(r.toBinary()).concat(a);case 8:return"".concat(r.toOctal()).concat(a);case 16:return"".concat(r.toHexadecimal()).concat(a);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",i,n;if(e!==void 0&&(e.notation&&(t=e.notation),typeof e=="number"?i=e:e.precision&&(i=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,i);case"exponential":return pl(r,i);case"engineering":return ug(r,i);case"bin":return Ho(r,2,n);case"oct":return Ho(r,8,n);case"hex":return Ho(r,16,n);case"auto":{var a=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(i),u=l.e;return u>=a&&u<o?f=l.toFixed():f=pl(r,i),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,i=t%3===0?t:t<0?t-3-t%3:t-t%3,n=r.mul(Math.pow(10,-i)),a=n.toPrecision(e);return a.indexOf("e")!==-1&&(a=n.toString()),a+"e"+(t>=0?"+":"")+i.toString()}function pl(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,i=r.length;return r.substring(t,i)===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 Dn(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(Xr(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(i=>'"'+i+'": '+Ye(r[i],e));return"{"+t.join(", ")+"}"}return String(r)}function oi(r){for(var e=String(r),t="",i=0;i<e.length;){var n=e.charAt(i);n==="\\"?(t+=n,i++,n=e.charAt(i),(n===""||'"\\/bfnrtu'.indexOf(n)===-1)&&(t+="\\"),t+=n):n==='"'?t+='\\"':t+=n,i++}return'"'+t+'"'}function ot(r){var e=String(r);return e=e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),e}function dl(r,e){if(Array.isArray(r)){for(var t="[",i=r.length,n=0;n<i;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 Zo(r,e){if(!Xr(r))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+br(r)+", index: 0)");if(!Xr(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 pt(r,e,t){if(!(this instanceof pt))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}pt.prototype=new RangeError,pt.prototype.constructor=RangeError,pt.prototype.name="IndexError",pt.prototype.isIndexError=!0;function er(r){for(var e=[];Array.isArray(r);)e.push(r.length),r=r[0];return e}function hl(r,e,t){var i,n=r.length;if(n!==e[t])throw new Ke(n,e[t]);if(t<e.length-1){var a=t+1;for(i=0;i<n;i++){var o=r[i];if(!Array.isArray(o))throw new Ke(e.length-1,e.length,"<");hl(r[i],e,a)}}else for(i=0;i<n;i++)if(Array.isArray(r[i]))throw new Ke(e.length+1,e.length,">")}function gl(r,e){var t=e.length===0;if(t){if(Array.isArray(r))throw new Ke(r.length,0)}else hl(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 pt(r,e)}function Hn(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 i=t!==void 0?t:0;return Jo(r,e,0,i),r}function Jo(r,e,t,i){var n,a,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++)a=r[n],Array.isArray(a)||(a=[a],r[n]=a),Jo(a,e,u,i);for(n=l;n<f;n++)a=[],r[n]=a,Jo(a,e,u,i)}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]=i}}function yl(r,e){var t=or(r),i=t.length;if(!Array.isArray(r)||!Array.isArray(e))throw new TypeError("Array expected");if(e.length===0)throw new Ke(0,i,"!=");e=Xo(e,i);var n=bl(e);if(i!==n)throw new Ke(n,i,"!=");try{return vg(t,e)}catch(a){throw a instanceof Ke?new Ke(n,i,"!="):a}}function Xo(r,e){var t=bl(r),i=r.slice(),n=-1,a=r.indexOf(n),o=r.indexOf(n,a+1)>=0;if(o)throw new Error("More than one wildcard in sizes");var f=a>=0,l=e%t===0;if(f)if(l)i[a]=-e/t;else throw new Error("Could not replace wildcard, since "+e+" is no multiple of "+-t);return i}function bl(r){return r.reduce((e,t)=>e*t,1)}function vg(r,e){for(var t=r,i,n=e.length-1;n>0;n--){var a=e[n];i=[];for(var o=t.length/a,f=0;f<o;f++)i.push(t.slice(f*a,(f+1)*a));t=i}return t}function si(r,e){for(var t=er(r);Array.isArray(r)&&r.length===1;)r=r[0],t.shift();for(var i=t.length;t[i-1]===1;)i--;return i<t.length&&(r=xl(r,i,0),t.length=i),r}function xl(r,e,t){var i,n;if(t<e){var a=t+1;for(i=0,n=r.length;i<n;i++)r[i]=xl(r[i],e,a)}else for(;Array.isArray(r);)r=r[0];return r}function wl(r,e,t,i){var n=i||er(r);if(t)for(var a=0;a<t;a++)r=[r],n.unshift(1);for(r=Nl(r,e,0);n.length<e;)n.push(1);return r}function Nl(r,e,t){var i,n;if(Array.isArray(r)){var a=t+1;for(i=0,n=r.length;i<n;i++)r[i]=Nl(r[i],e,a)}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(i){Array.isArray(i)?i.forEach(t):e.push(i)}),e}function Vt(r,e){return Array.prototype.map.call(r,e)}function ui(r,e){Array.prototype.forEach.call(r,e)}function Dl(r,e){if(er(r).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(r,e)}function li(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 Al(r,e){return Array.prototype.join.call(r,e)}function Zn(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 i=1;i<r.length;i++)r[i]===r[i-1]?t++:t=0,e.push({value:r[i],identifier:t});return e}function ci(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 Ia(r,e){for(var t,i=0,n=0;n<r.length;n++){var a=r[n],o=Array.isArray(a);if(n===0&&o&&(i=a.length),o&&a.length!==i)return;var f=o?Ia(a,e):e(a);if(t===void 0)t=f;else if(t!==f)return"mixed"}return t}function q(r,e,t,i){function n(a){var o=U0(a,e.map(hg));return pg(r,e,a),t(o)}return n.isFactory=!0,n.fn=r,n.dependencies=e.slice().sort(),i&&(n.meta=i),n}function pg(r,e,t){var i=e.filter(a=>!dg(a)).every(a=>t[a]!==void 0);if(!i){var n=e.filter(a=>t[a]===void 0);throw new Error('Cannot create function "'.concat(r,'", ')+"some dependencies are missing: ".concat(n.map(a=>'"'.concat(a,'"')).join(", "),"."))}}function dg(r){return r&&r[0]==="?"}function hg(r){return r&&r[0]==="?"?r.slice(1):r}function st(r,e){if(El(r)&&Wo(r,e))return r[e];throw typeof r[e]=="function"&&Yo(r,e)?new Error('Cannot access method "'+e+'" as a property'):new Error('No access to property "'+e+'"')}function Jn(r,e,t){if(El(r)&&Wo(r,e))return r[e]=t,t;throw new Error('No access to property "'+e+'"')}function gg(r,e){return e in r}function Wo(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(!Yo(r,e))throw new Error('No access to method "'+e+'"')}function Yo(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 El(r){return typeof r=="object"&&r&&r.constructor===Object}var bg={length:!0,name:!0},xg={toString:!0,valueOf:!0,toLocaleString:!0};class Qo{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return st(this.wrappedObject,e)}set(e,t){return Jn(this.wrappedObject,e,t),this}has(e){return gg(this.wrappedObject,e)}}function Xn(){return new Map}function Wn(r){if(!r)return Xn();if(Ko(r))return r;if(ko(r))return new Qo(r);throw new Error("createMap can create maps from objects or Maps")}function wg(r){if(r instanceof Qo)return r.wrappedObject;var e={};for(var t of r.keys()){var i=r.get(t);Jn(e,t,i)}return e}function Ko(r){return r?r instanceof Map||r instanceof Qo||typeof r.set=="function"&&typeof r.get=="function"&&typeof r.keys=="function"&&typeof r.has=="function":!1}function Sl(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;i<e;i++)t[i-1]=arguments[i];for(var n of t)if(n){if(Ko(n))for(var a of n.keys())r.set(a,n.get(a));else if(ko(n))for(var o of Object.keys(n))r.set(o,n[o])}return r}var Cl=function(){return Cl=fl.create,fl},Ng=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],Dg=q("typed",Ng,function(e){var{BigNumber:t,Complex:i,DenseMatrix:n,Fraction:a}=e,o=Cl();return o.clear(),o.addTypes([{name:"number",test:tr},{name:"Complex",test:Lt},{name:"BigNumber",test:rr},{name:"Fraction",test:Ba},{name:"Unit",test:Ut},{name:"identifier",test:f=>Xr&&/^(?:[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:Xr},{name:"Chain",test:il},{name:"Array",test:cr},{name:"Matrix",test:Ve},{name:"DenseMatrix",test:ri},{name:"SparseMatrix",test:wn},{name:"Range",test:Uo},{name:"Index",test:ti},{name:"boolean",test:C0},{name:"ResultSet",test:M0},{name:"Help",test:al},{name:"function",test:F0},{name:"Date",test:T0},{name:"RegExp",test:B0},{name:"null",test:$0},{name:"undefined",test:O0},{name:"AccessorNode",test:Nn},{name:"ArrayNode",test:at},{name:"AssignmentNode",test:I0},{name:"BlockNode",test:R0},{name:"ConditionalNode",test:_0},{name:"ConstantNode",test:ir},{name:"FunctionNode",test:jt},{name:"FunctionAssignmentNode",test:$a},{name:"IndexNode",test:Un},{name:"Node",test:fr},{name:"ObjectNode",test:ni},{name:"OperatorNode",test:Tr},{name:"ParenthesisNode",test:kt},{name:"RangeNode",test:q0},{name:"RelationalNode",test:z0},{name:"SymbolNode",test:_r},{name:"Map",test:Ko},{name:"Object",test:ko}]),o.addConversions([{from:"number",to:"BigNumber",convert:function(l){if(t||jo(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 i||fi(l),new i(l,0)}},{from:"BigNumber",to:"Complex",convert:function(l){return i||fi(l),new i(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 i||fi(l),new i(l.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(l){a||es(l);var u=new a(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||jo(l);try{return new t(l)}catch{throw new Error('Cannot convert "'+l+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(l){a||es(l);try{return new a(l)}catch{throw new Error('Cannot convert "'+l+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(l){i||fi(l);try{return new i(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||jo(l),new t(+l)}},{from:"boolean",to:"Fraction",convert:function(l){return a||es(l),new a(+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&&Ct(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&&Ct(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 jo(r){throw new Error("Cannot convert value ".concat(r," into a BigNumber: no class 'BigNumber' provided"))}function fi(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 es(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});var Yn=9e15,rn=1e9,rs="0123456789abcdef",mi="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",vi="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ts={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Yn,maxE:Yn,crypto:!1},Ml,Gt,Xe=!0,pi="[DecimalError] ",tn=pi+"Invalid argument: ",Fl=pi+"Precision limit exceeded",Tl=pi+"crypto unavailable",Bl="[object Decimal]",Vr=Math.floor,$r=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,$l=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,dt=1e7,He=7,Bg=9007199254740991,$g=mi.length-1,ns=vi.length-1,we={toStringTag:Bl};we.absoluteValue=we.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),Pe(r)},we.ceil=function(){return Pe(new this.constructor(this),this.e+1,2)},we.clampedTo=we.clamp=function(r,e){var t,i=this,n=i.constructor;if(r=new n(r),e=new n(e),!r.s||!e.s)return new n(NaN);if(r.gt(e))throw Error(tn+e);return t=i.cmp(r),t<0?r:i.cmp(e)>0?e:new n(i)},we.comparedTo=we.cmp=function(r){var e,t,i,n,a=this,o=a.d,f=(r=new a.constructor(r)).d,l=a.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(a.e!==r.e)return a.e>r.e^l<0?1:-1;for(i=o.length,n=f.length,e=0,t=i<n?i:n;e<t;++e)if(o[e]!==f[e])return o[e]>f[e]^l<0?1:-1;return i===n?0:i>n^l<0?1:-1},we.cosine=we.cos=function(){var r,e,t=this,i=t.constructor;return t.d?t.d[0]?(r=i.precision,e=i.rounding,i.precision=r+Math.max(t.e,t.sd())+He,i.rounding=1,t=Og(i,zl(i,t)),i.precision=r,i.rounding=e,Pe(Gt==2||Gt==3?t.neg():t,r,e,!0)):new i(1):new i(NaN)},we.cubeRoot=we.cbrt=function(){var r,e,t,i,n,a,o,f,l,u,s=this,c=s.constructor;if(!s.isFinite()||s.isZero())return new c(s);for(Xe=!1,a=s.s*$r(s.s*s,1/3),!a||Math.abs(a)==1/0?(t=Pr(s.d),r=s.e,(a=(r-t.length+1)%3)&&(t+=a==1||a==-2?"0":"00"),a=$r(t,1/3),r=Vr((r+1)/3)-(r%3==(r<0?-1:2)),a==1/0?t="5e"+r:(t=a.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),i=new c(t),i.s=s.s):i=new c(a.toString()),o=(r=c.precision)+3;;)if(f=i,l=f.times(f).times(f),u=l.plus(s),i=gr(u.plus(s).times(f),u.plus(l),o+2,1),Pr(f.d).slice(0,o)===(t=Pr(i.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))){i=f;break}o+=4,n=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Pe(i,r+1,1),e=!i.times(i).times(i).eq(s));break}return Xe=!0,Pe(i,r,c.rounding,e)},we.decimalPlaces=we.dp=function(){var r,e=this.d,t=NaN;if(e){if(r=e.length-1,t=(r-Vr(this.e/He))*He,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t},we.dividedBy=we.div=function(r){return gr(this,new this.constructor(r))},we.dividedToIntegerBy=we.divToInt=function(r){var e=this,t=e.constructor;return Pe(gr(e,new t(r),0,1,1),t.precision,t.rounding)},we.equals=we.eq=function(r){return this.cmp(r)===0},we.floor=function(){return Pe(new this.constructor(this),this.e+1,3)},we.greaterThan=we.gt=function(r){return this.cmp(r)>0},we.greaterThanOrEqualTo=we.gte=function(r){var e=this.cmp(r);return e==1||e===0},we.hyperbolicCosine=we.cosh=function(){var r,e,t,i,n,a=this,o=a.constructor,f=new o(1);if(!a.isFinite())return new o(a.s?1/0:NaN);if(a.isZero())return f;t=o.precision,i=o.rounding,o.precision=t+Math.max(a.e,a.sd())+4,o.rounding=1,n=a.d.length,n<32?(r=Math.ceil(n/3),e=(1/yi(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),a=Qn(o,1,a.times(e),new o(1),!0);for(var l,u=r,s=new o(8);u--;)l=a.times(a),a=f.minus(l.times(s.minus(l.times(s))));return Pe(a,o.precision=t,o.rounding=i,!0)},we.hyperbolicSine=we.sinh=function(){var r,e,t,i,n=this,a=n.constructor;if(!n.isFinite()||n.isZero())return new a(n);if(e=a.precision,t=a.rounding,a.precision=e+Math.max(n.e,n.sd())+4,a.rounding=1,i=n.d.length,i<3)n=Qn(a,2,n,n,!0);else{r=1.4*Math.sqrt(i),r=r>16?16:r|0,n=n.times(1/yi(5,r)),n=Qn(a,2,n,n,!0);for(var o,f=new a(5),l=new a(16),u=new a(20);r--;)o=n.times(n),n=n.times(f.plus(o.times(l.times(o).plus(u))))}return a.precision=e,a.rounding=t,Pe(n,e,t,!0)},we.hyperbolicTangent=we.tanh=function(){var r,e,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(r=i.precision,e=i.rounding,i.precision=r+7,i.rounding=1,gr(t.sinh(),t.cosh(),i.precision=r,i.rounding=e)):new i(t.s)},we.inverseCosine=we.acos=function(){var r,e=this,t=e.constructor,i=e.abs().cmp(1),n=t.precision,a=t.rounding;return i!==-1?i===0?e.isNeg()?ht(t,n,a):new t(0):new t(NaN):e.isZero()?ht(t,n+4,a).times(.5):(t.precision=n+6,t.rounding=1,e=e.asin(),r=ht(t,n+4,a).times(.5),t.precision=n,t.rounding=a,r.minus(e))},we.inverseHyperbolicCosine=we.acosh=function(){var r,e,t=this,i=t.constructor;return t.lte(1)?new i(t.eq(1)?0:NaN):t.isFinite()?(r=i.precision,e=i.rounding,i.precision=r+Math.max(Math.abs(t.e),t.sd())+4,i.rounding=1,Xe=!1,t=t.times(t).minus(1).sqrt().plus(t),Xe=!0,i.precision=r,i.rounding=e,t.ln()):new i(t)},we.inverseHyperbolicSine=we.asinh=function(){var r,e,t=this,i=t.constructor;return!t.isFinite()||t.isZero()?new i(t):(r=i.precision,e=i.rounding,i.precision=r+2*Math.max(Math.abs(t.e),t.sd())+6,i.rounding=1,Xe=!1,t=t.times(t).plus(1).sqrt().plus(t),Xe=!0,i.precision=r,i.rounding=e,t.ln())},we.inverseHyperbolicTangent=we.atanh=function(){var r,e,t,i,n=this,a=n.constructor;return n.isFinite()?n.e>=0?new a(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(r=a.precision,e=a.rounding,i=n.sd(),Math.max(i,r)<2*-n.e-1?Pe(new a(n),r,e,!0):(a.precision=t=i-n.e,n=gr(n.plus(1),new a(1).minus(n),t+r,1),a.precision=r+4,a.rounding=1,n=n.ln(),a.precision=r,a.rounding=e,n.times(.5))):new a(NaN)},we.inverseSine=we.asin=function(){var r,e,t,i,n=this,a=n.constructor;return n.isZero()?new a(n):(e=n.abs().cmp(1),t=a.precision,i=a.rounding,e!==-1?e===0?(r=ht(a,t+4,i).times(.5),r.s=n.s,r):new a(NaN):(a.precision=t+6,a.rounding=1,n=n.div(new a(1).minus(n.times(n)).sqrt().plus(1)).atan(),a.precision=t,a.rounding=i,n.times(2)))},we.inverseTangent=we.atan=function(){var r,e,t,i,n,a,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<=ns)return o=ht(s,c+4,m).times(.25),o.s=u.s,o}else{if(!u.s)return new s(NaN);if(c+4<=ns)return o=ht(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),i=1,l=u.times(u),o=new s(u),n=u;r!==-1;)if(n=n.times(l),a=o.minus(n.div(i+=2)),n=n.times(l),o=a.plus(n.div(i+=2)),o.d[e]!==void 0)for(r=e;o.d[r]===a.d[r]&&r--;);return t&&(o=o.times(2<<t-1)),Xe=!0,Pe(o,s.precision=c,s.rounding=m,!0)},we.isFinite=function(){return!!this.d},we.isInteger=we.isInt=function(){return!!this.d&&Vr(this.e/He)>this.d.length-2},we.isNaN=function(){return!this.s},we.isNegative=we.isNeg=function(){return this.s<0},we.isPositive=we.isPos=function(){return this.s>0},we.isZero=function(){return!!this.d&&this.d[0]===0},we.lessThan=we.lt=function(r){return this.cmp(r)<0},we.lessThanOrEqualTo=we.lte=function(r){return this.cmp(r)<1},we.logarithm=we.log=function(r){var e,t,i,n,a,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)a=!0;else{for(n=t[0];n%10===0;)n/=10;a=n!==1}if(Xe=!1,f=c+v,o=an(u,f),i=e?gi(s,f+10):an(r,f),l=gr(o,i,f,1),Ra(l.d,n=c,m))do if(f+=10,o=an(u,f),i=e?gi(s,f+10):an(r,f),l=gr(o,i,f,1),!a){+Pr(l.d).slice(n+1,n+15)+1==1e14&&(l=Pe(l,c+1,0));break}while(Ra(l.d,n+=10,m));return Xe=!0,Pe(l,c,m)},we.minus=we.sub=function(r){var e,t,i,n,a,o,f,l,u,s,c,m,v=this,d=v.constructor;if(r=new d(r),!v.d||!r.d)return!v.s||!r.s?r=new d(NaN):v.d?r.s=-r.s:r=new d(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=d.precision,l=d.rounding,!u[0]||!m[0]){if(m[0])r.s=-r.s;else if(u[0])r=new d(v);else return new d(l===3?-0:0);return Xe?Pe(r,f,l):r}if(t=Vr(r.e/He),s=Vr(v.e/He),u=u.slice(),a=s-t,a){for(c=a<0,c?(e=u,a=-a,o=m.length):(e=m,t=s,o=u.length),i=Math.max(Math.ceil(f/He),o)+2,a>i&&(a=i,e.length=1),e.reverse(),i=a;i--;)e.push(0);e.reverse()}else{for(i=u.length,o=m.length,c=i<o,c&&(o=i),i=0;i<o;i++)if(u[i]!=m[i]){c=u[i]<m[i];break}a=0}for(c&&(e=u,u=m,m=e,r.s=-r.s),o=u.length,i=m.length-o;i>0;--i)u[o++]=0;for(i=m.length;i>a;){if(u[--i]<m[i]){for(n=i;n&&u[--n]===0;)u[n]=dt-1;--u[n],u[i]+=dt}u[i]-=m[i]}for(;u[--o]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(r.d=u,r.e=hi(u,t),Xe?Pe(r,f,l):r):new d(l===3?-0:0)},we.modulo=we.mod=function(r){var e,t=this,i=t.constructor;return r=new i(r),!t.d||!r.s||r.d&&!r.d[0]?new i(NaN):!r.d||t.d&&!t.d[0]?Pe(new i(t),i.precision,i.rounding):(Xe=!1,i.modulo==9?(e=gr(t,r.abs(),0,3,1),e.s*=r.s):e=gr(t,r,0,i.modulo,1),e=e.times(r),Xe=!0,t.minus(e))},we.naturalExponential=we.exp=function(){return as(this)},we.naturalLogarithm=we.ln=function(){return an(this)},we.negated=we.neg=function(){var r=new this.constructor(this);return r.s=-r.s,Pe(r)},we.plus=we.add=function(r){var e,t,i,n,a,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(a=Vr(c.e/He),i=Vr(r.e/He),u=u.slice(),n=a-i,n){for(n<0?(t=u,n=-n,o=s.length):(t=s,i=a,o=u.length),a=Math.ceil(f/He),o=a>o?a+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),++i),o=u.length;u[--o]==0;)u.pop();return r.d=u,r.e=hi(u,i),Xe?Pe(r,f,l):r},we.precision=we.sd=function(r){var e,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(tn+r);return t.d?(e=Ol(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e},we.round=function(){var r=this,e=r.constructor;return Pe(new e(r),r.e+1,e.rounding)},we.sine=we.sin=function(){var r,e,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(r=i.precision,e=i.rounding,i.precision=r+Math.max(t.e,t.sd())+He,i.rounding=1,t=Rg(i,zl(i,t)),i.precision=r,i.rounding=e,Pe(Gt>2?t.neg():t,r,e,!0)):new i(NaN)},we.squareRoot=we.sqrt=function(){var r,e,t,i,n,a,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=Vr((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),i=new s(e)):i=new s(u.toString()),t=(l=s.precision)+3;;)if(a=i,i=a.plus(gr(o,a,t+2,1)).times(.5),Pr(a.d).slice(0,t)===(e=Pr(i.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!n&&e=="4999"){if(!n&&(Pe(a,l+1,0),a.times(a).eq(o))){i=a;break}t+=4,n=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(Pe(i,l+1,1),r=!i.times(i).eq(o));break}return Xe=!0,Pe(i,l,s.rounding,r)},we.tangent=we.tan=function(){var r,e,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(r=i.precision,e=i.rounding,i.precision=r+10,i.rounding=1,t=t.sin(),t.s=1,t=gr(t,new i(1).minus(t.times(t)).sqrt(),r+10,0),i.precision=r,i.rounding=e,Pe(Gt==2||Gt==4?t.neg():t,r,e,!0)):new i(NaN)},we.times=we.mul=function(r){var e,t,i,n,a,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=Vr(s.e/He)+Vr(r.e/He),l=m.length,u=v.length,l<u&&(a=m,m=v,v=a,o=l,l=u,u=o),a=[],o=l+u,i=o;i--;)a.push(0);for(i=u;--i>=0;){for(e=0,n=l+i;n>i;)f=a[n]+v[i]*m[n-i-1]+e,a[n--]=f%dt|0,e=f/dt|0;a[n]=(a[n]+e)%dt|0}for(;!a[--o];)a.pop();return e?++t:a.shift(),r.d=a,r.e=hi(a,t),Xe?Pe(r,c.precision,c.rounding):r},we.toBinary=function(r,e){return os(this,2,r,e)},we.toDecimalPlaces=we.toDP=function(r,e){var t=this,i=t.constructor;return t=new i(t),r===void 0?t:(jr(r,0,rn),e===void 0?e=i.rounding:jr(e,0,8),Pe(t,r+t.e+1,e))},we.toExponential=function(r,e){var t,i=this,n=i.constructor;return r===void 0?t=Mt(i,!0):(jr(r,0,rn),e===void 0?e=n.rounding:jr(e,0,8),i=Pe(new n(i),r+1,e),t=Mt(i,!0,r+1)),i.isNeg()&&!i.isZero()?"-"+t:t},we.toFixed=function(r,e){var t,i,n=this,a=n.constructor;return r===void 0?t=Mt(n):(jr(r,0,rn),e===void 0?e=a.rounding:jr(e,0,8),i=Pe(new a(n),r+n.e+1,e),t=Mt(i,!1,r+i.e+1)),n.isNeg()&&!n.isZero()?"-"+t:t},we.toFraction=function(r){var e,t,i,n,a,o,f,l,u,s,c,m,v=this,d=v.d,p=v.constructor;if(!d)return new p(v);if(u=t=new p(1),i=l=new p(0),e=new p(i),a=e.e=Ol(d)-v.e-1,o=a%He,e.d[0]=$r(10,o<0?He+o:o),r==null)r=a>0?e:u;else{if(f=new p(r),!f.isInt()||f.lt(u))throw Error(tn+f);r=f.gt(e)?a>0?e:u:f}for(Xe=!1,f=new p(Pr(d)),s=p.precision,p.precision=a=d.length*He*2;c=gr(f,e,0,1,1),n=t.plus(c.times(i)),n.cmp(r)!=1;)t=i,i=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),i,0,1,1),l=l.plus(n.times(u)),t=t.plus(n.times(i)),l.s=u.s=v.s,m=gr(u,i,a,1).minus(v).abs().cmp(gr(l,t,a,1).minus(v).abs())<1?[u,i]:[l,t],p.precision=s,Xe=!0,m},we.toHexadecimal=we.toHex=function(r,e){return os(this,16,r,e)},we.toNearest=function(r,e){var t=this,i=t.constructor;if(t=new i(t),r==null){if(!t.d)return t;r=new i(1),e=i.rounding}else{if(r=new i(r),e===void 0?e=i.rounding:jr(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},we.toNumber=function(){return+this},we.toOctal=function(r,e){return os(this,8,r,e)},we.toPower=we.pow=function(r){var e,t,i,n,a,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($r(+f,u));if(f=new l(f),f.eq(1))return f;if(i=l.precision,a=l.rounding,r.eq(1))return Pe(f,i,a);if(e=Vr(r.e/He),e>=r.d.length-1&&(t=u<0?-u:u)<=Bg)return n=Il(l,f,t,i),r.s<0?new l(1).div(n):Pe(n,i,a);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=$r(+f,u),e=t==0||!isFinite(t)?Vr(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=as(r.times(an(f,i+t)),i),n.d&&(n=Pe(n,i+5,1),Ra(n.d,i,a)&&(e=i+10,n=Pe(as(r.times(an(f,e+t)),e),e+5,1),+Pr(n.d).slice(i+1,i+15)+1==1e14&&(n=Pe(n,i+1,0)))),n.s=o,Xe=!0,l.rounding=a,Pe(n,i,a))},we.toPrecision=function(r,e){var t,i=this,n=i.constructor;return r===void 0?t=Mt(i,i.e<=n.toExpNeg||i.e>=n.toExpPos):(jr(r,1,rn),e===void 0?e=n.rounding:jr(e,0,8),i=Pe(new n(i),r,e),t=Mt(i,r<=i.e||i.e<=n.toExpNeg,r)),i.isNeg()&&!i.isZero()?"-"+t:t},we.toSignificantDigits=we.toSD=function(r,e){var t=this,i=t.constructor;return r===void 0?(r=i.precision,e=i.rounding):(jr(r,1,rn),e===void 0?e=i.rounding:jr(e,0,8)),Pe(new i(t),r,e)},we.toString=function(){var r=this,e=r.constructor,t=Mt(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t},we.truncated=we.trunc=function(){return Pe(new this.constructor(this),this.e+1,1)},we.valueOf=we.toJSON=function(){var r=this,e=r.constructor,t=Mt(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function Pr(r){var e,t,i,n=r.length-1,a="",o=r[0];if(n>0){for(a+=o,e=1;e<n;e++)i=r[e]+"",t=He-i.length,t&&(a+=nn(t)),a+=i;o=r[e],i=o+"",t=He-i.length,t&&(a+=nn(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return a+o}function jr(r,e,t){if(r!==~~r||r<e||r>t)throw Error(tn+r)}function Ra(r,e,t,i){var n,a,o,f;for(a=r[0];a>=10;a/=10)--e;return--e<0?(e+=He,n=0):(n=Math.ceil((e+1)/He),e%=He),a=$r(10,He-e),f=r[n]%a|0,i==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==a||t>3&&f+1==a/2)&&(r[n+1]/a/100|0)==$r(10,e-2)-1||(f==a/2||f==0)&&(r[n+1]/a/100|0)==0:e<4?(e==0?f=f/1e3|0:e==1?f=f/100|0:e==2&&(f=f/10|0),o=(i||t<4)&&f==9999||!i&&t>3&&f==4999):o=((i||t<4)&&f+1==a||!i&&t>3&&f+1==a/2)&&(r[n+1]/a/1e3|0)==$r(10,e-3)-1,o}function di(r,e,t){for(var i,n=[0],a,o=0,f=r.length;o<f;){for(a=n.length;a--;)n[a]*=e;for(n[0]+=rs.indexOf(r.charAt(o++)),i=0;i<n.length;i++)n[i]>t-1&&(n[i+1]===void 0&&(n[i+1]=0),n[i+1]+=n[i]/t|0,n[i]%=t)}return n.reverse()}function Og(r,e){var t,i,n;if(e.isZero())return e;i=e.d.length,i<32?(t=Math.ceil(i/3),n=(1/yi(4,t)).toString()):(t=16,n="2.3283064365386962890625e-10"),r.precision+=t,e=Qn(r,1,e.times(n),new r(1));for(var a=t;a--;){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(i,n,a){var o,f=0,l=i.length;for(i=i.slice();l--;)o=i[l]*n+f,i[l]=o%a|0,f=o/a|0;return f&&i.unshift(f),i}function e(i,n,a,o){var f,l;if(a!=o)l=a>o?1:-1;else for(f=l=0;f<a;f++)if(i[f]!=n[f]){l=i[f]>n[f]?1:-1;break}return l}function t(i,n,a,o){for(var f=0;a--;)i[a]-=f,f=i[a]<n[a]?1:0,i[a]=f*o+i[a]-n[a];for(;!i[0]&&i.length>1;)i.shift()}return function(i,n,a,o,f,l){var u,s,c,m,v,d,p,g,y,N,h,w,x,b,E,A,S,D,T,B,I=i.constructor,P=i.s==n.s?1:-1,R=i.d,M=n.d;if(!R||!R[0]||!M||!M[0])return new I(!i.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=i.e-n.e):(l=dt,v=He,s=Vr(i.e/v)-Vr(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--,a==null?(b=a=I.precision,o=I.rounding):f?b=a+(i.e-n.e)+1:b=a,b<0)N.push(1),d=!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;d=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,h=R.slice(0,T),w=h.length;w<T;)h[w++]=0;B=M.slice(),B.unshift(0),D=M[0],M[1]>=l/2&&++D;do m=0,u=e(M,h,T,w),u<0?(x=h[0],T!=w&&(x=x*l+(h[1]||0)),m=x/D|0,m>1?(m>=l&&(m=l-1),p=r(M,m,l),g=p.length,w=h.length,u=e(p,h,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(h,p,w,l),u==-1&&(w=h.length,u=e(M,h,T,w),u<1&&(m++,t(h,T<w?B:M,w,l))),w=h.length):u===0&&(m++,h=[0]),N[c++]=m,u&&h[0]?h[w++]=R[A]||0:(h=[R[A]],w=1);while((A++<S||h[0]!==void 0)&&b--);d=h[0]!==void 0}N[0]||N.shift()}if(v==1)y.e=s,Ml=d;else{for(c=1,m=N[0];m>=10;m/=10)c++;y.e=c+s*v-1,Pe(y,f?a+y.e+1:a,o,d)}return y}})();function Pe(r,e,t,i){var n,a,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(a=e-n,a<0)a+=He,o=e,s=c[m=0],l=s/$r(10,n-o-1)%10|0;else if(m=Math.ceil((a+1)/He),f=c.length,m>=f)if(i){for(;f++<=m;)c.push(0);s=l=0,n=1,a%=He,o=a-He+1}else break e;else{for(s=f=c[m],n=1;f>=10;f/=10)n++;a%=He,o=a-He+n,l=o<0?0:s/$r(10,n-o-1)%10|0}if(i=i||e<0||c[m+1]!==void 0||(o<0?s:s%$r(10,n-o-1)),u=t<4?(l||i)&&(t==0||t==(r.s<0?3:2)):l>5||l==5&&(t==4||i||t==6&&(a>0?o>0?s/$r(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]=$r(10,(He-e%He)%He),r.e=-e||0):c[0]=r.e=0,r;if(a==0?(c.length=m,f=1,m--):(c.length=m+1,f=$r(10,He-a),c[m]=o>0?(s/$r(10,n-o)%$r(10,o)|0)*f:0),u)for(;;)if(m==0){for(a=1,o=c[0];o>=10;o/=10)a++;for(o=c[0]+=f,f=1;o>=10;o/=10)f++;a!=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(a=c.length;c[--a]===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 Mt(r,e,t){if(!r.isFinite())return ql(r);var i,n=r.e,a=Pr(r.d),o=a.length;return e?(t&&(i=t-o)>0?a=a.charAt(0)+"."+a.slice(1)+nn(i):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(r.e<0?"e":"e+")+r.e):n<0?(a="0."+nn(-n-1)+a,t&&(i=t-o)>0&&(a+=nn(i))):n>=o?(a+=nn(n+1-o),t&&(i=t-n-1)>0&&(a=a+"."+nn(i))):((i=n+1)<o&&(a=a.slice(0,i)+"."+a.slice(i)),t&&(i=t-o)>0&&(n+1===o&&(a+="."),a+=nn(i))),a}function hi(r,e){var t=r[0];for(e*=He;t>=10;t/=10)e++;return e}function gi(r,e,t){if(e>$g)throw Xe=!0,t&&(r.precision=t),Error(Fl);return Pe(new r(mi),e,1,!0)}function ht(r,e,t){if(e>ns)throw Error(Fl);return Pe(new r(vi),e,t,!0)}function Ol(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 nn(r){for(var e="";r--;)e+="0";return e}function Il(r,e,t,i){var n,a=new r(1),o=Math.ceil(i/He+4);for(Xe=!1;;){if(t%2&&(a=a.times(e),Pl(a.d,o)&&(n=!0)),t=Vr(t/2),t===0){t=a.d.length-1,n&&a.d[t]===0&&++a.d[t];break}e=e.times(e),Pl(e.d,o)}return Xe=!0,a}function Rl(r){return r.d[r.d.length-1]&1}function _l(r,e,t){for(var i,n=new r(e[0]),a=0;++a<e.length;)if(i=new r(e[a]),i.s)n[t](i)&&(n=i);else{n=i;break}return n}function as(r,e){var t,i,n,a,o,f,l,u=0,s=0,c=0,m=r.constructor,v=m.rounding,d=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:NaN);for(e==null?(Xe=!1,l=d):l=e,f=new m(.03125);r.e>-2;)r=r.times(f),c+=5;for(i=Math.log($r(2,c))/Math.LN10*2+5|0,l+=i,t=a=o=new m(1),m.precision=l;;){if(a=Pe(a.times(r),l,1),t=t.times(++s),f=o.plus(gr(a,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&&Ra(o.d,l-i,v,u))m.precision=l+=10,t=a=f=new m(1),s=0,u++;else return Pe(o,m.precision=d,v,Xe=!0);else return m.precision=d,o}o=f}}function an(r,e){var t,i,n,a,o,f,l,u,s,c,m,v=1,d=10,p=r,g=p.d,y=p.constructor,N=y.rounding,h=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=h):s=e,y.precision=s+=d,t=Pr(g),i=t.charAt(0),Math.abs(a=p.e)<15e14){for(;i<7&&i!=1||i==1&&t.charAt(1)>3;)p=p.times(r),t=Pr(p.d),i=t.charAt(0),v++;a=p.e,i>1?(p=new y("0."+t),a++):p=new y(i+"."+t.slice(1))}else return u=gi(y,s+2,h).times(a+""),p=an(new y(i+"."+t.slice(1)),s-d).plus(u),y.precision=h,e==null?Pe(p,h,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),a!==0&&(l=l.plus(gi(y,s+2,h).times(a+""))),l=gr(l,new y(v),s,1),e==null)if(Ra(l.d,s-d,N,f))y.precision=s+=d,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=h,N,Xe=!0);else return y.precision=h,l;l=u,n+=2}}function ql(r){return String(r.s*r.s/0)}function is(r,e){var t,i,n;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(i=e.search(/e/i))>0?(t<0&&(t=i),t+=+e.slice(i+1),e=e.substring(0,i)):t<0&&(t=e.length),i=0;e.charCodeAt(i)===48;i++);for(n=e.length;e.charCodeAt(n-1)===48;--n);if(e=e.slice(i,n),e){if(n-=i,r.e=t=t-i-1,r.d=[],i=(t+1)%He,t<0&&(i+=He),i<n){for(i&&r.d.push(+e.slice(0,i)),n-=He;i<n;)r.d.push(+e.slice(i,i+=He));e=e.slice(i),i=He-e.length}else i-=n;for(;i--;)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,i,n,a,o,f,l,u,s;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),$l.test(e))return is(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(tn+e);for(a=e.search(/p/i),a>0?(l=+e.slice(a+1),e=e.substring(2,a)):e=e.slice(2),a=e.indexOf("."),o=a>=0,i=r.constructor,o&&(e=e.replace(".",""),f=e.length,a=f-a,n=Il(i,new i(t),a,a*2)),u=di(e,t,dt),s=u.length-1,a=s;u[a]===0;--a)u.pop();return a<0?new i(r.s*0):(r.e=hi(u,s),r.d=u,Xe=!1,o&&(r=gr(r,n,f*4)),l&&(r=r.times(Math.abs(l)<54?$r(2,l):on.pow(2,l))),Xe=!0,r)}function Rg(r,e){var t,i=e.d.length;if(i<3)return e.isZero()?e:Qn(r,2,e,e);t=1.4*Math.sqrt(i),t=t>16?16:t|0,e=e.times(1/yi(5,t)),e=Qn(r,2,e,e);for(var n,a=new r(5),o=new r(16),f=new r(20);t--;)n=e.times(e),e=e.times(a.plus(n.times(o.times(n).minus(f))));return e}function Qn(r,e,t,i,n){var a,o,f,l,u=r.precision,s=Math.ceil(u/He);for(Xe=!1,l=t.times(t),f=new r(i);;){if(o=gr(f.times(l),new r(e++*e++),u,1),f=n?i.plus(o):i.minus(o),i=gr(o.times(l),new r(e++*e++),u,1),o=f.plus(i),o.d[s]!==void 0){for(a=s;o.d[a]===f.d[a]&&a--;);if(a==-1)break}a=f,f=i,i=o,o=a}return Xe=!0,o.d.length=s+1,o}function yi(r,e){for(var t=r;--e;)t*=r;return t}function zl(r,e){var t,i=e.s<0,n=ht(r,r.precision,1),a=n.times(.5);if(e=e.abs(),e.lte(a))return Gt=i?4:1,e;if(t=e.divToInt(n),t.isZero())Gt=i?3:2;else{if(e=e.minus(t.times(n)),e.lte(a))return Gt=Rl(t)?i?2:3:i?4:1,e;Gt=Rl(t)?i?1:4:i?3:2}return e.minus(n).abs()}function os(r,e,t,i){var n,a,o,f,l,u,s,c,m,v=r.constructor,d=t!==void 0;if(d?(jr(t,1,rn),i===void 0?i=v.rounding:jr(i,0,8)):(t=v.precision,i=v.rounding),!r.isFinite())s=ql(r);else{for(s=Mt(r),o=s.indexOf("."),d?(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=di(Mt(m),10,n),m.e=m.d.length),c=di(s,10,n),a=l=c.length;c[--l]==0;)c.pop();if(!c[0])s=d?"0p+0":"0";else{if(o<0?a--:(r=new v(r),r.d=c,r.e=a,r=gr(r,m,t,i,0,n),c=r.d,a=r.e,u=Ml),o=c[t],f=n/2,u=u||c[t+1]!==void 0,u=i<4?(o!==void 0||u)&&(i===0||i===(r.s<0?3:2)):o>f||o===f&&(i===4||u||i===6&&c[t-1]&1||i===(r.s<0?8:7)),c.length=t,u)for(;++c[--t]>n-1;)c[t]=0,t||(++a,c.unshift(1));for(l=c.length;!c[l-1];--l);for(o=0,s="";o<l;o++)s+=rs.charAt(c[o]);if(d){if(l>1)if(e==16||e==8){for(o=e==16?4:3,--l;l%o;l++)s+="0";for(c=di(s,n,e),l=c.length;!c[l-1];--l);for(o=1,s="1.";o<l;o++)s+=rs.charAt(c[o])}else s=s.charAt(0)+"."+s.slice(1);s=s+(a<0?"p":"p+")+a}else if(a<0){for(;++a;)s="0"+s;s="0."+s}else if(++a>l)for(a-=l;a--;)s+="0";else a<l&&(s=s.slice(0,a)+"."+s.slice(a))}s=(e==16?"0x":e==2?"0b":e==8?"0o":"")+s}return r.s<0?"-"+s:s}function Pl(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 Lg(r){return new this(r).asin()}function Ug(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,i=this.precision,n=this.rounding,a=i+4;return!r.s||!e.s?t=new this(NaN):!r.d&&!e.d?(t=ht(this,a,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?ht(this,i,n):new this(0),t.s=r.s):!r.d||e.isZero()?(t=ht(this,a,1).times(.5),t.s=r.s):e.s<0?(this.precision=a,this.rounding=1,t=this.atan(gr(r,e,a,1)),e=ht(this,a,1),this.precision=i,this.rounding=n,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(gr(r,e,a,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(pi+"Object expected");var e,t,i,n=r.defaults===!0,a=["precision",1,rn,"rounding",0,8,"toExpNeg",-Yn,0,"toExpPos",0,Yn,"maxE",0,Yn,"minE",-Yn,0,"modulo",0,9];for(e=0;e<a.length;e+=3)if(t=a[e],n&&(this[t]=ts[t]),(i=r[t])!==void 0)if(Vr(i)===i&&i>=a[e+1]&&i<=a[e+2])this[t]=i;else throw Error(tn+t+": "+i);if(t="crypto",n&&(this[t]=ts[t]),(i=r[t])!==void 0)if(i===!0||i===!1||i===0||i===1)if(i)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Tl);else this[t]=!1;else throw Error(tn+t+": "+i);return this}function Wg(r){return new this(r).cos()}function Yg(r){return new this(r).cosh()}function Ll(r){var e,t,i;function n(a){var o,f,l,u=this;if(!(u instanceof n))return new n(a);if(u.constructor=n,Ul(a)){u.s=a.s,Xe?!a.d||a.e>n.maxE?(u.e=NaN,u.d=null):a.e<n.minE?(u.e=0,u.d=[0]):(u.e=a.e,u.d=a.d.slice()):(u.e=a.e,u.d=a.d?a.d.slice():a.d);return}if(l=typeof a,l==="number"){if(a===0){u.s=1/a<0?-1:1,u.e=0,u.d=[0];return}if(a<0?(a=-a,u.s=-1):u.s=1,a===~~a&&a<1e7){for(o=0,f=a;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=[a]):(u.e=o,u.d=[a]);return}else if(a*0!==0){a||(u.s=NaN),u.e=NaN,u.d=null;return}return is(u,a.toString())}else if(l!=="string")throw Error(tn+a);return(f=a.charCodeAt(0))===45?(a=a.slice(1),u.s=-1):(f===43&&(a=a.slice(1)),u.s=1),$l.test(a)?is(u,a):Ig(u,a)}if(n.prototype=we,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=Ul,n.abs=_g,n.acos=qg,n.acosh=zg,n.add=Pg,n.asin=Lg,n.asinh=Ug,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=d1,n.sub=h1,n.sum=g1,n.tan=y1,n.tanh=b1,n.trunc=x1,r===void 0&&(r={}),r&&r.defaults!==!0)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<i.length;)r.hasOwnProperty(t=i[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 Ul(r){return r instanceof on||r&&r.toStringTag===Bl||!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 _l(this,arguments,"lt")}function o1(){return _l(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,i,n,a=0,o=new this(1),f=[];if(r===void 0?r=this.precision:jr(r,1,rn),i=Math.ceil(r/He),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(i));a<i;)n=e[a],n>=429e7?e[a]=crypto.getRandomValues(new Uint32Array(1))[0]:f[a++]=n%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(i*=4);a<i;)n=e[a]+(e[a+1]<<8)+(e[a+2]<<16)+((e[a+3]&127)<<24),n>=214e7?crypto.randomBytes(4).copy(e,a):(f.push(n%1e7),a+=4);a=i/4}else throw Error(Tl);else for(;a<i;)f[a++]=Math.random()*1e7|0;for(i=f[--a],r%=He,i&&r&&(n=$r(10,He-r),f[a]=(i/n|0)*n);f[a]===0;a--)f.pop();if(a<0)t=0,f=[0];else{for(t=-1;f[0]===0;t-=He)f.shift();for(i=1,n=f[0];n>=10;n/=10)i++;i<He&&(t-=He-i)}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 d1(r){return new this(r).sqrt()}function h1(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)}we[Symbol.for("nodejs.util.inspect.custom")]=we.toString,we[Symbol.toStringTag]="Decimal";var on=we.constructor=Ll(ts);mi=new on(mi),vi=new on(vi);var w1="BigNumber",N1=["?on","config"],D1=q(w1,N1,r=>{var{on:e,config:t}=r,i=on.clone({precision:t.precision,modulo:on.EUCLID});return i.prototype=Object.create(i.prototype),i.prototype.type="BigNumber",i.prototype.isBigNumber=!0,i.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},i.fromJSON=function(n){return new i(n.value)},e&&e("config",function(n,a){n.precision!==a.precision&&i.config({precision:n.precision})}),i},{isClass:!0});function _a(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function A1(r){if(Object.prototype.hasOwnProperty.call(r,"__esModule"))return r;var e=r.default;if(typeof e=="function"){var t=function i(){var n=!1;try{n=this instanceof i}catch{}return n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var n=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:function(){return r[i]}})}),t}var ss={exports:{}};var kl;function E1(){return kl||(kl=1,(function(r,e){(function(t){var i=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},a=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),d=Math.abs(m);return v<3e3&&d<3e3?Math.sqrt(v*v+d*d):(v<d?(v=d,d=c/m):d=m/c,v*Math.sqrt(1+d*d))},f=function(){throw SyntaxError("Invalid Param")};function l(c,m){var v=Math.abs(c),d=Math.abs(m);return c===0?Math.log(d):m===0?Math.log(v):v<3e3&&d<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 d=c.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),p=1,g=0;d===null&&f();for(var y=0;y<d.length;y++){var N=d[y];N===" "||N===" "||N===`
10
+ `||(N==="+"?p++:N==="-"?g++:N==="i"||N==="I"?(p+g===0&&f(),d[y+1]!==" "&&!isNaN(d[y+1])?(v.im+=parseFloat((g%2?"-":"")+d[y+1]),y++):v.im+=parseFloat((g%2?"-":"")+"1"),p=g=0):((p+g===0||isNaN(N))&&f(),d[y+1]==="i"||d[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 d=v.re,p=v.im,g,y;return p===0?new s(c/d,m/d):Math.abs(d)<Math.abs(p)?(y=d/p,g=d*y+p,new s((c*y+m)/g,(m*y-c)/g)):(y=p/d,g=p*y+d,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 d=Math.atan2(m,c),p=l(c,m);return c=Math.exp(v.re*p-v.im*d),m=v.im*p+v.re*d,new s(c*Math.cos(m),c*Math.sin(m))},sqrt:function(){var c=this.re,m=this.im,v=this.abs(),d,p;if(c>=0){if(m===0)return new s(Math.sqrt(c),0);d=.5*Math.sqrt(2*(v+c))}else d=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(d,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)+a(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)*i(m),Math.cos(c)*n(m))},cos:function(){var c=this.re,m=this.im;return new s(Math.cos(c)*i(m),-Math.sin(c)*n(m))},tan:function(){var c=2*this.re,m=2*this.im,v=Math.cos(c)+i(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)-i(m);return new s(-Math.sin(c)/v,n(m)/v)},sec:function(){var c=this.re,m=this.im,v=.5*i(2*m)+.5*Math.cos(2*c);return new s(Math.cos(c)*i(m)/v,Math.sin(c)*n(m)/v)},csc:function(){var c=this.re,m=this.im,v=.5*i(2*m)-.5*Math.cos(2*c);return new s(Math.sin(c)*i(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(),d=new s(v.re-m,v.im+c).log();return new s(d.im,-d.re)},acos:function(){var c=this.re,m=this.im,v=new s(m*m-c*c+1,-2*c*m).sqrt(),d=new s(v.re-m,v.im+c).log();return new s(Math.PI/2-d.im,d.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),d=new s((1-m*m-c*c)/v,-2*c/v).log();return new s(-.5*d.im,.5*d.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),i(c)*Math.sin(m))},cosh:function(){var c=this.re,m=this.im;return new s(i(c)*Math.cos(m),n(c)*Math.sin(m))},tanh:function(){var c=2*this.re,m=2*this.im,v=i(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=i(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)-i(2*c);return new s(-2*n(c)*Math.cos(m)/v,2*i(c)*Math.sin(m)/v)},sech:function(){var c=this.re,m=this.im,v=Math.cos(2*m)+i(2*c);return new s(2*i(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,d=1-c,p=1+c,g=d*d+m*m,y=g!==0?new s((p*d-m*m)/g,(m*d+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})()})(ss)),ss.exports}var S1=E1();const Lr=_a(S1);var C1="Complex",M1=[],F1=q(C1,M1,()=>(Object.defineProperty(Lr,"name",{value:"Complex"}),Lr.prototype.constructor=Lr,Lr.prototype.type="Complex",Lr.prototype.isComplex=!0,Lr.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Lr.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Lr.prototype.format=function(r){var e="",t=this.im,i=this.re,n=Dn(this.re,r),a=Dn(this.im,r),o=tr(r)?r:r?r.precision:null;if(o!==null){var f=Math.pow(10,-o);Math.abs(i/t)<f&&(i=0),Math.abs(t/i)<f&&(t=0)}return t===0?e=n:i===0?t===1?e="i":t===-1?e="-i":e=a+"i":t<0?t===-1?e=n+" - i":e=n+" - "+a.substring(1)+"i":t===1?e=n+" + i":e=n+" + "+a+"i",e},Lr.fromPolar=function(r){switch(arguments.length){case 1:{var e=arguments[0];if(typeof e=="object")return Lr(e);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var t=arguments[0],i=arguments[1];if(tr(t)){if(Ut(i)&&i.hasBase("ANGLE")&&(i=i.toNumber("rad")),tr(i))return new Lr({r:t,phi:i});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")}},Lr.prototype.valueOf=Lr.prototype.toString,Lr.fromJSON=function(r){return new Lr(r)},Lr.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},Lr),{isClass:!0}),us={exports:{}};var Vl;function T1(){return Vl||(Vl=1,(function(r,e){(function(t){var i=2e3,n={s:1,n:0,d:1};function a(d,p){if(isNaN(d=parseInt(d,10)))throw v.InvalidParameter;return d*p}function o(d,p){if(p===0)throw v.DivisionByZero;var g=Object.create(v.prototype);g.s=d<0?-1:1,d=d<0?-d:d;var y=m(d,p);return g.n=d/y,g.d=p/y,g}function f(d){for(var p={},g=d,y=2,N=4;N<=g;){for(;g%y===0;)g/=y,p[y]=(p[y]||0)+1;N+=1+2*y++}return g!==d?g>1&&(p[g]=(p[g]||0)+1):p[d]=(p[d]||0)+1,p}var l=function(d,p){var g=0,y=1,N=1,h=0,w=0,x=0,b=1,E=1,A=0,S=1,D=1,T=1,B=1e7,I;if(d!=null)if(p!==void 0){if(g=d,y=p,N=g*y,g%1!==0||y%1!==0)throw v.NonIntegerParameter}else switch(typeof d){case"object":{if("d"in d&&"n"in d)g=d.n,y=d.d,"s"in d&&(g*=d.s);else if(0 in d)g=d[0],1 in d&&(y=d[1]);else throw v.InvalidParameter;N=g*y;break}case"number":{if(d<0&&(N=d,d=-d),d%1===0)g=d;else if(d>0){for(d>=1&&(E=Math.pow(10,Math.floor(1+Math.log(d)/Math.LN10)),d/=E);S<=B&&T<=B;)if(I=(A+D)/(S+T),d===I){S+T<=B?(g=A+D,y=S+T):T>S?(g=D,y=T):(g=A,y=S);break}else d>I?(A+=D,S+=T):(D+=A,T+=S),S>B?(g=D,y=T):(g=A,y=S);g*=E}else(isNaN(d)||isNaN(p))&&(y=g=NaN);break}case"string":{if(S=d.match(/\d+|./g),S===null)throw v.InvalidParameter;if(S[A]==="-"?(N=-1,A++):S[A]==="+"&&A++,S.length===A+1?w=a(S[A++],N):S[A+1]==="."||S[A]==="."?(S[A]!=="."&&(h=a(S[A++],N)),A++,(A+1===S.length||S[A+1]==="("&&S[A+3]===")"||S[A+1]==="'"&&S[A+3]==="'")&&(w=a(S[A],N),b=Math.pow(10,S[A].length),A++),(S[A]==="("&&S[A+2]===")"||S[A]==="'"&&S[A+2]==="'")&&(x=a(S[A+1],N),E=Math.pow(10,S[A+1].length)-1,A+=3)):S[A+1]==="/"||S[A+1]===":"?(w=a(S[A],N),b=a(S[A+2],1),A+=3):S[A+3]==="/"&&S[A+1]===" "&&(h=a(S[A],N),w=a(S[A+2],N),b=a(S[A+4],1),A+=5),S.length<=A){y=b*E,N=g=x+y*h+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(d,p,g){for(var y=1;p>0;d=d*d%g,p>>=1)p&1&&(y=y*d%g);return y}function s(d,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>i)return 0;return y}function c(d,p,g){for(var y=1,N=u(10,g,p),h=0;h<300;h++){if(y===N)return h;y=y*10%p,N=N*10%p}return 0}function m(d,p){if(!d)return p;if(!p)return d;for(;;){if(d%=p,!d)return p;if(p%=d,!p)return d}}function v(d,p){if(l(d,p),this instanceof v)d=m(n.d,n.n),this.s=n.s,this.n=n.n/d,this.d=n.d/d;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(d,p){return l(d,p),o(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(d,p){return l(d,p),o(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(d,p){return l(d,p),o(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(d,p){return l(d,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(d,p){if(isNaN(this.n)||isNaN(this.d))return new v(NaN);if(d===void 0)return o(this.s*this.n%this.d,1);if(l(d,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(d,p){return l(d,p),o(m(n.n,this.n)*m(n.d,this.d),n.d*this.d)},lcm:function(d,p){return l(d,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(d){return d=Math.pow(10,d||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):o(Math.ceil(d*this.s*this.n/this.d),d)},floor:function(d){return d=Math.pow(10,d||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):o(Math.floor(d*this.s*this.n/this.d),d)},round:function(d){return d=Math.pow(10,d||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):o(Math.round(d*this.s*this.n/this.d),d)},inverse:function(){return o(this.s*this.d,this.n)},pow:function(d,p){if(l(d,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,h=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;h*=Math.pow(w,y[w])}return n.s<0?o(h,N):o(N,h)},equals:function(d,p){return l(d,p),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(d,p){l(d,p);var g=this.s*this.n*n.d-n.s*n.n*this.d;return(0<g)-(g<0)},simplify:function(d){if(isNaN(this.n)||isNaN(this.d))return this;d=d||.001;for(var p=this.abs(),g=p.toContinued(),y=1;y<g.length;y++){for(var N=o(g[y-1],1),h=y-2;h>=0;h--)N=N.inverse().add(g[h]);if(N.sub(p).abs().valueOf()<d)return N.mul(this.s)}return this},divisible:function(d,p){return l(d,p),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(d){var p,g="",y=this.n,N=this.d;return this.s<0&&(g+="-"),N===1?g+=y:(d&&(p=Math.floor(y/N))>0&&(g+=p,g+=" ",y%=N),g+=y,g+="/",g+=N),g},toLatex:function(d){var p,g="",y=this.n,N=this.d;return this.s<0&&(g+="-"),N===1?g+=y:(d&&(p=Math.floor(y/N))>0&&(g+=p,y%=N),g+="\\frac{",g+=y,g+="}{",g+=N,g+="}"),g},toContinued:function(){var d,p=this.n,g=this.d,y=[];if(isNaN(p)||isNaN(g))return y;do y.push(Math.floor(p/g)),d=p%g,p=g,g=d;while(p!==1);return y},toString:function(d){var p=this.n,g=this.d;if(isNaN(p)||isNaN(g))return"NaN";d=d||15;var y=s(p,g),N=c(p,g,y),h=this.s<0?"-":"";if(h+=p/g|0,p%=g,p*=10,p&&(h+="."),y){for(var w=N;w--;)h+=p/g|0,p%=g,p*=10;h+="(";for(var w=y;w--;)h+=p/g|0,p%=g,p*=10;h+=")"}else for(var w=d;p&&w--;)h+=p/g|0,p%=g,p*=10;return h}},Object.defineProperty(v,"__esModule",{value:!0}),v.default=v,v.Fraction=v,r.exports=v})()})(us)),us.exports}var B1=T1();const Ht=_a(B1);var $1="Fraction",O1=[],I1=q($1,O1,()=>(Object.defineProperty(Ht,"name",{value:"Fraction"}),Ht.prototype.constructor=Ht,Ht.prototype.type="Fraction",Ht.prototype.isFraction=!0,Ht.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},Ht.fromJSON=function(r){return new Ht(r)},Ht),{isClass:!0}),R1="Range",_1=[],q1=q(R1,_1,()=>{function r(e,t,i){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");var n=e!=null,a=t!=null,o=i!=null;if(n){if(rr(e))e=e.toNumber();else if(typeof e!="number")throw new TypeError("Parameter start must be a number")}if(a){if(rr(t))t=t.toNumber();else if(typeof t!="number")throw new TypeError("Parameter end must be a number")}if(o){if(rr(i))i=i.toNumber();else if(typeof i!="number")throw new TypeError("Parameter step must be a number")}this.start=n?parseFloat(e):0,this.end=a?parseFloat(t):0,this.step=o?parseFloat(i):1}return r.prototype.type="Range",r.prototype.isRange=!0,r.parse=function(e){if(typeof e!="string")return null;var t=e.split(":"),i=t.map(function(a){return parseFloat(a)}),n=i.some(function(a){return isNaN(a)});if(n)return null;switch(i.length){case 2:return new r(i[0],i[1]);case 3:return new r(i[0],i[2],i[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,i=this.step,n=this.end,a=n-t;return en(i)===en(a)?e=Math.ceil(a/i):a===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,i=this.step,n=this.end,a=0;if(i>0)for(;t<n;)e(t,[a],this),t+=i,a++;else if(i<0)for(;t>n;)e(t,[a],this),t+=i,a++},r.prototype.map=function(e){var t=[];return this.forEach(function(i,n,a){t[n[0]]=e(i,n,a)}),t},r.prototype.toArray=function(){var e=[];return this.forEach(function(t,i){e[i[0]]=t}),e},r.prototype.valueOf=function(){return this.toArray()},r.prototype.format=function(e){var t=Dn(this.start,e);return this.step!==1&&(t+=":"+Dn(this.step,e)),t+=":"+Dn(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}),z1="Matrix",P1=[],L1=q(z1,P1,()=>{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,i){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,i){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 U1(r){var e=0,t=1,i=Object.create(null),n=Object.create(null),a=0,o=function(l){var u=n[l];if(u&&(delete i[u],delete n[l],--e,t===u)){if(!e){a=0,t=1;return}for(;!hasOwnProperty.call(i,++t););}};return r=Math.abs(r),{hit:function(l){var u=n[l],s=++a;if(i[s]=l,n[l]=s,!u)return++e,e<=r?void 0:(l=i[t],o(l),l);if(delete i[u],t===u)for(;!hasOwnProperty.call(i,++t););},delete:o,clear:function(){e=a=0,t=1,i=Object.create(null),n=Object.create(null)}}}function qa(r){var{hasher:e,limit:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return t=t??Number.POSITIVE_INFINITY,e=e??JSON.stringify,function i(){typeof i.cache!="object"&&(i.cache={values:new Map,lru:U1(t||Number.POSITIVE_INFINITY)});for(var n=[],a=0;a<arguments.length;a++)n[a]=arguments[a];var o=e(n);if(i.cache.values.has(o))return i.cache.lru.hit(o),i.cache.values.get(o);var f=r.apply(r,n);return i.cache.values.set(o,f),i.cache.values.delete(i.cache.lru.hit(o)),f}}function sn(r){return Object.keys(r.signatures||{}).reduce(function(e,t){var i=(t.match(/,/g)||[]).length+1;return Math.max(e,i)},-1)}var k1="DenseMatrix",V1=["Matrix"],G1=q(k1,V1,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&&!Xr(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,gl(this._data,this._size),this._datatype=c||s.datatype;else if(cr(s))this._data=u(s),this._size=er(this._data),gl(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 Ia(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 i(this,s);case 2:case 3:return a(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,d=s.length;v<d;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,d,p,g=s.map(function(N){return N+1});l(this,g,m);var y=this._data;for(v=0,d=s.length-1;v<d;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 i(s,c){if(!ti(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 d=c.min(),p=c.max(),g=0,y=s._size.length;g<y;g++)vr(d[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 d=v===m-1,p=c.dimension(v);return d?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 a(s,c,m,v){if(!c||c.isIndex!==!0)throw new TypeError("Invalid index");var d=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(d.length<s._size.length)throw new Ke(d.length,s._size.length,"<");if(g.length<d.length){for(var y=0,N=0;d[y]===1&&g[y]===1;)y++;for(;d[y]===1;)N++,y++;m=wl(m,d.length,N,g)}if(!Oa(d,g))throw new Ke(d,g,">");var h=c.max().map(function(b){return b+1});l(s,h,v);var w=d.length,x=0;o(s._data,c,m,w,x)}return s}function o(s,c,m,v,d){var p=d===v-1,g=c.dimension(d);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,d+1)})}t.prototype.resize=function(s,c,m){if(!Ct(s))throw new TypeError("Array or Matrix expected");var v=s.valueOf().map(p=>Array.isArray(p)&&p.length===1?p[0]:p),d=m?this.clone():this;return f(d,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=Hn(s._data,s._size,m),s}t.prototype.reshape=function(s,c){var m=c?this.clone():this;m._data=yl(m._data,s);var v=m._size.reduce((d,p)=>d*p);return m._size=Xo(s,v),m};function l(s,c,m){for(var v=s._size.slice(0),d=!1;v.length<c.length;)v.push(0),d=!0;for(var p=0,g=c.length;p<g;p++)c[p]>v[p]&&(v[p]=c[p],d=!0);d&&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=sn(s),v=function g(y,N){return cr(y)?y.map(function(h,w){return g(h,N.concat(w))}):m===1?s(y):m===2?s(y,N):s(y,N,c)},d=v(this._data,[]),p=this._datatype!==void 0?Ia(d,br):void 0;return new t(d,p)},t.prototype.forEach=function(s){var c=this,m=function v(d,p){cr(d)?d.forEach(function(g,y){v(g,p.concat(y))}):s(d,p,c)};m(this._data,[])},t.prototype[Symbol.iterator]=function*(){var s=function*c(m,v){if(cr(m))for(var d=0;d<m.length;d++)yield*c(m[d],v.concat(d));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,d=function(y){var N=v.map(h=>[h[y]]);c.push(new t(N,s._datatype))},p=0;p<m[1];p++)d(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],d=this._size[1],p=Math.min(v-m,d-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 d=m>0?m:0,p=m<0?-m:0,g=s[0],y=s[1],N=Math.min(g-p,y-d),h;if(cr(c)){if(c.length!==N)throw new Error("Invalid value array length");h=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");h=function(A){return c.get([A])}}else h=function(){return c};v||(v=rr(h(0))?h(0).mul(0):0);var x=[];if(s.length>0){x=Hn(x,s,v);for(var b=0;b<N;b++)x[b+p][b+d]=h(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}),Gl="clone",H1=["typed"],Z1=q(Gl,H1,r=>{var{typed:e}=r;return e(Gl,{any:Ge})});function Hl(r){var e=r.length,t=r[0].length,i,n,a=[];for(n=0;n<t;n++){var o=[];for(i=0;i<e;i++)o.push(r[i][n]);a.push(o)}return a}function Kn(r){for(var e=0;e<r.length;e++)if(Ct(r[e]))return!0;return!1}function Zt(r,e){Ve(r)&&(r=r.valueOf());for(var t=0,i=r.length;t<i;t++){var n=r[t];Array.isArray(n)?Zt(n,e):e(n)}}function je(r,e,t){return r&&typeof r.map=="function"?r.map(function(i){return je(i,e)}):e(r)}function bi(r,e,t){var i=Array.isArray(r)?er(r):r.size();if(e<0||e>=i.length)throw new pt(e,i.length);return Ve(r)?r.create(xi(r.valueOf(),e,t)):xi(r,e,t)}function xi(r,e,t){var i,n,a,o;if(e<=0)if(Array.isArray(r[0])){for(o=Hl(r),n=[],i=0;i<o.length;i++)n[i]=xi(o[i],e-1,t);return n}else{for(a=r[0],i=1;i<r.length;i++)a=t(a,r[i]);return a}else{for(n=[],i=0;i<r.length;i++)n[i]=xi(r[i],e-1,t);return n}}function Zl(r,e,t,i,n,a,o,f,l,u,s){var c=r._values,m=r._index,v=r._ptr,d,p,g,y;if(i)for(p=v[e],g=v[e+1],d=p;d<g;d++)y=m[d],t[y]!==a?(t[y]=a,o.push(y),i[y]=c[d]):(i[y]=f(i[y],c[d]),n[y]=a);else for(p=v[e],g=v[e+1],d=p;d<g;d++)y=m[d],t[y]!==a?(t[y]=a,o.push(y)):n[y]=a}var Jl="isInteger",J1=["typed"],X1=q(Jl,J1,r=>{var{typed:e}=r;return e(Jl,{number:qe,BigNumber:function(i){return i.isInt()},Fraction:function(i){return i.d===1&&isFinite(i.n)},"Array | Matrix":e.referToSelf(t=>i=>je(i,t))})}),gt="number",An="number, number";function Xl(r){return Math.abs(r)}Xl.signature=gt;function Wl(r,e){return r+e}Wl.signature=An;function Yl(r,e){return r*e}Yl.signature=An;function Ql(r){return-r}Ql.signature=gt;function Kl(r){return r}Kl.signature=gt;function za(r){return X0(r)}za.signature=gt;function jl(r){return r*r*r}jl.signature=gt;function ec(r){return Math.exp(r)}ec.signature=gt;function rc(r){return W0(r)}rc.signature=gt;function tc(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}tc.signature=An;function nc(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,i=r*e;e!==0;)t=e,e=r%t,r=t;return Math.abs(i/r)}nc.signature=An;function W1(r,e){return Math.log(r)}function ac(r){return Z0(r)}ac.signature=gt;function ic(r){return H0(r)}ic.signature=gt;function oc(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")}oc.signature=An;function sc(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 i=Math.pow(Math.abs(r),1/e);return i=r<0?-i:i,t?1/i:i}function ls(r){return en(r)}ls.signature=gt;function uc(r){return r*r}uc.signature=gt;function lc(r,e){var t,i,n,a=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;)i=Math.floor(r/e),n=r-i*e,t=a,a=o-i*a,o=t,t=f,f=l-i*f,l=t,r=e,e=n;var u;return r<0?u=[-r,-o,-l]:u=[r,r?o:0,l],u}lc.signature=An;function cc(r,e){return r*r<1&&e===1/0||r*r>1&&e===-1/0?0:Math.pow(r,e)}cc.signature=An;function fc(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(ml(r,e))}var Y1="number",jn="number, number";function mc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitAnd");return r&e}mc.signature=jn;function vc(r){if(!qe(r))throw new Error("Integer expected in function bitNot");return~r}vc.signature=Y1;function pc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitOr");return r|e}pc.signature=jn;function dc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitXor");return r^e}dc.signature=jn;function hc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function leftShift");return r<<e}hc.signature=jn;function gc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function rightArithShift");return r>>e}gc.signature=jn;function yc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function rightLogShift");return r>>>e}yc.signature=jn;function Jt(r,e){if(e<r)return 1;if(e===r)return e;var t=e+r>>1;return Jt(r,t)*Jt(t+1,e)}function bc(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,i=1,n=e<t?t+1:e+1,a=2,o=e<t?e:t,f=n;f<=r;++f)for(i*=f;a<=o&&i%a===0;)i/=a,++a;return a<=o&&(i/=Jt(a,o)),i}bc.signature="number, number";var Q1=Math.PI,K1=2*Math.PI,j1=Math.E,ey=1.618033988749895,ry="number",cs="number, number";function xc(r){return!r}xc.signature=ry;function wc(r,e){return!!(r||e)}wc.signature=cs;function Nc(r,e){return!!r!=!!e}Nc.signature=cs;function Dc(r,e){return!!(r&&e)}Dc.signature=cs;function wi(r){var e;if(qe(r))return r<=0?isFinite(r)?1/0:NaN:r>171?1/0:Jt(1,r-1);if(r<.5)return Math.PI/(Math.sin(Math.PI*r)*wi(1-r));if(r>=171.35)return 1/0;if(r>85){var t=r*r,i=t*r,n=i*r,a=n*r;return Math.sqrt(2*Math.PI/r)*Math.pow(r/Math.E,r)*(1+1/(12*r)+1/(288*t)-139/(51840*i)-571/(2488320*n)+163879/(209018880*a)+5246819/(75246796800*a*r))}--r,e=ea[0];for(var o=1;o<ea.length;++o)e+=ea[o]/(r+o);var f=r+Ac+.5;return Math.sqrt(2*Math.PI)*Math.pow(f,r+.5)*Math.exp(-f)*e}wi.signature="number";var Ac=4.7421875,ea=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],Ec=.9189385332046728,ty=5,ny=7,Sc=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function Ni(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))-Ni(1-r);r=r-1;for(var e=r+ty+.5,t=Sc[0],i=ny-1;i>=1;i--)t+=Sc[i]/(r+i);return Ec+(r+.5)*Math.log(e)-e+Math.log(t)}Ni.signature="number";var Gr="number";function Cc(r){return eg(r)}Cc.signature=Gr;function Mc(r){return Math.atan(1/r)}Mc.signature=Gr;function Fc(r){return isFinite(r)?(Math.log((r+1)/r)+Math.log(r/(r-1)))/2:0}Fc.signature=Gr;function Tc(r){return Math.asin(1/r)}Tc.signature=Gr;function Bc(r){var e=1/r;return Math.log(e+Math.sqrt(e*e+1))}Bc.signature=Gr;function $c(r){return Math.acos(1/r)}$c.signature=Gr;function Oc(r){var e=1/r,t=Math.sqrt(e*e-1);return Math.log(t+e)}Oc.signature=Gr;function Ic(r){return rg(r)}Ic.signature=Gr;function Rc(r){return tg(r)}Rc.signature=Gr;function _c(r){return 1/Math.tan(r)}_c.signature=Gr;function qc(r){var e=Math.exp(2*r);return(e+1)/(e-1)}qc.signature=Gr;function zc(r){return 1/Math.sin(r)}zc.signature=Gr;function Pc(r){return r===0?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(r)-Math.exp(-r)))*en(r)}Pc.signature=Gr;function Lc(r){return 1/Math.cos(r)}Lc.signature=Gr;function Uc(r){return 2/(Math.exp(r)+Math.exp(-r))}Uc.signature=Gr;function kc(r){return ag(r)}kc.signature=Gr;var Di="number";function Vc(r){return r<0}Vc.signature=Di;function Gc(r){return r>0}Gc.signature=Di;function Hc(r){return r===0}Hc.signature=Di;function Zc(r){return Number.isNaN(r)}Zc.signature=Di;var Jc="isNegative",ay=["typed"],iy=q(Jc,ay,r=>{var{typed:e}=r;return e(Jc,{number:Vc,BigNumber:function(i){return i.isNeg()&&!i.isZero()&&!i.isNaN()},Fraction:function(i){return i.s<0},Unit:e.referToSelf(t=>i=>e.find(t,i.valueType())(i.value)),"Array | Matrix":e.referToSelf(t=>i=>je(i,t))})}),Xc="isNumeric",oy=["typed"],sy=q(Xc,oy,r=>{var{typed:e}=r;return e(Xc,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":e.referToSelf(t=>i=>je(i,t))})}),Wc="hasNumericValue",uy=["typed","isNumeric"],ly=q(Wc,uy,r=>{var{typed:e,isNumeric:t}=r;return e(Wc,{boolean:()=>!0,string:function(n){return n.trim().length>0&&!isNaN(Number(n))},any:function(n){return t(n)}})}),Yc="isPositive",cy=["typed"],fy=q(Yc,cy,r=>{var{typed:e}=r;return e(Yc,{number:Gc,BigNumber:function(i){return!i.isNeg()&&!i.isZero()&&!i.isNaN()},Fraction:function(i){return i.s>0&&i.n>0},Unit:e.referToSelf(t=>i=>e.find(t,i.valueType())(i.value)),"Array | Matrix":e.referToSelf(t=>i=>je(i,t))})}),Qc="isZero",my=["typed"],vy=q(Qc,my,r=>{var{typed:e}=r;return e(Qc,{number:Hc,BigNumber:function(i){return i.isZero()},Complex:function(i){return i.re===0&&i.im===0},Fraction:function(i){return i.d===1&&i.n===0},Unit:e.referToSelf(t=>i=>e.find(t,i.valueType())(i.value)),"Array | Matrix":e.referToSelf(t=>i=>je(i,t))})}),Kc="isNaN",py=["typed"],dy=q(Kc,py,r=>{var{typed:e}=r;return e(Kc,{number:Zc,BigNumber:function(i){return i.isNaN()},Fraction:function(i){return!1},Complex:function(i){return i.isNaN()},Unit:function(i){return Number.isNaN(i.value)},"Array | Matrix":function(i){return je(i,Number.isNaN)}})}),jc="typeOf",hy=["typed"],gy=q(jc,hy,r=>{var{typed:e}=r;return e(jc,{any:br})});function Ft(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 i=r.minus(e).abs();if(i.isZero())return!0;var n=r.constructor.max(r.abs(),e.abs());return i.lte(n.times(t))}return!1}function yy(r,e,t){return rt(r.re,e.re,t)&&rt(r.im,e.im,t)}var ra=q("compareUnits",["typed"],r=>{var{typed:e}=r;return{"Unit, Unit":e.referToSelf(t=>(i,n)=>{if(!i.equalBase(n))throw new Error("Cannot compare units with different base");return e.find(t,[i.valueType(),n.valueType()])(i.value,n.value)})}}),Ai="equalScalar",by=["typed","config"],xy=q(Ai,by,r=>{var{typed:e,config:t}=r,i=ra({typed:e});return e(Ai,{"boolean, boolean":function(a,o){return a===o},"number, number":function(a,o){return rt(a,o,t.epsilon)},"BigNumber, BigNumber":function(a,o){return a.eq(o)||Ft(a,o,t.epsilon)},"Fraction, Fraction":function(a,o){return a.equals(o)},"Complex, Complex":function(a,o){return yy(a,o,t.epsilon)}},i)});q(Ai,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Ai,{"number, number":function(n,a){return rt(n,a,t.epsilon)}})});var wy="SparseMatrix",Ny=["typed","equalScalar","Matrix"],Dy=q(wy,Ny,r=>{var{typed:e,equalScalar:t,Matrix:i}=r;function n(p,g){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(g&&!Xr(g))throw new Error("Invalid datatype: "+g);if(Ve(p))a(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 a(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,h=0,w=t,x=0;if(Xr(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&&h<A.length&&(h=A.length),b<A.length){var S=A[b];w(S,x)||(p._values.push(S),p._index.push(E))}}else b===0&&h<1&&(h=1),w(A,x)||(p._values.push(A),p._index.push(E))}b++}while(b<h)}p._ptr.push(p._index.length),p._size=[N,h]}n.prototype=new i,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 Ia(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(!ti(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 h,w,x,b,E=g.min(),A=g.max();for(h=0,w=p._size.length;h<w;h++)vr(E[h],p._size[h]),vr(A[h],p._size[h]);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++)h=D[x],P[h]===!0&&(F.push(R[h]),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 h=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(h.length!==1&&h.length!==2)throw new Ke(h.length,p._size.length,"<");if(x.length<h.length){for(var b=0,E=0;h[b]===1&&x[b]===1;)b++;for(;h[b]===1;)E++,b++;y=wl(y,h.length,E,x)}if(!Oa(h,x))throw new Ke(h,x,">");if(h.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],h=p[1],w=this._size[0],x=this._size[1],b=t,E=0;Xr(this._datatype)&&(b=e.find(t,[this._datatype,this._datatype])||t,E=e.convert(0,this._datatype)),(N>w-1||h>x-1)&&(m(this,Math.max(N+1,w),Math.max(h+1,x),y),w=this._size[0],x=this._size[1]),vr(N,w),vr(h,x);var A=u(N,this._ptr[h],this._ptr[h+1],this._index);return A<this._ptr[h+1]&&this._index[A]===N?b(g,E)?s(A,h,this._values,this._index,this._ptr):this._values[A]=g:b(g,E)||c(A,N,h,g,this._values,this._index,this._ptr),this};function u(p,g,y,N){if(y-g===0)return y;for(var h=g;h<y;h++)if(N[h]===p)return h;return g}function s(p,g,y,N,h){y.splice(p,1),N.splice(p,1);for(var w=g+1;w<h.length;w++)h[w]--}function c(p,g,y,N,h,w,x){h.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(!Ct(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 h=y?this.clone():this;return m(h,N[0],N[1],g)};function m(p,g,y,N){var h=N||0,w=t,x=0;Xr(p._datatype)&&(w=e.find(t,[p._datatype,p._datatype])||t,x=e.convert(0,p._datatype),h=e.convert(h,p._datatype));var b=!w(h,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(h),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,h),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=Xo(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 h=g?this.clone():this;if(this._size[0]===p[0]&&this._size[1]===p[1])return h;for(var w=[],x=0;x<h._ptr.length;x++)for(var b=0;b<h._ptr[x+1]-h._ptr[x];b++)w.push(x);for(var E=h._values.slice(),A=h._index.slice(),S=0;S<h._index.length;S++){var D=A[S],T=w[S],B=D*h._size[1]+T;w[S]=B%p[1],A[S]=Math.floor(B/p[1])}h._values.length=0,h._index.length=0,h._ptr.length=p[1]+1,h._size=p.slice();for(var I=0;I<h._ptr.length;I++)h._ptr[I]=0;for(var P=0;P<E.length;P++){var R=A[P],M=w[P],F=E[P],H=u(R,h._ptr[M],h._ptr[M+1],h._index);c(H,R,M,F,h._values,h._index,h._ptr)}return h},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],h=this._size[1],w=sn(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,h-1,x,g)};function v(p,g,y,N,h,w,x){var b=[],E=[],A=[],S=t,D=0;Xr(p._datatype)&&(S=e.find(t,[p._datatype,p._datatype])||t,D=e.convert(0,p._datatype));for(var T=function(U,j,ae){U=w(U,j,ae),S(U,D)||(b.push(U),E.push(j))},B=N;B<=h;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,h-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],h=this._size[1],w=0;w<h;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],h=y;h<N;h++){var w=this._index[h];yield{value:this._values[h],index:[w,g]}}},n.prototype.toArray=function(){return d(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return d(this._values,this._index,this._ptr,this._size,!1)};function d(p,g,y,N,h){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?h?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(),h="Sparse Matrix ["+Ye(g,p)+" x "+Ye(y,p)+"] density: "+Ye(N,p)+`
28
11
  `,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];h+=`
29
- (`+Ye(A,p)+", "+Ye(w,p)+") ==> "+(this._values?Ye(this._values[E],p):"X")}return h},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],h=this._size[1],w=Math.min(N-y,h-g),x=[],b=[],E=[];E[0]=0;for(var A=g;A<h&&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,h){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;Xr(h)&&(w=e.find(t,[h,h])||t,x=e.convert(0,h));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,h){for(var w=N[p],x=N[p+1],b=w;b<x;b++)h(y[b],g[b])},n._swapRows=function(p,g,y,N,h,w){for(var x=0;x<y;x++){var b=w[x],E=w[x+1],A=u(p,b,E,h),S=u(g,b,E,h);if(A<E&&S<E&&h[A]===p&&h[S]===g){if(N){var D=N[A];N[A]=N[S],N[S]=D}continue}if(A<E&&h[A]===p&&(S>=E||h[S]!==g)){var T=N?N[A]:void 0;h.splice(S,0,g),N&&N.splice(S,0,T),h.splice(S<=A?A+1:A,1),N&&N.splice(S<=A?A+1:A,1);continue}if(S<E&&h[S]===g&&(A>=E||h[A]!==p)){var B=N?N[S]:void 0;h.splice(A,0,p),N&&N.splice(A,0,B),h.splice(A<=S?S+1:S,1),N&&N.splice(A<=S?S+1:S,1)}}},n},{isClass:!0}),Ry="number",_y=["typed"];function qy(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 zy(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 Py=q(Ry,_y,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=qy(n);if(i)return zy(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}),sf="string",Ly=["typed"],Uy=q(sf,Ly,r=>{var{typed:e}=r;return e(sf,{"":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)}})}),uf="boolean",ky=["typed"],Vy=q(uf,ky,r=>{var{typed:e}=r;return e(uf,{"":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))})}),Gy="bignumber",Hy=["typed","BigNumber"],Zy=q(Gy,Hy,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))})}),Jy="complex",Wy=["typed","Complex"],Xy=q(Jy,Wy,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))})}),Yy="fraction",Qy=["typed","Fraction"],Ky=q(Yy,Qy,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))})}),lf="matrix",jy=["typed","Matrix","DenseMatrix","SparseMatrix"],eb=q(lf,jy,r=>{var{typed:e,Matrix:t,DenseMatrix:a,SparseMatrix:n}=r;return e(lf,{"":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)+".")}}),cf="matrixFromFunction",rb=["typed","matrix","isZero"],tb=q(cf,rb,r=>{var{typed:e,matrix:t,isZero:a}=r;return e(cf,{"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}}),ff="matrixFromRows",nb=["typed","matrix","flatten","size"],ab=q(ff,nb,r=>{var{typed:e,matrix:t,flatten:a,size:n}=r;return e(ff,{"...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.")}}),mf="matrixFromColumns",ib=["typed","matrix","flatten","size"],ob=q(mf,ib,r=>{var{typed:e,matrix:t,flatten:a,size:n}=r;return e(mf,{"...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),d=0;d<l;d++)u[d].push(v[d])}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.")}}),vf="splitUnit",sb=["typed"],ub=q(vf,sb,r=>{var{typed:e}=r;return e(vf,{"Unit, Array":function(a,n){return a.splitUnit(n)}})}),pf="unaryMinus",lb=["typed"],cb=q(pf,lb,r=>{var{typed:e}=r;return e(pf,{number:nc,"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))})}),df="unaryPlus",fb=["typed","config","BigNumber"],mb=q(df,fb,r=>{var{typed:e,config:t,BigNumber:a}=r;return e(df,{number:ac,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}})}),hf="abs",vb=["typed"],pb=q(hf,vb,r=>{var{typed:e}=r;return e(hf,{number:ec,"Complex | BigNumber | Fraction | Unit":t=>t.abs(),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),gf="apply",db=["typed","isInteger"],yf=q(gf,db,r=>{var{typed:e,isInteger:t}=r;return e(gf,{"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(Oi(n.valueOf(),i,o)):Oi(n,i,o)}})});function Oi(r,e,t){var a,n,i;if(e<=0)if(Array.isArray(r[0])){for(i=hb(r),n=[],a=0;a<i.length;a++)n[a]=Oi(i[a],e-1,t);return n}else return t(r);else{for(n=[],a=0;a<r.length;a++)n[a]=Oi(r[a],e-1,t);return n}}function hb(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 bf="addScalar",gb=["typed"],yb=q(bf,gb,r=>{var{typed:e}=r;return e(bf,{"number, number":rc,"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})})}),xf="cbrt",bb=["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],xb=q(xf,bb,r=>{var{config:e,typed:t,isNegative:a,unaryMinus:n,matrix:i,Complex:o,BigNumber:f,Fraction:l}=r;return t(xf,{number:Ga,Complex:u,"Complex, boolean":u,BigNumber:function(m){return m.cbrt()},Unit:s});function u(c,m){var v=c.arg()/3,d=c.abs(),p=new o(Ga(d),0).mul(new o(0,v).exp());if(m){var g=[p,new o(Ga(d),0).mul(new o(0,v+Math.PI*2/3).exp()),new o(Ga(d),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 d;rr(c.value)?d=new f(1).div(3):za(c.value)?d=new l(1,3):d=1/3;var p=c.pow(d);return v&&(p.value=n(p.value)),p}}}),wb="matAlgo11xS0s",Nb=["typed","equalScalar"],Ur=q(wb,Nb,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],d=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 h=[],w=[],x=[],b=0;b<d;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),h.push(T))}}return x[d]=w.length,n.createSparseMatrix({values:h,index:w,ptr:x,size:[v,d],datatype:p})}}),Db="matAlgo12xSfs",Ab=["typed","DenseMatrix"],Ir=q(Db,Ab,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],d=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=[],h=[],w=0;w<d;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],h[S]=x}for(var D=0;D<v;D++)w===0&&(y[D]=[]),h[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,d],datatype:p})}}),Eb="matAlgo14xDs",Sb=["typed"],xt=q(Eb,Sb,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}}),ls="ceil",Cb=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],Mb=q(ls,["typed","config","round"],r=>{var{typed:e,config:t,round:a}=r;return e(ls,{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))}})}),Fb=q(ls,Cb,r=>{var{typed:e,config:t,round:a,matrix:n,equalScalar:i,zeros:o,DenseMatrix:f}=r,l=Ur({typed:e,equalScalar:i}),u=Ir({typed:e,DenseMatrix:f}),s=xt({typed:e}),c=Mb({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,d){return v.ceil(d)},"Complex, BigNumber":function(v,d){return v.ceil(d.toNumber())},BigNumber:function(v){return Bt(v,a(v),t.epsilon)?a(v):v.ceil()},"BigNumber, BigNumber":function(v,d){return Bt(v,a(v,d),t.epsilon)?a(v,d):v.toDecimalPlaces(d.toNumber(),cn.ROUND_CEIL)},Fraction:function(v){return v.ceil()},"Fraction, number":function(v,d){return v.ceil(d)},"Fraction, BigNumber":function(v,d){return v.ceil(d.toNumber())},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array, number | BigNumber":e.referToSelf(m=>(v,d)=>je(v,p=>m(p,d))),"SparseMatrix, number | BigNumber":e.referToSelf(m=>(v,d)=>l(v,d,m,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(m=>(v,d)=>s(v,d,m,!1)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,d)=>s(n(d),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,d)=>i(v,0)?o(d.size(),d.storage()):d.storage()==="dense"?s(d,v,m,!0):u(d,v,m,!0))})}),wf="cube",Tb=["typed"],Bb=q(wf,Tb,r=>{var{typed:e}=r;return e(wf,{number:ic,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)}})}),Nf="exp",$b=["typed"],Ob=q(Nf,$b,r=>{var{typed:e}=r;return e(Nf,{number:oc,Complex:function(a){return a.exp()},BigNumber:function(a){return a.exp()}})}),Df="expm1",Ib=["typed","Complex"],Rb=q(Df,Ib,r=>{var{typed:e,Complex:t}=r;return e(Df,{number:sc,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)}})}),cs="fix",_b=["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],qb=q(cs,["typed","ceil","floor"],r=>{var{typed:e,ceil:t,floor:a}=r;return e(cs,{number:function(i){return i>0?a(i):t(i)},"number, number":function(i,o){return i>0?a(i,o):t(i,o)}})}),zb=q(cs,_b,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=qb({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,d){return new t(v.re>0?i(v.re,d):n(v.re,d),v.im>0?i(v.im,d):n(v.im,d))},"Complex, BigNumber":function(v,d){var p=d.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,d){return v.isNegative()?n(v,d):i(v,d)},Fraction:function(v){return v.s<0?v.ceil():v.floor()},"Fraction, number | BigNumber":function(v,d){return v.s<0?n(v,d):i(v,d)},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array | Matrix, number | BigNumber":e.referToSelf(m=>(v,d)=>je(v,p=>m(p,d))),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,d)=>s(a(d),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,d)=>o(v,0)?f(d.size(),d.storage()):d.storage()==="dense"?s(d,v,m,!0):u(d,v,m,!0))})}),fs="floor",Pb=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],Lb=q(fs,["typed","config","round"],r=>{var{typed:e,config:t,round:a}=r;return e(fs,{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))}})}),Ub=q(fs,Pb,r=>{var{typed:e,config:t,round:a,matrix:n,equalScalar:i,zeros:o,DenseMatrix:f}=r,l=Ur({typed:e,equalScalar:i}),u=Ir({typed:e,DenseMatrix:f}),s=xt({typed:e}),c=Lb({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,d){return v.floor(d)},"Complex, BigNumber":function(v,d){return v.floor(d.toNumber())},BigNumber:function(v){return Bt(v,a(v),t.epsilon)?a(v):v.floor()},"BigNumber, BigNumber":function(v,d){return Bt(v,a(v,d),t.epsilon)?a(v,d):v.toDecimalPlaces(d.toNumber(),cn.ROUND_FLOOR)},Fraction:function(v){return v.floor()},"Fraction, number":function(v,d){return v.floor(d)},"Fraction, BigNumber":function(v,d){return v.floor(d.toNumber())},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array, number | BigNumber":e.referToSelf(m=>(v,d)=>je(v,p=>m(p,d))),"SparseMatrix, number | BigNumber":e.referToSelf(m=>(v,d)=>l(v,d,m,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(m=>(v,d)=>s(v,d,m,!1)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,d)=>s(n(d),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,d)=>i(v,0)?o(d.size(),d.storage()):d.storage()==="dense"?s(d,v,m,!0):u(d,v,m,!0))})}),kb="matAlgo01xDSid",Vb=["typed"],mn=q(kb,Vb,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,d=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===d?u:void 0,N=y?e.find(i,[y,y]):i,h,w,x=[];for(h=0;h<p;h++)x[h]=[];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++)h=c[T],b[h]=o?N(s[T],f[h][w]):N(f[h][w],s[T]),E[h]=A;for(h=0;h<p;h++)E[h]===A?x[h][w]=b[h]:x[h][w]=f[h][w]}return a.createDenseMatrix({data:x,size:[p,g],datatype:y})}}),Gb="matAlgo04xSidSid",Hb=["typed","equalScalar"],ms=q(Gb,Hb,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,d=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],h,w=t,x=0,b=o;typeof c=="string"&&c===g&&(h=c,w=e.find(t,[h,h]),x=e.convert(0,h),b=e.find(o,[h,h]));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=d[R],H=d[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:h})}}),Zb="matAlgo10xSids",Jb=["typed","DenseMatrix"],Tn=q(Zb,Jb,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],d=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=[],h=[],w=0;w<d;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],h[S]=x}for(var D=0;D<v;D++)w===0&&(y[D]=[]),h[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,d],datatype:p})}}),Wb="matAlgo13xDD",Xb=["typed"],Yb=q(Wb,Xb,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 d=0;d<l.length;d++){if(l[d]!==c[d])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+c+")");v[d]=l[d]}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}}),Qb="broadcast",Kb=["concat"],jb=q(Qb,Kb,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(),d=o.clone();v._size.length<f?v.reshape(t(v._size,f,1)):d._size.length<f&&d.reshape(t(d._size,f,1));for(var p=0;p<f;p++)v._size[p]<s[p]&&(v=a(v,s[p],p)),d._size[p]<s[p]&&(d=a(d,s[p],p));return[v,d]};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]))}}),ex="matrixAlgorithmSuite",rx=["typed","matrix","concat"],hr=q(ex,rx,r=>{var{typed:e,matrix:t,concat:a}=r,n=Yb({typed:e}),i=xt({typed:e}),o=jb({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 d=l.sS!==void 0?l.sS:l.Ss;return u?(l.Ss&&(c["SparseMatrix,"+m]=(p,g)=>l.Ss(p,g,u,!1)),d&&(c[m+", SparseMatrix"]=(p,g)=>d(g,p,u,!0))):(l.Ss&&(c["SparseMatrix,"+m]=e.referToSelf(p=>(g,y)=>l.Ss(g,y,p,!1))),d&&(c[m+", SparseMatrix"]=e.referToSelf(p=>(g,y)=>d(y,g,p,!0)))),u&&u.signatures&&fl(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 Af="gcd",tx=["typed","matrix","equalScalar","BigNumber","DenseMatrix","concat"],vs="number | BigNumber | Fraction | Matrix | Array",nx="".concat(vs,", ").concat(vs,", ...").concat(vs);function Ef(r){return!r.some(e=>Array.isArray(e))}var ax=q(Af,tx,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n,DenseMatrix:i,concat:o}=r,f=mn({typed:e}),l=ms({typed:e,equalScalar:a}),u=Tn({typed:e,DenseMatrix:i}),s=hr({typed:e,matrix:t,concat:o});return e(Af,{"number, number":uc,"BigNumber, BigNumber":c,"Fraction, Fraction":(m,v)=>m.gcd(v)},s({SS:l,DS:f,Ss:u}),{[nx]:e.referToSelf(m=>(v,d,p)=>{for(var g=m(v,d),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])&&Ef(v[0]))return m(...v[0]);if(Ef(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 d=new n(0);!v.isZero();){var p=m.mod(v);m=v,v=p}return m.lt(d)?m.neg():m}}),ix="matAlgo02xDS0",ox=["typed","equalScalar"],wt=q(ix,ox,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,d=i._size,p=i._datatype;if(u.length!==d.length)throw new Ke(u.length,d.length);if(u[0]!==d[0]||u[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+d+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var g=u[0],y=u[1],N,h=t,w=0,x=o;typeof s=="string"&&s===p&&(N=s,h=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]);h(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})}}),sx="matAlgo06xS0S0",ux=["typed","equalScalar"],Ii=q(sx,ux,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],d=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 h=f&&s?[]:void 0,w=[],x=[],b=h?[]:void 0,E=[],A=[],S=0;S<d;S++){x[S]=w.length;var D=S+1;if(Kl(n,S,E,b,A,D,w,N),Kl(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):(h.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[d]=w.length,n.createSparseMatrix({values:h,index:w,ptr:x,size:[v,d],datatype:p})}}),Sf="lcm",lx=["typed","matrix","equalScalar","concat"],cx=q(Sf,lx,r=>{var{typed:e,matrix:t,equalScalar:a,concat:n}=r,i=wt({typed:e,equalScalar:a}),o=Ii({typed:e,equalScalar:a}),f=Ur({typed:e,equalScalar:a}),l=hr({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,d,p)=>{for(var g=m(v,d),y=0;y<p.length;y++)g=m(g,p[y]);return g}),e(Sf,{"number, number":lc,"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 d=m.times(v);!v.isZero();){var p=v;v=m.mod(p),m=p}return d.div(m).abs()}}),Cf="log10",fx=["typed","config","Complex"],mx=q(Cf,fx,r=>{var{typed:e,config:t,Complex:a}=r;return e(Cf,{number:function(i){return i>=0||t.predictable?cc(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))})}),Mf="log2",vx=["typed","config","Complex"],px=q(Mf,vx,r=>{var{typed:e,config:t,Complex:a}=r;return e(Mf,{number:function(o){return o>=0||t.predictable?fc(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)}}),dx="matAlgo03xDSf",hx=["typed"],Yr=q(dx,hx,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,d=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,h=i;typeof u=="string"&&u===d&&(y=u,N=e.convert(0,y),h=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?h(s[B],f[I][A]):h(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?h(N,f[P][A]):h(f[P][A],N)}return a.createDenseMatrix({data:w,size:[p,g],datatype:y})}}),gx="matAlgo05xSfSf",yx=["typed","equalScalar"],Ri=q(gx,yx,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,d=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],h,w=t,x=0,b=o;typeof c=="string"&&c===g&&(h=c,w=e.find(t,[h,h]),x=e.convert(0,h),b=e.find(o,[h,h]));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=d[R],F=d[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,U=b(Q,K);w(U,x)?A.splice(M,1):(E.push(U),M++)}}}return S[N]=A.length,n.createSparseMatrix({values:E,index:A,ptr:S,size:[y,N],datatype:h})}}),Ff="mod",bx=["typed","matrix","equalScalar","DenseMatrix","concat"],xx=q(Ff,bx,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n,concat:i}=r,o=wt({typed:e,equalScalar:a}),f=Yr({typed:e}),l=Ri({typed:e,equalScalar:a}),u=Ur({typed:e,equalScalar:a}),s=Ir({typed:e,DenseMatrix:n}),c=hr({typed:e,matrix:t,concat:i});return e(Ff,{"number, number":mc,"BigNumber, BigNumber":function(v,d){if(d.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return d.isZero()?v:v.mod(d)},"Fraction, Fraction":function(v,d){if(d.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return v.compare(0)>=0?v.mod(d):v.mod(d).add(d).mod(d)}},c({SS:l,DS:f,SD:o,Ss:u,sS:s}))}),wx="multiplyScalar",Nx=["typed"],Dx=q(wx,Nx,r=>{var{typed:e}=r;return e("multiplyScalar",{"number, number":tc,"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)})}),Tf="multiply",Ax=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],Ex=q(Tf,Ax,r=>{var{typed:e,matrix:t,addScalar:a,multiplyScalar:n,equalScalar:i,dot:o}=r,f=Ur({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}),d=e("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":g,"DenseMatrix, SparseMatrix":y,"SparseMatrix, DenseMatrix":h,"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 U=H(Q[0],D[0][K]),j=1;j<P;j++)U=F(U,H(Q[j],D[j][K]));$[k][K]=U}}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=[],U=[],j=[],ae=b.createSparseMatrix({values:K,index:U,ptr:j,size:[R,M],datatype:F}),re=0;re<M;re++){j[re]=U.length;var me=B[re],he=B[re+1];if(he>me)for(var fe=0,ie=0;ie<R;ie++){for(var Ae=ie+1,Oe=void 0,Ce=me;Ce<he;Ce++){var $e=T[Ce];fe!==Ae?(Oe=$(E[ie][$e],D[Ce]),fe=Ae):Oe=H(Oe,$(E[ie][$e],D[Ce]))}fe===Ae&&!k(Oe,Q)&&(U.push(ie),K.push(Oe))}}return j[M]=U.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 U=[],j=[];F[0]=0;for(var ae=0;ae<P;ae++){var re=T[ae];if(!Q(re,K))for(var me=S[ae],he=S[ae+1],fe=me;fe<he;fe++){var ie=A[fe];j[ie]?U[ie]=$(U[ie],k(re,E[fe])):(j[ie]=!0,M.push(ie),U[ie]=k(re,E[fe]))}}for(var Ae=M.length,Oe=0;Oe<Ae;Oe++){var Ce=M[Oe];R[Oe]=U[Ce]}return F[1]=M.length,x.createSparseMatrix({values:R,index:M,ptr:F,size:[I,1],datatype:H})}function h(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=[],U=[],j=x.createSparseMatrix({values:Q,index:K,ptr:U,size:[I,R],datatype:M}),ae=[],re=[],me=0;me<R;me++){U[me]=K.length;for(var he=me+1,fe=0;fe<P;fe++){var ie=T[fe][me];if(!$(ie,k))for(var Ae=S[fe],Oe=S[fe+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=U[me],W=K.length,se=V;se<W;se++){var G=K[se];Q[se]=ae[G]}}return U[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=[],U=[],j=x.createSparseMatrix({values:Q,index:K,ptr:U,size:[R,M],datatype:H}),ae=F?[]:void 0,re=[],me,he,fe,ie,Ae,Oe,Ce,$e,V=0;V<M;V++){U[V]=K.length;var W=V+1;for(Ae=I[V],Oe=I[V+1],ie=Ae;ie<Oe;ie++)if($e=B[ie],F)for(he=S[$e],fe=S[$e+1],me=he;me<fe;me++)Ce=A[me],re[Ce]!==W?(re[Ce]=W,K.push(Ce),ae[Ce]=k(T[ie],E[me])):ae[Ce]=$(ae[Ce],k(T[ie],E[me]));else for(he=S[$e],fe=S[$e+1],me=he;me<fe;me++)Ce=A[me],re[Ce]!==W&&(re[Ce]=W,K.push(Ce));if(F)for(var se=U[V],G=K.length,Y=se;Y<G;Y++){var te=K[Y];Q[Y]=ae[te]}}return U[M]=K.length,j}return e(Tf,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):d(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})})}),Bf="nthRoot",Sx=["typed","matrix","equalScalar","BigNumber","concat"],Cx=q(Bf,Sx,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n,concat:i}=r,o=mn({typed:e}),f=wt({typed:e,equalScalar:a}),l=Ii({typed:e,equalScalar:a}),u=Ur({typed:e,equalScalar:a}),s=hr({typed:e,matrix:t,concat:i});function c(){throw new Error("Complex number not supported in function nthRoot. Use nthRoots instead.")}return e(Bf,{number:vc,"number, number":vc,BigNumber:v=>m(v,new n(2)),"BigNumber, BigNumber":m,Complex:c,"Complex, number":c,Array:e.referTo("DenseMatrix,number",v=>d=>v(t(d),2).valueOf()),DenseMatrix:e.referTo("DenseMatrix,number",v=>d=>v(d,2)),SparseMatrix:e.referTo("SparseMatrix,number",v=>d=>v(d,2)),"SparseMatrix, SparseMatrix":e.referToSelf(v=>(d,p)=>{if(p.density()===1)return l(d,p,v);throw new Error("Root must be non-zero")}),"DenseMatrix, SparseMatrix":e.referToSelf(v=>(d,p)=>{if(p.density()===1)return o(d,p,v,!1);throw new Error("Root must be non-zero")}),"Array, SparseMatrix":e.referTo("DenseMatrix,SparseMatrix",v=>(d,p)=>v(t(d),p)),"number | BigNumber, SparseMatrix":e.referToSelf(v=>(d,p)=>{if(p.density()===1)return u(p,d,v,!0);throw new Error("Root must be non-zero")})},s({scalar:"number | BigNumber",SD:f,Ss:u,sS:!1}));function m(v,d){var p=n.precision,g=n.clone({precision:p+2}),y=new n(0),N=new g(1),h=d.isNegative();if(h&&(d=d.neg()),d.isZero())throw new Error("Root must be non-zero");if(v.isNegative()&&!d.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(v.isZero())return h?new g(1/0):0;if(!v.isFinite())return h?y:v;var w=v.abs().pow(N.div(d));return w=v.isNeg()?w.neg():w,new n((h?N.div(w):w).toPrecision(p))}}),$f="sign",Mx=["typed","BigNumber","Fraction","complex"],Fx=q($f,Mx,r=>{var{typed:e,BigNumber:t,complex:a,Fraction:n}=r;return e($f,{number:ss,Complex:function(o){return o.im===0?a(ss(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)})})}),Tx="sqrt",Bx=["config","typed","Complex"],$x=q(Tx,Bx,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()}}),Of="square",Ox=["typed"],Ix=q(Of,Ox,r=>{var{typed:e}=r;return e(Of,{number:pc,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)}})}),If="subtract",Rx=["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix","concat"],_x=q(If,Rx,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=Ri({typed:e,equalScalar:a}),c=Tn({typed:e,DenseMatrix:o}),m=Ir({typed:e,DenseMatrix:o}),v=hr({typed:e,matrix:t,concat:f});return e(If,{"number, number":(d,p)=>d-p,"Complex, Complex":(d,p)=>d.sub(p),"BigNumber, BigNumber":(d,p)=>d.minus(p),"Fraction, Fraction":(d,p)=>d.sub(p),"Unit, Unit":e.referToSelf(d=>(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(d,[y.valueType(),g.valueType()])(y.value,g.value),y.fixPrefix=!1,y})},v({SS:s,DS:l,SD:u,Ss:m,sS:c}))}),Rf="xgcd",qx=["typed","config","matrix","BigNumber"],zx=q(Rf,qx,r=>{var{typed:e,config:t,matrix:a,BigNumber:n}=r;return e(Rf,{"number, number":function(f,l){var u=dc(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,d=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=d.minus(u.times(v)),d=l,l=p,p=g.minus(u.times(p)),g=l,o=f,f=s;var y;return o.lt(c)?y=[o.neg(),d.neg(),g.neg()]:y=[o,o.isZero()?0:d,g],t.matrix==="Array"?y:a(y)}}),_f="invmod",Px=["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],Lx=q(_f,Px,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[d,p]=v;return i(d,a(1))?(p=f(p,m),o(p,a(0))&&(p=l(p,m)),p):NaN}}),Ux="matAlgo09xS0Sf",kx=["typed","equalScalar"],qf=q(Ux,kx,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,d=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],h,w=t,x=0,b=o;typeof c=="string"&&c===g&&(h=c,w=e.find(t,[h,h]),x=e.convert(0,h),b=e.find(o,[h,h]));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=d[I],M=d[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:h})}}),zf="dotMultiply",Vx=["typed","matrix","equalScalar","multiplyScalar","concat"],Gx=q(zf,Vx,r=>{var{typed:e,matrix:t,equalScalar:a,multiplyScalar:n,concat:i}=r,o=wt({typed:e,equalScalar:a}),f=qf({typed:e,equalScalar:a}),l=Ur({typed:e,equalScalar:a}),u=hr({typed:e,matrix:t,concat:i});return e(zf,u({elop:n,SS:f,DS:o,Ss:l}))});function Hx(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 ps(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 Zx(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:ps(r,e,function(n,i){return n|i})}function ps(r,e,t){var a=r.constructor,n,i,o=+(r.s<0),f=+(e.s<0);if(o){n=_i(Ha(r));for(var l=0;l<n.length;++l)n[l]^=1}else n=_i(r);if(f){i=_i(Ha(e));for(var u=0;u<i.length;++u)i[u]^=1}else i=_i(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,d=c.length,p=t(o,f)^1,g=new a(p^1),y=new a(1),N=new a(2),h=a.precision;for(a.config({precision:1e9});v>0;)t(s[--v],c[--d])===p&&(g=g.plus(y)),y=y.times(N);for(;d>0;)t(m,c[--d])===p&&(g=g.plus(y)),y=y.times(N);return a.config({precision:h}),p===0&&(g.s=-g.s),g}function _i(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 Jx(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):ps(r,e,function(n,i){return n^i})}function Wx(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 Xx(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 Pf="bitAnd",Yx=["typed","matrix","equalScalar","concat"],Qx=q(Pf,Yx,r=>{var{typed:e,matrix:t,equalScalar:a,concat:n}=r,i=wt({typed:e,equalScalar:a}),o=Ii({typed:e,equalScalar:a}),f=Ur({typed:e,equalScalar:a}),l=hr({typed:e,matrix:t,concat:n});return e(Pf,{"number, number":yc,"BigNumber, BigNumber":Hx},l({SS:o,DS:i,Ss:f}))}),Lf="bitNot",Kx=["typed"],jx=q(Lf,Kx,r=>{var{typed:e}=r;return e(Lf,{number:bc,BigNumber:Ha,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Uf="bitOr",ew=["typed","matrix","equalScalar","DenseMatrix","concat"],rw=q(Uf,ew,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n,concat:i}=r,o=mn({typed:e}),f=ms({typed:e,equalScalar:a}),l=Tn({typed:e,DenseMatrix:n}),u=hr({typed:e,matrix:t,concat:i});return e(Uf,{"number, number":xc,"BigNumber, BigNumber":Zx},u({SS:f,DS:o,Ss:l}))}),tw="matAlgo07xSSf",nw=["typed","DenseMatrix"],$t=q(tw,nw,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],d,p=0,g=f;typeof u=="string"&&u===c&&(d=u,p=e.convert(0,d),g=e.find(f,[d,d]));var y,N,h=[];for(y=0;y<m;y++)h[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;h[y][N]=g(S,D)}}return new t({data:h,size:[m,v],datatype:d})};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 d=s[m];o[d]=l,f[d]=u[m]}}}),kf="bitXor",aw=["typed","matrix","DenseMatrix","concat"],iw=q(kf,aw,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=hr({typed:e,matrix:t,concat:n});return e(kf,{"number, number":wc,"BigNumber, BigNumber":Jx},l({SS:o,DS:i,Ss:f}))}),Vf="arg",ow=["typed"],sw=q(Vf,ow,r=>{var{typed:e}=r;return e(Vf,{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))})}),Gf="conj",uw=["typed"],lw=q(Gf,uw,r=>{var{typed:e}=r;return e(Gf,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.conjugate(),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Hf="im",cw=["typed"],fw=q(Hf,cw,r=>{var{typed:e}=r;return e(Hf,{number:()=>0,"BigNumber | Fraction":t=>t.mul(0),Complex:t=>t.im,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Zf="re",mw=["typed"],vw=q(Zf,mw,r=>{var{typed:e}=r;return e(Zf,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.re,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Jf="not",pw=["typed"],dw=q(Jf,pw,r=>{var{typed:e}=r;return e(Jf,{"null | undefined":()=>!0,number:Sc,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))})}),Wf="or",hw=["typed","matrix","equalScalar","DenseMatrix","concat"],gw=q(Wf,hw,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n,concat:i}=r,o=Yr({typed:e}),f=Ri({typed:e,equalScalar:a}),l=Ir({typed:e,DenseMatrix:n}),u=hr({typed:e,matrix:t,concat:i});return e(Wf,{"number, number":Cc,"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}))}),Xf="xor",yw=["typed","matrix","DenseMatrix","concat"],bw=q(Xf,yw,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=hr({typed:e,matrix:t,concat:n});return e(Xf,{"number, number":Mc,"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}))}),Yf="concat",xw=["typed","matrix","isInteger"],Qf=q(Yf,xw,r=>{var{typed:e,matrix:t,isInteger:a}=r;return e(Yf,{"...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(),d=er(v);if(c[o]=v,u=l,l=d.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=Kf(p,c.shift(),l,0);return s?t(p):p},"...string":function(i){return i.join("")}})});function Kf(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]=Kf(r[i],e[i],t,a+1);return n}else return r.concat(e)}var jf="column",ww=["typed","Index","matrix","range"],em=q(jf,ww,r=>{var{typed:e,Index:t,matrix:a,range:n}=r;return e(jf,{"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]])}}),rm="count",Nw=["typed","size","prod"],Dw=q(rm,Nw,r=>{var{typed:e,size:t,prod:a}=r;return e(rm,{string:function(i){return i.length},"Matrix | Array":function(i){return a(t(i))}})}),tm="cross",Aw=["typed","matrix","subtract","multiply"],Ew=q(tm,Aw,r=>{var{typed:e,matrix:t,subtract:a,multiply:n}=r;return e(tm,{"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=di(o),f=di(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}}),nm="diag",Sw=["typed","matrix","DenseMatrix","SparseMatrix"],Cw=q(nm,Sw,r=>{var{typed:e,matrix:t,DenseMatrix:a,SparseMatrix:n}=r;return e(nm,{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 d=[c+m,c+v];if(s&&s!=="sparse"&&s!=="dense")throw new TypeError("Unknown matrix type ".concat(s,'"'));var p=s==="sparse"?n.diagonal(d,l,u):a.diagonal(d,l,u);return s!==null?p:p.valueOf()}function f(l,u,s,c,m,v){if(Ve(l)){var d=l.diagonal(u);return s!==null?s!==d.storage()?t(d,s):d:d.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}}),Mw="filter",Fw=["typed"],Tw=q(Mw,Fw,r=>{var{typed:e}=r;return e("filter",{"Array, function":am,"Matrix, function":function(a,n){return a.create(am(a.toArray(),n))},"Array, RegExp":gi,"Matrix, RegExp":function(a,n){return a.create(gi(a.toArray(),n))}})});function am(r,e){var t=fn(e);return Ml(r,function(a,n,i){return t===1?e(a):t===2?e(a,[n]):e(a,[n],i)})}var im="flatten",Bw=["typed","matrix"],$w=q(im,Bw,r=>{var{typed:e,matrix:t}=r;return e(im,{Array:function(n){return or(n)},Matrix:function(n){var i=or(n.toArray());return t(i)}})}),om="forEach",Ow=["typed"],Iw=q(om,Ow,r=>{var{typed:e}=r;return e(om,{"Array, function":Rw,"Matrix, function":function(a,n){a.forEach(n)}})});function Rw(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 sm="getMatrixDataType",_w=["typed"],qw=q(sm,_w,r=>{var{typed:e}=r;return e(sm,{Array:function(a){return Ua(a,br)},Matrix:function(a){return a.getDataType()}})}),um="identity",zw=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],Pw=q(um,zw,r=>{var{typed:e,config:t,matrix:a,BigNumber:n,DenseMatrix:i,SparseMatrix:o}=r;return e(um,{"":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,d=m?new m(0):0,p=[u,s];if(c){if(c==="sparse")return o.diagonal(p,v,0,d);if(c==="dense")return i.diagonal(p,v,0,d);throw new TypeError('Unknown matrix type "'.concat(c,'"'))}for(var g=Qn([],p,d),y=u<s?u:s,N=0;N<y;N++)g[N][N]=v;return g}}),lm="kron",Lw=["typed","matrix","multiplyScalar"],Uw=q(lm,Lw,r=>{var{typed:e,matrix:t,multiplyScalar:a}=r;return e(lm,{"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}}),cm="map",kw=["typed"],Vw=q(cm,kw,r=>{var{typed:e}=r;return e(cm,{"Array, function":Gw,"Matrix, function":function(a,n){return a.map(n)}})});function Gw(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 fm="diff",Hw=["typed","matrix","subtract","number"],mm=q(fm,Hw,r=>{var{typed:e,matrix:t,subtract:a,number:n}=r;return e(fm,{"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}}),Zw="ones",Jw=["typed","config","matrix","BigNumber"],Ww=q(Zw,Jw,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 ds(){throw new Error('No "bignumber" implementation available')}function vm(){throw new Error('No "fraction" implementation available')}function pm(){throw new Error('No "matrix" implementation available')}var dm="range",Xw=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],hm=q(dm,Xw,r=>{var{typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:o,larger:f,largerEq:l}=r;return e(dm,{string:s,"string, boolean":s,"number, number":function(y,N){return u(c(y,N,1))},"number, number, number":function(y,N,h){return u(c(y,N,h))},"number, number, boolean":function(y,N,h){return u(h?m(y,N,1):c(y,N,1))},"number, number, number, boolean":function(y,N,h,w){return u(w?m(y,N,h):c(y,N,h))},"BigNumber, BigNumber":function(y,N){var h=y.constructor;return u(v(y,N,new h(1)))},"BigNumber, BigNumber, BigNumber":function(y,N,h){return u(v(y,N,h))},"BigNumber, BigNumber, boolean":function(y,N,h){var w=y.constructor;return u(h?d(y,N,new w(1)):v(y,N,new w(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(y,N,h,w){return u(w?d(y,N,h):v(y,N,h))}});function u(g){return t.matrix==="Matrix"?a?a(g):pm():g}function s(g,y){var N=p(g);if(!N)throw new SyntaxError('String "'+g+'" is no valid range');var h;return t.number==="BigNumber"?(n===void 0&&ds(),h=y?d:v,u(h(n(N.start),n(N.end),n(N.step)))):(h=y?m:c,u(h(N.start,N.end,N.step)))}function c(g,y,N){var h=[],w=g;if(N>0)for(;i(w,y);)h.push(w),w+=N;else if(N<0)for(;f(w,y);)h.push(w),w+=N;return h}function m(g,y,N){var h=[],w=g;if(N>0)for(;o(w,y);)h.push(w),w+=N;else if(N<0)for(;l(w,y);)h.push(w),w+=N;return h}function v(g,y,N){var h=n(0),w=[],x=g;if(N.gt(h))for(;i(x,y);)w.push(x),x=x.plus(N);else if(N.lt(h))for(;f(x,y);)w.push(x),x=x.plus(N);return w}function d(g,y,N){var h=n(0),w=[],x=g;if(N.gt(h))for(;o(x,y);)w.push(x),x=x.plus(N);else if(N.lt(h))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)}),h=N.some(function(w){return isNaN(w)});if(h)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}}}),gm="reshape",Yw=["typed","isInteger","matrix"],Qw=q(gm,Yw,r=>{var{typed:e,isInteger:t}=r;return e(gm,{"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)}),Dl(n,i)}})}),Kw="resize",jw=["config","matrix"],eN=q(Kw,jw,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}}),ym="rotate",rN=["typed","multiply","rotationMatrix"],tN=q(ym,rN,r=>{var{typed:e,multiply:t,rotationMatrix:a}=r;return e(ym,{"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))}}),bm="rotationMatrix",nN=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],aN=q(bm,nN,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(bm,{"":function(){return t.matrix==="Matrix"?l([]):[]},string:function(h){return l(h)},"number | BigNumber | Complex | Unit":function(h){return v(h,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(h,w){return v(h,w)},"number | BigNumber | Complex | Unit, Array":function(h,w){var x=l(w);return d(x),y(h,x,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(h,w){d(w);var x=w.storage()||(t.matrix==="Matrix"?"dense":void 0);return y(h,w,x)},"number | BigNumber | Complex | Unit, Array, string":function(h,w,x){var b=l(w);return d(b),y(h,b,x)},"number | BigNumber | Complex | Unit, Matrix, string":function(h,w,x){return d(w),y(h,w,x)}});function v(N,h){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,h)}function d(N){var h=N.size();if(h.length<1||h[0]!==3)throw new RangeError("Vector must be of dimensions 1x3")}function p(N){return N.reduce((h,w)=>a(h,w))}function g(N,h){if(h){if(h==="sparse")return new s(N);if(h==="dense")return new u(N);throw new TypeError('Unknown matrix type "'.concat(h,'"'))}return N}function y(N,h,w){var x=o(h);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(h.get([0])/x):h.get([0])/x,D=b?new b(h.get([1])/x):h.get([1])/x,T=b?new b(h.get([2])/x):h.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])),U=n(B,p([T,T,I])),j=[[R,M,F],[H,$,k],[Q,K,U]];return g(j,w)}}),xm="row",iN=["typed","Index","matrix","range"],wm=q(xm,iN,r=>{var{typed:e,Index:t,matrix:a,range:n}=r;return e(xm,{"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]])}}),Nm="size",oN=["typed","config","?matrix"],sN=q(Nm,oN,r=>{var{typed:e,config:t,matrix:a}=r;return e(Nm,{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([]):pm()}})}),Dm="squeeze",uN=["typed","matrix"],lN=q(Dm,uN,r=>{var{typed:e,matrix:t}=r;return e(Dm,{Array:function(n){return di(Ge(n))},Matrix:function(n){var i=di(n.toArray());return Array.isArray(i)?t(i):i},any:function(n){return Ge(n)}})}),Am="subset",cN=["typed","matrix"],Em=q(Am,cN,r=>{var{typed:e,matrix:t}=r;return e(Am,{"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":mN,"string, Index":fN,"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":Sm,"string, Index, string, string":Sm,"Object, Index, any":vN})});function fN(r,e){if(!ci(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 Sm(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 mN(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 vN(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 Cm="transpose",pN=["typed","matrix"],dN=q(Cm,pN,r=>{var{typed:e,matrix:t}=r;return e(Cm,{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=[],d=[],p=[],g=0;g<f;g++)p[g]=0;var y,N,h;for(y=0,N=s.length;y<N;y++)p[s[y]]++;for(var w=0,x=0;x<f;x++)d.push(w),w+=p[x],p[x]=d[x];for(d.push(w),h=0;h<l;h++)for(var b=c[h],E=c[h+1],A=b;A<E;A++){var S=p[s[A]]++;v[S]=h,u&&(m[S]=Ge(u[A]))}return o.createSparseMatrix({values:m,index:v,ptr:d,size:[l,f],datatype:o._datatype})}}),Mm="ctranspose",hN=["typed","transpose","conj"],gN=q(Mm,hN,r=>{var{typed:e,transpose:t,conj:a}=r;return e(Mm,{any:function(i){return a(t(i))}})}),Fm="zeros",yN=["typed","config","matrix","BigNumber"],bN=q(Fm,yN,r=>{var{typed:e,config:t,matrix:a,BigNumber:n}=r;return e(Fm,{"":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")})}}),Tm="fft",xN=["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i","dotDivide","conj","pow","ceil","log2"],wN=q(Tm,xN,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(Tm,{Array:d,Matrix:function(h){return h.create(d(h.toArray()))}});function d(N){var h=er(N);return h.length===1?y(N,h[0]):p(N.map(w=>d(w,h.slice(1))),0)}function p(N,h){var w=er(N);if(h!==0)return new Array(w[0]).fill(0).map((b,E)=>p(N[E],h-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 h=N.length,w=o(i(n(-1,n(l,f)),h)),x=[],b=1-h;b<h;b++)x.push(c(w,i(c(b,2),2)));for(var E=c(2,m(v(h+h-1))),A=[...new Array(h).fill(0).map((M,F)=>n(N[F],x[h-1+F])),...new Array(E-h).fill(0)],S=[...new Array(h+h-1).fill(0).map((M,F)=>i(1,x[F])),...new Array(E-(h+h-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(d(s(B))),E),P=[],R=h-1;R<h+h-1;R++)P.push(n(I[R],x[R]));return P}function y(N){var h=N.length;if(h===1)return[N[0]];if(h%2===0){for(var w=[...y(N.filter((A,S)=>S%2===0)),...y(N.filter((A,S)=>S%2===1))],x=0;x<h/2;x++){var b=w[x],E=n(w[x+h/2],o(n(n(f,l),i(-x,h))));w[x]=a(b,E),w[x+h/2]=a(b,n(-1,E))}return w}else return g(N)}}),Bm="ifft",NN=["typed","fft","dotDivide","conj"],DN=q(Bm,NN,r=>{var{typed:e,fft:t,dotDivide:a,conj:n}=r;return e(Bm,{"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))}})}),AN="erf",EN=["typed"],SN=q(AN,EN,r=>{var{typed:e}=r;return e("name",{number:function(o){var f=Math.abs(o);return f>=FN?an(o):f<=CN?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=(MN-s)/i,o=parseInt(i*16)/16;var c=(i-o)*(i+o);return Math.exp(-o*o)*Math.exp(-c)*s}}),CN=.46875,MN=.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]],FN=Math.pow(2,53),$m="mode",TN=["typed","isNaN","isNumeric"],BN=q($m,TN,r=>{var{typed:e,isNaN:t,isNumeric:a}=r;return e($m,{"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 Om="prod",$N=["typed","config","multiplyScalar","numeric"],ON=q(Om,$N,r=>{var{typed:e,config:t,multiplyScalar:a,numeric:n}=r;return e(Om,{"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(Wt(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}}),Im="format",IN=["typed"],RN=q(Im,IN,r=>{var{typed:e}=r;return e(Im,{any:Ye,"any, Object | function | number":Ye})}),Rm="bin",_N=["typed","format"],qN=q(Rm,_N,r=>{var{typed:e,format:t}=r;return e(Rm,{"number | BigNumber":function(n){return t(n,{notation:"bin"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"bin",wordSize:i})}})}),_m="oct",zN=["typed","format"],PN=q(_m,zN,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})}})}),qm="hex",LN=["typed","format"],UN=q(qm,LN,r=>{var{typed:e,format:t}=r;return e(qm,{"number | BigNumber":function(n){return t(n,{notation:"hex"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"hex",wordSize:i})}})}),zm="print",kN=["typed"],VN=q(zm,kN,r=>{var{typed:e}=r;return e(zm,{"string, Object | Array":Pm,"string, Object | Array, number | Object":Pm})});function Pm(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?Xr(o)?o:Ye(o,t):a})}var Lm="to",GN=["typed","matrix","concat"],HN=q(Lm,GN,r=>{var{typed:e,matrix:t,concat:a}=r,n=hr({typed:e,matrix:t,concat:a});return e(Lm,{"Unit, Unit | string":(i,o)=>i.to(o)},n({Ds:!0}))}),Um="isPrime",ZN=["typed"],JN=q(Um,ZN,r=>{var{typed:e}=r;return e(Um,{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,h,w){for(var x=1;!h.eq(0);)h.mod(2).eq(0)?(h=h.div(2),N=N.mul(N).mod(w)):(h=h.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 d=s[v],p=o(a.sub(a).add(d),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))})}),WN="numeric",XN=["number","?bignumber","?fraction"],YN=q(WN,XN,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):ds,Fraction:a?o=>a(o):vm};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)}}),km="divideScalar",QN=["typed","numeric"],KN=q(km,QN,r=>{var{typed:e,numeric:t}=r;return e(km,{"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)})}),Vm="pow",jN=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],e2=q(Vm,jN,r=>{var{typed:e,config:t,identity:a,multiply:n,matrix:i,inv:o,number:f,fraction:l,Complex:u}=r;return e(Vm,{"number, number":s,"Complex, Complex":function(d,p){return d.pow(p)},"BigNumber, BigNumber":function(d,p){return p.isInteger()||d>=0||t.predictable?d.pow(p):new u(d.toNumber(),0).pow(p.toNumber(),0)},"Fraction, Fraction":function(d,p){var g=d.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(d.valueOf(),p.valueOf())},"Array, number":c,"Array, BigNumber":function(d,p){return c(d,p.toNumber())},"Matrix, number":m,"Matrix, BigNumber":function(d,p){return m(d,p.toNumber())},"Unit, number | BigNumber":function(d,p){return d.pow(p)}});function s(v,d){if(t.predictable&&!qe(d)&&v<0)try{var p=l(d),g=f(p);if((d===g||Math.abs((d-g)/d)<1e-14)&&p.d%2===1)return(p.n%2===0?1:-1)*Math.pow(-v,d)}catch{}return t.predictable&&(v<-1&&d===1/0||v>-1&&v<0&&d===-1/0)?NaN:qe(d)||v>=0||t.predictable?hc(v,d):v*v<1&&d===1/0||v*v>1&&d===-1/0?0:new u(v,0).pow(d,0)}function c(v,d){if(!qe(d))throw new TypeError("For A^b, b must be an integer (value is "+d+")");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(d<0)try{return c(o(v),-d)}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 "+d+")"):N}for(var g=a(p[0]).valueOf(),y=v;d>=1;)(d&1)===1&&(g=n(y,g)),d>>=1,y=n(y,y);return g}function m(v,d){return i(c(v.valueOf(),d))}}),la="Number of decimals in function round must be an integer",Gm="round",r2=["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],t2=q(Gm,r2,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,BigNumber:i,DenseMatrix:o}=r,f=Ur({typed:e,equalScalar:a}),l=Ir({typed:e,DenseMatrix:o}),u=xt({typed:e});return e(Gm,{number:gc,"number, number":gc,"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())})}),Hm="log",n2=["config","typed","divideScalar","Complex"],a2=q(Hm,n2,r=>{var{typed:e,config:t,divideScalar:a,Complex:n}=r;return e(Hm,{number:function(o){return o>=0||t.predictable?oy(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)))})}),Zm="log1p",i2=["typed","config","divideScalar","log","Complex"],o2=q(Zm,i2,r=>{var{typed:e,config:t,divideScalar:a,log:n,Complex:i}=r;return e(Zm,{number:function(l){return l>=-1||t.predictable?ug(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))}}),Jm="nthRoots",s2=["config","typed","divideScalar","Complex"],u2=q(Jm,s2,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=[],d=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](d));continue}v.push(new n({r:d,phi:(c+2*Math.PI*p)/l}))}return v}return e(Jm,{Complex:function(l){return o(l,2)},"Complex, number":o})}),Wm="dotPow",l2=["typed","equalScalar","matrix","pow","DenseMatrix","concat"],c2=q(Wm,l2,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=Ur({typed:e,equalScalar:t}),s=Ir({typed:e,DenseMatrix:i}),c=hr({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 d=e(m);return e(Wm,c({elop:d,SS:l,DS:f,Ss:u,sS:s}))}),Xm="dotDivide",f2=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],m2=q(Xm,f2,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=Ur({typed:e,equalScalar:a}),c=Ir({typed:e,DenseMatrix:i}),m=hr({typed:e,matrix:t,concat:o});return e(Xm,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(li(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 d=0;d<f;d++)u[d]=[0];for(var p=n._values,g=n._index,y=n._ptr,N=y[1],h=y[0];h<N;h++){var w=g[h];u[w][0]=p[h]}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 Ym="lsolve",v2=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],p2=q(Ym,v2,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 d=t(m),p=u(d,v);return p.valueOf()}});function u(c,m){m=l(c,m,!0);for(var v=m._data,d=c._size[0],p=c._size[1],g=[],y=c._data,N=0;N<p;N++){var h=v[N][0]||0,w=void 0;if(o(h,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(h,x);for(var b=N+1;b<d;b++)v[b]=[i(v[b][0]||0,n(w,y[b][N]))]}g[N]=[w]}return new f({data:g,size:[d,1]})}function s(c,m){m=l(c,m,!0);for(var v=m._data,d=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,h=[],w=0;w<p;w++){var x=v[w][0]||0;if(o(x,0))h[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]))]}h[w]=[I]}}return new f({data:h,size:[d,1]})}}),Qm="usolve",d2=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],h2=q(Qm,d2,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 d=t(m),p=u(d,v);return p.valueOf()}});function u(c,m){m=l(c,m,!0);for(var v=m._data,d=c._size[0],p=c._size[1],g=[],y=c._data,N=p-1;N>=0;N--){var h=v[N][0]||0,w=void 0;if(o(h,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(h,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:[d,1]})}function s(c,m){m=l(c,m,!0);for(var v=m._data,d=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,h=[],w=p-1;w>=0;w--){var x=v[w][0]||0;if(o(x,0))h[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]))]}h[w]=[I]}}return new f({data:h,size:[d,1]})}}),Km="lsolveAll",g2=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],y2=q(Km,g2,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:o,DenseMatrix:f}=r,l=Za({DenseMatrix:f});return e(Km,{"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 d=t(m),p=u(d,v);return p.map(g=>g.valueOf())}});function u(c,m){for(var v=[l(c,m,!0)._data.map(A=>A[0])],d=c._data,p=c._size[0],g=c._size[1],y=0;y<g;y++)for(var N=v.length,h=0;h<N;h++){var w=v[h];if(o(d[y][y],0))if(o(w[y],0)){if(h===0){var b=[...w];b[y]=1;for(var E=y+1;E<g;E++)b[E]=i(b[E],d[E][y]);v.push(b)}}else{if(h===0)return[];v.splice(h,1),h-=1,N-=1}else{w[y]=a(w[y],d[y][y]);for(var x=y+1;x<g;x++)w[x]=i(w[x],n(w[y],d[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])],d=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,h=0;h<p;h++)for(var w=v.length,x=0;x<w;x++){for(var b=v[x],E=[],A=[],S=N[h],D=N[h+1],T=0,B=S;B<D;B++){var I=y[B];I===h?T=g[B]:I>h&&(E.push(g[B]),A.push(I))}if(o(T,0))if(o(b[h],0)){if(x===0){var F=[...b];F[h]=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[h]=a(b[h],T);for(var P=0,R=A.length;P<R;P++){var M=A[P];b[M]=i(b[M],n(b[h],E[P]))}}}return v.map(Q=>new f({data:Q.map(K=>[K]),size:[d,1]}))}}),jm="usolveAll",b2=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],x2=q(jm,b2,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:o,DenseMatrix:f}=r,l=Za({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 d=t(m),p=u(d,v);return p.map(g=>g.valueOf())}});function u(c,m){for(var v=[l(c,m,!0)._data.map(A=>A[0])],d=c._data,p=c._size[0],g=c._size[1],y=g-1;y>=0;y--)for(var N=v.length,h=0;h<N;h++){var w=v[h];if(o(d[y][y],0))if(o(w[y],0)){if(h===0){var b=[...w];b[y]=1;for(var E=y-1;E>=0;E--)b[E]=i(b[E],d[E][y]);v.push(b)}}else{if(h===0)return[];v.splice(h,1),h-=1,N-=1}else{w[y]=a(w[y],d[y][y]);for(var x=y-1;x>=0;x--)w[x]=i(w[x],n(w[y],d[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])],d=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,h=p-1;h>=0;h--)for(var w=v.length,x=0;x<w;x++){for(var b=v[x],E=[],A=[],S=N[h],D=N[h+1],T=0,B=D-1;B>=S;B--){var I=y[B];I===h?T=g[B]:I<h&&(E.push(g[B]),A.push(I))}if(o(T,0))if(o(b[h],0)){if(x===0){var F=[...b];F[h]=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[h]=a(b[h],T);for(var P=0,R=A.length;P<R;P++){var M=A[P];b[M]=i(b[M],n(b[h],E[P]))}}}return v.map(Q=>new f({data:Q.map(K=>[K]),size:[d,1]}))}}),w2="matAlgo08xS0Sid",N2=["typed","equalScalar"],hs=q(w2,N2,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,d=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],h,w=t,x=0,b=o;typeof c=="string"&&c===g&&(h=c,w=e.find(t,[h,h]),x=e.convert(0,h),b=e.find(o,[h,h]));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=d[M],P=d[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:h})}}),gs=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())}}),ev="leftShift",D2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],A2=q(ev,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=Ur({typed:e,equalScalar:a}),m=xt({typed:e}),v=hr({typed:e,matrix:t,concat:o}),d=gs({typed:e,matrix:t});return e(ev,{"number, number":Nc,"BigNumber, BigNumber":Wx,"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))},d,v({SS:u,DS:f,SD:l}))}),rv="rightArithShift",E2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],S2=q(rv,E2,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=Ur({typed:e,equalScalar:a}),m=xt({typed:e}),v=hr({typed:e,matrix:t,concat:o}),d=gs({typed:e,matrix:t});return e(rv,{"number, number":Dc,"BigNumber, BigNumber":Xx,"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))},d,v({SS:u,DS:f,SD:l}))}),tv="rightLogShift",C2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],M2=q(tv,C2,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=Ur({typed:e,equalScalar:a}),m=xt({typed:e}),v=hr({typed:e,matrix:t,concat:o}),d=gs({typed:e,matrix:t});return e(tv,{"number, number":Ac,"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))},d,v({SS:u,DS:f,SD:l}))}),nv="and",F2=["typed","matrix","equalScalar","zeros","not","concat"],T2=q(nv,F2,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,not:i,concat:o}=r,f=wt({typed:e,equalScalar:a}),l=Ii({typed:e,equalScalar:a}),u=Ur({typed:e,equalScalar:a}),s=xt({typed:e}),c=hr({typed:e,matrix:t,concat:o});return e(nv,{"number, number":Fc,"Complex, Complex":function(v,d){return(v.re!==0||v.im!==0)&&(d.re!==0||d.im!==0)},"BigNumber, BigNumber":function(v,d){return!v.isZero()&&!d.isZero()&&!v.isNaN()&&!d.isNaN()},"Unit, Unit":e.referToSelf(m=>(v,d)=>m(v.value||0,d.value||0)),"SparseMatrix, any":e.referToSelf(m=>(v,d)=>i(d)?n(v.size(),v.storage()):u(v,d,m,!1)),"DenseMatrix, any":e.referToSelf(m=>(v,d)=>i(d)?n(v.size(),v.storage()):s(v,d,m,!1)),"any, SparseMatrix":e.referToSelf(m=>(v,d)=>i(v)?n(v.size(),v.storage()):u(d,v,m,!0)),"any, DenseMatrix":e.referToSelf(m=>(v,d)=>i(v)?n(v.size(),v.storage()):s(d,v,m,!0)),"Array, any":e.referToSelf(m=>(v,d)=>m(t(v),d).valueOf()),"any, Array":e.referToSelf(m=>(v,d)=>m(v,t(d)).valueOf())},c({SS:l,DS:f}))}),qi="compare",B2=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],$2=q(qi,B2,r=>{var{typed:e,config:t,equalScalar:a,matrix:n,BigNumber:i,Fraction:o,DenseMatrix:f,concat:l}=r,u=Yr({typed:e}),s=Ri({typed:e,equalScalar:a}),c=Ir({typed:e,DenseMatrix:f}),m=hr({typed:e,matrix:n,concat:l}),v=sa({typed:e});return e(qi,O2({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}))}),O2=q(qi,["typed","config"],r=>{var{typed:e,config:t}=r;return e(qi,{"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(h){return r.insensitive&&(""+h).toLowerCase()||""+h},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),d=parseInt(s.match(o),16)||v&&s.match(i)&&Date.parse(s)||null,p,g;if(d){if(v<d)return-1;if(v>d)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},av="compareNatural",I2=["typed","compare"],R2=q(av,I2,r=>{var{typed:e,compare:t}=r,a=t.signatures["boolean,boolean"];return e(av,{"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 _2(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()):li(u)?i(l,u.toJSON().data,s):li(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 d=0;d<c.length;d++){var p=l(u[c[d]],s[m[d]]);if(p!==0)return p}return 0}});function _2(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 iv="compareText",q2=["typed","matrix","concat"];Zo.signature="any, any";var z2=q(iv,q2,r=>{var{typed:e,matrix:t,concat:a}=r,n=hr({typed:e,matrix:t,concat:a});return e(iv,Zo,n({elop:Zo,Ds:!0}))}),zi="equal",P2=["typed","matrix","equalScalar","DenseMatrix","concat"],L2=q(zi,P2,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=hr({typed:e,matrix:t,concat:i});return e(zi,U2({typed:e,equalScalar:a}),u({elop:a,SS:f,DS:o,Ss:l}))}),U2=q(zi,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e(zi,{"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="equalText",k2=["typed","compareText","isZero"],V2=q(ov,k2,r=>{var{typed:e,compareText:t,isZero:a}=r;return e(ov,{"any, any":function(i,o){return a(t(i,o))}})}),Pi="smaller",G2=["typed","config","matrix","DenseMatrix","concat"],H2=q(Pi,G2,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=hr({typed:e,matrix:a,concat:i}),s=sa({typed:e});return e(Pi,Z2({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}))}),Z2=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)}})}),Li="smallerEq",J2=["typed","config","matrix","DenseMatrix","concat"],W2=q(Li,J2,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=hr({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.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}))}),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)}})}),Ui="larger",Y2=["typed","config","matrix","DenseMatrix","concat"],Q2=q(Ui,Y2,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=hr({typed:e,matrix:a,concat:i}),s=sa({typed:e});return e(Ui,K2({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}))}),K2=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)}})}),ki="largerEq",j2=["typed","config","matrix","DenseMatrix","concat"],eD=q(ki,j2,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=hr({typed:e,matrix:a,concat:i}),s=sa({typed:e});return e(ki,rD({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}))}),rD=q(ki,["typed","config"],r=>{var{typed:e,config:t}=r;return e(ki,{"number, number":function(n,i){return n>=i||nt(n,i,t.epsilon)}})}),sv="deepEqual",tD=["typed","equal"],nD=q(sv,tD,r=>{var{typed:e,equal:t}=r;return e(sv,{"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)}}),Vi="unequal",aD=["typed","config","equalScalar","matrix","DenseMatrix","concat"],iD=q(Vi,aD,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=hr({typed:e,matrix:n,concat:o});return e(Vi,oD({typed:e,equalScalar:a}),s({elop:c,SS:l,DS:f,Ss:u}));function c(m,v){return!a(m,v)}}),oD=q(Vi,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e(Vi,{"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)}})}),uv="partitionSelect",sD=["typed","isNumeric","isNaN","compare"],uD=q(uv,sD,r=>{var{typed:e,isNumeric:t,isNaN:a,compare:n}=r,i=n,o=(u,s)=>-n(u,s);return e(uv,{"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,d=u.length-1;v<d;){for(var p=v,g=d,y=u[Math.floor(Math.random()*(d-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?d=p:v=p+1}return u[s]}}),lv="sort",lD=["typed","matrix","compare","compareNatural"],cD=q(lv,lD,r=>{var{typed:e,matrix:t,compare:a,compareNatural:n}=r,i=a,o=(s,c)=>-a(s,c);return e(lv,{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")}}),cv="max",fD=["typed","config","numeric","larger"],fv=q(cv,fD,r=>{var{typed:e,config:t,numeric:a,larger:n}=r;return e(cv,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(l,u){return Ci(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(Wt(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}}),mv="min",mD=["typed","config","numeric","smaller"],vv=q(mv,mD,r=>{var{typed:e,config:t,numeric:a,smaller:n}=r;return e(mv,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(l,u){return Ci(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(Wt(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}}),vD="ImmutableDenseMatrix",pD=["smaller","DenseMatrix"],dD=q(vD,pD,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&&!Xr(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}),hD="Index",gD=["ImmutableDenseMatrix"],yD=q(hD,gD,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}),bD="FibonacciHeap",xD=["smaller","larger"],wD=q(bD,xD,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 d=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=d,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),d=0,p=s;if(p)for(d++,p=p.right;p!==s;)d++,p=p.right;for(var g;d>0;){for(var y=p.degree,N=p.right;g=v[y],!!g;){if(t(p.key,g.key)){var h=g;g=p,p=h}l(g,p),v[y]=null,y++}v[y]=p,p=N,d--}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}),ND="Spa",DD=["addScalar","equalScalar","FibonacciHeap"],AD=q(ND,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 ED(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 SD(r){var e=ED(r,"string");return Ja(e)==="symbol"?e:String(e)}function zr(r,e,t){return e=SD(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var CD=Va(function(r){return new r(1).exp()},{hasher:Gi}),MD=Va(function(r){return new r(1).plus(new r(5).sqrt()).div(2)},{hasher:Gi}),ys=Va(function(r){return r.acos(-1)},{hasher:Gi}),FD=Va(function(r){return ys(r).times(2)},{hasher:Gi});function Gi(r){return r[0].precision}function pv(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 bs(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?pv(Object(t),!0).forEach(function(a){zr(r,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):pv(Object(t)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(t,a))})}return r}var TD="Unit",BD=["?on","config","addScalar","subtract","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","number","Complex","BigNumber","Fraction"],$D=q(TD,BD,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:d,Complex:p,BigNumber:g,Fraction:y}=r,N=d;function h(V,W){if(!(this instanceof h))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,W===void 0)this.units=[],this.dimensions=H.map(G=>0);else if(typeof W=="string"){var se=h.parse(W);this.units=se.units,this.dimensions=se.dimensions}else if(Vt(W)&&W.value===null)this.fixPrefix=W.fixPrefix,this.skipAutomaticSimplification=W.skipAutomaticSimplification,this.dimensions=W.dimensions.slice(0),this.units=W.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(h,"name",{value:"Unit"}),h.prototype.constructor=h,h.prototype.type="Unit",h.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="",W=x;if(b==="+"?D():b==="-"&&(V+=b,D()),!A(b))return T(W),null;if(b==="."){if(V+=b,D(),!S(b))return T(W),null}else{for(;S(b);)V+=b,D();b==="."&&(V+=b,D())}for(;S(b);)V+=b,D();if(b==="E"||b==="e"){var se="",G=x;if(se+=b,D(),(b==="+"||b==="-")&&(se+=b,D()),!S(b))return T(G),V;for(V=V+se;S(b);)V+=b,D()}return V}function I(){for(var V="";S(b)||h.isValidAlpha(b);)V+=b,D();var W=V.charAt(0);return h.isValidAlpha(W)?V:null}function P(V){return b===V?(D(),V):null}h.parse=function(V,W){if(W=W||{},w=V,x=-1,b="",typeof w!="string")throw new TypeError("Invalid argument in Unit.parse, string expected");var se=new h;se.units=[];var G=1,Y=!1;D(),E();var te=B(),be=null;if(te){if(t.number==="BigNumber")be=new g(te);else if(t.number==="Fraction")try{be=new y(te)}catch{be=parseFloat(te)}else be=parseFloat(te);E(),P("*")?(G=1,Y=!0):P("/")&&(G=-1,Y=!0)}for(var ve=[],z=1;;){for(E();b==="(";)ve.push(G),z*=G,G=1,D(),E();var L=void 0;if(b){var ee=b;if(L=I(),L===null)throw new SyntaxError('Unexpected "'+ee+'" in "'+w+'" at index '+x.toString())}else break;var le=R(L);if(le===null)throw new SyntaxError('Unit "'+L+'" not found.');var pe=G*z;if(E(),P("^")){E();var ge=B();if(ge===null)throw new SyntaxError('In "'+V+'", "^" must be followed by a floating-point number');pe*=ge}se.units.push({unit:le.unit,prefix:le.prefix,power:pe});for(var xe=0;xe<H.length;xe++)se.dimensions[xe]+=(le.unit.dimensions[xe]||0)*pe;for(E();b===")";){if(ve.length===0)throw new SyntaxError('Unmatched ")" in "'+w+'" at index '+x.toString());z/=ve.pop(),D(),E()}if(Y=!1,P("*")?(G=1,Y=!0):P("/")?(G=-1,Y=!0):G=1,le.unit.base){var de=le.unit.base.key;re.auto[de]={unit:le.unit,prefix:le.prefix}}}if(E(),b)throw new SyntaxError('Could not parse: "'+V+'"');if(Y)throw new SyntaxError('Trailing characters: "'+V+'"');if(ve.length!==0)throw new SyntaxError('Unmatched "(" in "'+w+'"');if(se.units.length===0&&!W.allowNoUnits)throw new SyntaxError('"'+V+'" contains no units');return se.value=be!==void 0?se._normalize(be):null,se},h.prototype.clone=function(){var V=new h;V.fixPrefix=this.fixPrefix,V.skipAutomaticSimplification=this.skipAutomaticSimplification,V.value=Ge(this.value),V.dimensions=this.dimensions.slice(0),V.units=[];for(var W=0;W<this.units.length;W++){V.units[W]={};for(var se in this.units[W])Re(this.units[W],se)&&(V.units[W][se]=this.units[W][se])}return V},h.prototype.valueType=function(){return br(this.value)},h.prototype._isDerived=function(){return this.units.length===0?!1:this.units.length>1||Math.abs(this.units[0].power-1)>1e-15},h.prototype._normalize=function(V){if(V==null||this.units.length===0)return V;for(var W=V,se=h._getNumberConverter(br(V)),G=0;G<this.units.length;G++){var Y=se(this.units[G].unit.value),te=se(this.units[G].prefix.value),be=se(this.units[G].power);W=i(W,f(i(Y,te),be))}return W},h.prototype._denormalize=function(V,W){if(V==null||this.units.length===0)return V;for(var se=V,G=h._getNumberConverter(br(V)),Y=0;Y<this.units.length;Y++){var te=G(this.units[Y].unit.value),be=G(this.units[Y].prefix.value),ve=G(this.units[Y].power);se=o(se,f(i(te,be),ve))}return se};var R=Va(V=>{if(Re(U,V)){var W=U[V],se=W.prefixes[""];return{unit:W,prefix:se}}for(var G in U)if(Re(U,G)&&Eg(V,G)){var Y=U[G],te=V.length-G.length,be=V.substring(0,te),ve=Re(Y.prefixes,be)?Y.prefixes[be]:void 0;if(ve!==void 0)return{unit:Y,prefix:ve}}return null},{hasher:V=>V[0],limit:100});h.isValuelessUnit=function(V){return R(V)!==null},h.prototype.hasBase=function(V){if(typeof V=="string"&&(V=$[V]),!V)return!1;for(var W=0;W<H.length;W++)if(Math.abs((this.dimensions[W]||0)-(V.dimensions[W]||0))>1e-12)return!1;return!0},h.prototype.equalBase=function(V){for(var W=0;W<H.length;W++)if(Math.abs((this.dimensions[W]||0)-(V.dimensions[W]||0))>1e-12)return!1;return!0},h.prototype.equals=function(V){return this.equalBase(V)&&c(this.value,V.value)},h.prototype.multiply=function(V){for(var W=this.clone(),se=Vt(V)?V:new h(V),G=0;G<H.length;G++)W.dimensions[G]=(this.dimensions[G]||0)+(se.dimensions[G]||0);for(var Y=0;Y<se.units.length;Y++){var te=bs({},se.units[Y]);W.units.push(te)}if(this.value!==null||se.value!==null){var be=this.value===null?this._normalize(1):this.value,ve=se.value===null?se._normalize(1):se.value;W.value=i(be,ve)}else W.value=null;return Vt(V)&&(W.skipAutomaticSimplification=!1),M(W)},h.prototype.divideInto=function(V){return new h(V).divide(this)},h.prototype.divide=function(V){for(var W=this.clone(),se=Vt(V)?V:new h(V),G=0;G<H.length;G++)W.dimensions[G]=(this.dimensions[G]||0)-(se.dimensions[G]||0);for(var Y=0;Y<se.units.length;Y++){var te=bs(bs({},se.units[Y]),{},{power:-se.units[Y].power});W.units.push(te)}if(this.value!==null||se.value!==null){var be=this.value===null?this._normalize(1):this.value,ve=se.value===null?se._normalize(1):se.value;W.value=o(be,ve)}else W.value=null;return Vt(V)&&(W.skipAutomaticSimplification=!1),M(W)},h.prototype.pow=function(V){for(var W=this.clone(),se=0;se<H.length;se++)W.dimensions[se]=(this.dimensions[se]||0)*V;for(var G=0;G<W.units.length;G++)W.units[G].power*=V;return W.value!==null?W.value=f(W.value,V):W.value=null,W.skipAutomaticSimplification=!1,M(W)};function M(V){return V.equalBase($.NONE)&&V.value!==null&&!t.predictable?V.value:V}h.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 W=V._numberConverter(),se=W(V.units[0].unit.value),G=W(V.units[0].unit.offset),Y=i(se,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=U.W);return V},h.prototype.to=function(V){var W=this.value===null?this._normalize(1):this.value,se;if(typeof V=="string")se=h.parse(V);else if(Vt(V))se=V.clone();else throw new Error("String or Unit expected as parameter");if(!this.equalBase(se))throw new Error("Units do not match ('".concat(se.toString(),"' != '").concat(this.toString(),"')"));if(se.value!==null)throw new Error("Cannot convert to a unit with a value");if(this.value===null||this._isDerived()||this.units[0].unit.offset===se.units[0].unit.offset)se.value=Ge(W);else{var G=h._getNumberConverter(br(W)),Y=G(this.units[0].unit.value),te=G(this.units[0].unit.offset),be=i(Y,te),ve=G(se.units[0].unit.value),z=G(se.units[0].unit.offset),L=i(ve,z);se.value=n(a(W,be),L)}return se.fixPrefix=!0,se.skipAutomaticSimplification=!0,se},h.prototype.toNumber=function(V){return N(this.toNumeric(V))},h.prototype.toNumeric=function(V){var W;return V?W=this.to(V):W=this.clone(),W._isDerived()||W.units.length===0?W._denormalize(W.value):W._denormalize(W.value,W.units[0].prefix.value)},h.prototype.toString=function(){return this.format()},h.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.formatUnits(),fixPrefix:this.fixPrefix}},h.fromJSON=function(V){var W=new h(V.value,V.unit);return W.fixPrefix=V.fixPrefix||!1,W},h.prototype.valueOf=h.prototype.toString,h.prototype.simplify=function(){var V=this.clone(),W=[],se;for(var G in me)if(Re(me,G)&&V.hasBase($[G])){se=G;break}if(se==="NONE")V.units=[];else{var Y;if(se&&Re(me,se)&&(Y=me[se]),Y)V.units=[{unit:Y.unit,prefix:Y.prefix,power:1}];else{for(var te=!1,be=0;be<H.length;be++){var ve=H[be];Math.abs(V.dimensions[be]||0)>1e-12&&(Re(me,ve)?W.push({unit:me[ve].unit,prefix:me[ve].prefix,power:V.dimensions[be]||0}):te=!0)}W.length<V.units.length&&!te&&(V.units=W)}}return V},h.prototype.toSI=function(){for(var V=this.clone(),W=[],se=0;se<H.length;se++){var G=H[se];if(Math.abs(V.dimensions[se]||0)>1e-12)if(Re(re.si,G))W.push({unit:re.si[G].unit,prefix:re.si[G].prefix,power:V.dimensions[se]||0});else throw new Error("Cannot express custom unit "+G+" in SI units")}return V.units=W,V.fixPrefix=!0,V.skipAutomaticSimplification=!0,V},h.prototype.formatUnits=function(){for(var V="",W="",se=0,G=0,Y=0;Y<this.units.length;Y++)this.units[Y].power>0?(se++,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&&(se>0?(W+=" "+this.units[te].prefix.name+this.units[te].unit.name,Math.abs(this.units[te].power+1)>1e-15&&(W+="^"+-this.units[te].power)):(W+=" "+this.units[te].prefix.name+this.units[te].unit.name,W+="^"+this.units[te].power));V=V.substr(1),W=W.substr(1),se>1&&G>0&&(V="("+V+")"),G>1&&se>0&&(W="("+W+")");var be=V;return se>0&&G>0&&(be+=" / "),be+=W,be},h.prototype.format=function(V){var W=this.skipAutomaticSimplification||this.value===null?this.clone():this.simplify(),se=!1;typeof W.value<"u"&&W.value!==null&&kt(W.value)&&(se=Math.abs(W.value.re)<1e-14);for(var G in W.units)Re(W.units,G)&&W.units[G].unit&&(W.units[G].unit.name==="VA"&&se?W.units[G].unit=U.VAR:W.units[G].unit.name==="VAR"&&!se&&(W.units[G].unit=U.VA));W.units.length===1&&!W.fixPrefix&&Math.abs(W.units[0].power-Math.round(W.units[0].power))<1e-14&&(W.units[0].prefix=W._bestPrefix());var Y=W._denormalize(W.value),te=W.value!==null?v(Y,V||{}):"",be=W.formatUnits();return W.value&&kt(W.value)&&(te="("+te+")"),be.length>0&&te.length>0&&(te+=" "),te+=be,te},h.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,W=l(this.units[0].unit.value),se=this.units[0].prefix;if(V===0)return se;var G=this.units[0].power,Y=Math.log(V/Math.pow(se.value*W,G))/Math.LN10-1.2;if(Y>-2.200001&&Y<1.800001)return se;Y=Math.abs(Y);var te=this.units[0].unit.prefixes;for(var be in te)if(Re(te,be)){var ve=te[be];if(ve.scientific){var z=Math.abs(Math.log(V/Math.pow(ve.value*W,G))/Math.LN10-1.2);(z<Y||z===Y&&ve.name.length<se.name.length)&&(se=ve,Y=z)}}return se},h.prototype.splitUnit=function(V){for(var W=this.clone(),se=[],G=0;G<V.length&&(W=W.to(V[G]),G!==V.length-1);G++){var Y=W.toNumeric(),te=s(Y),be=void 0,ve=c(te,Y);ve?be=te:be=u(W.toNumeric());var z=new h(be,V[G].toString());se.push(z),W=n(W,z)}for(var L=0,ee=0;ee<se.length;ee++)L=a(L,se[ee].value);return c(L,this.value)&&(W.value=0),se.push(W),se};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)},U={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 W=ys(g);U.rad.value=new g(1),U.deg.value=W.div(180),U.grad.value=W.div(200),U.cycle.value=W.times(2),U.arcsec.value=W.div(648e3),U.arcmin.value=W.div(10800)}else U.rad.value=1,U.deg.value=Math.PI/180,U.grad.value=Math.PI/200,U.cycle.value=Math.PI*2,U.arcsec.value=Math.PI/648e3,U.arcmin.value=Math.PI/10800;U.radian.value=U.rad.value,U.degree.value=U.deg.value,U.gradian.value=U.grad.value}ae(t),e&&e("config",function(V,W){V.number!==W.number&&ae(V)});var re={si:{NONE:{unit:K,prefix:F.NONE[""]},LENGTH:{unit:U.m,prefix:F.SHORT[""]},MASS:{unit:U.g,prefix:F.SHORT.k},TIME:{unit:U.s,prefix:F.SHORT[""]},CURRENT:{unit:U.A,prefix:F.SHORT[""]},TEMPERATURE:{unit:U.K,prefix:F.SHORT[""]},LUMINOUS_INTENSITY:{unit:U.cd,prefix:F.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:U.mol,prefix:F.SHORT[""]},ANGLE:{unit:U.rad,prefix:F.SHORT[""]},BIT:{unit:U.bits,prefix:F.SHORT[""]},FORCE:{unit:U.N,prefix:F.SHORT[""]},ENERGY:{unit:U.J,prefix:F.SHORT[""]},POWER:{unit:U.W,prefix:F.SHORT[""]},PRESSURE:{unit:U.Pa,prefix:F.SHORT[""]},ELECTRIC_CHARGE:{unit:U.C,prefix:F.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:U.F,prefix:F.SHORT[""]},ELECTRIC_POTENTIAL:{unit:U.V,prefix:F.SHORT[""]},ELECTRIC_RESISTANCE:{unit:U.ohm,prefix:F.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:U.H,prefix:F.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:U.S,prefix:F.SHORT[""]},MAGNETIC_FLUX:{unit:U.Wb,prefix:F.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:U.T,prefix:F.SHORT[""]},FREQUENCY:{unit:U.Hz,prefix:F.SHORT[""]}}};re.cgs=JSON.parse(JSON.stringify(re.si)),re.cgs.LENGTH={unit:U.m,prefix:F.SHORT.c},re.cgs.MASS={unit:U.g,prefix:F.SHORT[""]},re.cgs.FORCE={unit:U.dyn,prefix:F.SHORT[""]},re.cgs.ENERGY={unit:U.erg,prefix:F.NONE[""]},re.us=JSON.parse(JSON.stringify(re.si)),re.us.LENGTH={unit:U.ft,prefix:F.NONE[""]},re.us.MASS={unit:U.lbm,prefix:F.NONE[""]},re.us.TEMPERATURE={unit:U.degF,prefix:F.NONE[""]},re.us.FORCE={unit:U.lbf,prefix:F.NONE[""]},re.us.ENERGY={unit:U.BTU,prefix:F.BTU[""]},re.us.POWER={unit:U.hp,prefix:F.NONE[""]},re.us.PRESSURE={unit:U.psi,prefix:F.NONE[""]},re.auto=JSON.parse(JSON.stringify(re.si));var me=re.auto;h.setUnitSystem=function(V){if(Re(re,V))me=re[V];else throw new Error("Unit system "+V+" does not exist. Choices are: "+Object.keys(re).join(", "))},h.getUnitSystem=function(){for(var V in re)if(Re(re,V)&&re[V]===me)return V},h.typeConverters={BigNumber:function(W){return new g(W+"")},Fraction:function(W){return new y(W)},Complex:function(W){return W},number:function(W){return W}},h.prototype._numberConverter=function(){var V=h.typeConverters[this.valueType()];if(V)return V;throw new TypeError('Unsupported Unit value type "'+this.valueType()+'"')},h._getNumberConverter=function(V){if(!h.typeConverters[V])throw new TypeError('Unsupported type "'+V+'"');return h.typeConverters[V]};for(var he in U)if(Re(U,he)){var fe=U[he];fe.dimensions=fe.base.dimensions}for(var ie in j)if(Re(j,ie)){var Ae=U[j[ie]],Oe={};for(var Ce in Ae)Re(Ae,Ce)&&(Oe[Ce]=Ae[Ce]);Oe.name=ie,U[ie]=Oe}h.isValidAlpha=function(W){return/^[a-zA-Z]$/.test(W)};function $e(V){for(var W=0;W<V.length;W++){if(b=V.charAt(W),W===0&&!h.isValidAlpha(b))throw new Error('Invalid unit name (must begin with alpha character): "'+V+'"');if(W>0&&!(h.isValidAlpha(b)||S(b)))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+V+'"')}}return h.createUnit=function(V,W){if(typeof V!="object")throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(W&&W.override){for(var se in V)if(Re(V,se)&&h.deleteUnit(se),V[se].aliases)for(var G=0;G<V[se].aliases.length;G++)h.deleteUnit(V[se].aliases[G])}var Y;for(var te in V)Re(V,te)&&(Y=h.createUnitSingle(te,V[te]));return Y},h.createUnitSingle=function(V,W){if((typeof W>"u"||W===null)&&(W={}),typeof V!="string")throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");if(Re(U,V))throw new Error('Cannot create unit "'+V+'": a unit with that name already exists');$e(V);var se=null,G=[],Y=0,te,be,ve;if(W&&W.type==="Unit")se=W.clone();else if(typeof W=="string")W!==""&&(te=W);else if(typeof W=="object")te=W.definition,be=W.prefixes,Y=W.offset,ve=W.baseName,W.aliases&&(G=W.aliases.valueOf());else throw new TypeError('Cannot create unit "'+V+'" from "'+W.toString()+'": expecting "string" or "Unit" or "Object"');if(G){for(var z=0;z<G.length;z++)if(Re(U,G[z]))throw new Error('Cannot create alias "'+G[z]+'": a unit with that name already exists')}if(te&&typeof te=="string"&&!se)try{se=h.parse(te,{allowNoUnits:!0})}catch(mr){throw mr.message='Could not create unit "'+V+'" from "'+te+'": '+mr.message,mr}else te&&te.type==="Unit"&&(se=te.clone());G=G||[],Y=Y||0,be&&be.toUpperCase?be=F[be.toUpperCase()]||F.NONE:be=F.NONE;var L={};if(se){L={name:V,value:se.value,dimensions:se.dimensions.slice(0),prefixes:be,offset:Y};var ge=!1;for(var xe in $)if(Re($,xe)){for(var de=!0,Ne=0;Ne<H.length;Ne++)if(Math.abs((L.dimensions[Ne]||0)-($[xe].dimensions[Ne]||0))>1e-12){de=!1;break}if(de){ge=!0,L.base=$[xe];break}}if(!ge){ve=ve||V+"_STUFF";var _e={dimensions:se.dimensions.slice(0)};_e.key=ve,$[ve]=_e,me[ve]={unit:L,prefix:F.NONE[""]},L.base=$[ve]}}else{if(ve=ve||V+"_STUFF",H.indexOf(ve)>=0)throw new Error('Cannot create new base unit "'+V+'": a base unit with that name already exists (and cannot be overridden)');H.push(ve);for(var ee in $)Re($,ee)&&($[ee].dimensions[H.length-1]=0);for(var le={dimensions:[]},pe=0;pe<H.length;pe++)le.dimensions[pe]=0;le.dimensions[H.length-1]=1,le.key=ve,$[ve]=le,L={name:V,value:1,dimensions:$[ve].dimensions.slice(0),prefixes:be,offset:Y,base:$[ve]},me[ve]={unit:L,prefix:F.NONE[""]}}h.UNITS[V]=L;for(var Ue=0;Ue<G.length;Ue++){var Be=G[Ue],ar={};for(var Je in L)Re(L,Je)&&(ar[Je]=L[Je]);ar.name=Be,h.UNITS[Be]=ar}return delete R.cache,new h(null,V)},h.deleteUnit=function(V){delete h.UNITS[V]},h.PREFIXES=F,h.BASE_DIMENSIONS=H,h.BASE_UNITS=$,h.UNIT_SYSTEMS=re,h.UNITS=U,h},{isClass:!0}),dv="unit",OD=["typed","Unit"],ID=q(dv,OD,r=>{var{typed:e,Unit:t}=r;return e(dv,{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))})}),hv="sparse",RD=["typed","SparseMatrix"],_D=q(hv,RD,r=>{var{typed:e,SparseMatrix:t}=r;return e(hv,{"":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)}})}),gv="createUnit",qD=["typed","Unit"],zD=q(gv,qD,r=>{var{typed:e,Unit:t}=r;return e(gv,{"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,{})}})}),yv="acos",PD=["typed","config","Complex"],LD=q(yv,PD,r=>{var{typed:e,config:t,Complex:a}=r;return e(yv,{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()}})}),bv="acosh",UD=["typed","config","Complex"],kD=q(bv,UD,r=>{var{typed:e,config:t,Complex:a}=r;return e(bv,{number:function(i){return i>=1||t.predictable?Oc(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()}})}),xv="acot",VD=["typed","BigNumber"],GD=q(xv,VD,r=>{var{typed:e,BigNumber:t}=r;return e(xv,{number:Ic,Complex:function(n){return n.acot()},BigNumber:function(n){return new t(1).div(n).atan()}})}),wv="acoth",HD=["typed","config","Complex","BigNumber"],ZD=q(wv,HD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(wv,{number:function(o){return o>=1||o<=-1||t.predictable?Rc(o):new a(o,0).acoth()},Complex:function(o){return o.acoth()},BigNumber:function(o){return new n(1).div(o).atanh()}})}),Nv="acsc",JD=["typed","config","Complex","BigNumber"],WD=q(Nv,JD,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).acsc()},Complex:function(o){return o.acsc()},BigNumber:function(o){return new n(1).div(o).asin()}})}),Dv="acsch",XD=["typed","BigNumber"],YD=q(Dv,XD,r=>{var{typed:e,BigNumber:t}=r;return e(Dv,{number:qc,Complex:function(n){return n.acsch()},BigNumber:function(n){return new t(1).div(n).asinh()}})}),Av="asec",QD=["typed","config","Complex","BigNumber"],KD=q(Av,QD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(Av,{number:function(o){return o<=-1||o>=1||t.predictable?zc(o):new a(o,0).asec()},Complex:function(o){return o.asec()},BigNumber:function(o){return new n(1).div(o).acos()}})}),Ev="asech",jD=["typed","config","Complex","BigNumber"],eA=q(Ev,jD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(Ev,{number:function(o){if(o<=1&&o>=-1||t.predictable){var f=1/o;if(f>0||t.predictable)return Pc(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()}})}),Sv="asin",rA=["typed","config","Complex"],tA=q(Sv,rA,r=>{var{typed:e,config:t,Complex:a}=r;return e(Sv,{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()}})}),nA="asinh",aA=["typed"],iA=q(nA,aA,r=>{var{typed:e}=r;return e("asinh",{number:Lc,Complex:function(a){return a.asinh()},BigNumber:function(a){return a.asinh()}})}),oA="atan",sA=["typed"],uA=q(oA,sA,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()}})}),Cv="atan2",lA=["typed","matrix","equalScalar","BigNumber","DenseMatrix","concat"],cA=q(Cv,lA,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=qf({typed:e,equalScalar:a}),s=Ur({typed:e,equalScalar:a}),c=Ir({typed:e,DenseMatrix:i}),m=hr({typed:e,matrix:t,concat:o});return e(Cv,{"number, number":Math.atan2,"BigNumber, BigNumber":(v,d)=>n.atan2(v,d)},m({scalar:"number | BigNumber",SS:u,DS:l,SD:f,Ss:s,sS:c}))}),Mv="atanh",fA=["typed","config","Complex"],mA=q(Mv,fA,r=>{var{typed:e,config:t,Complex:a}=r;return e(Mv,{number:function(i){return i<=1&&i>=-1||t.predictable?Uc(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)})}}),Fv="cos",vA=["typed"],pA=q(Fv,vA,r=>{var{typed:e}=r,t=fa({typed:e});return e(Fv,{number:Math.cos,"Complex | BigNumber":a=>a.cos()},t)}),Tv="cosh",dA=["typed"],hA=q(Tv,dA,r=>{var{typed:e}=r;return e(Tv,{number:yg,"Complex | BigNumber":t=>t.cosh()})}),Bv="cot",gA=["typed","BigNumber"],yA=q(Bv,gA,r=>{var{typed:e,BigNumber:t}=r,a=fa({typed:e});return e(Bv,{number:kc,Complex:n=>n.cot(),BigNumber:n=>new t(1).div(n.tan())},a)}),$v="coth",bA=["typed","BigNumber"],xA=q($v,bA,r=>{var{typed:e,BigNumber:t}=r;return e($v,{number:Vc,Complex:a=>a.coth(),BigNumber:a=>new t(1).div(a.tanh())})}),Ov="csc",wA=["typed","BigNumber"],NA=q(Ov,wA,r=>{var{typed:e,BigNumber:t}=r,a=fa({typed:e});return e(Ov,{number:Gc,Complex:n=>n.csc(),BigNumber:n=>new t(1).div(n.sin())},a)}),Iv="csch",DA=["typed","BigNumber"],AA=q(Iv,DA,r=>{var{typed:e,BigNumber:t}=r;return e(Iv,{number:Hc,Complex:a=>a.csch(),BigNumber:a=>new t(1).div(a.sinh())})}),Rv="sec",EA=["typed","BigNumber"],SA=q(Rv,EA,r=>{var{typed:e,BigNumber:t}=r,a=fa({typed:e});return e(Rv,{number:Zc,Complex:n=>n.sec(),BigNumber:n=>new t(1).div(n.cos())},a)}),_v="sech",CA=["typed","BigNumber"],MA=q(_v,CA,r=>{var{typed:e,BigNumber:t}=r;return e(_v,{number:Jc,Complex:a=>a.sech(),BigNumber:a=>new t(1).div(a.cosh())})}),qv="sin",FA=["typed"],TA=q(qv,FA,r=>{var{typed:e}=r,t=fa({typed:e});return e(qv,{number:Math.sin,"Complex | BigNumber":a=>a.sin()},t)}),zv="sinh",BA=["typed"],$A=q(zv,BA,r=>{var{typed:e}=r;return e(zv,{number:Wc,"Complex | BigNumber":t=>t.sinh()})}),Pv="tan",OA=["typed"],IA=q(Pv,OA,r=>{var{typed:e}=r,t=fa({typed:e});return e(Pv,{number:Math.tan,"Complex | BigNumber":a=>a.tan()},t)}),RA="tanh",_A=["typed"],qA=q(RA,_A,r=>{var{typed:e}=r;return e("tanh",{number:xg,"Complex | BigNumber":t=>t.tanh()})}),Lv="setCartesian",zA=["typed","size","subset","compareNatural","Index","DenseMatrix"],PA=q(Lv,zA,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){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 d=0;d<m.length;d++)s.push([c[v],m[d]])}return Array.isArray(l)&&Array.isArray(u)?s:new o(s)}})}),Uv="setDifference",LA=["typed","size","subset","compareNatural","Index","DenseMatrix"],UA=q(Uv,LA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:o}=r;return e(Uv,{"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,d=0;d<c.length;d++){v=!1;for(var p=0;p<m.length;p++)if(n(c[d].value,m[p].value)===0&&c[d].identifier===m[p].identifier){v=!0;break}v||s.push(c[d])}}return Array.isArray(l)&&Array.isArray(u)?yi(s):new o(yi(s))}})}),kv="setDistinct",kA=["typed","size","subset","compareNatural","Index","DenseMatrix"],VA=q(kv,kA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:o}=r;return e(kv,{"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)}})}),Vv="setIntersect",GA=["typed","size","subset","compareNatural","Index","DenseMatrix"],HA=q(Vv,GA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:o}=r;return e(Vv,{"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 d=0;d<m.length;d++)if(n(c[v].value,m[d].value)===0&&c[v].identifier===m[d].identifier){s.push(c[v]);break}}return Array.isArray(l)&&Array.isArray(u)?yi(s):new o(yi(s))}})}),Gv="setIsSubset",ZA=["typed","size","subset","compareNatural","Index"],JA=q(Gv,ZA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(Gv,{"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}})}),Hv="setMultiplicity",WA=["typed","size","subset","compareNatural","Index"],XA=q(Hv,WA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(Hv,{"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}})}),Zv="setPowerset",YA=["typed","size","subset","compareNatural","Index"],QA=q(Zv,YA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(Zv,{"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}}),Jv="setSize",KA=["typed","compareNatural"],jA=q(Jv,KA,r=>{var{typed:e,compareNatural:t}=r;return e(Jv,{"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}})}),Wv="setSymDifference",eE=["typed","size","concat","subset","setDifference","Index"],rE=q(Wv,eE,r=>{var{typed:e,size:t,concat:a,subset:n,setDifference:i,Index:o}=r;return e(Wv,{"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))}})}),Xv="setUnion",tE=["typed","size","concat","subset","setIntersect","setSymDifference","Index"],nE=q(Xv,tE,r=>{var{typed:e,size:t,concat:a,subset:n,setIntersect:i,setSymDifference:o,Index:f}=r;return e(Xv,{"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))}})}),Yv="add",aE=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],iE=q(Yv,aE,r=>{var{typed:e,matrix:t,addScalar:a,equalScalar:n,DenseMatrix:i,SparseMatrix:o,concat:f}=r,l=mn({typed:e}),u=ms({typed:e,equalScalar:n}),s=Tn({typed:e,DenseMatrix:i}),c=hr({typed:e,matrix:t,concat:f});return e(Yv,{"any, any":a,"any, any, ...any":e.referToSelf(m=>(v,d,p)=>{for(var g=m(v,d),y=0;y<p.length;y++)g=m(g,p[y]);return g})},c({elop:a,DS:l,SS:u,Ss:s}))}),Qv="hypot",oE=["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],sE=q(Qv,oE,r=>{var{typed:e,abs:t,addScalar:a,divideScalar:n,multiplyScalar:i,sqrt:o,smaller:f,isPositive:l}=r;return e(Qv,{"... 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 d=t(s[v]);f(m,d)?(c=i(c,i(n(m,d),n(m,d))),c=a(c,1),m=d):c=a(c,l(d)?i(n(d,m),n(d,m)):d)}return i(m,o(c))}}),Kv="norm",uE=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],lE=q(Kv,uE,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(Kv,{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 d(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 d(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 h(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 h(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")}}}),jv="dot",cE=["typed","addScalar","multiplyScalar","conj","size"],fE=q(jv,cE,r=>{var{typed:e,addScalar:t,multiplyScalar:a,conj:n,size:i}=r;return e(jv,{"Array | DenseMatrix, Array | DenseMatrix":f,"SparseMatrix, SparseMatrix":l});function o(s,c){var m=u(s),v=u(c),d,p;if(m.length===1)d=m[0];else if(m.length===2&&m[1]===1)d=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(d!==p)throw new RangeError("Vectors must have equal length ("+d+" != "+p+")");if(d===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return d}function f(s,c){var m=o(s,c),v=Ve(s)?s._data:s,d=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,h=t,w=a;if(d&&g&&d===g&&typeof d=="string"){var x=d;h=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=h(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=h(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=h(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=h(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,d=c._index,p=c._values,g=0,y=t,N=a,h=0,w=0;h<m.length&&w<d.length;){var x=m[h],b=d[w];if(x<b){h++;continue}if(x>b){w++;continue}x===b&&(g=y(g,N(v[h],p[w])),h++,w++)}return g}function u(s){return Ve(s)?s.size():i(s)}}),mE="trace",vE=["typed","matrix","add"],pE=q(mE,vE,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 d=0;d<m;d++)for(var p=u[d],g=u[d+1],y=p;y<g;y++){var N=l[y];if(N===d){v=a(v,f[y]);break}if(N>d)break}return v}throw new RangeError("Matrix must be square (size: "+Ye(s)+")")}}),ep="index",dE=["typed","Index"],hE=q(ep,dE,r=>{var{typed:e,Index:t}=r;return e(ep,{"...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}})}),rp=new Set(["end"]),gE="Node",yE=["mathWithTransform"],bE=q(gE,yE,r=>{var{mathWithTransform:e}=r;function t(n){for(var i of[...rp])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&&La(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 tp(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 Hi="AccessorNode",xE=["subset","Node"],wE=q(Hi,xE,r=>{var{subset:e,Node:t}=r,a=tp({subset:e});function n(o){return!(Sn(o)||ot(o)||ir(o)||nn(o)||fi(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 Hi}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,d,p){return lt(u(v,d,p),c)}}else return function(v,d,p){var g=u(v,d,p),y=s(v,d,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:Hi,object:this.object,index:this.index}}static fromJSON(f){return new i(f.object,f.index)}}return zr(i,"name",Hi),i},{isClass:!0,isNode:!0}),Zi="ArrayNode",NE=["Node"],DE=q(Zi,NE,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 Zi}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:Zi,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",Zi),t},{isClass:!0,isNode:!0});function AE(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 Ji(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=Ji(n.args[0],e);!(ir(l)&&a&&a.getIdentifier()==="OperatorNode:divide"&&Vo(Ji(a.args[0],e)))&&!(l.getIdentifier()==="OperatorNode:divide"&&Vo(Ji(l.args[0],e))&&ir(Ji(l.args[1])))&&(o+=1)}return o}function Wa(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 xs(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 EE(r){var e="OperatorNode:"+r;for(var t of Nt)if(e in t)return t[e].op;return null}var Wi="AssignmentNode",SE=["subset","?matrix","Node"],CE=q(Wi,SE,r=>{var{subset:e,matrix:t,Node:a}=r,n=tp({subset:e}),i=AE({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 Wi}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),d=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(d,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(d,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:Wi,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",Wi),f},{isClass:!0,isNode:!0}),Xi="BlockNode",ME=["ResultSet","Node"],FE=q(Xi,ME,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(d){var p=d.evaluate(u,s,c);d.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
- `)}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}),Yi="ConditionalNode",TE=["Node"],BE=q(Yi,TE,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 Yi}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:Yi,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",Yi),a},{isClass:!0,isNode:!0}),ws=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},$E={"{":"\\{","}":"\\}","\\":"\\textbackslash{}","#":"\\#",$:"\\$","%":"\\%","&":"\\&","^":"\\textasciicircum{}",_:"\\_","~":"\\textasciitilde{}"},OE={"\u2013":"\\--","\u2014":"\\---"," ":"~"," ":"\\qquad{}","\r\n":"\\newline{}","\n":"\\newline{}"},IE=function(e,t){return ws({},e,t)},RE=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?IE:n,o=String(r),f="",l=i(ws({},$E),a?ws({},OE):{}),u=Object.keys(l),s=function(){var m=!1;u.forEach(function(v,d){m||o.length>=v.length&&o.slice(0,v.length)===v&&(f+=l[u[d]],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 _E=RE;var Ns={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"},np={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(Ns.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)"}},qE="\\mathrm{${name}}\\left(${args}\\right)",ap={deg:"^\\circ"};function Ds(r){return _E(r,{preserveFormatting:!0})}function ip(r,e){return e=typeof e>"u"?!1:e,e?Re(ap,r)?ap[r]:"\\mathrm{"+Ds(r)+"}":Re(Ns,r)?Ns[r]:Ds(r)}var Qi="ConstantNode",zE=["Node"],PE=q(Qi,zE,r=>{var{Node:e}=r;class t extends e{constructor(n){super(),this.value=n}get type(){return Qi}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:Qi,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{"+Ds(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",Qi),t},{isClass:!0,isNode:!0}),Ki="FunctionAssignmentNode",LE=["typed","Node"],UE=q(Ki,LE,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(rp.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 Ki}get isFunctionAssignmentNode(){return!0}_compile(o,f){var l=Object.create(f);hi(this.params,function(d){l[d]=!0});var u=this.expr._compile(o,l),s=this.name,c=this.params,m=Fl(this.types,","),v=s+"("+Fl(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 h=e(s,N);return h.syntax=v,p.set(s,h),h}}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:Ki,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(ip).join(",")+"\\right):="+l}}return zr(n,"name",Ki),n},{isClass:!0,isNode:!0}),ji="IndexNode",kE=["Node","size"],VE=q(ji,kE,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 ji}get isIndexNode(){return!0}_compile(i,o){var f=Ht(this.dimensions,function(u,s){var c=u.filter(d=>d.isSymbolNode&&d.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)&&!Xr(y))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+br(y));var N=t(y).valueOf(),h=Object.create(g);return h.end=N[s],v(p,h,y)}}else return u._compile(i,o)}),l=lt(i,"index");return function(s,c,m){var v=Ht(f,function(d){return d(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:ji,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",ji),a},{isClass:!0,isNode:!0}),eo="ObjectNode",GE=["Node"],HE=q(eo,GE,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 eo}get isObjectNode(){return!0}_compile(n,i){var o={};for(var f in this.properties)if(Re(this.properties,f)){var l=pi(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 d={};for(var p in o)Re(o,p)&&(d[p]=o[p](c,m,v));return d}}forEach(n){for(var i in this.properties)Re(this.properties,i)&&n(this.properties[i],"properties["+pi(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["+pi(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(pi(o)+": "+this.properties[o].toString(n));return"{"+i.join(", ")+"}"}toJSON(){return{mathjs:eo,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",eo),t},{isClass:!0,isNode:!0}),ro="OperatorNode",ZE=["Node"],JE=q(ro,ZE,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=Wa(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 d,p;if(o==="keep"?(d=l[0].getIdentifier(),p=i.getIdentifier()):(d=l[0].getContent().getIdentifier(),p=i.getContent().getIdentifier()),Nt[s][p].latexLeftParens===!1){m=[!1];break}if(Nt[v][d].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=xs(i,l[0],o);y===null?g=!1:y===s&&c==="right"&&!N||y<s?g=!0:g=!1;var h,w=pr(l[1],o,f,i),x=xs(i,l[1],o);if(w===null?h=!1:w===s&&c==="left"&&!x||w<s?h=!0:h=!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&&(h=!1),Nt[w][A].latexParens===!1&&(h=!1))}m=[g,h]}break;default:(i.getIdentifier()==="OperatorNode:add"||i.getIdentifier()==="OperatorNode:multiply")&&(m=l.map(function(D){var T=pr(D,o,f,i),B=xs(i,D,o),I=Wa(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 ro}get isOperatorNode(){return!0}_compile(o,f){if(typeof this.fn!="string"||!Yo(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(d,p,g){return l(s(d,p,g))}}else if(u.length===2){var c=u[0],m=u[1];return function(d,p,g){return l(c(d,p,g),m(d,p,g))}}else return function(d,p,g){return l.apply(null,Ht(u,function(y){return y(d,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=Wa(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 d=u[0].toString(o),p=u[1].toString(o);return s[0]&&(d="("+d+")"),s[1]&&(p="("+p+")"),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?d+" "+p:d+" "+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:ro,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=Wa(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),d=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]&&(d='<span class="math-parenthesis math-round-parenthesis">(</span>'+d+'<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>'+d:v+'<span class="math-operator math-binary-operator math-explicit-binary-operator">'+ut(this.op)+"</span>"+d}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=Wa(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 d=u[0],p=d.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=d.getIdentifier():N=d.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 h=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"?h.join("~"):h.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",ro),n},{isClass:!0,isNode:!0}),to="ParenthesisNode",WE=["Node"],XE=q(to,WE,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 to}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:to,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",to),t},{isClass:!0,isNode:!0}),no="RangeNode",YE=["Node"],QE=q(no,YE,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 no}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,d){return f(l(m,v,d),u(m,v,d),s(m,v,d))}}else return function(m,v,d){return f(l(m,v,d),u(m,v,d))}}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:no,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",no),a},{isClass:!0,isNode:!0}),ao="RelationalNode",KE=["Node"],jE=q(ao,KE,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 ao}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,d=l[0](s,c,m),p=0;p<f.conditionals.length;p++){v=d,d=l[p+1](s,c,m);var g=lt(i,f.conditionals[p]);if(!g(v,d))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:ao,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",ao),a},{isClass:!0,isNode:!0}),eS="SymbolNode",rS=["math","?Unit","Node"],tS=q(eS,rS,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=ip(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"?Bl(r.createSubScope(),...t):Bl(ea(),r,...t)}var io="FunctionNode",nS=["math","Node","SymbolNode"],aS=q(io,nS,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 d=l[v[1]];if(!d)throw new ReferenceError("Template: Property "+v[1]+" does not exist.");if(v[2]===void 0)switch(typeof d){case"string":s+=d;break;case"object":if(fr(d))s+=d.toTex(u);else if(Array.isArray(d))s+=d.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(d[v[2]]&&d[v[2]]))s+=d[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 io}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?lt(l,c):void 0,v=typeof m=="function"&&m.rawArgs===!0,d=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=d(A);return T(p,l,Xa(A,S),A)}}else switch(s.length){case 0:return function(A,S,D){var T=d(A);return T()};case 1:return function(A,S,D){var T=d(A),B=s[0];return T(B(A,S,D))};case 2:return function(A,S,D){var T=d(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=d(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(),h=this.args;return function(A,S,D){var T=y(A,S,D);Og(T,N);var B=T[N]&&T[N].rawArgs;if(B)return T[N](h,l,Xa(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,Xa(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:io,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;np[this.name]&&(s=np[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(qE,this,l)}getIdentifier(){return this.type+":"+this.name}}return zr(o,"name",io),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}),op="parse",iS=["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],oS=q(op,iS,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:d,ParenthesisNode:p,RangeNode:g,RelationalNode:y,SymbolNode:N}=r,h=e(op,{string:function(Z){return k(Z,{})},"Array | Matrix":function(Z){return w(Z,{})},"string, Object":function(Z,ue){var Ee=ue.nodes!==void 0?ue.nodes:{};return k(Z,Ee)},"Array | Matrix, Object":w});function w(C){var Z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ue=Z.nodes!==void 0?Z.nodes:{};return je(C,function(Ee){if(typeof Ee!="string")throw new TypeError("String expected");return k(Ee,ue)})}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)!==`
12
+ (`+Ye(A,p)+", "+Ye(w,p)+") ==> "+(this._values?Ye(this._values[E],p):"X")}return h},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],h=this._size[1],w=Math.min(N-y,h-g),x=[],b=[],E=[];E[0]=0;for(var A=g;A<h&&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,h){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;Xr(h)&&(w=e.find(t,[h,h])||t,x=e.convert(0,h));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,h){for(var w=N[p],x=N[p+1],b=w;b<x;b++)h(y[b],g[b])},n._swapRows=function(p,g,y,N,h,w){for(var x=0;x<y;x++){var b=w[x],E=w[x+1],A=u(p,b,E,h),S=u(g,b,E,h);if(A<E&&S<E&&h[A]===p&&h[S]===g){if(N){var D=N[A];N[A]=N[S],N[S]=D}continue}if(A<E&&h[A]===p&&(S>=E||h[S]!==g)){var T=N?N[A]:void 0;h.splice(S,0,g),N&&N.splice(S,0,T),h.splice(S<=A?A+1:A,1),N&&N.splice(S<=A?A+1:A,1);continue}if(S<E&&h[S]===g&&(A>=E||h[A]!==p)){var B=N?N[S]:void 0;h.splice(A,0,p),N&&N.splice(A,0,B),h.splice(A<=S?S+1:S,1),N&&N.splice(A<=S?S+1:S,1)}}},n},{isClass:!0}),Ay="number",Ey=["typed"];function Sy(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]],i=e[2],n=e[3];return{input:r,radix:t,integerPart:i,fractionalPart:n}}else return null}function Cy(r){for(var e=parseInt(r.integerPart,r.radix),t=0,i=0;i<r.fractionalPart.length;i++){var n=parseInt(r.fractionalPart[i],r.radix);t+=n/Math.pow(r.radix,i+1)}var a=e+t;if(isNaN(a))throw new SyntaxError('String "'+r.input+'" is no valid number');return a}var My=q(Ay,Ey,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 a=Sy(n);if(a)return Cy(a);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,a){return n.toNumber(a)},"Array | Matrix":e.referToSelf(i=>n=>je(n,i))});return t.fromJSON=function(i){return parseFloat(i.value)},t}),ef="string",Fy=["typed"],Ty=q(ef,Fy,r=>{var{typed:e}=r;return e(ef,{"":function(){return""},number:Dn,null:function(i){return"null"},boolean:function(i){return i+""},string:function(i){return i},"Array | Matrix":e.referToSelf(t=>i=>je(i,t)),any:function(i){return String(i)}})}),rf="boolean",By=["typed"],$y=q(rf,By,r=>{var{typed:e}=r;return e(rf,{"":function(){return!1},boolean:function(i){return i},number:function(i){return!!i},null:function(i){return!1},BigNumber:function(i){return!i.isZero()},string:function(i){var n=i.toLowerCase();if(n==="true")return!0;if(n==="false")return!1;var a=Number(i);if(i!==""&&!isNaN(a))return!!a;throw new Error('Cannot convert "'+i+'" to a boolean')},"Array | Matrix":e.referToSelf(t=>i=>je(i,t))})}),Oy="bignumber",Iy=["typed","BigNumber"],Ry=q(Oy,Iy,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 a=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(a){var o=a[2],f=t(a[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(i=>n=>je(n,i))})}),_y="complex",qy=["typed","Complex"],zy=q(_y,qy,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,a){return new t(n,a)},"BigNumber, BigNumber":function(n,a){return new t(n.toNumber(),a.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(i=>n=>je(n,i))})}),Py="fraction",Ly=["typed","Fraction"],Uy=q(Py,Ly,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,a){return new t(n,a)},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(i=>n=>je(n,i))})}),tf="matrix",ky=["typed","Matrix","DenseMatrix","SparseMatrix"],Vy=q(tf,ky,r=>{var{typed:e,Matrix:t,DenseMatrix:i,SparseMatrix:n}=r;return e(tf,{"":function(){return a([])},string:function(f){return a([],f)},"string, string":function(f,l){return a([],f,l)},Array:function(f){return a(f)},Matrix:function(f){return a(f,f.storage())},"Array | Matrix, string":a,"Array | Matrix, string, string":a});function a(o,f,l){if(f==="dense"||f==="default"||f===void 0)return new i(o,l);if(f==="sparse")return new n(o,l);throw new TypeError("Unknown matrix type "+JSON.stringify(f)+".")}}),nf="matrixFromFunction",Gy=["typed","matrix","isZero"],Hy=q(nf,Gy,r=>{var{typed:e,matrix:t,isZero:i}=r;return e(nf,{"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(a,o,f,l){var u;return l!==void 0?u=t(f,l):u=t(f),u.resize(a),u.forEach(function(s,c){var m=o(c);i(m)||u.set(c,m)}),u}}),af="matrixFromRows",Zy=["typed","matrix","flatten","size"],Jy=q(af,Zy,r=>{var{typed:e,matrix:t,flatten:i,size:n}=r;return e(af,{"...Array":function(l){return a(l)},"...Matrix":function(l){return t(a(l.map(u=>u.toArray())))}});function a(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)+" ≠ "+(c|0));u.push(i(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.")}}),of="matrixFromColumns",Xy=["typed","matrix","flatten","size"],Wy=q(of,Xy,r=>{var{typed:e,matrix:t,flatten:i,size:n}=r;return e(of,{"...Array":function(l){return a(l)},"...Matrix":function(l){return t(a(l.map(u=>u.toArray())))}});function a(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)+" ≠ "+(m|0));for(var v=i(c),d=0;d<l;d++)u[d].push(v[d])}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.")}}),sf="splitUnit",Yy=["typed"],Qy=q(sf,Yy,r=>{var{typed:e}=r;return e(sf,{"Unit, Array":function(i,n){return i.splitUnit(n)}})}),uf="unaryMinus",Ky=["typed"],jy=q(uf,Ky,r=>{var{typed:e}=r;return e(uf,{number:Ql,"Complex | BigNumber | Fraction":t=>t.neg(),Unit:e.referToSelf(t=>i=>{var n=i.clone();return n.value=e.find(t,n.valueType())(i.value),n}),"Array | Matrix":e.referToSelf(t=>i=>je(i,t))})}),lf="unaryPlus",eb=["typed","config","BigNumber"],rb=q(lf,eb,r=>{var{typed:e,config:t,BigNumber:i}=r;return e(lf,{number:Kl,Complex:function(a){return a},BigNumber:function(a){return a},Fraction:function(a){return a},Unit:function(a){return a.clone()},"Array | Matrix":e.referToSelf(n=>a=>je(a,n)),"boolean | string":function(a){return t.number==="BigNumber"?new i(+a):+a}})}),cf="abs",tb=["typed"],nb=q(cf,tb,r=>{var{typed:e}=r;return e(cf,{number:Xl,"Complex | BigNumber | Fraction | Unit":t=>t.abs(),"Array | Matrix":e.referToSelf(t=>i=>je(i,t))})}),ff="apply",ab=["typed","isInteger"],mf=q(ff,ab,r=>{var{typed:e,isInteger:t}=r;return e(ff,{"Array | Matrix, number | BigNumber, function":function(n,a,o){if(!t(a))throw new TypeError("Integer number expected for dimension");var f=Array.isArray(n)?er(n):n.size();if(a<0||a>=f.length)throw new pt(a,f.length);return Ve(n)?n.create(Ei(n.valueOf(),a,o)):Ei(n,a,o)}})});function Ei(r,e,t){var i,n,a;if(e<=0)if(Array.isArray(r[0])){for(a=ib(r),n=[],i=0;i<a.length;i++)n[i]=Ei(a[i],e-1,t);return n}else return t(r);else{for(n=[],i=0;i<r.length;i++)n[i]=Ei(r[i],e-1,t);return n}}function ib(r){var e=r.length,t=r[0].length,i,n,a=[];for(n=0;n<t;n++){var o=[];for(i=0;i<e;i++)o.push(r[i][n]);a.push(o)}return a}var vf="addScalar",ob=["typed"],sb=q(vf,ob,r=>{var{typed:e}=r;return e(vf,{"number, number":Wl,"Complex, Complex":function(i,n){return i.add(n)},"BigNumber, BigNumber":function(i,n){return i.plus(n)},"Fraction, Fraction":function(i,n){return i.add(n)},"Unit, Unit":e.referToSelf(t=>(i,n)=>{if(i.value===null||i.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(!i.equalBase(n))throw new Error("Units do not match");var a=i.clone();return a.value=e.find(t,[a.valueType(),n.valueType()])(a.value,n.value),a.fixPrefix=!1,a})})}),pf="cbrt",ub=["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],lb=q(pf,ub,r=>{var{config:e,typed:t,isNegative:i,unaryMinus:n,matrix:a,Complex:o,BigNumber:f,Fraction:l}=r;return t(pf,{number:za,Complex:u,"Complex, boolean":u,BigNumber:function(m){return m.cbrt()},Unit:s});function u(c,m){var v=c.arg()/3,d=c.abs(),p=new o(za(d),0).mul(new o(0,v).exp());if(m){var g=[p,new o(za(d),0).mul(new o(0,v+Math.PI*2/3).exp()),new o(za(d),0).mul(new o(0,v-Math.PI*2/3).exp())];return e.matrix==="Array"?g:a(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=i(c.value);v&&(c.value=n(c.value));var d;rr(c.value)?d=new f(1).div(3):Ba(c.value)?d=new l(1,3):d=1/3;var p=c.pow(d);return v&&(p.value=n(p.value)),p}}}),cb="matAlgo11xS0s",fb=["typed","equalScalar"],Ur=q(cb,fb,r=>{var{typed:e,equalScalar:t}=r;return function(n,a,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],d=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),a=e.convert(a,p),N=e.find(o,[p,p]));for(var h=[],w=[],x=[],b=0;b<d;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(a,l[S]):N(l[S],a);g(T,y)||(w.push(D),h.push(T))}}return x[d]=w.length,n.createSparseMatrix({values:h,index:w,ptr:x,size:[v,d],datatype:p})}}),mb="matAlgo12xSfs",vb=["typed","DenseMatrix"],Or=q(mb,vb,r=>{var{typed:e,DenseMatrix:t}=r;return function(n,a,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],d=c[1],p,g=o;typeof m=="string"&&(p=m,a=e.convert(a,p),g=e.find(o,[p,p]));for(var y=[],N=[],h=[],w=0;w<d;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],h[S]=x}for(var D=0;D<v;D++)w===0&&(y[D]=[]),h[D]===x?y[D][w]=f?g(a,N[D]):g(N[D],a):y[D][w]=f?g(a,0):g(0,a)}return new t({data:y,size:[v,d],datatype:p})}}),pb="matAlgo14xDs",db=["typed"],yt=q(pb,db,r=>{var{typed:e}=r;return function(n,a,o,f){var l=n._data,u=n._size,s=n._datatype,c,m=o;typeof s=="string"&&(c=s,a=e.convert(a,c),m=e.find(o,[c,c]));var v=u.length>0?t(m,0,u,u[0],l,a,f):[];return n.createDenseMatrix({data:v,size:Ge(u),datatype:c})};function t(i,n,a,o,f,l,u){var s=[];if(n===a.length-1)for(var c=0;c<o;c++)s[c]=u?i(l,f[c]):i(f[c],l);else for(var m=0;m<o;m++)s[m]=t(i,n+1,a,a[n+1],f[m],l,u);return s}}),fs="ceil",hb=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],gb=q(fs,["typed","config","round"],r=>{var{typed:e,config:t,round:i}=r;return e(fs,{number:function(a){return rt(a,i(a),t.epsilon)?i(a):Math.ceil(a)},"number, number":function(a,o){if(rt(a,i(a,o),t.epsilon))return i(a,o);var[f,l]="".concat(a,"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))}})}),yb=q(fs,hb,r=>{var{typed:e,config:t,round:i,matrix:n,equalScalar:a,zeros:o,DenseMatrix:f}=r,l=Ur({typed:e,equalScalar:a}),u=Or({typed:e,DenseMatrix:f}),s=yt({typed:e}),c=gb({typed:e,config:t,round:i});return e("ceil",{number:c.signatures.number,"number,number":c.signatures["number,number"],Complex:function(v){return v.ceil()},"Complex, number":function(v,d){return v.ceil(d)},"Complex, BigNumber":function(v,d){return v.ceil(d.toNumber())},BigNumber:function(v){return Ft(v,i(v),t.epsilon)?i(v):v.ceil()},"BigNumber, BigNumber":function(v,d){return Ft(v,i(v,d),t.epsilon)?i(v,d):v.toDecimalPlaces(d.toNumber(),on.ROUND_CEIL)},Fraction:function(v){return v.ceil()},"Fraction, number":function(v,d){return v.ceil(d)},"Fraction, BigNumber":function(v,d){return v.ceil(d.toNumber())},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array, number | BigNumber":e.referToSelf(m=>(v,d)=>je(v,p=>m(p,d))),"SparseMatrix, number | BigNumber":e.referToSelf(m=>(v,d)=>l(v,d,m,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(m=>(v,d)=>s(v,d,m,!1)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,d)=>s(n(d),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,d)=>a(v,0)?o(d.size(),d.storage()):d.storage()==="dense"?s(d,v,m,!0):u(d,v,m,!0))})}),df="cube",bb=["typed"],xb=q(df,bb,r=>{var{typed:e}=r;return e(df,{number:jl,Complex:function(i){return i.mul(i).mul(i)},BigNumber:function(i){return i.times(i).times(i)},Fraction:function(i){return i.pow(3)},Unit:function(i){return i.pow(3)}})}),hf="exp",wb=["typed"],Nb=q(hf,wb,r=>{var{typed:e}=r;return e(hf,{number:ec,Complex:function(i){return i.exp()},BigNumber:function(i){return i.exp()}})}),gf="expm1",Db=["typed","Complex"],Ab=q(gf,Db,r=>{var{typed:e,Complex:t}=r;return e(gf,{number:rc,Complex:function(n){var a=Math.exp(n.re);return new t(a*Math.cos(n.im)-1,a*Math.sin(n.im))},BigNumber:function(n){return n.exp().minus(1)}})}),ms="fix",Eb=["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],Sb=q(ms,["typed","ceil","floor"],r=>{var{typed:e,ceil:t,floor:i}=r;return e(ms,{number:function(a){return a>0?i(a):t(a)},"number, number":function(a,o){return a>0?i(a,o):t(a,o)}})}),Cb=q(ms,Eb,r=>{var{typed:e,Complex:t,matrix:i,ceil:n,floor:a,equalScalar:o,zeros:f,DenseMatrix:l}=r,u=Or({typed:e,DenseMatrix:l}),s=yt({typed:e}),c=Sb({typed:e,ceil:n,floor:a});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,d){return new t(v.re>0?a(v.re,d):n(v.re,d),v.im>0?a(v.im,d):n(v.im,d))},"Complex, BigNumber":function(v,d){var p=d.toNumber();return new t(v.re>0?a(v.re,p):n(v.re,p),v.im>0?a(v.im,p):n(v.im,p))},BigNumber:function(v){return v.isNegative()?n(v):a(v)},"BigNumber, number | BigNumber":function(v,d){return v.isNegative()?n(v,d):a(v,d)},Fraction:function(v){return v.s<0?v.ceil():v.floor()},"Fraction, number | BigNumber":function(v,d){return v.s<0?n(v,d):a(v,d)},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array | Matrix, number | BigNumber":e.referToSelf(m=>(v,d)=>je(v,p=>m(p,d))),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,d)=>s(i(d),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,d)=>o(v,0)?f(d.size(),d.storage()):d.storage()==="dense"?s(d,v,m,!0):u(d,v,m,!0))})}),vs="floor",Mb=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],Fb=q(vs,["typed","config","round"],r=>{var{typed:e,config:t,round:i}=r;return e(vs,{number:function(a){return rt(a,i(a),t.epsilon)?i(a):Math.floor(a)},"number, number":function(a,o){if(rt(a,i(a,o),t.epsilon))return i(a,o);var[f,l]="".concat(a,"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))}})}),Tb=q(vs,Mb,r=>{var{typed:e,config:t,round:i,matrix:n,equalScalar:a,zeros:o,DenseMatrix:f}=r,l=Ur({typed:e,equalScalar:a}),u=Or({typed:e,DenseMatrix:f}),s=yt({typed:e}),c=Fb({typed:e,config:t,round:i});return e("floor",{number:c.signatures.number,"number,number":c.signatures["number,number"],Complex:function(v){return v.floor()},"Complex, number":function(v,d){return v.floor(d)},"Complex, BigNumber":function(v,d){return v.floor(d.toNumber())},BigNumber:function(v){return Ft(v,i(v),t.epsilon)?i(v):v.floor()},"BigNumber, BigNumber":function(v,d){return Ft(v,i(v,d),t.epsilon)?i(v,d):v.toDecimalPlaces(d.toNumber(),on.ROUND_FLOOR)},Fraction:function(v){return v.floor()},"Fraction, number":function(v,d){return v.floor(d)},"Fraction, BigNumber":function(v,d){return v.floor(d.toNumber())},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array, number | BigNumber":e.referToSelf(m=>(v,d)=>je(v,p=>m(p,d))),"SparseMatrix, number | BigNumber":e.referToSelf(m=>(v,d)=>l(v,d,m,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(m=>(v,d)=>s(v,d,m,!1)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,d)=>s(n(d),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,d)=>a(v,0)?o(d.size(),d.storage()):d.storage()==="dense"?s(d,v,m,!0):u(d,v,m,!0))})}),Bb="matAlgo01xDSid",$b=["typed"],un=q(Bb,$b,r=>{var{typed:e}=r;return function(i,n,a,o){var f=i._data,l=i._size,u=i._datatype,s=n._values,c=n._index,m=n._ptr,v=n._size,d=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===d?u:void 0,N=y?e.find(a,[y,y]):a,h,w,x=[];for(h=0;h<p;h++)x[h]=[];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++)h=c[T],b[h]=o?N(s[T],f[h][w]):N(f[h][w],s[T]),E[h]=A;for(h=0;h<p;h++)E[h]===A?x[h][w]=b[h]:x[h][w]=f[h][w]}return i.createDenseMatrix({data:x,size:[p,g],datatype:y})}}),Ob="matAlgo04xSidSid",Ib=["typed","equalScalar"],ps=q(Ob,Ib,r=>{var{typed:e,equalScalar:t}=r;return function(n,a,o){var f=n._values,l=n._index,u=n._ptr,s=n._size,c=n._datatype,m=a._values,v=a._index,d=a._ptr,p=a._size,g=a._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],h,w=t,x=0,b=o;typeof c=="string"&&c===g&&(h=c,w=e.find(t,[h,h]),x=e.convert(0,h),b=e.find(o,[h,h]));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=d[R],H=d[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:h})}}),Rb="matAlgo10xSids",_b=["typed","DenseMatrix"],En=q(Rb,_b,r=>{var{typed:e,DenseMatrix:t}=r;return function(n,a,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],d=c[1],p,g=o;typeof m=="string"&&(p=m,a=e.convert(a,p),g=e.find(o,[p,p]));for(var y=[],N=[],h=[],w=0;w<d;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],h[S]=x}for(var D=0;D<v;D++)w===0&&(y[D]=[]),h[D]===x?y[D][w]=f?g(a,N[D]):g(N[D],a):y[D][w]=a}return new t({data:y,size:[v,d],datatype:p})}}),qb="matAlgo13xDD",zb=["typed"],Pb=q(qb,zb,r=>{var{typed:e}=r;return function(n,a,o){var f=n._data,l=n._size,u=n._datatype,s=a._data,c=a._size,m=a._datatype,v=[];if(l.length!==c.length)throw new Ke(l.length,c.length);for(var d=0;d<l.length;d++){if(l[d]!==c[d])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+c+")");v[d]=l[d]}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(i,n,a,o,f,l){var u=[];if(n===a.length-1)for(var s=0;s<o;s++)u[s]=i(f[s],l[s]);else for(var c=0;c<o;c++)u[c]=t(i,n+1,a,a[n+1],f[c],l[c]);return u}}),Lb="broadcast",Ub=["concat"],kb=q(Lb,Ub,r=>{var{concat:e}=r;return function(a,o){var f=Math.max(a._size.length,o._size.length);if(a._size.length===o._size.length&&a._size.every((g,y)=>g===o._size[y]))return[a,o];for(var l=t(a._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=a.clone(),d=o.clone();v._size.length<f?v.reshape(t(v._size,f,1)):d._size.length<f&&d.reshape(t(d._size,f,1));for(var p=0;p<f;p++)v._size[p]<s[p]&&(v=i(v,s[p],p)),d._size[p]<s[p]&&(d=i(d,s[p],p));return[v,d]};function t(a,o,f){return[...Array(o-a.length).fill(f),...a]}function i(a,o,f){return e(...Array(o).fill(a),f)}function n(a,o,f){if(a[f]<o[f]&a[f]>1)throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(a,") not possible to broadcast dimension ").concat(f," with size ").concat(a[f]," to size ").concat(o[f]))}}),Vb="matrixAlgorithmSuite",Gb=["typed","matrix","concat"],hr=q(Vb,Gb,r=>{var{typed:e,matrix:t,concat:i}=r,n=Pb({typed:e}),a=yt({typed:e}),o=kb({concat:i});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)=>a(p,g,u,!1),c[m+", DenseMatrix"]=(p,g)=>a(g,p,u,!0),c["Array,"+m]=(p,g)=>a(t(p),g,u,!1).valueOf(),c[m+", Array"]=(p,g)=>a(t(g),p,u,!0).valueOf()):(c["DenseMatrix,"+m]=e.referToSelf(p=>(g,y)=>a(g,y,p,!1)),c[m+", DenseMatrix"]=e.referToSelf(p=>(g,y)=>a(y,g,p,!0)),c["Array,"+m]=e.referToSelf(p=>(g,y)=>a(t(g),y,p,!1).valueOf()),c[m+", Array"]=e.referToSelf(p=>(g,y)=>a(t(y),g,p,!0).valueOf())));var d=l.sS!==void 0?l.sS:l.Ss;return u?(l.Ss&&(c["SparseMatrix,"+m]=(p,g)=>l.Ss(p,g,u,!1)),d&&(c[m+", SparseMatrix"]=(p,g)=>d(g,p,u,!0))):(l.Ss&&(c["SparseMatrix,"+m]=e.referToSelf(p=>(g,y)=>l.Ss(g,y,p,!1))),d&&(c[m+", SparseMatrix"]=e.referToSelf(p=>(g,y)=>d(y,g,p,!0)))),u&&u.signatures&&ol(c,u.signatures),c}});function Sn(r,e,t,i){if(!(this instanceof Sn))throw new SyntaxError("Constructor must be called with the new operator");this.fn=r,this.count=e,this.min=t,this.max=i,this.message="Wrong number of arguments in function "+r+" ("+e+" provided, "+t+(i!=null?"-"+i:"")+" expected)",this.stack=new Error().stack}Sn.prototype=new Error,Sn.prototype.constructor=Error,Sn.prototype.name="ArgumentsError",Sn.prototype.isArgumentsError=!0;var yf="gcd",Hb=["typed","matrix","equalScalar","BigNumber","DenseMatrix","concat"],ds="number | BigNumber | Fraction | Matrix | Array",Zb="".concat(ds,", ").concat(ds,", ...").concat(ds);function bf(r){return!r.some(e=>Array.isArray(e))}var Jb=q(yf,Hb,r=>{var{typed:e,matrix:t,equalScalar:i,BigNumber:n,DenseMatrix:a,concat:o}=r,f=un({typed:e}),l=ps({typed:e,equalScalar:i}),u=En({typed:e,DenseMatrix:a}),s=hr({typed:e,matrix:t,concat:o});return e(yf,{"number, number":tc,"BigNumber, BigNumber":c,"Fraction, Fraction":(m,v)=>m.gcd(v)},s({SS:l,DS:f,Ss:u}),{[Zb]:e.referToSelf(m=>(v,d,p)=>{for(var g=m(v,d),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])&&bf(v[0]))return m(...v[0]);if(bf(v))return m(...v);throw new Sn("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 d=new n(0);!v.isZero();){var p=m.mod(v);m=v,v=p}return m.lt(d)?m.neg():m}}),Xb="matAlgo02xDS0",Wb=["typed","equalScalar"],bt=q(Xb,Wb,r=>{var{typed:e,equalScalar:t}=r;return function(n,a,o,f){var l=n._data,u=n._size,s=n._datatype,c=a._values,m=a._index,v=a._ptr,d=a._size,p=a._datatype;if(u.length!==d.length)throw new Ke(u.length,d.length);if(u[0]!==d[0]||u[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+d+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var g=u[0],y=u[1],N,h=t,w=0,x=o;typeof s=="string"&&s===p&&(N=s,h=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]);h(P,w)||(E.push(I),b.push(P))}}return A[y]=E.length,a.createSparseMatrix({values:b,index:E,ptr:A,size:[g,y],datatype:N})}}),Yb="matAlgo06xS0S0",Qb=["typed","equalScalar"],Si=q(Yb,Qb,r=>{var{typed:e,equalScalar:t}=r;return function(n,a,o){var f=n._values,l=n._size,u=n._datatype,s=a._values,c=a._size,m=a._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],d=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 h=f&&s?[]:void 0,w=[],x=[],b=h?[]:void 0,E=[],A=[],S=0;S<d;S++){x[S]=w.length;var D=S+1;if(Zl(n,S,E,b,A,D,w,N),Zl(a,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):(h.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[d]=w.length,n.createSparseMatrix({values:h,index:w,ptr:x,size:[v,d],datatype:p})}}),xf="lcm",Kb=["typed","matrix","equalScalar","concat"],jb=q(xf,Kb,r=>{var{typed:e,matrix:t,equalScalar:i,concat:n}=r,a=bt({typed:e,equalScalar:i}),o=Si({typed:e,equalScalar:i}),f=Ur({typed:e,equalScalar:i}),l=hr({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,d,p)=>{for(var g=m(v,d),y=0;y<p.length;y++)g=m(g,p[y]);return g}),e(xf,{"number, number":nc,"BigNumber, BigNumber":c,"Fraction, Fraction":(m,v)=>m.lcm(v)},l({SS:o,DS:a,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 d=m.times(v);!v.isZero();){var p=v;v=m.mod(p),m=p}return d.div(m).abs()}}),wf="log10",ex=["typed","config","Complex"],rx=q(wf,ex,r=>{var{typed:e,config:t,Complex:i}=r;return e(wf,{number:function(a){return a>=0||t.predictable?ac(a):new i(a,0).log().div(Math.LN10)},Complex:function(a){return new i(a).log().div(Math.LN10)},BigNumber:function(a){return!a.isNegative()||t.predictable?a.log():new i(a.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":e.referToSelf(n=>a=>je(a,n))})}),Nf="log2",tx=["typed","config","Complex"],nx=q(Nf,tx,r=>{var{typed:e,config:t,Complex:i}=r;return e(Nf,{number:function(o){return o>=0||t.predictable?ic(o):n(new i(o,0))},Complex:n,BigNumber:function(o){return!o.isNegative()||t.predictable?o.log(2):n(new i(o.toNumber(),0))},"Array | Matrix":e.referToSelf(a=>o=>je(o,a))});function n(a){var o=Math.sqrt(a.re*a.re+a.im*a.im);return new i(Math.log2?Math.log2(o):Math.log(o)/Math.LN2,Math.atan2(a.im,a.re)/Math.LN2)}}),ax="matAlgo03xDSf",ix=["typed"],Wr=q(ax,ix,r=>{var{typed:e}=r;return function(i,n,a,o){var f=i._data,l=i._size,u=i._datatype,s=n._values,c=n._index,m=n._ptr,v=n._size,d=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,h=a;typeof u=="string"&&u===d&&(y=u,N=e.convert(0,y),h=e.find(a,[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?h(s[B],f[I][A]):h(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?h(N,f[P][A]):h(f[P][A],N)}return i.createDenseMatrix({data:w,size:[p,g],datatype:y})}}),ox="matAlgo05xSfSf",sx=["typed","equalScalar"],Ci=q(ox,sx,r=>{var{typed:e,equalScalar:t}=r;return function(n,a,o){var f=n._values,l=n._index,u=n._ptr,s=n._size,c=n._datatype,m=a._values,v=a._index,d=a._ptr,p=a._size,g=a._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],h,w=t,x=0,b=o;typeof c=="string"&&c===g&&(h=c,w=e.find(t,[h,h]),x=e.convert(0,h),b=e.find(o,[h,h]));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=d[R],F=d[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,U=b(Q,K);w(U,x)?A.splice(M,1):(E.push(U),M++)}}}return S[N]=A.length,n.createSparseMatrix({values:E,index:A,ptr:S,size:[y,N],datatype:h})}}),Df="mod",ux=["typed","matrix","equalScalar","DenseMatrix","concat"],lx=q(Df,ux,r=>{var{typed:e,matrix:t,equalScalar:i,DenseMatrix:n,concat:a}=r,o=bt({typed:e,equalScalar:i}),f=Wr({typed:e}),l=Ci({typed:e,equalScalar:i}),u=Ur({typed:e,equalScalar:i}),s=Or({typed:e,DenseMatrix:n}),c=hr({typed:e,matrix:t,concat:a});return e(Df,{"number, number":oc,"BigNumber, BigNumber":function(v,d){if(d.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return d.isZero()?v:v.mod(d)},"Fraction, Fraction":function(v,d){if(d.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return v.compare(0)>=0?v.mod(d):v.mod(d).add(d).mod(d)}},c({SS:l,DS:f,SD:o,Ss:u,sS:s}))}),cx="multiplyScalar",fx=["typed"],mx=q(cx,fx,r=>{var{typed:e}=r;return e("multiplyScalar",{"number, number":Yl,"Complex, Complex":function(i,n){return i.mul(n)},"BigNumber, BigNumber":function(i,n){return i.times(n)},"Fraction, Fraction":function(i,n){return i.mul(n)},"number | Fraction | BigNumber | Complex, Unit":(t,i)=>i.multiply(t),"Unit, number | Fraction | BigNumber | Complex | Unit":(t,i)=>t.multiply(i)})}),Af="multiply",vx=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],px=q(Af,vx,r=>{var{typed:e,matrix:t,addScalar:i,multiplyScalar:n,equalScalar:a,dot:o}=r,f=Ur({typed:e,equalScalar:a}),l=yt({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=i,F=n;S&&B&&S===B&&typeof S=="string"&&(R=S,M=e.find(i,[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}),d=e("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":g,"DenseMatrix, SparseMatrix":y,"SparseMatrix, DenseMatrix":h,"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=i,M=n;S&&T&&S===T&&typeof S=="string"&&(P=S,R=e.find(i,[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=i,H=n;S&&B&&S===B&&typeof S=="string"&&(M=S,F=e.find(i,[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 U=H(Q[0],D[0][K]),j=1;j<P;j++)U=F(U,H(Q[j],D[j][K]));$[k][K]=U}}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=i,$=n,k=a,Q=0;S&&P&&S===P&&typeof S=="string"&&(F=S,H=e.find(i,[F,F]),$=e.find(n,[F,F]),k=e.find(a,[F,F]),Q=e.convert(0,F));for(var K=[],U=[],j=[],ae=b.createSparseMatrix({values:K,index:U,ptr:j,size:[R,M],datatype:F}),re=0;re<M;re++){j[re]=U.length;var me=B[re],he=B[re+1];if(he>me)for(var fe=0,ie=0;ie<R;ie++){for(var Ae=ie+1,Oe=void 0,Ce=me;Ce<he;Ce++){var $e=T[Ce];fe!==Ae?(Oe=$(E[ie][$e],D[Ce]),fe=Ae):Oe=H(Oe,$(E[ie][$e],D[Ce]))}fe===Ae&&!k(Oe,Q)&&(U.push(ie),K.push(Oe))}}return j[M]=U.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,$=i,k=n,Q=a,K=0;D&&B&&D===B&&typeof D=="string"&&(H=D,$=e.find(i,[H,H]),k=e.find(n,[H,H]),Q=e.find(a,[H,H]),K=e.convert(0,H));var U=[],j=[];F[0]=0;for(var ae=0;ae<P;ae++){var re=T[ae];if(!Q(re,K))for(var me=S[ae],he=S[ae+1],fe=me;fe<he;fe++){var ie=A[fe];j[ie]?U[ie]=$(U[ie],k(re,E[fe])):(j[ie]=!0,M.push(ie),U[ie]=k(re,E[fe]))}}for(var Ae=M.length,Oe=0;Oe<Ae;Oe++){var Ce=M[Oe];R[Oe]=U[Ce]}return F[1]=M.length,x.createSparseMatrix({values:R,index:M,ptr:F,size:[I,1],datatype:H})}function h(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=i,H=n,$=a,k=0;D&&B&&D===B&&typeof D=="string"&&(M=D,F=e.find(i,[M,M]),H=e.find(n,[M,M]),$=e.find(a,[M,M]),k=e.convert(0,M));for(var Q=[],K=[],U=[],j=x.createSparseMatrix({values:Q,index:K,ptr:U,size:[I,R],datatype:M}),ae=[],re=[],me=0;me<R;me++){U[me]=K.length;for(var he=me+1,fe=0;fe<P;fe++){var ie=T[fe][me];if(!$(ie,k))for(var Ae=S[fe],Oe=S[fe+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=U[me],X=K.length,oe=V;oe<X;oe++){var G=K[oe];Q[oe]=ae[G]}}return U[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,$=i,k=n;D&&P&&D===P&&typeof D=="string"&&(H=D,$=e.find(i,[H,H]),k=e.find(n,[H,H]));for(var Q=F?[]:void 0,K=[],U=[],j=x.createSparseMatrix({values:Q,index:K,ptr:U,size:[R,M],datatype:H}),ae=F?[]:void 0,re=[],me,he,fe,ie,Ae,Oe,Ce,$e,V=0;V<M;V++){U[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],fe=S[$e+1],me=he;me<fe;me++)Ce=A[me],re[Ce]!==X?(re[Ce]=X,K.push(Ce),ae[Ce]=k(T[ie],E[me])):ae[Ce]=$(ae[Ce],k(T[ie],E[me]));else for(he=S[$e],fe=S[$e+1],me=he;me<fe;me++)Ce=A[me],re[Ce]!==X&&(re[Ce]=X,K.push(Ce));if(F)for(var oe=U[V],G=K.length,Y=oe;Y<G;Y++){var te=K[Y];Q[Y]=ae[te]}}return U[M]=K.length,j}return e(Af,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):d(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})})}),Ef="nthRoot",dx=["typed","matrix","equalScalar","BigNumber","concat"],hx=q(Ef,dx,r=>{var{typed:e,matrix:t,equalScalar:i,BigNumber:n,concat:a}=r,o=un({typed:e}),f=bt({typed:e,equalScalar:i}),l=Si({typed:e,equalScalar:i}),u=Ur({typed:e,equalScalar:i}),s=hr({typed:e,matrix:t,concat:a});function c(){throw new Error("Complex number not supported in function nthRoot. Use nthRoots instead.")}return e(Ef,{number:sc,"number, number":sc,BigNumber:v=>m(v,new n(2)),"BigNumber, BigNumber":m,Complex:c,"Complex, number":c,Array:e.referTo("DenseMatrix,number",v=>d=>v(t(d),2).valueOf()),DenseMatrix:e.referTo("DenseMatrix,number",v=>d=>v(d,2)),SparseMatrix:e.referTo("SparseMatrix,number",v=>d=>v(d,2)),"SparseMatrix, SparseMatrix":e.referToSelf(v=>(d,p)=>{if(p.density()===1)return l(d,p,v);throw new Error("Root must be non-zero")}),"DenseMatrix, SparseMatrix":e.referToSelf(v=>(d,p)=>{if(p.density()===1)return o(d,p,v,!1);throw new Error("Root must be non-zero")}),"Array, SparseMatrix":e.referTo("DenseMatrix,SparseMatrix",v=>(d,p)=>v(t(d),p)),"number | BigNumber, SparseMatrix":e.referToSelf(v=>(d,p)=>{if(p.density()===1)return u(p,d,v,!0);throw new Error("Root must be non-zero")})},s({scalar:"number | BigNumber",SD:f,Ss:u,sS:!1}));function m(v,d){var p=n.precision,g=n.clone({precision:p+2}),y=new n(0),N=new g(1),h=d.isNegative();if(h&&(d=d.neg()),d.isZero())throw new Error("Root must be non-zero");if(v.isNegative()&&!d.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(v.isZero())return h?new g(1/0):0;if(!v.isFinite())return h?y:v;var w=v.abs().pow(N.div(d));return w=v.isNeg()?w.neg():w,new n((h?N.div(w):w).toPrecision(p))}}),Sf="sign",gx=["typed","BigNumber","Fraction","complex"],yx=q(Sf,gx,r=>{var{typed:e,BigNumber:t,complex:i,Fraction:n}=r;return e(Sf,{number:ls,Complex:function(o){return o.im===0?i(ls(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(a=>o=>je(o,a)),Unit:e.referToSelf(a=>o=>{if(!o._isDerived()&&o.units[0].unit.offset!==0)throw new TypeError("sign is ambiguous for units with offset");return e.find(a,o.valueType())(o.value)})})}),bx="sqrt",xx=["config","typed","Complex"],wx=q(bx,xx,r=>{var{config:e,typed:t,Complex:i}=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(a){return isNaN(a)?NaN:a>=0||e.predictable?Math.sqrt(a):new i(a,0).sqrt()}}),Cf="square",Nx=["typed"],Dx=q(Cf,Nx,r=>{var{typed:e}=r;return e(Cf,{number:uc,Complex:function(i){return i.mul(i)},BigNumber:function(i){return i.times(i)},Fraction:function(i){return i.mul(i)},Unit:function(i){return i.pow(2)}})}),Mf="subtract",Ax=["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix","concat"],Ex=q(Mf,Ax,r=>{var{typed:e,matrix:t,equalScalar:i,addScalar:n,unaryMinus:a,DenseMatrix:o,concat:f}=r,l=un({typed:e}),u=Wr({typed:e}),s=Ci({typed:e,equalScalar:i}),c=En({typed:e,DenseMatrix:o}),m=Or({typed:e,DenseMatrix:o}),v=hr({typed:e,matrix:t,concat:f});return e(Mf,{"number, number":(d,p)=>d-p,"Complex, Complex":(d,p)=>d.sub(p),"BigNumber, BigNumber":(d,p)=>d.minus(p),"Fraction, Fraction":(d,p)=>d.sub(p),"Unit, Unit":e.referToSelf(d=>(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(d,[y.valueType(),g.valueType()])(y.value,g.value),y.fixPrefix=!1,y})},v({SS:s,DS:l,SD:u,Ss:m,sS:c}))}),Ff="xgcd",Sx=["typed","config","matrix","BigNumber"],Cx=q(Ff,Sx,r=>{var{typed:e,config:t,matrix:i,BigNumber:n}=r;return e(Ff,{"number, number":function(f,l){var u=lc(f,l);return t.matrix==="Array"?u:i(u)},"BigNumber, BigNumber":a});function a(o,f){var l,u,s,c=new n(0),m=new n(1),v=c,d=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=d.minus(u.times(v)),d=l,l=p,p=g.minus(u.times(p)),g=l,o=f,f=s;var y;return o.lt(c)?y=[o.neg(),d.neg(),g.neg()]:y=[o,o.isZero()?0:d,g],t.matrix==="Array"?y:i(y)}}),Tf="invmod",Mx=["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],Fx=q(Tf,Mx,r=>{var{typed:e,config:t,BigNumber:i,xgcd:n,equal:a,smaller:o,mod:f,add:l,isInteger:u}=r;return e(Tf,{"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),a(m,0))throw new Error("Divisor must be non zero");var v=n(c,m);v=v.valueOf();var[d,p]=v;return a(d,i(1))?(p=f(p,m),o(p,i(0))&&(p=l(p,m)),p):NaN}}),Tx="matAlgo09xS0Sf",Bx=["typed","equalScalar"],Bf=q(Tx,Bx,r=>{var{typed:e,equalScalar:t}=r;return function(n,a,o){var f=n._values,l=n._index,u=n._ptr,s=n._size,c=n._datatype,m=a._values,v=a._index,d=a._ptr,p=a._size,g=a._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],h,w=t,x=0,b=o;typeof c=="string"&&c===g&&(h=c,w=e.find(t,[h,h]),x=e.convert(0,h),b=e.find(o,[h,h]));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=d[I],M=d[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:h})}}),$f="dotMultiply",$x=["typed","matrix","equalScalar","multiplyScalar","concat"],Ox=q($f,$x,r=>{var{typed:e,matrix:t,equalScalar:i,multiplyScalar:n,concat:a}=r,o=bt({typed:e,equalScalar:i}),f=Bf({typed:e,equalScalar:i}),l=Ur({typed:e,equalScalar:i}),u=hr({typed:e,matrix:t,concat:a});return e($f,u({elop:n,SS:f,DS:o,Ss:l}))});function Ix(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 hs(r,e,function(i,n){return i&n})}function Pa(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 i=r.plus(new e(1));return i.s=-i.s||null,e.config({precision:t}),i}function Rx(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 i=new t(-1);return r.isZero()||e.eq(i)||r.eq(e)?e:e.isZero()||r.eq(i)?r:!r.isFinite()||!e.isFinite()?!r.isFinite()&&!r.isNegative()&&e.isNegative()||r.isNegative()&&!e.isNegative()&&!e.isFinite()?i:r.isNegative()&&e.isNegative()?r.isFinite()?r:e:r.isFinite()?e:r:hs(r,e,function(n,a){return n|a})}function hs(r,e,t){var i=r.constructor,n,a,o=+(r.s<0),f=+(e.s<0);if(o){n=Mi(Pa(r));for(var l=0;l<n.length;++l)n[l]^=1}else n=Mi(r);if(f){a=Mi(Pa(e));for(var u=0;u<a.length;++u)a[u]^=1}else a=Mi(e);var s,c,m;n.length<=a.length?(s=n,c=a,m=o):(s=a,c=n,m=f);var v=s.length,d=c.length,p=t(o,f)^1,g=new i(p^1),y=new i(1),N=new i(2),h=i.precision;for(i.config({precision:1e9});v>0;)t(s[--v],c[--d])===p&&(g=g.plus(y)),y=y.times(N);for(;d>0;)t(m,c[--d])===p&&(g=g.plus(y)),y=y.times(N);return i.config({precision:h}),p===0&&(g.s=-g.s),g}function Mi(r){for(var e=r.d,t=e[0]+"",i=1;i<e.length;++i){for(var n=e[i]+"",a=7-n.length;a--;)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 i=new t(-1);return r.eq(i)?Pa(e):e.eq(i)?Pa(r):!r.isFinite()||!e.isFinite()?!r.isFinite()&&!e.isFinite()?i:new t(r.isNegative()===e.isNegative()?1/0:-1/0):hs(r,e,function(n,a){return n^a})}function qx(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 zx(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 Of="bitAnd",Px=["typed","matrix","equalScalar","concat"],Lx=q(Of,Px,r=>{var{typed:e,matrix:t,equalScalar:i,concat:n}=r,a=bt({typed:e,equalScalar:i}),o=Si({typed:e,equalScalar:i}),f=Ur({typed:e,equalScalar:i}),l=hr({typed:e,matrix:t,concat:n});return e(Of,{"number, number":mc,"BigNumber, BigNumber":Ix},l({SS:o,DS:a,Ss:f}))}),If="bitNot",Ux=["typed"],kx=q(If,Ux,r=>{var{typed:e}=r;return e(If,{number:vc,BigNumber:Pa,"Array | Matrix":e.referToSelf(t=>i=>je(i,t))})}),Rf="bitOr",Vx=["typed","matrix","equalScalar","DenseMatrix","concat"],Gx=q(Rf,Vx,r=>{var{typed:e,matrix:t,equalScalar:i,DenseMatrix:n,concat:a}=r,o=un({typed:e}),f=ps({typed:e,equalScalar:i}),l=En({typed:e,DenseMatrix:n}),u=hr({typed:e,matrix:t,concat:a});return e(Rf,{"number, number":pc,"BigNumber, BigNumber":Rx},u({SS:f,DS:o,Ss:l}))}),Hx="matAlgo07xSSf",Zx=["typed","DenseMatrix"],Tt=q(Hx,Zx,r=>{var{typed:e,DenseMatrix:t}=r;return function(a,o,f){var l=a._size,u=a._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],d,p=0,g=f;typeof u=="string"&&u===c&&(d=u,p=e.convert(0,d),g=e.find(f,[d,d]));var y,N,h=[];for(y=0;y<m;y++)h[y]=[];var w=[],x=[],b=[],E=[];for(N=0;N<v;N++){var A=N+1;for(i(a,N,b,w,A),i(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;h[y][N]=g(S,D)}}return new t({data:h,size:[m,v],datatype:d})};function i(n,a,o,f,l){for(var u=n._values,s=n._index,c=n._ptr,m=c[a],v=c[a+1];m<v;m++){var d=s[m];o[d]=l,f[d]=u[m]}}}),_f="bitXor",Jx=["typed","matrix","DenseMatrix","concat"],Xx=q(_f,Jx,r=>{var{typed:e,matrix:t,DenseMatrix:i,concat:n}=r,a=Wr({typed:e}),o=Tt({typed:e,DenseMatrix:i}),f=Or({typed:e,DenseMatrix:i}),l=hr({typed:e,matrix:t,concat:n});return e(_f,{"number, number":dc,"BigNumber, BigNumber":_x},l({SS:o,DS:a,Ss:f}))}),qf="arg",Wx=["typed"],Yx=q(qf,Wx,r=>{var{typed:e}=r;return e(qf,{number:function(i){return Math.atan2(0,i)},BigNumber:function(i){return i.constructor.atan2(0,i)},Complex:function(i){return i.arg()},"Array | Matrix":e.referToSelf(t=>i=>je(i,t))})}),zf="conj",Qx=["typed"],Kx=q(zf,Qx,r=>{var{typed:e}=r;return e(zf,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.conjugate(),"Array | Matrix":e.referToSelf(t=>i=>je(i,t))})}),Pf="im",jx=["typed"],ew=q(Pf,jx,r=>{var{typed:e}=r;return e(Pf,{number:()=>0,"BigNumber | Fraction":t=>t.mul(0),Complex:t=>t.im,"Array | Matrix":e.referToSelf(t=>i=>je(i,t))})}),Lf="re",rw=["typed"],tw=q(Lf,rw,r=>{var{typed:e}=r;return e(Lf,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.re,"Array | Matrix":e.referToSelf(t=>i=>je(i,t))})}),Uf="not",nw=["typed"],aw=q(Uf,nw,r=>{var{typed:e}=r;return e(Uf,{"null | undefined":()=>!0,number:xc,Complex:function(i){return i.re===0&&i.im===0},BigNumber:function(i){return i.isZero()||i.isNaN()},Unit:e.referToSelf(t=>i=>e.find(t,i.valueType())(i.value)),"Array | Matrix":e.referToSelf(t=>i=>je(i,t))})}),kf="or",iw=["typed","matrix","equalScalar","DenseMatrix","concat"],ow=q(kf,iw,r=>{var{typed:e,matrix:t,equalScalar:i,DenseMatrix:n,concat:a}=r,o=Wr({typed:e}),f=Ci({typed:e,equalScalar:i}),l=Or({typed:e,DenseMatrix:n}),u=hr({typed:e,matrix:t,concat:a});return e(kf,{"number, number":wc,"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}))}),Vf="xor",sw=["typed","matrix","DenseMatrix","concat"],uw=q(Vf,sw,r=>{var{typed:e,matrix:t,DenseMatrix:i,concat:n}=r,a=Wr({typed:e}),o=Tt({typed:e,DenseMatrix:i}),f=Or({typed:e,DenseMatrix:i}),l=hr({typed:e,matrix:t,concat:n});return e(Vf,{"number, number":Nc,"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:a,Ss:f}))}),Gf="concat",lw=["typed","matrix","isInteger"],Hf=q(Gf,lw,r=>{var{typed:e,matrix:t,isInteger:i}=r;return e(Gf,{"...Array | Matrix | number | BigNumber":function(a){var o,f=a.length,l=-1,u,s=!1,c=[];for(o=0;o<f;o++){var m=a[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(),!i(l))throw new TypeError("Integer number expected for dimension");if(l<0||o>0&&l>u)throw new pt(l,u+1)}else{var v=Ge(m).valueOf(),d=er(v);if(c[o]=v,u=l,l=d.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=Zf(p,c.shift(),l,0);return s?t(p):p},"...string":function(a){return a.join("")}})});function Zf(r,e,t,i){if(i<t){if(r.length!==e.length)throw new Ke(r.length,e.length);for(var n=[],a=0;a<r.length;a++)n[a]=Zf(r[a],e[a],t,i+1);return n}else return r.concat(e)}var Jf="column",cw=["typed","Index","matrix","range"],Xf=q(Jf,cw,r=>{var{typed:e,Index:t,matrix:i,range:n}=r;return e(Jf,{"Matrix, number":a,"Array, number":function(f,l){return a(i(Ge(f)),l).valueOf()}});function a(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:i([[s]])}}),Wf="count",fw=["typed","size","prod"],mw=q(Wf,fw,r=>{var{typed:e,size:t,prod:i}=r;return e(Wf,{string:function(a){return a.length},"Matrix | Array":function(a){return i(t(a))}})}),Yf="cross",vw=["typed","matrix","subtract","multiply"],pw=q(Yf,vw,r=>{var{typed:e,matrix:t,subtract:i,multiply:n}=r;return e(Yf,{"Matrix, Matrix":function(f,l){return t(a(f.toArray(),l.toArray()))},"Matrix, Array":function(f,l){return t(a(f.toArray(),l))},"Array, Matrix":function(f,l){return t(a(f,l.toArray()))},"Array, Array":a});function a(o,f){var l=Math.max(er(o).length,er(f).length);o=si(o),f=si(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=[i(n(o[1],f[2]),n(o[2],f[1])),i(n(o[2],f[0]),n(o[0],f[2])),i(n(o[0],f[1]),n(o[1],f[0]))];return l>1?[c]:c}}),Qf="diag",dw=["typed","matrix","DenseMatrix","SparseMatrix"],hw=q(Qf,dw,r=>{var{typed:e,matrix:t,DenseMatrix:i,SparseMatrix:n}=r;return e(Qf,{Array:function(u){return a(u,0,er(u),null)},"Array, number":function(u,s){return a(u,s,er(u),null)},"Array, BigNumber":function(u,s){return a(u,s.toNumber(),er(u),null)},"Array, string":function(u,s){return a(u,0,er(u),s)},"Array, number, string":function(u,s,c){return a(u,s,er(u),c)},"Array, BigNumber, string":function(u,s,c){return a(u,s.toNumber(),er(u),c)},Matrix:function(u){return a(u,0,u.size(),u.storage())},"Matrix, number":function(u,s){return a(u,s,u.size(),u.storage())},"Matrix, BigNumber":function(u,s){return a(u,s.toNumber(),u.size(),u.storage())},"Matrix, string":function(u,s){return a(u,0,u.size(),s)},"Matrix, number, string":function(u,s,c){return a(u,s,u.size(),c)},"Matrix, BigNumber, string":function(u,s,c){return a(u,s.toNumber(),u.size(),c)}});function a(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 d=[c+m,c+v];if(s&&s!=="sparse"&&s!=="dense")throw new TypeError("Unknown matrix type ".concat(s,'"'));var p=s==="sparse"?n.diagonal(d,l,u):i.diagonal(d,l,u);return s!==null?p:p.valueOf()}function f(l,u,s,c,m,v){if(Ve(l)){var d=l.diagonal(u);return s!==null?s!==d.storage()?t(d,s):d:d.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}}),gw="filter",yw=["typed"],bw=q(gw,yw,r=>{var{typed:e}=r;return e("filter",{"Array, function":Kf,"Matrix, function":function(i,n){return i.create(Kf(i.toArray(),n))},"Array, RegExp":li,"Matrix, RegExp":function(i,n){return i.create(li(i.toArray(),n))}})});function Kf(r,e){var t=sn(e);return Dl(r,function(i,n,a){return t===1?e(i):t===2?e(i,[n]):e(i,[n],a)})}var jf="flatten",xw=["typed","matrix"],ww=q(jf,xw,r=>{var{typed:e,matrix:t}=r;return e(jf,{Array:function(n){return or(n)},Matrix:function(n){var a=or(n.toArray());return t(a)}})}),em="forEach",Nw=["typed"],Dw=q(em,Nw,r=>{var{typed:e}=r;return e(em,{"Array, function":Aw,"Matrix, function":function(i,n){i.forEach(n)}})});function Aw(r,e){var t=sn(e),i=function n(a,o){Array.isArray(a)?ui(a,function(f,l){n(f,o.concat(l))}):t===1?e(a):t===2?e(a,o):e(a,o,r)};i(r,[])}var rm="getMatrixDataType",Ew=["typed"],Sw=q(rm,Ew,r=>{var{typed:e}=r;return e(rm,{Array:function(i){return Ia(i,br)},Matrix:function(i){return i.getDataType()}})}),tm="identity",Cw=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],Mw=q(tm,Cw,r=>{var{typed:e,config:t,matrix:i,BigNumber:n,DenseMatrix:a,SparseMatrix:o}=r;return e(tm,{"":function(){return t.matrix==="Matrix"?i([]):[]},string:function(s){return i(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?i(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,d=m?new m(0):0,p=[u,s];if(c){if(c==="sparse")return o.diagonal(p,v,0,d);if(c==="dense")return a.diagonal(p,v,0,d);throw new TypeError('Unknown matrix type "'.concat(c,'"'))}for(var g=Hn([],p,d),y=u<s?u:s,N=0;N<y;N++)g[N][N]=v;return g}}),nm="kron",Fw=["typed","matrix","multiplyScalar"],Tw=q(nm,Fw,r=>{var{typed:e,matrix:t,multiplyScalar:i}=r;return e(nm,{"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(a,o){if(er(a).length===1&&(a=[a]),er(o).length===1&&(o=[o]),er(a).length>2||er(o).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(a.length)+", y = "+JSON.stringify(o.length)+")");var f=[],l=[];return a.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(i(c,m))})})})})&&f}}),am="map",Bw=["typed"],$w=q(am,Bw,r=>{var{typed:e}=r;return e(am,{"Array, function":Ow,"Matrix, function":function(i,n){return i.map(n)}})});function Ow(r,e){var t=sn(e),i=function n(a,o){if(Array.isArray(a))return a.map(function(u,s){return n(u,o.concat(s))});try{return t===1?e(a):t===2?e(a,o):e(a,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(a),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 i(r,[])}var im="diff",Iw=["typed","matrix","subtract","number"],om=q(im,Iw,r=>{var{typed:e,matrix:t,subtract:i,number:n}=r;return e(im,{"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(a(s.toArray(),c)):a(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 a(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(a(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 i(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}}),Rw="ones",_w=["typed","config","matrix","BigNumber"],qw=q(Rw,_w,r=>{var{typed:e,config:t,matrix:i,BigNumber:n}=r;return e("ones",{"":function(){return t.matrix==="Array"?a([]):a([],"default")},"...number | BigNumber | string":function(u){var s=u[u.length-1];if(typeof s=="string"){var c=u.pop();return a(u,c)}else return t.matrix==="Array"?a(u):a(u,"default")},Array:a,Matrix:function(u){var s=u.storage();return a(u.valueOf(),s)},"Array | Matrix, string":function(u,s){return a(u.valueOf(),s)}});function a(l,u){var s=o(l),c=s?new n(1):1;if(f(l),u){var m=i(u);return l.length>0?m.resize(l,c):m}else{var v=[];return l.length>0?Hn(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 gs(){throw new Error('No "bignumber" implementation available')}function sm(){throw new Error('No "fraction" implementation available')}function um(){throw new Error('No "matrix" implementation available')}var lm="range",zw=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],cm=q(lm,zw,r=>{var{typed:e,config:t,matrix:i,bignumber:n,smaller:a,smallerEq:o,larger:f,largerEq:l}=r;return e(lm,{string:s,"string, boolean":s,"number, number":function(y,N){return u(c(y,N,1))},"number, number, number":function(y,N,h){return u(c(y,N,h))},"number, number, boolean":function(y,N,h){return u(h?m(y,N,1):c(y,N,1))},"number, number, number, boolean":function(y,N,h,w){return u(w?m(y,N,h):c(y,N,h))},"BigNumber, BigNumber":function(y,N){var h=y.constructor;return u(v(y,N,new h(1)))},"BigNumber, BigNumber, BigNumber":function(y,N,h){return u(v(y,N,h))},"BigNumber, BigNumber, boolean":function(y,N,h){var w=y.constructor;return u(h?d(y,N,new w(1)):v(y,N,new w(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(y,N,h,w){return u(w?d(y,N,h):v(y,N,h))}});function u(g){return t.matrix==="Matrix"?i?i(g):um():g}function s(g,y){var N=p(g);if(!N)throw new SyntaxError('String "'+g+'" is no valid range');var h;return t.number==="BigNumber"?(n===void 0&&gs(),h=y?d:v,u(h(n(N.start),n(N.end),n(N.step)))):(h=y?m:c,u(h(N.start,N.end,N.step)))}function c(g,y,N){var h=[],w=g;if(N>0)for(;a(w,y);)h.push(w),w+=N;else if(N<0)for(;f(w,y);)h.push(w),w+=N;return h}function m(g,y,N){var h=[],w=g;if(N>0)for(;o(w,y);)h.push(w),w+=N;else if(N<0)for(;l(w,y);)h.push(w),w+=N;return h}function v(g,y,N){var h=n(0),w=[],x=g;if(N.gt(h))for(;a(x,y);)w.push(x),x=x.plus(N);else if(N.lt(h))for(;f(x,y);)w.push(x),x=x.plus(N);return w}function d(g,y,N){var h=n(0),w=[],x=g;if(N.gt(h))for(;o(x,y);)w.push(x),x=x.plus(N);else if(N.lt(h))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)}),h=N.some(function(w){return isNaN(w)});if(h)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}}}),fm="reshape",Pw=["typed","isInteger","matrix"],Lw=q(fm,Pw,r=>{var{typed:e,isInteger:t}=r;return e(fm,{"Matrix, Array":function(n,a){return n.reshape(a,!0)},"Array, Array":function(n,a){return a.forEach(function(o){if(!t(o))throw new TypeError("Invalid size for dimension: "+o)}),yl(n,a)}})}),Uw="resize",kw=["config","matrix"],Vw=q(Uw,kw,r=>{var{config:e,matrix:t}=r;return function(a,o,f){if(arguments.length!==2&&arguments.length!==3)throw new Sn("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(a))return a.resize(o,f,!0);if(typeof a=="string")return i(a,o,f);var l=Array.isArray(a)?!1:e.matrix!=="Array";if(o.length===0){for(;Array.isArray(a);)a=a[0];return Ge(a)}else{Array.isArray(a)||(a=[a]),a=Ge(a);var u=Hn(a,o,f);return l?t(u):u}};function i(n,a,o){if(o!==void 0){if(typeof o!="string"||o.length!==1)throw new TypeError("Single character expected as defaultValue")}else o=" ";if(a.length!==1)throw new Ke(a.length,1);var f=a[0];if(typeof f!="number"||!qe(f))throw new TypeError("Invalid size, must contain positive integers (size: "+Ye(a)+")");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}}),mm="rotate",Gw=["typed","multiply","rotationMatrix"],Hw=q(mm,Gw,r=>{var{typed:e,multiply:t,rotationMatrix:i}=r;return e(mm,{"Array , number | BigNumber | Complex | Unit":function(o,f){n(o,2);var l=t(i(f),o);return l.toArray()},"Matrix , number | BigNumber | Complex | Unit":function(o,f){return n(o,2),t(i(f),o)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(o,f,l){n(o,3);var u=t(i(f,l),o);return u},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(o,f,l){return n(o,3),t(i(f,l),o)}});function n(a,o){var f=Array.isArray(a)?er(a):a.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))}}),vm="rotationMatrix",Zw=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],Jw=q(vm,Zw,r=>{var{typed:e,config:t,multiplyScalar:i,addScalar:n,unaryMinus:a,norm:o,BigNumber:f,matrix:l,DenseMatrix:u,SparseMatrix:s,cos:c,sin:m}=r;return e(vm,{"":function(){return t.matrix==="Matrix"?l([]):[]},string:function(h){return l(h)},"number | BigNumber | Complex | Unit":function(h){return v(h,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(h,w){return v(h,w)},"number | BigNumber | Complex | Unit, Array":function(h,w){var x=l(w);return d(x),y(h,x,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(h,w){d(w);var x=w.storage()||(t.matrix==="Matrix"?"dense":void 0);return y(h,w,x)},"number | BigNumber | Complex | Unit, Array, string":function(h,w,x){var b=l(w);return d(b),y(h,b,x)},"number | BigNumber | Complex | Unit, Matrix, string":function(h,w,x){return d(w),y(h,w,x)}});function v(N,h){var w=rr(N),x=w?new f(-1):-1,b=c(N),E=m(N),A=[[b,i(x,E)],[E,b]];return g(A,h)}function d(N){var h=N.size();if(h.length<1||h[0]!==3)throw new RangeError("Vector must be of dimensions 1x3")}function p(N){return N.reduce((h,w)=>i(h,w))}function g(N,h){if(h){if(h==="sparse")return new s(N);if(h==="dense")return new u(N);throw new TypeError('Unknown matrix type "'.concat(h,'"'))}return N}function y(N,h,w){var x=o(h);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(h.get([0])/x):h.get([0])/x,D=b?new b(h.get([1])/x):h.get([1])/x,T=b?new b(h.get([2])/x):h.get([2])/x,B=c(N),I=n(E,a(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])),U=n(B,p([T,T,I])),j=[[R,M,F],[H,$,k],[Q,K,U]];return g(j,w)}}),pm="row",Xw=["typed","Index","matrix","range"],dm=q(pm,Xw,r=>{var{typed:e,Index:t,matrix:i,range:n}=r;return e(pm,{"Matrix, number":a,"Array, number":function(f,l){return a(i(Ge(f)),l).valueOf()}});function a(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:i([[s]])}}),hm="size",Ww=["typed","config","?matrix"],Yw=q(hm,Ww,r=>{var{typed:e,config:t,matrix:i}=r;return e(hm,{Matrix:function(a){return a.create(a.size())},Array:er,string:function(a){return t.matrix==="Array"?[a.length]:i([a.length])},"number | Complex | BigNumber | Unit | boolean | null":function(a){return t.matrix==="Array"?[]:i?i([]):um()}})}),gm="squeeze",Qw=["typed","matrix"],Kw=q(gm,Qw,r=>{var{typed:e,matrix:t}=r;return e(gm,{Array:function(n){return si(Ge(n))},Matrix:function(n){var a=si(n.toArray());return Array.isArray(a)?t(a):a},any:function(n){return Ge(n)}})}),ym="subset",jw=["typed","matrix"],bm=q(ym,jw,r=>{var{typed:e,matrix:t}=r;return e(ym,{"Array, Index":function(n,a){var o=t(n),f=o.subset(a);return a.isScalar()?f:f.valueOf()},"Matrix, Index":function(n,a){return n.subset(a)},"Object, Index":rN,"string, Index":eN,"Array, Index, any":function(n,a,o){return t(Ge(n)).subset(a,o,void 0).valueOf()},"Array, Index, any, any":function(n,a,o,f){return t(Ge(n)).subset(a,o,f).valueOf()},"Matrix, Index, any":function(n,a,o){return n.clone().subset(a,o)},"Matrix, Index, any, any":function(n,a,o,f){return n.clone().subset(a,o,f)},"string, Index, string":xm,"string, Index, string, string":xm,"Object, Index, any":tN})});function eN(r,e){if(!ti(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 i=e.dimension(0),n="";return i.forEach(function(a){n+=r.charAt(a)}),n}function xm(r,e,t,i){if(!e||e.isIndex!==!0)throw new TypeError("Index expected");if(e.size().length!==1)throw new Ke(e.size().length,1);if(i!==void 0){if(typeof i!="string"||i.length!==1)throw new TypeError("Single character expected as defaultValue")}else i=" ";var n=e.dimension(0),a=n.size()[0];if(a!==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]=i);return f.join("")}function rN(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 st(r,t)}function tN(r,e,t){if(e.size().length!==1)throw new Ke(e.size(),1);var i=e.dimension(0);if(typeof i!="string")throw new TypeError("String expected as index to retrieve an object property");var n=Ge(r);return Jn(n,i,t),n}var wm="transpose",nN=["typed","matrix"],aN=q(wm,nN,r=>{var{typed:e,matrix:t}=r;return e(wm,{Array:o=>i(t(o)).valueOf(),Matrix:i,any:Ge});function i(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=a(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 a(o,f,l){for(var u=o._values,s=o._index,c=o._ptr,m=u?[]:void 0,v=[],d=[],p=[],g=0;g<f;g++)p[g]=0;var y,N,h;for(y=0,N=s.length;y<N;y++)p[s[y]]++;for(var w=0,x=0;x<f;x++)d.push(w),w+=p[x],p[x]=d[x];for(d.push(w),h=0;h<l;h++)for(var b=c[h],E=c[h+1],A=b;A<E;A++){var S=p[s[A]]++;v[S]=h,u&&(m[S]=Ge(u[A]))}return o.createSparseMatrix({values:m,index:v,ptr:d,size:[l,f],datatype:o._datatype})}}),Nm="ctranspose",iN=["typed","transpose","conj"],oN=q(Nm,iN,r=>{var{typed:e,transpose:t,conj:i}=r;return e(Nm,{any:function(a){return i(t(a))}})}),Dm="zeros",sN=["typed","config","matrix","BigNumber"],uN=q(Dm,sN,r=>{var{typed:e,config:t,matrix:i,BigNumber:n}=r;return e(Dm,{"":function(){return t.matrix==="Array"?a([]):a([],"default")},"...number | BigNumber | string":function(u){var s=u[u.length-1];if(typeof s=="string"){var c=u.pop();return a(u,c)}else return t.matrix==="Array"?a(u):a(u,"default")},Array:a,Matrix:function(u){var s=u.storage();return a(u.valueOf(),s)},"Array | Matrix, string":function(u,s){return a(u.valueOf(),s)}});function a(l,u){var s=o(l),c=s?new n(0):0;if(f(l),u){var m=i(u);return l.length>0?m.resize(l,c):m}else{var v=[];return l.length>0?Hn(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")})}}),Am="fft",lN=["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i","dotDivide","conj","pow","ceil","log2"],cN=q(Am,lN,r=>{var{typed:e,matrix:t,addScalar:i,multiplyScalar:n,divideScalar:a,exp:o,tau:f,i:l,dotDivide:u,conj:s,pow:c,ceil:m,log2:v}=r;return e(Am,{Array:d,Matrix:function(h){return h.create(d(h.toArray()))}});function d(N){var h=er(N);return h.length===1?y(N,h[0]):p(N.map(w=>d(w,h.slice(1))),0)}function p(N,h){var w=er(N);if(h!==0)return new Array(w[0]).fill(0).map((b,E)=>p(N[E],h-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 h=N.length,w=o(a(n(-1,n(l,f)),h)),x=[],b=1-h;b<h;b++)x.push(c(w,a(c(b,2),2)));for(var E=c(2,m(v(h+h-1))),A=[...new Array(h).fill(0).map((M,F)=>n(N[F],x[h-1+F])),...new Array(E-h).fill(0)],S=[...new Array(h+h-1).fill(0).map((M,F)=>a(1,x[F])),...new Array(E-(h+h-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(d(s(B))),E),P=[],R=h-1;R<h+h-1;R++)P.push(n(I[R],x[R]));return P}function y(N){var h=N.length;if(h===1)return[N[0]];if(h%2===0){for(var w=[...y(N.filter((A,S)=>S%2===0)),...y(N.filter((A,S)=>S%2===1))],x=0;x<h/2;x++){var b=w[x],E=n(w[x+h/2],o(n(n(f,l),a(-x,h))));w[x]=i(b,E),w[x+h/2]=i(b,n(-1,E))}return w}else return g(N)}}),Em="ifft",fN=["typed","fft","dotDivide","conj"],mN=q(Em,fN,r=>{var{typed:e,fft:t,dotDivide:i,conj:n}=r;return e(Em,{"Array | Matrix":function(o){var f=Ve(o)?o.size():er(o);return i(n(t(n(o))),f.reduce((l,u)=>l*u,1))}})}),vN="erf",pN=["typed"],dN=q(vN,pN,r=>{var{typed:e}=r;return e("name",{number:function(o){var f=Math.abs(o);return f>=yN?en(o):f<=hN?en(o)*t(f):f<=4?en(o)*(1-i(f)):en(o)*(1-n(f))},"Array | Matrix":e.referToSelf(a=>o=>je(o,a))});function t(a){var o=a*a,f=Xt[0][4]*o,l=o,u;for(u=0;u<3;u+=1)f=(f+Xt[0][u])*o,l=(l+ta[0][u])*o;return a*(f+Xt[0][3])/(l+ta[0][3])}function i(a){var o=Xt[1][8]*a,f=a,l;for(l=0;l<7;l+=1)o=(o+Xt[1][l])*a,f=(f+ta[1][l])*a;var u=(o+Xt[1][7])/(f+ta[1][7]),s=parseInt(a*16)/16,c=(a-s)*(a+s);return Math.exp(-s*s)*Math.exp(-c)*u}function n(a){var o=1/(a*a),f=Xt[2][5]*o,l=o,u;for(u=0;u<4;u+=1)f=(f+Xt[2][u])*o,l=(l+ta[2][u])*o;var s=o*(f+Xt[2][4])/(l+ta[2][4]);s=(gN-s)/a,o=parseInt(a*16)/16;var c=(a-o)*(a+o);return Math.exp(-o*o)*Math.exp(-c)*s}}),hN=.46875,gN=.5641895835477563,Xt=[[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]],ta=[[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]],yN=Math.pow(2,53),Sm="mode",bN=["typed","isNaN","isNumeric"],xN=q(Sm,bN,r=>{var{typed:e,isNaN:t,isNumeric:i}=r;return e(Sm,{"Array | Matrix":n,"...":function(o){return n(o)}});function n(a){a=or(a.valueOf());var o=a.length;if(o===0)throw new Error("Cannot calculate mode of an empty array");for(var f={},l=[],u=0,s=0;s<a.length;s++){var c=a[s];if(i(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 Yr(r,e,t){var i;return String(r).indexOf("Unexpected type")!==-1?(i=arguments.length>2?" (type: "+br(t)+", value: "+JSON.stringify(t)+")":" (type: "+r.data.actual+")",new TypeError("Cannot calculate "+e+", unexpected type of argument"+i)):String(r).indexOf("complex numbers")!==-1?(i=arguments.length>2?" (type: "+br(t)+", value: "+JSON.stringify(t)+")":"",new TypeError("Cannot calculate "+e+", no ordering relation is defined for complex numbers"+i)):r}var Cm="prod",wN=["typed","config","multiplyScalar","numeric"],NN=q(Cm,wN,r=>{var{typed:e,config:t,multiplyScalar:i,numeric:n}=r;return e(Cm,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(f,l){throw new Error("prod(A, dim) is not yet supported")},"...":function(f){return a(f)}});function a(o){var f;if(Zt(o,function(l){try{f=f===void 0?l:i(f,l)}catch(u){throw Yr(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}}),Mm="format",DN=["typed"],AN=q(Mm,DN,r=>{var{typed:e}=r;return e(Mm,{any:Ye,"any, Object | function | number":Ye})}),Fm="bin",EN=["typed","format"],SN=q(Fm,EN,r=>{var{typed:e,format:t}=r;return e(Fm,{"number | BigNumber":function(n){return t(n,{notation:"bin"})},"number | BigNumber, number":function(n,a){return t(n,{notation:"bin",wordSize:a})}})}),Tm="oct",CN=["typed","format"],MN=q(Tm,CN,r=>{var{typed:e,format:t}=r;return e(Tm,{"number | BigNumber":function(n){return t(n,{notation:"oct"})},"number | BigNumber, number":function(n,a){return t(n,{notation:"oct",wordSize:a})}})}),Bm="hex",FN=["typed","format"],TN=q(Bm,FN,r=>{var{typed:e,format:t}=r;return e(Bm,{"number | BigNumber":function(n){return t(n,{notation:"hex"})},"number | BigNumber, number":function(n,a){return t(n,{notation:"hex",wordSize:a})}})}),$m="print",BN=["typed"],$N=q($m,BN,r=>{var{typed:e}=r;return e($m,{"string, Object | Array":Om,"string, Object | Array, number | Object":Om})});function Om(r,e,t){return r.replace(/\$([\w.]+)/g,function(i,n){for(var a=n.split("."),o=e[a.shift()];a.length&&o!==void 0;){var f=a.shift();o=f?o[f]:o+"."}return o!==void 0?Xr(o)?o:Ye(o,t):i})}var Im="to",ON=["typed","matrix","concat"],IN=q(Im,ON,r=>{var{typed:e,matrix:t,concat:i}=r,n=hr({typed:e,matrix:t,concat:i});return e(Im,{"Unit, Unit | string":(a,o)=>a.to(o)},n({Ds:!0}))}),Rm="isPrime",RN=["typed"],_N=q(Rm,RN,r=>{var{typed:e}=r;return e(Rm,{number:function(i){if(i*0!==0)return!1;if(i<=3)return i>1;if(i%2===0||i%3===0)return!1;for(var n=5;n*n<=i;n+=6)if(i%n===0||i%(n+2)===0)return!1;return!0},BigNumber:function(i){if(i.toNumber()*0!==0)return!1;if(i.lte(3))return i.gt(1);if(i.mod(2).eq(0)||i.mod(3).eq(0))return!1;if(i.lt(Math.pow(2,32))){for(var n=i.toNumber(),a=5;a*a<=n;a+=6)if(n%a===0||n%(a+2)===0)return!1;return!0}function o(N,h,w){for(var x=1;!h.eq(0);)h.mod(2).eq(0)?(h=h.div(2),N=N.mul(N).mod(w)):(h=h.sub(1),x=N.mul(x).mod(w));return x}var f=i.constructor.clone({precision:i.toFixed(0).length*2});i=new f(i);for(var l=0,u=i.sub(1);u.mod(2).eq(0);)u=u.div(2),l+=1;var s=null;if(i.lt("3317044064679887385961981"))s=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter(N=>N<i);else{var c=Math.min(i.toNumber()-2,Math.floor(2*Math.pow(i.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 d=s[v],p=o(i.sub(i).add(d),u,i);if(!p.eq(1)){for(var g=0,y=p;!y.eq(i.sub(1));g+=1,y=y.mul(y).mod(i))if(g===l-1)return!1}}return!0},"Array | Matrix":e.referToSelf(t=>i=>je(i,t))})}),qN="numeric",zN=["number","?bignumber","?fraction"],PN=q(qN,zN,r=>{var{number:e,bignumber:t,fraction:i}=r,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},a={number:o=>e(o),BigNumber:t?o=>t(o):gs,Fraction:i?o=>i(o):sm};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 a))throw new TypeError("Cannot convert "+f+' to type "'+l+'"; valid output types are '+Object.keys(a).join(", "));return l===s?f:a[l](f)}}),_m="divideScalar",LN=["typed","numeric"],UN=q(_m,LN,r=>{var{typed:e,numeric:t}=r;return e(_m,{"number, number":function(n,a){return n/a},"Complex, Complex":function(n,a){return n.div(a)},"BigNumber, BigNumber":function(n,a){return n.div(a)},"Fraction, Fraction":function(n,a){return n.div(a)},"Unit, number | Complex | Fraction | BigNumber | Unit":(i,n)=>i.divide(n),"number | Fraction | Complex | BigNumber, Unit":(i,n)=>n.divideInto(i)})}),qm="pow",kN=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],VN=q(qm,kN,r=>{var{typed:e,config:t,identity:i,multiply:n,matrix:a,inv:o,number:f,fraction:l,Complex:u}=r;return e(qm,{"number, number":s,"Complex, Complex":function(d,p){return d.pow(p)},"BigNumber, BigNumber":function(d,p){return p.isInteger()||d>=0||t.predictable?d.pow(p):new u(d.toNumber(),0).pow(p.toNumber(),0)},"Fraction, Fraction":function(d,p){var g=d.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(d.valueOf(),p.valueOf())},"Array, number":c,"Array, BigNumber":function(d,p){return c(d,p.toNumber())},"Matrix, number":m,"Matrix, BigNumber":function(d,p){return m(d,p.toNumber())},"Unit, number | BigNumber":function(d,p){return d.pow(p)}});function s(v,d){if(t.predictable&&!qe(d)&&v<0)try{var p=l(d),g=f(p);if((d===g||Math.abs((d-g)/d)<1e-14)&&p.d%2===1)return(p.n%2===0?1:-1)*Math.pow(-v,d)}catch{}return t.predictable&&(v<-1&&d===1/0||v>-1&&v<0&&d===-1/0)?NaN:qe(d)||v>=0||t.predictable?cc(v,d):v*v<1&&d===1/0||v*v>1&&d===-1/0?0:new u(v,0).pow(d,0)}function c(v,d){if(!qe(d))throw new TypeError("For A^b, b must be an integer (value is "+d+")");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(d<0)try{return c(o(v),-d)}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 "+d+")"):N}for(var g=i(p[0]).valueOf(),y=v;d>=1;)(d&1)===1&&(g=n(y,g)),d>>=1,y=n(y,y);return g}function m(v,d){return a(c(v.valueOf(),d))}}),na="Number of decimals in function round must be an integer",zm="round",GN=["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],HN=q(zm,GN,r=>{var{typed:e,matrix:t,equalScalar:i,zeros:n,BigNumber:a,DenseMatrix:o}=r,f=Ur({typed:e,equalScalar:i}),l=Or({typed:e,DenseMatrix:o}),u=yt({typed:e});return e(zm,{number:fc,"number, number":fc,"number, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(na);return new a(c).toDecimalPlaces(m.toNumber())},Complex:function(c){return c.round()},"Complex, number":function(c,m){if(m%1)throw new TypeError(na);return c.round(m)},"Complex, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(na);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(na);return c.toDecimalPlaces(m.toNumber())},Fraction:function(c){return c.round()},"Fraction, number":function(c,m){if(m%1)throw new TypeError(na);return c.round(m)},"Fraction, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(na);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)=>i(c,0)?n(m.size(),m.storage()):l(m,c,s,!0)),"number | Complex | BigNumber | Fraction, DenseMatrix":e.referToSelf(s=>(c,m)=>i(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())})}),Pm="log",ZN=["config","typed","divideScalar","Complex"],JN=q(Pm,ZN,r=>{var{typed:e,config:t,divideScalar:i,Complex:n}=r;return e(Pm,{number:function(o){return o>=0||t.predictable?W1(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(a=>(o,f)=>i(a(o),a(f)))})}),Lm="log1p",XN=["typed","config","divideScalar","log","Complex"],WN=q(Lm,XN,r=>{var{typed:e,config:t,divideScalar:i,log:n,Complex:a}=r;return e(Lm,{number:function(l){return l>=-1||t.predictable?J0(l):o(new a(l,0))},Complex:o,BigNumber:function(l){var u=l.plus(1);return!u.isNegative()||t.predictable?u.ln():o(new a(l.toNumber(),0))},"Array | Matrix":e.referToSelf(f=>l=>je(l,f)),"any, any":e.referToSelf(f=>(l,u)=>i(f(l),n(u)))});function o(f){var l=f.re+1;return new a(Math.log(Math.sqrt(l*l+f.im*f.im)),Math.atan2(f.im,l))}}),Um="nthRoots",YN=["config","typed","divideScalar","Complex"],QN=q(Um,YN,r=>{var{typed:e,config:t,divideScalar:i,Complex:n}=r,a=[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=[],d=Math.pow(m,1/l),p=0;p<l;p++){var g=(s+4*p)/l;if(g===Math.round(g)){v.push(a[g%4](d));continue}v.push(new n({r:d,phi:(c+2*Math.PI*p)/l}))}return v}return e(Um,{Complex:function(l){return o(l,2)},"Complex, number":o})}),km="dotPow",KN=["typed","equalScalar","matrix","pow","DenseMatrix","concat"],jN=q(km,KN,r=>{var{typed:e,equalScalar:t,matrix:i,pow:n,DenseMatrix:a,concat:o}=r,f=Wr({typed:e}),l=Tt({typed:e,DenseMatrix:a}),u=Ur({typed:e,equalScalar:t}),s=Or({typed:e,DenseMatrix:a}),c=hr({typed:e,matrix:i,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 d=e(m);return e(km,c({elop:d,SS:l,DS:f,Ss:u,sS:s}))}),Vm="dotDivide",e2=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],r2=q(Vm,e2,r=>{var{typed:e,matrix:t,equalScalar:i,divideScalar:n,DenseMatrix:a,concat:o}=r,f=bt({typed:e,equalScalar:i}),l=Wr({typed:e}),u=Tt({typed:e,DenseMatrix:a}),s=Ur({typed:e,equalScalar:i}),c=Or({typed:e,DenseMatrix:a}),m=hr({typed:e,matrix:t,concat:o});return e(Vm,m({elop:n,SS:u,DS:l,SD:f,Ss:s,sS:c}))});function La(r){var{DenseMatrix:e}=r;return function(i,n,a){var o=i.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(ri(n)){if(a){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(wn(n)){for(var d=0;d<f;d++)u[d]=[0];for(var p=n._values,g=n._index,y=n._ptr,N=y[1],h=y[0];h<N;h++){var w=g[h];u[w][0]=p[h]}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 Gm="lsolve",t2=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],n2=q(Gm,t2,r=>{var{typed:e,matrix:t,divideScalar:i,multiplyScalar:n,subtract:a,equalScalar:o,DenseMatrix:f}=r,l=La({DenseMatrix:f});return e(Gm,{"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 d=t(m),p=u(d,v);return p.valueOf()}});function u(c,m){m=l(c,m,!0);for(var v=m._data,d=c._size[0],p=c._size[1],g=[],y=c._data,N=0;N<p;N++){var h=v[N][0]||0,w=void 0;if(o(h,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=i(h,x);for(var b=N+1;b<d;b++)v[b]=[a(v[b][0]||0,n(w,y[b][N]))]}g[N]=[w]}return new f({data:g,size:[d,1]})}function s(c,m){m=l(c,m,!0);for(var v=m._data,d=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,h=[],w=0;w<p;w++){var x=v[w][0]||0;if(o(x,0))h[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=i(x,b),P=0,R=A.length;P<R;P++){var M=A[P];v[M]=[a(v[M][0]||0,n(I,E[P]))]}h[w]=[I]}}return new f({data:h,size:[d,1]})}}),Hm="usolve",a2=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],i2=q(Hm,a2,r=>{var{typed:e,matrix:t,divideScalar:i,multiplyScalar:n,subtract:a,equalScalar:o,DenseMatrix:f}=r,l=La({DenseMatrix:f});return e(Hm,{"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 d=t(m),p=u(d,v);return p.valueOf()}});function u(c,m){m=l(c,m,!0);for(var v=m._data,d=c._size[0],p=c._size[1],g=[],y=c._data,N=p-1;N>=0;N--){var h=v[N][0]||0,w=void 0;if(o(h,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=i(h,x);for(var b=N-1;b>=0;b--)v[b]=[a(v[b][0]||0,n(w,y[b][N]))]}g[N]=[w]}return new f({data:g,size:[d,1]})}function s(c,m){m=l(c,m,!0);for(var v=m._data,d=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,h=[],w=p-1;w>=0;w--){var x=v[w][0]||0;if(o(x,0))h[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=i(x,b),P=0,R=A.length;P<R;P++){var M=A[P];v[M]=[a(v[M][0],n(I,E[P]))]}h[w]=[I]}}return new f({data:h,size:[d,1]})}}),Zm="lsolveAll",o2=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],s2=q(Zm,o2,r=>{var{typed:e,matrix:t,divideScalar:i,multiplyScalar:n,subtract:a,equalScalar:o,DenseMatrix:f}=r,l=La({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 d=t(m),p=u(d,v);return p.map(g=>g.valueOf())}});function u(c,m){for(var v=[l(c,m,!0)._data.map(A=>A[0])],d=c._data,p=c._size[0],g=c._size[1],y=0;y<g;y++)for(var N=v.length,h=0;h<N;h++){var w=v[h];if(o(d[y][y],0))if(o(w[y],0)){if(h===0){var b=[...w];b[y]=1;for(var E=y+1;E<g;E++)b[E]=a(b[E],d[E][y]);v.push(b)}}else{if(h===0)return[];v.splice(h,1),h-=1,N-=1}else{w[y]=i(w[y],d[y][y]);for(var x=y+1;x<g;x++)w[x]=a(w[x],n(w[y],d[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])],d=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,h=0;h<p;h++)for(var w=v.length,x=0;x<w;x++){for(var b=v[x],E=[],A=[],S=N[h],D=N[h+1],T=0,B=S;B<D;B++){var I=y[B];I===h?T=g[B]:I>h&&(E.push(g[B]),A.push(I))}if(o(T,0))if(o(b[h],0)){if(x===0){var F=[...b];F[h]=1;for(var H=0,$=A.length;H<$;H++){var k=A[H];F[k]=a(F[k],E[H])}v.push(F)}}else{if(x===0)return[];v.splice(x,1),x-=1,w-=1}else{b[h]=i(b[h],T);for(var P=0,R=A.length;P<R;P++){var M=A[P];b[M]=a(b[M],n(b[h],E[P]))}}}return v.map(Q=>new f({data:Q.map(K=>[K]),size:[d,1]}))}}),Jm="usolveAll",u2=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],l2=q(Jm,u2,r=>{var{typed:e,matrix:t,divideScalar:i,multiplyScalar:n,subtract:a,equalScalar:o,DenseMatrix:f}=r,l=La({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 d=t(m),p=u(d,v);return p.map(g=>g.valueOf())}});function u(c,m){for(var v=[l(c,m,!0)._data.map(A=>A[0])],d=c._data,p=c._size[0],g=c._size[1],y=g-1;y>=0;y--)for(var N=v.length,h=0;h<N;h++){var w=v[h];if(o(d[y][y],0))if(o(w[y],0)){if(h===0){var b=[...w];b[y]=1;for(var E=y-1;E>=0;E--)b[E]=a(b[E],d[E][y]);v.push(b)}}else{if(h===0)return[];v.splice(h,1),h-=1,N-=1}else{w[y]=i(w[y],d[y][y]);for(var x=y-1;x>=0;x--)w[x]=a(w[x],n(w[y],d[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])],d=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,h=p-1;h>=0;h--)for(var w=v.length,x=0;x<w;x++){for(var b=v[x],E=[],A=[],S=N[h],D=N[h+1],T=0,B=D-1;B>=S;B--){var I=y[B];I===h?T=g[B]:I<h&&(E.push(g[B]),A.push(I))}if(o(T,0))if(o(b[h],0)){if(x===0){var F=[...b];F[h]=1;for(var H=0,$=A.length;H<$;H++){var k=A[H];F[k]=a(F[k],E[H])}v.push(F)}}else{if(x===0)return[];v.splice(x,1),x-=1,w-=1}else{b[h]=i(b[h],T);for(var P=0,R=A.length;P<R;P++){var M=A[P];b[M]=a(b[M],n(b[h],E[P]))}}}return v.map(Q=>new f({data:Q.map(K=>[K]),size:[d,1]}))}}),c2="matAlgo08xS0Sid",f2=["typed","equalScalar"],ys=q(c2,f2,r=>{var{typed:e,equalScalar:t}=r;return function(n,a,o){var f=n._values,l=n._index,u=n._ptr,s=n._size,c=n._datatype,m=a._values,v=a._index,d=a._ptr,p=a._size,g=a._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],h,w=t,x=0,b=o;typeof c=="string"&&c===g&&(h=c,w=e.find(t,[h,h]),x=e.convert(0,h),b=e.find(o,[h,h]));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=d[M],P=d[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:h})}}),bs=q("useMatrixForArrayScalar",["typed","matrix"],r=>{var{typed:e,matrix:t}=r;return{"Array, number":e.referTo("DenseMatrix, number",i=>(n,a)=>i(t(n),a).valueOf()),"Array, BigNumber":e.referTo("DenseMatrix, BigNumber",i=>(n,a)=>i(t(n),a).valueOf()),"number, Array":e.referTo("number, DenseMatrix",i=>(n,a)=>i(n,t(a)).valueOf()),"BigNumber, Array":e.referTo("BigNumber, DenseMatrix",i=>(n,a)=>i(n,t(a)).valueOf())}}),Xm="leftShift",m2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],v2=q(Xm,m2,r=>{var{typed:e,matrix:t,equalScalar:i,zeros:n,DenseMatrix:a,concat:o}=r,f=un({typed:e}),l=bt({typed:e,equalScalar:i}),u=ys({typed:e,equalScalar:i}),s=En({typed:e,DenseMatrix:a}),c=Ur({typed:e,equalScalar:i}),m=yt({typed:e}),v=hr({typed:e,matrix:t,concat:o}),d=bs({typed:e,matrix:t});return e(Xm,{"number, number":hc,"BigNumber, BigNumber":qx,"SparseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>i(y,0)?g.clone():c(g,y,p,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>i(y,0)?g.clone():m(g,y,p,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(p=>(g,y)=>i(g,0)?n(y.size(),y.storage()):s(y,g,p,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(p=>(g,y)=>i(g,0)?n(y.size(),y.storage()):m(y,g,p,!0))},d,v({SS:u,DS:f,SD:l}))}),Wm="rightArithShift",p2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],d2=q(Wm,p2,r=>{var{typed:e,matrix:t,equalScalar:i,zeros:n,DenseMatrix:a,concat:o}=r,f=un({typed:e}),l=bt({typed:e,equalScalar:i}),u=ys({typed:e,equalScalar:i}),s=En({typed:e,DenseMatrix:a}),c=Ur({typed:e,equalScalar:i}),m=yt({typed:e}),v=hr({typed:e,matrix:t,concat:o}),d=bs({typed:e,matrix:t});return e(Wm,{"number, number":gc,"BigNumber, BigNumber":zx,"SparseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>i(y,0)?g.clone():c(g,y,p,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>i(y,0)?g.clone():m(g,y,p,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(p=>(g,y)=>i(g,0)?n(y.size(),y.storage()):s(y,g,p,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(p=>(g,y)=>i(g,0)?n(y.size(),y.storage()):m(y,g,p,!0))},d,v({SS:u,DS:f,SD:l}))}),Ym="rightLogShift",h2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],g2=q(Ym,h2,r=>{var{typed:e,matrix:t,equalScalar:i,zeros:n,DenseMatrix:a,concat:o}=r,f=un({typed:e}),l=bt({typed:e,equalScalar:i}),u=ys({typed:e,equalScalar:i}),s=En({typed:e,DenseMatrix:a}),c=Ur({typed:e,equalScalar:i}),m=yt({typed:e}),v=hr({typed:e,matrix:t,concat:o}),d=bs({typed:e,matrix:t});return e(Ym,{"number, number":yc,"SparseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>i(y,0)?g.clone():c(g,y,p,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>i(y,0)?g.clone():m(g,y,p,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(p=>(g,y)=>i(g,0)?n(y.size(),y.storage()):s(y,g,p,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(p=>(g,y)=>i(g,0)?n(y.size(),y.storage()):m(y,g,p,!0))},d,v({SS:u,DS:f,SD:l}))}),Qm="and",y2=["typed","matrix","equalScalar","zeros","not","concat"],b2=q(Qm,y2,r=>{var{typed:e,matrix:t,equalScalar:i,zeros:n,not:a,concat:o}=r,f=bt({typed:e,equalScalar:i}),l=Si({typed:e,equalScalar:i}),u=Ur({typed:e,equalScalar:i}),s=yt({typed:e}),c=hr({typed:e,matrix:t,concat:o});return e(Qm,{"number, number":Dc,"Complex, Complex":function(v,d){return(v.re!==0||v.im!==0)&&(d.re!==0||d.im!==0)},"BigNumber, BigNumber":function(v,d){return!v.isZero()&&!d.isZero()&&!v.isNaN()&&!d.isNaN()},"Unit, Unit":e.referToSelf(m=>(v,d)=>m(v.value||0,d.value||0)),"SparseMatrix, any":e.referToSelf(m=>(v,d)=>a(d)?n(v.size(),v.storage()):u(v,d,m,!1)),"DenseMatrix, any":e.referToSelf(m=>(v,d)=>a(d)?n(v.size(),v.storage()):s(v,d,m,!1)),"any, SparseMatrix":e.referToSelf(m=>(v,d)=>a(v)?n(v.size(),v.storage()):u(d,v,m,!0)),"any, DenseMatrix":e.referToSelf(m=>(v,d)=>a(v)?n(v.size(),v.storage()):s(d,v,m,!0)),"Array, any":e.referToSelf(m=>(v,d)=>m(t(v),d).valueOf()),"any, Array":e.referToSelf(m=>(v,d)=>m(v,t(d)).valueOf())},c({SS:l,DS:f}))}),Fi="compare",x2=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],w2=q(Fi,x2,r=>{var{typed:e,config:t,equalScalar:i,matrix:n,BigNumber:a,Fraction:o,DenseMatrix:f,concat:l}=r,u=Wr({typed:e}),s=Ci({typed:e,equalScalar:i}),c=Or({typed:e,DenseMatrix:f}),m=hr({typed:e,matrix:n,concat:l}),v=ra({typed:e});return e(Fi,N2({typed:e,config:t}),{"boolean, boolean":function(p,g){return p===g?0:p>g?1:-1},"BigNumber, BigNumber":function(p,g){return Ft(p,g,t.epsilon)?new a(0):new a(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}))}),N2=q(Fi,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Fi,{"number, number":function(n,a){return rt(n,a,t.epsilon)?0:n>a?1:-1}})}),xs,Km;function D2(){return Km||(Km=1,xs=function r(e,t){var i=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,n=/(^[ ]*|[ ]*$)/g,a=/(^([\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(h){return r.insensitive&&(""+h).toLowerCase()||""+h},u=l(e).replace(n,"")||"",s=l(t).replace(n,"")||"",c=u.replace(i,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),m=s.replace(i,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),v=parseInt(u.match(o),16)||c.length!==1&&u.match(a)&&Date.parse(u),d=parseInt(s.match(o),16)||v&&s.match(a)&&Date.parse(s)||null,p,g;if(d){if(v<d)return-1;if(v>d)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}),xs}var A2=D2();const aa=_a(A2);var jm="compareNatural",E2=["typed","compare"],S2=q(jm,E2,r=>{var{typed:e,compare:t}=r,i=t.signatures["boolean,boolean"];return e(jm,{"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:aa(s,c);var v=["Array","DenseMatrix","SparseMatrix"];if(v.includes(s)||v.includes(c))return m=a(n,l,u),m!==0?m:aa(s,c);if(s!==c)return aa(s,c);if(s==="Complex")return C2(l,u);if(s==="Unit")return l.equalBase(u)?n(l.value,u.value):o(n,l.formatUnits(),u.formatUnits());if(s==="boolean")return i(l,u);if(s==="string")return aa(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 a(l,u,s){return wn(u)&&wn(s)?o(l,u.toJSON().values,s.toJSON().values):wn(u)?a(l,u.toArray(),s):wn(s)?a(l,u,s.toArray()):ri(u)?a(l,u.toJSON().data,s):ri(s)?a(l,u,s.toJSON().data):Array.isArray(u)?Array.isArray(s)?o(l,u,s):a(l,u,[s]):a(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(aa),m.sort(aa);var v=o(l,c,m);if(v!==0)return v;for(var d=0;d<c.length;d++){var p=l(u[c[d]],s[m[d]]);if(p!==0)return p}return 0}});function C2(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 ev="compareText",M2=["typed","matrix","concat"];Zo.signature="any, any";var F2=q(ev,M2,r=>{var{typed:e,matrix:t,concat:i}=r,n=hr({typed:e,matrix:t,concat:i});return e(ev,Zo,n({elop:Zo,Ds:!0}))}),Ti="equal",T2=["typed","matrix","equalScalar","DenseMatrix","concat"],B2=q(Ti,T2,r=>{var{typed:e,matrix:t,equalScalar:i,DenseMatrix:n,concat:a}=r,o=Wr({typed:e}),f=Tt({typed:e,DenseMatrix:n}),l=Or({typed:e,DenseMatrix:n}),u=hr({typed:e,matrix:t,concat:a});return e(Ti,$2({typed:e,equalScalar:i}),u({elop:i,SS:f,DS:o,Ss:l}))}),$2=q(Ti,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e(Ti,{"any, any":function(n,a){return n===null?a===null:a===null?n===null:n===void 0?a===void 0:a===void 0?n===void 0:t(n,a)}})}),rv="equalText",O2=["typed","compareText","isZero"],I2=q(rv,O2,r=>{var{typed:e,compareText:t,isZero:i}=r;return e(rv,{"any, any":function(a,o){return i(t(a,o))}})}),Bi="smaller",R2=["typed","config","matrix","DenseMatrix","concat"],_2=q(Bi,R2,r=>{var{typed:e,config:t,matrix:i,DenseMatrix:n,concat:a}=r,o=Wr({typed:e}),f=Tt({typed:e,DenseMatrix:n}),l=Or({typed:e,DenseMatrix:n}),u=hr({typed:e,matrix:i,concat:a}),s=ra({typed:e});return e(Bi,q2({typed:e,config:t}),{"boolean, boolean":(c,m)=>c<m,"BigNumber, BigNumber":function(m,v){return m.lt(v)&&!Ft(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}))}),q2=q(Bi,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Bi,{"number, number":function(n,a){return n<a&&!rt(n,a,t.epsilon)}})}),$i="smallerEq",z2=["typed","config","matrix","DenseMatrix","concat"],P2=q($i,z2,r=>{var{typed:e,config:t,matrix:i,DenseMatrix:n,concat:a}=r,o=Wr({typed:e}),f=Tt({typed:e,DenseMatrix:n}),l=Or({typed:e,DenseMatrix:n}),u=hr({typed:e,matrix:i,concat:a}),s=ra({typed:e});return e($i,L2({typed:e,config:t}),{"boolean, boolean":(c,m)=>c<=m,"BigNumber, BigNumber":function(m,v){return m.lte(v)||Ft(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}))}),L2=q($i,["typed","config"],r=>{var{typed:e,config:t}=r;return e($i,{"number, number":function(n,a){return n<=a||rt(n,a,t.epsilon)}})}),Oi="larger",U2=["typed","config","matrix","DenseMatrix","concat"],k2=q(Oi,U2,r=>{var{typed:e,config:t,matrix:i,DenseMatrix:n,concat:a}=r,o=Wr({typed:e}),f=Tt({typed:e,DenseMatrix:n}),l=Or({typed:e,DenseMatrix:n}),u=hr({typed:e,matrix:i,concat:a}),s=ra({typed:e});return e(Oi,V2({typed:e,config:t}),{"boolean, boolean":(c,m)=>c>m,"BigNumber, BigNumber":function(m,v){return m.gt(v)&&!Ft(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}))}),V2=q(Oi,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Oi,{"number, number":function(n,a){return n>a&&!rt(n,a,t.epsilon)}})}),Ii="largerEq",G2=["typed","config","matrix","DenseMatrix","concat"],H2=q(Ii,G2,r=>{var{typed:e,config:t,matrix:i,DenseMatrix:n,concat:a}=r,o=Wr({typed:e}),f=Tt({typed:e,DenseMatrix:n}),l=Or({typed:e,DenseMatrix:n}),u=hr({typed:e,matrix:i,concat:a}),s=ra({typed:e});return e(Ii,Z2({typed:e,config:t}),{"boolean, boolean":(c,m)=>c>=m,"BigNumber, BigNumber":function(m,v){return m.gte(v)||Ft(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}))}),Z2=q(Ii,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Ii,{"number, number":function(n,a){return n>=a||rt(n,a,t.epsilon)}})}),tv="deepEqual",J2=["typed","equal"],X2=q(tv,J2,r=>{var{typed:e,equal:t}=r;return e(tv,{"any, any":function(a,o){return i(a.valueOf(),o.valueOf())}});function i(n,a){if(Array.isArray(n))if(Array.isArray(a)){var o=n.length;if(o!==a.length)return!1;for(var f=0;f<o;f++)if(!i(n[f],a[f]))return!1;return!0}else return!1;else return Array.isArray(a)?!1:t(n,a)}}),Ri="unequal",W2=["typed","config","equalScalar","matrix","DenseMatrix","concat"],Y2=q(Ri,W2,r=>{var{typed:e,config:t,equalScalar:i,matrix:n,DenseMatrix:a,concat:o}=r,f=Wr({typed:e}),l=Tt({typed:e,DenseMatrix:a}),u=Or({typed:e,DenseMatrix:a}),s=hr({typed:e,matrix:n,concat:o});return e(Ri,Q2({typed:e,equalScalar:i}),s({elop:c,SS:l,DS:f,Ss:u}));function c(m,v){return!i(m,v)}}),Q2=q(Ri,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e(Ri,{"any, any":function(n,a){return n===null?a!==null:a===null?n!==null:n===void 0?a!==void 0:a===void 0?n!==void 0:!t(n,a)}})}),nv="partitionSelect",K2=["typed","isNumeric","isNaN","compare"],j2=q(nv,K2,r=>{var{typed:e,isNumeric:t,isNaN:i,compare:n}=r,a=n,o=(u,s)=>-n(u,s);return e(nv,{"Array | Matrix, number":function(s,c){return f(s,c,a)},"Array | Matrix, number, string":function(s,c,m){if(m==="asc")return f(s,c,a);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])&&i(u[m]))return u[m];for(var v=0,d=u.length-1;v<d;){for(var p=v,g=d,y=u[Math.floor(Math.random()*(d-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?d=p:v=p+1}return u[s]}}),av="sort",eD=["typed","matrix","compare","compareNatural"],rD=q(av,eD,r=>{var{typed:e,matrix:t,compare:i,compareNatural:n}=r,a=i,o=(s,c)=>-i(s,c);return e(av,{Array:function(c){return l(c),c.sort(a)},Matrix:function(c){return u(c),t(c.toArray().sort(a),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 a;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")}}),iv="max",tD=["typed","config","numeric","larger"],ov=q(iv,tD,r=>{var{typed:e,config:t,numeric:i,larger:n}=r;return e(iv,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(l,u){return bi(l,u.valueOf(),a)},"...":function(l){if(Kn(l))throw new TypeError("Scalar values expected in function max");return o(l)}});function a(f,l){try{return n(f,l)?f:l}catch(u){throw Yr(u,"max",l)}}function o(f){var l;if(Zt(f,function(u){try{isNaN(u)&&typeof u=="number"?l=NaN:(l===void 0||n(u,l))&&(l=u)}catch(s){throw Yr(s,"max",u)}}),l===void 0)throw new Error("Cannot calculate max of an empty array");return typeof l=="string"&&(l=i(l,t.number)),l}}),sv="min",nD=["typed","config","numeric","smaller"],uv=q(sv,nD,r=>{var{typed:e,config:t,numeric:i,smaller:n}=r;return e(sv,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(l,u){return bi(l,u.valueOf(),a)},"...":function(l){if(Kn(l))throw new TypeError("Scalar values expected in function min");return o(l)}});function a(f,l){try{return n(f,l)?f:l}catch(u){throw Yr(u,"min",l)}}function o(f){var l;if(Zt(f,function(u){try{isNaN(u)&&typeof u=="number"?l=NaN:(l===void 0||n(u,l))&&(l=u)}catch(s){throw Yr(s,"min",u)}}),l===void 0)throw new Error("Cannot calculate min of an empty array");return typeof l=="string"&&(l=i(l,t.number)),l}}),aD="ImmutableDenseMatrix",iD=["smaller","DenseMatrix"],oD=q(aD,iD,r=>{var{smaller:e,DenseMatrix:t}=r;function i(n,a){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(a&&!Xr(a))throw new Error("Invalid datatype: "+a);if(Ve(n)||cr(n)){var o=new t(n,a);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=a,this._min=null,this._max=null}}return i.prototype=new t,i.prototype.type="ImmutableDenseMatrix",i.prototype.isImmutableDenseMatrix=!0,i.prototype.subset=function(n){switch(arguments.length){case 1:{var a=t.prototype.subset.call(this,n);return Ve(a)?new i({data:a._data,size:a._size,datatype:a._datatype}):a}case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},i.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},i.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},i.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},i.prototype.clone=function(){return new i({data:Ge(this._data),size:Ge(this._size),datatype:this._datatype})},i.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},i.fromJSON=function(n){return new i(n)},i.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},i.prototype.min=function(){if(this._min===null){var n=null;this.forEach(function(a){(n===null||e(a,n))&&(n=a)}),this._min=n!==null?n:void 0}return this._min},i.prototype.max=function(){if(this._max===null){var n=null;this.forEach(function(a){(n===null||e(n,a))&&(n=a)}),this._max=n!==null?n:void 0}return this._max},i},{isClass:!0}),sD="Index",uD=["ImmutableDenseMatrix"],lD=q(sD,uD,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 a=0,o=arguments.length;a<o;a++){var f=arguments[a];if(Uo(f))this._dimensions.push(f),this._isScalar=!1;else if(Array.isArray(f)||Ve(f)){var l=i(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(i([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 i(n){for(var a=0,o=n.length;a<o;a++)if(typeof n[a]!="number"||!qe(n[a]))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 a=new t;return t.apply(a,n),a},t.prototype.size=function(){for(var n=[],a=0,o=this._dimensions.length;a<o;a++){var f=this._dimensions[a];n[a]=typeof f=="string"?1:f.size()[0]}return n},t.prototype.max=function(){for(var n=[],a=0,o=this._dimensions.length;a<o;a++){var f=this._dimensions[a];n[a]=typeof f=="string"?f:f.max()}return n},t.prototype.min=function(){for(var n=[],a=0,o=this._dimensions.length;a<o;a++){var f=this._dimensions[a];n[a]=typeof f=="string"?f:f.min()}return n},t.prototype.forEach=function(n){for(var a=0,o=this._dimensions.length;a<o;a++)n(this._dimensions[a],a,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=[],a=0,o=this._dimensions.length;a<o;a++){var f=this._dimensions[a];n.push(typeof f=="string"?f:f.toArray())}return n},t.prototype.valueOf=t.prototype.toArray,t.prototype.toString=function(){for(var n=[],a=0,o=this._dimensions.length;a<o;a++){var f=this._dimensions[a];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}),cD="FibonacciHeap",fD=["smaller","larger"],mD=q(cD,fD,r=>{var{smaller:e,larger:t}=r,i=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 d=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=d,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=a(this._minimum,s,-1),this.extractMinimum()};function a(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)*i)+1,v=new Array(m),d=0,p=s;if(p)for(d++,p=p.right;p!==s;)d++,p=p.right;for(var g;d>0;){for(var y=p.degree,N=p.right;g=v[y],!!g;){if(t(p.key,g.key)){var h=g;g=p,p=h}l(g,p),v[y]=null,y++}v[y]=p,p=N,d--}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}),vD="Spa",pD=["addScalar","equalScalar","FibonacciHeap"],dD=q(vD,pD,r=>{var{addScalar:e,equalScalar:t,FibonacciHeap:i}=r;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new i}return n.prototype.type="Spa",n.prototype.isSpa=!0,n.prototype.set=function(a,o){if(this._values[a])this._values[a].value=o;else{var f=this._heap.insert(a,o);this._values[a]=f}},n.prototype.get=function(a){var o=this._values[a];return o?o.value:0},n.prototype.accumulate=function(a,o){var f=this._values[a];f?f.value=e(f.value,o):(f=this._heap.insert(a,o),this._values[a]=f)},n.prototype.forEach=function(a,o,f){var l=this._heap,u=this._values,s=[],c=l.extractMinimum();for(c&&s.push(c);c&&c.key<=o;)c.key>=a&&(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(a,o){var f=this._values[a],l=this._values[o];if(!f&&l)f=this._heap.insert(a,l.value),this._heap.remove(l),this._values[a]=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[a]=void 0;else if(f&&l){var u=f.value;f.value=l.value,l.value=u}},n},{isClass:!0});function Ua(r){"@babel/helpers - typeof";return Ua=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},Ua(r)}function hD(r,e){if(Ua(r)!=="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var i=t.call(r,e);if(Ua(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function gD(r){var e=hD(r,"string");return Ua(e)==="symbol"?e:String(e)}function qr(r,e,t){return e=gD(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var yD=qa(function(r){return new r(1).exp()},{hasher:_i}),bD=qa(function(r){return new r(1).plus(new r(5).sqrt()).div(2)},{hasher:_i}),ws=qa(function(r){return r.acos(-1)},{hasher:_i}),xD=qa(function(r){return ws(r).times(2)},{hasher:_i});function _i(r){return r[0].precision}function lv(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,i)}return t}function Ns(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?lv(Object(t),!0).forEach(function(i){qr(r,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):lv(Object(t)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(t,i))})}return r}var wD="Unit",ND=["?on","config","addScalar","subtract","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","number","Complex","BigNumber","Fraction"],DD=q(wD,ND,r=>{var{on:e,config:t,addScalar:i,subtract:n,multiplyScalar:a,divideScalar:o,pow:f,abs:l,fix:u,round:s,equal:c,isNumeric:m,format:v,number:d,Complex:p,BigNumber:g,Fraction:y}=r,N=d;function h(V,X){if(!(this instanceof h))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=h.parse(X);this.units=oe.units,this.dimensions=oe.dimensions}else if(Ut(X)&&X.value===null)this.fixPrefix=X.fixPrefix,this.skipAutomaticSimplification=X.skipAutomaticSimplification,this.dimensions=X.dimensions.slice(0),this.units=X.units.map(G=>zr({},G));else throw new TypeError("Second parameter in Unit constructor must be a string or valueless Unit");this.value=this._normalize(V)}Object.defineProperty(h,"name",{value:"Unit"}),h.prototype.constructor=h,h.prototype.type="Unit",h.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)||h.isValidAlpha(b);)V+=b,D();var X=V.charAt(0);return h.isValidAlpha(X)?V:null}function P(V){return b===V?(D(),V):null}h.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 h;oe.units=[];var G=1,Y=!1;D(),E();var te=B(),be=null;if(te){if(t.number==="BigNumber")be=new g(te);else if(t.number==="Fraction")try{be=new y(te)}catch{be=parseFloat(te)}else be=parseFloat(te);E(),P("*")?(G=1,Y=!0):P("/")&&(G=-1,Y=!0)}for(var ve=[],z=1;;){for(E();b==="(";)ve.push(G),z*=G,G=1,D(),E();var L=void 0;if(b){var ee=b;if(L=I(),L===null)throw new SyntaxError('Unexpected "'+ee+'" in "'+w+'" at index '+x.toString())}else break;var le=R(L);if(le===null)throw new SyntaxError('Unit "'+L+'" not found.');var pe=G*z;if(E(),P("^")){E();var ge=B();if(ge===null)throw new SyntaxError('In "'+V+'", "^" must be followed by a floating-point number');pe*=ge}oe.units.push({unit:le.unit,prefix:le.prefix,power:pe});for(var xe=0;xe<H.length;xe++)oe.dimensions[xe]+=(le.unit.dimensions[xe]||0)*pe;for(E();b===")";){if(ve.length===0)throw new SyntaxError('Unmatched ")" in "'+w+'" at index '+x.toString());z/=ve.pop(),D(),E()}if(Y=!1,P("*")?(G=1,Y=!0):P("/")?(G=-1,Y=!0):G=1,le.unit.base){var de=le.unit.base.key;re.auto[de]={unit:le.unit,prefix:le.prefix}}}if(E(),b)throw new SyntaxError('Could not parse: "'+V+'"');if(Y)throw new SyntaxError('Trailing characters: "'+V+'"');if(ve.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=be!==void 0?oe._normalize(be):null,oe},h.prototype.clone=function(){var V=new h;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},h.prototype.valueType=function(){return br(this.value)},h.prototype._isDerived=function(){return this.units.length===0?!1:this.units.length>1||Math.abs(this.units[0].power-1)>1e-15},h.prototype._normalize=function(V){if(V==null||this.units.length===0)return V;for(var X=V,oe=h._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),be=oe(this.units[G].power);X=a(X,f(a(Y,te),be))}return X},h.prototype._denormalize=function(V,X){if(V==null||this.units.length===0)return V;for(var oe=V,G=h._getNumberConverter(br(V)),Y=0;Y<this.units.length;Y++){var te=G(this.units[Y].unit.value),be=G(this.units[Y].prefix.value),ve=G(this.units[Y].power);oe=o(oe,f(a(te,be),ve))}return oe};var R=qa(V=>{if(Re(U,V)){var X=U[V],oe=X.prefixes[""];return{unit:X,prefix:oe}}for(var G in U)if(Re(U,G)&&cg(V,G)){var Y=U[G],te=V.length-G.length,be=V.substring(0,te),ve=Re(Y.prefixes,be)?Y.prefixes[be]:void 0;if(ve!==void 0)return{unit:Y,prefix:ve}}return null},{hasher:V=>V[0],limit:100});h.isValuelessUnit=function(V){return R(V)!==null},h.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},h.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},h.prototype.equals=function(V){return this.equalBase(V)&&c(this.value,V.value)},h.prototype.multiply=function(V){for(var X=this.clone(),oe=Ut(V)?V:new h(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=Ns({},oe.units[Y]);X.units.push(te)}if(this.value!==null||oe.value!==null){var be=this.value===null?this._normalize(1):this.value,ve=oe.value===null?oe._normalize(1):oe.value;X.value=a(be,ve)}else X.value=null;return Ut(V)&&(X.skipAutomaticSimplification=!1),M(X)},h.prototype.divideInto=function(V){return new h(V).divide(this)},h.prototype.divide=function(V){for(var X=this.clone(),oe=Ut(V)?V:new h(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=Ns(Ns({},oe.units[Y]),{},{power:-oe.units[Y].power});X.units.push(te)}if(this.value!==null||oe.value!==null){var be=this.value===null?this._normalize(1):this.value,ve=oe.value===null?oe._normalize(1):oe.value;X.value=o(be,ve)}else X.value=null;return Ut(V)&&(X.skipAutomaticSimplification=!1),M(X)},h.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}h.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=a(oe,G);V.value=n(l(i(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=U.W);return V},h.prototype.to=function(V){var X=this.value===null?this._normalize(1):this.value,oe;if(typeof V=="string")oe=h.parse(V);else if(Ut(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=h._getNumberConverter(br(X)),Y=G(this.units[0].unit.value),te=G(this.units[0].unit.offset),be=a(Y,te),ve=G(oe.units[0].unit.value),z=G(oe.units[0].unit.offset),L=a(ve,z);oe.value=n(i(X,be),L)}return oe.fixPrefix=!0,oe.skipAutomaticSimplification=!0,oe},h.prototype.toNumber=function(V){return N(this.toNumeric(V))},h.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)},h.prototype.toString=function(){return this.format()},h.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.formatUnits(),fixPrefix:this.fixPrefix}},h.fromJSON=function(V){var X=new h(V.value,V.unit);return X.fixPrefix=V.fixPrefix||!1,X},h.prototype.valueOf=h.prototype.toString,h.prototype.simplify=function(){var V=this.clone(),X=[],oe;for(var G in me)if(Re(me,G)&&V.hasBase($[G])){oe=G;break}if(oe==="NONE")V.units=[];else{var Y;if(oe&&Re(me,oe)&&(Y=me[oe]),Y)V.units=[{unit:Y.unit,prefix:Y.prefix,power:1}];else{for(var te=!1,be=0;be<H.length;be++){var ve=H[be];Math.abs(V.dimensions[be]||0)>1e-12&&(Re(me,ve)?X.push({unit:me[ve].unit,prefix:me[ve].prefix,power:V.dimensions[be]||0}):te=!0)}X.length<V.units.length&&!te&&(V.units=X)}}return V},h.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},h.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 be=V;return oe>0&&G>0&&(be+=" / "),be+=X,be},h.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=U.VAR:X.units[G].unit.name==="VAR"&&!oe&&(X.units[G].unit=U.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||{}):"",be=X.formatUnits();return X.value&&Lt(X.value)&&(te="("+te+")"),be.length>0&&te.length>0&&(te+=" "),te+=be,te},h.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 be in te)if(Re(te,be)){var ve=te[be];if(ve.scientific){var z=Math.abs(Math.log(V/Math.pow(ve.value*X,G))/Math.LN10-1.2);(z<Y||z===Y&&ve.name.length<oe.name.length)&&(oe=ve,Y=z)}}return oe},h.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),be=void 0,ve=c(te,Y);ve?be=te:be=u(X.toNumeric());var z=new h(be,V[G].toString());oe.push(z),X=n(X,z)}for(var L=0,ee=0;ee<oe.length;ee++)L=i(L,oe[ee].value);return c(L,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=zr({},F.SHORT,F.LONG),F.BINARY_SHORT=zr({},F.BINARY_SHORT_SI,F.BINARY_SHORT_IEC),F.BINARY_LONG=zr({},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)},U={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=ws(g);U.rad.value=new g(1),U.deg.value=X.div(180),U.grad.value=X.div(200),U.cycle.value=X.times(2),U.arcsec.value=X.div(648e3),U.arcmin.value=X.div(10800)}else U.rad.value=1,U.deg.value=Math.PI/180,U.grad.value=Math.PI/200,U.cycle.value=Math.PI*2,U.arcsec.value=Math.PI/648e3,U.arcmin.value=Math.PI/10800;U.radian.value=U.rad.value,U.degree.value=U.deg.value,U.gradian.value=U.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:U.m,prefix:F.SHORT[""]},MASS:{unit:U.g,prefix:F.SHORT.k},TIME:{unit:U.s,prefix:F.SHORT[""]},CURRENT:{unit:U.A,prefix:F.SHORT[""]},TEMPERATURE:{unit:U.K,prefix:F.SHORT[""]},LUMINOUS_INTENSITY:{unit:U.cd,prefix:F.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:U.mol,prefix:F.SHORT[""]},ANGLE:{unit:U.rad,prefix:F.SHORT[""]},BIT:{unit:U.bits,prefix:F.SHORT[""]},FORCE:{unit:U.N,prefix:F.SHORT[""]},ENERGY:{unit:U.J,prefix:F.SHORT[""]},POWER:{unit:U.W,prefix:F.SHORT[""]},PRESSURE:{unit:U.Pa,prefix:F.SHORT[""]},ELECTRIC_CHARGE:{unit:U.C,prefix:F.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:U.F,prefix:F.SHORT[""]},ELECTRIC_POTENTIAL:{unit:U.V,prefix:F.SHORT[""]},ELECTRIC_RESISTANCE:{unit:U.ohm,prefix:F.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:U.H,prefix:F.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:U.S,prefix:F.SHORT[""]},MAGNETIC_FLUX:{unit:U.Wb,prefix:F.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:U.T,prefix:F.SHORT[""]},FREQUENCY:{unit:U.Hz,prefix:F.SHORT[""]}}};re.cgs=JSON.parse(JSON.stringify(re.si)),re.cgs.LENGTH={unit:U.m,prefix:F.SHORT.c},re.cgs.MASS={unit:U.g,prefix:F.SHORT[""]},re.cgs.FORCE={unit:U.dyn,prefix:F.SHORT[""]},re.cgs.ENERGY={unit:U.erg,prefix:F.NONE[""]},re.us=JSON.parse(JSON.stringify(re.si)),re.us.LENGTH={unit:U.ft,prefix:F.NONE[""]},re.us.MASS={unit:U.lbm,prefix:F.NONE[""]},re.us.TEMPERATURE={unit:U.degF,prefix:F.NONE[""]},re.us.FORCE={unit:U.lbf,prefix:F.NONE[""]},re.us.ENERGY={unit:U.BTU,prefix:F.BTU[""]},re.us.POWER={unit:U.hp,prefix:F.NONE[""]},re.us.PRESSURE={unit:U.psi,prefix:F.NONE[""]},re.auto=JSON.parse(JSON.stringify(re.si));var me=re.auto;h.setUnitSystem=function(V){if(Re(re,V))me=re[V];else throw new Error("Unit system "+V+" does not exist. Choices are: "+Object.keys(re).join(", "))},h.getUnitSystem=function(){for(var V in re)if(Re(re,V)&&re[V]===me)return V},h.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}},h.prototype._numberConverter=function(){var V=h.typeConverters[this.valueType()];if(V)return V;throw new TypeError('Unsupported Unit value type "'+this.valueType()+'"')},h._getNumberConverter=function(V){if(!h.typeConverters[V])throw new TypeError('Unsupported type "'+V+'"');return h.typeConverters[V]};for(var he in U)if(Re(U,he)){var fe=U[he];fe.dimensions=fe.base.dimensions}for(var ie in j)if(Re(j,ie)){var Ae=U[j[ie]],Oe={};for(var Ce in Ae)Re(Ae,Ce)&&(Oe[Ce]=Ae[Ce]);Oe.name=ie,U[ie]=Oe}h.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&&!h.isValidAlpha(b))throw new Error('Invalid unit name (must begin with alpha character): "'+V+'"');if(X>0&&!(h.isValidAlpha(b)||S(b)))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+V+'"')}}return h.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)&&h.deleteUnit(oe),V[oe].aliases)for(var G=0;G<V[oe].aliases.length;G++)h.deleteUnit(V[oe].aliases[G])}var Y;for(var te in V)Re(V,te)&&(Y=h.createUnitSingle(te,V[te]));return Y},h.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(U,V))throw new Error('Cannot create unit "'+V+'": a unit with that name already exists');$e(V);var oe=null,G=[],Y=0,te,be,ve;if(X&&X.type==="Unit")oe=X.clone();else if(typeof X=="string")X!==""&&(te=X);else if(typeof X=="object")te=X.definition,be=X.prefixes,Y=X.offset,ve=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(U,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=h.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,be&&be.toUpperCase?be=F[be.toUpperCase()]||F.NONE:be=F.NONE;var L={};if(oe){L={name:V,value:oe.value,dimensions:oe.dimensions.slice(0),prefixes:be,offset:Y};var ge=!1;for(var xe in $)if(Re($,xe)){for(var de=!0,Ne=0;Ne<H.length;Ne++)if(Math.abs((L.dimensions[Ne]||0)-($[xe].dimensions[Ne]||0))>1e-12){de=!1;break}if(de){ge=!0,L.base=$[xe];break}}if(!ge){ve=ve||V+"_STUFF";var _e={dimensions:oe.dimensions.slice(0)};_e.key=ve,$[ve]=_e,me[ve]={unit:L,prefix:F.NONE[""]},L.base=$[ve]}}else{if(ve=ve||V+"_STUFF",H.indexOf(ve)>=0)throw new Error('Cannot create new base unit "'+V+'": a base unit with that name already exists (and cannot be overridden)');H.push(ve);for(var ee in $)Re($,ee)&&($[ee].dimensions[H.length-1]=0);for(var le={dimensions:[]},pe=0;pe<H.length;pe++)le.dimensions[pe]=0;le.dimensions[H.length-1]=1,le.key=ve,$[ve]=le,L={name:V,value:1,dimensions:$[ve].dimensions.slice(0),prefixes:be,offset:Y,base:$[ve]},me[ve]={unit:L,prefix:F.NONE[""]}}h.UNITS[V]=L;for(var Ue=0;Ue<G.length;Ue++){var Be=G[Ue],ar={};for(var Je in L)Re(L,Je)&&(ar[Je]=L[Je]);ar.name=Be,h.UNITS[Be]=ar}return delete R.cache,new h(null,V)},h.deleteUnit=function(V){delete h.UNITS[V]},h.PREFIXES=F,h.BASE_DIMENSIONS=H,h.BASE_UNITS=$,h.UNIT_SYSTEMS=re,h.UNITS=U,h},{isClass:!0}),cv="unit",AD=["typed","Unit"],ED=q(cv,AD,r=>{var{typed:e,Unit:t}=r;return e(cv,{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,a){return new t(n,a)},"number | BigNumber | Fraction":function(n){return new t(n)},"Array | Matrix":e.referToSelf(i=>n=>je(n,i))})}),fv="sparse",SD=["typed","SparseMatrix"],CD=q(fv,SD,r=>{var{typed:e,SparseMatrix:t}=r;return e(fv,{"":function(){return new t([])},string:function(n){return new t([],n)},"Array | Matrix":function(n){return new t(n)},"Array | Matrix, string":function(n,a){return new t(n,a)}})}),mv="createUnit",MD=["typed","Unit"],FD=q(mv,MD,r=>{var{typed:e,Unit:t}=r;return e(mv,{"Object, Object":function(n,a){return t.createUnit(n,a)},Object:function(n){return t.createUnit(n,{})},"string, Unit | string | Object, Object":function(n,a,o){var f={};return f[n]=a,t.createUnit(f,o)},"string, Unit | string | Object":function(n,a){var o={};return o[n]=a,t.createUnit(o,{})},string:function(n){var a={};return a[n]={},t.createUnit(a,{})}})}),vv="acos",TD=["typed","config","Complex"],BD=q(vv,TD,r=>{var{typed:e,config:t,Complex:i}=r;return e(vv,{number:function(a){return a>=-1&&a<=1||t.predictable?Math.acos(a):new i(a,0).acos()},Complex:function(a){return a.acos()},BigNumber:function(a){return a.acos()}})}),pv="acosh",$D=["typed","config","Complex"],OD=q(pv,$D,r=>{var{typed:e,config:t,Complex:i}=r;return e(pv,{number:function(a){return a>=1||t.predictable?Cc(a):a<=-1?new i(Math.log(Math.sqrt(a*a-1)-a),Math.PI):new i(a,0).acosh()},Complex:function(a){return a.acosh()},BigNumber:function(a){return a.acosh()}})}),dv="acot",ID=["typed","BigNumber"],RD=q(dv,ID,r=>{var{typed:e,BigNumber:t}=r;return e(dv,{number:Mc,Complex:function(n){return n.acot()},BigNumber:function(n){return new t(1).div(n).atan()}})}),hv="acoth",_D=["typed","config","Complex","BigNumber"],qD=q(hv,_D,r=>{var{typed:e,config:t,Complex:i,BigNumber:n}=r;return e(hv,{number:function(o){return o>=1||o<=-1||t.predictable?Fc(o):new i(o,0).acoth()},Complex:function(o){return o.acoth()},BigNumber:function(o){return new n(1).div(o).atanh()}})}),gv="acsc",zD=["typed","config","Complex","BigNumber"],PD=q(gv,zD,r=>{var{typed:e,config:t,Complex:i,BigNumber:n}=r;return e(gv,{number:function(o){return o<=-1||o>=1||t.predictable?Tc(o):new i(o,0).acsc()},Complex:function(o){return o.acsc()},BigNumber:function(o){return new n(1).div(o).asin()}})}),yv="acsch",LD=["typed","BigNumber"],UD=q(yv,LD,r=>{var{typed:e,BigNumber:t}=r;return e(yv,{number:Bc,Complex:function(n){return n.acsch()},BigNumber:function(n){return new t(1).div(n).asinh()}})}),bv="asec",kD=["typed","config","Complex","BigNumber"],VD=q(bv,kD,r=>{var{typed:e,config:t,Complex:i,BigNumber:n}=r;return e(bv,{number:function(o){return o<=-1||o>=1||t.predictable?$c(o):new i(o,0).asec()},Complex:function(o){return o.asec()},BigNumber:function(o){return new n(1).div(o).acos()}})}),xv="asech",GD=["typed","config","Complex","BigNumber"],HD=q(xv,GD,r=>{var{typed:e,config:t,Complex:i,BigNumber:n}=r;return e(xv,{number:function(o){if(o<=1&&o>=-1||t.predictable){var f=1/o;if(f>0||t.predictable)return Oc(o);var l=Math.sqrt(f*f-1);return new i(Math.log(l-f),Math.PI)}return new i(o,0).asech()},Complex:function(o){return o.asech()},BigNumber:function(o){return new n(1).div(o).acosh()}})}),wv="asin",ZD=["typed","config","Complex"],JD=q(wv,ZD,r=>{var{typed:e,config:t,Complex:i}=r;return e(wv,{number:function(a){return a>=-1&&a<=1||t.predictable?Math.asin(a):new i(a,0).asin()},Complex:function(a){return a.asin()},BigNumber:function(a){return a.asin()}})}),XD="asinh",WD=["typed"],YD=q(XD,WD,r=>{var{typed:e}=r;return e("asinh",{number:Ic,Complex:function(i){return i.asinh()},BigNumber:function(i){return i.asinh()}})}),QD="atan",KD=["typed"],jD=q(QD,KD,r=>{var{typed:e}=r;return e("atan",{number:function(i){return Math.atan(i)},Complex:function(i){return i.atan()},BigNumber:function(i){return i.atan()}})}),Nv="atan2",eA=["typed","matrix","equalScalar","BigNumber","DenseMatrix","concat"],rA=q(Nv,eA,r=>{var{typed:e,matrix:t,equalScalar:i,BigNumber:n,DenseMatrix:a,concat:o}=r,f=bt({typed:e,equalScalar:i}),l=Wr({typed:e}),u=Bf({typed:e,equalScalar:i}),s=Ur({typed:e,equalScalar:i}),c=Or({typed:e,DenseMatrix:a}),m=hr({typed:e,matrix:t,concat:o});return e(Nv,{"number, number":Math.atan2,"BigNumber, BigNumber":(v,d)=>n.atan2(v,d)},m({scalar:"number | BigNumber",SS:u,DS:l,SD:f,Ss:s,sS:c}))}),Dv="atanh",tA=["typed","config","Complex"],nA=q(Dv,tA,r=>{var{typed:e,config:t,Complex:i}=r;return e(Dv,{number:function(a){return a<=1&&a>=-1||t.predictable?Rc(a):new i(a,0).atanh()},Complex:function(a){return a.atanh()},BigNumber:function(a){return a.atanh()}})}),ia=q("trigUnit",["typed"],r=>{var{typed:e}=r;return{Unit:e.referToSelf(t=>i=>{if(!i.hasBase(i.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return e.find(t,i.valueType())(i.value)})}}),Av="cos",aA=["typed"],iA=q(Av,aA,r=>{var{typed:e}=r,t=ia({typed:e});return e(Av,{number:Math.cos,"Complex | BigNumber":i=>i.cos()},t)}),Ev="cosh",oA=["typed"],sA=q(Ev,oA,r=>{var{typed:e}=r;return e(Ev,{number:ng,"Complex | BigNumber":t=>t.cosh()})}),Sv="cot",uA=["typed","BigNumber"],lA=q(Sv,uA,r=>{var{typed:e,BigNumber:t}=r,i=ia({typed:e});return e(Sv,{number:_c,Complex:n=>n.cot(),BigNumber:n=>new t(1).div(n.tan())},i)}),Cv="coth",cA=["typed","BigNumber"],fA=q(Cv,cA,r=>{var{typed:e,BigNumber:t}=r;return e(Cv,{number:qc,Complex:i=>i.coth(),BigNumber:i=>new t(1).div(i.tanh())})}),Mv="csc",mA=["typed","BigNumber"],vA=q(Mv,mA,r=>{var{typed:e,BigNumber:t}=r,i=ia({typed:e});return e(Mv,{number:zc,Complex:n=>n.csc(),BigNumber:n=>new t(1).div(n.sin())},i)}),Fv="csch",pA=["typed","BigNumber"],dA=q(Fv,pA,r=>{var{typed:e,BigNumber:t}=r;return e(Fv,{number:Pc,Complex:i=>i.csch(),BigNumber:i=>new t(1).div(i.sinh())})}),Tv="sec",hA=["typed","BigNumber"],gA=q(Tv,hA,r=>{var{typed:e,BigNumber:t}=r,i=ia({typed:e});return e(Tv,{number:Lc,Complex:n=>n.sec(),BigNumber:n=>new t(1).div(n.cos())},i)}),Bv="sech",yA=["typed","BigNumber"],bA=q(Bv,yA,r=>{var{typed:e,BigNumber:t}=r;return e(Bv,{number:Uc,Complex:i=>i.sech(),BigNumber:i=>new t(1).div(i.cosh())})}),$v="sin",xA=["typed"],wA=q($v,xA,r=>{var{typed:e}=r,t=ia({typed:e});return e($v,{number:Math.sin,"Complex | BigNumber":i=>i.sin()},t)}),Ov="sinh",NA=["typed"],DA=q(Ov,NA,r=>{var{typed:e}=r;return e(Ov,{number:kc,"Complex | BigNumber":t=>t.sinh()})}),Iv="tan",AA=["typed"],EA=q(Iv,AA,r=>{var{typed:e}=r,t=ia({typed:e});return e(Iv,{number:Math.tan,"Complex | BigNumber":i=>i.tan()},t)}),SA="tanh",CA=["typed"],MA=q(SA,CA,r=>{var{typed:e}=r;return e("tanh",{number:ig,"Complex | BigNumber":t=>t.tanh()})}),Rv="setCartesian",FA=["typed","size","subset","compareNatural","Index","DenseMatrix"],TA=q(Rv,FA,r=>{var{typed:e,size:t,subset:i,compareNatural:n,Index:a,DenseMatrix:o}=r;return e(Rv,{"Array | Matrix, Array | Matrix":function(l,u){var s=[];if(i(t(l),new a(0))!==0&&i(t(u),new a(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 d=0;d<m.length;d++)s.push([c[v],m[d]])}return Array.isArray(l)&&Array.isArray(u)?s:new o(s)}})}),_v="setDifference",BA=["typed","size","subset","compareNatural","Index","DenseMatrix"],$A=q(_v,BA,r=>{var{typed:e,size:t,subset:i,compareNatural:n,Index:a,DenseMatrix:o}=r;return e(_v,{"Array | Matrix, Array | Matrix":function(l,u){var s;if(i(t(l),new a(0))===0)s=[];else{if(i(t(u),new a(0))===0)return or(l.toArray());var c=Zn(or(Array.isArray(l)?l:l.toArray()).sort(n)),m=Zn(or(Array.isArray(u)?u:u.toArray()).sort(n));s=[];for(var v,d=0;d<c.length;d++){v=!1;for(var p=0;p<m.length;p++)if(n(c[d].value,m[p].value)===0&&c[d].identifier===m[p].identifier){v=!0;break}v||s.push(c[d])}}return Array.isArray(l)&&Array.isArray(u)?ci(s):new o(ci(s))}})}),qv="setDistinct",OA=["typed","size","subset","compareNatural","Index","DenseMatrix"],IA=q(qv,OA,r=>{var{typed:e,size:t,subset:i,compareNatural:n,Index:a,DenseMatrix:o}=r;return e(qv,{"Array | Matrix":function(l){var u;if(i(t(l),new a(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)}})}),zv="setIntersect",RA=["typed","size","subset","compareNatural","Index","DenseMatrix"],_A=q(zv,RA,r=>{var{typed:e,size:t,subset:i,compareNatural:n,Index:a,DenseMatrix:o}=r;return e(zv,{"Array | Matrix, Array | Matrix":function(l,u){var s;if(i(t(l),new a(0))===0||i(t(u),new a(0))===0)s=[];else{var c=Zn(or(Array.isArray(l)?l:l.toArray()).sort(n)),m=Zn(or(Array.isArray(u)?u:u.toArray()).sort(n));s=[];for(var v=0;v<c.length;v++)for(var d=0;d<m.length;d++)if(n(c[v].value,m[d].value)===0&&c[v].identifier===m[d].identifier){s.push(c[v]);break}}return Array.isArray(l)&&Array.isArray(u)?ci(s):new o(ci(s))}})}),Pv="setIsSubset",qA=["typed","size","subset","compareNatural","Index"],zA=q(Pv,qA,r=>{var{typed:e,size:t,subset:i,compareNatural:n,Index:a}=r;return e(Pv,{"Array | Matrix, Array | Matrix":function(f,l){if(i(t(f),new a(0))===0)return!0;if(i(t(l),new a(0))===0)return!1;for(var u=Zn(or(Array.isArray(f)?f:f.toArray()).sort(n)),s=Zn(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",PA=["typed","size","subset","compareNatural","Index"],LA=q(Lv,PA,r=>{var{typed:e,size:t,subset:i,compareNatural:n,Index:a}=r;return e(Lv,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(f,l){if(i(t(l),new a(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}})}),Uv="setPowerset",UA=["typed","size","subset","compareNatural","Index"],kA=q(Uv,UA,r=>{var{typed:e,size:t,subset:i,compareNatural:n,Index:a}=r;return e(Uv,{"Array | Matrix":function(u){if(i(t(u),new a(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}}),kv="setSize",VA=["typed","compareNatural"],GA=q(kv,VA,r=>{var{typed:e,compareNatural:t}=r;return e(kv,{"Array | Matrix":function(n){return Array.isArray(n)?or(n).length:or(n.toArray()).length},"Array | Matrix, boolean":function(n,a){if(a===!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}})}),Vv="setSymDifference",HA=["typed","size","concat","subset","setDifference","Index"],ZA=q(Vv,HA,r=>{var{typed:e,size:t,concat:i,subset:n,setDifference:a,Index:o}=r;return e(Vv,{"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 i(a(s,c),a(c,s))}})}),Gv="setUnion",JA=["typed","size","concat","subset","setIntersect","setSymDifference","Index"],XA=q(Gv,JA,r=>{var{typed:e,size:t,concat:i,subset:n,setIntersect:a,setSymDifference:o,Index:f}=r;return e(Gv,{"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 i(o(c,m),a(c,m))}})}),Hv="add",WA=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],YA=q(Hv,WA,r=>{var{typed:e,matrix:t,addScalar:i,equalScalar:n,DenseMatrix:a,SparseMatrix:o,concat:f}=r,l=un({typed:e}),u=ps({typed:e,equalScalar:n}),s=En({typed:e,DenseMatrix:a}),c=hr({typed:e,matrix:t,concat:f});return e(Hv,{"any, any":i,"any, any, ...any":e.referToSelf(m=>(v,d,p)=>{for(var g=m(v,d),y=0;y<p.length;y++)g=m(g,p[y]);return g})},c({elop:i,DS:l,SS:u,Ss:s}))}),Zv="hypot",QA=["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],KA=q(Zv,QA,r=>{var{typed:e,abs:t,addScalar:i,divideScalar:n,multiplyScalar:a,sqrt:o,smaller:f,isPositive:l}=r;return e(Zv,{"... 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 d=t(s[v]);f(m,d)?(c=a(c,a(n(m,d),n(m,d))),c=i(c,1),m=d):c=i(c,l(d)?a(n(d,m),n(d,m)):d)}return a(m,o(c))}}),Jv="norm",jA=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],eE=q(Jv,jA,r=>{var{typed:e,abs:t,add:i,pow:n,conj:a,sqrt:o,multiply:f,equalScalar:l,larger:u,smaller:s,matrix:c,ctranspose:m,eigs:v}=r;return e(Jv,{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 d(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 d(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=i(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=i(A,f(S,a(S)))}),t(o(A))}function N(E){var A=[],S=0;return E.forEach(function(D,T){var B=T[1],I=i(A[B]||0,t(D));u(I,S)&&(S=I),A[B]=I},!0),S}function h(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=i(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 h(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")}}}),Xv="dot",rE=["typed","addScalar","multiplyScalar","conj","size"],tE=q(Xv,rE,r=>{var{typed:e,addScalar:t,multiplyScalar:i,conj:n,size:a}=r;return e(Xv,{"Array | DenseMatrix, Array | DenseMatrix":f,"SparseMatrix, SparseMatrix":l});function o(s,c){var m=u(s),v=u(c),d,p;if(m.length===1)d=m[0];else if(m.length===2&&m[1]===1)d=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(d!==p)throw new RangeError("Vectors must have equal length ("+d+" != "+p+")");if(d===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return d}function f(s,c){var m=o(s,c),v=Ve(s)?s._data:s,d=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,h=t,w=i;if(d&&g&&d===g&&typeof d=="string"){var x=d;h=e.find(t,[x,x]),w=e.find(i,[x,x])}if(!y&&!N){for(var b=w(n(v[0]),p[0]),E=1;E<m;E++)b=h(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=h(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=h(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=h(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,d=c._index,p=c._values,g=0,y=t,N=i,h=0,w=0;h<m.length&&w<d.length;){var x=m[h],b=d[w];if(x<b){h++;continue}if(x>b){w++;continue}x===b&&(g=y(g,N(v[h],p[w])),h++,w++)}return g}function u(s){return Ve(s)?s.size():a(s)}}),nE="trace",aE=["typed","matrix","add"],iE=q(nE,aE,r=>{var{typed:e,matrix:t,add:i}=r;return e("trace",{Array:function(f){return n(t(f))},SparseMatrix:a,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=i(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 a(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 d=0;d<m;d++)for(var p=u[d],g=u[d+1],y=p;y<g;y++){var N=l[y];if(N===d){v=i(v,f[y]);break}if(N>d)break}return v}throw new RangeError("Matrix must be square (size: "+Ye(s)+")")}}),Wv="index",oE=["typed","Index"],sE=q(Wv,oE,r=>{var{typed:e,Index:t}=r;return e(Wv,{"...number | string | BigNumber | Range | Array | Matrix":function(n){var a=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,a),o}})}),Yv=new Set(["end"]),uE="Node",lE=["mathWithTransform"],cE=q(uE,lE,r=>{var{mathWithTransform:e}=r;function t(n){for(var a of[...Yv])if(n.has(a))throw new Error('Scope contains an illegal symbol, "'+a+'" is a reserved keyword')}class i{get type(){return"Node"}get isNode(){return!0}evaluate(a){return this.compile().evaluate(a)}compile(){var a=this._compile(e,{}),o={},f=null;function l(u){var s=Wn(u);return t(s),a(s,o,f)}return{evaluate:l}}_compile(a,o){throw new Error("Method _compile must be implemented by type "+this.type)}forEach(a){throw new Error("Cannot run forEach on a Node interface")}map(a){throw new Error("Cannot run map on a Node interface")}_ifNode(a){if(!fr(a))throw new TypeError("Callback function must return a Node");return a}traverse(a){a(this,null,null);function o(f,l){f.forEach(function(u,s,c){l(u,s,c),o(u,l)})}o(this,a)}transform(a){function o(f,l,u){var s=a(f,l,u);return s!==f?s:f.map(o)}return o(this,null,null)}filter(a){var o=[];return this.traverse(function(f,l,u){a(f,l,u)&&o.push(f)}),o}clone(){throw new Error("Cannot clone a Node interface")}cloneDeep(){return this.map(function(a){return a.cloneDeep()})}equals(a){return a?this.type===a.type&&Oa(this,a):!1}toString(a){var o=this._getCustomString(a);return typeof o<"u"?o:this._toString(a)}toJSON(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)}toHTML(a){var o=this._getCustomString(a);return typeof o<"u"?o:this.toHTML(a)}_toString(){throw new Error("_toString not implemented for "+this.type)}toTex(a){var o=this._getCustomString(a);return typeof o<"u"?o:this._toTex(a)}_toTex(a){throw new Error("_toTex not implemented for "+this.type)}_getCustomString(a){if(a&&typeof a=="object")switch(typeof a.handler){case"object":case"undefined":return;case"function":return a.handler(this,a);default:throw new TypeError("Object or function expected as callback")}}getIdentifier(){return this.type}getContent(){return this}}return i},{isClass:!0,isNode:!0});function Qr(r){return r&&r.isIndexError?new pt(r.index+1,r.min+1,r.max!==void 0?r.max+1:void 0):r}function Qv(r){var{subset:e}=r;return function(i,n){try{if(Array.isArray(i))return e(i,n);if(i&&typeof i.subset=="function")return i.subset(n);if(typeof i=="string")return e(i,n);if(typeof i=="object"){if(!n.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return st(i,n.getObjectProperty())}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(a){throw Qr(a)}}}var qi="AccessorNode",fE=["subset","Node"],mE=q(qi,fE,r=>{var{subset:e,Node:t}=r,i=Qv({subset:e});function n(o){return!(Nn(o)||at(o)||ir(o)||jt(o)||ni(o)||kt(o)||_r(o))}class a extends t{constructor(f,l){if(super(),!fr(f))throw new TypeError('Node expected for parameter "object"');if(!Un(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 qi}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,d,p){return st(u(v,d,p),c)}}else return function(v,d,p){var g=u(v,d,p),y=s(v,d,g);return i(g,y)}}forEach(f){f(this.object,"object",this),f(this.index,"index",this)}map(f){return new a(this._ifNode(f(this.object,"object",this)),this._ifNode(f(this.index,"index",this)))}clone(){return new a(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:qi,object:this.object,index:this.index}}static fromJSON(f){return new a(f.object,f.index)}}return qr(a,"name",qi),a},{isClass:!0,isNode:!0}),zi="ArrayNode",vE=["Node"],pE=q(zi,vE,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 zi}get isArrayNode(){return!0}_compile(n,a){var o=Vt(this.items,function(u){return u._compile(n,a)}),f=n.config.matrix!=="Array";if(f){var l=n.matrix;return function(s,c,m){return l(Vt(o,function(v){return v(s,c,m)}))}}else return function(s,c,m){return Vt(o,function(v){return v(s,c,m)})}}forEach(n){for(var a=0;a<this.items.length;a++){var o=this.items[a];n(o,"items["+a+"]",this)}}map(n){for(var a=[],o=0;o<this.items.length;o++)a[o]=this._ifNode(n(this.items[o],"items["+o+"]",this));return new t(a)}clone(){return new t(this.items.slice(0))}_toString(n){var a=this.items.map(function(o){return o.toString(n)});return"["+a.join(", ")+"]"}toJSON(){return{mathjs:zi,items:this.items}}static fromJSON(n){return new t(n.items)}toHTML(n){var a=this.items.map(function(o){return o.toHTML(n)});return'<span class="math-parenthesis math-square-parenthesis">[</span>'+a.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(n){function a(o,f){var l=o.some(at)&&!o.every(at),u=f||l,s=u?"&":"\\\\",c=o.map(function(m){return m.items?a(m.items,!f):m.toTex(n)}).join(s);return l||!u||u&&!f?"\\begin{bmatrix}"+c+"\\end{bmatrix}":c}return a(this.items,!1)}}return qr(t,"name",zi),t},{isClass:!0,isNode:!0});function dE(r){var{subset:e,matrix:t}=r;return function(n,a,o){try{if(Array.isArray(n))return t(n).subset(a,o).valueOf();if(n&&typeof n.subset=="function")return n.subset(a,o);if(typeof n=="string")return e(n,a,o);if(typeof n=="object"){if(!a.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return Jn(n,a.getObjectProperty(),o),n}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(f){throw Qr(f)}}}var xt=[{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 Pi(r,e){if(!e||e!=="auto")return r;for(var t=r;kt(t);)t=t.content;return t}function pr(r,e,t,i){var n=r;e!=="keep"&&(n=r.getContent());for(var a=n.getIdentifier(),o=null,f=0;f<xt.length;f++)if(a in xt[f]){o=f;break}if(a==="OperatorNode:multiply"&&n.implicit&&t!=="show"){var l=Pi(n.args[0],e);!(ir(l)&&i&&i.getIdentifier()==="OperatorNode:divide"&&Vo(Pi(i.args[0],e)))&&!(l.getIdentifier()==="OperatorNode:divide"&&Vo(Pi(l.args[0],e))&&ir(Pi(l.args[1])))&&(o+=1)}return o}function ka(r,e){var t=r;e!=="keep"&&(t=r.getContent());var i=t.getIdentifier(),n=pr(t,e);if(n===null)return null;var a=xt[n][i];if(Re(a,"associativity")){if(a.associativity==="left")return"left";if(a.associativity==="right")return"right";throw Error("'"+i+"' has the invalid associativity '"+a.associativity+"'.")}return null}function Ds(r,e,t){var i=t!=="keep"?r.getContent():r,n=t!=="keep"?r.getContent():e,a=i.getIdentifier(),o=n.getIdentifier(),f=pr(i,t);if(f===null)return null;var l=xt[f][a];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 hE(r){var e="OperatorNode:"+r;for(var t of xt)if(e in t)return t[e].op;return null}var Li="AssignmentNode",gE=["subset","?matrix","Node"],yE=q(Li,gE,r=>{var{subset:e,matrix:t,Node:i}=r,n=Qv({subset:e}),a=dE({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 i{constructor(u,s,c){if(super(),this.object=u,this.index=c?s:null,this.value=c||s,!_r(u)&&!Nn(u))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(_r(u)&&u.name==="end")throw new Error('Cannot assign to symbol "end"');if(this.index&&!Un(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 Li}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),d=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(_r(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(d,a(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=st(E,y),S=m(w,x,A),D=v(w,x,b);return Jn(E,y,a(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 a(E,A,a(S,D,T)),T}}}else{if(!_r(this.object))throw new TypeError("SymbolNode expected as object");return function(w,x,b){var E=v(w,x,b);return w.set(d,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:Li,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 qr(f,"name",Li),f},{isClass:!0,isNode:!0}),Ui="BlockNode",bE=["ResultSet","Node"],xE=q(Ui,bE,r=>{var{ResultSet:e,Node:t}=r;class i extends t{constructor(a){if(super(),!Array.isArray(a))throw new Error("Array expected");this.blocks=a.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 Ui}get isBlockNode(){return!0}_compile(a,o){var f=Vt(this.blocks,function(l){return{evaluate:l.node._compile(a,o),visible:l.visible}});return function(u,s,c){var m=[];return ui(f,function(d){var p=d.evaluate(u,s,c);d.visible&&m.push(p)}),new e(m)}}forEach(a){for(var o=0;o<this.blocks.length;o++)a(this.blocks[o].node,"blocks["+o+"].node",this)}map(a){for(var o=[],f=0;f<this.blocks.length;f++){var l=this.blocks[f],u=this._ifNode(a(l.node,"blocks["+f+"].node",this));o[f]={node:u,visible:l.visible}}return new i(o)}clone(){var a=this.blocks.map(function(o){return{node:o.node,visible:o.visible}});return new i(a)}_toString(a){return this.blocks.map(function(o){return o.node.toString(a)+(o.visible?"":";")}).join(`
13
+ `)}toJSON(){return{mathjs:Ui,blocks:this.blocks}}static fromJSON(a){return new i(a.blocks)}toHTML(a){return this.blocks.map(function(o){return o.node.toHTML(a)+(o.visible?"":'<span class="math-separator">;</span>')}).join('<span class="math-separator"><br /></span>')}_toTex(a){return this.blocks.map(function(o){return o.node.toTex(a)+(o.visible?"":";")}).join(`\\;\\;
14
+ `)}}return qr(i,"name",Ui),i},{isClass:!0,isNode:!0}),ki="ConditionalNode",wE=["Node"],NE=q(ki,wE,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(Ut(n))return!!n.value}if(n==null)return!1;throw new TypeError('Unsupported type of condition "'+br(n)+'"')}class i extends e{constructor(a,o,f){if(super(),!fr(a))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=a,this.trueExpr=o,this.falseExpr=f}get type(){return ki}get isConditionalNode(){return!0}_compile(a,o){var f=this.condition._compile(a,o),l=this.trueExpr._compile(a,o),u=this.falseExpr._compile(a,o);return function(c,m,v){return t(f(c,m,v))?l(c,m,v):u(c,m,v)}}forEach(a){a(this.condition,"condition",this),a(this.trueExpr,"trueExpr",this),a(this.falseExpr,"falseExpr",this)}map(a){return new i(this._ifNode(a(this.condition,"condition",this)),this._ifNode(a(this.trueExpr,"trueExpr",this)),this._ifNode(a(this.falseExpr,"falseExpr",this)))}clone(){return new i(this.condition,this.trueExpr,this.falseExpr)}_toString(a){var o=a&&a.parenthesis?a.parenthesis:"keep",f=pr(this,o,a&&a.implicit),l=this.condition.toString(a),u=pr(this.condition,o,a&&a.implicit);(o==="all"||this.condition.type==="OperatorNode"||u!==null&&u<=f)&&(l="("+l+")");var s=this.trueExpr.toString(a),c=pr(this.trueExpr,o,a&&a.implicit);(o==="all"||this.trueExpr.type==="OperatorNode"||c!==null&&c<=f)&&(s="("+s+")");var m=this.falseExpr.toString(a),v=pr(this.falseExpr,o,a&&a.implicit);return(o==="all"||this.falseExpr.type==="OperatorNode"||v!==null&&v<=f)&&(m="("+m+")"),l+" ? "+s+" : "+m}toJSON(){return{mathjs:ki,condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}}static fromJSON(a){return new i(a.condition,a.trueExpr,a.falseExpr)}toHTML(a){var o=a&&a.parenthesis?a.parenthesis:"keep",f=pr(this,o,a&&a.implicit),l=this.condition.toHTML(a),u=pr(this.condition,o,a&&a.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(a),c=pr(this.trueExpr,o,a&&a.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(a),v=pr(this.falseExpr,o,a&&a.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(a){return"\\begin{cases} {"+this.trueExpr.toTex(a)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(a)+"}\\\\{"+this.falseExpr.toTex(a)+"}, &\\quad{\\text{otherwise}}\\end{cases}"}}return qr(i,"name",ki),i},{isClass:!0,isNode:!0}),As,Kv;function DE(){if(Kv)return As;Kv=1;var r=Object.assign||function(n){for(var a=1;a<arguments.length;a++){var o=arguments[a];for(var f in o)Object.prototype.hasOwnProperty.call(o,f)&&(n[f]=o[f])}return n},e={"{":"\\{","}":"\\}","\\":"\\textbackslash{}","#":"\\#",$:"\\$","%":"\\%","&":"\\&","^":"\\textasciicircum{}",_:"\\_","~":"\\textasciitilde{}"},t={"–":"\\--","—":"\\---"," ":"~"," ":"\\qquad{}","\r\n":"\\newline{}","\n":"\\newline{}"},i=function(a,o){return r({},a,o)};return As=function(n){for(var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=a.preserveFormatting,f=o===void 0?!1:o,l=a.escapeMapFn,u=l===void 0?i:l,s=String(n),c="",m=u(r({},e),f?r({},t):{}),v=Object.keys(m),d=function(){var g=!1;v.forEach(function(y,N){g||s.length>=y.length&&s.slice(0,y.length)===y&&(c+=m[v[N]],s=s.slice(y.length,s.length),g=!0)}),g||(c+=s.slice(0,1),s=s.slice(1,s.length))};s;)d();return c},As}var AE=DE();const EE=_a(AE);var Es={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(Es.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)"}},SE="\\mathrm{${name}}\\left(${args}\\right)",ep={deg:"^\\circ"};function Ss(r){return EE(r,{preserveFormatting:!0})}function rp(r,e){return e=typeof e>"u"?!1:e,e?Re(ep,r)?ep[r]:"\\mathrm{"+Ss(r)+"}":Re(Es,r)?Es[r]:Ss(r)}var Vi="ConstantNode",CE=["Node"],ME=q(Vi,CE,r=>{var{Node:e}=r;class t extends e{constructor(n){super(),this.value=n}get type(){return Vi}get isConstantNode(){return!0}_compile(n,a){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 a=this._toString(n);switch(br(this.value)){case"number":case"BigNumber":case"Fraction":return'<span class="math-number">'+a+"</span>";case"string":return'<span class="math-string">'+a+"</span>";case"boolean":return'<span class="math-boolean">'+a+"</span>";case"null":return'<span class="math-null-symbol">'+a+"</span>";case"undefined":return'<span class="math-undefined">'+a+"</span>";default:return'<span class="math-symbol">'+a+"</span>"}}toJSON(){return{mathjs:Vi,value:this.value}}static fromJSON(n){return new t(n.value)}_toTex(n){var a=this._toString(n);switch(br(this.value)){case"string":return"\\mathtt{"+Ss(a)+"}";case"number":case"BigNumber":{if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var o=a.toLowerCase().indexOf("e");if(o!==-1)return a.substring(0,o)+"\\cdot10^{"+a.substring(o+1)+"}"}return a;case"Fraction":return this.value.toLatex();default:return a}}}return qr(t,"name",Vi),t},{isClass:!0,isNode:!0}),Gi="FunctionAssignmentNode",FE=["typed","Node"],TE=q(Gi,FE,r=>{var{typed:e,Node:t}=r;function i(a,o,f){var l=pr(a,o,f),u=pr(a.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(Yv.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 Gi}get isFunctionAssignmentNode(){return!0}_compile(o,f){var l=Object.create(f);ui(this.params,function(d){l[d]=!0});var u=this.expr._compile(o,l),s=this.name,c=this.params,m=Al(this.types,","),v=s+"("+Al(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 h=e(s,N);return h.syntax=v,p.set(s,h),h}}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 i(this,f,o&&o.implicit)&&(l="("+l+")"),this.name+"("+this.params.join(", ")+") = "+l}toJSON(){var o=this.types;return{mathjs:Gi,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">'+ot(this.params[u])+"</span>");var s=this.expr.toHTML(o);return i(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">'+ot(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 i(this,f,o&&o.implicit)&&(l="\\left(".concat(l,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(rp).join(",")+"\\right):="+l}}return qr(n,"name",Gi),n},{isClass:!0,isNode:!0}),Hi="IndexNode",BE=["Node","size"],$E=q(Hi,BE,r=>{var{Node:e,size:t}=r;class i extends e{constructor(a,o){if(super(),this.dimensions=a,this.dotNotation=o||!1,!Array.isArray(a)||!a.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 Hi}get isIndexNode(){return!0}_compile(a,o){var f=Vt(this.dimensions,function(u,s){var c=u.filter(d=>d.isSymbolNode&&d.name==="end").length>0;if(c){var m=Object.create(o);m.end=!0;var v=u._compile(a,m);return function(p,g,y){if(!Ve(y)&&!cr(y)&&!Xr(y))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+br(y));var N=t(y).valueOf(),h=Object.create(g);return h.end=N[s],v(p,h,y)}}else return u._compile(a,o)}),l=st(a,"index");return function(s,c,m){var v=Vt(f,function(d){return d(s,c,m)});return l(...v)}}forEach(a){for(var o=0;o<this.dimensions.length;o++)a(this.dimensions[o],"dimensions["+o+"]",this)}map(a){for(var o=[],f=0;f<this.dimensions.length;f++)o[f]=this._ifNode(a(this.dimensions[f],"dimensions["+f+"]",this));return new i(o,this.dotNotation)}clone(){return new i(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(a){return this.dotNotation?"."+this.getObjectProperty():"["+this.dimensions.join(", ")+"]"}toJSON(){return{mathjs:Hi,dimensions:this.dimensions,dotNotation:this.dotNotation}}static fromJSON(a){return new i(a.dimensions,a.dotNotation)}toHTML(a){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">'+ot(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(a){var o=this.dimensions.map(function(f){return f.toTex(a)});return this.dotNotation?"."+this.getObjectProperty():"_{"+o.join(",")+"}"}}return qr(i,"name",Hi),i},{isClass:!0,isNode:!0}),Zi="ObjectNode",OE=["Node"],IE=q(Zi,OE,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(a){return fr(n[a])})))throw new TypeError("Object containing Nodes expected")}get type(){return Zi}get isObjectNode(){return!0}_compile(n,a){var o={};for(var f in this.properties)if(Re(this.properties,f)){var l=oi(f),u=JSON.parse(l);if(!Wo(this.properties,u))throw new Error('No access to property "'+u+'"');o[u]=this.properties[f]._compile(n,a)}return function(c,m,v){var d={};for(var p in o)Re(o,p)&&(d[p]=o[p](c,m,v));return d}}forEach(n){for(var a in this.properties)Re(this.properties,a)&&n(this.properties[a],"properties["+oi(a)+"]",this)}map(n){var a={};for(var o in this.properties)Re(this.properties,o)&&(a[o]=this._ifNode(n(this.properties[o],"properties["+oi(o)+"]",this)));return new t(a)}clone(){var n={};for(var a in this.properties)Re(this.properties,a)&&(n[a]=this.properties[a]);return new t(n)}_toString(n){var a=[];for(var o in this.properties)Re(this.properties,o)&&a.push(oi(o)+": "+this.properties[o].toString(n));return"{"+a.join(", ")+"}"}toJSON(){return{mathjs:Zi,properties:this.properties}}static fromJSON(n){return new t(n.properties)}toHTML(n){var a=[];for(var o in this.properties)Re(this.properties,o)&&a.push('<span class="math-symbol math-property">'+ot(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>'+a.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-curly-parenthesis">}</span>'}_toTex(n){var a=[];for(var o in this.properties)Re(this.properties,o)&&a.push("\\mathbf{"+o+":} & "+this.properties[o].toTex(n)+"\\\\");var f="\\left\\{\\begin{array}{ll}"+a.join(`
15
+ `)+"\\end{array}\\right\\}";return f}}return qr(t,"name",Zi),t},{isClass:!0,isNode:!0}),Ji="OperatorNode",RE=["Node"],_E=q(Ji,RE,r=>{var{Node:e}=r;function t(a,o){var f=a;if(o==="auto")for(;kt(f);)f=f.content;return ir(f)?!0:Tr(f)?t(f.args[0],o):!1}function i(a,o,f,l,u){var s=pr(a,o,f),c=ka(a,o);if(o==="all"||l.length>2&&a.getIdentifier()!=="OperatorNode:add"&&a.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,a);if(u&&v!==null){var d,p;if(o==="keep"?(d=l[0].getIdentifier(),p=a.getIdentifier()):(d=l[0].getContent().getIdentifier(),p=a.getContent().getIdentifier()),xt[s][p].latexLeftParens===!1){m=[!1];break}if(xt[v][d].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,a),N=Ds(a,l[0],o);y===null?g=!1:y===s&&c==="right"&&!N||y<s?g=!0:g=!1;var h,w=pr(l[1],o,f,a),x=Ds(a,l[1],o);if(w===null?h=!1:w===s&&c==="left"&&!x||w<s?h=!0:h=!1,u){var b,E,A;o==="keep"?(b=a.getIdentifier(),E=a.args[0].getIdentifier(),A=a.args[1].getIdentifier()):(b=a.getContent().getIdentifier(),E=a.args[0].getContent().getIdentifier(),A=a.args[1].getContent().getIdentifier()),y!==null&&(xt[s][b].latexLeftParens===!1&&(g=!1),xt[y][E].latexParens===!1&&(g=!1)),w!==null&&(xt[s][b].latexRightParens===!1&&(h=!1),xt[w][A].latexParens===!1&&(h=!1))}m=[g,h]}break;default:(a.getIdentifier()==="OperatorNode:add"||a.getIdentifier()==="OperatorNode:multiply")&&(m=l.map(function(D){var T=pr(D,o,f,a),B=Ds(a,D,o),I=ka(D,o);return T===null?!1:s===T&&c===I&&!B?!0:T<s}));break}if(l.length>=2&&a.getIdentifier()==="OperatorNode:multiply"&&a.implicit&&o!=="all"&&f==="hide")for(var S=1;S<m.length;++S)t(l[S],o)&&!m[S-1]&&(o!=="keep"||!kt(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 Ji}get isOperatorNode(){return!0}_compile(o,f){if(typeof this.fn!="string"||!Yo(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=st(o,this.fn),u=Vt(this.args,function(v){return v._compile(o,f)});if(u.length===1){var s=u[0];return function(d,p,g){return l(s(d,p,g))}}else if(u.length===2){var c=u[0],m=u[1];return function(d,p,g){return l(c(d,p,g),m(d,p,g))}}else return function(d,p,g){return l.apply(null,Vt(u,function(y){return y(d,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=i(this,f,l,u,!1);if(u.length===1){var c=ka(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 d=u[0].toString(o),p=u[1].toString(o);return s[0]&&(d="("+d+")"),s[1]&&(p="("+p+")"),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?d+" "+p:d+" "+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:Ji,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=i(this,f,l,u,!1);if(u.length===1){var c=ka(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">'+ot(this.op)+"</span>"+m:m+'<span class="math-operator math-unary-operator math-righthand-unary-operator">'+ot(this.op)+"</span>"}else if(u.length===2){var v=u[0].toHTML(o),d=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]&&(d='<span class="math-parenthesis math-round-parenthesis">(</span>'+d+'<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>'+d:v+'<span class="math-operator math-binary-operator math-explicit-binary-operator">'+ot(this.op)+"</span>"+d}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">'+ot(this.op)+"</span>"):'<span class="math-function">'+ot(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=i(this,f,l,u,!0),c=sr[this.fn];if(c=typeof c>"u"?this.op:c,u.length===1){var m=ka(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 d=u[0],p=d.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=d.getIdentifier():N=d.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 h=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"?h.join("~"):h.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 qr(n,"name",Ji),n},{isClass:!0,isNode:!0}),Xi="ParenthesisNode",qE=["Node"],zE=q(Xi,qE,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 Xi}get isParenthesisNode(){return!0}_compile(n,a){return this.content._compile(n,a)}getContent(){return this.content.getContent()}forEach(n){n(this.content,"content",this)}map(n){var a=n(this.content,"content",this);return new t(a)}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:Xi,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 qr(t,"name",Xi),t},{isClass:!0,isNode:!0}),Wi="RangeNode",PE=["Node"],LE=q(Wi,PE,r=>{var{Node:e}=r;function t(n,a,o){var f=pr(n,a,o),l={},u=pr(n.start,a,o);if(l.start=u!==null&&u<=f||a==="all",n.step){var s=pr(n.step,a,o);l.step=s!==null&&s<=f||a==="all"}var c=pr(n.end,a,o);return l.end=c!==null&&c<=f||a==="all",l}class i extends e{constructor(a,o,f){if(super(),!fr(a))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=a,this.end=o,this.step=f||null}get type(){return Wi}get isRangeNode(){return!0}needsEnd(){var a=this.filter(function(o){return _r(o)&&o.name==="end"});return a.length>0}_compile(a,o){var f=a.range,l=this.start._compile(a,o),u=this.end._compile(a,o);if(this.step){var s=this.step._compile(a,o);return function(m,v,d){return f(l(m,v,d),u(m,v,d),s(m,v,d))}}else return function(m,v,d){return f(l(m,v,d),u(m,v,d))}}forEach(a){a(this.start,"start",this),a(this.end,"end",this),this.step&&a(this.step,"step",this)}map(a){return new i(this._ifNode(a(this.start,"start",this)),this._ifNode(a(this.end,"end",this)),this.step&&this._ifNode(a(this.step,"step",this)))}clone(){return new i(this.start,this.end,this.step&&this.step)}_toString(a){var o=a&&a.parenthesis?a.parenthesis:"keep",f=t(this,o,a&&a.implicit),l,u=this.start.toString(a);if(f.start&&(u="("+u+")"),l=u,this.step){var s=this.step.toString(a);f.step&&(s="("+s+")"),l+=":"+s}var c=this.end.toString(a);return f.end&&(c="("+c+")"),l+=":"+c,l}toJSON(){return{mathjs:Wi,start:this.start,end:this.end,step:this.step}}static fromJSON(a){return new i(a.start,a.end,a.step)}toHTML(a){var o=a&&a.parenthesis?a.parenthesis:"keep",f=t(this,o,a&&a.implicit),l,u=this.start.toHTML(a);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(a);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(a);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(a){var o=a&&a.parenthesis?a.parenthesis:"keep",f=t(this,o,a&&a.implicit),l=this.start.toTex(a);if(f.start&&(l="\\left(".concat(l,"\\right)")),this.step){var u=this.step.toTex(a);f.step&&(u="\\left(".concat(u,"\\right)")),l+=":"+u}var s=this.end.toTex(a);return f.end&&(s="\\left(".concat(s,"\\right)")),l+=":"+s,l}}return qr(i,"name",Wi),i},{isClass:!0,isNode:!0}),Yi="RelationalNode",UE=["Node"],kE=q(Yi,UE,r=>{var{Node:e}=r,t={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="};class i extends e{constructor(a,o){if(super(),!Array.isArray(a))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(o))throw new TypeError("Parameter params must be an array");if(a.length!==o.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=a,this.params=o}get type(){return Yi}get isRelationalNode(){return!0}_compile(a,o){var f=this,l=this.params.map(u=>u._compile(a,o));return function(s,c,m){for(var v,d=l[0](s,c,m),p=0;p<f.conditionals.length;p++){v=d,d=l[p+1](s,c,m);var g=st(a,f.conditionals[p]);if(!g(v,d))return!1}return!0}}forEach(a){this.params.forEach((o,f)=>a(o,"params["+f+"]",this),this)}map(a){return new i(this.conditionals.slice(),this.params.map((o,f)=>this._ifNode(a(o,"params["+f+"]",this)),this))}clone(){return new i(this.conditionals,this.params)}_toString(a){for(var o=a&&a.parenthesis?a.parenthesis:"keep",f=pr(this,o,a&&a.implicit),l=this.params.map(function(c,m){var v=pr(c,o,a&&a.implicit);return o==="all"||v!==null&&v<=f?"("+c.toString(a)+")":c.toString(a)}),u=l[0],s=0;s<this.conditionals.length;s++)u+=" "+t[this.conditionals[s]],u+=" "+l[s+1];return u}toJSON(){return{mathjs:Yi,conditionals:this.conditionals,params:this.params}}static fromJSON(a){return new i(a.conditionals,a.params)}toHTML(a){for(var o=a&&a.parenthesis?a.parenthesis:"keep",f=pr(this,o,a&&a.implicit),l=this.params.map(function(c,m){var v=pr(c,o,a&&a.implicit);return o==="all"||v!==null&&v<=f?'<span class="math-parenthesis math-round-parenthesis">(</span>'+c.toHTML(a)+'<span class="math-parenthesis math-round-parenthesis">)</span>':c.toHTML(a)}),u=l[0],s=0;s<this.conditionals.length;s++)u+='<span class="math-operator math-binary-operator math-explicit-binary-operator">'+ot(t[this.conditionals[s]])+"</span>"+l[s+1];return u}_toTex(a){for(var o=a&&a.parenthesis?a.parenthesis:"keep",f=pr(this,o,a&&a.implicit),l=this.params.map(function(c,m){var v=pr(c,o,a&&a.implicit);return o==="all"||v!==null&&v<=f?"\\left("+c.toTex(a)+"\right)":c.toTex(a)}),u=l[0],s=0;s<this.conditionals.length;s++)u+=sr[this.conditionals[s]]+l[s+1];return u}}return qr(i,"name",Yi),i},{isClass:!0,isNode:!0}),VE="SymbolNode",GE=["math","?Unit","Node"],HE=q(VE,GE,r=>{var{math:e,Unit:t,Node:i}=r;function n(o){return t?t.isValuelessUnit(o):!1}class a extends i{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):st(f,u)};var s=n(u);return function(c,m,v){return c.has(u)?c.get(u):s?new t(null,u):a.onUndefinedSymbol(u)}}forEach(f){}map(f){return this.clone()}static onUndefinedSymbol(f){throw new Error("Undefined symbol "+f)}clone(){return new a(this.name)}_toString(f){return this.name}toHTML(f){var l=ot(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 a(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 a},{isClass:!0,isNode:!0});function Va(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;i<e;i++)t[i-1]=arguments[i];return typeof r.createSubScope=="function"?Sl(r.createSubScope(),...t):Sl(Xn(),r,...t)}var Qi="FunctionNode",ZE=["math","Node","SymbolNode"],JE=q(Qi,ZE,r=>{var{math:e,Node:t,SymbolNode:i}=r,n=f=>Ye(f,{truncate:78});function a(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 d=l[v[1]];if(!d)throw new ReferenceError("Template: Property "+v[1]+" does not exist.");if(v[2]===void 0)switch(typeof d){case"string":s+=d;break;case"object":if(fr(d))s+=d.toTex(u);else if(Array.isArray(d))s+=d.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(d[v[2]]&&d[v[2]]))s+=d[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 i(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 Qi}get isFunctionNode(){return!0}_compile(l,u){var s=this.args.map(E=>E._compile(l,u));if(_r(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,Va(A,S),A);var B=s.map(I=>I(A,S,D));return T.apply(T,B)}}else{var m=c in l?st(l,c):void 0,v=typeof m=="function"&&m.rawArgs===!0,d=E=>{var A;if(E.has(c))A=E.get(c);else if(c in l)A=st(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:
16
+ `).concat(n(A)))};if(v){var p=this.args;return function(A,S,D){var T=d(A);return T(p,l,Va(A,S),A)}}else switch(s.length){case 0:return function(A,S,D){var T=d(A);return T()};case 1:return function(A,S,D){var T=d(A),B=s[0];return T(B(A,S,D))};case 2:return function(A,S,D){var T=d(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=d(A),B=s.map(I=>I(A,S,D));return T(...B)}}}}else if(Nn(this.fn)&&Un(this.fn.index)&&this.fn.index.isObjectProperty()){var y=this.fn.object._compile(l,u),N=this.fn.index.getObjectProperty(),h=this.args;return function(A,S,D){var T=y(A,S,D);yg(T,N);var B=T[N]&&T[N].rawArgs;if(B)return T[N](h,l,Va(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:")+`
17
+ `.concat(n(T)));if(T.rawArgs)return T(b,l,Va(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=$a(this.fn)?"("+this.fn.toString(l)+")":this.fn.toString(l);return s+"("+u.join(", ")+")"}toJSON(){return{mathjs:Qi,fn:this.fn,args:this.args}}toHTML(l){var u=this.args.map(function(s){return s.toHTML(l)});return'<span class="math-function">'+ot(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;jv[this.name]&&(s=jv[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=a(s,this,l);break;case"object":switch(typeof s[u.length]){case"function":c=s[u.length](this,l);break;case"string":c=a(s[u.length],this,l);break}}return typeof c<"u"?c:a(SE,this,l)}getIdentifier(){return this.type+":"+this.name}}return qr(o,"name",Qi),qr(o,"onUndefinedFunction",function(f){throw new Error("Undefined function "+f)}),qr(o,"fromJSON",function(f){return new o(f.fn,f.args)}),o},{isClass:!0,isNode:!0}),tp="parse",XE=["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],WE=q(tp,XE,r=>{var{typed:e,numeric:t,config:i,AccessorNode:n,ArrayNode:a,AssignmentNode:o,BlockNode:f,ConditionalNode:l,ConstantNode:u,FunctionAssignmentNode:s,FunctionNode:c,IndexNode:m,ObjectNode:v,OperatorNode:d,ParenthesisNode:p,RangeNode:g,RelationalNode:y,SymbolNode:N}=r,h=e(tp,{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
18
  `&&B(C)!=="";)C.comment+=B(C),I(C);if(h.isWhitespace(B(C),C.nestingLevel))I(C);else break}if(B(C)===""){C.tokenType=x.DELIMITER;return}if(B(C)===`
36
- `&&!C.nestingLevel){C.tokenType=x.DELIMITER,C.token=B(C),I(C);return}var Z=B(C),ue=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(ue.length===2&&b[ue]){C.tokenType=x.DELIMITER,C.token=ue,I(C),I(C);return}if(b[Z]){C.tokenType=x.DELIMITER,C.token=Z,I(C);return}if(h.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);h.isHexDigit(B(C));)C.token+=B(C),I(C);if(B(C)===".")for(C.token+=".",I(C);h.isHexDigit(B(C));)C.token+=B(C),I(C);else if(B(C)==="i")for(C.token+="i",I(C);h.isDigit(B(C));)C.token+=B(C),I(C);return}if(B(C)==="."){if(C.token+=B(C),I(C),!h.isDigit(B(C))){C.tokenType=x.DELIMITER;return}}else{for(;h.isDigit(B(C));)C.token+=B(C),I(C);h.isDecimalMark(B(C),R(C))&&(C.token+=B(C),I(C))}for(;h.isDigit(B(C));)C.token+=B(C),I(C);if(B(C)==="E"||B(C)==="e"){if(h.isDigit(R(C))||R(C)==="-"||R(C)==="+"){if(C.token+=B(C),I(C),(B(C)==="+"||B(C)==="-")&&(C.token+=B(C),I(C)),!h.isDigit(B(C)))throw Je(C,'Digit expected, got "'+B(C)+'"');for(;h.isDigit(B(C));)C.token+=B(C),I(C);if(h.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(h.isAlpha(B(C),P(C),R(C))){for(;h.isAlpha(B(C),P(C),R(C))||h.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
- `)}function H(C){C.nestingLevel++}function $(C){C.nestingLevel--}h.isAlpha=function(Z,ue,Ee){return h.isValidLatinOrGreek(Z)||h.isValidMathSymbol(Z,Ee)||h.isValidMathSymbol(ue,Z)},h.isValidLatinOrGreek=function(Z){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(Z)},h.isValidMathSymbol=function(Z,ue){return/^[\uD835]$/.test(Z)&&/^[\uDC00-\uDFFF]$/.test(ue)&&/^[^\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(ue)},h.isWhitespace=function(Z,ue){return Z===" "||Z===" "||Z===`
38
- `&&ue>0},h.isDecimalMark=function(Z,ue){return Z==="."&&ue!=="/"&&ue!=="*"&&ue!=="^"},h.isDigitDot=function(Z){return Z>="0"&&Z<="9"||Z==="."},h.isDigit=function(Z){return Z>="0"&&Z<="9"},h.isHexDigit=function(Z){return Z>="0"&&Z<="9"||Z>="a"&&Z<="f"||Z>="A"&&Z<="F"};function k(C,Z){var ue=D();Sr(ue,{expression:C,extraNodes:Z}),M(ue);var Ee=Q(ue);if(ue.token!=="")throw ue.tokenType===x.DELIMITER?mr(ue,"Unexpected operator "+ue.token):Je(ue,'Unexpected part "'+ue.token+'"');return Ee}function Q(C){var Z,ue=[],Ee;for(C.token!==""&&C.token!==`
19
+ `&&!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(h.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);h.isHexDigit(B(C));)C.token+=B(C),I(C);if(B(C)===".")for(C.token+=".",I(C);h.isHexDigit(B(C));)C.token+=B(C),I(C);else if(B(C)==="i")for(C.token+="i",I(C);h.isDigit(B(C));)C.token+=B(C),I(C);return}if(B(C)==="."){if(C.token+=B(C),I(C),!h.isDigit(B(C))){C.tokenType=x.DELIMITER;return}}else{for(;h.isDigit(B(C));)C.token+=B(C),I(C);h.isDecimalMark(B(C),R(C))&&(C.token+=B(C),I(C))}for(;h.isDigit(B(C));)C.token+=B(C),I(C);if(B(C)==="E"||B(C)==="e"){if(h.isDigit(R(C))||R(C)==="-"||R(C)==="+"){if(C.token+=B(C),I(C),(B(C)==="+"||B(C)==="-")&&(C.token+=B(C),I(C)),!h.isDigit(B(C)))throw Je(C,'Digit expected, got "'+B(C)+'"');for(;h.isDigit(B(C));)C.token+=B(C),I(C);if(h.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(h.isAlpha(B(C),P(C),R(C))){for(;h.isAlpha(B(C),P(C),R(C))||h.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===`
20
+ `)}function H(C){C.nestingLevel++}function $(C){C.nestingLevel--}h.isAlpha=function(Z,se,Ee){return h.isValidLatinOrGreek(Z)||h.isValidMathSymbol(Z,Ee)||h.isValidMathSymbol(se,Z)},h.isValidLatinOrGreek=function(Z){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(Z)},h.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)},h.isWhitespace=function(Z,se){return Z===" "||Z===" "||Z===`
21
+ `&&se>0},h.isDecimalMark=function(Z,se){return Z==="."&&se!=="/"&&se!=="*"&&se!=="^"},h.isDigitDot=function(Z){return Z>="0"&&Z<="9"||Z==="."},h.isDigit=function(Z){return Z>="0"&&Z<="9"},h.isHexDigit=function(Z){return Z>="0"&&Z<="9"||Z>="a"&&Z<="f"||Z>="A"&&Z<="F"};function k(C,Z){var se=D();zr(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
22
  `&&C.token!==";"&&(Z=K(C),C.comment&&(Z.comment=C.comment));C.token===`
40
- `||C.token===";";)ue.length===0&&Z&&(Ee=C.token!==";",ue.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!==";",ue.push({node:Z,visible:Ee}));return ue.length>0?new f(ue):(Z||(Z=new u(void 0),C.comment&&(Z.comment=C.comment)),Z)}function K(C){var Z,ue,Ee,ze,ke=U(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,ue=[],Z=ke.name,ke.args.forEach(function(Fr,_r){qr(Fr)?ue[_r]=Fr.name:ze=!1}),ze))return F(C),Ee=K(C),new s(Z,ue,Ee);throw Je(C,"Invalid left hand side of assignment operator =")}return ke}function U(C){for(var Z=j(C);C.token==="?";){var ue=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=ue}return Z}function j(C){for(var Z=ae(C);C.token==="or";)F(C),Z=new d("or","or",[Z,ae(C)]);return Z}function ae(C){for(var Z=re(C);C.token==="xor";)F(C),Z=new d("xor","xor",[Z,re(C)]);return Z}function re(C){for(var Z=me(C);C.token==="and";)F(C),Z=new d("and","and",[Z,me(C)]);return Z}function me(C){for(var Z=he(C);C.token==="|";)F(C),Z=new d("|","bitOr",[Z,he(C)]);return Z}function he(C){for(var Z=fe(C);C.token==="^|";)F(C),Z=new d("^|","bitXor",[Z,fe(C)]);return Z}function fe(C){for(var Z=ie(C);C.token==="&";)F(C),Z=new d("&","bitAnd",[Z,ie(C)]);return Z}function ie(C){for(var Z=[Ae(C)],ue=[],Ee={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};Re(Ee,C.token);){var ze={name:C.token,fn:Ee[C.token]};ue.push(ze),F(C),Z.push(Ae(C))}return Z.length===1?Z[0]:Z.length===2?new d(ue[0].name,ue[0].fn,Z):new y(ue.map(ke=>ke.fn),Z)}function Ae(C){var Z,ue,Ee,ze;Z=Oe(C);for(var ke={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Re(ke,C.token);)ue=C.token,Ee=ke[ue],F(C),ze=[Z,Oe(C)],Z=new d(ue,Ee,ze);return Z}function Oe(C){var Z,ue,Ee,ze;Z=Ce(C);for(var ke={to:"to",in:"to"};Re(ke,C.token);)ue=C.token,Ee=ke[ue],F(C),ue==="in"&&C.token===""?Z=new d("*","multiply",[Z,new N("in")],!0):(ze=[Z,Ce(C)],Z=new d(ue,Ee,ze));return Z}function Ce(C){var Z,ue=[];if(C.token===":"?Z=new u(1):Z=$e(C),C.token===":"&&C.conditionalLevel!==C.nestingLevel){for(ue.push(Z);C.token===":"&&ue.length<3;)F(C),C.token===")"||C.token==="]"||C.token===","||C.token===""?ue.push(new N("end")):ue.push($e(C));ue.length===3?Z=new g(ue[0],ue[2],ue[1]):Z=new g(ue[0],ue[1])}return Z}function $e(C){var Z,ue,Ee,ze;Z=V(C);for(var ke={"+":"add","-":"subtract"};Re(ke,C.token);){ue=C.token,Ee=ke[ue],F(C);var Fr=V(C);Fr.isPercentage?ze=[Z,new d("*","multiply",[Z,Fr])]:ze=[Z,Fr],Z=new d(ue,Ee,ze)}return Z}function V(C){var Z,ue,Ee,ze;Z=W(C),ue=Z;for(var ke={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};Re(ke,C.token);)Ee=C.token,ze=ke[Ee],F(C),ue=W(C),Z=new d(Ee,ze,[Z,ue]);return Z}function W(C){var Z,ue;for(Z=se(C),ue=Z;C.tokenType===x.SYMBOL||C.token==="in"&&ir(Z)||C.tokenType===x.NUMBER&&!ir(ue)&&(!Br(ue)||ue.op==="!")||C.token==="(";)ue=se(C),Z=new d("*","multiply",[Z,ue],!0);return Z}function se(C){for(var Z=G(C),ue=Z,Ee=[];C.token==="/"&&Vo(ue);)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(),ue=G(C),Z=new d("/","divide",[Z,ue]);else{Ee.pop(),Sr(C,Ee.pop());break}else{Sr(C,Ee.pop());break}return Z}function G(C){var Z,ue,Ee,ze;Z=Y(C);for(var ke={"%":"mod",mod:"mod"};Re(ke,C.token);)ue=C.token,Ee=ke[ue],F(C),ue==="%"&&C.tokenType===x.DELIMITER&&C.token!=="("?Z=new d("/","divide",[Z,new u(100)],!1,!0):(ze=[Z,Y(C)],Z=new d(ue,Ee,ze));return Z}function Y(C){var Z,ue,Ee,ze={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Re(ze,C.token)?(Ee=ze[C.token],Z=C.token,F(C),ue=[Y(C)],new d(Z,Ee,ue)):te(C)}function te(C){var Z,ue,Ee,ze;return Z=be(C),(C.token==="^"||C.token===".^")&&(ue=C.token,Ee=ue==="^"?"pow":"dotPow",F(C),ze=[Z,Y(C)],Z=new d(ue,Ee,ze)),Z}function be(C){var Z,ue,Ee,ze;Z=ve(C);for(var ke={"!":"factorial","'":"ctranspose"};Re(ke,C.token);)ue=C.token,Ee=ke[ue],M(C),ze=[Z],Z=new d(ue,Ee,ze),Z=L(C,Z);return Z}function ve(C){var Z=[];if(C.tokenType===x.SYMBOL&&Re(C.extraNodes,C.token)){var ue=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 ue(Z)}return z(C)}function z(C){var Z,ue;return C.tokenType===x.SYMBOL||C.tokenType===x.DELIMITER&&C.token in E?(ue=C.token,M(C),Re(A,ue)?Z=new u(A[ue]):S.indexOf(ue)!==-1?Z=new u(t(ue,"number")):Z=new N(ue),Z=L(C,Z),Z):ee(C)}function L(C,Z,ue){for(var Ee;(C.token==="("||C.token==="["||C.token===".")&&(!ue||ue.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,ue;return C.token==='"'?(ue=le(C),Z=new u(ue),Z=L(C,Z),Z):pe(C)}function le(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 pe(C){var Z,ue;return C.token==="'"?(ue=ge(C),Z=new u(ue),Z=L(C,Z),Z):xe(C)}function ge(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 xe(C){var Z,ue,Ee,ze;if(C.token==="["){if(H(C),M(C),C.token!=="]"){var ke=de(C);if(C.token===";"){for(Ee=1,ue=[ke];C.token===";";)M(C),ue[Ee]=de(C),Ee++;if(C.token!=="]")throw Je(C,"End of matrix ] expected");$(C),M(C),ze=ue[0].items.length;for(var Fr=1;Fr<Ee;Fr++)if(ue[Fr].items.length!==ze)throw mr(C,"Column dimensions mismatch ("+ue[Fr].items.length+" !== "+ze+")");Z=new i(ue)}else{if(C.token!=="]")throw Je(C,"End of matrix ] expected");$(C),M(C),Z=ke}}else $(C),M(C),Z=new i([]);return L(C,Z)}return Ne(C)}function de(C){for(var Z=[K(C)],ue=1;C.token===",";)M(C),Z[ue]=K(C),ue++;return new i(Z)}function Ne(C){if(C.token==="{"){H(C);var Z,ue={};do if(M(C),C.token!=="}"){if(C.token==='"')Z=le(C);else if(C.token==="'")Z=ge(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),ue[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(ue);return Ee=L(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))):Ue(C)}function Ue(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=L(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 ue=ar(C),Ee=new SyntaxError(Z+" (char "+ue+")");return Ee.char=ue,Ee}function mr(C,Z){var ue=ar(C),Ee=new SyntaxError(Z+" (char "+ue+")");return Ee.char=ue,Ee}return e.addConversion({from:"string",to:"Node",convert:h}),h}),sp="compile",sS=["typed","parse"],uS=q(sp,sS,r=>{var{typed:e,parse:t}=r;return e(sp,{string:function(n){return t(n).compile()},"Array | Matrix":function(n){return je(n,function(i){return t(i).compile()})}})}),up="evaluate",lS=["typed","parse"],cS=q(up,lS,r=>{var{typed:e,parse:t}=r;return e(up,{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)})}})}),fS="Parser",mS=["evaluate"],vS=q(fS,mS,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 _g(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}),lp="parser",pS=["typed","Parser"],dS=q(lp,pS,r=>{var{typed:e,Parser:t}=r;return e(lp,{"":function(){return new t}})}),cp="lup",hS=["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],gS=q(cp,hS,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(cp,{DenseMatrix:function(y){return d(y)},SparseMatrix:function(y){return p(y)},Array:function(y){var N=t(y),h=d(N);return{L:h.L.valueOf(),U:h.U.valueOf(),p:h.p}}});function d(g){var y=g._size[0],N=g._size[1],h=Math.min(y,N),w=Ge(g._data),x=[],b=[y,h],E=[],A=[h,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}),U=[];for(S=0,h=B.length;S<h;S++)U[B[S]]=S;return{L:Q,U:K,p:U,toString:function(){return"L: "+this.L.toString()+`
23
+ `||C.token===";";)se.length===0&&Z&&(Ee=C.token!==";",se.push({node:Z,visible:Ee})),M(C),C.token!==`
24
+ `&&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=U(C);if(C.token==="="){if(_r(ke))return Z=ke.name,F(C),Ee=K(C),new o(new N(Z),Ee);if(Nn(ke))return F(C),Ee=K(C),new o(ke.object,ke.index,Ee);if(jt(ke)&&_r(ke.fn)&&(ze=!0,se=[],Z=ke.name,ke.args.forEach(function(Mr,Rr){_r(Mr)?se[Rr]=Mr.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 U(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 d("or","or",[Z,ae(C)]);return Z}function ae(C){for(var Z=re(C);C.token==="xor";)F(C),Z=new d("xor","xor",[Z,re(C)]);return Z}function re(C){for(var Z=me(C);C.token==="and";)F(C),Z=new d("and","and",[Z,me(C)]);return Z}function me(C){for(var Z=he(C);C.token==="|";)F(C),Z=new d("|","bitOr",[Z,he(C)]);return Z}function he(C){for(var Z=fe(C);C.token==="^|";)F(C),Z=new d("^|","bitXor",[Z,fe(C)]);return Z}function fe(C){for(var Z=ie(C);C.token==="&";)F(C),Z=new d("&","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 d(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 d(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 d("*","multiply",[Z,new N("in")],!0):(ze=[Z,Ce(C)],Z=new d(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 Mr=V(C);Mr.isPercentage?ze=[Z,new d("*","multiply",[Z,Mr])]:ze=[Z,Mr],Z=new d(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 d(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)&&(!Tr(se)||se.op==="!")||C.token==="(";)se=oe(C),Z=new d("*","multiply",[Z,se],!0);return Z}function oe(C){for(var Z=G(C),se=Z,Ee=[];C.token==="/"&&Vo(se);)if(Ee.push(zr({},C)),F(C),C.tokenType===x.NUMBER)if(Ee.push(zr({},C)),F(C),C.tokenType===x.SYMBOL||C.token==="(")zr(C,Ee.pop()),Ee.pop(),se=G(C),Z=new d("/","divide",[Z,se]);else{Ee.pop(),zr(C,Ee.pop());break}else{zr(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 d("/","divide",[Z,new u(100)],!1,!0):(ze=[Z,Y(C)],Z=new d(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 d(Z,Ee,se)):te(C)}function te(C){var Z,se,Ee,ze;return Z=be(C),(C.token==="^"||C.token===".^")&&(se=C.token,Ee=se==="^"?"pow":"dotPow",F(C),ze=[Z,Y(C)],Z=new d(se,Ee,ze)),Z}function be(C){var Z,se,Ee,ze;Z=ve(C);for(var ke={"!":"factorial","'":"ctranspose"};Re(ke,C.token);)se=C.token,Ee=ke[se],M(C),ze=[Z],Z=new d(se,Ee,ze),Z=L(C,Z);return Z}function ve(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=L(C,Z),Z):ee(C)}function L(C,Z,se){for(var Ee;C.token==="("||C.token==="["||C.token===".";)if(Ee=[],C.token==="(")if(_r(Z)||Nn(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=le(C),Z=new u(se),Z=L(C,Z),Z):pe(C)}function le(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 pe(C){var Z,se;return C.token==="'"?(se=ge(C),Z=new u(se),Z=L(C,Z),Z):xe(C)}function ge(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 xe(C){var Z,se,Ee,ze;if(C.token==="["){if(H(C),M(C),C.token!=="]"){var ke=de(C);if(C.token===";"){for(Ee=1,se=[ke];C.token===";";)M(C),se[Ee]=de(C),Ee++;if(C.token!=="]")throw Je(C,"End of matrix ] expected");$(C),M(C),ze=se[0].items.length;for(var Mr=1;Mr<Ee;Mr++)if(se[Mr].items.length!==ze)throw mr(C,"Column dimensions mismatch ("+se[Mr].items.length+" !== "+ze+")");Z=new a(se)}else{if(C.token!=="]")throw Je(C,"End of matrix ] expected");$(C),M(C),Z=ke}}else $(C),M(C),Z=new a([]);return L(C,Z)}return Ne(C)}function de(C){for(var Z=[K(C)],se=1;C.token===",";)M(C),Z[se]=K(C),se++;return new a(Z)}function Ne(C){if(C.token==="{"){H(C);var Z,se={};do if(M(C),C.token!=="}"){if(C.token==='"')Z=le(C);else if(C.token==="'")Z=ge(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=L(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,i.number))):Ue(C)}function Ue(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=L(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:h}),h}),np="compile",YE=["typed","parse"],QE=q(np,YE,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(a){return t(a).compile()})}})}),ap="evaluate",KE=["typed","parse"],jE=q(ap,KE,r=>{var{typed:e,parse:t}=r;return e(ap,{string:function(n){var a=Xn();return t(n).compile().evaluate(a)},"string, Map | Object":function(n,a){return t(n).compile().evaluate(a)},"Array | Matrix":function(n){var a=Xn();return je(n,function(o){return t(o).compile().evaluate(a)})},"Array | Matrix, Map | Object":function(n,a){return je(n,function(o){return t(o).compile().evaluate(a)})}})}),eS="Parser",rS=["evaluate"],tS=q(eS,rS,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:Xn(),writable:!1})}return t.prototype.type="Parser",t.prototype.isParser=!0,t.prototype.evaluate=function(i){return e(i,this.scope)},t.prototype.get=function(i){if(this.scope.has(i))return this.scope.get(i)},t.prototype.getAll=function(){return wg(this.scope)},t.prototype.getAllAsMap=function(){return this.scope},t.prototype.set=function(i,n){return this.scope.set(i,n),n},t.prototype.remove=function(i){this.scope.delete(i)},t.prototype.clear=function(){this.scope.clear()},t},{isClass:!0}),ip="parser",nS=["typed","Parser"],aS=q(ip,nS,r=>{var{typed:e,Parser:t}=r;return e(ip,{"":function(){return new t}})}),op="lup",iS=["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],oS=q(op,iS,r=>{var{typed:e,matrix:t,abs:i,addScalar:n,divideScalar:a,multiplyScalar:o,subtract:f,larger:l,equalScalar:u,unaryMinus:s,DenseMatrix:c,SparseMatrix:m,Spa:v}=r;return e(op,{DenseMatrix:function(y){return d(y)},SparseMatrix:function(y){return p(y)},Array:function(y){var N=t(y),h=d(N);return{L:h.L.valueOf(),U:h.U.valueOf(),p:h.p}}});function d(g){var y=g._size[0],N=g._size[1],h=Math.min(y,N),w=Ge(g._data),x=[],b=[y,h],E=[],A=[h,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],$=i(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]=a(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}),U=[];for(S=0,h=B.length;S<h;S++)U[B[S]]=S;return{L:Q,U:K,p:U,toString:function(){return"L: "+this.L.toString()+`
42
25
  U: `+this.U.toString()+`
43
- P: `+this.p}}}function p(g){var y=g._size[0],N=g._size[1],h=Math.min(y,N),w=g._values,x=g._index,b=g._ptr,E=[],A=[],S=[],D=[y,h],T=[],B=[],I=[],P=[h,N],R,M,F,H=[],$=[];for(R=0;R<y;R++)H[R]=R,$[R]=R;var k=function(U,j){var ae=$[U],re=$[j];H[ae]=j,H[re]=U,$[U]=re,$[j]=ae},Q=function(){var U=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],U.set(H[R],w[F]);M>0&&U.forEach(0,M-1,function(fe,ie){m._forEachRow(fe,E,A,S,function(Ae,Oe){Ae>fe&&U.accumulate(Ae,s(o(Oe,ie)))})});var re=M,me=U.get(M),he=a(me);U.forEach(M+1,y-1,function(fe,ie){var Ae=a(ie);l(Ae,he)&&(re=fe,he=Ae,me=ie)}),M!==re&&(m._swapRows(M,re,D[1],E,A,S),m._swapRows(M,re,P[1],T,B,I),U.swap(M,re),k(M,re)),U.forEach(0,y-1,function(fe,ie){fe<=M?(T.push(ie),B.push(fe)):(ie=i(ie,me),u(ie,0)||(E.push(ie),A.push(fe)))})};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()+`
26
+ P: `+this.p}}}function p(g){var y=g._size[0],N=g._size[1],h=Math.min(y,N),w=g._values,x=g._index,b=g._ptr,E=[],A=[],S=[],D=[y,h],T=[],B=[],I=[],P=[h,N],R,M,F,H=[],$=[];for(R=0;R<y;R++)H[R]=R,$[R]=R;var k=function(U,j){var ae=$[U],re=$[j];H[ae]=j,H[re]=U,$[U]=re,$[j]=ae},Q=function(){var U=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],U.set(H[R],w[F]);M>0&&U.forEach(0,M-1,function(fe,ie){m._forEachRow(fe,E,A,S,function(Ae,Oe){Ae>fe&&U.accumulate(Ae,s(o(Oe,ie)))})});var re=M,me=U.get(M),he=i(me);U.forEach(M+1,y-1,function(fe,ie){var Ae=i(ie);l(Ae,he)&&(re=fe,he=Ae,me=ie)}),M!==re&&(m._swapRows(M,re,D[1],E,A,S),m._swapRows(M,re,P[1],T,B,I),U.swap(M,re),k(M,re)),U.forEach(0,y-1,function(fe,ie){fe<=M?(T.push(ie),B.push(fe)):(ie=a(ie,me),u(ie,0)||(E.push(ie),A.push(fe)))})};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
27
  U: `+this.U.toString()+`
45
- P: `+this.p}}}}),fp="qr",yS=["typed","matrix","zeros","identity","isZero","equal","sign","sqrt","conj","unaryMinus","addScalar","divideScalar","multiplyScalar","subtract","complex"],bS=q(fp,yS,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:d,complex:p}=r;return Sr(e(fp,{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(h){var w=h._size[0],x=h._size[1],b=n([w],"dense"),E=b._data,A=h.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 $=d(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(d(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(d(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(h){var w=g(h),x=w.R._data;if(h._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(h){throw new Error("qr not implemented for sparse matrices yet")}});function xS(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=[],d=0,p=0;p<s;p++){v[p]=d;for(var g=t?t[p]:p,y=o[g],N=o[g+1],h=y;h<N;h++){var w=e?e[i[h]]:i[h];m[d]=w,c&&(c[d]=n[h]),d++}}return v[s]=d,r.createSparseMatrix({values:c,index:m,ptr:v,size:[u,s],datatype:l})}function mp(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 wS(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=mp(a,t,i,o,f,n,l));return n}function NS(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 d=a[v],p=a[v+1],g=d;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 AS="csAmd",ES=["add","multiply","transpose"],SS=q(AS,ES,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],d=m[1],p=0,g=Math.max(16,10*Math.sqrt(d));g=Math.min(d-2,g);var y=n(s,c,v,d,g);DS(y,l,null);for(var N=y._index,h=y._ptr,w=h[d],x=[],b=[],E=0,A=d+1,S=2*(d+1),D=3*(d+1),T=4*(d+1),B=5*(d+1),I=6*(d+1),P=7*(d+1),R=x,M=i(d,h,b,E,D,R,S,P,A,I,T,B),F=o(d,h,b,B,T,I,g,A,D,R,S),H=0,$,k,Q,K,U,j,ae,re,me,he,fe,ie,Ae,Oe,Ce,$e;F<d;){for(Q=-1;H<d&&(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],W=b[A+Q];F+=W;var se=0;b[A+Q]=-W;var G=h[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=h[j],re=b[E+j]),U=1;U<=re;U++)$=N[ae++],!((me=b[A+$])<=0)&&(se+=me,b[A+$]=-me,N[te++]=$,b[S+$]!==-1&&(R[b[S+$]]=R[$]),R[$]!==-1?b[S+R[$]]=b[S+$]:b[D+b[B+$]]=b[S+$]);j!==Q&&(h[j]=vn(Q),b[I+j]=0)}for(V!==0&&(w=te),b[B+Q]=se,h[Q]=Y,b[E+Q]=te-Y,b[T+Q]=-2,M=f(M,p,b,I,d),he=Y;he<te;he++)if($=N[he],!((fe=b[T+$])<=0)){me=-b[A+$];var be=M-me;for(G=h[$],ie=h[$]+fe-1;G<=ie;G++)j=N[G],b[I+j]>=M?b[I+j]-=me:b[I+j]!==0&&(b[I+j]=b[B+j]+be)}for(he=Y;he<te;he++){for($=N[he],ie=h[$],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 ve=b[I+j]-M;ve>0?($e+=ve,N[Oe++]=j,Ce+=j):(h[j]=vn(Q),b[I+j]=0)}b[T+$]=Oe-ie+1;var z=Oe,L=ie+b[E+$];for(G=Ae+1;G<L;G++){k=N[G];var ee=b[A+k];ee<=0||($e+=ee,N[Oe++]=k,Ce+=k)}$e===0?(h[$]=vn(Q),me=-b[A+$],se-=me,W+=me,F+=me,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)%d,b[S+$]=b[P+Ce],b[P+Ce]=$,R[$]=Ce)}for(b[B+Q]=se,p=Math.max(p,se),M=f(M+p,p,b,I,d),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+$],fe=b[T+$],G=h[$]+1;G<=h[$]+re-1;G++)b[I+N[G]]=M;var le=$;for(k=b[S+$];k!==-1;){var pe=b[E+k]===re&&b[T+k]===fe;for(G=h[k]+1;pe&&G<=h[k]+re-1;G++)b[I+N[G]]!==M&&(pe=0);pe?(h[k]=vn($),b[A+$]+=b[A+k],b[A+k]=0,b[T+k]=-1,k=b[S+k],b[S+le]=k):(le=k,k=b[S+k])}}for(G=Y,he=Y;he<te;he++)$=N[he],!((me=-b[A+$])<=0)&&(b[A+$]=me,$e=b[B+$]+se-me,$e=Math.min($e,d-F-me),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]=W,(b[E+Q]=G-Y)===0&&(h[Q]=-1,b[I+Q]=0),V!==0&&(w=G)}for($=0;$<d;$++)h[$]=vn(h[$]);for(k=0;k<=d;k++)b[D+k]=-1;for(k=d;k>=0;k--)b[A+k]>0||(b[S+k]=b[D+h[k]],b[D+h[k]]=k);for(j=d;j>=0;j--)b[A+j]<=0||h[j]!==-1&&(b[S+j]=b[D+h[j]],b[D+h[j]]=j);for(Q=0,$=0;$<=d;$++)h[$]===-1&&(Q=mp($,Q,b,D,S,x,I));return x.splice(x.length-1,1),x};function n(u,s,c,m,v){var d=a(s);if(u===1&&m===c)return e(s,d);if(u===2){for(var p=d._index,g=d._ptr,y=0,N=0;N<c;N++){var h=g[N];if(g[N]=y,!(g[N+1]-h>v))for(var w=g[N+1];h<w;h++)p[y++]=p[h]}return g[c]=y,s=a(d),t(d,s)}return t(d,s)}function i(u,s,c,m,v,d,p,g,y,N,h,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,d[b]=-1,c[p+b]=-1,c[g+b]=-1,c[y+b]=1,c[N+b]=1,c[h+b]=0,c[w+b]=c[m+b];var E=f(0,0,c,N,u);return c[h+u]=-2,s[u]=-1,c[N+u]=0,E}function o(u,s,c,m,v,d,p,g,y,N,h){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[d+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[h+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 d=0;d<v;d++)c[m+d]!==0&&(c[m+d]=1);u=2}return u}function l(u,s){return u!==s}});function CS(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 MS="csCounts",FS=["transpose"],TS=q(MS,FS,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,d,p,g=4*l+(i?l+f+1:0),y=[],N=0,h=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,d=T[u],p=T[u+1],v=d;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=CS(u,s,y,x,h,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}}),BS="csSqr",$S=["add","multiply","transpose"],OS=q(BS,$S,r=>{var{add:e,multiply:t,transpose:a}=r,n=SS({add:e,multiply:t,transpose:a}),i=TS({transpose:a});return function(l,u,s){var c=u._ptr,m=u._size,v=m[1],d,p={};if(p.q=n(l,u),l&&!p.q)return null;if(s){var g=l?xS(u,null,p.q,0):u;p.parent=NS(g,1);var y=wS(p.parent,v);if(p.cp=i(g,p.parent,y,1),g&&p.parent&&p.cp&&o(g,p))for(p.unz=0,d=0;d<v;d++)p.unz+=p.cp[d]}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 d=l.parent,p=l.pinv,g=l.leftmost,y=[],N=0,h=m,w=m+v,x=m+2*v,b,E,A,S,D;for(E=0;E<v;E++)y[h+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[h+E],y[h+E]=b);for(l.lnz=0,l.m2=m,E=0;E<v;E++)if(b=y[h+E],l.lnz++,b<0&&(b=l.m2++),p[b]=E,!(--x[E]<=0)){l.lnz+=y[x+E];var T=d[E];T!==-1&&(y[x+T]===0&&(y[w+T]=y[w+E]),y[N+y[w+E]]=y[h+T],y[h+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 As(r,e){return r[e]<0}function vp(r,e){r[e]=vn(r[e])}function pp(r){return r<0?vn(r):r}function IS(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;As(o,r)||(vp(o,r),a[l+m]=v<0?0:pp(o[v]));var d=1;for(s=a[l+m],c=v<0?0:pp(o[v+1]);s<c;s++)if(u=i[s],!As(o,u)){a[l+m]=s,a[++m]=u,d=0;break}d&&(m--,a[--t]=r)}return t}function RS(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 d=f[s];As(i,d)||(v=IS(d,r,v,a,n))}for(s=v;s<u;s++)vp(i,a[s]);return v}var _S="csSpsolve",qS=["divideScalar","multiply","subtract"],zS=q(_S,qS,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,d=i._ptr,p=i._size,g=p[1],y=o._values,N=o._index,h=o._ptr,w,x,b,E,A=RS(i,o,f,l,s);for(w=A;w<g;w++)u[l[w]]=0;for(x=h[f],b=h[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=d[T],b=d[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}}),PS="csLu",LS=["abs","divideScalar","multiply","subtract","larger","largerEq","SparseMatrix"],US=q(PS,LS,r=>{var{abs:e,divideScalar:t,multiply:a,subtract:n,larger:i,largerEq:o,SparseMatrix:f}=r,l=zS({divideScalar:t,multiply:a,subtract:n});return function(s,c,m){if(!s)return null;var v=s._size,d=v[1],p,g=100,y=100;c&&(p=c.q,g=c.lnz||g,y=c.unz||y);var N=[],h=[],w=[],x=new f({values:N,index:h,ptr:w,size:[d,d]}),b=[],E=[],A=[],S=new f({values:b,index:E,ptr:A,size:[d,d]}),D=[],T,B,I=[],P=[];for(T=0;T<d;T++)I[T]=0,D[T]=-1,w[T+1]=0;g=0,y=0;for(var R=0;R<d;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<d;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,h[g]=H,N[g++]=1,B=F;B<d;B++)T=P[B],D[T]<0&&(h[g]=T,N[g++]=t(I[T],Q)),I[T]=0}for(w[d]=g,A[d]=y,B=0;B<g;B++)h[B]=D[h[B]];return N.splice(g,N.length-g),h.splice(g,h.length-g),b.splice(y,b.length-y),E.splice(y,E.length-y),{L:x,U:S,pinv:D}}}),dp="slu",kS=["typed","abs","add","multiply","transpose","divideScalar","subtract","larger","largerEq","SparseMatrix"],VS=q(dp,kS,r=>{var{typed:e,abs:t,add:a,multiply:n,transpose:i,divideScalar:o,subtract:f,larger:l,largerEq:u,SparseMatrix:s}=r,c=OS({add:a,multiply:n,transpose:i}),m=US({abs:t,divideScalar:o,multiply:n,subtract:f,larger:l,largerEq:u,SparseMatrix:s});return e(dp,{"SparseMatrix, number, number":function(d,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,d,!1),N=m(d,y,g);return{L:N.L,U:N.U,p:N.pinv,q:y.q,toString:function(){return"L: "+this.L.toString()+`
28
+ P: `+this.p}}}}),sp="qr",sS=["typed","matrix","zeros","identity","isZero","equal","sign","sqrt","conj","unaryMinus","addScalar","divideScalar","multiplyScalar","subtract","complex"],uS=q(sp,sS,r=>{var{typed:e,matrix:t,zeros:i,identity:n,isZero:a,equal:o,sign:f,sqrt:l,conj:u,unaryMinus:s,addScalar:c,divideScalar:m,multiplyScalar:v,subtract:d,complex:p}=r;return zr(e(sp,{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(h){var w=h._size[0],x=h._size[1],b=n([w],"dense"),E=b._data,A=h.clone(),S=A._data,D,T,B,I=i([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(!a(H)){var $=d(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(d(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(d(E[D][T],v(Q,u(I[T]))),M)}}}return{Q:b,R:A,toString:function(){return"Q: "+this.Q.toString()+`
29
+ R: `+this.R.toString()}}}function y(h){var w=g(h),x=w.R._data;if(h._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(h){throw new Error("qr not implemented for sparse matrices yet")}});function lS(r,e,t,i){r._values;for(var n=r._index,a=r._ptr,o=r._size,f=r._datatype,l=o[0],u=o[1],s=null,c=[],m=[],v=0,d=0;d<u;d++){m[d]=v;for(var p=t?t[d]:d,g=a[p],y=a[p+1],N=g;N<y;N++){var h=n[N];c[v]=h,v++}}return m[u]=v,r.createSparseMatrix({values:s,index:c,ptr:m,size:[l,u],datatype:f})}function up(r,e,t,i,n,a,o){var f=0;for(t[o]=r;f>=0;){var l=t[o+f],u=t[i+l];u===-1?(f--,a[e++]=l):(t[i+l]=t[n+u],++f,t[o+f]=u)}return e}function cS(r,e){if(!r)return null;var t=0,i,n=[],a=[],o=0,f=e,l=2*e;for(i=0;i<e;i++)a[o+i]=-1;for(i=e-1;i>=0;i--)r[i]!==-1&&(a[f+i]=a[o+r[i]],a[o+r[i]]=i);for(i=0;i<e;i++)r[i]===-1&&(t=up(i,t,a,o,f,n,l));return n}function fS(r,e){if(!r)return null;var t=r._index,i=r._ptr,n=r._size,a=n[0],o=n[1],f=[],l=[],u=0,s=o,c,m;for(c=0;c<a;c++)l[s+c]=-1;for(var v=0;v<o;v++){f[v]=-1,l[u+v]=-1;for(var d=i[v],p=i[v+1],g=d;g<p;g++){var y=t[g];for(c=l[s+y];c!==-1&&c<v;c=m)m=l[u+c],l[u+c]=v,m===-1&&(f[c]=v);l[s+y]=v}}return f}function mS(r,e,t){for(var i=r._values,n=r._index,a=r._ptr,o=r._size,f=o[1],l=0,u=0;u<f;u++){var s=a[u];for(a[u]=l;s<a[u+1];s++)e(n[s],u,i?i[s]:1,t)&&(n[l]=n[s],i&&(i[l]=i[s]),l++)}return a[f]=l,n.splice(l,n.length-l),i&&i.splice(l,i.length-l),l}function ln(r){return-r-2}var vS="csAmd",pS=["add","multiply","transpose"],dS=q(vS,pS,r=>{var{add:e,multiply:t,transpose:i}=r;return function(s,c){if(!c||s<=0||s>3)return null;var m=c._size,v=m[0],d=m[1],p=0,g=Math.max(16,10*Math.sqrt(d));g=Math.min(d-2,g);var y=n(s,c,v,d,g);mS(y,l,null);for(var N=y._index,h=y._ptr,w=h[d],x=[],b=[],E=0,A=d+1,S=2*(d+1),D=3*(d+1),T=4*(d+1),B=5*(d+1),I=6*(d+1),P=7*(d+1),R=x,M=a(d,h,b,E,D,R,S,P,A,I,T,B),F=o(d,h,b,B,T,I,g,A,D,R,S),H=0,$,k,Q,K,U,j,ae,re,me,he,fe,ie,Ae,Oe,Ce,$e;F<d;){for(Q=-1;H<d&&(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=h[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=h[j],re=b[E+j]),U=1;U<=re;U++)$=N[ae++],!((me=b[A+$])<=0)&&(oe+=me,b[A+$]=-me,N[te++]=$,b[S+$]!==-1&&(R[b[S+$]]=R[$]),R[$]!==-1?b[S+R[$]]=b[S+$]:b[D+b[B+$]]=b[S+$]);j!==Q&&(h[j]=ln(Q),b[I+j]=0)}for(V!==0&&(w=te),b[B+Q]=oe,h[Q]=Y,b[E+Q]=te-Y,b[T+Q]=-2,M=f(M,p,b,I,d),he=Y;he<te;he++)if($=N[he],!((fe=b[T+$])<=0)){me=-b[A+$];var be=M-me;for(G=h[$],ie=h[$]+fe-1;G<=ie;G++)j=N[G],b[I+j]>=M?b[I+j]-=me:b[I+j]!==0&&(b[I+j]=b[B+j]+be)}for(he=Y;he<te;he++){for($=N[he],ie=h[$],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 ve=b[I+j]-M;ve>0?($e+=ve,N[Oe++]=j,Ce+=j):(h[j]=ln(Q),b[I+j]=0)}b[T+$]=Oe-ie+1;var z=Oe,L=ie+b[E+$];for(G=Ae+1;G<L;G++){k=N[G];var ee=b[A+k];ee<=0||($e+=ee,N[Oe++]=k,Ce+=k)}$e===0?(h[$]=ln(Q),me=-b[A+$],oe-=me,X+=me,F+=me,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)%d,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,d),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+$],fe=b[T+$],G=h[$]+1;G<=h[$]+re-1;G++)b[I+N[G]]=M;var le=$;for(k=b[S+$];k!==-1;){var pe=b[E+k]===re&&b[T+k]===fe;for(G=h[k]+1;pe&&G<=h[k]+re-1;G++)b[I+N[G]]!==M&&(pe=0);pe?(h[k]=ln($),b[A+$]+=b[A+k],b[A+k]=0,b[T+k]=-1,k=b[S+k],b[S+le]=k):(le=k,k=b[S+k])}}for(G=Y,he=Y;he<te;he++)$=N[he],!((me=-b[A+$])<=0)&&(b[A+$]=me,$e=b[B+$]+oe-me,$e=Math.min($e,d-F-me),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&&(h[Q]=-1,b[I+Q]=0),V!==0&&(w=G)}for($=0;$<d;$++)h[$]=ln(h[$]);for(k=0;k<=d;k++)b[D+k]=-1;for(k=d;k>=0;k--)b[A+k]>0||(b[S+k]=b[D+h[k]],b[D+h[k]]=k);for(j=d;j>=0;j--)b[A+j]<=0||h[j]!==-1&&(b[S+j]=b[D+h[j]],b[D+h[j]]=j);for(Q=0,$=0;$<=d;$++)h[$]===-1&&(Q=up($,Q,b,D,S,x,I));return x.splice(x.length-1,1),x};function n(u,s,c,m,v){var d=i(s);if(u===1&&m===c)return e(s,d);if(u===2){for(var p=d._index,g=d._ptr,y=0,N=0;N<c;N++){var h=g[N];if(g[N]=y,!(g[N+1]-h>v))for(var w=g[N+1];h<w;h++)p[y++]=p[h]}return g[c]=y,s=i(d),t(d,s)}return t(d,s)}function a(u,s,c,m,v,d,p,g,y,N,h,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,d[b]=-1,c[p+b]=-1,c[g+b]=-1,c[y+b]=1,c[N+b]=1,c[h+b]=0,c[w+b]=c[m+b];var E=f(0,0,c,N,u);return c[h+u]=-2,s[u]=-1,c[N+u]=0,E}function o(u,s,c,m,v,d,p,g,y,N,h){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[d+x]=0;else if(b>p)c[g+x]=0,c[v+x]=-1,w++,s[x]=ln(u),c[g+u]++;else{var E=c[y+b];E!==-1&&(N[E]=x),c[h+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 d=0;d<v;d++)c[m+d]!==0&&(c[m+d]=1);u=2}return u}function l(u,s){return u!==s}});function hS(r,e,t,i,n,a,o){var f,l,u=0,s;if(r<=e||t[i+e]<=t[n+r])return-1;t[n+r]=t[i+e];var c=t[a+r];if(t[a+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 gS="csCounts",yS=["transpose"],bS=q(gS,yS,r=>{var{transpose:e}=r;return function(t,i,n,a){if(!t||!i||!n)return null;var o=t._size,f=o[0],l=o[1],u,s,c,m,v,d,p,g=4*l+(a?l+f+1:0),y=[],N=0,h=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=i[s])y[x+s]=c;if(a){for(c=0;c<l;c++)y[n[c]]=c;for(u=0;u<f;u++){for(c=l,d=T[u],p=T[u+1],v=d;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],i[s]!==-1&&A[i[s]]--,m=a?y[b+c]:s;m!==-1;m=a?y[E+m]:-1)for(v=T[m];v<T[m+1];v++){u=D[v];var B=hS(u,s,y,x,h,w,N);B.jleaf>=1&&A[s]++,B.jleaf===2&&A[B.q]--}i[s]!==-1&&(y[N+s]=i[s])}for(s=0;s<l;s++)i[s]!==-1&&(A[i[s]]+=A[s]);return A}}),xS="csSqr",wS=["add","multiply","transpose"],NS=q(xS,wS,r=>{var{add:e,multiply:t,transpose:i}=r,n=dS({add:e,multiply:t,transpose:i}),a=bS({transpose:i});return function(l,u,s){var c=u._ptr,m=u._size,v=m[1],d,p={};if(p.q=n(l,u),l&&!p.q)return null;if(s){var g=l?lS(u,null,p.q):u;p.parent=fS(g);var y=cS(p.parent,v);if(p.cp=a(g,p.parent,y,1),g&&p.parent&&p.cp&&o(g,p))for(p.unz=0,d=0;d<v;d++)p.unz+=p.cp[d]}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 d=l.parent,p=l.pinv,g=l.leftmost,y=[],N=0,h=m,w=m+v,x=m+2*v,b,E,A,S,D;for(E=0;E<v;E++)y[h+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[h+E],y[h+E]=b);for(l.lnz=0,l.m2=m,E=0;E<v;E++)if(b=y[h+E],l.lnz++,b<0&&(b=l.m2++),p[b]=E,!(--x[E]<=0)){l.lnz+=y[x+E];var T=d[E];T!==-1&&(y[x+T]===0&&(y[w+T]=y[w+E]),y[N+y[w+E]]=y[h+T],y[h+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 Cs(r,e){return r[e]<0}function lp(r,e){r[e]=ln(r[e])}function cp(r){return r<0?ln(r):r}function DS(r,e,t,i,n){var a=e._index,o=e._ptr,f=e._size,l=f[1],u,s,c,m=0;for(i[0]=r;m>=0;){r=i[m];var v=n?n[r]:r;Cs(o,r)||(lp(o,r),i[l+m]=v<0?0:cp(o[v]));var d=1;for(s=i[l+m],c=v<0?0:cp(o[v+1]);s<c;s++)if(u=a[s],!Cs(o,u)){i[l+m]=s,i[++m]=u,d=0;break}d&&(m--,i[--t]=r)}return t}function AS(r,e,t,i,n){var a=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 d=f[s];Cs(a,d)||(v=DS(d,r,v,i,n))}for(s=v;s<u;s++)lp(a,i[s]);return v}var ES="csSpsolve",SS=["divideScalar","multiply","subtract"],CS=q(ES,SS,r=>{var{divideScalar:e,multiply:t,subtract:i}=r;return function(a,o,f,l,u,s,c){var m=a._values,v=a._index,d=a._ptr,p=a._size,g=p[1],y=o._values,N=o._index,h=o._ptr,w,x,b,E,A=AS(a,o,f,l,s);for(w=A;w<g;w++)u[l[w]]=0;for(x=h[f],b=h[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=d[T],b=d[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]=i(u[B],t(m[w],u[D]))}}return A}}),MS="csLu",FS=["abs","divideScalar","multiply","subtract","larger","largerEq","SparseMatrix"],TS=q(MS,FS,r=>{var{abs:e,divideScalar:t,multiply:i,subtract:n,larger:a,largerEq:o,SparseMatrix:f}=r,l=CS({divideScalar:t,multiply:i,subtract:n});return function(s,c,m){if(!s)return null;var v=s._size,d=v[1],p,g=100,y=100;c&&(p=c.q,g=c.lnz||g,y=c.unz||y);var N=[],h=[],w=[],x=new f({values:N,index:h,ptr:w,size:[d,d]}),b=[],E=[],A=[],S=new f({values:b,index:E,ptr:A,size:[d,d]}),D=[],T,B,I=[],P=[];for(T=0;T<d;T++)I[T]=0,D[T]=-1,w[T+1]=0;g=0,y=0;for(var R=0;R<d;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<d;B++)if(T=P[B],D[T]<0){var k=e(I[T]);a(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]),i($,m))&&(H=M);var Q=I[H];for(E[y]=R,b[y++]=Q,D[H]=R,h[g]=H,N[g++]=1,B=F;B<d;B++)T=P[B],D[T]<0&&(h[g]=T,N[g++]=t(I[T],Q)),I[T]=0}for(w[d]=g,A[d]=y,B=0;B<g;B++)h[B]=D[h[B]];return N.splice(g,N.length-g),h.splice(g,h.length-g),b.splice(y,b.length-y),E.splice(y,E.length-y),{L:x,U:S,pinv:D}}}),fp="slu",BS=["typed","abs","add","multiply","transpose","divideScalar","subtract","larger","largerEq","SparseMatrix"],$S=q(fp,BS,r=>{var{typed:e,abs:t,add:i,multiply:n,transpose:a,divideScalar:o,subtract:f,larger:l,largerEq:u,SparseMatrix:s}=r,c=NS({add:i,multiply:n,transpose:a}),m=TS({abs:t,divideScalar:o,multiply:n,subtract:f,larger:l,largerEq:u,SparseMatrix:s});return e(fp,{"SparseMatrix, number, number":function(d,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,d,!1),N=m(d,y,g);return{L:N.L,U:N.U,p:N.pinv,q:y.q,toString:function(){return"L: "+this.L.toString()+`
47
30
  U: `+this.U.toString()+`
48
31
  p: `+this.p.toString()+(this.q?`
49
32
  q: `+this.q.toString():"")+`
50
- `}}}})});function hp(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 gp="lusolve",GS=["typed","matrix","lup","slu","usolve","lsolve","DenseMatrix"],HS=q(gp,GS,r=>{var{typed:e,matrix:t,lup:a,slu:n,usolve:i,lsolve:o,DenseMatrix:f}=r,l=Za({DenseMatrix:f});return e(gp,{"Array, Array | Matrix":function(m,v){m=t(m);var d=a(m),p=s(d.L,d.U,d.p,null,v);return p.valueOf()},"DenseMatrix, Array | Matrix":function(m,v){var d=a(m);return s(d.L,d.U,d.p,null,v)},"SparseMatrix, Array | Matrix":function(m,v){var d=a(m);return s(d.L,d.U,d.p,null,v)},"SparseMatrix, Array | Matrix, number, number":function(m,v,d,p){var g=n(m,d,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,d,p){c=u(c),m=u(m),v&&(p=l(c,p,!0),p._data=hp(v,p._data));var g=o(c,p),y=i(m,g);return d&&(y._data=hp(d,y._data)),y}}),yp="polynomialRoot",ZS=["typed","isZero","equalScalar","add","subtract","multiply","divide","sqrt","unaryMinus","cbrt","typeOf","im","re"],JS=q(yp,ZS,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(yp,{"number|Complex, ...number|Complex":(d,p)=>{for(var g=[d,...p];g.length>0&&t(g[g.length-1]);)g.pop();if(g.length<2)throw new RangeError("Polynomial [".concat(d,", ").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,h]=g,w=o(2,h),x=o(N,N),b=o(4,h,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,U=s(Q,K).toArray().map(j=>f(n(D,j,f(F,j)),B));return U.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))}}})}),WS="Help",XS=["parse"],YS=q(WS,XS,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
- `;if(a.name&&(n+="Name: "+a.name+`
33
+ `}}}})});function mp(r,e){var t,i=e.length,n=[];if(r)for(t=0;t<i;t++)n[r[t]]=e[t];else for(t=0;t<i;t++)n[t]=e[t];return n}var vp="lusolve",OS=["typed","matrix","lup","slu","usolve","lsolve","DenseMatrix"],IS=q(vp,OS,r=>{var{typed:e,matrix:t,lup:i,slu:n,usolve:a,lsolve:o,DenseMatrix:f}=r,l=La({DenseMatrix:f});return e(vp,{"Array, Array | Matrix":function(m,v){m=t(m);var d=i(m),p=s(d.L,d.U,d.p,null,v);return p.valueOf()},"DenseMatrix, Array | Matrix":function(m,v){var d=i(m);return s(d.L,d.U,d.p,null,v)},"SparseMatrix, Array | Matrix":function(m,v){var d=i(m);return s(d.L,d.U,d.p,null,v)},"SparseMatrix, Array | Matrix, number, number":function(m,v,d,p){var g=n(m,d,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,d,p){c=u(c),m=u(m),v&&(p=l(c,p,!0),p._data=mp(v,p._data));var g=o(c,p),y=a(m,g);return d&&(y._data=mp(d,y._data)),y}}),pp="polynomialRoot",RS=["typed","isZero","equalScalar","add","subtract","multiply","divide","sqrt","unaryMinus","cbrt","typeOf","im","re"],_S=q(pp,RS,r=>{var{typed:e,isZero:t,equalScalar:i,add:n,subtract:a,multiply:o,divide:f,sqrt:l,unaryMinus:u,cbrt:s,typeOf:c,im:m,re:v}=r;return e(pp,{"number|Complex, ...number|Complex":(d,p)=>{for(var g=[d,...p];g.length>0&&t(g[g.length-1]);)g.pop();if(g.length<2)throw new RangeError("Polynomial [".concat(d,", ").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,h]=g,w=o(2,h),x=o(N,N),b=o(4,h,y);if(i(x,b))return[f(u(N),w)];var E=l(a(x,b));return[f(a(E,N),w),f(a(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(i(I,P)&&i(R,M))return[f(D,B)];var F=a(I,P),H=a(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(i($,k))return[f(a(o(4,T,D,S),n(o(9,T,T,A),o(D,D,D))),o(T,F)),f(a(o(9,T,A),o(D,S)),o(2,F))];var Q;i(I,P)?Q=H:Q=f(n(H,l(a(o(H,H),o(4,F,F,F)))),2);var K=!0,U=s(Q,K).toArray().map(j=>f(n(D,j,f(F,j)),B));return U.map(j=>c(j)==="Complex"&&i(v(j),v(j)+m(j))?v(j):j)}default:throw new RangeError("only implemented for cubic or lower-order polynomials, not ".concat(g))}}})}),qS="Help",zS=["parse"],PS=q(qS,zS,r=>{var{parse:e}=r;function t(i){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(!i)throw new Error('Argument "doc" missing');this.doc=i}return t.prototype.type="Help",t.prototype.isHelp=!0,t.prototype.toString=function(){var i=this.doc||{},n=`
34
+ `;if(i.name&&(n+="Name: "+i.name+`
52
35
 
53
- `),a.category&&(n+="Category: "+a.category+`
36
+ `),i.category&&(n+="Category: "+i.category+`
54
37
 
55
- `),a.description&&(n+=`Description:
56
- `+a.description+`
38
+ `),i.description&&(n+=`Description:
39
+ `+i.description+`
57
40
 
58
- `),a.syntax&&(n+=`Syntax:
59
- `+a.syntax.join(`
41
+ `),i.syntax&&(n+=`Syntax:
42
+ `+i.syntax.join(`
60
43
  `)+`
61
44
 
62
- `),a.examples){n+=`Examples:
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&&!ll(l)&&(n+=" "+Ye(l,{precision:14})+`
45
+ `),i.examples){n+=`Examples:
46
+ `;for(var a={},o=0;o<i.examples.length;o++){var f=i.examples[o];n+=" "+f+`
47
+ `;var l=void 0;try{l=e(f).compile().evaluate(a)}catch(u){l=u}l!==void 0&&!al(l)&&(n+=" "+Ye(l,{precision:14})+`
65
48
  `)}n+=`
66
- `}return a.mayThrow&&a.mayThrow.length&&(n+="Throws: "+a.mayThrow.join(", ")+`
49
+ `}return i.mayThrow&&i.mayThrow.length&&(n+="Throws: "+i.mayThrow.join(", ")+`
67
50
 
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}),QS="Chain",KS=["?on","math","typed"],jS=q(QS,KS,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");cl(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){rg(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(d){Re(u,d)&&l[d]===void 0&&o(d,()=>u[d])};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}),bp={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"]},eC={name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},rC={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:[]},tC={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:[]},nC={name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},aC={name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},iC={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:[]},oC={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:[]},sC={name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},uC={name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},lC={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:[]},xp={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"]},cC={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:[]},fC={name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},mC={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"]},vC={name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},pC={name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},dC={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"]},hC={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"]},gC={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"]},yC={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"]},bC={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"]},xC={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"]},wC={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"]},NC={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"]},AC={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"]},EC={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"]},SC={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"]},CC={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:[]},MC={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:[]},FC={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:[]},TC={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"]},BC={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"]},$C={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"]},OC={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"]},IC={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"]},RC={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"]},_C={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"]},qC={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"]},zC={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"]},PC={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"]},LC={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"]},UC={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"]},kC={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"]},VC={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"]},GC={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"]},HC={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"]},ZC={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"]},JC={name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},WC={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"]},XC={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"]},YC={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"]},QC={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"]},KC={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"]},jC={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"]},eM={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"]},rM={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"]},tM={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"]},nM={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"]},aM={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"]},iM={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"]},oM={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"]},sM={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"]},uM={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"]},lM={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"]},cM={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"]},fM={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"]},mM={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"]},vM={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"]},pM={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"]},dM={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"]},hM={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"]},gM={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")']},yM={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"]},bM={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"]},xM={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"]},wM={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"]},NM={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"]},AM={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"]},EM={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"]},SM={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"]},CM={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"]},MM={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"]},FM={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"]},TM={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"]},BM={name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},$M={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"]},OM={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"]},IM={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"]},RM={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"]},_M={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"]},qM={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"]},zM={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"]},PM={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"]},LM={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"]},UM={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"]},kM={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"]},VM={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"]},GM={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"]},HM={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"]},ZM={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"]},JM={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"]},WM={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:[]},XM={name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},YM={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:[]},QM={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:[]},KM={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"]},jM={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"]},e3={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"]},r3={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"]},t3={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"]},n3={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"]},a3={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"]},i3={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"]},o3={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"]},s3={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"]},u3={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"]},l3={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"]},c3={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"]},f3={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"]},m3={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"]},v3={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"]},p3={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"]},d3={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"]},h3={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"]},g3={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"]},y3={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"]},b3={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"]},x3={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"]},w3={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"]},N3={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"]},A3={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"]},E3={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"]},S3={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"]},C3={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"]},M3={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"]},F3={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"]},T3={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"]},B3={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"]},$3={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"]},O3={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"]},I3={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"]},R3={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"]},_3={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"]},q3={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"]},z3={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"]},P3={name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},L3={name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},U3={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"]},k3={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"]},V3={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"]},G3={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"]},H3={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"]},Z3={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:[]},J3={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"]},W3={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"]},X3={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"]},Y3={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"]},Q3={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"]},K3={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"]},j3={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"]},eF={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"]},rF={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"]},tF={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"]},nF={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"]},aF={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"]},iF={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"]},oF={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"]},sF={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"]},uF={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"]},lF={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"]},cF={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"]},fF={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"]},mF={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"]},vF={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"]},pF={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"]},dF={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"]},hF={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"]},gF={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"]},yF={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"]},bF={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:[]},xF={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"]},wF={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"]},NF={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"]},AF={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"]},EF={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"]},SF={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"]},CF={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.
51
+ `),i.seealso&&i.seealso.length&&(n+="See also: "+i.seealso.join(", ")+`
52
+ `),n},t.prototype.toJSON=function(){var i=Ge(this.doc);return i.mathjs="Help",i},t.fromJSON=function(i){var n={};return Object.keys(i).filter(a=>a!=="mathjs").forEach(a=>{n[a]=i[a]}),new t(n)},t.prototype.valueOf=t.prototype.toString,t},{isClass:!0}),LS="Chain",US=["?on","math","typed"],kS=q(LS,US,r=>{var{on:e,math:t,typed:i}=r;function n(u){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");il(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 a(u,s){typeof s=="function"&&(n.prototype[u]=f(s))}function o(u,s){L0(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(i.isTypedFunction(u)){var m=i.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")a(u,s);else{var c=function(d){Re(u,d)&&l[d]===void 0&&o(d,()=>u[d])};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}),dp={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"]},VS={name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},GS={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:[]},HS={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:[]},ZS={name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},JS={name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},XS={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:[]},WS={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:[]},YS={name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},QS={name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},KS={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:[]},hp={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"]},jS={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:[]},eC={name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},rC={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"]},tC={name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},nC={name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},aC={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"]},iC={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"]},oC={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"]},sC={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"]},uC={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"]},lC={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"]},cC={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"]},fC={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"]},mC={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"]},vC={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"]},pC={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"]},dC={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"]},hC={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:[]},gC={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:[]},yC={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:[]},bC={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"]},xC={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"]},wC={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"]},NC={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"]},DC={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"]},AC={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"]},EC={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"]},SC={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"]},CC={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"]},MC={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"]},FC={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"]},TC={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"]},BC={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"]},OC={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"]},IC={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"]},RC={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"]},qC={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"]},zC={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"]},PC={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"]},LC={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"]},UC={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"]},kC={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"]},VC={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"]},GC={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"]},HC={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"]},ZC={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"]},JC={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"]},XC={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"]},WC={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"]},YC={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"]},QC={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"]},KC={name:"invmod",category:"Arithmetic",syntax:["invmod(a, b)"],description:"Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)",examples:["invmod(8, 12)=NaN","invmod(7, 13)=2","invmod(15151, 15122)=10429"],seealso:["gcd","xgcd"]},jC={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"]},eM={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"]},rM={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"]},tM={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"]},nM={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"]},aM={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"]},iM={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"]},oM={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")']},sM={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"]},uM={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"]},lM={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"]},cM={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"]},fM={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"]},mM={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"]},vM={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"]},pM={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"]},dM={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"]},hM={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"]},gM={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"]},yM={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"]},bM={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"]},xM={name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},wM={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"]},NM={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"]},DM={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"]},AM={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"]},EM={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"]},SM={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"]},CM={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"]},MM={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"]},FM={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"]},TM={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"]},BM={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"]},OM={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"]},IM={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"]},RM={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"]},qM={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:[]},zM={name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},PM={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:[]},LM={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:[]},UM={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"]},kM={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"]},VM={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"]},GM={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"]},HM={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"]},ZM={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"]},JM={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"]},XM={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"]},WM={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"]},YM={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"]},QM={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"]},KM={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"]},jM={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"]},e3={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"]},r3={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"]},t3={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"]},n3={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"]},a3={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"]},i3={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"]},o3={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"]},s3={name:"pinv",category:"Matrix",syntax:["pinv(x)"],description:"Calculate the Moore–Penrose inverse of a matrix",examples:["pinv([1, 2; 3, 4])","pinv([[1, 0], [0, 1], [0, 1]])","pinv(4)"],seealso:["inv"]},u3={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"]},l3={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"]},c3={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"]},f3={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"]},m3={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"]},v3={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"]},p3={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"]},d3={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"]},h3={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"]},g3={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"]},y3={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"]},b3={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"]},x3={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"]},w3={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"]},N3={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"]},D3={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"]},A3={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"]},E3={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"]},S3={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"]},C3={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"]},M3={name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},F3={name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},T3={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"]},B3={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"]},O3={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"]},I3={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"]},R3={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"]},q3={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"]},z3={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"]},P3={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"]},L3={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"]},U3={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"]},k3={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"]},V3={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"]},G3={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"]},H3={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"]},Z3={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"]},J3={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"]},X3={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"]},W3={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"]},Y3={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"]},Q3={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"]},K3={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"]},j3={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"]},eF={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"]},rF={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"]},tF={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"]},nF={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"]},aF={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"]},iF={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"]},oF={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"]},sF={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"]},uF={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:[]},lF={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"]},cF={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"]},fF={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"]},mF={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"]},vF={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"]},pF={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"]},dF={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"]},hF={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
53
 
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"]},MF={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"]},FF={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"]},TF={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"]},BF={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"]},$F={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"]},OF={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"]},IF={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"]},RF={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"]},_F={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"]},qF={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"]},zF={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"]},PF={name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},LF={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"]},UF={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"]},kF={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"]},VF={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"]},GF={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"]},HF={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"]},ZF={name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},JF={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"]},WF={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"]},XF={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"]},YF={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"]},QF={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"]},KF={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"]},jF={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"]},e4={name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},r4={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"]},t4={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"]},n4={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:[]},a4={name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},i4={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:[]},o4={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"]},s4={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"]},u4={name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},l4={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"]},c4={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"]},f4={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"]},m4={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"]},v4={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"]},p4={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"]},d4={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"]},h4={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"]},g4={name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},y4={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"]},b4={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"]},x4={bignumber:dC,boolean:hC,complex:gC,createUnit:yC,fraction:bC,index:xC,matrix:wC,number:NC,sparse:DC,splitUnit:AC,string:EC,unit:SC,e:bp,E:bp,false:eC,i:rC,Infinity:tC,LN2:aC,LN10:nC,LOG2E:oC,LOG10E:iC,NaN:sC,null:uC,pi:xp,PI:xp,phi:lC,SQRT1_2:cC,SQRT2:fC,tau:mC,true:vC,version:pC,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:TC,lsolve:$C,lsolveAll:OC,lup:IC,lusolve:RC,leafCount:BC,polynomialRoot:_C,resolve:PC,simplify:LC,simplifyConstant:UC,simplifyCore:kC,symbolicEqual:GC,rationalize:zC,slu:VC,usolve:HC,usolveAll:ZC,qr:qC,abs:JC,add:WC,cbrt:XC,ceil:YC,cube:QC,divide:KC,dotDivide:jC,dotMultiply:eM,dotPow:rM,exp:tM,expm:nM,expm1:aM,fix:iM,floor:oM,gcd:sM,hypot:uM,lcm:cM,log:fM,log2:pM,log1p:vM,log10:mM,mod:dM,multiply:hM,norm:gM,nthRoot:yM,nthRoots:bM,pow:xM,round:wM,sign:NM,sqrt:DM,sqrtm:AM,square:MM,subtract:FM,unaryMinus:TM,unaryPlus:BM,xgcd:$M,invmod:lM,bitAnd:OM,bitNot:IM,bitOr:RM,bitXor:_M,leftShift:qM,rightArithShift:zM,rightLogShift:PM,bellNumbers:LM,catalan:UM,composition:kM,stirlingS2:VM,config:CC,import:MC,typed:FC,arg:GM,conj:HM,re:JM,im:ZM,evaluate:WM,help:XM,distance:YM,intersect:QM,and:KM,not:jM,or:e3,xor:r3,concat:n3,count:a3,cross:i3,column:t3,ctranspose:o3,det:s3,diag:u3,diff:l3,dot:c3,getMatrixDataType:d3,identity:h3,filter:m3,flatten:v3,forEach:p3,inv:g3,pinv:y3,eigs:f3,kron:b3,matrixFromFunction:N3,matrixFromRows:D3,matrixFromColumns:w3,map:x3,ones:A3,partitionSelect:E3,range:S3,resize:M3,reshape:C3,rotate:F3,rotationMatrix:T3,row:B3,size:$3,sort:O3,squeeze:I3,subset:R3,trace:_3,transpose:q3,zeros:z3,fft:P3,ifft:L3,sylvester:EM,schur:SM,lyap:CM,combinations:U3,combinationsWithRep:k3,factorial:V3,gamma:G3,kldivergence:Z3,lgamma:H3,multinomial:J3,permutations:W3,pickRandom:X3,random:Y3,randomInt:Q3,compare:K3,compareNatural:j3,compareText:eF,deepEqual:rF,equal:tF,equalText:nF,larger:aF,largerEq:iF,smaller:oF,smallerEq:sF,unequal:uF,setCartesian:lF,setDifference:cF,setDistinct:fF,setIntersect:mF,setIsSubset:vF,setMultiplicity:pF,setPowerset:dF,setSize:hF,setSymDifference:gF,setUnion:yF,erf:bF,cumsum:FF,mad:xF,max:wF,mean:NF,median:DF,min:AF,mode:EF,prod:SF,quantileSeq:CF,std:MF,sum:TF,variance:BF,acos:$F,acosh:OF,acot:IF,acoth:RF,acsc:_F,acsch:qF,asec:zF,asech:PF,asin:LF,asinh:UF,atan:kF,atanh:GF,atan2:VF,cos:HF,cosh:ZF,cot:JF,coth:WF,csc:XF,csch:YF,sec:QF,sech:KF,sin:jF,sinh:e4,tan:r4,tanh:t4,to:n4,clone:i4,format:o4,bin:a4,oct:g4,hex:u4,isNaN:c4,isInteger:l4,isNegative:f4,isNumeric:m4,hasNumericValue:s4,isPositive:v4,isPrime:p4,isZero:d4,print:y4,typeOf:b4,numeric:h4},wp="help",w4=["typed","mathWithTransform","Help"],N4=q(wp,w4,r=>{var{typed:e,mathWithTransform:t,Help:a}=r;return e(wp,{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(x4,f);if(!l){var u=typeof f=="function"?f.name:f;throw new Error('No documentation found on "'+u+'"')}return new a(l)}})}),Np="chain",D4=["typed","Chain"],A4=q(Np,D4,r=>{var{typed:e,Chain:t}=r;return e(Np,{"":function(){return new t},any:function(n){return new t(n)}})}),Dp="det",E4=["typed","matrix","subtract","multiply","divideScalar","isZero","unaryMinus"],S4=q(Dp,E4,r=>{var{typed:e,matrix:t,subtract:a,multiply:n,divideScalar:i,isZero:o,unaryMinus:f}=r;return e(Dp,{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),d=0;d<s;d++){var p=v[d];if(o(u[p][d])){var g=void 0;for(g=d+1;g<s;g++)if(!o(u[v[g]][d])){p=v[g],v[g]=v[d],v[d]=p,m=!m;break}if(g===s)return u[p][d]}for(var y=u[p][d],N=d===0?1:u[v[d-1]][d-1],h=d+1;h<s;h++)for(var w=v[h],x=d+1;x<s;x++)u[w][x]=i(a(n(u[w][x],y),n(u[w][d],u[p][x])),N)}var b=u[v[s-1]][s-1];return m?f(b):b}}),Ap="inv",C4=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],M4=q(Ap,C4,r=>{var{typed:e,matrix:t,divideScalar:a,addScalar:n,multiply:i,unaryMinus:o,det:f,identity:l,abs:u}=r;return e(Ap,{"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 d=v[0],p=v[1];if(d===p)return Ve(m)?t(s(m.valueOf(),d,p),m.storage()):s(m,d,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 d,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 h=f(c);if(h===0)throw Error("Cannot calculate inverse, determinant is zero");return[[a(c[1][1],h),a(o(c[0][1]),h)],[a(o(c[1][0]),h),a(c[0][0],h)]]}else{var w=c.concat();for(d=0;d<m;d++)w[d]=w[d].concat();for(var x=l(m).valueOf(),b=0;b<v;b++){var E=u(w[b][b]),A=b;for(d=b+1;d<m;)u(w[d][b])>E&&(E=u(w[d][b]),A=d),d++;if(E===0)throw Error("Cannot calculate inverse, determinant is zero");d=A,d!==b&&(N=w[b],w[b]=w[d],w[d]=N,N=x[b],x[b]=x[d],x[d]=N);var S=w[b],D=x[b];for(d=0;d<m;d++){var T=w[d],B=x[d];if(d!==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}}}),Ep="pinv",F4=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],T4=q(Ep,F4,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(Ep,{"Array | Matrix":function(h){var w=Ve(h)?h.size():er(h);switch(w.length){case 1:return y(h)?l(h):w[0]===1?a(h):o(l(h),f(h,h));case 2:{if(y(h))return l(h);var x=w[0],b=w[1];if(x===b)try{return a(h)}catch(E){if(!(E instanceof Error&&E.message.match(/Cannot calculate inverse, determinant is zero/)))throw E}return Ve(h)?t(v(h.valueOf(),x,b),h.storage()):v(h,x,b)}default:throw new RangeError("Matrix must be two dimensional (size: "+Ye(w)+")")}},any:function(h){return i(h,0)?Ge(h):u(1,h)}});function v(N,h,w){var{C:x,F:b}=p(N,h,w),E=s(a(s(l(x),x)),l(x)),A=s(l(b),a(s(b,l(b))));return s(A,E)}function d(N,h,w){for(var x=Ge(N),b=0,E=0;E<h;E++){if(w<=b)return x;for(var A=E;g(x[A][b]);)if(A++,h===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<h;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,h,w){var x=d(N,h,w),b=N.map((A,S)=>A.filter((D,T)=>T<h&&!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 B4(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:d,equal:p,complex:g,larger:y,smaller:N,matrixFromColumns:h,dot:w}=r;function x(k,Q,K,U,j){j===void 0&&(j=!0);var ae=b(k,Q,K,U,j);E(k,Q,K,U,j,ae);var{values:re,C:me}=A(k,Q,K,U,j),he;return j&&(he=S(k,Q,me,ae,re,K,U),he=h(...he)),{values:re,vectors:he}}function b(k,Q,K,U,j){var ae=U==="BigNumber",re=U==="Complex",me=ae?u(0):0,he=ae?u(1):re?g(1):1,fe=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=me,W=me,se=0;se<Q;se++)if($e!==se){var G=l(k[$e][se]);V=e(V,G),W=e(W,G)}if(!p(V,0)&&!p(W,0)){for(var Y=fe,te=V,be=o(W,ie),ve=i(W,ie);N(te,be);)te=i(te,Ae),Y=i(Y,ie);for(;y(te,ve);)te=o(te,Ae),Y=o(Y,ie);var z=N(o(e(te,W),Y),i(e(V,W),.95));if(z){Ce=!1;for(var L=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],L));j&&(Oe[$e]=i(Oe[$e],Y))}}}}return s(Oe)}function E(k,Q,K,U,j,ae){var re=U==="BigNumber",me=U==="Complex",he=re?u(0):me?g(0):0;re&&(K=u(K));for(var fe=0;fe<Q-2;fe++){for(var ie=0,Ae=he,Oe=fe+1;Oe<Q;Oe++){var Ce=k[Oe][fe];N(l(Ae),l(Ce))&&(Ae=Ce,ie=Oe)}if(!N(l(Ae),K)){if(ie!==fe+1){var $e=k[ie];k[ie]=k[fe+1],k[fe+1]=$e;for(var V=0;V<Q;V++){var W=k[V][ie];k[V][ie]=k[V][fe+1],k[V][fe+1]=W}if(j){var se=ae[ie];ae[ie]=ae[fe+1],ae[fe+1]=se}}for(var G=fe+2;G<Q;G++){var Y=o(k[G][fe],Ae);if(Y!==0){for(var te=0;te<Q;te++)k[G][te]=t(k[G][te],i(Y,k[fe+1][te]));for(var be=0;be<Q;be++)k[be][fe+1]=e(k[be][fe+1],i(Y,k[be][G]));if(j)for(var ve=0;ve<Q;ve++)ae[G][ve]=t(ae[G][ve],i(Y,ae[fe+1][ve]))}}}}return ae}function A(k,Q,K,U,j){var ae=U==="BigNumber",re=U==="Complex",me=ae?u(1):re?g(1):1;ae&&(K=u(K));for(var he=Ge(k),fe=[],ie=Q,Ae=[],Oe=j?s(Array(Q).fill(me)):void 0,Ce=j?s(Array(ie).fill(me)):void 0,$e=0;$e<=100;){$e+=1;for(var V=0,W=0;W<ie;W++)he[W][W]=t(he[W][W],V);var{Q:se,R:G}=m(he);he=n(G,se);for(var Y=0;Y<ie;Y++)he[Y][Y]=e(he[Y][Y],V);if(j&&(Ce=n(Ce,se)),ie===1||N(l(he[ie-1][ie-2]),K)){$e=0,fe.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(me)))),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 be=D(he[ie-2][ie-2],he[ie-2][ie-1],he[ie-1][ie-2],he[ie-1][ie-1]);fe.push(...be),j&&(Ae.unshift(T(he[ie-2][ie-2],he[ie-2][ie-1],he[ie-1][ie-2],he[ie-1][ie-1],be[0],be[1],K,U)),B(Ce,Q),Oe=n(Oe,Ce),ie>2&&(Ce=s(Array(ie-2).fill(me)))),ie-=2,he.pop(),he.pop();for(var ve=0;ve<ie;ve++)he[ve].pop(),he[ve].pop()}if(ie===0)break}if(fe.sort((ee,le)=>+t(l(ee),l(le))),$e>100){var z=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+fe.join(", "));throw z.values=fe,z.vectors=[],z}var L=j?n(Oe,I(Ae,Q)):void 0;return{values:fe,C:L}}function S(k,Q,K,U,j,ae,re){var me=c(K),he=n(me,k,K),fe=re==="BigNumber",ie=re==="Complex",Ae=fe?u(0):ie?g(0):0,Oe=fe?u(1):ie?g(1):1,Ce=[],$e=[];for(var V of j){var W=P(Ce,V,p);W===-1?(Ce.push(V),$e.push(1)):$e[W]+=1}for(var se=[],G=Ce.length,Y=Array(Q).fill(Ae),te=s(Array(Q).fill(Oe)),be=[],ve=function(){var le=Ce[z],pe=t(he,n(le,te)),ge=d(pe,Y);for(ge.shift();ge.length<$e[z];){var xe=R(pe,Q,ge,ae,re);if(xe==null){be.push(le);break}ge.push(xe)}var de=n(c(U),K);ge=ge.map(Ne=>n(de,Ne)),se.push(...ge.map(Ne=>a(Ne)))},z=0;z<G;z++)ve();if(be.length!==0){var L=new Error("Failed to find eigenvectors for the following eigenvalues: "+be.join(", "));throw L.values=j,L.vectors=se,L}return se}function D(k,Q,K,U){var j=e(k,U),ae=t(i(k,U),i(Q,K)),re=i(j,.5),me=i(f(t(i(j,j),i(4,ae))),.5);return[e(re,me),t(re,me)]}function T(k,Q,K,U,j,ae,re,me){var he=me==="BigNumber",fe=me==="Complex",ie=he?u(0):fe?g(0):0,Ae=he?u(1):fe?g(1):1;if(N(l(K),re))return[[Ae,ie],[ie,Ae]];if(y(l(t(j,ae)),re))return[[t(j,U),t(ae,U)],[K,K]];var Oe=t(k,j),Ce=t(Q,j),$e=t(K,j),V=t(U,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 U=k.length;U<Q;U++)k.push(Array(Q).fill(0)),k[U][U]=1;return k}function I(k,Q){for(var K=[],U=0;U<Q;U++)K[U]=Array(Q).fill(0);var j=0;for(var ae of k){for(var re=ae.length,me=0;me<re;me++)for(var he=0;he<re;he++)K[j+me][j+he]=ae[me][he];j+=re}return K}function P(k,Q,K){for(var U=0;U<k.length;U++)if(K(k[U],Q))return U;return-1}function R(k,Q,K,U,j){for(var ae=j==="BigNumber"?u(1e3):1e3,re,me=0;re=M(Q,K,j),re=v(k,re),!y(H(re),ae);)if(++me>=5)return null;for(me=0;;){var he=v(k,re);if(N(H(F(re,[he])),U))break;if(++me>=10)return null;re=$(he)}return re}function M(k,Q,K){var U=K==="BigNumber",j=K==="Complex",ae=Array(k).fill(0).map(re=>2*Math.random()-1);return U&&(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",U=Q==="Complex",j=K?u(1):U?g(1):1;return n(o(j,H(k)),k)}return x}function $4(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 d(D,B);if(I==="BigNumber")return p(D,B);throw TypeError("Unsupported data type: "+I)}function d(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=h(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 h(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])),U=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]=U,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],U=0;U<P;U++)$[U]=R*D[B][U]-M*D[I][U],k[U]=M*D[B][U]+R*D[I][U];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 O4="eigs",I4=["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"],R4=q(O4,I4,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:d,multiply:p,add:g,larger:y,column:N,flatten:h,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=$4({config:e,addScalar:n,subtract:i,column:N,flatten:h,equal:o,abs:f,atan:l,cos:u,sin:s,multiplyScalar:c,inv:v,bignumber:d,complex:x,multiply:p,add:g}),F=B4({config:e,addScalar:n,subtract:i,multiply:p,multiplyScalar:c,flatten:h,divideScalar:m,sqrt:b,abs:f,bignumber:d,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:me}=H(j,ae);return{values:a(re),vectors:a(me)}}});function H(U,j){j===void 0&&(j=e.epsilon);var ae=U.size();if(ae.length!==2||ae[0]!==ae[1])throw new RangeError("Matrix must be square (size: "+Ye(ae)+")");var re=U.toArray(),me=ae[0];if(k(re,me,j)&&(Q(re,me),$(re,me,j))){var he=K(U,re,me);return M(re,me,j,he)}var fe=K(U,re,me);return F(re,me,j,fe)}function $(U,j,ae){for(var re=0;re<j;re++)for(var me=re;me<j;me++)if(y(d(f(i(U[re][me],U[me][re]))),ae))return!1;return!0}function k(U,j,ae){for(var re=0;re<j;re++)for(var me=0;me<j;me++)if(y(d(f(T(U[re][me]))),ae))return!1;return!0}function Q(U,j){for(var ae=0;ae<j;ae++)for(var re=0;re<j;re++)U[ae][re]=B(U[ae][re])}function K(U,j,ae){var re=U.datatype();if(re==="number"||re==="BigNumber"||re==="Complex")return re;for(var me=!1,he=!1,fe=!1,ie=0;ie<ae;ie++)for(var Ae=0;Ae<ae;Ae++){var Oe=j[ie][Ae];if(tr(Oe)||za(Oe))me=!0;else if(rr(Oe))he=!0;else if(kt(Oe))fe=!0;else throw TypeError("Unsupported type in Matrix: "+br(Oe))}if(he&&fe&&console.warn("Complex BigNumbers not supported, this operation will lose precission."),fe){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 W=0;W<ae;W++)j[V][W]=d(j[V][W]);return"BigNumber"}if(me){for(var se=0;se<ae;se++)for(var G=0;G<ae;G++)j[se][G]=w(j[se][G]);return"number"}else throw TypeError("Matrix contains unsupported types only.")}}),Sp="expm",_4=["typed","abs","add","identity","inv","multiply"],q4=q(Sp,_4,r=>{var{typed:e,abs:t,add:a,identity:n,inv:i,multiply:o}=r;return e(Sp,{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],d=1e-15,p=f(c),g=l(p,d),y=g.q,N=g.j,h=o(c,Math.pow(2,-N)),w=n(v),x=n(v),b=1,E=h,A=-1,S=1;S<=y;S++)S>1&&(E=o(E,h),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 d=0,p=0;p<c;p++)d+=t(s.get([v,p]));m=Math.max(d,m)}return m}function l(s,c){for(var m=30,v=0;v<m;v++)for(var d=0;d<=v;d++){var p=v-d;if(u(s,d,p)<c)return{q:d,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,d=2;d<=c;d++)v*=d;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)}}),Cp="sqrtm",z4=["typed","abs","add","multiply","map","sqrt","subtract","inv","size","max","identity"],P4=q(Cp,z4,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 d(p){var g,y=0,N=p,h=c(u(p));do{var w=N;if(N=n(.5,a(w,l(h))),h=n(.5,a(h,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(Cp,{"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],h=y[1];if(N===h)return d(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)+")")}}})}),Mp="sylvester",L4=["typed","schur","matrixFromColumns","matrix","multiply","range","concat","transpose","index","subset","add","subtract","identity","lusolve","abs"],U4=q(Mp,L4,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:d,abs:p}=r;return e(Mp,{"Matrix, Matrix, Matrix":g,"Array, Matrix, Matrix":function(N,h,w){return g(n(N),h,w)},"Array, Array, Matrix":function(N,h,w){return g(n(N),n(h),w)},"Array, Matrix, Array":function(N,h,w){return g(n(N),h,n(w))},"Matrix, Array, Matrix":function(N,h,w){return g(N,n(h),w)},"Matrix, Array, Array":function(N,h,w){return g(N,n(h),n(w))},"Matrix, Matrix, Array":function(N,h,w){return g(N,h,n(w))},"Array, Array, Array":function(N,h,w){return g(n(N),n(h),n(w)).toArray()}});function g(y,N,h){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),h),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)))),U=i(v(x),i(-1,s(D,u(F+1,F+1)))),j=M(R(c(E,k),Q),R(K,c(E,U))),ae=d(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)),me=0;me<F;me++)re=c(re,i(P[me],s(D,u(me,F))));var he=s(D,u(F,F)),fe=m(E,i(he,v(x)));P[F]=d(fe,re)}var ie=n(a(...P)),Ae=i(A,i(ie,l(T)));return Ae}}),Fp="schur",k4=["typed","matrix","identity","multiply","qr","norm","subtract"],V4=q(Fp,k4,r=>{var{typed:e,matrix:t,identity:a,multiply:n,qr:i,norm:o,subtract:f}=r;return e(Fp,{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,d;do{d=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,d))>1e-4);return{U:m,T:c}}}),Tp="lyap",G4=["typed","matrix","sylvester","multiply","transpose"],H4=q(Tp,G4,r=>{var{typed:e,matrix:t,sylvester:a,multiply:n,transpose:i}=r;return e(Tp,{"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()}})}),Z4="divide",J4=["typed","matrix","multiply","equalScalar","divideScalar","inv"],W4=q(Z4,J4,r=>{var{typed:e,matrix:t,multiply:a,equalScalar:n,divideScalar:i,inv:o}=r,f=Ur({typed:e,equalScalar:n}),l=xt({typed:e});return e("divide",fl({"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))}),Bp="distance",X4=["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],Y4=q(Bp,X4,r=>{var{typed:e,addScalar:t,subtract:a,multiplyScalar:n,divideScalar:i,unaryMinus:o,sqrt:f,abs:l}=r;return e(Bp,{"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 h(x)}});function u(w){return typeof w=="number"||rr(w)}function s(w){return w.constructor!==Array&&(w=d(w)),u(w[0])&&u(w[1])}function c(w){return w.constructor!==Array&&(w=d(w)),u(w[0])&&u(w[1])&&u(w[2])}function m(w){return Array.isArray(w)||(w=d(w)),w.every(u)}function v(w){return w.constructor!==Array&&(w=d(w)),u(w[0])&&u(w[1])&&u(w[2])&&u(w[3])&&u(w[4])&&u(w[5])}function d(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 h(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}}),Q4="intersect",K4=["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],j4=q(Q4,K4,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:d,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(!h(D))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!h(T))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!h(B))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!h(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 h(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(d(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]),U=u(i(s(s($,k),Q),K),H);return n(f(M,U),P)}function E(D,T,B,I,P,R,M,F,H,$,k,Q){var K=l(s(D,T),s(B,I)),U=l(s(P,R),s(M,F)),j=l(s(H,$),s(k,Q));return i(i(K,U),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),U=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),me=s(l(K,U),l(j,ae)),he=s(l(re,ae),l(U,U));if(d(he))return null;var fe=u(me,he),ie=u(i(K,l(fe,U)),ae),Ae=i(D,l(fe,s(I,D))),Oe=i(T,l(fe,s(P,T))),Ce=i(B,l(fe,s(R,B))),$e=i(M,l(ie,s($,M))),V=i(F,l(ie,s(k,F))),W=i(H,l(ie,s(Q,H)));return m(Ae,$e)&&m(Oe,V)&&m(Ce,W)?[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),U=l(P,F),j=l(B,H),ae=l(R,H),re=s(s(s($,k),K),j),me=s(s(s(i(i(Q,U),ae),k),K),j),he=u(re,me),fe=i(D,l(he,s(I,D))),ie=i(T,l(he,s(P,T))),Ae=i(B,l(he,s(R,B)));return[fe,ie,Ae]}}),$p="sum",eT=["typed","config","add","numeric"],Op=q($p,eT,r=>{var{typed:e,config:t,add:a,numeric:n}=r;return e($p,{"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 Wt(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=Ci(f,l,a);return u}catch(s){throw Qr(s,"sum")}}}),oo="cumsum",rT=["typed","add","unaryPlus"],Ip=q(oo,rT,r=>{var{typed:e,add:t,unaryPlus:a}=r;return e(oo,{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,oo)}}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,oo)}}function f(l,u){var s,c,m;if(u<=0){var v=l[0][0];if(Array.isArray(v)){for(m=Ql(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}}}),Rp="mean",tT=["typed","add","divide"],_p=q(Rp,tT,r=>{var{typed:e,add:t,divide:a}=r;return e(Rp,{"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=Ci(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(Wt(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)}}),qp="median",nT=["typed","add","divide","compare","partitionSelect"],aT=q(qp,nT,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],d=0;d<c;++d)n(u[d],v)>0&&(v=u[d]);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(qp,{"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)}})}),zp="mad",iT=["typed","abs","map","median","subtract"],oT=q(zp,iT,r=>{var{typed:e,abs:t,map:a,median:n,subtract:i}=r;return e(zp,{"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")}}}),Es="unbiased",Pp="variance",sT=["typed","add","subtract","multiply","divide","apply","isNaN"],Lp=q(Pp,sT,r=>{var{typed:e,add:t,subtract:a,multiply:n,divide:i,apply:o,isNaN:f}=r;return e(Pp,{"Array | Matrix":function(c){return l(c,Es)},"Array | Matrix, string":l,"Array | Matrix, number | BigNumber":function(c,m){return u(c,m,Es)},"Array | Matrix, number | BigNumber, string":u,"...":function(c){return l(c,Es)}});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(Wt(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 d=i(m,v);if(m=void 0,Wt(s,function(g){var y=a(g,d);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")}}}),uT="quantileSeq",lT=["typed","add","multiply","partitionSelect","compare"],cT=q(uT,lT,r=>{var{typed:e,add:t,multiply:a,partitionSelect:n,compare:i}=r;function o(u,s,c){var m,v,d;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(d=new y(1),s.lte(d))return new y(f(v,s,c));if(s.gt(d)){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 h=new y(N+1);m=new Array(N);for(var w=0;w<N;)m[w]=new y(f(v,new y(++w).div(h),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(d=new E.constructor(1),E.isNegative()||E.gt(d))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 d=s*(v-1),p=d%1;if(p===0){var g=c?m[d]:n(m,d);return l(g),g}var y=Math.floor(d),N,h;if(c)N=m[y],h=m[y+1];else{h=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(h),t(a(N,1-p),a(h,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}),Up="std",fT=["typed","map","sqrt","variance"],kp=q(Up,fT,r=>{var{typed:e,map:t,sqrt:a,variance:n}=r;return e(Up,{"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}}}),Vp="combinations",mT=["typed"],vT=q(Vp,mT,r=>{var{typed:e}=r;return e(Vp,{"number, number":Ec,"BigNumber, BigNumber":function(a,n){var i=a.constructor,o,f,l=a.minus(n),u=new i(1);if(!Gp(a)||!Gp(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 Gp(r){return r.isInteger()&&r.gte(0)}var Hp="combinationsWithRep",pT=["typed"],dT=q(Hp,pT,r=>{var{typed:e}=r;return e(Hp,{"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(!Zp(a)||!Zp(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 Zp(r){return r.isInteger()&&r.gte(0)}var Jp="gamma",hT=["typed","config","multiplyScalar","pow","BigNumber","Complex"],gT=q(Jp,hT,r=>{var{typed:e,config:t,multiplyScalar:a,pow:n,BigNumber:i,Complex:o}=r;function f(u){if(u.im===0)return Fi(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 d=new o(oa[v],0);m=m.add(d.div(u.add(v)))}var p=new o(u.re+Tc+.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(Jp,{number:Fi,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),d=u.toNumber();m>2;)m-=2,d+=m,v=v.times(d);return new i(v.toPrecision(i.precision))}}),Wp="lgamma",yT=["Complex","typed"],bT=q(Wp,yT,r=>{var{Complex:e,typed:t}=r,a=7,n=7,i=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return t(Wp,{number:Ti,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(Ti(u.re),0);if(u.re>=a||Math.abs(u.im)>=n)return f(u);if(u.re<=m){var v=wg(s,u.im)*Math.floor(.5*u.re+.25),d=u.mul(Math.PI).sin().log(),p=o(new e(1-u.re,-u.im));return new e(c,v).sub(d).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(Bc),c=new e(1,0).div(u),m=c.div(u),v=i[0],d=i[1],p=2*m.re,g=m.re*m.re+m.im*m.im,y=2;y<8;y++){var N=d;d=-g*v+i[y],v=p*v+N}var h=c.mul(m.mul(v).add(d));return s.add(h)}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))}}),Xp="factorial",xT=["typed","gamma"],wT=q(Xp,xT,r=>{var{typed:e,gamma:t}=r;return e(Xp,{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))})}),Yp="kldivergence",NT=["typed","matrix","divide","sum","multiply","map","dotDivide","log","isNumeric"],DT=q(Yp,NT,r=>{var{typed:e,matrix:t,divide:a,sum:n,multiply:i,map:o,dotDivide:f,log:l,isNumeric:u}=r;return e(Yp,{"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,d=c.size().length;if(v>1)throw new Error("first object must be one dimensional");if(d>1)throw new Error("second object must be one dimensional");if(v!==d)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)),h=n(i(y,o(f(y,N),w=>l(w))));return u(h)?h:Number.NaN}}),Qp="multinomial",AT=["typed","add","divide","multiply","factorial","isInteger","isPositive"],ET=q(Qp,AT,r=>{var{typed:e,add:t,divide:a,multiply:n,factorial:i,isInteger:o,isPositive:f}=r;return e(Qp,{"Array | Matrix":function(u){var s=0,c=1;return Wt(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)}})}),Kp="permutations",ST=["typed","factorial"],CT=q(Kp,ST,r=>{var{typed:e,factorial:t}=r;return e(Kp,{"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(!jp(n)||!jp(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 jp(r){return r.isInteger()&&r.gte(0)}var ed={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)})(ed);var rd={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,d=(m+v)/(1<<21);while(d===0);return d},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)})(rd);var td={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,d=(m+v)/(1<<21);while(d===0);return d},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)})(td);var nd={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,d=(m+v)/(1<<21);while(d===0);return d},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)})(nd);var ad={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,d;return l.w=s=s+1640531527|0,d=c[m+34&127],v=c[m=m+1&127],d^=d<<13,v^=v<<17,d^=d>>>15,v^=v>>>12,d=c[m]=d^v,l.i=m,d+(s^s>>>16)|0};function u(s,c){var m,v,d,p,g,y=[],N=128;for(c===(c|0)?(v=c,c=null):(c=c+"\0",v=0,N=Math.max(N,c.length)),d=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,d=m==0?d+1:0);for(d>=128&&(y[(c&&c.length||0)&127]=-1),d=127,p=4*128;p>0;--p)v=y[d+34&127],m=y[d=d+1&127],v^=v<<13,m^=m<<17,v^=v>>>15,m^=m>>>12,y[d]=v^m;s.w=g,s.X=y,s.i=d}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,d=(m+v)/(1<<21);while(d===0);return d},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)})(ad);var id={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,d=l.a;return c=c<<25^c>>>7^m,m=m-v|0,v=v<<24^v>>>8^d,d=d-c|0,l.b=c=c<<20^c>>>12^m,l.c=m=m-v|0,l.d=v<<16^m>>>16^d,l.a=d-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,d=(m+v)/(1<<21);while(d===0);return d},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)})(id);var od={exports:{}};const MT=P1(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,h(t)]:w==null?N():w,3),E),S=new d(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(h(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 d(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 h(x)}function N(){try{var w;return m&&(w=m.randomBytes)?w=w(n):(w=new Uint8Array(n),(e.crypto||e.msCrypto).getRandomValues(w)),h(w)}catch{var x=e.navigator,b=x&&x.plugins;return[+new Date,e,b,e.screen,h(t)]}}function h(w){return String.fromCharCode.apply(0,w)}if(y(a.random(),t),r.exports){r.exports=v;try{m=MT}catch{}}else a["seed"+f]=v})(typeof self<"u"?self:Mn,[],Math)})(od);var FT=ed.exports,TT=rd.exports,BT=td.exports,$T=nd.exports,OT=ad.exports,IT=id.exports,$n=od.exports;$n.alea=FT,$n.xor128=TT,$n.xorwow=BT,$n.xorshift7=$T,$n.xor4096=OT,$n.tychei=IT;var sd=$n,RT=sd(Date.now());function ma(r){var e;function t(n){e=n===null?RT:sd(String(n))}t(r);function a(){return e()}return a}var ud="pickRandom",_T=["typed","config","?on"],qT=q(ud,_T,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(ud,{"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 d=0,p=u.length;d<p;d++){if(!tr(u[d])||u[d]<0)throw new Error("Weights must be an array of positive numbers");v+=u[d]}}for(var g=o.length,y=[],N;y.length<l;){if(typeof u>"u")N=o[Math.floor(n()*g)];else for(var h=n()*v,w=0,x=o.length;w<x;w++)if(h-=u[w],h<0){N=o[w];break}y.push(N)}return c?y[0]:m?m(y):y}});function Ss(r,e){var t=[];if(r=r.slice(0),r.length>1)for(var a=0,n=r.shift();a<n;a++)t.push(Ss(r,e));else for(var i=0,o=r.shift();i<o;i++)t.push(e());return t}var ld="random",zT=["typed","config","?on"],PT=q(ld,zT,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(ld,{"":()=>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=Ss(f.valueOf(),()=>o(l,u));return Ve(f)?f.create(s):s}function o(f,l){return f+n()*(l-f)}}),cd="randomInt",LT=["typed","config","?on"],UT=q(cd,LT,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(cd,{"":()=>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=Ss(f.valueOf(),()=>o(l,u));return Ve(f)?f.create(s):s}function o(f,l){return Math.floor(f+n()*(l-f))}}),fd="stirlingS2",kT=["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],VT=q(fd,kT,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,d=[],p=[];return e(fd,{"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 h=!(tr(y)&&tr(N)),w=h?p:d,x=h?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]}})}),md="bellNumbers",GT=["typed","addScalar","isNegative","isInteger","stirlingS2"],HT=q(md,GT,r=>{var{typed:e,addScalar:t,isNegative:a,isInteger:n,stirlingS2:i}=r;return e(md,{"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}})}),vd="catalan",ZT=["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],JT=q(vd,ZT,r=>{var{typed:e,addScalar:t,divideScalar:a,multiplyScalar:n,combinations:i,isNegative:o,isInteger:f}=r;return e(vd,{"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))}})}),pd="composition",WT=["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],XT=q(pd,WT,r=>{var{typed:e,addScalar:t,combinations:a,isPositive:n,isNegative:i,isInteger:o,larger:f}=r;return e(pd,{"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))}})}),dd="leafCount",YT=["parse","typed"],QT=q(dd,YT,r=>{var{parse:e,typed:t}=r;function a(n){var i=0;return n.forEach(o=>{i+=a(o)}),i||1}return t(dd,{Node:function(i){return a(i)}})});function hd(r){return ir(r)||Br(r)&&r.isUnary()&&ir(r.args[0])}function so(r){return!!(ir(r)||(nn(r)||Br(r))&&r.args.every(so)||Gt(r)&&so(r.content))}function gd(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 Cs(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?gd(Object(t),!0).forEach(function(a){zr(r,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):gd(Object(t)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(t,a))})}return r}var KT="simplifyUtil",jT=["FunctionNode","OperatorNode","SymbolNode"],Ms=q(KT,jT,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(h,w){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:f,b=o;if(typeof h=="string"?b=h:Br(h)?b=h.fn.toString():nn(h)?b=h.name:Gt(h)&&(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(h){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f;return s(h,"commutative",w)}function m(h){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f;return s(h,"associative",w)}function v(h,w){var x=Cs({},h);for(var b in w)Re(h,b)?x[b]=Cs(Cs({},w[b]),h[b]):x[b]=w[b];return x}function d(h,w){if(!h.args||h.args.length===0)return h;h.args=p(h,w);for(var x=0;x<h.args.length;x++)d(h.args[x],w)}function p(h,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(h,w)?(x=h.op,E(h),b):h.args}function g(h,w){if(!(!h.args||h.args.length===0)){for(var x=N(h),b=h.args.length,E=0;E<b;E++)g(h.args[E],w);if(b>2&&m(h,w)){for(var A=h.args.pop();h.args.length>0;)A=x([h.args.pop(),A]);h.args=A.args}}}function y(h,w){if(!(!h.args||h.args.length===0)){for(var x=N(h),b=h.args.length,E=0;E<b;E++)y(h.args[E],w);if(b>2&&m(h,w)){for(var A=h.args.shift();h.args.length>0;)A=x([A,h.args.shift()]);h.args=A.args}}}function N(h){return Br(h)?function(w){try{return new t(h.op,h.fn,w,h.implicit)}catch(x){return console.error(x),[]}}:function(w){return new e(new a(h.name),w)}}return{createMakeNodeFunction:N,hasProperty:s,isCommutative:c,isAssociative:m,mergeContext:v,flatten:d,allChildren:p,unflattenr:g,unflattenl:y,defaultContext:f,realContext:l,positiveContext:u}}),eB="simplify",rB=["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"],tB=q(eB,rB,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:d,bignumber:p,mathWithTransform:g,matrix:y,AccessorNode:N,ArrayNode:h,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}=Ms({FunctionNode:x,OperatorNode:A,SymbolNode:D});t.addConversion({from:"Object",to:"Map",convert:ra});var K=t("simplify",{Node:fe,"Node, Map":(G,Y)=>fe(G,!1,Y),"Node, Map, Object":(G,Y,te)=>fe(G,!1,Y,te),"Node, Array":fe,"Node, Array, Map":fe,"Node, Array, Map, Object":fe});t.removeConversion({from:"Object",to:"Map",convert:ra}),K.defaultContext=$,K.realContext=k,K.positiveContext=Q;function U(G){return G.transform(function(Y,te,be){return Gt(Y)?U(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 be=G.s.split("->");if(be.length===2)te.l=be[0],te.r=be[1];else throw SyntaxError("Could not parse rule: "+G.s)}else te.l=G.l,te.r=G.r;te.l=U(a(te.l)),te.r=U(a(te.r));for(var ve of["imposeContext","repeat","assuming"])ve in G&&(te[ve]=G[ve]);if(G.evaluate&&(te.evaluate=a(G.evaluate)),I(te.l,Y)){var z=!B(te.l,Y),L;z&&(L=he());var ee=H(te.l),le=he();te.expanded={},te.expanded.l=ee([te.l,le]),R(te.expanded.l,Y),M(te.expanded.l,Y),te.expanded.r=ee([te.r,le]),z&&(te.expandedNC1={},te.expandedNC1.l=ee([L,te.l]),te.expandedNC1.r=ee([L,te.r]),te.expandedNC2={},te.expandedNC2.l=ee([L,te.expanded.l]),te.expandedNC2.r=ee([L,te.expanded.r]))}return te}function re(G,Y){for(var te=[],be=0;be<G.length;be++){var ve=G[be],z=void 0,L=typeof ve;switch(L){case"string":ve={s:ve};case"object":z=ae(ve,Y);break;case"function":z=ve;break;default:throw TypeError("Unsupported type of rule: "+L)}te.push(z)}return te}var me=0;function he(){return new D("_p"+me++)}function fe(G,Y){var te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ea(),be=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},ve=be.consoleDebug;Y=re(Y||K.rules,be.context);var z=c(G,te);z=U(z);for(var L={},ee=z.toString({parenthesis:"all"});!L[ee];){L[ee]=!0,me=0;var le=ee;ve&&console.log("Working on: ",ee);for(var pe=0;pe<Y.length;pe++){var ge="";if(typeof Y[pe]=="function"?(z=Y[pe](z,be),ve&&(ge=Y[pe].name)):(R(z,be.context),z=Ae(z,Y[pe],be.context),ve&&(ge="".concat(Y[pe].l.toString()," -> ").concat(Y[pe].r.toString()))),ve){var xe=z.toString({parenthesis:"all"});xe!==le&&(console.log("Applying",ge,"produced",xe),le=xe)}F(z,be.context)}ee=z.toString({parenthesis:"all"})}return z}function ie(G,Y,te){var be=G;if(G)for(var ve=0;ve<G.length;++ve){var z=Ae(G[ve],Y,te);z!==G[ve]&&(be===G&&(be=G.slice()),be[ve]=z)}return be}function Ae(G,Y,te){if(Y.assuming){for(var be in Y.assuming)for(var ve in Y.assuming[be])if(T(be,ve,te)!==Y.assuming[be][ve])return G}var z=P(Y.imposeContext,te),L=G;if(L instanceof A||L instanceof x){var ee=ie(L.args,Y,te);ee!==L.args&&(L=L.clone(),L.args=ee)}else if(L instanceof S){if(L.content){var le=Ae(L.content,Y,te);le!==L.content&&(L=new S(le))}}else if(L instanceof h){var pe=ie(L.items,Y,te);pe!==L.items&&(L=new h(pe))}else if(L instanceof N){var ge=L.object;L.object&&(ge=Ae(L.object,Y,te));var xe=L.index;L.index&&(xe=Ae(L.index,Y,te)),(ge!==L.object||xe!==L.index)&&(L=new N(ge,xe))}else if(L instanceof b){var de=ie(L.dimensions,Y,te);de!==L.dimensions&&(L=new b(de))}else if(L instanceof E){var Ne=!1,_e={};for(var Ue in L.properties)_e[Ue]=Ae(L.properties[Ue],Y,te),_e[Ue]!==L.properties[Ue]&&(Ne=!0);Ne&&(L=new E(_e))}var Be=Y.r,ar=W(Y.l,L,z)[0];if(!ar&&Y.expanded&&(Be=Y.expanded.r,ar=W(Y.expanded.l,L,z)[0]),!ar&&Y.expandedNC1&&(Be=Y.expandedNC1.r,ar=W(Y.expandedNC1.l,L,z)[0],ar||(Be=Y.expandedNC2.r,ar=W(Y.expandedNC2.l,L,z)[0])),ar){var Je=L.implicit;L=Be.clone(),Je&&"implicit"in Be&&(L.implicit=!0),L=L.transform(function(mr){return mr.isSymbolNode&&Re(ar.placeholders,mr.name)?ar.placeholders[mr.name].clone():mr})}return Y.repeat&&L!==G&&(L=Ae(L,Y,te)),L}function Oe(G,Y){var te=[],be,ve,z=H(G);if(B(G,Y))for(var L=0;L<G.args.length;L++)ve=G.args.slice(0),ve.splice(L,1),be=ve.length===1?ve[0]:z(ve),te.push(z([G.args[L],be]));else for(var ee=1;ee<G.args.length;ee++){var le=G.args[0];ee>1&&(le=z(G.args.slice(0,ee))),ve=G.args.slice(ee),be=ve.length===1?ve[0]:z(ve),te.push(z([le,be]))}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 be in G.placeholders)if(Re(G.placeholders,be)&&(te.placeholders[be]=G.placeholders[be],Re(Y.placeholders,be)&&!se(G.placeholders[be],Y.placeholders[be])))return null;for(var ve in Y.placeholders)Re(Y.placeholders,ve)&&(te.placeholders[ve]=Y.placeholders[ve]);return te}function $e(G,Y){var te=[];if(G.length===0||Y.length===0)return te;for(var be,ve=0;ve<G.length;ve++)for(var z=0;z<Y.length;z++)be=Ce(G[ve],Y[z]),be&&te.push(be);return te}function V(G){if(G.length===0)return G;for(var Y=G.reduce($e),te=[],be={},ve=0;ve<Y.length;ve++){var z=JSON.stringify(Y[ve]);be[z]||(be[z]=!0,te.push(Y[ve]))}return te}function W(G,Y,te,be){var ve=[{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||be){for(var z=[],L=0;L<G.args.length;L++){var ee=W(G.args[L],Y.args[L],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 le=W(G.args[0],Y.args[1],te);if(le.length===0)return[];var pe=W(G.args[1],Y.args[0],te);if(pe.length===0)return[];z=[le,pe]}ve=V(z)}else if(Y.args.length>=2&&G.args.length===2){for(var ge=Oe(Y,te),xe=[],de=0;de<ge.length;de++){var Ne=W(G,ge[de],te,!0);xe=xe.concat(Ne)}return xe}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":ve[0].placeholders[G.name]=Y;break;case"c":case"cl":if(ir(Y))ve[0].placeholders[G.name]=Y;else return[];break;case"v":if(!ir(Y))ve[0].placeholders[G.name]=Y;else return[];break;case"vl":if(qr(Y))ve[0].placeholders[G.name]=Y;else return[];break;case"cd":if(hd(Y))ve[0].placeholders[G.name]=Y;else return[];break;case"vd":if(!hd(Y))ve[0].placeholders[G.name]=Y;else return[];break;case"ce":if(so(Y))ve[0].placeholders[G.name]=Y;else return[];break;case"ve":if(!so(Y))ve[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 ve}function se(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(!se(G.args[te],Y.args[te]))return!1}else return!1;return!0}return K}),nB="simplifyConstant",aB=["typed","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],iB=q(nB,aB,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:d}=r,{isCommutative:p,isAssociative:g,allChildren:y,createMakeNodeFunction:N}=Ms({FunctionNode:s,OperatorNode:v,SymbolNode:d}),h=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&&ds(),o(M);if(t.number==="Fraction")return i===void 0&&vm(),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 U of K)if(ot(U))Q.push(U.items[k-1]);else if(Ve(R))Q.push(U[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(fi(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 U=Q.pop();if(fr(U))return[U,K];try{return Q.push(x(R,[U,K],H)),Q}catch{Q.push(U)}}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,U,j=N(R);if(Br(R)&&R.isUnary())K=[P(R.args[0],M)],fr(K[0])?U=j(K):U=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=[],me=0;me<K.length;me++)fr(K[me])?re.push(K[me]):ae.push(K[me]);ae.length>1?(U=I(Q,ae,j,M),re.unshift(U),U=I(Q,re,j,M)):U=I(Q,K,j,M)}else U=I(Q,K,j,M);else K=R.args.map(Ae=>P(Ae,M)),U=I(Q,K,j,M);return U}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=>h(Ae,M)));case"ObjectNode":{var fe={};for(var ie in R.properties)fe[ie]=h(R.properties[ie],M);return new m(fe)}case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"RangeNode":case"ConditionalNode":default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(R.type))}}return h}),yd="simplifyCore",oB=["typed","parse","equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],sB=q(yd,oB,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:d,ObjectNode:p,OperatorNode:g,ParenthesisNode:y,SymbolNode:N}=r,h=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}=Ms({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=EE(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),U=D(M.args[1],B);if(M.op==="+"){if(ir(K)&&n(K.value))return U;if(ir(U)&&n(U.value))return K;Br(U)&&U.isUnary()&&U.op==="-"&&(U=U.args[0],M=new g("-","subtract",[K,U]))}if(M.op==="-")return Br(U)&&U.isUnary()&&U.op==="-"?D(new g("+","add",[K,U.args[0]]),B):ir(K)&&n(K.value)?D(new g("-","unaryMinus",[U])):ir(U)&&n(U.value)?K:new g(M.op,M.fn,[K,U]);if(M.op==="*"){if(ir(K)){if(n(K.value))return h;if(a(K.value,1))return U}if(ir(U)){if(n(U.value))return h;if(a(U.value,1))return K;if(S(M,I))return new g(M.op,M.fn,[U,K],M.implicit)}return new g(M.op,M.fn,[K,U],M.implicit)}if(M.op==="/")return ir(K)&&n(K.value)?h:ir(U)&&a(U.value,1)?K:new g(M.op,M.fn,[K,U]);if(M.op==="^"&&ir(U)){if(n(U.value))return w;if(a(U.value,1))return K}if(M.op==="and"){if(ir(K))if(K.value){if(E(U))return U}else return b;if(ir(U))if(U.value){if(E(K))return K}else return b}if(M.op==="or"){if(ir(K)){if(K.value)return x;if(E(U))return U}if(ir(U)){if(U.value)return x;if(E(K))return K}}return new g(M.op,M.fn,[K,U])}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 d(M.dimensions.map(re=>D(re,B)));if(fi(M)){var j={};for(var ae in M.properties)j[ae]=D(M.properties[ae],B);return new p(j)}return M}return e(yd,{Node:D,"Node,Object":D})}),uB="resolve",lB=["typed","parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],cB=q(uB,lB,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 d=l.args.map(function(g){return f(g,u,s)});return new i(l.op,l.fn,d,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)))})}),bd="symbolicEqual",fB=["parse","simplify","typed","OperatorNode"],mB=q(bd,fB,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(bd,{"Node, Node":i,"Node, Node, Object":i})}),xd="derivative",vB=["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],pB=q(xd,vB,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 d=e(xd,{"Node, SymbolNode":v,"Node, SymbolNode, Object":v});e.removeConversion({from:"identifier",to:"SymbolNode",convert:a}),d._simplify=!0,d.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 h(0)},"SymbolNode, Object":function(x,b){return b[x]!==void 0?h(0):h(1)},"ParenthesisNode, Object":function(x,b){return new c(y(x.content,b))},"FunctionAssignmentNode, Object":function(x,b){return b[x]!==void 0?h(0):y(x.expr,b)},"FunctionNode, Object":function(x,b){if(x.args.length!==1&&N(x),b[x]!==void 0)return h(0);var E=x.args[0],A,S=!1,D=!1,T;switch(x.name){case"cbrt":S=!0,T=new s("*","multiply",[h(3),new s("^","pow",[E,new s("/","divide",[h(2),h(3)])])]);break;case"sqrt":case"nthRoot":if(x.args.length===1)S=!0,T=new s("*","multiply",[h(2),new u("sqrt",[E])]);else if(x.args.length===2)return A=new s("/","divide",[h(1),x.args[1]]),b[A]=b[x.args[1]],y(new s("^","pow",[E,A]),b);break;case"log10":A=h(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()]),h(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()]),h(2)]);break;case"asin":S=!0,T=new u("sqrt",[new s("-","subtract",[h(1),new s("^","pow",[E.clone(),h(2)])])]);break;case"acos":S=!0,D=!0,T=new u("sqrt",[new s("-","subtract",[h(1),new s("^","pow",[E.clone(),h(2)])])]);break;case"atan":S=!0,T=new s("+","add",[new s("^","pow",[E.clone(),h(2)]),h(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(),h(2)]),h(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(),h(2)]),h(1)])])]);break;case"acot":S=!0,D=!0,T=new s("+","add",[new s("^","pow",[E.clone(),h(2)]),h(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()]),h(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()]),h(2)]);break;case"asinh":S=!0,T=new u("sqrt",[new s("+","add",[new s("^","pow",[E.clone(),h(2)]),h(1)])]);break;case"acosh":S=!0,T=new u("sqrt",[new s("-","subtract",[new s("^","pow",[E.clone(),h(2)]),h(1)])]);break;case"atanh":S=!0,T=new s("-","subtract",[h(1),new s("^","pow",[E.clone(),h(2)])]);break;case"asech":S=!0,D=!0,T=new s("*","multiply",[E.clone(),new u("sqrt",[new s("-","subtract",[h(1),new s("^","pow",[E.clone(),h(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(),h(2)]),h(1)])])]);break;case"acoth":S=!0,D=!0,T=new s("-","subtract",[h(1),new s("^","pow",[E.clone(),h(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 h(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(),h(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(),h(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))?h(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 h(0);if(i(P.value,1))return y(I,b)}var R=new s("^","pow",[I.clone(),new s("-","subtract",[P,h(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]=h(0);throw w.compile().evaluate(),new Error("Expected TypeError, but none found")}}function h(w,x){return new l(f(w,x||t.number))}return d}),wd="rationalize",dB=["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"],hB=q(wd,dB,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:d,bignumber:p,mathWithTransform:g,matrix:y,AccessorNode:N,ArrayNode:h,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},U={exactFractions:!0};if(M=k.expression,Q>=1){M=P(M);var j,ae,re=!0,me=!1;M=v(M,$.firstRules,{},K);for(var he;ae=re?$.distrDivRules:$.sucDivRules,M=v(M,ae,{},U),re=!re,he=M.toString(),he!==j;)me=!0,j=he;me&&(M=v(M,$.firstRulesAgain,{},K)),M=v(M,$.finalRules,{},K)}var fe=[],ie={};return M.type==="OperatorNode"&&M.isBinary()&&M.op==="/"?(Q===1&&(M.args[0]=R(M.args[0],fe),M.args[1]=R(M.args[1])),H&&(ie.numerator=M.args[0],ie.denominator=M.args[1])):(Q===1&&(M=R(M,fe)),H&&(ie.numerator=M,ie.denominator=null)),H?(ie.coefficients=fe,ie.variables=k.variables,ie.expression=M,ie):M}return t(wd,{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 U={};return U.expression=Q,U.variables=k,U;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 me=0;me<ae.args.length;me++)j(ae.args[me])}else if(re==="SymbolNode"){var he=ae.name,fe=k.indexOf(he);fe===-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 U=M.args[0],j=new A("^","pow",[M.args[0].cloneDeep(),new w(K-1)]);M=new A("*","multiply",[U,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,U=$;U>=0;U--)if(F[U]!==0){var j=new w(Q?F[U]:Math.abs(F[U])),ae=F[U]<0?"-":"+";if(U>0){var re=new S(k);if(U>1){var me=new w(U);re=new A("^","pow",[re,me])}F[U]===-1&&Q?j=new A("-","unaryMinus",[re]):Math.abs(F[U])===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(fe,ie,Ae){var Oe=fe.type;if(Oe==="FunctionNode")throw new Error("There is an unsolved function call");if(Oe==="OperatorNode"){if("+-*^".indexOf(fe.op)===-1)throw new Error("Operator "+fe.op+" invalid");if(ie!==null){if((fe.fn==="unaryMinus"||fe.fn==="pow")&&ie.fn!=="add"&&ie.fn!=="subtract"&&ie.fn!=="multiply")throw new Error("Invalid "+fe.op+" placing");if((fe.fn==="subtract"||fe.fn==="add"||fe.fn==="multiply")&&ie.fn!=="add"&&ie.fn!=="subtract")throw new Error("Invalid "+fe.op+" placing");if((fe.fn==="subtract"||fe.fn==="add"||fe.fn==="unaryMinus")&&Ae.noFil!==0)throw new Error("Invalid "+fe.op+" placing")}(fe.op==="^"||fe.op==="*")&&(Ae.fire=fe.op);for(var Ce=0;Ce<fe.args.length;Ce++)fe.fn==="unaryMinus"&&(Ae.oper="-"),(fe.op==="+"||fe.fn==="subtract")&&(Ae.fire="",Ae.cte=1,Ae.oper=Ce===0?"+":fe.op),Ae.noFil=Ce,he(fe.args[Ce],fe,Ae)}else if(Oe==="SymbolNode"){if(fe.name!==k&&k!=="")throw new Error("There is more than one variable");if(k=fe.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(fe.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")}}}),gB="reviver",yB=["classes"],bB=q(gB,yB,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}}),xB="replacer",wB=[],NB=q(xB,wB,()=>function(e,t){return typeof t=="number"&&(!isFinite(t)||isNaN(t))?{mathjs:"number",value:String(t)}:t}),DB="11.8.0",AB=q("true",[],()=>!0),EB=q("false",[],()=>!1),SB=q("null",[],()=>null),CB=at("Infinity",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1/0):1/0}),MB=at("NaN",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(NaN):NaN}),FB=at("pi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?ys(t):uy}),TB=at("tau",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?FD(t):ly}),BB=at("e",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?CD(t):cy}),$B=at("phi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?MD(t):fy}),OB=at("LN2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).ln():Math.LN2}),IB=at("LN10",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(10).ln():Math.LN10}),RB=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}),_B=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}),qB=at("SQRT1_2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t("0.5").sqrt():Math.SQRT1_2}),zB=at("SQRT2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).sqrt():Math.SQRT2}),PB=at("i",["Complex"],r=>{var{Complex:e}=r;return e.I}),LB=q("version",[],()=>DB);function at(r,e,t){return q(r,e,t,{recreateOnConfigChange:!0})}var UB=Xe("speedOfLight","299792458","m s^-1"),kB=Xe("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),VB=Xe("planckConstant","6.62607015e-34","J s"),GB=Xe("reducedPlanckConstant","1.0545718176461565e-34","J s"),HB=Xe("magneticConstant","1.25663706212e-6","N A^-2"),ZB=Xe("electricConstant","8.8541878128e-12","F m^-1"),JB=Xe("vacuumImpedance","376.730313667","ohm"),WB=Xe("coulomb","8.987551792261171e9","N m^2 C^-2"),XB=Xe("elementaryCharge","1.602176634e-19","C"),YB=Xe("bohrMagneton","9.2740100783e-24","J T^-1"),QB=Xe("conductanceQuantum","7.748091729863649e-5","S"),KB=Xe("inverseConductanceQuantum","12906.403729652257","ohm"),jB=Xe("magneticFluxQuantum","2.0678338484619295e-15","Wb"),e$=Xe("nuclearMagneton","5.0507837461e-27","J T^-1"),r$=Xe("klitzing","25812.807459304513","ohm"),t$=Xe("bohrRadius","5.29177210903e-11","m"),n$=Xe("classicalElectronRadius","2.8179403262e-15","m"),a$=Xe("electronMass","9.1093837015e-31","kg"),i$=Xe("fermiCoupling","1.1663787e-5","GeV^-2"),o$=uo("fineStructure",.0072973525693),s$=Xe("hartreeEnergy","4.3597447222071e-18","J"),u$=Xe("protonMass","1.67262192369e-27","kg"),l$=Xe("deuteronMass","3.3435830926e-27","kg"),c$=Xe("neutronMass","1.6749271613e-27","kg"),f$=Xe("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),m$=Xe("rydberg","10973731.568160","m^-1"),v$=Xe("thomsonCrossSection","6.6524587321e-29","m^2"),p$=uo("weakMixingAngle",.2229),d$=uo("efimovFactor",22.7),h$=Xe("atomicMass","1.66053906660e-27","kg"),g$=Xe("avogadro","6.02214076e23","mol^-1"),y$=Xe("boltzmann","1.380649e-23","J K^-1"),b$=Xe("faraday","96485.33212331001","C mol^-1"),x$=Xe("firstRadiation","3.7417718521927573e-16","W m^2"),w$=Xe("loschmidt","2.686780111798444e25","m^-3"),N$=Xe("gasConstant","8.31446261815324","J K^-1 mol^-1"),D$=Xe("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),A$=Xe("molarVolume","0.022413969545014137","m^3 mol^-1"),E$=uo("sackurTetrode",-1.16487052358),S$=Xe("secondRadiation","0.014387768775039337","m K"),C$=Xe("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),M$=Xe("wienDisplacement","2.897771955e-3","m K"),F$=Xe("molarMass","0.99999999965e-3","kg mol^-1"),T$=Xe("molarMassC12","11.9999999958e-3","kg mol^-1"),B$=Xe("gravity","9.80665","m s^-2"),$$=Xe("planckLength","1.616255e-35","m"),O$=Xe("planckMass","2.176435e-8","kg"),I$=Xe("planckTime","5.391245e-44","s"),R$=Xe("planckCharge","1.87554603778e-18","C"),_$=Xe("planckTemperature","1.416785e+32","K");function Xe(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 uo(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 q$="apply",z$=["typed","isInteger"],P$=q(q$,z$,r=>{var{typed:e,isInteger:t}=r,a=yf({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}),L$="column",U$=["typed","Index","matrix","range"],k$=q(L$,U$,r=>{var{typed:e,Index:t,matrix:a,range:n}=r,i=em({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 Fs(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 V$="filter",G$=["typed"],H$=q(V$,G$,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=Fs(n[1],i,o)),a(f,l)}t.rawArgs=!0;var a=e("filter",{"Array, function":Nd,"Matrix, function":function(i,o){return i.create(Nd(i.toArray(),o))},"Array, RegExp":gi,"Matrix, RegExp":function(i,o){return i.create(gi(i.toArray(),o))}});return t},{isTransformFunction:!0});function Nd(r,e){var t=fn(e);return Ml(r,function(a,n,i){return t===1?e(a):t===2?e(a,[n+1]):e(a,[n+1],i)})}var Z$="forEach",J$=["typed"],W$=q(Z$,J$,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=Fs(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}),X$="index",Y$=["Index"],Q$=q(X$,Y$,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}),K$="map",j$=["typed"],e5=q(K$,j$,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=Fs(n[1],i,o)),a(f,l)}t.rawArgs=!0;var a=e("map",{"Array, function":function(i,o){return Dd(i,o,i)},"Matrix, function":function(i,o){return i.create(Dd(i.valueOf(),o,i))}});return t},{isTransformFunction:!0});function Dd(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 r5="max",t5=["typed","config","numeric","larger"],n5=q(r5,t5,r=>{var{typed:e,config:t,numeric:a,larger:n}=r,i=fv({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}),a5="mean",i5=["typed","add","divide"],o5=q(a5,i5,r=>{var{typed:e,add:t,divide:a}=r,n=_p({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}),s5="min",u5=["typed","config","numeric","smaller"],l5=q(s5,u5,r=>{var{typed:e,config:t,numeric:a,smaller:n}=r,i=vv({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}),c5="range",f5=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],m5=q(c5,f5,r=>{var{typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:o,larger:f,largerEq:l}=r,u=hm({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}),v5="row",p5=["typed","Index","matrix","range"],d5=q(v5,p5,r=>{var{typed:e,Index:t,matrix:a,range:n}=r,i=wm({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}),h5="subset",g5=["typed","matrix"],y5=q(h5,g5,r=>{var{typed:e,matrix:t}=r,a=Em({typed:e,matrix:t});return e("subset",{"...any":function(i){try{return a.apply(null,i)}catch(o){throw Kr(o)}}})},{isTransformFunction:!0}),b5="concat",x5=["typed","matrix","isInteger"],w5=q(b5,x5,r=>{var{typed:e,matrix:t,isInteger:a}=r,n=Qf({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}),Ad="diff",N5=["typed","matrix","subtract","number","bignumber"],D5=q(Ad,N5,r=>{var{typed:e,matrix:t,subtract:a,number:n,bignumber:i}=r,o=mm({typed:e,matrix:t,subtract:a,number:n,bignumber:i});return e(Ad,{"...any":function(l){l=On(l);try{return o.apply(null,l)}catch(u){throw Kr(u)}}})},{isTransformFunction:!0}),A5="std",E5=["typed","map","sqrt","variance"],S5=q(A5,E5,r=>{var{typed:e,map:t,sqrt:a,variance:n}=r,i=kp({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}),Ed="sum",C5=["typed","config","add","numeric"],M5=q(Ed,C5,r=>{var{typed:e,config:t,add:a,numeric:n}=r,i=Op({typed:e,config:t,add:a,numeric:n});return e(Ed,{"...any":function(f){f=On(f);try{return i.apply(null,f)}catch(l){throw Kr(l)}}})},{isTransformFunction:!0}),Sd="cumsum",F5=["typed","add","unaryPlus"],T5=q(Sd,F5,r=>{var{typed:e,add:t,unaryPlus:a}=r,n=Ip({typed:e,add:t,unaryPlus:a});return e(Sd,{"...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}),Cd="variance",B5=["typed","add","subtract","multiply","divide","apply","isNaN"],$5=q(Cd,B5,r=>{var{typed:e,add:t,subtract:a,multiply:n,divide:i,apply:o,isNaN:f}=r,l=Lp({typed:e,add:t,subtract:a,multiply:n,divide:i,apply:o,isNaN:f});return e(Cd,{"...any":function(s){s=On(s);try{return l.apply(null,s)}catch(c){throw Kr(c)}}})},{isTransformFunction:!0}),Me=z1({config:ye}),xr=k1({}),Md=BB({BigNumber:Me,config:ye}),O5=EB({}),I5=o$({BigNumber:Me,config:ye}),In=H1({}),Fd=PB({Complex:xr}),R5=CB({BigNumber:Me,config:ye}),_5=IB({BigNumber:Me,config:ye}),q5=_B({BigNumber:Me,config:ye}),lo=Q1({}),z5=MB({BigNumber:Me,config:ye}),P5=SB({}),L5=$B({BigNumber:Me,config:ye}),U5=W1({}),Td=kg({}),k5=qB({BigNumber:Me,config:ye}),V5=E$({BigNumber:Me,config:ye}),Bd=TB({BigNumber:Me,config:ye}),G5=AB({}),H5=LB({}),Qe=ry({Matrix:lo}),Z5=d$({BigNumber:Me,config:ye}),J5=OB({BigNumber:Me,config:ye}),$d=FB({BigNumber:Me,config:ye}),W5=NB({}),X5=zB({BigNumber:Me,config:ye}),J=zg({BigNumber:Me,Complex:xr,DenseMatrix:Qe,Fraction:In}),Ts=mb({BigNumber:Me,config:ye,typed:J}),Y5=p$({BigNumber:Me,config:ye}),rt=pb({typed:J}),Q5=LD({Complex:xr,config:ye,typed:J}),K5=GD({BigNumber:Me,typed:J}),j5=WD({BigNumber:Me,Complex:xr,config:ye,typed:J}),$r=yb({typed:J}),eO=sw({typed:J}),rO=eA({BigNumber:Me,Complex:xr,config:ye,typed:J}),tO=iA({typed:J}),Od=uA({typed:J}),nO=mA({Complex:xr,config:ye,typed:J}),Ot=Zy({BigNumber:Me,typed:J}),aO=jx({typed:J}),iO=Vy({typed:J}),oO=ny({typed:J}),co=vT({typed:J}),fo=Xy({Complex:xr,typed:J}),Rn=lw({typed:J}),sO=hA({typed:J}),uO=xA({BigNumber:Me,typed:J}),lO=NA({BigNumber:Me,typed:J}),cO=Bb({typed:J}),nr=By({config:ye,typed:J}),fO=SN({typed:J}),Id=Ob({typed:J}),mO=Rb({Complex:xr,typed:J}),vO=Tw({typed:J}),pO=Iw({typed:J}),Ya=RN({typed:J}),dO=qw({typed:J}),hO=UN({format:Ya,typed:J}),Bs=fw({typed:J}),ct=iy({typed:J}),va=hy({typed:J}),mo=Ny({typed:J}),Dt=Ay({typed:J}),gO=RB({BigNumber:Me,config:ye}),yO=bT({Complex:xr,typed:J}),bO=mx({Complex:xr,config:ye,typed:J}),Rd=px({Complex:xr,config:ye,typed:J}),pa=Vw({typed:J}),Cr=Dx({typed:J}),_d=dw({typed:J}),pn=Py({typed:J}),xO=PN({format:Ya,typed:J}),wO=qT({config:ye,typed:J}),NO=VN({typed:J}),DO=PT({config:ye,typed:J}),$s=vw({typed:J}),AO=SA({BigNumber:Me,typed:J}),qd=Fx({BigNumber:Me,Fraction:In,complex:fo,typed:J}),Os=TA({typed:J}),Qt=Iy({Matrix:lo,equalScalar:nr,typed:J}),EO=ub({typed:J}),SO=Ix({typed:J}),CO=Uy({typed:J}),MO=IA({typed:J}),zd=My({typed:J}),FO=kD({Complex:xr,config:ye,typed:J}),TO=YD({BigNumber:Me,typed:J}),Is=yf({isInteger:ct,typed:J}),BO=KD({BigNumber:Me,Complex:xr,config:ye,typed:J}),$O=qN({format:Ya,typed:J}),OO=dT({typed:J}),Rs=pA({typed:J}),IO=AA({BigNumber:Me,typed:J}),Qa=Sy({typed:J}),RO=JN({typed:J}),_O=UT({config:ye,typed:J}),qO=MA({BigNumber:Me,typed:J}),zO=$A({typed:J}),PO=_D({SparseMatrix:Qt,typed:J}),It=$x({Complex:xr,config:ye,typed:J}),LO=qA({typed:J}),Rt=cb({typed:J}),UO=ZD({BigNumber:Me,Complex:xr,config:ye,typed:J}),kO=yA({BigNumber:Me,typed:J}),da=Ky({Fraction:In,typed:J}),_n=yy({typed:J}),Te=eb({DenseMatrix:Qe,Matrix:lo,SparseMatrix:Qt,typed:J}),VO=tb({isZero:Dt,matrix:Te,typed:J}),GO=BN({isNaN:Qa,isNumeric:_n,typed:J}),At=YN({bignumber:Ot,fraction:da,number:pn}),Pd=ON({config:ye,multiplyScalar:Cr,numeric:At,typed:J}),HO=Qw({isInteger:ct,matrix:Te,typed:J}),Zr=sN({matrix:Te,config:ye,typed:J}),ZO=lN({matrix:Te,typed:J}),it=Em({matrix:Te,typed:J}),Ka=dN({matrix:Te,typed:J}),Ld=zx({BigNumber:Me,config:ye,matrix:Te,typed:J}),_t=bN({BigNumber:Me,config:ye,matrix:Te,typed:J}),JO=tA({Complex:xr,config:ye,typed:J}),Ud=xb({BigNumber:Me,Complex:xr,Fraction:In,config:ye,isNegative:va,matrix:Te,typed:J,unaryMinus:Rt}),ur=Qf({isInteger:ct,matrix:Te,typed:J}),WO=Dw({prod:Pd,size:Zr,typed:J}),_s=gN({conj:Rn,transpose:Ka,typed:J}),kd=Cw({DenseMatrix:Qe,SparseMatrix:Qt,matrix:Te,typed:J}),Dr=KN({numeric:At,typed:J}),ja=m2({DenseMatrix:Qe,concat:ur,divideScalar:Dr,equalScalar:nr,matrix:Te,typed:J}),Et=L2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),ei=$w({matrix:Te,typed:J}),XO=ax({BigNumber:Me,DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),YO=xy({isNumeric:_n,typed:J}),dn=Pw({BigNumber:Me,DenseMatrix:Qe,SparseMatrix:Qt,config:ye,matrix:Te,typed:J}),QO=Uw({matrix:Te,multiplyScalar:Cr,typed:J}),vo=eD({DenseMatrix:Qe,concat:ur,config:ye,matrix:Te,typed:J}),KO=A2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J,zeros:_t}),qs=ob({flatten:ei,matrix:Te,size:Zr,typed:J}),Vd=xx({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),jO=Cx({BigNumber:Me,concat:ur,equalScalar:nr,matrix:Te,typed:J}),e8=Ww({BigNumber:Me,config:ye,matrix:Te,typed:J}),r8=eN({config:ye,matrix:Te}),t8=S2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J,zeros:_t}),po=t2({BigNumber:Me,DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J,zeros:_t}),ft=H2({DenseMatrix:Qe,concat:ur,config:ye,matrix:Te,typed:J}),n8=HN({concat:ur,matrix:Te,typed:J}),a8=iD({DenseMatrix:Qe,concat:ur,config:ye,equalScalar:nr,matrix:Te,typed:J}),i8=bw({DenseMatrix:Qe,concat:ur,matrix:Te,typed:J}),wr=iE({DenseMatrix:Qe,SparseMatrix:Qt,addScalar:$r,concat:ur,equalScalar:nr,matrix:Te,typed:J}),o8=Qx({concat:ur,equalScalar:nr,matrix:Te,typed:J}),s8=iw({DenseMatrix:Qe,concat:ur,matrix:Te,typed:J}),u8=JT({addScalar:$r,combinations:co,divideScalar:Dr,isInteger:ct,isNegative:va,multiplyScalar:Cr,typed:J}),ha=$2({BigNumber:Me,DenseMatrix:Qe,Fraction:In,concat:ur,config:ye,equalScalar:nr,matrix:Te,typed:J}),Gd=z2({concat:ur,matrix:Te,typed:J}),l8=Ip({add:wr,typed:J,unaryPlus:Ts}),Hd=nD({equal:Et,typed:J}),ho=fE({addScalar:$r,conj:Rn,multiplyScalar:Cr,size:Zr,typed:J}),c8=V2({compareText:Gd,isZero:Dt,typed:J}),Zd=Ub({DenseMatrix:Qe,config:ye,equalScalar:nr,matrix:Te,round:po,typed:J,zeros:_t}),f8=sE({abs:rt,addScalar:$r,divideScalar:Dr,isPositive:mo,multiplyScalar:Cr,smaller:ft,sqrt:It,typed:J}),Jd=dD({DenseMatrix:Qe,smaller:ft}),Jr=yD({ImmutableDenseMatrix:Jd}),m8=Lx({BigNumber:Me,add:wr,config:ye,equal:Et,isInteger:ct,mod:Vd,smaller:ft,typed:J,xgcd:Ld}),mt=Q2({DenseMatrix:Qe,concat:ur,config:ye,matrix:Te,typed:J}),zs=a2({Complex:xr,config:ye,divideScalar:Dr,typed:J}),v8=ab({flatten:ei,matrix:Te,size:Zr,typed:J}),p8=vv({config:ye,numeric:At,smaller:ft,typed:J}),Nr=Ex({addScalar:$r,dot:ho,equalScalar:nr,matrix:Te,multiplyScalar:Cr,typed:J}),d8=u2({Complex:xr,config:ye,divideScalar:Dr,typed:J}),h8=gw({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),Ps=uD({compare:ha,isNaN:Qa,isNumeric:_n,typed:J}),g8=cT({add:wr,compare:ha,multiply:Nr,partitionSelect:Ps,typed:J}),y8=M2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J,zeros:_t}),Ls=W2({DenseMatrix:Qe,concat:ur,config:ye,matrix:Te,typed:J}),yr=_x({DenseMatrix:Qe,addScalar:$r,concat:ur,equalScalar:nr,matrix:Te,typed:J,unaryMinus:Rt}),b8=pE({add:wr,matrix:Te,typed:J}),Us=h2({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J}),x8=T2({concat:ur,equalScalar:nr,matrix:Te,not:_d,typed:J,zeros:_t}),w8=rw({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),ks=Fb({DenseMatrix:Qe,config:ye,equalScalar:nr,matrix:Te,round:po,typed:J,zeros:_t}),qt=R2({compare:ha,typed:J}),N8=XT({addScalar:$r,combinations:co,isInteger:ct,isNegative:va,isPositive:mo,larger:mt,typed:J}),D8=Ew({matrix:Te,multiply:Nr,subtract:yr,typed:J}),Wd=S4({divideScalar:Dr,isZero:Dt,matrix:Te,multiply:Nr,subtract:yr,typed:J,unaryMinus:Rt}),A8=mm({matrix:Te,number:pn,subtract:yr,typed:J}),E8=Y4({abs:rt,addScalar:$r,divideScalar:Dr,multiplyScalar:Cr,sqrt:It,subtract:yr,typed:J,unaryMinus:Rt}),S8=Gx({concat:ur,equalScalar:nr,matrix:Te,multiplyScalar:Cr,typed:J}),Xd=wD({larger:mt,smaller:ft}),Yd=zb({Complex:xr,DenseMatrix:Qe,ceil:ks,equalScalar:nr,floor:Zd,matrix:Te,typed:J,zeros:_t}),Qd=hE({Index:Jr,typed:J}),C8=j4({abs:rt,add:wr,addScalar:$r,config:ye,divideScalar:Dr,equalScalar:nr,flatten:ei,isNumeric:_n,isZero:Dt,matrix:Te,multiply:Nr,multiplyScalar:Cr,smaller:ft,subtract:yr,typed:J}),M8=cx({concat:ur,equalScalar:nr,matrix:Te,typed:J}),F8=o2({Complex:xr,config:ye,divideScalar:Dr,log:zs,typed:J}),Kd=p2({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J}),jd=fv({config:ye,larger:mt,numeric:At,typed:J}),Vs=bS({addScalar:$r,complex:fo,conj:Rn,divideScalar:Dr,equal:Et,identity:dn,isZero:Dt,matrix:Te,multiplyScalar:Cr,sign:qd,sqrt:It,subtract:yr,typed:J,unaryMinus:Rt,zeros:_t}),ga=hm({bignumber:Ot,matrix:Te,config:ye,larger:mt,largerEq:vo,smaller:ft,smallerEq:Ls,typed:J}),T8=wm({Index:Jr,matrix:Te,range:ga,typed:J}),B8=PA({DenseMatrix:Qe,Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),$8=VA({DenseMatrix:Qe,Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),O8=JA({Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),I8=QA({Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),eh=VS({SparseMatrix:Qt,abs:rt,add:wr,divideScalar:Dr,larger:mt,largerEq:vo,multiply:Nr,subtract:yr,transpose:Ka,typed:J}),rh=AD({FibonacciHeap:Xd,addScalar:$r,equalScalar:nr}),th=Op({add:wr,config:ye,numeric:At,typed:J}),nh=x2({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J}),R8=cA({BigNumber:Me,DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),ah=em({Index:Jr,matrix:Te,range:ga,typed:J}),_8=y2({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J}),ih=UA({DenseMatrix:Qe,Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),q8=XA({Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),oh=rE({Index:Jr,concat:ur,setDifference:ih,size:Zr,subset:it,typed:J}),z8=cD({compare:ha,compareNatural:qt,matrix:Te,typed:J}),qn=M4({abs:rt,addScalar:$r,det:Wd,divideScalar:Dr,identity:dn,matrix:Te,multiply:Nr,typed:J,unaryMinus:Rt}),sh=gS({DenseMatrix:Qe,Spa:rh,SparseMatrix:Qt,abs:rt,addScalar:$r,divideScalar:Dr,equalScalar:nr,larger:mt,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J,unaryMinus:Rt}),P8=T4({Complex:xr,add:wr,ctranspose:_s,deepEqual:Hd,divideScalar:Dr,dot:ho,dotDivide:ja,equal:Et,inv:qn,matrix:Te,multiply:Nr,typed:J}),zt=e2({Complex:xr,config:ye,fraction:da,identity:dn,inv:qn,matrix:Te,multiply:Nr,number:pn,typed:J}),uh=HA({DenseMatrix:Qe,Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),L8=nE({Index:Jr,concat:ur,setIntersect:uh,setSymDifference:oh,size:Zr,subset:it,typed:J}),U8=P4({abs:rt,add:wr,identity:dn,inv:qn,map:pa,max:jd,multiply:Nr,size:Zr,sqrt:It,subtract:yr,typed:J}),Ze=$D({BigNumber:Me,Complex:xr,Fraction:In,abs:rt,addScalar:$r,config:ye,divideScalar:Dr,equal:Et,fix:Yd,format:Ya,isNumeric:_n,multiplyScalar:Cr,number:pn,pow:zt,round:po,subtract:yr}),k8=JB({BigNumber:Me,Unit:Ze,config:ye}),V8=M$({BigNumber:Me,Unit:Ze,config:ye}),G8=h$({BigNumber:Me,Unit:Ze,config:ye}),H8=YB({BigNumber:Me,Unit:Ze,config:ye}),Z8=y$({BigNumber:Me,Unit:Ze,config:ye}),J8=QB({BigNumber:Me,Unit:Ze,config:ye}),W8=zD({Unit:Ze,typed:J}),X8=l$({BigNumber:Me,Unit:Ze,config:ye}),Y8=c2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,pow:zt,typed:J}),Q8=ZB({BigNumber:Me,Unit:Ze,config:ye}),K8=XB({BigNumber:Me,Unit:Ze,config:ye}),j8=q4({abs:rt,add:wr,identity:dn,inv:qn,multiply:Nr,typed:J}),e6=b$({BigNumber:Me,Unit:Ze,config:ye}),lh=wN({addScalar:$r,ceil:ks,conj:Rn,divideScalar:Dr,dotDivide:ja,exp:Id,i:Fd,log2:Rd,matrix:Te,multiplyScalar:Cr,pow:zt,tau:Bd,typed:J}),ch=gT({BigNumber:Me,Complex:xr,config:ye,multiplyScalar:Cr,pow:zt,typed:J}),r6=kB({BigNumber:Me,Unit:Ze,config:ye}),t6=s$({BigNumber:Me,Unit:Ze,config:ye}),n6=DN({conj:Rn,dotDivide:ja,fft:lh,typed:J}),a6=r$({BigNumber:Me,Unit:Ze,config:ye}),i6=w$({BigNumber:Me,Unit:Ze,config:ye}),o6=HB({BigNumber:Me,Unit:Ze,config:ye}),s6=F$({BigNumber:Me,Unit:Ze,config:ye}),u6=D$({BigNumber:Me,Unit:Ze,config:ye}),l6=c$({BigNumber:Me,Unit:Ze,config:ye}),c6=e$({BigNumber:Me,Unit:Ze,config:ye}),f6=R$({BigNumber:Me,Unit:Ze,config:ye}),m6=$$({BigNumber:Me,Unit:Ze,config:ye}),v6=_$({BigNumber:Me,Unit:Ze,config:ye}),p6=u$({BigNumber:Me,Unit:Ze,config:ye}),d6=GB({BigNumber:Me,Unit:Ze,config:ye}),h6=m$({BigNumber:Me,Unit:Ze,config:ye}),g6=S$({BigNumber:Me,Unit:Ze,config:ye}),y6=UB({BigNumber:Me,Unit:Ze,config:ye}),b6=C$({BigNumber:Me,Unit:Ze,config:ye}),x6=v$({BigNumber:Me,Unit:Ze,config:ye}),w6=g$({BigNumber:Me,Unit:Ze,config:ye}),N6=t$({BigNumber:Me,Unit:Ze,config:ye}),D6=WB({BigNumber:Me,Unit:Ze,config:ye}),vt=W4({divideScalar:Dr,equalScalar:nr,inv:qn,matrix:Te,multiply:Nr,typed:J}),A6=a$({BigNumber:Me,Unit:Ze,config:ye}),go=wT({gamma:ch,typed:J}),E6=x$({BigNumber:Me,Unit:Ze,config:ye}),S6=N$({BigNumber:Me,Unit:Ze,config:ye}),C6=KB({BigNumber:Me,Unit:Ze,config:ye}),fh=HS({DenseMatrix:Qe,lsolve:Kd,lup:sh,matrix:Te,slu:eh,typed:J,usolve:Us}),M6=jB({BigNumber:Me,Unit:Ze,config:ye}),F6=T$({BigNumber:Me,Unit:Ze,config:ye}),T6=ET({add:wr,divide:vt,factorial:go,isInteger:ct,isPositive:mo,multiply:Nr,typed:J}),B6=CT({factorial:go,typed:J}),$6=O$({BigNumber:Me,Unit:Ze,config:ye}),O6=JS({add:wr,cbrt:Ud,divide:vt,equalScalar:nr,im:Bs,isZero:Dt,multiply:Nr,re:$s,sqrt:It,subtract:yr,typeOf:zd,typed:J,unaryMinus:Rt}),I6=jA({compareNatural:qt,typed:J}),mh=VT({bignumber:Ot,addScalar:$r,combinations:co,divideScalar:Dr,factorial:go,isInteger:ct,isNegative:va,larger:mt,multiplyScalar:Cr,number:pn,pow:zt,subtract:yr,typed:J}),R6=ID({Unit:Ze,typed:J}),_6=HT({addScalar:$r,isInteger:ct,isNegative:va,stirlingS2:mh,typed:J}),vh=R4({abs:rt,add:wr,addScalar:$r,atan:Od,bignumber:Ot,column:ah,complex:fo,config:ye,cos:Rs,diag:kd,divideScalar:Dr,dot:ho,equal:Et,flatten:ei,im:Bs,inv:qn,larger:mt,matrix:Te,matrixFromColumns:qs,multiply:Nr,multiplyScalar:Cr,number:pn,qr:Vs,re:$s,sin:Os,smaller:ft,sqrt:It,subtract:yr,typed:J,usolve:Us,usolveAll:nh}),q6=i$({BigNumber:Me,Unit:Ze,config:ye}),z6=B$({BigNumber:Me,Unit:Ze,config:ye}),P6=DT({divide:vt,dotDivide:ja,isNumeric:_n,log:zs,map:pa,matrix:Te,multiply:Nr,sum:th,typed:J}),L6=_p({add:wr,divide:vt,typed:J}),U6=A$({BigNumber:Me,Unit:Ze,config:ye}),k6=VB({BigNumber:Me,Unit:Ze,config:ye}),V6=f$({BigNumber:Me,Unit:Ze,config:ye}),Gs=Lp({add:wr,apply:Is,divide:vt,isNaN:Qa,multiply:Nr,subtract:yr,typed:J}),G6=n$({BigNumber:Me,Unit:Ze,config:ye}),ph=aT({add:wr,compare:ha,divide:vt,partitionSelect:Ps,typed:J}),H6=I$({BigNumber:Me,Unit:Ze,config:ye}),Z6=kp({map:pa,sqrt:It,typed:J,variance:Gs}),J6=oT({abs:rt,map:pa,median:ph,subtract:yr,typed:J}),Hs=lE({abs:rt,add:wr,conj:Rn,ctranspose:_s,eigs:vh,equalScalar:nr,larger:mt,matrix:Te,multiply:Nr,pow:zt,smaller:ft,sqrt:It,typed:J}),dh=aN({BigNumber:Me,DenseMatrix:Qe,SparseMatrix:Qt,addScalar:$r,config:ye,cos:Rs,matrix:Te,multiplyScalar:Cr,norm:Hs,sin:Os,typed:J,unaryMinus:Rt}),W6=tN({multiply:Nr,rotationMatrix:dh,typed:J}),hh=V4({identity:dn,matrix:Te,multiply:Nr,norm:Hs,qr:Vs,subtract:yr,typed:J}),gh=U4({abs:rt,add:wr,concat:ur,identity:dn,index:Qd,lusolve:fh,matrix:Te,matrixFromColumns:qs,multiply:Nr,range:ga,schur:hh,subset:it,subtract:yr,transpose:Ka,typed:J}),X6=H4({matrix:Te,multiply:Nr,sylvester:gh,transpose:Ka,typed:J}),ya={},ba={},yh={},Wr=bE({mathWithTransform:ba}),xa=HE({Node:Wr}),Kt=JE({Node:Wr}),zn=XE({Node:Wr}),bh=jE({Node:Wr}),wa=DE({Node:Wr}),xh=FE({Node:Wr,ResultSet:Td}),wh=BE({Node:Wr}),hn=PE({Node:Wr}),Nh=QE({Node:Wr}),Y6=bB({classes:yh}),Zs=jS({math:ya,typed:J}),Dh=UE({Node:Wr,typed:J}),Q6=A4({Chain:Zs,typed:J}),Na=wE({Node:Wr,subset:it}),Da=VE({Node:Wr,size:Zr}),Ah=CE({matrix:Te,Node:Wr,subset:it}),gn=tS({Unit:Ze,Node:Wr,math:ya}),yn=aS({Node:Wr,SymbolNode:gn,math:ya}),St=oS({AccessorNode:Na,ArrayNode:wa,AssignmentNode:Ah,BlockNode:xh,ConditionalNode:wh,ConstantNode:hn,FunctionAssignmentNode:Dh,FunctionNode:yn,IndexNode:Da,ObjectNode:xa,OperatorNode:Kt,ParenthesisNode:zn,RangeNode:Nh,RelationalNode:bh,SymbolNode:gn,config:ye,numeric:At,typed:J}),Eh=cB({ConstantNode:hn,FunctionNode:yn,OperatorNode:Kt,ParenthesisNode:zn,parse:St,typed:J}),Js=iB({bignumber:Ot,fraction:da,AccessorNode:Na,ArrayNode:wa,ConstantNode:hn,FunctionNode:yn,IndexNode:Da,ObjectNode:xa,OperatorNode:Kt,SymbolNode:gn,config:ye,mathWithTransform:ba,matrix:Te,typed:J}),K6=uS({parse:St,typed:J}),Ws=cS({parse:St,typed:J}),Sh=YS({parse:St}),Ch=vS({evaluate:Ws}),Xs=sB({AccessorNode:Na,ArrayNode:wa,ConstantNode:hn,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}),j6=N4({Help:Sh,mathWithTransform:ba,typed:J}),yo=tB({bignumber:Ot,fraction:da,AccessorNode:Na,ArrayNode:wa,ConstantNode:hn,FunctionNode:yn,IndexNode:Da,ObjectNode:xa,OperatorNode:Kt,ParenthesisNode:zn,SymbolNode:gn,add:wr,config:ye,divide:vt,equal:Et,isZero:Dt,mathWithTransform:ba,matrix:Te,multiply:Nr,parse:St,pow:zt,resolve:Eh,simplifyConstant:Js,simplifyCore:Xs,subtract:yr,typed:J}),e7=mB({OperatorNode:Kt,parse:St,simplify:yo,typed:J}),r7=pB({ConstantNode:hn,FunctionNode:yn,OperatorNode:Kt,ParenthesisNode:zn,SymbolNode:gn,config:ye,equal:Et,isZero:Dt,numeric:At,parse:St,simplify:yo,typed:J}),t7=dS({Parser:Ch,typed:J}),n7=QT({parse:St,typed:J}),a7=hB({bignumber:Ot,fraction:da,AccessorNode:Na,ArrayNode:wa,ConstantNode:hn,FunctionNode:yn,IndexNode:Da,ObjectNode:xa,OperatorNode:Kt,ParenthesisNode:zn,SymbolNode:gn,add:wr,config:ye,divide:vt,equal:Et,isZero:Dt,mathWithTransform:ba,matrix:Te,multiply:Nr,parse:St,pow:zt,simplify:yo,simplifyConstant:Js,simplifyCore:Xs,subtract:yr,typed:J});Sr(ya,{e:Md,false:O5,fineStructure:I5,i:Fd,Infinity:R5,LN10:_5,LOG10E:q5,NaN:z5,null:P5,phi:L5,SQRT1_2:k5,sackurTetrode:V5,tau:Bd,true:G5,E:Md,version:H5,efimovFactor:Z5,LN2:J5,pi:$d,replacer:W5,reviver:Y6,SQRT2:X5,typed:J,unaryPlus:Ts,PI:$d,weakMixingAngle:Y5,abs:rt,acos:Q5,acot:K5,acsc:j5,addScalar:$r,arg:eO,asech:rO,asinh:tO,atan:Od,atanh:nO,bignumber:Ot,bitNot:aO,boolean:iO,clone:oO,combinations:co,complex:fo,conj:Rn,cosh:sO,coth:uO,csc:lO,cube:cO,equalScalar:nr,erf:fO,exp:Id,expm1:mO,filter:vO,forEach:pO,format:Ya,getMatrixDataType:dO,hex:hO,im:Bs,isInteger:ct,isNegative:va,isPositive:mo,isZero:Dt,LOG2E:gO,lgamma:yO,log10:bO,log2:Rd,map:pa,multiplyScalar:Cr,not:_d,number:pn,oct:xO,pickRandom:wO,print:NO,random:DO,re:$s,sec:AO,sign:qd,sin:Os,splitUnit:EO,square:SO,string:CO,tan:MO,typeOf:zd,acosh:FO,acsch:TO,apply:Is,asec:BO,bin:$O,chain:Q6,combinationsWithRep:OO,cos:Rs,csch:IO,isNaN:Qa,isPrime:RO,randomInt:_O,sech:qO,sinh:zO,sparse:PO,sqrt:It,tanh:LO,unaryMinus:Rt,acoth:UO,cot:kO,fraction:da,isNumeric:_n,matrix:Te,matrixFromFunction:VO,mode:GO,numeric:At,prod:Pd,reshape:HO,size:Zr,squeeze:ZO,subset:it,transpose:Ka,xgcd:Ld,zeros:_t,asin:JO,cbrt:Ud,concat:ur,count:WO,ctranspose:_s,diag:kd,divideScalar:Dr,dotDivide:ja,equal:Et,flatten:ei,gcd:XO,hasNumericValue:YO,identity:dn,kron:QO,largerEq:vo,leftShift:KO,matrixFromColumns:qs,mod:Vd,nthRoot:jO,ones:e8,resize:r8,rightArithShift:t8,round:po,smaller:ft,to:n8,unequal:a8,xor:i8,add:wr,bitAnd:o8,bitXor:s8,catalan:u8,compare:ha,compareText:Gd,cumsum:l8,deepEqual:Hd,dot:ho,equalText:c8,floor:Zd,hypot:f8,invmod:m8,larger:mt,log:zs,matrixFromRows:v8,min:p8,multiply:Nr,nthRoots:d8,or:h8,partitionSelect:Ps,quantileSeq:g8,rightLogShift:y8,smallerEq:Ls,subtract:yr,trace:b8,usolve:Us,and:x8,bitOr:w8,ceil:ks,compareNatural:qt,composition:N8,cross:D8,det:Wd,diff:A8,distance:E8,dotMultiply:S8,fix:Yd,index:Qd,intersect:C8,lcm:M8,log1p:F8,lsolve:Kd,max:jd,qr:Vs,range:ga,row:T8,setCartesian:B8,setDistinct:$8,setIsSubset:O8,setPowerset:I8,slu:eh,sum:th,usolveAll:nh,atan2:R8,column:ah,lsolveAll:_8,setDifference:ih,setMultiplicity:q8,setSymDifference:oh,sort:z8,inv:qn,lup:sh,pinv:P8,pow:zt,setIntersect:uh,setUnion:L8,sqrtm:U8,vacuumImpedance:k8,wienDisplacement:V8,atomicMass:G8,bohrMagneton:H8,boltzmann:Z8,conductanceQuantum:J8,createUnit:W8,deuteronMass:X8,dotPow:Y8,electricConstant:Q8,elementaryCharge:K8,expm:j8,faraday:e6,fft:lh,gamma:ch,gravitationConstant:r6,hartreeEnergy:t6,ifft:n6,klitzing:a6,loschmidt:i6,magneticConstant:o6,molarMass:s6,molarPlanckConstant:u6,neutronMass:l6,nuclearMagneton:c6,planckCharge:f6,planckLength:m6,planckTemperature:v6,protonMass:p6,reducedPlanckConstant:d6,rydberg:h6,secondRadiation:g6,speedOfLight:y6,stefanBoltzmann:b6,thomsonCrossSection:x6,avogadro:w6,bohrRadius:N6,coulomb:D6,divide:vt,electronMass:A6,factorial:go,firstRadiation:E6,gasConstant:S6,inverseConductanceQuantum:C6,lusolve:fh,magneticFluxQuantum:M6,molarMassC12:F6,multinomial:T6,permutations:B6,planckMass:$6,polynomialRoot:O6,setSize:I6,stirlingS2:mh,unit:R6,bellNumbers:_6,eigs:vh,fermiCoupling:q6,gravity:z6,kldivergence:P6,mean:L6,molarVolume:U6,planckConstant:k6,quantumOfCirculation:V6,variance:Gs,classicalElectronRadius:G6,median:ph,parse:St,planckTime:H6,resolve:Eh,simplifyConstant:Js,std:Z6,compile:K6,evaluate:Ws,mad:J6,simplifyCore:Xs,help:j6,norm:Hs,rotationMatrix:dh,simplify:yo,symbolicEqual:e7,derivative:r7,parser:t7,rotate:W6,leafCount:n7,rationalize:a7,schur:hh,sylvester:gh,lyap:X6,config:ye}),Sr(ba,ya,{filter:H$({typed:J}),forEach:W$({typed:J}),map:e5({typed:J}),apply:P$({isInteger:ct,typed:J}),subset:y5({matrix:Te,typed:J}),concat:w5({isInteger:ct,matrix:Te,typed:J}),max:n5({config:ye,larger:mt,numeric:At,typed:J}),sum:M5({add:wr,config:ye,numeric:At,typed:J}),min:l5({config:ye,numeric:At,smaller:ft,typed:J}),cumsum:T5({add:wr,typed:J,unaryPlus:Ts}),diff:D5({bignumber:Ot,matrix:Te,number:pn,subtract:yr,typed:J}),index:Q$({Index:Jr}),range:m5({bignumber:Ot,matrix:Te,config:ye,larger:mt,largerEq:vo,smaller:ft,smallerEq:Ls,typed:J}),row:d5({Index:Jr,matrix:Te,range:ga,typed:J}),column:k$({Index:Jr,matrix:Te,range:ga,typed:J}),mean:o5({add:wr,divide:vt,typed:J}),variance:$5({add:wr,apply:Is,divide:vt,isNaN:Qa,multiply:Nr,subtract:yr,typed:J}),std:S5({map:pa,sqrt:It,typed:J,variance:Gs})}),Sr(yh,{BigNumber:Me,Complex:xr,Fraction:In,Matrix:lo,Node:Wr,ObjectNode:xa,OperatorNode:Kt,ParenthesisNode:zn,Range:U5,RelationalNode:bh,ResultSet:Td,ArrayNode:wa,BlockNode:xh,ConditionalNode:wh,ConstantNode:hn,DenseMatrix:Qe,RangeNode:Nh,Chain:Zs,FunctionAssignmentNode:Dh,SparseMatrix:Qt,AccessorNode:Na,IndexNode:Da,AssignmentNode:Ah,ImmutableDenseMatrix:Jd,Index:Jr,FibonacciHeap:Xd,Spa:rh,Unit:Ze,SymbolNode:gn,FunctionNode:yn,Help:Sh,Parser:Ch}),Zs.createProxy(ya);/**
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
- *
74
- * @version 5.5.0
75
- * @license MIT
76
- * @author GreenImp Media <info@greenimp.co.uk> (https://greenimp.co.uk)
77
- * @link https://dice-roller.github.io/documentation
78
- */class Ys extends TypeError{constructor(e){super(`Operator "${e}" is invalid`),TypeError.captureStackTrace&&TypeError.captureStackTrace(this,Ys),this.name="CompareOperatorError",this.operator=e}}class Qs extends Error{constructor(e){super(`Invalid data format: ${e}`),Error.captureStackTrace&&Error.captureStackTrace(this,Qs),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 bo extends Error{constructor(e){super(`Notation "${e}" is invalid`),Error.captureStackTrace&&Error.captureStackTrace(this,bo),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 i7=(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},Mh=r=>Ws(r),Mr=r=>typeof r!="number"&&typeof r!="string"?!1:!Number.isNaN(r)&&Number.isFinite(Number(r)),Ks=r=>{if(!Mr(r))return!1;const e=Number(r);return e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER},o7=r=>Array.isArray(r)?r.reduce((e,t)=>e+(Mr(t)?parseFloat(`${t}`):0),0):0,s7=(r,e=0)=>parseFloat(parseFloat(`${r}`).toFixed(e||0)),Rr=9007199254740992,ti=Rr-1,xo=-1>>>0,pt=xo+1,jt=pt/2,js=jt-1,ni=1<<21,Pn=ni-1;function eu(r){return r.next()|0}function bn(r,e){return e===0?r:t=>r(t)+e}function ru(r){const e=r.next()|0,t=r.next()>>>0;return(e&Pn)*pt+t+(e&ni?-Rr:0)}function Fh(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 Th(r){return r.next()>>>0}function wo(r){const e=r.next()&Pn,t=r.next()>>>0;return e*pt+t}function tu(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 Bh(r){return(r+1&r)===0}function u7(r){return e=>e.next()&r}function l7(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 c7(r){return Bh(r)?u7(r):l7(r)}function f7(r){return(r|0)===0}function m7(r){return e=>{const t=e.next()&r,a=e.next()>>>0;return t*pt+a}}function v7(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 p7(r){const e=r+1;if(f7(e)){const t=(e/pt|0)-1;if(Bh(t))return m7(t)}return v7(e)}function $h(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 Ln(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===xo?r===0?Th:bn(eu,r+jt):t<xo?bn(c7(t),r):t===ti?bn(wo,r):t<ti?bn(p7(t),r):e-1-r===ti?bn(tu,r):r===-Rr&&e===Rr?Fh:r===-Rr&&e===ti?ru:r===-ti&&e===Rr?bn(ru,1):e===Rr?bn($h(r-1,e-1),1):$h(r,e)}function d7(r){return(r.next()&1)===1}function nu(r,e){return t=>r(t)<e}function h7(r){if(r<=0)return()=>!1;if(r>=1)return()=>!0;{const e=r*pt;return e%1===0?nu(eu,e-jt|0):nu(wo,Math.round(r*Rr))}}function g7(r,e){return e==null?r==null?d7:h7(r):r<=0?()=>!1:r>=e?()=>!0:nu(Ln(0,e-1),r)}function y7(r,e){const t=Ln(+r,+e);return a=>new Date(t(a))}function Oh(r){return Ln(1,r)}function b7(r,e){const t=Oh(r);return a=>{const n=[];for(let i=0;i<e;++i)n.push(t(a));return n}}const x7="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-";function au(r=x7){const e=r.length;if(!e)throw new Error("Expected pool not to be an empty string");const t=Ln(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 Ih="0123456789abcdef",w7=au(Ih),N7=au(Ih.toUpperCase());function D7(r){return r?N7:w7}function Rh(r,e){return r<0?Math.max(r+e,0):Math.min(r,e)}function _h(r){const e=+r;return e<0?Math.ceil(e):Math.floor(e)}function A7(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:Rh(_h(t),n),o=a===void 0?n:Rh(_h(a),n);if(i>=o)throw new RangeError(`Cannot pick between bounds ${i} and ${o}`);const f=Ln(i,o-1);return e[f(r)]}function E7(r,e){return e===1?r:e===0?()=>0:t=>r(t)*e}function qh(r){return wo(r)/Rr}function zh(r){return tu(r)/Rr}function S7(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(E7(t?zh:qh,e-r),r)}const C7=Array.prototype.slice;function iu(r,e,t=0){const a=e.length;if(a)for(let n=a-1>>>0;n>t;--n){const o=Ln(0,n)(r);if(n!==o){const f=e[n];e[n]=e[o],e[o]=f}}return e}function M7(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=C7.call(e),n=a.length;if(n===t)return iu(r,a,0);const i=n-t;return iu(r,a,i-1).slice(i)}const F7=(()=>{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 F7("0",e-r.length)+r}function T7(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 B7{constructor(e=Ea){this.engine=e}int32(){return eu(this.engine)}uint32(){return Th(this.engine)}uint53(){return wo(this.engine)}uint53Full(){return tu(this.engine)}int53(){return ru(this.engine)}int53Full(){return Fh(this.engine)}integer(e,t){return Ln(e,t)(this.engine)}realZeroToOneInclusive(){return zh(this.engine)}realZeroToOneExclusive(){return qh(this.engine)}real(e,t,a=!1){return S7(e,t,a)(this.engine)}bool(e,t){return g7(e,t)(this.engine)}pick(e,t,a){return A7(this.engine,e,t,a)}shuffle(e){return iu(this.engine,e)}sample(e,t){return M7(this.engine,e,t)}die(e){return Oh(e)(this.engine)}dice(e,t){return b7(e,t)(this.engine)}uuid4(){return T7(this.engine)}string(e,t){return au(t)(this.engine,e)}hex(e,t){return D7(t)(this.engine,e)}date(e,t){return y7(e,t)(this.engine)}}const Ph=(()=>{try{const r=new ArrayBuffer(4),e=new Int32Array(r);if(e[0]=jt,e[0]===-jt)return Int32Array}catch{}return Array})();let No=null;const ou=128;let su=ou;const $7={next(){return su>=ou&&(No===null&&(No=new Ph(ou)),crypto.getRandomValues(No),su=0),No[su++]|0}};function O7(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 uu=(()=>{try{if(Math.imul(xo,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}})(),Lt=624,xn=Lt-1,lu=397,Lh=Lt-lu,cu=2567483615;class ai{constructor(){this.data=new Ph(Lt),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(O7())}next(){(this.index|0)>=Lt&&(fu(this.data),this.index=0);const e=this.data[this.index];return this.index=this.index+1|0,this.uses+=1,I7(e)|0}getUseCount(){return this.uses}discard(e){if(e<=0)return this;for(this.uses+=e,(this.index|0)>=Lt&&(fu(this.data),this.index=0);e+this.index>Lt;)e-=Lt-this.index,fu(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<Lt;a=a+1|0)this.data[a]=t=uu(t^t>>>30,1812433253)+a|0;return this.index=Lt,this.uses=0,this}seedWithArray(e){return this.seed(19650218),R7(this.data,e),this}}function fu(r){let e=0,t=0;for(;(e|0)<Lh;e=e+1|0)t=r[e]&jt|r[e+1|0]&js,r[e]=r[e+lu|0]^t>>>1^(t&1?cu:0);for(;(e|0)<xn;e=e+1|0)t=r[e]&jt|r[e+1|0]&js,r[e]=r[e-Lh|0]^t>>>1^(t&1?cu:0);t=r[xn]&jt|r[0]&js,r[xn]=r[lu-1]^t>>>1^(t&1?cu:0)}function I7(r){return r^=r>>>11,r^=r<<7&2636928640,r^=r<<15&4022730752,r^r>>>18}function R7(r,e){let t=1,a=0;const n=e.length;let i=Math.max(n,Lt)|0,o=r[0]|0;for(;(i|0)>0;--i)r[t]=o=(r[t]^uu(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]^uu(o^o>>>30,1566083941))-t|0,t=t+1|0,(t|0)>xn&&(r[0]=r[xn],t=1);r[0]=jt}let Uh=null;const mu=128;let vu=mu;const _7={next(){return vu>=mu&&(Uh=new Int32Array(new Int8Array(require("crypto").randomBytes(4*mu)).buffer),vu=0),Uh[vu++]|0}},ii=Symbol("engine"),pu=Symbol("random"),kh={browserCrypto:$7,nodeCrypto:_7,MersenneTwister19937:ai,nativeMath:Ea,min:{next(){return 0}},max:{range:[],next(){return this.range[1]-this.range[0]}}};class q7{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[pu]=new B7(this[ii])}integer(e,t){return this[ii].range=[e,t],this[pu].integer(e,t)}real(e,t,a=!1){return this[ii].range=[e,t],this[pu].real(e,t,a)}}const Sa=new q7,Vh=Symbol("text"),Gh=Symbol("type");class Ct{constructor(e,t=this.constructor.types.INLINE){this.text=e,this.type=t}get text(){return this[Vh]}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[Vh]=`${e}`.trim()}get type(){return this[Gh]}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[Gh]=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 Do=Symbol("description");class Hh{constructor(e=null){this.description=e}get description(){return this[Do]||null}set description(e){if(!e&&e!==0)this[Do]=null;else if(e instanceof Ct)this[Do]=e;else if(typeof e=="string")this[Do]=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 z7={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"},Zh=(...r)=>[...r].reduce((e,t)=>{let a;return t instanceof en?a=t.name:a=t,e+(z7[a]||a)},""),du=Symbol("calculation-value"),hu=Symbol("modifiers"),oi=Symbol("initial-value"),Jh=Symbol("use-in-total"),gu=Symbol("value");class Ao{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[du])?parseFloat(this[du]):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[du]=t?parseFloat(`${e}`):null}get initialValue(){return this[oi]}get modifierFlags(){return Zh(...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[Jh]}set useInTotal(e){this[Jh]=!!e}get value(){return Mr(this[gu])?this[gu]: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[gu]=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 yu=Symbol("rolls");class rn{constructor(e=[]){this.rolls=e}get length(){return this.rolls.length||0}get rolls(){return[...this[yu]]}set rolls(e){if(!e||!Array.isArray(e))throw new TypeError(`rolls must be an array: ${e}`);this[yu]=[],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 Ao?e:new Ao(e);this[yu].push(t)}toJSON(){const{rolls:e,value:t}=this;return{rolls:e,type:"roll-results",value:t}}toString(){return`[${this.rolls.join(", ")}]`}}const bu=Symbol("modifiers"),Wh=Symbol("qty"),Xh=Symbol("sides"),Yh=Symbol("min-value"),Qh=Symbol("max-value");class Ca extends Hh{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||!Ks(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(!Ks(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&&!Ks(i))throw new RangeError("max must a finite number");this[Wh]=parseInt(`${t}`,10),this[Xh]=e,a&&(this.modifiers=a),this[Yh]=parseInt(f,10),this[Qh]=i?parseInt(`${i}`,10):e}get average(){return(this.min+this.max)/2}get modifiers(){return this[bu]?new Map([...this[bu]].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[bu]=t}get max(){return this[Qh]}get min(){return this[Yh]}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[Wh]}get sides(){return this[Xh]}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 Ao(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 P7 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 Ao(e)}}class L7 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 Kh=Symbol("operator"),jh=Symbol("value");class Eo{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 Ys(e);this[Kh]=e}get operator(){return this[Kh]}set value(e){if(!Mr(e))throw new TypeError("value must be a finite number");this[jh]=Number(e)}get value(){return this[jh]}isMatch(e){return i7(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 e0=Symbol("compare-point");class Ma extends en{constructor(e){super(),e&&(this.comparePoint=e)}get comparePoint(){return this[e0]}set comparePoint(e){if(!(e instanceof Eo))throw new TypeError("comparePoint must be instance of ComparePoint");this[e0]=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 Eo(...t)}:{}}isComparePoint(e){return this.comparePoint?this.comparePoint.isMatch(e):!1}toJSON(){const{comparePoint:e}=this;return Object.assign(super.toJSON(),{comparePoint:e})}}class r0 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(r0,"order",10);class t0 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(t0,"order",9);const xu=Symbol("calculation-value"),n0=Symbol("is-roll-group"),wu=Symbol("modifiers"),Nu=Symbol("results"),a0=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[xu])?parseFloat(this[xu]):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[xu]=t?parseFloat(`${e}`):null}get isRollGroup(){return this[n0]}set isRollGroup(e){this[n0]=!!e}get length(){return this.results.length||0}get modifierFlags(){return Zh(...this.modifiers)}get modifiers(){return this[wu]}set modifiers(e){if((Array.isArray(e)||e instanceof Set)&&[...e].every(t=>typeof t=="string"))this[wu]=new Set([...e]);else if(!e&&e!==0)this[wu]=new Set;else throw new TypeError(`modifiers must be a Set or array of modifier names: ${e}`)}get results(){return[...this[Nu]]}set results(e){if(!e||!Array.isArray(e))throw new TypeError(`results must be an array: ${e}`);this[Nu]=[],e.forEach(t=>{this.addResult(t)})}get useInTotal(){return!!this[a0]}set useInTotal(e){this[a0]=!!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"?Mh(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[Nu].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 i0=Symbol("end"),o0=Symbol("qty");class Du extends en{constructor(e="h",t=1){super(),this.end=e,this.qty=t}get end(){return this[i0]}set end(e){if(e!=="h"&&e!=="l")throw new RangeError('End must be "h" or "l"');this[i0]=e}get name(){return`keep-${this.end}`}get notation(){return`k${this.end}${this.qty}`}get qty(){return this[o0]}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[o0]=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(Du,"order",6);class s0 extends Du{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(s0,"order",7);const u0=Symbol("compound"),l0=Symbol("penetrate");class c0 extends Ma{constructor(e=null,t=!1,a=!1){super(e),this[u0]=!!t,this[l0]=!!a}get compound(){return this[u0]}get name(){return"explode"}get notation(){return`!${this.compound?"!":""}${this.penetrate?"p":""}${super.notation}`}get penetrate(){return this[l0]}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=o7(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(c0,"order",3);const f0=Symbol("max");class m0 extends en{constructor(e){super(),this.max=e}get max(){return this[f0]}set max(e){if(!Mr(e))throw new TypeError("max must be a number");this[f0]=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(m0,"order",2);const v0=Symbol("min");class p0 extends en{constructor(e){super(),this.min=e}get min(){return this[v0]}set min(e){if(!Mr(e))throw new TypeError("min must be a number");this[v0]=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(p0,"order",1);const d0=Symbol("once");class h0 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[d0]}set once(e){this[d0]=!!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(h0,"order",4);const g0=Symbol("direction");class y0 extends en{constructor(e="a"){super(),this.direction=e}get direction(){return this[g0]}set direction(e){if(e!=="a"&&e!=="d")throw new RangeError('Direction must be "a" (Ascending) or "d" (Descending)');this[g0]=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(y0,"order",11);const b0=Symbol("failure-cp");class x0 extends Ma{constructor(e,t=null){super(e),this.failureComparePoint=t}get failureComparePoint(){return this[b0]}set failureComparePoint(e){if(e&&!(e instanceof Eo))throw new TypeError("failure comparePoint must be instance of ComparePoint or null");this[b0]=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(x0,"order",8);const w0=Symbol("once"),U7=(r,e,t,a=!1)=>{const n=t.map(i=>i.value).indexOf(r.value);return a?n<e:n!==e};class N0 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[w0]}set once(e){this[w0]=!!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))&&U7(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(N0,"order",5);const k7=r=>{try{return!!(r&&btoa(atob(r))===r)}catch{return!1}},V7=r=>{try{const e=r?JSON.parse(r):!1;return!!(e&&typeof e=="object")}catch{return!1}},Au=Symbol("expressions"),Eu=Symbol("modifiers");class D0 extends Hh{constructor(e=[],t=[],a=null){super(a),this.expressions=e,this.modifiers=t}get expressions(){return[...this[Au]||[]]}set expressions(e){if(!e)throw new Pt("expressions");if(!Array.isArray(e))throw new TypeError(`expressions must be an array: ${e}`);this[Au]=[],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[Au].push(t)})}get modifiers(){return this[Eu]?new Map([...this[Eu]].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[Eu]=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 G7(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}G7(Fa,Error);function Su(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=Su("",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+=`
54
+ 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"]},gF={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"]},yF={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"]},bF={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"]},xF={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"]},wF={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"]},NF={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"]},DF={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"]},AF={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"]},EF={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"]},SF={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"]},CF={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"]},MF={name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},FF={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"]},TF={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"]},BF={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"]},OF={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"]},IF={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"]},RF={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"]},qF={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"]},zF={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"]},PF={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"]},LF={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"]},UF={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"]},kF={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"]},VF={name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},GF={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"]},HF={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"]},ZF={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:[]},JF={name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},XF={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:[]},WF={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"]},YF={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"]},QF={name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},KF={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"]},jF={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"]},e4={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"]},r4={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"]},t4={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"]},n4={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"]},a4={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"]},i4={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"]},o4={name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},s4={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"]},u4={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"]},l4={bignumber:aC,boolean:iC,complex:oC,createUnit:sC,fraction:uC,index:lC,matrix:cC,number:fC,sparse:mC,splitUnit:vC,string:pC,unit:dC,e:dp,E:dp,false:VS,i:GS,Infinity:HS,LN2:JS,LN10:ZS,LOG2E:WS,LOG10E:XS,NaN:YS,null:QS,pi:hp,PI:hp,phi:KS,SQRT1_2:jS,SQRT2:eC,tau:rC,true:tC,version:nC,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:bC,lsolve:wC,lsolveAll:NC,lup:DC,lusolve:AC,leafCount:xC,polynomialRoot:EC,resolve:MC,simplify:FC,simplifyConstant:TC,simplifyCore:BC,symbolicEqual:OC,rationalize:CC,slu:$C,usolve:IC,usolveAll:RC,qr:SC,abs:_C,add:qC,cbrt:zC,ceil:PC,cube:LC,divide:UC,dotDivide:kC,dotMultiply:VC,dotPow:GC,exp:HC,expm:ZC,expm1:JC,fix:XC,floor:WC,gcd:YC,hypot:QC,lcm:jC,log:eM,log2:nM,log1p:tM,log10:rM,mod:aM,multiply:iM,norm:oM,nthRoot:sM,nthRoots:uM,pow:lM,round:cM,sign:fM,sqrt:mM,sqrtm:vM,square:gM,subtract:yM,unaryMinus:bM,unaryPlus:xM,xgcd:wM,invmod:KC,bitAnd:NM,bitNot:DM,bitOr:AM,bitXor:EM,leftShift:SM,rightArithShift:CM,rightLogShift:MM,bellNumbers:FM,catalan:TM,composition:BM,stirlingS2:$M,config:hC,import:gC,typed:yC,arg:OM,conj:IM,re:_M,im:RM,evaluate:qM,help:zM,distance:PM,intersect:LM,and:UM,not:kM,or:VM,xor:GM,concat:ZM,count:JM,cross:XM,column:HM,ctranspose:WM,det:YM,diag:QM,diff:KM,dot:jM,getMatrixDataType:a3,identity:i3,filter:r3,flatten:t3,forEach:n3,inv:o3,pinv:s3,eigs:e3,kron:u3,matrixFromFunction:f3,matrixFromRows:m3,matrixFromColumns:c3,map:l3,ones:v3,partitionSelect:p3,range:d3,resize:g3,reshape:h3,rotate:y3,rotationMatrix:b3,row:x3,size:w3,sort:N3,squeeze:D3,subset:A3,trace:E3,transpose:S3,zeros:C3,fft:M3,ifft:F3,sylvester:pM,schur:dM,lyap:hM,combinations:T3,combinationsWithRep:B3,factorial:$3,gamma:O3,kldivergence:R3,lgamma:I3,multinomial:_3,permutations:q3,pickRandom:z3,random:P3,randomInt:L3,compare:U3,compareNatural:k3,compareText:V3,deepEqual:G3,equal:H3,equalText:Z3,larger:J3,largerEq:X3,smaller:W3,smallerEq:Y3,unequal:Q3,setCartesian:K3,setDifference:j3,setDistinct:eF,setIntersect:rF,setIsSubset:tF,setMultiplicity:nF,setPowerset:aF,setSize:iF,setSymDifference:oF,setUnion:sF,erf:uF,cumsum:yF,mad:lF,max:cF,mean:fF,median:mF,min:vF,mode:pF,prod:dF,quantileSeq:hF,std:gF,sum:bF,variance:xF,acos:wF,acosh:NF,acot:DF,acoth:AF,acsc:EF,acsch:SF,asec:CF,asech:MF,asin:FF,asinh:TF,atan:BF,atanh:OF,atan2:$F,cos:IF,cosh:RF,cot:_F,coth:qF,csc:zF,csch:PF,sec:LF,sech:UF,sin:kF,sinh:VF,tan:GF,tanh:HF,to:ZF,clone:XF,format:WF,bin:JF,oct:o4,hex:QF,isNaN:jF,isInteger:KF,isNegative:e4,isNumeric:r4,hasNumericValue:YF,isPositive:t4,isPrime:n4,isZero:a4,print:s4,typeOf:u4,numeric:i4},gp="help",c4=["typed","mathWithTransform","Help"],f4=q(gp,c4,r=>{var{typed:e,mathWithTransform:t,Help:i}=r;return e(gp,{any:function(a){var o,f=a;if(typeof a!="string"){for(o in t)if(Re(t,o)&&a===t[o]){f=o;break}}var l=st(l4,f);if(!l){var u=typeof f=="function"?f.name:f;throw new Error('No documentation found on "'+u+'"')}return new i(l)}})}),yp="chain",m4=["typed","Chain"],v4=q(yp,m4,r=>{var{typed:e,Chain:t}=r;return e(yp,{"":function(){return new t},any:function(n){return new t(n)}})}),bp="det",p4=["typed","matrix","subtract","multiply","divideScalar","isZero","unaryMinus"],d4=q(bp,p4,r=>{var{typed:e,matrix:t,subtract:i,multiply:n,divideScalar:a,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 i(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),d=0;d<s;d++){var p=v[d];if(o(u[p][d])){var g=void 0;for(g=d+1;g<s;g++)if(!o(u[v[g]][d])){p=v[g],v[g]=v[d],v[d]=p,m=!m;break}if(g===s)return u[p][d]}for(var y=u[p][d],N=d===0?1:u[v[d-1]][d-1],h=d+1;h<s;h++)for(var w=v[h],x=d+1;x<s;x++)u[w][x]=a(i(n(u[w][x],y),n(u[w][d],u[p][x])),N)}var b=u[v[s-1]][s-1];return m?f(b):b}}),xp="inv",h4=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],g4=q(xp,h4,r=>{var{typed:e,matrix:t,divideScalar:i,addScalar:n,multiply:a,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([i(1,m.valueOf()[0])]):[i(1,m[0])];throw new RangeError("Matrix must be square (size: "+Ye(v)+")");case 2:{var d=v[0],p=v[1];if(d===p)return Ve(m)?t(s(m.valueOf(),d,p),m.storage()):s(m,d,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 i(1,m)}});function s(c,m,v){var d,p,g,y,N;if(m===1){if(y=c[0][0],y===0)throw Error("Cannot calculate inverse, determinant is zero");return[[i(1,y)]]}else if(m===2){var h=f(c);if(h===0)throw Error("Cannot calculate inverse, determinant is zero");return[[i(c[1][1],h),i(o(c[0][1]),h)],[i(o(c[1][0]),h),i(c[0][0],h)]]}else{var w=c.concat();for(d=0;d<m;d++)w[d]=w[d].concat();for(var x=l(m).valueOf(),b=0;b<v;b++){var E=u(w[b][b]),A=b;for(d=b+1;d<m;)u(w[d][b])>E&&(E=u(w[d][b]),A=d),d++;if(E===0)throw Error("Cannot calculate inverse, determinant is zero");d=A,d!==b&&(N=w[b],w[b]=w[d],w[d]=N,N=x[b],x[b]=x[d],x[d]=N);var S=w[b],D=x[b];for(d=0;d<m;d++){var T=w[d],B=x[d];if(d!==b){if(T[b]!==0){for(g=i(o(T[b]),S[b]),p=b;p<v;p++)T[p]=n(T[p],a(g,S[p]));for(p=0;p<v;p++)B[p]=n(B[p],a(g,D[p]))}}else{for(g=S[b],p=b;p<v;p++)T[p]=i(T[p],g);for(p=0;p<v;p++)B[p]=i(B[p],g)}}}return x}}}),wp="pinv",y4=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],b4=q(wp,y4,r=>{var{typed:e,matrix:t,inv:i,deepEqual:n,equal:a,dotDivide:o,dot:f,ctranspose:l,divideScalar:u,multiply:s,add:c,Complex:m}=r;return e(wp,{"Array | Matrix":function(h){var w=Ve(h)?h.size():er(h);switch(w.length){case 1:return y(h)?l(h):w[0]===1?i(h):o(l(h),f(h,h));case 2:{if(y(h))return l(h);var x=w[0],b=w[1];if(x===b)try{return i(h)}catch(E){if(!(E instanceof Error&&E.message.match(/Cannot calculate inverse, determinant is zero/)))throw E}return Ve(h)?t(v(h.valueOf(),x,b),h.storage()):v(h,x,b)}default:throw new RangeError("Matrix must be two dimensional (size: "+Ye(w)+")")}},any:function(h){return a(h,0)?Ge(h):u(1,h)}});function v(N,h,w){var{C:x,F:b}=p(N,h,w),E=s(i(s(l(x),x)),l(x)),A=s(l(b),i(s(b,l(b))));return s(A,E)}function d(N,h,w){for(var x=Ge(N),b=0,E=0;E<h;E++){if(w<=b)return x;for(var A=E;g(x[A][b]);)if(A++,h===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<h;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,h,w){var x=d(N,h,w),b=N.map((A,S)=>A.filter((D,T)=>T<h&&!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 a(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 x4(r){var{addScalar:e,subtract:t,flatten:i,multiply:n,multiplyScalar:a,divideScalar:o,sqrt:f,abs:l,bignumber:u,diag:s,inv:c,qr:m,usolve:v,usolveAll:d,equal:p,complex:g,larger:y,smaller:N,matrixFromColumns:h,dot:w}=r;function x(k,Q,K,U,j){j===void 0&&(j=!0);var ae=b(k,Q,K,U,j);E(k,Q,K,U,j,ae);var{values:re,C:me}=A(k,Q,K,U,j),he;return j&&(he=S(k,Q,me,ae,re,K,U),he=h(...he)),{values:re,vectors:he}}function b(k,Q,K,U,j){var ae=U==="BigNumber",re=U==="Complex",me=ae?u(0):0,he=ae?u(1):re?g(1):1,fe=ae?u(1):1,ie=ae?u(10):2,Ae=a(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=me,X=me,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=fe,te=V,be=o(X,ie),ve=a(X,ie);N(te,be);)te=a(te,Ae),Y=a(Y,ie);for(;y(te,ve);)te=o(te,Ae),Y=o(Y,ie);var z=N(o(e(te,X),Y),a(e(V,X),.95));if(z){Ce=!1;for(var L=o(1,Y),ee=0;ee<Q;ee++)$e!==ee&&(k[$e][ee]=a(k[$e][ee],Y),k[ee][$e]=a(k[ee][$e],L));j&&(Oe[$e]=a(Oe[$e],Y))}}}}return s(Oe)}function E(k,Q,K,U,j,ae){var re=U==="BigNumber",me=U==="Complex",he=re?u(0):me?g(0):0;re&&(K=u(K));for(var fe=0;fe<Q-2;fe++){for(var ie=0,Ae=he,Oe=fe+1;Oe<Q;Oe++){var Ce=k[Oe][fe];N(l(Ae),l(Ce))&&(Ae=Ce,ie=Oe)}if(!N(l(Ae),K)){if(ie!==fe+1){var $e=k[ie];k[ie]=k[fe+1],k[fe+1]=$e;for(var V=0;V<Q;V++){var X=k[V][ie];k[V][ie]=k[V][fe+1],k[V][fe+1]=X}if(j){var oe=ae[ie];ae[ie]=ae[fe+1],ae[fe+1]=oe}}for(var G=fe+2;G<Q;G++){var Y=o(k[G][fe],Ae);if(Y!==0){for(var te=0;te<Q;te++)k[G][te]=t(k[G][te],a(Y,k[fe+1][te]));for(var be=0;be<Q;be++)k[be][fe+1]=e(k[be][fe+1],a(Y,k[be][G]));if(j)for(var ve=0;ve<Q;ve++)ae[G][ve]=t(ae[G][ve],a(Y,ae[fe+1][ve]))}}}}return ae}function A(k,Q,K,U,j){var ae=U==="BigNumber",re=U==="Complex",me=ae?u(1):re?g(1):1;ae&&(K=u(K));for(var he=Ge(k),fe=[],ie=Q,Ae=[],Oe=j?s(Array(Q).fill(me)):void 0,Ce=j?s(Array(ie).fill(me)):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,fe.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(me)))),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 be=D(he[ie-2][ie-2],he[ie-2][ie-1],he[ie-1][ie-2],he[ie-1][ie-1]);fe.push(...be),j&&(Ae.unshift(T(he[ie-2][ie-2],he[ie-2][ie-1],he[ie-1][ie-2],he[ie-1][ie-1],be[0],be[1],K,U)),B(Ce,Q),Oe=n(Oe,Ce),ie>2&&(Ce=s(Array(ie-2).fill(me)))),ie-=2,he.pop(),he.pop();for(var ve=0;ve<ie;ve++)he[ve].pop(),he[ve].pop()}if(ie===0)break}if(fe.sort((ee,le)=>+t(l(ee),l(le))),$e>100){var z=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+fe.join(", "));throw z.values=fe,z.vectors=[],z}var L=j?n(Oe,I(Ae,Q)):void 0;return{values:fe,C:L}}function S(k,Q,K,U,j,ae,re){var me=c(K),he=n(me,k,K),fe=re==="BigNumber",ie=re==="Complex",Ae=fe?u(0):ie?g(0):0,Oe=fe?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)),be=[],ve=function(){var le=Ce[z],pe=t(he,n(le,te)),ge=d(pe,Y);for(ge.shift();ge.length<$e[z];){var xe=R(pe,Q,ge,ae,re);if(xe==null){be.push(le);break}ge.push(xe)}var de=n(c(U),K);ge=ge.map(Ne=>n(de,Ne)),oe.push(...ge.map(Ne=>i(Ne)))},z=0;z<G;z++)ve();if(be.length!==0){var L=new Error("Failed to find eigenvectors for the following eigenvalues: "+be.join(", "));throw L.values=j,L.vectors=oe,L}return oe}function D(k,Q,K,U){var j=e(k,U),ae=t(a(k,U),a(Q,K)),re=a(j,.5),me=a(f(t(a(j,j),a(4,ae))),.5);return[e(re,me),t(re,me)]}function T(k,Q,K,U,j,ae,re,me){var he=me==="BigNumber",fe=me==="Complex",ie=he?u(0):fe?g(0):0,Ae=he?u(1):fe?g(1):1;if(N(l(K),re))return[[Ae,ie],[ie,Ae]];if(y(l(t(j,ae)),re))return[[t(j,U),t(ae,U)],[K,K]];var Oe=t(k,j),Ce=t(Q,j),$e=t(K,j),V=t(U,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 U=k.length;U<Q;U++)k.push(Array(Q).fill(0)),k[U][U]=1;return k}function I(k,Q){for(var K=[],U=0;U<Q;U++)K[U]=Array(Q).fill(0);var j=0;for(var ae of k){for(var re=ae.length,me=0;me<re;me++)for(var he=0;he<re;he++)K[j+me][j+he]=ae[me][he];j+=re}return K}function P(k,Q,K){for(var U=0;U<k.length;U++)if(K(k[U],Q))return U;return-1}function R(k,Q,K,U,j){for(var ae=j==="BigNumber"?u(1e3):1e3,re,me=0;re=M(Q,K,j),re=v(k,re),!y(H(re),ae);)if(++me>=5)return null;for(me=0;;){var he=v(k,re);if(N(H(F(re,[he])),U))break;if(++me>=10)return null;re=$(he)}return re}function M(k,Q,K){var U=K==="BigNumber",j=K==="Complex",ae=Array(k).fill(0).map(re=>2*Math.random()-1);return U&&(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",U=Q==="Complex",j=K?u(1):U?g(1):1;return n(o(j,H(k)),k)}return x}function w4(r){var{config:e,addScalar:t,subtract:i,abs:n,atan:a,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 d(D,B);if(I==="BigNumber")return p(D,B);throw TypeError("Unsupported data type: "+I)}function d(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=h(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=i(T,D);return n(I)<=e.epsilon?s(-1).acos().div(4):l(.5,a(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 h(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[$]=i(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(i(l(F,D[B][B]),Q),l(H,D[I][I])),U=m(l(H,D[B][B]),Q,l(F,D[I][I])),j=0;j<P;j++)$[j]=i(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]=U,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],U=0;U<P;U++)$[U]=R*D[B][U]-M*D[I][U],k[U]=M*D[B][U]+R*D[I][U];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 N4="eigs",D4=["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"],A4=q(N4,D4,r=>{var{config:e,typed:t,matrix:i,addScalar:n,subtract:a,equal:o,abs:f,atan:l,cos:u,sin:s,multiplyScalar:c,divideScalar:m,inv:v,bignumber:d,multiply:p,add:g,larger:y,column:N,flatten:h,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=w4({config:e,addScalar:n,subtract:a,abs:f,atan:l,cos:u,sin:s,multiplyScalar:c,inv:v,bignumber:d,multiply:p,add:g}),F=x4({addScalar:n,subtract:a,multiply:p,multiplyScalar:c,flatten:h,divideScalar:m,sqrt:b,abs:f,bignumber:d,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=i(j);return H(ae)},"Array, number|BigNumber":function(j,ae){var re=i(j);return H(re,ae)},Matrix:function(j){var{values:ae,vectors:re}=H(j);return{values:i(ae),vectors:i(re)}},"Matrix, number|BigNumber":function(j,ae){var{values:re,vectors:me}=H(j,ae);return{values:i(re),vectors:i(me)}}});function H(U,j){j===void 0&&(j=e.epsilon);var ae=U.size();if(ae.length!==2||ae[0]!==ae[1])throw new RangeError("Matrix must be square (size: "+Ye(ae)+")");var re=U.toArray(),me=ae[0];if(k(re,me,j)&&(Q(re,me),$(re,me,j))){var he=K(U,re,me);return M(re,me,j,he)}var fe=K(U,re,me);return F(re,me,j,fe)}function $(U,j,ae){for(var re=0;re<j;re++)for(var me=re;me<j;me++)if(y(d(f(a(U[re][me],U[me][re]))),ae))return!1;return!0}function k(U,j,ae){for(var re=0;re<j;re++)for(var me=0;me<j;me++)if(y(d(f(T(U[re][me]))),ae))return!1;return!0}function Q(U,j){for(var ae=0;ae<j;ae++)for(var re=0;re<j;re++)U[ae][re]=B(U[ae][re])}function K(U,j,ae){var re=U.datatype();if(re==="number"||re==="BigNumber"||re==="Complex")return re;for(var me=!1,he=!1,fe=!1,ie=0;ie<ae;ie++)for(var Ae=0;Ae<ae;Ae++){var Oe=j[ie][Ae];if(tr(Oe)||Ba(Oe))me=!0;else if(rr(Oe))he=!0;else if(Lt(Oe))fe=!0;else throw TypeError("Unsupported type in Matrix: "+br(Oe))}if(he&&fe&&console.warn("Complex BigNumbers not supported, this operation will lose precission."),fe){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]=d(j[V][X]);return"BigNumber"}if(me){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",E4=["typed","abs","add","identity","inv","multiply"],S4=q(Np,E4,r=>{var{typed:e,abs:t,add:i,identity:n,inv:a,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],d=1e-15,p=f(c),g=l(p,d),y=g.q,N=g.j,h=o(c,Math.pow(2,-N)),w=n(v),x=n(v),b=1,E=h,A=-1,S=1;S<=y;S++)S>1&&(E=o(E,h),A=-A),b=b*(y-S+1)/((2*y-S+1)*S),w=i(w,o(b,E)),x=i(x,o(b*A,E));for(var D=o(a(x),w),T=0;T<N;T++)D=o(D,D);return wn(c)?c.createSparseMatrix(D):D}});function f(s){for(var c=s.size()[0],m=0,v=0;v<c;v++){for(var d=0,p=0;p<c;p++)d+=t(s.get([v,p]));m=Math.max(d,m)}return m}function l(s,c){for(var m=30,v=0;v<m;v++)for(var d=0;d<=v;d++){var p=v-d;if(u(s,d,p)<c)return{q:d,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,d=2;d<=c;d++)v*=d;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",C4=["typed","abs","add","multiply","map","sqrt","subtract","inv","size","max","identity"],M4=q(Dp,C4,r=>{var{typed:e,abs:t,add:i,multiply:n,map:a,sqrt:o,subtract:f,inv:l,size:u,max:s,identity:c}=r,m=1e3,v=1e-6;function d(p){var g,y=0,N=p,h=c(u(p));do{var w=N;if(N=n(.5,i(w,l(h))),h=n(.5,i(h,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 a(g,o);throw new RangeError("Matrix must be square (size: "+Ye(y)+")");case 2:{var N=y[0],h=y[1];if(N===h)return d(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",F4=["typed","schur","matrixFromColumns","matrix","multiply","range","concat","transpose","index","subset","add","subtract","identity","lusolve","abs"],T4=q(Ap,F4,r=>{var{typed:e,schur:t,matrixFromColumns:i,matrix:n,multiply:a,range:o,concat:f,transpose:l,index:u,subset:s,add:c,subtract:m,identity:v,lusolve:d,abs:p}=r;return e(Ap,{"Matrix, Matrix, Matrix":g,"Array, Matrix, Matrix":function(N,h,w){return g(n(N),h,w)},"Array, Array, Matrix":function(N,h,w){return g(n(N),n(h),w)},"Array, Matrix, Array":function(N,h,w){return g(n(N),h,n(w))},"Matrix, Array, Matrix":function(N,h,w){return g(N,n(h),w)},"Matrix, Array, Array":function(N,h,w){return g(N,n(h),n(w))},"Matrix, Matrix, Array":function(N,h,w){return g(N,h,n(w))},"Array, Array, Array":function(N,h,w){return g(n(N),n(h),n(w)).toArray()}});function g(y,N,h){for(var w=N.size()[0],x=y.size()[0],b=t(y),E=b.T,A=b.U,S=t(a(-1,N)),D=S.T,T=S.U,B=a(a(l(A),h),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(a(P[$],s(D,u($,F))),a(P[$],s(D,u($,F+1)))));var k=a(v(x),a(-1,s(D,u(F,F)))),Q=a(v(x),a(-1,s(D,u(F+1,F)))),K=a(v(x),a(-1,s(D,u(F,F+1)))),U=a(v(x),a(-1,s(D,u(F+1,F+1)))),j=M(R(c(E,k),Q),R(K,c(E,U))),ae=d(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)),me=0;me<F;me++)re=c(re,a(P[me],s(D,u(me,F))));var he=s(D,u(F,F)),fe=m(E,a(he,v(x)));P[F]=d(fe,re)}var ie=n(i(...P)),Ae=a(A,a(ie,l(T)));return Ae}}),Ep="schur",B4=["typed","matrix","identity","multiply","qr","norm","subtract"],$4=q(Ep,B4,r=>{var{typed:e,matrix:t,identity:i,multiply:n,qr:a,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=i(s),v=0,d;do{d=c;var p=a(c),g=p.Q,y=p.R;if(c=n(y,g),m=n(m,g),v++>100)break}while(o(f(c,d))>1e-4);return{U:m,T:c}}}),Sp="lyap",O4=["typed","matrix","sylvester","multiply","transpose"],I4=q(Sp,O4,r=>{var{typed:e,matrix:t,sylvester:i,multiply:n,transpose:a}=r;return e(Sp,{"Matrix, Matrix":function(f,l){return i(f,a(f),n(-1,l))},"Array, Matrix":function(f,l){return i(t(f),a(t(f)),n(-1,l))},"Matrix, Array":function(f,l){return i(f,a(t(f)),t(n(-1,l)))},"Array, Array":function(f,l){return i(t(f),a(t(f)),t(n(-1,l))).toArray()}})}),R4="divide",_4=["typed","matrix","multiply","equalScalar","divideScalar","inv"],q4=q(R4,_4,r=>{var{typed:e,matrix:t,multiply:i,equalScalar:n,divideScalar:a,inv:o}=r,f=Ur({typed:e,equalScalar:n}),l=yt({typed:e});return e("divide",ol({"Array | Matrix, Array | Matrix":function(s,c){return i(s,o(c))},"DenseMatrix, any":function(s,c){return l(s,c,a,!1)},"SparseMatrix, any":function(s,c){return f(s,c,a,!1)},"Array, any":function(s,c){return l(t(s),c,a,!1).valueOf()},"any, Array | Matrix":function(s,c){return i(s,o(c))}},a.signatures))}),Cp="distance",z4=["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],P4=q(Cp,z4,r=>{var{typed:e,addScalar:t,subtract:i,multiplyScalar:n,divideScalar:a,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=a(i(E[1],E[0]),i(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=a(i(E.lineTwoPtY,E.lineTwoPtX),i(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 h(x)}});function u(w){return typeof w=="number"||rr(w)}function s(w){return w.constructor!==Array&&(w=d(w)),u(w[0])&&u(w[1])}function c(w){return w.constructor!==Array&&(w=d(w)),u(w[0])&&u(w[1])&&u(w[2])}function m(w){return Array.isArray(w)||(w=d(w)),w.every(u)}function v(w){return w.constructor!==Array&&(w=d(w)),u(w[0])&&u(w[1])&&u(w[2])&&u(w[3])&&u(w[4])&&u(w[5])}function d(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 a(S,D)}function y(w,x,b,E,A,S,D,T,B){var I=[i(n(i(A,x),B),n(i(S,b),T)),i(n(i(S,b),D),n(i(E,w),B)),i(n(i(E,w),T),n(i(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 a(I,P)}function N(w,x){for(var b=w.length,E=0,A=0,S=0;S<b;S++)A=i(w[S],x[S]),E=t(n(A,A),E);return f(E)}function h(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}}),L4="intersect",U4=["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],k4=q(L4,U4,r=>{var{typed:e,config:t,abs:i,add:n,addScalar:a,matrix:o,multiply:f,multiplyScalar:l,divideScalar:u,subtract:s,smaller:c,equalScalar:m,flatten:v,isZero:d,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(!h(D))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!h(T))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!h(B))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!h(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 h(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(d(H)||c(i(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]),U=u(a(s(s($,k),Q),K),H);return n(f(M,U),P)}function E(D,T,B,I,P,R,M,F,H,$,k,Q){var K=l(s(D,T),s(B,I)),U=l(s(P,R),s(M,F)),j=l(s(H,$),s(k,Q));return a(a(K,U),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),U=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),me=s(l(K,U),l(j,ae)),he=s(l(re,ae),l(U,U));if(d(he))return null;var fe=u(me,he),ie=u(a(K,l(fe,U)),ae),Ae=a(D,l(fe,s(I,D))),Oe=a(T,l(fe,s(P,T))),Ce=a(B,l(fe,s(R,B))),$e=a(M,l(ie,s($,M))),V=a(F,l(ie,s(k,F))),X=a(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),U=l(P,F),j=l(B,H),ae=l(R,H),re=s(s(s($,k),K),j),me=s(s(s(a(a(Q,U),ae),k),K),j),he=u(re,me),fe=a(D,l(he,s(I,D))),ie=a(T,l(he,s(P,T))),Ae=a(B,l(he,s(R,B)));return[fe,ie,Ae]}}),Mp="sum",V4=["typed","config","add","numeric"],Fp=q(Mp,V4,r=>{var{typed:e,config:t,add:i,numeric:n}=r;return e(Mp,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":o,"...":function(l){if(Kn(l))throw new TypeError("Scalar values expected in function sum");return a(l)}});function a(f){var l;return Zt(f,function(u){try{l=l===void 0?u:i(l,u)}catch(s){throw Yr(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=bi(f,l,i);return u}catch(s){throw Yr(s,"sum")}}}),Ki="cumsum",G4=["typed","add","unaryPlus"],Tp=q(Ki,G4,r=>{var{typed:e,add:t,unaryPlus:i}=r;return e(Ki,{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(Kn(u))throw new TypeError("All values expected to be scalar in function cumsum");return n(u)}});function n(l){try{return a(l)}catch(u){throw Yr(u,Ki)}}function a(l){if(l.length===0)return[];for(var u=[i(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 pt(u,s.length);try{return f(l,u)}catch(c){throw Yr(c,Ki)}}function f(l,u){var s,c,m;if(u<=0){var v=l[0][0];if(Array.isArray(v)){for(m=Hl(l),c=[],s=0;s<m.length;s++)c[s]=f(m[s],u-1);return c}else return a(l)}else{for(c=[],s=0;s<l.length;s++)c[s]=f(l[s],u-1);return c}}}),Bp="mean",H4=["typed","add","divide"],$p=q(Bp,H4,r=>{var{typed:e,add:t,divide:i}=r;return e(Bp,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":n,"...":function(f){if(Kn(f))throw new TypeError("Scalar values expected in function mean");return a(f)}});function n(o,f){try{var l=bi(o,f,t),u=Array.isArray(o)?er(o):o.size();return i(l,u[f])}catch(s){throw Yr(s,"mean")}}function a(o){var f,l=0;if(Zt(o,function(u){try{f=f===void 0?u:t(f,u),l++}catch(s){throw Yr(s,"mean",u)}}),l===0)throw new Error("Cannot calculate the mean of an empty array");return i(f,l)}}),Op="median",Z4=["typed","add","divide","compare","partitionSelect"],J4=q(Op,Z4,r=>{var{typed:e,add:t,divide:i,compare:n,partitionSelect:a}=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=a(u,c+1),v=u[c],d=0;d<c;++d)n(u[d],v)>0&&(v=u[d]);return l(v,m)}else{var p=a(u,(s-1)/2);return f(p)}}catch(g){throw Yr(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 i(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(Kn(s))throw new TypeError("Scalar values expected in function median");return o(s)}})}),Ip="mad",X4=["typed","abs","map","median","subtract"],W4=q(Ip,X4,r=>{var{typed:e,abs:t,map:i,median:n,subtract:a}=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(i(f,function(u){return t(a(u,l))}))}catch(u){throw u instanceof TypeError&&u.message.indexOf("median")!==-1?new TypeError(u.message.replace("median","mad")):Yr(u,"mad")}}}),Ms="unbiased",Rp="variance",Y4=["typed","add","subtract","multiply","divide","apply","isNaN"],_p=q(Rp,Y4,r=>{var{typed:e,add:t,subtract:i,multiply:n,divide:a,apply:o,isNaN:f}=r;return e(Rp,{"Array | Matrix":function(c){return l(c,Ms)},"Array | Matrix, string":l,"Array | Matrix, number | BigNumber":function(c,m){return u(c,m,Ms)},"Array | Matrix, number | BigNumber, string":u,"...":function(c){return l(c,Ms)}});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(Zt(s,function(g){try{m=m===void 0?g:t(m,g),v++}catch(y){throw Yr(y,"variance",g)}}),v===0)throw new Error("Cannot calculate variance of an empty array");var d=a(m,v);if(m=void 0,Zt(s,function(g){var y=i(g,d);m=m===void 0?n(y,y):t(m,n(y,y))}),f(m))return m;switch(c){case"uncorrected":return a(m,v);case"biased":return a(m,v+1);case"unbiased":{var p=rr(m)?m.mul(0):0;return v===1?p:a(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 Yr(v,"variance")}}}),Q4="quantileSeq",K4=["typed","add","multiply","partitionSelect","compare"],j4=q(Q4,K4,r=>{var{typed:e,add:t,multiply:i,partitionSelect:n,compare:a}=r;function o(u,s,c){var m,v,d;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(Ct(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(d=new y(1),s.lte(d))return new y(f(v,s,c));if(s.gt(d)){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 h=new y(N+1);m=new Array(N);for(var w=0;w<N;)m[w]=new y(f(v,new y(++w).div(h),c));return m}}if(Ct(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(d=new E.constructor(1),E.isNegative()||E.gt(d))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 d=s*(v-1),p=d%1;if(p===0){var g=c?m[d]:n(m,d);return l(g),g}var y=Math.floor(d),N,h;if(c)N=m[y],h=m[y+1];else{h=n(m,y+1),N=m[y];for(var w=0;w<y;++w)a(m[w],N)>0&&(N=m[w])}return l(N),l(h),t(i(N,1-p),i(h,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)a(m[B],D)>0&&(D=m[B])}l(D),l(T);var I=new A.constructor(1);return t(i(D,I.minus(A)),i(T,A))}var l=e({"number | BigNumber | Unit":function(s){return s}});return o}),qp="std",eT=["typed","map","sqrt","variance"],zp=q(qp,eT,r=>{var{typed:e,map:t,sqrt:i,variance:n}=r;return e(qp,{"Array | Matrix":a,"Array | Matrix, string":a,"Array | Matrix, number | BigNumber":a,"Array | Matrix, number | BigNumber, string":a,"...":function(f){return a(f)}});function a(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 Ct(l)?t(l,i):i(l)}catch(u){throw u instanceof TypeError&&u.message.indexOf(" variance")!==-1?new TypeError(u.message.replace(" variance"," std")):u}}}),Pp="combinations",rT=["typed"],tT=q(Pp,rT,r=>{var{typed:e}=r;return e(Pp,{"number, number":bc,"BigNumber, BigNumber":function(i,n){var a=i.constructor,o,f,l=i.minus(n),u=new a(1);if(!Lp(i)||!Lp(n))throw new TypeError("Positive integer value expected in function combinations");if(n.gt(i))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 Lp(r){return r.isInteger()&&r.gte(0)}var Up="combinationsWithRep",nT=["typed"],aT=q(Up,nT,r=>{var{typed:e}=r;return e(Up,{"number, number":function(i,n){if(!qe(i)||i<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(i<1)throw new TypeError("k must be less than or equal to n + k - 1");if(n<i-1){var a=Jt(i,i+n-1);return a/Jt(1,n)}var o=Jt(n+1,i+n-1);return o/Jt(1,i-1)},"BigNumber, BigNumber":function(i,n){var a=i.constructor,o,f,l=new a(1),u=i.minus(l);if(!kp(i)||!kp(n))throw new TypeError("Positive integer value expected in function combinationsWithRep");if(i.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",iT=["typed","config","multiplyScalar","pow","BigNumber","Complex"],oT=q(Vp,iT,r=>{var{typed:e,config:t,multiplyScalar:i,pow:n,BigNumber:a,Complex:o}=r;function f(u){if(u.im===0)return wi(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(ea[0],0),v=1;v<ea.length;++v){var d=new o(ea[v],0);m=m.add(d.div(u.add(v)))}var p=new o(u.re+Ac+.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:wi,Complex:f,BigNumber:function(s){if(s.isInteger())return s.isNegative()||s.isZero()?new a(1/0):l(s.minus(1));if(!s.isFinite())return new a(s.isNegative()?NaN:1/0);throw new Error("Integer BigNumber expected")}});function l(u){if(u<8)return new a([1,1,2,6,24,120,720,5040][u]);var s=t.precision+(Math.log(u.toNumber())|0),c=a.clone({precision:s});if(u%2===1)return u.times(l(new a(u-1)));for(var m=u,v=new c(u),d=u.toNumber();m>2;)m-=2,d+=m,v=v.times(d);return new a(v.toPrecision(a.precision))}}),Gp="lgamma",sT=["Complex","typed"],uT=q(Gp,sT,r=>{var{Complex:e,typed:t}=r,i=7,n=7,a=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return t(Gp,{number:Ni,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(Ni(u.re),0);if(u.re>=i||Math.abs(u.im)>=n)return f(u);if(u.re<=m){var v=og(s,u.im)*Math.floor(.5*u.re+.25),d=u.mul(Math.PI).sin().log(),p=o(new e(1-u.re,-u.im));return new e(c,v).sub(d).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(Ec),c=new e(1,0).div(u),m=c.div(u),v=a[0],d=a[1],p=2*m.re,g=m.re*m.re+m.im*m.im,y=2;y<8;y++){var N=d;d=-g*v+a[y],v=p*v+N}var h=c.mul(m.mul(v).add(d));return s.add(h)}function l(u){var s=0,c=0,m=u;for(u=u.add(1);u.re<=i;){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",lT=["typed","gamma"],cT=q(Hp,lT,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(i=>n=>je(n,i))})}),Zp="kldivergence",fT=["typed","matrix","divide","sum","multiply","map","dotDivide","log","isNumeric"],mT=q(Zp,fT,r=>{var{typed:e,matrix:t,divide:i,sum:n,multiply:a,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,d=c.size().length;if(v>1)throw new Error("first object must be one dimensional");if(d>1)throw new Error("second object must be one dimensional");if(v!==d)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=i(c,n(c)),N=i(m,n(m)),h=n(a(y,o(f(y,N),w=>l(w))));return u(h)?h:Number.NaN}}),Jp="multinomial",vT=["typed","add","divide","multiply","factorial","isInteger","isPositive"],pT=q(Jp,vT,r=>{var{typed:e,add:t,divide:i,multiply:n,factorial:a,isInteger:o,isPositive:f}=r;return e(Jp,{"Array | Matrix":function(u){var s=0,c=1;return Zt(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,a(m))}),i(a(s),c)}})}),Xp="permutations",dT=["typed","factorial"],hT=q(Xp,dT,r=>{var{typed:e,factorial:t}=r;return e(Xp,{"number | BigNumber":t,"number, number":function(n,a){if(!qe(n)||n<0)throw new TypeError("Positive integer value expected in function permutations");if(!qe(a)||a<0)throw new TypeError("Positive integer value expected in function permutations");if(a>n)throw new TypeError("second argument k must be less than or equal to first argument n");return Jt(n-a+1,n)},"BigNumber, BigNumber":function(n,a){var o,f;if(!Wp(n)||!Wp(a))throw new TypeError("Positive integer value expected in function permutations");if(a.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(a).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 ji={exports:{}},gT=ji.exports,Yp;function yT(){return Yp||(Yp=1,(function(r){(function(e,t,i){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 a(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"&&a(c,s),m.state=function(){return a(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:this.alea=o})(gT,r)})(ji)),ji.exports}var eo={exports:{}},bT=eo.exports,Qp;function xT(){return Qp||(Qp=1,(function(r){(function(e,t,i){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 a(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,d=(m+v)/(1<<21);while(d===0);return d},c.int32=u.next,c.quick=c,s&&(typeof s=="object"&&a(s,u),c.state=function(){return a(u,{})}),c}t&&t.exports?t.exports=o:this.xor128=o})(bT,r)})(eo)),eo.exports}var ro={exports:{}},wT=ro.exports,Kp;function NT(){return Kp||(Kp=1,(function(r){(function(e,t,i){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 a(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,d=(m+v)/(1<<21);while(d===0);return d},c.int32=u.next,c.quick=c,s&&(typeof s=="object"&&a(s,u),c.state=function(){return a(u,{})}),c}t&&t.exports?t.exports=o:this.xorwow=o})(wT,r)})(ro)),ro.exports}var to={exports:{}},DT=to.exports,jp;function AT(){return jp||(jp=1,(function(r){(function(e,t,i){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 a(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,d=(m+v)/(1<<21);while(d===0);return d},c.int32=u.next,c.quick=c,s&&(s.x&&a(s,u),c.state=function(){return a(u,{})}),c}t&&t.exports?t.exports=o:this.xorshift7=o})(DT,r)})(to)),to.exports}var no={exports:{}},ET=no.exports,ed;function ST(){return ed||(ed=1,(function(r){(function(e,t,i){function n(f){var l=this;l.next=function(){var s=l.w,c=l.X,m=l.i,v,d;return l.w=s=s+1640531527|0,d=c[m+34&127],v=c[m=m+1&127],d^=d<<13,v^=v<<17,d^=d>>>15,v^=v>>>12,d=c[m]=d^v,l.i=m,d+(s^s>>>16)|0};function u(s,c){var m,v,d,p,g,y=[],N=128;for(c===(c|0)?(v=c,c=null):(c=c+"\0",v=0,N=Math.max(N,c.length)),d=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,d=m==0?d+1:0);for(d>=128&&(y[(c&&c.length||0)&127]=-1),d=127,p=512;p>0;--p)v=y[d+34&127],m=y[d=d+1&127],v^=v<<13,m^=m<<17,v^=v>>>15,m^=m>>>12,y[d]=v^m;s.w=g,s.X=y,s.i=d}u(l,f)}function a(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,d=(m+v)/(1<<21);while(d===0);return d},c.int32=u.next,c.quick=c,s&&(s.X&&a(s,u),c.state=function(){return a(u,{})}),c}t&&t.exports?t.exports=o:this.xor4096=o})(ET,r)})(no)),no.exports}var ao={exports:{}},CT=ao.exports,rd;function MT(){return rd||(rd=1,(function(r){(function(e,t,i){function n(f){var l=this,u="";l.next=function(){var c=l.b,m=l.c,v=l.d,d=l.a;return c=c<<25^c>>>7^m,m=m-v|0,v=v<<24^v>>>8^d,d=d-c|0,l.b=c=c<<20^c>>>12^m,l.c=m=m-v|0,l.d=v<<16^m>>>16^d,l.a=d-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 a(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,d=(m+v)/(1<<21);while(d===0);return d},c.int32=u.next,c.quick=c,s&&(typeof s=="object"&&a(s,u),c.state=function(){return a(u,{})}),c}t&&t.exports?t.exports=o:this.tychei=o})(CT,r)})(ao)),ao.exports}var io={exports:{}};const FT=A1(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var TT=io.exports,td;function BT(){return td||(td=1,(function(r){(function(e,t,i){var n=256,a=6,o=52,f="random",l=i.pow(n,a),u=i.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,h(t)]:w??N(),3),E),S=new d(E),D=function(){for(var T=S.g(a),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(h(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?(i[f]=T,B):T})(D,A,"global"in x?x.global:this==i,x.state)}function d(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 h(x)}function N(){try{var w;return m&&(w=m.randomBytes)?w=w(n):(w=new Uint8Array(n),(e.crypto||e.msCrypto).getRandomValues(w)),h(w)}catch{var x=e.navigator,b=x&&x.plugins;return[+new Date,e,b,e.screen,h(t)]}}function h(w){return String.fromCharCode.apply(0,w)}if(y(i.random(),t),r.exports){r.exports=v;try{m=FT}catch{}}else i["seed"+f]=v})(typeof self<"u"?self:TT,[],Math)})(io)),io.exports}var Fs,nd;function $T(){if(nd)return Fs;nd=1;var r=yT(),e=xT(),t=NT(),i=AT(),n=ST(),a=MT(),o=BT();return o.alea=r,o.xor128=e,o.xorwow=t,o.xorshift7=i,o.xor4096=n,o.tychei=a,Fs=o,Fs}var OT=$T();const ad=_a(OT);var IT=ad(Date.now());function oa(r){var e;function t(n){e=n===null?IT:ad(String(n))}t(r);function i(){return e()}return i}var id="pickRandom",RT=["typed","config","?on"],_T=q(id,RT,r=>{var{typed:e,config:t,on:i}=r,n=oa(t.randomSeed);return i&&i("config",function(o,f){o.randomSeed!==f.randomSeed&&(n=oa(o.randomSeed))}),e(id,{"Array | Matrix":function(f){return a(f,{})},"Array | Matrix, Object":function(f,l){return a(f,l)},"Array | Matrix, number":function(f,l){return a(f,{number:l})},"Array | Matrix, Array | Matrix":function(f,l){return a(f,{weights:l})},"Array | Matrix, Array | Matrix, number":function(f,l,u){return a(f,{number:u,weights:l})},"Array | Matrix, number, Array | Matrix":function(f,l,u){return a(f,{number:l,weights:u})}});function a(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 d=0,p=u.length;d<p;d++){if(!tr(u[d])||u[d]<0)throw new Error("Weights must be an array of positive numbers");v+=u[d]}}for(var g=o.length,y=[],N;y.length<l;){if(typeof u>"u")N=o[Math.floor(n()*g)];else for(var h=n()*v,w=0,x=o.length;w<x;w++)if(h-=u[w],h<0){N=o[w];break}y.push(N)}return c?y[0]:m?m(y):y}});function Ts(r,e){var t=[];if(r=r.slice(0),r.length>1)for(var i=0,n=r.shift();i<n;i++)t.push(Ts(r,e));else for(var a=0,o=r.shift();a<o;a++)t.push(e());return t}var od="random",qT=["typed","config","?on"],zT=q(od,qT,r=>{var{typed:e,config:t,on:i}=r,n=oa(t.randomSeed);return i&&i("config",function(f,l){f.randomSeed!==l.randomSeed&&(n=oa(f.randomSeed))}),e(od,{"":()=>o(0,1),number:f=>o(0,f),"number, number":(f,l)=>o(f,l),"Array | Matrix":f=>a(f,0,1),"Array | Matrix, number":(f,l)=>a(f,0,l),"Array | Matrix, number, number":(f,l,u)=>a(f,l,u)});function a(f,l,u){var s=Ts(f.valueOf(),()=>o(l,u));return Ve(f)?f.create(s):s}function o(f,l){return f+n()*(l-f)}}),sd="randomInt",PT=["typed","config","?on"],LT=q(sd,PT,r=>{var{typed:e,config:t,on:i}=r,n=oa(t.randomSeed);return i&&i("config",function(f,l){f.randomSeed!==l.randomSeed&&(n=oa(f.randomSeed))}),e(sd,{"":()=>o(0,1),number:f=>o(0,f),"number, number":(f,l)=>o(f,l),"Array | Matrix":f=>a(f,0,1),"Array | Matrix, number":(f,l)=>a(f,0,l),"Array | Matrix, number, number":(f,l,u)=>a(f,l,u)});function a(f,l,u){var s=Ts(f.valueOf(),()=>o(l,u));return Ve(f)?f.create(s):s}function o(f,l){return Math.floor(f+n()*(l-f))}}),ud="stirlingS2",UT=["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],kT=q(ud,UT,r=>{var{typed:e,addScalar:t,subtract:i,multiplyScalar:n,divideScalar:a,pow:o,factorial:f,combinations:l,isNegative:u,isInteger:s,number:c,bignumber:m,larger:v}=r,d=[],p=[];return e(ud,{"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 h=!(tr(y)&&tr(N)),w=h?p:d,x=h?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]}})}),ld="bellNumbers",VT=["typed","addScalar","isNegative","isInteger","stirlingS2"],GT=q(ld,VT,r=>{var{typed:e,addScalar:t,isNegative:i,isInteger:n,stirlingS2:a}=r;return e(ld,{"number | BigNumber":function(f){if(!n(f)||i(f))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var l=0,u=0;u<=f;u++)l=t(l,a(f,u));return l}})}),cd="catalan",HT=["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],ZT=q(cd,HT,r=>{var{typed:e,addScalar:t,divideScalar:i,multiplyScalar:n,combinations:a,isNegative:o,isInteger:f}=r;return e(cd,{"number | BigNumber":function(u){if(!f(u)||o(u))throw new TypeError("Non-negative integer value expected in function catalan");return i(a(n(u,2),u),t(u,1))}})}),fd="composition",JT=["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],XT=q(fd,JT,r=>{var{typed:e,addScalar:t,combinations:i,isPositive:n,isNegative:a,isInteger:o,larger:f}=r;return e(fd,{"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 i(t(u,-1),t(s,-1))}})}),md="leafCount",WT=["parse","typed"],YT=q(md,WT,r=>{var{parse:e,typed:t}=r;function i(n){var a=0;return n.forEach(o=>{a+=i(o)}),a||1}return t(md,{Node:function(a){return i(a)}})});function vd(r){return ir(r)||Tr(r)&&r.isUnary()&&ir(r.args[0])}function oo(r){return!!(ir(r)||(jt(r)||Tr(r))&&r.args.every(oo)||kt(r)&&oo(r.content))}function pd(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,i)}return t}function Bs(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?pd(Object(t),!0).forEach(function(i){qr(r,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):pd(Object(t)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(t,i))})}return r}var QT="simplifyUtil",KT=["FunctionNode","OperatorNode","SymbolNode"],$s=q(QT,KT,r=>{var{FunctionNode:e,OperatorNode:t,SymbolNode:i}=r,n=!0,a=!1,o="defaultF",f={add:{trivial:n,total:n,commutative:n,associative:n},unaryPlus:{trivial:n,total:n,commutative:n,associative:n},subtract:{trivial:a,total:n,commutative:a,associative:a},multiply:{trivial:n,total:n,commutative:n,associative:n},divide:{trivial:a,total:n,commutative:a,associative:a},paren:{trivial:n,total:n,commutative:n,associative:a},defaultF:{trivial:a,total:n,commutative:a,associative:a}},l={divide:{total:a},log:{total:a}},u={subtract:{total:a},abs:{trivial:n},log:{total:n}};function s(h,w){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:f,b=o;if(typeof h=="string"?b=h:Tr(h)?b=h.fn.toString():jt(h)?b=h.name:kt(h)&&(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(h){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f;return s(h,"commutative",w)}function m(h){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f;return s(h,"associative",w)}function v(h,w){var x=Bs({},h);for(var b in w)Re(h,b)?x[b]=Bs(Bs({},w[b]),h[b]):x[b]=w[b];return x}function d(h,w){if(!h.args||h.args.length===0)return h;h.args=p(h,w);for(var x=0;x<h.args.length;x++)d(h.args[x],w)}function p(h,w){var x,b=[],E=function A(S){for(var D=0;D<S.args.length;D++){var T=S.args[D];Tr(T)&&x===T.op?A(T):b.push(T)}};return m(h,w)?(x=h.op,E(h),b):h.args}function g(h,w){if(!(!h.args||h.args.length===0)){for(var x=N(h),b=h.args.length,E=0;E<b;E++)g(h.args[E],w);if(b>2&&m(h,w)){for(var A=h.args.pop();h.args.length>0;)A=x([h.args.pop(),A]);h.args=A.args}}}function y(h,w){if(!(!h.args||h.args.length===0)){for(var x=N(h),b=h.args.length,E=0;E<b;E++)y(h.args[E],w);if(b>2&&m(h,w)){for(var A=h.args.shift();h.args.length>0;)A=x([A,h.args.shift()]);h.args=A.args}}}function N(h){return Tr(h)?function(w){try{return new t(h.op,h.fn,w,h.implicit)}catch(x){return console.error(x),[]}}:function(w){return new e(new i(h.name),w)}}return{createMakeNodeFunction:N,hasProperty:s,isCommutative:c,isAssociative:m,mergeContext:v,flatten:d,allChildren:p,unflattenr:g,unflattenl:y,defaultContext:f,realContext:l,positiveContext:u}}),jT="simplify",eB=["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"],rB=q(jT,eB,r=>{var{config:e,typed:t,parse:i,add:n,subtract:a,multiply:o,divide:f,pow:l,isZero:u,equal:s,resolve:c,simplifyConstant:m,simplifyCore:v,fraction:d,bignumber:p,mathWithTransform:g,matrix:y,AccessorNode:N,ArrayNode:h,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}=$s({FunctionNode:x,OperatorNode:A,SymbolNode:D});t.addConversion({from:"Object",to:"Map",convert:Wn});var K=t("simplify",{Node:fe,"Node, Map":(G,Y)=>fe(G,!1,Y),"Node, Map, Object":(G,Y,te)=>fe(G,!1,Y,te),"Node, Array":fe,"Node, Array, Map":fe,"Node, Array, Map, Object":fe});t.removeConversion({from:"Object",to:"Map",convert:Wn}),K.defaultContext=$,K.realContext=k,K.positiveContext=Q;function U(G){return G.transform(function(Y,te,be){return kt(Y)?U(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 be=G.s.split("->");if(be.length===2)te.l=be[0],te.r=be[1];else throw SyntaxError("Could not parse rule: "+G.s)}else te.l=G.l,te.r=G.r;te.l=U(i(te.l)),te.r=U(i(te.r));for(var ve of["imposeContext","repeat","assuming"])ve in G&&(te[ve]=G[ve]);if(G.evaluate&&(te.evaluate=i(G.evaluate)),I(te.l,Y)){var z=!B(te.l,Y),L;z&&(L=he());var ee=H(te.l),le=he();te.expanded={},te.expanded.l=ee([te.l,le]),R(te.expanded.l,Y),M(te.expanded.l,Y),te.expanded.r=ee([te.r,le]),z&&(te.expandedNC1={},te.expandedNC1.l=ee([L,te.l]),te.expandedNC1.r=ee([L,te.r]),te.expandedNC2={},te.expandedNC2.l=ee([L,te.expanded.l]),te.expandedNC2.r=ee([L,te.expanded.r]))}return te}function re(G,Y){for(var te=[],be=0;be<G.length;be++){var ve=G[be],z=void 0,L=typeof ve;switch(L){case"string":ve={s:ve};case"object":z=ae(ve,Y);break;case"function":z=ve;break;default:throw TypeError("Unsupported type of rule: "+L)}te.push(z)}return te}var me=0;function he(){return new D("_p"+me++)}function fe(G,Y){var te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Xn(),be=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},ve=be.consoleDebug;Y=re(Y||K.rules,be.context);var z=c(G,te);z=U(z);for(var L={},ee=z.toString({parenthesis:"all"});!L[ee];){L[ee]=!0,me=0;var le=ee;ve&&console.log("Working on: ",ee);for(var pe=0;pe<Y.length;pe++){var ge="";if(typeof Y[pe]=="function"?(z=Y[pe](z,be),ve&&(ge=Y[pe].name)):(R(z,be.context),z=Ae(z,Y[pe],be.context),ve&&(ge="".concat(Y[pe].l.toString()," -> ").concat(Y[pe].r.toString()))),ve){var xe=z.toString({parenthesis:"all"});xe!==le&&(console.log("Applying",ge,"produced",xe),le=xe)}F(z,be.context)}ee=z.toString({parenthesis:"all"})}return z}function ie(G,Y,te){var be=G;if(G)for(var ve=0;ve<G.length;++ve){var z=Ae(G[ve],Y,te);z!==G[ve]&&(be===G&&(be=G.slice()),be[ve]=z)}return be}function Ae(G,Y,te){if(Y.assuming){for(var be in Y.assuming)for(var ve in Y.assuming[be])if(T(be,ve,te)!==Y.assuming[be][ve])return G}var z=P(Y.imposeContext,te),L=G;if(L instanceof A||L instanceof x){var ee=ie(L.args,Y,te);ee!==L.args&&(L=L.clone(),L.args=ee)}else if(L instanceof S){if(L.content){var le=Ae(L.content,Y,te);le!==L.content&&(L=new S(le))}}else if(L instanceof h){var pe=ie(L.items,Y,te);pe!==L.items&&(L=new h(pe))}else if(L instanceof N){var ge=L.object;L.object&&(ge=Ae(L.object,Y,te));var xe=L.index;L.index&&(xe=Ae(L.index,Y,te)),(ge!==L.object||xe!==L.index)&&(L=new N(ge,xe))}else if(L instanceof b){var de=ie(L.dimensions,Y,te);de!==L.dimensions&&(L=new b(de))}else if(L instanceof E){var Ne=!1,_e={};for(var Ue in L.properties)_e[Ue]=Ae(L.properties[Ue],Y,te),_e[Ue]!==L.properties[Ue]&&(Ne=!0);Ne&&(L=new E(_e))}var Be=Y.r,ar=X(Y.l,L,z)[0];if(!ar&&Y.expanded&&(Be=Y.expanded.r,ar=X(Y.expanded.l,L,z)[0]),!ar&&Y.expandedNC1&&(Be=Y.expandedNC1.r,ar=X(Y.expandedNC1.l,L,z)[0],ar||(Be=Y.expandedNC2.r,ar=X(Y.expandedNC2.l,L,z)[0])),ar){var Je=L.implicit;L=Be.clone(),Je&&"implicit"in Be&&(L.implicit=!0),L=L.transform(function(mr){return mr.isSymbolNode&&Re(ar.placeholders,mr.name)?ar.placeholders[mr.name].clone():mr})}return Y.repeat&&L!==G&&(L=Ae(L,Y,te)),L}function Oe(G,Y){var te=[],be,ve,z=H(G);if(B(G,Y))for(var L=0;L<G.args.length;L++)ve=G.args.slice(0),ve.splice(L,1),be=ve.length===1?ve[0]:z(ve),te.push(z([G.args[L],be]));else for(var ee=1;ee<G.args.length;ee++){var le=G.args[0];ee>1&&(le=z(G.args.slice(0,ee))),ve=G.args.slice(ee),be=ve.length===1?ve[0]:z(ve),te.push(z([le,be]))}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 be in G.placeholders)if(Re(G.placeholders,be)&&(te.placeholders[be]=G.placeholders[be],Re(Y.placeholders,be)&&!oe(G.placeholders[be],Y.placeholders[be])))return null;for(var ve in Y.placeholders)Re(Y.placeholders,ve)&&(te.placeholders[ve]=Y.placeholders[ve]);return te}function $e(G,Y){var te=[];if(G.length===0||Y.length===0)return te;for(var be,ve=0;ve<G.length;ve++)for(var z=0;z<Y.length;z++)be=Ce(G[ve],Y[z]),be&&te.push(be);return te}function V(G){if(G.length===0)return G;for(var Y=G.reduce($e),te=[],be={},ve=0;ve<Y.length;ve++){var z=JSON.stringify(Y[ve]);be[z]||(be[z]=!0,te.push(Y[ve]))}return te}function X(G,Y,te,be){var ve=[{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||be){for(var z=[],L=0;L<G.args.length;L++){var ee=X(G.args[L],Y.args[L],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 le=X(G.args[0],Y.args[1],te);if(le.length===0)return[];var pe=X(G.args[1],Y.args[0],te);if(pe.length===0)return[];z=[le,pe]}ve=V(z)}else if(Y.args.length>=2&&G.args.length===2){for(var ge=Oe(Y,te),xe=[],de=0;de<ge.length;de++){var Ne=X(G,ge[de],te,!0);xe=xe.concat(Ne)}return xe}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":ve[0].placeholders[G.name]=Y;break;case"c":case"cl":if(ir(Y))ve[0].placeholders[G.name]=Y;else return[];break;case"v":if(!ir(Y))ve[0].placeholders[G.name]=Y;else return[];break;case"vl":if(_r(Y))ve[0].placeholders[G.name]=Y;else return[];break;case"cd":if(vd(Y))ve[0].placeholders[G.name]=Y;else return[];break;case"vd":if(!vd(Y))ve[0].placeholders[G.name]=Y;else return[];break;case"ce":if(oo(Y))ve[0].placeholders[G.name]=Y;else return[];break;case"ve":if(!oo(Y))ve[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 ve}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}),tB="simplifyConstant",nB=["typed","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],aB=q(tB,nB,r=>{var{typed:e,config:t,mathWithTransform:i,matrix:n,fraction:a,bignumber:o,AccessorNode:f,ArrayNode:l,ConstantNode:u,FunctionNode:s,IndexNode:c,ObjectNode:m,OperatorNode:v,SymbolNode:d}=r,{isCommutative:p,isAssociative:g,allChildren:y,createMakeNodeFunction:N}=$s({FunctionNode:s,OperatorNode:v,SymbolNode:d}),h=e("simplifyConstant",{Node:R=>E(P(R,{})),"Node, Object":function(M,F){return E(P(M,F))}});function w(R){return Ba(R)?R.valueOf():R instanceof Array?R.map(w):Ve(R)?n(w(R.valueOf())):R}function x(R,M,F){try{return i[R].apply(null,M)}catch{return M=M.map(w),S(i[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)&&a){var H=a(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&&gs(),o(M);if(t.number==="Fraction")return a===void 0&&sm(),a(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(!Un(M))return new f(E(R),E(M));if(at(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);at(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=at(R)?R.items:R.valueOf();for(var U of K)if(at(U))Q.push(U.items[k-1]);else if(Ve(R))Q.push(U[k-1]);else break;if(Q.length===K.length)at(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(ni(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 U=Q.pop();if(fr(U))return[U,K];try{return Q.push(x(R,[U,K],H)),Q}catch{Q.push(U)}}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(i[R.name]&&i[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&&at(H[0])){for(var $=[],k=H[0];at(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,U,j=N(R);if(Tr(R)&&R.isUnary())K=[P(R.args[0],M)],fr(K[0])?U=j(K):U=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=[],me=0;me<K.length;me++)fr(K[me])?re.push(K[me]):ae.push(K[me]);ae.length>1?(U=I(Q,ae,j,M),re.unshift(U),U=I(Q,re,j,M)):U=I(Q,K,j,M)}else U=I(Q,K,j,M);else K=R.args.map(Ae=>P(Ae,M)),U=I(Q,K,j,M);return U}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=>h(Ae,M)));case"ObjectNode":{var fe={};for(var ie in R.properties)fe[ie]=h(R.properties[ie],M);return new m(fe)}default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(R.type))}}return h}),dd="simplifyCore",iB=["typed","parse","equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],oB=q(dd,iB,r=>{var{typed:e,parse:t,equal:i,isZero:n,add:a,subtract:o,multiply:f,divide:l,pow:u,AccessorNode:s,ArrayNode:c,ConstantNode:m,FunctionNode:v,IndexNode:d,ObjectNode:p,OperatorNode:g,ParenthesisNode:y,SymbolNode:N}=r,h=new m(0),w=new m(1),x=new m(!0),b=new m(!1);function E(T){return Tr(T)&&["and","not","or"].includes(T.op)}var{hasProperty:A,isCommutative:S}=$s({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(jt(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(jt(M)){var F=hE(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(Tr(M)&&M.isUnary()){var k=D(M.args[0],B);if(M.op==="~"&&Tr(k)&&k.isUnary()&&k.op==="~"||M.op==="not"&&Tr(k)&&k.isUnary()&&k.op==="not"&&E(k.args[0]))return k.args[0];var Q=!0;if(M.op==="-"&&Tr(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(Tr(M)&&M.isBinary()){var K=D(M.args[0],B),U=D(M.args[1],B);if(M.op==="+"){if(ir(K)&&n(K.value))return U;if(ir(U)&&n(U.value))return K;Tr(U)&&U.isUnary()&&U.op==="-"&&(U=U.args[0],M=new g("-","subtract",[K,U]))}if(M.op==="-")return Tr(U)&&U.isUnary()&&U.op==="-"?D(new g("+","add",[K,U.args[0]]),B):ir(K)&&n(K.value)?D(new g("-","unaryMinus",[U])):ir(U)&&n(U.value)?K:new g(M.op,M.fn,[K,U]);if(M.op==="*"){if(ir(K)){if(n(K.value))return h;if(i(K.value,1))return U}if(ir(U)){if(n(U.value))return h;if(i(U.value,1))return K;if(S(M,I))return new g(M.op,M.fn,[U,K],M.implicit)}return new g(M.op,M.fn,[K,U],M.implicit)}if(M.op==="/")return ir(K)&&n(K.value)?h:ir(U)&&i(U.value,1)?K:new g(M.op,M.fn,[K,U]);if(M.op==="^"&&ir(U)){if(n(U.value))return w;if(i(U.value,1))return K}if(M.op==="and"){if(ir(K))if(K.value){if(E(U))return U}else return b;if(ir(U))if(U.value){if(E(K))return K}else return b}if(M.op==="or"){if(ir(K)){if(K.value)return x;if(E(U))return U}if(ir(U)){if(U.value)return x;if(E(K))return K}}return new g(M.op,M.fn,[K,U])}if(Tr(M))return new g(M.op,M.fn,M.args.map(re=>D(re,B)));if(at(M))return new c(M.items.map(re=>D(re,B)));if(Nn(M))return new s(D(M.object,B),D(M.index,B));if(Un(M))return new d(M.dimensions.map(re=>D(re,B)));if(ni(M)){var j={};for(var ae in M.properties)j[ae]=D(M.properties[ae],B);return new p(j)}return M}return e(dd,{Node:D,"Node,Object":D})}),sB="resolve",uB=["typed","parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],lB=q(sB,uB,r=>{var{typed:e,parse:t,ConstantNode:i,FunctionNode:n,OperatorNode:a,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(_r(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 i(m):l}else if(Tr(l)){var d=l.args.map(function(g){return f(g,u,s)});return new a(l.op,l.fn,d,l.implicit)}else{if(kt(l))return new o(f(l.content,u,s));if(jt(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,Wn(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,Wn(s))),"Matrix, Object":e.referTo("Matrix,Map",l=>(u,s)=>l(u,Wn(s))),"Array | Matrix, Map":e.referToSelf(l=>(u,s)=>u.map(c=>l(c,s)))})}),hd="symbolicEqual",cB=["parse","simplify","typed","OperatorNode"],fB=q(hd,cB,r=>{var{parse:e,simplify:t,typed:i,OperatorNode:n}=r;function a(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 i(hd,{"Node, Node":a,"Node, Node, Object":a})}),gd="derivative",mB=["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],vB=q(gd,mB,r=>{var{typed:e,config:t,parse:i,simplify:n,equal:a,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:i});var d=e(gd,{"Node, SymbolNode":v,"Node, SymbolNode, Object":v});e.removeConversion({from:"identifier",to:"SymbolNode",convert:i}),d._simplify=!0,d.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(i(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,i(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 h(0)},"SymbolNode, Object":function(x,b){return b[x]!==void 0?h(0):h(1)},"ParenthesisNode, Object":function(x,b){return new c(y(x.content,b))},"FunctionAssignmentNode, Object":function(x,b){return b[x]!==void 0?h(0):y(x.expr,b)},"FunctionNode, Object":function(x,b){if(x.args.length!==1&&N(x),b[x]!==void 0)return h(0);var E=x.args[0],A,S=!1,D=!1,T;switch(x.name){case"cbrt":S=!0,T=new s("*","multiply",[h(3),new s("^","pow",[E,new s("/","divide",[h(2),h(3)])])]);break;case"sqrt":case"nthRoot":if(x.args.length===1)S=!0,T=new s("*","multiply",[h(2),new u("sqrt",[E])]);else if(x.args.length===2)return A=new s("/","divide",[h(1),x.args[1]]),b[A]=b[x.args[1]],y(new s("^","pow",[E,A]),b);break;case"log10":A=h(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()]),h(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()]),h(2)]);break;case"asin":S=!0,T=new u("sqrt",[new s("-","subtract",[h(1),new s("^","pow",[E.clone(),h(2)])])]);break;case"acos":S=!0,D=!0,T=new u("sqrt",[new s("-","subtract",[h(1),new s("^","pow",[E.clone(),h(2)])])]);break;case"atan":S=!0,T=new s("+","add",[new s("^","pow",[E.clone(),h(2)]),h(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(),h(2)]),h(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(),h(2)]),h(1)])])]);break;case"acot":S=!0,D=!0,T=new s("+","add",[new s("^","pow",[E.clone(),h(2)]),h(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()]),h(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()]),h(2)]);break;case"asinh":S=!0,T=new u("sqrt",[new s("+","add",[new s("^","pow",[E.clone(),h(2)]),h(1)])]);break;case"acosh":S=!0,T=new u("sqrt",[new s("-","subtract",[new s("^","pow",[E.clone(),h(2)]),h(1)])]);break;case"atanh":S=!0,T=new s("-","subtract",[h(1),new s("^","pow",[E.clone(),h(2)])]);break;case"asech":S=!0,D=!0,T=new s("*","multiply",[E.clone(),new u("sqrt",[new s("-","subtract",[h(1),new s("^","pow",[E.clone(),h(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(),h(2)]),h(1)])])]);break;case"acoth":S=!0,D=!0,T=new s("-","subtract",[h(1),new s("^","pow",[E.clone(),h(2)])]);break;case"abs":T=new s("/","divide",[new u(new m("abs"),[E.clone()]),E.clone()]);break;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 h(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(),h(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(),h(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)||a(I.value,1))?h(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 h(0);if(a(P.value,1))return y(I,b)}var R=new s("^","pow",[I.clone(),new s("-","subtract",[P,h(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]=h(0);throw w.compile().evaluate(),new Error("Expected TypeError, but none found")}}function h(w,x){return new l(f(w,t.number))}return d}),yd="rationalize",pB=["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"],dB=q(yd,pB,r=>{var{config:e,typed:t,equal:i,isZero:n,add:a,subtract:o,multiply:f,divide:l,pow:u,parse:s,simplifyConstant:c,simplifyCore:m,simplify:v,fraction:d,bignumber:p,mathWithTransform:g,matrix:y,AccessorNode:N,ArrayNode:h,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},U={exactFractions:!0};if(M=k.expression,Q>=1){M=P(M);var j,ae,re=!0,me=!1;M=v(M,$.firstRules,{},K);for(var he;ae=re?$.distrDivRules:$.sucDivRules,M=v(M,ae,{},U),re=!re,he=M.toString(),he!==j;)me=!0,j=he;me&&(M=v(M,$.firstRulesAgain,{},K)),M=v(M,$.finalRules,{},K)}var fe=[],ie={};return M.type==="OperatorNode"&&M.isBinary()&&M.op==="/"?(Q===1&&(M.args[0]=R(M.args[0],fe),M.args[1]=R(M.args[1])),H&&(ie.numerator=M.args[0],ie.denominator=M.args[1])):(Q===1&&(M=R(M,fe)),H&&(ie.numerator=M,ie.denominator=null)),H?(ie.coefficients=fe,ie.variables=k.variables,ie.expression=M,ie):M}return t(yd,{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 U={};return U.expression=Q,U.variables=k,U;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 me=0;me<ae.args.length;me++)j(ae.args[me])}else if(re==="SymbolNode"){var he=ae.name,fe=k.indexOf(he);fe===-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 U=M.args[0],j=new A("^","pow",[M.args[0].cloneDeep(),new w(K-1)]);M=new A("*","multiply",[U,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,U=$;U>=0;U--)if(F[U]!==0){var j=new w(Q?F[U]:Math.abs(F[U])),ae=F[U]<0?"-":"+";if(U>0){var re=new S(k);if(U>1){var me=new w(U);re=new A("^","pow",[re,me])}F[U]===-1&&Q?j=new A("-","unaryMinus",[re]):Math.abs(F[U])===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(fe,ie,Ae){var Oe=fe.type;if(Oe==="FunctionNode")throw new Error("There is an unsolved function call");if(Oe==="OperatorNode"){if("+-*^".indexOf(fe.op)===-1)throw new Error("Operator "+fe.op+" invalid");if(ie!==null){if((fe.fn==="unaryMinus"||fe.fn==="pow")&&ie.fn!=="add"&&ie.fn!=="subtract"&&ie.fn!=="multiply")throw new Error("Invalid "+fe.op+" placing");if((fe.fn==="subtract"||fe.fn==="add"||fe.fn==="multiply")&&ie.fn!=="add"&&ie.fn!=="subtract")throw new Error("Invalid "+fe.op+" placing");if((fe.fn==="subtract"||fe.fn==="add"||fe.fn==="unaryMinus")&&Ae.noFil!==0)throw new Error("Invalid "+fe.op+" placing")}(fe.op==="^"||fe.op==="*")&&(Ae.fire=fe.op);for(var Ce=0;Ce<fe.args.length;Ce++)fe.fn==="unaryMinus"&&(Ae.oper="-"),(fe.op==="+"||fe.fn==="subtract")&&(Ae.fire="",Ae.cte=1,Ae.oper=Ce===0?"+":fe.op),Ae.noFil=Ce,he(fe.args[Ce],fe,Ae)}else if(Oe==="SymbolNode"){if(fe.name!==k&&k!=="")throw new Error("There is more than one variable");if(k=fe.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(fe.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")}}}),hB="reviver",gB=["classes"],yB=q(hB,gB,r=>{var{classes:e}=r;return function(i,n){var a=e[n&&n.mathjs];return a&&typeof a.fromJSON=="function"?a.fromJSON(n):n}}),bB="replacer",xB=[],wB=q(bB,xB,()=>function(e,t){return typeof t=="number"&&(!isFinite(t)||isNaN(t))?{mathjs:"number",value:String(t)}:t}),NB="11.8.0",DB=q("true",[],()=>!0),AB=q("false",[],()=>!1),EB=q("null",[],()=>null),SB=tt("Infinity",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1/0):1/0}),CB=tt("NaN",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(NaN):NaN}),MB=tt("pi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?ws(t):Q1}),FB=tt("tau",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?xD(t):K1}),TB=tt("e",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?yD(t):j1}),BB=tt("phi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?bD(t):ey}),$B=tt("LN2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).ln():Math.LN2}),OB=tt("LN10",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(10).ln():Math.LN10}),IB=tt("LOG2E",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1).div(new t(2).ln()):Math.LOG2E}),RB=tt("LOG10E",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1).div(new t(10).ln()):Math.LOG10E}),_B=tt("SQRT1_2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t("0.5").sqrt():Math.SQRT1_2}),qB=tt("SQRT2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).sqrt():Math.SQRT2}),zB=tt("i",["Complex"],r=>{var{Complex:e}=r;return e.I}),PB=q("version",[],()=>NB);function tt(r,e,t){return q(r,e,t,{recreateOnConfigChange:!0})}var LB=We("speedOfLight","299792458","m s^-1"),UB=We("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),kB=We("planckConstant","6.62607015e-34","J s"),VB=We("reducedPlanckConstant","1.0545718176461565e-34","J s"),GB=We("magneticConstant","1.25663706212e-6","N A^-2"),HB=We("electricConstant","8.8541878128e-12","F m^-1"),ZB=We("vacuumImpedance","376.730313667","ohm"),JB=We("coulomb","8.987551792261171e9","N m^2 C^-2"),XB=We("elementaryCharge","1.602176634e-19","C"),WB=We("bohrMagneton","9.2740100783e-24","J T^-1"),YB=We("conductanceQuantum","7.748091729863649e-5","S"),QB=We("inverseConductanceQuantum","12906.403729652257","ohm"),KB=We("magneticFluxQuantum","2.0678338484619295e-15","Wb"),jB=We("nuclearMagneton","5.0507837461e-27","J T^-1"),e$=We("klitzing","25812.807459304513","ohm"),r$=We("bohrRadius","5.29177210903e-11","m"),t$=We("classicalElectronRadius","2.8179403262e-15","m"),n$=We("electronMass","9.1093837015e-31","kg"),a$=We("fermiCoupling","1.1663787e-5","GeV^-2"),i$=so("fineStructure",.0072973525693),o$=We("hartreeEnergy","4.3597447222071e-18","J"),s$=We("protonMass","1.67262192369e-27","kg"),u$=We("deuteronMass","3.3435830926e-27","kg"),l$=We("neutronMass","1.6749271613e-27","kg"),c$=We("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),f$=We("rydberg","10973731.568160","m^-1"),m$=We("thomsonCrossSection","6.6524587321e-29","m^2"),v$=so("weakMixingAngle",.2229),p$=so("efimovFactor",22.7),d$=We("atomicMass","1.66053906660e-27","kg"),h$=We("avogadro","6.02214076e23","mol^-1"),g$=We("boltzmann","1.380649e-23","J K^-1"),y$=We("faraday","96485.33212331001","C mol^-1"),b$=We("firstRadiation","3.7417718521927573e-16","W m^2"),x$=We("loschmidt","2.686780111798444e25","m^-3"),w$=We("gasConstant","8.31446261815324","J K^-1 mol^-1"),N$=We("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),D$=We("molarVolume","0.022413969545014137","m^3 mol^-1"),A$=so("sackurTetrode",-1.16487052358),E$=We("secondRadiation","0.014387768775039337","m K"),S$=We("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),C$=We("wienDisplacement","2.897771955e-3","m K"),M$=We("molarMass","0.99999999965e-3","kg mol^-1"),F$=We("molarMassC12","11.9999999958e-3","kg mol^-1"),T$=We("gravity","9.80665","m s^-2"),B$=We("planckLength","1.616255e-35","m"),$$=We("planckMass","2.176435e-8","kg"),O$=We("planckTime","5.391245e-44","s"),I$=We("planckCharge","1.87554603778e-18","C"),R$=We("planckTemperature","1.416785e+32","K");function We(r,e,t){var i=["config","Unit","BigNumber"];return q(r,i,n=>{var{config:a,Unit:o,BigNumber:f}=n,l=a.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,i=>{var{config:n,BigNumber:a}=i;return n.number==="BigNumber"?new a(e):e})}var _$="apply",q$=["typed","isInteger"],z$=q(_$,q$,r=>{var{typed:e,isInteger:t}=r,i=mf({typed:e,isInteger:t});return e("apply",{"...any":function(a){var o=a[1];tr(o)?a[1]=o-1:rr(o)&&(a[1]=o.minus(1));try{return i.apply(null,a)}catch(f){throw Qr(f)}}})},{isTransformFunction:!0}),P$="column",L$=["typed","Index","matrix","range"],U$=q(P$,L$,r=>{var{typed:e,Index:t,matrix:i,range:n}=r,a=Xf({typed:e,Index:t,matrix:i,range:n});return e("column",{"...any":function(f){var l=f.length-1,u=f[l];tr(u)&&(f[l]=u-1);try{return a.apply(null,f)}catch(s){throw Qr(s)}}})},{isTransformFunction:!0});function Os(r,e,t){var i=r.filter(function(f){return _r(f)&&!(f.name in e)&&!t.has(f.name)})[0];if(!i)throw new Error('No undefined variable found in inline expression "'+r+'"');var n=i.name,a=Va(t),o=r.compile();return function(l){return a.set(n,l),o.evaluate(a)}}var k$="filter",V$=["typed"],G$=q(k$,V$,r=>{var{typed:e}=r;function t(n,a,o){var f,l;return n[0]&&(f=n[0].compile().evaluate(o)),n[1]&&(_r(n[1])||$a(n[1])?l=n[1].compile().evaluate(o):l=Os(n[1],a,o)),i(f,l)}t.rawArgs=!0;var i=e("filter",{"Array, function":bd,"Matrix, function":function(a,o){return a.create(bd(a.toArray(),o))},"Array, RegExp":li,"Matrix, RegExp":function(a,o){return a.create(li(a.toArray(),o))}});return t},{isTransformFunction:!0});function bd(r,e){var t=sn(e);return Dl(r,function(i,n,a){return t===1?e(i):t===2?e(i,[n+1]):e(i,[n+1],a)})}var H$="forEach",Z$=["typed"],J$=q(H$,Z$,r=>{var{typed:e}=r;function t(n,a,o){var f,l;return n[0]&&(f=n[0].compile().evaluate(o)),n[1]&&(_r(n[1])||$a(n[1])?l=n[1].compile().evaluate(o):l=Os(n[1],a,o)),i(f,l)}t.rawArgs=!0;var i=e("forEach",{"Array | Matrix, function":function(a,o){var f=sn(o),l=function u(s,c){Array.isArray(s)?ui(s,function(m,v){u(m,c.concat(v+1))}):f===1?o(s):f===2?o(s,c):o(s,c,a)};l(a.valueOf(),[])}});return t},{isTransformFunction:!0}),X$="index",W$=["Index"],Y$=q(X$,W$,r=>{var{Index:e}=r;return function(){for(var i=[],n=0,a=arguments.length;n<a;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");i[n]=o}var f=new e;return e.apply(f,i),f}},{isTransformFunction:!0}),Q$="map",K$=["typed"],j$=q(Q$,K$,r=>{var{typed:e}=r;function t(n,a,o){var f,l;return n[0]&&(f=n[0].compile().evaluate(o)),n[1]&&(_r(n[1])||$a(n[1])?l=n[1].compile().evaluate(o):l=Os(n[1],a,o)),i(f,l)}t.rawArgs=!0;var i=e("map",{"Array, function":function(a,o){return xd(a,o,a)},"Matrix, function":function(a,o){return a.create(xd(a.valueOf(),o,a))}});return t},{isTransformFunction:!0});function xd(r,e,t){var i=sn(e);function n(a,o){return Array.isArray(a)?Vt(a,function(f,l){return n(f,o.concat(l+1))}):i===1?e(a):i===2?e(a,o):e(a,o,t)}return n(r,[])}function Cn(r){if(r.length===2&&Ct(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 e5="max",r5=["typed","config","numeric","larger"],t5=q(e5,r5,r=>{var{typed:e,config:t,numeric:i,larger:n}=r,a=ov({typed:e,config:t,numeric:i,larger:n});return e("max",{"...any":function(f){f=Cn(f);try{return a.apply(null,f)}catch(l){throw Qr(l)}}})},{isTransformFunction:!0}),n5="mean",a5=["typed","add","divide"],i5=q(n5,a5,r=>{var{typed:e,add:t,divide:i}=r,n=$p({typed:e,add:t,divide:i});return e("mean",{"...any":function(o){o=Cn(o);try{return n.apply(null,o)}catch(f){throw Qr(f)}}})},{isTransformFunction:!0}),o5="min",s5=["typed","config","numeric","smaller"],u5=q(o5,s5,r=>{var{typed:e,config:t,numeric:i,smaller:n}=r,a=uv({typed:e,config:t,numeric:i,smaller:n});return e("min",{"...any":function(f){f=Cn(f);try{return a.apply(null,f)}catch(l){throw Qr(l)}}})},{isTransformFunction:!0}),l5="range",c5=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],f5=q(l5,c5,r=>{var{typed:e,config:t,matrix:i,bignumber:n,smaller:a,smallerEq:o,larger:f,largerEq:l}=r,u=cm({typed:e,config:t,matrix:i,bignumber:n,smaller:a,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}),m5="row",v5=["typed","Index","matrix","range"],p5=q(m5,v5,r=>{var{typed:e,Index:t,matrix:i,range:n}=r,a=dm({typed:e,Index:t,matrix:i,range:n});return e("row",{"...any":function(f){var l=f.length-1,u=f[l];tr(u)&&(f[l]=u-1);try{return a.apply(null,f)}catch(s){throw Qr(s)}}})},{isTransformFunction:!0}),d5="subset",h5=["typed","matrix"],g5=q(d5,h5,r=>{var{typed:e,matrix:t}=r,i=bm({typed:e,matrix:t});return e("subset",{"...any":function(a){try{return i.apply(null,a)}catch(o){throw Qr(o)}}})},{isTransformFunction:!0}),y5="concat",b5=["typed","matrix","isInteger"],x5=q(y5,b5,r=>{var{typed:e,matrix:t,isInteger:i}=r,n=Hf({typed:e,matrix:t,isInteger:i});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 Qr(u)}}})},{isTransformFunction:!0}),wd="diff",w5=["typed","matrix","subtract","number","bignumber"],N5=q(wd,w5,r=>{var{typed:e,matrix:t,subtract:i,number:n,bignumber:a}=r,o=om({typed:e,matrix:t,subtract:i,number:n,bignumber:a});return e(wd,{"...any":function(l){l=Cn(l);try{return o.apply(null,l)}catch(u){throw Qr(u)}}})},{isTransformFunction:!0}),D5="std",A5=["typed","map","sqrt","variance"],E5=q(D5,A5,r=>{var{typed:e,map:t,sqrt:i,variance:n}=r,a=zp({typed:e,map:t,sqrt:i,variance:n});return e("std",{"...any":function(f){f=Cn(f);try{return a.apply(null,f)}catch(l){throw Qr(l)}}})},{isTransformFunction:!0}),Nd="sum",S5=["typed","config","add","numeric"],C5=q(Nd,S5,r=>{var{typed:e,config:t,add:i,numeric:n}=r,a=Fp({typed:e,config:t,add:i,numeric:n});return e(Nd,{"...any":function(f){f=Cn(f);try{return a.apply(null,f)}catch(l){throw Qr(l)}}})},{isTransformFunction:!0}),Dd="cumsum",M5=["typed","add","unaryPlus"],F5=q(Dd,M5,r=>{var{typed:e,add:t,unaryPlus:i}=r,n=Tp({typed:e,add:t,unaryPlus:i});return e(Dd,{"...any":function(o){if(o.length===2&&Ct(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 Qr(l)}}})},{isTransformFunction:!0}),Ad="variance",T5=["typed","add","subtract","multiply","divide","apply","isNaN"],B5=q(Ad,T5,r=>{var{typed:e,add:t,subtract:i,multiply:n,divide:a,apply:o,isNaN:f}=r,l=_p({typed:e,add:t,subtract:i,multiply:n,divide:a,apply:o,isNaN:f});return e(Ad,{"...any":function(s){s=Cn(s);try{return l.apply(null,s)}catch(c){throw Qr(c)}}})},{isTransformFunction:!0}),Me=D1({config:ye}),xr=F1({}),Ed=TB({BigNumber:Me,config:ye}),$5=AB({}),O5=i$({BigNumber:Me,config:ye}),Mn=I1({}),Sd=zB({Complex:xr}),I5=SB({BigNumber:Me,config:ye}),R5=OB({BigNumber:Me,config:ye}),_5=RB({BigNumber:Me,config:ye}),uo=L1({}),q5=CB({BigNumber:Me,config:ye}),z5=EB({}),P5=BB({BigNumber:Me,config:ye}),L5=q1({}),Cd=Cg({}),U5=_B({BigNumber:Me,config:ye}),k5=A$({BigNumber:Me,config:ye}),Md=FB({BigNumber:Me,config:ye}),V5=DB({}),G5=PB({}),Qe=G1({Matrix:uo}),H5=p$({BigNumber:Me,config:ye}),Z5=$B({BigNumber:Me,config:ye}),Fd=MB({BigNumber:Me,config:ye}),J5=wB({}),X5=qB({BigNumber:Me,config:ye}),J=Dg({BigNumber:Me,Complex:xr,DenseMatrix:Qe,Fraction:Mn}),Is=rb({BigNumber:Me,config:ye,typed:J}),W5=v$({BigNumber:Me,config:ye}),et=nb({typed:J}),Y5=BD({Complex:xr,config:ye,typed:J}),Q5=RD({BigNumber:Me,typed:J}),K5=PD({BigNumber:Me,Complex:xr,config:ye,typed:J}),Br=sb({typed:J}),j5=Yx({typed:J}),eO=HD({BigNumber:Me,Complex:xr,config:ye,typed:J}),rO=YD({typed:J}),Td=jD({typed:J}),tO=nA({Complex:xr,config:ye,typed:J}),Bt=Ry({BigNumber:Me,typed:J}),nO=kx({typed:J}),aO=$y({typed:J}),iO=Z1({typed:J}),lo=tT({typed:J}),co=zy({Complex:xr,typed:J}),Fn=Kx({typed:J}),oO=sA({typed:J}),sO=fA({BigNumber:Me,typed:J}),uO=vA({BigNumber:Me,typed:J}),lO=xb({typed:J}),nr=xy({config:ye,typed:J}),cO=dN({typed:J}),Bd=Nb({typed:J}),fO=Ab({Complex:xr,typed:J}),mO=bw({typed:J}),vO=Dw({typed:J}),Ga=AN({typed:J}),pO=Sw({typed:J}),dO=TN({format:Ga,typed:J}),Rs=ew({typed:J}),ut=X1({typed:J}),sa=iy({typed:J}),fo=fy({typed:J}),wt=vy({typed:J}),hO=IB({BigNumber:Me,config:ye}),gO=uT({Complex:xr,typed:J}),yO=rx({Complex:xr,config:ye,typed:J}),$d=nx({Complex:xr,config:ye,typed:J}),ua=$w({typed:J}),Sr=mx({typed:J}),Od=aw({typed:J}),cn=My({typed:J}),bO=MN({format:Ga,typed:J}),xO=_T({config:ye,typed:J}),wO=$N({typed:J}),NO=zT({config:ye,typed:J}),_s=tw({typed:J}),DO=gA({BigNumber:Me,typed:J}),Id=yx({BigNumber:Me,Fraction:Mn,complex:co,typed:J}),qs=wA({typed:J}),Wt=Dy({Matrix:uo,equalScalar:nr,typed:J}),AO=Qy({typed:J}),EO=Dx({typed:J}),SO=Ty({typed:J}),CO=EA({typed:J}),Rd=gy({typed:J}),MO=OD({Complex:xr,config:ye,typed:J}),FO=UD({BigNumber:Me,typed:J}),zs=mf({isInteger:ut,typed:J}),TO=VD({BigNumber:Me,Complex:xr,config:ye,typed:J}),BO=SN({format:Ga,typed:J}),$O=aT({typed:J}),Ps=iA({typed:J}),OO=dA({BigNumber:Me,typed:J}),Ha=dy({typed:J}),IO=_N({typed:J}),RO=LT({config:ye,typed:J}),_O=bA({BigNumber:Me,typed:J}),qO=DA({typed:J}),zO=CD({SparseMatrix:Wt,typed:J}),$t=wx({Complex:xr,config:ye,typed:J}),PO=MA({typed:J}),Ot=jy({typed:J}),LO=qD({BigNumber:Me,Complex:xr,config:ye,typed:J}),UO=lA({BigNumber:Me,typed:J}),la=Uy({Fraction:Mn,typed:J}),Tn=sy({typed:J}),Te=Vy({DenseMatrix:Qe,Matrix:uo,SparseMatrix:Wt,typed:J}),kO=Hy({isZero:wt,matrix:Te,typed:J}),VO=xN({isNaN:Ha,isNumeric:Tn,typed:J}),Nt=PN({bignumber:Bt,fraction:la,number:cn}),_d=NN({config:ye,multiplyScalar:Sr,numeric:Nt,typed:J}),GO=Lw({isInteger:ut,matrix:Te,typed:J}),Hr=Yw({matrix:Te,config:ye,typed:J}),HO=Kw({matrix:Te,typed:J}),nt=bm({matrix:Te,typed:J}),Za=aN({matrix:Te,typed:J}),qd=Cx({BigNumber:Me,config:ye,matrix:Te,typed:J}),It=uN({BigNumber:Me,config:ye,matrix:Te,typed:J}),ZO=JD({Complex:xr,config:ye,typed:J}),zd=lb({BigNumber:Me,Complex:xr,Fraction:Mn,config:ye,isNegative:sa,matrix:Te,typed:J,unaryMinus:Ot}),ur=Hf({isInteger:ut,matrix:Te,typed:J}),JO=mw({prod:_d,size:Hr,typed:J}),Ls=oN({conj:Fn,transpose:Za,typed:J}),Pd=hw({DenseMatrix:Qe,SparseMatrix:Wt,matrix:Te,typed:J}),Dr=UN({numeric:Nt,typed:J}),Ja=r2({DenseMatrix:Qe,concat:ur,divideScalar:Dr,equalScalar:nr,matrix:Te,typed:J}),Dt=B2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),Xa=ww({matrix:Te,typed:J}),XO=Jb({BigNumber:Me,DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),WO=ly({isNumeric:Tn,typed:J}),fn=Mw({BigNumber:Me,DenseMatrix:Qe,SparseMatrix:Wt,config:ye,matrix:Te,typed:J}),YO=Tw({matrix:Te,multiplyScalar:Sr,typed:J}),mo=H2({DenseMatrix:Qe,concat:ur,config:ye,matrix:Te,typed:J}),QO=v2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J,zeros:It}),Us=Wy({flatten:Xa,matrix:Te,size:Hr,typed:J}),Ld=lx({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),KO=hx({BigNumber:Me,concat:ur,equalScalar:nr,matrix:Te,typed:J}),jO=qw({BigNumber:Me,config:ye,matrix:Te,typed:J}),e8=Vw({config:ye,matrix:Te}),r8=d2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J,zeros:It}),vo=HN({BigNumber:Me,DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J,zeros:It}),lt=_2({DenseMatrix:Qe,concat:ur,config:ye,matrix:Te,typed:J}),t8=IN({concat:ur,matrix:Te,typed:J}),n8=Y2({DenseMatrix:Qe,concat:ur,config:ye,equalScalar:nr,matrix:Te,typed:J}),a8=uw({DenseMatrix:Qe,concat:ur,matrix:Te,typed:J}),wr=YA({DenseMatrix:Qe,SparseMatrix:Wt,addScalar:Br,concat:ur,equalScalar:nr,matrix:Te,typed:J}),i8=Lx({concat:ur,equalScalar:nr,matrix:Te,typed:J}),o8=Xx({DenseMatrix:Qe,concat:ur,matrix:Te,typed:J}),s8=ZT({addScalar:Br,combinations:lo,divideScalar:Dr,isInteger:ut,isNegative:sa,multiplyScalar:Sr,typed:J}),ca=w2({BigNumber:Me,DenseMatrix:Qe,Fraction:Mn,concat:ur,config:ye,equalScalar:nr,matrix:Te,typed:J}),Ud=F2({concat:ur,matrix:Te,typed:J}),u8=Tp({add:wr,typed:J,unaryPlus:Is}),kd=X2({equal:Dt,typed:J}),po=tE({addScalar:Br,conj:Fn,multiplyScalar:Sr,size:Hr,typed:J}),l8=I2({compareText:Ud,isZero:wt,typed:J}),Vd=Tb({DenseMatrix:Qe,config:ye,equalScalar:nr,matrix:Te,round:vo,typed:J,zeros:It}),c8=KA({abs:et,addScalar:Br,divideScalar:Dr,isPositive:fo,multiplyScalar:Sr,smaller:lt,sqrt:$t,typed:J}),Gd=oD({DenseMatrix:Qe,smaller:lt}),Zr=lD({ImmutableDenseMatrix:Gd}),f8=Fx({BigNumber:Me,add:wr,config:ye,equal:Dt,isInteger:ut,mod:Ld,smaller:lt,typed:J,xgcd:qd}),ct=k2({DenseMatrix:Qe,concat:ur,config:ye,matrix:Te,typed:J}),ks=JN({Complex:xr,config:ye,divideScalar:Dr,typed:J}),m8=Jy({flatten:Xa,matrix:Te,size:Hr,typed:J}),v8=uv({config:ye,numeric:Nt,smaller:lt,typed:J}),Nr=px({addScalar:Br,dot:po,equalScalar:nr,matrix:Te,multiplyScalar:Sr,typed:J}),p8=QN({Complex:xr,config:ye,divideScalar:Dr,typed:J}),d8=ow({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),Vs=j2({compare:ca,isNaN:Ha,isNumeric:Tn,typed:J}),h8=j4({add:wr,compare:ca,multiply:Nr,partitionSelect:Vs,typed:J}),g8=g2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J,zeros:It}),Gs=P2({DenseMatrix:Qe,concat:ur,config:ye,matrix:Te,typed:J}),yr=Ex({DenseMatrix:Qe,addScalar:Br,concat:ur,equalScalar:nr,matrix:Te,typed:J,unaryMinus:Ot}),y8=iE({add:wr,matrix:Te,typed:J}),Hs=i2({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Sr,subtract:yr,typed:J}),b8=b2({concat:ur,equalScalar:nr,matrix:Te,not:Od,typed:J,zeros:It}),x8=Gx({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),Zs=yb({DenseMatrix:Qe,config:ye,equalScalar:nr,matrix:Te,round:vo,typed:J,zeros:It}),Rt=S2({compare:ca,typed:J}),w8=XT({addScalar:Br,combinations:lo,isInteger:ut,isNegative:sa,isPositive:fo,larger:ct,typed:J}),N8=pw({matrix:Te,multiply:Nr,subtract:yr,typed:J}),Hd=d4({divideScalar:Dr,isZero:wt,matrix:Te,multiply:Nr,subtract:yr,typed:J,unaryMinus:Ot}),D8=om({matrix:Te,number:cn,subtract:yr,typed:J}),A8=P4({abs:et,addScalar:Br,divideScalar:Dr,multiplyScalar:Sr,sqrt:$t,subtract:yr,typed:J,unaryMinus:Ot}),E8=Ox({concat:ur,equalScalar:nr,matrix:Te,multiplyScalar:Sr,typed:J}),Zd=mD({larger:ct,smaller:lt}),Jd=Cb({Complex:xr,DenseMatrix:Qe,ceil:Zs,equalScalar:nr,floor:Vd,matrix:Te,typed:J,zeros:It}),Xd=sE({Index:Zr,typed:J}),S8=k4({abs:et,add:wr,addScalar:Br,config:ye,divideScalar:Dr,equalScalar:nr,flatten:Xa,isNumeric:Tn,isZero:wt,matrix:Te,multiply:Nr,multiplyScalar:Sr,smaller:lt,subtract:yr,typed:J}),C8=jb({concat:ur,equalScalar:nr,matrix:Te,typed:J}),M8=WN({Complex:xr,config:ye,divideScalar:Dr,log:ks,typed:J}),Wd=n2({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Sr,subtract:yr,typed:J}),Yd=ov({config:ye,larger:ct,numeric:Nt,typed:J}),Js=uS({addScalar:Br,complex:co,conj:Fn,divideScalar:Dr,equal:Dt,identity:fn,isZero:wt,matrix:Te,multiplyScalar:Sr,sign:Id,sqrt:$t,subtract:yr,typed:J,unaryMinus:Ot,zeros:It}),fa=cm({bignumber:Bt,matrix:Te,config:ye,larger:ct,largerEq:mo,smaller:lt,smallerEq:Gs,typed:J}),F8=dm({Index:Zr,matrix:Te,range:fa,typed:J}),T8=TA({DenseMatrix:Qe,Index:Zr,compareNatural:Rt,size:Hr,subset:nt,typed:J}),B8=IA({DenseMatrix:Qe,Index:Zr,compareNatural:Rt,size:Hr,subset:nt,typed:J}),$8=zA({Index:Zr,compareNatural:Rt,size:Hr,subset:nt,typed:J}),O8=kA({Index:Zr,compareNatural:Rt,size:Hr,subset:nt,typed:J}),Qd=$S({SparseMatrix:Wt,abs:et,add:wr,divideScalar:Dr,larger:ct,largerEq:mo,multiply:Nr,subtract:yr,transpose:Za,typed:J}),Kd=dD({FibonacciHeap:Zd,addScalar:Br,equalScalar:nr}),jd=Fp({add:wr,config:ye,numeric:Nt,typed:J}),eh=l2({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Sr,subtract:yr,typed:J}),I8=rA({BigNumber:Me,DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),rh=Xf({Index:Zr,matrix:Te,range:fa,typed:J}),R8=s2({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Sr,subtract:yr,typed:J}),th=$A({DenseMatrix:Qe,Index:Zr,compareNatural:Rt,size:Hr,subset:nt,typed:J}),_8=LA({Index:Zr,compareNatural:Rt,size:Hr,subset:nt,typed:J}),nh=ZA({Index:Zr,concat:ur,setDifference:th,size:Hr,subset:nt,typed:J}),q8=rD({compare:ca,compareNatural:Rt,matrix:Te,typed:J}),Bn=g4({abs:et,addScalar:Br,det:Hd,divideScalar:Dr,identity:fn,matrix:Te,multiply:Nr,typed:J,unaryMinus:Ot}),ah=oS({DenseMatrix:Qe,Spa:Kd,SparseMatrix:Wt,abs:et,addScalar:Br,divideScalar:Dr,equalScalar:nr,larger:ct,matrix:Te,multiplyScalar:Sr,subtract:yr,typed:J,unaryMinus:Ot}),z8=b4({Complex:xr,add:wr,ctranspose:Ls,deepEqual:kd,divideScalar:Dr,dot:po,dotDivide:Ja,equal:Dt,inv:Bn,matrix:Te,multiply:Nr,typed:J}),_t=VN({Complex:xr,config:ye,fraction:la,identity:fn,inv:Bn,matrix:Te,multiply:Nr,number:cn,typed:J}),ih=_A({DenseMatrix:Qe,Index:Zr,compareNatural:Rt,size:Hr,subset:nt,typed:J}),P8=XA({Index:Zr,concat:ur,setIntersect:ih,setSymDifference:nh,size:Hr,subset:nt,typed:J}),L8=M4({abs:et,add:wr,identity:fn,inv:Bn,map:ua,max:Yd,multiply:Nr,size:Hr,sqrt:$t,subtract:yr,typed:J}),Ze=DD({BigNumber:Me,Complex:xr,Fraction:Mn,abs:et,addScalar:Br,config:ye,divideScalar:Dr,equal:Dt,fix:Jd,format:Ga,isNumeric:Tn,multiplyScalar:Sr,number:cn,pow:_t,round:vo,subtract:yr}),U8=ZB({BigNumber:Me,Unit:Ze,config:ye}),k8=C$({BigNumber:Me,Unit:Ze,config:ye}),V8=d$({BigNumber:Me,Unit:Ze,config:ye}),G8=WB({BigNumber:Me,Unit:Ze,config:ye}),H8=g$({BigNumber:Me,Unit:Ze,config:ye}),Z8=YB({BigNumber:Me,Unit:Ze,config:ye}),J8=FD({Unit:Ze,typed:J}),X8=u$({BigNumber:Me,Unit:Ze,config:ye}),W8=jN({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,pow:_t,typed:J}),Y8=HB({BigNumber:Me,Unit:Ze,config:ye}),Q8=XB({BigNumber:Me,Unit:Ze,config:ye}),K8=S4({abs:et,add:wr,identity:fn,inv:Bn,multiply:Nr,typed:J}),j8=y$({BigNumber:Me,Unit:Ze,config:ye}),oh=cN({addScalar:Br,ceil:Zs,conj:Fn,divideScalar:Dr,dotDivide:Ja,exp:Bd,i:Sd,log2:$d,matrix:Te,multiplyScalar:Sr,pow:_t,tau:Md,typed:J}),sh=oT({BigNumber:Me,Complex:xr,config:ye,multiplyScalar:Sr,pow:_t,typed:J}),e6=UB({BigNumber:Me,Unit:Ze,config:ye}),r6=o$({BigNumber:Me,Unit:Ze,config:ye}),t6=mN({conj:Fn,dotDivide:Ja,fft:oh,typed:J}),n6=e$({BigNumber:Me,Unit:Ze,config:ye}),a6=x$({BigNumber:Me,Unit:Ze,config:ye}),i6=GB({BigNumber:Me,Unit:Ze,config:ye}),o6=M$({BigNumber:Me,Unit:Ze,config:ye}),s6=N$({BigNumber:Me,Unit:Ze,config:ye}),u6=l$({BigNumber:Me,Unit:Ze,config:ye}),l6=jB({BigNumber:Me,Unit:Ze,config:ye}),c6=I$({BigNumber:Me,Unit:Ze,config:ye}),f6=B$({BigNumber:Me,Unit:Ze,config:ye}),m6=R$({BigNumber:Me,Unit:Ze,config:ye}),v6=s$({BigNumber:Me,Unit:Ze,config:ye}),p6=VB({BigNumber:Me,Unit:Ze,config:ye}),d6=f$({BigNumber:Me,Unit:Ze,config:ye}),h6=E$({BigNumber:Me,Unit:Ze,config:ye}),g6=LB({BigNumber:Me,Unit:Ze,config:ye}),y6=S$({BigNumber:Me,Unit:Ze,config:ye}),b6=m$({BigNumber:Me,Unit:Ze,config:ye}),x6=h$({BigNumber:Me,Unit:Ze,config:ye}),w6=r$({BigNumber:Me,Unit:Ze,config:ye}),N6=JB({BigNumber:Me,Unit:Ze,config:ye}),ft=q4({divideScalar:Dr,equalScalar:nr,inv:Bn,matrix:Te,multiply:Nr,typed:J}),D6=n$({BigNumber:Me,Unit:Ze,config:ye}),ho=cT({gamma:sh,typed:J}),A6=b$({BigNumber:Me,Unit:Ze,config:ye}),E6=w$({BigNumber:Me,Unit:Ze,config:ye}),S6=QB({BigNumber:Me,Unit:Ze,config:ye}),uh=IS({DenseMatrix:Qe,lsolve:Wd,lup:ah,matrix:Te,slu:Qd,typed:J,usolve:Hs}),C6=KB({BigNumber:Me,Unit:Ze,config:ye}),M6=F$({BigNumber:Me,Unit:Ze,config:ye}),F6=pT({add:wr,divide:ft,factorial:ho,isInteger:ut,isPositive:fo,multiply:Nr,typed:J}),T6=hT({factorial:ho,typed:J}),B6=$$({BigNumber:Me,Unit:Ze,config:ye}),$6=_S({add:wr,cbrt:zd,divide:ft,equalScalar:nr,im:Rs,isZero:wt,multiply:Nr,re:_s,sqrt:$t,subtract:yr,typeOf:Rd,typed:J,unaryMinus:Ot}),O6=GA({compareNatural:Rt,typed:J}),lh=kT({bignumber:Bt,addScalar:Br,combinations:lo,divideScalar:Dr,factorial:ho,isInteger:ut,isNegative:sa,larger:ct,multiplyScalar:Sr,number:cn,pow:_t,subtract:yr,typed:J}),I6=ED({Unit:Ze,typed:J}),R6=GT({addScalar:Br,isInteger:ut,isNegative:sa,stirlingS2:lh,typed:J}),ch=A4({abs:et,add:wr,addScalar:Br,atan:Td,bignumber:Bt,column:rh,complex:co,config:ye,cos:Ps,diag:Pd,divideScalar:Dr,dot:po,equal:Dt,flatten:Xa,im:Rs,inv:Bn,larger:ct,matrix:Te,matrixFromColumns:Us,multiply:Nr,multiplyScalar:Sr,number:cn,qr:Js,re:_s,sin:qs,smaller:lt,sqrt:$t,subtract:yr,typed:J,usolve:Hs,usolveAll:eh}),_6=a$({BigNumber:Me,Unit:Ze,config:ye}),q6=T$({BigNumber:Me,Unit:Ze,config:ye}),z6=mT({divide:ft,dotDivide:Ja,isNumeric:Tn,log:ks,map:ua,matrix:Te,multiply:Nr,sum:jd,typed:J}),P6=$p({add:wr,divide:ft,typed:J}),L6=D$({BigNumber:Me,Unit:Ze,config:ye}),U6=kB({BigNumber:Me,Unit:Ze,config:ye}),k6=c$({BigNumber:Me,Unit:Ze,config:ye}),Xs=_p({add:wr,apply:zs,divide:ft,isNaN:Ha,multiply:Nr,subtract:yr,typed:J}),V6=t$({BigNumber:Me,Unit:Ze,config:ye}),fh=J4({add:wr,compare:ca,divide:ft,partitionSelect:Vs,typed:J}),G6=O$({BigNumber:Me,Unit:Ze,config:ye}),H6=zp({map:ua,sqrt:$t,typed:J,variance:Xs}),Z6=W4({abs:et,map:ua,median:fh,subtract:yr,typed:J}),Ws=eE({abs:et,add:wr,conj:Fn,ctranspose:Ls,eigs:ch,equalScalar:nr,larger:ct,matrix:Te,multiply:Nr,pow:_t,smaller:lt,sqrt:$t,typed:J}),mh=Jw({BigNumber:Me,DenseMatrix:Qe,SparseMatrix:Wt,addScalar:Br,config:ye,cos:Ps,matrix:Te,multiplyScalar:Sr,norm:Ws,sin:qs,typed:J,unaryMinus:Ot}),J6=Hw({multiply:Nr,rotationMatrix:mh,typed:J}),vh=$4({identity:fn,matrix:Te,multiply:Nr,norm:Ws,qr:Js,subtract:yr,typed:J}),ph=T4({abs:et,add:wr,concat:ur,identity:fn,index:Xd,lusolve:uh,matrix:Te,matrixFromColumns:Us,multiply:Nr,range:fa,schur:vh,subset:nt,subtract:yr,transpose:Za,typed:J}),X6=I4({matrix:Te,multiply:Nr,sylvester:ph,transpose:Za,typed:J}),ma={},va={},dh={},Jr=cE({mathWithTransform:va}),pa=IE({Node:Jr}),Yt=_E({Node:Jr}),$n=zE({Node:Jr}),hh=kE({Node:Jr}),da=pE({Node:Jr}),gh=xE({Node:Jr,ResultSet:Cd}),yh=NE({Node:Jr}),mn=ME({Node:Jr}),bh=LE({Node:Jr}),W6=yB({classes:dh}),Ys=kS({math:ma,typed:J}),xh=TE({Node:Jr,typed:J}),Y6=v4({Chain:Ys,typed:J}),ha=mE({Node:Jr,subset:nt}),ga=$E({Node:Jr,size:Hr}),wh=yE({matrix:Te,Node:Jr,subset:nt}),vn=HE({Unit:Ze,Node:Jr,math:ma}),pn=JE({Node:Jr,SymbolNode:vn,math:ma}),At=WE({AccessorNode:ha,ArrayNode:da,AssignmentNode:wh,BlockNode:gh,ConditionalNode:yh,ConstantNode:mn,FunctionAssignmentNode:xh,FunctionNode:pn,IndexNode:ga,ObjectNode:pa,OperatorNode:Yt,ParenthesisNode:$n,RangeNode:bh,RelationalNode:hh,SymbolNode:vn,config:ye,numeric:Nt,typed:J}),Nh=lB({ConstantNode:mn,FunctionNode:pn,OperatorNode:Yt,ParenthesisNode:$n,parse:At,typed:J}),Qs=aB({bignumber:Bt,fraction:la,AccessorNode:ha,ArrayNode:da,ConstantNode:mn,FunctionNode:pn,IndexNode:ga,ObjectNode:pa,OperatorNode:Yt,SymbolNode:vn,config:ye,mathWithTransform:va,matrix:Te,typed:J}),Q6=QE({parse:At,typed:J}),Ks=jE({parse:At,typed:J}),Dh=PS({parse:At}),Ah=tS({evaluate:Ks}),js=oB({AccessorNode:ha,ArrayNode:da,ConstantNode:mn,FunctionNode:pn,IndexNode:ga,ObjectNode:pa,OperatorNode:Yt,ParenthesisNode:$n,SymbolNode:vn,add:wr,divide:ft,equal:Dt,isZero:wt,multiply:Nr,parse:At,pow:_t,subtract:yr,typed:J}),K6=f4({Help:Dh,mathWithTransform:va,typed:J}),go=rB({bignumber:Bt,fraction:la,AccessorNode:ha,ArrayNode:da,ConstantNode:mn,FunctionNode:pn,IndexNode:ga,ObjectNode:pa,OperatorNode:Yt,ParenthesisNode:$n,SymbolNode:vn,add:wr,config:ye,divide:ft,equal:Dt,isZero:wt,mathWithTransform:va,matrix:Te,multiply:Nr,parse:At,pow:_t,resolve:Nh,simplifyConstant:Qs,simplifyCore:js,subtract:yr,typed:J}),j6=fB({OperatorNode:Yt,parse:At,simplify:go,typed:J}),e7=vB({ConstantNode:mn,FunctionNode:pn,OperatorNode:Yt,ParenthesisNode:$n,SymbolNode:vn,config:ye,equal:Dt,isZero:wt,numeric:Nt,parse:At,simplify:go,typed:J}),r7=aS({Parser:Ah,typed:J}),t7=YT({parse:At,typed:J}),n7=dB({bignumber:Bt,fraction:la,AccessorNode:ha,ArrayNode:da,ConstantNode:mn,FunctionNode:pn,IndexNode:ga,ObjectNode:pa,OperatorNode:Yt,ParenthesisNode:$n,SymbolNode:vn,add:wr,config:ye,divide:ft,equal:Dt,isZero:wt,mathWithTransform:va,matrix:Te,multiply:Nr,parse:At,pow:_t,simplify:go,simplifyConstant:Qs,simplifyCore:js,subtract:yr,typed:J});zr(ma,{e:Ed,false:$5,fineStructure:O5,i:Sd,Infinity:I5,LN10:R5,LOG10E:_5,NaN:q5,null:z5,phi:P5,SQRT1_2:U5,sackurTetrode:k5,tau:Md,true:V5,E:Ed,version:G5,efimovFactor:H5,LN2:Z5,pi:Fd,replacer:J5,reviver:W6,SQRT2:X5,typed:J,unaryPlus:Is,PI:Fd,weakMixingAngle:W5,abs:et,acos:Y5,acot:Q5,acsc:K5,addScalar:Br,arg:j5,asech:eO,asinh:rO,atan:Td,atanh:tO,bignumber:Bt,bitNot:nO,boolean:aO,clone:iO,combinations:lo,complex:co,conj:Fn,cosh:oO,coth:sO,csc:uO,cube:lO,equalScalar:nr,erf:cO,exp:Bd,expm1:fO,filter:mO,forEach:vO,format:Ga,getMatrixDataType:pO,hex:dO,im:Rs,isInteger:ut,isNegative:sa,isPositive:fo,isZero:wt,LOG2E:hO,lgamma:gO,log10:yO,log2:$d,map:ua,multiplyScalar:Sr,not:Od,number:cn,oct:bO,pickRandom:xO,print:wO,random:NO,re:_s,sec:DO,sign:Id,sin:qs,splitUnit:AO,square:EO,string:SO,tan:CO,typeOf:Rd,acosh:MO,acsch:FO,apply:zs,asec:TO,bin:BO,chain:Y6,combinationsWithRep:$O,cos:Ps,csch:OO,isNaN:Ha,isPrime:IO,randomInt:RO,sech:_O,sinh:qO,sparse:zO,sqrt:$t,tanh:PO,unaryMinus:Ot,acoth:LO,cot:UO,fraction:la,isNumeric:Tn,matrix:Te,matrixFromFunction:kO,mode:VO,numeric:Nt,prod:_d,reshape:GO,size:Hr,squeeze:HO,subset:nt,transpose:Za,xgcd:qd,zeros:It,asin:ZO,cbrt:zd,concat:ur,count:JO,ctranspose:Ls,diag:Pd,divideScalar:Dr,dotDivide:Ja,equal:Dt,flatten:Xa,gcd:XO,hasNumericValue:WO,identity:fn,kron:YO,largerEq:mo,leftShift:QO,matrixFromColumns:Us,mod:Ld,nthRoot:KO,ones:jO,resize:e8,rightArithShift:r8,round:vo,smaller:lt,to:t8,unequal:n8,xor:a8,add:wr,bitAnd:i8,bitXor:o8,catalan:s8,compare:ca,compareText:Ud,cumsum:u8,deepEqual:kd,dot:po,equalText:l8,floor:Vd,hypot:c8,invmod:f8,larger:ct,log:ks,matrixFromRows:m8,min:v8,multiply:Nr,nthRoots:p8,or:d8,partitionSelect:Vs,quantileSeq:h8,rightLogShift:g8,smallerEq:Gs,subtract:yr,trace:y8,usolve:Hs,and:b8,bitOr:x8,ceil:Zs,compareNatural:Rt,composition:w8,cross:N8,det:Hd,diff:D8,distance:A8,dotMultiply:E8,fix:Jd,index:Xd,intersect:S8,lcm:C8,log1p:M8,lsolve:Wd,max:Yd,qr:Js,range:fa,row:F8,setCartesian:T8,setDistinct:B8,setIsSubset:$8,setPowerset:O8,slu:Qd,sum:jd,usolveAll:eh,atan2:I8,column:rh,lsolveAll:R8,setDifference:th,setMultiplicity:_8,setSymDifference:nh,sort:q8,inv:Bn,lup:ah,pinv:z8,pow:_t,setIntersect:ih,setUnion:P8,sqrtm:L8,vacuumImpedance:U8,wienDisplacement:k8,atomicMass:V8,bohrMagneton:G8,boltzmann:H8,conductanceQuantum:Z8,createUnit:J8,deuteronMass:X8,dotPow:W8,electricConstant:Y8,elementaryCharge:Q8,expm:K8,faraday:j8,fft:oh,gamma:sh,gravitationConstant:e6,hartreeEnergy:r6,ifft:t6,klitzing:n6,loschmidt:a6,magneticConstant:i6,molarMass:o6,molarPlanckConstant:s6,neutronMass:u6,nuclearMagneton:l6,planckCharge:c6,planckLength:f6,planckTemperature:m6,protonMass:v6,reducedPlanckConstant:p6,rydberg:d6,secondRadiation:h6,speedOfLight:g6,stefanBoltzmann:y6,thomsonCrossSection:b6,avogadro:x6,bohrRadius:w6,coulomb:N6,divide:ft,electronMass:D6,factorial:ho,firstRadiation:A6,gasConstant:E6,inverseConductanceQuantum:S6,lusolve:uh,magneticFluxQuantum:C6,molarMassC12:M6,multinomial:F6,permutations:T6,planckMass:B6,polynomialRoot:$6,setSize:O6,stirlingS2:lh,unit:I6,bellNumbers:R6,eigs:ch,fermiCoupling:_6,gravity:q6,kldivergence:z6,mean:P6,molarVolume:L6,planckConstant:U6,quantumOfCirculation:k6,variance:Xs,classicalElectronRadius:V6,median:fh,parse:At,planckTime:G6,resolve:Nh,simplifyConstant:Qs,std:H6,compile:Q6,evaluate:Ks,mad:Z6,simplifyCore:js,help:K6,norm:Ws,rotationMatrix:mh,simplify:go,symbolicEqual:j6,derivative:e7,parser:r7,rotate:J6,leafCount:t7,rationalize:n7,schur:vh,sylvester:ph,lyap:X6,config:ye}),zr(va,ma,{filter:G$({typed:J}),forEach:J$({typed:J}),map:j$({typed:J}),apply:z$({isInteger:ut,typed:J}),subset:g5({matrix:Te,typed:J}),concat:x5({isInteger:ut,matrix:Te,typed:J}),max:t5({config:ye,larger:ct,numeric:Nt,typed:J}),sum:C5({add:wr,config:ye,numeric:Nt,typed:J}),min:u5({config:ye,numeric:Nt,smaller:lt,typed:J}),cumsum:F5({add:wr,typed:J,unaryPlus:Is}),diff:N5({bignumber:Bt,matrix:Te,number:cn,subtract:yr,typed:J}),index:Y$({Index:Zr}),range:f5({bignumber:Bt,matrix:Te,config:ye,larger:ct,largerEq:mo,smaller:lt,smallerEq:Gs,typed:J}),row:p5({Index:Zr,matrix:Te,range:fa,typed:J}),column:U$({Index:Zr,matrix:Te,range:fa,typed:J}),mean:i5({add:wr,divide:ft,typed:J}),variance:B5({add:wr,apply:zs,divide:ft,isNaN:Ha,multiply:Nr,subtract:yr,typed:J}),std:E5({map:ua,sqrt:$t,typed:J,variance:Xs})}),zr(dh,{BigNumber:Me,Complex:xr,Fraction:Mn,Matrix:uo,Node:Jr,ObjectNode:pa,OperatorNode:Yt,ParenthesisNode:$n,Range:L5,RelationalNode:hh,ResultSet:Cd,ArrayNode:da,BlockNode:gh,ConditionalNode:yh,ConstantNode:mn,DenseMatrix:Qe,RangeNode:bh,Chain:Ys,FunctionAssignmentNode:xh,SparseMatrix:Wt,AccessorNode:ha,IndexNode:ga,AssignmentNode:wh,ImmutableDenseMatrix:Gd,Index:Zr,FibonacciHeap:Zd,Spa:Kd,Unit:Ze,SymbolNode:vn,FunctionNode:pn,Help:Dh,Parser:Ah}),Ys.createProxy(ma);class eu extends TypeError{constructor(e){super(`Operator "${e}" is invalid`),TypeError.captureStackTrace&&TypeError.captureStackTrace(this,eu),this.name="CompareOperatorError",this.operator=e}}class ru extends Error{constructor(e){super(`Invalid data format: ${e}`),Error.captureStackTrace&&Error.captureStackTrace(this,ru),this.name="ImportError",this.data=e}}class Wa 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,Wa),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 qt extends Error{constructor(e=null){super(`Missing argument${e?` "${e}"`:""}`),Error.captureStackTrace&&Error.captureStackTrace(this,qt),this.argumentName=e}}const a7=(r,e,t)=>{const i=Number(r),n=Number(e);let a;if(Number.isNaN(i)||Number.isNaN(n))return!1;switch(t){case"=":case"==":a=i===n;break;case"<":a=i<n;break;case">":a=i>n;break;case"<=":a=i<=n;break;case">=":a=i>=n;break;case"!":case"!=":case"<>":a=i!==n;break;default:a=!1;break}return a},Eh=r=>Ks(r),Cr=r=>typeof r!="number"&&typeof r!="string"?!1:!Number.isNaN(r)&&Number.isFinite(Number(r)),tu=r=>{if(!Cr(r))return!1;const e=Number(r);return e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER},i7=r=>Array.isArray(r)?r.reduce((e,t)=>e+(Cr(t)?parseFloat(`${t}`):0),0):0,o7=(r,e=0)=>parseFloat(parseFloat(`${r}`).toFixed(e||0)),Ir=9007199254740992,Ya=Ir-1,bo=-1>>>0,mt=bo+1,xo=mt/2,Qa=1<<21,On=Qa-1;function nu(r){return r.next()|0}function dn(r,e){return e===0?r:t=>r(t)+e}function au(r){const e=r.next()|0,t=r.next()>>>0;return(e&On)*mt+t+(e&Qa?-Ir:0)}function Sh(r){for(;;){const e=r.next()|0;if(e&4194304){if((e&8388607)===4194304&&(r.next()|0)===0)return Ir}else{const t=r.next()>>>0;return(e&On)*mt+t+(e&Qa?-Ir:0)}}}function Ch(r){return r.next()>>>0}function wo(r){const e=r.next()&On,t=r.next()>>>0;return e*mt+t}function iu(r){for(;;){const e=r.next()|0;if(e&Qa){if((e&On)===0&&(r.next()|0)===0)return Ir}else{const t=r.next()>>>0;return(e&On)*mt+t}}}function Mh(r){return(r+1&r)===0}function s7(r){return e=>e.next()&r}function u7(r){const e=r+1,t=e*Math.floor(mt/e);return i=>{let n=0;do n=i.next()>>>0;while(n>=t);return n%e}}function l7(r){return Mh(r)?s7(r):u7(r)}function c7(r){return(r|0)===0}function f7(r){return e=>{const t=e.next()&r,i=e.next()>>>0;return t*mt+i}}function m7(r){const e=r*Math.floor(Ir/r);return t=>{let i=0;do{const n=t.next()&On,a=t.next()>>>0;i=n*mt+a}while(i>=e);return i%r}}function v7(r){const e=r+1;if(c7(e)){const t=(e/mt|0)-1;if(Mh(t))return f7(t)}return m7(e)}function Fh(r,e){return t=>{let i=0;do{const n=t.next()|0,a=t.next()>>>0;i=(n&On)*mt+a+(n&Qa?-Ir:0)}while(i<r||i>e);return i}}function In(r,e){if(r=Math.floor(r),e=Math.floor(e),r<-Ir||!isFinite(r))throw new RangeError(`Expected min to be at least ${-Ir}`);if(e>Ir||!isFinite(e))throw new RangeError(`Expected max to be at most ${Ir}`);const t=e-r;return t<=0||!isFinite(t)?()=>r:t===bo?r===0?Ch:dn(nu,r+xo):t<bo?dn(l7(t),r):t===Ya?dn(wo,r):t<Ya?dn(v7(t),r):e-1-r===Ya?dn(iu,r):r===-Ir&&e===Ir?Sh:r===-Ir&&e===Ya?au:r===-Ya&&e===Ir?dn(au,1):e===Ir?dn(Fh(r-1,e-1),1):Fh(r,e)}function p7(r){return(r.next()&1)===1}function ou(r,e){return t=>r(t)<e}function d7(r){if(r<=0)return()=>!1;if(r>=1)return()=>!0;{const e=r*mt;return e%1===0?ou(nu,e-xo|0):ou(wo,Math.round(r*Ir))}}function h7(r,e){return e==null?r==null?p7:d7(r):r<=0?()=>!1:r>=e?()=>!0:ou(In(0,e-1),r)}function g7(r,e){const t=In(+r,+e);return i=>new Date(t(i))}function Th(r){return In(1,r)}function y7(r,e){const t=Th(r);return i=>{const n=[];for(let a=0;a<e;++a)n.push(t(i));return n}}const b7="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-";function su(r=b7){const e=r.length;if(!e)throw new Error("Expected pool not to be an empty string");const t=In(0,e-1);return(i,n)=>{let a="";for(let o=0;o<n;++o){const f=t(i);a+=r.charAt(f)}return a}}const Bh="0123456789abcdef",x7=su(Bh),w7=su(Bh.toUpperCase());function N7(r){return r?w7:x7}function $h(r,e){return r<0?Math.max(r+e,0):Math.min(r,e)}function Oh(r){const e=+r;return e<0?Math.ceil(e):Math.floor(e)}function D7(r,e,t,i){const n=e.length;if(n===0)throw new RangeError("Cannot pick from an empty array");const a=t==null?0:$h(Oh(t),n),o=i===void 0?n:$h(Oh(i),n);if(a>=o)throw new RangeError(`Cannot pick between bounds ${a} and ${o}`);const f=In(a,o-1);return e[f(r)]}function A7(r,e){return e===1?r:e===0?()=>0:t=>r(t)*e}function Ih(r){return wo(r)/Ir}function Rh(r){return iu(r)/Ir}function E7(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 dn(A7(t?Rh:Ih,e-r),r)}const S7=Array.prototype.slice;function uu(r,e,t=0){const i=e.length;if(i)for(let n=i-1>>>0;n>t;--n){const o=In(0,n)(r);if(n!==o){const f=e[n];e[n]=e[o],e[o]=f}}return e}function C7(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 i=S7.call(e),n=i.length;if(n===t)return uu(r,i,0);const a=n-t;return uu(r,i,a-1).slice(a)}const M7=(()=>{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 ya(r,e){return M7("0",e-r.length)+r}function F7(r){const e=r.next()>>>0,t=r.next()|0,i=r.next()|0,n=r.next()>>>0;return ya(e.toString(16),8)+"-"+ya((t&65535).toString(16),4)+"-"+ya((t>>4&4095|16384).toString(16),4)+"-"+ya((i&16383|32768).toString(16),4)+"-"+ya((i>>4&65535).toString(16),4)+ya(n.toString(16),8)}const No={next(){return Math.random()*mt|0}};class T7{constructor(e=No){this.engine=e}int32(){return nu(this.engine)}uint32(){return Ch(this.engine)}uint53(){return wo(this.engine)}uint53Full(){return iu(this.engine)}int53(){return au(this.engine)}int53Full(){return Sh(this.engine)}integer(e,t){return In(e,t)(this.engine)}realZeroToOneInclusive(){return Rh(this.engine)}realZeroToOneExclusive(){return Ih(this.engine)}real(e,t,i=!1){return E7(e,t,i)(this.engine)}bool(e,t){return h7(e,t)(this.engine)}pick(e,t,i){return D7(this.engine,e,t,i)}shuffle(e){return uu(this.engine,e)}sample(e,t){return C7(this.engine,e,t)}die(e){return Th(e)(this.engine)}dice(e,t){return y7(e,t)(this.engine)}uuid4(){return F7(this.engine)}string(e,t){return su(t)(this.engine,e)}hex(e,t){return N7(t)(this.engine,e)}date(e,t){return g7(e,t)(this.engine)}}(()=>{try{const r=new ArrayBuffer(4),e=new Int32Array(r);if(e[0]=xo,e[0]===-xo)return Int32Array}catch{}return Array})(),(()=>{try{if(Math.imul(bo,5)===-5)return Math.imul}catch{}const r=65535;return(e,t)=>{const i=e>>>16&r,n=e&r,a=t>>>16&r,o=t&r;return n*o+(i*o+n*a<<16>>>0)|0}})();const Ka=Symbol("engine"),lu=Symbol("random"),_h={min:{next(){return 0}},max:{range:[],next(){return this.range[1]-this.range[0]}}};class B7{constructor(e=No){this.engine=e||No}get engine(){return this[Ka]}set engine(e){if(e&&typeof e.next!="function")throw new TypeError("engine must have function `next()`");this[Ka]=e||No,this[lu]=new T7(this[Ka])}integer(e,t){return this[Ka].range=[e,t],this[lu].integer(e,t)}real(e,t,i=!1){return this[Ka].range=[e,t],this[lu].real(e,t,i)}}const ba=new B7,qh=Symbol("text"),zh=Symbol("type");class zt{static types={MULTILINE:"multiline",INLINE:"inline"};constructor(e,t=this.constructor.types.INLINE){this.text=e,this.type=t}get text(){return this[qh]}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[qh]=`${e}`.trim()}get type(){return this[zh]}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[zh]=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}]`}}const Do=Symbol("description");class Ph{constructor(e=null){this.description=e}get description(){return this[Do]||null}set description(e){if(!e&&e!==0)this[Do]=null;else if(e instanceof zt)this[Do]=e;else if(typeof e=="string")this[Do]=new zt(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 hn{static order=999;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,i])=>{typeof this[t]>"u"&&(this[t]=i)})}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}}const $7={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"},Lh=(...r)=>[...r].reduce((e,t)=>{let i;return t instanceof hn?i=t.name:i=t,e+($7[i]||i)},""),cu=Symbol("calculation-value"),fu=Symbol("modifiers"),ja=Symbol("initial-value"),Uh=Symbol("use-in-total"),mu=Symbol("value");class Ao{constructor(e,t=[],i=!0){if(Cr(e))this[ja]=Number(e),this.modifiers=t||[],this.useInTotal=i;else if(e&&typeof e=="object"&&!Array.isArray(e)){const n=Cr(e.initialValue)?e.initialValue:e.value;if(!Cr(n))throw new TypeError(`Result value is invalid: ${n}`);this[ja]=Number(n),Cr(e.value)&&Number(e.value)!==this[ja]&&(this.value=e.value),Cr(e.calculationValue)&&parseFloat(`${e.calculationValue}`)!==this.value&&(this.calculationValue=e.calculationValue),this.modifiers=e.modifiers||t||[],this.useInTotal=typeof e.useInTotal=="boolean"?e.useInTotal:i||!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 Cr(this[cu])?parseFloat(this[cu]):this.value}set calculationValue(e){const t=Cr(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[cu]=t?parseFloat(`${e}`):null}get initialValue(){return this[ja]}get modifierFlags(){return Lh(...this.modifiers)}get modifiers(){return this[fu]}set modifiers(e){if((Array.isArray(e)||e instanceof Set)&&[...e].every(t=>typeof t=="string")){this[fu]=new Set([...e]);return}if(!e&&e!==0){this[fu]=new Set;return}throw new TypeError(`modifiers must be a Set or array of modifier names: ${e}`)}get useInTotal(){return!!this[Uh]}set useInTotal(e){this[Uh]=!!e}get value(){return Cr(this[mu])?this[mu]:this[ja]}set value(e){if(e===1/0)throw new RangeError("Result value must be a finite number");if(!Cr(e))throw new TypeError(`Result value is invalid: ${e}`);this[mu]=Number(e)}toJSON(){const{calculationValue:e,initialValue:t,modifierFlags:i,modifiers:n,useInTotal:a,value:o}=this;return{calculationValue:e,initialValue:t,modifierFlags:i,modifiers:[...n],type:"result",useInTotal:a,value:o}}toString(){return this.value+this.modifierFlags}}const vu=Symbol("rolls");class Qt{constructor(e=[]){this.rolls=e}get length(){return this.rolls.length||0}get rolls(){return[...this[vu]]}set rolls(e){if(!e||!Array.isArray(e))throw new TypeError(`rolls must be an array: ${e}`);this[vu]=[],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 Ao?e:new Ao(e);this[vu].push(t)}toJSON(){const{rolls:e,value:t}=this;return{rolls:e,type:"roll-results",value:t}}toString(){return`[${this.rolls.join(", ")}]`}}const pu=Symbol("modifiers"),kh=Symbol("qty"),Vh=Symbol("sides"),Gh=Symbol("min-value"),Hh=Symbol("max-value");class xa extends Ph{constructor(e,t=1,i=null,n=1,a=null,o=null){if(super(o),!e&&e!==0)throw new qt("sides");if(e===1/0)throw new RangeError("numerical sides must be finite number");if(Cr(e)){if(e<1||!tu(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(Cr(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(Cr(f)){if(!tu(f))throw new RangeError("min must a finite number")}else throw new TypeError("min must a finite number");if(a&&!Cr(a))throw new TypeError("max must a finite number");if(a&&!tu(a))throw new RangeError("max must a finite number");this[kh]=parseInt(`${t}`,10),this[Vh]=e,i&&(this.modifiers=i),this[Gh]=parseInt(f,10),this[Hh]=a?parseInt(`${a}`,10):e}get average(){return(this.min+this.max)/2}get modifiers(){return this[pu]?new Map([...this[pu]].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(i=>[i.name,i]));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(i=>!(i[1]instanceof hn)))throw new TypeError("modifiers must only contain Modifier instances");this[pu]=t}get max(){return this[Hh]}get min(){return this[Gh]}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,i)=>t+i.notation,"")),e}get qty(){return this[kh]}get sides(){return this[Vh]}roll(){const e=new Qt;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 Ao(ba.integer(this.min,this.max))}toJSON(){const{average:e,max:t,min:i,modifiers:n,name:a,notation:o,qty:f,sides:l}=this;return Object.assign(super.toJSON(),{average:e,max:t,min:i,modifiers:n,name:a,notation:o,qty:f,sides:l,type:"die"})}toString(){return`${this.notation}${this.description?` ${this.description}`:""}`}}class O7 extends xa{constructor(e=2,t=1,i=null,n=null){let a=e;if(!a&&a!==0)a=2;else if(a!==1&&a!==2)throw new RangeError("nonBlanks must be 1 or 2");super(a,t,i,-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=ba.integer(1,3)-2;else if(this.nonBlanks===1){const t=ba.integer(1,6);t===1?e=-1:t===6&&(e=1)}return new Ao(e)}}class I7 extends xa{constructor(e=1,t=null,i=!1,n=null){super(100,e,t,null,null,n),this.sidesAsNumber=!!i}get name(){return"percentile"}get sides(){return this.sidesAsNumber?super.sides:"%"}}const Zh=Symbol("operator"),Jh=Symbol("value");class Eo{constructor(e,t){if(e){if(!t&&t!==0)throw new qt("value")}else throw new qt("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 eu(e);this[Zh]=e}get operator(){return this[Zh]}set value(e){if(!Cr(e))throw new TypeError("value must be a finite number");this[Jh]=Number(e)}get value(){return this[Jh]}isMatch(e){return a7(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 Xh=Symbol("compare-point");class wa extends hn{constructor(e){super(),e&&(this.comparePoint=e)}get comparePoint(){return this[Xh]}set comparePoint(e){if(!(e instanceof Eo))throw new TypeError("comparePoint must be instance of ComparePoint");this[Xh]=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 Eo(...t)}:{}}isComparePoint(e){return this.comparePoint?this.comparePoint.isMatch(e):!1}toJSON(){const{comparePoint:e}=this;return Object.assign(super.toJSON(),{comparePoint:e})}}class R7 extends wa{static order=10;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(i=>(this.isComparePoint(i.value)&&i.modifiers.add("critical-failure"),i)),e}}class _7 extends wa{static order=9;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(i=>(this.isComparePoint(i.value)&&i.modifiers.add("critical-success"),i)),e}}const du=Symbol("calculation-value"),Wh=Symbol("is-roll-group"),hu=Symbol("modifiers"),gu=Symbol("results"),Yh=Symbol("use-in-total");class kr{constructor(e=[],t=[],i=!1,n=!0){this.isRollGroup=i,this.modifiers=t,this.results=e,this.useInTotal=n}get calculationValue(){return Cr(this[du])?parseFloat(this[du]):this.value}set calculationValue(e){const t=Cr(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[du]=t?parseFloat(`${e}`):null}get isRollGroup(){return this[Wh]}set isRollGroup(e){this[Wh]=!!e}get length(){return this.results.length||0}get modifierFlags(){return Lh(...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]);else if(!e&&e!==0)this[hu]=new Set;else throw new TypeError(`modifiers must be a Set or array of modifier names: ${e}`)}get results(){return[...this[gu]]}set results(e){if(!e||!Array.isArray(e))throw new TypeError(`results must be an array: ${e}`);this[gu]=[],e.forEach(t=>{this.addResult(t)})}get useInTotal(){return!!this[Yh]}set useInTotal(e){this[Yh]=!!e}get value(){if(!this.results.length)return 0;const e=this.results.reduce((t,i)=>{let n=i;return i instanceof kr?n=i.useInTotal?i.calculationValue:0:i instanceof Qt&&(n=i.value),t+n},typeof this.results[0]=="string"?"":0);return typeof e=="string"?Eh(e):e}addResult(e){let t;if(e instanceof kr||e instanceof Qt)t=e;else if(typeof e=="string"||Cr(e))t=e;else throw new TypeError("value must be one of ResultGroup, RollResults, string, or number");this[gu].push(t)}toJSON(){const{calculationValue:e,isRollGroup:t,modifierFlags:i,modifiers:n,results:a,useInTotal:o,value:f}=this;return{calculationValue:e,isRollGroup:t,modifierFlags:i,modifiers:[...n],results:a,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 Qh=Symbol("end"),Kh=Symbol("qty");class jh extends hn{static order=6;constructor(e="h",t=1){super(),this.end=e,this.qty=t}get end(){return this[Qh]}set end(e){if(e!=="h"&&e!=="l")throw new RangeError('End must be "h" or "l"');this[Qh]=e}get name(){return`keep-${this.end}`}get notation(){return`k${this.end}${this.qty}`}get qty(){return this[Kh]}set qty(e){if(e===1/0)throw new RangeError("qty must be a finite number");if(!Cr(e)||e<1)throw new TypeError("qty must be a positive finite integer");this[Kh]=Math.floor(e)}rangeToDrop(e){return this.end==="h"?[0,e.length-this.qty]:[this.qty,e.length]}run(e,t){let i,n;return e instanceof kr?(i=e.results,i.length===1&&i[0]instanceof kr?n=i[0].results.map((a,o)=>a instanceof Qt?a.rolls.map((f,l)=>({value:f.value,index:[o,l]})):null).flat().filter(Boolean):n=[...i].map((a,o)=>({value:a.value,index:o}))):(i=e.rolls,n=[...i].map((a,o)=>({value:a.value,index:o}))),n=n.sort((a,o)=>a.value-o.value).map(a=>a.index).slice(...this.rangeToDrop(n)),n.forEach(a=>{let o;Array.isArray(a)?o=i[0].results[a[0]].rolls[a[1]]:o=i[a],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 q7 extends jh{static order=7;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]}}const e0=Symbol("compound"),r0=Symbol("penetrate");class z7 extends wa{static order=3;constructor(e=null,t=!1,i=!1){super(e),this[e0]=!!t,this[r0]=!!i}get compound(){return this[e0]}get name(){return"explode"}get notation(){return`!${this.compound?"!":""}${this.penetrate?"p":""}${super.notation}`}get penetrate(){return this[r0]}defaultComparePoint(e){return["=",e.max]}run(e,t){if(super.run(e,t),t.min===t.max)throw new Wa(t,"explode");const i=e;return i.rolls=e.rolls.map(n=>{const a=[n];let o=n.value;for(let f=0;f<this.maxIterations&&this.isComparePoint(o);f++){const l=a[a.length-1],u=t.rollOnce();o=u.value,l.modifiers.add("explode"),this.penetrate&&(l.modifiers.add("penetrate"),u.value-=1),a.push(u)}return this.compound&&a.length>1?(n.value=i7(a.map(f=>f.value)),n.modifiers=["explode","compound"],this.penetrate&&n.modifiers.add("penetrate"),n):a}).flat(),i}toJSON(){const{compound:e,penetrate:t}=this;return Object.assign(super.toJSON(),{compound:e,penetrate:t})}}const t0=Symbol("max");class P7 extends hn{static order=2;constructor(e){super(),this.max=e}get max(){return this[t0]}set max(e){if(!Cr(e))throw new TypeError("max must be a number");this[t0]=parseFloat(`${e}`)}get name(){return"max"}get notation(){return`max${this.max}`}run(e,t){const i=e;return i.rolls=e.rolls.map(n=>{const a=n;return n.value>this.max&&(a.value=this.max,a.modifiers.add("max")),a}),i}toJSON(){const{max:e}=this;return Object.assign(super.toJSON(),{max:e})}}const n0=Symbol("min");class L7 extends hn{static order=1;constructor(e){super(),this.min=e}get min(){return this[n0]}set min(e){if(!Cr(e))throw new TypeError("min must be a number");this[n0]=parseFloat(`${e}`)}get name(){return"min"}get notation(){return`min${this.min}`}run(e,t){const i=e;return i.rolls=e.rolls.map(n=>{const a=n;return n.value<this.min&&(a.value=this.min,a.modifiers.add("min")),a}),i}toJSON(){const{min:e}=this;return Object.assign(super.toJSON(),{min:e})}}const a0=Symbol("once");class U7 extends wa{static order=4;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[a0]}set once(e){this[a0]=!!e}defaultComparePoint(e){return["=",e.min]}run(e,t){if(super.run(e,t),t.min===t.max)throw new Wa(t,"re-roll");return e.rolls.map(i=>{for(let n=0;n<this.maxIterations&&this.isComparePoint(i.value);n++){const a=t.rollOnce();if(i.value=a.value,i.modifiers.add(`re-roll${this.once?"-once":""}`),this.once)break}return i}),e}toJSON(){const{once:e}=this;return Object.assign(super.toJSON(),{once:e})}}const i0=Symbol("direction");class k7 extends hn{static order=11;constructor(e="a"){super(),this.direction=e}get direction(){return this[i0]}set direction(e){if(e!=="a"&&e!=="d")throw new RangeError('Direction must be "a" (Ascending) or "d" (Descending)');this[i0]=e}get name(){return"sorting"}get notation(){return`s${this.direction}`}run(e,t){let i;return e instanceof kr?i="results":i="rolls",e[i]=e[i].sort((n,a)=>this.direction==="d"?a.value-n.value:n.value-a.value),e instanceof kr&&(e[i]=e[i].map(n=>n instanceof kr||n instanceof Qt?this.run(n,t):n)),e}toJSON(){const{direction:e}=this;return Object.assign(super.toJSON(),{direction:e})}}const o0=Symbol("failure-cp");class V7 extends wa{static order=8;constructor(e,t=null){super(e),this.failureComparePoint=t}get failureComparePoint(){return this[o0]}set failureComparePoint(e){if(e&&!(e instanceof Eo))throw new TypeError("failure comparePoint must be instance of ComparePoint or null");this[o0]=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 i;return e instanceof kr?i=e.results:i=e.rolls,i.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,i=super.toJSON();return delete i.comparePoint,Object.assign(i,{failureComparePoint:e,successComparePoint:t})}}const s0=Symbol("once"),G7=(r,e,t,i=!1)=>{const n=t.map(a=>a.value).indexOf(r.value);return i?n<e:n!==e};class H7 extends wa{static order=5;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[s0]}set once(e){this[s0]=!!e}run(e,t){if(t.min===t.max)throw new Wa(t,"re-roll");return e.rolls.forEach((i,n,a)=>{if(n!==0)for(let o=0;o<this.maxIterations&&(!this.comparePoint||this.isComparePoint(i.value))&&G7(i,n,a,!0);o++){const f=t.rollOnce();if(i.value=f.value,i.modifiers.add(`unique${this.once?"-once":""}`),this.once)break}}),e}toJSON(){const{once:e}=this;return Object.assign(super.toJSON(),{once:e})}}const Z7=r=>{try{return!!(r&&btoa(atob(r))===r)}catch{return!1}},J7=r=>{try{const e=r?JSON.parse(r):!1;return!!(e&&typeof e=="object")}catch{return!1}},yu=Symbol("expressions"),bu=Symbol("modifiers");class u0 extends Ph{constructor(e=[],t=[],i=null){super(i),this.expressions=e,this.modifiers=t}get expressions(){return[...this[yu]||[]]}set expressions(e){if(!e)throw new qt("expressions");if(!Array.isArray(e))throw new TypeError(`expressions must be an array: ${e}`);this[yu]=[],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(i=>i instanceof xa||typeof i=="string"||typeof i=="number"))throw new TypeError("Sub expression items must be Dice, numbers, or strings");this[yu].push(t)})}get modifiers(){return this[bu]?new Map([...this[bu]].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(i=>[i.name,i]));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(i=>!(i[1]instanceof hn)))throw new TypeError("modifiers must only contain Modifier instances");this[bu]=t}get notation(){let e=this.expressions.map(t=>t.reduce((i,n)=>i+n,"")).join(", ");return e=`{${e}}`,this.modifiers&&this.modifiers.size&&(e+=[...this.modifiers.values()].reduce((t,i)=>t+i.notation,"")),e}roll(){const e=new kr(this.expressions.map(t=>{const i=t.map(n=>n instanceof xa?n.roll():n);return new kr(i)}));return e.isRollGroup=!0,(this.modifiers||[]).forEach(t=>{t.run(e,this)}),e}toJSON(){const{modifiers:e,notation:t,expressions:i}=this;return Object.assign(super.toJSON(),{expressions:i,modifiers:e,notation:t,type:"group"})}toString(){return`${this.notation}${this.description?` ${this.description}`:""}`}}function X7(r,e){function t(){this.constructor=r}t.prototype=e.prototype,r.prototype=new t}function Na(r,e,t,i){var n=Error.call(this,r);return Object.setPrototypeOf&&Object.setPrototypeOf(n,Na.prototype),n.expected=e,n.found=t,n.location=i,n.name="SyntaxError",n}X7(Na,Error);function xu(r,e,t){return t=t||" ",r.length>e?r:(e-=r.length,t+=t.repeat(e),r+t.slice(0,e))}Na.prototype.format=function(r){var e="Error: "+this.message;if(this.location){var t=null,i;for(i=0;i<r.length;i++)if(r[i].source===this.location.source){t=r[i].text.split(/\r\n|\n|\r/g);break}var n=this.location.start,a=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(n):n,o=this.location.source+":"+a.line+":"+a.column;if(t){var f=this.location.end,l=xu("",a.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
55
  --> `+o+`
80
56
  `+l+` |
81
- `+i.line+" | "+u+`
82
- `+l+" | "+Su("",n.column-1," ")+Su("",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 H7(r,e){e=e!==void 0?e:{};var t={},a=e.grammarSource,n={Main:q0},i=q0,o="{",f=",",l="}",u="d",s="d%",c="dF",m=".",v="!",d="p",p="k",g="max",y="min",N="r",h="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",U="floor",j="log",ae="round",re="sign",me="sin",he="sqrt",fe="tan",ie="pow",Ae="-",Oe="**",Ce="*",$e="^",V="%",W="/",se="+",G="/*",Y="*/",te="[",be="]",ve="//",z="#",L=/^[12]/,ee=/^[lh]/,le=/^[.]/,pe=/^[1-9]/,ge=/^[0-9]/,xe=/^[^\]]/,de=/^[\n\r\u2028\u2029]/,Ne=/^[ \t\n\r]/,_e=Le("{",!1),Ue=Le(",",!1),Be=Le("}",!1),ar=Le("d",!1),Je=Le("d%",!1),mr=Le("dF",!1),C=Le(".",!1),Z=Dn(["1","2"],!1,!1),ue=Le("!",!1),Ee=Le("p",!1),ze=Dn(["l","h"],!1,!1),ke=Le("k",!1),Fr=Le("max",!1),_r=Le("min",!1),tn=Le("r",!1),Un=Le("o",!1),kn=Le("u",!1),Ou=Le("cs",!1),Iu=Le("cf",!1),Ru=Le("s",!1),_u=Le("a",!1),qu=Le("f",!1),zu=Le("!=",!1),Pu=Le("<=",!1),Lu=Le(">=",!1),Uu=Le("=",!1),Vn=Le("<>",!1),ku=Le(">",!1),Vu=Le("<",!1),Oa=Le("(",!1),Ia=Le(")",!1),Gu=Le("abs",!1),Hu=Le("ceil",!1),Zu=Le("cos",!1),Ju=Le("exp",!1),Wu=Le("floor",!1),Xu=Le("log",!1),Yu=Le("round",!1),Qu=Le("sign",!1),Ku=Le("sin",!1),ju=Le("sqrt",!1),el=Le("tan",!1),rl=Le("pow",!1),Fo=Le("-",!1),Gn=Dn(["."],!1,!1),jr=Dn([["1","9"]],!1,!1),Tr=Dn([["0","9"]],!1,!1),To=Le("**",!1),tl=Le("*",!1),Ra=Le("^",!1),_a=Le("%",!1),Bo=Le("/",!1),$o=Le("+",!1),Nn=il("comment"),$9=Le("/*",!1),nl=Le("*/",!1),Oo=gI(),O9=Le("[",!1),I0=Dn(["]"],!0,!1),I9=Le("]",!1),R9=Le("//",!1),_9=Le("#",!1),q9=Dn([`
84
- `,"\r","\u2028","\u2029"],!1,!1),z9=il("whitespace"),P9=Dn([" "," ",`
85
- `,"\r"],!1,!1),L9=il("whitespace or comment"),U9=function(O,X,ne,ce){return new D0([O,...X.map(Se=>Se[3])],Object.assign({},...ne.map(Se=>({[Se.name]:Se}))),ce.find(Se=>Se instanceof Ct))},k9=function(O,X,ne){return O.modifiers=Object.assign({},...X.map(ce=>({[ce.name]:ce}))),O.description=ne.find(ce=>ce instanceof Ct),O},V9=function(O,X){return new Ca(X,O||1)},G9=function(O){return new L7(O||1)},H9=function(O,X){return new P7(X?parseInt(X[1],10):2,O||1)},Z9=function(O,X,ne){return new c0(ne,!!O,!!X)},J9=function(O,X){return new x0(O,X)},W9=function(O,X){return new s0(O||"l",X)},X9=function(O,X){return new Du(O||"h",X)},Y9=function(O){return new m0(O)},Q9=function(O){return new p0(O)},K9=function(O,X){return new h0(!!O,X)},j9=function(O,X){return new N0(!!O,X)},eI=function(O){return new t0(O)},rI=function(O){return new r0(O)},tI=function(O){return new y0(O||"a")},nI=function(O){return O},aI=function(O,X){return new Eo(O,X)},iI=function(O,X,ne){return Mh(_o())},oI=function(O,X){return O=Array.isArray(O)?O:[O],[...O,...X.map(([,ne,,ce])=>[ne,ce]).flat(2)]},sI=function(O,X,ne){return[O,...X,ne]},uI=function(O,X){return[`${O}(`,...X,")"]},lI=function(O,X,ne){return[`${O}(`,...X,",",...ne,")"]},cI=function(){return parseFloat(_o())},fI=function(){return parseInt(_o(),10)},mI=function(){return parseInt(_o(),10)},vI=function(){return"^"},pI=function(O){return new Ct(O.flat().join(""),Ct.types.MULTILINE)},dI=function(O){return new Ct(O.flat().join(""),Ct.types.MULTILINE)},hI=function(O){return new Ct(O.flat().join(""),Ct.types.INLINE)},_=0,lr=0,Io=[{line:1,column:1}],Ut=0,al=[],De=0,Ro;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 _o(){return r.substring(lr,_)}function Le(O,X){return{type:"literal",text:O,ignoreCase:X}}function Dn(O,X,ne){return{type:"class",parts:O,inverted:X,ignoreCase:ne}}function gI(){return{type:"any"}}function yI(){return{type:"end"}}function il(O){return{type:"other",description:O}}function R0(O){var X=Io[O],ne;if(X)return X;for(ne=O-1;!Io[ne];)ne--;for(X=Io[ne],X={line:X.line,column:X.column};ne<O;)r.charCodeAt(ne)===10?(X.line++,X.column=1):X.column++,ne++;return Io[O]=X,X}function _0(O,X,ne){var ce=R0(O),Se=R0(X),Ie={source:a,start:{offset:O,line:ce.line,column:ce.column},end:{offset:X,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=_,al=[]),al.push(O))}function bI(O,X,ne){return new Fa(Fa.buildMessage(O,X),O,X,ne)}function q0(){var O;return O=An(),O}function xI(){var O,X,ne,ce,Se,Ie,dr,Er,Mt;if(O=_,r.charCodeAt(_)===123?(X=o,_++):(X=t,De===0&&Fe(_e)),X!==t)if(Ar(),ne=An(),ne!==t){for(ce=[],Se=_,Ie=Ar(),r.charCodeAt(_)===44?(dr=f,_++):(dr=t,De===0&&Fe(Ue)),dr!==t?(Er=Ar(),Mt=An(),Mt!==t?(Ie=[Ie,dr,Er,Mt],Se=Ie):(_=Se,Se=t)):(_=Se,Se=t);Se!==t;)ce.push(Se),Se=_,Ie=Ar(),r.charCodeAt(_)===44?(dr=f,_++):(dr=t,De===0&&Fe(Ue)),dr!==t?(Er=Ar(),Mt=An(),Mt!==t?(Ie=[Ie,dr,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(dr=[],Er=qo();Er!==t;)dr.push(Er),Er=qo();Er=U0(),lr=O,O=U9(ne,ce,dr,Er)}else _=O,O=t}else _=O,O=t;else _=O,O=t;return O}function wI(){var O,X,ne,ce;if(O=_,X=NI(),X===t&&(X=DI(),X===t&&(X=AI())),X!==t){for(ne=[],ce=qo();ce!==t;)ne.push(ce),ce=qo();ce=U0(),lr=O,O=k9(X,ne,ce)}else _=O,O=t;return O}function NI(){var O,X,ne,ce;return O=_,X=zo(),X===t&&(X=null),r.charCodeAt(_)===100?(ne=u,_++):(ne=t,De===0&&Fe(ar)),ne!==t?(ce=zo(),ce!==t?(lr=O,O=V9(X,ce)):(_=O,O=t)):(_=O,O=t),O}function DI(){var O,X,ne;return O=_,X=zo(),X===t&&(X=null),r.substr(_,2)===s?(ne=s,_+=2):(ne=t,De===0&&Fe(Je)),ne!==t?(lr=O,O=G9(X)):(_=O,O=t),O}function AI(){var O,X,ne,ce,Se,Ie;return O=_,X=zo(),X===t&&(X=null),r.substr(_,2)===c?(ne=c,_+=2):(ne=t,De===0&&Fe(mr)),ne!==t?(ce=_,r.charCodeAt(_)===46?(Se=m,_++):(Se=t,De===0&&Fe(C)),Se!==t?(L.test(r.charAt(_))?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe(Z)),Ie!==t?(Se=[Se,Ie],ce=Se):(_=ce,ce=t)):(_=ce,ce=t),ce===t&&(ce=null),lr=O,O=H9(X,ce)):(_=O,O=t),O}function qo(){var O;return O=EI(),O===t&&(O=SI(),O===t&&(O=CI(),O===t&&(O=MI(),O===t&&(O=BI(),O===t&&(O=$I(),O===t&&(O=OI(),O===t&&(O=II(),O===t&&(O=RI(),O===t&&(O=FI(),O===t&&(O=TI())))))))))),O}function EI(){var O,X,ne,ce,Se;return O=_,r.charCodeAt(_)===33?(X=v,_++):(X=t,De===0&&Fe(ue)),X!==t?(r.charCodeAt(_)===33?(ne=v,_++):(ne=t,De===0&&Fe(ue)),ne===t&&(ne=null),r.charCodeAt(_)===112?(ce=d,_++):(ce=t,De===0&&Fe(Ee)),ce===t&&(ce=null),Se=Hn(),Se===t&&(Se=null),lr=O,O=Z9(ne,ce,Se)):(_=O,O=t),O}function SI(){var O,X,ne;return O=_,X=Hn(),X!==t?(ne=_I(),ne===t&&(ne=null),lr=O,O=J9(X,ne)):(_=O,O=t),O}function CI(){var O,X,ne,ce;return O=_,r.charCodeAt(_)===100?(X=u,_++):(X=t,De===0&&Fe(ar)),X!==t?(ee.test(r.charAt(_))?(ne=r.charAt(_),_++):(ne=t,De===0&&Fe(ze)),ne===t&&(ne=null),ce=sl(),ce!==t?(lr=O,O=W9(ne,ce)):(_=O,O=t)):(_=O,O=t),O}function MI(){var O,X,ne,ce;return O=_,r.charCodeAt(_)===107?(X=p,_++):(X=t,De===0&&Fe(ke)),X!==t?(ee.test(r.charAt(_))?(ne=r.charAt(_),_++):(ne=t,De===0&&Fe(ze)),ne===t&&(ne=null),ce=sl(),ce!==t?(lr=O,O=X9(ne,ce)):(_=O,O=t)):(_=O,O=t),O}function FI(){var O,X,ne;return O=_,r.substr(_,3)===g?(X=g,_+=3):(X=t,De===0&&Fe(Fr)),X!==t?(ne=Zn(),ne!==t?(lr=O,O=Y9(ne)):(_=O,O=t)):(_=O,O=t),O}function TI(){var O,X,ne;return O=_,r.substr(_,3)===y?(X=y,_+=3):(X=t,De===0&&Fe(_r)),X!==t?(ne=Zn(),ne!==t?(lr=O,O=Q9(ne)):(_=O,O=t)):(_=O,O=t),O}function BI(){var O,X,ne,ce;return O=_,r.charCodeAt(_)===114?(X=N,_++):(X=t,De===0&&Fe(tn)),X!==t?(r.charCodeAt(_)===111?(ne=h,_++):(ne=t,De===0&&Fe(Un)),ne===t&&(ne=null),ce=Hn(),ce===t&&(ce=null),lr=O,O=K9(ne,ce)):(_=O,O=t),O}function $I(){var O,X,ne,ce;return O=_,r.charCodeAt(_)===117?(X=w,_++):(X=t,De===0&&Fe(kn)),X!==t?(r.charCodeAt(_)===111?(ne=h,_++):(ne=t,De===0&&Fe(Un)),ne===t&&(ne=null),ce=Hn(),ce===t&&(ce=null),lr=O,O=j9(ne,ce)):(_=O,O=t),O}function OI(){var O,X,ne;return O=_,r.substr(_,2)===x?(X=x,_+=2):(X=t,De===0&&Fe(Ou)),X!==t?(ne=Hn(),ne===t&&(ne=null),lr=O,O=eI(ne)):(_=O,O=t),O}function II(){var O,X,ne;return O=_,r.substr(_,2)===b?(X=b,_+=2):(X=t,De===0&&Fe(Iu)),X!==t?(ne=Hn(),ne===t&&(ne=null),lr=O,O=rI(ne)):(_=O,O=t),O}function RI(){var O,X,ne;return O=_,r.charCodeAt(_)===115?(X=E,_++):(X=t,De===0&&Fe(Ru)),X!==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=tI(ne)):(_=O,O=t),O}function _I(){var O,X,ne;return O=_,r.charCodeAt(_)===102?(X=S,_++):(X=t,De===0&&Fe(qu)),X!==t?(ne=Hn(),ne!==t?(lr=O,O=nI(ne)):(_=O,O=t)):(_=O,O=t),O}function Hn(){var O,X,ne;return O=_,X=qI(),X!==t?(ne=Zn(),ne!==t?(lr=O,O=aI(X,ne)):(_=O,O=t)):(_=O,O=t),O}function qI(){var O;return r.substr(_,2)===D?(O=D,_+=2):(O=t,De===0&&Fe(zu)),O===t&&(r.substr(_,2)===T?(O=T,_+=2):(O=t,De===0&&Fe(Pu)),O===t&&(r.substr(_,2)===B?(O=B,_+=2):(O=t,De===0&&Fe(Lu)),O===t&&(r.charCodeAt(_)===61?(O=I,_++):(O=t,De===0&&Fe(Uu)),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(ku)),O===t&&(r.charCodeAt(_)===60?(O=M,_++):(O=t,De===0&&Fe(Vu)))))))),O}function zo(){var O,X,ne,ce,Se,Ie,dr,Er,Mt,qa;if(O=sl(),O===t)if(O=_,r.charCodeAt(_)===40?(X=F,_++):(X=t,De===0&&Fe(Oa)),X!==t){if(Ar(),ne=_,ce=Zn(),ce!==t){if(Se=[],Ie=_,dr=Ar(),Er=Po(),Er!==t?(Mt=Ar(),qa=Zn(),qa!==t?(dr=[dr,Er,Mt,qa],Ie=dr):(_=Ie,Ie=t)):(_=Ie,Ie=t),Ie!==t)for(;Ie!==t;)Se.push(Ie),Ie=_,dr=Ar(),Er=Po(),Er!==t?(Mt=Ar(),qa=Zn(),qa!==t?(dr=[dr,Er,Mt,qa],Ie=dr):(_=Ie,Ie=t)):(_=Ie,Ie=t);else Se=t;Se!==t?(ce=[ce,Se],ne=ce):(_=ne,ne=t)}else _=ne,ne=t;ne!==t?(ce=Ar(),r.charCodeAt(_)===41?(Se=H,_++):(Se=t,De===0&&Fe(Ia)),Se!==t?(lr=O,O=iI()):(_=O,O=t)):(_=O,O=t)}else _=O,O=t;return O}function An(){var O,X,ne,ce,Se,Ie,dr,Er;if(O=_,X=ol(),X!==t){for(ne=[],ce=_,Se=Ar(),Ie=Po(),Ie!==t?(dr=Ar(),Er=ol(),Er!==t?(Se=[Se,Ie,dr,Er],ce=Se):(_=ce,ce=t)):(_=ce,ce=t);ce!==t;)ne.push(ce),ce=_,Se=Ar(),Ie=Po(),Ie!==t?(dr=Ar(),Er=ol(),Er!==t?(Se=[Se,Ie,dr,Er],ce=Se):(_=ce,ce=t)):(_=ce,ce=t);lr=O,O=oI(X,ne)}else _=O,O=t;return O}function ol(){var O,X,ne,ce;return O=zI(),O===t&&(O=wI(),O===t&&(O=Zn(),O===t&&(O=_,r.charCodeAt(_)===40?(X=F,_++):(X=t,De===0&&Fe(Oa)),X!==t?(Ar(),ne=An(),ne!==t?(Ar(),r.charCodeAt(_)===41?(ce=H,_++):(ce=t,De===0&&Fe(Ia)),ce!==t?(lr=O,O=sI(X,ne,ce)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t),O===t&&(O=xI())))),O}function zI(){var O,X,ne,ce,Se,Ie,dr;return O=_,r.substr(_,3)===$?(X=$,_+=3):(X=t,De===0&&Fe(Gu)),X===t&&(r.substr(_,4)===k?(X=k,_+=4):(X=t,De===0&&Fe(Hu)),X===t&&(r.substr(_,3)===Q?(X=Q,_+=3):(X=t,De===0&&Fe(Zu)),X===t&&(r.substr(_,3)===K?(X=K,_+=3):(X=t,De===0&&Fe(Ju)),X===t&&(r.substr(_,5)===U?(X=U,_+=5):(X=t,De===0&&Fe(Wu)),X===t&&(r.substr(_,3)===j?(X=j,_+=3):(X=t,De===0&&Fe(Xu)),X===t&&(r.substr(_,5)===ae?(X=ae,_+=5):(X=t,De===0&&Fe(Yu)),X===t&&(r.substr(_,4)===re?(X=re,_+=4):(X=t,De===0&&Fe(Qu)),X===t&&(r.substr(_,3)===me?(X=me,_+=3):(X=t,De===0&&Fe(Ku)),X===t&&(r.substr(_,4)===he?(X=he,_+=4):(X=t,De===0&&Fe(ju)),X===t&&(r.substr(_,3)===fe?(X=fe,_+=3):(X=t,De===0&&Fe(el)))))))))))),X!==t?(r.charCodeAt(_)===40?(ne=F,_++):(ne=t,De===0&&Fe(Oa)),ne!==t?(Ar(),ce=An(),ce!==t?(Ar(),r.charCodeAt(_)===41?(Se=H,_++):(Se=t,De===0&&Fe(Ia)),Se!==t?(lr=O,O=uI(X,ce)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t),O===t&&(O=_,r.substr(_,3)===ie?(X=ie,_+=3):(X=t,De===0&&Fe(rl)),X===t&&(r.substr(_,3)===g?(X=g,_+=3):(X=t,De===0&&Fe(Fr)),X===t&&(r.substr(_,3)===y?(X=y,_+=3):(X=t,De===0&&Fe(_r)))),X!==t?(r.charCodeAt(_)===40?(ne=F,_++):(ne=t,De===0&&Fe(Oa)),ne!==t?(Ar(),ce=An(),ce!==t?(Ar(),r.charCodeAt(_)===44?(Se=f,_++):(Se=t,De===0&&Fe(Ue)),Se!==t?(Ar(),Ie=An(),Ie!==t?(Ar(),r.charCodeAt(_)===41?(dr=H,_++):(dr=t,De===0&&Fe(Ia)),dr!==t?(lr=O,O=lI(X,ce,Ie)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)),O}function Zn(){var O,X,ne,ce,Se;return O=_,r.charCodeAt(_)===45?_++:De===0&&Fe(Fo),X=z0(),X!==t?(ne=_,le.test(r.charAt(_))?(ce=r.charAt(_),_++):(ce=t,De===0&&Fe(Gn)),ce!==t?(Se=z0(),Se!==t?(ce=[ce,Se],ne=ce):(_=ne,ne=t)):(_=ne,ne=t),ne===t&&(ne=null),lr=O,O=cI()):(_=O,O=t),O}function sl(){var O,X,ne,ce;if(O=_,pe.test(r.charAt(_))?(X=r.charAt(_),_++):(X=t,De===0&&Fe(jr)),X!==t){for(ne=[],ge.test(r.charAt(_))?(ce=r.charAt(_),_++):(ce=t,De===0&&Fe(Tr));ce!==t;)ne.push(ce),ge.test(r.charAt(_))?(ce=r.charAt(_),_++):(ce=t,De===0&&Fe(Tr));lr=O,O=fI()}else _=O,O=t;return O}function z0(){var O,X,ne;if(O=_,X=[],ge.test(r.charAt(_))?(ne=r.charAt(_),_++):(ne=t,De===0&&Fe(Tr)),ne!==t)for(;ne!==t;)X.push(ne),ge.test(r.charAt(_))?(ne=r.charAt(_),_++):(ne=t,De===0&&Fe(Tr));else X=t;return X!==t&&(lr=O,X=mI()),O=X,O}function Po(){var O,X;return O=_,r.substr(_,2)===Oe?(X=Oe,_+=2):(X=t,De===0&&Fe(To)),X!==t&&(lr=O,X=vI()),O=X,O===t&&(r.charCodeAt(_)===42?(O=Ce,_++):(O=t,De===0&&Fe(tl)),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=W,_++):(O=t,De===0&&Fe(Bo)),O===t&&(r.charCodeAt(_)===43?(O=se,_++):(O=t,De===0&&Fe($o)),O===t&&(r.charCodeAt(_)===45?(O=Ae,_++):(O=t,De===0&&Fe(Fo)))))))),O}function P0(){var O;return De++,O=PI(),O===t&&(O=LI()),De--,O===t&&De===0&&Fe(Nn),O}function PI(){var O,X,ne,ce,Se,Ie;if(O=_,r.substr(_,2)===G?(X=G,_+=2):(X=t,De===0&&Fe($9)),X!==t){for(ne=[],ce=_,Se=_,De++,r.substr(_,2)===Y?(Ie=Y,_+=2):(Ie=t,De===0&&Fe(nl)),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe(Oo)),Ie!==t?(Se=[Se,Ie],ce=Se):(_=ce,ce=t)):(_=ce,ce=t);ce!==t;)ne.push(ce),ce=_,Se=_,De++,r.substr(_,2)===Y?(Ie=Y,_+=2):(Ie=t,De===0&&Fe(nl)),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe(Oo)),Ie!==t?(Se=[Se,Ie],ce=Se):(_=ce,ce=t)):(_=ce,ce=t);r.substr(_,2)===Y?(ce=Y,_+=2):(ce=t,De===0&&Fe(nl)),ce!==t?(lr=O,O=pI(ne)):(_=O,O=t)}else _=O,O=t;if(O===t)if(O=_,r.charCodeAt(_)===91?(X=te,_++):(X=t,De===0&&Fe(O9)),X!==t){for(ne=[],xe.test(r.charAt(_))?(ce=r.charAt(_),_++):(ce=t,De===0&&Fe(I0));ce!==t;)ne.push(ce),xe.test(r.charAt(_))?(ce=r.charAt(_),_++):(ce=t,De===0&&Fe(I0));r.charCodeAt(_)===93?(ce=be,_++):(ce=t,De===0&&Fe(I9)),ce!==t?(lr=O,O=dI(ne)):(_=O,O=t)}else _=O,O=t;return O}function LI(){var O,X,ne,ce,Se,Ie;if(O=_,r.substr(_,2)===ve?(X=ve,_+=2):(X=t,De===0&&Fe(R9)),X===t&&(r.charCodeAt(_)===35?(X=z,_++):(X=t,De===0&&Fe(_9))),X!==t){for(ne=[],ce=_,Se=_,De++,Ie=L0(),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe(Oo)),Ie!==t?(Se=[Se,Ie],ce=Se):(_=ce,ce=t)):(_=ce,ce=t);ce!==t;)ne.push(ce),ce=_,Se=_,De++,Ie=L0(),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe(Oo)),Ie!==t?(Se=[Se,Ie],ce=Se):(_=ce,ce=t)):(_=ce,ce=t);lr=O,O=hI(ne)}else _=O,O=t;return O}function L0(){var O;return de.test(r.charAt(_))?(O=r.charAt(_),_++):(O=t,De===0&&Fe(q9)),O}function Lo(){var O;return De++,Ne.test(r.charAt(_))?(O=r.charAt(_),_++):(O=t,De===0&&Fe(P9)),De--,O===t&&De===0&&Fe(z9),O}function Ar(){var O,X;for(O=[],X=Lo();X!==t;)O.push(X),X=Lo();return O}function U0(){var O,X;for(De++,O=[],X=Lo(),X===t&&(X=P0());X!==t;)O.push(X),X=Lo(),X===t&&(X=P0());return De--,X=t,De===0&&Fe(L9),O}if(Ro=i(),Ro!==t&&_===r.length)return Ro;throw Ro!==t&&_<r.length&&Fe(yI()),bI(al,Ut<r.length?r.charAt(Ut):null,Ut<r.length?_0(Ut,Ut+1):_0(Ut,Ut))}class A0{static parse(e){if(!e)throw new Pt("notation");if(typeof e!="string")throw new TypeError("Notation must be a string");return H7(e)}}const Ta=Object.freeze({BASE_64:1,JSON:0,OBJECT:2}),Cu=Symbol("notation"),Mu=Symbol("maxTotal"),Fu=Symbol("minTotal"),Ba=Symbol("expressions"),So=Symbol("roll-method"),wn=Symbol("rolls"),E0=Symbol("set-rolls"),Co=Symbol("total"),Tu=r=>s7(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 bo(e.notation);e.rolls&&this[E0](e.rolls)}else throw new Pt("notation");this[Cu]=e.notation,this[Ba]=A0.parse(this.notation),this.hasRolls()||this.roll()}else if(typeof e=="string")this[Cu]=e,this[Ba]=A0.parse(this.notation),this.roll();else throw new bo(e)}get averageTotal(){return(this.maxTotal+this.minTotal)/2}get maxTotal(){if(!this.hasExpressions())return 0;if(!this[Mu]){const e=this[So](kh.max);this[Mu]=Tu(e)}return this[Mu]}get minTotal(){if(!this.hasExpressions())return 0;if(!this[Fu]){const e=this[So](kh.min);this[Fu]=Tu(e)}return this[Fu]}get notation(){return this[Cu]}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[Co]&&this.hasRolls()&&(this[Co]=Tu(this[wn])),this[Co]||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[Co]=0,this[wn]=this[So](),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(V7(e))return si.import(JSON.parse(e));if(k7(e))return si.import(atob(e));if(typeof e=="object")return new si(e);throw new Qs(e)}else throw new Pt("data")}[So](e){let t;e&&(t=Sa.engine,Sa.engine=e);const a=new kr(this[Ba].map(n=>n instanceof Ca||n instanceof D0?n.roll():n).filter(n=>!!n||n===0));return e&&(Sa.engine=t),a}[E0](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")}}function Z7(r,e){return oe.getCurrentScope()?(oe.onScopeDispose(r,e),!0):!1}const ui=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const J7=Object.prototype.toString,W7=r=>J7.call(r)==="[object Object]";function X7(r){let e;function t(){return e||(e=r()),e}return t.reset=async()=>{const a=e;e=void 0,a&&await a},t}function Bu(r){return Array.isArray(r)?r:[r]}function Y7(r,e,t={}){const{immediate:a=!0,immediateCallback:n=!1}=t,i=oe.shallowRef(!1);let o;function f(){o&&(clearTimeout(o),o=void 0)}function l(){i.value=!1,f()}function u(...s){n&&r(),f(),i.value=!0,o=setTimeout(()=>{i.value=!1,o=void 0,r(...s)},oe.toValue(e))}return a&&(i.value=!0,ui&&u()),Z7(l),{isPending:oe.shallowReadonly(i),start:u,stop:l}}function Q7(r,e,t){return oe.watch(r,e,{...t,immediate:!0})}const K7=ui?window:void 0;ui&&window.document;const S0=ui?window.navigator:void 0;ui&&window.location;function j7(r){var e;const t=oe.toValue(r);return(e=t==null?void 0:t.$el)!==null&&e!==void 0?e:t}function C0(...r){const e=(a,n,i,o)=>(a.addEventListener(n,i,o),()=>a.removeEventListener(n,i,o)),t=oe.computed(()=>{const a=Bu(oe.toValue(r[0])).filter(n=>n!=null);return a.every(n=>typeof n!="string")?a:void 0});return Q7(()=>{var a,n;return[(a=(n=t.value)===null||n===void 0?void 0:n.map(i=>j7(i)))!==null&&a!==void 0?a:[K7].filter(i=>i!=null),Bu(oe.toValue(t.value?r[1]:r[0])),Bu(oe.unref(t.value?r[2]:r[1])),oe.toValue(t.value?r[3]:r[2])]},([a,n,i,o],f,l)=>{if(!(a!=null&&a.length)||!(n!=null&&n.length)||!(i!=null&&i.length))return;const u=W7(o)?{...o}:o,s=a.flatMap(c=>n.flatMap(m=>i.map(v=>e(c,m,v,u))));l(()=>{s.forEach(c=>c())})},{flush:"post"})}function e9(){const r=oe.shallowRef(!1),e=oe.getCurrentInstance();return e&&oe.onMounted(()=>{r.value=!0},e),r}function M0(r){const e=e9();return oe.computed(()=>(e.value,Boolean(r())))}function F0(r,e={}){const{controls:t=!1,navigator:a=S0}=e,n=M0(()=>a&&"permissions"in a),i=oe.shallowRef(),o=typeof r=="string"?{name:r}:r,f=oe.shallowRef(),l=()=>{var s,c;f.value=(s=(c=i.value)===null||c===void 0?void 0:c.state)!==null&&s!==void 0?s:"prompt"};C0(i,"change",l,{passive:!0});const u=X7(async()=>{if(!!n.value){if(!i.value)try{i.value=await a.permissions.query(o)}catch{i.value=void 0}finally{l()}if(t)return oe.toRaw(i.value)}});return u(),t?{state:f,isSupported:n,query:u}:f}function r9(r={}){const{navigator:e=S0,read:t=!1,source:a,copiedDuring:n=1500,legacy:i=!1}=r,o=M0(()=>e&&"clipboard"in e),f=F0("clipboard-read"),l=F0("clipboard-write"),u=oe.computed(()=>o.value||i),s=oe.shallowRef(""),c=oe.shallowRef(!1),m=Y7(()=>c.value=!1,n,{immediate:!1});async function v(){let N=!(o.value&&y(f.value));if(!N)try{s.value=await e.clipboard.readText()}catch{N=!0}N&&(s.value=g())}u.value&&t&&C0(["copy","cut"],v,{passive:!0});async function d(N=oe.toValue(a)){if(u.value&&N!=null){let h=!(o.value&&y(l.value));if(!h)try{await e.clipboard.writeText(N)}catch{h=!0}h&&p(N),s.value=N,c.value=!0,m.start()}}function p(N){const h=document.createElement("textarea");h.value=N,h.style.position="absolute",h.style.opacity="0",h.setAttribute("readonly",""),document.body.appendChild(h),h.select(),document.execCommand("copy"),h.remove()}function g(){var N,h,w;return(N=(h=document)===null||h===void 0||(w=h.getSelection)===null||w===void 0||(w=w.call(h))===null||w===void 0?void 0:w.toString())!==null&&N!==void 0?N:""}function y(N){return N==="granted"||N==="prompt"}return{isSupported:u,text:oe.readonly(s),copied:oe.readonly(c),copy:d}}const Mo={__name:"DiceRollerRenderless",props:{notation:String},emits:["notation:change","roll"],setup(r,{emit:e}){const t=e,a=r,n=oe.ref(`${a.notation||""}`),i=oe.ref(null),o=oe.ref(null),f=async()=>{i.value=null;try{o.value=n.value?new si(oe.unref(n)):null}catch(d){o.value=null,d.name==="SyntaxError"?i.value=`Invalid notation; ${d.message}`:i.value=`An error has occurred: ${d.message}`}finally{t("roll",oe.unref(n),oe.unref(o))}},l=d=>{n.value=d,t("notation:change",d)},{text:u,copy:s,copied:c,isSupported:m}=r9({output:o}),v=()=>s(`${oe.unref(o)}`);return(d,p)=>oe.renderSlot(d.$slots,"default",{currentNotation:n.value,error:i.value,output:o.value,roll:f,bind:{value:n.value},on:{input:g=>l(g.target.value),change:g=>l(g.target.value),keyup:g=>g.keyCode===13?f():void 0},copy:{copy:v,copied:oe.unref(c),text:oe.unref(u),isSupported:oe.unref(m)}})}},t9=()=>typeof crypto<"u"&&crypto&&crypto.randomUUID,n9=()=>t9()?crypto.randomUUID():`${Date.now().toString(32)}-${Math.random().toString(36).substring(2)}`;function $u(r){const e=oe.ref(null);return e.value=`${r}${n9()}`,{id:e}}function T0(r,e){return oe.openBlock(),oe.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[oe.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"})])}const a9=["id"],i9=["for"],o9=["onClick"],s9=["for"],u9=["id","placeholder"],l9=["onClick"],c9={__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}=$u(`${e.id||"dice-roller"}-`);return(a,n)=>(oe.openBlock(),oe.createBlock(Mo,{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:oe.withCtx(({error:i,output:o,roll:f,on:l,bind:u,copy:s})=>[oe.createElementVNode("section",{id:r.id,class:oe.normalizeClass(r.className)},[o?(oe.openBlock(),oe.createElementBlock("output",{key:0,name:"output",for:oe.unref(t),class:oe.normalizeClass(`${r.className}-output`)},[oe.createTextVNode(oe.toDisplayString(o)+" ",1),s.isSupported?(oe.openBlock(),oe.createElementBlock("button",{key:0,title:"Copy to clipboard",class:oe.normalizeClass(`${r.className}-copy-button`),onClick:c=>s.copy()},[oe.createVNode(oe.unref(T0),{class:oe.normalizeClass(`${r.className}-copy-icon`)},null,8,["class"]),s.copied?(oe.openBlock(),oe.createElementBlock("span",{key:0,class:oe.normalizeClass(`${r.className}-copy-label-success`)}," Copied! ",2)):(oe.openBlock(),oe.createElementBlock("span",{key:1,class:oe.normalizeClass(`${r.className}-copy-label`)}," Copy ",2))],10,o9)):oe.createCommentVNode("",!0)],10,i9)):oe.createCommentVNode("",!0),oe.createElementVNode("div",{class:oe.normalizeClass(`${r.className}-input-group`)},[oe.createElementVNode("label",{for:oe.unref(t),class:oe.normalizeClass(`${r.className}-label`)}," Notation ",10,s9),oe.createElementVNode("input",oe.mergeProps({type:"text",name:"notation",id:oe.unref(t),placeholder:`e.g. ${r.notation||"4d6"}`,class:[`${r.className}-input`,i?`${r.className}-input-invalid`:null]},oe.toHandlers(l,!0),u),null,16,u9),oe.createElementVNode("button",{type:"button",class:oe.normalizeClass(`${r.className}-button`),onClick:f},[oe.renderSlot(a.$slots,"button",{},()=>[oe.createTextVNode(oe.toDisplayString(r.btnLabel),1)])],10,l9)],2),i?(oe.openBlock(),oe.createElementBlock("span",{key:1,class:oe.normalizeClass(`${r.className}-error`)},oe.toDisplayString(i),3)):oe.createCommentVNode("",!0)],10,a9)]),_:3},8,["notation"]))}},f9=["id"],m9=["for"],v9=["onClick"],p9={key:0,class:"absolute content-center top-1/2 -my-3 h-6 right-full text-sm color-gray-500"},d9={key:1,class:"sr-only"},h9={class:"flex flex-col sm:flex-row gap-y-4"},g9=["for"],y9=["id","placeholder"],b9=["onClick"],x9={key:1,class:"block mt-4 text-red-600 text-sm dark:text-red-200"},w9={__name:"DiceRollerTailwind",props:{btnLabel:{type:String,default:"Roll"},id:String,notation:String},emits:["notation:change","roll"],setup(r){const e=r,{id:t}=$u(`${e.id||"dice-roller"}-`);return(a,n)=>(oe.openBlock(),oe.createBlock(Mo,{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:oe.withCtx(({error:i,output:o,roll:f,on:l,bind:u,copy:s})=>[oe.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?(oe.openBlock(),oe.createElementBlock("output",{key:0,name:"output",for:oe.unref(t),class:"flex flex-row flex-nowrap justify-between mb-8 p-4 text-2xl rounded bg-white text-black dark:bg-gray-300 dark:text-gray-800 border-l-8 border-[#d4f4c6]"},[oe.createTextVNode(oe.toDisplayString(o)+" ",1),s.isSupported?(oe.openBlock(),oe.createElementBlock("button",{key:0,title:"Copy to clipboard",class:"relative group/copy",onClick:c=>s.copy()},[oe.createVNode(oe.unref(T0),{class:"w-6 h-6 opacity-50 group-hover/copy:opacity-100"}),s.copied?(oe.openBlock(),oe.createElementBlock("span",p9," Copied! ")):(oe.openBlock(),oe.createElementBlock("span",d9," Copy to clipboard "))],8,v9)):oe.createCommentVNode("",!0)],8,m9)):oe.createCommentVNode("",!0),oe.createElementVNode("div",h9,[oe.createElementVNode("label",{for:oe.unref(t),class:"sr-only"}," Notation ",8,g9),oe.createElementVNode("input",oe.mergeProps({type:"text",name:"notation",id:oe.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"]},oe.toHandlers(l,!0),u),null,16,y9),oe.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},[oe.renderSlot(a.$slots,"button",{},()=>[oe.createTextVNode(oe.toDisplayString(r.btnLabel),1)])],8,b9)]),i?(oe.openBlock(),oe.createElementBlock("span",x9,oe.toDisplayString(i),1)):oe.createCommentVNode("",!0)],8,f9)]),_:3},8,["notation"]))}},N9=["id"],D9={class:"card-body"},A9=["for"],E9=["for"],S9={class:"input-group"},C9=["id","placeholder"],M9=["onClick"],F9={key:1,class:"d-block mt-3 invalid-feedback"},$a=["primary","secondary","success","danger","warning","info","light","dark"],B0=[...$a,"body","white","transparent"],$0=[...$a,"body","muted","white","black-50","white-50"],T9=[...$a,"link","outline-primary","outline-secondary","outline-success","outline-danger","outline-warning","outline-info","outline-light","outline-dark"],O0=[...$a,"white"],B9={__name:"DiceRollerBootstrap",props:{bgVariant:{type:String,validator(r){return B0.includes(r)}},borderVariant:{type:String,validator(r){return O0.includes(r)}},btnLabel:{type:String,default:"Roll"},btnVariant:{type:String,default:"primary",validator(r){return T9.includes(r)}},id:String,notation:String,outputBgVariant:{type:String,validator(r){return B0.includes(r)}},outputBorderVariant:{type:String,validator(r){return O0.includes(r)}},outputTextVariant:{type:String,validator(r){return $0.includes(r)}},outputVariant:{type:String,validator(r){return $a.includes(r)}},textVariant:{type:String,validator(r){return $0.includes(r)}},variant:{type:String,validator(r){return $a.includes(r)}}},emits:["notation:change","roll"],setup(r){const e=r,t=oe.computed(()=>({[`text-bg-${e.variant}`]:e.variant,[`bg-${e.bgVariant}`]:e.bgVariant,[`text-${e.textVariant}`]:e.textVariant,[`border-${e.borderVariant}`]:e.borderVariant})),a=oe.computed(()=>({[`text-bg-${e.outputVariant}`]:e.outputVariant,[`bg-${e.outputBgVariant}`]:e.outputBgVariant,[`text-${e.outputTextVariant}`]:e.outputTextVariant,[`border-${e.outputBorderVariant}`]:e.outputBorderVariant})),n=oe.computed(()=>`btn-${e.btnVariant||"primary"}`),{id:i}=$u(`${e.id||"dice-roller"}-`);return(o,f)=>(oe.openBlock(),oe.createBlock(Mo,{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:oe.withCtx(({error:l,output:u,roll:s,on:c,bind:m})=>[oe.createElementVNode("div",{id:r.id,class:oe.normalizeClass(["dice-roller card",t.value])},[oe.createElementVNode("div",D9,[u?(oe.openBlock(),oe.createElementBlock("output",{key:0,name:"output",for:oe.unref(i),class:oe.normalizeClass(["d-block mb-4 p-3 fs-4 rounded border",a.value])},oe.toDisplayString(u),11,A9)):oe.createCommentVNode("",!0),oe.createElementVNode("label",{for:oe.unref(i),class:"form-label visually-hidden"}," Notation ",8,E9),oe.createElementVNode("div",S9,[oe.createElementVNode("input",oe.mergeProps({type:"text",name:"notation",id:oe.unref(i),placeholder:`e.g. ${r.notation||"4d6"}`,class:["form-control",l?"is-invalid":""]},oe.toHandlers(c,!0),m),null,16,C9),oe.createElementVNode("button",{type:"button",class:oe.normalizeClass(["btn",n.value]),onClick:s},[oe.renderSlot(o.$slots,"button",{},()=>[oe.createTextVNode(oe.toDisplayString(r.btnLabel),1)])],10,M9)]),l?(oe.openBlock(),oe.createElementBlock("span",F9,oe.toDisplayString(l),1)):oe.createCommentVNode("",!0)])],10,N9)]),_:3},8,["notation"]))}};Vr.DiceRoller=c9,Vr.DiceRollerBootstrap=B9,Vr.DiceRollerRenderless=Mo,Vr.DiceRollerTailwind=w9,Object.defineProperties(Vr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
57
+ `+a.line+" | "+u+`
58
+ `+l+" | "+xu("",n.column-1," ")+xu("",c,"^")}else e+=`
59
+ at `+o}return e},Na.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)?a(c[0])+"-"+a(c[1]):a(c)});return"["+(u.inverted?"^":"")+s.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(u){return u.description}};function i(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"+i(s)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(s){return"\\x"+i(s)})}function a(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"+i(s)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(s){return"\\x"+i(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 W7(r,e){e=e!==void 0?e:{};var t={},i=e.grammarSource,n={Main:N0},a=N0,o="{",f=",",l="}",u="d",s="d%",c="dF",m=".",v="!",d="p",p="k",g="max",y="min",N="r",h="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",U="floor",j="log",ae="round",re="sign",me="sin",he="sqrt",fe="tan",ie="pow",Ae="-",Oe="**",Ce="*",$e="^",V="%",X="/",oe="+",G="/*",Y="*/",te="[",be="]",ve="//",z="#",L=/^[12]/,ee=/^[lh]/,le=/^[.]/,pe=/^[1-9]/,ge=/^[0-9]/,xe=/^[^\]]/,de=/^[\n\r\u2028\u2029]/,Ne=/^[ \t\n\r]/,_e=Le("{",!1),Ue=Le(",",!1),Be=Le("}",!1),ar=Le("d",!1),Je=Le("d%",!1),mr=Le("dF",!1),C=Le(".",!1),Z=bn(["1","2"],!1,!1),se=Le("!",!1),Ee=Le("p",!1),ze=bn(["l","h"],!1,!1),ke=Le("k",!1),Mr=Le("max",!1),Rr=Le("min",!1),Kt=Le("r",!1),Rn=Le("o",!1),_n=Le("u",!1),Mu=Le("cs",!1),Fu=Le("cf",!1),Tu=Le("s",!1),Bu=Le("a",!1),$u=Le("f",!1),Ou=Le("!=",!1),Iu=Le("<=",!1),Ru=Le(">=",!1),_u=Le("=",!1),qn=Le("<>",!1),qu=Le(">",!1),zu=Le("<",!1),Sa=Le("(",!1),Ca=Le(")",!1),Pu=Le("abs",!1),Lu=Le("ceil",!1),Uu=Le("cos",!1),ku=Le("exp",!1),Vu=Le("floor",!1),Gu=Le("log",!1),Hu=Le("round",!1),Zu=Le("sign",!1),Ju=Le("sin",!1),Xu=Le("sqrt",!1),Wu=Le("tan",!1),Yu=Le("pow",!1),Fo=Le("-",!1),zn=bn(["."],!1,!1),Kr=bn([["1","9"]],!1,!1),Fr=bn([["0","9"]],!1,!1),To=Le("**",!1),Qu=Le("*",!1),Ma=Le("^",!1),Fa=Le("%",!1),Bo=Le("/",!1),$o=Le("+",!1),yn=el("comment"),_9=Le("/*",!1),Ku=Le("*/",!1),Oo=wI(),q9=Le("[",!1),b0=bn(["]"],!0,!1),z9=Le("]",!1),P9=Le("//",!1),L9=Le("#",!1),U9=bn([`
60
+ `,"\r","\u2028","\u2029"],!1,!1),k9=el("whitespace"),V9=bn([" "," ",`
61
+ `,"\r"],!1,!1),G9=el("whitespace or comment"),H9=function(O,W,ne,ce){return new u0([O,...W.map(Se=>Se[3])],Object.assign({},...ne.map(Se=>({[Se.name]:Se}))),ce.find(Se=>Se instanceof zt))},Z9=function(O,W,ne){return O.modifiers=Object.assign({},...W.map(ce=>({[ce.name]:ce}))),O.description=ne.find(ce=>ce instanceof zt),O},J9=function(O,W){return new xa(W,O||1)},X9=function(O){return new I7(O||1)},W9=function(O,W){return new O7(W?parseInt(W[1],10):2,O||1)},Y9=function(O,W,ne){return new z7(ne,!!O,!!W)},Q9=function(O,W){return new V7(O,W)},K9=function(O,W){return new q7(O||"l",W)},j9=function(O,W){return new jh(O||"h",W)},eI=function(O){return new P7(O)},rI=function(O){return new L7(O)},tI=function(O,W){return new U7(!!O,W)},nI=function(O,W){return new H7(!!O,W)},aI=function(O){return new _7(O)},iI=function(O){return new R7(O)},oI=function(O){return new k7(O||"a")},sI=function(O){return O},uI=function(O,W){return new Eo(O,W)},lI=function(O,W,ne){return Eh(_o())},cI=function(O,W){return O=Array.isArray(O)?O:[O],[...O,...W.map(([,ne,,ce])=>[ne,ce]).flat(2)]},fI=function(O,W,ne){return[O,...W,ne]},mI=function(O,W){return[`${O}(`,...W,")"]},vI=function(O,W,ne){return[`${O}(`,...W,",",...ne,")"]},pI=function(){return parseFloat(_o())},dI=function(){return parseInt(_o(),10)},hI=function(){return parseInt(_o(),10)},gI=function(){return"^"},yI=function(O){return new zt(O.flat().join(""),zt.types.MULTILINE)},bI=function(O){return new zt(O.flat().join(""),zt.types.MULTILINE)},xI=function(O){return new zt(O.flat().join(""),zt.types.INLINE)},_=0,lr=0,Io=[{line:1,column:1}],Pt=0,ju=[],De=0,Ro;if("startRule"in e){if(!(e.startRule in n))throw new Error(`Can't start parsing from rule "`+e.startRule+'".');a=n[e.startRule]}function _o(){return r.substring(lr,_)}function Le(O,W){return{type:"literal",text:O,ignoreCase:W}}function bn(O,W,ne){return{type:"class",parts:O,inverted:W,ignoreCase:ne}}function wI(){return{type:"any"}}function NI(){return{type:"end"}}function el(O){return{type:"other",description:O}}function x0(O){var W=Io[O],ne;if(W)return W;for(ne=O-1;!Io[ne];)ne--;for(W=Io[ne],W={line:W.line,column:W.column};ne<O;)r.charCodeAt(ne)===10?(W.line++,W.column=1):W.column++,ne++;return Io[O]=W,W}function w0(O,W,ne){var ce=x0(O),Se=x0(W),Ie={source:i,start:{offset:O,line:ce.line,column:ce.column},end:{offset:W,line:Se.line,column:Se.column}};return Ie}function Fe(O){_<Pt||(_>Pt&&(Pt=_,ju=[]),ju.push(O))}function DI(O,W,ne){return new Na(Na.buildMessage(O,W),O,W,ne)}function N0(){var O;return O=xn(),O}function AI(){var O,W,ne,ce,Se,Ie,dr,Er,Et;if(O=_,r.charCodeAt(_)===123?(W=o,_++):(W=t,De===0&&Fe(_e)),W!==t)if(Ar(),ne=xn(),ne!==t){for(ce=[],Se=_,Ie=Ar(),r.charCodeAt(_)===44?(dr=f,_++):(dr=t,De===0&&Fe(Ue)),dr!==t?(Er=Ar(),Et=xn(),Et!==t?(Ie=[Ie,dr,Er,Et],Se=Ie):(_=Se,Se=t)):(_=Se,Se=t);Se!==t;)ce.push(Se),Se=_,Ie=Ar(),r.charCodeAt(_)===44?(dr=f,_++):(dr=t,De===0&&Fe(Ue)),dr!==t?(Er=Ar(),Et=xn(),Et!==t?(Ie=[Ie,dr,Er,Et],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(dr=[],Er=qo();Er!==t;)dr.push(Er),Er=qo();Er=S0(),lr=O,O=H9(ne,ce,dr,Er)}else _=O,O=t}else _=O,O=t;else _=O,O=t;return O}function EI(){var O,W,ne,ce;if(O=_,W=SI(),W===t&&(W=CI(),W===t&&(W=MI())),W!==t){for(ne=[],ce=qo();ce!==t;)ne.push(ce),ce=qo();ce=S0(),lr=O,O=Z9(W,ne,ce)}else _=O,O=t;return O}function SI(){var O,W,ne,ce;return O=_,W=zo(),W===t&&(W=null),r.charCodeAt(_)===100?(ne=u,_++):(ne=t,De===0&&Fe(ar)),ne!==t?(ce=zo(),ce!==t?(lr=O,O=J9(W,ce)):(_=O,O=t)):(_=O,O=t),O}function CI(){var O,W,ne;return O=_,W=zo(),W===t&&(W=null),r.substr(_,2)===s?(ne=s,_+=2):(ne=t,De===0&&Fe(Je)),ne!==t?(lr=O,O=X9(W)):(_=O,O=t),O}function MI(){var O,W,ne,ce,Se,Ie;return O=_,W=zo(),W===t&&(W=null),r.substr(_,2)===c?(ne=c,_+=2):(ne=t,De===0&&Fe(mr)),ne!==t?(ce=_,r.charCodeAt(_)===46?(Se=m,_++):(Se=t,De===0&&Fe(C)),Se!==t?(L.test(r.charAt(_))?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe(Z)),Ie!==t?(Se=[Se,Ie],ce=Se):(_=ce,ce=t)):(_=ce,ce=t),ce===t&&(ce=null),lr=O,O=W9(W,ce)):(_=O,O=t),O}function qo(){var O;return O=FI(),O===t&&(O=TI(),O===t&&(O=BI(),O===t&&(O=$I(),O===t&&(O=RI(),O===t&&(O=_I(),O===t&&(O=qI(),O===t&&(O=zI(),O===t&&(O=PI(),O===t&&(O=OI(),O===t&&(O=II())))))))))),O}function FI(){var O,W,ne,ce,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?(ce=d,_++):(ce=t,De===0&&Fe(Ee)),ce===t&&(ce=null),Se=Pn(),Se===t&&(Se=null),lr=O,O=Y9(ne,ce,Se)):(_=O,O=t),O}function TI(){var O,W,ne;return O=_,W=Pn(),W!==t?(ne=LI(),ne===t&&(ne=null),lr=O,O=Q9(W,ne)):(_=O,O=t),O}function BI(){var O,W,ne,ce;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),ce=tl(),ce!==t?(lr=O,O=K9(ne,ce)):(_=O,O=t)):(_=O,O=t),O}function $I(){var O,W,ne,ce;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),ce=tl(),ce!==t?(lr=O,O=j9(ne,ce)):(_=O,O=t)):(_=O,O=t),O}function OI(){var O,W,ne;return O=_,r.substr(_,3)===g?(W=g,_+=3):(W=t,De===0&&Fe(Mr)),W!==t?(ne=Ln(),ne!==t?(lr=O,O=eI(ne)):(_=O,O=t)):(_=O,O=t),O}function II(){var O,W,ne;return O=_,r.substr(_,3)===y?(W=y,_+=3):(W=t,De===0&&Fe(Rr)),W!==t?(ne=Ln(),ne!==t?(lr=O,O=rI(ne)):(_=O,O=t)):(_=O,O=t),O}function RI(){var O,W,ne,ce;return O=_,r.charCodeAt(_)===114?(W=N,_++):(W=t,De===0&&Fe(Kt)),W!==t?(r.charCodeAt(_)===111?(ne=h,_++):(ne=t,De===0&&Fe(Rn)),ne===t&&(ne=null),ce=Pn(),ce===t&&(ce=null),lr=O,O=tI(ne,ce)):(_=O,O=t),O}function _I(){var O,W,ne,ce;return O=_,r.charCodeAt(_)===117?(W=w,_++):(W=t,De===0&&Fe(_n)),W!==t?(r.charCodeAt(_)===111?(ne=h,_++):(ne=t,De===0&&Fe(Rn)),ne===t&&(ne=null),ce=Pn(),ce===t&&(ce=null),lr=O,O=nI(ne,ce)):(_=O,O=t),O}function qI(){var O,W,ne;return O=_,r.substr(_,2)===x?(W=x,_+=2):(W=t,De===0&&Fe(Mu)),W!==t?(ne=Pn(),ne===t&&(ne=null),lr=O,O=aI(ne)):(_=O,O=t),O}function zI(){var O,W,ne;return O=_,r.substr(_,2)===b?(W=b,_+=2):(W=t,De===0&&Fe(Fu)),W!==t?(ne=Pn(),ne===t&&(ne=null),lr=O,O=iI(ne)):(_=O,O=t),O}function PI(){var O,W,ne;return O=_,r.charCodeAt(_)===115?(W=E,_++):(W=t,De===0&&Fe(Tu)),W!==t?(r.charCodeAt(_)===97?(ne=A,_++):(ne=t,De===0&&Fe(Bu)),ne===t&&(r.charCodeAt(_)===100?(ne=u,_++):(ne=t,De===0&&Fe(ar))),ne===t&&(ne=null),lr=O,O=oI(ne)):(_=O,O=t),O}function LI(){var O,W,ne;return O=_,r.charCodeAt(_)===102?(W=S,_++):(W=t,De===0&&Fe($u)),W!==t?(ne=Pn(),ne!==t?(lr=O,O=sI(ne)):(_=O,O=t)):(_=O,O=t),O}function Pn(){var O,W,ne;return O=_,W=UI(),W!==t?(ne=Ln(),ne!==t?(lr=O,O=uI(W,ne)):(_=O,O=t)):(_=O,O=t),O}function UI(){var O;return r.substr(_,2)===D?(O=D,_+=2):(O=t,De===0&&Fe(Ou)),O===t&&(r.substr(_,2)===T?(O=T,_+=2):(O=t,De===0&&Fe(Iu)),O===t&&(r.substr(_,2)===B?(O=B,_+=2):(O=t,De===0&&Fe(Ru)),O===t&&(r.charCodeAt(_)===61?(O=I,_++):(O=t,De===0&&Fe(_u)),O===t&&(r.substr(_,2)===P?(O=P,_+=2):(O=t,De===0&&Fe(qn)),O===t&&(r.charCodeAt(_)===62?(O=R,_++):(O=t,De===0&&Fe(qu)),O===t&&(r.charCodeAt(_)===60?(O=M,_++):(O=t,De===0&&Fe(zu)))))))),O}function zo(){var O,W,ne,ce,Se,Ie,dr,Er,Et,Ta;if(O=tl(),O===t)if(O=_,r.charCodeAt(_)===40?(W=F,_++):(W=t,De===0&&Fe(Sa)),W!==t){if(Ar(),ne=_,ce=Ln(),ce!==t){if(Se=[],Ie=_,dr=Ar(),Er=Po(),Er!==t?(Et=Ar(),Ta=Ln(),Ta!==t?(dr=[dr,Er,Et,Ta],Ie=dr):(_=Ie,Ie=t)):(_=Ie,Ie=t),Ie!==t)for(;Ie!==t;)Se.push(Ie),Ie=_,dr=Ar(),Er=Po(),Er!==t?(Et=Ar(),Ta=Ln(),Ta!==t?(dr=[dr,Er,Et,Ta],Ie=dr):(_=Ie,Ie=t)):(_=Ie,Ie=t);else Se=t;Se!==t?(ce=[ce,Se],ne=ce):(_=ne,ne=t)}else _=ne,ne=t;ne!==t?(ce=Ar(),r.charCodeAt(_)===41?(Se=H,_++):(Se=t,De===0&&Fe(Ca)),Se!==t?(lr=O,O=lI()):(_=O,O=t)):(_=O,O=t)}else _=O,O=t;return O}function xn(){var O,W,ne,ce,Se,Ie,dr,Er;if(O=_,W=rl(),W!==t){for(ne=[],ce=_,Se=Ar(),Ie=Po(),Ie!==t?(dr=Ar(),Er=rl(),Er!==t?(Se=[Se,Ie,dr,Er],ce=Se):(_=ce,ce=t)):(_=ce,ce=t);ce!==t;)ne.push(ce),ce=_,Se=Ar(),Ie=Po(),Ie!==t?(dr=Ar(),Er=rl(),Er!==t?(Se=[Se,Ie,dr,Er],ce=Se):(_=ce,ce=t)):(_=ce,ce=t);lr=O,O=cI(W,ne)}else _=O,O=t;return O}function rl(){var O,W,ne,ce;return O=kI(),O===t&&(O=EI(),O===t&&(O=Ln(),O===t&&(O=_,r.charCodeAt(_)===40?(W=F,_++):(W=t,De===0&&Fe(Sa)),W!==t?(Ar(),ne=xn(),ne!==t?(Ar(),r.charCodeAt(_)===41?(ce=H,_++):(ce=t,De===0&&Fe(Ca)),ce!==t?(lr=O,O=fI(W,ne,ce)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t),O===t&&(O=AI())))),O}function kI(){var O,W,ne,ce,Se,Ie,dr;return O=_,r.substr(_,3)===$?(W=$,_+=3):(W=t,De===0&&Fe(Pu)),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(Uu)),W===t&&(r.substr(_,3)===K?(W=K,_+=3):(W=t,De===0&&Fe(ku)),W===t&&(r.substr(_,5)===U?(W=U,_+=5):(W=t,De===0&&Fe(Vu)),W===t&&(r.substr(_,3)===j?(W=j,_+=3):(W=t,De===0&&Fe(Gu)),W===t&&(r.substr(_,5)===ae?(W=ae,_+=5):(W=t,De===0&&Fe(Hu)),W===t&&(r.substr(_,4)===re?(W=re,_+=4):(W=t,De===0&&Fe(Zu)),W===t&&(r.substr(_,3)===me?(W=me,_+=3):(W=t,De===0&&Fe(Ju)),W===t&&(r.substr(_,4)===he?(W=he,_+=4):(W=t,De===0&&Fe(Xu)),W===t&&(r.substr(_,3)===fe?(W=fe,_+=3):(W=t,De===0&&Fe(Wu)))))))))))),W!==t?(r.charCodeAt(_)===40?(ne=F,_++):(ne=t,De===0&&Fe(Sa)),ne!==t?(Ar(),ce=xn(),ce!==t?(Ar(),r.charCodeAt(_)===41?(Se=H,_++):(Se=t,De===0&&Fe(Ca)),Se!==t?(lr=O,O=mI(W,ce)):(_=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(Yu)),W===t&&(r.substr(_,3)===g?(W=g,_+=3):(W=t,De===0&&Fe(Mr)),W===t&&(r.substr(_,3)===y?(W=y,_+=3):(W=t,De===0&&Fe(Rr)))),W!==t?(r.charCodeAt(_)===40?(ne=F,_++):(ne=t,De===0&&Fe(Sa)),ne!==t?(Ar(),ce=xn(),ce!==t?(Ar(),r.charCodeAt(_)===44?(Se=f,_++):(Se=t,De===0&&Fe(Ue)),Se!==t?(Ar(),Ie=xn(),Ie!==t?(Ar(),r.charCodeAt(_)===41?(dr=H,_++):(dr=t,De===0&&Fe(Ca)),dr!==t?(lr=O,O=vI(W,ce,Ie)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)),O}function Ln(){var O,W,ne,ce,Se;return O=_,r.charCodeAt(_)===45?_++:De===0&&Fe(Fo),W=D0(),W!==t?(ne=_,le.test(r.charAt(_))?(ce=r.charAt(_),_++):(ce=t,De===0&&Fe(zn)),ce!==t?(Se=D0(),Se!==t?(ce=[ce,Se],ne=ce):(_=ne,ne=t)):(_=ne,ne=t),ne===t&&(ne=null),lr=O,O=pI()):(_=O,O=t),O}function tl(){var O,W,ne,ce;if(O=_,pe.test(r.charAt(_))?(W=r.charAt(_),_++):(W=t,De===0&&Fe(Kr)),W!==t){for(ne=[],ge.test(r.charAt(_))?(ce=r.charAt(_),_++):(ce=t,De===0&&Fe(Fr));ce!==t;)ne.push(ce),ge.test(r.charAt(_))?(ce=r.charAt(_),_++):(ce=t,De===0&&Fe(Fr));lr=O,O=dI()}else _=O,O=t;return O}function D0(){var O,W,ne;if(O=_,W=[],ge.test(r.charAt(_))?(ne=r.charAt(_),_++):(ne=t,De===0&&Fe(Fr)),ne!==t)for(;ne!==t;)W.push(ne),ge.test(r.charAt(_))?(ne=r.charAt(_),_++):(ne=t,De===0&&Fe(Fr));else W=t;return W!==t&&(lr=O,W=hI()),O=W,O}function Po(){var O,W;return O=_,r.substr(_,2)===Oe?(W=Oe,_+=2):(W=t,De===0&&Fe(To)),W!==t&&(lr=O,W=gI()),O=W,O===t&&(r.charCodeAt(_)===42?(O=Ce,_++):(O=t,De===0&&Fe(Qu)),O===t&&(r.charCodeAt(_)===94?(O=$e,_++):(O=t,De===0&&Fe(Ma)),O===t&&(r.charCodeAt(_)===37?(O=V,_++):(O=t,De===0&&Fe(Fa)),O===t&&(r.charCodeAt(_)===47?(O=X,_++):(O=t,De===0&&Fe(Bo)),O===t&&(r.charCodeAt(_)===43?(O=oe,_++):(O=t,De===0&&Fe($o)),O===t&&(r.charCodeAt(_)===45?(O=Ae,_++):(O=t,De===0&&Fe(Fo)))))))),O}function A0(){var O;return De++,O=VI(),O===t&&(O=GI()),De--,O===t&&De===0&&Fe(yn),O}function VI(){var O,W,ne,ce,Se,Ie;if(O=_,r.substr(_,2)===G?(W=G,_+=2):(W=t,De===0&&Fe(_9)),W!==t){for(ne=[],ce=_,Se=_,De++,r.substr(_,2)===Y?(Ie=Y,_+=2):(Ie=t,De===0&&Fe(Ku)),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe(Oo)),Ie!==t?(Se=[Se,Ie],ce=Se):(_=ce,ce=t)):(_=ce,ce=t);ce!==t;)ne.push(ce),ce=_,Se=_,De++,r.substr(_,2)===Y?(Ie=Y,_+=2):(Ie=t,De===0&&Fe(Ku)),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe(Oo)),Ie!==t?(Se=[Se,Ie],ce=Se):(_=ce,ce=t)):(_=ce,ce=t);r.substr(_,2)===Y?(ce=Y,_+=2):(ce=t,De===0&&Fe(Ku)),ce!==t?(lr=O,O=yI(ne)):(_=O,O=t)}else _=O,O=t;if(O===t)if(O=_,r.charCodeAt(_)===91?(W=te,_++):(W=t,De===0&&Fe(q9)),W!==t){for(ne=[],xe.test(r.charAt(_))?(ce=r.charAt(_),_++):(ce=t,De===0&&Fe(b0));ce!==t;)ne.push(ce),xe.test(r.charAt(_))?(ce=r.charAt(_),_++):(ce=t,De===0&&Fe(b0));r.charCodeAt(_)===93?(ce=be,_++):(ce=t,De===0&&Fe(z9)),ce!==t?(lr=O,O=bI(ne)):(_=O,O=t)}else _=O,O=t;return O}function GI(){var O,W,ne,ce,Se,Ie;if(O=_,r.substr(_,2)===ve?(W=ve,_+=2):(W=t,De===0&&Fe(P9)),W===t&&(r.charCodeAt(_)===35?(W=z,_++):(W=t,De===0&&Fe(L9))),W!==t){for(ne=[],ce=_,Se=_,De++,Ie=E0(),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe(Oo)),Ie!==t?(Se=[Se,Ie],ce=Se):(_=ce,ce=t)):(_=ce,ce=t);ce!==t;)ne.push(ce),ce=_,Se=_,De++,Ie=E0(),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe(Oo)),Ie!==t?(Se=[Se,Ie],ce=Se):(_=ce,ce=t)):(_=ce,ce=t);lr=O,O=xI(ne)}else _=O,O=t;return O}function E0(){var O;return de.test(r.charAt(_))?(O=r.charAt(_),_++):(O=t,De===0&&Fe(U9)),O}function Lo(){var O;return De++,Ne.test(r.charAt(_))?(O=r.charAt(_),_++):(O=t,De===0&&Fe(V9)),De--,O===t&&De===0&&Fe(k9),O}function Ar(){var O,W;for(O=[],W=Lo();W!==t;)O.push(W),W=Lo();return O}function S0(){var O,W;for(De++,O=[],W=Lo(),W===t&&(W=A0());W!==t;)O.push(W),W=Lo(),W===t&&(W=A0());return De--,W=t,De===0&&Fe(G9),O}if(Ro=a(),Ro!==t&&_===r.length)return Ro;throw Ro!==t&&_<r.length&&Fe(NI()),DI(ju,Pt<r.length?r.charAt(Pt):null,Pt<r.length?w0(Pt,Pt+1):w0(Pt,Pt))}class l0{static parse(e){if(!e)throw new qt("notation");if(typeof e!="string")throw new TypeError("Notation must be a string");return W7(e)}}const Da=Object.freeze({BASE_64:1,JSON:0,OBJECT:2}),wu=Symbol("notation"),Nu=Symbol("maxTotal"),Du=Symbol("minTotal"),Aa=Symbol("expressions"),So=Symbol("roll-method"),gn=Symbol("rolls"),c0=Symbol("set-rolls"),Co=Symbol("total"),Au=r=>o7(r.calculationValue,2);class ei{constructor(e){if(!e)throw new qt("notation");if(this[Aa]=[],e instanceof Object&&!Array.isArray(e)){if(e.notation){if(typeof e.notation!="string")throw new yo(e.notation);e.rolls&&this[c0](e.rolls)}else throw new qt("notation");this[wu]=e.notation,this[Aa]=l0.parse(this.notation),this.hasRolls()||this.roll()}else if(typeof e=="string")this[wu]=e,this[Aa]=l0.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[Nu]){const e=this[So](_h.max);this[Nu]=Au(e)}return this[Nu]}get minTotal(){if(!this.hasExpressions())return 0;if(!this[Du]){const e=this[So](_h.min);this[Du]=Au(e)}return this[Du]}get notation(){return this[wu]}get output(){let e=`${this.notation}: `;return this.hasRolls()?e+=`${this[gn]} = ${this.total}`:e+="No dice rolled",e}get rolls(){return this[gn]?this[gn].results:[]}get total(){return!this[Co]&&this.hasRolls()&&(this[Co]=Au(this[gn])),this[Co]||0}export(e=Da.JSON){switch(e){case Da.BASE_64:return btoa(this.export(Da.JSON));case Da.JSON:return JSON.stringify(this);case Da.OBJECT:return JSON.parse(this.export(Da.JSON));default:throw new TypeError(`Invalid export format "${e}"`)}}hasExpressions(){return this[Aa]&&this[Aa].length>0}hasRolls(){return this.hasExpressions()&&this.rolls.length>0}roll(){return this[Co]=0,this[gn]=this[So](),this.rolls}toJSON(){const{averageTotal:e,maxTotal:t,minTotal:i,notation:n,output:a,rolls:o,total:f}=this;return{averageTotal:e,maxTotal:t,minTotal:i,notation:n,output:a,rolls:o,total:f,type:"dice-roll"}}toString(){return this.output}static import(e){if(e){if(J7(e))return ei.import(JSON.parse(e));if(Z7(e))return ei.import(atob(e));if(typeof e=="object")return new ei(e);throw new ru(e)}else throw new qt("data")}[So](e){let t;e&&(t=ba.engine,ba.engine=e);const i=new kr(this[Aa].map(n=>n instanceof xa||n instanceof u0?n.roll():n).filter(n=>!!n||n===0));return e&&(ba.engine=t),i}[c0](e){if(e instanceof kr)this[gn]=e;else if(e instanceof Qt)this[gn]=new kr([e]);else if(Array.isArray(e))this[gn]=new kr(e.map(t=>{if(t instanceof kr||t instanceof Qt)return t;if(Array.isArray(t))return new Qt(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 Qt(t.rolls)}return t}));else throw new TypeError("Rolls must be a valid result object, or an array")}}function Y7(r,e){return ue.getCurrentScope()?(ue.onScopeDispose(r,e),!0):!1}const Eu=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Q7=Object.prototype.toString,K7=r=>Q7.call(r)==="[object Object]";function j7(r){let e;function t(){return e||(e=r()),e}return t.reset=async()=>{const i=e;e=void 0,i&&await i},t}function Su(r){return Array.isArray(r)?r:[r]}function e9(r,e,t={}){const{immediate:i=!0,immediateCallback:n=!1}=t,a=ue.shallowRef(!1);let o;function f(){o&&(clearTimeout(o),o=void 0)}function l(){a.value=!1,f()}function u(...s){n&&r(),f(),a.value=!0,o=setTimeout(()=>{a.value=!1,o=void 0,r(...s)},ue.toValue(e))}return i&&(a.value=!0,Eu&&u()),Y7(l),{isPending:ue.shallowReadonly(a),start:u,stop:l}}function r9(r,e,t){return ue.watch(r,e,{...t,immediate:!0})}const t9=Eu?window:void 0,f0=Eu?window.navigator:void 0;function n9(r){var e;const t=ue.toValue(r);return(e=t?.$el)!==null&&e!==void 0?e:t}function m0(...r){const e=(i,n,a,o)=>(i.addEventListener(n,a,o),()=>i.removeEventListener(n,a,o)),t=ue.computed(()=>{const i=Su(ue.toValue(r[0])).filter(n=>n!=null);return i.every(n=>typeof n!="string")?i:void 0});return r9(()=>{var i,n;return[(i=(n=t.value)===null||n===void 0?void 0:n.map(a=>n9(a)))!==null&&i!==void 0?i:[t9].filter(a=>a!=null),Su(ue.toValue(t.value?r[1]:r[0])),Su(ue.unref(t.value?r[2]:r[1])),ue.toValue(t.value?r[3]:r[2])]},([i,n,a,o],f,l)=>{if(!i?.length||!n?.length||!a?.length)return;const u=K7(o)?{...o}:o,s=i.flatMap(c=>n.flatMap(m=>a.map(v=>e(c,m,v,u))));l(()=>{s.forEach(c=>c())})},{flush:"post"})}function a9(){const r=ue.shallowRef(!1),e=ue.getCurrentInstance();return e&&ue.onMounted(()=>{r.value=!0},e),r}function v0(r){const e=a9();return ue.computed(()=>(e.value,!!r()))}function p0(r,e={}){const{controls:t=!1,navigator:i=f0}=e,n=v0(()=>i&&"permissions"in i),a=ue.shallowRef(),o=typeof r=="string"?{name:r}:r,f=ue.shallowRef(),l=()=>{var s,c;f.value=(s=(c=a.value)===null||c===void 0?void 0:c.state)!==null&&s!==void 0?s:"prompt"};m0(a,"change",l,{passive:!0});const u=j7(async()=>{if(n.value){if(!a.value)try{a.value=await i.permissions.query(o)}catch{a.value=void 0}finally{l()}if(t)return ue.toRaw(a.value)}});return u(),t?{state:f,isSupported:n,query:u}:f}function i9(r={}){const{navigator:e=f0,read:t=!1,source:i,copiedDuring:n=1500,legacy:a=!1}=r,o=v0(()=>e&&"clipboard"in e),f=p0("clipboard-read"),l=p0("clipboard-write"),u=ue.computed(()=>o.value||a),s=ue.shallowRef(""),c=ue.shallowRef(!1),m=e9(()=>c.value=!1,n,{immediate:!1});async function v(){let N=!(o.value&&y(f.value));if(!N)try{s.value=await e.clipboard.readText()}catch{N=!0}N&&(s.value=g())}u.value&&t&&m0(["copy","cut"],v,{passive:!0});async function d(N=ue.toValue(i)){if(u.value&&N!=null){let h=!(o.value&&y(l.value));if(!h)try{await e.clipboard.writeText(N)}catch{h=!0}h&&p(N),s.value=N,c.value=!0,m.start()}}function p(N){const h=document.createElement("textarea");h.value=N,h.style.position="absolute",h.style.opacity="0",h.setAttribute("readonly",""),document.body.appendChild(h),h.select(),document.execCommand("copy"),h.remove()}function g(){var N,h,w;return(N=(h=document)===null||h===void 0||(w=h.getSelection)===null||w===void 0||(w=w.call(h))===null||w===void 0?void 0:w.toString())!==null&&N!==void 0?N:""}function y(N){return N==="granted"||N==="prompt"}return{isSupported:u,text:ue.readonly(s),copied:ue.readonly(c),copy:d}}const Mo={__name:"DiceRollerRenderless",props:{notation:String},emits:["notation:change","roll"],setup(r,{emit:e}){const t=e,i=r,n=ue.ref(`${i.notation||""}`),a=ue.ref(null),o=ue.ref(null),f=async()=>{a.value=null;try{o.value=n.value?new ei(ue.unref(n)):null}catch(d){o.value=null,d.name==="SyntaxError"?a.value=`Invalid notation; ${d.message}`:a.value=`An error has occurred: ${d.message}`}finally{t("roll",ue.unref(n),ue.unref(o))}},l=d=>{n.value=d,t("notation:change",d)},{text:u,copy:s,copied:c,isSupported:m}=i9({}),v=()=>s(`${ue.unref(o)}`);return(d,p)=>ue.renderSlot(d.$slots,"default",{currentNotation:n.value,error:a.value,output:o.value,roll:f,bind:{value:n.value},on:{input:g=>l(g.target.value),change:g=>l(g.target.value),keyup:g=>g.keyCode===13?f():void 0},copy:{copy:v,copied:ue.unref(c),text:ue.unref(u),isSupported:ue.unref(m)}})}},o9=()=>typeof crypto<"u"&&crypto&&crypto.randomUUID,s9=()=>o9()?crypto.randomUUID():`${Date.now().toString(32)}-${Math.random().toString(36).substring(2)}`;function Cu(r){const e=ue.ref(null);return e.value=`${r}${s9()}`,{id:e}}function d0(r,e){return ue.openBlock(),ue.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[ue.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"})])}const u9=["id"],l9=["for"],c9=["onClick"],f9=["for"],m9=["id","placeholder"],v9=["disabled","onClick"],p9={__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}=Cu(`${e.id||"dice-roller"}-`);return(i,n)=>(ue.openBlock(),ue.createBlock(Mo,{notation:r.notation,"onNotation:change":n[0]||(n[0]=a=>i.$emit("notation:change",a)),onRoll:n[1]||(n[1]=a=>i.$emit("roll",a))},{default:ue.withCtx(({error:a,output:o,roll:f,on:l,bind:u,copy:s})=>[ue.createElementVNode("section",{id:r.id,class:ue.normalizeClass(r.className)},[o?(ue.openBlock(),ue.createElementBlock("output",{key:0,name:"output",for:ue.unref(t),class:ue.normalizeClass(`${r.className}-output`)},[ue.createTextVNode(ue.toDisplayString(o)+" ",1),s.isSupported?(ue.openBlock(),ue.createElementBlock("button",{key:0,title:"Copy to clipboard",class:ue.normalizeClass(`${r.className}-copy-button`),onClick:c=>s.copy()},[ue.createVNode(ue.unref(d0),{class:ue.normalizeClass(`${r.className}-copy-icon`)},null,8,["class"]),s.copied?(ue.openBlock(),ue.createElementBlock("span",{key:0,class:ue.normalizeClass(`${r.className}-copy-label-success`)}," Copied! ",2)):(ue.openBlock(),ue.createElementBlock("span",{key:1,class:ue.normalizeClass(`${r.className}-copy-label`)}," Copy ",2))],10,c9)):ue.createCommentVNode("",!0)],10,l9)):ue.createCommentVNode("",!0),ue.createElementVNode("div",{class:ue.normalizeClass(`${r.className}-input-group`)},[ue.createElementVNode("label",{for:ue.unref(t),class:ue.normalizeClass(`${r.className}-label`)}," Notation ",10,f9),ue.createElementVNode("input",ue.mergeProps({type:"text",name:"notation",id:ue.unref(t),placeholder:`e.g. ${r.notation||"4d6"}`,class:[`${r.className}-input`,a?`${r.className}-input-invalid`:null]},ue.toHandlers(l,!0),u),null,16,m9),ue.createElementVNode("button",{type:"button",class:ue.normalizeClass(`${r.className}-button`),disabled:!u.value,onClick:f},[ue.renderSlot(i.$slots,"button",{},()=>[ue.createTextVNode(ue.toDisplayString(r.btnLabel),1)])],10,v9)],2),a?(ue.openBlock(),ue.createElementBlock("span",{key:1,class:ue.normalizeClass(`${r.className}-error`)},ue.toDisplayString(a),3)):ue.createCommentVNode("",!0)],10,u9)]),_:3},8,["notation"]))}},d9=["id"],h9=["for"],g9=["onClick"],y9={key:0,class:"absolute content-center top-1/2 -my-3 h-6 right-full text-sm color-gray-500"},b9={key:1,class:"sr-only"},x9={class:"flex flex-col sm:flex-row gap-y-4"},w9=["for"],N9=["id","placeholder"],D9=["disabled","onClick"],A9={key:1,class:"block mt-4 text-red-600 text-sm dark:text-red-200"},E9={__name:"DiceRollerTailwind",props:{btnLabel:{type:String,default:"Roll"},id:String,notation:String},emits:["notation:change","roll"],setup(r){const e=r,{id:t}=Cu(`${e.id||"dice-roller"}-`);return(i,n)=>(ue.openBlock(),ue.createBlock(Mo,{notation:r.notation,"onNotation:change":n[0]||(n[0]=a=>i.$emit("notation:change",a)),onRoll:n[1]||(n[1]=a=>i.$emit("roll",a))},{default:ue.withCtx(({error:a,output:o,roll:f,on:l,bind:u,copy:s})=>[ue.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?(ue.openBlock(),ue.createElementBlock("output",{key:0,name:"output",for:ue.unref(t),class:"flex flex-row flex-nowrap justify-between mb-8 p-4 text-2xl rounded bg-white text-black dark:bg-gray-300 dark:text-gray-800 border-l-8 border-[#d4f4c6]"},[ue.createTextVNode(ue.toDisplayString(o)+" ",1),s.isSupported?(ue.openBlock(),ue.createElementBlock("button",{key:0,title:"Copy to clipboard",class:"relative group/copy",onClick:c=>s.copy()},[ue.createVNode(ue.unref(d0),{class:"w-6 h-6 opacity-50 group-hover/copy:opacity-100"}),s.copied?(ue.openBlock(),ue.createElementBlock("span",y9," Copied! ")):(ue.openBlock(),ue.createElementBlock("span",b9," Copy to clipboard "))],8,g9)):ue.createCommentVNode("",!0)],8,h9)):ue.createCommentVNode("",!0),ue.createElementVNode("div",x9,[ue.createElementVNode("label",{for:ue.unref(t),class:"sr-only"}," Notation ",8,w9),ue.createElementVNode("input",ue.mergeProps({type:"text",name:"notation",id:ue.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",a?"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"]},ue.toHandlers(l,!0),u),null,16,N9),ue.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",disabled:!u.value,onClick:f},[ue.renderSlot(i.$slots,"button",{},()=>[ue.createTextVNode(ue.toDisplayString(r.btnLabel),1)])],8,D9)]),a?(ue.openBlock(),ue.createElementBlock("span",A9,ue.toDisplayString(a),1)):ue.createCommentVNode("",!0)],8,d9)]),_:3},8,["notation"]))}},S9=["id"],C9={class:"card-body"},M9=["for"],F9=["for"],T9={class:"input-group"},B9=["id","placeholder"],$9=["disabled","onClick"],O9={key:1,class:"d-block mt-3 invalid-feedback"},Ea=["primary","secondary","success","danger","warning","info","light","dark"],h0=[...Ea,"body","white","transparent"],g0=[...Ea,"body","muted","white","black-50","white-50"],I9=[...Ea,"link","outline-primary","outline-secondary","outline-success","outline-danger","outline-warning","outline-info","outline-light","outline-dark"],y0=[...Ea,"white"],R9={__name:"DiceRollerBootstrap",props:{bgVariant:{type:String,validator(r){return h0.includes(r)}},borderVariant:{type:String,validator(r){return y0.includes(r)}},btnLabel:{type:String,default:"Roll"},btnVariant:{type:String,default:"primary",validator(r){return I9.includes(r)}},id:String,notation:String,outputBgVariant:{type:String,validator(r){return h0.includes(r)}},outputBorderVariant:{type:String,validator(r){return y0.includes(r)}},outputTextVariant:{type:String,validator(r){return g0.includes(r)}},outputVariant:{type:String,validator(r){return Ea.includes(r)}},textVariant:{type:String,validator(r){return g0.includes(r)}},variant:{type:String,validator(r){return Ea.includes(r)}}},emits:["notation:change","roll"],setup(r){const e=r,t=ue.computed(()=>({[`text-bg-${e.variant}`]:e.variant,[`bg-${e.bgVariant}`]:e.bgVariant,[`text-${e.textVariant}`]:e.textVariant,[`border-${e.borderVariant}`]:e.borderVariant})),i=ue.computed(()=>({[`text-bg-${e.outputVariant}`]:e.outputVariant,[`bg-${e.outputBgVariant}`]:e.outputBgVariant,[`text-${e.outputTextVariant}`]:e.outputTextVariant,[`border-${e.outputBorderVariant}`]:e.outputBorderVariant})),n=ue.computed(()=>`btn-${e.btnVariant||"primary"}`),{id:a}=Cu(`${e.id||"dice-roller"}-`);return(o,f)=>(ue.openBlock(),ue.createBlock(Mo,{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:ue.withCtx(({error:l,output:u,roll:s,on:c,bind:m})=>[ue.createElementVNode("div",{id:r.id,class:ue.normalizeClass(["dice-roller card",t.value])},[ue.createElementVNode("div",C9,[u?(ue.openBlock(),ue.createElementBlock("output",{key:0,name:"output",for:ue.unref(a),class:ue.normalizeClass(["d-block mb-4 p-3 fs-4 rounded border",i.value])},ue.toDisplayString(u),11,M9)):ue.createCommentVNode("",!0),ue.createElementVNode("label",{for:ue.unref(a),class:"form-label visually-hidden"}," Notation ",8,F9),ue.createElementVNode("div",T9,[ue.createElementVNode("input",ue.mergeProps({type:"text",name:"notation",id:ue.unref(a),placeholder:`e.g. ${r.notation||"4d6"}`,class:["form-control",l?"is-invalid":""]},ue.toHandlers(c,!0),m),null,16,B9),ue.createElementVNode("button",{type:"button",class:ue.normalizeClass(["btn",n.value]),disabled:!m.value,onClick:s},[ue.renderSlot(o.$slots,"button",{},()=>[ue.createTextVNode(ue.toDisplayString(r.btnLabel),1)])],10,$9)]),l?(ue.openBlock(),ue.createElementBlock("span",O9,ue.toDisplayString(l),1)):ue.createCommentVNode("",!0)])],10,S9)]),_:3},8,["notation"]))}};St.DiceRoller=p9,St.DiceRollerBootstrap=R9,St.DiceRollerRenderless=Mo,St.DiceRollerTailwind=E9,Object.defineProperty(St,Symbol.toStringTag,{value:"Module"})}));