@dice-roller/vue 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/vue.js +12588 -12002
  2. package/dist/vue.umd.cjs +40 -40
  3. package/package.json +2 -2
package/dist/vue.umd.cjs CHANGED
@@ -1,53 +1,53 @@
1
- (function(kr,xe){typeof exports=="object"&&typeof module<"u"?xe(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],xe):(kr=typeof globalThis<"u"?globalThis:kr||self,xe(kr.DiceRollerVue={},kr.Vue))})(this,function(kr,xe){"use strict";var R7=Object.defineProperty;var q7=(kr,xe,Ar)=>xe in kr?R7(kr,xe,{enumerable:!0,configurable:!0,writable:!0,value:Ar}):kr[xe]=Ar;var u0=(kr,xe,Ar)=>(q7(kr,typeof xe!="symbol"?xe+"":xe,Ar),Ar);function Ar(){return Ar=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},Ar.apply(this,arguments)}var Wu={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 zt(r){return r&&typeof r=="object"&&Object.getPrototypeOf(r).isComplex===!0||!1}function _a(r){return r&&typeof r=="object"&&Object.getPrototypeOf(r).isFraction===!0||!1}function Pt(r){return r&&r.constructor.prototype.isUnit===!0||!1}function Wr(r){return typeof r=="string"}var ur=Array.isArray;function He(r){return r&&r.constructor.prototype.isMatrix===!0||!1}function Lt(r){return Array.isArray(r)||He(r)}function ni(r){return r&&r.isDenseMatrix&&r.constructor.prototype.isMatrix===!0||!1}function Nn(r){return r&&r.isSparseMatrix&&r.constructor.prototype.isMatrix===!0||!1}function Ro(r){return r&&r.constructor.prototype.isRange===!0||!1}function ai(r){return r&&r.constructor.prototype.isIndex===!0||!1}function l0(r){return typeof r=="boolean"}function c0(r){return r&&r.constructor.prototype.isResultSet===!0||!1}function Xu(r){return r&&r.constructor.prototype.isHelp===!0||!1}function f0(r){return typeof r=="function"}function m0(r){return r instanceof Date}function v0(r){return r instanceof RegExp}function qo(r){return!!(r&&typeof r=="object"&&r.constructor===Object&&!zt(r)&&!_a(r))}function p0(r){return r===null}function h0(r){return r===void 0}function Dn(r){return r&&r.isAccessorNode===!0&&r.constructor.prototype.isNode===!0||!1}function nt(r){return r&&r.isArrayNode===!0&&r.constructor.prototype.isNode===!0||!1}function d0(r){return r&&r.isAssignmentNode===!0&&r.constructor.prototype.isNode===!0||!1}function g0(r){return r&&r.isBlockNode===!0&&r.constructor.prototype.isNode===!0||!1}function y0(r){return r&&r.isConditionalNode===!0&&r.constructor.prototype.isNode===!0||!1}function sr(r){return r&&r.isConstantNode===!0&&r.constructor.prototype.isNode===!0||!1}function zo(r){return sr(r)||_r(r)&&r.args.length===1&&sr(r.args[0])&&"-+~".includes(r.op)}function Ia(r){return r&&r.isFunctionAssignmentNode===!0&&r.constructor.prototype.isNode===!0||!1}function An(r){return r&&r.isFunctionNode===!0&&r.constructor.prototype.isNode===!0||!1}function Ln(r){return r&&r.isIndexNode===!0&&r.constructor.prototype.isNode===!0||!1}function or(r){return r&&r.isNode===!0&&r.constructor.prototype.isNode===!0||!1}function ii(r){return r&&r.isObjectNode===!0&&r.constructor.prototype.isNode===!0||!1}function _r(r){return r&&r.isOperatorNode===!0&&r.constructor.prototype.isNode===!0||!1}function rn(r){return r&&r.isParenthesisNode===!0&&r.constructor.prototype.isNode===!0||!1}function b0(r){return r&&r.isRangeNode===!0&&r.constructor.prototype.isNode===!0||!1}function x0(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 Yu(r){return r&&r.constructor.prototype.isChain===!0||!1}function gr(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 ke(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 ke(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 w0(r,ke)}function w0(r,e){var t={};for(var a in r)Re(r,a)&&(t[a]=e(r[a]));return t}function Qu(r,e){for(var t in e)Re(e,t)&&(r[t]=e[t]);return r}function Ra(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(!Ra(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)||!Ra(r[t],e[t]))return!1;for(t in e)if(!(t in r))return!1;return!0}else return r===e}}function N0(r,e,t){var a=!0,n;Object.defineProperty(r,e,{get:function(){return a&&(n=t(),a=!1),n},set:function(s){n=s,a=!1},configurable:!0,enumerable:!0})}function Re(r,e){return r&&Object.hasOwnProperty.call(r,e)}function D0(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 A0=["Matrix","Array"],E0=["number","BigNumber","Fraction"],de=function(e){if(e)throw new Error(`The global config is readonly.
1
+ (function(Vr,Ne){typeof exports=="object"&&typeof module<"u"?Ne(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],Ne):(Vr=typeof globalThis<"u"?globalThis:Vr||self,Ne(Vr.DiceRollerVue={},Vr.Vue))})(this,function(Vr,Ne){"use strict";var xI=Object.defineProperty;var wI=(Vr,Ne,Sr)=>Ne in Vr?xI(Vr,Ne,{enumerable:!0,configurable:!0,writable:!0,value:Sr}):Vr[Ne]=Sr;var tt=(Vr,Ne,Sr)=>(wI(Vr,typeof Ne!="symbol"?Ne+"":Ne,Sr),Sr);function Sr(){return Sr=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=t[a])}return r},Sr.apply(this,arguments)}var ol={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function tr(r){return typeof r=="number"}function rr(r){return!r||typeof r!="object"||typeof r.constructor!="function"?!1:r.isBigNumber===!0&&typeof r.constructor.prototype=="object"&&r.constructor.prototype.isBigNumber===!0||typeof r.constructor.isDecimal=="function"&&r.constructor.isDecimal(r)===!0}function kt(r){return r&&typeof r=="object"&&Object.getPrototypeOf(r).isComplex===!0||!1}function za(r){return r&&typeof r=="object"&&Object.getPrototypeOf(r).isFraction===!0||!1}function Vt(r){return r&&r.constructor.prototype.isUnit===!0||!1}function Wr(r){return typeof r=="string"}var cr=Array.isArray;function Ve(r){return r&&r.constructor.prototype.isMatrix===!0||!1}function Ft(r){return Array.isArray(r)||Ve(r)}function ui(r){return r&&r.isDenseMatrix&&r.constructor.prototype.isMatrix===!0||!1}function En(r){return r&&r.isSparseMatrix&&r.constructor.prototype.isMatrix===!0||!1}function Uo(r){return r&&r.constructor.prototype.isRange===!0||!1}function li(r){return r&&r.constructor.prototype.isIndex===!0||!1}function R0(r){return typeof r=="boolean"}function _0(r){return r&&r.constructor.prototype.isResultSet===!0||!1}function sl(r){return r&&r.constructor.prototype.isHelp===!0||!1}function q0(r){return typeof r=="function"}function z0(r){return r instanceof Date}function P0(r){return r instanceof RegExp}function Lo(r){return!!(r&&typeof r=="object"&&r.constructor===Object&&!kt(r)&&!za(r))}function U0(r){return r===null}function L0(r){return r===void 0}function Sn(r){return r&&r.isAccessorNode===!0&&r.constructor.prototype.isNode===!0||!1}function ot(r){return r&&r.isArrayNode===!0&&r.constructor.prototype.isNode===!0||!1}function k0(r){return r&&r.isAssignmentNode===!0&&r.constructor.prototype.isNode===!0||!1}function V0(r){return r&&r.isBlockNode===!0&&r.constructor.prototype.isNode===!0||!1}function G0(r){return r&&r.isConditionalNode===!0&&r.constructor.prototype.isNode===!0||!1}function ir(r){return r&&r.isConstantNode===!0&&r.constructor.prototype.isNode===!0||!1}function ko(r){return ir(r)||Br(r)&&r.args.length===1&&ir(r.args[0])&&"-+~".includes(r.op)}function Pa(r){return r&&r.isFunctionAssignmentNode===!0&&r.constructor.prototype.isNode===!0||!1}function nn(r){return r&&r.isFunctionNode===!0&&r.constructor.prototype.isNode===!0||!1}function Jn(r){return r&&r.isIndexNode===!0&&r.constructor.prototype.isNode===!0||!1}function fr(r){return r&&r.isNode===!0&&r.constructor.prototype.isNode===!0||!1}function ci(r){return r&&r.isObjectNode===!0&&r.constructor.prototype.isNode===!0||!1}function Br(r){return r&&r.isOperatorNode===!0&&r.constructor.prototype.isNode===!0||!1}function Gt(r){return r&&r.isParenthesisNode===!0&&r.constructor.prototype.isNode===!0||!1}function H0(r){return r&&r.isRangeNode===!0&&r.constructor.prototype.isNode===!0||!1}function Z0(r){return r&&r.isRelationalNode===!0&&r.constructor.prototype.isNode===!0||!1}function qr(r){return r&&r.isSymbolNode===!0&&r.constructor.prototype.isNode===!0||!1}function ul(r){return r&&r.constructor.prototype.isChain===!0||!1}function br(r){var e=typeof r;return e==="object"?r===null?"null":rr(r)?"BigNumber":r.constructor&&r.constructor.name?r.constructor.name:"Object":e}function Ge(r){var e=typeof r;if(e==="number"||e==="string"||e==="boolean"||r===null||r===void 0)return r;if(typeof r.clone=="function")return r.clone();if(Array.isArray(r))return r.map(function(t){return Ge(t)});if(r instanceof Date)return new Date(r.valueOf());if(rr(r))return r;if(r instanceof RegExp)throw new TypeError("Cannot clone "+r);return J0(r,Ge)}function J0(r,e){var t={};for(var a in r)Re(r,a)&&(t[a]=e(r[a]));return t}function ll(r,e){for(var t in e)Re(e,t)&&(r[t]=e[t]);return r}function Ua(r,e){var t,a,n;if(Array.isArray(r)){if(!Array.isArray(e)||r.length!==e.length)return!1;for(a=0,n=r.length;a<n;a++)if(!Ua(r[a],e[a]))return!1;return!0}else{if(typeof r=="function")return r===e;if(r instanceof Object){if(Array.isArray(e)||!(e instanceof Object))return!1;for(t in r)if(!(t in e)||!Ua(r[t],e[t]))return!1;for(t in e)if(!(t in r))return!1;return!0}else return r===e}}function X0(r,e,t){var a=!0,n;Object.defineProperty(r,e,{get:function(){return a&&(n=t(),a=!1),n},set:function(o){n=o,a=!1},configurable:!0,enumerable:!0})}function Re(r,e){return r&&Object.hasOwnProperty.call(r,e)}function W0(r,e){for(var t={},a=0;a<e.length;a++){var n=e[a],i=r[n];i!==void 0&&(t[n]=i)}return t}var Y0=["Matrix","Array"],Q0=["number","BigNumber","Fraction"],ge=function(e){if(e)throw new Error(`The global config is readonly.
2
2
  Please create a mathjs instance if you want to change the default configuration.
3
3
  Example:
4
4
 
5
5
  import { create, all } from 'mathjs';
6
6
  const mathjs = create(all);
7
7
  mathjs.config({ number: 'BigNumber' });
8
- `);return Object.freeze(Wu)};Ar(de,Wu,{MATRIX_OPTIONS:A0,NUMBER_OPTIONS:E0});function vt(r,e){var t=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=S0(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,s=!1,f;return{s:function(){t=t.call(r)},n:function(){var u=t.next();return i=u.done,u},e:function(u){s=!0,f=u},f:function(){try{!i&&t.return!=null&&t.return()}finally{if(s)throw f}}}}function S0(r,e){if(!!r){if(typeof r=="string")return Ku(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 Ku(r,e)}}function Ku(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 Un(r){return Un=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},Un(r)}function ju(){return!0}function at(){return!1}function kn(){}var el="Argument is not a typed-function.";function rl(){function r(q){return Un(q)==="object"&&q!==null&&q.constructor===Object}var e=[{name:"number",test:function(z){return typeof z=="number"}},{name:"string",test:function(z){return typeof z=="string"}},{name:"boolean",test:function(z){return typeof z=="boolean"}},{name:"Function",test:function(z){return typeof z=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(z){return z instanceof Date}},{name:"RegExp",test:function(z){return z instanceof RegExp}},{name:"Object",test:r},{name:"null",test:function(z){return z===null}},{name:"undefined",test:function(z){return z===void 0}}],t={name:"any",test:ju,isAny:!0},a,n,i=0,s={createCount:0};function f(q){var z=a.get(q);if(z)return z;var ee='Unknown type "'+q+'"',ue=q.toLowerCase(),me,ye=vt(n),be;try{for(ye.s();!(be=ye.n()).done;)if(me=be.value,me.toLowerCase()===ue){ee+='. Did you mean "'+me+'" ?';break}}catch(ve){ye.e(ve)}finally{ye.f()}throw new TypeError(ee)}function l(q){for(var z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any",ee=z?f(z).index:n.length,ue=[],me=0;me<q.length;++me){if(!q[me]||typeof q[me].name!="string"||typeof q[me].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");var ye=q[me].name;if(a.has(ye))throw new TypeError('Duplicate type name "'+ye+'"');ue.push(ye),a.set(ye,{name:ye,test:q[me].test,isAny:q[me].isAny,index:ee+me,conversionsTo:[]})}var be=n.slice(ee);n=n.slice(0,ee).concat(ue).concat(be);for(var ve=ee+ue.length;ve<n.length;++ve)a.get(n[ve]).index=ve}function u(){a=new Map,n=[],i=0,l([t],!1)}u(),l(e);function o(){var q,z=vt(n),ee;try{for(z.s();!(ee=z.n()).done;)q=ee.value,a.get(q).conversionsTo=[]}catch(ue){z.e(ue)}finally{z.f()}i=0}function c(q){var z=n.filter(function(ee){var ue=a.get(ee);return!ue.isAny&&ue.test(q)});return z.length?z:["any"]}function m(q){return q&&typeof q=="function"&&"_typedFunctionData"in q}function v(q,z,ee){if(!m(q))throw new TypeError(el);var ue=ee&&ee.exact,me=Array.isArray(z)?z.join(","):z,ye=w(me),be=y(ye);if(!ue||be in q.signatures){var ve=q._typedFunctionData.signatureMap.get(be);if(ve)return ve}var Ne=ye.length,Ie;if(ue){Ie=[];var Ge;for(Ge in q.signatures)Ie.push(q._typedFunctionData.signatureMap.get(Ge))}else Ie=q._typedFunctionData.signatures;for(var Be=0;Be<Ne;++Be){var lr=ye[Be],Je=[],cr=void 0,M=vt(Ie),H;try{for(M.s();!(H=M.n()).done;){cr=H.value;var se=N(cr.params,Be);if(!(!se||lr.restParam&&!se.restParam)){if(!se.hasAny){var De=function(){var Rr=d(se);if(lr.types.some(function(en){return!Rr.has(en.name)}))return"continue"}();if(De==="continue")continue}Je.push(cr)}}}catch(Rr){M.e(Rr)}finally{M.f()}if(Ie=Je,Ie.length===0)break}var ze,Le=vt(Ie),Mr;try{for(Le.s();!(Mr=Le.n()).done;)if(ze=Mr.value,ze.params.length<=Ne)return ze}catch(Rr){Le.e(Rr)}finally{Le.f()}throw new TypeError("Signature not found (signature: "+(q.name||"unnamed")+"("+y(ye,", ")+"))")}function p(q,z,ee){return v(q,z,ee).implementation}function h(q,z){var ee=f(z);if(ee.test(q))return q;var ue=ee.conversionsTo;if(ue.length===0)throw new Error("There are no conversions to "+z+" defined.");for(var me=0;me<ue.length;me++){var ye=f(ue[me].from);if(ye.test(q))return ue[me].convert(q)}throw new Error("Cannot convert "+q+" to "+z)}function y(q){var z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return q.map(function(ee){return ee.name}).join(z)}function b(q){var z=q.indexOf("...")===0,ee=z?q.length>3?q.slice(3):"any":q,ue=ee.split("|").map(function(ve){return f(ve.trim())}),me=!1,ye=z?"...":"",be=ue.map(function(ve){return me=ve.isAny||me,ye+=ve.name+"|",{name:ve.name,typeIndex:ve.index,test:ve.test,isAny:ve.isAny,conversion:null,conversionIndex:-1}});return{types:be,name:ye.slice(0,-1),hasAny:me,hasConversion:!1,restParam:z}}function A(q){var z=q.types.map(function(be){return be.name}),ee=F(z),ue=q.hasAny,me=q.name,ye=ee.map(function(be){var ve=f(be.from);return ue=ve.isAny||ue,me+="|"+be.from,{name:be.from,typeIndex:ve.index,test:ve.test,isAny:ve.isAny,conversion:be,conversionIndex:be.index}});return{types:q.types.concat(ye),name:me,hasAny:ue,hasConversion:ye.length>0,restParam:q.restParam}}function d(q){return q.typeSet||(q.typeSet=new Set,q.types.forEach(function(z){return q.typeSet.add(z.name)})),q.typeSet}function w(q){var z=[];if(typeof q!="string")throw new TypeError("Signatures must be strings");var ee=q.trim();if(ee==="")return z;for(var ue=ee.split(","),me=0;me<ue.length;++me){var ye=b(ue[me].trim());if(ye.restParam&&me!==ue.length-1)throw new SyntaxError('Unexpected rest parameter "'+ue[me]+'": only allowed for the last parameter');if(ye.types.length===0)return null;z.push(ye)}return z}function x(q){var z=ce(q);return z?z.restParam:!1}function g(q){if(!q||q.types.length===0)return ju;if(q.types.length===1)return f(q.types[0].name).test;if(q.types.length===2){var z=f(q.types[0].name).test,ee=f(q.types[1].name).test;return function(ye){return z(ye)||ee(ye)}}else{var ue=q.types.map(function(me){return f(me.name).test});return function(ye){for(var be=0;be<ue.length;be++)if(ue[be](ye))return!0;return!1}}}function E(q){var z,ee,ue;if(x(q)){z=pe(q).map(g);var me=z.length,ye=g(ce(q)),be=function(Ne){for(var Ie=me;Ie<Ne.length;Ie++)if(!ye(Ne[Ie]))return!1;return!0};return function(Ne){for(var Ie=0;Ie<z.length;Ie++)if(!z[Ie](Ne[Ie]))return!1;return be(Ne)&&Ne.length>=me+1}}else return q.length===0?function(Ne){return Ne.length===0}:q.length===1?(ee=g(q[0]),function(Ne){return ee(Ne[0])&&Ne.length===1}):q.length===2?(ee=g(q[0]),ue=g(q[1]),function(Ne){return ee(Ne[0])&&ue(Ne[1])&&Ne.length===2}):(z=q.map(g),function(Ne){for(var Ie=0;Ie<z.length;Ie++)if(!z[Ie](Ne[Ie]))return!1;return Ne.length===z.length})}function N(q,z){return z<q.length?q[z]:x(q)?ce(q):null}function S(q,z){var ee=N(q,z);return ee?d(ee):new Set}function D(q){return q.conversion===null||q.conversion===void 0}function T(q,z){var ee=new Set;return q.forEach(function(ue){var me=S(ue.params,z),ye,be=vt(me),ve;try{for(be.s();!(ve=be.n()).done;)ye=ve.value,ee.add(ye)}catch(Ne){be.e(Ne)}finally{be.f()}}),ee.has("any")?["any"]:Array.from(ee)}function B(q,z,ee){var ue,me,ye=q||"unnamed",be=ee,ve,Ne=function(){var M=[];if(be.forEach(function(se){var De=N(se.params,ve),ze=g(De);(ve<se.params.length||x(se.params))&&ze(z[ve])&&M.push(se)}),M.length===0){if(me=T(be,ve),me.length>0){var H=c(z[ve]);return ue=new TypeError("Unexpected type of argument in function "+ye+" (expected: "+me.join(" or ")+", actual: "+H.join(" | ")+", index: "+ve+")"),ue.data={category:"wrongType",fn:ye,index:ve,actual:H,expected:me},{v:ue}}}else be=M};for(ve=0;ve<z.length;ve++){var Ie=Ne();if(Un(Ie)==="object")return Ie.v}var Ge=be.map(function(cr){return x(cr.params)?1/0:cr.params.length});if(z.length<Math.min.apply(null,Ge))return me=T(be,ve),ue=new TypeError("Too few arguments in function "+ye+" (expected: "+me.join(" or ")+", index: "+z.length+")"),ue.data={category:"tooFewArgs",fn:ye,index:z.length,expected:me},ue;var Be=Math.max.apply(null,Ge);if(z.length>Be)return ue=new TypeError("Too many arguments in function "+ye+" (expected: "+Be+", actual: "+z.length+")"),ue.data={category:"tooManyArgs",fn:ye,index:z.length,expectedLength:Be},ue;for(var lr=[],Je=0;Je<z.length;++Je)lr.push(c(z[Je]).join("|"));return ue=new TypeError('Arguments of type "'+lr.join(", ")+'" do not match any of the defined signatures of function '+ye+"."),ue.data={category:"mismatch",actual:lr},ue}function _(q){for(var z=n.length+1,ee=0;ee<q.types.length;ee++)D(q.types[ee])&&(z=Math.min(z,q.types[ee].typeIndex));return z}function L(q){for(var z=i+1,ee=0;ee<q.types.length;ee++)D(q.types[ee])||(z=Math.min(z,q.types[ee].conversionIndex));return z}function G(q,z){if(q.hasAny){if(!z.hasAny)return 1}else if(z.hasAny)return-1;if(q.restParam){if(!z.restParam)return 1}else if(z.restParam)return-1;if(q.hasConversion){if(!z.hasConversion)return 1}else if(z.hasConversion)return-1;var ee=_(q)-_(z);if(ee<0)return-1;if(ee>0)return 1;var ue=L(q)-L(z);return ue<0?-1:ue>0?1:0}function C(q,z){var ee=q.params,ue=z.params,me=ce(ee),ye=ce(ue),be=x(ee),ve=x(ue);if(be&&me.hasAny){if(!ve||!ye.hasAny)return 1}else if(ve&&ye.hasAny)return-1;var Ne=0,Ie=0,Ge,Be=vt(ee),lr;try{for(Be.s();!(lr=Be.n()).done;)Ge=lr.value,Ge.hasAny&&++Ne,Ge.hasConversion&&++Ie}catch(qn){Be.e(qn)}finally{Be.f()}var Je=0,cr=0,M=vt(ue),H;try{for(M.s();!(H=M.n()).done;)Ge=H.value,Ge.hasAny&&++Je,Ge.hasConversion&&++cr}catch(qn){M.e(qn)}finally{M.f()}if(Ne!==Je)return Ne-Je;if(be&&me.hasConversion){if(!ve||!ye.hasConversion)return 1}else if(ve&&ye.hasConversion)return-1;if(Ie!==cr)return Ie-cr;if(be){if(!ve)return 1}else if(ve)return-1;var se=(ee.length-ue.length)*(be?-1:1);if(se!==0)return se;for(var De=[],ze=0,Le=0;Le<ee.length;++Le){var Mr=G(ee[Le],ue[Le]);De.push(Mr),ze+=Mr}if(ze!==0)return ze;for(var Rr,en=0,Ca=De;en<Ca.length;en++)if(Rr=Ca[en],Rr!==0)return Rr;return 0}function F(q){if(q.length===0)return[];var z=q.map(f);q.length>1&&z.sort(function(Ne,Ie){return Ne.index-Ie.index});var ee=z[0].conversionsTo;if(q.length===1)return ee;ee=ee.concat([]);for(var ue=new Set(q),me=1;me<z.length;++me){var ye=void 0,be=vt(z[me].conversionsTo),ve;try{for(be.s();!(ve=be.n()).done;)ye=ve.value,ue.has(ye.from)||(ee.push(ye),ue.add(ye.from))}catch(Ne){be.e(Ne)}finally{be.f()}}return ee}function Z(q,z){var ee=z;if(q.some(function(ve){return ve.hasConversion})){var ue=x(q),me=q.map($);ee=function(){for(var Ne=[],Ie=ue?arguments.length-1:arguments.length,Ge=0;Ge<Ie;Ge++)Ne[Ge]=me[Ge](arguments[Ge]);return ue&&(Ne[Ie]=arguments[Ie].map(me[Ie])),z.apply(this,Ne)}}var ye=ee;if(x(q)){var be=q.length-1;ye=function(){return ee.apply(this,oe(arguments,0,be).concat([oe(arguments,be)]))}}return ye}function $(q){var z,ee,ue,me,ye=[],be=[];switch(q.types.forEach(function(ve){ve.conversion&&(ye.push(f(ve.conversion.from).test),be.push(ve.conversion.convert))}),be.length){case 0:return function(Ne){return Ne};case 1:return z=ye[0],ue=be[0],function(Ne){return z(Ne)?ue(Ne):Ne};case 2:return z=ye[0],ee=ye[1],ue=be[0],me=be[1],function(Ne){return z(Ne)?ue(Ne):ee(Ne)?me(Ne):Ne};default:return function(Ne){for(var Ie=0;Ie<be.length;Ie++)if(ye[Ie](Ne))return be[Ie](Ne);return Ne}}}function U(q){function z(ee,ue,me){if(ue<ee.length){var ye=ee[ue],be=[];if(ye.restParam){var ve=ye.types.filter(D);ve.length<ye.types.length&&be.push({types:ve,name:"..."+ve.map(function(Ne){return Ne.name}).join("|"),hasAny:ve.some(function(Ne){return Ne.isAny}),hasConversion:!1,restParam:!0}),be.push(ye)}else be=ye.types.map(function(Ne){return{types:[Ne],name:Ne.name,hasAny:Ne.isAny,hasConversion:Ne.conversion,restParam:!1}});return Oe(be,function(Ne){return z(ee,ue+1,me.concat([Ne]))})}else return[me]}return z(q,0,[])}function Y(q,z){for(var ee=Math.max(q.length,z.length),ue=0;ue<ee;ue++){var me=S(q,ue),ye=S(z,ue),be=!1,ve=void 0,Ne=vt(ye),Ie;try{for(Ne.s();!(Ie=Ne.n()).done;)if(ve=Ie.value,me.has(ve)){be=!0;break}}catch(cr){Ne.e(cr)}finally{Ne.f()}if(!be)return!1}var Ge=q.length,Be=z.length,lr=x(q),Je=x(z);return lr?Je?Ge===Be:Be>=Ge:Je?Ge>=Be:Ge===Be}function j(q){return q.map(function(z){return ie(z)?k(z.referToSelf.callback):W(z)?$e(z.referTo.references,z.referTo.callback):z})}function P(q,z,ee){var ue=[],me,ye=vt(q),be;try{for(ye.s();!(be=ye.n()).done;){me=be.value;var ve=ee[me];if(typeof ve!="number")throw new TypeError('No definition for referenced signature "'+me+'"');if(ve=z[ve],typeof ve!="function")return!1;ue.push(ve)}}catch(Ne){ye.e(Ne)}finally{ye.f()}return ue}function K(q,z,ee){for(var ue=j(q),me=new Array(ue.length).fill(!1),ye=!0;ye;){ye=!1;for(var be=!0,ve=0;ve<ue.length;++ve)if(!me[ve]){var Ne=ue[ve];if(ie(Ne))ue[ve]=Ne.referToSelf.callback(ee),ue[ve].referToSelf=Ne.referToSelf,me[ve]=!0,be=!1;else if(W(Ne)){var Ie=P(Ne.referTo.references,ue,z);Ie?(ue[ve]=Ne.referTo.callback.apply(this,Ie),ue[ve].referTo=Ne.referTo,me[ve]=!0,be=!1):ye=!0}}if(be&&ye)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return ue}function ne(q){var z=/\bthis(\(|\.signatures\b)/;Object.keys(q).forEach(function(ee){var ue=q[ee];if(z.test(ue.toString()))throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function re(q,z){if(s.createCount++,Object.keys(z).length===0)throw new SyntaxError("No signatures provided");s.warnAgainstDeprecatedThis&&ne(z);var ee=[],ue=[],me={},ye=[],be,ve=function(){if(!Object.prototype.hasOwnProperty.call(z,be))return"continue";var Or=w(be);if(!Or)return"continue";ee.forEach(function(Rt){if(Y(Rt,Or))throw new TypeError('Conflicting signatures "'+y(Rt)+'" and "'+y(Or)+'".')}),ee.push(Or);var Eo=ue.length;ue.push(z[be]);var Vu=Or.map(A),Ta=void 0,Ba=vt(U(Vu)),So;try{for(Ba.s();!(So=Ba.n()).done;){Ta=So.value;var Co=y(Ta);ye.push({params:Ta,name:Co,fn:Eo}),Ta.every(function(Rt){return!Rt.hasConversion})&&(me[Co]=Eo)}}catch(Rt){Ba.e(Rt)}finally{Ba.f()}};for(be in z)var Ne=ve();ye.sort(C);var Ie=K(ue,me,It),Ge;for(Ge in me)Object.prototype.hasOwnProperty.call(me,Ge)&&(me[Ge]=Ie[me[Ge]]);for(var Be=[],lr=new Map,Je=0,cr=ye;Je<cr.length;Je++)Ge=cr[Je],lr.has(Ge.name)||(Ge.fn=Ie[Ge.fn],Be.push(Ge),lr.set(Ge.name,Ge));for(var M=Be[0]&&Be[0].params.length<=2&&!x(Be[0].params),H=Be[1]&&Be[1].params.length<=2&&!x(Be[1].params),se=Be[2]&&Be[2].params.length<=2&&!x(Be[2].params),De=Be[3]&&Be[3].params.length<=2&&!x(Be[3].params),ze=Be[4]&&Be[4].params.length<=2&&!x(Be[4].params),Le=Be[5]&&Be[5].params.length<=2&&!x(Be[5].params),Mr=M&&H&&se&&De&&ze&&Le,Rr=0;Rr<Be.length;++Rr)Be[Rr].test=E(Be[Rr].params);for(var en=M?g(Be[0].params[0]):at,Ca=H?g(Be[1].params[0]):at,qn=se?g(Be[2].params[0]):at,xu=De?g(Be[3].params[0]):at,wu=ze?g(Be[4].params[0]):at,Nu=Le?g(Be[5].params[0]):at,Du=M?g(Be[0].params[1]):at,Au=H?g(Be[1].params[1]):at,Eu=se?g(Be[2].params[1]):at,Su=De?g(Be[3].params[1]):at,Cu=ze?g(Be[4].params[1]):at,Mu=Le?g(Be[5].params[1]):at,zn=0;zn<Be.length;++zn)Be[zn].implementation=Z(Be[zn].params,Be[zn].fn);var Ma=M?Be[0].implementation:kn,Fa=H?Be[1].implementation:kn,Fu=se?Be[2].implementation:kn,Tu=De?Be[3].implementation:kn,Bu=ze?Be[4].implementation:kn,$u=Le?Be[5].implementation:kn,Ou=M?Be[0].params.length:-1,_u=H?Be[1].params.length:-1,Iu=se?Be[2].params.length:-1,Ru=De?Be[3].params.length:-1,qu=ze?Be[4].params.length:-1,zu=Le?Be[5].params.length:-1,Pu=Mr?6:0,Lu=Be.length,Ao=Be.map(function(Kr){return Kr.test}),Uu=Be.map(function(Kr){return Kr.implementation}),ku=function(){for(var Or=Pu;Or<Lu;Or++)if(Ao[Or](arguments))return Uu[Or].apply(this,arguments);return s.onMismatch(q,arguments,Be)};function It(Kr,Or){return arguments.length===Ou&&en(Kr)&&Du(Or)?Ma.apply(this,arguments):arguments.length===_u&&Ca(Kr)&&Au(Or)?Fa.apply(this,arguments):arguments.length===Iu&&qn(Kr)&&Eu(Or)?Fu.apply(this,arguments):arguments.length===Ru&&xu(Kr)&&Su(Or)?Tu.apply(this,arguments):arguments.length===qu&&wu(Kr)&&Cu(Or)?Bu.apply(this,arguments):arguments.length===zu&&Nu(Kr)&&Mu(Or)?$u.apply(this,arguments):ku.apply(this,arguments)}try{Object.defineProperty(It,"name",{value:q})}catch{}return It.signatures=me,It._typedFunctionData={signatures:Be,signatureMap:lr},It}function fe(q,z,ee){throw B(q,z,ee)}function pe(q){return oe(q,0,q.length-1)}function ce(q){return q[q.length-1]}function oe(q,z,ee){return Array.prototype.slice.call(q,z,ee)}function Ce(q,z){for(var ee=0;ee<q.length;ee++)if(z(q[ee]))return q[ee]}function Oe(q,z){return Array.prototype.concat.apply([],q.map(z))}function Me(){var q=pe(arguments).map(function(ee){return y(w(ee))}),z=ce(arguments);if(typeof z!="function")throw new TypeError("Callback function expected as last argument");return $e(q,z)}function $e(q,z){return{referTo:{references:q,callback:z}}}function k(q){if(typeof q!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:q}}}function W(q){return q&&Un(q.referTo)==="object"&&Array.isArray(q.referTo.references)&&typeof q.referTo.callback=="function"}function ie(q){return q&&Un(q.referToSelf)==="object"&&typeof q.referToSelf.callback=="function"}function V(q,z){if(!q)return z;if(z&&z!==q){var ee=new Error("Function names do not match (expected: "+q+", actual: "+z+")");throw ee.data={actual:z,expected:q},ee}return q}function Q(q){var z;for(var ee in q)Object.prototype.hasOwnProperty.call(q,ee)&&(m(q[ee])||typeof q[ee].signature=="string")&&(z=V(z,q[ee].name));return z}function te(q,z){var ee;for(ee in z)if(Object.prototype.hasOwnProperty.call(z,ee)){if(ee in q&&z[ee]!==q[ee]){var ue=new Error('Signature "'+ee+'" is defined twice');throw ue.data={signature:ee,sourceFunction:z[ee],destFunction:q[ee]},ue}q[ee]=z[ee]}}var ge=s;s=function(z){for(var ee=typeof z=="string",ue=ee?1:0,me=ee?z:"",ye={},be=ue;be<arguments.length;++be){var ve=arguments[be],Ne={},Ie=void 0;if(typeof ve=="function"?(Ie=ve.name,typeof ve.signature=="string"?Ne[ve.signature]=ve:m(ve)&&(Ne=ve.signatures)):r(ve)&&(Ne=ve,ee||(Ie=Q(ve))),Object.keys(Ne).length===0){var Ge=new TypeError("Argument to 'typed' at index "+be+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw Ge.data={index:be,argument:ve},Ge}ee||(me=V(me,Ie)),te(ye,Ne)}return re(me||"",ye)},s.create=rl,s.createCount=ge.createCount,s.onMismatch=fe,s.throwMismatchError=fe,s.createError=B,s.clear=u,s.clearConversions=o,s.addTypes=l,s._findType=f,s.referTo=Me,s.referToSelf=k,s.convert=h,s.findSignature=v,s.find=p,s.isTypedFunction=m,s.warnAgainstDeprecatedThis=!0,s.addType=function(q,z){var ee="any";z!==!1&&a.has("Object")&&(ee="Object"),s.addTypes([q],ee)};function he(q){if(!q||typeof q.from!="string"||typeof q.to!="string"||typeof q.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(q.to===q.from)throw new SyntaxError('Illegal to define conversion from "'+q.from+'" to itself.')}return s.addConversion=function(q){he(q);var z=f(q.to);if(z.conversionsTo.every(function(ee){return ee.from!==q.from}))z.conversionsTo.push({from:q.from,convert:q.convert,index:i++});else throw new Error('There is already a conversion from "'+q.from+'" to "'+z.name+'"')},s.addConversions=function(q){q.forEach(s.addConversion)},s.removeConversion=function(q){he(q);var z=f(q.to),ee=Ce(z.conversionsTo,function(me){return me.from===q.from});if(!ee)throw new Error("Attempt to remove nonexistent conversion from "+q.from+" to "+q.to);if(ee.convert!==q.convert)throw new Error("Conversion to remove does not match existing conversion");var ue=z.conversionsTo.indexOf(ee);z.conversionsTo.splice(ue,1)},s.resolve=function(q,z){if(!m(q))throw new TypeError(el);for(var ee=q._typedFunctionData.signatures,ue=0;ue<ee.length;++ue)if(ee[ue].test(z))return ee[ue];return null},s}const tl=rl();function qe(r){return typeof r=="boolean"?!0:isFinite(r)?r===Math.round(r):!1}var tn=Math.sign||function(r){return r>0?1:r<0?-1:0},C0=Math.log2||function(e){return Math.log(e)/Math.LN2},M0=Math.log10||function(e){return Math.log(e)/Math.LN10},F0=Math.log1p||function(r){return Math.log(r+1)},T0=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},B0=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function Po(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 s="";return r<0&&(r=-r,s="-"),"".concat(s).concat(n).concat(r.toString(e)).concat(i)}function En(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 nl(r,a);case"exponential":return al(r,a);case"engineering":return $0(r,a);case"bin":return Po(r,2,n);case"oct":return Po(r,8,n);case"hex":return Po(r,16,n);case"auto":return O0(r,a,e&&e).replace(/((\.\d*?)(0+))($|e)/,function(){var i=arguments[2],s=arguments[4];return i!=="."?i+s:s});default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function oi(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 s=a.replace(".","").replace(/^0*/,function(f){return n-=f.length,""}).replace(/0*$/,"").split("").map(function(f){return parseInt(f)});return s.length===0&&(s.push(0),n++),{sign:t,coefficients:s,exponent:n}}function $0(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=oi(r),a=si(t,e),n=a.exponent,i=a.coefficients,s=n%3===0?n:n<0?n-3-n%3:n-n%3;if(tr(e))for(;e>i.length||n-s+1>i.length;)i.push(0);else for(var f=Math.abs(n-s)-(i.length-1),l=0;l<f;l++)i.push(0);for(var u=Math.abs(n-s),o=1;u>0;)o++,u--;var c=i.slice(o).join(""),m=tr(e)&&c.length||c.match(/[1-9]/)?"."+c:"",v=i.slice(0,o).join("")+m+"e"+(n>=0?"+":"")+s.toString();return a.sign+v}function nl(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=oi(r),a=typeof e=="number"?si(t,t.exponent+1+e):t,n=a.coefficients,i=a.exponent+1,s=i+(e||0);return n.length<s&&(n=n.concat(Vn(s-n.length))),i<0&&(n=Vn(-i+1).concat(n),i=1),i<n.length&&n.splice(i,0,i===0?"0.":"."),a.sign+n.join("")}function al(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=oi(r),a=e?si(t,e):t,n=a.coefficients,i=a.exponent;n.length<e&&(n=n.concat(Vn(e-n.length)));var s=n.shift();return a.sign+s+(n.length>0?"."+n.join(""):"")+"e"+(i>=0?"+":"")+i}function O0(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=oi(r),s=e?si(i,e):i;if(s.exponent<a||s.exponent>=n)return al(r,e);var f=s.coefficients,l=s.exponent;f.length<e&&(f=f.concat(Vn(e-f.length))),f=f.concat(Vn(l-f.length+1+(f.length<e?e-f.length:0))),f=Vn(-l).concat(f);var u=l>0?l:0;return u<f.length-1&&f.splice(u+1,0,"."),s.sign+f.join("")}function si(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 Vn(r){for(var e=[],t=0;t<r;t++)e.push(0);return e}function _0(r){return r.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var I0=Number.EPSILON||2220446049250313e-31;function et(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<I0?!0:a<=Math.max(Math.abs(r),Math.abs(e))*t}return!1}var R0=Math.acosh||function(r){return Math.log(Math.sqrt(r*r-1)+r)},q0=Math.asinh||function(r){return Math.log(Math.sqrt(r*r+1)+r)},z0=Math.atanh||function(r){return Math.log((1+r)/(1-r))/2},P0=Math.cosh||function(r){return(Math.exp(r)+Math.exp(-r))/2},L0=Math.sinh||function(r){return(Math.exp(r)-Math.exp(-r))/2},U0=Math.tanh||function(r){var e=Math.exp(2*r);return(e-1)/(e+1)};function k0(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 Lo(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 V0(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 H0(r,a);case"exponential":return il(r,a);case"engineering":return G0(r,a);case"bin":return Lo(r,2,n);case"oct":return Lo(r,8,n);case"hex":return Lo(r,16,n);case"auto":{var i=e&&e.lowerExp!==void 0?e.lowerExp:-3,s=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<s?f=l.toFixed():f=il(r,a),f.replace(/((\.\d*?)(0+))($|e)/,function(){var o=arguments[2],c=arguments[4];return o!=="."?o+c:c})}default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function G0(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 il(r,e){return e!==void 0?r.toExponential(e-1):r.toExponential()}function H0(r,e){return r.toFixed(e)}function Z0(r,e){var t=r.length-e.length,a=r.length;return r.substring(t,a)===e}function Ye(r,e){var t=J0(r,e);return e&&typeof e=="object"&&"truncate"in e&&t.length>e.truncate?t.substring(0,e.truncate-3)+"...":t}function J0(r,e){if(typeof r=="number")return En(r,e);if(rr(r))return V0(r,e);if(W0(r))return!e||e.fraction!=="decimal"?r.s*r.n+"/"+r.d:r.toString();if(Array.isArray(r))return ol(r,e);if(Wr(r))return'"'+r+'"';if(typeof r=="function")return r.syntax?String(r.syntax):"function";if(r&&typeof r=="object"){if(typeof r.format=="function")return r.format(e);if(r&&r.toString(e)!=={}.toString())return r.toString(e);var t=Object.keys(r).map(a=>'"'+a+'": '+Ye(r[a],e));return"{"+t.join(", ")+"}"}return String(r)}function ui(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 it(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 ol(r,e){if(Array.isArray(r)){for(var t="[",a=r.length,n=0;n<a;n++)n!==0&&(t+=", "),t+=ol(r[n],e);return t+="]",t}else return Ye(r,e)}function W0(r){return r&&typeof r=="object"&&typeof r.s=="number"&&typeof r.n=="number"&&typeof r.d=="number"||!1}function Uo(r,e){if(!Wr(r))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+gr(r)+", index: 0)");if(!Wr(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+gr(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 sl(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 s=r[a];if(!Array.isArray(s))throw new Ke(e.length-1,e.length,"<");sl(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 ul(r,e){var t=e.length===0;if(t){if(Array.isArray(r))throw new Ke(r.length,0)}else sl(r,e,0)}function mr(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 Gn(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 ko(r,e,0,a),r}function ko(r,e,t,a){var n,i,s=r.length,f=e[t],l=Math.min(s,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),ko(i,e,u,a);for(n=l;n<f;n++)i=[],r[n]=i,ko(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 ll(r,e){var t=ar(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=Vo(e,a);var n=cl(e);if(a!==n)throw new Ke(n,a,"!=");try{return X0(t,e)}catch(i){throw i instanceof Ke?new Ke(n,a,"!="):i}}function Vo(r,e){var t=cl(r),a=r.slice(),n=-1,i=r.indexOf(n),s=r.indexOf(n,i+1)>=0;if(s)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 cl(r){return r.reduce((e,t)=>e*t,1)}function X0(r,e){for(var t=r,a,n=e.length-1;n>0;n--){var i=e[n];a=[];for(var s=t.length/i,f=0;f<s;f++)a.push(t.slice(f*i,(f+1)*i));t=a}return t}function li(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=fl(r,a,0),t.length=a),r}function fl(r,e,t){var a,n;if(t<e){var i=t+1;for(a=0,n=r.length;a<n;a++)r[a]=fl(r[a],e,i)}else for(;Array.isArray(r);)r=r[0];return r}function ml(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=vl(r,e,0);n.length<e;)n.push(1);return r}function vl(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]=vl(r[a],e,i)}else for(var s=t;s<e;s++)r=[r];return r}function ar(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 Ut(r,e){return Array.prototype.map.call(r,e)}function ci(r,e){Array.prototype.forEach.call(r,e)}function pl(r,e){if(er(r).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(r,e)}function fi(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 hl(r,e){return Array.prototype.join.call(r,e)}function Hn(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 mi(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 qa(r,e){for(var t,a=0,n=0;n<r.length;n++){var i=r[n],s=Array.isArray(i);if(n===0&&s&&(a=i.length),s&&i.length!==a)return;var f=s?qa(i,e):e(i);if(t===void 0)t=f;else if(t!==f)return"mixed"}return t}function R(r,e,t,a){function n(i){var s=D0(i,e.map(K0));return Y0(r,e,i),t(s)}return n.isFactory=!0,n.fn=r,n.dependencies=e.slice().sort(),a&&(n.meta=a),n}function Y0(r,e,t){var a=e.filter(i=>!Q0(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 Q0(r){return r&&r[0]==="?"}function K0(r){return r&&r[0]==="?"?r.slice(1):r}function ot(r,e){if(dl(r)&&Go(r,e))return r[e];throw typeof r[e]=="function"&&Ho(r,e)?new Error('Cannot access method "'+e+'" as a property'):new Error('No access to property "'+e+'"')}function Zn(r,e,t){if(dl(r)&&Go(r,e))return r[e]=t,t;throw new Error('No access to property "'+e+'"')}function j0(r,e){return e in r}function Go(r,e){return!r||typeof r!="object"?!1:Re(rg,e)?!0:!(e in Object.prototype||e in Function.prototype)}function eg(r,e){if(!Ho(r,e))throw new Error('No access to method "'+e+'"')}function Ho(r,e){return r==null||typeof r[e]!="function"||Re(r,e)&&Object.getPrototypeOf&&e in Object.getPrototypeOf(r)?!1:Re(tg,e)?!0:!(e in Object.prototype||e in Function.prototype)}function dl(r){return typeof r=="object"&&r&&r.constructor===Object}var rg={length:!0,name:!0},tg={toString:!0,valueOf:!0,toLocaleString:!0};class Zo{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return ot(this.wrappedObject,e)}set(e,t){return Zn(this.wrappedObject,e,t),this}has(e){return j0(this.wrappedObject,e)}}function Jn(){return new Map}function Wn(r){if(!r)return Jn();if(Jo(r))return r;if(qo(r))return new Zo(r);throw new Error("createMap can create maps from objects or Maps")}function ng(r){if(r instanceof Zo)return r.wrappedObject;var e={};for(var t of r.keys()){var a=r.get(t);Zn(e,t,a)}return e}function Jo(r){return r?r instanceof Map||r instanceof Zo||typeof r.set=="function"&&typeof r.get=="function"&&typeof r.keys=="function"&&typeof r.has=="function":!1}function gl(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(Jo(n))for(var i of n.keys())r.set(i,n.get(i));else if(qo(n))for(var s of Object.keys(n))r.set(s,n[s])}return r}var yl=function(){return yl=tl.create,tl},ag=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],ig=R("typed",ag,function(e){var{BigNumber:t,Complex:a,DenseMatrix:n,Fraction:i}=e,s=yl();return s.clear(),s.addTypes([{name:"number",test:tr},{name:"Complex",test:zt},{name:"BigNumber",test:rr},{name:"Fraction",test:_a},{name:"Unit",test:Pt},{name:"identifier",test:f=>Wr&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\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\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\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\uDD50-\uDD52\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]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\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-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])(?:[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\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\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\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\uDD50-\uDD52\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]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\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-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])*$/.test(f)},{name:"string",test:Wr},{name:"Chain",test:Yu},{name:"Array",test:ur},{name:"Matrix",test:He},{name:"DenseMatrix",test:ni},{name:"SparseMatrix",test:Nn},{name:"Range",test:Ro},{name:"Index",test:ai},{name:"boolean",test:l0},{name:"ResultSet",test:c0},{name:"Help",test:Xu},{name:"function",test:f0},{name:"Date",test:m0},{name:"RegExp",test:v0},{name:"null",test:p0},{name:"undefined",test:h0},{name:"AccessorNode",test:Dn},{name:"ArrayNode",test:nt},{name:"AssignmentNode",test:d0},{name:"BlockNode",test:g0},{name:"ConditionalNode",test:y0},{name:"ConstantNode",test:sr},{name:"FunctionNode",test:An},{name:"FunctionAssignmentNode",test:Ia},{name:"IndexNode",test:Ln},{name:"Node",test:or},{name:"ObjectNode",test:ii},{name:"OperatorNode",test:_r},{name:"ParenthesisNode",test:rn},{name:"RangeNode",test:b0},{name:"RelationalNode",test:x0},{name:"SymbolNode",test:qr},{name:"Map",test:Jo},{name:"Object",test:qo}]),s.addConversions([{from:"number",to:"BigNumber",convert:function(l){if(t||Wo(l),_0(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||vi(l),new a(l,0)}},{from:"BigNumber",to:"Complex",convert:function(l){return a||vi(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||vi(l),new a(l.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(l){i||Xo(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||Wo(l);try{return new t(l)}catch{throw new Error('Cannot convert "'+l+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(l){i||Xo(l);try{return new i(l)}catch{throw new Error('Cannot convert "'+l+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(l){a||vi(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||Wo(l),new t(+l)}},{from:"boolean",to:"Fraction",convert:function(l){return i||Xo(l),new i(+l)}},{from:"boolean",to:"string",convert:function(l){return String(l)}},{from:"Array",to:"Matrix",convert:function(l){return n||og(),new n(l)}},{from:"Matrix",to:"Array",convert:function(l){return l.valueOf()}}]),s.onMismatch=(f,l,u)=>{var o=s.createError(f,l,u);if(["wrongType","mismatch"].includes(o.data.category)&&l.length===1&&Lt(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=o.data,c}throw o},s.onMismatch=(f,l,u)=>{var o=s.createError(f,l,u);if(["wrongType","mismatch"].includes(o.data.category)&&l.length===1&&Lt(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=o.data,c}throw o},s});function Wo(r){throw new Error("Cannot convert value ".concat(r," into a BigNumber: no class 'BigNumber' provided"))}function vi(r){throw new Error("Cannot convert value ".concat(r," into a Complex number: no class 'Complex' provided"))}function og(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function Xo(r){throw new Error("Cannot convert value ".concat(r," into a Fraction, no class 'Fraction' provided."))}var sg="ResultSet",ug=[],lg=R(sg,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.2
8
+ `);return Object.freeze(ol)};Sr(ge,ol,{MATRIX_OPTIONS:Y0,NUMBER_OPTIONS:Q0});function ht(r,e){var t=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=K0(r))||e&&r&&typeof r.length=="number"){t&&(r=t);var a=0,n=function(){};return{s:n,n:function(){return a>=r.length?{done:!0}:{done:!1,value:r[a++]}},e:function(u){throw u},f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
9
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i=!0,o=!1,f;return{s:function(){t=t.call(r)},n:function(){var u=t.next();return i=u.done,u},e:function(u){o=!0,f=u},f:function(){try{!i&&t.return!=null&&t.return()}finally{if(o)throw f}}}}function K0(r,e){if(!!r){if(typeof r=="string")return cl(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);if(t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set")return Array.from(r);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return cl(r,e)}}function cl(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,a=new Array(e);t<e;t++)a[t]=r[t];return a}function Xn(r){return Xn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Xn(r)}function fl(){return!0}function st(){return!1}function Wn(){}var ml="Argument is not a typed-function.";function vl(){function r(z){return Xn(z)==="object"&&z!==null&&z.constructor===Object}var e=[{name:"number",test:function(U){return typeof U=="number"}},{name:"string",test:function(U){return typeof U=="string"}},{name:"boolean",test:function(U){return typeof U=="boolean"}},{name:"Function",test:function(U){return typeof U=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(U){return U instanceof Date}},{name:"RegExp",test:function(U){return U instanceof RegExp}},{name:"Object",test:r},{name:"null",test:function(U){return U===null}},{name:"undefined",test:function(U){return U===void 0}}],t={name:"any",test:fl,isAny:!0},a,n,i=0,o={createCount:0};function f(z){var U=a.get(z);if(U)return U;var ee='Unknown type "'+z+'"',ue=z.toLowerCase(),ve,de=ht(n),be;try{for(de.s();!(be=de.n()).done;)if(ve=be.value,ve.toLowerCase()===ue){ee+='. Did you mean "'+ve+'" ?';break}}catch(pe){de.e(pe)}finally{de.f()}throw new TypeError(ee)}function l(z){for(var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any",ee=U?f(U).index:n.length,ue=[],ve=0;ve<z.length;++ve){if(!z[ve]||typeof z[ve].name!="string"||typeof z[ve].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");var de=z[ve].name;if(a.has(de))throw new TypeError('Duplicate type name "'+de+'"');ue.push(de),a.set(de,{name:de,test:z[ve].test,isAny:z[ve].isAny,index:ee+ve,conversionsTo:[]})}var be=n.slice(ee);n=n.slice(0,ee).concat(ue).concat(be);for(var pe=ee+ue.length;pe<n.length;++pe)a.get(n[pe]).index=pe}function u(){a=new Map,n=[],i=0,l([t],!1)}u(),l(e);function s(){var z,U=ht(n),ee;try{for(U.s();!(ee=U.n()).done;)z=ee.value,a.get(z).conversionsTo=[]}catch(ue){U.e(ue)}finally{U.f()}i=0}function c(z){var U=n.filter(function(ee){var ue=a.get(ee);return!ue.isAny&&ue.test(z)});return U.length?U:["any"]}function m(z){return z&&typeof z=="function"&&"_typedFunctionData"in z}function v(z,U,ee){if(!m(z))throw new TypeError(ml);var ue=ee&&ee.exact,ve=Array.isArray(U)?U.join(","):U,de=w(ve),be=g(de);if(!ue||be in z.signatures){var pe=z._typedFunctionData.signatureMap.get(be);if(pe)return pe}var we=de.length,_e;if(ue){_e=[];var Le;for(Le in z.signatures)_e.push(z._typedFunctionData.signatureMap.get(Le))}else _e=z._typedFunctionData.signatures;for(var Be=0;Be<we;++Be){var ar=de[Be],Je=[],mr=void 0,C=ht(_e),Z;try{for(C.s();!(Z=C.n()).done;){mr=Z.value;var se=A(mr.params,Be);if(!(!se||ar.restParam&&!se.restParam)){if(!se.hasAny){var Ee=function(){var _r=d(se);if(ar.types.some(function(tn){return!_r.has(tn.name)}))return"continue"}();if(Ee==="continue")continue}Je.push(mr)}}}catch(_r){C.e(_r)}finally{C.f()}if(_e=Je,_e.length===0)break}var ze,ke=ht(_e),Fr;try{for(ke.s();!(Fr=ke.n()).done;)if(ze=Fr.value,ze.params.length<=we)return ze}catch(_r){ke.e(_r)}finally{ke.f()}throw new TypeError("Signature not found (signature: "+(z.name||"unnamed")+"("+g(de,", ")+"))")}function h(z,U,ee){return v(z,U,ee).implementation}function p(z,U){var ee=f(U);if(ee.test(z))return z;var ue=ee.conversionsTo;if(ue.length===0)throw new Error("There are no conversions to "+U+" defined.");for(var ve=0;ve<ue.length;ve++){var de=f(ue[ve].from);if(de.test(z))return ue[ve].convert(z)}throw new Error("Cannot convert "+z+" to "+U)}function g(z){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return z.map(function(ee){return ee.name}).join(U)}function y(z){var U=z.indexOf("...")===0,ee=U?z.length>3?z.slice(3):"any":z,ue=ee.split("|").map(function(pe){return f(pe.trim())}),ve=!1,de=U?"...":"",be=ue.map(function(pe){return ve=pe.isAny||ve,de+=pe.name+"|",{name:pe.name,typeIndex:pe.index,test:pe.test,isAny:pe.isAny,conversion:null,conversionIndex:-1}});return{types:be,name:de.slice(0,-1),hasAny:ve,hasConversion:!1,restParam:U}}function N(z){var U=z.types.map(function(be){return be.name}),ee=F(U),ue=z.hasAny,ve=z.name,de=ee.map(function(be){var pe=f(be.from);return ue=pe.isAny||ue,ve+="|"+be.from,{name:be.from,typeIndex:pe.index,test:pe.test,isAny:pe.isAny,conversion:be,conversionIndex:be.index}});return{types:z.types.concat(de),name:ve,hasAny:ue,hasConversion:de.length>0,restParam:z.restParam}}function d(z){return z.typeSet||(z.typeSet=new Set,z.types.forEach(function(U){return z.typeSet.add(U.name)})),z.typeSet}function w(z){var U=[];if(typeof z!="string")throw new TypeError("Signatures must be strings");var ee=z.trim();if(ee==="")return U;for(var ue=ee.split(","),ve=0;ve<ue.length;++ve){var de=y(ue[ve].trim());if(de.restParam&&ve!==ue.length-1)throw new SyntaxError('Unexpected rest parameter "'+ue[ve]+'": only allowed for the last parameter');if(de.types.length===0)return null;U.push(de)}return U}function x(z){var U=ce(z);return U?U.restParam:!1}function b(z){if(!z||z.types.length===0)return fl;if(z.types.length===1)return f(z.types[0].name).test;if(z.types.length===2){var U=f(z.types[0].name).test,ee=f(z.types[1].name).test;return function(de){return U(de)||ee(de)}}else{var ue=z.types.map(function(ve){return f(ve.name).test});return function(de){for(var be=0;be<ue.length;be++)if(ue[be](de))return!0;return!1}}}function E(z){var U,ee,ue;if(x(z)){U=he(z).map(b);var ve=U.length,de=b(ce(z)),be=function(we){for(var _e=ve;_e<we.length;_e++)if(!de(we[_e]))return!1;return!0};return function(we){for(var _e=0;_e<U.length;_e++)if(!U[_e](we[_e]))return!1;return be(we)&&we.length>=ve+1}}else return z.length===0?function(we){return we.length===0}:z.length===1?(ee=b(z[0]),function(we){return ee(we[0])&&we.length===1}):z.length===2?(ee=b(z[0]),ue=b(z[1]),function(we){return ee(we[0])&&ue(we[1])&&we.length===2}):(U=z.map(b),function(we){for(var _e=0;_e<U.length;_e++)if(!U[_e](we[_e]))return!1;return we.length===U.length})}function A(z,U){return U<z.length?z[U]:x(z)?ce(z):null}function S(z,U){var ee=A(z,U);return ee?d(ee):new Set}function D(z){return z.conversion===null||z.conversion===void 0}function T(z,U){var ee=new Set;return z.forEach(function(ue){var ve=S(ue.params,U),de,be=ht(ve),pe;try{for(be.s();!(pe=be.n()).done;)de=pe.value,ee.add(de)}catch(we){be.e(we)}finally{be.f()}}),ee.has("any")?["any"]:Array.from(ee)}function B(z,U,ee){var ue,ve,de=z||"unnamed",be=ee,pe,we=function(){var C=[];if(be.forEach(function(se){var Ee=A(se.params,pe),ze=b(Ee);(pe<se.params.length||x(se.params))&&ze(U[pe])&&C.push(se)}),C.length===0){if(ve=T(be,pe),ve.length>0){var Z=c(U[pe]);return ue=new TypeError("Unexpected type of argument in function "+de+" (expected: "+ve.join(" or ")+", actual: "+Z.join(" | ")+", index: "+pe+")"),ue.data={category:"wrongType",fn:de,index:pe,actual:Z,expected:ve},{v:ue}}}else be=C};for(pe=0;pe<U.length;pe++){var _e=we();if(Xn(_e)==="object")return _e.v}var Le=be.map(function(mr){return x(mr.params)?1/0:mr.params.length});if(U.length<Math.min.apply(null,Le))return ve=T(be,pe),ue=new TypeError("Too few arguments in function "+de+" (expected: "+ve.join(" or ")+", index: "+U.length+")"),ue.data={category:"tooFewArgs",fn:de,index:U.length,expected:ve},ue;var Be=Math.max.apply(null,Le);if(U.length>Be)return ue=new TypeError("Too many arguments in function "+de+" (expected: "+Be+", actual: "+U.length+")"),ue.data={category:"tooManyArgs",fn:de,index:U.length,expectedLength:Be},ue;for(var ar=[],Je=0;Je<U.length;++Je)ar.push(c(U[Je]).join("|"));return ue=new TypeError('Arguments of type "'+ar.join(", ")+'" do not match any of the defined signatures of function '+de+"."),ue.data={category:"mismatch",actual:ar},ue}function I(z){for(var U=n.length+1,ee=0;ee<z.types.length;ee++)D(z.types[ee])&&(U=Math.min(U,z.types[ee].typeIndex));return U}function P(z){for(var U=i+1,ee=0;ee<z.types.length;ee++)D(z.types[ee])||(U=Math.min(U,z.types[ee].conversionIndex));return U}function R(z,U){if(z.hasAny){if(!U.hasAny)return 1}else if(U.hasAny)return-1;if(z.restParam){if(!U.restParam)return 1}else if(U.restParam)return-1;if(z.hasConversion){if(!U.hasConversion)return 1}else if(U.hasConversion)return-1;var ee=I(z)-I(U);if(ee<0)return-1;if(ee>0)return 1;var ue=P(z)-P(U);return ue<0?-1:ue>0?1:0}function M(z,U){var ee=z.params,ue=U.params,ve=ce(ee),de=ce(ue),be=x(ee),pe=x(ue);if(be&&ve.hasAny){if(!pe||!de.hasAny)return 1}else if(pe&&de.hasAny)return-1;var we=0,_e=0,Le,Be=ht(ee),ar;try{for(Be.s();!(ar=Be.n()).done;)Le=ar.value,Le.hasAny&&++we,Le.hasConversion&&++_e}catch(kn){Be.e(kn)}finally{Be.f()}var Je=0,mr=0,C=ht(ue),Z;try{for(C.s();!(Z=C.n()).done;)Le=Z.value,Le.hasAny&&++Je,Le.hasConversion&&++mr}catch(kn){C.e(kn)}finally{C.f()}if(we!==Je)return we-Je;if(be&&ve.hasConversion){if(!pe||!de.hasConversion)return 1}else if(pe&&de.hasConversion)return-1;if(_e!==mr)return _e-mr;if(be){if(!pe)return 1}else if(pe)return-1;var se=(ee.length-ue.length)*(be?-1:1);if(se!==0)return se;for(var Ee=[],ze=0,ke=0;ke<ee.length;++ke){var Fr=R(ee[ke],ue[ke]);Ee.push(Fr),ze+=Fr}if(ze!==0)return ze;for(var _r,tn=0,Ln=Ee;tn<Ln.length;tn++)if(_r=Ln[tn],_r!==0)return _r;return 0}function F(z){if(z.length===0)return[];var U=z.map(f);z.length>1&&U.sort(function(we,_e){return we.index-_e.index});var ee=U[0].conversionsTo;if(z.length===1)return ee;ee=ee.concat([]);for(var ue=new Set(z),ve=1;ve<U.length;++ve){var de=void 0,be=ht(U[ve].conversionsTo),pe;try{for(be.s();!(pe=be.n()).done;)de=pe.value,ue.has(de.from)||(ee.push(de),ue.add(de.from))}catch(we){be.e(we)}finally{be.f()}}return ee}function H(z,U){var ee=U;if(z.some(function(pe){return pe.hasConversion})){var ue=x(z),ve=z.map($);ee=function(){for(var we=[],_e=ue?arguments.length-1:arguments.length,Le=0;Le<_e;Le++)we[Le]=ve[Le](arguments[Le]);return ue&&(we[_e]=arguments[_e].map(ve[_e])),U.apply(this,we)}}var de=ee;if(x(z)){var be=z.length-1;de=function(){return ee.apply(this,ie(arguments,0,be).concat([ie(arguments,be)]))}}return de}function $(z){var U,ee,ue,ve,de=[],be=[];switch(z.types.forEach(function(pe){pe.conversion&&(de.push(f(pe.conversion.from).test),be.push(pe.conversion.convert))}),be.length){case 0:return function(we){return we};case 1:return U=de[0],ue=be[0],function(we){return U(we)?ue(we):we};case 2:return U=de[0],ee=de[1],ue=be[0],ve=be[1],function(we){return U(we)?ue(we):ee(we)?ve(we):we};default:return function(we){for(var _e=0;_e<be.length;_e++)if(de[_e](we))return be[_e](we);return we}}}function k(z){function U(ee,ue,ve){if(ue<ee.length){var de=ee[ue],be=[];if(de.restParam){var pe=de.types.filter(D);pe.length<de.types.length&&be.push({types:pe,name:"..."+pe.map(function(we){return we.name}).join("|"),hasAny:pe.some(function(we){return we.isAny}),hasConversion:!1,restParam:!0}),be.push(de)}else be=de.types.map(function(we){return{types:[we],name:we.name,hasAny:we.isAny,hasConversion:we.conversion,restParam:!1}});return Oe(be,function(we){return U(ee,ue+1,ve.concat([we]))})}else return[ve]}return U(z,0,[])}function Q(z,U){for(var ee=Math.max(z.length,U.length),ue=0;ue<ee;ue++){var ve=S(z,ue),de=S(U,ue),be=!1,pe=void 0,we=ht(de),_e;try{for(we.s();!(_e=we.n()).done;)if(pe=_e.value,ve.has(pe)){be=!0;break}}catch(mr){we.e(mr)}finally{we.f()}if(!be)return!1}var Le=z.length,Be=U.length,ar=x(z),Je=x(U);return ar?Je?Le===Be:Be>=Le:Je?Le>=Be:Le===Be}function K(z){return z.map(function(U){return oe(U)?V(U.referToSelf.callback):X(U)?$e(U.referTo.references,U.referTo.callback):U})}function L(z,U,ee){var ue=[],ve,de=ht(z),be;try{for(de.s();!(be=de.n()).done;){ve=be.value;var pe=ee[ve];if(typeof pe!="number")throw new TypeError('No definition for referenced signature "'+ve+'"');if(pe=U[pe],typeof pe!="function")return!1;ue.push(pe)}}catch(we){de.e(we)}finally{de.f()}return ue}function j(z,U,ee){for(var ue=K(z),ve=new Array(ue.length).fill(!1),de=!0;de;){de=!1;for(var be=!0,pe=0;pe<ue.length;++pe)if(!ve[pe]){var we=ue[pe];if(oe(we))ue[pe]=we.referToSelf.callback(ee),ue[pe].referToSelf=we.referToSelf,ve[pe]=!0,be=!1;else if(X(we)){var _e=L(we.referTo.references,ue,U);_e?(ue[pe]=we.referTo.callback.apply(this,_e),ue[pe].referTo=we.referTo,ve[pe]=!0,be=!1):de=!0}}if(be&&de)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return ue}function ae(z){var U=/\bthis(\(|\.signatures\b)/;Object.keys(z).forEach(function(ee){var ue=z[ee];if(U.test(ue.toString()))throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function re(z,U){if(o.createCount++,Object.keys(U).length===0)throw new SyntaxError("No signatures provided");o.warnAgainstDeprecatedThis&&ae(U);var ee=[],ue=[],ve={},de=[],be,pe=function(){if(!Object.prototype.hasOwnProperty.call(U,be))return"continue";var Tr=w(be);if(!Tr)return"continue";ee.forEach(function(Nn){if(Q(Nn,Tr))throw new TypeError('Conflicting signatures "'+g(Nn)+'" and "'+g(Tr)+'".')}),ee.push(Tr);var Fo=ue.length;ue.push(U[be]);var el=Tr.map(N),Ra=void 0,_a=ht(k(el)),To;try{for(_a.s();!(To=_a.n()).done;){Ra=To.value;var Bo=g(Ra);de.push({params:Ra,name:Bo,fn:Fo}),Ra.every(function(Nn){return!Nn.hasConversion})&&(ve[Bo]=Fo)}}catch(Nn){_a.e(Nn)}finally{_a.f()}};for(be in U)var we=pe();de.sort(M);var _e=j(ue,ve,Gn),Le;for(Le in ve)Object.prototype.hasOwnProperty.call(ve,Le)&&(ve[Le]=_e[ve[Le]]);for(var Be=[],ar=new Map,Je=0,mr=de;Je<mr.length;Je++)Le=mr[Je],ar.has(Le.name)||(Le.fn=_e[Le.fn],Be.push(Le),ar.set(Le.name,Le));for(var C=Be[0]&&Be[0].params.length<=2&&!x(Be[0].params),Z=Be[1]&&Be[1].params.length<=2&&!x(Be[1].params),se=Be[2]&&Be[2].params.length<=2&&!x(Be[2].params),Ee=Be[3]&&Be[3].params.length<=2&&!x(Be[3].params),ze=Be[4]&&Be[4].params.length<=2&&!x(Be[4].params),ke=Be[5]&&Be[5].params.length<=2&&!x(Be[5].params),Fr=C&&Z&&se&&Ee&&ze&&ke,_r=0;_r<Be.length;++_r)Be[_r].test=E(Be[_r].params);for(var tn=C?b(Be[0].params[0]):st,Ln=Z?b(Be[1].params[0]):st,kn=se?b(Be[2].params[0]):st,Bu=Ee?b(Be[3].params[0]):st,$u=ze?b(Be[4].params[0]):st,Ou=ke?b(Be[5].params[0]):st,Iu=C?b(Be[0].params[1]):st,Ru=Z?b(Be[1].params[1]):st,_u=se?b(Be[2].params[1]):st,qu=Ee?b(Be[3].params[1]):st,zu=ze?b(Be[4].params[1]):st,Pu=ke?b(Be[5].params[1]):st,Vn=0;Vn<Be.length;++Vn)Be[Vn].implementation=H(Be[Vn].params,Be[Vn].fn);var Uu=C?Be[0].implementation:Wn,Lu=Z?Be[1].implementation:Wn,Oa=se?Be[2].implementation:Wn,Ia=Ee?Be[3].implementation:Wn,ku=ze?Be[4].implementation:Wn,Vu=ke?Be[5].implementation:Wn,Gu=C?Be[0].params.length:-1,Hu=Z?Be[1].params.length:-1,Zu=se?Be[2].params.length:-1,Ju=Ee?Be[3].params.length:-1,Xu=ze?Be[4].params.length:-1,Wu=ke?Be[5].params.length:-1,Yu=Fr?6:0,Qu=Be.length,Ku=Be.map(function(jr){return jr.test}),ju=Be.map(function(jr){return jr.implementation}),Mo=function(){for(var Tr=Yu;Tr<Qu;Tr++)if(Ku[Tr](arguments))return ju[Tr].apply(this,arguments);return o.onMismatch(z,arguments,Be)};function Gn(jr,Tr){return arguments.length===Gu&&tn(jr)&&Iu(Tr)?Uu.apply(this,arguments):arguments.length===Hu&&Ln(jr)&&Ru(Tr)?Lu.apply(this,arguments):arguments.length===Zu&&kn(jr)&&_u(Tr)?Oa.apply(this,arguments):arguments.length===Ju&&Bu(jr)&&qu(Tr)?Ia.apply(this,arguments):arguments.length===Xu&&$u(jr)&&zu(Tr)?ku.apply(this,arguments):arguments.length===Wu&&Ou(jr)&&Pu(Tr)?Vu.apply(this,arguments):Mo.apply(this,arguments)}try{Object.defineProperty(Gn,"name",{value:z})}catch{}return Gn.signatures=ve,Gn._typedFunctionData={signatures:Be,signatureMap:ar},Gn}function fe(z,U,ee){throw B(z,U,ee)}function he(z){return ie(z,0,z.length-1)}function ce(z){return z[z.length-1]}function ie(z,U,ee){return Array.prototype.slice.call(z,U,ee)}function Ae(z,U){for(var ee=0;ee<z.length;ee++)if(U(z[ee]))return z[ee]}function Oe(z,U){return Array.prototype.concat.apply([],z.map(U))}function Ce(){var z=he(arguments).map(function(ee){return g(w(ee))}),U=ce(arguments);if(typeof U!="function")throw new TypeError("Callback function expected as last argument");return $e(z,U)}function $e(z,U){return{referTo:{references:z,callback:U}}}function V(z){if(typeof z!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:z}}}function X(z){return z&&Xn(z.referTo)==="object"&&Array.isArray(z.referTo.references)&&typeof z.referTo.callback=="function"}function oe(z){return z&&Xn(z.referToSelf)==="object"&&typeof z.referToSelf.callback=="function"}function G(z,U){if(!z)return U;if(U&&U!==z){var ee=new Error("Function names do not match (expected: "+z+", actual: "+U+")");throw ee.data={actual:U,expected:z},ee}return z}function Y(z){var U;for(var ee in z)Object.prototype.hasOwnProperty.call(z,ee)&&(m(z[ee])||typeof z[ee].signature=="string")&&(U=G(U,z[ee].name));return U}function te(z,U){var ee;for(ee in U)if(Object.prototype.hasOwnProperty.call(U,ee)){if(ee in z&&U[ee]!==z[ee]){var ue=new Error('Signature "'+ee+'" is defined twice');throw ue.data={signature:ee,sourceFunction:U[ee],destFunction:z[ee]},ue}z[ee]=U[ee]}}var ye=o;o=function(U){for(var ee=typeof U=="string",ue=ee?1:0,ve=ee?U:"",de={},be=ue;be<arguments.length;++be){var pe=arguments[be],we={},_e=void 0;if(typeof pe=="function"?(_e=pe.name,typeof pe.signature=="string"?we[pe.signature]=pe:m(pe)&&(we=pe.signatures)):r(pe)&&(we=pe,ee||(_e=Y(pe))),Object.keys(we).length===0){var Le=new TypeError("Argument to 'typed' at index "+be+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw Le.data={index:be,argument:pe},Le}ee||(ve=G(ve,_e)),te(de,we)}return re(ve||"",de)},o.create=vl,o.createCount=ye.createCount,o.onMismatch=fe,o.throwMismatchError=fe,o.createError=B,o.clear=u,o.clearConversions=s,o.addTypes=l,o._findType=f,o.referTo=Ce,o.referToSelf=V,o.convert=p,o.findSignature=v,o.find=h,o.isTypedFunction=m,o.warnAgainstDeprecatedThis=!0,o.addType=function(z,U){var ee="any";U!==!1&&a.has("Object")&&(ee="Object"),o.addTypes([z],ee)};function me(z){if(!z||typeof z.from!="string"||typeof z.to!="string"||typeof z.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(z.to===z.from)throw new SyntaxError('Illegal to define conversion from "'+z.from+'" to itself.')}return o.addConversion=function(z){me(z);var U=f(z.to);if(U.conversionsTo.every(function(ee){return ee.from!==z.from}))U.conversionsTo.push({from:z.from,convert:z.convert,index:i++});else throw new Error('There is already a conversion from "'+z.from+'" to "'+U.name+'"')},o.addConversions=function(z){z.forEach(o.addConversion)},o.removeConversion=function(z){me(z);var U=f(z.to),ee=Ae(U.conversionsTo,function(ve){return ve.from===z.from});if(!ee)throw new Error("Attempt to remove nonexistent conversion from "+z.from+" to "+z.to);if(ee.convert!==z.convert)throw new Error("Conversion to remove does not match existing conversion");var ue=U.conversionsTo.indexOf(ee);U.conversionsTo.splice(ue,1)},o.resolve=function(z,U){if(!m(z))throw new TypeError(ml);for(var ee=z._typedFunctionData.signatures,ue=0;ue<ee.length;++ue)if(ee[ue].test(U))return ee[ue];return null},o}const pl=vl();function qe(r){return typeof r=="boolean"?!0:isFinite(r)?r===Math.round(r):!1}var an=Math.sign||function(r){return r>0?1:r<0?-1:0},j0=Math.log2||function(e){return Math.log(e)/Math.LN2},eg=Math.log10||function(e){return Math.log(e)/Math.LN10},rg=Math.log1p||function(r){return Math.log(r+1)},tg=Math.cbrt||function(e){if(e===0)return e;var t=e<0,a;return t&&(e=-e),isFinite(e)?(a=Math.exp(Math.log(e)/3),a=(e/(a*a)+2*a)/3):a=e,t?-a:a},ng=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function Vo(r,e,t){var a={2:"0b",8:"0o",16:"0x"},n=a[e],i="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!qe(t))throw new Error("size must be an integer");if(r>2**(t-1)-1||r<-(2**(t-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!qe(r))throw new Error("Value must be an integer");r<0&&(r=r+2**t),i="i".concat(t)}var o="";return r<0&&(r=-r,o="-"),"".concat(o).concat(n).concat(r.toString(e)).concat(i)}function Cn(r,e){if(typeof e=="function")return e(r);if(r===1/0)return"Infinity";if(r===-1/0)return"-Infinity";if(isNaN(r))return"NaN";var t="auto",a,n;if(e&&(e.notation&&(t=e.notation),tr(e)?a=e:tr(e.precision)&&(a=e.precision),e.wordSize&&(n=e.wordSize,typeof n!="number")))throw new Error('Option "wordSize" must be a number');switch(t){case"fixed":return hl(r,a);case"exponential":return dl(r,a);case"engineering":return ag(r,a);case"bin":return Vo(r,2,n);case"oct":return Vo(r,8,n);case"hex":return Vo(r,16,n);case"auto":return ig(r,a,e&&e).replace(/((\.\d*?)(0+))($|e)/,function(){var i=arguments[2],o=arguments[4];return i!=="."?i+o:o});default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function fi(r){var e=String(r).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!e)throw new SyntaxError("Invalid number "+r);var t=e[1],a=e[2],n=parseFloat(e[4]||"0"),i=a.indexOf(".");n+=i!==-1?i-1:a.length-1;var o=a.replace(".","").replace(/^0*/,function(f){return n-=f.length,""}).replace(/0*$/,"").split("").map(function(f){return parseInt(f)});return o.length===0&&(o.push(0),n++),{sign:t,coefficients:o,exponent:n}}function ag(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=fi(r),a=mi(t,e),n=a.exponent,i=a.coefficients,o=n%3===0?n:n<0?n-3-n%3:n-n%3;if(tr(e))for(;e>i.length||n-o+1>i.length;)i.push(0);else for(var f=Math.abs(n-o)-(i.length-1),l=0;l<f;l++)i.push(0);for(var u=Math.abs(n-o),s=1;u>0;)s++,u--;var c=i.slice(s).join(""),m=tr(e)&&c.length||c.match(/[1-9]/)?"."+c:"",v=i.slice(0,s).join("")+m+"e"+(n>=0?"+":"")+o.toString();return a.sign+v}function hl(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=fi(r),a=typeof e=="number"?mi(t,t.exponent+1+e):t,n=a.coefficients,i=a.exponent+1,o=i+(e||0);return n.length<o&&(n=n.concat(Yn(o-n.length))),i<0&&(n=Yn(-i+1).concat(n),i=1),i<n.length&&n.splice(i,0,i===0?"0.":"."),a.sign+n.join("")}function dl(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=fi(r),a=e?mi(t,e):t,n=a.coefficients,i=a.exponent;n.length<e&&(n=n.concat(Yn(e-n.length)));var o=n.shift();return a.sign+o+(n.length>0?"."+n.join(""):"")+"e"+(i>=0?"+":"")+i}function ig(r,e,t){if(isNaN(r)||!isFinite(r))return String(r);var a=t&&t.lowerExp!==void 0?t.lowerExp:-3,n=t&&t.upperExp!==void 0?t.upperExp:5,i=fi(r),o=e?mi(i,e):i;if(o.exponent<a||o.exponent>=n)return dl(r,e);var f=o.coefficients,l=o.exponent;f.length<e&&(f=f.concat(Yn(e-f.length))),f=f.concat(Yn(l-f.length+1+(f.length<e?e-f.length:0))),f=Yn(-l).concat(f);var u=l>0?l:0;return u<f.length-1&&f.splice(u+1,0,"."),o.sign+f.join("")}function mi(r,e){for(var t={sign:r.sign,coefficients:r.coefficients,exponent:r.exponent},a=t.coefficients;e<=0;)a.unshift(0),t.exponent++,e++;if(a.length>e){var n=a.splice(e,a.length-e);if(n[0]>=5){var i=e-1;for(a[i]++;a[i]===10;)a.pop(),i===0&&(a.unshift(0),t.exponent++,i++),i--,a[i]++}}return t}function Yn(r){for(var e=[],t=0;t<r;t++)e.push(0);return e}function og(r){return r.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var sg=Number.EPSILON||2220446049250313e-31;function nt(r,e,t){if(t==null)return r===e;if(r===e)return!0;if(isNaN(r)||isNaN(e))return!1;if(isFinite(r)&&isFinite(e)){var a=Math.abs(r-e);return a<sg?!0:a<=Math.max(Math.abs(r),Math.abs(e))*t}return!1}var ug=Math.acosh||function(r){return Math.log(Math.sqrt(r*r-1)+r)},lg=Math.asinh||function(r){return Math.log(Math.sqrt(r*r+1)+r)},cg=Math.atanh||function(r){return Math.log((1+r)/(1-r))/2},fg=Math.cosh||function(r){return(Math.exp(r)+Math.exp(-r))/2},mg=Math.sinh||function(r){return(Math.exp(r)-Math.exp(-r))/2},vg=Math.tanh||function(r){var e=Math.exp(2*r);return(e-1)/(e+1)};function pg(r,e){var t=r>0?!0:r<0?!1:1/r===1/0,a=e>0?!0:e<0?!1:1/e===1/0;return t^a?-r:r}function Go(r,e,t){var a=r.constructor,n=new a(2),i="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!qe(t))throw new Error("size must be an integer");if(r.greaterThan(n.pow(t-1).sub(1))||r.lessThan(n.pow(t-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!r.isInteger())throw new Error("Value must be an integer");r.lessThan(0)&&(r=r.add(n.pow(t))),i="i".concat(t)}switch(e){case 2:return"".concat(r.toBinary()).concat(i);case 8:return"".concat(r.toOctal()).concat(i);case 16:return"".concat(r.toHexadecimal()).concat(i);default:throw new Error("Base ".concat(e," not supported "))}}function hg(r,e){if(typeof e=="function")return e(r);if(!r.isFinite())return r.isNaN()?"NaN":r.gt(0)?"Infinity":"-Infinity";var t="auto",a,n;if(e!==void 0&&(e.notation&&(t=e.notation),typeof e=="number"?a=e:e.precision&&(a=e.precision),e.wordSize&&(n=e.wordSize,typeof n!="number")))throw new Error('Option "wordSize" must be a number');switch(t){case"fixed":return gg(r,a);case"exponential":return gl(r,a);case"engineering":return dg(r,a);case"bin":return Go(r,2,n);case"oct":return Go(r,8,n);case"hex":return Go(r,16,n);case"auto":{var i=e&&e.lowerExp!==void 0?e.lowerExp:-3,o=e&&e.upperExp!==void 0?e.upperExp:5;if(r.isZero())return"0";var f,l=r.toSignificantDigits(a),u=l.e;return u>=i&&u<o?f=l.toFixed():f=gl(r,a),f.replace(/((\.\d*?)(0+))($|e)/,function(){var s=arguments[2],c=arguments[4];return s!=="."?s+c:c})}default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function dg(r,e){var t=r.e,a=t%3===0?t:t<0?t-3-t%3:t-t%3,n=r.mul(Math.pow(10,-a)),i=n.toPrecision(e);return i.indexOf("e")!==-1&&(i=n.toString()),i+"e"+(t>=0?"+":"")+a.toString()}function gl(r,e){return e!==void 0?r.toExponential(e-1):r.toExponential()}function gg(r,e){return r.toFixed(e)}function yg(r,e){var t=r.length-e.length,a=r.length;return r.substring(t,a)===e}function Ye(r,e){var t=bg(r,e);return e&&typeof e=="object"&&"truncate"in e&&t.length>e.truncate?t.substring(0,e.truncate-3)+"...":t}function bg(r,e){if(typeof r=="number")return Cn(r,e);if(rr(r))return hg(r,e);if(xg(r))return!e||e.fraction!=="decimal"?r.s*r.n+"/"+r.d:r.toString();if(Array.isArray(r))return yl(r,e);if(Wr(r))return'"'+r+'"';if(typeof r=="function")return r.syntax?String(r.syntax):"function";if(r&&typeof r=="object"){if(typeof r.format=="function")return r.format(e);if(r&&r.toString(e)!=={}.toString())return r.toString(e);var t=Object.keys(r).map(a=>'"'+a+'": '+Ye(r[a],e));return"{"+t.join(", ")+"}"}return String(r)}function vi(r){for(var e=String(r),t="",a=0;a<e.length;){var n=e.charAt(a);n==="\\"?(t+=n,a++,n=e.charAt(a),(n===""||'"\\/bfnrtu'.indexOf(n)===-1)&&(t+="\\"),t+=n):n==='"'?t+='\\"':t+=n,a++}return'"'+t+'"'}function ut(r){var e=String(r);return e=e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),e}function yl(r,e){if(Array.isArray(r)){for(var t="[",a=r.length,n=0;n<a;n++)n!==0&&(t+=", "),t+=yl(r[n],e);return t+="]",t}else return Ye(r,e)}function xg(r){return r&&typeof r=="object"&&typeof r.s=="number"&&typeof r.n=="number"&&typeof r.d=="number"||!1}function Ho(r,e){if(!Wr(r))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+br(r)+", index: 0)");if(!Wr(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+br(e)+", index: 1)");return r===e?0:r>e?1:-1}function Ke(r,e,t){if(!(this instanceof Ke))throw new SyntaxError("Constructor must be called with the new operator");this.actual=r,this.expected=e,this.relation=t,this.message="Dimension mismatch ("+(Array.isArray(r)?"["+r.join(", ")+"]":r)+" "+(this.relation||"!=")+" "+(Array.isArray(e)?"["+e.join(", ")+"]":e)+")",this.stack=new Error().stack}Ke.prototype=new RangeError,Ke.prototype.constructor=RangeError,Ke.prototype.name="DimensionError",Ke.prototype.isDimensionError=!0;function dt(r,e,t){if(!(this instanceof dt))throw new SyntaxError("Constructor must be called with the new operator");this.index=r,arguments.length<3?(this.min=0,this.max=e):(this.min=e,this.max=t),this.min!==void 0&&this.index<this.min?this.message="Index out of range ("+this.index+" < "+this.min+")":this.max!==void 0&&this.index>=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=new Error().stack}dt.prototype=new RangeError,dt.prototype.constructor=RangeError,dt.prototype.name="IndexError",dt.prototype.isIndexError=!0;function er(r){for(var e=[];Array.isArray(r);)e.push(r.length),r=r[0];return e}function bl(r,e,t){var a,n=r.length;if(n!==e[t])throw new Ke(n,e[t]);if(t<e.length-1){var i=t+1;for(a=0;a<n;a++){var o=r[a];if(!Array.isArray(o))throw new Ke(e.length-1,e.length,"<");bl(r[a],e,i)}}else for(a=0;a<n;a++)if(Array.isArray(r[a]))throw new Ke(e.length+1,e.length,">")}function xl(r,e){var t=e.length===0;if(t){if(Array.isArray(r))throw new Ke(r.length,0)}else bl(r,e,0)}function vr(r,e){if(!tr(r)||!qe(r))throw new TypeError("Index must be an integer (value: "+r+")");if(r<0||typeof e=="number"&&r>=e)throw new dt(r,e)}function Qn(r,e,t){if(!Array.isArray(r)||!Array.isArray(e))throw new TypeError("Array expected");if(e.length===0)throw new Error("Resizing to scalar is not supported");e.forEach(function(n){if(!tr(n)||!qe(n)||n<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Ye(e)+")")});var a=t!==void 0?t:0;return Zo(r,e,0,a),r}function Zo(r,e,t,a){var n,i,o=r.length,f=e[t],l=Math.min(o,f);if(r.length=f,t<e.length-1){var u=t+1;for(n=0;n<l;n++)i=r[n],Array.isArray(i)||(i=[i],r[n]=i),Zo(i,e,u,a);for(n=l;n<f;n++)i=[],r[n]=i,Zo(i,e,u,a)}else{for(n=0;n<l;n++)for(;Array.isArray(r[n]);)r[n]=r[n][0];for(n=l;n<f;n++)r[n]=a}}function wl(r,e){var t=or(r),a=t.length;if(!Array.isArray(r)||!Array.isArray(e))throw new TypeError("Array expected");if(e.length===0)throw new Ke(0,a,"!=");e=Jo(e,a);var n=Nl(e);if(a!==n)throw new Ke(n,a,"!=");try{return wg(t,e)}catch(i){throw i instanceof Ke?new Ke(n,a,"!="):i}}function Jo(r,e){var t=Nl(r),a=r.slice(),n=-1,i=r.indexOf(n),o=r.indexOf(n,i+1)>=0;if(o)throw new Error("More than one wildcard in sizes");var f=i>=0,l=e%t===0;if(f)if(l)a[i]=-e/t;else throw new Error("Could not replace wildcard, since "+e+" is no multiple of "+-t);return a}function Nl(r){return r.reduce((e,t)=>e*t,1)}function wg(r,e){for(var t=r,a,n=e.length-1;n>0;n--){var i=e[n];a=[];for(var o=t.length/i,f=0;f<o;f++)a.push(t.slice(f*i,(f+1)*i));t=a}return t}function pi(r,e){for(var t=e||er(r);Array.isArray(r)&&r.length===1;)r=r[0],t.shift();for(var a=t.length;t[a-1]===1;)a--;return a<t.length&&(r=Dl(r,a,0),t.length=a),r}function Dl(r,e,t){var a,n;if(t<e){var i=t+1;for(a=0,n=r.length;a<n;a++)r[a]=Dl(r[a],e,i)}else for(;Array.isArray(r);)r=r[0];return r}function Al(r,e,t,a){var n=a||er(r);if(t)for(var i=0;i<t;i++)r=[r],n.unshift(1);for(r=El(r,e,0);n.length<e;)n.push(1);return r}function El(r,e,t){var a,n;if(Array.isArray(r)){var i=t+1;for(a=0,n=r.length;a<n;a++)r[a]=El(r[a],e,i)}else for(var o=t;o<e;o++)r=[r];return r}function or(r){if(!Array.isArray(r))return r;var e=[];return r.forEach(function t(a){Array.isArray(a)?a.forEach(t):e.push(a)}),e}function Ht(r,e){return Array.prototype.map.call(r,e)}function hi(r,e){Array.prototype.forEach.call(r,e)}function Sl(r,e){if(er(r).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(r,e)}function di(r,e){if(er(r).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(r,t=>e.test(t))}function Cl(r,e){return Array.prototype.join.call(r,e)}function Kn(r){if(!Array.isArray(r))throw new TypeError("Array input expected");if(r.length===0)return r;var e=[],t=0;e[0]={value:r[0],identifier:0};for(var a=1;a<r.length;a++)r[a]===r[a-1]?t++:t=0,e.push({value:r[a],identifier:t});return e}function gi(r){if(!Array.isArray(r))throw new TypeError("Array input expected");if(r.length===0)return r;for(var e=[],t=0;t<r.length;t++)e.push(r[t].value);return e}function La(r,e){for(var t,a=0,n=0;n<r.length;n++){var i=r[n],o=Array.isArray(i);if(n===0&&o&&(a=i.length),o&&i.length!==a)return;var f=o?La(i,e):e(i);if(t===void 0)t=f;else if(t!==f)return"mixed"}return t}function q(r,e,t,a){function n(i){var o=W0(i,e.map(Ag));return Ng(r,e,i),t(o)}return n.isFactory=!0,n.fn=r,n.dependencies=e.slice().sort(),a&&(n.meta=a),n}function Ng(r,e,t){var a=e.filter(i=>!Dg(i)).every(i=>t[i]!==void 0);if(!a){var n=e.filter(i=>t[i]===void 0);throw new Error('Cannot create function "'.concat(r,'", ')+"some dependencies are missing: ".concat(n.map(i=>'"'.concat(i,'"')).join(", "),"."))}}function Dg(r){return r&&r[0]==="?"}function Ag(r){return r&&r[0]==="?"?r.slice(1):r}function lt(r,e){if(Ml(r)&&Xo(r,e))return r[e];throw typeof r[e]=="function"&&Wo(r,e)?new Error('Cannot access method "'+e+'" as a property'):new Error('No access to property "'+e+'"')}function jn(r,e,t){if(Ml(r)&&Xo(r,e))return r[e]=t,t;throw new Error('No access to property "'+e+'"')}function Eg(r,e){return e in r}function Xo(r,e){return!r||typeof r!="object"?!1:Re(Cg,e)?!0:!(e in Object.prototype||e in Function.prototype)}function Sg(r,e){if(!Wo(r,e))throw new Error('No access to method "'+e+'"')}function Wo(r,e){return r==null||typeof r[e]!="function"||Re(r,e)&&Object.getPrototypeOf&&e in Object.getPrototypeOf(r)?!1:Re(Mg,e)?!0:!(e in Object.prototype||e in Function.prototype)}function Ml(r){return typeof r=="object"&&r&&r.constructor===Object}var Cg={length:!0,name:!0},Mg={toString:!0,valueOf:!0,toLocaleString:!0};class Yo{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return lt(this.wrappedObject,e)}set(e,t){return jn(this.wrappedObject,e,t),this}has(e){return Eg(this.wrappedObject,e)}}function ea(){return new Map}function ra(r){if(!r)return ea();if(Qo(r))return r;if(Lo(r))return new Yo(r);throw new Error("createMap can create maps from objects or Maps")}function Fg(r){if(r instanceof Yo)return r.wrappedObject;var e={};for(var t of r.keys()){var a=r.get(t);jn(e,t,a)}return e}function Qo(r){return r?r instanceof Map||r instanceof Yo||typeof r.set=="function"&&typeof r.get=="function"&&typeof r.keys=="function"&&typeof r.has=="function":!1}function Fl(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),a=1;a<e;a++)t[a-1]=arguments[a];for(var n of t)if(!!n){if(Qo(n))for(var i of n.keys())r.set(i,n.get(i));else if(Lo(n))for(var o of Object.keys(n))r.set(o,n[o])}return r}var Tl=function(){return Tl=pl.create,pl},Tg=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],Bg=q("typed",Tg,function(e){var{BigNumber:t,Complex:a,DenseMatrix:n,Fraction:i}=e,o=Tl();return o.clear(),o.addTypes([{name:"number",test:tr},{name:"Complex",test:kt},{name:"BigNumber",test:rr},{name:"Fraction",test:za},{name:"Unit",test:Vt},{name:"identifier",test:f=>Wr&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])*$/.test(f)},{name:"string",test:Wr},{name:"Chain",test:ul},{name:"Array",test:cr},{name:"Matrix",test:Ve},{name:"DenseMatrix",test:ui},{name:"SparseMatrix",test:En},{name:"Range",test:Uo},{name:"Index",test:li},{name:"boolean",test:R0},{name:"ResultSet",test:_0},{name:"Help",test:sl},{name:"function",test:q0},{name:"Date",test:z0},{name:"RegExp",test:P0},{name:"null",test:U0},{name:"undefined",test:L0},{name:"AccessorNode",test:Sn},{name:"ArrayNode",test:ot},{name:"AssignmentNode",test:k0},{name:"BlockNode",test:V0},{name:"ConditionalNode",test:G0},{name:"ConstantNode",test:ir},{name:"FunctionNode",test:nn},{name:"FunctionAssignmentNode",test:Pa},{name:"IndexNode",test:Jn},{name:"Node",test:fr},{name:"ObjectNode",test:ci},{name:"OperatorNode",test:Br},{name:"ParenthesisNode",test:Gt},{name:"RangeNode",test:H0},{name:"RelationalNode",test:Z0},{name:"SymbolNode",test:qr},{name:"Map",test:Qo},{name:"Object",test:Lo}]),o.addConversions([{from:"number",to:"BigNumber",convert:function(l){if(t||Ko(l),og(l)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+l+"). Use function bignumber(x) to convert to BigNumber.");return new t(l)}},{from:"number",to:"Complex",convert:function(l){return a||yi(l),new a(l,0)}},{from:"BigNumber",to:"Complex",convert:function(l){return a||yi(l),new a(l.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(l){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(l){return a||yi(l),new a(l.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(l){i||jo(l);var u=new i(l);if(u.valueOf()!==l)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+l+"). Use function fraction(x) to convert to Fraction.");return u}},{from:"string",to:"number",convert:function(l){var u=Number(l);if(isNaN(u))throw new Error('Cannot convert "'+l+'" to a number');return u}},{from:"string",to:"BigNumber",convert:function(l){t||Ko(l);try{return new t(l)}catch{throw new Error('Cannot convert "'+l+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(l){i||jo(l);try{return new i(l)}catch{throw new Error('Cannot convert "'+l+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(l){a||yi(l);try{return new a(l)}catch{throw new Error('Cannot convert "'+l+'" to Complex')}}},{from:"boolean",to:"number",convert:function(l){return+l}},{from:"boolean",to:"BigNumber",convert:function(l){return t||Ko(l),new t(+l)}},{from:"boolean",to:"Fraction",convert:function(l){return i||jo(l),new i(+l)}},{from:"boolean",to:"string",convert:function(l){return String(l)}},{from:"Array",to:"Matrix",convert:function(l){return n||$g(),new n(l)}},{from:"Matrix",to:"Array",convert:function(l){return l.valueOf()}}]),o.onMismatch=(f,l,u)=>{var s=o.createError(f,l,u);if(["wrongType","mismatch"].includes(s.data.category)&&l.length===1&&Ft(l[0])&&u.some(m=>!m.params.includes(","))){var c=new TypeError("Function '".concat(f,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(f,")'."));throw c.data=s.data,c}throw s},o.onMismatch=(f,l,u)=>{var s=o.createError(f,l,u);if(["wrongType","mismatch"].includes(s.data.category)&&l.length===1&&Ft(l[0])&&u.some(m=>!m.params.includes(","))){var c=new TypeError("Function '".concat(f,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(f,")'."));throw c.data=s.data,c}throw s},o});function Ko(r){throw new Error("Cannot convert value ".concat(r," into a BigNumber: no class 'BigNumber' provided"))}function yi(r){throw new Error("Cannot convert value ".concat(r," into a Complex number: no class 'Complex' provided"))}function $g(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function jo(r){throw new Error("Cannot convert value ".concat(r," into a Fraction, no class 'Fraction' provided."))}var Og="ResultSet",Ig=[],Rg=q(Og,Ig,()=>{function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this.entries=e||[]}return r.prototype.type="ResultSet",r.prototype.isResultSet=!0,r.prototype.valueOf=function(){return this.entries},r.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},r.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},r.fromJSON=function(e){return new r(e.entries)},r},{isClass:!0});/*!
10
+ * decimal.js v10.4.3
11
11
  * An arbitrary-precision Decimal type for JavaScript.
12
12
  * https://github.com/MikeMcl/decimal.js
13
13
  * Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
14
14
  * MIT Licence
15
- */var Xn=9e15,nn=1e9,Yo="0123456789abcdef",pi="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",hi="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Qo={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Xn,maxE:Xn,crypto:!1},bl,kt,We=!0,di="[DecimalError] ",an=di+"Invalid argument: ",xl=di+"Precision limit exceeded",wl=di+"crypto unavailable",Nl="[object Decimal]",Vr=Math.floor,Tr=Math.pow,cg=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,fg=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,mg=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Dl=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,ht=1e7,Ve=7,vg=9007199254740991,pg=pi.length-1,Ko=hi.length-1,we={toStringTag:Nl};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(an+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,s=i.d,f=(r=new i.constructor(r)).d,l=i.s,u=r.s;if(!s||!f)return!l||!u?NaN:l!==u?l:s===f?0:!s^l<0?1:-1;if(!s[0]||!f[0])return s[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=s.length,n=f.length,e=0,t=a<n?a:n;e<t;++e)if(s[e]!==f[e])return s[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())+Ve,a.rounding=1,t=hg(a,Fl(a,t)),a.precision=r,a.rounding=e,Pe(kt==2||kt==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,s,f,l,u,o=this,c=o.constructor;if(!o.isFinite()||o.isZero())return new c(o);for(We=!1,i=o.s*Tr(o.s*o,1/3),!i||Math.abs(i)==1/0?(t=zr(o.d),r=o.e,(i=(r-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=Tr(t,1/3),r=Vr((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=o.s):a=new c(i.toString()),s=(r=c.precision)+3;;)if(f=a,l=f.times(f).times(f),u=l.plus(o),a=dr(u.plus(o).times(f),u.plus(l),s+2,1),zr(f.d).slice(0,s)===(t=zr(a.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!n&&t=="4999"){if(!n&&(Pe(f,r+1,0),f.times(f).times(f).eq(o))){a=f;break}s+=4,n=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Pe(a,r+1,1),e=!a.times(a).times(a).eq(o));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-Vr(this.e/Ve))*Ve,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t},we.dividedBy=we.div=function(r){return dr(this,new this.constructor(r))},we.dividedToIntegerBy=we.divToInt=function(r){var e=this,t=e.constructor;return Pe(dr(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,s=i.constructor,f=new s(1);if(!i.isFinite())return new s(i.s?1/0:NaN);if(i.isZero())return f;t=s.precision,a=s.rounding,s.precision=t+Math.max(i.e,i.sd())+4,s.rounding=1,n=i.d.length,n<32?(r=Math.ceil(n/3),e=(1/xi(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),i=Yn(s,1,i.times(e),new s(1),!0);for(var l,u=r,o=new s(8);u--;)l=i.times(i),i=f.minus(l.times(o.minus(l.times(o))));return Pe(i,s.precision=t,s.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=Yn(i,2,n,n,!0);else{r=1.4*Math.sqrt(a),r=r>16?16:r|0,n=n.times(1/xi(5,r)),n=Yn(i,2,n,n,!0);for(var s,f=new i(5),l=new i(16),u=new i(20);r--;)s=n.times(n),n=n.times(f.plus(s.times(l.times(s).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,dr(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()?dt(t,n,i):new t(0):new t(NaN):e.isZero()?dt(t,n+4,i).times(.5):(t.precision=n+6,t.rounding=1,e=e.asin(),r=dt(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=dr(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=dt(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,s,f,l,u=this,o=u.constructor,c=o.precision,m=o.rounding;if(u.isFinite()){if(u.isZero())return new o(u);if(u.abs().eq(1)&&c+4<=Ko)return s=dt(o,c+4,m).times(.25),s.s=u.s,s}else{if(!u.s)return new o(NaN);if(c+4<=Ko)return s=dt(o,c+4,m).times(.5),s.s=u.s,s}for(o.precision=f=c+10,o.rounding=1,t=Math.min(28,f/Ve+2|0),r=t;r;--r)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(We=!1,e=Math.ceil(f/Ve),a=1,l=u.times(u),s=new o(u),n=u;r!==-1;)if(n=n.times(l),i=s.minus(n.div(a+=2)),n=n.times(l),s=i.plus(n.div(a+=2)),s.d[e]!==void 0)for(r=e;s.d[r]===i.d[r]&&r--;);return t&&(s=s.times(2<<t-1)),We=!0,Pe(s,o.precision=c,o.rounding=m,!0)},we.isFinite=function(){return!!this.d},we.isInteger=we.isInt=function(){return!!this.d&&Vr(this.e/Ve)>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,s,f,l,u=this,o=u.constructor,c=o.precision,m=o.rounding,v=5;if(r==null)r=new o(10),e=!0;else{if(r=new o(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new o(NaN);e=r.eq(10)}if(t=u.d,u.s<0||!t||!t[0]||u.eq(1))return new o(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,s=sn(u,f),a=e?bi(o,f+10):sn(r,f),l=dr(s,a,f,1),za(l.d,n=c,m))do if(f+=10,s=sn(u,f),a=e?bi(o,f+10):sn(r,f),l=dr(s,a,f,1),!i){+zr(l.d).slice(n+1,n+15)+1==1e14&&(l=Pe(l,c+1,0));break}while(za(l.d,n+=10,m));return We=!0,Pe(l,c,m)},we.minus=we.sub=function(r){var e,t,a,n,i,s,f,l,u,o,c,m,v=this,p=v.constructor;if(r=new p(r),!v.d||!r.d)return!v.s||!r.s?r=new p(NaN):v.d?r.s=-r.s:r=new p(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=p.precision,l=p.rounding,!u[0]||!m[0]){if(m[0])r.s=-r.s;else if(u[0])r=new p(v);else return new p(l===3?-0:0);return We?Pe(r,f,l):r}if(t=Vr(r.e/Ve),o=Vr(v.e/Ve),u=u.slice(),i=o-t,i){for(c=i<0,c?(e=u,i=-i,s=m.length):(e=m,t=o,s=u.length),a=Math.max(Math.ceil(f/Ve),s)+2,i>a&&(i=a,e.length=1),e.reverse(),a=i;a--;)e.push(0);e.reverse()}else{for(a=u.length,s=m.length,c=a<s,c&&(s=a),a=0;a<s;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),s=u.length,a=m.length-s;a>0;--a)u[s++]=0;for(a=m.length;a>i;){if(u[--a]<m[a]){for(n=a;n&&u[--n]===0;)u[n]=ht-1;--u[n],u[a]+=ht}u[a]-=m[a]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(r.d=u,r.e=yi(u,t),We?Pe(r,f,l):r):new p(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=dr(t,r.abs(),0,3,1),e.s*=r.s):e=dr(t,r,0,a.modulo,1),e=e.times(r),We=!0,t.minus(e))},we.naturalExponential=we.exp=function(){return jo(this)},we.naturalLogarithm=we.ln=function(){return sn(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,s,f,l,u,o,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,o=r.d,f=m.precision,l=m.rounding,!u[0]||!o[0])return o[0]||(r=new m(c)),We?Pe(r,f,l):r;if(i=Vr(c.e/Ve),a=Vr(r.e/Ve),u=u.slice(),n=i-a,n){for(n<0?(t=u,n=-n,s=o.length):(t=o,a=i,s=u.length),i=Math.ceil(f/Ve),s=i>s?i+1:s+1,n>s&&(n=s,t.length=1),t.reverse();n--;)t.push(0);t.reverse()}for(s=u.length,n=o.length,s-n<0&&(n=s,t=o,o=u,u=t),e=0;n;)e=(u[--n]=u[n]+o[n]+e)/ht|0,u[n]%=ht;for(e&&(u.unshift(e),++a),s=u.length;u[--s]==0;)u.pop();return r.d=u,r.e=yi(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(an+r);return t.d?(e=Al(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())+Ve,a.rounding=1,t=gg(a,Fl(a,t)),a.precision=r,a.rounding=e,Pe(kt>2?t.neg():t,r,e,!0)):new a(NaN)},we.squareRoot=we.sqrt=function(){var r,e,t,a,n,i,s=this,f=s.d,l=s.e,u=s.s,o=s.constructor;if(u!==1||!f||!f[0])return new o(!u||u<0&&(!f||f[0])?NaN:f?s:1/0);for(We=!1,u=Math.sqrt(+s),u==0||u==1/0?(e=zr(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),a=new o(e)):a=new o(u.toString()),t=(l=o.precision)+3;;)if(i=a,a=i.plus(dr(s,i,t+2,1)).times(.5),zr(i.d).slice(0,t)===(e=zr(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(s))){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(s));break}return We=!0,Pe(a,l,o.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=dr(t,new a(1).minus(t.times(t)).sqrt(),r+10,0),a.precision=r,a.rounding=e,Pe(kt==2||kt==4?t.neg():t,r,e,!0)):new a(NaN)},we.times=we.mul=function(r){var e,t,a,n,i,s,f,l,u,o=this,c=o.constructor,m=o.d,v=(r=new c(r)).d;if(r.s*=o.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(o.e/Ve)+Vr(r.e/Ve),l=m.length,u=v.length,l<u&&(i=m,m=v,v=i,s=l,l=u,u=s),i=[],s=l+u,a=s;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%ht|0,e=f/ht|0;i[n]=(i[n]+e)%ht|0}for(;!i[--s];)i.pop();return e?++t:i.shift(),r.d=i,r.e=yi(i,t),We?Pe(r,c.precision,c.rounding):r},we.toBinary=function(r,e){return rs(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:(jr(r,0,nn),e===void 0?e=a.rounding:jr(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=St(a,!0):(jr(r,0,nn),e===void 0?e=n.rounding:jr(e,0,8),a=Pe(new n(a),r+1,e),t=St(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=St(n):(jr(r,0,nn),e===void 0?e=i.rounding:jr(e,0,8),a=Pe(new i(n),r+n.e+1,e),t=St(a,!1,r+a.e+1)),n.isNeg()&&!n.isZero()?"-"+t:t},we.toFraction=function(r){var e,t,a,n,i,s,f,l,u,o,c,m,v=this,p=v.d,h=v.constructor;if(!p)return new h(v);if(u=t=new h(1),a=l=new h(0),e=new h(a),i=e.e=Al(p)-v.e-1,s=i%Ve,e.d[0]=Tr(10,s<0?Ve+s:s),r==null)r=i>0?e:u;else{if(f=new h(r),!f.isInt()||f.lt(u))throw Error(an+f);r=f.gt(e)?i>0?e:u:f}for(We=!1,f=new h(zr(p)),o=h.precision,h.precision=i=p.length*Ve*2;c=dr(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=dr(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=dr(u,a,i,1).minus(v).abs().cmp(dr(l,t,i,1).minus(v).abs())<1?[u,a]:[l,t],h.precision=o,We=!0,m},we.toHexadecimal=we.toHex=function(r,e){return rs(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: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]?(We=!1,t=dr(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 rs(this,8,r,e)},we.toPower=we.pow=function(r){var e,t,a,n,i,s,f=this,l=f.constructor,u=+(r=new l(r));if(!f.d||!r.d||!f.d[0]||!r.d[0])return new l(Tr(+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=Vr(r.e/Ve),e>=r.d.length-1&&(t=u<0?-u:u)<=vg)return n=El(l,f,t,a),r.s<0?new l(1).div(n):Pe(n,a,i);if(s=f.s,s<0){if(e<r.d.length-1)return new l(NaN);if((r.d[e]&1)==0&&(s=1),f.e==0&&f.d[0]==1&&f.d.length==1)return f.s=s,f}return t=Tr(+f,u),e=t==0||!isFinite(t)?Vr(u*(Math.log("0."+zr(f.d))/Math.LN10+f.e+1)):new l(t+"").e,e>l.maxE+1||e<l.minE-1?new l(e>0?s/0:0):(We=!1,l.rounding=f.s=1,t=Math.min(12,(e+"").length),n=jo(r.times(sn(f,a+t)),a),n.d&&(n=Pe(n,a+5,1),za(n.d,a,i)&&(e=a+10,n=Pe(jo(r.times(sn(f,e+t)),e),e+5,1),+zr(n.d).slice(a+1,a+15)+1==1e14&&(n=Pe(n,a+1,0)))),n.s=s,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=St(a,a.e<=n.toExpNeg||a.e>=n.toExpPos):(jr(r,1,nn),e===void 0?e=n.rounding:jr(e,0,8),a=Pe(new n(a),r,e),t=St(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):(jr(r,1,nn),e===void 0?e=a.rounding:jr(e,0,8)),Pe(new a(t),r,e)},we.toString=function(){var r=this,e=r.constructor,t=St(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=St(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function zr(r){var e,t,a,n=r.length-1,i="",s=r[0];if(n>0){for(i+=s,e=1;e<n;e++)a=r[e]+"",t=Ve-a.length,t&&(i+=on(t)),i+=a;s=r[e],a=s+"",t=Ve-a.length,t&&(i+=on(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return i+s}function jr(r,e,t){if(r!==~~r||r<e||r>t)throw Error(an+r)}function za(r,e,t,a){var n,i,s,f;for(i=r[0];i>=10;i/=10)--e;return--e<0?(e+=Ve,n=0):(n=Math.ceil((e+1)/Ve),e%=Ve),i=Tr(10,Ve-e),f=r[n]%i|0,a==null?e<3?(e==0?f=f/100|0:e==1&&(f=f/10|0),s=t<4&&f==99999||t>3&&f==49999||f==5e4||f==0):s=(t<4&&f+1==i||t>3&&f+1==i/2)&&(r[n+1]/i/100|0)==Tr(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),s=(a||t<4)&&f==9999||!a&&t>3&&f==4999):s=((a||t<4)&&f+1==i||!a&&t>3&&f+1==i/2)&&(r[n+1]/i/1e3|0)==Tr(10,e-3)-1,s}function gi(r,e,t){for(var a,n=[0],i,s=0,f=r.length;s<f;){for(i=n.length;i--;)n[i]*=e;for(n[0]+=Yo.indexOf(r.charAt(s++)),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 hg(r,e){var t,a,n;if(e.isZero())return e;a=e.d.length,a<32?(t=Math.ceil(a/3),n=(1/xi(4,t)).toString()):(t=16,n="2.3283064365386962890625e-10"),r.precision+=t,e=Yn(r,1,e.times(n),new r(1));for(var i=t;i--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return r.precision-=t,e}var dr=function(){function r(a,n,i){var s,f=0,l=a.length;for(a=a.slice();l--;)s=a[l]*n+f,a[l]=s%i|0,f=s/i|0;return f&&a.unshift(f),a}function e(a,n,i,s){var f,l;if(i!=s)l=i>s?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,s){for(var f=0;i--;)a[i]-=f,f=a[i]<n[i]?1:0,a[i]=f*s+a[i]-n[i];for(;!a[0]&&a.length>1;)a.shift()}return function(a,n,i,s,f,l){var u,o,c,m,v,p,h,y,b,A,d,w,x,g,E,N,S,D,T,B,_=a.constructor,L=a.s==n.s?1:-1,G=a.d,C=n.d;if(!G||!G[0]||!C||!C[0])return new _(!a.s||!n.s||(G?C&&G[0]==C[0]:!C)?NaN:G&&G[0]==0||!C?L*0:L/0);for(l?(v=1,o=a.e-n.e):(l=ht,v=Ve,o=Vr(a.e/v)-Vr(n.e/v)),T=C.length,S=G.length,b=new _(L),A=b.d=[],c=0;C[c]==(G[c]||0);c++);if(C[c]>(G[c]||0)&&o--,i==null?(g=i=_.precision,s=_.rounding):f?g=i+(a.e-n.e)+1:g=i,g<0)A.push(1),p=!0;else{if(g=g/v+2|0,c=0,T==1){for(m=0,C=C[0],g++;(c<S||m)&&g--;c++)E=m*l+(G[c]||0),A[c]=E/C|0,m=E%C|0;p=m||c<S}else{for(m=l/(C[0]+1)|0,m>1&&(C=r(C,m,l),G=r(G,m,l),T=C.length,S=G.length),N=T,d=G.slice(0,T),w=d.length;w<T;)d[w++]=0;B=C.slice(),B.unshift(0),D=C[0],C[1]>=l/2&&++D;do m=0,u=e(C,d,T,w),u<0?(x=d[0],T!=w&&(x=x*l+(d[1]||0)),m=x/D|0,m>1?(m>=l&&(m=l-1),h=r(C,m,l),y=h.length,w=d.length,u=e(h,d,y,w),u==1&&(m--,t(h,T<y?B:C,y,l))):(m==0&&(u=m=1),h=C.slice()),y=h.length,y<w&&h.unshift(0),t(d,h,w,l),u==-1&&(w=d.length,u=e(C,d,T,w),u<1&&(m++,t(d,T<w?B:C,w,l))),w=d.length):u===0&&(m++,d=[0]),A[c++]=m,u&&d[0]?d[w++]=G[N]||0:(d=[G[N]],w=1);while((N++<S||d[0]!==void 0)&&g--);p=d[0]!==void 0}A[0]||A.shift()}if(v==1)b.e=o,bl=p;else{for(c=1,m=A[0];m>=10;m/=10)c++;b.e=c+o*v-1,Pe(b,f?i+b.e+1:i,s,p)}return b}}();function Pe(r,e,t,a){var n,i,s,f,l,u,o,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+=Ve,s=e,o=c[m=0],l=o/Tr(10,n-s-1)%10|0;else if(m=Math.ceil((i+1)/Ve),f=c.length,m>=f)if(a){for(;f++<=m;)c.push(0);o=l=0,n=1,i%=Ve,s=i-Ve+1}else break e;else{for(o=f=c[m],n=1;f>=10;f/=10)n++;i%=Ve,s=i-Ve+n,l=s<0?0:o/Tr(10,n-s-1)%10|0}if(a=a||e<0||c[m+1]!==void 0||(s<0?o:o%Tr(10,n-s-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?s>0?o/Tr(10,n-s):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]=Tr(10,(Ve-e%Ve)%Ve),r.e=-e||0):c[0]=r.e=0,r;if(i==0?(c.length=m,f=1,m--):(c.length=m+1,f=Tr(10,Ve-i),c[m]=s>0?(o/Tr(10,n-s)%Tr(10,s)|0)*f:0),u)for(;;)if(m==0){for(i=1,s=c[0];s>=10;s/=10)i++;for(s=c[0]+=f,f=1;s>=10;s/=10)f++;i!=f&&(r.e++,c[0]==ht&&(c[0]=1));break}else{if(c[m]+=f,c[m]!=ht)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 St(r,e,t){if(!r.isFinite())return Ml(r);var a,n=r.e,i=zr(r.d),s=i.length;return e?(t&&(a=t-s)>0?i=i.charAt(0)+"."+i.slice(1)+on(a):s>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(r.e<0?"e":"e+")+r.e):n<0?(i="0."+on(-n-1)+i,t&&(a=t-s)>0&&(i+=on(a))):n>=s?(i+=on(n+1-s),t&&(a=t-n-1)>0&&(i=i+"."+on(a))):((a=n+1)<s&&(i=i.slice(0,a)+"."+i.slice(a)),t&&(a=t-s)>0&&(n+1===s&&(i+="."),i+=on(a))),i}function yi(r,e){var t=r[0];for(e*=Ve;t>=10;t/=10)e++;return e}function bi(r,e,t){if(e>pg)throw We=!0,t&&(r.precision=t),Error(xl);return Pe(new r(pi),e,1,!0)}function dt(r,e,t){if(e>Ko)throw Error(xl);return Pe(new r(hi),e,t,!0)}function Al(r){var e=r.length-1,t=e*Ve+1;if(e=r[e],e){for(;e%10==0;e/=10)t--;for(e=r[0];e>=10;e/=10)t++}return t}function on(r){for(var e="";r--;)e+="0";return e}function El(r,e,t,a){var n,i=new r(1),s=Math.ceil(a/Ve+4);for(We=!1;;){if(t%2&&(i=i.times(e),Tl(i.d,s)&&(n=!0)),t=Vr(t/2),t===0){t=i.d.length-1,n&&i.d[t]===0&&++i.d[t];break}e=e.times(e),Tl(e.d,s)}return We=!0,i}function Sl(r){return r.d[r.d.length-1]&1}function Cl(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 jo(r,e){var t,a,n,i,s,f,l,u=0,o=0,c=0,m=r.constructor,v=m.rounding,p=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=p):l=e,f=new m(.03125);r.e>-2;)r=r.times(f),c+=5;for(a=Math.log(Tr(2,c))/Math.LN10*2+5|0,l+=a,t=i=s=new m(1),m.precision=l;;){if(i=Pe(i.times(r),l,1),t=t.times(++o),f=s.plus(dr(i,t,l,1)),zr(f.d).slice(0,l)===zr(s.d).slice(0,l)){for(n=c;n--;)s=Pe(s.times(s),l,1);if(e==null)if(u<3&&za(s.d,l-a,v,u))m.precision=l+=10,t=i=f=new m(1),o=0,u++;else return Pe(s,m.precision=p,v,We=!0);else return m.precision=p,s}s=f}}function sn(r,e){var t,a,n,i,s,f,l,u,o,c,m,v=1,p=10,h=r,y=h.d,b=h.constructor,A=b.rounding,d=b.precision;if(h.s<0||!y||!y[0]||!h.e&&y[0]==1&&y.length==1)return new b(y&&!y[0]?-1/0:h.s!=1?NaN:y?0:h);if(e==null?(We=!1,o=d):o=e,b.precision=o+=p,t=zr(y),a=t.charAt(0),Math.abs(i=h.e)<15e14){for(;a<7&&a!=1||a==1&&t.charAt(1)>3;)h=h.times(r),t=zr(h.d),a=t.charAt(0),v++;i=h.e,a>1?(h=new b("0."+t),i++):h=new b(a+"."+t.slice(1))}else return u=bi(b,o+2,d).times(i+""),h=sn(new b(a+"."+t.slice(1)),o-p).plus(u),b.precision=d,e==null?Pe(h,d,A,We=!0):h;for(c=h,l=s=h=dr(h.minus(1),h.plus(1),o,1),m=Pe(h.times(h),o,1),n=3;;){if(s=Pe(s.times(m),o,1),u=l.plus(dr(s,new b(n),o,1)),zr(u.d).slice(0,o)===zr(l.d).slice(0,o))if(l=l.times(2),i!==0&&(l=l.plus(bi(b,o+2,d).times(i+""))),l=dr(l,new b(v),o,1),e==null)if(za(l.d,o-p,A,f))b.precision=o+=p,u=s=h=dr(c.minus(1),c.plus(1),o,1),m=Pe(h.times(h),o,1),n=f=1;else return Pe(l,b.precision=d,A,We=!0);else return b.precision=d,l;l=u,n+=2}}function Ml(r){return String(r.s*r.s/0)}function es(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)%Ve,t<0&&(a+=Ve),a<n){for(a&&r.d.push(+e.slice(0,a)),n-=Ve;a<n;)r.d.push(+e.slice(a,a+=Ve));e=e.slice(a),a=Ve-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 dg(r,e){var t,a,n,i,s,f,l,u,o;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Dl.test(e))return es(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(cg.test(e))t=2;else if(mg.test(e))t=8;else throw Error(an+e);for(i=e.search(/p/i),i>0?(l=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),s=i>=0,a=r.constructor,s&&(e=e.replace(".",""),f=e.length,i=f-i,n=El(a,new a(t),i,i*2)),u=gi(e,t,ht),o=u.length-1,i=o;u[i]===0;--i)u.pop();return i<0?new a(r.s*0):(r.e=yi(u,o),r.d=u,We=!1,s&&(r=dr(r,n,f*4)),l&&(r=r.times(Math.abs(l)<54?Tr(2,l):un.pow(2,l))),We=!0,r)}function gg(r,e){var t,a=e.d.length;if(a<3)return e.isZero()?e:Yn(r,2,e,e);t=1.4*Math.sqrt(a),t=t>16?16:t|0,e=e.times(1/xi(5,t)),e=Yn(r,2,e,e);for(var n,i=new r(5),s=new r(16),f=new r(20);t--;)n=e.times(e),e=e.times(i.plus(n.times(s.times(n).minus(f))));return e}function Yn(r,e,t,a,n){var i,s,f,l,u=r.precision,o=Math.ceil(u/Ve);for(We=!1,l=t.times(t),f=new r(a);;){if(s=dr(f.times(l),new r(e++*e++),u,1),f=n?a.plus(s):a.minus(s),a=dr(s.times(l),new r(e++*e++),u,1),s=f.plus(a),s.d[o]!==void 0){for(i=o;s.d[i]===f.d[i]&&i--;);if(i==-1)break}i=f,f=a,a=s,s=i}return We=!0,s.d.length=o+1,s}function xi(r,e){for(var t=r;--e;)t*=r;return t}function Fl(r,e){var t,a=e.s<0,n=dt(r,r.precision,1),i=n.times(.5);if(e=e.abs(),e.lte(i))return kt=a?4:1,e;if(t=e.divToInt(n),t.isZero())kt=a?3:2;else{if(e=e.minus(t.times(n)),e.lte(i))return kt=Sl(t)?a?2:3:a?4:1,e;kt=Sl(t)?a?1:4:a?3:2}return e.minus(n).abs()}function rs(r,e,t,a){var n,i,s,f,l,u,o,c,m,v=r.constructor,p=t!==void 0;if(p?(jr(t,1,nn),a===void 0?a=v.rounding:jr(a,0,8)):(t=v.precision,a=v.rounding),!r.isFinite())o=Ml(r);else{for(o=St(r),s=o.indexOf("."),p?(n=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):n=e,s>=0&&(o=o.replace(".",""),m=new v(1),m.e=o.length-s,m.d=gi(St(m),10,n),m.e=m.d.length),c=gi(o,10,n),i=l=c.length;c[--l]==0;)c.pop();if(!c[0])o=p?"0p+0":"0";else{if(s<0?i--:(r=new v(r),r.d=c,r.e=i,r=dr(r,m,t,a,0,n),c=r.d,i=r.e,u=bl),s=c[t],f=n/2,u=u||c[t+1]!==void 0,u=a<4?(s!==void 0||u)&&(a===0||a===(r.s<0?3:2)):s>f||s===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(s=0,o="";s<l;s++)o+=Yo.charAt(c[s]);if(p){if(l>1)if(e==16||e==8){for(s=e==16?4:3,--l;l%s;l++)o+="0";for(c=gi(o,n,e),l=c.length;!c[l-1];--l);for(s=1,o="1.";s<l;s++)o+=Yo.charAt(c[s])}else o=o.charAt(0)+"."+o.slice(1);o=o+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)o="0"+o;o="0."+o}else if(++i>l)for(i-=l;i--;)o+="0";else i<l&&(o=o.slice(0,i)+"."+o.slice(i))}o=(e==16?"0x":e==2?"0b":e==8?"0o":"")+o}return r.s<0?"-"+o:o}function Tl(r,e){if(r.length>e)return r.length=e,!0}function yg(r){return new this(r).abs()}function bg(r){return new this(r).acos()}function xg(r){return new this(r).acosh()}function wg(r,e){return new this(r).plus(e)}function Ng(r){return new this(r).asin()}function Dg(r){return new this(r).asinh()}function Ag(r){return new this(r).atan()}function Eg(r){return new this(r).atanh()}function Sg(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=dt(this,i,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?dt(this,a,n):new this(0),t.s=r.s):!r.d||e.isZero()?(t=dt(this,i,1).times(.5),t.s=r.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(dr(r,e,i,1)),e=dt(this,i,1),this.precision=a,this.rounding=n,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(dr(r,e,i,1)),t}function Cg(r){return new this(r).cbrt()}function Mg(r){return Pe(r=new this(r),r.e+1,2)}function Fg(r,e,t){return new this(r).clamp(e,t)}function Tg(r){if(!r||typeof r!="object")throw Error(di+"Object expected");var e,t,a,n=r.defaults===!0,i=["precision",1,nn,"rounding",0,8,"toExpNeg",-Xn,0,"toExpPos",0,Xn,"maxE",0,Xn,"minE",-Xn,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],n&&(this[t]=Qo[t]),(a=r[t])!==void 0)if(Vr(a)===a&&a>=i[e+1]&&a<=i[e+2])this[t]=a;else throw Error(an+t+": "+a);if(t="crypto",n&&(this[t]=Qo[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(wl);else this[t]=!1;else throw Error(an+t+": "+a);return this}function Bg(r){return new this(r).cos()}function $g(r){return new this(r).cosh()}function Bl(r){var e,t,a;function n(i){var s,f,l,u=this;if(!(u instanceof n))return new n(i);if(u.constructor=n,$l(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(s=0,f=i;f>=10;f/=10)s++;We?s>n.maxE?(u.e=NaN,u.d=null):s<n.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[i]):(u.e=s,u.d=[i]);return}else if(i*0!==0){i||(u.s=NaN),u.e=NaN,u.d=null;return}return es(u,i.toString())}else if(l!=="string")throw Error(an+i);return(f=i.charCodeAt(0))===45?(i=i.slice(1),u.s=-1):(f===43&&(i=i.slice(1)),u.s=1),Dl.test(i)?es(u,i):dg(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=Tg,n.clone=Bl,n.isDecimal=$l,n.abs=yg,n.acos=bg,n.acosh=xg,n.add=wg,n.asin=Ng,n.asinh=Dg,n.atan=Ag,n.atanh=Eg,n.atan2=Sg,n.cbrt=Cg,n.ceil=Mg,n.clamp=Fg,n.cos=Bg,n.cosh=$g,n.div=Og,n.exp=_g,n.floor=Ig,n.hypot=Rg,n.ln=qg,n.log=zg,n.log10=Lg,n.log2=Pg,n.max=Ug,n.min=kg,n.mod=Vg,n.mul=Gg,n.pow=Hg,n.random=Zg,n.round=Jg,n.sign=Wg,n.sin=Xg,n.sinh=Yg,n.sqrt=Qg,n.sub=Kg,n.sum=jg,n.tan=e1,n.tanh=r1,n.trunc=t1,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 Og(r,e){return new this(r).div(e)}function _g(r){return new this(r).exp()}function Ig(r){return Pe(r=new this(r),r.e+1,3)}function Rg(){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 $l(r){return r instanceof un||r&&r.toStringTag===Nl||!1}function qg(r){return new this(r).ln()}function zg(r,e){return new this(r).log(e)}function Pg(r){return new this(r).log(2)}function Lg(r){return new this(r).log(10)}function Ug(){return Cl(this,arguments,"lt")}function kg(){return Cl(this,arguments,"gt")}function Vg(r,e){return new this(r).mod(e)}function Gg(r,e){return new this(r).mul(e)}function Hg(r,e){return new this(r).pow(e)}function Zg(r){var e,t,a,n,i=0,s=new this(1),f=[];if(r===void 0?r=this.precision:jr(r,1,nn),a=Math.ceil(r/Ve),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(wl);else for(;i<a;)f[i++]=Math.random()*1e7|0;for(a=f[--i],r%=Ve,a&&r&&(n=Tr(10,Ve-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-=Ve)f.shift();for(a=1,n=f[0];n>=10;n/=10)a++;a<Ve&&(t-=Ve-a)}return s.e=t,s.d=f,s}function Jg(r){return Pe(r=new this(r),r.e+1,this.rounding)}function Wg(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function Xg(r){return new this(r).sin()}function Yg(r){return new this(r).sinh()}function Qg(r){return new this(r).sqrt()}function Kg(r,e){return new this(r).sub(e)}function jg(){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 e1(r){return new this(r).tan()}function r1(r){return new this(r).tanh()}function t1(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 un=we.constructor=Bl(Qo);pi=new un(pi),hi=new un(hi);var n1="BigNumber",a1=["?on","config"],i1=R(n1,a1,r=>{var{on:e,config:t}=r,a=un.clone({precision:t.precision,modulo:un.EUCLID});return a.prototype=Object.create(a.prototype),a.prototype.type="BigNumber",a.prototype.isBigNumber=!0,a.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},a.fromJSON=function(n){return new a(n.value)},e&&e("config",function(n,i){n.precision!==i.precision&&a.config({precision:n.precision})}),a},{isClass:!0}),Sn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ol(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function o1(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 _l={exports:{}};/**
15
+ */var ta=9e15,on=1e9,es="0123456789abcdef",bi="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",xi="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",rs={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ta,maxE:ta,crypto:!1},Bl,Zt,Xe=!0,wi="[DecimalError] ",sn=wi+"Invalid argument: ",$l=wi+"Precision limit exceeded",Ol=wi+"crypto unavailable",Il="[object Decimal]",Gr=Math.floor,Or=Math.pow,_g=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,qg=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,zg=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Rl=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,gt=1e7,He=7,Pg=9007199254740991,Ug=bi.length-1,ts=xi.length-1,xe={toStringTag:Il};xe.absoluteValue=xe.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),Pe(r)},xe.ceil=function(){return Pe(new this.constructor(this),this.e+1,2)},xe.clampedTo=xe.clamp=function(r,e){var t,a=this,n=a.constructor;if(r=new n(r),e=new n(e),!r.s||!e.s)return new n(NaN);if(r.gt(e))throw Error(sn+e);return t=a.cmp(r),t<0?r:a.cmp(e)>0?e:new n(a)},xe.comparedTo=xe.cmp=function(r){var e,t,a,n,i=this,o=i.d,f=(r=new i.constructor(r)).d,l=i.s,u=r.s;if(!o||!f)return!l||!u?NaN:l!==u?l:o===f?0:!o^l<0?1:-1;if(!o[0]||!f[0])return o[0]?l:f[0]?-u:0;if(l!==u)return l;if(i.e!==r.e)return i.e>r.e^l<0?1:-1;for(a=o.length,n=f.length,e=0,t=a<n?a:n;e<t;++e)if(o[e]!==f[e])return o[e]>f[e]^l<0?1:-1;return a===n?0:a>n^l<0?1:-1},xe.cosine=xe.cos=function(){var r,e,t=this,a=t.constructor;return t.d?t.d[0]?(r=a.precision,e=a.rounding,a.precision=r+Math.max(t.e,t.sd())+He,a.rounding=1,t=Lg(a,Ll(a,t)),a.precision=r,a.rounding=e,Pe(Zt==2||Zt==3?t.neg():t,r,e,!0)):new a(1):new a(NaN)},xe.cubeRoot=xe.cbrt=function(){var r,e,t,a,n,i,o,f,l,u,s=this,c=s.constructor;if(!s.isFinite()||s.isZero())return new c(s);for(Xe=!1,i=s.s*Or(s.s*s,1/3),!i||Math.abs(i)==1/0?(t=Pr(s.d),r=s.e,(i=(r-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=Or(t,1/3),r=Gr((r+1)/3)-(r%3==(r<0?-1:2)),i==1/0?t="5e"+r:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),a=new c(t),a.s=s.s):a=new c(i.toString()),o=(r=c.precision)+3;;)if(f=a,l=f.times(f).times(f),u=l.plus(s),a=gr(u.plus(s).times(f),u.plus(l),o+2,1),Pr(f.d).slice(0,o)===(t=Pr(a.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!n&&t=="4999"){if(!n&&(Pe(f,r+1,0),f.times(f).times(f).eq(s))){a=f;break}o+=4,n=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Pe(a,r+1,1),e=!a.times(a).times(a).eq(s));break}return Xe=!0,Pe(a,r,c.rounding,e)},xe.decimalPlaces=xe.dp=function(){var r,e=this.d,t=NaN;if(e){if(r=e.length-1,t=(r-Gr(this.e/He))*He,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t},xe.dividedBy=xe.div=function(r){return gr(this,new this.constructor(r))},xe.dividedToIntegerBy=xe.divToInt=function(r){var e=this,t=e.constructor;return Pe(gr(e,new t(r),0,1,1),t.precision,t.rounding)},xe.equals=xe.eq=function(r){return this.cmp(r)===0},xe.floor=function(){return Pe(new this.constructor(this),this.e+1,3)},xe.greaterThan=xe.gt=function(r){return this.cmp(r)>0},xe.greaterThanOrEqualTo=xe.gte=function(r){var e=this.cmp(r);return e==1||e===0},xe.hyperbolicCosine=xe.cosh=function(){var r,e,t,a,n,i=this,o=i.constructor,f=new o(1);if(!i.isFinite())return new o(i.s?1/0:NaN);if(i.isZero())return f;t=o.precision,a=o.rounding,o.precision=t+Math.max(i.e,i.sd())+4,o.rounding=1,n=i.d.length,n<32?(r=Math.ceil(n/3),e=(1/Ei(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),i=na(o,1,i.times(e),new o(1),!0);for(var l,u=r,s=new o(8);u--;)l=i.times(i),i=f.minus(l.times(s.minus(l.times(s))));return Pe(i,o.precision=t,o.rounding=a,!0)},xe.hyperbolicSine=xe.sinh=function(){var r,e,t,a,n=this,i=n.constructor;if(!n.isFinite()||n.isZero())return new i(n);if(e=i.precision,t=i.rounding,i.precision=e+Math.max(n.e,n.sd())+4,i.rounding=1,a=n.d.length,a<3)n=na(i,2,n,n,!0);else{r=1.4*Math.sqrt(a),r=r>16?16:r|0,n=n.times(1/Ei(5,r)),n=na(i,2,n,n,!0);for(var o,f=new i(5),l=new i(16),u=new i(20);r--;)o=n.times(n),n=n.times(f.plus(o.times(l.times(o).plus(u))))}return i.precision=e,i.rounding=t,Pe(n,e,t,!0)},xe.hyperbolicTangent=xe.tanh=function(){var r,e,t=this,a=t.constructor;return t.isFinite()?t.isZero()?new a(t):(r=a.precision,e=a.rounding,a.precision=r+7,a.rounding=1,gr(t.sinh(),t.cosh(),a.precision=r,a.rounding=e)):new a(t.s)},xe.inverseCosine=xe.acos=function(){var r,e=this,t=e.constructor,a=e.abs().cmp(1),n=t.precision,i=t.rounding;return a!==-1?a===0?e.isNeg()?yt(t,n,i):new t(0):new t(NaN):e.isZero()?yt(t,n+4,i).times(.5):(t.precision=n+6,t.rounding=1,e=e.asin(),r=yt(t,n+4,i).times(.5),t.precision=n,t.rounding=i,r.minus(e))},xe.inverseHyperbolicCosine=xe.acosh=function(){var r,e,t=this,a=t.constructor;return t.lte(1)?new a(t.eq(1)?0:NaN):t.isFinite()?(r=a.precision,e=a.rounding,a.precision=r+Math.max(Math.abs(t.e),t.sd())+4,a.rounding=1,Xe=!1,t=t.times(t).minus(1).sqrt().plus(t),Xe=!0,a.precision=r,a.rounding=e,t.ln()):new a(t)},xe.inverseHyperbolicSine=xe.asinh=function(){var r,e,t=this,a=t.constructor;return!t.isFinite()||t.isZero()?new a(t):(r=a.precision,e=a.rounding,a.precision=r+2*Math.max(Math.abs(t.e),t.sd())+6,a.rounding=1,Xe=!1,t=t.times(t).plus(1).sqrt().plus(t),Xe=!0,a.precision=r,a.rounding=e,t.ln())},xe.inverseHyperbolicTangent=xe.atanh=function(){var r,e,t,a,n=this,i=n.constructor;return n.isFinite()?n.e>=0?new i(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(r=i.precision,e=i.rounding,a=n.sd(),Math.max(a,r)<2*-n.e-1?Pe(new i(n),r,e,!0):(i.precision=t=a-n.e,n=gr(n.plus(1),new i(1).minus(n),t+r,1),i.precision=r+4,i.rounding=1,n=n.ln(),i.precision=r,i.rounding=e,n.times(.5))):new i(NaN)},xe.inverseSine=xe.asin=function(){var r,e,t,a,n=this,i=n.constructor;return n.isZero()?new i(n):(e=n.abs().cmp(1),t=i.precision,a=i.rounding,e!==-1?e===0?(r=yt(i,t+4,a).times(.5),r.s=n.s,r):new i(NaN):(i.precision=t+6,i.rounding=1,n=n.div(new i(1).minus(n.times(n)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=a,n.times(2)))},xe.inverseTangent=xe.atan=function(){var r,e,t,a,n,i,o,f,l,u=this,s=u.constructor,c=s.precision,m=s.rounding;if(u.isFinite()){if(u.isZero())return new s(u);if(u.abs().eq(1)&&c+4<=ts)return o=yt(s,c+4,m).times(.25),o.s=u.s,o}else{if(!u.s)return new s(NaN);if(c+4<=ts)return o=yt(s,c+4,m).times(.5),o.s=u.s,o}for(s.precision=f=c+10,s.rounding=1,t=Math.min(28,f/He+2|0),r=t;r;--r)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(Xe=!1,e=Math.ceil(f/He),a=1,l=u.times(u),o=new s(u),n=u;r!==-1;)if(n=n.times(l),i=o.minus(n.div(a+=2)),n=n.times(l),o=i.plus(n.div(a+=2)),o.d[e]!==void 0)for(r=e;o.d[r]===i.d[r]&&r--;);return t&&(o=o.times(2<<t-1)),Xe=!0,Pe(o,s.precision=c,s.rounding=m,!0)},xe.isFinite=function(){return!!this.d},xe.isInteger=xe.isInt=function(){return!!this.d&&Gr(this.e/He)>this.d.length-2},xe.isNaN=function(){return!this.s},xe.isNegative=xe.isNeg=function(){return this.s<0},xe.isPositive=xe.isPos=function(){return this.s>0},xe.isZero=function(){return!!this.d&&this.d[0]===0},xe.lessThan=xe.lt=function(r){return this.cmp(r)<0},xe.lessThanOrEqualTo=xe.lte=function(r){return this.cmp(r)<1},xe.logarithm=xe.log=function(r){var e,t,a,n,i,o,f,l,u=this,s=u.constructor,c=s.precision,m=s.rounding,v=5;if(r==null)r=new s(10),e=!0;else{if(r=new s(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new s(NaN);e=r.eq(10)}if(t=u.d,u.s<0||!t||!t[0]||u.eq(1))return new s(t&&!t[0]?-1/0:u.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)i=!0;else{for(n=t[0];n%10===0;)n/=10;i=n!==1}if(Xe=!1,f=c+v,o=ln(u,f),a=e?Ai(s,f+10):ln(r,f),l=gr(o,a,f,1),ka(l.d,n=c,m))do if(f+=10,o=ln(u,f),a=e?Ai(s,f+10):ln(r,f),l=gr(o,a,f,1),!i){+Pr(l.d).slice(n+1,n+15)+1==1e14&&(l=Pe(l,c+1,0));break}while(ka(l.d,n+=10,m));return Xe=!0,Pe(l,c,m)},xe.minus=xe.sub=function(r){var e,t,a,n,i,o,f,l,u,s,c,m,v=this,h=v.constructor;if(r=new h(r),!v.d||!r.d)return!v.s||!r.s?r=new h(NaN):v.d?r.s=-r.s:r=new h(r.d||v.s!==r.s?v:NaN),r;if(v.s!=r.s)return r.s=-r.s,v.plus(r);if(u=v.d,m=r.d,f=h.precision,l=h.rounding,!u[0]||!m[0]){if(m[0])r.s=-r.s;else if(u[0])r=new h(v);else return new h(l===3?-0:0);return Xe?Pe(r,f,l):r}if(t=Gr(r.e/He),s=Gr(v.e/He),u=u.slice(),i=s-t,i){for(c=i<0,c?(e=u,i=-i,o=m.length):(e=m,t=s,o=u.length),a=Math.max(Math.ceil(f/He),o)+2,i>a&&(i=a,e.length=1),e.reverse(),a=i;a--;)e.push(0);e.reverse()}else{for(a=u.length,o=m.length,c=a<o,c&&(o=a),a=0;a<o;a++)if(u[a]!=m[a]){c=u[a]<m[a];break}i=0}for(c&&(e=u,u=m,m=e,r.s=-r.s),o=u.length,a=m.length-o;a>0;--a)u[o++]=0;for(a=m.length;a>i;){if(u[--a]<m[a]){for(n=a;n&&u[--n]===0;)u[n]=gt-1;--u[n],u[a]+=gt}u[a]-=m[a]}for(;u[--o]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(r.d=u,r.e=Di(u,t),Xe?Pe(r,f,l):r):new h(l===3?-0:0)},xe.modulo=xe.mod=function(r){var e,t=this,a=t.constructor;return r=new a(r),!t.d||!r.s||r.d&&!r.d[0]?new a(NaN):!r.d||t.d&&!t.d[0]?Pe(new a(t),a.precision,a.rounding):(Xe=!1,a.modulo==9?(e=gr(t,r.abs(),0,3,1),e.s*=r.s):e=gr(t,r,0,a.modulo,1),e=e.times(r),Xe=!0,t.minus(e))},xe.naturalExponential=xe.exp=function(){return ns(this)},xe.naturalLogarithm=xe.ln=function(){return ln(this)},xe.negated=xe.neg=function(){var r=new this.constructor(this);return r.s=-r.s,Pe(r)},xe.plus=xe.add=function(r){var e,t,a,n,i,o,f,l,u,s,c=this,m=c.constructor;if(r=new m(r),!c.d||!r.d)return!c.s||!r.s?r=new m(NaN):c.d||(r=new m(r.d||c.s===r.s?c:NaN)),r;if(c.s!=r.s)return r.s=-r.s,c.minus(r);if(u=c.d,s=r.d,f=m.precision,l=m.rounding,!u[0]||!s[0])return s[0]||(r=new m(c)),Xe?Pe(r,f,l):r;if(i=Gr(c.e/He),a=Gr(r.e/He),u=u.slice(),n=i-a,n){for(n<0?(t=u,n=-n,o=s.length):(t=s,a=i,o=u.length),i=Math.ceil(f/He),o=i>o?i+1:o+1,n>o&&(n=o,t.length=1),t.reverse();n--;)t.push(0);t.reverse()}for(o=u.length,n=s.length,o-n<0&&(n=o,t=s,s=u,u=t),e=0;n;)e=(u[--n]=u[n]+s[n]+e)/gt|0,u[n]%=gt;for(e&&(u.unshift(e),++a),o=u.length;u[--o]==0;)u.pop();return r.d=u,r.e=Di(u,a),Xe?Pe(r,f,l):r},xe.precision=xe.sd=function(r){var e,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(sn+r);return t.d?(e=_l(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e},xe.round=function(){var r=this,e=r.constructor;return Pe(new e(r),r.e+1,e.rounding)},xe.sine=xe.sin=function(){var r,e,t=this,a=t.constructor;return t.isFinite()?t.isZero()?new a(t):(r=a.precision,e=a.rounding,a.precision=r+Math.max(t.e,t.sd())+He,a.rounding=1,t=Vg(a,Ll(a,t)),a.precision=r,a.rounding=e,Pe(Zt>2?t.neg():t,r,e,!0)):new a(NaN)},xe.squareRoot=xe.sqrt=function(){var r,e,t,a,n,i,o=this,f=o.d,l=o.e,u=o.s,s=o.constructor;if(u!==1||!f||!f[0])return new s(!u||u<0&&(!f||f[0])?NaN:f?o:1/0);for(Xe=!1,u=Math.sqrt(+o),u==0||u==1/0?(e=Pr(f),(e.length+l)%2==0&&(e+="0"),u=Math.sqrt(e),l=Gr((l+1)/2)-(l<0||l%2),u==1/0?e="5e"+l:(e=u.toExponential(),e=e.slice(0,e.indexOf("e")+1)+l),a=new s(e)):a=new s(u.toString()),t=(l=s.precision)+3;;)if(i=a,a=i.plus(gr(o,i,t+2,1)).times(.5),Pr(i.d).slice(0,t)===(e=Pr(a.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!n&&e=="4999"){if(!n&&(Pe(i,l+1,0),i.times(i).eq(o))){a=i;break}t+=4,n=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(Pe(a,l+1,1),r=!a.times(a).eq(o));break}return Xe=!0,Pe(a,l,s.rounding,r)},xe.tangent=xe.tan=function(){var r,e,t=this,a=t.constructor;return t.isFinite()?t.isZero()?new a(t):(r=a.precision,e=a.rounding,a.precision=r+10,a.rounding=1,t=t.sin(),t.s=1,t=gr(t,new a(1).minus(t.times(t)).sqrt(),r+10,0),a.precision=r,a.rounding=e,Pe(Zt==2||Zt==4?t.neg():t,r,e,!0)):new a(NaN)},xe.times=xe.mul=function(r){var e,t,a,n,i,o,f,l,u,s=this,c=s.constructor,m=s.d,v=(r=new c(r)).d;if(r.s*=s.s,!m||!m[0]||!v||!v[0])return new c(!r.s||m&&!m[0]&&!v||v&&!v[0]&&!m?NaN:!m||!v?r.s/0:r.s*0);for(t=Gr(s.e/He)+Gr(r.e/He),l=m.length,u=v.length,l<u&&(i=m,m=v,v=i,o=l,l=u,u=o),i=[],o=l+u,a=o;a--;)i.push(0);for(a=u;--a>=0;){for(e=0,n=l+a;n>a;)f=i[n]+v[a]*m[n-a-1]+e,i[n--]=f%gt|0,e=f/gt|0;i[n]=(i[n]+e)%gt|0}for(;!i[--o];)i.pop();return e?++t:i.shift(),r.d=i,r.e=Di(i,t),Xe?Pe(r,c.precision,c.rounding):r},xe.toBinary=function(r,e){return is(this,2,r,e)},xe.toDecimalPlaces=xe.toDP=function(r,e){var t=this,a=t.constructor;return t=new a(t),r===void 0?t:(et(r,0,on),e===void 0?e=a.rounding:et(e,0,8),Pe(t,r+t.e+1,e))},xe.toExponential=function(r,e){var t,a=this,n=a.constructor;return r===void 0?t=Tt(a,!0):(et(r,0,on),e===void 0?e=n.rounding:et(e,0,8),a=Pe(new n(a),r+1,e),t=Tt(a,!0,r+1)),a.isNeg()&&!a.isZero()?"-"+t:t},xe.toFixed=function(r,e){var t,a,n=this,i=n.constructor;return r===void 0?t=Tt(n):(et(r,0,on),e===void 0?e=i.rounding:et(e,0,8),a=Pe(new i(n),r+n.e+1,e),t=Tt(a,!1,r+a.e+1)),n.isNeg()&&!n.isZero()?"-"+t:t},xe.toFraction=function(r){var e,t,a,n,i,o,f,l,u,s,c,m,v=this,h=v.d,p=v.constructor;if(!h)return new p(v);if(u=t=new p(1),a=l=new p(0),e=new p(a),i=e.e=_l(h)-v.e-1,o=i%He,e.d[0]=Or(10,o<0?He+o:o),r==null)r=i>0?e:u;else{if(f=new p(r),!f.isInt()||f.lt(u))throw Error(sn+f);r=f.gt(e)?i>0?e:u:f}for(Xe=!1,f=new p(Pr(h)),s=p.precision,p.precision=i=h.length*He*2;c=gr(f,e,0,1,1),n=t.plus(c.times(a)),n.cmp(r)!=1;)t=a,a=n,n=u,u=l.plus(c.times(n)),l=n,n=e,e=f.minus(c.times(n)),f=n;return n=gr(r.minus(t),a,0,1,1),l=l.plus(n.times(u)),t=t.plus(n.times(a)),l.s=u.s=v.s,m=gr(u,a,i,1).minus(v).abs().cmp(gr(l,t,i,1).minus(v).abs())<1?[u,a]:[l,t],p.precision=s,Xe=!0,m},xe.toHexadecimal=xe.toHex=function(r,e){return is(this,16,r,e)},xe.toNearest=function(r,e){var t=this,a=t.constructor;if(t=new a(t),r==null){if(!t.d)return t;r=new a(1),e=a.rounding}else{if(r=new a(r),e===void 0?e=a.rounding:et(e,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(Xe=!1,t=gr(t,r,0,e,1).times(r),Xe=!0,Pe(t)):(r.s=t.s,t=r),t},xe.toNumber=function(){return+this},xe.toOctal=function(r,e){return is(this,8,r,e)},xe.toPower=xe.pow=function(r){var e,t,a,n,i,o,f=this,l=f.constructor,u=+(r=new l(r));if(!f.d||!r.d||!f.d[0]||!r.d[0])return new l(Or(+f,u));if(f=new l(f),f.eq(1))return f;if(a=l.precision,i=l.rounding,r.eq(1))return Pe(f,a,i);if(e=Gr(r.e/He),e>=r.d.length-1&&(t=u<0?-u:u)<=Pg)return n=ql(l,f,t,a),r.s<0?new l(1).div(n):Pe(n,a,i);if(o=f.s,o<0){if(e<r.d.length-1)return new l(NaN);if((r.d[e]&1)==0&&(o=1),f.e==0&&f.d[0]==1&&f.d.length==1)return f.s=o,f}return t=Or(+f,u),e=t==0||!isFinite(t)?Gr(u*(Math.log("0."+Pr(f.d))/Math.LN10+f.e+1)):new l(t+"").e,e>l.maxE+1||e<l.minE-1?new l(e>0?o/0:0):(Xe=!1,l.rounding=f.s=1,t=Math.min(12,(e+"").length),n=ns(r.times(ln(f,a+t)),a),n.d&&(n=Pe(n,a+5,1),ka(n.d,a,i)&&(e=a+10,n=Pe(ns(r.times(ln(f,e+t)),e),e+5,1),+Pr(n.d).slice(a+1,a+15)+1==1e14&&(n=Pe(n,a+1,0)))),n.s=o,Xe=!0,l.rounding=i,Pe(n,a,i))},xe.toPrecision=function(r,e){var t,a=this,n=a.constructor;return r===void 0?t=Tt(a,a.e<=n.toExpNeg||a.e>=n.toExpPos):(et(r,1,on),e===void 0?e=n.rounding:et(e,0,8),a=Pe(new n(a),r,e),t=Tt(a,r<=a.e||a.e<=n.toExpNeg,r)),a.isNeg()&&!a.isZero()?"-"+t:t},xe.toSignificantDigits=xe.toSD=function(r,e){var t=this,a=t.constructor;return r===void 0?(r=a.precision,e=a.rounding):(et(r,1,on),e===void 0?e=a.rounding:et(e,0,8)),Pe(new a(t),r,e)},xe.toString=function(){var r=this,e=r.constructor,t=Tt(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t},xe.truncated=xe.trunc=function(){return Pe(new this.constructor(this),this.e+1,1)},xe.valueOf=xe.toJSON=function(){var r=this,e=r.constructor,t=Tt(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function Pr(r){var e,t,a,n=r.length-1,i="",o=r[0];if(n>0){for(i+=o,e=1;e<n;e++)a=r[e]+"",t=He-a.length,t&&(i+=un(t)),i+=a;o=r[e],a=o+"",t=He-a.length,t&&(i+=un(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return i+o}function et(r,e,t){if(r!==~~r||r<e||r>t)throw Error(sn+r)}function ka(r,e,t,a){var n,i,o,f;for(i=r[0];i>=10;i/=10)--e;return--e<0?(e+=He,n=0):(n=Math.ceil((e+1)/He),e%=He),i=Or(10,He-e),f=r[n]%i|0,a==null?e<3?(e==0?f=f/100|0:e==1&&(f=f/10|0),o=t<4&&f==99999||t>3&&f==49999||f==5e4||f==0):o=(t<4&&f+1==i||t>3&&f+1==i/2)&&(r[n+1]/i/100|0)==Or(10,e-2)-1||(f==i/2||f==0)&&(r[n+1]/i/100|0)==0:e<4?(e==0?f=f/1e3|0:e==1?f=f/100|0:e==2&&(f=f/10|0),o=(a||t<4)&&f==9999||!a&&t>3&&f==4999):o=((a||t<4)&&f+1==i||!a&&t>3&&f+1==i/2)&&(r[n+1]/i/1e3|0)==Or(10,e-3)-1,o}function Ni(r,e,t){for(var a,n=[0],i,o=0,f=r.length;o<f;){for(i=n.length;i--;)n[i]*=e;for(n[0]+=es.indexOf(r.charAt(o++)),a=0;a<n.length;a++)n[a]>t-1&&(n[a+1]===void 0&&(n[a+1]=0),n[a+1]+=n[a]/t|0,n[a]%=t)}return n.reverse()}function Lg(r,e){var t,a,n;if(e.isZero())return e;a=e.d.length,a<32?(t=Math.ceil(a/3),n=(1/Ei(4,t)).toString()):(t=16,n="2.3283064365386962890625e-10"),r.precision+=t,e=na(r,1,e.times(n),new r(1));for(var i=t;i--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return r.precision-=t,e}var gr=function(){function r(a,n,i){var o,f=0,l=a.length;for(a=a.slice();l--;)o=a[l]*n+f,a[l]=o%i|0,f=o/i|0;return f&&a.unshift(f),a}function e(a,n,i,o){var f,l;if(i!=o)l=i>o?1:-1;else for(f=l=0;f<i;f++)if(a[f]!=n[f]){l=a[f]>n[f]?1:-1;break}return l}function t(a,n,i,o){for(var f=0;i--;)a[i]-=f,f=a[i]<n[i]?1:0,a[i]=f*o+a[i]-n[i];for(;!a[0]&&a.length>1;)a.shift()}return function(a,n,i,o,f,l){var u,s,c,m,v,h,p,g,y,N,d,w,x,b,E,A,S,D,T,B,I=a.constructor,P=a.s==n.s?1:-1,R=a.d,M=n.d;if(!R||!R[0]||!M||!M[0])return new I(!a.s||!n.s||(R?M&&R[0]==M[0]:!M)?NaN:R&&R[0]==0||!M?P*0:P/0);for(l?(v=1,s=a.e-n.e):(l=gt,v=He,s=Gr(a.e/v)-Gr(n.e/v)),T=M.length,S=R.length,y=new I(P),N=y.d=[],c=0;M[c]==(R[c]||0);c++);if(M[c]>(R[c]||0)&&s--,i==null?(b=i=I.precision,o=I.rounding):f?b=i+(a.e-n.e)+1:b=i,b<0)N.push(1),h=!0;else{if(b=b/v+2|0,c=0,T==1){for(m=0,M=M[0],b++;(c<S||m)&&b--;c++)E=m*l+(R[c]||0),N[c]=E/M|0,m=E%M|0;h=m||c<S}else{for(m=l/(M[0]+1)|0,m>1&&(M=r(M,m,l),R=r(R,m,l),T=M.length,S=R.length),A=T,d=R.slice(0,T),w=d.length;w<T;)d[w++]=0;B=M.slice(),B.unshift(0),D=M[0],M[1]>=l/2&&++D;do m=0,u=e(M,d,T,w),u<0?(x=d[0],T!=w&&(x=x*l+(d[1]||0)),m=x/D|0,m>1?(m>=l&&(m=l-1),p=r(M,m,l),g=p.length,w=d.length,u=e(p,d,g,w),u==1&&(m--,t(p,T<g?B:M,g,l))):(m==0&&(u=m=1),p=M.slice()),g=p.length,g<w&&p.unshift(0),t(d,p,w,l),u==-1&&(w=d.length,u=e(M,d,T,w),u<1&&(m++,t(d,T<w?B:M,w,l))),w=d.length):u===0&&(m++,d=[0]),N[c++]=m,u&&d[0]?d[w++]=R[A]||0:(d=[R[A]],w=1);while((A++<S||d[0]!==void 0)&&b--);h=d[0]!==void 0}N[0]||N.shift()}if(v==1)y.e=s,Bl=h;else{for(c=1,m=N[0];m>=10;m/=10)c++;y.e=c+s*v-1,Pe(y,f?i+y.e+1:i,o,h)}return y}}();function Pe(r,e,t,a){var n,i,o,f,l,u,s,c,m,v=r.constructor;e:if(e!=null){if(c=r.d,!c)return r;for(n=1,f=c[0];f>=10;f/=10)n++;if(i=e-n,i<0)i+=He,o=e,s=c[m=0],l=s/Or(10,n-o-1)%10|0;else if(m=Math.ceil((i+1)/He),f=c.length,m>=f)if(a){for(;f++<=m;)c.push(0);s=l=0,n=1,i%=He,o=i-He+1}else break e;else{for(s=f=c[m],n=1;f>=10;f/=10)n++;i%=He,o=i-He+n,l=o<0?0:s/Or(10,n-o-1)%10|0}if(a=a||e<0||c[m+1]!==void 0||(o<0?s:s%Or(10,n-o-1)),u=t<4?(l||a)&&(t==0||t==(r.s<0?3:2)):l>5||l==5&&(t==4||a||t==6&&(i>0?o>0?s/Or(10,n-o):0:c[m-1])%10&1||t==(r.s<0?8:7)),e<1||!c[0])return c.length=0,u?(e-=r.e+1,c[0]=Or(10,(He-e%He)%He),r.e=-e||0):c[0]=r.e=0,r;if(i==0?(c.length=m,f=1,m--):(c.length=m+1,f=Or(10,He-i),c[m]=o>0?(s/Or(10,n-o)%Or(10,o)|0)*f:0),u)for(;;)if(m==0){for(i=1,o=c[0];o>=10;o/=10)i++;for(o=c[0]+=f,f=1;o>=10;o/=10)f++;i!=f&&(r.e++,c[0]==gt&&(c[0]=1));break}else{if(c[m]+=f,c[m]!=gt)break;c[m--]=0,f=1}for(i=c.length;c[--i]===0;)c.pop()}return Xe&&(r.e>v.maxE?(r.d=null,r.e=NaN):r.e<v.minE&&(r.e=0,r.d=[0])),r}function Tt(r,e,t){if(!r.isFinite())return Ul(r);var a,n=r.e,i=Pr(r.d),o=i.length;return e?(t&&(a=t-o)>0?i=i.charAt(0)+"."+i.slice(1)+un(a):o>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(r.e<0?"e":"e+")+r.e):n<0?(i="0."+un(-n-1)+i,t&&(a=t-o)>0&&(i+=un(a))):n>=o?(i+=un(n+1-o),t&&(a=t-n-1)>0&&(i=i+"."+un(a))):((a=n+1)<o&&(i=i.slice(0,a)+"."+i.slice(a)),t&&(a=t-o)>0&&(n+1===o&&(i+="."),i+=un(a))),i}function Di(r,e){var t=r[0];for(e*=He;t>=10;t/=10)e++;return e}function Ai(r,e,t){if(e>Ug)throw Xe=!0,t&&(r.precision=t),Error($l);return Pe(new r(bi),e,1,!0)}function yt(r,e,t){if(e>ts)throw Error($l);return Pe(new r(xi),e,t,!0)}function _l(r){var e=r.length-1,t=e*He+1;if(e=r[e],e){for(;e%10==0;e/=10)t--;for(e=r[0];e>=10;e/=10)t++}return t}function un(r){for(var e="";r--;)e+="0";return e}function ql(r,e,t,a){var n,i=new r(1),o=Math.ceil(a/He+4);for(Xe=!1;;){if(t%2&&(i=i.times(e),kl(i.d,o)&&(n=!0)),t=Gr(t/2),t===0){t=i.d.length-1,n&&i.d[t]===0&&++i.d[t];break}e=e.times(e),kl(e.d,o)}return Xe=!0,i}function zl(r){return r.d[r.d.length-1]&1}function Pl(r,e,t){for(var a,n=new r(e[0]),i=0;++i<e.length;)if(a=new r(e[i]),a.s)n[t](a)&&(n=a);else{n=a;break}return n}function ns(r,e){var t,a,n,i,o,f,l,u=0,s=0,c=0,m=r.constructor,v=m.rounding,h=m.precision;if(!r.d||!r.d[0]||r.e>17)return new m(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:0/0);for(e==null?(Xe=!1,l=h):l=e,f=new m(.03125);r.e>-2;)r=r.times(f),c+=5;for(a=Math.log(Or(2,c))/Math.LN10*2+5|0,l+=a,t=i=o=new m(1),m.precision=l;;){if(i=Pe(i.times(r),l,1),t=t.times(++s),f=o.plus(gr(i,t,l,1)),Pr(f.d).slice(0,l)===Pr(o.d).slice(0,l)){for(n=c;n--;)o=Pe(o.times(o),l,1);if(e==null)if(u<3&&ka(o.d,l-a,v,u))m.precision=l+=10,t=i=f=new m(1),s=0,u++;else return Pe(o,m.precision=h,v,Xe=!0);else return m.precision=h,o}o=f}}function ln(r,e){var t,a,n,i,o,f,l,u,s,c,m,v=1,h=10,p=r,g=p.d,y=p.constructor,N=y.rounding,d=y.precision;if(p.s<0||!g||!g[0]||!p.e&&g[0]==1&&g.length==1)return new y(g&&!g[0]?-1/0:p.s!=1?NaN:g?0:p);if(e==null?(Xe=!1,s=d):s=e,y.precision=s+=h,t=Pr(g),a=t.charAt(0),Math.abs(i=p.e)<15e14){for(;a<7&&a!=1||a==1&&t.charAt(1)>3;)p=p.times(r),t=Pr(p.d),a=t.charAt(0),v++;i=p.e,a>1?(p=new y("0."+t),i++):p=new y(a+"."+t.slice(1))}else return u=Ai(y,s+2,d).times(i+""),p=ln(new y(a+"."+t.slice(1)),s-h).plus(u),y.precision=d,e==null?Pe(p,d,N,Xe=!0):p;for(c=p,l=o=p=gr(p.minus(1),p.plus(1),s,1),m=Pe(p.times(p),s,1),n=3;;){if(o=Pe(o.times(m),s,1),u=l.plus(gr(o,new y(n),s,1)),Pr(u.d).slice(0,s)===Pr(l.d).slice(0,s))if(l=l.times(2),i!==0&&(l=l.plus(Ai(y,s+2,d).times(i+""))),l=gr(l,new y(v),s,1),e==null)if(ka(l.d,s-h,N,f))y.precision=s+=h,u=o=p=gr(c.minus(1),c.plus(1),s,1),m=Pe(p.times(p),s,1),n=f=1;else return Pe(l,y.precision=d,N,Xe=!0);else return y.precision=d,l;l=u,n+=2}}function Ul(r){return String(r.s*r.s/0)}function as(r,e){var t,a,n;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(a=e.search(/e/i))>0?(t<0&&(t=a),t+=+e.slice(a+1),e=e.substring(0,a)):t<0&&(t=e.length),a=0;e.charCodeAt(a)===48;a++);for(n=e.length;e.charCodeAt(n-1)===48;--n);if(e=e.slice(a,n),e){if(n-=a,r.e=t=t-a-1,r.d=[],a=(t+1)%He,t<0&&(a+=He),a<n){for(a&&r.d.push(+e.slice(0,a)),n-=He;a<n;)r.d.push(+e.slice(a,a+=He));e=e.slice(a),a=He-e.length}else a-=n;for(;a--;)e+="0";r.d.push(+e),Xe&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}function kg(r,e){var t,a,n,i,o,f,l,u,s;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Rl.test(e))return as(r,e)}else if(e==="Infinity"||e==="NaN")return+e||(r.s=NaN),r.e=NaN,r.d=null,r;if(qg.test(e))t=16,e=e.toLowerCase();else if(_g.test(e))t=2;else if(zg.test(e))t=8;else throw Error(sn+e);for(i=e.search(/p/i),i>0?(l=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),o=i>=0,a=r.constructor,o&&(e=e.replace(".",""),f=e.length,i=f-i,n=ql(a,new a(t),i,i*2)),u=Ni(e,t,gt),s=u.length-1,i=s;u[i]===0;--i)u.pop();return i<0?new a(r.s*0):(r.e=Di(u,s),r.d=u,Xe=!1,o&&(r=gr(r,n,f*4)),l&&(r=r.times(Math.abs(l)<54?Or(2,l):cn.pow(2,l))),Xe=!0,r)}function Vg(r,e){var t,a=e.d.length;if(a<3)return e.isZero()?e:na(r,2,e,e);t=1.4*Math.sqrt(a),t=t>16?16:t|0,e=e.times(1/Ei(5,t)),e=na(r,2,e,e);for(var n,i=new r(5),o=new r(16),f=new r(20);t--;)n=e.times(e),e=e.times(i.plus(n.times(o.times(n).minus(f))));return e}function na(r,e,t,a,n){var i,o,f,l,u=r.precision,s=Math.ceil(u/He);for(Xe=!1,l=t.times(t),f=new r(a);;){if(o=gr(f.times(l),new r(e++*e++),u,1),f=n?a.plus(o):a.minus(o),a=gr(o.times(l),new r(e++*e++),u,1),o=f.plus(a),o.d[s]!==void 0){for(i=s;o.d[i]===f.d[i]&&i--;);if(i==-1)break}i=f,f=a,a=o,o=i}return Xe=!0,o.d.length=s+1,o}function Ei(r,e){for(var t=r;--e;)t*=r;return t}function Ll(r,e){var t,a=e.s<0,n=yt(r,r.precision,1),i=n.times(.5);if(e=e.abs(),e.lte(i))return Zt=a?4:1,e;if(t=e.divToInt(n),t.isZero())Zt=a?3:2;else{if(e=e.minus(t.times(n)),e.lte(i))return Zt=zl(t)?a?2:3:a?4:1,e;Zt=zl(t)?a?1:4:a?3:2}return e.minus(n).abs()}function is(r,e,t,a){var n,i,o,f,l,u,s,c,m,v=r.constructor,h=t!==void 0;if(h?(et(t,1,on),a===void 0?a=v.rounding:et(a,0,8)):(t=v.precision,a=v.rounding),!r.isFinite())s=Ul(r);else{for(s=Tt(r),o=s.indexOf("."),h?(n=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):n=e,o>=0&&(s=s.replace(".",""),m=new v(1),m.e=s.length-o,m.d=Ni(Tt(m),10,n),m.e=m.d.length),c=Ni(s,10,n),i=l=c.length;c[--l]==0;)c.pop();if(!c[0])s=h?"0p+0":"0";else{if(o<0?i--:(r=new v(r),r.d=c,r.e=i,r=gr(r,m,t,a,0,n),c=r.d,i=r.e,u=Bl),o=c[t],f=n/2,u=u||c[t+1]!==void 0,u=a<4?(o!==void 0||u)&&(a===0||a===(r.s<0?3:2)):o>f||o===f&&(a===4||u||a===6&&c[t-1]&1||a===(r.s<0?8:7)),c.length=t,u)for(;++c[--t]>n-1;)c[t]=0,t||(++i,c.unshift(1));for(l=c.length;!c[l-1];--l);for(o=0,s="";o<l;o++)s+=es.charAt(c[o]);if(h){if(l>1)if(e==16||e==8){for(o=e==16?4:3,--l;l%o;l++)s+="0";for(c=Ni(s,n,e),l=c.length;!c[l-1];--l);for(o=1,s="1.";o<l;o++)s+=es.charAt(c[o])}else s=s.charAt(0)+"."+s.slice(1);s=s+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)s="0"+s;s="0."+s}else if(++i>l)for(i-=l;i--;)s+="0";else i<l&&(s=s.slice(0,i)+"."+s.slice(i))}s=(e==16?"0x":e==2?"0b":e==8?"0o":"")+s}return r.s<0?"-"+s:s}function kl(r,e){if(r.length>e)return r.length=e,!0}function Gg(r){return new this(r).abs()}function Hg(r){return new this(r).acos()}function Zg(r){return new this(r).acosh()}function Jg(r,e){return new this(r).plus(e)}function Xg(r){return new this(r).asin()}function Wg(r){return new this(r).asinh()}function Yg(r){return new this(r).atan()}function Qg(r){return new this(r).atanh()}function Kg(r,e){r=new this(r),e=new this(e);var t,a=this.precision,n=this.rounding,i=a+4;return!r.s||!e.s?t=new this(NaN):!r.d&&!e.d?(t=yt(this,i,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?yt(this,a,n):new this(0),t.s=r.s):!r.d||e.isZero()?(t=yt(this,i,1).times(.5),t.s=r.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(gr(r,e,i,1)),e=yt(this,i,1),this.precision=a,this.rounding=n,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(gr(r,e,i,1)),t}function jg(r){return new this(r).cbrt()}function e1(r){return Pe(r=new this(r),r.e+1,2)}function r1(r,e,t){return new this(r).clamp(e,t)}function t1(r){if(!r||typeof r!="object")throw Error(wi+"Object expected");var e,t,a,n=r.defaults===!0,i=["precision",1,on,"rounding",0,8,"toExpNeg",-ta,0,"toExpPos",0,ta,"maxE",0,ta,"minE",-ta,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],n&&(this[t]=rs[t]),(a=r[t])!==void 0)if(Gr(a)===a&&a>=i[e+1]&&a<=i[e+2])this[t]=a;else throw Error(sn+t+": "+a);if(t="crypto",n&&(this[t]=rs[t]),(a=r[t])!==void 0)if(a===!0||a===!1||a===0||a===1)if(a)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Ol);else this[t]=!1;else throw Error(sn+t+": "+a);return this}function n1(r){return new this(r).cos()}function a1(r){return new this(r).cosh()}function Vl(r){var e,t,a;function n(i){var o,f,l,u=this;if(!(u instanceof n))return new n(i);if(u.constructor=n,Gl(i)){u.s=i.s,Xe?!i.d||i.e>n.maxE?(u.e=NaN,u.d=null):i.e<n.minE?(u.e=0,u.d=[0]):(u.e=i.e,u.d=i.d.slice()):(u.e=i.e,u.d=i.d?i.d.slice():i.d);return}if(l=typeof i,l==="number"){if(i===0){u.s=1/i<0?-1:1,u.e=0,u.d=[0];return}if(i<0?(i=-i,u.s=-1):u.s=1,i===~~i&&i<1e7){for(o=0,f=i;f>=10;f/=10)o++;Xe?o>n.maxE?(u.e=NaN,u.d=null):o<n.minE?(u.e=0,u.d=[0]):(u.e=o,u.d=[i]):(u.e=o,u.d=[i]);return}else if(i*0!==0){i||(u.s=NaN),u.e=NaN,u.d=null;return}return as(u,i.toString())}else if(l!=="string")throw Error(sn+i);return(f=i.charCodeAt(0))===45?(i=i.slice(1),u.s=-1):(f===43&&(i=i.slice(1)),u.s=1),Rl.test(i)?as(u,i):kg(u,i)}if(n.prototype=xe,n.ROUND_UP=0,n.ROUND_DOWN=1,n.ROUND_CEIL=2,n.ROUND_FLOOR=3,n.ROUND_HALF_UP=4,n.ROUND_HALF_DOWN=5,n.ROUND_HALF_EVEN=6,n.ROUND_HALF_CEIL=7,n.ROUND_HALF_FLOOR=8,n.EUCLID=9,n.config=n.set=t1,n.clone=Vl,n.isDecimal=Gl,n.abs=Gg,n.acos=Hg,n.acosh=Zg,n.add=Jg,n.asin=Xg,n.asinh=Wg,n.atan=Yg,n.atanh=Qg,n.atan2=Kg,n.cbrt=jg,n.ceil=e1,n.clamp=r1,n.cos=n1,n.cosh=a1,n.div=i1,n.exp=o1,n.floor=s1,n.hypot=u1,n.ln=l1,n.log=c1,n.log10=m1,n.log2=f1,n.max=v1,n.min=p1,n.mod=h1,n.mul=d1,n.pow=g1,n.random=y1,n.round=b1,n.sign=x1,n.sin=w1,n.sinh=N1,n.sqrt=D1,n.sub=A1,n.sum=E1,n.tan=S1,n.tanh=C1,n.trunc=M1,r===void 0&&(r={}),r&&r.defaults!==!0)for(a=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<a.length;)r.hasOwnProperty(t=a[e++])||(r[t]=this[t]);return n.config(r),n}function i1(r,e){return new this(r).div(e)}function o1(r){return new this(r).exp()}function s1(r){return Pe(r=new this(r),r.e+1,3)}function u1(){var r,e,t=new this(0);for(Xe=!1,r=0;r<arguments.length;)if(e=new this(arguments[r++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return Xe=!0,new this(1/0);t=e}return Xe=!0,t.sqrt()}function Gl(r){return r instanceof cn||r&&r.toStringTag===Il||!1}function l1(r){return new this(r).ln()}function c1(r,e){return new this(r).log(e)}function f1(r){return new this(r).log(2)}function m1(r){return new this(r).log(10)}function v1(){return Pl(this,arguments,"lt")}function p1(){return Pl(this,arguments,"gt")}function h1(r,e){return new this(r).mod(e)}function d1(r,e){return new this(r).mul(e)}function g1(r,e){return new this(r).pow(e)}function y1(r){var e,t,a,n,i=0,o=new this(1),f=[];if(r===void 0?r=this.precision:et(r,1,on),a=Math.ceil(r/He),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(a));i<a;)n=e[i],n>=429e7?e[i]=crypto.getRandomValues(new Uint32Array(1))[0]:f[i++]=n%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(a*=4);i<a;)n=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+((e[i+3]&127)<<24),n>=214e7?crypto.randomBytes(4).copy(e,i):(f.push(n%1e7),i+=4);i=a/4}else throw Error(Ol);else for(;i<a;)f[i++]=Math.random()*1e7|0;for(a=f[--i],r%=He,a&&r&&(n=Or(10,He-r),f[i]=(a/n|0)*n);f[i]===0;i--)f.pop();if(i<0)t=0,f=[0];else{for(t=-1;f[0]===0;t-=He)f.shift();for(a=1,n=f[0];n>=10;n/=10)a++;a<He&&(t-=He-a)}return o.e=t,o.d=f,o}function b1(r){return Pe(r=new this(r),r.e+1,this.rounding)}function x1(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function w1(r){return new this(r).sin()}function N1(r){return new this(r).sinh()}function D1(r){return new this(r).sqrt()}function A1(r,e){return new this(r).sub(e)}function E1(){var r=0,e=arguments,t=new this(e[r]);for(Xe=!1;t.s&&++r<e.length;)t=t.plus(e[r]);return Xe=!0,Pe(t,this.precision,this.rounding)}function S1(r){return new this(r).tan()}function C1(r){return new this(r).tanh()}function M1(r){return Pe(r=new this(r),r.e+1,1)}xe[Symbol.for("nodejs.util.inspect.custom")]=xe.toString,xe[Symbol.toStringTag]="Decimal";var cn=xe.constructor=Vl(rs);bi=new cn(bi),xi=new cn(xi);var F1="BigNumber",T1=["?on","config"],B1=q(F1,T1,r=>{var{on:e,config:t}=r,a=cn.clone({precision:t.precision,modulo:cn.EUCLID});return a.prototype=Object.create(a.prototype),a.prototype.type="BigNumber",a.prototype.isBigNumber=!0,a.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},a.fromJSON=function(n){return new a(n.value)},e&&e("config",function(n,i){n.precision!==i.precision&&a.config({precision:n.precision})}),a},{isClass:!0}),Mn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Hl(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function $1(r){var e=r.default;if(typeof e=="function"){var t=function(){return e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(a){var n=Object.getOwnPropertyDescriptor(r,a);Object.defineProperty(t,a,n.get?n:{enumerable:!0,get:function(){return r[a]}})}),t}var Zl={exports:{}};/**
16
16
  * @license Complex.js v2.1.1 12/05/2020
17
17
  *
18
18
  * Copyright (c) 2020, Robert Eisele (robert@xarg.org)
19
19
  * Dual licensed under the MIT or GPL Version 2 licenses.
20
- **/(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)},s=function(c,m){var v=Math.abs(c),p=Math.abs(m);return v<3e3&&p<3e3?Math.sqrt(v*v+p*p):(v<p?(v=p,p=c/m):p=m/c,v*Math.sqrt(1+p*p))},f=function(){throw SyntaxError("Invalid Param")};function l(c,m){var v=Math.abs(c),p=Math.abs(m);return c===0?Math.log(p):m===0?Math.log(v):v<3e3&&p<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 o.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 o.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 p=c.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),h=1,y=0;p===null&&f();for(var b=0;b<p.length;b++){var A=p[b];A===" "||A===" "||A===`
21
- `||(A==="+"?h++:A==="-"?y++:A==="i"||A==="I"?(h+y===0&&f(),p[b+1]!==" "&&!isNaN(p[b+1])?(v.im+=parseFloat((y%2?"-":"")+p[b+1]),b++):v.im+=parseFloat((y%2?"-":"")+"1"),h=y=0):((h+y===0||isNaN(A))&&f(),p[b+1]==="i"||p[b+1]==="I"?(v.im+=parseFloat((y%2?"-":"")+A),b++):v.re+=parseFloat((y%2?"-":"")+A),h=y=0))}h+y>0&&f();break;case"number":v.im=0,v.re=c;break;default:f()}return isNaN(v.re)||isNaN(v.im),v};function o(c,m){if(!(this instanceof o))return new o(c,m);var v=u(c,m);this.re=v.re,this.im=v.im}o.prototype={re:0,im:0,sign:function(){var c=this.abs();return new o(this.re/c,this.im/c)},add:function(c,m){var v=new o(c,m);return this.isInfinite()&&v.isInfinite()?o.NAN:this.isInfinite()||v.isInfinite()?o.INFINITY:new o(this.re+v.re,this.im+v.im)},sub:function(c,m){var v=new o(c,m);return this.isInfinite()&&v.isInfinite()?o.NAN:this.isInfinite()||v.isInfinite()?o.INFINITY:new o(this.re-v.re,this.im-v.im)},mul:function(c,m){var v=new o(c,m);return this.isInfinite()&&v.isZero()||this.isZero()&&v.isInfinite()?o.NAN:this.isInfinite()||v.isInfinite()?o.INFINITY:v.im===0&&this.im===0?new o(this.re*v.re,0):new o(this.re*v.re-this.im*v.im,this.re*v.im+this.im*v.re)},div:function(c,m){var v=new o(c,m);if(this.isZero()&&v.isZero()||this.isInfinite()&&v.isInfinite())return o.NAN;if(this.isInfinite()||v.isZero())return o.INFINITY;if(this.isZero()||v.isInfinite())return o.ZERO;c=this.re,m=this.im;var p=v.re,h=v.im,y,b;return h===0?new o(c/p,m/p):Math.abs(p)<Math.abs(h)?(b=p/h,y=p*b+h,new o((c*b+m)/y,(m*b-c)/y)):(b=h/p,y=h*b+p,new o((c+m*b)/y,(m-c*b)/y))},pow:function(c,m){var v=new o(c,m);if(c=this.re,m=this.im,v.isZero())return o.ONE;if(v.im===0){if(m===0&&c>0)return new o(Math.pow(c,v.re),0);if(c===0)switch((v.re%4+4)%4){case 0:return new o(Math.pow(m,v.re),0);case 1:return new o(0,Math.pow(m,v.re));case 2:return new o(-Math.pow(m,v.re),0);case 3:return new o(0,-Math.pow(m,v.re))}}if(c===0&&m===0&&v.re>0&&v.im>=0)return o.ZERO;var p=Math.atan2(m,c),h=l(c,m);return c=Math.exp(v.re*h-v.im*p),m=v.im*h+v.re*p,new o(c*Math.cos(m),c*Math.sin(m))},sqrt:function(){var c=this.re,m=this.im,v=this.abs(),p,h;if(c>=0){if(m===0)return new o(Math.sqrt(c),0);p=.5*Math.sqrt(2*(v+c))}else p=Math.abs(m)/Math.sqrt(2*(v-c));return c<=0?h=.5*Math.sqrt(2*(v-c)):h=Math.abs(m)/Math.sqrt(2*(v+c)),new o(p,m<0?-h:h)},exp:function(){var c=Math.exp(this.re);return this.im,new o(c*Math.cos(this.im),c*Math.sin(this.im))},expm1:function(){var c=this.re,m=this.im;return new o(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 o(l(c,m),Math.atan2(m,c))},abs:function(){return s(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var c=this.re,m=this.im;return new o(Math.sin(c)*a(m),Math.cos(c)*n(m))},cos:function(){var c=this.re,m=this.im;return new o(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 o(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 o(-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 o(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 o(Math.sin(c)*a(m)/v,-Math.cos(c)*n(m)/v)},asin:function(){var c=this.re,m=this.im,v=new o(m*m-c*c+1,-2*c*m).sqrt(),p=new o(v.re-m,v.im+c).log();return new o(p.im,-p.re)},acos:function(){var c=this.re,m=this.im,v=new o(m*m-c*c+1,-2*c*m).sqrt(),p=new o(v.re-m,v.im+c).log();return new o(Math.PI/2-p.im,p.re)},atan:function(){var c=this.re,m=this.im;if(c===0){if(m===1)return new o(0,1/0);if(m===-1)return new o(0,-1/0)}var v=c*c+(1-m)*(1-m),p=new o((1-m*m-c*c)/v,-2*c/v).log();return new o(-.5*p.im,.5*p.re)},acot:function(){var c=this.re,m=this.im;if(m===0)return new o(Math.atan2(1,c),0);var v=c*c+m*m;return v!==0?new o(c/v,-m/v).atan():new o(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 o(0,1/0);var v=c*c+m*m;return v!==0?new o(c/v,-m/v).acos():new o(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 o(Math.PI/2,1/0);var v=c*c+m*m;return v!==0?new o(c/v,-m/v).asin():new o(c!==0?c/0:0,m!==0?-m/0:0).asin()},sinh:function(){var c=this.re,m=this.im;return new o(n(c)*Math.cos(m),a(c)*Math.sin(m))},cosh:function(){var c=this.re,m=this.im;return new o(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 o(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 o(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 o(-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 o(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,p=1-c,h=1+c,y=p*p+m*m,b=y!==0?new o((h*p-m*m)/y,(m*p+h*m)/y):new o(c!==-1?c/0:0,m!==0?m/0:0),A=b.re;return b.re=l(b.re,b.im)/2,b.im=Math.atan2(b.im,A)/2,v&&(b.im=-b.im),b},acoth:function(){var c=this.re,m=this.im;if(c===0&&m===0)return new o(0,Math.PI/2);var v=c*c+m*m;return v!==0?new o(c/v,-m/v).atanh():new o(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 o(c!==0?Math.log(c+Math.sqrt(c*c+1)):1/0,0);var v=c*c+m*m;return v!==0?new o(c/v,-m/v).asinh():new o(c!==0?c/0:0,m!==0?-m/0:0).asinh()},asech:function(){var c=this.re,m=this.im;if(this.isZero())return o.INFINITY;var v=c*c+m*m;return v!==0?new o(c/v,-m/v).acosh():new o(c!==0?c/0:0,m!==0?-m/0:0).acosh()},inverse:function(){if(this.isZero())return o.INFINITY;if(this.isInfinite())return o.ZERO;var c=this.re,m=this.im,v=c*c+m*m;return new o(c/v,-m/v)},conjugate:function(){return new o(this.re,-this.im)},neg:function(){return new o(-this.re,-this.im)},ceil:function(c){return c=Math.pow(10,c||0),new o(Math.ceil(this.re*c)/c,Math.ceil(this.im*c)/c)},floor:function(c){return c=Math.pow(10,c||0),new o(Math.floor(this.re*c)/c,Math.floor(this.im*c)/c)},round:function(c){return c=Math.pow(10,c||0),new o(Math.round(this.re*c)/c,Math.round(this.im*c)/c)},equals:function(c,m){var v=new o(c,m);return Math.abs(v.re-this.re)<=o.EPSILON&&Math.abs(v.im-this.im)<=o.EPSILON},clone:function(){return new o(this.re,this.im)},toString:function(){var c=this.re,m=this.im,v="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(c)<o.EPSILON&&(c=0),Math.abs(m)<o.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())}},o.ZERO=new o(0,0),o.ONE=new o(1,0),o.I=new o(0,1),o.PI=new o(Math.PI,0),o.E=new o(Math.E,0),o.INFINITY=new o(1/0,1/0),o.NAN=new o(NaN,NaN),o.EPSILON=1e-15,Object.defineProperty(o,"__esModule",{value:!0}),o.default=o,o.Complex=o,r.exports=o})()})(_l);const Pr=Ol(_l.exports);var s1="Complex",u1=[],l1=R(s1,u1,()=>(Object.defineProperty(Pr,"name",{value:"Complex"}),Pr.prototype.constructor=Pr,Pr.prototype.type="Complex",Pr.prototype.isComplex=!0,Pr.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Pr.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Pr.prototype.format=function(r){var e="",t=this.im,a=this.re,n=En(this.re,r),i=En(this.im,r),s=tr(r)?r:r?r.precision:null;if(s!==null){var f=Math.pow(10,-s);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},Pr.fromPolar=function(r){switch(arguments.length){case 1:{var e=arguments[0];if(typeof e=="object")return Pr(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(Pt(a)&&a.hasBase("ANGLE")&&(a=a.toNumber("rad")),tr(a))return new Pr({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")}},Pr.prototype.valueOf=Pr.prototype.toString,Pr.fromJSON=function(r){return new Pr(r)},Pr.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},Pr),{isClass:!0}),Il={exports:{}};/**
20
+ **/(function(r,e){(function(t){var a=Math.cosh||function(c){return Math.abs(c)<1e-9?1-c:(Math.exp(c)+Math.exp(-c))*.5},n=Math.sinh||function(c){return Math.abs(c)<1e-9?c:(Math.exp(c)-Math.exp(-c))*.5},i=function(c){var m=Math.PI/4;if(-m>c||c>m)return Math.cos(c)-1;var v=c*c;return v*(v*(v*(v*(v*(v*(v*(v/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},o=function(c,m){var v=Math.abs(c),h=Math.abs(m);return v<3e3&&h<3e3?Math.sqrt(v*v+h*h):(v<h?(v=h,h=c/m):h=m/c,v*Math.sqrt(1+h*h))},f=function(){throw SyntaxError("Invalid Param")};function l(c,m){var v=Math.abs(c),h=Math.abs(m);return c===0?Math.log(h):m===0?Math.log(v):v<3e3&&h<3e3?Math.log(c*c+m*m)*.5:(c=c/2,m=m/2,.5*Math.log(c*c+m*m)+Math.LN2)}var u=function(c,m){var v={re:0,im:0};if(c==null)v.re=v.im=0;else if(m!==void 0)v.re=c,v.im=m;else switch(typeof c){case"object":if("im"in c&&"re"in c)v.re=c.re,v.im=c.im;else if("abs"in c&&"arg"in c){if(!Number.isFinite(c.abs)&&Number.isFinite(c.arg))return s.INFINITY;v.re=c.abs*Math.cos(c.arg),v.im=c.abs*Math.sin(c.arg)}else if("r"in c&&"phi"in c){if(!Number.isFinite(c.r)&&Number.isFinite(c.phi))return s.INFINITY;v.re=c.r*Math.cos(c.phi),v.im=c.r*Math.sin(c.phi)}else c.length===2?(v.re=c[0],v.im=c[1]):f();break;case"string":v.im=v.re=0;var h=c.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),p=1,g=0;h===null&&f();for(var y=0;y<h.length;y++){var N=h[y];N===" "||N===" "||N===`
21
+ `||(N==="+"?p++:N==="-"?g++:N==="i"||N==="I"?(p+g===0&&f(),h[y+1]!==" "&&!isNaN(h[y+1])?(v.im+=parseFloat((g%2?"-":"")+h[y+1]),y++):v.im+=parseFloat((g%2?"-":"")+"1"),p=g=0):((p+g===0||isNaN(N))&&f(),h[y+1]==="i"||h[y+1]==="I"?(v.im+=parseFloat((g%2?"-":"")+N),y++):v.re+=parseFloat((g%2?"-":"")+N),p=g=0))}p+g>0&&f();break;case"number":v.im=0,v.re=c;break;default:f()}return isNaN(v.re)||isNaN(v.im),v};function s(c,m){if(!(this instanceof s))return new s(c,m);var v=u(c,m);this.re=v.re,this.im=v.im}s.prototype={re:0,im:0,sign:function(){var c=this.abs();return new s(this.re/c,this.im/c)},add:function(c,m){var v=new s(c,m);return this.isInfinite()&&v.isInfinite()?s.NAN:this.isInfinite()||v.isInfinite()?s.INFINITY:new s(this.re+v.re,this.im+v.im)},sub:function(c,m){var v=new s(c,m);return this.isInfinite()&&v.isInfinite()?s.NAN:this.isInfinite()||v.isInfinite()?s.INFINITY:new s(this.re-v.re,this.im-v.im)},mul:function(c,m){var v=new s(c,m);return this.isInfinite()&&v.isZero()||this.isZero()&&v.isInfinite()?s.NAN:this.isInfinite()||v.isInfinite()?s.INFINITY:v.im===0&&this.im===0?new s(this.re*v.re,0):new s(this.re*v.re-this.im*v.im,this.re*v.im+this.im*v.re)},div:function(c,m){var v=new s(c,m);if(this.isZero()&&v.isZero()||this.isInfinite()&&v.isInfinite())return s.NAN;if(this.isInfinite()||v.isZero())return s.INFINITY;if(this.isZero()||v.isInfinite())return s.ZERO;c=this.re,m=this.im;var h=v.re,p=v.im,g,y;return p===0?new s(c/h,m/h):Math.abs(h)<Math.abs(p)?(y=h/p,g=h*y+p,new s((c*y+m)/g,(m*y-c)/g)):(y=p/h,g=p*y+h,new s((c+m*y)/g,(m-c*y)/g))},pow:function(c,m){var v=new s(c,m);if(c=this.re,m=this.im,v.isZero())return s.ONE;if(v.im===0){if(m===0&&c>0)return new s(Math.pow(c,v.re),0);if(c===0)switch((v.re%4+4)%4){case 0:return new s(Math.pow(m,v.re),0);case 1:return new s(0,Math.pow(m,v.re));case 2:return new s(-Math.pow(m,v.re),0);case 3:return new s(0,-Math.pow(m,v.re))}}if(c===0&&m===0&&v.re>0&&v.im>=0)return s.ZERO;var h=Math.atan2(m,c),p=l(c,m);return c=Math.exp(v.re*p-v.im*h),m=v.im*p+v.re*h,new s(c*Math.cos(m),c*Math.sin(m))},sqrt:function(){var c=this.re,m=this.im,v=this.abs(),h,p;if(c>=0){if(m===0)return new s(Math.sqrt(c),0);h=.5*Math.sqrt(2*(v+c))}else h=Math.abs(m)/Math.sqrt(2*(v-c));return c<=0?p=.5*Math.sqrt(2*(v-c)):p=Math.abs(m)/Math.sqrt(2*(v+c)),new s(h,m<0?-p:p)},exp:function(){var c=Math.exp(this.re);return this.im,new s(c*Math.cos(this.im),c*Math.sin(this.im))},expm1:function(){var c=this.re,m=this.im;return new s(Math.expm1(c)*Math.cos(m)+i(m),Math.exp(c)*Math.sin(m))},log:function(){var c=this.re,m=this.im;return new s(l(c,m),Math.atan2(m,c))},abs:function(){return o(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var c=this.re,m=this.im;return new s(Math.sin(c)*a(m),Math.cos(c)*n(m))},cos:function(){var c=this.re,m=this.im;return new s(Math.cos(c)*a(m),-Math.sin(c)*n(m))},tan:function(){var c=2*this.re,m=2*this.im,v=Math.cos(c)+a(m);return new s(Math.sin(c)/v,n(m)/v)},cot:function(){var c=2*this.re,m=2*this.im,v=Math.cos(c)-a(m);return new s(-Math.sin(c)/v,n(m)/v)},sec:function(){var c=this.re,m=this.im,v=.5*a(2*m)+.5*Math.cos(2*c);return new s(Math.cos(c)*a(m)/v,Math.sin(c)*n(m)/v)},csc:function(){var c=this.re,m=this.im,v=.5*a(2*m)-.5*Math.cos(2*c);return new s(Math.sin(c)*a(m)/v,-Math.cos(c)*n(m)/v)},asin:function(){var c=this.re,m=this.im,v=new s(m*m-c*c+1,-2*c*m).sqrt(),h=new s(v.re-m,v.im+c).log();return new s(h.im,-h.re)},acos:function(){var c=this.re,m=this.im,v=new s(m*m-c*c+1,-2*c*m).sqrt(),h=new s(v.re-m,v.im+c).log();return new s(Math.PI/2-h.im,h.re)},atan:function(){var c=this.re,m=this.im;if(c===0){if(m===1)return new s(0,1/0);if(m===-1)return new s(0,-1/0)}var v=c*c+(1-m)*(1-m),h=new s((1-m*m-c*c)/v,-2*c/v).log();return new s(-.5*h.im,.5*h.re)},acot:function(){var c=this.re,m=this.im;if(m===0)return new s(Math.atan2(1,c),0);var v=c*c+m*m;return v!==0?new s(c/v,-m/v).atan():new s(c!==0?c/0:0,m!==0?-m/0:0).atan()},asec:function(){var c=this.re,m=this.im;if(c===0&&m===0)return new s(0,1/0);var v=c*c+m*m;return v!==0?new s(c/v,-m/v).acos():new s(c!==0?c/0:0,m!==0?-m/0:0).acos()},acsc:function(){var c=this.re,m=this.im;if(c===0&&m===0)return new s(Math.PI/2,1/0);var v=c*c+m*m;return v!==0?new s(c/v,-m/v).asin():new s(c!==0?c/0:0,m!==0?-m/0:0).asin()},sinh:function(){var c=this.re,m=this.im;return new s(n(c)*Math.cos(m),a(c)*Math.sin(m))},cosh:function(){var c=this.re,m=this.im;return new s(a(c)*Math.cos(m),n(c)*Math.sin(m))},tanh:function(){var c=2*this.re,m=2*this.im,v=a(c)+Math.cos(m);return new s(n(c)/v,Math.sin(m)/v)},coth:function(){var c=2*this.re,m=2*this.im,v=a(c)-Math.cos(m);return new s(n(c)/v,-Math.sin(m)/v)},csch:function(){var c=this.re,m=this.im,v=Math.cos(2*m)-a(2*c);return new s(-2*n(c)*Math.cos(m)/v,2*a(c)*Math.sin(m)/v)},sech:function(){var c=this.re,m=this.im,v=Math.cos(2*m)+a(2*c);return new s(2*a(c)*Math.cos(m)/v,-2*n(c)*Math.sin(m)/v)},asinh:function(){var c=this.im;this.im=-this.re,this.re=c;var m=this.asin();return this.re=-this.im,this.im=c,c=m.re,m.re=-m.im,m.im=c,m},acosh:function(){var c=this.acos();if(c.im<=0){var m=c.re;c.re=-c.im,c.im=m}else{var m=c.im;c.im=-c.re,c.re=m}return c},atanh:function(){var c=this.re,m=this.im,v=c>1&&m===0,h=1-c,p=1+c,g=h*h+m*m,y=g!==0?new s((p*h-m*m)/g,(m*h+p*m)/g):new s(c!==-1?c/0:0,m!==0?m/0:0),N=y.re;return y.re=l(y.re,y.im)/2,y.im=Math.atan2(y.im,N)/2,v&&(y.im=-y.im),y},acoth:function(){var c=this.re,m=this.im;if(c===0&&m===0)return new s(0,Math.PI/2);var v=c*c+m*m;return v!==0?new s(c/v,-m/v).atanh():new s(c!==0?c/0:0,m!==0?-m/0:0).atanh()},acsch:function(){var c=this.re,m=this.im;if(m===0)return new s(c!==0?Math.log(c+Math.sqrt(c*c+1)):1/0,0);var v=c*c+m*m;return v!==0?new s(c/v,-m/v).asinh():new s(c!==0?c/0:0,m!==0?-m/0:0).asinh()},asech:function(){var c=this.re,m=this.im;if(this.isZero())return s.INFINITY;var v=c*c+m*m;return v!==0?new s(c/v,-m/v).acosh():new s(c!==0?c/0:0,m!==0?-m/0:0).acosh()},inverse:function(){if(this.isZero())return s.INFINITY;if(this.isInfinite())return s.ZERO;var c=this.re,m=this.im,v=c*c+m*m;return new s(c/v,-m/v)},conjugate:function(){return new s(this.re,-this.im)},neg:function(){return new s(-this.re,-this.im)},ceil:function(c){return c=Math.pow(10,c||0),new s(Math.ceil(this.re*c)/c,Math.ceil(this.im*c)/c)},floor:function(c){return c=Math.pow(10,c||0),new s(Math.floor(this.re*c)/c,Math.floor(this.im*c)/c)},round:function(c){return c=Math.pow(10,c||0),new s(Math.round(this.re*c)/c,Math.round(this.im*c)/c)},equals:function(c,m){var v=new s(c,m);return Math.abs(v.re-this.re)<=s.EPSILON&&Math.abs(v.im-this.im)<=s.EPSILON},clone:function(){return new s(this.re,this.im)},toString:function(){var c=this.re,m=this.im,v="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(c)<s.EPSILON&&(c=0),Math.abs(m)<s.EPSILON&&(m=0),m===0?v+c:(c!==0?(v+=c,v+=" ",m<0?(m=-m,v+="-"):v+="+",v+=" "):m<0&&(m=-m,v+="-"),m!==1&&(v+=m),v+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return this.im===0?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return this.im===0&&this.re===0},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!(this.isNaN()||this.isFinite())}},s.ZERO=new s(0,0),s.ONE=new s(1,0),s.I=new s(0,1),s.PI=new s(Math.PI,0),s.E=new s(Math.E,0),s.INFINITY=new s(1/0,1/0),s.NAN=new s(NaN,NaN),s.EPSILON=1e-15,Object.defineProperty(s,"__esModule",{value:!0}),s.default=s,s.Complex=s,r.exports=s})()})(Zl);const Ur=Hl(Zl.exports);var O1="Complex",I1=[],R1=q(O1,I1,()=>(Object.defineProperty(Ur,"name",{value:"Complex"}),Ur.prototype.constructor=Ur,Ur.prototype.type="Complex",Ur.prototype.isComplex=!0,Ur.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Ur.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Ur.prototype.format=function(r){var e="",t=this.im,a=this.re,n=Cn(this.re,r),i=Cn(this.im,r),o=tr(r)?r:r?r.precision:null;if(o!==null){var f=Math.pow(10,-o);Math.abs(a/t)<f&&(a=0),Math.abs(t/a)<f&&(t=0)}return t===0?e=n:a===0?t===1?e="i":t===-1?e="-i":e=i+"i":t<0?t===-1?e=n+" - i":e=n+" - "+i.substring(1)+"i":t===1?e=n+" + i":e=n+" + "+i+"i",e},Ur.fromPolar=function(r){switch(arguments.length){case 1:{var e=arguments[0];if(typeof e=="object")return Ur(e);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var t=arguments[0],a=arguments[1];if(tr(t)){if(Vt(a)&&a.hasBase("ANGLE")&&(a=a.toNumber("rad")),tr(a))return new Ur({r:t,phi:a});throw new TypeError("Phi is not a number nor an angle unit.")}else throw new TypeError("Radius r is not a number.")}default:throw new SyntaxError("Wrong number of arguments in function fromPolar")}},Ur.prototype.valueOf=Ur.prototype.toString,Ur.fromJSON=function(r){return new Ur(r)},Ur.compare=function(r,e){return r.re>e.re?1:r.re<e.re?-1:r.im>e.im?1:r.im<e.im?-1:0},Ur),{isClass:!0}),Jl={exports:{}};/**
22
22
  * @license Fraction.js v4.2.0 05/03/2022
23
23
  * https://www.xarg.org/2014/03/rational-numbers-in-javascript/
24
24
  *
25
25
  * Copyright (c) 2021, Robert Eisele (robert@xarg.org)
26
26
  * Dual licensed under the MIT or GPL Version 2 licenses.
27
- **/(function(r,e){(function(t){var a=2e3,n={s:1,n:0,d:1};function i(p,h){if(isNaN(p=parseInt(p,10)))throw v.InvalidParameter;return p*h}function s(p,h){if(h===0)throw v.DivisionByZero;var y=Object.create(v.prototype);y.s=p<0?-1:1,p=p<0?-p:p;var b=m(p,h);return y.n=p/b,y.d=h/b,y}function f(p){for(var h={},y=p,b=2,A=4;A<=y;){for(;y%b===0;)y/=b,h[b]=(h[b]||0)+1;A+=1+2*b++}return y!==p?y>1&&(h[y]=(h[y]||0)+1):h[p]=(h[p]||0)+1,h}var l=function(p,h){var y=0,b=1,A=1,d=0,w=0,x=0,g=1,E=1,N=0,S=1,D=1,T=1,B=1e7,_;if(p!=null)if(h!==void 0){if(y=p,b=h,A=y*b,y%1!==0||b%1!==0)throw v.NonIntegerParameter}else switch(typeof p){case"object":{if("d"in p&&"n"in p)y=p.n,b=p.d,"s"in p&&(y*=p.s);else if(0 in p)y=p[0],1 in p&&(b=p[1]);else throw v.InvalidParameter;A=y*b;break}case"number":{if(p<0&&(A=p,p=-p),p%1===0)y=p;else if(p>0){for(p>=1&&(E=Math.pow(10,Math.floor(1+Math.log(p)/Math.LN10)),p/=E);S<=B&&T<=B;)if(_=(N+D)/(S+T),p===_){S+T<=B?(y=N+D,b=S+T):T>S?(y=D,b=T):(y=N,b=S);break}else p>_?(N+=D,S+=T):(D+=N,T+=S),S>B?(y=D,b=T):(y=N,b=S);y*=E}else(isNaN(p)||isNaN(h))&&(b=y=NaN);break}case"string":{if(S=p.match(/\d+|./g),S===null)throw v.InvalidParameter;if(S[N]==="-"?(A=-1,N++):S[N]==="+"&&N++,S.length===N+1?w=i(S[N++],A):S[N+1]==="."||S[N]==="."?(S[N]!=="."&&(d=i(S[N++],A)),N++,(N+1===S.length||S[N+1]==="("&&S[N+3]===")"||S[N+1]==="'"&&S[N+3]==="'")&&(w=i(S[N],A),g=Math.pow(10,S[N].length),N++),(S[N]==="("&&S[N+2]===")"||S[N]==="'"&&S[N+2]==="'")&&(x=i(S[N+1],A),E=Math.pow(10,S[N+1].length)-1,N+=3)):S[N+1]==="/"||S[N+1]===":"?(w=i(S[N],A),g=i(S[N+2],1),N+=3):S[N+3]==="/"&&S[N+1]===" "&&(d=i(S[N],A),w=i(S[N+2],A),g=i(S[N+4],1),N+=5),S.length<=N){b=g*E,A=y=x+b*d+E*w;break}}default:throw v.InvalidParameter}if(b===0)throw v.DivisionByZero;n.s=A<0?-1:1,n.n=Math.abs(y),n.d=Math.abs(b)};function u(p,h,y){for(var b=1;h>0;p=p*p%y,h>>=1)h&1&&(b=b*p%y);return b}function o(p,h){for(;h%2===0;h/=2);for(;h%5===0;h/=5);if(h===1)return 0;for(var y=10%h,b=1;y!==1;b++)if(y=y*10%h,b>a)return 0;return b}function c(p,h,y){for(var b=1,A=u(10,y,h),d=0;d<300;d++){if(b===A)return d;b=b*10%h,A=A*10%h}return 0}function m(p,h){if(!p)return h;if(!h)return p;for(;;){if(p%=h,!p)return h;if(h%=p,!h)return p}}function v(p,h){if(l(p,h),this instanceof v)p=m(n.d,n.n),this.s=n.s,this.n=n.n/p,this.d=n.d/p;else return s(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 s(this.n,this.d)},neg:function(){return s(-this.s*this.n,this.d)},add:function(p,h){return l(p,h),s(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(p,h){return l(p,h),s(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(p,h){return l(p,h),s(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(p,h){return l(p,h),s(this.s*n.s*this.n*n.d,this.d*n.n)},clone:function(){return s(this.s*this.n,this.d)},mod:function(p,h){if(isNaN(this.n)||isNaN(this.d))return new v(NaN);if(p===void 0)return s(this.s*this.n%this.d,1);if(l(p,h),n.n===0&&this.d===0)throw v.DivisionByZero;return s(this.s*(n.d*this.n)%(n.n*this.d),n.d*this.d)},gcd:function(p,h){return l(p,h),s(m(n.n,this.n)*m(n.d,this.d),n.d*this.d)},lcm:function(p,h){return l(p,h),n.n===0&&this.n===0?s(0,1):s(n.n*this.n,m(n.n,this.n)*m(n.d,this.d))},ceil:function(p){return p=Math.pow(10,p||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):s(Math.ceil(p*this.s*this.n/this.d),p)},floor:function(p){return p=Math.pow(10,p||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):s(Math.floor(p*this.s*this.n/this.d),p)},round:function(p){return p=Math.pow(10,p||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):s(Math.round(p*this.s*this.n/this.d),p)},inverse:function(){return s(this.s*this.d,this.n)},pow:function(p,h){if(l(p,h),n.d===1)return n.s<0?s(Math.pow(this.s*this.d,n.n),Math.pow(this.n,n.n)):s(Math.pow(this.s*this.n,n.n),Math.pow(this.d,n.n));if(this.s<0)return null;var y=f(this.n),b=f(this.d),A=1,d=1;for(var w in y)if(w!=="1"){if(w==="0"){A=0;break}if(y[w]*=n.n,y[w]%n.d===0)y[w]/=n.d;else return null;A*=Math.pow(w,y[w])}for(var w in b)if(w!=="1"){if(b[w]*=n.n,b[w]%n.d===0)b[w]/=n.d;else return null;d*=Math.pow(w,b[w])}return n.s<0?s(d,A):s(A,d)},equals:function(p,h){return l(p,h),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(p,h){l(p,h);var y=this.s*this.n*n.d-n.s*n.n*this.d;return(0<y)-(y<0)},simplify:function(p){if(isNaN(this.n)||isNaN(this.d))return this;p=p||.001;for(var h=this.abs(),y=h.toContinued(),b=1;b<y.length;b++){for(var A=s(y[b-1],1),d=b-2;d>=0;d--)A=A.inverse().add(y[d]);if(A.sub(h).abs().valueOf()<p)return A.mul(this.s)}return this},divisible:function(p,h){return l(p,h),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(p){var h,y="",b=this.n,A=this.d;return this.s<0&&(y+="-"),A===1?y+=b:(p&&(h=Math.floor(b/A))>0&&(y+=h,y+=" ",b%=A),y+=b,y+="/",y+=A),y},toLatex:function(p){var h,y="",b=this.n,A=this.d;return this.s<0&&(y+="-"),A===1?y+=b:(p&&(h=Math.floor(b/A))>0&&(y+=h,b%=A),y+="\\frac{",y+=b,y+="}{",y+=A,y+="}"),y},toContinued:function(){var p,h=this.n,y=this.d,b=[];if(isNaN(h)||isNaN(y))return b;do b.push(Math.floor(h/y)),p=h%y,h=y,y=p;while(h!==1);return b},toString:function(p){var h=this.n,y=this.d;if(isNaN(h)||isNaN(y))return"NaN";p=p||15;var b=o(h,y),A=c(h,y,b),d=this.s<0?"-":"";if(d+=h/y|0,h%=y,h*=10,h&&(d+="."),b){for(var w=A;w--;)d+=h/y|0,h%=y,h*=10;d+="(";for(var w=b;w--;)d+=h/y|0,h%=y,h*=10;d+=")"}else for(var w=p;h&&w--;)d+=h/y|0,h%=y,h*=10;return d}},Object.defineProperty(v,"__esModule",{value:!0}),v.default=v,v.Fraction=v,r.exports=v})()})(Il);const Vt=Ol(Il.exports);var c1="Fraction",f1=[],m1=R(c1,f1,()=>(Object.defineProperty(Vt,"name",{value:"Fraction"}),Vt.prototype.constructor=Vt,Vt.prototype.type="Fraction",Vt.prototype.isFraction=!0,Vt.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},Vt.fromJSON=function(r){return new Vt(r)},Vt),{isClass:!0}),v1="Range",p1=[],h1=R(v1,p1,()=>{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,s=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(s){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=s?parseFloat(a):1}return r.prototype.type="Range",r.prototype.isRange=!0,r.parse=function(e){if(typeof e!="string")return null;var t=e.split(":"),a=t.map(function(i){return parseFloat(i)}),n=a.some(function(i){return isNaN(i)});if(n)return null;switch(a.length){case 2:return new r(a[0],a[1]);case 3:return new r(a[0],a[2],a[1]);default:return null}},r.prototype.clone=function(){return new r(this.start,this.end,this.step)},r.prototype.size=function(){var e=0,t=this.start,a=this.step,n=this.end,i=n-t;return tn(a)===tn(i)?e=Math.ceil(i/a):i===0&&(e=0),isNaN(e)&&(e=0),[e]},r.prototype.min=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start:this.start+(e-1)*this.step},r.prototype.max=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start+(e-1)*this.step:this.start},r.prototype.forEach=function(e){var t=this.start,a=this.step,n=this.end,i=0;if(a>0)for(;t<n;)e(t,[i],this),t+=a,i++;else if(a<0)for(;t>n;)e(t,[i],this),t+=a,i++},r.prototype.map=function(e){var t=[];return this.forEach(function(a,n,i){t[n[0]]=e(a,n,i)}),t},r.prototype.toArray=function(){var e=[];return this.forEach(function(t,a){e[a[0]]=t}),e},r.prototype.valueOf=function(){return this.toArray()},r.prototype.format=function(e){var t=En(this.start,e);return this.step!==1&&(t+=":"+En(this.step,e)),t+=":"+En(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}),d1="Matrix",g1=[],y1=R(d1,g1,()=>{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 b1(r){var e=0,t=1,a=Object.create(null),n=Object.create(null),i=0,s=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],o=++i;if(a[o]=l,n[l]=o,!u)return++e,e<=r?void 0:(l=a[t],s(l),l);if(delete a[u],t===u)for(;!hasOwnProperty.call(a,++t););},delete:s,clear:function(){e=i=0,t=1,a=Object.create(null),n=Object.create(null)}}}function Pa(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:b1(t||Number.POSITIVE_INFINITY)});for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var s=e(n);if(a.cache.values.has(s))return a.cache.lru.hit(s),a.cache.values.get(s);var f=r.apply(r,n);return a.cache.values.set(s,f),a.cache.values.delete(a.cache.lru.hit(s)),f}}function ln(r){return Object.keys(r.signatures||{}).reduce(function(e,t){var a=(t.match(/,/g)||[]).length+1;return Math.max(e,a)},-1)}var x1="DenseMatrix",w1=["Matrix"],N1=R(x1,w1,r=>{var{Matrix:e}=r;function t(o,c){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(c&&!Wr(c))throw new Error("Invalid datatype: "+c);if(He(o))o.type==="DenseMatrix"?(this._data=ke(o._data),this._size=ke(o._size),this._datatype=c||o._datatype):(this._data=o.toArray(),this._size=o.size(),this._datatype=c||o._datatype);else if(o&&ur(o.data)&&ur(o.size))this._data=o.data,this._size=o.size,ul(this._data,this._size),this._datatype=c||o.datatype;else if(ur(o))this._data=u(o),this._size=er(this._data),ul(this._data,this._size),this._datatype=c;else{if(o)throw new TypeError("Unsupported type of data ("+gr(o)+")");this._data=[],this._size=[0],this._datatype=c}}t.prototype=new e,t.prototype.createDenseMatrix=function(o,c){return new t(o,c)},Object.defineProperty(t,"name",{value:"DenseMatrix"}),t.prototype.constructor=t,t.prototype.type="DenseMatrix",t.prototype.isDenseMatrix=!0,t.prototype.getDataType=function(){return qa(this._data,gr)},t.prototype.storage=function(){return"dense"},t.prototype.datatype=function(){return this._datatype},t.prototype.create=function(o,c){return new t(o,c)},t.prototype.subset=function(o,c,m){switch(arguments.length){case 1:return a(this,o);case 2:case 3:return i(this,o,c,m);default:throw new SyntaxError("Wrong number of arguments")}},t.prototype.get=function(o){if(!ur(o))throw new TypeError("Array expected");if(o.length!==this._size.length)throw new Ke(o.length,this._size.length);for(var c=0;c<o.length;c++)mr(o[c],this._size[c]);for(var m=this._data,v=0,p=o.length;v<p;v++){var h=o[v];mr(h,m.length),m=m[h]}return m},t.prototype.set=function(o,c,m){if(!ur(o))throw new TypeError("Array expected");if(o.length<this._size.length)throw new Ke(o.length,this._size.length,"<");var v,p,h,y=o.map(function(A){return A+1});l(this,y,m);var b=this._data;for(v=0,p=o.length-1;v<p;v++)h=o[v],mr(h,b.length),b=b[h];return h=o[o.length-1],mr(h,b.length),b[h]=c,this};function a(o,c){if(!ai(c))throw new TypeError("Invalid index");var m=c.isScalar();if(m)return o.get(c.min());var v=c.size();if(v.length!==o._size.length)throw new Ke(v.length,o._size.length);for(var p=c.min(),h=c.max(),y=0,b=o._size.length;y<b;y++)mr(p[y],o._size[y]),mr(h[y],o._size[y]);return new t(n(o._data,c,v.length,0),o._datatype)}function n(o,c,m,v){var p=v===m-1,h=c.dimension(v);return p?h.map(function(y){return mr(y,o.length),o[y]}).valueOf():h.map(function(y){mr(y,o.length);var b=o[y];return n(b,c,m,v+1)}).valueOf()}function i(o,c,m,v){if(!c||c.isIndex!==!0)throw new TypeError("Invalid index");var p=c.size(),h=c.isScalar(),y;if(He(m)?(y=m.size(),m=m.valueOf()):y=er(m),h){if(y.length!==0)throw new TypeError("Scalar expected");o.set(c.min(),m,v)}else{if(p.length<o._size.length)throw new Ke(p.length,o._size.length,"<");if(y.length<p.length){for(var b=0,A=0;p[b]===1&&y[b]===1;)b++;for(;p[b]===1;)A++,b++;m=ml(m,p.length,A,y)}if(!Ra(p,y))throw new Ke(p,y,">");var d=c.max().map(function(g){return g+1});l(o,d,v);var w=p.length,x=0;s(o._data,c,m,w,x)}return o}function s(o,c,m,v,p){var h=p===v-1,y=c.dimension(p);h?y.forEach(function(b,A){mr(b),o[b]=m[A[0]]}):y.forEach(function(b,A){mr(b),s(o[b],c,m[A[0]],v,p+1)})}t.prototype.resize=function(o,c,m){if(!Lt(o))throw new TypeError("Array or Matrix expected");var v=o.valueOf().map(h=>Array.isArray(h)&&h.length===1?h[0]:h),p=m?this.clone():this;return f(p,v,c)};function f(o,c,m){if(c.length===0){for(var v=o._data;ur(v);)v=v[0];return v}return o._size=c.slice(0),o._data=Gn(o._data,o._size,m),o}t.prototype.reshape=function(o,c){var m=c?this.clone():this;m._data=ll(m._data,o);var v=m._size.reduce((p,h)=>p*h);return m._size=Vo(o,v),m};function l(o,c,m){for(var v=o._size.slice(0),p=!1;v.length<c.length;)v.push(0),p=!0;for(var h=0,y=c.length;h<y;h++)c[h]>v[h]&&(v[h]=c[h],p=!0);p&&f(o,v,m)}t.prototype.clone=function(){var o=new t({data:ke(this._data),size:ke(this._size),datatype:this._datatype});return o},t.prototype.size=function(){return this._size.slice(0)},t.prototype.map=function(o){var c=this,m=ln(o),v=function y(b,A){return ur(b)?b.map(function(d,w){return y(d,A.concat(w))}):m===1?o(b):m===2?o(b,A):o(b,A,c)},p=v(this._data,[]),h=this._datatype!==void 0?qa(p,gr):void 0;return new t(p,h)},t.prototype.forEach=function(o){var c=this,m=function v(p,h){ur(p)?p.forEach(function(y,b){v(y,h.concat(b))}):o(p,h,c)};m(this._data,[])},t.prototype[Symbol.iterator]=function*(){var o=function*c(m,v){if(ur(m))for(var p=0;p<m.length;p++)yield*c(m[p],v.concat(p));else yield{value:m,index:v}};yield*o(this._data,[])},t.prototype.rows=function(){var o=[],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)o.push(new t([v],this._datatype));return o},t.prototype.columns=function(){var o=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,p=function(b){var A=v.map(d=>[d[b]]);c.push(new t(A,o._datatype))},h=0;h<m[1];h++)p(h);return c},t.prototype.toArray=function(){return ke(this._data)},t.prototype.valueOf=function(){return this._data},t.prototype.format=function(o){return Ye(this._data,o)},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(o){if(o){if(rr(o)&&(o=o.toNumber()),!tr(o)||!qe(o))throw new TypeError("The parameter k must be an integer number")}else o=0;for(var c=o>0?o:0,m=o<0?-o:0,v=this._size[0],p=this._size[1],h=Math.min(v-m,p-c),y=[],b=0;b<h;b++)y[b]=this._data[b+m][b+c];return new t({data:y,size:[h],datatype:this._datatype})},t.diagonal=function(o,c,m,v){if(!ur(o))throw new TypeError("Array expected, size parameter");if(o.length!==2)throw new Error("Only two dimensions matrix are supported");if(o=o.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 p=m>0?m:0,h=m<0?-m:0,y=o[0],b=o[1],A=Math.min(y-h,b-p),d;if(ur(c)){if(c.length!==A)throw new Error("Invalid value array length");d=function(N){return c[N]}}else if(He(c)){var w=c.size();if(w.length!==1||w[0]!==A)throw new Error("Invalid matrix length");d=function(N){return c.get([N])}}else d=function(){return c};v||(v=rr(d(0))?d(0).mul(0):0);var x=[];if(o.length>0){x=Gn(x,o,v);for(var g=0;g<A;g++)x[g+h][g+p]=d(g)}return new t({data:x,size:[y,b]})},t.fromJSON=function(o){return new t(o)},t.prototype.swapRows=function(o,c){if(!tr(o)||!qe(o)||!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 mr(o,this._size[0]),mr(c,this._size[0]),t._swapRows(o,c,this._data),this},t._swapRows=function(o,c,m){var v=m[o];m[o]=m[c],m[c]=v};function u(o){for(var c=0,m=o.length;c<m;c++){var v=o[c];ur(v)?o[c]=u(v):v&&v.isMatrix===!0&&(o[c]=u(v.valueOf()))}return o}return t},{isClass:!0}),Rl="clone",D1=["typed"],A1=R(Rl,D1,r=>{var{typed:e}=r;return e(Rl,{any:ke})});function ql(r){var e=r.length,t=r[0].length,a,n,i=[];for(n=0;n<t;n++){var s=[];for(a=0;a<e;a++)s.push(r[a][n]);i.push(s)}return i}function Qn(r){for(var e=0;e<r.length;e++)if(Lt(r[e]))return!0;return!1}function Gt(r,e){He(r)&&(r=r.valueOf());for(var t=0,a=r.length;t<a;t++){var n=r[t];Array.isArray(n)?Gt(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 wi(r,e,t){var a=Array.isArray(r)?er(r):r.size();if(e<0||e>=a.length)throw new pt(e,a.length);return He(r)?r.create(Ni(r.valueOf(),e,t)):Ni(r,e,t)}function Ni(r,e,t){var a,n,i,s;if(e<=0)if(Array.isArray(r[0])){for(s=ql(r),n=[],a=0;a<s.length;a++)n[a]=Ni(s[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]=Ni(r[a],e-1,t);return n}}function zl(r,e,t,a,n,i,s,f,l,u,o){var c=r._values,m=r._index,v=r._ptr,p,h,y,b;if(a)for(h=v[e],y=v[e+1],p=h;p<y;p++)b=m[p],t[b]!==i?(t[b]=i,s.push(b),u?(a[b]=l?f(c[p],o):f(o,c[p]),n[b]=i):a[b]=c[p]):(a[b]=l?f(c[p],a[b]):f(a[b],c[p]),n[b]=i);else for(h=v[e],y=v[e+1],p=h;p<y;p++)b=m[p],t[b]!==i?(t[b]=i,s.push(b)):n[b]=i}var Pl="isInteger",E1=["typed"],S1=R(Pl,E1,r=>{var{typed:e}=r;return e(Pl,{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))})}),gt="number",Cn="number, number";function Ll(r){return Math.abs(r)}Ll.signature=gt;function Ul(r,e){return r+e}Ul.signature=Cn;function kl(r,e){return r*e}kl.signature=Cn;function Vl(r){return-r}Vl.signature=gt;function Gl(r){return r}Gl.signature=gt;function La(r){return T0(r)}La.signature=gt;function Hl(r){return r*r*r}Hl.signature=gt;function Zl(r){return Math.exp(r)}Zl.signature=gt;function Jl(r){return B0(r)}Jl.signature=gt;function Wl(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}Wl.signature=Cn;function Xl(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)}Xl.signature=Cn;function C1(r,e){return e?Math.log(r)/Math.log(e):Math.log(r)}function Yl(r){return M0(r)}Yl.signature=gt;function Ql(r){return C0(r)}Ql.signature=gt;function Kl(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")}Kl.signature=Cn;function jl(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 ts(r){return tn(r)}ts.signature=gt;function ec(r){return r*r}ec.signature=gt;function rc(r,e){var t,a,n,i=0,s=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=s-a*i,s=t,t=f,f=l-a*f,l=t,r=e,e=n;var u;return r<0?u=[-r,-s,-l]:u=[r,r?s:0,l],u}rc.signature=Cn;function tc(r,e){return r*r<1&&e===1/0||r*r>1&&e===-1/0?0:Math.pow(r,e)}tc.signature=Cn;function nc(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(nl(r,e))}var M1="number",Kn="number, number";function ac(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitAnd");return r&e}ac.signature=Kn;function ic(r){if(!qe(r))throw new Error("Integer expected in function bitNot");return~r}ic.signature=M1;function oc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitOr");return r|e}oc.signature=Kn;function sc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitXor");return r^e}sc.signature=Kn;function uc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function leftShift");return r<<e}uc.signature=Kn;function lc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function rightArithShift");return r>>e}lc.signature=Kn;function cc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function rightLogShift");return r>>>e}cc.signature=Kn;function Ht(r,e){if(e<r)return 1;if(e===r)return e;var t=e+r>>1;return Ht(r,t)*Ht(t+1,e)}function fc(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,s=e<t?e:t,f=n;f<=r;++f)for(a*=f;i<=s&&a%i===0;)a/=i,++i;return i<=s&&(a/=Ht(i,s)),a}fc.signature="number, number";var F1=Math.PI,T1=2*Math.PI,B1=Math.E,$1=1.618033988749895,O1="number",ns="number, number";function mc(r){return!r}mc.signature=O1;function vc(r,e){return!!(r||e)}vc.signature=ns;function pc(r,e){return!!r!=!!e}pc.signature=ns;function hc(r,e){return!!(r&&e)}hc.signature=ns;function Di(r){var e;if(qe(r))return r<=0?isFinite(r)?1/0:NaN:r>171?1/0:Ht(1,r-1);if(r<.5)return Math.PI/(Math.sin(Math.PI*r)*Di(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=jn[0];for(var s=1;s<jn.length;++s)e+=jn[s]/(r+s);var f=r+dc+.5;return Math.sqrt(2*Math.PI)*Math.pow(f,r+.5)*Math.exp(-f)*e}Di.signature="number";var dc=4.7421875,jn=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],gc=.9189385332046728,_1=5,I1=7,yc=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function Ai(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))-Ai(1-r);r=r-1;for(var e=r+_1+.5,t=yc[0],a=I1-1;a>=1;a--)t+=yc[a]/(r+a);return gc+(r+.5)*Math.log(e)-e+Math.log(t)}Ai.signature="number";var Gr="number";function bc(r){return R0(r)}bc.signature=Gr;function xc(r){return Math.atan(1/r)}xc.signature=Gr;function wc(r){return isFinite(r)?(Math.log((r+1)/r)+Math.log(r/(r-1)))/2:0}wc.signature=Gr;function Nc(r){return Math.asin(1/r)}Nc.signature=Gr;function Dc(r){var e=1/r;return Math.log(e+Math.sqrt(e*e+1))}Dc.signature=Gr;function Ac(r){return Math.acos(1/r)}Ac.signature=Gr;function Ec(r){var e=1/r,t=Math.sqrt(e*e-1);return Math.log(t+e)}Ec.signature=Gr;function Sc(r){return q0(r)}Sc.signature=Gr;function Cc(r){return z0(r)}Cc.signature=Gr;function Mc(r){return 1/Math.tan(r)}Mc.signature=Gr;function Fc(r){var e=Math.exp(2*r);return(e+1)/(e-1)}Fc.signature=Gr;function Tc(r){return 1/Math.sin(r)}Tc.signature=Gr;function Bc(r){return r===0?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(r)-Math.exp(-r)))*tn(r)}Bc.signature=Gr;function $c(r){return 1/Math.cos(r)}$c.signature=Gr;function Oc(r){return 2/(Math.exp(r)+Math.exp(-r))}Oc.signature=Gr;function _c(r){return L0(r)}_c.signature=Gr;var Ei="number";function Ic(r){return r<0}Ic.signature=Ei;function Rc(r){return r>0}Rc.signature=Ei;function qc(r){return r===0}qc.signature=Ei;function zc(r){return Number.isNaN(r)}zc.signature=Ei;var Pc="isNegative",R1=["typed"],q1=R(Pc,R1,r=>{var{typed:e}=r;return e(Pc,{number:Ic,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))})}),Lc="isNumeric",z1=["typed"],P1=R(Lc,z1,r=>{var{typed:e}=r;return e(Lc,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Uc="hasNumericValue",L1=["typed","isNumeric"],U1=R(Uc,L1,r=>{var{typed:e,isNumeric:t}=r;return e(Uc,{boolean:()=>!0,string:function(n){return n.trim().length>0&&!isNaN(Number(n))},any:function(n){return t(n)}})}),kc="isPositive",k1=["typed"],V1=R(kc,k1,r=>{var{typed:e}=r;return e(kc,{number:Rc,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))})}),Vc="isZero",G1=["typed"],H1=R(Vc,G1,r=>{var{typed:e}=r;return e(Vc,{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))})}),Gc="isNaN",Z1=["typed"],J1=R(Gc,Z1,r=>{var{typed:e}=r;return e(Gc,{number:zc,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)}})}),Hc="typeOf",W1=["typed"],X1=R(Hc,W1,r=>{var{typed:e}=r;return e(Hc,{any:gr})});function Ct(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 Y1(r,e,t){return et(r.re,e.re,t)&&et(r.im,e.im,t)}var ea=R("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)})}}),Si="equalScalar",Q1=["typed","config"],K1=R(Si,Q1,r=>{var{typed:e,config:t}=r,a=ea({typed:e});return e(Si,{"boolean, boolean":function(i,s){return i===s},"number, number":function(i,s){return et(i,s,t.epsilon)},"BigNumber, BigNumber":function(i,s){return i.eq(s)||Ct(i,s,t.epsilon)},"Fraction, Fraction":function(i,s){return i.equals(s)},"Complex, Complex":function(i,s){return Y1(i,s,t.epsilon)}},a)});R(Si,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Si,{"number, number":function(n,i){return et(n,i,t.epsilon)}})});var j1="SparseMatrix",ey=["typed","equalScalar","Matrix"],ry=R(j1,ey,r=>{var{typed:e,equalScalar:t,Matrix:a}=r;function n(h,y){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(y&&!Wr(y))throw new Error("Invalid datatype: "+y);if(He(h))i(this,h,y);else if(h&&ur(h.index)&&ur(h.ptr)&&ur(h.size))this._values=h.values,this._index=h.index,this._ptr=h.ptr,this._size=h.size,this._datatype=y||h.datatype;else if(ur(h))s(this,h,y);else{if(h)throw new TypeError("Unsupported type of data ("+gr(h)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=y}}function i(h,y,b){y.type==="SparseMatrix"?(h._values=y._values?ke(y._values):void 0,h._index=ke(y._index),h._ptr=ke(y._ptr),h._size=ke(y._size),h._datatype=b||y._datatype):s(h,y.valueOf(),b||y._datatype)}function s(h,y,b){h._values=[],h._index=[],h._ptr=[],h._datatype=b;var A=y.length,d=0,w=t,x=0;if(Wr(b)&&(w=e.find(t,[b,b])||t,x=e.convert(0,b)),A>0){var g=0;do{h._ptr.push(h._index.length);for(var E=0;E<A;E++){var N=y[E];if(ur(N)){if(g===0&&d<N.length&&(d=N.length),g<N.length){var S=N[g];w(S,x)||(h._values.push(S),h._index.push(E))}}else g===0&&d<1&&(d=1),w(N,x)||(h._values.push(N),h._index.push(E))}g++}while(g<d)}h._ptr.push(h._index.length),h._size=[A,d]}n.prototype=new a,n.prototype.createSparseMatrix=function(h,y){return new n(h,y)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return qa(this._values,gr)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(h,y){return new n(h,y)},n.prototype.density=function(){var h=this._size[0],y=this._size[1];return h!==0&&y!==0?this._index.length/(h*y):0},n.prototype.subset=function(h,y,b){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return f(this,h);case 2:case 3:return l(this,h,y,b);default:throw new SyntaxError("Wrong number of arguments")}};function f(h,y){if(!ai(y))throw new TypeError("Invalid index");var b=y.isScalar();if(b)return h.get(y.min());var A=y.size();if(A.length!==h._size.length)throw new Ke(A.length,h._size.length);var d,w,x,g,E=y.min(),N=y.max();for(d=0,w=h._size.length;d<w;d++)mr(E[d],h._size[d]),mr(N[d],h._size[d]);var S=h._values,D=h._index,T=h._ptr,B=y.dimension(0),_=y.dimension(1),L=[],G=[];B.forEach(function($,U){G[$]=U[0],L[$]=!0});var C=S?[]:void 0,F=[],Z=[];return _.forEach(function($){for(Z.push(F.length),x=T[$],g=T[$+1];x<g;x++)d=D[x],L[d]===!0&&(F.push(G[d]),C&&C.push(S[x]))}),Z.push(F.length),new n({values:C,index:F,ptr:Z,size:A,datatype:h._datatype})}function l(h,y,b,A){if(!y||y.isIndex!==!0)throw new TypeError("Invalid index");var d=y.size(),w=y.isScalar(),x;if(He(b)?(x=b.size(),b=b.toArray()):x=er(b),w){if(x.length!==0)throw new TypeError("Scalar expected");h.set(y.min(),b,A)}else{if(d.length!==1&&d.length!==2)throw new Ke(d.length,h._size.length,"<");if(x.length<d.length){for(var g=0,E=0;d[g]===1&&x[g]===1;)g++;for(;d[g]===1;)E++,g++;b=ml(b,d.length,E,x)}if(!Ra(d,x))throw new Ke(d,x,">");if(d.length===1){var N=y.dimension(0);N.forEach(function(T,B){mr(T),h.set([T,0],b[B[0]],A)})}else{var S=y.dimension(0),D=y.dimension(1);S.forEach(function(T,B){mr(T),D.forEach(function(_,L){mr(_),h.set([T,_],b[B[0]][L[0]],A)})})}}return h}n.prototype.get=function(h){if(!ur(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new Ke(h.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var y=h[0],b=h[1];mr(y,this._size[0]),mr(b,this._size[1]);var A=u(y,this._ptr[b],this._ptr[b+1],this._index);return A<this._ptr[b+1]&&this._index[A]===y?this._values[A]:0},n.prototype.set=function(h,y,b){if(!ur(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new Ke(h.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var A=h[0],d=h[1],w=this._size[0],x=this._size[1],g=t,E=0;Wr(this._datatype)&&(g=e.find(t,[this._datatype,this._datatype])||t,E=e.convert(0,this._datatype)),(A>w-1||d>x-1)&&(m(this,Math.max(A+1,w),Math.max(d+1,x),b),w=this._size[0],x=this._size[1]),mr(A,w),mr(d,x);var N=u(A,this._ptr[d],this._ptr[d+1],this._index);return N<this._ptr[d+1]&&this._index[N]===A?g(y,E)?o(N,d,this._values,this._index,this._ptr):this._values[N]=y:c(N,A,d,y,this._values,this._index,this._ptr),this};function u(h,y,b,A){if(b-y===0)return b;for(var d=y;d<b;d++)if(A[d]===h)return d;return y}function o(h,y,b,A,d){b.splice(h,1),A.splice(h,1);for(var w=y+1;w<d.length;w++)d[w]--}function c(h,y,b,A,d,w,x){d.splice(h,0,A),w.splice(h,0,y);for(var g=b+1;g<x.length;g++)x[g]++}n.prototype.resize=function(h,y,b){if(!Lt(h))throw new TypeError("Array or Matrix expected");var A=h.valueOf().map(w=>Array.isArray(w)&&w.length===1?w[0]:w);if(A.length!==2)throw new Error("Only two dimensions matrix are supported");A.forEach(function(w){if(!tr(w)||!qe(w)||w<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Ye(A)+")")});var d=b?this.clone():this;return m(d,A[0],A[1],y)};function m(h,y,b,A){var d=A||0,w=t,x=0;Wr(h._datatype)&&(w=e.find(t,[h._datatype,h._datatype])||t,x=e.convert(0,h._datatype),d=e.convert(d,h._datatype));var g=!w(d,x),E=h._size[0],N=h._size[1],S,D,T;if(b>N){for(D=N;D<b;D++)if(h._ptr[D]=h._values.length,g)for(S=0;S<E;S++)h._values.push(d),h._index.push(S);h._ptr[b]=h._values.length}else b<N&&(h._ptr.splice(b+1,N-b),h._values.splice(h._ptr[b],h._values.length),h._index.splice(h._ptr[b],h._index.length));if(N=b,y>E){if(g){var B=0;for(D=0;D<N;D++){h._ptr[D]=h._ptr[D]+B,T=h._ptr[D+1]+B;var _=0;for(S=E;S<y;S++,_++)h._values.splice(T+_,0,d),h._index.splice(T+_,0,S),B++}h._ptr[N]=h._values.length}}else if(y<E){var L=0;for(D=0;D<N;D++){h._ptr[D]=h._ptr[D]-L;var G=h._ptr[D],C=h._ptr[D+1]-L;for(T=G;T<C;T++)S=h._index[T],S>y-1&&(h._values.splice(T,1),h._index.splice(T,1),L++)}h._ptr[D]=h._values.length}return h._size[0]=y,h._size[1]=b,h}n.prototype.reshape=function(h,y){if(!ur(h))throw new TypeError("Array expected");if(h.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");h.forEach(function($){if(!tr($)||!qe($)||$<=-2||$===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Ye(h)+")")});var b=this._size[0]*this._size[1];h=Vo(h,b);var A=h[0]*h[1];if(b!==A)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var d=y?this.clone():this;if(this._size[0]===h[0]&&this._size[1]===h[1])return d;for(var w=[],x=0;x<d._ptr.length;x++)for(var g=0;g<d._ptr[x+1]-d._ptr[x];g++)w.push(x);for(var E=d._values.slice(),N=d._index.slice(),S=0;S<d._index.length;S++){var D=N[S],T=w[S],B=D*d._size[1]+T;w[S]=B%h[1],N[S]=Math.floor(B/h[1])}d._values.length=0,d._index.length=0,d._ptr.length=h[1]+1,d._size=h.slice();for(var _=0;_<d._ptr.length;_++)d._ptr[_]=0;for(var L=0;L<E.length;L++){var G=N[L],C=w[L],F=E[L],Z=u(G,d._ptr[C],d._ptr[C+1],d._index);c(Z,G,C,F,d._values,d._index,d._ptr)}return d},n.prototype.clone=function(){var h=new n({values:this._values?ke(this._values):void 0,index:ke(this._index),ptr:ke(this._ptr),size:ke(this._size),datatype:this._datatype});return h},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(h,y){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var b=this,A=this._size[0],d=this._size[1],w=ln(h),x=function(E,N,S){return w===1?h(E):w===2?h(E,[N,S]):h(E,[N,S],b)};return v(this,0,A-1,0,d-1,x,y)};function v(h,y,b,A,d,w,x){var g=[],E=[],N=[],S=t,D=0;Wr(h._datatype)&&(S=e.find(t,[h._datatype,h._datatype])||t,D=e.convert(0,h._datatype));for(var T=function(P,K,ne){P=w(P,K,ne),S(P,D)||(g.push(P),E.push(K))},B=A;B<=d;B++){N.push(g.length);var _=h._ptr[B],L=h._ptr[B+1];if(x)for(var G=_;G<L;G++){var C=h._index[G];C>=y&&C<=b&&T(h._values[G],C-y,B-A)}else{for(var F={},Z=_;Z<L;Z++){var $=h._index[Z];F[$]=h._values[Z]}for(var U=y;U<=b;U++){var Y=U in F?F[U]:0;T(Y,U-y,B-A)}}}return N.push(g.length),new n({values:g,index:E,ptr:N,size:[b-y+1,d-A+1]})}n.prototype.forEach=function(h,y){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var b=this,A=this._size[0],d=this._size[1],w=0;w<d;w++){var x=this._ptr[w],g=this._ptr[w+1];if(y)for(var E=x;E<g;E++){var N=this._index[E];h(this._values[E],[N,w],b)}else{for(var S={},D=x;D<g;D++){var T=this._index[D];S[T]=this._values[D]}for(var B=0;B<A;B++){var _=B in S?S[B]:0;h(_,[B,w],b)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var h=this._size[1],y=0;y<h;y++)for(var b=this._ptr[y],A=this._ptr[y+1],d=b;d<A;d++){var w=this._index[d];yield{value:this._values[d],index:[w,y]}}},n.prototype.toArray=function(){return p(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return p(this._values,this._index,this._ptr,this._size,!1)};function p(h,y,b,A,d){var w=A[0],x=A[1],g=[],E,N;for(E=0;E<w;E++)for(g[E]=[],N=0;N<x;N++)g[E][N]=0;for(N=0;N<x;N++)for(var S=b[N],D=b[N+1],T=S;T<D;T++)E=y[T],g[E][N]=h?d?ke(h[T]):h[T]:1;return g}return n.prototype.format=function(h){for(var y=this._size[0],b=this._size[1],A=this.density(),d="Sparse Matrix ["+Ye(y,h)+" x "+Ye(b,h)+"] density: "+Ye(A,h)+`
28
- `,w=0;w<b;w++)for(var x=this._ptr[w],g=this._ptr[w+1],E=x;E<g;E++){var N=this._index[E];d+=`
29
- (`+Ye(N,h)+", "+Ye(w,h)+") ==> "+(this._values?Ye(this._values[E],h):"X")}return d},n.prototype.toString=function(){return Ye(this.toArray())},n.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(h){if(h){if(rr(h)&&(h=h.toNumber()),!tr(h)||!qe(h))throw new TypeError("The parameter k must be an integer number")}else h=0;var y=h>0?h:0,b=h<0?-h:0,A=this._size[0],d=this._size[1],w=Math.min(A-b,d-y),x=[],g=[],E=[];E[0]=0;for(var N=y;N<d&&x.length<w;N++)for(var S=this._ptr[N],D=this._ptr[N+1],T=S;T<D;T++){var B=this._index[T];if(B===N-y+b){x.push(this._values[T]),g[x.length-1]=B-b;break}}return E.push(x.length),new n({values:x,index:g,ptr:E,size:[w,1]})},n.fromJSON=function(h){return new n(h)},n.diagonal=function(h,y,b,A,d){if(!ur(h))throw new TypeError("Array expected, size parameter");if(h.length!==2)throw new Error("Only two dimensions matrix are supported");if(h=h.map(function($){if(rr($)&&($=$.toNumber()),!tr($)||!qe($)||$<1)throw new Error("Size values must be positive integers");return $}),b){if(rr(b)&&(b=b.toNumber()),!tr(b)||!qe(b))throw new TypeError("The parameter k must be an integer number")}else b=0;var w=t,x=0;Wr(d)&&(w=e.find(t,[d,d])||t,x=e.convert(0,d));var g=b>0?b:0,E=b<0?-b:0,N=h[0],S=h[1],D=Math.min(N-E,S-g),T;if(ur(y)){if(y.length!==D)throw new Error("Invalid value array length");T=function(U){return y[U]}}else if(He(y)){var B=y.size();if(B.length!==1||B[0]!==D)throw new Error("Invalid matrix length");T=function(U){return y.get([U])}}else T=function(){return y};for(var _=[],L=[],G=[],C=0;C<S;C++){G.push(_.length);var F=C-g;if(F>=0&&F<D){var Z=T(F);w(Z,x)||(L.push(F+E),_.push(Z))}}return G.push(_.length),new n({values:_,index:L,ptr:G,size:[N,S]})},n.prototype.swapRows=function(h,y){if(!tr(h)||!qe(h)||!tr(y)||!qe(y))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return mr(h,this._size[0]),mr(y,this._size[0]),n._swapRows(h,y,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(h,y,b,A,d){for(var w=A[h],x=A[h+1],g=w;g<x;g++)d(b[g],y[g])},n._swapRows=function(h,y,b,A,d,w){for(var x=0;x<b;x++){var g=w[x],E=w[x+1],N=u(h,g,E,d),S=u(y,g,E,d);if(N<E&&S<E&&d[N]===h&&d[S]===y){if(A){var D=A[N];A[N]=A[S],A[S]=D}continue}if(N<E&&d[N]===h&&(S>=E||d[S]!==y)){var T=A?A[N]:void 0;d.splice(S,0,y),A&&A.splice(S,0,T),d.splice(S<=N?N+1:N,1),A&&A.splice(S<=N?N+1:N,1);continue}if(S<E&&d[S]===y&&(N>=E||d[N]!==h)){var B=A?A[S]:void 0;d.splice(N,0,h),A&&A.splice(N,0,B),d.splice(N<=S?S+1:S,1),A&&A.splice(N<=S?S+1:S,1)}}},n},{isClass:!0}),ty="number",ny=["typed"];function ay(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 iy(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 oy=R(ty,ny,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=ay(n);if(i)return iy(i);var s=0,f=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);f&&(s=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**s-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));l>=2**(s-1)&&(l=l-2**s)}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}),Zc="string",sy=["typed"],uy=R(Zc,sy,r=>{var{typed:e}=r;return e(Zc,{"":function(){return""},number:En,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)}})}),Jc="boolean",ly=["typed"],cy=R(Jc,ly,r=>{var{typed:e}=r;return e(Jc,{"":function(){return!1},boolean:function(a){return a},number:function(a){return!!a},null:function(a){return!1},BigNumber:function(a){return!a.isZero()},string:function(a){var n=a.toLowerCase();if(n==="true")return!0;if(n==="false")return!1;var i=Number(a);if(a!==""&&!isNaN(i))return!!i;throw new Error('Cannot convert "'+a+'" to a boolean')},"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),fy="bignumber",my=["typed","BigNumber"],vy=R(fy,my,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 s=i[2],f=t(i[1]),l=new t(2).pow(Number(s));if(f.gt(l.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var u=new t(2).pow(Number(s)-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))})}),py="complex",hy=["typed","Complex"],dy=R(py,hy,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))})}),gy="fraction",yy=["typed","Fraction"],by=R(gy,yy,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))})}),Wc="matrix",xy=["typed","Matrix","DenseMatrix","SparseMatrix"],wy=R(Wc,xy,r=>{var{typed:e,Matrix:t,DenseMatrix:a,SparseMatrix:n}=r;return e(Wc,{"":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(s,f,l){if(f==="dense"||f==="default"||f===void 0)return new a(s,l);if(f==="sparse")return new n(s,l);throw new TypeError("Unknown matrix type "+JSON.stringify(f)+".")}}),Xc="matrixFromFunction",Ny=["typed","matrix","isZero"],Dy=R(Xc,Ny,r=>{var{typed:e,matrix:t,isZero:a}=r;return e(Xc,{"Array | Matrix, function, string, string":function(s,f,l,u){return n(s,f,l,u)},"Array | Matrix, function, string":function(s,f,l){return n(s,f,l)},"Matrix, function":function(s,f){return n(s,f,"dense")},"Array, function":function(s,f){return n(s,f,"dense").toArray()},"Array | Matrix, string, function":function(s,f,l){return n(s,l,f)},"Array | Matrix, string, string, function":function(s,f,l,u){return n(s,u,f,l)}});function n(i,s,f,l){var u;return l!==void 0?u=t(f,l):u=t(f),u.resize(i),u.forEach(function(o,c){var m=s(c);a(m)||u.set(c,m)}),u}}),Yc="matrixFromRows",Ay=["typed","matrix","flatten","size"],Ey=R(Yc,Ay,r=>{var{typed:e,matrix:t,flatten:a,size:n}=r;return e(Yc,{"...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=s(f[0]),u=[];for(var o of f){var c=s(o);if(c!==l)throw new TypeError("The vectors had different length: "+(l|0)+" \u2260 "+(c|0));u.push(a(o))}return u}function s(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.")}}),Qc="matrixFromColumns",Sy=["typed","matrix","flatten","size"],Cy=R(Qc,Sy,r=>{var{typed:e,matrix:t,flatten:a,size:n}=r;return e(Qc,{"...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=s(f[0]),u=[],o=0;o<l;o++)u[o]=[];for(var c of f){var m=s(c);if(m!==l)throw new TypeError("The vectors had different length: "+(l|0)+" \u2260 "+(m|0));for(var v=a(c),p=0;p<l;p++)u[p].push(v[p])}return u}function s(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.")}}),Kc="splitUnit",My=["typed"],Fy=R(Kc,My,r=>{var{typed:e}=r;return e(Kc,{"Unit, Array":function(a,n){return a.splitUnit(n)}})}),jc="unaryMinus",Ty=["typed"],By=R(jc,Ty,r=>{var{typed:e}=r;return e(jc,{number:Vl,"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))})}),ef="unaryPlus",$y=["typed","config","BigNumber"],Oy=R(ef,$y,r=>{var{typed:e,config:t,BigNumber:a}=r;return e(ef,{number:Gl,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}})}),rf="abs",_y=["typed"],Iy=R(rf,_y,r=>{var{typed:e}=r;return e(rf,{number:Ll,"Complex | BigNumber | Fraction | Unit":t=>t.abs(),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),tf="apply",Ry=["typed","isInteger"],nf=R(tf,Ry,r=>{var{typed:e,isInteger:t}=r;return e(tf,{"Array | Matrix, number | BigNumber, function":function(n,i,s){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 pt(i,f.length);return He(n)?n.create(Ci(n.valueOf(),i,s)):Ci(n,i,s)}})});function Ci(r,e,t){var a,n,i;if(e<=0)if(Array.isArray(r[0])){for(i=qy(r),n=[],a=0;a<i.length;a++)n[a]=Ci(i[a],e-1,t);return n}else return t(r);else{for(n=[],a=0;a<r.length;a++)n[a]=Ci(r[a],e-1,t);return n}}function qy(r){var e=r.length,t=r[0].length,a,n,i=[];for(n=0;n<t;n++){var s=[];for(a=0;a<e;a++)s.push(r[a][n]);i.push(s)}return i}var af="addScalar",zy=["typed"],Py=R(af,zy,r=>{var{typed:e}=r;return e(af,{"number, number":Ul,"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})})}),of="cbrt",Ly=["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],Uy=R(of,Ly,r=>{var{config:e,typed:t,isNegative:a,unaryMinus:n,matrix:i,Complex:s,BigNumber:f,Fraction:l}=r;return t(of,{number:La,Complex:u,"Complex, boolean":u,BigNumber:function(m){return m.cbrt()},Unit:o});function u(c,m){var v=c.arg()/3,p=c.abs(),h=new s(La(p),0).mul(new s(0,v).exp());if(m){var y=[h,new s(La(p),0).mul(new s(0,v+Math.PI*2/3).exp()),new s(La(p),0).mul(new s(0,v-Math.PI*2/3).exp())];return e.matrix==="Array"?y:i(y)}else return h}function o(c){if(c.value&&zt(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 p;rr(c.value)?p=new f(1).div(3):_a(c.value)?p=new l(1,3):p=1/3;var h=c.pow(p);return v&&(h.value=n(h.value)),h}}}),ky="matAlgo11xS0s",Vy=["typed","equalScalar"],Lr=R(ky,Vy,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,s,f){var l=n._values,u=n._index,o=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],p=c[1],h,y=t,b=0,A=s;typeof m=="string"&&(h=m,y=e.find(t,[h,h]),b=e.convert(0,h),i=e.convert(i,h),A=e.find(s,[h,h]));for(var d=[],w=[],x=[],g=0;g<p;g++){x[g]=w.length;for(var E=o[g],N=o[g+1],S=E;S<N;S++){var D=u[S],T=f?A(i,l[S]):A(l[S],i);y(T,b)||(w.push(D),d.push(T))}}return x[p]=w.length,n.createSparseMatrix({values:d,index:w,ptr:x,size:[v,p],datatype:h})}}),Gy="matAlgo12xSfs",Hy=["typed","DenseMatrix"],Br=R(Gy,Hy,r=>{var{typed:e,DenseMatrix:t}=r;return function(n,i,s,f){var l=n._values,u=n._index,o=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],p=c[1],h,y=s;typeof m=="string"&&(h=m,i=e.convert(i,h),y=e.find(s,[h,h]));for(var b=[],A=[],d=[],w=0;w<p;w++){for(var x=w+1,g=o[w],E=o[w+1],N=g;N<E;N++){var S=u[N];A[S]=l[N],d[S]=x}for(var D=0;D<v;D++)w===0&&(b[D]=[]),d[D]===x?b[D][w]=f?y(i,A[D]):y(A[D],i):b[D][w]=f?y(i,0):y(0,i)}return new t({data:b,size:[v,p],datatype:h})}}),Zy="matAlgo14xDs",Jy=["typed"],yt=R(Zy,Jy,r=>{var{typed:e}=r;return function(n,i,s,f){var l=n._data,u=n._size,o=n._datatype,c,m=s;typeof o=="string"&&(c=o,i=e.convert(i,c),m=e.find(s,[c,c]));var v=u.length>0?t(m,0,u,u[0],l,i,f):[];return n.createDenseMatrix({data:v,size:ke(u),datatype:c})};function t(a,n,i,s,f,l,u){var o=[];if(n===i.length-1)for(var c=0;c<s;c++)o[c]=u?a(l,f[c]):a(f[c],l);else for(var m=0;m<s;m++)o[m]=t(a,n+1,i,i[n+1],f[m],l,u);return o}}),as="ceil",Wy=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],Xy=R(as,["typed","config","round"],r=>{var{typed:e,config:t,round:a}=r;return e(as,{number:function(i){return et(i,a(i),t.epsilon)?a(i):Math.ceil(i)},"number, number":function(i,s){if(et(i,a(i,s),t.epsilon))return a(i,s);var[f,l]="".concat(i,"e").split("e"),u=Math.ceil(Number("".concat(f,"e").concat(Number(l)+s)));return[f,l]="".concat(u,"e").split("e"),Number("".concat(f,"e").concat(Number(l)-s))}})}),Yy=R(as,Wy,r=>{var{typed:e,config:t,round:a,matrix:n,equalScalar:i,zeros:s,DenseMatrix:f}=r,l=Lr({typed:e,equalScalar:i}),u=Br({typed:e,DenseMatrix:f}),o=yt({typed:e}),c=Xy({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,p){return v.ceil(p)},"Complex, BigNumber":function(v,p){return v.ceil(p.toNumber())},BigNumber:function(v){return Ct(v,a(v),t.epsilon)?a(v):v.ceil()},"BigNumber, BigNumber":function(v,p){return Ct(v,a(v,p),t.epsilon)?a(v,p):v.toDecimalPlaces(p.toNumber(),un.ROUND_CEIL)},Fraction:function(v){return v.ceil()},"Fraction, number":function(v,p){return v.ceil(p)},"Fraction, BigNumber":function(v,p){return v.ceil(p.toNumber())},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array, number | BigNumber":e.referToSelf(m=>(v,p)=>je(v,h=>m(h,p))),"SparseMatrix, number | BigNumber":e.referToSelf(m=>(v,p)=>l(v,p,m,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(m=>(v,p)=>o(v,p,m,!1)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,p)=>o(n(p),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,p)=>i(v,0)?s(p.size(),p.storage()):p.storage()==="dense"?o(p,v,m,!0):u(p,v,m,!0))})}),sf="cube",Qy=["typed"],Ky=R(sf,Qy,r=>{var{typed:e}=r;return e(sf,{number:Hl,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)}})}),uf="exp",jy=["typed"],eb=R(uf,jy,r=>{var{typed:e}=r;return e(uf,{number:Zl,Complex:function(a){return a.exp()},BigNumber:function(a){return a.exp()}})}),lf="expm1",rb=["typed","Complex"],tb=R(lf,rb,r=>{var{typed:e,Complex:t}=r;return e(lf,{number:Jl,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)}})}),is="fix",nb=["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],ab=R(is,["typed","ceil","floor"],r=>{var{typed:e,ceil:t,floor:a}=r;return e(is,{number:function(i){return i>0?a(i):t(i)},"number, number":function(i,s){return i>0?a(i,s):t(i,s)}})}),ib=R(is,nb,r=>{var{typed:e,Complex:t,matrix:a,ceil:n,floor:i,equalScalar:s,zeros:f,DenseMatrix:l}=r,u=Br({typed:e,DenseMatrix:l}),o=yt({typed:e}),c=ab({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,p){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))},"Complex, BigNumber":function(v,p){var h=p.toNumber();return new t(v.re>0?i(v.re,h):n(v.re,h),v.im>0?i(v.im,h):n(v.im,h))},BigNumber:function(v){return v.isNegative()?n(v):i(v)},"BigNumber, number | BigNumber":function(v,p){return v.isNegative()?n(v,p):i(v,p)},Fraction:function(v){return v.s<0?v.ceil():v.floor()},"Fraction, number | BigNumber":function(v,p){return v.s<0?n(v,p):i(v,p)},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array | Matrix, number | BigNumber":e.referToSelf(m=>(v,p)=>je(v,h=>m(h,p))),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,p)=>o(a(p),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,p)=>s(v,0)?f(p.size(),p.storage()):p.storage()==="dense"?o(p,v,m,!0):u(p,v,m,!0))})}),os="floor",ob=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],sb=R(os,["typed","config","round"],r=>{var{typed:e,config:t,round:a}=r;return e(os,{number:function(i){return et(i,a(i),t.epsilon)?a(i):Math.floor(i)},"number, number":function(i,s){if(et(i,a(i,s),t.epsilon))return a(i,s);var[f,l]="".concat(i,"e").split("e"),u=Math.floor(Number("".concat(f,"e").concat(Number(l)+s)));return[f,l]="".concat(u,"e").split("e"),Number("".concat(f,"e").concat(Number(l)-s))}})}),ub=R(os,ob,r=>{var{typed:e,config:t,round:a,matrix:n,equalScalar:i,zeros:s,DenseMatrix:f}=r,l=Lr({typed:e,equalScalar:i}),u=Br({typed:e,DenseMatrix:f}),o=yt({typed:e}),c=sb({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,p){return v.floor(p)},"Complex, BigNumber":function(v,p){return v.floor(p.toNumber())},BigNumber:function(v){return Ct(v,a(v),t.epsilon)?a(v):v.floor()},"BigNumber, BigNumber":function(v,p){return Ct(v,a(v,p),t.epsilon)?a(v,p):v.toDecimalPlaces(p.toNumber(),un.ROUND_FLOOR)},Fraction:function(v){return v.floor()},"Fraction, number":function(v,p){return v.floor(p)},"Fraction, BigNumber":function(v,p){return v.floor(p.toNumber())},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array, number | BigNumber":e.referToSelf(m=>(v,p)=>je(v,h=>m(h,p))),"SparseMatrix, number | BigNumber":e.referToSelf(m=>(v,p)=>l(v,p,m,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(m=>(v,p)=>o(v,p,m,!1)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,p)=>o(n(p),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,p)=>i(v,0)?s(p.size(),p.storage()):p.storage()==="dense"?o(p,v,m,!0):u(p,v,m,!0))})}),lb="matAlgo01xDSid",cb=["typed"],cn=R(lb,cb,r=>{var{typed:e}=r;return function(a,n,i,s){var f=a._data,l=a._size,u=a._datatype,o=n._values,c=n._index,m=n._ptr,v=n._size,p=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(!o)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h=l[0],y=l[1],b=typeof u=="string"&&u===p?u:void 0,A=b?e.find(i,[b,b]):i,d,w,x=[];for(d=0;d<h;d++)x[d]=[];var g=[],E=[];for(w=0;w<y;w++){for(var N=w+1,S=m[w],D=m[w+1],T=S;T<D;T++)d=c[T],g[d]=s?A(o[T],f[d][w]):A(f[d][w],o[T]),E[d]=N;for(d=0;d<h;d++)E[d]===N?x[d][w]=g[d]:x[d][w]=f[d][w]}return a.createDenseMatrix({data:x,size:[h,y],datatype:b})}}),fb="matAlgo04xSidSid",mb=["typed","equalScalar"],ss=R(fb,mb,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,s){var f=n._values,l=n._index,u=n._ptr,o=n._size,c=n._datatype,m=i._values,v=i._index,p=i._ptr,h=i._size,y=i._datatype;if(o.length!==h.length)throw new Ke(o.length,h.length);if(o[0]!==h[0]||o[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+h+")");var b=o[0],A=o[1],d,w=t,x=0,g=s;typeof c=="string"&&c===y&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),g=e.find(s,[d,d]));var E=f&&m?[]:void 0,N=[],S=[],D=f&&m?[]:void 0,T=f&&m?[]:void 0,B=[],_=[],L,G,C,F,Z;for(G=0;G<A;G++){S[G]=N.length;var $=G+1;for(F=u[G],Z=u[G+1],C=F;C<Z;C++)L=l[C],N.push(L),B[L]=$,D&&(D[L]=f[C]);for(F=p[G],Z=p[G+1],C=F;C<Z;C++)if(L=v[C],B[L]===$){if(D){var U=g(D[L],m[C]);w(U,x)?B[L]=null:D[L]=U}}else N.push(L),_[L]=$,T&&(T[L]=m[C]);if(D&&T)for(C=S[G];C<N.length;)L=N[C],B[L]===$?(E[C]=D[L],C++):_[L]===$?(E[C]=T[L],C++):N.splice(C,1)}return S[A]=N.length,n.createSparseMatrix({values:E,index:N,ptr:S,size:[b,A],datatype:d})}}),vb="matAlgo10xSids",pb=["typed","DenseMatrix"],Mn=R(vb,pb,r=>{var{typed:e,DenseMatrix:t}=r;return function(n,i,s,f){var l=n._values,u=n._index,o=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],p=c[1],h,y=s;typeof m=="string"&&(h=m,i=e.convert(i,h),y=e.find(s,[h,h]));for(var b=[],A=[],d=[],w=0;w<p;w++){for(var x=w+1,g=o[w],E=o[w+1],N=g;N<E;N++){var S=u[N];A[S]=l[N],d[S]=x}for(var D=0;D<v;D++)w===0&&(b[D]=[]),d[D]===x?b[D][w]=f?y(i,A[D]):y(A[D],i):b[D][w]=i}return new t({data:b,size:[v,p],datatype:h})}}),hb="matAlgo13xDD",db=["typed"],gb=R(hb,db,r=>{var{typed:e}=r;return function(n,i,s){var f=n._data,l=n._size,u=n._datatype,o=i._data,c=i._size,m=i._datatype,v=[];if(l.length!==c.length)throw new Ke(l.length,c.length);for(var p=0;p<l.length;p++){if(l[p]!==c[p])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+c+")");v[p]=l[p]}var h,y=s;typeof u=="string"&&u===m&&(h=u,y=e.find(s,[h,h]));var b=v.length>0?t(y,0,v,v[0],f,o):[];return n.createDenseMatrix({data:b,size:v,datatype:h})};function t(a,n,i,s,f,l){var u=[];if(n===i.length-1)for(var o=0;o<s;o++)u[o]=a(f[o],l[o]);else for(var c=0;c<s;c++)u[c]=t(a,n+1,i,i[n+1],f[c],l[c]);return u}}),yb="matrixAlgorithmSuite",bb=["typed","matrix"],hr=R(yb,bb,r=>{var{typed:e,matrix:t}=r,a=gb({typed:e}),n=yt({typed:e});return function(s){var f=s.elop,l=s.SD||s.DS,u;f?(u={"DenseMatrix, DenseMatrix":(v,p)=>a(v,p,f),"Array, Array":(v,p)=>a(t(v),t(p),f).valueOf(),"Array, DenseMatrix":(v,p)=>a(t(v),p,f),"DenseMatrix, Array":(v,p)=>a(v,t(p),f)},s.SS&&(u["SparseMatrix, SparseMatrix"]=(v,p)=>s.SS(v,p,f,!1)),s.DS&&(u["DenseMatrix, SparseMatrix"]=(v,p)=>s.DS(v,p,f,!1),u["Array, SparseMatrix"]=(v,p)=>s.DS(t(v),p,f,!1)),l&&(u["SparseMatrix, DenseMatrix"]=(v,p)=>l(p,v,f,!0),u["SparseMatrix, Array"]=(v,p)=>l(t(p),v,f,!0))):(u={"DenseMatrix, DenseMatrix":e.referToSelf(v=>(p,h)=>a(p,h,v)),"Array, Array":e.referToSelf(v=>(p,h)=>a(t(p),t(h),v).valueOf()),"Array, DenseMatrix":e.referToSelf(v=>(p,h)=>a(t(p),h,v)),"DenseMatrix, Array":e.referToSelf(v=>(p,h)=>a(p,t(h),v))},s.SS&&(u["SparseMatrix, SparseMatrix"]=e.referToSelf(v=>(p,h)=>s.SS(p,h,v,!1))),s.DS&&(u["DenseMatrix, SparseMatrix"]=e.referToSelf(v=>(p,h)=>s.DS(p,h,v,!1)),u["Array, SparseMatrix"]=e.referToSelf(v=>(p,h)=>s.DS(t(p),h,v,!1))),l&&(u["SparseMatrix, DenseMatrix"]=e.referToSelf(v=>(p,h)=>l(h,p,v,!0)),u["SparseMatrix, Array"]=e.referToSelf(v=>(p,h)=>l(t(h),p,v,!0))));var o=s.scalar||"any",c=s.Ds||s.Ss;c&&(f?(u["DenseMatrix,"+o]=(v,p)=>n(v,p,f,!1),u[o+", DenseMatrix"]=(v,p)=>n(p,v,f,!0),u["Array,"+o]=(v,p)=>n(t(v),p,f,!1).valueOf(),u[o+", Array"]=(v,p)=>n(t(p),v,f,!0).valueOf()):(u["DenseMatrix,"+o]=e.referToSelf(v=>(p,h)=>n(p,h,v,!1)),u[o+", DenseMatrix"]=e.referToSelf(v=>(p,h)=>n(h,p,v,!0)),u["Array,"+o]=e.referToSelf(v=>(p,h)=>n(t(p),h,v,!1).valueOf()),u[o+", Array"]=e.referToSelf(v=>(p,h)=>n(t(h),p,v,!0).valueOf())));var m=s.sS!==void 0?s.sS:s.Ss;return f?(s.Ss&&(u["SparseMatrix,"+o]=(v,p)=>s.Ss(v,p,f,!1)),m&&(u[o+", SparseMatrix"]=(v,p)=>m(p,v,f,!0))):(s.Ss&&(u["SparseMatrix,"+o]=e.referToSelf(v=>(p,h)=>s.Ss(p,h,v,!1))),m&&(u[o+", SparseMatrix"]=e.referToSelf(v=>(p,h)=>m(h,p,v,!0)))),f&&f.signatures&&Qu(u,f.signatures),u}}),cf="gcd",xb=["typed","matrix","equalScalar","BigNumber","DenseMatrix"],wb=R(cf,xb,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n,DenseMatrix:i}=r,s=cn({typed:e}),f=ss({typed:e,equalScalar:a}),l=Mn({typed:e,DenseMatrix:i}),u=hr({typed:e,matrix:t}),o="number | BigNumber | Fraction | Matrix | Array",c={};return c["".concat(o,", ").concat(o,", ...").concat(o)]=e.referToSelf(v=>(p,h,y)=>{for(var b=v(p,h),A=0;A<y.length;A++)b=v(b,y[A]);return b}),e(cf,{"number, number":Wl,"BigNumber, BigNumber":m,"Fraction, Fraction":(v,p)=>v.gcd(p)},u({SS:f,DS:s,Ss:l}),c);function m(v,p){if(!v.isInt()||!p.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var h=new n(0);!p.isZero();){var y=v.mod(p);v=p,p=y}return v.lt(h)?v.neg():v}}),Nb="matAlgo02xDS0",Db=["typed","equalScalar"],bt=R(Nb,Db,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,s,f){var l=n._data,u=n._size,o=n._datatype,c=i._values,m=i._index,v=i._ptr,p=i._size,h=i._datatype;if(u.length!==p.length)throw new Ke(u.length,p.length);if(u[0]!==p[0]||u[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+p+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var y=u[0],b=u[1],A,d=t,w=0,x=s;typeof o=="string"&&o===h&&(A=o,d=e.find(t,[A,A]),w=e.convert(0,A),x=e.find(s,[A,A]));for(var g=[],E=[],N=[],S=0;S<b;S++){N[S]=E.length;for(var D=v[S],T=v[S+1],B=D;B<T;B++){var _=m[B],L=f?x(c[B],l[_][S]):x(l[_][S],c[B]);d(L,w)||(E.push(_),g.push(L))}}return N[b]=E.length,i.createSparseMatrix({values:g,index:E,ptr:N,size:[y,b],datatype:A})}}),Ab="matAlgo06xS0S0",Eb=["typed","equalScalar"],Mi=R(Ab,Eb,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,s){var f=n._values,l=n._size,u=n._datatype,o=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],p=l[1],h,y=t,b=0,A=s;typeof u=="string"&&u===m&&(h=u,y=e.find(t,[h,h]),b=e.convert(0,h),A=e.find(s,[h,h]));for(var d=f&&o?[]:void 0,w=[],x=[],g=d?[]:void 0,E=[],N=[],S=0;S<p;S++){x[S]=w.length;var D=S+1;if(zl(n,S,E,g,N,D,w,A),zl(i,S,E,g,N,D,w,A),g)for(var T=x[S];T<w.length;){var B=w[T];if(N[B]===D){var _=g[B];y(_,b)?w.splice(T,1):(d.push(_),T++)}else w.splice(T,1)}else for(var L=x[S];L<w.length;){var G=w[L];N[G]!==D?w.splice(L,1):L++}}return x[p]=w.length,n.createSparseMatrix({values:d,index:w,ptr:x,size:[v,p],datatype:h})}}),ff="lcm",Sb=["typed","matrix","equalScalar"],Cb=R(ff,Sb,r=>{var{typed:e,matrix:t,equalScalar:a}=r,n=bt({typed:e,equalScalar:a}),i=Mi({typed:e,equalScalar:a}),s=Lr({typed:e,equalScalar:a}),f=hr({typed:e,matrix:t}),l="number | BigNumber | Fraction | Matrix | Array",u={};return u["".concat(l,", ").concat(l,", ...").concat(l)]=e.referToSelf(c=>(m,v,p)=>{for(var h=c(m,v),y=0;y<p.length;y++)h=c(h,p[y]);return h}),e(ff,{"number, number":Xl,"BigNumber, BigNumber":o,"Fraction, Fraction":(c,m)=>c.lcm(m)},f({SS:i,DS:n,Ss:s}),u);function o(c,m){if(!c.isInt()||!m.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(c.isZero())return c;if(m.isZero())return m;for(var v=c.times(m);!m.isZero();){var p=m;m=c.mod(p),c=p}return v.div(c).abs()}}),mf="log10",Mb=["typed","config","Complex"],Fb=R(mf,Mb,r=>{var{typed:e,config:t,Complex:a}=r;return e(mf,{number:function(i){return i>=0||t.predictable?Yl(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))})}),vf="log2",Tb=["typed","config","Complex"],Bb=R(vf,Tb,r=>{var{typed:e,config:t,Complex:a}=r;return e(vf,{number:function(s){return s>=0||t.predictable?Ql(s):n(new a(s,0))},Complex:n,BigNumber:function(s){return!s.isNegative()||t.predictable?s.log(2):n(new a(s.toNumber(),0))},"Array | Matrix":e.referToSelf(i=>s=>je(s,i))});function n(i){var s=Math.sqrt(i.re*i.re+i.im*i.im);return new a(Math.log2?Math.log2(s):Math.log(s)/Math.LN2,Math.atan2(i.im,i.re)/Math.LN2)}}),$b="matAlgo03xDSf",Ob=["typed"],Xr=R($b,Ob,r=>{var{typed:e}=r;return function(a,n,i,s){var f=a._data,l=a._size,u=a._datatype,o=n._values,c=n._index,m=n._ptr,v=n._size,p=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(!o)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h=l[0],y=l[1],b,A=0,d=i;typeof u=="string"&&u===p&&(b=u,A=e.convert(0,b),d=e.find(i,[b,b]));for(var w=[],x=0;x<h;x++)w[x]=[];for(var g=[],E=[],N=0;N<y;N++){for(var S=N+1,D=m[N],T=m[N+1],B=D;B<T;B++){var _=c[B];g[_]=s?d(o[B],f[_][N]):d(f[_][N],o[B]),E[_]=S}for(var L=0;L<h;L++)E[L]===S?w[L][N]=g[L]:w[L][N]=s?d(A,f[L][N]):d(f[L][N],A)}return a.createDenseMatrix({data:w,size:[h,y],datatype:b})}}),_b="matAlgo05xSfSf",Ib=["typed","equalScalar"],Fi=R(_b,Ib,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,s){var f=n._values,l=n._index,u=n._ptr,o=n._size,c=n._datatype,m=i._values,v=i._index,p=i._ptr,h=i._size,y=i._datatype;if(o.length!==h.length)throw new Ke(o.length,h.length);if(o[0]!==h[0]||o[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+h+")");var b=o[0],A=o[1],d,w=t,x=0,g=s;typeof c=="string"&&c===y&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),g=e.find(s,[d,d]));var E=f&&m?[]:void 0,N=[],S=[],D=E?[]:void 0,T=E?[]:void 0,B=[],_=[],L,G,C,F;for(G=0;G<A;G++){S[G]=N.length;var Z=G+1;for(C=u[G],F=u[G+1];C<F;C++)L=l[C],N.push(L),B[L]=Z,D&&(D[L]=f[C]);for(C=p[G],F=p[G+1];C<F;C++)L=v[C],B[L]!==Z&&N.push(L),_[L]=Z,T&&(T[L]=m[C]);if(E)for(C=S[G];C<N.length;){L=N[C];var $=B[L],U=_[L];if($===Z||U===Z){var Y=$===Z?D[L]:x,j=U===Z?T[L]:x,P=g(Y,j);w(P,x)?N.splice(C,1):(E.push(P),C++)}}}return S[A]=N.length,n.createSparseMatrix({values:E,index:N,ptr:S,size:[b,A],datatype:d})}}),pf="mod",Rb=["typed","matrix","equalScalar","DenseMatrix"],qb=R(pf,Rb,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n}=r,i=bt({typed:e,equalScalar:a}),s=Xr({typed:e}),f=Fi({typed:e,equalScalar:a}),l=Lr({typed:e,equalScalar:a}),u=Br({typed:e,DenseMatrix:n}),o=hr({typed:e,matrix:t});return e(pf,{"number, number":Kl,"BigNumber, BigNumber":function(m,v){if(v.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return v.isZero()?m:m.mod(v)},"Fraction, Fraction":function(m,v){if(v.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return m.compare(0)>=0?m.mod(v):m.mod(v).add(v).mod(v)}},o({SS:f,DS:s,SD:i,Ss:l,sS:u}))}),zb="multiplyScalar",Pb=["typed"],Lb=R(zb,Pb,r=>{var{typed:e}=r;return e("multiplyScalar",{"number, number":kl,"Complex, Complex":function(a,n){return a.mul(n)},"BigNumber, BigNumber":function(a,n){return a.times(n)},"Fraction, Fraction":function(a,n){return a.mul(n)},"number | Fraction | BigNumber | Complex, Unit":(t,a)=>a.multiply(t),"Unit, number | Fraction | BigNumber | Complex | Unit":(t,a)=>t.multiply(a)})}),hf="multiply",Ub=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],kb=R(hf,Ub,r=>{var{typed:e,matrix:t,addScalar:a,multiplyScalar:n,equalScalar:i,dot:s}=r,f=Lr({typed:e,equalScalar:i}),l=yt({typed:e});function u(x,g){switch(x.length){case 1:switch(g.length){case 1:if(x[0]!==g[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(x[0]!==g[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+x[0]+") must match Matrix rows ("+g[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+g.length+" dimensions)")}break;case 2:switch(g.length){case 1:if(x[1]!==g[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+x[1]+") must match Vector length ("+g[0]+")");break;case 2:if(x[1]!==g[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+x[1]+") must match Matrix B rows ("+g[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+g.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+x.length+" dimensions)")}}function o(x,g,E){if(E===0)throw new Error("Cannot multiply two empty vectors");return s(x,g)}function c(x,g){if(g.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return m(x,g)}function m(x,g){var E=x._data,N=x._size,S=x._datatype,D=g._data,T=g._size,B=g._datatype,_=N[0],L=T[1],G,C=a,F=n;S&&B&&S===B&&typeof S=="string"&&(G=S,C=e.find(a,[G,G]),F=e.find(n,[G,G]));for(var Z=[],$=0;$<L;$++){for(var U=F(E[0],D[0][$]),Y=1;Y<_;Y++)U=C(U,F(E[Y],D[Y][$]));Z[$]=U}return x.createDenseMatrix({data:Z,size:[L],datatype:G})}var v=e("_multiplyMatrixVector",{"DenseMatrix, any":h,"SparseMatrix, any":A}),p=e("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":y,"DenseMatrix, SparseMatrix":b,"SparseMatrix, DenseMatrix":d,"SparseMatrix, SparseMatrix":w});function h(x,g){var E=x._data,N=x._size,S=x._datatype,D=g._data,T=g._datatype,B=N[0],_=N[1],L,G=a,C=n;S&&T&&S===T&&typeof S=="string"&&(L=S,G=e.find(a,[L,L]),C=e.find(n,[L,L]));for(var F=[],Z=0;Z<B;Z++){for(var $=E[Z],U=C($[0],D[0]),Y=1;Y<_;Y++)U=G(U,C($[Y],D[Y]));F[Z]=U}return x.createDenseMatrix({data:F,size:[B],datatype:L})}function y(x,g){var E=x._data,N=x._size,S=x._datatype,D=g._data,T=g._size,B=g._datatype,_=N[0],L=N[1],G=T[1],C,F=a,Z=n;S&&B&&S===B&&typeof S=="string"&&(C=S,F=e.find(a,[C,C]),Z=e.find(n,[C,C]));for(var $=[],U=0;U<_;U++){var Y=E[U];$[U]=[];for(var j=0;j<G;j++){for(var P=Z(Y[0],D[0][j]),K=1;K<L;K++)P=F(P,Z(Y[K],D[K][j]));$[U][j]=P}}return x.createDenseMatrix({data:$,size:[_,G],datatype:C})}function b(x,g){var E=x._data,N=x._size,S=x._datatype,D=g._values,T=g._index,B=g._ptr,_=g._size,L=g._datatype;if(!D)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var G=N[0],C=_[1],F,Z=a,$=n,U=i,Y=0;S&&L&&S===L&&typeof S=="string"&&(F=S,Z=e.find(a,[F,F]),$=e.find(n,[F,F]),U=e.find(i,[F,F]),Y=e.convert(0,F));for(var j=[],P=[],K=[],ne=g.createSparseMatrix({values:j,index:P,ptr:K,size:[G,C],datatype:F}),re=0;re<C;re++){K[re]=P.length;var fe=B[re],pe=B[re+1];if(pe>fe)for(var ce=0,oe=0;oe<G;oe++){for(var Ce=oe+1,Oe=void 0,Me=fe;Me<pe;Me++){var $e=T[Me];ce!==Ce?(Oe=$(E[oe][$e],D[Me]),ce=Ce):Oe=Z(Oe,$(E[oe][$e],D[Me]))}ce===Ce&&!U(Oe,Y)&&(P.push(oe),j.push(Oe))}}return K[C]=P.length,ne}function A(x,g){var E=x._values,N=x._index,S=x._ptr,D=x._datatype;if(!E)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var T=g._data,B=g._datatype,_=x._size[0],L=g._size[0],G=[],C=[],F=[],Z,$=a,U=n,Y=i,j=0;D&&B&&D===B&&typeof D=="string"&&(Z=D,$=e.find(a,[Z,Z]),U=e.find(n,[Z,Z]),Y=e.find(i,[Z,Z]),j=e.convert(0,Z));var P=[],K=[];F[0]=0;for(var ne=0;ne<L;ne++){var re=T[ne];if(!Y(re,j))for(var fe=S[ne],pe=S[ne+1],ce=fe;ce<pe;ce++){var oe=N[ce];K[oe]?P[oe]=$(P[oe],U(re,E[ce])):(K[oe]=!0,C.push(oe),P[oe]=U(re,E[ce]))}}for(var Ce=C.length,Oe=0;Oe<Ce;Oe++){var Me=C[Oe];G[Oe]=P[Me]}return F[1]=C.length,x.createSparseMatrix({values:G,index:C,ptr:F,size:[_,1],datatype:Z})}function d(x,g){var E=x._values,N=x._index,S=x._ptr,D=x._datatype;if(!E)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var T=g._data,B=g._datatype,_=x._size[0],L=g._size[0],G=g._size[1],C,F=a,Z=n,$=i,U=0;D&&B&&D===B&&typeof D=="string"&&(C=D,F=e.find(a,[C,C]),Z=e.find(n,[C,C]),$=e.find(i,[C,C]),U=e.convert(0,C));for(var Y=[],j=[],P=[],K=x.createSparseMatrix({values:Y,index:j,ptr:P,size:[_,G],datatype:C}),ne=[],re=[],fe=0;fe<G;fe++){P[fe]=j.length;for(var pe=fe+1,ce=0;ce<L;ce++){var oe=T[ce][fe];if(!$(oe,U))for(var Ce=S[ce],Oe=S[ce+1],Me=Ce;Me<Oe;Me++){var $e=N[Me];re[$e]!==pe?(re[$e]=pe,j.push($e),ne[$e]=Z(oe,E[Me])):ne[$e]=F(ne[$e],Z(oe,E[Me]))}}for(var k=P[fe],W=j.length,ie=k;ie<W;ie++){var V=j[ie];Y[ie]=ne[V]}}return P[G]=j.length,K}function w(x,g){var E=x._values,N=x._index,S=x._ptr,D=x._datatype,T=g._values,B=g._index,_=g._ptr,L=g._datatype,G=x._size[0],C=g._size[1],F=E&&T,Z,$=a,U=n;D&&L&&D===L&&typeof D=="string"&&(Z=D,$=e.find(a,[Z,Z]),U=e.find(n,[Z,Z]));for(var Y=F?[]:void 0,j=[],P=[],K=x.createSparseMatrix({values:Y,index:j,ptr:P,size:[G,C],datatype:Z}),ne=F?[]:void 0,re=[],fe,pe,ce,oe,Ce,Oe,Me,$e,k=0;k<C;k++){P[k]=j.length;var W=k+1;for(Ce=_[k],Oe=_[k+1],oe=Ce;oe<Oe;oe++)if($e=B[oe],F)for(pe=S[$e],ce=S[$e+1],fe=pe;fe<ce;fe++)Me=N[fe],re[Me]!==W?(re[Me]=W,j.push(Me),ne[Me]=U(T[oe],E[fe])):ne[Me]=$(ne[Me],U(T[oe],E[fe]));else for(pe=S[$e],ce=S[$e+1],fe=pe;fe<ce;fe++)Me=N[fe],re[Me]!==W&&(re[Me]=W,j.push(Me));if(F)for(var ie=P[k],V=j.length,Q=ie;Q<V;Q++){var te=j[Q];Y[Q]=ne[te]}}return P[C]=j.length,K}return e(hf,n,{"Array, Array":e.referTo("Matrix, Matrix",x=>(g,E)=>{u(er(g),er(E));var N=x(t(g),t(E));return He(N)?N.valueOf():N}),"Matrix, Matrix":function(g,E){var N=g.size(),S=E.size();return u(N,S),N.length===1?S.length===1?o(g,E,N[0]):c(g,E):S.length===1?v(g,E):p(g,E)},"Matrix, Array":e.referTo("Matrix,Matrix",x=>(g,E)=>x(g,t(E))),"Array, Matrix":e.referToSelf(x=>(g,E)=>x(t(g,E.storage()),E)),"SparseMatrix, any":function(g,E){return f(g,E,n,!1)},"DenseMatrix, any":function(g,E){return l(g,E,n,!1)},"any, SparseMatrix":function(g,E){return f(E,g,n,!0)},"any, DenseMatrix":function(g,E){return l(E,g,n,!0)},"Array, any":function(g,E){return l(t(g),E,n,!1).valueOf()},"any, Array":function(g,E){return l(t(E),g,n,!0).valueOf()},"any, any":n,"any, any, ...any":e.referToSelf(x=>(g,E,N)=>{for(var S=x(g,E),D=0;D<N.length;D++)S=x(S,N[D]);return S})})}),df="nthRoot",Vb=["typed","matrix","equalScalar","BigNumber"],Gb=R(df,Vb,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n}=r,i=cn({typed:e}),s=bt({typed:e,equalScalar:a}),f=Mi({typed:e,equalScalar:a}),l=Lr({typed:e,equalScalar:a}),u=hr({typed:e,matrix:t});function o(){throw new Error("Complex number not supported in function nthRoot. Use nthRoots instead.")}return e(df,{number:jl,"number, number":jl,BigNumber:m=>c(m,new n(2)),"BigNumber, BigNumber":c,Complex:o,"Complex, number":o,Array:e.referTo("DenseMatrix,number",m=>v=>m(t(v),2).valueOf()),DenseMatrix:e.referTo("DenseMatrix,number",m=>v=>m(v,2)),SparseMatrix:e.referTo("SparseMatrix,number",m=>v=>m(v,2)),"SparseMatrix, SparseMatrix":e.referToSelf(m=>(v,p)=>{if(p.density()===1)return f(v,p,m);throw new Error("Root must be non-zero")}),"DenseMatrix, SparseMatrix":e.referToSelf(m=>(v,p)=>{if(p.density()===1)return i(v,p,m,!1);throw new Error("Root must be non-zero")}),"Array, SparseMatrix":e.referTo("DenseMatrix,SparseMatrix",m=>(v,p)=>m(t(v),p)),"number | BigNumber, SparseMatrix":e.referToSelf(m=>(v,p)=>{if(p.density()===1)return l(p,v,m,!0);throw new Error("Root must be non-zero")})},u({scalar:"number | BigNumber",SD:s,Ss:l,sS:!1}));function c(m,v){var p=n.precision,h=n.clone({precision:p+2}),y=new n(0),b=new h(1),A=v.isNegative();if(A&&(v=v.neg()),v.isZero())throw new Error("Root must be non-zero");if(m.isNegative()&&!v.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(m.isZero())return A?new h(1/0):0;if(!m.isFinite())return A?y:m;var d=m.abs().pow(b.div(v));return d=m.isNeg()?d.neg():d,new n((A?b.div(d):d).toPrecision(p))}}),gf="sign",Hb=["typed","BigNumber","Fraction","complex"],Zb=R(gf,Hb,r=>{var{typed:e,BigNumber:t,complex:a,Fraction:n}=r;return e(gf,{number:ts,Complex:function(s){return s.im===0?a(ts(s.re)):s.sign()},BigNumber:function(s){return new t(s.cmp(0))},Fraction:function(s){return new n(s.s,1)},"Array | Matrix":e.referToSelf(i=>s=>je(s,i)),Unit:e.referToSelf(i=>s=>{if(!s._isDerived()&&s.units[0].unit.offset!==0)throw new TypeError("sign is ambiguous for units with offset");return e.find(i,s.valueType())(s.value)})})}),Jb="sqrt",Wb=["config","typed","Complex"],Xb=R(Jb,Wb,r=>{var{config:e,typed:t,Complex:a}=r;return t("sqrt",{number:n,Complex:function(s){return s.sqrt()},BigNumber:function(s){return!s.isNegative()||e.predictable?s.sqrt():n(s.toNumber())},Unit:function(s){return s.pow(.5)}});function n(i){return isNaN(i)?NaN:i>=0||e.predictable?Math.sqrt(i):new a(i,0).sqrt()}}),yf="square",Yb=["typed"],Qb=R(yf,Yb,r=>{var{typed:e}=r;return e(yf,{number:ec,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)}})}),bf="subtract",Kb=["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix"],jb=R(bf,Kb,r=>{var{typed:e,matrix:t,equalScalar:a,addScalar:n,unaryMinus:i,DenseMatrix:s}=r,f=cn({typed:e}),l=Xr({typed:e}),u=Fi({typed:e,equalScalar:a}),o=Mn({typed:e,DenseMatrix:s}),c=Br({typed:e,DenseMatrix:s}),m=hr({typed:e,matrix:t});return e(bf,{"number, number":(v,p)=>v-p,"Complex, Complex":(v,p)=>v.sub(p),"BigNumber, BigNumber":(v,p)=>v.minus(p),"Fraction, Fraction":(v,p)=>v.sub(p),"Unit, Unit":e.referToSelf(v=>(p,h)=>{if(p.value===null)throw new Error("Parameter x contains a unit with undefined value");if(h.value===null)throw new Error("Parameter y contains a unit with undefined value");if(!p.equalBase(h))throw new Error("Units do not match");var y=p.clone();return y.value=e.find(v,[y.valueType(),h.valueType()])(y.value,h.value),y.fixPrefix=!1,y})},m({SS:u,DS:f,SD:l,Ss:c,sS:o}))}),xf="xgcd",ex=["typed","config","matrix","BigNumber"],rx=R(xf,ex,r=>{var{typed:e,config:t,matrix:a,BigNumber:n}=r;return e(xf,{"number, number":function(f,l){var u=rc(f,l);return t.matrix==="Array"?u:a(u)},"BigNumber, BigNumber":i});function i(s,f){var l,u,o,c=new n(0),m=new n(1),v=c,p=m,h=m,y=c;if(!s.isInt()||!f.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!f.isZero();)u=s.div(f).floor(),o=s.mod(f),l=v,v=p.minus(u.times(v)),p=l,l=h,h=y.minus(u.times(h)),y=l,s=f,f=o;var b;return s.lt(c)?b=[s.neg(),p.neg(),y.neg()]:b=[s,s.isZero()?0:p,y],t.matrix==="Array"?b:a(b)}}),wf="invmod",tx=["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],nx=R(wf,tx,r=>{var{typed:e,config:t,BigNumber:a,xgcd:n,equal:i,smaller:s,mod:f,add:l,isInteger:u}=r;return e(wf,{"number, number":o,"BigNumber, BigNumber":o});function o(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[p,h]=v;return i(p,a(1))?(h=f(h,m),s(h,a(0))&&(h=l(h,m)),h):NaN}}),ax="matAlgo09xS0Sf",ix=["typed","equalScalar"],Nf=R(ax,ix,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,s){var f=n._values,l=n._index,u=n._ptr,o=n._size,c=n._datatype,m=i._values,v=i._index,p=i._ptr,h=i._size,y=i._datatype;if(o.length!==h.length)throw new Ke(o.length,h.length);if(o[0]!==h[0]||o[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+h+")");var b=o[0],A=o[1],d,w=t,x=0,g=s;typeof c=="string"&&c===y&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),g=e.find(s,[d,d]));var E=f&&m?[]:void 0,N=[],S=[],D=E?[]:void 0,T=[],B,_,L,G,C;for(_=0;_<A;_++){S[_]=N.length;var F=_+1;if(D)for(G=p[_],C=p[_+1],L=G;L<C;L++)B=v[L],T[B]=F,D[B]=m[L];for(G=u[_],C=u[_+1],L=G;L<C;L++)if(B=l[L],D){var Z=T[B]===F?D[B]:x,$=g(f[L],Z);w($,x)||(N.push(B),E.push($))}else N.push(B)}return S[A]=N.length,n.createSparseMatrix({values:E,index:N,ptr:S,size:[b,A],datatype:d})}}),Df="dotMultiply",ox=["typed","matrix","equalScalar","multiplyScalar"],sx=R(Df,ox,r=>{var{typed:e,matrix:t,equalScalar:a,multiplyScalar:n}=r,i=bt({typed:e,equalScalar:a}),s=Nf({typed:e,equalScalar:a}),f=Lr({typed:e,equalScalar:a}),l=hr({typed:e,matrix:t});return e(Df,l({elop:n,SS:s,DS:i,Ss:f}))});function ux(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 us(r,e,function(a,n){return a&n})}function Ua(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 lx(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:us(r,e,function(n,i){return n|i})}function us(r,e,t){var a=r.constructor,n,i,s=+(r.s<0),f=+(e.s<0);if(s){n=Ti(Ua(r));for(var l=0;l<n.length;++l)n[l]^=1}else n=Ti(r);if(f){i=Ti(Ua(e));for(var u=0;u<i.length;++u)i[u]^=1}else i=Ti(e);var o,c,m;n.length<=i.length?(o=n,c=i,m=s):(o=i,c=n,m=f);var v=o.length,p=c.length,h=t(s,f)^1,y=new a(h^1),b=new a(1),A=new a(2),d=a.precision;for(a.config({precision:1e9});v>0;)t(o[--v],c[--p])===h&&(y=y.plus(b)),b=b.times(A);for(;p>0;)t(m,c[--p])===h&&(y=y.plus(b)),b=b.times(A);return a.config({precision:d}),h===0&&(y.s=-y.s),y}function Ti(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 s=t.length;t.charAt(s)==="0";)s--;var f=r.e,l=t.slice(0,s+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 o=[0],c=0;c<l.length;){for(var m=o.length;m--;)o[m]*=10;o[0]+=parseInt(l.charAt(c++));for(var v=0;v<o.length;++v)o[v]>1&&((o[v+1]===null||o[v+1]===void 0)&&(o[v+1]=0),o[v+1]+=o[v]>>1,o[v]&=1)}return o.reverse()}function cx(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)?Ua(e):e.eq(a)?Ua(r):!r.isFinite()||!e.isFinite()?!r.isFinite()&&!e.isFinite()?a:new t(r.isNegative()===e.isNegative()?1/0:-1/0):us(r,e,function(n,i){return n^i})}function fx(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 mx(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 Af="bitAnd",vx=["typed","matrix","equalScalar"],px=R(Af,vx,r=>{var{typed:e,matrix:t,equalScalar:a}=r,n=bt({typed:e,equalScalar:a}),i=Mi({typed:e,equalScalar:a}),s=Lr({typed:e,equalScalar:a}),f=hr({typed:e,matrix:t});return e(Af,{"number, number":ac,"BigNumber, BigNumber":ux},f({SS:i,DS:n,Ss:s}))}),Ef="bitNot",hx=["typed"],dx=R(Ef,hx,r=>{var{typed:e}=r;return e(Ef,{number:ic,BigNumber:Ua,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Sf="bitOr",gx=["typed","matrix","equalScalar","DenseMatrix"],yx=R(Sf,gx,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n}=r,i=cn({typed:e}),s=ss({typed:e,equalScalar:a}),f=Mn({typed:e,DenseMatrix:n}),l=hr({typed:e,matrix:t});return e(Sf,{"number, number":oc,"BigNumber, BigNumber":lx},l({SS:s,DS:i,Ss:f}))}),bx="matAlgo07xSSf",xx=["typed","DenseMatrix"],Mt=R(bx,xx,r=>{var{typed:e,DenseMatrix:t}=r;return function(i,s,f){var l=i._size,u=i._datatype,o=s._size,c=s._datatype;if(l.length!==o.length)throw new Ke(l.length,o.length);if(l[0]!==o[0]||l[1]!==o[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+o+")");var m=l[0],v=l[1],p,h=0,y=f;typeof u=="string"&&u===c&&(p=u,h=e.convert(0,p),y=e.find(f,[p,p]));var b,A,d=[];for(b=0;b<m;b++)d[b]=[];var w=[],x=[],g=[],E=[];for(A=0;A<v;A++){var N=A+1;for(a(i,A,g,w,N),a(s,A,E,x,N),b=0;b<m;b++){var S=g[b]===N?w[b]:h,D=E[b]===N?x[b]:h;d[b][A]=y(S,D)}}return new t({data:d,size:[m,v],datatype:p})};function a(n,i,s,f,l){for(var u=n._values,o=n._index,c=n._ptr,m=c[i],v=c[i+1];m<v;m++){var p=o[m];s[p]=l,f[p]=u[m]}}}),Cf="bitXor",wx=["typed","matrix","DenseMatrix"],Nx=R(Cf,wx,r=>{var{typed:e,matrix:t,DenseMatrix:a}=r,n=Xr({typed:e}),i=Mt({typed:e,DenseMatrix:a}),s=Br({typed:e,DenseMatrix:a}),f=hr({typed:e,matrix:t});return e(Cf,{"number, number":sc,"BigNumber, BigNumber":cx},f({SS:i,DS:n,Ss:s}))}),Mf="arg",Dx=["typed"],Ax=R(Mf,Dx,r=>{var{typed:e}=r;return e(Mf,{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))})}),Ff="conj",Ex=["typed"],Sx=R(Ff,Ex,r=>{var{typed:e}=r;return e(Ff,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.conjugate(),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Tf="im",Cx=["typed"],Mx=R(Tf,Cx,r=>{var{typed:e}=r;return e(Tf,{number:()=>0,"BigNumber | Fraction":t=>t.mul(0),Complex:t=>t.im,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Bf="re",Fx=["typed"],Tx=R(Bf,Fx,r=>{var{typed:e}=r;return e(Bf,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.re,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),$f="not",Bx=["typed"],$x=R($f,Bx,r=>{var{typed:e}=r;return e($f,{"null | undefined":()=>!0,number:mc,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))})}),Of="or",Ox=["typed","matrix","equalScalar","DenseMatrix"],_x=R(Of,Ox,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n}=r,i=Xr({typed:e}),s=Fi({typed:e,equalScalar:a}),f=Br({typed:e,DenseMatrix:n}),l=hr({typed:e,matrix:t});return e(Of,{"number, number":vc,"Complex, Complex":function(o,c){return o.re!==0||o.im!==0||c.re!==0||c.im!==0},"BigNumber, BigNumber":function(o,c){return!o.isZero()&&!o.isNaN()||!c.isZero()&&!c.isNaN()},"Unit, Unit":e.referToSelf(u=>(o,c)=>u(o.value||0,c.value||0))},l({SS:s,DS:i,Ss:f}))}),_f="xor",Ix=["typed","matrix","DenseMatrix"],Rx=R(_f,Ix,r=>{var{typed:e,matrix:t,DenseMatrix:a}=r,n=Xr({typed:e}),i=Mt({typed:e,DenseMatrix:a}),s=Br({typed:e,DenseMatrix:a}),f=hr({typed:e,matrix:t});return e(_f,{"number, number":pc,"Complex, Complex":function(u,o){return(u.re!==0||u.im!==0)!=(o.re!==0||o.im!==0)},"BigNumber, BigNumber":function(u,o){return(!u.isZero()&&!u.isNaN())!=(!o.isZero()&&!o.isNaN())},"Unit, Unit":e.referToSelf(l=>(u,o)=>l(u.value||0,o.value||0))},f({SS:i,DS:n,Ss:s}))}),If="concat",qx=["typed","matrix","isInteger"],Rf=R(If,qx,r=>{var{typed:e,matrix:t,isInteger:a}=r;return e(If,{"...Array | Matrix | number | BigNumber":function(i){var s,f=i.length,l=-1,u,o=!1,c=[];for(s=0;s<f;s++){var m=i[s];if(He(m)&&(o=!0),tr(m)||rr(m)){if(s!==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||s>0&&l>u)throw new pt(l,u+1)}else{var v=ke(m).valueOf(),p=er(v);if(c[s]=v,u=l,l=p.length-1,s>0&&l!==u)throw new Ke(u+1,l+1)}}if(c.length===0)throw new SyntaxError("At least one matrix expected");for(var h=c.shift();c.length;)h=qf(h,c.shift(),l,0);return o?t(h):h},"...string":function(i){return i.join("")}})});function qf(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]=qf(r[i],e[i],t,a+1);return n}else return r.concat(e)}var zf="column",zx=["typed","Index","matrix","range"],Pf=R(zf,zx,r=>{var{typed:e,Index:t,matrix:a,range:n}=r;return e(zf,{"Matrix, number":i,"Array, number":function(f,l){return i(a(ke(f)),l).valueOf()}});function i(s,f){if(s.size().length!==2)throw new Error("Only two dimensional matrix is supported");mr(f,s.size()[1]);var l=n(0,s.size()[0]),u=new t(l,f);return s.subset(u)}}),Lf="count",Px=["typed","size","prod"],Lx=R(Lf,Px,r=>{var{typed:e,size:t,prod:a}=r;return e(Lf,{string:function(i){return i.length},"Matrix | Array":function(i){return a(t(i))}})}),Uf="cross",Ux=["typed","matrix","subtract","multiply"],kx=R(Uf,Ux,r=>{var{typed:e,matrix:t,subtract:a,multiply:n}=r;return e(Uf,{"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(s,f){var l=Math.max(er(s).length,er(f).length);s=li(s),f=li(f);var u=er(s),o=er(f);if(u.length!==1||o.length!==1||u[0]!==3||o[0]!==3)throw new RangeError("Vectors with length 3 expected (Size A = ["+u.join(", ")+"], B = ["+o.join(", ")+"])");var c=[a(n(s[1],f[2]),n(s[2],f[1])),a(n(s[2],f[0]),n(s[0],f[2])),a(n(s[0],f[1]),n(s[1],f[0]))];return l>1?[c]:c}}),kf="diag",Vx=["typed","matrix","DenseMatrix","SparseMatrix"],Gx=R(kf,Vx,r=>{var{typed:e,matrix:t,DenseMatrix:a,SparseMatrix:n}=r;return e(kf,{Array:function(u){return i(u,0,er(u),null)},"Array, number":function(u,o){return i(u,o,er(u),null)},"Array, BigNumber":function(u,o){return i(u,o.toNumber(),er(u),null)},"Array, string":function(u,o){return i(u,0,er(u),o)},"Array, number, string":function(u,o,c){return i(u,o,er(u),c)},"Array, BigNumber, string":function(u,o,c){return i(u,o.toNumber(),er(u),c)},Matrix:function(u){return i(u,0,u.size(),u.storage())},"Matrix, number":function(u,o){return i(u,o,u.size(),u.storage())},"Matrix, BigNumber":function(u,o){return i(u,o.toNumber(),u.size(),u.storage())},"Matrix, string":function(u,o){return i(u,0,u.size(),o)},"Matrix, number, string":function(u,o,c){return i(u,o,u.size(),c)},"Matrix, BigNumber, string":function(u,o,c){return i(u,o.toNumber(),u.size(),c)}});function i(l,u,o,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(o.length){case 1:return s(l,u,c,o[0],v,m);case 2:return f(l,u,c,o,v,m)}throw new RangeError("Matrix for function diag must be 2 dimensional")}function s(l,u,o,c,m,v){var p=[c+m,c+v];if(o&&o!=="sparse"&&o!=="dense")throw new TypeError("Unknown matrix type ".concat(o,'"'));var h=o==="sparse"?n.diagonal(p,l,u):a.diagonal(p,l,u);return o!==null?h:h.valueOf()}function f(l,u,o,c,m,v){if(He(l)){var p=l.diagonal(u);return o!==null?o!==p.storage()?t(p,o):p:p.valueOf()}for(var h=Math.min(c[0]-m,c[1]-v),y=[],b=0;b<h;b++)y[b]=l[b+m][b+v];return o!==null?t(y):y}}),Hx="filter",Zx=["typed"],Jx=R(Hx,Zx,r=>{var{typed:e}=r;return e("filter",{"Array, function":Vf,"Matrix, function":function(a,n){return a.create(Vf(a.toArray(),n))},"Array, RegExp":fi,"Matrix, RegExp":function(a,n){return a.create(fi(a.toArray(),n))}})});function Vf(r,e){var t=ln(e);return pl(r,function(a,n,i){return t===1?e(a):t===2?e(a,[n]):e(a,[n],i)})}var Gf="flatten",Wx=["typed","matrix"],Xx=R(Gf,Wx,r=>{var{typed:e,matrix:t}=r;return e(Gf,{Array:function(n){return ar(n)},Matrix:function(n){var i=ar(n.toArray());return t(i)}})}),Hf="forEach",Yx=["typed"],Qx=R(Hf,Yx,r=>{var{typed:e}=r;return e(Hf,{"Array, function":Kx,"Matrix, function":function(a,n){return a.forEach(n)}})});function Kx(r,e){var t=ln(e),a=function n(i,s){Array.isArray(i)?ci(i,function(f,l){n(f,s.concat(l))}):t===1?e(i):t===2?e(i,s):e(i,s,r)};a(r,[])}var Zf="getMatrixDataType",jx=["typed"],ew=R(Zf,jx,r=>{var{typed:e}=r;return e(Zf,{Array:function(a){return qa(a,gr)},Matrix:function(a){return a.getDataType()}})}),Jf="identity",rw=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],tw=R(Jf,rw,r=>{var{typed:e,config:t,matrix:a,BigNumber:n,DenseMatrix:i,SparseMatrix:s}=r;return e(Jf,{"":function(){return t.matrix==="Matrix"?a([]):[]},string:function(o){return a(o)},"number | BigNumber":function(o){return l(o,o,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(o,c){return l(o,o,c)},"number | BigNumber, number | BigNumber":function(o,c){return l(o,c,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(o,c,m){return l(o,c,m)},Array:function(o){return f(o)},"Array, string":function(o,c){return f(o,c)},Matrix:function(o){return f(o.valueOf(),o.storage())},"Matrix, string":function(o,c){return f(o.valueOf(),c)}});function f(u,o){switch(u.length){case 0:return o?a(o):[];case 1:return l(u[0],u[0],o);case 2:return l(u[0],u[1],o);default:throw new Error("Vector containing two values expected")}}function l(u,o,c){var m=rr(u)||rr(o)?n:null;if(rr(u)&&(u=u.toNumber()),rr(o)&&(o=o.toNumber()),!qe(u)||u<1)throw new Error("Parameters in function identity must be positive integers");if(!qe(o)||o<1)throw new Error("Parameters in function identity must be positive integers");var v=m?new n(1):1,p=m?new m(0):0,h=[u,o];if(c){if(c==="sparse")return s.diagonal(h,v,0,p);if(c==="dense")return i.diagonal(h,v,0,p);throw new TypeError('Unknown matrix type "'.concat(c,'"'))}for(var y=Gn([],h,p),b=u<o?u:o,A=0;A<b;A++)y[A][A]=v;return y}}),Wf="kron",nw=["typed","matrix","multiplyScalar"],aw=R(Wf,nw,r=>{var{typed:e,matrix:t,multiplyScalar:a}=r;return e(Wf,{"Matrix, Matrix":function(s,f){return t(n(s.toArray(),f.toArray()))},"Matrix, Array":function(s,f){return t(n(s.toArray(),f))},"Array, Matrix":function(s,f){return t(n(s,f.toArray()))},"Array, Array":n});function n(i,s){if(er(i).length===1&&(i=[i]),er(s).length===1&&(s=[s]),er(i).length>2||er(s).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(i.length)+", y = "+JSON.stringify(s.length)+")");var f=[],l=[];return i.map(function(u){return s.map(function(o){return l=[],f.push(l),u.map(function(c){return o.map(function(m){return l.push(a(c,m))})})})})&&f}}),Xf="map",iw=["typed"],ow=R(Xf,iw,r=>{var{typed:e}=r;return e(Xf,{"Array, function":sw,"Matrix, function":function(a,n){return a.map(n)}})});function sw(r,e){var t=ln(e),a=function n(i,s){if(Array.isArray(i))return i.map(function(u,o){return n(u,s.concat(o))});try{return t===1?e(i):t===2?e(i,s):e(i,s,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(s);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 Yf="diff",uw=["typed","matrix","subtract","number"],Qf=R(Yf,uw,r=>{var{typed:e,matrix:t,subtract:a,number:n}=r;return e(Yf,{"Array | Matrix":function(o){return He(o)?t(s(o.toArray())):s(o)},"Array | Matrix, number":function(o,c){if(!qe(c))throw new RangeError("Dimension must be a whole number");return He(o)?t(i(o.toArray(),c)):i(o,c)},"Array, BigNumber":e.referTo("Array,number",u=>(o,c)=>u(o,n(c))),"Matrix, BigNumber":e.referTo("Matrix,number",u=>(o,c)=>u(o,n(c)))});function i(u,o){if(He(u)&&(u=u.toArray()),!Array.isArray(u))throw RangeError("Array/Matrix does not have that many dimensions");if(o>0){var c=[];return u.forEach(m=>{c.push(i(m,o-1))}),c}else{if(o===0)return s(u);throw RangeError("Cannot have negative dimension")}}function s(u){for(var o=[],c=u.length,m=1;m<c;m++)o.push(f(u[m-1],u[m]));return o}function f(u,o){He(u)&&(u=u.toArray()),He(o)&&(o=o.toArray());var c=Array.isArray(u),m=Array.isArray(o);if(c&&m)return l(u,o);if(!c&&!m)return a(o,u);throw TypeError("Cannot calculate difference between 1 array and 1 non-array")}function l(u,o){if(u.length!==o.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],o[v]));return c}}),lw="ones",cw=["typed","config","matrix","BigNumber"],fw=R(lw,cw,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 o=u[u.length-1];if(typeof o=="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 o=u.storage();return i(u.valueOf(),o)},"Array | Matrix, string":function(u,o){return i(u.valueOf(),o)}});function i(l,u){var o=s(l),c=o?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?Gn(v,l,c):v}}function s(l){var u=!1;return l.forEach(function(o,c,m){rr(o)&&(u=!0,m[c]=o.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 ls(){throw new Error('No "bignumber" implementation available')}function Kf(){throw new Error('No "fraction" implementation available')}function jf(){throw new Error('No "matrix" implementation available')}var em="range",mw=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],rm=R(em,mw,r=>{var{typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:s,larger:f,largerEq:l}=r;return e(em,{string:o,"string, boolean":o,"number, number":function(b,A){return u(c(b,A,1))},"number, number, number":function(b,A,d){return u(c(b,A,d))},"number, number, boolean":function(b,A,d){return u(d?m(b,A,1):c(b,A,1))},"number, number, number, boolean":function(b,A,d,w){return u(w?m(b,A,d):c(b,A,d))},"BigNumber, BigNumber":function(b,A){var d=b.constructor;return u(v(b,A,new d(1)))},"BigNumber, BigNumber, BigNumber":function(b,A,d){return u(v(b,A,d))},"BigNumber, BigNumber, boolean":function(b,A,d){var w=b.constructor;return u(d?p(b,A,new w(1)):v(b,A,new w(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(b,A,d,w){return u(w?p(b,A,d):v(b,A,d))}});function u(y){return t.matrix==="Matrix"?a?a(y):jf():y}function o(y,b){var A=h(y);if(!A)throw new SyntaxError('String "'+y+'" is no valid range');var d;return t.number==="BigNumber"?(n===void 0&&ls(),d=b?p:v,u(d(n(A.start),n(A.end),n(A.step)))):(d=b?m:c,u(d(A.start,A.end,A.step)))}function c(y,b,A){var d=[],w=y;if(A>0)for(;i(w,b);)d.push(w),w+=A;else if(A<0)for(;f(w,b);)d.push(w),w+=A;return d}function m(y,b,A){var d=[],w=y;if(A>0)for(;s(w,b);)d.push(w),w+=A;else if(A<0)for(;l(w,b);)d.push(w),w+=A;return d}function v(y,b,A){var d=n(0),w=[],x=y;if(A.gt(d))for(;i(x,b);)w.push(x),x=x.plus(A);else if(A.lt(d))for(;f(x,b);)w.push(x),x=x.plus(A);return w}function p(y,b,A){var d=n(0),w=[],x=y;if(A.gt(d))for(;s(x,b);)w.push(x),x=x.plus(A);else if(A.lt(d))for(;l(x,b);)w.push(x),x=x.plus(A);return w}function h(y){var b=y.split(":"),A=b.map(function(w){return Number(w)}),d=A.some(function(w){return isNaN(w)});if(d)return null;switch(A.length){case 2:return{start:A[0],end:A[1],step:1};case 3:return{start:A[0],end:A[2],step:A[1]};default:return null}}}),tm="reshape",vw=["typed","isInteger","matrix"],pw=R(tm,vw,r=>{var{typed:e,isInteger:t}=r;return e(tm,{"Matrix, Array":function(n,i){return n.reshape(i)},"Array, Array":function(n,i){return i.forEach(function(s){if(!t(s))throw new TypeError("Invalid size for dimension: "+s)}),ll(n,i)}})});function ra(r,e,t,a){if(!(this instanceof ra))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}ra.prototype=new Error,ra.prototype.constructor=Error,ra.prototype.name="ArgumentsError",ra.prototype.isArgumentsError=!0;var hw="resize",dw=["config","matrix"],gw=R(hw,dw,r=>{var{config:e,matrix:t}=r;return function(i,s,f){if(arguments.length!==2&&arguments.length!==3)throw new ra("resize",arguments.length,2,3);if(He(s)&&(s=s.valueOf()),rr(s[0])&&(s=s.map(function(o){return rr(o)?o.toNumber():o})),He(i))return i.resize(s,f,!0);if(typeof i=="string")return a(i,s,f);var l=Array.isArray(i)?!1:e.matrix!=="Array";if(s.length===0){for(;Array.isArray(i);)i=i[0];return ke(i)}else{Array.isArray(i)||(i=[i]),i=ke(i);var u=Gn(i,s,f);return l?t(u):u}};function a(n,i,s){if(s!==void 0){if(typeof s!="string"||s.length!==1)throw new TypeError("Single character expected as defaultValue")}else s=" ";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,o=f-n.length;u<o;u++)l+=s;return l}else return n}}),nm="rotate",yw=["typed","multiply","rotationMatrix"],bw=R(nm,yw,r=>{var{typed:e,multiply:t,rotationMatrix:a}=r;return e(nm,{"Array , number | BigNumber | Complex | Unit":function(s,f){n(s,2);var l=t(a(f),s);return l.toArray()},"Matrix , number | BigNumber | Complex | Unit":function(s,f){return n(s,2),t(a(f),s)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(s,f,l){n(s,3);var u=t(a(f,l),s);return u},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(s,f,l){return n(s,3),t(a(f,l),s)}});function n(i,s){var f=Array.isArray(i)?er(i):i.size();if(f.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(s));if(f.length===2&&f[1]!==1)throw new RangeError("Vector must be of dimensions 1x".concat(s));if(f[0]!==s)throw new RangeError("Vector must be of dimensions 1x".concat(s))}}),am="rotationMatrix",xw=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],ww=R(am,xw,r=>{var{typed:e,config:t,multiplyScalar:a,addScalar:n,unaryMinus:i,norm:s,BigNumber:f,matrix:l,DenseMatrix:u,SparseMatrix:o,cos:c,sin:m}=r;return e(am,{"":function(){return t.matrix==="Matrix"?l([]):[]},string:function(d){return l(d)},"number | BigNumber | Complex | Unit":function(d){return v(d,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(d,w){return v(d,w)},"number | BigNumber | Complex | Unit, Array":function(d,w){var x=l(w);return p(x),b(d,x,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(d,w){p(w);var x=w.storage()||(t.matrix==="Matrix"?"dense":void 0);return b(d,w,x)},"number | BigNumber | Complex | Unit, Array, string":function(d,w,x){var g=l(w);return p(g),b(d,g,x)},"number | BigNumber | Complex | Unit, Matrix, string":function(d,w,x){return p(w),b(d,w,x)}});function v(A,d){var w=rr(A),x=w?new f(-1):-1,g=c(A),E=m(A),N=[[g,a(x,E)],[E,g]];return y(N,d)}function p(A){var d=A.size();if(d.length<1||d[0]!==3)throw new RangeError("Vector must be of dimensions 1x3")}function h(A){return A.reduce((d,w)=>a(d,w))}function y(A,d){if(d){if(d==="sparse")return new o(A);if(d==="dense")return new u(A);throw new TypeError('Unknown matrix type "'.concat(d,'"'))}return A}function b(A,d,w){var x=s(d);if(x===0)throw new RangeError("Rotation around zero vector");var g=rr(A)?f:null,E=g?new g(1):1,N=g?new g(-1):-1,S=g?new g(d.get([0])/x):d.get([0])/x,D=g?new g(d.get([1])/x):d.get([1])/x,T=g?new g(d.get([2])/x):d.get([2])/x,B=c(A),_=n(E,i(B)),L=m(A),G=n(B,h([S,S,_])),C=n(h([S,D,_]),h([N,T,L])),F=n(h([S,T,_]),h([D,L])),Z=n(h([S,D,_]),h([T,L])),$=n(B,h([D,D,_])),U=n(h([D,T,_]),h([N,S,L])),Y=n(h([S,T,_]),h([N,D,L])),j=n(h([D,T,_]),h([S,L])),P=n(B,h([T,T,_])),K=[[G,C,F],[Z,$,U],[Y,j,P]];return y(K,w)}}),im="row",Nw=["typed","Index","matrix","range"],om=R(im,Nw,r=>{var{typed:e,Index:t,matrix:a,range:n}=r;return e(im,{"Matrix, number":i,"Array, number":function(f,l){return i(a(ke(f)),l).valueOf()}});function i(s,f){if(s.size().length!==2)throw new Error("Only two dimensional matrix is supported");mr(f,s.size()[0]);var l=n(0,s.size()[1]),u=new t(f,l);return s.subset(u)}}),sm="size",Dw=["typed","config","?matrix"],Aw=R(sm,Dw,r=>{var{typed:e,config:t,matrix:a}=r;return e(sm,{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([]):jf()}})}),um="squeeze",Ew=["typed","matrix"],Sw=R(um,Ew,r=>{var{typed:e,matrix:t}=r;return e(um,{Array:function(n){return li(ke(n))},Matrix:function(n){var i=li(n.toArray());return Array.isArray(i)?t(i):i},any:function(n){return ke(n)}})}),lm="subset",Cw=["typed","matrix"],cm=R(lm,Cw,r=>{var{typed:e,matrix:t}=r;return e(lm,{"Array, Index":function(n,i){var s=t(n),f=s.subset(i);return i.isScalar()?f:f.valueOf()},"Matrix, Index":function(n,i){return n.subset(i)},"Object, Index":Fw,"string, Index":Mw,"Array, Index, any":function(n,i,s){return t(ke(n)).subset(i,s,void 0).valueOf()},"Array, Index, any, any":function(n,i,s,f){return t(ke(n)).subset(i,s,f).valueOf()},"Matrix, Index, any":function(n,i,s){return n.clone().subset(i,s)},"Matrix, Index, any, any":function(n,i,s,f){return n.clone().subset(i,s,f)},"string, Index, string":fm,"string, Index, string, string":fm,"Object, Index, any":Tw})});function Mw(r,e){if(!ai(e))throw new TypeError("Index expected");if(e.size().length!==1)throw new Ke(e.size().length,1);var t=r.length;mr(e.min()[0],t),mr(e.max()[0],t);var a=e.dimension(0),n="";return a.forEach(function(i){n+=r.charAt(i)}),n}function fm(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 s=r.length;mr(e.min()[0]),mr(e.max()[0]);for(var f=[],l=0;l<s;l++)f[l]=r.charAt(l);if(n.forEach(function(c,m){f[c]=t.charAt(m[0])}),f.length>s)for(var u=s-1,o=f.length;u<o;u++)f[u]||(f[u]=a);return f.join("")}function Fw(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 ot(r,t)}function Tw(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=ke(r);return Zn(n,a,t),n}var mm="transpose",Bw=["typed","matrix"],$w=R(mm,Bw,r=>{var{typed:e,matrix:t}=r;return e(mm,{Array:s=>a(t(s)).valueOf(),Matrix:a,any:ke});function a(s){var f=s.size(),l;switch(f.length){case 1:l=s.clone();break;case 2:{var u=f[0],o=f[1];if(o===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+Ye(f)+")");switch(s.storage()){case"dense":l=n(s,u,o);break;case"sparse":l=i(s,u,o);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+Ye(f)+")")}return l}function n(s,f,l){for(var u=s._data,o=[],c,m=0;m<l;m++){c=o[m]=[];for(var v=0;v<f;v++)c[v]=ke(u[v][m])}return s.createDenseMatrix({data:o,size:[l,f],datatype:s._datatype})}function i(s,f,l){for(var u=s._values,o=s._index,c=s._ptr,m=u?[]:void 0,v=[],p=[],h=[],y=0;y<f;y++)h[y]=0;var b,A,d;for(b=0,A=o.length;b<A;b++)h[o[b]]++;for(var w=0,x=0;x<f;x++)p.push(w),w+=h[x],h[x]=p[x];for(p.push(w),d=0;d<l;d++)for(var g=c[d],E=c[d+1],N=g;N<E;N++){var S=h[o[N]]++;v[S]=d,u&&(m[S]=ke(u[N]))}return s.createSparseMatrix({values:m,index:v,ptr:p,size:[l,f],datatype:s._datatype})}}),vm="ctranspose",Ow=["typed","transpose","conj"],_w=R(vm,Ow,r=>{var{typed:e,transpose:t,conj:a}=r;return e(vm,{any:function(i){return a(t(i))}})}),pm="zeros",Iw=["typed","config","matrix","BigNumber"],Rw=R(pm,Iw,r=>{var{typed:e,config:t,matrix:a,BigNumber:n}=r;return e(pm,{"":function(){return t.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(u){var o=u[u.length-1];if(typeof o=="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 o=u.storage();return i(u.valueOf(),o)},"Array | Matrix, string":function(u,o){return i(u.valueOf(),o)}});function i(l,u){var o=s(l),c=o?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?Gn(v,l,c):v}}function s(l){var u=!1;return l.forEach(function(o,c,m){rr(o)&&(u=!0,m[c]=o.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")})}}),hm="fft",qw=["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i"],zw=R(hm,qw,r=>{var{typed:e,matrix:t,addScalar:a,multiplyScalar:n,divideScalar:i,exp:s,tau:f,i:l}=r;return e(hm,{Array:u,Matrix:function(v){return v.create(u(v.toArray()))}});function u(m){var v=er(m);return v.length===1?c(m,v[0]):o(m.map(p=>u(p,v.slice(1))),0)}function o(m,v){var p=er(m);if(v!==0)return new Array(p[0]).fill(0).map((y,b)=>o(m[b],v-1));if(p.length===1)return c(m);function h(y){var b=er(y);return new Array(b[1]).fill(0).map((A,d)=>new Array(b[0]).fill(0).map((w,x)=>y[x][d]))}return h(o(h(m),1))}function c(m){var v=m.length;if(v===1)return[m[0]];if(v%2===0){for(var p=[...c(m.filter((A,d)=>d%2===0)),...c(m.filter((A,d)=>d%2===1))],h=0;h<v/2;h++){var y=p[h],b=n(p[h+v/2],s(n(n(f,l),i(-h,v))));p[h]=a(y,b),p[h+v/2]=a(y,n(-1,b))}return p}throw new Error("Can only calculate FFT of power-of-two size")}}),dm="ifft",Pw=["typed","fft","dotDivide","conj"],Lw=R(dm,Pw,r=>{var{typed:e,fft:t,dotDivide:a,conj:n}=r;return e(dm,{"Array | Matrix":function(s){var f=He(s)?s.size():er(s);return a(n(t(n(s))),f.reduce((l,u)=>l*u,1))}})}),Uw="erf",kw=["typed"],Vw=R(Uw,kw,r=>{var{typed:e}=r;return e("name",{number:function(s){var f=Math.abs(s);return f>=Zw?tn(s):f<=Gw?tn(s)*t(f):f<=4?tn(s)*(1-a(f)):tn(s)*(1-n(f))},"Array | Matrix":e.referToSelf(i=>s=>je(s,i))});function t(i){var s=i*i,f=Zt[0][4]*s,l=s,u;for(u=0;u<3;u+=1)f=(f+Zt[0][u])*s,l=(l+ta[0][u])*s;return i*(f+Zt[0][3])/(l+ta[0][3])}function a(i){var s=Zt[1][8]*i,f=i,l;for(l=0;l<7;l+=1)s=(s+Zt[1][l])*i,f=(f+ta[1][l])*i;var u=(s+Zt[1][7])/(f+ta[1][7]),o=parseInt(i*16)/16,c=(i-o)*(i+o);return Math.exp(-o*o)*Math.exp(-c)*u}function n(i){var s=1/(i*i),f=Zt[2][5]*s,l=s,u;for(u=0;u<4;u+=1)f=(f+Zt[2][u])*s,l=(l+ta[2][u])*s;var o=s*(f+Zt[2][4])/(l+ta[2][4]);o=(Hw-o)/i,s=parseInt(i*16)/16;var c=(i-s)*(i+s);return Math.exp(-s*s)*Math.exp(-c)*o}}),Gw=.46875,Hw=.5641895835477563,Zt=[[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]],Zw=Math.pow(2,53),gm="mode",Jw=["typed","isNaN","isNumeric"],Ww=R(gm,Jw,r=>{var{typed:e,isNaN:t,isNumeric:a}=r;return e(gm,{"Array | Matrix":n,"...":function(s){return n(s)}});function n(i){i=ar(i.valueOf());var s=i.length;if(s===0)throw new Error("Cannot calculate mode of an empty array");for(var f={},l=[],u=0,o=0;o<i.length;o++){var c=i[o];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 Yr(r,e,t){var a;return String(r).indexOf("Unexpected type")!==-1?(a=arguments.length>2?" (type: "+gr(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: "+gr(t)+", value: "+JSON.stringify(t)+")":"",new TypeError("Cannot calculate "+e+", no ordering relation is defined for complex numbers"+a)):r}var ym="prod",Xw=["typed","config","multiplyScalar","numeric"],Yw=R(ym,Xw,r=>{var{typed:e,config:t,multiplyScalar:a,numeric:n}=r;return e(ym,{"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(s){var f;if(Gt(s,function(l){try{f=f===void 0?l:a(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}}),bm="format",Qw=["typed"],Kw=R(bm,Qw,r=>{var{typed:e}=r;return e(bm,{any:Ye,"any, Object | function | number":Ye})}),xm="bin",jw=["typed","format"],eN=R(xm,jw,r=>{var{typed:e,format:t}=r;return e(xm,{"number | BigNumber":function(n){return t(n,{notation:"bin"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"bin",wordSize:i})}})}),wm="oct",rN=["typed","format"],tN=R(wm,rN,r=>{var{typed:e,format:t}=r;return e(wm,{"number | BigNumber":function(n){return t(n,{notation:"oct"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"oct",wordSize:i})}})}),Nm="hex",nN=["typed","format"],aN=R(Nm,nN,r=>{var{typed:e,format:t}=r;return e(Nm,{"number | BigNumber":function(n){return t(n,{notation:"hex"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"hex",wordSize:i})}})}),Dm="print",iN=["typed"],oN=R(Dm,iN,r=>{var{typed:e}=r;return e(Dm,{"string, Object | Array":Am,"string, Object | Array, number | Object":Am})});function Am(r,e,t){return r.replace(/\$([\w.]+)/g,function(a,n){for(var i=n.split("."),s=e[i.shift()];i.length&&s!==void 0;){var f=i.shift();s=f?s[f]:s+"."}return s!==void 0?Wr(s)?s:Ye(s,t):a})}var Em="to",sN=["typed","matrix"],uN=R(Em,sN,r=>{var{typed:e,matrix:t}=r,a=hr({typed:e,matrix:t});return e(Em,{"Unit, Unit | string":(n,i)=>n.to(i)},a({Ds:!0}))}),Sm="isPrime",lN=["typed"],cN=R(Sm,lN,r=>{var{typed:e}=r;return e(Sm,{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 s(A,d,w){for(var x=1;!d.eq(0);)d.mod(2).eq(0)?(d=d.div(2),A=A.mul(A).mod(w)):(d=d.sub(1),x=A.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 o=null;if(a.lt("3317044064679887385961981"))o=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter(A=>A<a);else{var c=Math.min(a.toNumber()-2,Math.floor(2*Math.pow(a.toFixed(0).length*Math.log(10),2)));o=[];for(var m=2;m<=c;m+=1)o.push(c)}for(var v=0;v<o.length;v+=1){var p=o[v],h=s(a.sub(a).add(p),u,a);if(!h.eq(1)){for(var y=0,b=h;!b.eq(a.sub(1));y+=1,b=b.mul(b).mod(a))if(y===l-1)return!1}}return!0},"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),fN="numeric",mN=["number","?bignumber","?fraction"],vN=R(fN,mN,r=>{var{number:e,bignumber:t,fraction:a}=r,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:s=>e(s),BigNumber:t?s=>t(s):ls,Fraction:a?s=>a(s):Kf};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 o=gr(f);if(!(o in n))throw new TypeError("Cannot convert "+f+' of type "'+o+'"; 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===o?f:i[l](f)}}),Cm="divideScalar",pN=["typed","numeric"],hN=R(Cm,pN,r=>{var{typed:e,numeric:t}=r;return e(Cm,{"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)})}),Mm="pow",dN=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],gN=R(Mm,dN,r=>{var{typed:e,config:t,identity:a,multiply:n,matrix:i,inv:s,number:f,fraction:l,Complex:u}=r;return e(Mm,{"number, number":o,"Complex, Complex":function(p,h){return p.pow(h)},"BigNumber, BigNumber":function(p,h){return h.isInteger()||p>=0||t.predictable?p.pow(h):new u(p.toNumber(),0).pow(h.toNumber(),0)},"Fraction, Fraction":function(p,h){var y=p.pow(h);if(y!=null)return y;if(t.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return o(p.valueOf(),h.valueOf())},"Array, number":c,"Array, BigNumber":function(p,h){return c(p,h.toNumber())},"Matrix, number":m,"Matrix, BigNumber":function(p,h){return m(p,h.toNumber())},"Unit, number | BigNumber":function(p,h){return p.pow(h)}});function o(v,p){if(t.predictable&&!qe(p)&&v<0)try{var h=l(p),y=f(h);if((p===y||Math.abs((p-y)/p)<1e-14)&&h.d%2===1)return(h.n%2===0?1:-1)*Math.pow(-v,p)}catch{}return t.predictable&&(v<-1&&p===1/0||v>-1&&v<0&&p===-1/0)?NaN:qe(p)||v>=0||t.predictable?tc(v,p):v*v<1&&p===1/0||v*v>1&&p===-1/0?0:new u(v,0).pow(p,0)}function c(v,p){if(!qe(p))throw new TypeError("For A^b, b must be an integer (value is "+p+")");var h=er(v);if(h.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+h.length+" dimensions)");if(h[0]!==h[1])throw new Error("For A^b, A must be square (size is "+h[0]+"x"+h[1]+")");if(p<0)try{return c(s(v),-p)}catch(A){throw A.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 "+p+")"):A}for(var y=a(h[0]).valueOf(),b=v;p>=1;)(p&1)===1&&(y=n(b,y)),p>>=1,b=n(b,b);return y}function m(v,p){return i(c(v.valueOf(),p))}}),na="Number of decimals in function round must be an integer",Fm="round",yN=["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],bN=R(Fm,yN,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,BigNumber:i,DenseMatrix:s}=r,f=Lr({typed:e,equalScalar:a}),l=Br({typed:e,DenseMatrix:s}),u=yt({typed:e});return e(Fm,{number:nc,"number, number":nc,"number, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(na);return new i(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(o=>c=>je(c,o)),"SparseMatrix, number | BigNumber":e.referToSelf(o=>(c,m)=>f(c,m,o,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(o=>(c,m)=>u(c,m,o,!1)),"Array, number | BigNumber":e.referToSelf(o=>(c,m)=>u(t(c),m,o,!1).valueOf()),"number | Complex | BigNumber | Fraction, SparseMatrix":e.referToSelf(o=>(c,m)=>a(c,0)?n(m.size(),m.storage()):l(m,c,o,!0)),"number | Complex | BigNumber | Fraction, DenseMatrix":e.referToSelf(o=>(c,m)=>a(c,0)?n(m.size(),m.storage()):u(m,c,o,!0)),"number | Complex | BigNumber | Fraction, Array":e.referToSelf(o=>(c,m)=>u(t(m),c,o,!0).valueOf())})}),Tm="log",xN=["config","typed","divideScalar","Complex"],wN=R(Tm,xN,r=>{var{typed:e,config:t,divideScalar:a,Complex:n}=r;return e(Tm,{number:function(s){return s>=0||t.predictable?C1(s):new n(s,0).log()},Complex:function(s){return s.log()},BigNumber:function(s){return!s.isNegative()||t.predictable?s.ln():new n(s.toNumber(),0).log()},"any, any":e.referToSelf(i=>(s,f)=>a(i(s),i(f)))})}),Bm="log1p",NN=["typed","config","divideScalar","log","Complex"],DN=R(Bm,NN,r=>{var{typed:e,config:t,divideScalar:a,log:n,Complex:i}=r;return e(Bm,{number:function(l){return l>=-1||t.predictable?F0(l):s(new i(l,0))},Complex:s,BigNumber:function(l){var u=l.plus(1);return!u.isNegative()||t.predictable?u.ln():s(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 s(f){var l=f.re+1;return new i(Math.log(Math.sqrt(l*l+f.im*f.im)),Math.atan2(f.im,l))}}),$m="nthRoots",AN=["config","typed","divideScalar","Complex"],EN=R($m,AN,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 s(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",o;(u||f.re===0||f.im===0)&&(u?o=2*+(f<0):f.im===0?o=2*+(f.re<0):o=2*+(f.im<0)+1);for(var c=f.arg(),m=f.abs(),v=[],p=Math.pow(m,1/l),h=0;h<l;h++){var y=(o+4*h)/l;if(y===Math.round(y)){v.push(i[y%4](p));continue}v.push(new n({r:p,phi:(c+2*Math.PI*h)/l}))}return v}return e($m,{Complex:function(l){return s(l,2)},"Complex, number":s})}),Om="dotPow",SN=["typed","equalScalar","matrix","pow","DenseMatrix"],CN=R(Om,SN,r=>{var{typed:e,equalScalar:t,matrix:a,pow:n,DenseMatrix:i}=r,s=Xr({typed:e}),f=Mt({typed:e,DenseMatrix:i}),l=Lr({typed:e,equalScalar:t}),u=Br({typed:e,DenseMatrix:i}),o=hr({typed:e,matrix:a}),c={};for(var m in n.signatures)Object.prototype.hasOwnProperty.call(n.signatures,m)&&!m.includes("Matrix")&&!m.includes("Array")&&(c[m]=n.signatures[m]);var v=e(c);return e(Om,o({elop:v,SS:f,DS:s,Ss:l,sS:u}))}),_m="dotDivide",MN=["typed","matrix","equalScalar","divideScalar","DenseMatrix"],FN=R(_m,MN,r=>{var{typed:e,matrix:t,equalScalar:a,divideScalar:n,DenseMatrix:i}=r,s=bt({typed:e,equalScalar:a}),f=Xr({typed:e}),l=Mt({typed:e,DenseMatrix:i}),u=Lr({typed:e,equalScalar:a}),o=Br({typed:e,DenseMatrix:i}),c=hr({typed:e,matrix:t});return e(_m,c({elop:n,SS:l,DS:f,SD:s,Ss:u,sS:o}))});function ka(r){var{DenseMatrix:e}=r;return function(a,n,i){var s=a.size();if(s.length!==2)throw new RangeError("Matrix must be two dimensional (size: "+Ye(s)+")");var f=s[0],l=s[1];if(f!==l)throw new RangeError("Matrix must be square (size: "+Ye(s)+")");var u=[];if(He(n)){var o=n.size(),c=n._data;if(o.length===1){if(o[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(o.length===2){if(o[0]!==f||o[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");if(ni(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(Nn(n)){for(var p=0;p<f;p++)u[p]=[0];for(var h=n._values,y=n._index,b=n._ptr,A=b[1],d=b[0];d<A;d++){var w=y[d];u[w][0]=h[d]}return new e({data:u,size:[f,1],datatype:n._datatype})}}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}if(ur(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 g=0;g<f;g++)u[g]=[n[g]];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 Im="lsolve",TN=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],BN=R(Im,TN,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:s,DenseMatrix:f}=r,l=ka({DenseMatrix:f});return e(Im,{"SparseMatrix, Array | Matrix":function(m,v){return o(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var p=t(m),h=u(p,v);return h.valueOf()}});function u(c,m){m=l(c,m,!0);for(var v=m._data,p=c._size[0],h=c._size[1],y=[],b=c._data,A=0;A<h;A++){var d=v[A][0]||0,w=void 0;if(s(d,0))w=0;else{var x=b[A][A];if(s(x,0))throw new Error("Linear system cannot be solved since matrix is singular");w=a(d,x);for(var g=A+1;g<p;g++)v[g]=[i(v[g][0]||0,n(w,b[g][A]))]}y[A]=[w]}return new f({data:y,size:[p,1]})}function o(c,m){m=l(c,m,!0);for(var v=m._data,p=c._size[0],h=c._size[1],y=c._values,b=c._index,A=c._ptr,d=[],w=0;w<h;w++){var x=v[w][0]||0;if(s(x,0))d[w]=[0];else{for(var g=0,E=[],N=[],S=A[w],D=A[w+1],T=S;T<D;T++){var B=b[T];B===w?g=y[T]:B>w&&(E.push(y[T]),N.push(B))}if(s(g,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var _=a(x,g),L=0,G=N.length;L<G;L++){var C=N[L];v[C]=[i(v[C][0]||0,n(_,E[L]))]}d[w]=[_]}}return new f({data:d,size:[p,1]})}}),Rm="usolve",$N=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],ON=R(Rm,$N,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:s,DenseMatrix:f}=r,l=ka({DenseMatrix:f});return e(Rm,{"SparseMatrix, Array | Matrix":function(m,v){return o(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var p=t(m),h=u(p,v);return h.valueOf()}});function u(c,m){m=l(c,m,!0);for(var v=m._data,p=c._size[0],h=c._size[1],y=[],b=c._data,A=h-1;A>=0;A--){var d=v[A][0]||0,w=void 0;if(s(d,0))w=0;else{var x=b[A][A];if(s(x,0))throw new Error("Linear system cannot be solved since matrix is singular");w=a(d,x);for(var g=A-1;g>=0;g--)v[g]=[i(v[g][0]||0,n(w,b[g][A]))]}y[A]=[w]}return new f({data:y,size:[p,1]})}function o(c,m){m=l(c,m,!0);for(var v=m._data,p=c._size[0],h=c._size[1],y=c._values,b=c._index,A=c._ptr,d=[],w=h-1;w>=0;w--){var x=v[w][0]||0;if(s(x,0))d[w]=[0];else{for(var g=0,E=[],N=[],S=A[w],D=A[w+1],T=D-1;T>=S;T--){var B=b[T];B===w?g=y[T]:B<w&&(E.push(y[T]),N.push(B))}if(s(g,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var _=a(x,g),L=0,G=N.length;L<G;L++){var C=N[L];v[C]=[i(v[C][0],n(_,E[L]))]}d[w]=[_]}}return new f({data:d,size:[p,1]})}}),qm="lsolveAll",_N=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],IN=R(qm,_N,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:s,DenseMatrix:f}=r,l=ka({DenseMatrix:f});return e(qm,{"SparseMatrix, Array | Matrix":function(m,v){return o(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var p=t(m),h=u(p,v);return h.map(y=>y.valueOf())}});function u(c,m){for(var v=[l(c,m,!0)._data.map(N=>N[0])],p=c._data,h=c._size[0],y=c._size[1],b=0;b<y;b++)for(var A=v.length,d=0;d<A;d++){var w=v[d];if(s(p[b][b],0))if(s(w[b],0)){if(d===0){var g=[...w];g[b]=1;for(var E=b+1;E<y;E++)g[E]=i(g[E],p[E][b]);v.push(g)}}else{if(d===0)return[];v.splice(d,1),d-=1,A-=1}else{w[b]=a(w[b],p[b][b]);for(var x=b+1;x<y;x++)w[x]=i(w[x],n(w[b],p[x][b]))}}return v.map(N=>new f({data:N.map(S=>[S]),size:[h,1]}))}function o(c,m){for(var v=[l(c,m,!0)._data.map(Y=>Y[0])],p=c._size[0],h=c._size[1],y=c._values,b=c._index,A=c._ptr,d=0;d<h;d++)for(var w=v.length,x=0;x<w;x++){for(var g=v[x],E=[],N=[],S=A[d],D=A[d+1],T=0,B=S;B<D;B++){var _=b[B];_===d?T=y[B]:_>d&&(E.push(y[B]),N.push(_))}if(s(T,0))if(s(g[d],0)){if(x===0){var F=[...g];F[d]=1;for(var Z=0,$=N.length;Z<$;Z++){var U=N[Z];F[U]=i(F[U],E[Z])}v.push(F)}}else{if(x===0)return[];v.splice(x,1),x-=1,w-=1}else{g[d]=a(g[d],T);for(var L=0,G=N.length;L<G;L++){var C=N[L];g[C]=i(g[C],n(g[d],E[L]))}}}return v.map(Y=>new f({data:Y.map(j=>[j]),size:[p,1]}))}}),zm="usolveAll",RN=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],qN=R(zm,RN,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:s,DenseMatrix:f}=r,l=ka({DenseMatrix:f});return e(zm,{"SparseMatrix, Array | Matrix":function(m,v){return o(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var p=t(m),h=u(p,v);return h.map(y=>y.valueOf())}});function u(c,m){for(var v=[l(c,m,!0)._data.map(N=>N[0])],p=c._data,h=c._size[0],y=c._size[1],b=y-1;b>=0;b--)for(var A=v.length,d=0;d<A;d++){var w=v[d];if(s(p[b][b],0))if(s(w[b],0)){if(d===0){var g=[...w];g[b]=1;for(var E=b-1;E>=0;E--)g[E]=i(g[E],p[E][b]);v.push(g)}}else{if(d===0)return[];v.splice(d,1),d-=1,A-=1}else{w[b]=a(w[b],p[b][b]);for(var x=b-1;x>=0;x--)w[x]=i(w[x],n(w[b],p[x][b]))}}return v.map(N=>new f({data:N.map(S=>[S]),size:[h,1]}))}function o(c,m){for(var v=[l(c,m,!0)._data.map(Y=>Y[0])],p=c._size[0],h=c._size[1],y=c._values,b=c._index,A=c._ptr,d=h-1;d>=0;d--)for(var w=v.length,x=0;x<w;x++){for(var g=v[x],E=[],N=[],S=A[d],D=A[d+1],T=0,B=D-1;B>=S;B--){var _=b[B];_===d?T=y[B]:_<d&&(E.push(y[B]),N.push(_))}if(s(T,0))if(s(g[d],0)){if(x===0){var F=[...g];F[d]=1;for(var Z=0,$=N.length;Z<$;Z++){var U=N[Z];F[U]=i(F[U],E[Z])}v.push(F)}}else{if(x===0)return[];v.splice(x,1),x-=1,w-=1}else{g[d]=a(g[d],T);for(var L=0,G=N.length;L<G;L++){var C=N[L];g[C]=i(g[C],n(g[d],E[L]))}}}return v.map(Y=>new f({data:Y.map(j=>[j]),size:[p,1]}))}}),zN="matAlgo08xS0Sid",PN=["typed","equalScalar"],cs=R(zN,PN,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,s){var f=n._values,l=n._index,u=n._ptr,o=n._size,c=n._datatype,m=i._values,v=i._index,p=i._ptr,h=i._size,y=i._datatype;if(o.length!==h.length)throw new Ke(o.length,h.length);if(o[0]!==h[0]||o[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+h+")");if(!f||!m)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var b=o[0],A=o[1],d,w=t,x=0,g=s;typeof c=="string"&&c===y&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),g=e.find(s,[d,d]));for(var E=[],N=[],S=[],D=[],T=[],B,_,L,G,C=0;C<A;C++){S[C]=N.length;var F=C+1;for(_=u[C],L=u[C+1],B=_;B<L;B++)G=l[B],T[G]=F,D[G]=f[B],N.push(G);for(_=p[C],L=p[C+1],B=_;B<L;B++)G=v[B],T[G]===F&&(D[G]=g(D[G],m[B]));for(B=S[C];B<N.length;){G=N[B];var Z=D[G];w(Z,x)?N.splice(B,1):(E.push(Z),B++)}}return S[A]=N.length,n.createSparseMatrix({values:E,index:N,ptr:S,size:[b,A],datatype:d})}}),fs=R("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())}}),Pm="leftShift",LN=["typed","matrix","equalScalar","zeros","DenseMatrix"],UN=R(Pm,LN,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,DenseMatrix:i}=r,s=cn({typed:e}),f=bt({typed:e,equalScalar:a}),l=cs({typed:e,equalScalar:a}),u=Mn({typed:e,DenseMatrix:i}),o=Lr({typed:e,equalScalar:a}),c=yt({typed:e}),m=hr({typed:e,matrix:t}),v=fs({typed:e,matrix:t});return e(Pm,{"number, number":uc,"BigNumber, BigNumber":fx,"SparseMatrix, number | BigNumber":e.referToSelf(p=>(h,y)=>a(y,0)?h.clone():o(h,y,p,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(p=>(h,y)=>a(y,0)?h.clone():c(h,y,p,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(p=>(h,y)=>a(h,0)?n(y.size(),y.storage()):u(y,h,p,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(p=>(h,y)=>a(h,0)?n(y.size(),y.storage()):c(y,h,p,!0))},v,m({SS:l,DS:s,SD:f}))}),Lm="rightArithShift",kN=["typed","matrix","equalScalar","zeros","DenseMatrix"],VN=R(Lm,kN,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,DenseMatrix:i}=r,s=cn({typed:e}),f=bt({typed:e,equalScalar:a}),l=cs({typed:e,equalScalar:a}),u=Mn({typed:e,DenseMatrix:i}),o=Lr({typed:e,equalScalar:a}),c=yt({typed:e}),m=hr({typed:e,matrix:t}),v=fs({typed:e,matrix:t});return e(Lm,{"number, number":lc,"BigNumber, BigNumber":mx,"SparseMatrix, number | BigNumber":e.referToSelf(p=>(h,y)=>a(y,0)?h.clone():o(h,y,p,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(p=>(h,y)=>a(y,0)?h.clone():c(h,y,p,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(p=>(h,y)=>a(h,0)?n(y.size(),y.storage()):u(y,h,p,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(p=>(h,y)=>a(h,0)?n(y.size(),y.storage()):c(y,h,p,!0))},v,m({SS:l,DS:s,SD:f}))}),Um="rightLogShift",GN=["typed","matrix","equalScalar","zeros","DenseMatrix"],HN=R(Um,GN,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,DenseMatrix:i}=r,s=cn({typed:e}),f=bt({typed:e,equalScalar:a}),l=cs({typed:e,equalScalar:a}),u=Mn({typed:e,DenseMatrix:i}),o=Lr({typed:e,equalScalar:a}),c=yt({typed:e}),m=hr({typed:e,matrix:t}),v=fs({typed:e,matrix:t});return e(Um,{"number, number":cc,"SparseMatrix, number | BigNumber":e.referToSelf(p=>(h,y)=>a(y,0)?h.clone():o(h,y,p,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(p=>(h,y)=>a(y,0)?h.clone():c(h,y,p,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(p=>(h,y)=>a(h,0)?n(y.size(),y.storage()):u(y,h,p,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(p=>(h,y)=>a(h,0)?n(y.size(),y.storage()):c(y,h,p,!0))},v,m({SS:l,DS:s,SD:f}))}),km="and",ZN=["typed","matrix","equalScalar","zeros","not"],JN=R(km,ZN,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,not:i}=r,s=bt({typed:e,equalScalar:a}),f=Mi({typed:e,equalScalar:a}),l=Lr({typed:e,equalScalar:a}),u=yt({typed:e}),o=hr({typed:e,matrix:t});return e(km,{"number, number":hc,"Complex, Complex":function(m,v){return(m.re!==0||m.im!==0)&&(v.re!==0||v.im!==0)},"BigNumber, BigNumber":function(m,v){return!m.isZero()&&!v.isZero()&&!m.isNaN()&&!v.isNaN()},"Unit, Unit":e.referToSelf(c=>(m,v)=>c(m.value||0,v.value||0)),"SparseMatrix, any":e.referToSelf(c=>(m,v)=>i(v)?n(m.size(),m.storage()):l(m,v,c,!1)),"DenseMatrix, any":e.referToSelf(c=>(m,v)=>i(v)?n(m.size(),m.storage()):u(m,v,c,!1)),"any, SparseMatrix":e.referToSelf(c=>(m,v)=>i(m)?n(m.size(),m.storage()):l(v,m,c,!0)),"any, DenseMatrix":e.referToSelf(c=>(m,v)=>i(m)?n(m.size(),m.storage()):u(v,m,c,!0)),"Array, any":e.referToSelf(c=>(m,v)=>c(t(m),v).valueOf()),"any, Array":e.referToSelf(c=>(m,v)=>c(m,t(v)).valueOf())},o({SS:f,DS:s}))}),Bi="compare",WN=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],XN=R(Bi,WN,r=>{var{typed:e,config:t,equalScalar:a,matrix:n,BigNumber:i,Fraction:s,DenseMatrix:f}=r,l=Xr({typed:e}),u=Fi({typed:e,equalScalar:a}),o=Br({typed:e,DenseMatrix:f}),c=hr({typed:e,matrix:n}),m=ea({typed:e});return e(Bi,YN({typed:e,config:t}),{"boolean, boolean":function(p,h){return p===h?0:p>h?1:-1},"BigNumber, BigNumber":function(p,h){return Ct(p,h,t.epsilon)?new i(0):new i(p.cmp(h))},"Fraction, Fraction":function(p,h){return new s(p.compare(h))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},m,c({SS:u,DS:l,Ss:o}))}),YN=R(Bi,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Bi,{"number, number":function(n,i){return et(n,i,t.epsilon)?0:n>i?1:-1}})}),aa=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})/,s=/^0x[0-9a-f]+$/i,f=/^0/,l=function(d){return r.insensitive&&(""+d).toLowerCase()||""+d},u=l(e).replace(n,"")||"",o=l(t).replace(n,"")||"",c=u.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),m=o.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),v=parseInt(u.match(s),16)||c.length!==1&&u.match(i)&&Date.parse(u),p=parseInt(o.match(s),16)||v&&o.match(i)&&Date.parse(o)||null,h,y;if(p){if(v<p)return-1;if(v>p)return 1}for(var b=0,A=Math.max(c.length,m.length);b<A;b++){if(h=!(c[b]||"").match(f)&&parseFloat(c[b])||c[b]||0,y=!(m[b]||"").match(f)&&parseFloat(m[b])||m[b]||0,isNaN(h)!==isNaN(y))return isNaN(h)?1:-1;if(typeof h!=typeof y&&(h+="",y+=""),h<y)return-1;if(h>y)return 1}return 0},Vm="compareNatural",QN=["typed","compare"],KN=R(Vm,QN,r=>{var{typed:e,compare:t}=r,a=t.signatures["boolean,boolean"];return e(Vm,{"any, any":n});function n(l,u){var o=gr(l),c=gr(u),m;if((o==="number"||o==="BigNumber"||o==="Fraction")&&(c==="number"||c==="BigNumber"||c==="Fraction"))return m=t(l,u),m.toString()!=="0"?m>0?1:-1:aa(o,c);var v=["Array","DenseMatrix","SparseMatrix"];if(v.includes(o)||v.includes(c))return m=i(n,l,u),m!==0?m:aa(o,c);if(o!==c)return aa(o,c);if(o==="Complex")return jN(l,u);if(o==="Unit")return l.equalBase(u)?n(l.value,u.value):s(n,l.formatUnits(),u.formatUnits());if(o==="boolean")return a(l,u);if(o==="string")return aa(l,u);if(o==="Object")return f(n,l,u);if(o==="null"||o==="undefined")return 0;throw new TypeError('Unsupported type of value "'+o+'"')}function i(l,u,o){return Nn(u)&&Nn(o)?s(l,u.toJSON().values,o.toJSON().values):Nn(u)?i(l,u.toArray(),o):Nn(o)?i(l,u,o.toArray()):ni(u)?i(l,u.toJSON().data,o):ni(o)?i(l,u,o.toJSON().data):Array.isArray(u)?Array.isArray(o)?s(l,u,o):i(l,u,[o]):i(l,[u],o)}function s(l,u,o){for(var c=0,m=Math.min(u.length,o.length);c<m;c++){var v=l(u[c],o[c]);if(v!==0)return v}return u.length>o.length?1:u.length<o.length?-1:0}function f(l,u,o){var c=Object.keys(u),m=Object.keys(o);c.sort(aa),m.sort(aa);var v=s(l,c,m);if(v!==0)return v;for(var p=0;p<c.length;p++){var h=l(u[c[p]],o[m[p]]);if(h!==0)return h}return 0}});function jN(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 Gm="compareText",e2=["typed","matrix"];Uo.signature="any, any";var r2=R(Gm,e2,r=>{var{typed:e,matrix:t}=r,a=hr({typed:e,matrix:t});return e(Gm,Uo,a({elop:Uo,Ds:!0}))}),$i="equal",t2=["typed","matrix","equalScalar","DenseMatrix"],n2=R($i,t2,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n}=r,i=Xr({typed:e}),s=Mt({typed:e,DenseMatrix:n}),f=Br({typed:e,DenseMatrix:n}),l=hr({typed:e,matrix:t});return e($i,a2({typed:e,equalScalar:a}),l({elop:a,SS:s,DS:i,Ss:f}))}),a2=R($i,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e($i,{"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)}})}),Hm="equalText",i2=["typed","compareText","isZero"],o2=R(Hm,i2,r=>{var{typed:e,compareText:t,isZero:a}=r;return e(Hm,{"any, any":function(i,s){return a(t(i,s))}})}),Oi="smaller",s2=["typed","config","matrix","DenseMatrix"],u2=R(Oi,s2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n}=r,i=Xr({typed:e}),s=Mt({typed:e,DenseMatrix:n}),f=Br({typed:e,DenseMatrix:n}),l=hr({typed:e,matrix:a}),u=ea({typed:e});return e(Oi,l2({typed:e,config:t}),{"boolean, boolean":(o,c)=>o<c,"BigNumber, BigNumber":function(c,m){return c.lt(m)&&!Ct(c,m,t.epsilon)},"Fraction, Fraction":(o,c)=>o.compare(c)===-1,"Complex, Complex":function(c,m){throw new TypeError("No ordering relation is defined for complex numbers")}},u,l({SS:s,DS:i,Ss:f}))}),l2=R(Oi,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Oi,{"number, number":function(n,i){return n<i&&!et(n,i,t.epsilon)}})}),_i="smallerEq",c2=["typed","config","matrix","DenseMatrix"],f2=R(_i,c2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n}=r,i=Xr({typed:e}),s=Mt({typed:e,DenseMatrix:n}),f=Br({typed:e,DenseMatrix:n}),l=hr({typed:e,matrix:a}),u=ea({typed:e});return e(_i,m2({typed:e,config:t}),{"boolean, boolean":(o,c)=>o<=c,"BigNumber, BigNumber":function(c,m){return c.lte(m)||Ct(c,m,t.epsilon)},"Fraction, Fraction":(o,c)=>o.compare(c)!==1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},u,l({SS:s,DS:i,Ss:f}))}),m2=R(_i,["typed","config"],r=>{var{typed:e,config:t}=r;return e(_i,{"number, number":function(n,i){return n<=i||et(n,i,t.epsilon)}})}),Ii="larger",v2=["typed","config","matrix","DenseMatrix"],p2=R(Ii,v2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n}=r,i=Xr({typed:e}),s=Mt({typed:e,DenseMatrix:n}),f=Br({typed:e,DenseMatrix:n}),l=hr({typed:e,matrix:a}),u=ea({typed:e});return e(Ii,h2({typed:e,config:t}),{"boolean, boolean":(o,c)=>o>c,"BigNumber, BigNumber":function(c,m){return c.gt(m)&&!Ct(c,m,t.epsilon)},"Fraction, Fraction":(o,c)=>o.compare(c)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},u,l({SS:s,DS:i,Ss:f}))}),h2=R(Ii,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Ii,{"number, number":function(n,i){return n>i&&!et(n,i,t.epsilon)}})}),Ri="largerEq",d2=["typed","config","matrix","DenseMatrix"],g2=R(Ri,d2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n}=r,i=Xr({typed:e}),s=Mt({typed:e,DenseMatrix:n}),f=Br({typed:e,DenseMatrix:n}),l=hr({typed:e,matrix:a}),u=ea({typed:e});return e(Ri,y2({typed:e,config:t}),{"boolean, boolean":(o,c)=>o>=c,"BigNumber, BigNumber":function(c,m){return c.gte(m)||Ct(c,m,t.epsilon)},"Fraction, Fraction":(o,c)=>o.compare(c)!==-1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},u,l({SS:s,DS:i,Ss:f}))}),y2=R(Ri,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Ri,{"number, number":function(n,i){return n>=i||et(n,i,t.epsilon)}})}),Zm="deepEqual",b2=["typed","equal"],x2=R(Zm,b2,r=>{var{typed:e,equal:t}=r;return e(Zm,{"any, any":function(i,s){return a(i.valueOf(),s.valueOf())}});function a(n,i){if(Array.isArray(n))if(Array.isArray(i)){var s=n.length;if(s!==i.length)return!1;for(var f=0;f<s;f++)if(!a(n[f],i[f]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:t(n,i)}}),qi="unequal",w2=["typed","config","equalScalar","matrix","DenseMatrix"],N2=R(qi,w2,r=>{var{typed:e,config:t,equalScalar:a,matrix:n,DenseMatrix:i}=r,s=Xr({typed:e}),f=Mt({typed:e,DenseMatrix:i}),l=Br({typed:e,DenseMatrix:i}),u=hr({typed:e,matrix:n});return e(qi,D2({typed:e,equalScalar:a}),u({elop:o,SS:f,DS:s,Ss:l}));function o(c,m){return!a(c,m)}}),D2=R(qi,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e(qi,{"any, any":function(n,i){return n===null?i!==null:i===null?n!==null:n===void 0?i!==void 0:i===void 0?n!==void 0:!t(n,i)}})}),Jm="partitionSelect",A2=["typed","isNumeric","isNaN","compare"],E2=R(Jm,A2,r=>{var{typed:e,isNumeric:t,isNaN:a,compare:n}=r,i=n,s=(u,o)=>-n(u,o);return e(Jm,{"Array | Matrix, number":function(o,c){return f(o,c,i)},"Array | Matrix, number, string":function(o,c,m){if(m==="asc")return f(o,c,i);if(m==="desc")return f(o,c,s);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":f});function f(u,o,c){if(!qe(o)||o<0)throw new Error("k must be a non-negative integer");if(He(u)){var m=u.size();if(m.length>1)throw new Error("Only one dimensional matrices supported");return l(u.valueOf(),o,c)}if(Array.isArray(u))return l(u,o,c)}function l(u,o,c){if(o>=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,p=u.length-1;v<p;){for(var h=v,y=p,b=u[Math.floor(Math.random()*(p-v+1))+v];h<y;)if(c(u[h],b)>=0){var A=u[y];u[y]=u[h],u[h]=A,--y}else++h;c(u[h],b)>0&&--h,o<=h?p=h:v=h+1}return u[o]}}),Wm="sort",S2=["typed","matrix","compare","compareNatural"],C2=R(Wm,S2,r=>{var{typed:e,matrix:t,compare:a,compareNatural:n}=r,i=a,s=(o,c)=>-a(o,c);return e(Wm,{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(o){if(o==="asc")return i;if(o==="desc")return s;if(o==="natural")return n;throw new Error('String "asc", "desc", or "natural" expected')}function l(o){if(er(o).length!==1)throw new Error("One dimensional array expected")}function u(o){if(o.size().length!==1)throw new Error("One dimensional matrix expected")}}),Xm="max",M2=["typed","config","numeric","larger"],Ym=R(Xm,M2,r=>{var{typed:e,config:t,numeric:a,larger:n}=r;return e(Xm,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(l,u){return wi(l,u.valueOf(),i)},"...":function(l){if(Qn(l))throw new TypeError("Scalar values expected in function max");return s(l)}});function i(f,l){try{return n(f,l)?f:l}catch(u){throw Yr(u,"max",l)}}function s(f){var l;if(Gt(f,function(u){try{isNaN(u)&&typeof u=="number"?l=NaN:(l===void 0||n(u,l))&&(l=u)}catch(o){throw Yr(o,"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}}),Qm="min",F2=["typed","config","numeric","smaller"],Km=R(Qm,F2,r=>{var{typed:e,config:t,numeric:a,smaller:n}=r;return e(Qm,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(l,u){return wi(l,u.valueOf(),i)},"...":function(l){if(Qn(l))throw new TypeError("Scalar values expected in function min");return s(l)}});function i(f,l){try{return n(f,l)?f:l}catch(u){throw Yr(u,"min",l)}}function s(f){var l;if(Gt(f,function(u){try{isNaN(u)&&typeof u=="number"?l=NaN:(l===void 0||n(u,l))&&(l=u)}catch(o){throw Yr(o,"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}}),T2="ImmutableDenseMatrix",B2=["smaller","DenseMatrix"],$2=R(T2,B2,r=>{var{smaller:e,DenseMatrix:t}=r;function a(n,i){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(i&&!Wr(i))throw new Error("Invalid datatype: "+i);if(He(n)||ur(n)){var s=new t(n,i);this._data=s._data,this._size=s._size,this._datatype=s._datatype,this._min=null,this._max=null}else if(n&&ur(n.data)&&ur(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 ("+gr(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 He(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:ke(this._data),size:ke(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}),O2="Index",_2=["ImmutableDenseMatrix"],I2=R(O2,_2,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,s=arguments.length;i<s;i++){var f=arguments[i];if(Ro(f))this._dimensions.push(f),this._isScalar=!1;else if(Array.isArray(f)||He(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,s=n.length;i<s;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=ke(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,s=this._dimensions.length;i<s;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,s=this._dimensions.length;i<s;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,s=this._dimensions.length;i<s;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,s=this._dimensions.length;i<s;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,s=this._dimensions.length;i<s;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,s=this._dimensions.length;i<s;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}),R2="FibonacciHeap",q2=["smaller","larger"],z2=R(R2,q2,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(o,c){var m={key:o,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(o,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 o=this._minimum;if(o===null)return o;for(var c=this._minimum,m=o.degree,v=o.child;m>0;){var p=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=p,m--}return o.left.right=o.right,o.right.left=o.left,o===o.right?c=null:(c=o.right,c=u(c,this._size)),this._size--,this._minimum=c,o},n.prototype.remove=function(o){this._minimum=i(this._minimum,o,-1),this.extractMinimum()};function i(o,c,m){c.key=m;var v=c.parent;return v&&e(c.key,v.key)&&(s(o,c,v),f(o,v)),e(c.key,o.key)&&(o=c),o}function s(o,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=o,c.right=o.right,o.right=c,c.right.left=c,c.parent=null,c.mark=!1}function f(o,c){var m=c.parent;!m||(c.mark?(s(o,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(o,c){var m=Math.floor(Math.log(c)*a)+1,v=new Array(m),p=0,h=o;if(h)for(p++,h=h.right;h!==o;)p++,h=h.right;for(var y;p>0;){for(var b=h.degree,A=h.right;y=v[b],!!y;){if(t(h.key,y.key)){var d=y;y=h,h=d}l(y,h),v[b]=null,b++}v[b]=h,h=A,p--}o=null;for(var w=0;w<m;w++)y=v[w],y&&(o?(y.left.right=y.right,y.right.left=y.left,y.left=o,y.right=o.right,o.right=y,y.right.left=y,e(y.key,o.key)&&(o=y)):o=y);return o}return n},{isClass:!0}),P2="Spa",L2=["addScalar","equalScalar","FibonacciHeap"],U2=R(P2,L2,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,s){if(this._values[i])this._values[i].value=s;else{var f=this._heap.insert(i,s);this._values[i]=f}},n.prototype.get=function(i){var s=this._values[i];return s?s.value:0},n.prototype.accumulate=function(i,s){var f=this._values[i];f?f.value=e(f.value,s):(f=this._heap.insert(i,s),this._values[i]=f)},n.prototype.forEach=function(i,s,f){var l=this._heap,u=this._values,o=[],c=l.extractMinimum();for(c&&o.push(c);c&&c.key<=s;)c.key>=i&&(t(c.value,0)||f(c.key,c.value,this)),c=l.extractMinimum(),c&&o.push(c);for(var m=0;m<o.length;m++){var v=o[m];c=l.insert(v.key,v.value),u[c.key]=c}},n.prototype.swap=function(i,s){var f=this._values[i],l=this._values[s];if(!f&&l)f=this._heap.insert(i,l.value),this._heap.remove(l),this._values[i]=f,this._values[s]=void 0;else if(f&&!l)l=this._heap.insert(s,f.value),this._heap.remove(f),this._values[s]=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 Ir(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var k2=Pa(function(r){return new r(1).exp()},{hasher:zi}),V2=Pa(function(r){return new r(1).plus(new r(5).sqrt()).div(2)},{hasher:zi}),ms=Pa(function(r){return r.acos(-1)},{hasher:zi}),G2=Pa(function(r){return ms(r).times(2)},{hasher:zi});function zi(r){return r[0].precision}function jm(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 vs(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?jm(Object(t),!0).forEach(function(a){Ir(r,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):jm(Object(t)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(t,a))})}return r}var H2="Unit",Z2=["?on","config","addScalar","subtract","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","number","Complex","BigNumber","Fraction"],J2=R(H2,Z2,r=>{var{on:e,config:t,addScalar:a,subtract:n,multiplyScalar:i,divideScalar:s,pow:f,abs:l,fix:u,round:o,equal:c,isNumeric:m,format:v,number:p,Complex:h,BigNumber:y,Fraction:b}=r,A=p;function d(k,W){if(!(this instanceof d))throw new Error("Constructor must be called with the new operator");if(!(k==null||m(k)||zt(k)))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=Z.map(V=>0);else if(typeof W=="string"){var ie=d.parse(W);this.units=ie.units,this.dimensions=ie.dimensions}else if(Pt(W)&&W.value===null)this.fixPrefix=W.fixPrefix,this.skipAutomaticSimplification=W.skipAutomaticSimplification,this.dimensions=W.dimensions.slice(0),this.units=W.units.map(V=>Ar({},V));else throw new TypeError("Second parameter in Unit constructor must be a string or valueless Unit");this.value=this._normalize(k)}Object.defineProperty(d,"name",{value:"Unit"}),d.prototype.constructor=d,d.prototype.type="Unit",d.prototype.isUnit=!0;var w,x,g;function E(){for(;g===" "||g===" ";)D()}function N(k){return k>="0"&&k<="9"||k==="."}function S(k){return k>="0"&&k<="9"}function D(){x++,g=w.charAt(x)}function T(k){x=k,g=w.charAt(x)}function B(){var k="",W=x;if(g==="+"?D():g==="-"&&(k+=g,D()),!N(g))return T(W),null;if(g==="."){if(k+=g,D(),!S(g))return T(W),null}else{for(;S(g);)k+=g,D();g==="."&&(k+=g,D())}for(;S(g);)k+=g,D();if(g==="E"||g==="e"){var ie="",V=x;if(ie+=g,D(),(g==="+"||g==="-")&&(ie+=g,D()),!S(g))return T(V),k;for(k=k+ie;S(g);)k+=g,D()}return k}function _(){for(var k="";S(g)||d.isValidAlpha(g);)k+=g,D();var W=k.charAt(0);return d.isValidAlpha(W)?k:null}function L(k){return g===k?(D(),k):null}d.parse=function(k,W){if(W=W||{},w=k,x=-1,g="",typeof w!="string")throw new TypeError("Invalid argument in Unit.parse, string expected");var ie=new d;ie.units=[];var V=1,Q=!1;D(),E();var te=B(),ge=null;if(te){if(t.number==="BigNumber")ge=new y(te);else if(t.number==="Fraction")try{ge=new b(te)}catch{ge=parseFloat(te)}else ge=parseFloat(te);E(),L("*")?(V=1,Q=!0):L("/")&&(V=-1,Q=!0)}for(var he=[],q=1;;){for(E();g==="(";)he.push(V),q*=V,V=1,D(),E();var z=void 0;if(g){var ee=g;if(z=_(),z===null)throw new SyntaxError('Unexpected "'+ee+'" in "'+w+'" at index '+x.toString())}else break;var ue=G(z);if(ue===null)throw new SyntaxError('Unit "'+z+'" not found.');var me=V*q;if(E(),L("^")){E();var ye=B();if(ye===null)throw new SyntaxError('In "'+k+'", "^" must be followed by a floating-point number');me*=ye}ie.units.push({unit:ue.unit,prefix:ue.prefix,power:me});for(var be=0;be<Z.length;be++)ie.dimensions[be]+=(ue.unit.dimensions[be]||0)*me;for(E();g===")";){if(he.length===0)throw new SyntaxError('Unmatched ")" in "'+w+'" at index '+x.toString());q/=he.pop(),D(),E()}if(Q=!1,L("*")?(V=1,Q=!0):L("/")?(V=-1,Q=!0):V=1,ue.unit.base){var ve=ue.unit.base.key;re.auto[ve]={unit:ue.unit,prefix:ue.prefix}}}if(E(),g)throw new SyntaxError('Could not parse: "'+k+'"');if(Q)throw new SyntaxError('Trailing characters: "'+k+'"');if(he.length!==0)throw new SyntaxError('Unmatched "(" in "'+w+'"');if(ie.units.length===0&&!W.allowNoUnits)throw new SyntaxError('"'+k+'" contains no units');return ie.value=ge!==void 0?ie._normalize(ge):null,ie},d.prototype.clone=function(){var k=new d;k.fixPrefix=this.fixPrefix,k.skipAutomaticSimplification=this.skipAutomaticSimplification,k.value=ke(this.value),k.dimensions=this.dimensions.slice(0),k.units=[];for(var W=0;W<this.units.length;W++){k.units[W]={};for(var ie in this.units[W])Re(this.units[W],ie)&&(k.units[W][ie]=this.units[W][ie])}return k},d.prototype.valueType=function(){return gr(this.value)},d.prototype._isDerived=function(){return this.units.length===0?!1:this.units.length>1||Math.abs(this.units[0].power-1)>1e-15},d.prototype._normalize=function(k){if(k==null||this.units.length===0)return k;for(var W=k,ie=d._getNumberConverter(gr(k)),V=0;V<this.units.length;V++){var Q=ie(this.units[V].unit.value),te=ie(this.units[V].prefix.value),ge=ie(this.units[V].power);W=i(W,f(i(Q,te),ge))}return W},d.prototype._denormalize=function(k,W){if(k==null||this.units.length===0)return k;for(var ie=k,V=d._getNumberConverter(gr(k)),Q=0;Q<this.units.length;Q++){var te=V(this.units[Q].unit.value),ge=V(this.units[Q].prefix.value),he=V(this.units[Q].power);ie=s(ie,f(i(te,ge),he))}return ie};var G=Pa(k=>{if(Re(P,k)){var W=P[k],ie=W.prefixes[""];return{unit:W,prefix:ie}}for(var V in P)if(Re(P,V)&&Z0(k,V)){var Q=P[V],te=k.length-V.length,ge=k.substring(0,te),he=Re(Q.prefixes,ge)?Q.prefixes[ge]:void 0;if(he!==void 0)return{unit:Q,prefix:he}}return null},{hasher:k=>k[0],limit:100});d.isValuelessUnit=function(k){return G(k)!==null},d.prototype.hasBase=function(k){if(typeof k=="string"&&(k=$[k]),!k)return!1;for(var W=0;W<Z.length;W++)if(Math.abs((this.dimensions[W]||0)-(k.dimensions[W]||0))>1e-12)return!1;return!0},d.prototype.equalBase=function(k){for(var W=0;W<Z.length;W++)if(Math.abs((this.dimensions[W]||0)-(k.dimensions[W]||0))>1e-12)return!1;return!0},d.prototype.equals=function(k){return this.equalBase(k)&&c(this.value,k.value)},d.prototype.multiply=function(k){for(var W=this.clone(),ie=Pt(k)?k:new d(k),V=0;V<Z.length;V++)W.dimensions[V]=(this.dimensions[V]||0)+(ie.dimensions[V]||0);for(var Q=0;Q<ie.units.length;Q++){var te=vs({},ie.units[Q]);W.units.push(te)}if(this.value!==null||ie.value!==null){var ge=this.value===null?this._normalize(1):this.value,he=ie.value===null?ie._normalize(1):ie.value;W.value=i(ge,he)}else W.value=null;return Pt(k)&&(W.skipAutomaticSimplification=!1),C(W)},d.prototype.divideInto=function(k){return new d(k).divide(this)},d.prototype.divide=function(k){for(var W=this.clone(),ie=Pt(k)?k:new d(k),V=0;V<Z.length;V++)W.dimensions[V]=(this.dimensions[V]||0)-(ie.dimensions[V]||0);for(var Q=0;Q<ie.units.length;Q++){var te=vs(vs({},ie.units[Q]),{},{power:-ie.units[Q].power});W.units.push(te)}if(this.value!==null||ie.value!==null){var ge=this.value===null?this._normalize(1):this.value,he=ie.value===null?ie._normalize(1):ie.value;W.value=s(ge,he)}else W.value=null;return Pt(k)&&(W.skipAutomaticSimplification=!1),C(W)},d.prototype.pow=function(k){for(var W=this.clone(),ie=0;ie<Z.length;ie++)W.dimensions[ie]=(this.dimensions[ie]||0)*k;for(var V=0;V<W.units.length;V++)W.units[V].power*=k;return W.value!==null?W.value=f(W.value,k):W.value=null,W.skipAutomaticSimplification=!1,C(W)};function C(k){return k.equalBase($.NONE)&&k.value!==null&&!t.predictable?k.value:k}d.prototype.abs=function(){var k=this.clone();if(k.value!==null)if(k._isDerived()||k.units[0].unit.offset===0)k.value=l(k.value);else{var W=k._numberConverter(),ie=W(k.units[0].unit.value),V=W(k.units[0].unit.offset),Q=i(ie,V);k.value=n(l(a(k.value,Q)),Q)}for(var te in k.units)(k.units[te].unit.name==="VA"||k.units[te].unit.name==="VAR")&&(k.units[te].unit=P.W);return k},d.prototype.to=function(k){var W=this.value===null?this._normalize(1):this.value,ie;if(typeof k=="string")ie=d.parse(k);else if(Pt(k))ie=k.clone();else throw new Error("String or Unit expected as parameter");if(!this.equalBase(ie))throw new Error("Units do not match ('".concat(ie.toString(),"' != '").concat(this.toString(),"')"));if(ie.value!==null)throw new Error("Cannot convert to a unit with a value");if(this.value===null||this._isDerived()||this.units[0].unit.offset===ie.units[0].unit.offset)ie.value=ke(W);else{var V=d._getNumberConverter(gr(W)),Q=V(this.units[0].unit.value),te=V(this.units[0].unit.offset),ge=i(Q,te),he=V(ie.units[0].unit.value),q=V(ie.units[0].unit.offset),z=i(he,q);ie.value=n(a(W,ge),z)}return ie.fixPrefix=!0,ie.skipAutomaticSimplification=!0,ie},d.prototype.toNumber=function(k){return A(this.toNumeric(k))},d.prototype.toNumeric=function(k){var W;return k?W=this.to(k):W=this.clone(),W._isDerived()||W.units.length===0?W._denormalize(W.value):W._denormalize(W.value,W.units[0].prefix.value)},d.prototype.toString=function(){return this.format()},d.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.formatUnits(),fixPrefix:this.fixPrefix}},d.fromJSON=function(k){var W=new d(k.value,k.unit);return W.fixPrefix=k.fixPrefix||!1,W},d.prototype.valueOf=d.prototype.toString,d.prototype.simplify=function(){var k=this.clone(),W=[],ie;for(var V in fe)if(Re(fe,V)&&k.hasBase($[V])){ie=V;break}if(ie==="NONE")k.units=[];else{var Q;if(ie&&Re(fe,ie)&&(Q=fe[ie]),Q)k.units=[{unit:Q.unit,prefix:Q.prefix,power:1}];else{for(var te=!1,ge=0;ge<Z.length;ge++){var he=Z[ge];Math.abs(k.dimensions[ge]||0)>1e-12&&(Re(fe,he)?W.push({unit:fe[he].unit,prefix:fe[he].prefix,power:k.dimensions[ge]||0}):te=!0)}W.length<k.units.length&&!te&&(k.units=W)}}return k},d.prototype.toSI=function(){for(var k=this.clone(),W=[],ie=0;ie<Z.length;ie++){var V=Z[ie];if(Math.abs(k.dimensions[ie]||0)>1e-12)if(Re(re.si,V))W.push({unit:re.si[V].unit,prefix:re.si[V].prefix,power:k.dimensions[ie]||0});else throw new Error("Cannot express custom unit "+V+" in SI units")}return k.units=W,k.fixPrefix=!0,k.skipAutomaticSimplification=!0,k},d.prototype.formatUnits=function(){for(var k="",W="",ie=0,V=0,Q=0;Q<this.units.length;Q++)this.units[Q].power>0?(ie++,k+=" "+this.units[Q].prefix.name+this.units[Q].unit.name,Math.abs(this.units[Q].power-1)>1e-15&&(k+="^"+this.units[Q].power)):this.units[Q].power<0&&V++;if(V>0)for(var te=0;te<this.units.length;te++)this.units[te].power<0&&(ie>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));k=k.substr(1),W=W.substr(1),ie>1&&V>0&&(k="("+k+")"),V>1&&ie>0&&(W="("+W+")");var ge=k;return ie>0&&V>0&&(ge+=" / "),ge+=W,ge},d.prototype.format=function(k){var W=this.skipAutomaticSimplification||this.value===null?this.clone():this.simplify(),ie=!1;typeof W.value<"u"&&W.value!==null&&zt(W.value)&&(ie=Math.abs(W.value.re)<1e-14);for(var V in W.units)Re(W.units,V)&&W.units[V].unit&&(W.units[V].unit.name==="VA"&&ie?W.units[V].unit=P.VAR:W.units[V].unit.name==="VAR"&&!ie&&(W.units[V].unit=P.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 Q=W._denormalize(W.value),te=W.value!==null?v(Q,k||{}):"",ge=W.formatUnits();return W.value&&zt(W.value)&&(te="("+te+")"),ge.length>0&&te.length>0&&(te+=" "),te+=ge,te},d.prototype._bestPrefix=function(){if(this.units.length!==1)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var k=this.value!==null?l(this.value):0,W=l(this.units[0].unit.value),ie=this.units[0].prefix;if(k===0)return ie;var V=this.units[0].power,Q=Math.log(k/Math.pow(ie.value*W,V))/Math.LN10-1.2;if(Q>-2.200001&&Q<1.800001)return ie;Q=Math.abs(Q);var te=this.units[0].unit.prefixes;for(var ge in te)if(Re(te,ge)){var he=te[ge];if(he.scientific){var q=Math.abs(Math.log(k/Math.pow(he.value*W,V))/Math.LN10-1.2);(q<Q||q===Q&&he.name.length<ie.name.length)&&(ie=he,Q=q)}}return ie},d.prototype.splitUnit=function(k){for(var W=this.clone(),ie=[],V=0;V<k.length&&(W=W.to(k[V]),V!==k.length-1);V++){var Q=W.toNumeric(),te=o(Q),ge=void 0,he=c(te,Q);he?ge=te:ge=u(W.toNumeric());var q=new d(ge,k[V].toString());ie.push(q),W=n(W,q)}for(var z=0,ee=0;ee<ie.length;ee++)z=a(z,ie[ee].value);return c(z,this.value)&&(W.value=0),ie.push(W),ie};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=Ar({},F.SHORT,F.LONG),F.BINARY_SHORT=Ar({},F.BINARY_SHORT_SI,F.BINARY_SHORT_IEC),F.BINARY_LONG=Ar({},F.BINARY_LONG_SI,F.BINARY_LONG_IEC);var Z=["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 U in $)Re($,U)&&($[U].key=U);var Y={},j={name:"",base:Y,value:1,offset:0,dimensions:Z.map(k=>0)},P={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.NONE,value:1,offset:0},degC:{name:"degC",base:$.TEMPERATURE,prefixes:F.NONE,value:1,offset:273.15},degF:{name:"degF",base:$.TEMPERATURE,prefixes:F.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:$.TEMPERATURE,prefixes:F.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:$.TEMPERATURE,prefixes:F.NONE,value:1,offset:0},celsius:{name:"celsius",base:$.TEMPERATURE,prefixes:F.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:$.TEMPERATURE,prefixes:F.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:$.TEMPERATURE,prefixes:F.NONE,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:h.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}},K={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function ne(k){if(k.number==="BigNumber"){var W=ms(y);P.rad.value=new y(1),P.deg.value=W.div(180),P.grad.value=W.div(200),P.cycle.value=W.times(2),P.arcsec.value=W.div(648e3),P.arcmin.value=W.div(10800)}else P.rad.value=1,P.deg.value=Math.PI/180,P.grad.value=Math.PI/200,P.cycle.value=Math.PI*2,P.arcsec.value=Math.PI/648e3,P.arcmin.value=Math.PI/10800;P.radian.value=P.rad.value,P.degree.value=P.deg.value,P.gradian.value=P.grad.value}ne(t),e&&e("config",function(k,W){k.number!==W.number&&ne(k)});var re={si:{NONE:{unit:j,prefix:F.NONE[""]},LENGTH:{unit:P.m,prefix:F.SHORT[""]},MASS:{unit:P.g,prefix:F.SHORT.k},TIME:{unit:P.s,prefix:F.SHORT[""]},CURRENT:{unit:P.A,prefix:F.SHORT[""]},TEMPERATURE:{unit:P.K,prefix:F.SHORT[""]},LUMINOUS_INTENSITY:{unit:P.cd,prefix:F.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:P.mol,prefix:F.SHORT[""]},ANGLE:{unit:P.rad,prefix:F.SHORT[""]},BIT:{unit:P.bits,prefix:F.SHORT[""]},FORCE:{unit:P.N,prefix:F.SHORT[""]},ENERGY:{unit:P.J,prefix:F.SHORT[""]},POWER:{unit:P.W,prefix:F.SHORT[""]},PRESSURE:{unit:P.Pa,prefix:F.SHORT[""]},ELECTRIC_CHARGE:{unit:P.C,prefix:F.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:P.F,prefix:F.SHORT[""]},ELECTRIC_POTENTIAL:{unit:P.V,prefix:F.SHORT[""]},ELECTRIC_RESISTANCE:{unit:P.ohm,prefix:F.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:P.H,prefix:F.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:P.S,prefix:F.SHORT[""]},MAGNETIC_FLUX:{unit:P.Wb,prefix:F.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:P.T,prefix:F.SHORT[""]},FREQUENCY:{unit:P.Hz,prefix:F.SHORT[""]}}};re.cgs=JSON.parse(JSON.stringify(re.si)),re.cgs.LENGTH={unit:P.m,prefix:F.SHORT.c},re.cgs.MASS={unit:P.g,prefix:F.SHORT[""]},re.cgs.FORCE={unit:P.dyn,prefix:F.SHORT[""]},re.cgs.ENERGY={unit:P.erg,prefix:F.NONE[""]},re.us=JSON.parse(JSON.stringify(re.si)),re.us.LENGTH={unit:P.ft,prefix:F.NONE[""]},re.us.MASS={unit:P.lbm,prefix:F.NONE[""]},re.us.TEMPERATURE={unit:P.degF,prefix:F.NONE[""]},re.us.FORCE={unit:P.lbf,prefix:F.NONE[""]},re.us.ENERGY={unit:P.BTU,prefix:F.BTU[""]},re.us.POWER={unit:P.hp,prefix:F.NONE[""]},re.us.PRESSURE={unit:P.psi,prefix:F.NONE[""]},re.auto=JSON.parse(JSON.stringify(re.si));var fe=re.auto;d.setUnitSystem=function(k){if(Re(re,k))fe=re[k];else throw new Error("Unit system "+k+" does not exist. Choices are: "+Object.keys(re).join(", "))},d.getUnitSystem=function(){for(var k in re)if(Re(re,k)&&re[k]===fe)return k},d.typeConverters={BigNumber:function(W){return new y(W+"")},Fraction:function(W){return new b(W)},Complex:function(W){return W},number:function(W){return W}},d.prototype._numberConverter=function(){var k=d.typeConverters[this.valueType()];if(k)return k;throw new TypeError('Unsupported Unit value type "'+this.valueType()+'"')},d._getNumberConverter=function(k){if(!d.typeConverters[k])throw new TypeError('Unsupported type "'+k+'"');return d.typeConverters[k]};for(var pe in P)if(Re(P,pe)){var ce=P[pe];ce.dimensions=ce.base.dimensions}for(var oe in K)if(Re(K,oe)){var Ce=P[K[oe]],Oe={};for(var Me in Ce)Re(Ce,Me)&&(Oe[Me]=Ce[Me]);Oe.name=oe,P[oe]=Oe}d.isValidAlpha=function(W){return/^[a-zA-Z]$/.test(W)};function $e(k){for(var W=0;W<k.length;W++){if(g=k.charAt(W),W===0&&!d.isValidAlpha(g))throw new Error('Invalid unit name (must begin with alpha character): "'+k+'"');if(W>0&&!(d.isValidAlpha(g)||S(g)))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+k+'"')}}return d.createUnit=function(k,W){if(typeof k!="object")throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(W&&W.override){for(var ie in k)if(Re(k,ie)&&d.deleteUnit(ie),k[ie].aliases)for(var V=0;V<k[ie].aliases.length;V++)d.deleteUnit(k[ie].aliases[V])}var Q;for(var te in k)Re(k,te)&&(Q=d.createUnitSingle(te,k[te]));return Q},d.createUnitSingle=function(k,W){if((typeof W>"u"||W===null)&&(W={}),typeof k!="string")throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");if(Re(P,k))throw new Error('Cannot create unit "'+k+'": a unit with that name already exists');$e(k);var ie=null,V=[],Q=0,te,ge,he;if(W&&W.type==="Unit")ie=W.clone();else if(typeof W=="string")W!==""&&(te=W);else if(typeof W=="object")te=W.definition,ge=W.prefixes,Q=W.offset,he=W.baseName,W.aliases&&(V=W.aliases.valueOf());else throw new TypeError('Cannot create unit "'+k+'" from "'+W.toString()+'": expecting "string" or "Unit" or "Object"');if(V){for(var q=0;q<V.length;q++)if(Re(P,V[q]))throw new Error('Cannot create alias "'+V[q]+'": a unit with that name already exists')}if(te&&typeof te=="string"&&!ie)try{ie=d.parse(te,{allowNoUnits:!0})}catch(cr){throw cr.message='Could not create unit "'+k+'" from "'+te+'": '+cr.message,cr}else te&&te.type==="Unit"&&(ie=te.clone());V=V||[],Q=Q||0,ge&&ge.toUpperCase?ge=F[ge.toUpperCase()]||F.NONE:ge=F.NONE;var z={};if(ie){z={name:k,value:ie.value,dimensions:ie.dimensions.slice(0),prefixes:ge,offset:Q};var ye=!1;for(var be in $)if(Re($,be)){for(var ve=!0,Ne=0;Ne<Z.length;Ne++)if(Math.abs((z.dimensions[Ne]||0)-($[be].dimensions[Ne]||0))>1e-12){ve=!1;break}if(ve){ye=!0,z.base=$[be];break}}if(!ye){he=he||k+"_STUFF";var Ie={dimensions:ie.dimensions.slice(0)};Ie.key=he,$[he]=Ie,fe[he]={unit:z,prefix:F.NONE[""]},z.base=$[he]}}else{if(he=he||k+"_STUFF",Z.indexOf(he)>=0)throw new Error('Cannot create new base unit "'+k+'": a base unit with that name already exists (and cannot be overridden)');Z.push(he);for(var ee in $)Re($,ee)&&($[ee].dimensions[Z.length-1]=0);for(var ue={dimensions:[]},me=0;me<Z.length;me++)ue.dimensions[me]=0;ue.dimensions[Z.length-1]=1,ue.key=he,$[he]=ue,z={name:k,value:1,dimensions:$[he].dimensions.slice(0),prefixes:ge,offset:Q,base:$[he]},fe[he]={unit:z,prefix:F.NONE[""]}}d.UNITS[k]=z;for(var Ge=0;Ge<V.length;Ge++){var Be=V[Ge],lr={};for(var Je in z)Re(z,Je)&&(lr[Je]=z[Je]);lr.name=Be,d.UNITS[Be]=lr}return delete G.cache,new d(null,k)},d.deleteUnit=function(k){delete d.UNITS[k]},d.PREFIXES=F,d.BASE_DIMENSIONS=Z,d.BASE_UNITS=$,d.UNIT_SYSTEMS=re,d.UNITS=P,d},{isClass:!0}),ev="unit",W2=["typed","Unit"],X2=R(ev,W2,r=>{var{typed:e,Unit:t}=r;return e(ev,{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))})}),rv="sparse",Y2=["typed","SparseMatrix"],Q2=R(rv,Y2,r=>{var{typed:e,SparseMatrix:t}=r;return e(rv,{"":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)}})}),tv="createUnit",K2=["typed","Unit"],j2=R(tv,K2,r=>{var{typed:e,Unit:t}=r;return e(tv,{"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,s){var f={};return f[n]=i,t.createUnit(f,s)},"string, Unit | string | Object":function(n,i){var s={};return s[n]=i,t.createUnit(s,{})},string:function(n){var i={};return i[n]={},t.createUnit(i,{})}})}),nv="acos",eD=["typed","config","Complex"],rD=R(nv,eD,r=>{var{typed:e,config:t,Complex:a}=r;return e(nv,{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()}})}),av="acosh",tD=["typed","config","Complex"],nD=R(av,tD,r=>{var{typed:e,config:t,Complex:a}=r;return e(av,{number:function(i){return i>=1||t.predictable?bc(i):i<=-1?new a(Math.log(Math.sqrt(i*i-1)-i),Math.PI):new a(i,0).acosh()},Complex:function(i){return i.acosh()},BigNumber:function(i){return i.acosh()}})}),iv="acot",aD=["typed","BigNumber"],iD=R(iv,aD,r=>{var{typed:e,BigNumber:t}=r;return e(iv,{number:xc,Complex:function(n){return n.acot()},BigNumber:function(n){return new t(1).div(n).atan()}})}),ov="acoth",oD=["typed","config","Complex","BigNumber"],sD=R(ov,oD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(ov,{number:function(s){return s>=1||s<=-1||t.predictable?wc(s):new a(s,0).acoth()},Complex:function(s){return s.acoth()},BigNumber:function(s){return new n(1).div(s).atanh()}})}),sv="acsc",uD=["typed","config","Complex","BigNumber"],lD=R(sv,uD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(sv,{number:function(s){return s<=-1||s>=1||t.predictable?Nc(s):new a(s,0).acsc()},Complex:function(s){return s.acsc()},BigNumber:function(s){return new n(1).div(s).asin()}})}),uv="acsch",cD=["typed","BigNumber"],fD=R(uv,cD,r=>{var{typed:e,BigNumber:t}=r;return e(uv,{number:Dc,Complex:function(n){return n.acsch()},BigNumber:function(n){return new t(1).div(n).asinh()}})}),lv="asec",mD=["typed","config","Complex","BigNumber"],vD=R(lv,mD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(lv,{number:function(s){return s<=-1||s>=1||t.predictable?Ac(s):new a(s,0).asec()},Complex:function(s){return s.asec()},BigNumber:function(s){return new n(1).div(s).acos()}})}),cv="asech",pD=["typed","config","Complex","BigNumber"],hD=R(cv,pD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(cv,{number:function(s){if(s<=1&&s>=-1||t.predictable){var f=1/s;if(f>0||t.predictable)return Ec(s);var l=Math.sqrt(f*f-1);return new a(Math.log(l-f),Math.PI)}return new a(s,0).asech()},Complex:function(s){return s.asech()},BigNumber:function(s){return new n(1).div(s).acosh()}})}),fv="asin",dD=["typed","config","Complex"],gD=R(fv,dD,r=>{var{typed:e,config:t,Complex:a}=r;return e(fv,{number:function(i){return i>=-1&&i<=1||t.predictable?Math.asin(i):new a(i,0).asin()},Complex:function(i){return i.asin()},BigNumber:function(i){return i.asin()}})}),yD="asinh",bD=["typed"],xD=R(yD,bD,r=>{var{typed:e}=r;return e("asinh",{number:Sc,Complex:function(a){return a.asinh()},BigNumber:function(a){return a.asinh()}})}),wD="atan",ND=["typed"],DD=R(wD,ND,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()}})}),mv="atan2",AD=["typed","matrix","equalScalar","BigNumber","DenseMatrix"],ED=R(mv,AD,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n,DenseMatrix:i}=r,s=bt({typed:e,equalScalar:a}),f=Xr({typed:e}),l=Nf({typed:e,equalScalar:a}),u=Lr({typed:e,equalScalar:a}),o=Br({typed:e,DenseMatrix:i}),c=hr({typed:e,matrix:t});return e(mv,{"number, number":Math.atan2,"BigNumber, BigNumber":(m,v)=>n.atan2(m,v)},c({scalar:"number | BigNumber",SS:l,DS:f,SD:s,Ss:u,sS:o}))}),vv="atanh",SD=["typed","config","Complex"],CD=R(vv,SD,r=>{var{typed:e,config:t,Complex:a}=r;return e(vv,{number:function(i){return i<=1&&i>=-1||t.predictable?Cc(i):new a(i,0).atanh()},Complex:function(i){return i.atanh()},BigNumber:function(i){return i.atanh()}})}),ia=R("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)})}}),pv="cos",MD=["typed"],FD=R(pv,MD,r=>{var{typed:e}=r,t=ia({typed:e});return e(pv,{number:Math.cos,"Complex | BigNumber":a=>a.cos()},t)}),hv="cosh",TD=["typed"],BD=R(hv,TD,r=>{var{typed:e}=r;return e(hv,{number:P0,"Complex | BigNumber":t=>t.cosh()})}),dv="cot",$D=["typed","BigNumber"],OD=R(dv,$D,r=>{var{typed:e,BigNumber:t}=r,a=ia({typed:e});return e(dv,{number:Mc,Complex:n=>n.cot(),BigNumber:n=>new t(1).div(n.tan())},a)}),gv="coth",_D=["typed","BigNumber"],ID=R(gv,_D,r=>{var{typed:e,BigNumber:t}=r;return e(gv,{number:Fc,Complex:a=>a.coth(),BigNumber:a=>new t(1).div(a.tanh())})}),yv="csc",RD=["typed","BigNumber"],qD=R(yv,RD,r=>{var{typed:e,BigNumber:t}=r,a=ia({typed:e});return e(yv,{number:Tc,Complex:n=>n.csc(),BigNumber:n=>new t(1).div(n.sin())},a)}),bv="csch",zD=["typed","BigNumber"],PD=R(bv,zD,r=>{var{typed:e,BigNumber:t}=r;return e(bv,{number:Bc,Complex:a=>a.csch(),BigNumber:a=>new t(1).div(a.sinh())})}),xv="sec",LD=["typed","BigNumber"],UD=R(xv,LD,r=>{var{typed:e,BigNumber:t}=r,a=ia({typed:e});return e(xv,{number:$c,Complex:n=>n.sec(),BigNumber:n=>new t(1).div(n.cos())},a)}),wv="sech",kD=["typed","BigNumber"],VD=R(wv,kD,r=>{var{typed:e,BigNumber:t}=r;return e(wv,{number:Oc,Complex:a=>a.sech(),BigNumber:a=>new t(1).div(a.cosh())})}),Nv="sin",GD=["typed"],HD=R(Nv,GD,r=>{var{typed:e}=r,t=ia({typed:e});return e(Nv,{number:Math.sin,"Complex | BigNumber":a=>a.sin()},t)}),Dv="sinh",ZD=["typed"],JD=R(Dv,ZD,r=>{var{typed:e}=r;return e(Dv,{number:_c,"Complex | BigNumber":t=>t.sinh()})}),Av="tan",WD=["typed"],XD=R(Av,WD,r=>{var{typed:e}=r,t=ia({typed:e});return e(Av,{number:Math.tan,"Complex | BigNumber":a=>a.tan()},t)}),YD="tanh",QD=["typed"],KD=R(YD,QD,r=>{var{typed:e}=r;return e("tanh",{number:U0,"Complex | BigNumber":t=>t.tanh()})}),Ev="setCartesian",jD=["typed","size","subset","compareNatural","Index","DenseMatrix"],eA=R(Ev,jD,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:s}=r;return e(Ev,{"Array | Matrix, Array | Matrix":function(l,u){var o=[];if(a(t(l),new i(0))!==0&&a(t(u),new i(0))!==0){var c=ar(Array.isArray(l)?l:l.toArray()).sort(n),m=ar(Array.isArray(u)?u:u.toArray()).sort(n);o=[];for(var v=0;v<c.length;v++)for(var p=0;p<m.length;p++)o.push([c[v],m[p]])}return Array.isArray(l)&&Array.isArray(u)?o:new s(o)}})}),Sv="setDifference",rA=["typed","size","subset","compareNatural","Index","DenseMatrix"],tA=R(Sv,rA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:s}=r;return e(Sv,{"Array | Matrix, Array | Matrix":function(l,u){var o;if(a(t(l),new i(0))===0)o=[];else{if(a(t(u),new i(0))===0)return ar(l.toArray());var c=Hn(ar(Array.isArray(l)?l:l.toArray()).sort(n)),m=Hn(ar(Array.isArray(u)?u:u.toArray()).sort(n));o=[];for(var v,p=0;p<c.length;p++){v=!1;for(var h=0;h<m.length;h++)if(n(c[p].value,m[h].value)===0&&c[p].identifier===m[h].identifier){v=!0;break}v||o.push(c[p])}}return Array.isArray(l)&&Array.isArray(u)?mi(o):new s(mi(o))}})}),Cv="setDistinct",nA=["typed","size","subset","compareNatural","Index","DenseMatrix"],aA=R(Cv,nA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:s}=r;return e(Cv,{"Array | Matrix":function(l){var u;if(a(t(l),new i(0))===0)u=[];else{var o=ar(Array.isArray(l)?l:l.toArray()).sort(n);u=[],u.push(o[0]);for(var c=1;c<o.length;c++)n(o[c],o[c-1])!==0&&u.push(o[c])}return Array.isArray(l)?u:new s(u)}})}),Mv="setIntersect",iA=["typed","size","subset","compareNatural","Index","DenseMatrix"],oA=R(Mv,iA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:s}=r;return e(Mv,{"Array | Matrix, Array | Matrix":function(l,u){var o;if(a(t(l),new i(0))===0||a(t(u),new i(0))===0)o=[];else{var c=Hn(ar(Array.isArray(l)?l:l.toArray()).sort(n)),m=Hn(ar(Array.isArray(u)?u:u.toArray()).sort(n));o=[];for(var v=0;v<c.length;v++)for(var p=0;p<m.length;p++)if(n(c[v].value,m[p].value)===0&&c[v].identifier===m[p].identifier){o.push(c[v]);break}}return Array.isArray(l)&&Array.isArray(u)?mi(o):new s(mi(o))}})}),Fv="setIsSubset",sA=["typed","size","subset","compareNatural","Index"],uA=R(Fv,sA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(Fv,{"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=Hn(ar(Array.isArray(f)?f:f.toArray()).sort(n)),o=Hn(ar(Array.isArray(l)?l:l.toArray()).sort(n)),c,m=0;m<u.length;m++){c=!1;for(var v=0;v<o.length;v++)if(n(u[m].value,o[v].value)===0&&u[m].identifier===o[v].identifier){c=!0;break}if(c===!1)return!1}return!0}})}),Tv="setMultiplicity",lA=["typed","size","subset","compareNatural","Index"],cA=R(Tv,lA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(Tv,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(f,l){if(a(t(l),new i(0))===0)return 0;for(var u=ar(Array.isArray(l)?l:l.toArray()),o=0,c=0;c<u.length;c++)n(u[c],f)===0&&o++;return o}})}),Bv="setPowerset",fA=["typed","size","subset","compareNatural","Index"],mA=R(Bv,fA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(Bv,{"Array | Matrix":function(u){if(a(t(u),new i(0))===0)return[];for(var o=ar(Array.isArray(u)?u:u.toArray()).sort(n),c=[],m=0;m.toString(2).length<=o.length;)c.push(s(o,m.toString(2).split("").reverse())),m++;return f(c)}});function s(l,u){for(var o=[],c=0;c<u.length;c++)u[c]==="1"&&o.push(l[c]);return o}function f(l){for(var u=[],o=l.length-1;o>0;o--)for(var c=0;c<o;c++)l[c].length>l[c+1].length&&(u=l[c],l[c]=l[c+1],l[c+1]=u);return l}}),$v="setSize",vA=["typed","compareNatural"],pA=R($v,vA,r=>{var{typed:e,compareNatural:t}=r;return e($v,{"Array | Matrix":function(n){return Array.isArray(n)?ar(n).length:ar(n.toArray()).length},"Array | Matrix, boolean":function(n,i){if(i===!1||n.length===0)return Array.isArray(n)?ar(n).length:ar(n.toArray()).length;for(var s=ar(Array.isArray(n)?n:n.toArray()).sort(t),f=1,l=1;l<s.length;l++)t(s[l],s[l-1])!==0&&f++;return f}})}),Ov="setSymDifference",hA=["typed","size","concat","subset","setDifference","Index"],dA=R(Ov,hA,r=>{var{typed:e,size:t,concat:a,subset:n,setDifference:i,Index:s}=r;return e(Ov,{"Array | Matrix, Array | Matrix":function(l,u){if(n(t(l),new s(0))===0)return ar(u);if(n(t(u),new s(0))===0)return ar(l);var o=ar(l),c=ar(u);return a(i(o,c),i(c,o))}})}),_v="setUnion",gA=["typed","size","concat","subset","setIntersect","setSymDifference","Index"],yA=R(_v,gA,r=>{var{typed:e,size:t,concat:a,subset:n,setIntersect:i,setSymDifference:s,Index:f}=r;return e(_v,{"Array | Matrix, Array | Matrix":function(u,o){if(n(t(u),new f(0))===0)return ar(o);if(n(t(o),new f(0))===0)return ar(u);var c=ar(u),m=ar(o);return a(s(c,m),i(c,m))}})}),Iv="add",bA=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],xA=R(Iv,bA,r=>{var{typed:e,matrix:t,addScalar:a,equalScalar:n,DenseMatrix:i,SparseMatrix:s}=r,f=cn({typed:e}),l=ss({typed:e,equalScalar:n}),u=Mn({typed:e,DenseMatrix:i}),o=hr({typed:e,matrix:t});return e(Iv,{"any, any":a,"any, any, ...any":e.referToSelf(c=>(m,v,p)=>{for(var h=c(m,v),y=0;y<p.length;y++)h=c(h,p[y]);return h})},o({elop:a,DS:f,SS:l,Ss:u}))}),Rv="hypot",wA=["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],NA=R(Rv,wA,r=>{var{typed:e,abs:t,addScalar:a,divideScalar:n,multiplyScalar:i,sqrt:s,smaller:f,isPositive:l}=r;return e(Rv,{"... number | BigNumber":u,Array:u,Matrix:o=>u(ar(o.toArray()))});function u(o){for(var c=0,m=0,v=0;v<o.length;v++){if(zt(o[v]))throw new TypeError("Unexpected type of argument to hypot");var p=t(o[v]);f(m,p)?(c=i(c,i(n(m,p),n(m,p))),c=a(c,1),m=p):c=a(c,l(p)?i(n(p,m),n(p,m)):p)}return i(m,s(c))}}),qv="norm",DA=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],AA=R(qv,DA,r=>{var{typed:e,abs:t,add:a,pow:n,conj:i,sqrt:s,multiply:f,equalScalar:l,larger:u,smaller:o,matrix:c,ctranspose:m,eigs:v}=r;return e(qv,{number:Math.abs,Complex:function(N){return N.abs()},BigNumber:function(N){return N.abs()},boolean:function(N){return Math.abs(N)},Array:function(N){return g(c(N),2)},Matrix:function(N){return g(N,2)},"Array, number | BigNumber | string":function(N,S){return g(c(N),S)},"Matrix, number | BigNumber | string":function(N,S){return g(N,S)}});function p(E){var N=0;return E.forEach(function(S){var D=t(S);u(D,N)&&(N=D)},!0),N}function h(E){var N;return E.forEach(function(S){var D=t(S);(!N||o(D,N))&&(N=D)},!0),N||0}function y(E,N){if(N===Number.POSITIVE_INFINITY||N==="inf")return p(E);if(N===Number.NEGATIVE_INFINITY||N==="-inf")return h(E);if(N==="fro")return g(E,2);if(typeof N=="number"&&!isNaN(N)){if(!l(N,0)){var S=0;return E.forEach(function(D){S=a(n(t(D),N),S)},!0),n(S,1/N)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}function b(E){var N=0;return E.forEach(function(S,D){N=a(N,f(S,i(S)))}),t(s(N))}function A(E){var N=[],S=0;return E.forEach(function(D,T){var B=T[1],_=a(N[B]||0,t(D));u(_,S)&&(S=_),N[B]=_},!0),S}function d(E){var N=E.size();if(N[0]!==N[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(s(B))}function w(E){var N=[],S=0;return E.forEach(function(D,T){var B=T[0],_=a(N[B]||0,t(D));u(_,S)&&(S=_),N[B]=_},!0),S}function x(E,N){if(N===1)return A(E);if(N===Number.POSITIVE_INFINITY||N==="inf")return w(E);if(N==="fro")return b(E);if(N===2)return d(E);throw new Error("Unsupported parameter value "+N)}function g(E,N){var S=E.size();if(S.length===1)return y(E,N);if(S.length===2){if(S[0]&&S[1])return x(E,N);throw new RangeError("Invalid matrix dimensions")}}}),zv="dot",EA=["typed","addScalar","multiplyScalar","conj","size"],SA=R(zv,EA,r=>{var{typed:e,addScalar:t,multiplyScalar:a,conj:n,size:i}=r;return e(zv,{"Array | DenseMatrix, Array | DenseMatrix":f,"SparseMatrix, SparseMatrix":l});function s(o,c){var m=u(o),v=u(c),p,h;if(m.length===1)p=m[0];else if(m.length===2&&m[1]===1)p=m[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+m.join(", ")+")");if(v.length===1)h=v[0];else if(v.length===2&&v[1]===1)h=v[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+v.join(", ")+")");if(p!==h)throw new RangeError("Vectors must have equal length ("+p+" != "+h+")");if(p===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return p}function f(o,c){var m=s(o,c),v=He(o)?o._data:o,p=He(o)?o._datatype:void 0,h=He(c)?c._data:c,y=He(c)?c._datatype:void 0,b=u(o).length===2,A=u(c).length===2,d=t,w=a;if(p&&y&&p===y&&typeof p=="string"){var x=p;d=e.find(t,[x,x]),w=e.find(a,[x,x])}if(!b&&!A){for(var g=w(n(v[0]),h[0]),E=1;E<m;E++)g=d(g,w(n(v[E]),h[E]));return g}if(!b&&A){for(var N=w(n(v[0]),h[0][0]),S=1;S<m;S++)N=d(N,w(n(v[S]),h[S][0]));return N}if(b&&!A){for(var D=w(n(v[0][0]),h[0]),T=1;T<m;T++)D=d(D,w(n(v[T][0]),h[T]));return D}if(b&&A){for(var B=w(n(v[0][0]),h[0][0]),_=1;_<m;_++)B=d(B,w(n(v[_][0]),h[_][0]));return B}}function l(o,c){s(o,c);for(var m=o._index,v=o._values,p=c._index,h=c._values,y=0,b=t,A=a,d=0,w=0;d<m.length&&w<p.length;){var x=m[d],g=p[w];if(x<g){d++;continue}if(x>g){w++;continue}x===g&&(y=b(y,A(v[d],h[w])),d++,w++)}return y}function u(o){return He(o)?o.size():i(o)}}),CA="trace",MA=["typed","matrix","add"],FA=R(CA,MA,r=>{var{typed:e,matrix:t,add:a}=r;return e("trace",{Array:function(f){return n(t(f))},SparseMatrix:i,DenseMatrix:n,any:ke});function n(s){var f=s._size,l=s._data;switch(f.length){case 1:if(f[0]===1)return ke(l[0]);throw new RangeError("Matrix must be square (size: "+Ye(f)+")");case 2:{var u=f[0],o=f[1];if(u===o){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(s){var f=s._values,l=s._index,u=s._ptr,o=s._size,c=o[0],m=o[1];if(c===m){var v=0;if(f.length>0)for(var p=0;p<m;p++)for(var h=u[p],y=u[p+1],b=h;b<y;b++){var A=l[b];if(A===p){v=a(v,f[b]);break}if(A>p)break}return v}throw new RangeError("Matrix must be square (size: "+Ye(o)+")")}}),Pv="index",TA=["typed","Index"],BA=R(Pv,TA,r=>{var{typed:e,Index:t}=r;return e(Pv,{"...number | string | BigNumber | Range | Array | Matrix":function(n){var i=n.map(function(f){return rr(f)?f.toNumber():Array.isArray(f)||He(f)?f.map(function(l){return rr(l)?l.toNumber():l}):f}),s=new t;return t.apply(s,i),s}})}),Lv=new Set(["end"]),$A="Node",OA=["mathWithTransform"],_A=R($A,OA,r=>{var{mathWithTransform:e}=r;function t(n){for(var i of[...Lv])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,{}),s={},f=null;function l(u){var o=Wn(u);return t(o),i(o,s,f)}return{evaluate:l}}_compile(i,s){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(!or(i))throw new TypeError("Callback function must return a Node");return i}traverse(i){i(this,null,null);function s(f,l){f.forEach(function(u,o,c){l(u,o,c),s(u,l)})}s(this,i)}transform(i){function s(f,l,u){var o=i(f,l,u);return o!==f?o:f.map(s)}return s(this,null,null)}filter(i){var s=[];return this.traverse(function(f,l,u){i(f,l,u)&&s.push(f)}),s}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&&Ra(this,i):!1}toString(i){var s=this._getCustomString(i);return typeof s<"u"?s:this._toString(i)}toJSON(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)}toHTML(i){var s=this._getCustomString(i);return typeof s<"u"?s:this.toHTML(i)}_toString(){throw new Error("_toString not implemented for "+this.type)}toTex(i){var s=this._getCustomString(i);return typeof s<"u"?s: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 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 Uv(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 ot(a,n.getObjectProperty())}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(i){throw Qr(i)}}}var Pi="AccessorNode",IA=["subset","Node"],RA=R(Pi,IA,r=>{var{subset:e,Node:t}=r,a=Uv({subset:e});function n(s){return!(Dn(s)||nt(s)||sr(s)||An(s)||ii(s)||rn(s)||qr(s))}class i extends t{constructor(f,l){if(super(),!or(f))throw new TypeError('Node expected for parameter "object"');if(!Ln(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 Pi}get isAccessorNode(){return!0}_compile(f,l){var u=this.object._compile(f,l),o=this.index._compile(f,l);if(this.index.isObjectProperty()){var c=this.index.getObjectProperty();return function(v,p,h){return ot(u(v,p,h),c)}}else return function(v,p,h){var y=u(v,p,h),b=o(v,p,y);return a(y,b)}}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:Pi,object:this.object,index:this.index}}static fromJSON(f){return new i(f.object,f.index)}}return Ir(i,"name",Pi),i},{isClass:!0,isNode:!0}),Li="ArrayNode",qA=["Node"],zA=R(Li,qA,r=>{var{Node:e}=r;class t extends e{constructor(n){if(super(),this.items=n||[],!Array.isArray(this.items)||!this.items.every(or))throw new TypeError("Array containing Nodes expected")}get type(){return Li}get isArrayNode(){return!0}_compile(n,i){var s=Ut(this.items,function(u){return u._compile(n,i)}),f=n.config.matrix!=="Array";if(f){var l=n.matrix;return function(o,c,m){return l(Ut(s,function(v){return v(o,c,m)}))}}else return function(o,c,m){return Ut(s,function(v){return v(o,c,m)})}}forEach(n){for(var i=0;i<this.items.length;i++){var s=this.items[i];n(s,"items["+i+"]",this)}}map(n){for(var i=[],s=0;s<this.items.length;s++)i[s]=this._ifNode(n(this.items[s],"items["+s+"]",this));return new t(i)}clone(){return new t(this.items.slice(0))}_toString(n){var i=this.items.map(function(s){return s.toString(n)});return"["+i.join(", ")+"]"}toJSON(){return{mathjs:Li,items:this.items}}static fromJSON(n){return new t(n.items)}toHTML(n){var i=this.items.map(function(s){return s.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(s,f){var l=s.some(nt)&&!s.every(nt),u=f||l,o=u?"&":"\\\\",c=s.map(function(m){return m.items?i(m.items,!f):m.toTex(n)}).join(o);return l||!u||u&&!f?"\\begin{bmatrix}"+c+"\\end{bmatrix}":c}return i(this.items,!1)}}return Ir(t,"name",Li),t},{isClass:!0,isNode:!0});function PA(r){var{subset:e,matrix:t}=r;return function(n,i,s){try{if(Array.isArray(n))return t(n).subset(i,s).valueOf();if(n&&typeof n.subset=="function")return n.subset(i,s);if(typeof n=="string")return e(n,i,s);if(typeof n=="object"){if(!i.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return Zn(n,i.getObjectProperty(),s),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 Ui(r,e){if(!e||e!=="auto")return r;for(var t=r;rn(t);)t=t.content;return t}function vr(r,e,t,a){var n=r;e!=="keep"&&(n=r.getContent());for(var i=n.getIdentifier(),s=null,f=0;f<xt.length;f++)if(i in xt[f]){s=f;break}if(i==="OperatorNode:multiply"&&n.implicit&&t!=="show"){var l=Ui(n.args[0],e);!(sr(l)&&a&&a.getIdentifier()==="OperatorNode:divide"&&zo(Ui(a.args[0],e)))&&!(l.getIdentifier()==="OperatorNode:divide"&&zo(Ui(l.args[0],e))&&sr(Ui(l.args[1])))&&(s+=1)}return s}function Va(r,e){var t=r;e!=="keep"&&(t=r.getContent());var a=t.getIdentifier(),n=vr(t,e);if(n===null)return null;var i=xt[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 ps(r,e,t){var a=t!=="keep"?r.getContent():r,n=t!=="keep"?r.getContent():e,i=a.getIdentifier(),s=n.getIdentifier(),f=vr(a,t);if(f===null)return null;var l=xt[f][i];if(Re(l,"associativeWith")&&l.associativeWith instanceof Array){for(var u=0;u<l.associativeWith.length;u++)if(l.associativeWith[u]===s)return!0;return!1}return null}function LA(r){var e="OperatorNode:"+r;for(var t of xt)if(e in t)return t[e].op;return null}var ki="AssignmentNode",UA=["subset","?matrix","Node"],kA=R(ki,UA,r=>{var{subset:e,matrix:t,Node:a}=r,n=Uv({subset:e}),i=PA({subset:e,matrix:t});function s(l,u,o){u||(u="keep");var c=vr(l,u,o),m=vr(l.value,u,o);return u==="all"||m!==null&&m<=c}class f extends a{constructor(u,o,c){if(super(),this.object=u,this.index=c?o:null,this.value=c||o,!qr(u)&&!Dn(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&&!Ln(this.index))throw new TypeError('IndexNode expected as "index"');if(!or(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 ki}get isAssignmentNode(){return!0}_compile(u,o){var c=this.object._compile(u,o),m=this.index?this.index._compile(u,o):null,v=this.value._compile(u,o),p=this.object.name;if(this.index)if(this.index.isObjectProperty()){var h=this.index.getObjectProperty();return function(w,x,g){var E=c(w,x,g),N=v(w,x,g);return Zn(E,h,N),N}}else{if(qr(this.object))return function(w,x,g){var E=c(w,x,g),N=v(w,x,g),S=m(w,x,E);return w.set(p,i(E,S,N)),N};var y=this.object.object._compile(u,o);if(this.object.index.isObjectProperty()){var b=this.object.index.getObjectProperty();return function(w,x,g){var E=y(w,x,g),N=ot(E,b),S=m(w,x,N),D=v(w,x,g);return Zn(E,b,i(N,S,D)),D}}else{var A=this.object.index._compile(u,o);return function(w,x,g){var E=y(w,x,g),N=A(w,x,E),S=n(E,N),D=m(w,x,S),T=v(w,x,g);return i(E,N,i(S,D,T)),T}}}else{if(!qr(this.object))throw new TypeError("SymbolNode expected as object");return function(w,x,g){var E=v(w,x,g);return w.set(p,E),E}}}forEach(u){u(this.object,"object",this),this.index&&u(this.index,"index",this),u(this.value,"value",this)}map(u){var o=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(o,c,m)}clone(){return new f(this.object,this.index,this.value)}_toString(u){var o=this.object.toString(u),c=this.index?this.index.toString(u):"",m=this.value.toString(u);return s(this,u&&u.parenthesis,u&&u.implicit)&&(m="("+m+")"),o+c+" = "+m}toJSON(){return{mathjs:ki,object:this.object,index:this.index,value:this.value}}static fromJSON(u){return new f(u.object,u.index,u.value)}toHTML(u){var o=this.object.toHTML(u),c=this.index?this.index.toHTML(u):"",m=this.value.toHTML(u);return s(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>'),o+c+'<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+m}_toTex(u){var o=this.object.toTex(u),c=this.index?this.index.toTex(u):"",m=this.value.toTex(u);return s(this,u&&u.parenthesis,u&&u.implicit)&&(m="\\left(".concat(m,"\\right)")),o+c+":="+m}}return Ir(f,"name",ki),f},{isClass:!0,isNode:!0}),Vi="BlockNode",VA=["ResultSet","Node"],GA=R(Vi,VA,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(s){var f=s&&s.node,l=s&&s.visible!==void 0?s.visible:!0;if(!or(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 Vi}get isBlockNode(){return!0}_compile(i,s){var f=Ut(this.blocks,function(l){return{evaluate:l.node._compile(i,s),visible:l.visible}});return function(u,o,c){var m=[];return ci(f,function(p){var h=p.evaluate(u,o,c);p.visible&&m.push(h)}),new e(m)}}forEach(i){for(var s=0;s<this.blocks.length;s++)i(this.blocks[s].node,"blocks["+s+"].node",this)}map(i){for(var s=[],f=0;f<this.blocks.length;f++){var l=this.blocks[f],u=this._ifNode(i(l.node,"blocks["+f+"].node",this));s[f]={node:u,visible:l.visible}}return new a(s)}clone(){var i=this.blocks.map(function(s){return{node:s.node,visible:s.visible}});return new a(i)}_toString(i){return this.blocks.map(function(s){return s.node.toString(i)+(s.visible?"":";")}).join(`
30
- `)}toJSON(){return{mathjs:Vi,blocks:this.blocks}}static fromJSON(i){return new a(i.blocks)}toHTML(i){return this.blocks.map(function(s){return s.node.toHTML(i)+(s.visible?"":'<span class="math-separator">;</span>')}).join('<span class="math-separator"><br /></span>')}_toTex(i){return this.blocks.map(function(s){return s.node.toTex(i)+(s.visible?"":";")}).join(`\\;\\;
31
- `)}}return Ir(a,"name",Vi),a},{isClass:!0,isNode:!0}),Gi="ConditionalNode",HA=["Node"],ZA=R(Gi,HA,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(zt(n))return!!(n.re||n.im);if(Pt(n))return!!n.value}if(n==null)return!1;throw new TypeError('Unsupported type of condition "'+gr(n)+'"')}class a extends e{constructor(i,s,f){if(super(),!or(i))throw new TypeError("Parameter condition must be a Node");if(!or(s))throw new TypeError("Parameter trueExpr must be a Node");if(!or(f))throw new TypeError("Parameter falseExpr must be a Node");this.condition=i,this.trueExpr=s,this.falseExpr=f}get type(){return Gi}get isConditionalNode(){return!0}_compile(i,s){var f=this.condition._compile(i,s),l=this.trueExpr._compile(i,s),u=this.falseExpr._compile(i,s);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 s=i&&i.parenthesis?i.parenthesis:"keep",f=vr(this,s,i&&i.implicit),l=this.condition.toString(i),u=vr(this.condition,s,i&&i.implicit);(s==="all"||this.condition.type==="OperatorNode"||u!==null&&u<=f)&&(l="("+l+")");var o=this.trueExpr.toString(i),c=vr(this.trueExpr,s,i&&i.implicit);(s==="all"||this.trueExpr.type==="OperatorNode"||c!==null&&c<=f)&&(o="("+o+")");var m=this.falseExpr.toString(i),v=vr(this.falseExpr,s,i&&i.implicit);return(s==="all"||this.falseExpr.type==="OperatorNode"||v!==null&&v<=f)&&(m="("+m+")"),l+" ? "+o+" : "+m}toJSON(){return{mathjs:Gi,condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}}static fromJSON(i){return new a(i.condition,i.trueExpr,i.falseExpr)}toHTML(i){var s=i&&i.parenthesis?i.parenthesis:"keep",f=vr(this,s,i&&i.implicit),l=this.condition.toHTML(i),u=vr(this.condition,s,i&&i.implicit);(s==="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 o=this.trueExpr.toHTML(i),c=vr(this.trueExpr,s,i&&i.implicit);(s==="all"||this.trueExpr.type==="OperatorNode"||c!==null&&c<=f)&&(o='<span class="math-parenthesis math-round-parenthesis">(</span>'+o+'<span class="math-parenthesis math-round-parenthesis">)</span>');var m=this.falseExpr.toHTML(i),v=vr(this.falseExpr,s,i&&i.implicit);return(s==="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>'+o+'<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 Ir(a,"name",Gi),a},{isClass:!0,isNode:!0}),hs=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},JA={"{":"\\{","}":"\\}","\\":"\\textbackslash{}","#":"\\#",$:"\\$","%":"\\%","&":"\\&","^":"\\textasciicircum{}",_:"\\_","~":"\\textasciitilde{}"},WA={"\u2013":"\\--","\u2014":"\\---"," ":"~"," ":"\\qquad{}","\r\n":"\\newline{}","\n":"\\newline{}"},XA=function(e,t){return hs({},e,t)},YA=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?XA:n,s=String(r),f="",l=i(hs({},JA),a?hs({},WA):{}),u=Object.keys(l),o=function(){var m=!1;u.forEach(function(v,p){m||s.length>=v.length&&s.slice(0,v.length)===v&&(f+=l[u[p]],s=s.slice(v.length,s.length),m=!0)}),m||(f+=s.slice(0,1),s=s.slice(1,s.length))};s;)o();return f};const QA=YA;var ds={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{?}"},ir={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"},kv={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(ir.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(ir.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(ir.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(ir.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(ir.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(ir.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(ir.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(ir.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(ir.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(ir.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(ir.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(ir.bitAnd,"${args[1]}\\right)")},bitNot:{1:ir.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(ir.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(ir.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(ir.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(ir.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(ir.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(ir.and,"${args[1]}\\right)")},not:{1:ir.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(ir.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(ir.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(ir.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(ir.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(ir.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(ir.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(ir.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(ir.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(ir.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(ir.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(ir.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(ir.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(ir.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(ds.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)"}},KA="\\mathrm{${name}}\\left(${args}\\right)",Vv={deg:"^\\circ"};function gs(r){return QA(r,{preserveFormatting:!0})}function Gv(r,e){return e=typeof e>"u"?!1:e,e?Re(Vv,r)?Vv[r]:"\\mathrm{"+gs(r)+"}":Re(ds,r)?ds[r]:gs(r)}var Hi="ConstantNode",jA=["Node"],eE=R(Hi,jA,r=>{var{Node:e}=r;class t extends e{constructor(n){super(),this.value=n}get type(){return Hi}get isConstantNode(){return!0}_compile(n,i){var s=this.value;return function(){return s}}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(gr(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:Hi,value:this.value}}static fromJSON(n){return new t(n.value)}_toTex(n){var i=this._toString(n);switch(gr(this.value)){case"string":return"\\mathtt{"+gs(i)+"}";case"number":case"BigNumber":{if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var s=i.toLowerCase().indexOf("e");if(s!==-1)return i.substring(0,s)+"\\cdot10^{"+i.substring(s+1)+"}"}return i;case"Fraction":return this.value.toLatex();default:return i}}}return Ir(t,"name",Hi),t},{isClass:!0,isNode:!0}),Zi="FunctionAssignmentNode",rE=["typed","Node"],tE=R(Zi,rE,r=>{var{typed:e,Node:t}=r;function a(i,s,f){var l=vr(i,s,f),u=vr(i.expr,s,f);return s==="all"||u!==null&&u<=l}class n extends t{constructor(s,f,l){if(super(),typeof s!="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(!or(l))throw new TypeError('Node expected for parameter "expr"');if(Lv.has(s))throw new Error('Illegal function name, "'+s+'" is a reserved keyword');var u=new Set;for(var o of f){var c=typeof o=="string"?o:o.name;if(u.has(c))throw new Error('Duplicate parameter name "'.concat(c,'"'));u.add(c)}this.name=s,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 Zi}get isFunctionAssignmentNode(){return!0}_compile(s,f){var l=Object.create(f);ci(this.params,function(p){l[p]=!0});var u=this.expr._compile(s,l),o=this.name,c=this.params,m=hl(this.types,","),v=o+"("+hl(this.params,", ")+")";return function(h,y,b){var A={};A[m]=function(){for(var w=Object.create(y),x=0;x<c.length;x++)w[c[x]]=arguments[x];return u(h,w,b)};var d=e(o,A);return d.syntax=v,h.set(o,d),d}}forEach(s){s(this.expr,"expr",this)}map(s){var f=this._ifNode(s(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(s){var f=s&&s.parenthesis?s.parenthesis:"keep",l=this.expr.toString(s);return a(this,f,s&&s.implicit)&&(l="("+l+")"),this.name+"("+this.params.join(", ")+") = "+l}toJSON(){var s=this.types;return{mathjs:Zi,name:this.name,params:this.params.map(function(f,l){return{name:f,type:s[l]}}),expr:this.expr}}static fromJSON(s){return new n(s.name,s.params,s.expr)}toHTML(s){for(var f=s&&s.parenthesis?s.parenthesis:"keep",l=[],u=0;u<this.params.length;u++)l.push('<span class="math-symbol math-parameter">'+it(this.params[u])+"</span>");var o=this.expr.toHTML(s);return a(this,f,s&&s.implicit)&&(o='<span class="math-parenthesis math-round-parenthesis">(</span>'+o+'<span class="math-parenthesis math-round-parenthesis">)</span>'),'<span class="math-function">'+it(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>'+o}_toTex(s){var f=s&&s.parenthesis?s.parenthesis:"keep",l=this.expr.toTex(s);return a(this,f,s&&s.implicit)&&(l="\\left(".concat(l,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(Gv).join(",")+"\\right):="+l}}return Ir(n,"name",Zi),n},{isClass:!0,isNode:!0}),Ji="IndexNode",nE=["Node","size"],aE=R(Ji,nE,r=>{var{Node:e,size:t}=r;class a extends e{constructor(i,s){if(super(),this.dimensions=i,this.dotNotation=s||!1,!Array.isArray(i)||!i.every(or))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,s){var f=Ut(this.dimensions,function(u,o){var c=u.filter(p=>p.isSymbolNode&&p.name==="end").length>0;if(c){var m=Object.create(s);m.end=!0;var v=u._compile(i,m);return function(h,y,b){if(!He(b)&&!ur(b)&&!Wr(b))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+gr(b));var A=t(b).valueOf(),d=Object.create(y);return d.end=A[o],v(h,d,b)}}else return u._compile(i,s)}),l=ot(i,"index");return function(o,c,m){var v=Ut(f,function(p){return p(o,c,m)});return l(...v)}}forEach(i){for(var s=0;s<this.dimensions.length;s++)i(this.dimensions[s],"dimensions["+s+"]",this)}map(i){for(var s=[],f=0;f<this.dimensions.length;f++)s[f]=this._ifNode(i(this.dimensions[f],"dimensions["+f+"]",this));return new a(s,this.dotNotation)}clone(){return new a(this.dimensions.slice(0),this.dotNotation)}isObjectProperty(){return this.dimensions.length===1&&sr(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 s=[],f=0;f<this.dimensions.length;f++)s[f]=this.dimensions[f].toHTML();return this.dotNotation?'<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">'+it(this.getObjectProperty())+"</span>":'<span class="math-parenthesis math-square-parenthesis">[</span>'+s.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(i){var s=this.dimensions.map(function(f){return f.toTex(i)});return this.dotNotation?"."+this.getObjectProperty():"_{"+s.join(",")+"}"}}return Ir(a,"name",Ji),a},{isClass:!0,isNode:!0}),Wi="ObjectNode",iE=["Node"],oE=R(Wi,iE,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 or(n[i])})))throw new TypeError("Object containing Nodes expected")}get type(){return Wi}get isObjectNode(){return!0}_compile(n,i){var s={};for(var f in this.properties)if(Re(this.properties,f)){var l=ui(f),u=JSON.parse(l);if(!Go(this.properties,u))throw new Error('No access to property "'+u+'"');s[u]=this.properties[f]._compile(n,i)}return function(c,m,v){var p={};for(var h in s)Re(s,h)&&(p[h]=s[h](c,m,v));return p}}forEach(n){for(var i in this.properties)Re(this.properties,i)&&n(this.properties[i],"properties["+ui(i)+"]",this)}map(n){var i={};for(var s in this.properties)Re(this.properties,s)&&(i[s]=this._ifNode(n(this.properties[s],"properties["+ui(s)+"]",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 s in this.properties)Re(this.properties,s)&&i.push(ui(s)+": "+this.properties[s].toString(n));return"{"+i.join(", ")+"}"}toJSON(){return{mathjs:Wi,properties:this.properties}}static fromJSON(n){return new t(n.properties)}toHTML(n){var i=[];for(var s in this.properties)Re(this.properties,s)&&i.push('<span class="math-symbol math-property">'+it(s)+'</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>'+this.properties[s].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 s in this.properties)Re(this.properties,s)&&i.push("\\mathbf{"+s+":} & "+this.properties[s].toTex(n)+"\\\\");var f="\\left\\{\\begin{array}{ll}"+i.join(`
32
- `)+"\\end{array}\\right\\}";return f}}return Ir(t,"name",Wi),t},{isClass:!0,isNode:!0}),Xi="OperatorNode",sE=["Node"],uE=R(Xi,sE,r=>{var{Node:e}=r;function t(i,s){var f=i;if(s==="auto")for(;rn(f);)f=f.content;return sr(f)?!0:_r(f)?t(f.args[0],s):!1}function a(i,s,f,l,u){var o=vr(i,s,f),c=Va(i,s);if(s==="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=vr(l[0],s,f,i);if(u&&v!==null){var p,h;if(s==="keep"?(p=l[0].getIdentifier(),h=i.getIdentifier()):(p=l[0].getContent().getIdentifier(),h=i.getContent().getIdentifier()),xt[o][h].latexLeftParens===!1){m=[!1];break}if(xt[v][p].latexParens===!1){m=[!1];break}}if(v===null){m=[!1];break}if(v<=o){m=[!0];break}m=[!1]}break;case 2:{var y,b=vr(l[0],s,f,i),A=ps(i,l[0],s);b===null?y=!1:b===o&&c==="right"&&!A||b<o?y=!0:y=!1;var d,w=vr(l[1],s,f,i),x=ps(i,l[1],s);if(w===null?d=!1:w===o&&c==="left"&&!x||w<o?d=!0:d=!1,u){var g,E,N;s==="keep"?(g=i.getIdentifier(),E=i.args[0].getIdentifier(),N=i.args[1].getIdentifier()):(g=i.getContent().getIdentifier(),E=i.args[0].getContent().getIdentifier(),N=i.args[1].getContent().getIdentifier()),b!==null&&(xt[o][g].latexLeftParens===!1&&(y=!1),xt[b][E].latexParens===!1&&(y=!1)),w!==null&&(xt[o][g].latexRightParens===!1&&(d=!1),xt[w][N].latexParens===!1&&(d=!1))}m=[y,d]}break;default:(i.getIdentifier()==="OperatorNode:add"||i.getIdentifier()==="OperatorNode:multiply")&&(m=l.map(function(D){var T=vr(D,s,f,i),B=ps(i,D,s),_=Va(D,s);return T===null?!1:o===T&&c===_&&!B?!0:T<o}));break}if(l.length>=2&&i.getIdentifier()==="OperatorNode:multiply"&&i.implicit&&s!=="all"&&f==="hide")for(var S=1;S<m.length;++S)t(l[S],s)&&!m[S-1]&&(s!=="keep"||!rn(l[S-1]))&&(m[S]=!0);return m}class n extends e{constructor(s,f,l,u,o){if(super(),typeof s!="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(or))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=u===!0,this.isPercentage=o===!0,this.op=s,this.fn=f,this.args=l||[]}get type(){return Xi}get isOperatorNode(){return!0}_compile(s,f){if(typeof this.fn!="string"||!Ho(s,this.fn))throw s[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var l=ot(s,this.fn),u=Ut(this.args,function(v){return v._compile(s,f)});if(u.length===1){var o=u[0];return function(p,h,y){return l(o(p,h,y))}}else if(u.length===2){var c=u[0],m=u[1];return function(p,h,y){return l(c(p,h,y),m(p,h,y))}}else return function(p,h,y){return l.apply(null,Ut(u,function(b){return b(p,h,y)}))}}forEach(s){for(var f=0;f<this.args.length;f++)s(this.args[f],"args["+f+"]",this)}map(s){for(var f=[],l=0;l<this.args.length;l++)f[l]=this._ifNode(s(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(s){var f=s&&s.parenthesis?s.parenthesis:"keep",l=s&&s.implicit?s.implicit:"hide",u=this.args,o=a(this,f,l,u,!1);if(u.length===1){var c=Va(this,f),m=u[0].toString(s);o[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 p=u[0].toString(s),h=u[1].toString(s);return o[0]&&(p="("+p+")"),o[1]&&(h="("+h+")"),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?p+" "+h:p+" "+this.op+" "+h}else if(u.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var y=u.map(function(b,A){return b=b.toString(s),o[A]&&(b="("+b+")"),b});return this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?y.join(" "):y.join(" "+this.op+" ")}else return this.fn+"("+this.args.join(", ")+")"}toJSON(){return{mathjs:Xi,op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}}static fromJSON(s){return new n(s.op,s.fn,s.args,s.implicit,s.isPercentage)}toHTML(s){var f=s&&s.parenthesis?s.parenthesis:"keep",l=s&&s.implicit?s.implicit:"hide",u=this.args,o=a(this,f,l,u,!1);if(u.length===1){var c=Va(this,f),m=u[0].toHTML(s);return o[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">'+it(this.op)+"</span>"+m:m+'<span class="math-operator math-unary-operator math-righthand-unary-operator">'+it(this.op)+"</span>"}else if(u.length===2){var v=u[0].toHTML(s),p=u[1].toHTML(s);return o[0]&&(v='<span class="math-parenthesis math-round-parenthesis">(</span>'+v+'<span class="math-parenthesis math-round-parenthesis">)</span>'),o[1]&&(p='<span class="math-parenthesis math-round-parenthesis">(</span>'+p+'<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>'+p:v+'<span class="math-operator math-binary-operator math-explicit-binary-operator">'+it(this.op)+"</span>"+p}else{var h=u.map(function(y,b){return y=y.toHTML(s),o[b]&&(y='<span class="math-parenthesis math-round-parenthesis">(</span>'+y+'<span class="math-parenthesis math-round-parenthesis">)</span>'),y});return u.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")?this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?h.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'):h.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">'+it(this.op)+"</span>"):'<span class="math-function">'+it(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+h.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}}_toTex(s){var f=s&&s.parenthesis?s.parenthesis:"keep",l=s&&s.implicit?s.implicit:"hide",u=this.args,o=a(this,f,l,u,!0),c=ir[this.fn];if(c=typeof c>"u"?this.op:c,u.length===1){var m=Va(this,f),v=u[0].toTex(s);return o[0]&&(v="\\left(".concat(v,"\\right)")),m==="right"?c+v:v+c}else if(u.length===2){var p=u[0],h=p.toTex(s);o[0]&&(h="\\left(".concat(h,"\\right)"));var y=u[1],b=y.toTex(s);o[1]&&(b="\\left(".concat(b,"\\right)"));var A;switch(f==="keep"?A=p.getIdentifier():A=p.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return c+"{"+h+"}{"+b+"}";case"OperatorNode:pow":switch(h="{"+h+"}",b="{"+b+"}",A){case"ConditionalNode":case"OperatorNode:divide":h="\\left(".concat(h,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&l==="hide")return h+"~"+b}return h+c+b}else if(u.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var d=u.map(function(w,x){return w=w.toTex(s),o[x]&&(w="\\left(".concat(w,"\\right)")),w});return this.getIdentifier()==="OperatorNode:multiply"&&this.implicit&&l==="hide"?d.join("~"):d.join(c)}else return"\\mathrm{"+this.fn+"}\\left("+u.map(function(w){return w.toTex(s)}).join(",")+"\\right)"}getIdentifier(){return this.type+":"+this.fn}}return Ir(n,"name",Xi),n},{isClass:!0,isNode:!0}),Yi="ParenthesisNode",lE=["Node"],cE=R(Yi,lE,r=>{var{Node:e}=r;class t extends e{constructor(n){if(super(),!or(n))throw new TypeError('Node expected for parameter "content"');this.content=n}get type(){return Yi}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:Yi,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 Ir(t,"name",Yi),t},{isClass:!0,isNode:!0}),Qi="RangeNode",fE=["Node"],mE=R(Qi,fE,r=>{var{Node:e}=r;function t(n,i,s){var f=vr(n,i,s),l={},u=vr(n.start,i,s);if(l.start=u!==null&&u<=f||i==="all",n.step){var o=vr(n.step,i,s);l.step=o!==null&&o<=f||i==="all"}var c=vr(n.end,i,s);return l.end=c!==null&&c<=f||i==="all",l}class a extends e{constructor(i,s,f){if(super(),!or(i))throw new TypeError("Node expected");if(!or(s))throw new TypeError("Node expected");if(f&&!or(f))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=i,this.end=s,this.step=f||null}get type(){return Qi}get isRangeNode(){return!0}needsEnd(){var i=this.filter(function(s){return qr(s)&&s.name==="end"});return i.length>0}_compile(i,s){var f=i.range,l=this.start._compile(i,s),u=this.end._compile(i,s);if(this.step){var o=this.step._compile(i,s);return function(m,v,p){return f(l(m,v,p),u(m,v,p),o(m,v,p))}}else return function(m,v,p){return f(l(m,v,p),u(m,v,p))}}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 s=i&&i.parenthesis?i.parenthesis:"keep",f=t(this,s,i&&i.implicit),l,u=this.start.toString(i);if(f.start&&(u="("+u+")"),l=u,this.step){var o=this.step.toString(i);f.step&&(o="("+o+")"),l+=":"+o}var c=this.end.toString(i);return f.end&&(c="("+c+")"),l+=":"+c,l}toJSON(){return{mathjs:Qi,start:this.start,end:this.end,step:this.step}}static fromJSON(i){return new a(i.start,i.end,i.step)}toHTML(i){var s=i&&i.parenthesis?i.parenthesis:"keep",f=t(this,s,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 o=this.step.toHTML(i);f.step&&(o='<span class="math-parenthesis math-round-parenthesis">(</span>'+o+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+='<span class="math-operator math-range-operator">:</span>'+o}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 s=i&&i.parenthesis?i.parenthesis:"keep",f=t(this,s,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 o=this.end.toTex(i);return f.end&&(o="\\left(".concat(o,"\\right)")),l+=":"+o,l}}return Ir(a,"name",Qi),a},{isClass:!0,isNode:!0}),Ki="RelationalNode",vE=["Node"],pE=R(Ki,vE,r=>{var{Node:e}=r,t={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="};class a extends e{constructor(i,s){if(super(),!Array.isArray(i))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(s))throw new TypeError("Parameter params must be an array");if(i.length!==s.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=i,this.params=s}get type(){return Ki}get isRelationalNode(){return!0}_compile(i,s){var f=this,l=this.params.map(u=>u._compile(i,s));return function(o,c,m){for(var v,p=l[0](o,c,m),h=0;h<f.conditionals.length;h++){v=p,p=l[h+1](o,c,m);var y=ot(i,f.conditionals[h]);if(!y(v,p))return!1}return!0}}forEach(i){this.params.forEach((s,f)=>i(s,"params["+f+"]",this),this)}map(i){return new a(this.conditionals.slice(),this.params.map((s,f)=>this._ifNode(i(s,"params["+f+"]",this)),this))}clone(){return new a(this.conditionals,this.params)}_toString(i){for(var s=i&&i.parenthesis?i.parenthesis:"keep",f=vr(this,s,i&&i.implicit),l=this.params.map(function(c,m){var v=vr(c,s,i&&i.implicit);return s==="all"||v!==null&&v<=f?"("+c.toString(i)+")":c.toString(i)}),u=l[0],o=0;o<this.conditionals.length;o++)u+=" "+t[this.conditionals[o]],u+=" "+l[o+1];return u}toJSON(){return{mathjs:Ki,conditionals:this.conditionals,params:this.params}}static fromJSON(i){return new a(i.conditionals,i.params)}toHTML(i){for(var s=i&&i.parenthesis?i.parenthesis:"keep",f=vr(this,s,i&&i.implicit),l=this.params.map(function(c,m){var v=vr(c,s,i&&i.implicit);return s==="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],o=0;o<this.conditionals.length;o++)u+='<span class="math-operator math-binary-operator math-explicit-binary-operator">'+it(t[this.conditionals[o]])+"</span>"+l[o+1];return u}_toTex(i){for(var s=i&&i.parenthesis?i.parenthesis:"keep",f=vr(this,s,i&&i.implicit),l=this.params.map(function(c,m){var v=vr(c,s,i&&i.implicit);return s==="all"||v!==null&&v<=f?"\\left("+c.toTex(i)+"\right)":c.toTex(i)}),u=l[0],o=0;o<this.conditionals.length;o++)u+=ir[this.conditionals[o]]+l[o+1];return u}}return Ir(a,"name",Ki),a},{isClass:!0,isNode:!0}),hE="SymbolNode",dE=["math","?Unit","Node"],gE=R(hE,dE,r=>{var{math:e,Unit:t,Node:a}=r;function n(s){return t?t.isValuelessUnit(s):!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):ot(f,u)};var o=n(u);return function(c,m,v){return c.has(u)?c.get(u):o?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=it(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=Gv(this.name,l);return u[0]==="\\"?u:" "+u}}return i},{isClass:!0,isNode:!0});function Ga(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"?gl(r.createSubScope(),...t):gl(Jn(),r,...t)}var ji="FunctionNode",yE=["math","Node","SymbolNode"],bE=R(ji,yE,r=>{var{math:e,Node:t,SymbolNode:a}=r,n=f=>Ye(f,{truncate:78});function i(f,l,u){for(var o="",c=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,m=0,v;(v=c.exec(f))!==null;)if(o+=f.substring(m,v.index),m=v.index,v[0]==="$$")o+="$",m++;else{m+=v[0].length;var p=l[v[1]];if(!p)throw new ReferenceError("Template: Property "+v[1]+" does not exist.");if(v[2]===void 0)switch(typeof p){case"string":o+=p;break;case"object":if(or(p))o+=p.toTex(u);else if(Array.isArray(p))o+=p.map(function(h,y){if(or(h))return h.toTex(u);throw new TypeError("Template: "+v[1]+"["+y+"] 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(or(p[v[2]]&&p[v[2]]))o+=p[v[2]].toTex(u);else throw new TypeError("Template: "+v[1]+"["+v[2]+"] is not a Node.")}return o+=f.slice(m),o}class s extends t{constructor(l,u){if(super(),typeof l=="string"&&(l=new a(l)),!or(l))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(u)||!u.every(or))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 ji}get isFunctionNode(){return!0}_compile(l,u){var o=this.args.map(E=>E._compile(l,u));if(qr(this.fn)){var c=this.fn.name;if(u[c]){var y=this.args;return function(N,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(y,l,Ga(N,S),N);var B=o.map(_=>_(N,S,D));return T.apply(T,B)}}else{var m=c in l?ot(l,c):void 0,v=typeof m=="function"&&m.rawArgs===!0,p=E=>{var N;if(E.has(c))N=E.get(c);else if(c in l)N=ot(l,c);else return s.onUndefinedFunction(c);if(typeof N=="function")return N;throw new TypeError("'".concat(c,`' is not a function; its value is:
33
- `).concat(n(N)))};if(v){var h=this.args;return function(N,S,D){var T=p(N);return T(h,l,Ga(N,S),N)}}else switch(o.length){case 0:return function(N,S,D){var T=p(N);return T()};case 1:return function(N,S,D){var T=p(N),B=o[0];return T(B(N,S,D))};case 2:return function(N,S,D){var T=p(N),B=o[0],_=o[1];return T(B(N,S,D),_(N,S,D))};default:return function(N,S,D){var T=p(N),B=o.map(_=>_(N,S,D));return T(...B)}}}}else if(Dn(this.fn)&&Ln(this.fn.index)&&this.fn.index.isObjectProperty()){var b=this.fn.object._compile(l,u),A=this.fn.index.getObjectProperty(),d=this.args;return function(N,S,D){var T=b(N,S,D);eg(T,A);var B=T[A]&&T[A].rawArgs;if(B)return T[A](d,l,Ga(N,S),N);var _=o.map(L=>L(N,S,D));return T[A].apply(T,_)}}else{var w=this.fn.toString(),x=this.fn._compile(l,u),g=this.args;return function(N,S,D){var T=x(N,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(g,l,Ga(N,S),N);var B=o.map(_=>_(N,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)),o=[],c=0;c<this.args.length;c++)o[c]=this._ifNode(l(this.args[c],"args["+c+"]",this));return new s(u,o)}clone(){return new s(this.fn,this.args.slice(0))}toString(l){var u,o=this.fn.toString(l);return l&&typeof l.handler=="object"&&Re(l.handler,o)&&(u=l.handler[o](this,l)),typeof u<"u"?u:super.toString(l)}_toString(l){var u=this.args.map(function(c){return c.toString(l)}),o=Ia(this.fn)?"("+this.fn.toString(l)+")":this.fn.toString(l);return o+"("+u.join(", ")+")"}toJSON(){return{mathjs:ji,fn:this.fn,args:this.args}}toHTML(l){var u=this.args.map(function(o){return o.toHTML(l)});return'<span class="math-function">'+it(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)}),o;kv[this.name]&&(o=kv[this.name]),e[this.name]&&(typeof e[this.name].toTex=="function"||typeof e[this.name].toTex=="object"||typeof e[this.name].toTex=="string")&&(o=e[this.name].toTex);var c;switch(typeof o){case"function":c=o(this,l);break;case"string":c=i(o,this,l);break;case"object":switch(typeof o[u.length]){case"function":c=o[u.length](this,l);break;case"string":c=i(o[u.length],this,l);break}}return typeof c<"u"?c:i(KA,this,l)}getIdentifier(){return this.type+":"+this.name}}return Ir(s,"name",ji),Ir(s,"onUndefinedFunction",function(f){throw new Error("Undefined function "+f)}),Ir(s,"fromJSON",function(f){return new s(f.fn,f.args)}),s},{isClass:!0,isNode:!0}),Hv="parse",xE=["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],wE=R(Hv,xE,r=>{var{typed:e,numeric:t,config:a,AccessorNode:n,ArrayNode:i,AssignmentNode:s,BlockNode:f,ConditionalNode:l,ConstantNode:u,FunctionAssignmentNode:o,FunctionNode:c,IndexNode:m,ObjectNode:v,OperatorNode:p,ParenthesisNode:h,RangeNode:y,RelationalNode:b,SymbolNode:A}=r,d=e(Hv,{string:function(H){return U(H,{})},"Array | Matrix":function(H){return w(H,{})},"string, Object":function(H,se){var De=se.nodes!==void 0?se.nodes:{};return U(H,De)},"Array | Matrix, Object":w});function w(M){var H=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},se=H.nodes!==void 0?H.nodes:{};return je(M,function(De){if(typeof De!="string")throw new TypeError("String expected");return U(De,se)})}var x={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},g={",":!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},N={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(M,H){return M.expression.substr(M.index,H)}function B(M){return T(M,1)}function _(M){M.index++}function L(M){return M.expression.charAt(M.index-1)}function G(M){return M.expression.charAt(M.index+1)}function C(M){for(M.tokenType=x.NULL,M.token="",M.comment="";;){if(B(M)==="#")for(;B(M)!==`
35
- `&&B(M)!=="";)M.comment+=B(M),_(M);if(d.isWhitespace(B(M),M.nestingLevel))_(M);else break}if(B(M)===""){M.tokenType=x.DELIMITER;return}if(B(M)===`
36
- `&&!M.nestingLevel){M.tokenType=x.DELIMITER,M.token=B(M),_(M);return}var H=B(M),se=T(M,2),De=T(M,3);if(De.length===3&&g[De]){M.tokenType=x.DELIMITER,M.token=De,_(M),_(M),_(M);return}if(se.length===2&&g[se]){M.tokenType=x.DELIMITER,M.token=se,_(M),_(M);return}if(g[H]){M.tokenType=x.DELIMITER,M.token=H,_(M);return}if(d.isDigitDot(H)){M.tokenType=x.NUMBER;var ze=T(M,2);if(ze==="0b"||ze==="0o"||ze==="0x"){for(M.token+=B(M),_(M),M.token+=B(M),_(M);d.isHexDigit(B(M));)M.token+=B(M),_(M);if(B(M)===".")for(M.token+=".",_(M);d.isHexDigit(B(M));)M.token+=B(M),_(M);else if(B(M)==="i")for(M.token+="i",_(M);d.isDigit(B(M));)M.token+=B(M),_(M);return}if(B(M)==="."){if(M.token+=B(M),_(M),!d.isDigit(B(M))){M.tokenType=x.DELIMITER;return}}else{for(;d.isDigit(B(M));)M.token+=B(M),_(M);d.isDecimalMark(B(M),G(M))&&(M.token+=B(M),_(M))}for(;d.isDigit(B(M));)M.token+=B(M),_(M);if(B(M)==="E"||B(M)==="e"){if(d.isDigit(G(M))||G(M)==="-"||G(M)==="+"){if(M.token+=B(M),_(M),(B(M)==="+"||B(M)==="-")&&(M.token+=B(M),_(M)),!d.isDigit(B(M)))throw Je(M,'Digit expected, got "'+B(M)+'"');for(;d.isDigit(B(M));)M.token+=B(M),_(M);if(d.isDecimalMark(B(M),G(M)))throw Je(M,'Digit expected, got "'+B(M)+'"')}else if(G(M)===".")throw _(M),Je(M,'Digit expected, got "'+B(M)+'"')}return}if(d.isAlpha(B(M),L(M),G(M))){for(;d.isAlpha(B(M),L(M),G(M))||d.isDigit(B(M));)M.token+=B(M),_(M);Re(E,M.token)?M.tokenType=x.DELIMITER:M.tokenType=x.SYMBOL;return}for(M.tokenType=x.UNKNOWN;B(M)!=="";)M.token+=B(M),_(M);throw Je(M,'Syntax error in part "'+M.token+'"')}function F(M){do C(M);while(M.token===`
37
- `)}function Z(M){M.nestingLevel++}function $(M){M.nestingLevel--}d.isAlpha=function(H,se,De){return d.isValidLatinOrGreek(H)||d.isValidMathSymbol(H,De)||d.isValidMathSymbol(se,H)},d.isValidLatinOrGreek=function(H){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(H)},d.isValidMathSymbol=function(H,se){return/^[\uD835]$/.test(H)&&/^[\uDC00-\uDFFF]$/.test(se)&&/^[^\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDFCC\uDFCD]$/.test(se)},d.isWhitespace=function(H,se){return H===" "||H===" "||H===`
38
- `&&se>0},d.isDecimalMark=function(H,se){return H==="."&&se!=="/"&&se!=="*"&&se!=="^"},d.isDigitDot=function(H){return H>="0"&&H<="9"||H==="."},d.isDigit=function(H){return H>="0"&&H<="9"},d.isHexDigit=function(H){return H>="0"&&H<="9"||H>="a"&&H<="f"||H>="A"&&H<="F"};function U(M,H){var se=D();Ar(se,{expression:M,extraNodes:H}),C(se);var De=Y(se);if(se.token!=="")throw se.tokenType===x.DELIMITER?cr(se,"Unexpected operator "+se.token):Je(se,'Unexpected part "'+se.token+'"');return De}function Y(M){var H,se=[],De;for(M.token!==""&&M.token!==`
39
- `&&M.token!==";"&&(H=j(M),M.comment&&(H.comment=M.comment));M.token===`
40
- `||M.token===";";)se.length===0&&H&&(De=M.token!==";",se.push({node:H,visible:De})),C(M),M.token!==`
41
- `&&M.token!==";"&&M.token!==""&&(H=j(M),M.comment&&(H.comment=M.comment),De=M.token!==";",se.push({node:H,visible:De}));return se.length>0?new f(se):(H||(H=new u(void 0),M.comment&&(H.comment=M.comment)),H)}function j(M){var H,se,De,ze,Le=P(M);if(M.token==="="){if(qr(Le))return H=Le.name,F(M),De=j(M),new s(new A(H),De);if(Dn(Le))return F(M),De=j(M),new s(Le.object,Le.index,De);if(An(Le)&&qr(Le.fn)&&(ze=!0,se=[],H=Le.name,Le.args.forEach(function(Mr,Rr){qr(Mr)?se[Rr]=Mr.name:ze=!1}),ze))return F(M),De=j(M),new o(H,se,De);throw Je(M,"Invalid left hand side of assignment operator =")}return Le}function P(M){for(var H=K(M);M.token==="?";){var se=M.conditionalLevel;M.conditionalLevel=M.nestingLevel,F(M);var De=H,ze=j(M);if(M.token!==":")throw Je(M,"False part of conditional expression expected");M.conditionalLevel=null,F(M);var Le=j(M);H=new l(De,ze,Le),M.conditionalLevel=se}return H}function K(M){for(var H=ne(M);M.token==="or";)F(M),H=new p("or","or",[H,ne(M)]);return H}function ne(M){for(var H=re(M);M.token==="xor";)F(M),H=new p("xor","xor",[H,re(M)]);return H}function re(M){for(var H=fe(M);M.token==="and";)F(M),H=new p("and","and",[H,fe(M)]);return H}function fe(M){for(var H=pe(M);M.token==="|";)F(M),H=new p("|","bitOr",[H,pe(M)]);return H}function pe(M){for(var H=ce(M);M.token==="^|";)F(M),H=new p("^|","bitXor",[H,ce(M)]);return H}function ce(M){for(var H=oe(M);M.token==="&";)F(M),H=new p("&","bitAnd",[H,oe(M)]);return H}function oe(M){for(var H=[Ce(M)],se=[],De={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};Re(De,M.token);){var ze={name:M.token,fn:De[M.token]};se.push(ze),F(M),H.push(Ce(M))}return H.length===1?H[0]:H.length===2?new p(se[0].name,se[0].fn,H):new b(se.map(Le=>Le.fn),H)}function Ce(M){var H,se,De,ze;H=Oe(M);for(var Le={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Re(Le,M.token);)se=M.token,De=Le[se],F(M),ze=[H,Oe(M)],H=new p(se,De,ze);return H}function Oe(M){var H,se,De,ze;H=Me(M);for(var Le={to:"to",in:"to"};Re(Le,M.token);)se=M.token,De=Le[se],F(M),se==="in"&&M.token===""?H=new p("*","multiply",[H,new A("in")],!0):(ze=[H,Me(M)],H=new p(se,De,ze));return H}function Me(M){var H,se=[];if(M.token===":"?H=new u(1):H=$e(M),M.token===":"&&M.conditionalLevel!==M.nestingLevel){for(se.push(H);M.token===":"&&se.length<3;)F(M),M.token===")"||M.token==="]"||M.token===","||M.token===""?se.push(new A("end")):se.push($e(M));se.length===3?H=new y(se[0],se[2],se[1]):H=new y(se[0],se[1])}return H}function $e(M){var H,se,De,ze;H=k(M);for(var Le={"+":"add","-":"subtract"};Re(Le,M.token);){se=M.token,De=Le[se],F(M);var Mr=k(M);Mr.isPercentage?ze=[H,new p("*","multiply",[H,Mr])]:ze=[H,Mr],H=new p(se,De,ze)}return H}function k(M){var H,se,De,ze;H=W(M),se=H;for(var Le={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};Re(Le,M.token);)De=M.token,ze=Le[De],F(M),se=W(M),H=new p(De,ze,[H,se]);return H}function W(M){var H,se;for(H=ie(M),se=H;M.tokenType===x.SYMBOL||M.token==="in"&&sr(H)||M.tokenType===x.NUMBER&&!sr(se)&&(!_r(se)||se.op==="!")||M.token==="(";)se=ie(M),H=new p("*","multiply",[H,se],!0);return H}function ie(M){for(var H=V(M),se=H,De=[];M.token==="/"&&zo(se);)if(De.push(Ar({},M)),F(M),M.tokenType===x.NUMBER)if(De.push(Ar({},M)),F(M),M.tokenType===x.SYMBOL||M.token==="(")Ar(M,De.pop()),De.pop(),se=V(M),H=new p("/","divide",[H,se]);else{De.pop(),Ar(M,De.pop());break}else{Ar(M,De.pop());break}return H}function V(M){var H,se,De,ze;H=Q(M);for(var Le={"%":"mod",mod:"mod"};Re(Le,M.token);)se=M.token,De=Le[se],F(M),se==="%"&&M.tokenType===x.DELIMITER&&M.token!=="("?H=new p("/","divide",[H,new u(100)],!1,!0):(ze=[H,Q(M)],H=new p(se,De,ze));return H}function Q(M){var H,se,De,ze={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Re(ze,M.token)?(De=ze[M.token],H=M.token,F(M),se=[Q(M)],new p(H,De,se)):te(M)}function te(M){var H,se,De,ze;return H=ge(M),(M.token==="^"||M.token===".^")&&(se=M.token,De=se==="^"?"pow":"dotPow",F(M),ze=[H,Q(M)],H=new p(se,De,ze)),H}function ge(M){var H,se,De,ze;H=he(M);for(var Le={"!":"factorial","'":"ctranspose"};Re(Le,M.token);)se=M.token,De=Le[se],C(M),ze=[H],H=new p(se,De,ze),H=z(M,H);return H}function he(M){var H=[];if(M.tokenType===x.SYMBOL&&Re(M.extraNodes,M.token)){var se=M.extraNodes[M.token];if(C(M),M.token==="("){if(H=[],Z(M),C(M),M.token!==")")for(H.push(j(M));M.token===",";)C(M),H.push(j(M));if(M.token!==")")throw Je(M,"Parenthesis ) expected");$(M),C(M)}return new se(H)}return q(M)}function q(M){var H,se;return M.tokenType===x.SYMBOL||M.tokenType===x.DELIMITER&&M.token in E?(se=M.token,C(M),Re(N,se)?H=new u(N[se]):S.indexOf(se)!==-1?H=new u(t(se,"number")):H=new A(se),H=z(M,H),H):ee(M)}function z(M,H,se){for(var De;(M.token==="("||M.token==="["||M.token===".")&&(!se||se.indexOf(M.token)!==-1);)if(De=[],M.token==="(")if(qr(H)||Dn(H)){if(Z(M),C(M),M.token!==")")for(De.push(j(M));M.token===",";)C(M),De.push(j(M));if(M.token!==")")throw Je(M,"Parenthesis ) expected");$(M),C(M),H=new c(H,De)}else return H;else if(M.token==="["){if(Z(M),C(M),M.token!=="]")for(De.push(j(M));M.token===",";)C(M),De.push(j(M));if(M.token!=="]")throw Je(M,"Parenthesis ] expected");$(M),C(M),H=new n(H,new m(De))}else{if(C(M),M.tokenType!==x.SYMBOL)throw Je(M,"Property name expected after dot");De.push(new u(M.token)),C(M);var ze=!0;H=new n(H,new m(De,ze))}return H}function ee(M){var H,se;return M.token==='"'?(se=ue(M),H=new u(se),H=z(M,H),H):me(M)}function ue(M){for(var H="";B(M)!==""&&B(M)!=='"';)B(M)==="\\"&&(H+=B(M),_(M)),H+=B(M),_(M);if(C(M),M.token!=='"')throw Je(M,'End of string " expected');return C(M),JSON.parse('"'+H+'"')}function me(M){var H,se;return M.token==="'"?(se=ye(M),H=new u(se),H=z(M,H),H):be(M)}function ye(M){for(var H="";B(M)!==""&&B(M)!=="'";)B(M)==="\\"&&(H+=B(M),_(M)),H+=B(M),_(M);if(C(M),M.token!=="'")throw Je(M,"End of string ' expected");return C(M),JSON.parse('"'+H+'"')}function be(M){var H,se,De,ze;if(M.token==="["){if(Z(M),C(M),M.token!=="]"){var Le=ve(M);if(M.token===";"){for(De=1,se=[Le];M.token===";";)C(M),se[De]=ve(M),De++;if(M.token!=="]")throw Je(M,"End of matrix ] expected");$(M),C(M),ze=se[0].items.length;for(var Mr=1;Mr<De;Mr++)if(se[Mr].items.length!==ze)throw cr(M,"Column dimensions mismatch ("+se[Mr].items.length+" !== "+ze+")");H=new i(se)}else{if(M.token!=="]")throw Je(M,"End of matrix ] expected");$(M),C(M),H=Le}}else $(M),C(M),H=new i([]);return z(M,H)}return Ne(M)}function ve(M){for(var H=[j(M)],se=1;M.token===",";)C(M),H[se]=j(M),se++;return new i(H)}function Ne(M){if(M.token==="{"){Z(M);var H,se={};do if(C(M),M.token!=="}"){if(M.token==='"')H=ue(M);else if(M.token==="'")H=ye(M);else if(M.tokenType===x.SYMBOL||M.tokenType===x.DELIMITER&&M.token in E)H=M.token,C(M);else throw Je(M,"Symbol or string expected as object key");if(M.token!==":")throw Je(M,"Colon : expected after object key");C(M),se[H]=j(M)}while(M.token===",");if(M.token!=="}")throw Je(M,"Comma , or bracket } expected after object value");$(M),C(M);var De=new v(se);return De=z(M,De),De}return Ie(M)}function Ie(M){var H;return M.tokenType===x.NUMBER?(H=M.token,C(M),new u(t(H,a.number))):Ge(M)}function Ge(M){var H;if(M.token==="("){if(Z(M),C(M),H=j(M),M.token!==")")throw Je(M,"Parenthesis ) expected");return $(M),C(M),H=new h(H),H=z(M,H),H}return Be(M)}function Be(M){throw M.token===""?Je(M,"Unexpected end of expression"):Je(M,"Value expected")}function lr(M){return M.index-M.token.length+1}function Je(M,H){var se=lr(M),De=new SyntaxError(H+" (char "+se+")");return De.char=se,De}function cr(M,H){var se=lr(M),De=new SyntaxError(H+" (char "+se+")");return De.char=se,De}return e.addConversion({from:"string",to:"Node",convert:d}),d}),Zv="compile",NE=["typed","parse"],DE=R(Zv,NE,r=>{var{typed:e,parse:t}=r;return e(Zv,{string:function(n){return t(n).compile()},"Array | Matrix":function(n){return je(n,function(i){return t(i).compile()})}})}),Jv="evaluate",AE=["typed","parse"],EE=R(Jv,AE,r=>{var{typed:e,parse:t}=r;return e(Jv,{string:function(n){var i=Jn();return t(n).compile().evaluate(i)},"string, Map | Object":function(n,i){return t(n).compile().evaluate(i)},"Array | Matrix":function(n){var i=Jn();return je(n,function(s){return t(s).compile().evaluate(i)})},"Array | Matrix, Map | Object":function(n,i){return je(n,function(s){return t(s).compile().evaluate(i)})}})}),SE="Parser",CE=["evaluate"],ME=R(SE,CE,r=>{var{evaluate:e}=r;function t(){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:Jn(),writable:!1})}return t.prototype.type="Parser",t.prototype.isParser=!0,t.prototype.evaluate=function(a){return e(a,this.scope)},t.prototype.get=function(a){if(this.scope.has(a))return this.scope.get(a)},t.prototype.getAll=function(){return ng(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}),Wv="parser",FE=["typed","Parser"],TE=R(Wv,FE,r=>{var{typed:e,Parser:t}=r;return e(Wv,{"":function(){return new t}})}),Xv="lup",BE=["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],$E=R(Xv,BE,r=>{var{typed:e,matrix:t,abs:a,addScalar:n,divideScalar:i,multiplyScalar:s,subtract:f,larger:l,equalScalar:u,unaryMinus:o,DenseMatrix:c,SparseMatrix:m,Spa:v}=r;return e(Xv,{DenseMatrix:function(b){return p(b)},SparseMatrix:function(b){return h(b)},Array:function(b){var A=t(b),d=p(A);return{L:d.L.valueOf(),U:d.U.valueOf(),p:d.p}}});function p(y){var b=y._size[0],A=y._size[1],d=Math.min(b,A),w=ke(y._data),x=[],g=[b,d],E=[],N=[d,A],S,D,T,B=[];for(S=0;S<b;S++)B[S]=S;for(D=0;D<A;D++){if(D>0)for(S=0;S<b;S++){var _=Math.min(S,D),L=0;for(T=0;T<_;T++)L=n(L,s(w[S][T],w[T][D]));w[S][D]=f(w[S][D],L)}var G=D,C=0,F=0;for(S=D;S<b;S++){var Z=w[S][D],$=a(Z);l($,C)&&(G=S,C=$,F=Z)}if(D!==G&&(B[D]=[B[G],B[G]=B[D]][0],c._swapRows(D,G,w)),D<b)for(S=D+1;S<b;S++){var U=w[S][D];u(U,0)||(w[S][D]=i(w[S][D],F))}}for(D=0;D<A;D++)for(S=0;S<b;S++){if(D===0&&(S<A&&(E[S]=[]),x[S]=[]),S<D){S<A&&(E[S][D]=w[S][D]),D<b&&(x[S][D]=0);continue}if(S===D){S<A&&(E[S][D]=w[S][D]),D<b&&(x[S][D]=1);continue}S<A&&(E[S][D]=0),D<b&&(x[S][D]=w[S][D])}var Y=new c({data:x,size:g}),j=new c({data:E,size:N}),P=[];for(S=0,d=B.length;S<d;S++)P[B[S]]=S;return{L:Y,U:j,p:P,toString:function(){return"L: "+this.L.toString()+`
27
+ **/(function(r,e){(function(t){var a=2e3,n={s:1,n:0,d:1};function i(h,p){if(isNaN(h=parseInt(h,10)))throw v.InvalidParameter;return h*p}function o(h,p){if(p===0)throw v.DivisionByZero;var g=Object.create(v.prototype);g.s=h<0?-1:1,h=h<0?-h:h;var y=m(h,p);return g.n=h/y,g.d=p/y,g}function f(h){for(var p={},g=h,y=2,N=4;N<=g;){for(;g%y===0;)g/=y,p[y]=(p[y]||0)+1;N+=1+2*y++}return g!==h?g>1&&(p[g]=(p[g]||0)+1):p[h]=(p[h]||0)+1,p}var l=function(h,p){var g=0,y=1,N=1,d=0,w=0,x=0,b=1,E=1,A=0,S=1,D=1,T=1,B=1e7,I;if(h!=null)if(p!==void 0){if(g=h,y=p,N=g*y,g%1!==0||y%1!==0)throw v.NonIntegerParameter}else switch(typeof h){case"object":{if("d"in h&&"n"in h)g=h.n,y=h.d,"s"in h&&(g*=h.s);else if(0 in h)g=h[0],1 in h&&(y=h[1]);else throw v.InvalidParameter;N=g*y;break}case"number":{if(h<0&&(N=h,h=-h),h%1===0)g=h;else if(h>0){for(h>=1&&(E=Math.pow(10,Math.floor(1+Math.log(h)/Math.LN10)),h/=E);S<=B&&T<=B;)if(I=(A+D)/(S+T),h===I){S+T<=B?(g=A+D,y=S+T):T>S?(g=D,y=T):(g=A,y=S);break}else h>I?(A+=D,S+=T):(D+=A,T+=S),S>B?(g=D,y=T):(g=A,y=S);g*=E}else(isNaN(h)||isNaN(p))&&(y=g=NaN);break}case"string":{if(S=h.match(/\d+|./g),S===null)throw v.InvalidParameter;if(S[A]==="-"?(N=-1,A++):S[A]==="+"&&A++,S.length===A+1?w=i(S[A++],N):S[A+1]==="."||S[A]==="."?(S[A]!=="."&&(d=i(S[A++],N)),A++,(A+1===S.length||S[A+1]==="("&&S[A+3]===")"||S[A+1]==="'"&&S[A+3]==="'")&&(w=i(S[A],N),b=Math.pow(10,S[A].length),A++),(S[A]==="("&&S[A+2]===")"||S[A]==="'"&&S[A+2]==="'")&&(x=i(S[A+1],N),E=Math.pow(10,S[A+1].length)-1,A+=3)):S[A+1]==="/"||S[A+1]===":"?(w=i(S[A],N),b=i(S[A+2],1),A+=3):S[A+3]==="/"&&S[A+1]===" "&&(d=i(S[A],N),w=i(S[A+2],N),b=i(S[A+4],1),A+=5),S.length<=A){y=b*E,N=g=x+y*d+E*w;break}}default:throw v.InvalidParameter}if(y===0)throw v.DivisionByZero;n.s=N<0?-1:1,n.n=Math.abs(g),n.d=Math.abs(y)};function u(h,p,g){for(var y=1;p>0;h=h*h%g,p>>=1)p&1&&(y=y*h%g);return y}function s(h,p){for(;p%2===0;p/=2);for(;p%5===0;p/=5);if(p===1)return 0;for(var g=10%p,y=1;g!==1;y++)if(g=g*10%p,y>a)return 0;return y}function c(h,p,g){for(var y=1,N=u(10,g,p),d=0;d<300;d++){if(y===N)return d;y=y*10%p,N=N*10%p}return 0}function m(h,p){if(!h)return p;if(!p)return h;for(;;){if(h%=p,!h)return p;if(p%=h,!p)return h}}function v(h,p){if(l(h,p),this instanceof v)h=m(n.d,n.n),this.s=n.s,this.n=n.n/h,this.d=n.d/h;else return o(n.s*n.n,n.d)}v.DivisionByZero=new Error("Division by Zero"),v.InvalidParameter=new Error("Invalid argument"),v.NonIntegerParameter=new Error("Parameters must be integer"),v.prototype={s:1,n:0,d:1,abs:function(){return o(this.n,this.d)},neg:function(){return o(-this.s*this.n,this.d)},add:function(h,p){return l(h,p),o(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(h,p){return l(h,p),o(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(h,p){return l(h,p),o(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(h,p){return l(h,p),o(this.s*n.s*this.n*n.d,this.d*n.n)},clone:function(){return o(this.s*this.n,this.d)},mod:function(h,p){if(isNaN(this.n)||isNaN(this.d))return new v(NaN);if(h===void 0)return o(this.s*this.n%this.d,1);if(l(h,p),n.n===0&&this.d===0)throw v.DivisionByZero;return o(this.s*(n.d*this.n)%(n.n*this.d),n.d*this.d)},gcd:function(h,p){return l(h,p),o(m(n.n,this.n)*m(n.d,this.d),n.d*this.d)},lcm:function(h,p){return l(h,p),n.n===0&&this.n===0?o(0,1):o(n.n*this.n,m(n.n,this.n)*m(n.d,this.d))},ceil:function(h){return h=Math.pow(10,h||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):o(Math.ceil(h*this.s*this.n/this.d),h)},floor:function(h){return h=Math.pow(10,h||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):o(Math.floor(h*this.s*this.n/this.d),h)},round:function(h){return h=Math.pow(10,h||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):o(Math.round(h*this.s*this.n/this.d),h)},inverse:function(){return o(this.s*this.d,this.n)},pow:function(h,p){if(l(h,p),n.d===1)return n.s<0?o(Math.pow(this.s*this.d,n.n),Math.pow(this.n,n.n)):o(Math.pow(this.s*this.n,n.n),Math.pow(this.d,n.n));if(this.s<0)return null;var g=f(this.n),y=f(this.d),N=1,d=1;for(var w in g)if(w!=="1"){if(w==="0"){N=0;break}if(g[w]*=n.n,g[w]%n.d===0)g[w]/=n.d;else return null;N*=Math.pow(w,g[w])}for(var w in y)if(w!=="1"){if(y[w]*=n.n,y[w]%n.d===0)y[w]/=n.d;else return null;d*=Math.pow(w,y[w])}return n.s<0?o(d,N):o(N,d)},equals:function(h,p){return l(h,p),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(h,p){l(h,p);var g=this.s*this.n*n.d-n.s*n.n*this.d;return(0<g)-(g<0)},simplify:function(h){if(isNaN(this.n)||isNaN(this.d))return this;h=h||.001;for(var p=this.abs(),g=p.toContinued(),y=1;y<g.length;y++){for(var N=o(g[y-1],1),d=y-2;d>=0;d--)N=N.inverse().add(g[d]);if(N.sub(p).abs().valueOf()<h)return N.mul(this.s)}return this},divisible:function(h,p){return l(h,p),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(h){var p,g="",y=this.n,N=this.d;return this.s<0&&(g+="-"),N===1?g+=y:(h&&(p=Math.floor(y/N))>0&&(g+=p,g+=" ",y%=N),g+=y,g+="/",g+=N),g},toLatex:function(h){var p,g="",y=this.n,N=this.d;return this.s<0&&(g+="-"),N===1?g+=y:(h&&(p=Math.floor(y/N))>0&&(g+=p,y%=N),g+="\\frac{",g+=y,g+="}{",g+=N,g+="}"),g},toContinued:function(){var h,p=this.n,g=this.d,y=[];if(isNaN(p)||isNaN(g))return y;do y.push(Math.floor(p/g)),h=p%g,p=g,g=h;while(p!==1);return y},toString:function(h){var p=this.n,g=this.d;if(isNaN(p)||isNaN(g))return"NaN";h=h||15;var y=s(p,g),N=c(p,g,y),d=this.s<0?"-":"";if(d+=p/g|0,p%=g,p*=10,p&&(d+="."),y){for(var w=N;w--;)d+=p/g|0,p%=g,p*=10;d+="(";for(var w=y;w--;)d+=p/g|0,p%=g,p*=10;d+=")"}else for(var w=h;p&&w--;)d+=p/g|0,p%=g,p*=10;return d}},Object.defineProperty(v,"__esModule",{value:!0}),v.default=v,v.Fraction=v,r.exports=v})()})(Jl);const Jt=Hl(Jl.exports);var _1="Fraction",q1=[],z1=q(_1,q1,()=>(Object.defineProperty(Jt,"name",{value:"Fraction"}),Jt.prototype.constructor=Jt,Jt.prototype.type="Fraction",Jt.prototype.isFraction=!0,Jt.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},Jt.fromJSON=function(r){return new Jt(r)},Jt),{isClass:!0}),P1="Range",U1=[],L1=q(P1,U1,()=>{function r(e,t,a){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");var n=e!=null,i=t!=null,o=a!=null;if(n){if(rr(e))e=e.toNumber();else if(typeof e!="number")throw new TypeError("Parameter start must be a number")}if(i){if(rr(t))t=t.toNumber();else if(typeof t!="number")throw new TypeError("Parameter end must be a number")}if(o){if(rr(a))a=a.toNumber();else if(typeof a!="number")throw new TypeError("Parameter step must be a number")}this.start=n?parseFloat(e):0,this.end=i?parseFloat(t):0,this.step=o?parseFloat(a):1}return r.prototype.type="Range",r.prototype.isRange=!0,r.parse=function(e){if(typeof e!="string")return null;var t=e.split(":"),a=t.map(function(i){return parseFloat(i)}),n=a.some(function(i){return isNaN(i)});if(n)return null;switch(a.length){case 2:return new r(a[0],a[1]);case 3:return new r(a[0],a[2],a[1]);default:return null}},r.prototype.clone=function(){return new r(this.start,this.end,this.step)},r.prototype.size=function(){var e=0,t=this.start,a=this.step,n=this.end,i=n-t;return an(a)===an(i)?e=Math.ceil(i/a):i===0&&(e=0),isNaN(e)&&(e=0),[e]},r.prototype.min=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start:this.start+(e-1)*this.step},r.prototype.max=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start+(e-1)*this.step:this.start},r.prototype.forEach=function(e){var t=this.start,a=this.step,n=this.end,i=0;if(a>0)for(;t<n;)e(t,[i],this),t+=a,i++;else if(a<0)for(;t>n;)e(t,[i],this),t+=a,i++},r.prototype.map=function(e){var t=[];return this.forEach(function(a,n,i){t[n[0]]=e(a,n,i)}),t},r.prototype.toArray=function(){var e=[];return this.forEach(function(t,a){e[a[0]]=t}),e},r.prototype.valueOf=function(){return this.toArray()},r.prototype.format=function(e){var t=Cn(this.start,e);return this.step!==1&&(t+=":"+Cn(this.step,e)),t+=":"+Cn(this.end,e),t},r.prototype.toString=function(){return this.format()},r.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},r.fromJSON=function(e){return new r(e.start,e.end,e.step)},r},{isClass:!0}),k1="Matrix",V1=[],G1=q(k1,V1,()=>{function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator")}return r.prototype.type="Matrix",r.prototype.isMatrix=!0,r.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},r.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},r.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},r.prototype.subset=function(e,t,a){throw new Error("Cannot invoke subset on a Matrix interface")},r.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},r.prototype.set=function(e,t,a){throw new Error("Cannot invoke set on a Matrix interface")},r.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},r.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},r.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},r.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},r.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},r.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},r.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},r.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},r.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},r.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},r.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},r},{isClass:!0});function H1(r){var e=0,t=1,a=Object.create(null),n=Object.create(null),i=0,o=function(l){var u=n[l];if(!!u&&(delete a[u],delete n[l],--e,t===u)){if(!e){i=0,t=1;return}for(;!hasOwnProperty.call(a,++t););}};return r=Math.abs(r),{hit:function(l){var u=n[l],s=++i;if(a[s]=l,n[l]=s,!u)return++e,e<=r?void 0:(l=a[t],o(l),l);if(delete a[u],t===u)for(;!hasOwnProperty.call(a,++t););},delete:o,clear:function(){e=i=0,t=1,a=Object.create(null),n=Object.create(null)}}}function Va(r){var{hasher:e,limit:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return t=t==null?Number.POSITIVE_INFINITY:t,e=e==null?JSON.stringify:e,function a(){typeof a.cache!="object"&&(a.cache={values:new Map,lru:H1(t||Number.POSITIVE_INFINITY)});for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=e(n);if(a.cache.values.has(o))return a.cache.lru.hit(o),a.cache.values.get(o);var f=r.apply(r,n);return a.cache.values.set(o,f),a.cache.values.delete(a.cache.lru.hit(o)),f}}function fn(r){return Object.keys(r.signatures||{}).reduce(function(e,t){var a=(t.match(/,/g)||[]).length+1;return Math.max(e,a)},-1)}var Z1="DenseMatrix",J1=["Matrix"],X1=q(Z1,J1,r=>{var{Matrix:e}=r;function t(s,c){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(c&&!Wr(c))throw new Error("Invalid datatype: "+c);if(Ve(s))s.type==="DenseMatrix"?(this._data=Ge(s._data),this._size=Ge(s._size),this._datatype=c||s._datatype):(this._data=s.toArray(),this._size=s.size(),this._datatype=c||s._datatype);else if(s&&cr(s.data)&&cr(s.size))this._data=s.data,this._size=s.size,xl(this._data,this._size),this._datatype=c||s.datatype;else if(cr(s))this._data=u(s),this._size=er(this._data),xl(this._data,this._size),this._datatype=c;else{if(s)throw new TypeError("Unsupported type of data ("+br(s)+")");this._data=[],this._size=[0],this._datatype=c}}t.prototype=new e,t.prototype.createDenseMatrix=function(s,c){return new t(s,c)},Object.defineProperty(t,"name",{value:"DenseMatrix"}),t.prototype.constructor=t,t.prototype.type="DenseMatrix",t.prototype.isDenseMatrix=!0,t.prototype.getDataType=function(){return La(this._data,br)},t.prototype.storage=function(){return"dense"},t.prototype.datatype=function(){return this._datatype},t.prototype.create=function(s,c){return new t(s,c)},t.prototype.subset=function(s,c,m){switch(arguments.length){case 1:return a(this,s);case 2:case 3:return i(this,s,c,m);default:throw new SyntaxError("Wrong number of arguments")}},t.prototype.get=function(s){if(!cr(s))throw new TypeError("Array expected");if(s.length!==this._size.length)throw new Ke(s.length,this._size.length);for(var c=0;c<s.length;c++)vr(s[c],this._size[c]);for(var m=this._data,v=0,h=s.length;v<h;v++){var p=s[v];vr(p,m.length),m=m[p]}return m},t.prototype.set=function(s,c,m){if(!cr(s))throw new TypeError("Array expected");if(s.length<this._size.length)throw new Ke(s.length,this._size.length,"<");var v,h,p,g=s.map(function(N){return N+1});l(this,g,m);var y=this._data;for(v=0,h=s.length-1;v<h;v++)p=s[v],vr(p,y.length),y=y[p];return p=s[s.length-1],vr(p,y.length),y[p]=c,this};function a(s,c){if(!li(c))throw new TypeError("Invalid index");var m=c.isScalar();if(m)return s.get(c.min());var v=c.size();if(v.length!==s._size.length)throw new Ke(v.length,s._size.length);for(var h=c.min(),p=c.max(),g=0,y=s._size.length;g<y;g++)vr(h[g],s._size[g]),vr(p[g],s._size[g]);return new t(n(s._data,c,v.length,0),s._datatype)}function n(s,c,m,v){var h=v===m-1,p=c.dimension(v);return h?p.map(function(g){return vr(g,s.length),s[g]}).valueOf():p.map(function(g){vr(g,s.length);var y=s[g];return n(y,c,m,v+1)}).valueOf()}function i(s,c,m,v){if(!c||c.isIndex!==!0)throw new TypeError("Invalid index");var h=c.size(),p=c.isScalar(),g;if(Ve(m)?(g=m.size(),m=m.valueOf()):g=er(m),p){if(g.length!==0)throw new TypeError("Scalar expected");s.set(c.min(),m,v)}else{if(h.length<s._size.length)throw new Ke(h.length,s._size.length,"<");if(g.length<h.length){for(var y=0,N=0;h[y]===1&&g[y]===1;)y++;for(;h[y]===1;)N++,y++;m=Al(m,h.length,N,g)}if(!Ua(h,g))throw new Ke(h,g,">");var d=c.max().map(function(b){return b+1});l(s,d,v);var w=h.length,x=0;o(s._data,c,m,w,x)}return s}function o(s,c,m,v,h){var p=h===v-1,g=c.dimension(h);p?g.forEach(function(y,N){vr(y),s[y]=m[N[0]]}):g.forEach(function(y,N){vr(y),o(s[y],c,m[N[0]],v,h+1)})}t.prototype.resize=function(s,c,m){if(!Ft(s))throw new TypeError("Array or Matrix expected");var v=s.valueOf().map(p=>Array.isArray(p)&&p.length===1?p[0]:p),h=m?this.clone():this;return f(h,v,c)};function f(s,c,m){if(c.length===0){for(var v=s._data;cr(v);)v=v[0];return v}return s._size=c.slice(0),s._data=Qn(s._data,s._size,m),s}t.prototype.reshape=function(s,c){var m=c?this.clone():this;m._data=wl(m._data,s);var v=m._size.reduce((h,p)=>h*p);return m._size=Jo(s,v),m};function l(s,c,m){for(var v=s._size.slice(0),h=!1;v.length<c.length;)v.push(0),h=!0;for(var p=0,g=c.length;p<g;p++)c[p]>v[p]&&(v[p]=c[p],h=!0);h&&f(s,v,m)}t.prototype.clone=function(){var s=new t({data:Ge(this._data),size:Ge(this._size),datatype:this._datatype});return s},t.prototype.size=function(){return this._size.slice(0)},t.prototype.map=function(s){var c=this,m=fn(s),v=function g(y,N){return cr(y)?y.map(function(d,w){return g(d,N.concat(w))}):m===1?s(y):m===2?s(y,N):s(y,N,c)},h=v(this._data,[]),p=this._datatype!==void 0?La(h,br):void 0;return new t(h,p)},t.prototype.forEach=function(s){var c=this,m=function v(h,p){cr(h)?h.forEach(function(g,y){v(g,p.concat(y))}):s(h,p,c)};m(this._data,[])},t.prototype[Symbol.iterator]=function*(){var s=function*c(m,v){if(cr(m))for(var h=0;h<m.length;h++)yield*c(m[h],v.concat(h));else yield{value:m,index:v}};yield*s(this._data,[])},t.prototype.rows=function(){var s=[],c=this.size();if(c.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var m=this._data;for(var v of m)s.push(new t([v],this._datatype));return s},t.prototype.columns=function(){var s=this,c=[],m=this.size();if(m.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var v=this._data,h=function(y){var N=v.map(d=>[d[y]]);c.push(new t(N,s._datatype))},p=0;p<m[1];p++)h(p);return c},t.prototype.toArray=function(){return Ge(this._data)},t.prototype.valueOf=function(){return this._data},t.prototype.format=function(s){return Ye(this._data,s)},t.prototype.toString=function(){return Ye(this._data)},t.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},t.prototype.diagonal=function(s){if(s){if(rr(s)&&(s=s.toNumber()),!tr(s)||!qe(s))throw new TypeError("The parameter k must be an integer number")}else s=0;for(var c=s>0?s:0,m=s<0?-s:0,v=this._size[0],h=this._size[1],p=Math.min(v-m,h-c),g=[],y=0;y<p;y++)g[y]=this._data[y+m][y+c];return new t({data:g,size:[p],datatype:this._datatype})},t.diagonal=function(s,c,m,v){if(!cr(s))throw new TypeError("Array expected, size parameter");if(s.length!==2)throw new Error("Only two dimensions matrix are supported");if(s=s.map(function(E){if(rr(E)&&(E=E.toNumber()),!tr(E)||!qe(E)||E<1)throw new Error("Size values must be positive integers");return E}),m){if(rr(m)&&(m=m.toNumber()),!tr(m)||!qe(m))throw new TypeError("The parameter k must be an integer number")}else m=0;var h=m>0?m:0,p=m<0?-m:0,g=s[0],y=s[1],N=Math.min(g-p,y-h),d;if(cr(c)){if(c.length!==N)throw new Error("Invalid value array length");d=function(A){return c[A]}}else if(Ve(c)){var w=c.size();if(w.length!==1||w[0]!==N)throw new Error("Invalid matrix length");d=function(A){return c.get([A])}}else d=function(){return c};v||(v=rr(d(0))?d(0).mul(0):0);var x=[];if(s.length>0){x=Qn(x,s,v);for(var b=0;b<N;b++)x[b+p][b+h]=d(b)}return new t({data:x,size:[g,y]})},t.fromJSON=function(s){return new t(s)},t.prototype.swapRows=function(s,c){if(!tr(s)||!qe(s)||!tr(c)||!qe(c))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return vr(s,this._size[0]),vr(c,this._size[0]),t._swapRows(s,c,this._data),this},t._swapRows=function(s,c,m){var v=m[s];m[s]=m[c],m[c]=v};function u(s){for(var c=0,m=s.length;c<m;c++){var v=s[c];cr(v)?s[c]=u(v):v&&v.isMatrix===!0&&(s[c]=u(v.valueOf()))}return s}return t},{isClass:!0}),Xl="clone",W1=["typed"],Y1=q(Xl,W1,r=>{var{typed:e}=r;return e(Xl,{any:Ge})});function Wl(r){var e=r.length,t=r[0].length,a,n,i=[];for(n=0;n<t;n++){var o=[];for(a=0;a<e;a++)o.push(r[a][n]);i.push(o)}return i}function aa(r){for(var e=0;e<r.length;e++)if(Ft(r[e]))return!0;return!1}function Xt(r,e){Ve(r)&&(r=r.valueOf());for(var t=0,a=r.length;t<a;t++){var n=r[t];Array.isArray(n)?Xt(n,e):e(n)}}function je(r,e,t){return r&&typeof r.map=="function"?r.map(function(a){return je(a,e)}):e(r)}function Si(r,e,t){var a=Array.isArray(r)?er(r):r.size();if(e<0||e>=a.length)throw new dt(e,a.length);return Ve(r)?r.create(Ci(r.valueOf(),e,t)):Ci(r,e,t)}function Ci(r,e,t){var a,n,i,o;if(e<=0)if(Array.isArray(r[0])){for(o=Wl(r),n=[],a=0;a<o.length;a++)n[a]=Ci(o[a],e-1,t);return n}else{for(i=r[0],a=1;a<r.length;a++)i=t(i,r[a]);return i}else{for(n=[],a=0;a<r.length;a++)n[a]=Ci(r[a],e-1,t);return n}}function Yl(r,e,t,a,n,i,o,f,l,u,s){var c=r._values,m=r._index,v=r._ptr,h,p,g,y;if(a)for(p=v[e],g=v[e+1],h=p;h<g;h++)y=m[h],t[y]!==i?(t[y]=i,o.push(y),u?(a[y]=l?f(c[h],s):f(s,c[h]),n[y]=i):a[y]=c[h]):(a[y]=l?f(c[h],a[y]):f(a[y],c[h]),n[y]=i);else for(p=v[e],g=v[e+1],h=p;h<g;h++)y=m[h],t[y]!==i?(t[y]=i,o.push(y)):n[y]=i}var Ql="isInteger",Q1=["typed"],K1=q(Ql,Q1,r=>{var{typed:e}=r;return e(Ql,{number:qe,BigNumber:function(a){return a.isInt()},Fraction:function(a){return a.d===1&&isFinite(a.n)},"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),bt="number",Fn="number, number";function Kl(r){return Math.abs(r)}Kl.signature=bt;function jl(r,e){return r+e}jl.signature=Fn;function ec(r,e){return r*e}ec.signature=Fn;function rc(r){return-r}rc.signature=bt;function tc(r){return r}tc.signature=bt;function Ga(r){return tg(r)}Ga.signature=bt;function nc(r){return r*r*r}nc.signature=bt;function ac(r){return Math.exp(r)}ac.signature=bt;function ic(r){return ng(r)}ic.signature=bt;function oc(r,e){if(!qe(r)||!qe(e))throw new Error("Parameters in function gcd must be integer numbers");for(var t;e!==0;)t=r%e,r=e,e=t;return r<0?-r:r}oc.signature=Fn;function sc(r,e){if(!qe(r)||!qe(e))throw new Error("Parameters in function lcm must be integer numbers");if(r===0||e===0)return 0;for(var t,a=r*e;e!==0;)t=e,e=r%t,r=t;return Math.abs(a/r)}sc.signature=Fn;function j1(r,e){return e?Math.log(r)/Math.log(e):Math.log(r)}function uc(r){return eg(r)}uc.signature=bt;function lc(r){return j0(r)}lc.signature=bt;function cc(r,e){if(e>0)return r-e*Math.floor(r/e);if(e===0)return r;throw new Error("Cannot calculate mod for a negative divisor")}cc.signature=Fn;function fc(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,t=e<0;if(t&&(e=-e),e===0)throw new Error("Root must be non-zero");if(r<0&&Math.abs(e)%2!==1)throw new Error("Root must be odd when a is negative.");if(r===0)return t?1/0:0;if(!isFinite(r))return t?0:r;var a=Math.pow(Math.abs(r),1/e);return a=r<0?-a:a,t?1/a:a}function os(r){return an(r)}os.signature=bt;function mc(r){return r*r}mc.signature=bt;function vc(r,e){var t,a,n,i=0,o=1,f=1,l=0;if(!qe(r)||!qe(e))throw new Error("Parameters in function xgcd must be integer numbers");for(;e;)a=Math.floor(r/e),n=r-a*e,t=i,i=o-a*i,o=t,t=f,f=l-a*f,l=t,r=e,e=n;var u;return r<0?u=[-r,-o,-l]:u=[r,r?o:0,l],u}vc.signature=Fn;function pc(r,e){return r*r<1&&e===1/0||r*r>1&&e===-1/0?0:Math.pow(r,e)}pc.signature=Fn;function hc(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!qe(e)||e<0||e>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(hl(r,e))}var ey="number",ia="number, number";function dc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitAnd");return r&e}dc.signature=ia;function gc(r){if(!qe(r))throw new Error("Integer expected in function bitNot");return~r}gc.signature=ey;function yc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitOr");return r|e}yc.signature=ia;function bc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitXor");return r^e}bc.signature=ia;function xc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function leftShift");return r<<e}xc.signature=ia;function wc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function rightArithShift");return r>>e}wc.signature=ia;function Nc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function rightLogShift");return r>>>e}Nc.signature=ia;function Wt(r,e){if(e<r)return 1;if(e===r)return e;var t=e+r>>1;return Wt(r,t)*Wt(t+1,e)}function Dc(r,e){if(!qe(r)||r<0)throw new TypeError("Positive integer value expected in function combinations");if(!qe(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(e>r)throw new TypeError("k must be less than or equal to n");for(var t=r-e,a=1,n=e<t?t+1:e+1,i=2,o=e<t?e:t,f=n;f<=r;++f)for(a*=f;i<=o&&a%i===0;)a/=i,++i;return i<=o&&(a/=Wt(i,o)),a}Dc.signature="number, number";var ry=Math.PI,ty=2*Math.PI,ny=Math.E,ay=1.618033988749895,iy="number",ss="number, number";function Ac(r){return!r}Ac.signature=iy;function Ec(r,e){return!!(r||e)}Ec.signature=ss;function Sc(r,e){return!!r!=!!e}Sc.signature=ss;function Cc(r,e){return!!(r&&e)}Cc.signature=ss;function Mi(r){var e;if(qe(r))return r<=0?isFinite(r)?1/0:NaN:r>171?1/0:Wt(1,r-1);if(r<.5)return Math.PI/(Math.sin(Math.PI*r)*Mi(1-r));if(r>=171.35)return 1/0;if(r>85){var t=r*r,a=t*r,n=a*r,i=n*r;return Math.sqrt(2*Math.PI/r)*Math.pow(r/Math.E,r)*(1+1/(12*r)+1/(288*t)-139/(51840*a)-571/(2488320*n)+163879/(209018880*i)+5246819/(75246796800*i*r))}--r,e=oa[0];for(var o=1;o<oa.length;++o)e+=oa[o]/(r+o);var f=r+Mc+.5;return Math.sqrt(2*Math.PI)*Math.pow(f,r+.5)*Math.exp(-f)*e}Mi.signature="number";var Mc=4.7421875,oa=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],Fc=.9189385332046728,oy=5,sy=7,Tc=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function Fi(r){if(r<0)return NaN;if(r===0)return 1/0;if(!isFinite(r))return r;if(r<.5)return Math.log(Math.PI/Math.sin(Math.PI*r))-Fi(1-r);r=r-1;for(var e=r+oy+.5,t=Tc[0],a=sy-1;a>=1;a--)t+=Tc[a]/(r+a);return Fc+(r+.5)*Math.log(e)-e+Math.log(t)}Fi.signature="number";var Hr="number";function Bc(r){return ug(r)}Bc.signature=Hr;function $c(r){return Math.atan(1/r)}$c.signature=Hr;function Oc(r){return isFinite(r)?(Math.log((r+1)/r)+Math.log(r/(r-1)))/2:0}Oc.signature=Hr;function Ic(r){return Math.asin(1/r)}Ic.signature=Hr;function Rc(r){var e=1/r;return Math.log(e+Math.sqrt(e*e+1))}Rc.signature=Hr;function _c(r){return Math.acos(1/r)}_c.signature=Hr;function qc(r){var e=1/r,t=Math.sqrt(e*e-1);return Math.log(t+e)}qc.signature=Hr;function zc(r){return lg(r)}zc.signature=Hr;function Pc(r){return cg(r)}Pc.signature=Hr;function Uc(r){return 1/Math.tan(r)}Uc.signature=Hr;function Lc(r){var e=Math.exp(2*r);return(e+1)/(e-1)}Lc.signature=Hr;function kc(r){return 1/Math.sin(r)}kc.signature=Hr;function Vc(r){return r===0?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(r)-Math.exp(-r)))*an(r)}Vc.signature=Hr;function Gc(r){return 1/Math.cos(r)}Gc.signature=Hr;function Hc(r){return 2/(Math.exp(r)+Math.exp(-r))}Hc.signature=Hr;function Zc(r){return mg(r)}Zc.signature=Hr;var Ti="number";function Jc(r){return r<0}Jc.signature=Ti;function Xc(r){return r>0}Xc.signature=Ti;function Wc(r){return r===0}Wc.signature=Ti;function Yc(r){return Number.isNaN(r)}Yc.signature=Ti;var Qc="isNegative",uy=["typed"],ly=q(Qc,uy,r=>{var{typed:e}=r;return e(Qc,{number:Jc,BigNumber:function(a){return a.isNeg()&&!a.isZero()&&!a.isNaN()},Fraction:function(a){return a.s<0},Unit:e.referToSelf(t=>a=>e.find(t,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Kc="isNumeric",cy=["typed"],fy=q(Kc,cy,r=>{var{typed:e}=r;return e(Kc,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),jc="hasNumericValue",my=["typed","isNumeric"],vy=q(jc,my,r=>{var{typed:e,isNumeric:t}=r;return e(jc,{boolean:()=>!0,string:function(n){return n.trim().length>0&&!isNaN(Number(n))},any:function(n){return t(n)}})}),ef="isPositive",py=["typed"],hy=q(ef,py,r=>{var{typed:e}=r;return e(ef,{number:Xc,BigNumber:function(a){return!a.isNeg()&&!a.isZero()&&!a.isNaN()},Fraction:function(a){return a.s>0&&a.n>0},Unit:e.referToSelf(t=>a=>e.find(t,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),rf="isZero",dy=["typed"],gy=q(rf,dy,r=>{var{typed:e}=r;return e(rf,{number:Wc,BigNumber:function(a){return a.isZero()},Complex:function(a){return a.re===0&&a.im===0},Fraction:function(a){return a.d===1&&a.n===0},Unit:e.referToSelf(t=>a=>e.find(t,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),tf="isNaN",yy=["typed"],by=q(tf,yy,r=>{var{typed:e}=r;return e(tf,{number:Yc,BigNumber:function(a){return a.isNaN()},Fraction:function(a){return!1},Complex:function(a){return a.isNaN()},Unit:function(a){return Number.isNaN(a.value)},"Array | Matrix":function(a){return je(a,Number.isNaN)}})}),nf="typeOf",xy=["typed"],wy=q(nf,xy,r=>{var{typed:e}=r;return e(nf,{any:br})});function Bt(r,e,t){if(t==null)return r.eq(e);if(r.eq(e))return!0;if(r.isNaN()||e.isNaN())return!1;if(r.isFinite()&&e.isFinite()){var a=r.minus(e).abs();if(a.isZero())return!0;var n=r.constructor.max(r.abs(),e.abs());return a.lte(n.times(t))}return!1}function Ny(r,e,t){return nt(r.re,e.re,t)&&nt(r.im,e.im,t)}var sa=q("compareUnits",["typed"],r=>{var{typed:e}=r;return{"Unit, Unit":e.referToSelf(t=>(a,n)=>{if(!a.equalBase(n))throw new Error("Cannot compare units with different base");return e.find(t,[a.valueType(),n.valueType()])(a.value,n.value)})}}),Bi="equalScalar",Dy=["typed","config"],Ay=q(Bi,Dy,r=>{var{typed:e,config:t}=r,a=sa({typed:e});return e(Bi,{"boolean, boolean":function(i,o){return i===o},"number, number":function(i,o){return nt(i,o,t.epsilon)},"BigNumber, BigNumber":function(i,o){return i.eq(o)||Bt(i,o,t.epsilon)},"Fraction, Fraction":function(i,o){return i.equals(o)},"Complex, Complex":function(i,o){return Ny(i,o,t.epsilon)}},a)});q(Bi,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Bi,{"number, number":function(n,i){return nt(n,i,t.epsilon)}})});var Ey="SparseMatrix",Sy=["typed","equalScalar","Matrix"],Cy=q(Ey,Sy,r=>{var{typed:e,equalScalar:t,Matrix:a}=r;function n(p,g){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(g&&!Wr(g))throw new Error("Invalid datatype: "+g);if(Ve(p))i(this,p,g);else if(p&&cr(p.index)&&cr(p.ptr)&&cr(p.size))this._values=p.values,this._index=p.index,this._ptr=p.ptr,this._size=p.size,this._datatype=g||p.datatype;else if(cr(p))o(this,p,g);else{if(p)throw new TypeError("Unsupported type of data ("+br(p)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=g}}function i(p,g,y){g.type==="SparseMatrix"?(p._values=g._values?Ge(g._values):void 0,p._index=Ge(g._index),p._ptr=Ge(g._ptr),p._size=Ge(g._size),p._datatype=y||g._datatype):o(p,g.valueOf(),y||g._datatype)}function o(p,g,y){p._values=[],p._index=[],p._ptr=[],p._datatype=y;var N=g.length,d=0,w=t,x=0;if(Wr(y)&&(w=e.find(t,[y,y])||t,x=e.convert(0,y)),N>0){var b=0;do{p._ptr.push(p._index.length);for(var E=0;E<N;E++){var A=g[E];if(cr(A)){if(b===0&&d<A.length&&(d=A.length),b<A.length){var S=A[b];w(S,x)||(p._values.push(S),p._index.push(E))}}else b===0&&d<1&&(d=1),w(A,x)||(p._values.push(A),p._index.push(E))}b++}while(b<d)}p._ptr.push(p._index.length),p._size=[N,d]}n.prototype=new a,n.prototype.createSparseMatrix=function(p,g){return new n(p,g)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return La(this._values,br)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(p,g){return new n(p,g)},n.prototype.density=function(){var p=this._size[0],g=this._size[1];return p!==0&&g!==0?this._index.length/(p*g):0},n.prototype.subset=function(p,g,y){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return f(this,p);case 2:case 3:return l(this,p,g,y);default:throw new SyntaxError("Wrong number of arguments")}};function f(p,g){if(!li(g))throw new TypeError("Invalid index");var y=g.isScalar();if(y)return p.get(g.min());var N=g.size();if(N.length!==p._size.length)throw new Ke(N.length,p._size.length);var d,w,x,b,E=g.min(),A=g.max();for(d=0,w=p._size.length;d<w;d++)vr(E[d],p._size[d]),vr(A[d],p._size[d]);var S=p._values,D=p._index,T=p._ptr,B=g.dimension(0),I=g.dimension(1),P=[],R=[];B.forEach(function($,k){R[$]=k[0],P[$]=!0});var M=S?[]:void 0,F=[],H=[];return I.forEach(function($){for(H.push(F.length),x=T[$],b=T[$+1];x<b;x++)d=D[x],P[d]===!0&&(F.push(R[d]),M&&M.push(S[x]))}),H.push(F.length),new n({values:M,index:F,ptr:H,size:N,datatype:p._datatype})}function l(p,g,y,N){if(!g||g.isIndex!==!0)throw new TypeError("Invalid index");var d=g.size(),w=g.isScalar(),x;if(Ve(y)?(x=y.size(),y=y.toArray()):x=er(y),w){if(x.length!==0)throw new TypeError("Scalar expected");p.set(g.min(),y,N)}else{if(d.length!==1&&d.length!==2)throw new Ke(d.length,p._size.length,"<");if(x.length<d.length){for(var b=0,E=0;d[b]===1&&x[b]===1;)b++;for(;d[b]===1;)E++,b++;y=Al(y,d.length,E,x)}if(!Ua(d,x))throw new Ke(d,x,">");if(d.length===1){var A=g.dimension(0);A.forEach(function(T,B){vr(T),p.set([T,0],y[B[0]],N)})}else{var S=g.dimension(0),D=g.dimension(1);S.forEach(function(T,B){vr(T),D.forEach(function(I,P){vr(I),p.set([T,I],y[B[0]][P[0]],N)})})}}return p}n.prototype.get=function(p){if(!cr(p))throw new TypeError("Array expected");if(p.length!==this._size.length)throw new Ke(p.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var g=p[0],y=p[1];vr(g,this._size[0]),vr(y,this._size[1]);var N=u(g,this._ptr[y],this._ptr[y+1],this._index);return N<this._ptr[y+1]&&this._index[N]===g?this._values[N]:0},n.prototype.set=function(p,g,y){if(!cr(p))throw new TypeError("Array expected");if(p.length!==this._size.length)throw new Ke(p.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var N=p[0],d=p[1],w=this._size[0],x=this._size[1],b=t,E=0;Wr(this._datatype)&&(b=e.find(t,[this._datatype,this._datatype])||t,E=e.convert(0,this._datatype)),(N>w-1||d>x-1)&&(m(this,Math.max(N+1,w),Math.max(d+1,x),y),w=this._size[0],x=this._size[1]),vr(N,w),vr(d,x);var A=u(N,this._ptr[d],this._ptr[d+1],this._index);return A<this._ptr[d+1]&&this._index[A]===N?b(g,E)?s(A,d,this._values,this._index,this._ptr):this._values[A]=g:b(g,E)||c(A,N,d,g,this._values,this._index,this._ptr),this};function u(p,g,y,N){if(y-g===0)return y;for(var d=g;d<y;d++)if(N[d]===p)return d;return g}function s(p,g,y,N,d){y.splice(p,1),N.splice(p,1);for(var w=g+1;w<d.length;w++)d[w]--}function c(p,g,y,N,d,w,x){d.splice(p,0,N),w.splice(p,0,g);for(var b=y+1;b<x.length;b++)x[b]++}n.prototype.resize=function(p,g,y){if(!Ft(p))throw new TypeError("Array or Matrix expected");var N=p.valueOf().map(w=>Array.isArray(w)&&w.length===1?w[0]:w);if(N.length!==2)throw new Error("Only two dimensions matrix are supported");N.forEach(function(w){if(!tr(w)||!qe(w)||w<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Ye(N)+")")});var d=y?this.clone():this;return m(d,N[0],N[1],g)};function m(p,g,y,N){var d=N||0,w=t,x=0;Wr(p._datatype)&&(w=e.find(t,[p._datatype,p._datatype])||t,x=e.convert(0,p._datatype),d=e.convert(d,p._datatype));var b=!w(d,x),E=p._size[0],A=p._size[1],S,D,T;if(y>A){for(D=A;D<y;D++)if(p._ptr[D]=p._values.length,b)for(S=0;S<E;S++)p._values.push(d),p._index.push(S);p._ptr[y]=p._values.length}else y<A&&(p._ptr.splice(y+1,A-y),p._values.splice(p._ptr[y],p._values.length),p._index.splice(p._ptr[y],p._index.length));if(A=y,g>E){if(b){var B=0;for(D=0;D<A;D++){p._ptr[D]=p._ptr[D]+B,T=p._ptr[D+1]+B;var I=0;for(S=E;S<g;S++,I++)p._values.splice(T+I,0,d),p._index.splice(T+I,0,S),B++}p._ptr[A]=p._values.length}}else if(g<E){var P=0;for(D=0;D<A;D++){p._ptr[D]=p._ptr[D]-P;var R=p._ptr[D],M=p._ptr[D+1]-P;for(T=R;T<M;T++)S=p._index[T],S>g-1&&(p._values.splice(T,1),p._index.splice(T,1),P++)}p._ptr[D]=p._values.length}return p._size[0]=g,p._size[1]=y,p}n.prototype.reshape=function(p,g){if(!cr(p))throw new TypeError("Array expected");if(p.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");p.forEach(function($){if(!tr($)||!qe($)||$<=-2||$===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Ye(p)+")")});var y=this._size[0]*this._size[1];p=Jo(p,y);var N=p[0]*p[1];if(y!==N)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var d=g?this.clone():this;if(this._size[0]===p[0]&&this._size[1]===p[1])return d;for(var w=[],x=0;x<d._ptr.length;x++)for(var b=0;b<d._ptr[x+1]-d._ptr[x];b++)w.push(x);for(var E=d._values.slice(),A=d._index.slice(),S=0;S<d._index.length;S++){var D=A[S],T=w[S],B=D*d._size[1]+T;w[S]=B%p[1],A[S]=Math.floor(B/p[1])}d._values.length=0,d._index.length=0,d._ptr.length=p[1]+1,d._size=p.slice();for(var I=0;I<d._ptr.length;I++)d._ptr[I]=0;for(var P=0;P<E.length;P++){var R=A[P],M=w[P],F=E[P],H=u(R,d._ptr[M],d._ptr[M+1],d._index);c(H,R,M,F,d._values,d._index,d._ptr)}return d},n.prototype.clone=function(){var p=new n({values:this._values?Ge(this._values):void 0,index:Ge(this._index),ptr:Ge(this._ptr),size:Ge(this._size),datatype:this._datatype});return p},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(p,g){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var y=this,N=this._size[0],d=this._size[1],w=fn(p),x=function(E,A,S){return w===1?p(E):w===2?p(E,[A,S]):p(E,[A,S],y)};return v(this,0,N-1,0,d-1,x,g)};function v(p,g,y,N,d,w,x){var b=[],E=[],A=[],S=t,D=0;Wr(p._datatype)&&(S=e.find(t,[p._datatype,p._datatype])||t,D=e.convert(0,p._datatype));for(var T=function(L,j,ae){L=w(L,j,ae),S(L,D)||(b.push(L),E.push(j))},B=N;B<=d;B++){A.push(b.length);var I=p._ptr[B],P=p._ptr[B+1];if(x)for(var R=I;R<P;R++){var M=p._index[R];M>=g&&M<=y&&T(p._values[R],M-g,B-N)}else{for(var F={},H=I;H<P;H++){var $=p._index[H];F[$]=p._values[H]}for(var k=g;k<=y;k++){var Q=k in F?F[k]:0;T(Q,k-g,B-N)}}}return A.push(b.length),new n({values:b,index:E,ptr:A,size:[y-g+1,d-N+1]})}n.prototype.forEach=function(p,g){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var y=this,N=this._size[0],d=this._size[1],w=0;w<d;w++){var x=this._ptr[w],b=this._ptr[w+1];if(g)for(var E=x;E<b;E++){var A=this._index[E];p(this._values[E],[A,w],y)}else{for(var S={},D=x;D<b;D++){var T=this._index[D];S[T]=this._values[D]}for(var B=0;B<N;B++){var I=B in S?S[B]:0;p(I,[B,w],y)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var p=this._size[1],g=0;g<p;g++)for(var y=this._ptr[g],N=this._ptr[g+1],d=y;d<N;d++){var w=this._index[d];yield{value:this._values[d],index:[w,g]}}},n.prototype.toArray=function(){return h(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return h(this._values,this._index,this._ptr,this._size,!1)};function h(p,g,y,N,d){var w=N[0],x=N[1],b=[],E,A;for(E=0;E<w;E++)for(b[E]=[],A=0;A<x;A++)b[E][A]=0;for(A=0;A<x;A++)for(var S=y[A],D=y[A+1],T=S;T<D;T++)E=g[T],b[E][A]=p?d?Ge(p[T]):p[T]:1;return b}return n.prototype.format=function(p){for(var g=this._size[0],y=this._size[1],N=this.density(),d="Sparse Matrix ["+Ye(g,p)+" x "+Ye(y,p)+"] density: "+Ye(N,p)+`
28
+ `,w=0;w<y;w++)for(var x=this._ptr[w],b=this._ptr[w+1],E=x;E<b;E++){var A=this._index[E];d+=`
29
+ (`+Ye(A,p)+", "+Ye(w,p)+") ==> "+(this._values?Ye(this._values[E],p):"X")}return d},n.prototype.toString=function(){return Ye(this.toArray())},n.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(p){if(p){if(rr(p)&&(p=p.toNumber()),!tr(p)||!qe(p))throw new TypeError("The parameter k must be an integer number")}else p=0;var g=p>0?p:0,y=p<0?-p:0,N=this._size[0],d=this._size[1],w=Math.min(N-y,d-g),x=[],b=[],E=[];E[0]=0;for(var A=g;A<d&&x.length<w;A++)for(var S=this._ptr[A],D=this._ptr[A+1],T=S;T<D;T++){var B=this._index[T];if(B===A-g+y){x.push(this._values[T]),b[x.length-1]=B-y;break}}return E.push(x.length),new n({values:x,index:b,ptr:E,size:[w,1]})},n.fromJSON=function(p){return new n(p)},n.diagonal=function(p,g,y,N,d){if(!cr(p))throw new TypeError("Array expected, size parameter");if(p.length!==2)throw new Error("Only two dimensions matrix are supported");if(p=p.map(function($){if(rr($)&&($=$.toNumber()),!tr($)||!qe($)||$<1)throw new Error("Size values must be positive integers");return $}),y){if(rr(y)&&(y=y.toNumber()),!tr(y)||!qe(y))throw new TypeError("The parameter k must be an integer number")}else y=0;var w=t,x=0;Wr(d)&&(w=e.find(t,[d,d])||t,x=e.convert(0,d));var b=y>0?y:0,E=y<0?-y:0,A=p[0],S=p[1],D=Math.min(A-E,S-b),T;if(cr(g)){if(g.length!==D)throw new Error("Invalid value array length");T=function(k){return g[k]}}else if(Ve(g)){var B=g.size();if(B.length!==1||B[0]!==D)throw new Error("Invalid matrix length");T=function(k){return g.get([k])}}else T=function(){return g};for(var I=[],P=[],R=[],M=0;M<S;M++){R.push(I.length);var F=M-b;if(F>=0&&F<D){var H=T(F);w(H,x)||(P.push(F+E),I.push(H))}}return R.push(I.length),new n({values:I,index:P,ptr:R,size:[A,S]})},n.prototype.swapRows=function(p,g){if(!tr(p)||!qe(p)||!tr(g)||!qe(g))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return vr(p,this._size[0]),vr(g,this._size[0]),n._swapRows(p,g,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(p,g,y,N,d){for(var w=N[p],x=N[p+1],b=w;b<x;b++)d(y[b],g[b])},n._swapRows=function(p,g,y,N,d,w){for(var x=0;x<y;x++){var b=w[x],E=w[x+1],A=u(p,b,E,d),S=u(g,b,E,d);if(A<E&&S<E&&d[A]===p&&d[S]===g){if(N){var D=N[A];N[A]=N[S],N[S]=D}continue}if(A<E&&d[A]===p&&(S>=E||d[S]!==g)){var T=N?N[A]:void 0;d.splice(S,0,g),N&&N.splice(S,0,T),d.splice(S<=A?A+1:A,1),N&&N.splice(S<=A?A+1:A,1);continue}if(S<E&&d[S]===g&&(A>=E||d[A]!==p)){var B=N?N[S]:void 0;d.splice(A,0,p),N&&N.splice(A,0,B),d.splice(A<=S?S+1:S,1),N&&N.splice(A<=S?S+1:S,1)}}},n},{isClass:!0}),My="number",Fy=["typed"];function Ty(r){var e=r.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(e){var t={"0b":2,"0o":8,"0x":16}[e[1]],a=e[2],n=e[3];return{input:r,radix:t,integerPart:a,fractionalPart:n}}else return null}function By(r){for(var e=parseInt(r.integerPart,r.radix),t=0,a=0;a<r.fractionalPart.length;a++){var n=parseInt(r.fractionalPart[a],r.radix);t+=n/Math.pow(r.radix,a+1)}var i=e+t;if(isNaN(i))throw new SyntaxError('String "'+r.input+'" is no valid number');return i}var $y=q(My,Fy,r=>{var{typed:e}=r,t=e("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var i=Ty(n);if(i)return By(i);var o=0,f=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);f&&(o=Number(f[2]),n=f[1]);var l=Number(n);if(isNaN(l))throw new SyntaxError('String "'+n+'" is no valid number');if(f){if(l>2**o-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));l>=2**(o-1)&&(l=l-2**o)}return l},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:function(n){throw new Error("Second argument with valueless unit expected")},null:function(n){return 0},"Unit, string | Unit":function(n,i){return n.toNumber(i)},"Array | Matrix":e.referToSelf(a=>n=>je(n,a))});return t.fromJSON=function(a){return parseFloat(a.value)},t}),af="string",Oy=["typed"],Iy=q(af,Oy,r=>{var{typed:e}=r;return e(af,{"":function(){return""},number:Cn,null:function(a){return"null"},boolean:function(a){return a+""},string:function(a){return a},"Array | Matrix":e.referToSelf(t=>a=>je(a,t)),any:function(a){return String(a)}})}),of="boolean",Ry=["typed"],_y=q(of,Ry,r=>{var{typed:e}=r;return e(of,{"":function(){return!1},boolean:function(a){return a},number:function(a){return!!a},null:function(a){return!1},BigNumber:function(a){return!a.isZero()},string:function(a){var n=a.toLowerCase();if(n==="true")return!0;if(n==="false")return!1;var i=Number(a);if(a!==""&&!isNaN(i))return!!i;throw new Error('Cannot convert "'+a+'" to a boolean')},"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),qy="bignumber",zy=["typed","BigNumber"],Py=q(qy,zy,r=>{var{typed:e,BigNumber:t}=r;return e("bignumber",{"":function(){return new t(0)},number:function(n){return new t(n+"")},string:function(n){var i=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(i){var o=i[2],f=t(i[1]),l=new t(2).pow(Number(o));if(f.gt(l.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var u=new t(2).pow(Number(o)-1);return f.gte(u)?f.sub(l):f}return new t(n)},BigNumber:function(n){return n},Fraction:function(n){return new t(n.n).div(n.d).times(n.s)},null:function(n){return new t(0)},"Array | Matrix":e.referToSelf(a=>n=>je(n,a))})}),Uy="complex",Ly=["typed","Complex"],ky=q(Uy,Ly,r=>{var{typed:e,Complex:t}=r;return e("complex",{"":function(){return t.ZERO},number:function(n){return new t(n,0)},"number, number":function(n,i){return new t(n,i)},"BigNumber, BigNumber":function(n,i){return new t(n.toNumber(),i.toNumber())},Fraction:function(n){return new t(n.valueOf(),0)},Complex:function(n){return n.clone()},string:function(n){return t(n)},null:function(n){return t(0)},Object:function(n){if("re"in n&&"im"in n)return new t(n.re,n.im);if("r"in n&&"phi"in n||"abs"in n&&"arg"in n)return new t(n);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":e.referToSelf(a=>n=>je(n,a))})}),Vy="fraction",Gy=["typed","Fraction"],Hy=q(Vy,Gy,r=>{var{typed:e,Fraction:t}=r;return e("fraction",{number:function(n){if(!isFinite(n)||isNaN(n))throw new Error(n+" cannot be represented as a fraction");return new t(n)},string:function(n){return new t(n)},"number, number":function(n,i){return new t(n,i)},null:function(n){return new t(0)},BigNumber:function(n){return new t(n.toString())},Fraction:function(n){return n},Object:function(n){return new t(n)},"Array | Matrix":e.referToSelf(a=>n=>je(n,a))})}),sf="matrix",Zy=["typed","Matrix","DenseMatrix","SparseMatrix"],Jy=q(sf,Zy,r=>{var{typed:e,Matrix:t,DenseMatrix:a,SparseMatrix:n}=r;return e(sf,{"":function(){return i([])},string:function(f){return i([],f)},"string, string":function(f,l){return i([],f,l)},Array:function(f){return i(f)},Matrix:function(f){return i(f,f.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(o,f,l){if(f==="dense"||f==="default"||f===void 0)return new a(o,l);if(f==="sparse")return new n(o,l);throw new TypeError("Unknown matrix type "+JSON.stringify(f)+".")}}),uf="matrixFromFunction",Xy=["typed","matrix","isZero"],Wy=q(uf,Xy,r=>{var{typed:e,matrix:t,isZero:a}=r;return e(uf,{"Array | Matrix, function, string, string":function(o,f,l,u){return n(o,f,l,u)},"Array | Matrix, function, string":function(o,f,l){return n(o,f,l)},"Matrix, function":function(o,f){return n(o,f,"dense")},"Array, function":function(o,f){return n(o,f,"dense").toArray()},"Array | Matrix, string, function":function(o,f,l){return n(o,l,f)},"Array | Matrix, string, string, function":function(o,f,l,u){return n(o,u,f,l)}});function n(i,o,f,l){var u;return l!==void 0?u=t(f,l):u=t(f),u.resize(i),u.forEach(function(s,c){var m=o(c);a(m)||u.set(c,m)}),u}}),lf="matrixFromRows",Yy=["typed","matrix","flatten","size"],Qy=q(lf,Yy,r=>{var{typed:e,matrix:t,flatten:a,size:n}=r;return e(lf,{"...Array":function(l){return i(l)},"...Matrix":function(l){return t(i(l.map(u=>u.toArray())))}});function i(f){if(f.length===0)throw new TypeError("At least one row is needed to construct a matrix.");var l=o(f[0]),u=[];for(var s of f){var c=o(s);if(c!==l)throw new TypeError("The vectors had different length: "+(l|0)+" \u2260 "+(c|0));u.push(a(s))}return u}function o(f){var l=n(f);if(l.length===1)return l[0];if(l.length===2){if(l[0]===1)return l[1];if(l[1]===1)return l[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),cf="matrixFromColumns",Ky=["typed","matrix","flatten","size"],jy=q(cf,Ky,r=>{var{typed:e,matrix:t,flatten:a,size:n}=r;return e(cf,{"...Array":function(l){return i(l)},"...Matrix":function(l){return t(i(l.map(u=>u.toArray())))}});function i(f){if(f.length===0)throw new TypeError("At least one column is needed to construct a matrix.");for(var l=o(f[0]),u=[],s=0;s<l;s++)u[s]=[];for(var c of f){var m=o(c);if(m!==l)throw new TypeError("The vectors had different length: "+(l|0)+" \u2260 "+(m|0));for(var v=a(c),h=0;h<l;h++)u[h].push(v[h])}return u}function o(f){var l=n(f);if(l.length===1)return l[0];if(l.length===2){if(l[0]===1)return l[1];if(l[1]===1)return l[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),ff="splitUnit",eb=["typed"],rb=q(ff,eb,r=>{var{typed:e}=r;return e(ff,{"Unit, Array":function(a,n){return a.splitUnit(n)}})}),mf="unaryMinus",tb=["typed"],nb=q(mf,tb,r=>{var{typed:e}=r;return e(mf,{number:rc,"Complex | BigNumber | Fraction":t=>t.neg(),Unit:e.referToSelf(t=>a=>{var n=a.clone();return n.value=e.find(t,n.valueType())(a.value),n}),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),vf="unaryPlus",ab=["typed","config","BigNumber"],ib=q(vf,ab,r=>{var{typed:e,config:t,BigNumber:a}=r;return e(vf,{number:tc,Complex:function(i){return i},BigNumber:function(i){return i},Fraction:function(i){return i},Unit:function(i){return i.clone()},"Array | Matrix":e.referToSelf(n=>i=>je(i,n)),"boolean | string":function(i){return t.number==="BigNumber"?new a(+i):+i}})}),pf="abs",ob=["typed"],sb=q(pf,ob,r=>{var{typed:e}=r;return e(pf,{number:Kl,"Complex | BigNumber | Fraction | Unit":t=>t.abs(),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),hf="apply",ub=["typed","isInteger"],df=q(hf,ub,r=>{var{typed:e,isInteger:t}=r;return e(hf,{"Array | Matrix, number | BigNumber, function":function(n,i,o){if(!t(i))throw new TypeError("Integer number expected for dimension");var f=Array.isArray(n)?er(n):n.size();if(i<0||i>=f.length)throw new dt(i,f.length);return Ve(n)?n.create($i(n.valueOf(),i,o)):$i(n,i,o)}})});function $i(r,e,t){var a,n,i;if(e<=0)if(Array.isArray(r[0])){for(i=lb(r),n=[],a=0;a<i.length;a++)n[a]=$i(i[a],e-1,t);return n}else return t(r);else{for(n=[],a=0;a<r.length;a++)n[a]=$i(r[a],e-1,t);return n}}function lb(r){var e=r.length,t=r[0].length,a,n,i=[];for(n=0;n<t;n++){var o=[];for(a=0;a<e;a++)o.push(r[a][n]);i.push(o)}return i}var gf="addScalar",cb=["typed"],fb=q(gf,cb,r=>{var{typed:e}=r;return e(gf,{"number, number":jl,"Complex, Complex":function(a,n){return a.add(n)},"BigNumber, BigNumber":function(a,n){return a.plus(n)},"Fraction, Fraction":function(a,n){return a.add(n)},"Unit, Unit":e.referToSelf(t=>(a,n)=>{if(a.value===null||a.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!a.equalBase(n))throw new Error("Units do not match");var i=a.clone();return i.value=e.find(t,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i})})}),yf="cbrt",mb=["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],vb=q(yf,mb,r=>{var{config:e,typed:t,isNegative:a,unaryMinus:n,matrix:i,Complex:o,BigNumber:f,Fraction:l}=r;return t(yf,{number:Ga,Complex:u,"Complex, boolean":u,BigNumber:function(m){return m.cbrt()},Unit:s});function u(c,m){var v=c.arg()/3,h=c.abs(),p=new o(Ga(h),0).mul(new o(0,v).exp());if(m){var g=[p,new o(Ga(h),0).mul(new o(0,v+Math.PI*2/3).exp()),new o(Ga(h),0).mul(new o(0,v-Math.PI*2/3).exp())];return e.matrix==="Array"?g:i(g)}else return p}function s(c){if(c.value&&kt(c.value)){var m=c.clone();return m.value=1,m=m.pow(1/3),m.value=u(c.value),m}else{var v=a(c.value);v&&(c.value=n(c.value));var h;rr(c.value)?h=new f(1).div(3):za(c.value)?h=new l(1,3):h=1/3;var p=c.pow(h);return v&&(p.value=n(p.value)),p}}}),pb="matAlgo11xS0s",hb=["typed","equalScalar"],Lr=q(pb,hb,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o,f){var l=n._values,u=n._index,s=n._ptr,c=n._size,m=n._datatype;if(!l)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=c[0],h=c[1],p,g=t,y=0,N=o;typeof m=="string"&&(p=m,g=e.find(t,[p,p]),y=e.convert(0,p),i=e.convert(i,p),N=e.find(o,[p,p]));for(var d=[],w=[],x=[],b=0;b<h;b++){x[b]=w.length;for(var E=s[b],A=s[b+1],S=E;S<A;S++){var D=u[S],T=f?N(i,l[S]):N(l[S],i);g(T,y)||(w.push(D),d.push(T))}}return x[h]=w.length,n.createSparseMatrix({values:d,index:w,ptr:x,size:[v,h],datatype:p})}}),db="matAlgo12xSfs",gb=["typed","DenseMatrix"],Ir=q(db,gb,r=>{var{typed:e,DenseMatrix:t}=r;return function(n,i,o,f){var l=n._values,u=n._index,s=n._ptr,c=n._size,m=n._datatype;if(!l)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=c[0],h=c[1],p,g=o;typeof m=="string"&&(p=m,i=e.convert(i,p),g=e.find(o,[p,p]));for(var y=[],N=[],d=[],w=0;w<h;w++){for(var x=w+1,b=s[w],E=s[w+1],A=b;A<E;A++){var S=u[A];N[S]=l[A],d[S]=x}for(var D=0;D<v;D++)w===0&&(y[D]=[]),d[D]===x?y[D][w]=f?g(i,N[D]):g(N[D],i):y[D][w]=f?g(i,0):g(0,i)}return new t({data:y,size:[v,h],datatype:p})}}),yb="matAlgo14xDs",bb=["typed"],xt=q(yb,bb,r=>{var{typed:e}=r;return function(n,i,o,f){var l=n._data,u=n._size,s=n._datatype,c,m=o;typeof s=="string"&&(c=s,i=e.convert(i,c),m=e.find(o,[c,c]));var v=u.length>0?t(m,0,u,u[0],l,i,f):[];return n.createDenseMatrix({data:v,size:Ge(u),datatype:c})};function t(a,n,i,o,f,l,u){var s=[];if(n===i.length-1)for(var c=0;c<o;c++)s[c]=u?a(l,f[c]):a(f[c],l);else for(var m=0;m<o;m++)s[m]=t(a,n+1,i,i[n+1],f[m],l,u);return s}}),us="ceil",xb=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],wb=q(us,["typed","config","round"],r=>{var{typed:e,config:t,round:a}=r;return e(us,{number:function(i){return nt(i,a(i),t.epsilon)?a(i):Math.ceil(i)},"number, number":function(i,o){if(nt(i,a(i,o),t.epsilon))return a(i,o);var[f,l]="".concat(i,"e").split("e"),u=Math.ceil(Number("".concat(f,"e").concat(Number(l)+o)));return[f,l]="".concat(u,"e").split("e"),Number("".concat(f,"e").concat(Number(l)-o))}})}),Nb=q(us,xb,r=>{var{typed:e,config:t,round:a,matrix:n,equalScalar:i,zeros:o,DenseMatrix:f}=r,l=Lr({typed:e,equalScalar:i}),u=Ir({typed:e,DenseMatrix:f}),s=xt({typed:e}),c=wb({typed:e,config:t,round:a});return e("ceil",{number:c.signatures.number,"number,number":c.signatures["number,number"],Complex:function(v){return v.ceil()},"Complex, number":function(v,h){return v.ceil(h)},"Complex, BigNumber":function(v,h){return v.ceil(h.toNumber())},BigNumber:function(v){return Bt(v,a(v),t.epsilon)?a(v):v.ceil()},"BigNumber, BigNumber":function(v,h){return Bt(v,a(v,h),t.epsilon)?a(v,h):v.toDecimalPlaces(h.toNumber(),cn.ROUND_CEIL)},Fraction:function(v){return v.ceil()},"Fraction, number":function(v,h){return v.ceil(h)},"Fraction, BigNumber":function(v,h){return v.ceil(h.toNumber())},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array, number | BigNumber":e.referToSelf(m=>(v,h)=>je(v,p=>m(p,h))),"SparseMatrix, number | BigNumber":e.referToSelf(m=>(v,h)=>l(v,h,m,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(m=>(v,h)=>s(v,h,m,!1)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,h)=>s(n(h),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,h)=>i(v,0)?o(h.size(),h.storage()):h.storage()==="dense"?s(h,v,m,!0):u(h,v,m,!0))})}),bf="cube",Db=["typed"],Ab=q(bf,Db,r=>{var{typed:e}=r;return e(bf,{number:nc,Complex:function(a){return a.mul(a).mul(a)},BigNumber:function(a){return a.times(a).times(a)},Fraction:function(a){return a.pow(3)},Unit:function(a){return a.pow(3)}})}),xf="exp",Eb=["typed"],Sb=q(xf,Eb,r=>{var{typed:e}=r;return e(xf,{number:ac,Complex:function(a){return a.exp()},BigNumber:function(a){return a.exp()}})}),wf="expm1",Cb=["typed","Complex"],Mb=q(wf,Cb,r=>{var{typed:e,Complex:t}=r;return e(wf,{number:ic,Complex:function(n){var i=Math.exp(n.re);return new t(i*Math.cos(n.im)-1,i*Math.sin(n.im))},BigNumber:function(n){return n.exp().minus(1)}})}),ls="fix",Fb=["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],Tb=q(ls,["typed","ceil","floor"],r=>{var{typed:e,ceil:t,floor:a}=r;return e(ls,{number:function(i){return i>0?a(i):t(i)},"number, number":function(i,o){return i>0?a(i,o):t(i,o)}})}),Bb=q(ls,Fb,r=>{var{typed:e,Complex:t,matrix:a,ceil:n,floor:i,equalScalar:o,zeros:f,DenseMatrix:l}=r,u=Ir({typed:e,DenseMatrix:l}),s=xt({typed:e}),c=Tb({typed:e,ceil:n,floor:i});return e("fix",{number:c.signatures.number,"number, number | BigNumber":c.signatures["number,number"],Complex:function(v){return new t(v.re>0?Math.floor(v.re):Math.ceil(v.re),v.im>0?Math.floor(v.im):Math.ceil(v.im))},"Complex, number":function(v,h){return new t(v.re>0?i(v.re,h):n(v.re,h),v.im>0?i(v.im,h):n(v.im,h))},"Complex, BigNumber":function(v,h){var p=h.toNumber();return new t(v.re>0?i(v.re,p):n(v.re,p),v.im>0?i(v.im,p):n(v.im,p))},BigNumber:function(v){return v.isNegative()?n(v):i(v)},"BigNumber, number | BigNumber":function(v,h){return v.isNegative()?n(v,h):i(v,h)},Fraction:function(v){return v.s<0?v.ceil():v.floor()},"Fraction, number | BigNumber":function(v,h){return v.s<0?n(v,h):i(v,h)},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array | Matrix, number | BigNumber":e.referToSelf(m=>(v,h)=>je(v,p=>m(p,h))),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,h)=>s(a(h),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,h)=>o(v,0)?f(h.size(),h.storage()):h.storage()==="dense"?s(h,v,m,!0):u(h,v,m,!0))})}),cs="floor",$b=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],Ob=q(cs,["typed","config","round"],r=>{var{typed:e,config:t,round:a}=r;return e(cs,{number:function(i){return nt(i,a(i),t.epsilon)?a(i):Math.floor(i)},"number, number":function(i,o){if(nt(i,a(i,o),t.epsilon))return a(i,o);var[f,l]="".concat(i,"e").split("e"),u=Math.floor(Number("".concat(f,"e").concat(Number(l)+o)));return[f,l]="".concat(u,"e").split("e"),Number("".concat(f,"e").concat(Number(l)-o))}})}),Ib=q(cs,$b,r=>{var{typed:e,config:t,round:a,matrix:n,equalScalar:i,zeros:o,DenseMatrix:f}=r,l=Lr({typed:e,equalScalar:i}),u=Ir({typed:e,DenseMatrix:f}),s=xt({typed:e}),c=Ob({typed:e,config:t,round:a});return e("floor",{number:c.signatures.number,"number,number":c.signatures["number,number"],Complex:function(v){return v.floor()},"Complex, number":function(v,h){return v.floor(h)},"Complex, BigNumber":function(v,h){return v.floor(h.toNumber())},BigNumber:function(v){return Bt(v,a(v),t.epsilon)?a(v):v.floor()},"BigNumber, BigNumber":function(v,h){return Bt(v,a(v,h),t.epsilon)?a(v,h):v.toDecimalPlaces(h.toNumber(),cn.ROUND_FLOOR)},Fraction:function(v){return v.floor()},"Fraction, number":function(v,h){return v.floor(h)},"Fraction, BigNumber":function(v,h){return v.floor(h.toNumber())},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array, number | BigNumber":e.referToSelf(m=>(v,h)=>je(v,p=>m(p,h))),"SparseMatrix, number | BigNumber":e.referToSelf(m=>(v,h)=>l(v,h,m,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(m=>(v,h)=>s(v,h,m,!1)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,h)=>s(n(h),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,h)=>i(v,0)?o(h.size(),h.storage()):h.storage()==="dense"?s(h,v,m,!0):u(h,v,m,!0))})}),Rb="matAlgo01xDSid",_b=["typed"],mn=q(Rb,_b,r=>{var{typed:e}=r;return function(a,n,i,o){var f=a._data,l=a._size,u=a._datatype,s=n._values,c=n._index,m=n._ptr,v=n._size,h=n._datatype;if(l.length!==v.length)throw new Ke(l.length,v.length);if(l[0]!==v[0]||l[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+v+")");if(!s)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var p=l[0],g=l[1],y=typeof u=="string"&&u===h?u:void 0,N=y?e.find(i,[y,y]):i,d,w,x=[];for(d=0;d<p;d++)x[d]=[];var b=[],E=[];for(w=0;w<g;w++){for(var A=w+1,S=m[w],D=m[w+1],T=S;T<D;T++)d=c[T],b[d]=o?N(s[T],f[d][w]):N(f[d][w],s[T]),E[d]=A;for(d=0;d<p;d++)E[d]===A?x[d][w]=b[d]:x[d][w]=f[d][w]}return a.createDenseMatrix({data:x,size:[p,g],datatype:y})}}),qb="matAlgo04xSidSid",zb=["typed","equalScalar"],fs=q(qb,zb,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o){var f=n._values,l=n._index,u=n._ptr,s=n._size,c=n._datatype,m=i._values,v=i._index,h=i._ptr,p=i._size,g=i._datatype;if(s.length!==p.length)throw new Ke(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");var y=s[0],N=s[1],d,w=t,x=0,b=o;typeof c=="string"&&c===g&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),b=e.find(o,[d,d]));var E=f&&m?[]:void 0,A=[],S=[],D=f&&m?[]:void 0,T=f&&m?[]:void 0,B=[],I=[],P,R,M,F,H;for(R=0;R<N;R++){S[R]=A.length;var $=R+1;for(F=u[R],H=u[R+1],M=F;M<H;M++)P=l[M],A.push(P),B[P]=$,D&&(D[P]=f[M]);for(F=h[R],H=h[R+1],M=F;M<H;M++)if(P=v[M],B[P]===$){if(D){var k=b(D[P],m[M]);w(k,x)?B[P]=null:D[P]=k}}else A.push(P),I[P]=$,T&&(T[P]=m[M]);if(D&&T)for(M=S[R];M<A.length;)P=A[M],B[P]===$?(E[M]=D[P],M++):I[P]===$?(E[M]=T[P],M++):A.splice(M,1)}return S[N]=A.length,n.createSparseMatrix({values:E,index:A,ptr:S,size:[y,N],datatype:d})}}),Pb="matAlgo10xSids",Ub=["typed","DenseMatrix"],Tn=q(Pb,Ub,r=>{var{typed:e,DenseMatrix:t}=r;return function(n,i,o,f){var l=n._values,u=n._index,s=n._ptr,c=n._size,m=n._datatype;if(!l)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=c[0],h=c[1],p,g=o;typeof m=="string"&&(p=m,i=e.convert(i,p),g=e.find(o,[p,p]));for(var y=[],N=[],d=[],w=0;w<h;w++){for(var x=w+1,b=s[w],E=s[w+1],A=b;A<E;A++){var S=u[A];N[S]=l[A],d[S]=x}for(var D=0;D<v;D++)w===0&&(y[D]=[]),d[D]===x?y[D][w]=f?g(i,N[D]):g(N[D],i):y[D][w]=i}return new t({data:y,size:[v,h],datatype:p})}}),Lb="matAlgo13xDD",kb=["typed"],Vb=q(Lb,kb,r=>{var{typed:e}=r;return function(n,i,o){var f=n._data,l=n._size,u=n._datatype,s=i._data,c=i._size,m=i._datatype,v=[];if(l.length!==c.length)throw new Ke(l.length,c.length);for(var h=0;h<l.length;h++){if(l[h]!==c[h])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+c+")");v[h]=l[h]}var p,g=o;typeof u=="string"&&u===m&&(p=u,g=e.find(o,[p,p]));var y=v.length>0?t(g,0,v,v[0],f,s):[];return n.createDenseMatrix({data:y,size:v,datatype:p})};function t(a,n,i,o,f,l){var u=[];if(n===i.length-1)for(var s=0;s<o;s++)u[s]=a(f[s],l[s]);else for(var c=0;c<o;c++)u[c]=t(a,n+1,i,i[n+1],f[c],l[c]);return u}}),Gb="broadcast",Hb=["concat"],Zb=q(Gb,Hb,r=>{var{concat:e}=r;return function(i,o){var f=Math.max(i._size.length,o._size.length);if(i._size.length===o._size.length&&i._size.every((g,y)=>g===o._size[y]))return[i,o];for(var l=t(i._size,f,0),u=t(o._size,f,0),s=[],c=0;c<f;c++)s[c]=Math.max(l[c],u[c]);for(var m=0;m<f;m++)n(l,s,m),n(u,s,m);var v=i.clone(),h=o.clone();v._size.length<f?v.reshape(t(v._size,f,1)):h._size.length<f&&h.reshape(t(h._size,f,1));for(var p=0;p<f;p++)v._size[p]<s[p]&&(v=a(v,s[p],p)),h._size[p]<s[p]&&(h=a(h,s[p],p));return[v,h]};function t(i,o,f){return[...Array(o-i.length).fill(f),...i]}function a(i,o,f){return e(...Array(o).fill(i),f)}function n(i,o,f){if(i[f]<o[f]&i[f]>1)throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(i,") not possible to broadcast dimension ").concat(f," with size ").concat(i[f]," to size ").concat(o[f]))}}),Jb="matrixAlgorithmSuite",Xb=["typed","matrix","concat"],dr=q(Jb,Xb,r=>{var{typed:e,matrix:t,concat:a}=r,n=Vb({typed:e}),i=xt({typed:e}),o=Zb({concat:a});return function(l){var u=l.elop,s=l.SD||l.DS,c;u?(c={"DenseMatrix, DenseMatrix":(p,g)=>n(...o(p,g),u),"Array, Array":(p,g)=>n(...o(t(p),t(g)),u).valueOf(),"Array, DenseMatrix":(p,g)=>n(...o(t(p),g),u),"DenseMatrix, Array":(p,g)=>n(...o(p,t(g)),u)},l.SS&&(c["SparseMatrix, SparseMatrix"]=(p,g)=>l.SS(...o(p,g),u,!1)),l.DS&&(c["DenseMatrix, SparseMatrix"]=(p,g)=>l.DS(...o(p,g),u,!1),c["Array, SparseMatrix"]=(p,g)=>l.DS(...o(t(p),g),u,!1)),s&&(c["SparseMatrix, DenseMatrix"]=(p,g)=>s(...o(g,p),u,!0),c["SparseMatrix, Array"]=(p,g)=>s(...o(t(g),p),u,!0))):(c={"DenseMatrix, DenseMatrix":e.referToSelf(p=>(g,y)=>n(...o(g,y),p)),"Array, Array":e.referToSelf(p=>(g,y)=>n(...o(t(g),t(y)),p).valueOf()),"Array, DenseMatrix":e.referToSelf(p=>(g,y)=>n(...o(t(g),y),p)),"DenseMatrix, Array":e.referToSelf(p=>(g,y)=>n(...o(g,t(y)),p))},l.SS&&(c["SparseMatrix, SparseMatrix"]=e.referToSelf(p=>(g,y)=>l.SS(...o(g,y),p,!1))),l.DS&&(c["DenseMatrix, SparseMatrix"]=e.referToSelf(p=>(g,y)=>l.DS(...o(g,y),p,!1)),c["Array, SparseMatrix"]=e.referToSelf(p=>(g,y)=>l.DS(...o(t(g),y),p,!1))),s&&(c["SparseMatrix, DenseMatrix"]=e.referToSelf(p=>(g,y)=>s(...o(y,g),p,!0)),c["SparseMatrix, Array"]=e.referToSelf(p=>(g,y)=>s(...o(t(y),g),p,!0))));var m=l.scalar||"any",v=l.Ds||l.Ss;v&&(u?(c["DenseMatrix,"+m]=(p,g)=>i(p,g,u,!1),c[m+", DenseMatrix"]=(p,g)=>i(g,p,u,!0),c["Array,"+m]=(p,g)=>i(t(p),g,u,!1).valueOf(),c[m+", Array"]=(p,g)=>i(t(g),p,u,!0).valueOf()):(c["DenseMatrix,"+m]=e.referToSelf(p=>(g,y)=>i(g,y,p,!1)),c[m+", DenseMatrix"]=e.referToSelf(p=>(g,y)=>i(y,g,p,!0)),c["Array,"+m]=e.referToSelf(p=>(g,y)=>i(t(g),y,p,!1).valueOf()),c[m+", Array"]=e.referToSelf(p=>(g,y)=>i(t(y),g,p,!0).valueOf())));var h=l.sS!==void 0?l.sS:l.Ss;return u?(l.Ss&&(c["SparseMatrix,"+m]=(p,g)=>l.Ss(p,g,u,!1)),h&&(c[m+", SparseMatrix"]=(p,g)=>h(g,p,u,!0))):(l.Ss&&(c["SparseMatrix,"+m]=e.referToSelf(p=>(g,y)=>l.Ss(g,y,p,!1))),h&&(c[m+", SparseMatrix"]=e.referToSelf(p=>(g,y)=>h(y,g,p,!0)))),u&&u.signatures&&ll(c,u.signatures),c}});function Bn(r,e,t,a){if(!(this instanceof Bn))throw new SyntaxError("Constructor must be called with the new operator");this.fn=r,this.count=e,this.min=t,this.max=a,this.message="Wrong number of arguments in function "+r+" ("+e+" provided, "+t+(a!=null?"-"+a:"")+" expected)",this.stack=new Error().stack}Bn.prototype=new Error,Bn.prototype.constructor=Error,Bn.prototype.name="ArgumentsError",Bn.prototype.isArgumentsError=!0;var Nf="gcd",Wb=["typed","matrix","equalScalar","BigNumber","DenseMatrix","concat"],ms="number | BigNumber | Fraction | Matrix | Array",Yb="".concat(ms,", ").concat(ms,", ...").concat(ms);function Df(r){return!r.some(e=>Array.isArray(e))}var Qb=q(Nf,Wb,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n,DenseMatrix:i,concat:o}=r,f=mn({typed:e}),l=fs({typed:e,equalScalar:a}),u=Tn({typed:e,DenseMatrix:i}),s=dr({typed:e,matrix:t,concat:o});return e(Nf,{"number, number":oc,"BigNumber, BigNumber":c,"Fraction, Fraction":(m,v)=>m.gcd(v)},s({SS:l,DS:f,Ss:u}),{[Yb]:e.referToSelf(m=>(v,h,p)=>{for(var g=m(v,h),y=0;y<p.length;y++)g=m(g,p[y]);return g}),Array:e.referToSelf(m=>v=>{if(v.length===1&&Array.isArray(v[0])&&Df(v[0]))return m(...v[0]);if(Df(v))return m(...v);throw new Bn("gcd() supports only 1d matrices!")}),Matrix:e.referToSelf(m=>v=>m(v.toArray()))});function c(m,v){if(!m.isInt()||!v.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var h=new n(0);!v.isZero();){var p=m.mod(v);m=v,v=p}return m.lt(h)?m.neg():m}}),Kb="matAlgo02xDS0",jb=["typed","equalScalar"],wt=q(Kb,jb,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o,f){var l=n._data,u=n._size,s=n._datatype,c=i._values,m=i._index,v=i._ptr,h=i._size,p=i._datatype;if(u.length!==h.length)throw new Ke(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var g=u[0],y=u[1],N,d=t,w=0,x=o;typeof s=="string"&&s===p&&(N=s,d=e.find(t,[N,N]),w=e.convert(0,N),x=e.find(o,[N,N]));for(var b=[],E=[],A=[],S=0;S<y;S++){A[S]=E.length;for(var D=v[S],T=v[S+1],B=D;B<T;B++){var I=m[B],P=f?x(c[B],l[I][S]):x(l[I][S],c[B]);d(P,w)||(E.push(I),b.push(P))}}return A[y]=E.length,i.createSparseMatrix({values:b,index:E,ptr:A,size:[g,y],datatype:N})}}),ex="matAlgo06xS0S0",rx=["typed","equalScalar"],Oi=q(ex,rx,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o){var f=n._values,l=n._size,u=n._datatype,s=i._values,c=i._size,m=i._datatype;if(l.length!==c.length)throw new Ke(l.length,c.length);if(l[0]!==c[0]||l[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+c+")");var v=l[0],h=l[1],p,g=t,y=0,N=o;typeof u=="string"&&u===m&&(p=u,g=e.find(t,[p,p]),y=e.convert(0,p),N=e.find(o,[p,p]));for(var d=f&&s?[]:void 0,w=[],x=[],b=d?[]:void 0,E=[],A=[],S=0;S<h;S++){x[S]=w.length;var D=S+1;if(Yl(n,S,E,b,A,D,w,N),Yl(i,S,E,b,A,D,w,N),b)for(var T=x[S];T<w.length;){var B=w[T];if(A[B]===D){var I=b[B];g(I,y)?w.splice(T,1):(d.push(I),T++)}else w.splice(T,1)}else for(var P=x[S];P<w.length;){var R=w[P];A[R]!==D?w.splice(P,1):P++}}return x[h]=w.length,n.createSparseMatrix({values:d,index:w,ptr:x,size:[v,h],datatype:p})}}),Af="lcm",tx=["typed","matrix","equalScalar","concat"],nx=q(Af,tx,r=>{var{typed:e,matrix:t,equalScalar:a,concat:n}=r,i=wt({typed:e,equalScalar:a}),o=Oi({typed:e,equalScalar:a}),f=Lr({typed:e,equalScalar:a}),l=dr({typed:e,matrix:t,concat:n}),u="number | BigNumber | Fraction | Matrix | Array",s={};return s["".concat(u,", ").concat(u,", ...").concat(u)]=e.referToSelf(m=>(v,h,p)=>{for(var g=m(v,h),y=0;y<p.length;y++)g=m(g,p[y]);return g}),e(Af,{"number, number":sc,"BigNumber, BigNumber":c,"Fraction, Fraction":(m,v)=>m.lcm(v)},l({SS:o,DS:i,Ss:f}),s);function c(m,v){if(!m.isInt()||!v.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(m.isZero())return m;if(v.isZero())return v;for(var h=m.times(v);!v.isZero();){var p=v;v=m.mod(p),m=p}return h.div(m).abs()}}),Ef="log10",ax=["typed","config","Complex"],ix=q(Ef,ax,r=>{var{typed:e,config:t,Complex:a}=r;return e(Ef,{number:function(i){return i>=0||t.predictable?uc(i):new a(i,0).log().div(Math.LN10)},Complex:function(i){return new a(i).log().div(Math.LN10)},BigNumber:function(i){return!i.isNegative()||t.predictable?i.log():new a(i.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":e.referToSelf(n=>i=>je(i,n))})}),Sf="log2",ox=["typed","config","Complex"],sx=q(Sf,ox,r=>{var{typed:e,config:t,Complex:a}=r;return e(Sf,{number:function(o){return o>=0||t.predictable?lc(o):n(new a(o,0))},Complex:n,BigNumber:function(o){return!o.isNegative()||t.predictable?o.log(2):n(new a(o.toNumber(),0))},"Array | Matrix":e.referToSelf(i=>o=>je(o,i))});function n(i){var o=Math.sqrt(i.re*i.re+i.im*i.im);return new a(Math.log2?Math.log2(o):Math.log(o)/Math.LN2,Math.atan2(i.im,i.re)/Math.LN2)}}),ux="matAlgo03xDSf",lx=["typed"],Yr=q(ux,lx,r=>{var{typed:e}=r;return function(a,n,i,o){var f=a._data,l=a._size,u=a._datatype,s=n._values,c=n._index,m=n._ptr,v=n._size,h=n._datatype;if(l.length!==v.length)throw new Ke(l.length,v.length);if(l[0]!==v[0]||l[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+v+")");if(!s)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var p=l[0],g=l[1],y,N=0,d=i;typeof u=="string"&&u===h&&(y=u,N=e.convert(0,y),d=e.find(i,[y,y]));for(var w=[],x=0;x<p;x++)w[x]=[];for(var b=[],E=[],A=0;A<g;A++){for(var S=A+1,D=m[A],T=m[A+1],B=D;B<T;B++){var I=c[B];b[I]=o?d(s[B],f[I][A]):d(f[I][A],s[B]),E[I]=S}for(var P=0;P<p;P++)E[P]===S?w[P][A]=b[P]:w[P][A]=o?d(N,f[P][A]):d(f[P][A],N)}return a.createDenseMatrix({data:w,size:[p,g],datatype:y})}}),cx="matAlgo05xSfSf",fx=["typed","equalScalar"],Ii=q(cx,fx,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o){var f=n._values,l=n._index,u=n._ptr,s=n._size,c=n._datatype,m=i._values,v=i._index,h=i._ptr,p=i._size,g=i._datatype;if(s.length!==p.length)throw new Ke(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");var y=s[0],N=s[1],d,w=t,x=0,b=o;typeof c=="string"&&c===g&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),b=e.find(o,[d,d]));var E=f&&m?[]:void 0,A=[],S=[],D=E?[]:void 0,T=E?[]:void 0,B=[],I=[],P,R,M,F;for(R=0;R<N;R++){S[R]=A.length;var H=R+1;for(M=u[R],F=u[R+1];M<F;M++)P=l[M],A.push(P),B[P]=H,D&&(D[P]=f[M]);for(M=h[R],F=h[R+1];M<F;M++)P=v[M],B[P]!==H&&A.push(P),I[P]=H,T&&(T[P]=m[M]);if(E)for(M=S[R];M<A.length;){P=A[M];var $=B[P],k=I[P];if($===H||k===H){var Q=$===H?D[P]:x,K=k===H?T[P]:x,L=b(Q,K);w(L,x)?A.splice(M,1):(E.push(L),M++)}}}return S[N]=A.length,n.createSparseMatrix({values:E,index:A,ptr:S,size:[y,N],datatype:d})}}),Cf="mod",mx=["typed","matrix","equalScalar","DenseMatrix","concat"],vx=q(Cf,mx,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n,concat:i}=r,o=wt({typed:e,equalScalar:a}),f=Yr({typed:e}),l=Ii({typed:e,equalScalar:a}),u=Lr({typed:e,equalScalar:a}),s=Ir({typed:e,DenseMatrix:n}),c=dr({typed:e,matrix:t,concat:i});return e(Cf,{"number, number":cc,"BigNumber, BigNumber":function(v,h){if(h.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return h.isZero()?v:v.mod(h)},"Fraction, Fraction":function(v,h){if(h.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return v.compare(0)>=0?v.mod(h):v.mod(h).add(h).mod(h)}},c({SS:l,DS:f,SD:o,Ss:u,sS:s}))}),px="multiplyScalar",hx=["typed"],dx=q(px,hx,r=>{var{typed:e}=r;return e("multiplyScalar",{"number, number":ec,"Complex, Complex":function(a,n){return a.mul(n)},"BigNumber, BigNumber":function(a,n){return a.times(n)},"Fraction, Fraction":function(a,n){return a.mul(n)},"number | Fraction | BigNumber | Complex, Unit":(t,a)=>a.multiply(t),"Unit, number | Fraction | BigNumber | Complex | Unit":(t,a)=>t.multiply(a)})}),Mf="multiply",gx=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],yx=q(Mf,gx,r=>{var{typed:e,matrix:t,addScalar:a,multiplyScalar:n,equalScalar:i,dot:o}=r,f=Lr({typed:e,equalScalar:i}),l=xt({typed:e});function u(x,b){switch(x.length){case 1:switch(b.length){case 1:if(x[0]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(x[0]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+x[0]+") must match Matrix rows ("+b[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+b.length+" dimensions)")}break;case 2:switch(b.length){case 1:if(x[1]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+x[1]+") must match Vector length ("+b[0]+")");break;case 2:if(x[1]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+x[1]+") must match Matrix B rows ("+b[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+b.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+x.length+" dimensions)")}}function s(x,b,E){if(E===0)throw new Error("Cannot multiply two empty vectors");return o(x,b)}function c(x,b){if(b.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return m(x,b)}function m(x,b){var E=x._data,A=x._size,S=x._datatype,D=b._data,T=b._size,B=b._datatype,I=A[0],P=T[1],R,M=a,F=n;S&&B&&S===B&&typeof S=="string"&&(R=S,M=e.find(a,[R,R]),F=e.find(n,[R,R]));for(var H=[],$=0;$<P;$++){for(var k=F(E[0],D[0][$]),Q=1;Q<I;Q++)k=M(k,F(E[Q],D[Q][$]));H[$]=k}return x.createDenseMatrix({data:H,size:[P],datatype:R})}var v=e("_multiplyMatrixVector",{"DenseMatrix, any":p,"SparseMatrix, any":N}),h=e("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":g,"DenseMatrix, SparseMatrix":y,"SparseMatrix, DenseMatrix":d,"SparseMatrix, SparseMatrix":w});function p(x,b){var E=x._data,A=x._size,S=x._datatype,D=b._data,T=b._datatype,B=A[0],I=A[1],P,R=a,M=n;S&&T&&S===T&&typeof S=="string"&&(P=S,R=e.find(a,[P,P]),M=e.find(n,[P,P]));for(var F=[],H=0;H<B;H++){for(var $=E[H],k=M($[0],D[0]),Q=1;Q<I;Q++)k=R(k,M($[Q],D[Q]));F[H]=k}return x.createDenseMatrix({data:F,size:[B],datatype:P})}function g(x,b){var E=x._data,A=x._size,S=x._datatype,D=b._data,T=b._size,B=b._datatype,I=A[0],P=A[1],R=T[1],M,F=a,H=n;S&&B&&S===B&&typeof S=="string"&&(M=S,F=e.find(a,[M,M]),H=e.find(n,[M,M]));for(var $=[],k=0;k<I;k++){var Q=E[k];$[k]=[];for(var K=0;K<R;K++){for(var L=H(Q[0],D[0][K]),j=1;j<P;j++)L=F(L,H(Q[j],D[j][K]));$[k][K]=L}}return x.createDenseMatrix({data:$,size:[I,R],datatype:M})}function y(x,b){var E=x._data,A=x._size,S=x._datatype,D=b._values,T=b._index,B=b._ptr,I=b._size,P=b._datatype;if(!D)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var R=A[0],M=I[1],F,H=a,$=n,k=i,Q=0;S&&P&&S===P&&typeof S=="string"&&(F=S,H=e.find(a,[F,F]),$=e.find(n,[F,F]),k=e.find(i,[F,F]),Q=e.convert(0,F));for(var K=[],L=[],j=[],ae=b.createSparseMatrix({values:K,index:L,ptr:j,size:[R,M],datatype:F}),re=0;re<M;re++){j[re]=L.length;var fe=B[re],he=B[re+1];if(he>fe)for(var ce=0,ie=0;ie<R;ie++){for(var Ae=ie+1,Oe=void 0,Ce=fe;Ce<he;Ce++){var $e=T[Ce];ce!==Ae?(Oe=$(E[ie][$e],D[Ce]),ce=Ae):Oe=H(Oe,$(E[ie][$e],D[Ce]))}ce===Ae&&!k(Oe,Q)&&(L.push(ie),K.push(Oe))}}return j[M]=L.length,ae}function N(x,b){var E=x._values,A=x._index,S=x._ptr,D=x._datatype;if(!E)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var T=b._data,B=b._datatype,I=x._size[0],P=b._size[0],R=[],M=[],F=[],H,$=a,k=n,Q=i,K=0;D&&B&&D===B&&typeof D=="string"&&(H=D,$=e.find(a,[H,H]),k=e.find(n,[H,H]),Q=e.find(i,[H,H]),K=e.convert(0,H));var L=[],j=[];F[0]=0;for(var ae=0;ae<P;ae++){var re=T[ae];if(!Q(re,K))for(var fe=S[ae],he=S[ae+1],ce=fe;ce<he;ce++){var ie=A[ce];j[ie]?L[ie]=$(L[ie],k(re,E[ce])):(j[ie]=!0,M.push(ie),L[ie]=k(re,E[ce]))}}for(var Ae=M.length,Oe=0;Oe<Ae;Oe++){var Ce=M[Oe];R[Oe]=L[Ce]}return F[1]=M.length,x.createSparseMatrix({values:R,index:M,ptr:F,size:[I,1],datatype:H})}function d(x,b){var E=x._values,A=x._index,S=x._ptr,D=x._datatype;if(!E)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var T=b._data,B=b._datatype,I=x._size[0],P=b._size[0],R=b._size[1],M,F=a,H=n,$=i,k=0;D&&B&&D===B&&typeof D=="string"&&(M=D,F=e.find(a,[M,M]),H=e.find(n,[M,M]),$=e.find(i,[M,M]),k=e.convert(0,M));for(var Q=[],K=[],L=[],j=x.createSparseMatrix({values:Q,index:K,ptr:L,size:[I,R],datatype:M}),ae=[],re=[],fe=0;fe<R;fe++){L[fe]=K.length;for(var he=fe+1,ce=0;ce<P;ce++){var ie=T[ce][fe];if(!$(ie,k))for(var Ae=S[ce],Oe=S[ce+1],Ce=Ae;Ce<Oe;Ce++){var $e=A[Ce];re[$e]!==he?(re[$e]=he,K.push($e),ae[$e]=H(ie,E[Ce])):ae[$e]=F(ae[$e],H(ie,E[Ce]))}}for(var V=L[fe],X=K.length,oe=V;oe<X;oe++){var G=K[oe];Q[oe]=ae[G]}}return L[R]=K.length,j}function w(x,b){var E=x._values,A=x._index,S=x._ptr,D=x._datatype,T=b._values,B=b._index,I=b._ptr,P=b._datatype,R=x._size[0],M=b._size[1],F=E&&T,H,$=a,k=n;D&&P&&D===P&&typeof D=="string"&&(H=D,$=e.find(a,[H,H]),k=e.find(n,[H,H]));for(var Q=F?[]:void 0,K=[],L=[],j=x.createSparseMatrix({values:Q,index:K,ptr:L,size:[R,M],datatype:H}),ae=F?[]:void 0,re=[],fe,he,ce,ie,Ae,Oe,Ce,$e,V=0;V<M;V++){L[V]=K.length;var X=V+1;for(Ae=I[V],Oe=I[V+1],ie=Ae;ie<Oe;ie++)if($e=B[ie],F)for(he=S[$e],ce=S[$e+1],fe=he;fe<ce;fe++)Ce=A[fe],re[Ce]!==X?(re[Ce]=X,K.push(Ce),ae[Ce]=k(T[ie],E[fe])):ae[Ce]=$(ae[Ce],k(T[ie],E[fe]));else for(he=S[$e],ce=S[$e+1],fe=he;fe<ce;fe++)Ce=A[fe],re[Ce]!==X&&(re[Ce]=X,K.push(Ce));if(F)for(var oe=L[V],G=K.length,Y=oe;Y<G;Y++){var te=K[Y];Q[Y]=ae[te]}}return L[M]=K.length,j}return e(Mf,n,{"Array, Array":e.referTo("Matrix, Matrix",x=>(b,E)=>{u(er(b),er(E));var A=x(t(b),t(E));return Ve(A)?A.valueOf():A}),"Matrix, Matrix":function(b,E){var A=b.size(),S=E.size();return u(A,S),A.length===1?S.length===1?s(b,E,A[0]):c(b,E):S.length===1?v(b,E):h(b,E)},"Matrix, Array":e.referTo("Matrix,Matrix",x=>(b,E)=>x(b,t(E))),"Array, Matrix":e.referToSelf(x=>(b,E)=>x(t(b,E.storage()),E)),"SparseMatrix, any":function(b,E){return f(b,E,n,!1)},"DenseMatrix, any":function(b,E){return l(b,E,n,!1)},"any, SparseMatrix":function(b,E){return f(E,b,n,!0)},"any, DenseMatrix":function(b,E){return l(E,b,n,!0)},"Array, any":function(b,E){return l(t(b),E,n,!1).valueOf()},"any, Array":function(b,E){return l(t(E),b,n,!0).valueOf()},"any, any":n,"any, any, ...any":e.referToSelf(x=>(b,E,A)=>{for(var S=x(b,E),D=0;D<A.length;D++)S=x(S,A[D]);return S})})}),Ff="nthRoot",bx=["typed","matrix","equalScalar","BigNumber","concat"],xx=q(Ff,bx,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n,concat:i}=r,o=mn({typed:e}),f=wt({typed:e,equalScalar:a}),l=Oi({typed:e,equalScalar:a}),u=Lr({typed:e,equalScalar:a}),s=dr({typed:e,matrix:t,concat:i});function c(){throw new Error("Complex number not supported in function nthRoot. Use nthRoots instead.")}return e(Ff,{number:fc,"number, number":fc,BigNumber:v=>m(v,new n(2)),"BigNumber, BigNumber":m,Complex:c,"Complex, number":c,Array:e.referTo("DenseMatrix,number",v=>h=>v(t(h),2).valueOf()),DenseMatrix:e.referTo("DenseMatrix,number",v=>h=>v(h,2)),SparseMatrix:e.referTo("SparseMatrix,number",v=>h=>v(h,2)),"SparseMatrix, SparseMatrix":e.referToSelf(v=>(h,p)=>{if(p.density()===1)return l(h,p,v);throw new Error("Root must be non-zero")}),"DenseMatrix, SparseMatrix":e.referToSelf(v=>(h,p)=>{if(p.density()===1)return o(h,p,v,!1);throw new Error("Root must be non-zero")}),"Array, SparseMatrix":e.referTo("DenseMatrix,SparseMatrix",v=>(h,p)=>v(t(h),p)),"number | BigNumber, SparseMatrix":e.referToSelf(v=>(h,p)=>{if(p.density()===1)return u(p,h,v,!0);throw new Error("Root must be non-zero")})},s({scalar:"number | BigNumber",SD:f,Ss:u,sS:!1}));function m(v,h){var p=n.precision,g=n.clone({precision:p+2}),y=new n(0),N=new g(1),d=h.isNegative();if(d&&(h=h.neg()),h.isZero())throw new Error("Root must be non-zero");if(v.isNegative()&&!h.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(v.isZero())return d?new g(1/0):0;if(!v.isFinite())return d?y:v;var w=v.abs().pow(N.div(h));return w=v.isNeg()?w.neg():w,new n((d?N.div(w):w).toPrecision(p))}}),Tf="sign",wx=["typed","BigNumber","Fraction","complex"],Nx=q(Tf,wx,r=>{var{typed:e,BigNumber:t,complex:a,Fraction:n}=r;return e(Tf,{number:os,Complex:function(o){return o.im===0?a(os(o.re)):o.sign()},BigNumber:function(o){return new t(o.cmp(0))},Fraction:function(o){return new n(o.s,1)},"Array | Matrix":e.referToSelf(i=>o=>je(o,i)),Unit:e.referToSelf(i=>o=>{if(!o._isDerived()&&o.units[0].unit.offset!==0)throw new TypeError("sign is ambiguous for units with offset");return e.find(i,o.valueType())(o.value)})})}),Dx="sqrt",Ax=["config","typed","Complex"],Ex=q(Dx,Ax,r=>{var{config:e,typed:t,Complex:a}=r;return t("sqrt",{number:n,Complex:function(o){return o.sqrt()},BigNumber:function(o){return!o.isNegative()||e.predictable?o.sqrt():n(o.toNumber())},Unit:function(o){return o.pow(.5)}});function n(i){return isNaN(i)?NaN:i>=0||e.predictable?Math.sqrt(i):new a(i,0).sqrt()}}),Bf="square",Sx=["typed"],Cx=q(Bf,Sx,r=>{var{typed:e}=r;return e(Bf,{number:mc,Complex:function(a){return a.mul(a)},BigNumber:function(a){return a.times(a)},Fraction:function(a){return a.mul(a)},Unit:function(a){return a.pow(2)}})}),$f="subtract",Mx=["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix","concat"],Fx=q($f,Mx,r=>{var{typed:e,matrix:t,equalScalar:a,addScalar:n,unaryMinus:i,DenseMatrix:o,concat:f}=r,l=mn({typed:e}),u=Yr({typed:e}),s=Ii({typed:e,equalScalar:a}),c=Tn({typed:e,DenseMatrix:o}),m=Ir({typed:e,DenseMatrix:o}),v=dr({typed:e,matrix:t,concat:f});return e($f,{"number, number":(h,p)=>h-p,"Complex, Complex":(h,p)=>h.sub(p),"BigNumber, BigNumber":(h,p)=>h.minus(p),"Fraction, Fraction":(h,p)=>h.sub(p),"Unit, Unit":e.referToSelf(h=>(p,g)=>{if(p.value===null)throw new Error("Parameter x contains a unit with undefined value");if(g.value===null)throw new Error("Parameter y contains a unit with undefined value");if(!p.equalBase(g))throw new Error("Units do not match");var y=p.clone();return y.value=e.find(h,[y.valueType(),g.valueType()])(y.value,g.value),y.fixPrefix=!1,y})},v({SS:s,DS:l,SD:u,Ss:m,sS:c}))}),Of="xgcd",Tx=["typed","config","matrix","BigNumber"],Bx=q(Of,Tx,r=>{var{typed:e,config:t,matrix:a,BigNumber:n}=r;return e(Of,{"number, number":function(f,l){var u=vc(f,l);return t.matrix==="Array"?u:a(u)},"BigNumber, BigNumber":i});function i(o,f){var l,u,s,c=new n(0),m=new n(1),v=c,h=m,p=m,g=c;if(!o.isInt()||!f.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!f.isZero();)u=o.div(f).floor(),s=o.mod(f),l=v,v=h.minus(u.times(v)),h=l,l=p,p=g.minus(u.times(p)),g=l,o=f,f=s;var y;return o.lt(c)?y=[o.neg(),h.neg(),g.neg()]:y=[o,o.isZero()?0:h,g],t.matrix==="Array"?y:a(y)}}),If="invmod",$x=["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],Ox=q(If,$x,r=>{var{typed:e,config:t,BigNumber:a,xgcd:n,equal:i,smaller:o,mod:f,add:l,isInteger:u}=r;return e(If,{"number, number":s,"BigNumber, BigNumber":s});function s(c,m){if(!u(c)||!u(m))throw new Error("Parameters in function invmod must be integer numbers");if(c=f(c,m),i(m,0))throw new Error("Divisor must be non zero");var v=n(c,m);v=v.valueOf();var[h,p]=v;return i(h,a(1))?(p=f(p,m),o(p,a(0))&&(p=l(p,m)),p):NaN}}),Ix="matAlgo09xS0Sf",Rx=["typed","equalScalar"],Rf=q(Ix,Rx,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o){var f=n._values,l=n._index,u=n._ptr,s=n._size,c=n._datatype,m=i._values,v=i._index,h=i._ptr,p=i._size,g=i._datatype;if(s.length!==p.length)throw new Ke(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");var y=s[0],N=s[1],d,w=t,x=0,b=o;typeof c=="string"&&c===g&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),b=e.find(o,[d,d]));var E=f&&m?[]:void 0,A=[],S=[],D=E?[]:void 0,T=[],B,I,P,R,M;for(I=0;I<N;I++){S[I]=A.length;var F=I+1;if(D)for(R=h[I],M=h[I+1],P=R;P<M;P++)B=v[P],T[B]=F,D[B]=m[P];for(R=u[I],M=u[I+1],P=R;P<M;P++)if(B=l[P],D){var H=T[B]===F?D[B]:x,$=b(f[P],H);w($,x)||(A.push(B),E.push($))}else A.push(B)}return S[N]=A.length,n.createSparseMatrix({values:E,index:A,ptr:S,size:[y,N],datatype:d})}}),_f="dotMultiply",_x=["typed","matrix","equalScalar","multiplyScalar","concat"],qx=q(_f,_x,r=>{var{typed:e,matrix:t,equalScalar:a,multiplyScalar:n,concat:i}=r,o=wt({typed:e,equalScalar:a}),f=Rf({typed:e,equalScalar:a}),l=Lr({typed:e,equalScalar:a}),u=dr({typed:e,matrix:t,concat:i});return e(_f,u({elop:n,SS:f,DS:o,Ss:l}))});function zx(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function bitAnd");var t=r.constructor;if(r.isNaN()||e.isNaN())return new t(NaN);if(r.isZero()||e.eq(-1)||r.eq(e))return r;if(e.isZero()||r.eq(-1))return e;if(!r.isFinite()||!e.isFinite()){if(!r.isFinite()&&!e.isFinite())return r.isNegative()===e.isNegative()?r:new t(0);if(!r.isFinite())return e.isNegative()?r:r.isNegative()?new t(0):e;if(!e.isFinite())return r.isNegative()?e:e.isNegative()?new t(0):r}return vs(r,e,function(a,n){return a&n})}function Ha(r){if(r.isFinite()&&!r.isInteger())throw new Error("Integer expected in function bitNot");var e=r.constructor,t=e.precision;e.config({precision:1e9});var a=r.plus(new e(1));return a.s=-a.s||null,e.config({precision:t}),a}function Px(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function bitOr");var t=r.constructor;if(r.isNaN()||e.isNaN())return new t(NaN);var a=new t(-1);return r.isZero()||e.eq(a)||r.eq(e)?e:e.isZero()||r.eq(a)?r:!r.isFinite()||!e.isFinite()?!r.isFinite()&&!r.isNegative()&&e.isNegative()||r.isNegative()&&!e.isNegative()&&!e.isFinite()?a:r.isNegative()&&e.isNegative()?r.isFinite()?r:e:r.isFinite()?e:r:vs(r,e,function(n,i){return n|i})}function vs(r,e,t){var a=r.constructor,n,i,o=+(r.s<0),f=+(e.s<0);if(o){n=Ri(Ha(r));for(var l=0;l<n.length;++l)n[l]^=1}else n=Ri(r);if(f){i=Ri(Ha(e));for(var u=0;u<i.length;++u)i[u]^=1}else i=Ri(e);var s,c,m;n.length<=i.length?(s=n,c=i,m=o):(s=i,c=n,m=f);var v=s.length,h=c.length,p=t(o,f)^1,g=new a(p^1),y=new a(1),N=new a(2),d=a.precision;for(a.config({precision:1e9});v>0;)t(s[--v],c[--h])===p&&(g=g.plus(y)),y=y.times(N);for(;h>0;)t(m,c[--h])===p&&(g=g.plus(y)),y=y.times(N);return a.config({precision:d}),p===0&&(g.s=-g.s),g}function Ri(r){for(var e=r.d,t=e[0]+"",a=1;a<e.length;++a){for(var n=e[a]+"",i=7-n.length;i--;)n="0"+n;t+=n}for(var o=t.length;t.charAt(o)==="0";)o--;var f=r.e,l=t.slice(0,o+1||1),u=l.length;if(f>0)if(++f>u)for(f-=u;f--;)l+="0";else f<u&&(l=l.slice(0,f)+"."+l.slice(f));for(var s=[0],c=0;c<l.length;){for(var m=s.length;m--;)s[m]*=10;s[0]+=parseInt(l.charAt(c++));for(var v=0;v<s.length;++v)s[v]>1&&((s[v+1]===null||s[v+1]===void 0)&&(s[v+1]=0),s[v+1]+=s[v]>>1,s[v]&=1)}return s.reverse()}function Ux(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function bitXor");var t=r.constructor;if(r.isNaN()||e.isNaN())return new t(NaN);if(r.isZero())return e;if(e.isZero())return r;if(r.eq(e))return new t(0);var a=new t(-1);return r.eq(a)?Ha(e):e.eq(a)?Ha(r):!r.isFinite()||!e.isFinite()?!r.isFinite()&&!e.isFinite()?a:new t(r.isNegative()===e.isNegative()?1/0:-1/0):vs(r,e,function(n,i){return n^i})}function Lx(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function leftShift");var t=r.constructor;return r.isNaN()||e.isNaN()||e.isNegative()&&!e.isZero()?new t(NaN):r.isZero()||e.isZero()?r:!r.isFinite()&&!e.isFinite()?new t(NaN):e.lt(55)?r.times(Math.pow(2,e.toNumber())+""):r.times(new t(2).pow(e))}function kx(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function rightArithShift");var t=r.constructor;return r.isNaN()||e.isNaN()||e.isNegative()&&!e.isZero()?new t(NaN):r.isZero()||e.isZero()?r:e.isFinite()?e.lt(55)?r.div(Math.pow(2,e.toNumber())+"").floor():r.div(new t(2).pow(e)).floor():r.isNegative()?new t(-1):r.isFinite()?new t(0):new t(NaN)}var qf="bitAnd",Vx=["typed","matrix","equalScalar","concat"],Gx=q(qf,Vx,r=>{var{typed:e,matrix:t,equalScalar:a,concat:n}=r,i=wt({typed:e,equalScalar:a}),o=Oi({typed:e,equalScalar:a}),f=Lr({typed:e,equalScalar:a}),l=dr({typed:e,matrix:t,concat:n});return e(qf,{"number, number":dc,"BigNumber, BigNumber":zx},l({SS:o,DS:i,Ss:f}))}),zf="bitNot",Hx=["typed"],Zx=q(zf,Hx,r=>{var{typed:e}=r;return e(zf,{number:gc,BigNumber:Ha,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Pf="bitOr",Jx=["typed","matrix","equalScalar","DenseMatrix","concat"],Xx=q(Pf,Jx,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n,concat:i}=r,o=mn({typed:e}),f=fs({typed:e,equalScalar:a}),l=Tn({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:t,concat:i});return e(Pf,{"number, number":yc,"BigNumber, BigNumber":Px},u({SS:f,DS:o,Ss:l}))}),Wx="matAlgo07xSSf",Yx=["typed","DenseMatrix"],$t=q(Wx,Yx,r=>{var{typed:e,DenseMatrix:t}=r;return function(i,o,f){var l=i._size,u=i._datatype,s=o._size,c=o._datatype;if(l.length!==s.length)throw new Ke(l.length,s.length);if(l[0]!==s[0]||l[1]!==s[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+s+")");var m=l[0],v=l[1],h,p=0,g=f;typeof u=="string"&&u===c&&(h=u,p=e.convert(0,h),g=e.find(f,[h,h]));var y,N,d=[];for(y=0;y<m;y++)d[y]=[];var w=[],x=[],b=[],E=[];for(N=0;N<v;N++){var A=N+1;for(a(i,N,b,w,A),a(o,N,E,x,A),y=0;y<m;y++){var S=b[y]===A?w[y]:p,D=E[y]===A?x[y]:p;d[y][N]=g(S,D)}}return new t({data:d,size:[m,v],datatype:h})};function a(n,i,o,f,l){for(var u=n._values,s=n._index,c=n._ptr,m=c[i],v=c[i+1];m<v;m++){var h=s[m];o[h]=l,f[h]=u[m]}}}),Uf="bitXor",Qx=["typed","matrix","DenseMatrix","concat"],Kx=q(Uf,Qx,r=>{var{typed:e,matrix:t,DenseMatrix:a,concat:n}=r,i=Yr({typed:e}),o=$t({typed:e,DenseMatrix:a}),f=Ir({typed:e,DenseMatrix:a}),l=dr({typed:e,matrix:t,concat:n});return e(Uf,{"number, number":bc,"BigNumber, BigNumber":Ux},l({SS:o,DS:i,Ss:f}))}),Lf="arg",jx=["typed"],ew=q(Lf,jx,r=>{var{typed:e}=r;return e(Lf,{number:function(a){return Math.atan2(0,a)},BigNumber:function(a){return a.constructor.atan2(0,a)},Complex:function(a){return a.arg()},"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),kf="conj",rw=["typed"],tw=q(kf,rw,r=>{var{typed:e}=r;return e(kf,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.conjugate(),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Vf="im",nw=["typed"],aw=q(Vf,nw,r=>{var{typed:e}=r;return e(Vf,{number:()=>0,"BigNumber | Fraction":t=>t.mul(0),Complex:t=>t.im,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Gf="re",iw=["typed"],ow=q(Gf,iw,r=>{var{typed:e}=r;return e(Gf,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.re,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Hf="not",sw=["typed"],uw=q(Hf,sw,r=>{var{typed:e}=r;return e(Hf,{"null | undefined":()=>!0,number:Ac,Complex:function(a){return a.re===0&&a.im===0},BigNumber:function(a){return a.isZero()||a.isNaN()},Unit:e.referToSelf(t=>a=>e.find(t,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Zf="or",lw=["typed","matrix","equalScalar","DenseMatrix","concat"],cw=q(Zf,lw,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n,concat:i}=r,o=Yr({typed:e}),f=Ii({typed:e,equalScalar:a}),l=Ir({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:t,concat:i});return e(Zf,{"number, number":Ec,"Complex, Complex":function(c,m){return c.re!==0||c.im!==0||m.re!==0||m.im!==0},"BigNumber, BigNumber":function(c,m){return!c.isZero()&&!c.isNaN()||!m.isZero()&&!m.isNaN()},"Unit, Unit":e.referToSelf(s=>(c,m)=>s(c.value||0,m.value||0))},u({SS:f,DS:o,Ss:l}))}),Jf="xor",fw=["typed","matrix","DenseMatrix","concat"],mw=q(Jf,fw,r=>{var{typed:e,matrix:t,DenseMatrix:a,concat:n}=r,i=Yr({typed:e}),o=$t({typed:e,DenseMatrix:a}),f=Ir({typed:e,DenseMatrix:a}),l=dr({typed:e,matrix:t,concat:n});return e(Jf,{"number, number":Sc,"Complex, Complex":function(s,c){return(s.re!==0||s.im!==0)!=(c.re!==0||c.im!==0)},"BigNumber, BigNumber":function(s,c){return(!s.isZero()&&!s.isNaN())!=(!c.isZero()&&!c.isNaN())},"Unit, Unit":e.referToSelf(u=>(s,c)=>u(s.value||0,c.value||0))},l({SS:o,DS:i,Ss:f}))}),Xf="concat",vw=["typed","matrix","isInteger"],Wf=q(Xf,vw,r=>{var{typed:e,matrix:t,isInteger:a}=r;return e(Xf,{"...Array | Matrix | number | BigNumber":function(i){var o,f=i.length,l=-1,u,s=!1,c=[];for(o=0;o<f;o++){var m=i[o];if(Ve(m)&&(s=!0),tr(m)||rr(m)){if(o!==f-1)throw new Error("Dimension must be specified as last argument");if(u=l,l=m.valueOf(),!a(l))throw new TypeError("Integer number expected for dimension");if(l<0||o>0&&l>u)throw new dt(l,u+1)}else{var v=Ge(m).valueOf(),h=er(v);if(c[o]=v,u=l,l=h.length-1,o>0&&l!==u)throw new Ke(u+1,l+1)}}if(c.length===0)throw new SyntaxError("At least one matrix expected");for(var p=c.shift();c.length;)p=Yf(p,c.shift(),l,0);return s?t(p):p},"...string":function(i){return i.join("")}})});function Yf(r,e,t,a){if(a<t){if(r.length!==e.length)throw new Ke(r.length,e.length);for(var n=[],i=0;i<r.length;i++)n[i]=Yf(r[i],e[i],t,a+1);return n}else return r.concat(e)}var Qf="column",pw=["typed","Index","matrix","range"],Kf=q(Qf,pw,r=>{var{typed:e,Index:t,matrix:a,range:n}=r;return e(Qf,{"Matrix, number":i,"Array, number":function(f,l){return i(a(Ge(f)),l).valueOf()}});function i(o,f){if(o.size().length!==2)throw new Error("Only two dimensional matrix is supported");vr(f,o.size()[1]);var l=n(0,o.size()[0]),u=new t(l,f),s=o.subset(u);return Ve(s)?s:a([[s]])}}),jf="count",hw=["typed","size","prod"],dw=q(jf,hw,r=>{var{typed:e,size:t,prod:a}=r;return e(jf,{string:function(i){return i.length},"Matrix | Array":function(i){return a(t(i))}})}),em="cross",gw=["typed","matrix","subtract","multiply"],yw=q(em,gw,r=>{var{typed:e,matrix:t,subtract:a,multiply:n}=r;return e(em,{"Matrix, Matrix":function(f,l){return t(i(f.toArray(),l.toArray()))},"Matrix, Array":function(f,l){return t(i(f.toArray(),l))},"Array, Matrix":function(f,l){return t(i(f,l.toArray()))},"Array, Array":i});function i(o,f){var l=Math.max(er(o).length,er(f).length);o=pi(o),f=pi(f);var u=er(o),s=er(f);if(u.length!==1||s.length!==1||u[0]!==3||s[0]!==3)throw new RangeError("Vectors with length 3 expected (Size A = ["+u.join(", ")+"], B = ["+s.join(", ")+"])");var c=[a(n(o[1],f[2]),n(o[2],f[1])),a(n(o[2],f[0]),n(o[0],f[2])),a(n(o[0],f[1]),n(o[1],f[0]))];return l>1?[c]:c}}),rm="diag",bw=["typed","matrix","DenseMatrix","SparseMatrix"],xw=q(rm,bw,r=>{var{typed:e,matrix:t,DenseMatrix:a,SparseMatrix:n}=r;return e(rm,{Array:function(u){return i(u,0,er(u),null)},"Array, number":function(u,s){return i(u,s,er(u),null)},"Array, BigNumber":function(u,s){return i(u,s.toNumber(),er(u),null)},"Array, string":function(u,s){return i(u,0,er(u),s)},"Array, number, string":function(u,s,c){return i(u,s,er(u),c)},"Array, BigNumber, string":function(u,s,c){return i(u,s.toNumber(),er(u),c)},Matrix:function(u){return i(u,0,u.size(),u.storage())},"Matrix, number":function(u,s){return i(u,s,u.size(),u.storage())},"Matrix, BigNumber":function(u,s){return i(u,s.toNumber(),u.size(),u.storage())},"Matrix, string":function(u,s){return i(u,0,u.size(),s)},"Matrix, number, string":function(u,s,c){return i(u,s,u.size(),c)},"Matrix, BigNumber, string":function(u,s,c){return i(u,s.toNumber(),u.size(),c)}});function i(l,u,s,c){if(!qe(u))throw new TypeError("Second parameter in function diag must be an integer");var m=u>0?u:0,v=u<0?-u:0;switch(s.length){case 1:return o(l,u,c,s[0],v,m);case 2:return f(l,u,c,s,v,m)}throw new RangeError("Matrix for function diag must be 2 dimensional")}function o(l,u,s,c,m,v){var h=[c+m,c+v];if(s&&s!=="sparse"&&s!=="dense")throw new TypeError("Unknown matrix type ".concat(s,'"'));var p=s==="sparse"?n.diagonal(h,l,u):a.diagonal(h,l,u);return s!==null?p:p.valueOf()}function f(l,u,s,c,m,v){if(Ve(l)){var h=l.diagonal(u);return s!==null?s!==h.storage()?t(h,s):h:h.valueOf()}for(var p=Math.min(c[0]-m,c[1]-v),g=[],y=0;y<p;y++)g[y]=l[y+m][y+v];return s!==null?t(g):g}}),ww="filter",Nw=["typed"],Dw=q(ww,Nw,r=>{var{typed:e}=r;return e("filter",{"Array, function":tm,"Matrix, function":function(a,n){return a.create(tm(a.toArray(),n))},"Array, RegExp":di,"Matrix, RegExp":function(a,n){return a.create(di(a.toArray(),n))}})});function tm(r,e){var t=fn(e);return Sl(r,function(a,n,i){return t===1?e(a):t===2?e(a,[n]):e(a,[n],i)})}var nm="flatten",Aw=["typed","matrix"],Ew=q(nm,Aw,r=>{var{typed:e,matrix:t}=r;return e(nm,{Array:function(n){return or(n)},Matrix:function(n){var i=or(n.toArray());return t(i)}})}),am="forEach",Sw=["typed"],Cw=q(am,Sw,r=>{var{typed:e}=r;return e(am,{"Array, function":Mw,"Matrix, function":function(a,n){a.forEach(n)}})});function Mw(r,e){var t=fn(e),a=function n(i,o){Array.isArray(i)?hi(i,function(f,l){n(f,o.concat(l))}):t===1?e(i):t===2?e(i,o):e(i,o,r)};a(r,[])}var im="getMatrixDataType",Fw=["typed"],Tw=q(im,Fw,r=>{var{typed:e}=r;return e(im,{Array:function(a){return La(a,br)},Matrix:function(a){return a.getDataType()}})}),om="identity",Bw=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],$w=q(om,Bw,r=>{var{typed:e,config:t,matrix:a,BigNumber:n,DenseMatrix:i,SparseMatrix:o}=r;return e(om,{"":function(){return t.matrix==="Matrix"?a([]):[]},string:function(s){return a(s)},"number | BigNumber":function(s){return l(s,s,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(s,c){return l(s,s,c)},"number | BigNumber, number | BigNumber":function(s,c){return l(s,c,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(s,c,m){return l(s,c,m)},Array:function(s){return f(s)},"Array, string":function(s,c){return f(s,c)},Matrix:function(s){return f(s.valueOf(),s.storage())},"Matrix, string":function(s,c){return f(s.valueOf(),c)}});function f(u,s){switch(u.length){case 0:return s?a(s):[];case 1:return l(u[0],u[0],s);case 2:return l(u[0],u[1],s);default:throw new Error("Vector containing two values expected")}}function l(u,s,c){var m=rr(u)||rr(s)?n:null;if(rr(u)&&(u=u.toNumber()),rr(s)&&(s=s.toNumber()),!qe(u)||u<1)throw new Error("Parameters in function identity must be positive integers");if(!qe(s)||s<1)throw new Error("Parameters in function identity must be positive integers");var v=m?new n(1):1,h=m?new m(0):0,p=[u,s];if(c){if(c==="sparse")return o.diagonal(p,v,0,h);if(c==="dense")return i.diagonal(p,v,0,h);throw new TypeError('Unknown matrix type "'.concat(c,'"'))}for(var g=Qn([],p,h),y=u<s?u:s,N=0;N<y;N++)g[N][N]=v;return g}}),sm="kron",Ow=["typed","matrix","multiplyScalar"],Iw=q(sm,Ow,r=>{var{typed:e,matrix:t,multiplyScalar:a}=r;return e(sm,{"Matrix, Matrix":function(o,f){return t(n(o.toArray(),f.toArray()))},"Matrix, Array":function(o,f){return t(n(o.toArray(),f))},"Array, Matrix":function(o,f){return t(n(o,f.toArray()))},"Array, Array":n});function n(i,o){if(er(i).length===1&&(i=[i]),er(o).length===1&&(o=[o]),er(i).length>2||er(o).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(i.length)+", y = "+JSON.stringify(o.length)+")");var f=[],l=[];return i.map(function(u){return o.map(function(s){return l=[],f.push(l),u.map(function(c){return s.map(function(m){return l.push(a(c,m))})})})})&&f}}),um="map",Rw=["typed"],_w=q(um,Rw,r=>{var{typed:e}=r;return e(um,{"Array, function":qw,"Matrix, function":function(a,n){return a.map(n)}})});function qw(r,e){var t=fn(e),a=function n(i,o){if(Array.isArray(i))return i.map(function(u,s){return n(u,o.concat(s))});try{return t===1?e(i):t===2?e(i,o):e(i,o,r)}catch(u){if(u instanceof TypeError&&"data"in u&&u.data.category==="wrongType"){var f="map attempted to call '".concat(u.data.fn,"(").concat(i),l=JSON.stringify(o);throw t===2?f+=","+l:t!==1&&(f+=",".concat(l,",").concat(r)),f+=")' but argument ".concat(u.data.index+1," of type "),f+="".concat(u.data.actual," does not match expected type "),f+=u.data.expected.join(" or "),new TypeError(f)}throw u}};return a(r,[])}var lm="diff",zw=["typed","matrix","subtract","number"],cm=q(lm,zw,r=>{var{typed:e,matrix:t,subtract:a,number:n}=r;return e(lm,{"Array | Matrix":function(s){return Ve(s)?t(o(s.toArray())):o(s)},"Array | Matrix, number":function(s,c){if(!qe(c))throw new RangeError("Dimension must be a whole number");return Ve(s)?t(i(s.toArray(),c)):i(s,c)},"Array, BigNumber":e.referTo("Array,number",u=>(s,c)=>u(s,n(c))),"Matrix, BigNumber":e.referTo("Matrix,number",u=>(s,c)=>u(s,n(c)))});function i(u,s){if(Ve(u)&&(u=u.toArray()),!Array.isArray(u))throw RangeError("Array/Matrix does not have that many dimensions");if(s>0){var c=[];return u.forEach(m=>{c.push(i(m,s-1))}),c}else{if(s===0)return o(u);throw RangeError("Cannot have negative dimension")}}function o(u){for(var s=[],c=u.length,m=1;m<c;m++)s.push(f(u[m-1],u[m]));return s}function f(u,s){Ve(u)&&(u=u.toArray()),Ve(s)&&(s=s.toArray());var c=Array.isArray(u),m=Array.isArray(s);if(c&&m)return l(u,s);if(!c&&!m)return a(s,u);throw TypeError("Cannot calculate difference between 1 array and 1 non-array")}function l(u,s){if(u.length!==s.length)throw RangeError("Not all sub-arrays have the same length");for(var c=[],m=u.length,v=0;v<m;v++)c.push(f(u[v],s[v]));return c}}),Pw="ones",Uw=["typed","config","matrix","BigNumber"],Lw=q(Pw,Uw,r=>{var{typed:e,config:t,matrix:a,BigNumber:n}=r;return e("ones",{"":function(){return t.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(u){var s=u[u.length-1];if(typeof s=="string"){var c=u.pop();return i(u,c)}else return t.matrix==="Array"?i(u):i(u,"default")},Array:i,Matrix:function(u){var s=u.storage();return i(u.valueOf(),s)},"Array | Matrix, string":function(u,s){return i(u.valueOf(),s)}});function i(l,u){var s=o(l),c=s?new n(1):1;if(f(l),u){var m=a(u);return l.length>0?m.resize(l,c):m}else{var v=[];return l.length>0?Qn(v,l,c):v}}function o(l){var u=!1;return l.forEach(function(s,c,m){rr(s)&&(u=!0,m[c]=s.toNumber())}),u}function f(l){l.forEach(function(u){if(typeof u!="number"||!qe(u)||u<0)throw new Error("Parameters in function ones must be positive integers")})}});function ps(){throw new Error('No "bignumber" implementation available')}function fm(){throw new Error('No "fraction" implementation available')}function mm(){throw new Error('No "matrix" implementation available')}var vm="range",kw=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],pm=q(vm,kw,r=>{var{typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:o,larger:f,largerEq:l}=r;return e(vm,{string:s,"string, boolean":s,"number, number":function(y,N){return u(c(y,N,1))},"number, number, number":function(y,N,d){return u(c(y,N,d))},"number, number, boolean":function(y,N,d){return u(d?m(y,N,1):c(y,N,1))},"number, number, number, boolean":function(y,N,d,w){return u(w?m(y,N,d):c(y,N,d))},"BigNumber, BigNumber":function(y,N){var d=y.constructor;return u(v(y,N,new d(1)))},"BigNumber, BigNumber, BigNumber":function(y,N,d){return u(v(y,N,d))},"BigNumber, BigNumber, boolean":function(y,N,d){var w=y.constructor;return u(d?h(y,N,new w(1)):v(y,N,new w(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(y,N,d,w){return u(w?h(y,N,d):v(y,N,d))}});function u(g){return t.matrix==="Matrix"?a?a(g):mm():g}function s(g,y){var N=p(g);if(!N)throw new SyntaxError('String "'+g+'" is no valid range');var d;return t.number==="BigNumber"?(n===void 0&&ps(),d=y?h:v,u(d(n(N.start),n(N.end),n(N.step)))):(d=y?m:c,u(d(N.start,N.end,N.step)))}function c(g,y,N){var d=[],w=g;if(N>0)for(;i(w,y);)d.push(w),w+=N;else if(N<0)for(;f(w,y);)d.push(w),w+=N;return d}function m(g,y,N){var d=[],w=g;if(N>0)for(;o(w,y);)d.push(w),w+=N;else if(N<0)for(;l(w,y);)d.push(w),w+=N;return d}function v(g,y,N){var d=n(0),w=[],x=g;if(N.gt(d))for(;i(x,y);)w.push(x),x=x.plus(N);else if(N.lt(d))for(;f(x,y);)w.push(x),x=x.plus(N);return w}function h(g,y,N){var d=n(0),w=[],x=g;if(N.gt(d))for(;o(x,y);)w.push(x),x=x.plus(N);else if(N.lt(d))for(;l(x,y);)w.push(x),x=x.plus(N);return w}function p(g){var y=g.split(":"),N=y.map(function(w){return Number(w)}),d=N.some(function(w){return isNaN(w)});if(d)return null;switch(N.length){case 2:return{start:N[0],end:N[1],step:1};case 3:return{start:N[0],end:N[2],step:N[1]};default:return null}}}),hm="reshape",Vw=["typed","isInteger","matrix"],Gw=q(hm,Vw,r=>{var{typed:e,isInteger:t}=r;return e(hm,{"Matrix, Array":function(n,i){return n.reshape(i,!0)},"Array, Array":function(n,i){return i.forEach(function(o){if(!t(o))throw new TypeError("Invalid size for dimension: "+o)}),wl(n,i)}})}),Hw="resize",Zw=["config","matrix"],Jw=q(Hw,Zw,r=>{var{config:e,matrix:t}=r;return function(i,o,f){if(arguments.length!==2&&arguments.length!==3)throw new Bn("resize",arguments.length,2,3);if(Ve(o)&&(o=o.valueOf()),rr(o[0])&&(o=o.map(function(s){return rr(s)?s.toNumber():s})),Ve(i))return i.resize(o,f,!0);if(typeof i=="string")return a(i,o,f);var l=Array.isArray(i)?!1:e.matrix!=="Array";if(o.length===0){for(;Array.isArray(i);)i=i[0];return Ge(i)}else{Array.isArray(i)||(i=[i]),i=Ge(i);var u=Qn(i,o,f);return l?t(u):u}};function a(n,i,o){if(o!==void 0){if(typeof o!="string"||o.length!==1)throw new TypeError("Single character expected as defaultValue")}else o=" ";if(i.length!==1)throw new Ke(i.length,1);var f=i[0];if(typeof f!="number"||!qe(f))throw new TypeError("Invalid size, must contain positive integers (size: "+Ye(i)+")");if(n.length>f)return n.substring(0,f);if(n.length<f){for(var l=n,u=0,s=f-n.length;u<s;u++)l+=o;return l}else return n}}),dm="rotate",Xw=["typed","multiply","rotationMatrix"],Ww=q(dm,Xw,r=>{var{typed:e,multiply:t,rotationMatrix:a}=r;return e(dm,{"Array , number | BigNumber | Complex | Unit":function(o,f){n(o,2);var l=t(a(f),o);return l.toArray()},"Matrix , number | BigNumber | Complex | Unit":function(o,f){return n(o,2),t(a(f),o)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(o,f,l){n(o,3);var u=t(a(f,l),o);return u},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(o,f,l){return n(o,3),t(a(f,l),o)}});function n(i,o){var f=Array.isArray(i)?er(i):i.size();if(f.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(o));if(f.length===2&&f[1]!==1)throw new RangeError("Vector must be of dimensions 1x".concat(o));if(f[0]!==o)throw new RangeError("Vector must be of dimensions 1x".concat(o))}}),gm="rotationMatrix",Yw=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],Qw=q(gm,Yw,r=>{var{typed:e,config:t,multiplyScalar:a,addScalar:n,unaryMinus:i,norm:o,BigNumber:f,matrix:l,DenseMatrix:u,SparseMatrix:s,cos:c,sin:m}=r;return e(gm,{"":function(){return t.matrix==="Matrix"?l([]):[]},string:function(d){return l(d)},"number | BigNumber | Complex | Unit":function(d){return v(d,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(d,w){return v(d,w)},"number | BigNumber | Complex | Unit, Array":function(d,w){var x=l(w);return h(x),y(d,x,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(d,w){h(w);var x=w.storage()||(t.matrix==="Matrix"?"dense":void 0);return y(d,w,x)},"number | BigNumber | Complex | Unit, Array, string":function(d,w,x){var b=l(w);return h(b),y(d,b,x)},"number | BigNumber | Complex | Unit, Matrix, string":function(d,w,x){return h(w),y(d,w,x)}});function v(N,d){var w=rr(N),x=w?new f(-1):-1,b=c(N),E=m(N),A=[[b,a(x,E)],[E,b]];return g(A,d)}function h(N){var d=N.size();if(d.length<1||d[0]!==3)throw new RangeError("Vector must be of dimensions 1x3")}function p(N){return N.reduce((d,w)=>a(d,w))}function g(N,d){if(d){if(d==="sparse")return new s(N);if(d==="dense")return new u(N);throw new TypeError('Unknown matrix type "'.concat(d,'"'))}return N}function y(N,d,w){var x=o(d);if(x===0)throw new RangeError("Rotation around zero vector");var b=rr(N)?f:null,E=b?new b(1):1,A=b?new b(-1):-1,S=b?new b(d.get([0])/x):d.get([0])/x,D=b?new b(d.get([1])/x):d.get([1])/x,T=b?new b(d.get([2])/x):d.get([2])/x,B=c(N),I=n(E,i(B)),P=m(N),R=n(B,p([S,S,I])),M=n(p([S,D,I]),p([A,T,P])),F=n(p([S,T,I]),p([D,P])),H=n(p([S,D,I]),p([T,P])),$=n(B,p([D,D,I])),k=n(p([D,T,I]),p([A,S,P])),Q=n(p([S,T,I]),p([A,D,P])),K=n(p([D,T,I]),p([S,P])),L=n(B,p([T,T,I])),j=[[R,M,F],[H,$,k],[Q,K,L]];return g(j,w)}}),ym="row",Kw=["typed","Index","matrix","range"],bm=q(ym,Kw,r=>{var{typed:e,Index:t,matrix:a,range:n}=r;return e(ym,{"Matrix, number":i,"Array, number":function(f,l){return i(a(Ge(f)),l).valueOf()}});function i(o,f){if(o.size().length!==2)throw new Error("Only two dimensional matrix is supported");vr(f,o.size()[0]);var l=n(0,o.size()[1]),u=new t(f,l),s=o.subset(u);return Ve(s)?s:a([[s]])}}),xm="size",jw=["typed","config","?matrix"],eN=q(xm,jw,r=>{var{typed:e,config:t,matrix:a}=r;return e(xm,{Matrix:function(i){return i.create(i.size())},Array:er,string:function(i){return t.matrix==="Array"?[i.length]:a([i.length])},"number | Complex | BigNumber | Unit | boolean | null":function(i){return t.matrix==="Array"?[]:a?a([]):mm()}})}),wm="squeeze",rN=["typed","matrix"],tN=q(wm,rN,r=>{var{typed:e,matrix:t}=r;return e(wm,{Array:function(n){return pi(Ge(n))},Matrix:function(n){var i=pi(n.toArray());return Array.isArray(i)?t(i):i},any:function(n){return Ge(n)}})}),Nm="subset",nN=["typed","matrix"],Dm=q(Nm,nN,r=>{var{typed:e,matrix:t}=r;return e(Nm,{"Array, Index":function(n,i){var o=t(n),f=o.subset(i);return i.isScalar()?f:f.valueOf()},"Matrix, Index":function(n,i){return n.subset(i)},"Object, Index":iN,"string, Index":aN,"Array, Index, any":function(n,i,o){return t(Ge(n)).subset(i,o,void 0).valueOf()},"Array, Index, any, any":function(n,i,o,f){return t(Ge(n)).subset(i,o,f).valueOf()},"Matrix, Index, any":function(n,i,o){return n.clone().subset(i,o)},"Matrix, Index, any, any":function(n,i,o,f){return n.clone().subset(i,o,f)},"string, Index, string":Am,"string, Index, string, string":Am,"Object, Index, any":oN})});function aN(r,e){if(!li(e))throw new TypeError("Index expected");if(e.size().length!==1)throw new Ke(e.size().length,1);var t=r.length;vr(e.min()[0],t),vr(e.max()[0],t);var a=e.dimension(0),n="";return a.forEach(function(i){n+=r.charAt(i)}),n}function Am(r,e,t,a){if(!e||e.isIndex!==!0)throw new TypeError("Index expected");if(e.size().length!==1)throw new Ke(e.size().length,1);if(a!==void 0){if(typeof a!="string"||a.length!==1)throw new TypeError("Single character expected as defaultValue")}else a=" ";var n=e.dimension(0),i=n.size()[0];if(i!==t.length)throw new Ke(n.size()[0],t.length);var o=r.length;vr(e.min()[0]),vr(e.max()[0]);for(var f=[],l=0;l<o;l++)f[l]=r.charAt(l);if(n.forEach(function(c,m){f[c]=t.charAt(m[0])}),f.length>o)for(var u=o-1,s=f.length;u<s;u++)f[u]||(f[u]=a);return f.join("")}function iN(r,e){if(e.size().length!==1)throw new Ke(e.size(),1);var t=e.dimension(0);if(typeof t!="string")throw new TypeError("String expected as index to retrieve an object property");return lt(r,t)}function oN(r,e,t){if(e.size().length!==1)throw new Ke(e.size(),1);var a=e.dimension(0);if(typeof a!="string")throw new TypeError("String expected as index to retrieve an object property");var n=Ge(r);return jn(n,a,t),n}var Em="transpose",sN=["typed","matrix"],uN=q(Em,sN,r=>{var{typed:e,matrix:t}=r;return e(Em,{Array:o=>a(t(o)).valueOf(),Matrix:a,any:Ge});function a(o){var f=o.size(),l;switch(f.length){case 1:l=o.clone();break;case 2:{var u=f[0],s=f[1];if(s===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+Ye(f)+")");switch(o.storage()){case"dense":l=n(o,u,s);break;case"sparse":l=i(o,u,s);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+Ye(f)+")")}return l}function n(o,f,l){for(var u=o._data,s=[],c,m=0;m<l;m++){c=s[m]=[];for(var v=0;v<f;v++)c[v]=Ge(u[v][m])}return o.createDenseMatrix({data:s,size:[l,f],datatype:o._datatype})}function i(o,f,l){for(var u=o._values,s=o._index,c=o._ptr,m=u?[]:void 0,v=[],h=[],p=[],g=0;g<f;g++)p[g]=0;var y,N,d;for(y=0,N=s.length;y<N;y++)p[s[y]]++;for(var w=0,x=0;x<f;x++)h.push(w),w+=p[x],p[x]=h[x];for(h.push(w),d=0;d<l;d++)for(var b=c[d],E=c[d+1],A=b;A<E;A++){var S=p[s[A]]++;v[S]=d,u&&(m[S]=Ge(u[A]))}return o.createSparseMatrix({values:m,index:v,ptr:h,size:[l,f],datatype:o._datatype})}}),Sm="ctranspose",lN=["typed","transpose","conj"],cN=q(Sm,lN,r=>{var{typed:e,transpose:t,conj:a}=r;return e(Sm,{any:function(i){return a(t(i))}})}),Cm="zeros",fN=["typed","config","matrix","BigNumber"],mN=q(Cm,fN,r=>{var{typed:e,config:t,matrix:a,BigNumber:n}=r;return e(Cm,{"":function(){return t.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(u){var s=u[u.length-1];if(typeof s=="string"){var c=u.pop();return i(u,c)}else return t.matrix==="Array"?i(u):i(u,"default")},Array:i,Matrix:function(u){var s=u.storage();return i(u.valueOf(),s)},"Array | Matrix, string":function(u,s){return i(u.valueOf(),s)}});function i(l,u){var s=o(l),c=s?new n(0):0;if(f(l),u){var m=a(u);return l.length>0?m.resize(l,c):m}else{var v=[];return l.length>0?Qn(v,l,c):v}}function o(l){var u=!1;return l.forEach(function(s,c,m){rr(s)&&(u=!0,m[c]=s.toNumber())}),u}function f(l){l.forEach(function(u){if(typeof u!="number"||!qe(u)||u<0)throw new Error("Parameters in function zeros must be positive integers")})}}),Mm="fft",vN=["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i","dotDivide","conj","pow","ceil","log2"],pN=q(Mm,vN,r=>{var{typed:e,matrix:t,addScalar:a,multiplyScalar:n,divideScalar:i,exp:o,tau:f,i:l,dotDivide:u,conj:s,pow:c,ceil:m,log2:v}=r;return e(Mm,{Array:h,Matrix:function(d){return d.create(h(d.toArray()))}});function h(N){var d=er(N);return d.length===1?y(N,d[0]):p(N.map(w=>h(w,d.slice(1))),0)}function p(N,d){var w=er(N);if(d!==0)return new Array(w[0]).fill(0).map((b,E)=>p(N[E],d-1));if(w.length===1)return y(N);function x(b){var E=er(b);return new Array(E[1]).fill(0).map((A,S)=>new Array(E[0]).fill(0).map((D,T)=>b[T][S]))}return x(p(x(N),1))}function g(N){for(var d=N.length,w=o(i(n(-1,n(l,f)),d)),x=[],b=1-d;b<d;b++)x.push(c(w,i(c(b,2),2)));for(var E=c(2,m(v(d+d-1))),A=[...new Array(d).fill(0).map((M,F)=>n(N[F],x[d-1+F])),...new Array(E-d).fill(0)],S=[...new Array(d+d-1).fill(0).map((M,F)=>i(1,x[F])),...new Array(E-(d+d-1)).fill(0)],D=y(A),T=y(S),B=new Array(E).fill(0).map((M,F)=>n(D[F],T[F])),I=u(s(h(s(B))),E),P=[],R=d-1;R<d+d-1;R++)P.push(n(I[R],x[R]));return P}function y(N){var d=N.length;if(d===1)return[N[0]];if(d%2===0){for(var w=[...y(N.filter((A,S)=>S%2===0)),...y(N.filter((A,S)=>S%2===1))],x=0;x<d/2;x++){var b=w[x],E=n(w[x+d/2],o(n(n(f,l),i(-x,d))));w[x]=a(b,E),w[x+d/2]=a(b,n(-1,E))}return w}else return g(N)}}),Fm="ifft",hN=["typed","fft","dotDivide","conj"],dN=q(Fm,hN,r=>{var{typed:e,fft:t,dotDivide:a,conj:n}=r;return e(Fm,{"Array | Matrix":function(o){var f=Ve(o)?o.size():er(o);return a(n(t(n(o))),f.reduce((l,u)=>l*u,1))}})}),gN="erf",yN=["typed"],bN=q(gN,yN,r=>{var{typed:e}=r;return e("name",{number:function(o){var f=Math.abs(o);return f>=NN?an(o):f<=xN?an(o)*t(f):f<=4?an(o)*(1-a(f)):an(o)*(1-n(f))},"Array | Matrix":e.referToSelf(i=>o=>je(o,i))});function t(i){var o=i*i,f=Yt[0][4]*o,l=o,u;for(u=0;u<3;u+=1)f=(f+Yt[0][u])*o,l=(l+ua[0][u])*o;return i*(f+Yt[0][3])/(l+ua[0][3])}function a(i){var o=Yt[1][8]*i,f=i,l;for(l=0;l<7;l+=1)o=(o+Yt[1][l])*i,f=(f+ua[1][l])*i;var u=(o+Yt[1][7])/(f+ua[1][7]),s=parseInt(i*16)/16,c=(i-s)*(i+s);return Math.exp(-s*s)*Math.exp(-c)*u}function n(i){var o=1/(i*i),f=Yt[2][5]*o,l=o,u;for(u=0;u<4;u+=1)f=(f+Yt[2][u])*o,l=(l+ua[2][u])*o;var s=o*(f+Yt[2][4])/(l+ua[2][4]);s=(wN-s)/i,o=parseInt(i*16)/16;var c=(i-o)*(i+o);return Math.exp(-o*o)*Math.exp(-c)*s}}),xN=.46875,wN=.5641895835477563,Yt=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,21531153547440383e-24],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],ua=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],NN=Math.pow(2,53),Tm="mode",DN=["typed","isNaN","isNumeric"],AN=q(Tm,DN,r=>{var{typed:e,isNaN:t,isNumeric:a}=r;return e(Tm,{"Array | Matrix":n,"...":function(o){return n(o)}});function n(i){i=or(i.valueOf());var o=i.length;if(o===0)throw new Error("Cannot calculate mode of an empty array");for(var f={},l=[],u=0,s=0;s<i.length;s++){var c=i[s];if(a(c)&&t(c))throw new Error("Cannot calculate mode of an array containing NaN values");c in f||(f[c]=0),f[c]++,f[c]===u?l.push(c):f[c]>u&&(u=f[c],l=[c])}return l}});function Qr(r,e,t){var a;return String(r).indexOf("Unexpected type")!==-1?(a=arguments.length>2?" (type: "+br(t)+", value: "+JSON.stringify(t)+")":" (type: "+r.data.actual+")",new TypeError("Cannot calculate "+e+", unexpected type of argument"+a)):String(r).indexOf("complex numbers")!==-1?(a=arguments.length>2?" (type: "+br(t)+", value: "+JSON.stringify(t)+")":"",new TypeError("Cannot calculate "+e+", no ordering relation is defined for complex numbers"+a)):r}var Bm="prod",EN=["typed","config","multiplyScalar","numeric"],SN=q(Bm,EN,r=>{var{typed:e,config:t,multiplyScalar:a,numeric:n}=r;return e(Bm,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(f,l){throw new Error("prod(A, dim) is not yet supported")},"...":function(f){return i(f)}});function i(o){var f;if(Xt(o,function(l){try{f=f===void 0?l:a(f,l)}catch(u){throw Qr(u,"prod",l)}}),typeof f=="string"&&(f=n(f,t.number)),f===void 0)throw new Error("Cannot calculate prod of an empty array");return f}}),$m="format",CN=["typed"],MN=q($m,CN,r=>{var{typed:e}=r;return e($m,{any:Ye,"any, Object | function | number":Ye})}),Om="bin",FN=["typed","format"],TN=q(Om,FN,r=>{var{typed:e,format:t}=r;return e(Om,{"number | BigNumber":function(n){return t(n,{notation:"bin"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"bin",wordSize:i})}})}),Im="oct",BN=["typed","format"],$N=q(Im,BN,r=>{var{typed:e,format:t}=r;return e(Im,{"number | BigNumber":function(n){return t(n,{notation:"oct"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"oct",wordSize:i})}})}),Rm="hex",ON=["typed","format"],IN=q(Rm,ON,r=>{var{typed:e,format:t}=r;return e(Rm,{"number | BigNumber":function(n){return t(n,{notation:"hex"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"hex",wordSize:i})}})}),_m="print",RN=["typed"],_N=q(_m,RN,r=>{var{typed:e}=r;return e(_m,{"string, Object | Array":qm,"string, Object | Array, number | Object":qm})});function qm(r,e,t){return r.replace(/\$([\w.]+)/g,function(a,n){for(var i=n.split("."),o=e[i.shift()];i.length&&o!==void 0;){var f=i.shift();o=f?o[f]:o+"."}return o!==void 0?Wr(o)?o:Ye(o,t):a})}var zm="to",qN=["typed","matrix","concat"],zN=q(zm,qN,r=>{var{typed:e,matrix:t,concat:a}=r,n=dr({typed:e,matrix:t,concat:a});return e(zm,{"Unit, Unit | string":(i,o)=>i.to(o)},n({Ds:!0}))}),Pm="isPrime",PN=["typed"],UN=q(Pm,PN,r=>{var{typed:e}=r;return e(Pm,{number:function(a){if(a*0!==0)return!1;if(a<=3)return a>1;if(a%2===0||a%3===0)return!1;for(var n=5;n*n<=a;n+=6)if(a%n===0||a%(n+2)===0)return!1;return!0},BigNumber:function(a){if(a.toNumber()*0!==0)return!1;if(a.lte(3))return a.gt(1);if(a.mod(2).eq(0)||a.mod(3).eq(0))return!1;if(a.lt(Math.pow(2,32))){for(var n=a.toNumber(),i=5;i*i<=n;i+=6)if(n%i===0||n%(i+2)===0)return!1;return!0}function o(N,d,w){for(var x=1;!d.eq(0);)d.mod(2).eq(0)?(d=d.div(2),N=N.mul(N).mod(w)):(d=d.sub(1),x=N.mul(x).mod(w));return x}var f=a.constructor.clone({precision:a.toFixed(0).length*2});a=new f(a);for(var l=0,u=a.sub(1);u.mod(2).eq(0);)u=u.div(2),l+=1;var s=null;if(a.lt("3317044064679887385961981"))s=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter(N=>N<a);else{var c=Math.min(a.toNumber()-2,Math.floor(2*Math.pow(a.toFixed(0).length*Math.log(10),2)));s=[];for(var m=2;m<=c;m+=1)s.push(c)}for(var v=0;v<s.length;v+=1){var h=s[v],p=o(a.sub(a).add(h),u,a);if(!p.eq(1)){for(var g=0,y=p;!y.eq(a.sub(1));g+=1,y=y.mul(y).mod(a))if(g===l-1)return!1}}return!0},"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),LN="numeric",kN=["number","?bignumber","?fraction"],VN=q(LN,kN,r=>{var{number:e,bignumber:t,fraction:a}=r,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:o=>e(o),BigNumber:t?o=>t(o):ps,Fraction:a?o=>a(o):fm};return function(f){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",u=arguments.length>2?arguments[2]:void 0;if(u!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var s=br(f);if(!(s in n))throw new TypeError("Cannot convert "+f+' of type "'+s+'"; valid input types are '+Object.keys(n).join(", "));if(!(l in i))throw new TypeError("Cannot convert "+f+' to type "'+l+'"; valid output types are '+Object.keys(i).join(", "));return l===s?f:i[l](f)}}),Um="divideScalar",GN=["typed","numeric"],HN=q(Um,GN,r=>{var{typed:e,numeric:t}=r;return e(Um,{"number, number":function(n,i){return n/i},"Complex, Complex":function(n,i){return n.div(i)},"BigNumber, BigNumber":function(n,i){return n.div(i)},"Fraction, Fraction":function(n,i){return n.div(i)},"Unit, number | Complex | Fraction | BigNumber | Unit":(a,n)=>a.divide(n),"number | Fraction | Complex | BigNumber, Unit":(a,n)=>n.divideInto(a)})}),Lm="pow",ZN=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],JN=q(Lm,ZN,r=>{var{typed:e,config:t,identity:a,multiply:n,matrix:i,inv:o,number:f,fraction:l,Complex:u}=r;return e(Lm,{"number, number":s,"Complex, Complex":function(h,p){return h.pow(p)},"BigNumber, BigNumber":function(h,p){return p.isInteger()||h>=0||t.predictable?h.pow(p):new u(h.toNumber(),0).pow(p.toNumber(),0)},"Fraction, Fraction":function(h,p){var g=h.pow(p);if(g!=null)return g;if(t.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return s(h.valueOf(),p.valueOf())},"Array, number":c,"Array, BigNumber":function(h,p){return c(h,p.toNumber())},"Matrix, number":m,"Matrix, BigNumber":function(h,p){return m(h,p.toNumber())},"Unit, number | BigNumber":function(h,p){return h.pow(p)}});function s(v,h){if(t.predictable&&!qe(h)&&v<0)try{var p=l(h),g=f(p);if((h===g||Math.abs((h-g)/h)<1e-14)&&p.d%2===1)return(p.n%2===0?1:-1)*Math.pow(-v,h)}catch{}return t.predictable&&(v<-1&&h===1/0||v>-1&&v<0&&h===-1/0)?NaN:qe(h)||v>=0||t.predictable?pc(v,h):v*v<1&&h===1/0||v*v>1&&h===-1/0?0:new u(v,0).pow(h,0)}function c(v,h){if(!qe(h))throw new TypeError("For A^b, b must be an integer (value is "+h+")");var p=er(v);if(p.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+p.length+" dimensions)");if(p[0]!==p[1])throw new Error("For A^b, A must be square (size is "+p[0]+"x"+p[1]+")");if(h<0)try{return c(o(v),-h)}catch(N){throw N.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+h+")"):N}for(var g=a(p[0]).valueOf(),y=v;h>=1;)(h&1)===1&&(g=n(y,g)),h>>=1,y=n(y,y);return g}function m(v,h){return i(c(v.valueOf(),h))}}),la="Number of decimals in function round must be an integer",km="round",XN=["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],WN=q(km,XN,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,BigNumber:i,DenseMatrix:o}=r,f=Lr({typed:e,equalScalar:a}),l=Ir({typed:e,DenseMatrix:o}),u=xt({typed:e});return e(km,{number:hc,"number, number":hc,"number, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(la);return new i(c).toDecimalPlaces(m.toNumber())},Complex:function(c){return c.round()},"Complex, number":function(c,m){if(m%1)throw new TypeError(la);return c.round(m)},"Complex, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(la);var v=m.toNumber();return c.round(v)},BigNumber:function(c){return c.toDecimalPlaces(0)},"BigNumber, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(la);return c.toDecimalPlaces(m.toNumber())},Fraction:function(c){return c.round()},"Fraction, number":function(c,m){if(m%1)throw new TypeError(la);return c.round(m)},"Fraction, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(la);return c.round(m.toNumber())},"Array | Matrix":e.referToSelf(s=>c=>je(c,s)),"SparseMatrix, number | BigNumber":e.referToSelf(s=>(c,m)=>f(c,m,s,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(s=>(c,m)=>u(c,m,s,!1)),"Array, number | BigNumber":e.referToSelf(s=>(c,m)=>u(t(c),m,s,!1).valueOf()),"number | Complex | BigNumber | Fraction, SparseMatrix":e.referToSelf(s=>(c,m)=>a(c,0)?n(m.size(),m.storage()):l(m,c,s,!0)),"number | Complex | BigNumber | Fraction, DenseMatrix":e.referToSelf(s=>(c,m)=>a(c,0)?n(m.size(),m.storage()):u(m,c,s,!0)),"number | Complex | BigNumber | Fraction, Array":e.referToSelf(s=>(c,m)=>u(t(m),c,s,!0).valueOf())})}),Vm="log",YN=["config","typed","divideScalar","Complex"],QN=q(Vm,YN,r=>{var{typed:e,config:t,divideScalar:a,Complex:n}=r;return e(Vm,{number:function(o){return o>=0||t.predictable?j1(o):new n(o,0).log()},Complex:function(o){return o.log()},BigNumber:function(o){return!o.isNegative()||t.predictable?o.ln():new n(o.toNumber(),0).log()},"any, any":e.referToSelf(i=>(o,f)=>a(i(o),i(f)))})}),Gm="log1p",KN=["typed","config","divideScalar","log","Complex"],jN=q(Gm,KN,r=>{var{typed:e,config:t,divideScalar:a,log:n,Complex:i}=r;return e(Gm,{number:function(l){return l>=-1||t.predictable?rg(l):o(new i(l,0))},Complex:o,BigNumber:function(l){var u=l.plus(1);return!u.isNegative()||t.predictable?u.ln():o(new i(l.toNumber(),0))},"Array | Matrix":e.referToSelf(f=>l=>je(l,f)),"any, any":e.referToSelf(f=>(l,u)=>a(f(l),n(u)))});function o(f){var l=f.re+1;return new i(Math.log(Math.sqrt(l*l+f.im*f.im)),Math.atan2(f.im,l))}}),Hm="nthRoots",e2=["config","typed","divideScalar","Complex"],r2=q(Hm,e2,r=>{var{typed:e,config:t,divideScalar:a,Complex:n}=r,i=[function(l){return new n(l,0)},function(l){return new n(0,l)},function(l){return new n(-l,0)},function(l){return new n(0,-l)}];function o(f,l){if(l<0)throw new Error("Root must be greater than zero");if(l===0)throw new Error("Root must be non-zero");if(l%1!==0)throw new Error("Root must be an integer");if(f===0||f.abs()===0)return[new n(0,0)];var u=typeof f=="number",s;(u||f.re===0||f.im===0)&&(u?s=2*+(f<0):f.im===0?s=2*+(f.re<0):s=2*+(f.im<0)+1);for(var c=f.arg(),m=f.abs(),v=[],h=Math.pow(m,1/l),p=0;p<l;p++){var g=(s+4*p)/l;if(g===Math.round(g)){v.push(i[g%4](h));continue}v.push(new n({r:h,phi:(c+2*Math.PI*p)/l}))}return v}return e(Hm,{Complex:function(l){return o(l,2)},"Complex, number":o})}),Zm="dotPow",t2=["typed","equalScalar","matrix","pow","DenseMatrix","concat"],n2=q(Zm,t2,r=>{var{typed:e,equalScalar:t,matrix:a,pow:n,DenseMatrix:i,concat:o}=r,f=Yr({typed:e}),l=$t({typed:e,DenseMatrix:i}),u=Lr({typed:e,equalScalar:t}),s=Ir({typed:e,DenseMatrix:i}),c=dr({typed:e,matrix:a,concat:o}),m={};for(var v in n.signatures)Object.prototype.hasOwnProperty.call(n.signatures,v)&&!v.includes("Matrix")&&!v.includes("Array")&&(m[v]=n.signatures[v]);var h=e(m);return e(Zm,c({elop:h,SS:l,DS:f,Ss:u,sS:s}))}),Jm="dotDivide",a2=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],i2=q(Jm,a2,r=>{var{typed:e,matrix:t,equalScalar:a,divideScalar:n,DenseMatrix:i,concat:o}=r,f=wt({typed:e,equalScalar:a}),l=Yr({typed:e}),u=$t({typed:e,DenseMatrix:i}),s=Lr({typed:e,equalScalar:a}),c=Ir({typed:e,DenseMatrix:i}),m=dr({typed:e,matrix:t,concat:o});return e(Jm,m({elop:n,SS:u,DS:l,SD:f,Ss:s,sS:c}))});function Za(r){var{DenseMatrix:e}=r;return function(a,n,i){var o=a.size();if(o.length!==2)throw new RangeError("Matrix must be two dimensional (size: "+Ye(o)+")");var f=o[0],l=o[1];if(f!==l)throw new RangeError("Matrix must be square (size: "+Ye(o)+")");var u=[];if(Ve(n)){var s=n.size(),c=n._data;if(s.length===1){if(s[0]!==f)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var m=0;m<f;m++)u[m]=[c[m]];return new e({data:u,size:[f,1],datatype:n._datatype})}if(s.length===2){if(s[0]!==f||s[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");if(ui(n)){if(i){u=[];for(var v=0;v<f;v++)u[v]=[c[v][0]];return new e({data:u,size:[f,1],datatype:n._datatype})}return n}if(En(n)){for(var h=0;h<f;h++)u[h]=[0];for(var p=n._values,g=n._index,y=n._ptr,N=y[1],d=y[0];d<N;d++){var w=g[d];u[w][0]=p[d]}return new e({data:u,size:[f,1],datatype:n._datatype})}}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}if(cr(n)){var x=er(n);if(x.length===1){if(x[0]!==f)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var b=0;b<f;b++)u[b]=[n[b]];return new e({data:u,size:[f,1]})}if(x.length===2){if(x[0]!==f||x[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var E=0;E<f;E++)u[E]=[n[E][0]];return new e({data:u,size:[f,1]})}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}}}var Xm="lsolve",o2=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],s2=q(Xm,o2,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:o,DenseMatrix:f}=r,l=Za({DenseMatrix:f});return e(Xm,{"SparseMatrix, Array | Matrix":function(m,v){return s(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var h=t(m),p=u(h,v);return p.valueOf()}});function u(c,m){m=l(c,m,!0);for(var v=m._data,h=c._size[0],p=c._size[1],g=[],y=c._data,N=0;N<p;N++){var d=v[N][0]||0,w=void 0;if(o(d,0))w=0;else{var x=y[N][N];if(o(x,0))throw new Error("Linear system cannot be solved since matrix is singular");w=a(d,x);for(var b=N+1;b<h;b++)v[b]=[i(v[b][0]||0,n(w,y[b][N]))]}g[N]=[w]}return new f({data:g,size:[h,1]})}function s(c,m){m=l(c,m,!0);for(var v=m._data,h=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,d=[],w=0;w<p;w++){var x=v[w][0]||0;if(o(x,0))d[w]=[0];else{for(var b=0,E=[],A=[],S=N[w],D=N[w+1],T=S;T<D;T++){var B=y[T];B===w?b=g[T]:B>w&&(E.push(g[T]),A.push(B))}if(o(b,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var I=a(x,b),P=0,R=A.length;P<R;P++){var M=A[P];v[M]=[i(v[M][0]||0,n(I,E[P]))]}d[w]=[I]}}return new f({data:d,size:[h,1]})}}),Wm="usolve",u2=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],l2=q(Wm,u2,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:o,DenseMatrix:f}=r,l=Za({DenseMatrix:f});return e(Wm,{"SparseMatrix, Array | Matrix":function(m,v){return s(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var h=t(m),p=u(h,v);return p.valueOf()}});function u(c,m){m=l(c,m,!0);for(var v=m._data,h=c._size[0],p=c._size[1],g=[],y=c._data,N=p-1;N>=0;N--){var d=v[N][0]||0,w=void 0;if(o(d,0))w=0;else{var x=y[N][N];if(o(x,0))throw new Error("Linear system cannot be solved since matrix is singular");w=a(d,x);for(var b=N-1;b>=0;b--)v[b]=[i(v[b][0]||0,n(w,y[b][N]))]}g[N]=[w]}return new f({data:g,size:[h,1]})}function s(c,m){m=l(c,m,!0);for(var v=m._data,h=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,d=[],w=p-1;w>=0;w--){var x=v[w][0]||0;if(o(x,0))d[w]=[0];else{for(var b=0,E=[],A=[],S=N[w],D=N[w+1],T=D-1;T>=S;T--){var B=y[T];B===w?b=g[T]:B<w&&(E.push(g[T]),A.push(B))}if(o(b,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var I=a(x,b),P=0,R=A.length;P<R;P++){var M=A[P];v[M]=[i(v[M][0],n(I,E[P]))]}d[w]=[I]}}return new f({data:d,size:[h,1]})}}),Ym="lsolveAll",c2=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],f2=q(Ym,c2,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:o,DenseMatrix:f}=r,l=Za({DenseMatrix:f});return e(Ym,{"SparseMatrix, Array | Matrix":function(m,v){return s(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var h=t(m),p=u(h,v);return p.map(g=>g.valueOf())}});function u(c,m){for(var v=[l(c,m,!0)._data.map(A=>A[0])],h=c._data,p=c._size[0],g=c._size[1],y=0;y<g;y++)for(var N=v.length,d=0;d<N;d++){var w=v[d];if(o(h[y][y],0))if(o(w[y],0)){if(d===0){var b=[...w];b[y]=1;for(var E=y+1;E<g;E++)b[E]=i(b[E],h[E][y]);v.push(b)}}else{if(d===0)return[];v.splice(d,1),d-=1,N-=1}else{w[y]=a(w[y],h[y][y]);for(var x=y+1;x<g;x++)w[x]=i(w[x],n(w[y],h[x][y]))}}return v.map(A=>new f({data:A.map(S=>[S]),size:[p,1]}))}function s(c,m){for(var v=[l(c,m,!0)._data.map(Q=>Q[0])],h=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,d=0;d<p;d++)for(var w=v.length,x=0;x<w;x++){for(var b=v[x],E=[],A=[],S=N[d],D=N[d+1],T=0,B=S;B<D;B++){var I=y[B];I===d?T=g[B]:I>d&&(E.push(g[B]),A.push(I))}if(o(T,0))if(o(b[d],0)){if(x===0){var F=[...b];F[d]=1;for(var H=0,$=A.length;H<$;H++){var k=A[H];F[k]=i(F[k],E[H])}v.push(F)}}else{if(x===0)return[];v.splice(x,1),x-=1,w-=1}else{b[d]=a(b[d],T);for(var P=0,R=A.length;P<R;P++){var M=A[P];b[M]=i(b[M],n(b[d],E[P]))}}}return v.map(Q=>new f({data:Q.map(K=>[K]),size:[h,1]}))}}),Qm="usolveAll",m2=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],v2=q(Qm,m2,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:o,DenseMatrix:f}=r,l=Za({DenseMatrix:f});return e(Qm,{"SparseMatrix, Array | Matrix":function(m,v){return s(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var h=t(m),p=u(h,v);return p.map(g=>g.valueOf())}});function u(c,m){for(var v=[l(c,m,!0)._data.map(A=>A[0])],h=c._data,p=c._size[0],g=c._size[1],y=g-1;y>=0;y--)for(var N=v.length,d=0;d<N;d++){var w=v[d];if(o(h[y][y],0))if(o(w[y],0)){if(d===0){var b=[...w];b[y]=1;for(var E=y-1;E>=0;E--)b[E]=i(b[E],h[E][y]);v.push(b)}}else{if(d===0)return[];v.splice(d,1),d-=1,N-=1}else{w[y]=a(w[y],h[y][y]);for(var x=y-1;x>=0;x--)w[x]=i(w[x],n(w[y],h[x][y]))}}return v.map(A=>new f({data:A.map(S=>[S]),size:[p,1]}))}function s(c,m){for(var v=[l(c,m,!0)._data.map(Q=>Q[0])],h=c._size[0],p=c._size[1],g=c._values,y=c._index,N=c._ptr,d=p-1;d>=0;d--)for(var w=v.length,x=0;x<w;x++){for(var b=v[x],E=[],A=[],S=N[d],D=N[d+1],T=0,B=D-1;B>=S;B--){var I=y[B];I===d?T=g[B]:I<d&&(E.push(g[B]),A.push(I))}if(o(T,0))if(o(b[d],0)){if(x===0){var F=[...b];F[d]=1;for(var H=0,$=A.length;H<$;H++){var k=A[H];F[k]=i(F[k],E[H])}v.push(F)}}else{if(x===0)return[];v.splice(x,1),x-=1,w-=1}else{b[d]=a(b[d],T);for(var P=0,R=A.length;P<R;P++){var M=A[P];b[M]=i(b[M],n(b[d],E[P]))}}}return v.map(Q=>new f({data:Q.map(K=>[K]),size:[h,1]}))}}),p2="matAlgo08xS0Sid",h2=["typed","equalScalar"],hs=q(p2,h2,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,o){var f=n._values,l=n._index,u=n._ptr,s=n._size,c=n._datatype,m=i._values,v=i._index,h=i._ptr,p=i._size,g=i._datatype;if(s.length!==p.length)throw new Ke(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!f||!m)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var y=s[0],N=s[1],d,w=t,x=0,b=o;typeof c=="string"&&c===g&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),b=e.find(o,[d,d]));for(var E=[],A=[],S=[],D=[],T=[],B,I,P,R,M=0;M<N;M++){S[M]=A.length;var F=M+1;for(I=u[M],P=u[M+1],B=I;B<P;B++)R=l[B],T[R]=F,D[R]=f[B],A.push(R);for(I=h[M],P=h[M+1],B=I;B<P;B++)R=v[B],T[R]===F&&(D[R]=b(D[R],m[B]));for(B=S[M];B<A.length;){R=A[B];var H=D[R];w(H,x)?A.splice(B,1):(E.push(H),B++)}}return S[N]=A.length,n.createSparseMatrix({values:E,index:A,ptr:S,size:[y,N],datatype:d})}}),ds=q("useMatrixForArrayScalar",["typed","matrix"],r=>{var{typed:e,matrix:t}=r;return{"Array, number":e.referTo("DenseMatrix, number",a=>(n,i)=>a(t(n),i).valueOf()),"Array, BigNumber":e.referTo("DenseMatrix, BigNumber",a=>(n,i)=>a(t(n),i).valueOf()),"number, Array":e.referTo("number, DenseMatrix",a=>(n,i)=>a(n,t(i)).valueOf()),"BigNumber, Array":e.referTo("BigNumber, DenseMatrix",a=>(n,i)=>a(n,t(i)).valueOf())}}),Km="leftShift",d2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],g2=q(Km,d2,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,DenseMatrix:i,concat:o}=r,f=mn({typed:e}),l=wt({typed:e,equalScalar:a}),u=hs({typed:e,equalScalar:a}),s=Tn({typed:e,DenseMatrix:i}),c=Lr({typed:e,equalScalar:a}),m=xt({typed:e}),v=dr({typed:e,matrix:t,concat:o}),h=ds({typed:e,matrix:t});return e(Km,{"number, number":xc,"BigNumber, BigNumber":Lx,"SparseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>a(y,0)?g.clone():c(g,y,p,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>a(y,0)?g.clone():m(g,y,p,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(p=>(g,y)=>a(g,0)?n(y.size(),y.storage()):s(y,g,p,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(p=>(g,y)=>a(g,0)?n(y.size(),y.storage()):m(y,g,p,!0))},h,v({SS:u,DS:f,SD:l}))}),jm="rightArithShift",y2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],b2=q(jm,y2,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,DenseMatrix:i,concat:o}=r,f=mn({typed:e}),l=wt({typed:e,equalScalar:a}),u=hs({typed:e,equalScalar:a}),s=Tn({typed:e,DenseMatrix:i}),c=Lr({typed:e,equalScalar:a}),m=xt({typed:e}),v=dr({typed:e,matrix:t,concat:o}),h=ds({typed:e,matrix:t});return e(jm,{"number, number":wc,"BigNumber, BigNumber":kx,"SparseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>a(y,0)?g.clone():c(g,y,p,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>a(y,0)?g.clone():m(g,y,p,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(p=>(g,y)=>a(g,0)?n(y.size(),y.storage()):s(y,g,p,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(p=>(g,y)=>a(g,0)?n(y.size(),y.storage()):m(y,g,p,!0))},h,v({SS:u,DS:f,SD:l}))}),ev="rightLogShift",x2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],w2=q(ev,x2,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,DenseMatrix:i,concat:o}=r,f=mn({typed:e}),l=wt({typed:e,equalScalar:a}),u=hs({typed:e,equalScalar:a}),s=Tn({typed:e,DenseMatrix:i}),c=Lr({typed:e,equalScalar:a}),m=xt({typed:e}),v=dr({typed:e,matrix:t,concat:o}),h=ds({typed:e,matrix:t});return e(ev,{"number, number":Nc,"SparseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>a(y,0)?g.clone():c(g,y,p,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(p=>(g,y)=>a(y,0)?g.clone():m(g,y,p,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(p=>(g,y)=>a(g,0)?n(y.size(),y.storage()):s(y,g,p,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(p=>(g,y)=>a(g,0)?n(y.size(),y.storage()):m(y,g,p,!0))},h,v({SS:u,DS:f,SD:l}))}),rv="and",N2=["typed","matrix","equalScalar","zeros","not","concat"],D2=q(rv,N2,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,not:i,concat:o}=r,f=wt({typed:e,equalScalar:a}),l=Oi({typed:e,equalScalar:a}),u=Lr({typed:e,equalScalar:a}),s=xt({typed:e}),c=dr({typed:e,matrix:t,concat:o});return e(rv,{"number, number":Cc,"Complex, Complex":function(v,h){return(v.re!==0||v.im!==0)&&(h.re!==0||h.im!==0)},"BigNumber, BigNumber":function(v,h){return!v.isZero()&&!h.isZero()&&!v.isNaN()&&!h.isNaN()},"Unit, Unit":e.referToSelf(m=>(v,h)=>m(v.value||0,h.value||0)),"SparseMatrix, any":e.referToSelf(m=>(v,h)=>i(h)?n(v.size(),v.storage()):u(v,h,m,!1)),"DenseMatrix, any":e.referToSelf(m=>(v,h)=>i(h)?n(v.size(),v.storage()):s(v,h,m,!1)),"any, SparseMatrix":e.referToSelf(m=>(v,h)=>i(v)?n(v.size(),v.storage()):u(h,v,m,!0)),"any, DenseMatrix":e.referToSelf(m=>(v,h)=>i(v)?n(v.size(),v.storage()):s(h,v,m,!0)),"Array, any":e.referToSelf(m=>(v,h)=>m(t(v),h).valueOf()),"any, Array":e.referToSelf(m=>(v,h)=>m(v,t(h)).valueOf())},c({SS:l,DS:f}))}),_i="compare",A2=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],E2=q(_i,A2,r=>{var{typed:e,config:t,equalScalar:a,matrix:n,BigNumber:i,Fraction:o,DenseMatrix:f,concat:l}=r,u=Yr({typed:e}),s=Ii({typed:e,equalScalar:a}),c=Ir({typed:e,DenseMatrix:f}),m=dr({typed:e,matrix:n,concat:l}),v=sa({typed:e});return e(_i,S2({typed:e,config:t}),{"boolean, boolean":function(p,g){return p===g?0:p>g?1:-1},"BigNumber, BigNumber":function(p,g){return Bt(p,g,t.epsilon)?new i(0):new i(p.cmp(g))},"Fraction, Fraction":function(p,g){return new o(p.compare(g))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},v,m({SS:s,DS:u,Ss:c}))}),S2=q(_i,["typed","config"],r=>{var{typed:e,config:t}=r;return e(_i,{"number, number":function(n,i){return nt(n,i,t.epsilon)?0:n>i?1:-1}})}),ca=function r(e,t){var a=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,n=/(^[ ]*|[ ]*$)/g,i=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,o=/^0x[0-9a-f]+$/i,f=/^0/,l=function(d){return r.insensitive&&(""+d).toLowerCase()||""+d},u=l(e).replace(n,"")||"",s=l(t).replace(n,"")||"",c=u.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),m=s.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),v=parseInt(u.match(o),16)||c.length!==1&&u.match(i)&&Date.parse(u),h=parseInt(s.match(o),16)||v&&s.match(i)&&Date.parse(s)||null,p,g;if(h){if(v<h)return-1;if(v>h)return 1}for(var y=0,N=Math.max(c.length,m.length);y<N;y++){if(p=!(c[y]||"").match(f)&&parseFloat(c[y])||c[y]||0,g=!(m[y]||"").match(f)&&parseFloat(m[y])||m[y]||0,isNaN(p)!==isNaN(g))return isNaN(p)?1:-1;if(typeof p!=typeof g&&(p+="",g+=""),p<g)return-1;if(p>g)return 1}return 0},tv="compareNatural",C2=["typed","compare"],M2=q(tv,C2,r=>{var{typed:e,compare:t}=r,a=t.signatures["boolean,boolean"];return e(tv,{"any, any":n});function n(l,u){var s=br(l),c=br(u),m;if((s==="number"||s==="BigNumber"||s==="Fraction")&&(c==="number"||c==="BigNumber"||c==="Fraction"))return m=t(l,u),m.toString()!=="0"?m>0?1:-1:ca(s,c);var v=["Array","DenseMatrix","SparseMatrix"];if(v.includes(s)||v.includes(c))return m=i(n,l,u),m!==0?m:ca(s,c);if(s!==c)return ca(s,c);if(s==="Complex")return F2(l,u);if(s==="Unit")return l.equalBase(u)?n(l.value,u.value):o(n,l.formatUnits(),u.formatUnits());if(s==="boolean")return a(l,u);if(s==="string")return ca(l,u);if(s==="Object")return f(n,l,u);if(s==="null"||s==="undefined")return 0;throw new TypeError('Unsupported type of value "'+s+'"')}function i(l,u,s){return En(u)&&En(s)?o(l,u.toJSON().values,s.toJSON().values):En(u)?i(l,u.toArray(),s):En(s)?i(l,u,s.toArray()):ui(u)?i(l,u.toJSON().data,s):ui(s)?i(l,u,s.toJSON().data):Array.isArray(u)?Array.isArray(s)?o(l,u,s):i(l,u,[s]):i(l,[u],s)}function o(l,u,s){for(var c=0,m=Math.min(u.length,s.length);c<m;c++){var v=l(u[c],s[c]);if(v!==0)return v}return u.length>s.length?1:u.length<s.length?-1:0}function f(l,u,s){var c=Object.keys(u),m=Object.keys(s);c.sort(ca),m.sort(ca);var v=o(l,c,m);if(v!==0)return v;for(var h=0;h<c.length;h++){var p=l(u[c[h]],s[m[h]]);if(p!==0)return p}return 0}});function F2(r,e){return r.re>e.re?1:r.re<e.re?-1:r.im>e.im?1:r.im<e.im?-1:0}var nv="compareText",T2=["typed","matrix","concat"];Ho.signature="any, any";var B2=q(nv,T2,r=>{var{typed:e,matrix:t,concat:a}=r,n=dr({typed:e,matrix:t,concat:a});return e(nv,Ho,n({elop:Ho,Ds:!0}))}),qi="equal",$2=["typed","matrix","equalScalar","DenseMatrix","concat"],O2=q(qi,$2,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n,concat:i}=r,o=Yr({typed:e}),f=$t({typed:e,DenseMatrix:n}),l=Ir({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:t,concat:i});return e(qi,I2({typed:e,equalScalar:a}),u({elop:a,SS:f,DS:o,Ss:l}))}),I2=q(qi,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e(qi,{"any, any":function(n,i){return n===null?i===null:i===null?n===null:n===void 0?i===void 0:i===void 0?n===void 0:t(n,i)}})}),av="equalText",R2=["typed","compareText","isZero"],_2=q(av,R2,r=>{var{typed:e,compareText:t,isZero:a}=r;return e(av,{"any, any":function(i,o){return a(t(i,o))}})}),zi="smaller",q2=["typed","config","matrix","DenseMatrix","concat"],z2=q(zi,q2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n,concat:i}=r,o=Yr({typed:e}),f=$t({typed:e,DenseMatrix:n}),l=Ir({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:a,concat:i}),s=sa({typed:e});return e(zi,P2({typed:e,config:t}),{"boolean, boolean":(c,m)=>c<m,"BigNumber, BigNumber":function(m,v){return m.lt(v)&&!Bt(m,v,t.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)===-1,"Complex, Complex":function(m,v){throw new TypeError("No ordering relation is defined for complex numbers")}},s,u({SS:f,DS:o,Ss:l}))}),P2=q(zi,["typed","config"],r=>{var{typed:e,config:t}=r;return e(zi,{"number, number":function(n,i){return n<i&&!nt(n,i,t.epsilon)}})}),Pi="smallerEq",U2=["typed","config","matrix","DenseMatrix","concat"],L2=q(Pi,U2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n,concat:i}=r,o=Yr({typed:e}),f=$t({typed:e,DenseMatrix:n}),l=Ir({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:a,concat:i}),s=sa({typed:e});return e(Pi,k2({typed:e,config:t}),{"boolean, boolean":(c,m)=>c<=m,"BigNumber, BigNumber":function(m,v){return m.lte(v)||Bt(m,v,t.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)!==1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},s,u({SS:f,DS:o,Ss:l}))}),k2=q(Pi,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Pi,{"number, number":function(n,i){return n<=i||nt(n,i,t.epsilon)}})}),Ui="larger",V2=["typed","config","matrix","DenseMatrix","concat"],G2=q(Ui,V2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n,concat:i}=r,o=Yr({typed:e}),f=$t({typed:e,DenseMatrix:n}),l=Ir({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:a,concat:i}),s=sa({typed:e});return e(Ui,H2({typed:e,config:t}),{"boolean, boolean":(c,m)=>c>m,"BigNumber, BigNumber":function(m,v){return m.gt(v)&&!Bt(m,v,t.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},s,u({SS:f,DS:o,Ss:l}))}),H2=q(Ui,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Ui,{"number, number":function(n,i){return n>i&&!nt(n,i,t.epsilon)}})}),Li="largerEq",Z2=["typed","config","matrix","DenseMatrix","concat"],J2=q(Li,Z2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n,concat:i}=r,o=Yr({typed:e}),f=$t({typed:e,DenseMatrix:n}),l=Ir({typed:e,DenseMatrix:n}),u=dr({typed:e,matrix:a,concat:i}),s=sa({typed:e});return e(Li,X2({typed:e,config:t}),{"boolean, boolean":(c,m)=>c>=m,"BigNumber, BigNumber":function(m,v){return m.gte(v)||Bt(m,v,t.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)!==-1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},s,u({SS:f,DS:o,Ss:l}))}),X2=q(Li,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Li,{"number, number":function(n,i){return n>=i||nt(n,i,t.epsilon)}})}),iv="deepEqual",W2=["typed","equal"],Y2=q(iv,W2,r=>{var{typed:e,equal:t}=r;return e(iv,{"any, any":function(i,o){return a(i.valueOf(),o.valueOf())}});function a(n,i){if(Array.isArray(n))if(Array.isArray(i)){var o=n.length;if(o!==i.length)return!1;for(var f=0;f<o;f++)if(!a(n[f],i[f]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:t(n,i)}}),ki="unequal",Q2=["typed","config","equalScalar","matrix","DenseMatrix","concat"],K2=q(ki,Q2,r=>{var{typed:e,config:t,equalScalar:a,matrix:n,DenseMatrix:i,concat:o}=r,f=Yr({typed:e}),l=$t({typed:e,DenseMatrix:i}),u=Ir({typed:e,DenseMatrix:i}),s=dr({typed:e,matrix:n,concat:o});return e(ki,j2({typed:e,equalScalar:a}),s({elop:c,SS:l,DS:f,Ss:u}));function c(m,v){return!a(m,v)}}),j2=q(ki,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e(ki,{"any, any":function(n,i){return n===null?i!==null:i===null?n!==null:n===void 0?i!==void 0:i===void 0?n!==void 0:!t(n,i)}})}),ov="partitionSelect",eD=["typed","isNumeric","isNaN","compare"],rD=q(ov,eD,r=>{var{typed:e,isNumeric:t,isNaN:a,compare:n}=r,i=n,o=(u,s)=>-n(u,s);return e(ov,{"Array | Matrix, number":function(s,c){return f(s,c,i)},"Array | Matrix, number, string":function(s,c,m){if(m==="asc")return f(s,c,i);if(m==="desc")return f(s,c,o);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":f});function f(u,s,c){if(!qe(s)||s<0)throw new Error("k must be a non-negative integer");if(Ve(u)){var m=u.size();if(m.length>1)throw new Error("Only one dimensional matrices supported");return l(u.valueOf(),s,c)}if(Array.isArray(u))return l(u,s,c)}function l(u,s,c){if(s>=u.length)throw new Error("k out of bounds");for(var m=0;m<u.length;m++)if(t(u[m])&&a(u[m]))return u[m];for(var v=0,h=u.length-1;v<h;){for(var p=v,g=h,y=u[Math.floor(Math.random()*(h-v+1))+v];p<g;)if(c(u[p],y)>=0){var N=u[g];u[g]=u[p],u[p]=N,--g}else++p;c(u[p],y)>0&&--p,s<=p?h=p:v=p+1}return u[s]}}),sv="sort",tD=["typed","matrix","compare","compareNatural"],nD=q(sv,tD,r=>{var{typed:e,matrix:t,compare:a,compareNatural:n}=r,i=a,o=(s,c)=>-a(s,c);return e(sv,{Array:function(c){return l(c),c.sort(i)},Matrix:function(c){return u(c),t(c.toArray().sort(i),c.storage())},"Array, function":function(c,m){return l(c),c.sort(m)},"Matrix, function":function(c,m){return u(c),t(c.toArray().sort(m),c.storage())},"Array, string":function(c,m){return l(c),c.sort(f(m))},"Matrix, string":function(c,m){return u(c),t(c.toArray().sort(f(m)),c.storage())}});function f(s){if(s==="asc")return i;if(s==="desc")return o;if(s==="natural")return n;throw new Error('String "asc", "desc", or "natural" expected')}function l(s){if(er(s).length!==1)throw new Error("One dimensional array expected")}function u(s){if(s.size().length!==1)throw new Error("One dimensional matrix expected")}}),uv="max",aD=["typed","config","numeric","larger"],lv=q(uv,aD,r=>{var{typed:e,config:t,numeric:a,larger:n}=r;return e(uv,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(l,u){return Si(l,u.valueOf(),i)},"...":function(l){if(aa(l))throw new TypeError("Scalar values expected in function max");return o(l)}});function i(f,l){try{return n(f,l)?f:l}catch(u){throw Qr(u,"max",l)}}function o(f){var l;if(Xt(f,function(u){try{isNaN(u)&&typeof u=="number"?l=NaN:(l===void 0||n(u,l))&&(l=u)}catch(s){throw Qr(s,"max",u)}}),l===void 0)throw new Error("Cannot calculate max of an empty array");return typeof l=="string"&&(l=a(l,t.number)),l}}),cv="min",iD=["typed","config","numeric","smaller"],fv=q(cv,iD,r=>{var{typed:e,config:t,numeric:a,smaller:n}=r;return e(cv,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(l,u){return Si(l,u.valueOf(),i)},"...":function(l){if(aa(l))throw new TypeError("Scalar values expected in function min");return o(l)}});function i(f,l){try{return n(f,l)?f:l}catch(u){throw Qr(u,"min",l)}}function o(f){var l;if(Xt(f,function(u){try{isNaN(u)&&typeof u=="number"?l=NaN:(l===void 0||n(u,l))&&(l=u)}catch(s){throw Qr(s,"min",u)}}),l===void 0)throw new Error("Cannot calculate min of an empty array");return typeof l=="string"&&(l=a(l,t.number)),l}}),oD="ImmutableDenseMatrix",sD=["smaller","DenseMatrix"],uD=q(oD,sD,r=>{var{smaller:e,DenseMatrix:t}=r;function a(n,i){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(i&&!Wr(i))throw new Error("Invalid datatype: "+i);if(Ve(n)||cr(n)){var o=new t(n,i);this._data=o._data,this._size=o._size,this._datatype=o._datatype,this._min=null,this._max=null}else if(n&&cr(n.data)&&cr(n.size))this._data=n.data,this._size=n.size,this._datatype=n.datatype,this._min=typeof n.min<"u"?n.min:null,this._max=typeof n.max<"u"?n.max:null;else{if(n)throw new TypeError("Unsupported type of data ("+br(n)+")");this._data=[],this._size=[0],this._datatype=i,this._min=null,this._max=null}}return a.prototype=new t,a.prototype.type="ImmutableDenseMatrix",a.prototype.isImmutableDenseMatrix=!0,a.prototype.subset=function(n){switch(arguments.length){case 1:{var i=t.prototype.subset.call(this,n);return Ve(i)?new a({data:i._data,size:i._size,datatype:i._datatype}):i}case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},a.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},a.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},a.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},a.prototype.clone=function(){return new a({data:Ge(this._data),size:Ge(this._size),datatype:this._datatype})},a.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},a.fromJSON=function(n){return new a(n)},a.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},a.prototype.min=function(){if(this._min===null){var n=null;this.forEach(function(i){(n===null||e(i,n))&&(n=i)}),this._min=n!==null?n:void 0}return this._min},a.prototype.max=function(){if(this._max===null){var n=null;this.forEach(function(i){(n===null||e(n,i))&&(n=i)}),this._max=n!==null?n:void 0}return this._max},a},{isClass:!0}),lD="Index",cD=["ImmutableDenseMatrix"],fD=q(lD,cD,r=>{var{ImmutableDenseMatrix:e}=r;function t(n){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var i=0,o=arguments.length;i<o;i++){var f=arguments[i];if(Uo(f))this._dimensions.push(f),this._isScalar=!1;else if(Array.isArray(f)||Ve(f)){var l=a(f.valueOf());this._dimensions.push(l);var u=l.size();(u.length!==1||u[0]!==1)&&(this._isScalar=!1)}else if(typeof f=="number")this._dimensions.push(a([f]));else if(typeof f=="string")this._dimensions.push(f);else throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range")}}t.prototype.type="Index",t.prototype.isIndex=!0;function a(n){for(var i=0,o=n.length;i<o;i++)if(typeof n[i]!="number"||!qe(n[i]))throw new TypeError("Index parameters must be positive integer numbers");return new e(n)}return t.prototype.clone=function(){var n=new t;return n._dimensions=Ge(this._dimensions),n._isScalar=this._isScalar,n},t.create=function(n){var i=new t;return t.apply(i,n),i},t.prototype.size=function(){for(var n=[],i=0,o=this._dimensions.length;i<o;i++){var f=this._dimensions[i];n[i]=typeof f=="string"?1:f.size()[0]}return n},t.prototype.max=function(){for(var n=[],i=0,o=this._dimensions.length;i<o;i++){var f=this._dimensions[i];n[i]=typeof f=="string"?f:f.max()}return n},t.prototype.min=function(){for(var n=[],i=0,o=this._dimensions.length;i<o;i++){var f=this._dimensions[i];n[i]=typeof f=="string"?f:f.min()}return n},t.prototype.forEach=function(n){for(var i=0,o=this._dimensions.length;i<o;i++)n(this._dimensions[i],i,this)},t.prototype.dimension=function(n){return this._dimensions[n]||null},t.prototype.isObjectProperty=function(){return this._dimensions.length===1&&typeof this._dimensions[0]=="string"},t.prototype.getObjectProperty=function(){return this.isObjectProperty()?this._dimensions[0]:null},t.prototype.isScalar=function(){return this._isScalar},t.prototype.toArray=function(){for(var n=[],i=0,o=this._dimensions.length;i<o;i++){var f=this._dimensions[i];n.push(typeof f=="string"?f:f.toArray())}return n},t.prototype.valueOf=t.prototype.toArray,t.prototype.toString=function(){for(var n=[],i=0,o=this._dimensions.length;i<o;i++){var f=this._dimensions[i];typeof f=="string"?n.push(JSON.stringify(f)):n.push(f.toString())}return"["+n.join(", ")+"]"},t.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},t.fromJSON=function(n){return t.create(n.dimensions)},t},{isClass:!0}),mD="FibonacciHeap",vD=["smaller","larger"],pD=q(mD,vD,r=>{var{smaller:e,larger:t}=r,a=1/Math.log((1+Math.sqrt(5))/2);function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}n.prototype.type="FibonacciHeap",n.prototype.isFibonacciHeap=!0,n.prototype.insert=function(s,c){var m={key:s,value:c,degree:0};if(this._minimum){var v=this._minimum;m.left=v,m.right=v.right,v.right=m,m.right.left=m,e(s,v.key)&&(this._minimum=m)}else m.left=m,m.right=m,this._minimum=m;return this._size++,m},n.prototype.size=function(){return this._size},n.prototype.clear=function(){this._minimum=null,this._size=0},n.prototype.isEmpty=function(){return this._size===0},n.prototype.extractMinimum=function(){var s=this._minimum;if(s===null)return s;for(var c=this._minimum,m=s.degree,v=s.child;m>0;){var h=v.right;v.left.right=v.right,v.right.left=v.left,v.left=c,v.right=c.right,c.right=v,v.right.left=v,v.parent=null,v=h,m--}return s.left.right=s.right,s.right.left=s.left,s===s.right?c=null:(c=s.right,c=u(c,this._size)),this._size--,this._minimum=c,s},n.prototype.remove=function(s){this._minimum=i(this._minimum,s,-1),this.extractMinimum()};function i(s,c,m){c.key=m;var v=c.parent;return v&&e(c.key,v.key)&&(o(s,c,v),f(s,v)),e(c.key,s.key)&&(s=c),s}function o(s,c,m){c.left.right=c.right,c.right.left=c.left,m.degree--,m.child===c&&(m.child=c.right),m.degree===0&&(m.child=null),c.left=s,c.right=s.right,s.right=c,c.right.left=c,c.parent=null,c.mark=!1}function f(s,c){var m=c.parent;!m||(c.mark?(o(s,c,m),f(m)):c.mark=!0)}var l=function(c,m){c.left.right=c.right,c.right.left=c.left,c.parent=m,m.child?(c.left=m.child,c.right=m.child.right,m.child.right=c,c.right.left=c):(m.child=c,c.right=c,c.left=c),m.degree++,c.mark=!1};function u(s,c){var m=Math.floor(Math.log(c)*a)+1,v=new Array(m),h=0,p=s;if(p)for(h++,p=p.right;p!==s;)h++,p=p.right;for(var g;h>0;){for(var y=p.degree,N=p.right;g=v[y],!!g;){if(t(p.key,g.key)){var d=g;g=p,p=d}l(g,p),v[y]=null,y++}v[y]=p,p=N,h--}s=null;for(var w=0;w<m;w++)g=v[w],g&&(s?(g.left.right=g.right,g.right.left=g.left,g.left=s,g.right=s.right,s.right=g,g.right.left=g,e(g.key,s.key)&&(s=g)):s=g);return s}return n},{isClass:!0}),hD="Spa",dD=["addScalar","equalScalar","FibonacciHeap"],gD=q(hD,dD,r=>{var{addScalar:e,equalScalar:t,FibonacciHeap:a}=r;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new a}return n.prototype.type="Spa",n.prototype.isSpa=!0,n.prototype.set=function(i,o){if(this._values[i])this._values[i].value=o;else{var f=this._heap.insert(i,o);this._values[i]=f}},n.prototype.get=function(i){var o=this._values[i];return o?o.value:0},n.prototype.accumulate=function(i,o){var f=this._values[i];f?f.value=e(f.value,o):(f=this._heap.insert(i,o),this._values[i]=f)},n.prototype.forEach=function(i,o,f){var l=this._heap,u=this._values,s=[],c=l.extractMinimum();for(c&&s.push(c);c&&c.key<=o;)c.key>=i&&(t(c.value,0)||f(c.key,c.value,this)),c=l.extractMinimum(),c&&s.push(c);for(var m=0;m<s.length;m++){var v=s[m];c=l.insert(v.key,v.value),u[c.key]=c}},n.prototype.swap=function(i,o){var f=this._values[i],l=this._values[o];if(!f&&l)f=this._heap.insert(i,l.value),this._heap.remove(l),this._values[i]=f,this._values[o]=void 0;else if(f&&!l)l=this._heap.insert(o,f.value),this._heap.remove(f),this._values[o]=l,this._values[i]=void 0;else if(f&&l){var u=f.value;f.value=l.value,l.value=u}},n},{isClass:!0});function Ja(r){return Ja=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ja(r)}function yD(r,e){if(Ja(r)!=="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var a=t.call(r,e||"default");if(Ja(a)!=="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function bD(r){var e=yD(r,"string");return Ja(e)==="symbol"?e:String(e)}function zr(r,e,t){return e=bD(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var xD=Va(function(r){return new r(1).exp()},{hasher:Vi}),wD=Va(function(r){return new r(1).plus(new r(5).sqrt()).div(2)},{hasher:Vi}),gs=Va(function(r){return r.acos(-1)},{hasher:Vi}),ND=Va(function(r){return gs(r).times(2)},{hasher:Vi});function Vi(r){return r[0].precision}function mv(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);e&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,a)}return t}function ys(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?mv(Object(t),!0).forEach(function(a){zr(r,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):mv(Object(t)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(t,a))})}return r}var DD="Unit",AD=["?on","config","addScalar","subtract","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","number","Complex","BigNumber","Fraction"],ED=q(DD,AD,r=>{var{on:e,config:t,addScalar:a,subtract:n,multiplyScalar:i,divideScalar:o,pow:f,abs:l,fix:u,round:s,equal:c,isNumeric:m,format:v,number:h,Complex:p,BigNumber:g,Fraction:y}=r,N=h;function d(V,X){if(!(this instanceof d))throw new Error("Constructor must be called with the new operator");if(!(V==null||m(V)||kt(V)))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(this.fixPrefix=!1,this.skipAutomaticSimplification=!0,X===void 0)this.units=[],this.dimensions=H.map(G=>0);else if(typeof X=="string"){var oe=d.parse(X);this.units=oe.units,this.dimensions=oe.dimensions}else if(Vt(X)&&X.value===null)this.fixPrefix=X.fixPrefix,this.skipAutomaticSimplification=X.skipAutomaticSimplification,this.dimensions=X.dimensions.slice(0),this.units=X.units.map(G=>Sr({},G));else throw new TypeError("Second parameter in Unit constructor must be a string or valueless Unit");this.value=this._normalize(V)}Object.defineProperty(d,"name",{value:"Unit"}),d.prototype.constructor=d,d.prototype.type="Unit",d.prototype.isUnit=!0;var w,x,b;function E(){for(;b===" "||b===" ";)D()}function A(V){return V>="0"&&V<="9"||V==="."}function S(V){return V>="0"&&V<="9"}function D(){x++,b=w.charAt(x)}function T(V){x=V,b=w.charAt(x)}function B(){var V="",X=x;if(b==="+"?D():b==="-"&&(V+=b,D()),!A(b))return T(X),null;if(b==="."){if(V+=b,D(),!S(b))return T(X),null}else{for(;S(b);)V+=b,D();b==="."&&(V+=b,D())}for(;S(b);)V+=b,D();if(b==="E"||b==="e"){var oe="",G=x;if(oe+=b,D(),(b==="+"||b==="-")&&(oe+=b,D()),!S(b))return T(G),V;for(V=V+oe;S(b);)V+=b,D()}return V}function I(){for(var V="";S(b)||d.isValidAlpha(b);)V+=b,D();var X=V.charAt(0);return d.isValidAlpha(X)?V:null}function P(V){return b===V?(D(),V):null}d.parse=function(V,X){if(X=X||{},w=V,x=-1,b="",typeof w!="string")throw new TypeError("Invalid argument in Unit.parse, string expected");var oe=new d;oe.units=[];var G=1,Y=!1;D(),E();var te=B(),ye=null;if(te){if(t.number==="BigNumber")ye=new g(te);else if(t.number==="Fraction")try{ye=new y(te)}catch{ye=parseFloat(te)}else ye=parseFloat(te);E(),P("*")?(G=1,Y=!0):P("/")&&(G=-1,Y=!0)}for(var me=[],z=1;;){for(E();b==="(";)me.push(G),z*=G,G=1,D(),E();var U=void 0;if(b){var ee=b;if(U=I(),U===null)throw new SyntaxError('Unexpected "'+ee+'" in "'+w+'" at index '+x.toString())}else break;var ue=R(U);if(ue===null)throw new SyntaxError('Unit "'+U+'" not found.');var ve=G*z;if(E(),P("^")){E();var de=B();if(de===null)throw new SyntaxError('In "'+V+'", "^" must be followed by a floating-point number');ve*=de}oe.units.push({unit:ue.unit,prefix:ue.prefix,power:ve});for(var be=0;be<H.length;be++)oe.dimensions[be]+=(ue.unit.dimensions[be]||0)*ve;for(E();b===")";){if(me.length===0)throw new SyntaxError('Unmatched ")" in "'+w+'" at index '+x.toString());z/=me.pop(),D(),E()}if(Y=!1,P("*")?(G=1,Y=!0):P("/")?(G=-1,Y=!0):G=1,ue.unit.base){var pe=ue.unit.base.key;re.auto[pe]={unit:ue.unit,prefix:ue.prefix}}}if(E(),b)throw new SyntaxError('Could not parse: "'+V+'"');if(Y)throw new SyntaxError('Trailing characters: "'+V+'"');if(me.length!==0)throw new SyntaxError('Unmatched "(" in "'+w+'"');if(oe.units.length===0&&!X.allowNoUnits)throw new SyntaxError('"'+V+'" contains no units');return oe.value=ye!==void 0?oe._normalize(ye):null,oe},d.prototype.clone=function(){var V=new d;V.fixPrefix=this.fixPrefix,V.skipAutomaticSimplification=this.skipAutomaticSimplification,V.value=Ge(this.value),V.dimensions=this.dimensions.slice(0),V.units=[];for(var X=0;X<this.units.length;X++){V.units[X]={};for(var oe in this.units[X])Re(this.units[X],oe)&&(V.units[X][oe]=this.units[X][oe])}return V},d.prototype.valueType=function(){return br(this.value)},d.prototype._isDerived=function(){return this.units.length===0?!1:this.units.length>1||Math.abs(this.units[0].power-1)>1e-15},d.prototype._normalize=function(V){if(V==null||this.units.length===0)return V;for(var X=V,oe=d._getNumberConverter(br(V)),G=0;G<this.units.length;G++){var Y=oe(this.units[G].unit.value),te=oe(this.units[G].prefix.value),ye=oe(this.units[G].power);X=i(X,f(i(Y,te),ye))}return X},d.prototype._denormalize=function(V,X){if(V==null||this.units.length===0)return V;for(var oe=V,G=d._getNumberConverter(br(V)),Y=0;Y<this.units.length;Y++){var te=G(this.units[Y].unit.value),ye=G(this.units[Y].prefix.value),me=G(this.units[Y].power);oe=o(oe,f(i(te,ye),me))}return oe};var R=Va(V=>{if(Re(L,V)){var X=L[V],oe=X.prefixes[""];return{unit:X,prefix:oe}}for(var G in L)if(Re(L,G)&&yg(V,G)){var Y=L[G],te=V.length-G.length,ye=V.substring(0,te),me=Re(Y.prefixes,ye)?Y.prefixes[ye]:void 0;if(me!==void 0)return{unit:Y,prefix:me}}return null},{hasher:V=>V[0],limit:100});d.isValuelessUnit=function(V){return R(V)!==null},d.prototype.hasBase=function(V){if(typeof V=="string"&&(V=$[V]),!V)return!1;for(var X=0;X<H.length;X++)if(Math.abs((this.dimensions[X]||0)-(V.dimensions[X]||0))>1e-12)return!1;return!0},d.prototype.equalBase=function(V){for(var X=0;X<H.length;X++)if(Math.abs((this.dimensions[X]||0)-(V.dimensions[X]||0))>1e-12)return!1;return!0},d.prototype.equals=function(V){return this.equalBase(V)&&c(this.value,V.value)},d.prototype.multiply=function(V){for(var X=this.clone(),oe=Vt(V)?V:new d(V),G=0;G<H.length;G++)X.dimensions[G]=(this.dimensions[G]||0)+(oe.dimensions[G]||0);for(var Y=0;Y<oe.units.length;Y++){var te=ys({},oe.units[Y]);X.units.push(te)}if(this.value!==null||oe.value!==null){var ye=this.value===null?this._normalize(1):this.value,me=oe.value===null?oe._normalize(1):oe.value;X.value=i(ye,me)}else X.value=null;return Vt(V)&&(X.skipAutomaticSimplification=!1),M(X)},d.prototype.divideInto=function(V){return new d(V).divide(this)},d.prototype.divide=function(V){for(var X=this.clone(),oe=Vt(V)?V:new d(V),G=0;G<H.length;G++)X.dimensions[G]=(this.dimensions[G]||0)-(oe.dimensions[G]||0);for(var Y=0;Y<oe.units.length;Y++){var te=ys(ys({},oe.units[Y]),{},{power:-oe.units[Y].power});X.units.push(te)}if(this.value!==null||oe.value!==null){var ye=this.value===null?this._normalize(1):this.value,me=oe.value===null?oe._normalize(1):oe.value;X.value=o(ye,me)}else X.value=null;return Vt(V)&&(X.skipAutomaticSimplification=!1),M(X)},d.prototype.pow=function(V){for(var X=this.clone(),oe=0;oe<H.length;oe++)X.dimensions[oe]=(this.dimensions[oe]||0)*V;for(var G=0;G<X.units.length;G++)X.units[G].power*=V;return X.value!==null?X.value=f(X.value,V):X.value=null,X.skipAutomaticSimplification=!1,M(X)};function M(V){return V.equalBase($.NONE)&&V.value!==null&&!t.predictable?V.value:V}d.prototype.abs=function(){var V=this.clone();if(V.value!==null)if(V._isDerived()||V.units[0].unit.offset===0)V.value=l(V.value);else{var X=V._numberConverter(),oe=X(V.units[0].unit.value),G=X(V.units[0].unit.offset),Y=i(oe,G);V.value=n(l(a(V.value,Y)),Y)}for(var te in V.units)(V.units[te].unit.name==="VA"||V.units[te].unit.name==="VAR")&&(V.units[te].unit=L.W);return V},d.prototype.to=function(V){var X=this.value===null?this._normalize(1):this.value,oe;if(typeof V=="string")oe=d.parse(V);else if(Vt(V))oe=V.clone();else throw new Error("String or Unit expected as parameter");if(!this.equalBase(oe))throw new Error("Units do not match ('".concat(oe.toString(),"' != '").concat(this.toString(),"')"));if(oe.value!==null)throw new Error("Cannot convert to a unit with a value");if(this.value===null||this._isDerived()||this.units[0].unit.offset===oe.units[0].unit.offset)oe.value=Ge(X);else{var G=d._getNumberConverter(br(X)),Y=G(this.units[0].unit.value),te=G(this.units[0].unit.offset),ye=i(Y,te),me=G(oe.units[0].unit.value),z=G(oe.units[0].unit.offset),U=i(me,z);oe.value=n(a(X,ye),U)}return oe.fixPrefix=!0,oe.skipAutomaticSimplification=!0,oe},d.prototype.toNumber=function(V){return N(this.toNumeric(V))},d.prototype.toNumeric=function(V){var X;return V?X=this.to(V):X=this.clone(),X._isDerived()||X.units.length===0?X._denormalize(X.value):X._denormalize(X.value,X.units[0].prefix.value)},d.prototype.toString=function(){return this.format()},d.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.formatUnits(),fixPrefix:this.fixPrefix}},d.fromJSON=function(V){var X=new d(V.value,V.unit);return X.fixPrefix=V.fixPrefix||!1,X},d.prototype.valueOf=d.prototype.toString,d.prototype.simplify=function(){var V=this.clone(),X=[],oe;for(var G in fe)if(Re(fe,G)&&V.hasBase($[G])){oe=G;break}if(oe==="NONE")V.units=[];else{var Y;if(oe&&Re(fe,oe)&&(Y=fe[oe]),Y)V.units=[{unit:Y.unit,prefix:Y.prefix,power:1}];else{for(var te=!1,ye=0;ye<H.length;ye++){var me=H[ye];Math.abs(V.dimensions[ye]||0)>1e-12&&(Re(fe,me)?X.push({unit:fe[me].unit,prefix:fe[me].prefix,power:V.dimensions[ye]||0}):te=!0)}X.length<V.units.length&&!te&&(V.units=X)}}return V},d.prototype.toSI=function(){for(var V=this.clone(),X=[],oe=0;oe<H.length;oe++){var G=H[oe];if(Math.abs(V.dimensions[oe]||0)>1e-12)if(Re(re.si,G))X.push({unit:re.si[G].unit,prefix:re.si[G].prefix,power:V.dimensions[oe]||0});else throw new Error("Cannot express custom unit "+G+" in SI units")}return V.units=X,V.fixPrefix=!0,V.skipAutomaticSimplification=!0,V},d.prototype.formatUnits=function(){for(var V="",X="",oe=0,G=0,Y=0;Y<this.units.length;Y++)this.units[Y].power>0?(oe++,V+=" "+this.units[Y].prefix.name+this.units[Y].unit.name,Math.abs(this.units[Y].power-1)>1e-15&&(V+="^"+this.units[Y].power)):this.units[Y].power<0&&G++;if(G>0)for(var te=0;te<this.units.length;te++)this.units[te].power<0&&(oe>0?(X+=" "+this.units[te].prefix.name+this.units[te].unit.name,Math.abs(this.units[te].power+1)>1e-15&&(X+="^"+-this.units[te].power)):(X+=" "+this.units[te].prefix.name+this.units[te].unit.name,X+="^"+this.units[te].power));V=V.substr(1),X=X.substr(1),oe>1&&G>0&&(V="("+V+")"),G>1&&oe>0&&(X="("+X+")");var ye=V;return oe>0&&G>0&&(ye+=" / "),ye+=X,ye},d.prototype.format=function(V){var X=this.skipAutomaticSimplification||this.value===null?this.clone():this.simplify(),oe=!1;typeof X.value<"u"&&X.value!==null&&kt(X.value)&&(oe=Math.abs(X.value.re)<1e-14);for(var G in X.units)Re(X.units,G)&&X.units[G].unit&&(X.units[G].unit.name==="VA"&&oe?X.units[G].unit=L.VAR:X.units[G].unit.name==="VAR"&&!oe&&(X.units[G].unit=L.VA));X.units.length===1&&!X.fixPrefix&&Math.abs(X.units[0].power-Math.round(X.units[0].power))<1e-14&&(X.units[0].prefix=X._bestPrefix());var Y=X._denormalize(X.value),te=X.value!==null?v(Y,V||{}):"",ye=X.formatUnits();return X.value&&kt(X.value)&&(te="("+te+")"),ye.length>0&&te.length>0&&(te+=" "),te+=ye,te},d.prototype._bestPrefix=function(){if(this.units.length!==1)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var V=this.value!==null?l(this.value):0,X=l(this.units[0].unit.value),oe=this.units[0].prefix;if(V===0)return oe;var G=this.units[0].power,Y=Math.log(V/Math.pow(oe.value*X,G))/Math.LN10-1.2;if(Y>-2.200001&&Y<1.800001)return oe;Y=Math.abs(Y);var te=this.units[0].unit.prefixes;for(var ye in te)if(Re(te,ye)){var me=te[ye];if(me.scientific){var z=Math.abs(Math.log(V/Math.pow(me.value*X,G))/Math.LN10-1.2);(z<Y||z===Y&&me.name.length<oe.name.length)&&(oe=me,Y=z)}}return oe},d.prototype.splitUnit=function(V){for(var X=this.clone(),oe=[],G=0;G<V.length&&(X=X.to(V[G]),G!==V.length-1);G++){var Y=X.toNumeric(),te=s(Y),ye=void 0,me=c(te,Y);me?ye=te:ye=u(X.toNumeric());var z=new d(ye,V[G].toString());oe.push(z),X=n(X,z)}for(var U=0,ee=0;ee<oe.length;ee++)U=a(U,oe[ee].value);return c(U,this.value)&&(X.value=0),oe.push(X),oe};var F={NONE:{"":{name:"",value:1,scientific:!0}},SHORT:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:10,scientific:!1},h:{name:"h",value:100,scientific:!1},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0},d:{name:"d",value:.1,scientific:!1},c:{name:"c",value:.01,scientific:!1},m:{name:"m",value:.001,scientific:!0},u:{name:"u",value:1e-6,scientific:!0},n:{name:"n",value:1e-9,scientific:!0},p:{name:"p",value:1e-12,scientific:!0},f:{name:"f",value:1e-15,scientific:!0},a:{name:"a",value:1e-18,scientific:!0},z:{name:"z",value:1e-21,scientific:!0},y:{name:"y",value:1e-24,scientific:!0}},LONG:{"":{name:"",value:1,scientific:!0},deca:{name:"deca",value:10,scientific:!1},hecto:{name:"hecto",value:100,scientific:!1},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0},deci:{name:"deci",value:.1,scientific:!1},centi:{name:"centi",value:.01,scientific:!1},milli:{name:"milli",value:.001,scientific:!0},micro:{name:"micro",value:1e-6,scientific:!0},nano:{name:"nano",value:1e-9,scientific:!0},pico:{name:"pico",value:1e-12,scientific:!0},femto:{name:"femto",value:1e-15,scientific:!0},atto:{name:"atto",value:1e-18,scientific:!0},zepto:{name:"zepto",value:1e-21,scientific:!0},yocto:{name:"yocto",value:1e-24,scientific:!0}},SQUARED:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:100,scientific:!1},h:{name:"h",value:1e4,scientific:!1},k:{name:"k",value:1e6,scientific:!0},M:{name:"M",value:1e12,scientific:!0},G:{name:"G",value:1e18,scientific:!0},T:{name:"T",value:1e24,scientific:!0},P:{name:"P",value:1e30,scientific:!0},E:{name:"E",value:1e36,scientific:!0},Z:{name:"Z",value:1e42,scientific:!0},Y:{name:"Y",value:1e48,scientific:!0},d:{name:"d",value:.01,scientific:!1},c:{name:"c",value:1e-4,scientific:!1},m:{name:"m",value:1e-6,scientific:!0},u:{name:"u",value:1e-12,scientific:!0},n:{name:"n",value:1e-18,scientific:!0},p:{name:"p",value:1e-24,scientific:!0},f:{name:"f",value:1e-30,scientific:!0},a:{name:"a",value:1e-36,scientific:!0},z:{name:"z",value:1e-42,scientific:!0},y:{name:"y",value:1e-48,scientific:!0}},CUBIC:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:1e3,scientific:!1},h:{name:"h",value:1e6,scientific:!1},k:{name:"k",value:1e9,scientific:!0},M:{name:"M",value:1e18,scientific:!0},G:{name:"G",value:1e27,scientific:!0},T:{name:"T",value:1e36,scientific:!0},P:{name:"P",value:1e45,scientific:!0},E:{name:"E",value:1e54,scientific:!0},Z:{name:"Z",value:1e63,scientific:!0},Y:{name:"Y",value:1e72,scientific:!0},d:{name:"d",value:.001,scientific:!1},c:{name:"c",value:1e-6,scientific:!1},m:{name:"m",value:1e-9,scientific:!0},u:{name:"u",value:1e-18,scientific:!0},n:{name:"n",value:1e-27,scientific:!0},p:{name:"p",value:1e-36,scientific:!0},f:{name:"f",value:1e-45,scientific:!0},a:{name:"a",value:1e-54,scientific:!0},z:{name:"z",value:1e-63,scientific:!0},y:{name:"y",value:1e-72,scientific:!0}},BINARY_SHORT_SI:{"":{name:"",value:1,scientific:!0},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0}},BINARY_SHORT_IEC:{"":{name:"",value:1,scientific:!0},Ki:{name:"Ki",value:1024,scientific:!0},Mi:{name:"Mi",value:Math.pow(1024,2),scientific:!0},Gi:{name:"Gi",value:Math.pow(1024,3),scientific:!0},Ti:{name:"Ti",value:Math.pow(1024,4),scientific:!0},Pi:{name:"Pi",value:Math.pow(1024,5),scientific:!0},Ei:{name:"Ei",value:Math.pow(1024,6),scientific:!0},Zi:{name:"Zi",value:Math.pow(1024,7),scientific:!0},Yi:{name:"Yi",value:Math.pow(1024,8),scientific:!0}},BINARY_LONG_SI:{"":{name:"",value:1,scientific:!0},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0}},BINARY_LONG_IEC:{"":{name:"",value:1,scientific:!0},kibi:{name:"kibi",value:1024,scientific:!0},mebi:{name:"mebi",value:Math.pow(1024,2),scientific:!0},gibi:{name:"gibi",value:Math.pow(1024,3),scientific:!0},tebi:{name:"tebi",value:Math.pow(1024,4),scientific:!0},pebi:{name:"pebi",value:Math.pow(1024,5),scientific:!0},exi:{name:"exi",value:Math.pow(1024,6),scientific:!0},zebi:{name:"zebi",value:Math.pow(1024,7),scientific:!0},yobi:{name:"yobi",value:Math.pow(1024,8),scientific:!0}},BTU:{"":{name:"",value:1,scientific:!0},MM:{name:"MM",value:1e6,scientific:!0}}};F.SHORTLONG=Sr({},F.SHORT,F.LONG),F.BINARY_SHORT=Sr({},F.BINARY_SHORT_SI,F.BINARY_SHORT_IEC),F.BINARY_LONG=Sr({},F.BINARY_LONG_SI,F.BINARY_LONG_IEC);var H=["MASS","LENGTH","TIME","CURRENT","TEMPERATURE","LUMINOUS_INTENSITY","AMOUNT_OF_SUBSTANCE","ANGLE","BIT"],$={NONE:{dimensions:[0,0,0,0,0,0,0,0,0]},MASS:{dimensions:[1,0,0,0,0,0,0,0,0]},LENGTH:{dimensions:[0,1,0,0,0,0,0,0,0]},TIME:{dimensions:[0,0,1,0,0,0,0,0,0]},CURRENT:{dimensions:[0,0,0,1,0,0,0,0,0]},TEMPERATURE:{dimensions:[0,0,0,0,1,0,0,0,0]},LUMINOUS_INTENSITY:{dimensions:[0,0,0,0,0,1,0,0,0]},AMOUNT_OF_SUBSTANCE:{dimensions:[0,0,0,0,0,0,1,0,0]},FORCE:{dimensions:[1,1,-2,0,0,0,0,0,0]},SURFACE:{dimensions:[0,2,0,0,0,0,0,0,0]},VOLUME:{dimensions:[0,3,0,0,0,0,0,0,0]},ENERGY:{dimensions:[1,2,-2,0,0,0,0,0,0]},POWER:{dimensions:[1,2,-3,0,0,0,0,0,0]},PRESSURE:{dimensions:[1,-1,-2,0,0,0,0,0,0]},ELECTRIC_CHARGE:{dimensions:[0,0,1,1,0,0,0,0,0]},ELECTRIC_CAPACITANCE:{dimensions:[-1,-2,4,2,0,0,0,0,0]},ELECTRIC_POTENTIAL:{dimensions:[1,2,-3,-1,0,0,0,0,0]},ELECTRIC_RESISTANCE:{dimensions:[1,2,-3,-2,0,0,0,0,0]},ELECTRIC_INDUCTANCE:{dimensions:[1,2,-2,-2,0,0,0,0,0]},ELECTRIC_CONDUCTANCE:{dimensions:[-1,-2,3,2,0,0,0,0,0]},MAGNETIC_FLUX:{dimensions:[1,2,-2,-1,0,0,0,0,0]},MAGNETIC_FLUX_DENSITY:{dimensions:[1,0,-2,-1,0,0,0,0,0]},FREQUENCY:{dimensions:[0,0,-1,0,0,0,0,0,0]},ANGLE:{dimensions:[0,0,0,0,0,0,0,1,0]},BIT:{dimensions:[0,0,0,0,0,0,0,0,1]}};for(var k in $)Re($,k)&&($[k].key=k);var Q={},K={name:"",base:Q,value:1,offset:0,dimensions:H.map(V=>0)},L={meter:{name:"meter",base:$.LENGTH,prefixes:F.LONG,value:1,offset:0},inch:{name:"inch",base:$.LENGTH,prefixes:F.NONE,value:.0254,offset:0},foot:{name:"foot",base:$.LENGTH,prefixes:F.NONE,value:.3048,offset:0},yard:{name:"yard",base:$.LENGTH,prefixes:F.NONE,value:.9144,offset:0},mile:{name:"mile",base:$.LENGTH,prefixes:F.NONE,value:1609.344,offset:0},link:{name:"link",base:$.LENGTH,prefixes:F.NONE,value:.201168,offset:0},rod:{name:"rod",base:$.LENGTH,prefixes:F.NONE,value:5.0292,offset:0},chain:{name:"chain",base:$.LENGTH,prefixes:F.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:$.LENGTH,prefixes:F.NONE,value:1e-10,offset:0},m:{name:"m",base:$.LENGTH,prefixes:F.SHORT,value:1,offset:0},in:{name:"in",base:$.LENGTH,prefixes:F.NONE,value:.0254,offset:0},ft:{name:"ft",base:$.LENGTH,prefixes:F.NONE,value:.3048,offset:0},yd:{name:"yd",base:$.LENGTH,prefixes:F.NONE,value:.9144,offset:0},mi:{name:"mi",base:$.LENGTH,prefixes:F.NONE,value:1609.344,offset:0},li:{name:"li",base:$.LENGTH,prefixes:F.NONE,value:.201168,offset:0},rd:{name:"rd",base:$.LENGTH,prefixes:F.NONE,value:5.02921,offset:0},ch:{name:"ch",base:$.LENGTH,prefixes:F.NONE,value:20.1168,offset:0},mil:{name:"mil",base:$.LENGTH,prefixes:F.NONE,value:254e-7,offset:0},m2:{name:"m2",base:$.SURFACE,prefixes:F.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:$.SURFACE,prefixes:F.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:$.SURFACE,prefixes:F.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:$.SURFACE,prefixes:F.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:$.SURFACE,prefixes:F.NONE,value:2589988110336e-6,offset:0},sqrd:{name:"sqrd",base:$.SURFACE,prefixes:F.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:$.SURFACE,prefixes:F.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:$.SURFACE,prefixes:F.NONE,value:64516e-14,offset:0},acre:{name:"acre",base:$.SURFACE,prefixes:F.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:$.SURFACE,prefixes:F.NONE,value:1e4,offset:0},m3:{name:"m3",base:$.VOLUME,prefixes:F.CUBIC,value:1,offset:0},L:{name:"L",base:$.VOLUME,prefixes:F.SHORT,value:.001,offset:0},l:{name:"l",base:$.VOLUME,prefixes:F.SHORT,value:.001,offset:0},litre:{name:"litre",base:$.VOLUME,prefixes:F.LONG,value:.001,offset:0},cuin:{name:"cuin",base:$.VOLUME,prefixes:F.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:$.VOLUME,prefixes:F.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:$.VOLUME,prefixes:F.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:$.VOLUME,prefixes:F.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:$.VOLUME,prefixes:F.NONE,value:15e-6,offset:0},drop:{name:"drop",base:$.VOLUME,prefixes:F.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:$.VOLUME,prefixes:F.NONE,value:5e-8,offset:0},minim:{name:"minim",base:$.VOLUME,prefixes:F.NONE,value:6161152e-14,offset:0},fluiddram:{name:"fluiddram",base:$.VOLUME,prefixes:F.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:$.VOLUME,prefixes:F.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:$.VOLUME,prefixes:F.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:$.VOLUME,prefixes:F.NONE,value:1e-6,offset:0},cup:{name:"cup",base:$.VOLUME,prefixes:F.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:$.VOLUME,prefixes:F.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:$.VOLUME,prefixes:F.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:$.VOLUME,prefixes:F.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:$.VOLUME,prefixes:F.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:$.VOLUME,prefixes:F.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:$.VOLUME,prefixes:F.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:$.VOLUME,prefixes:F.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:$.VOLUME,prefixes:F.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:$.VOLUME,prefixes:F.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:$.VOLUME,prefixes:F.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:$.VOLUME,prefixes:F.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:$.VOLUME,prefixes:F.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:$.VOLUME,prefixes:F.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:$.VOLUME,prefixes:F.NONE,value:.1173478,offset:0},obl:{name:"obl",base:$.VOLUME,prefixes:F.NONE,value:.1589873,offset:0},g:{name:"g",base:$.MASS,prefixes:F.SHORT,value:.001,offset:0},gram:{name:"gram",base:$.MASS,prefixes:F.LONG,value:.001,offset:0},ton:{name:"ton",base:$.MASS,prefixes:F.SHORT,value:907.18474,offset:0},t:{name:"t",base:$.MASS,prefixes:F.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:$.MASS,prefixes:F.LONG,value:1e3,offset:0},grain:{name:"grain",base:$.MASS,prefixes:F.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:$.MASS,prefixes:F.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:$.MASS,prefixes:F.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:$.MASS,prefixes:F.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:$.MASS,prefixes:F.NONE,value:45.359237,offset:0},stick:{name:"stick",base:$.MASS,prefixes:F.NONE,value:.115,offset:0},stone:{name:"stone",base:$.MASS,prefixes:F.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:$.MASS,prefixes:F.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:$.MASS,prefixes:F.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:$.MASS,prefixes:F.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:$.MASS,prefixes:F.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:$.MASS,prefixes:F.NONE,value:45.359237,offset:0},s:{name:"s",base:$.TIME,prefixes:F.SHORT,value:1,offset:0},min:{name:"min",base:$.TIME,prefixes:F.NONE,value:60,offset:0},h:{name:"h",base:$.TIME,prefixes:F.NONE,value:3600,offset:0},second:{name:"second",base:$.TIME,prefixes:F.LONG,value:1,offset:0},sec:{name:"sec",base:$.TIME,prefixes:F.LONG,value:1,offset:0},minute:{name:"minute",base:$.TIME,prefixes:F.NONE,value:60,offset:0},hour:{name:"hour",base:$.TIME,prefixes:F.NONE,value:3600,offset:0},day:{name:"day",base:$.TIME,prefixes:F.NONE,value:86400,offset:0},week:{name:"week",base:$.TIME,prefixes:F.NONE,value:7*86400,offset:0},month:{name:"month",base:$.TIME,prefixes:F.NONE,value:2629800,offset:0},year:{name:"year",base:$.TIME,prefixes:F.NONE,value:31557600,offset:0},decade:{name:"decade",base:$.TIME,prefixes:F.NONE,value:315576e3,offset:0},century:{name:"century",base:$.TIME,prefixes:F.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:$.TIME,prefixes:F.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:$.FREQUENCY,prefixes:F.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:$.FREQUENCY,prefixes:F.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:$.ANGLE,prefixes:F.SHORT,value:1,offset:0},radian:{name:"radian",base:$.ANGLE,prefixes:F.LONG,value:1,offset:0},deg:{name:"deg",base:$.ANGLE,prefixes:F.SHORT,value:null,offset:0},degree:{name:"degree",base:$.ANGLE,prefixes:F.LONG,value:null,offset:0},grad:{name:"grad",base:$.ANGLE,prefixes:F.SHORT,value:null,offset:0},gradian:{name:"gradian",base:$.ANGLE,prefixes:F.LONG,value:null,offset:0},cycle:{name:"cycle",base:$.ANGLE,prefixes:F.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:$.ANGLE,prefixes:F.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:$.ANGLE,prefixes:F.NONE,value:null,offset:0},A:{name:"A",base:$.CURRENT,prefixes:F.SHORT,value:1,offset:0},ampere:{name:"ampere",base:$.CURRENT,prefixes:F.LONG,value:1,offset:0},K:{name:"K",base:$.TEMPERATURE,prefixes:F.SHORT,value:1,offset:0},degC:{name:"degC",base:$.TEMPERATURE,prefixes:F.SHORT,value:1,offset:273.15},degF:{name:"degF",base:$.TEMPERATURE,prefixes:F.SHORT,value:1/1.8,offset:459.67},degR:{name:"degR",base:$.TEMPERATURE,prefixes:F.SHORT,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:$.TEMPERATURE,prefixes:F.LONG,value:1,offset:0},celsius:{name:"celsius",base:$.TEMPERATURE,prefixes:F.LONG,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:$.TEMPERATURE,prefixes:F.LONG,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:$.TEMPERATURE,prefixes:F.LONG,value:1/1.8,offset:0},mol:{name:"mol",base:$.AMOUNT_OF_SUBSTANCE,prefixes:F.SHORT,value:1,offset:0},mole:{name:"mole",base:$.AMOUNT_OF_SUBSTANCE,prefixes:F.LONG,value:1,offset:0},cd:{name:"cd",base:$.LUMINOUS_INTENSITY,prefixes:F.SHORT,value:1,offset:0},candela:{name:"candela",base:$.LUMINOUS_INTENSITY,prefixes:F.LONG,value:1,offset:0},N:{name:"N",base:$.FORCE,prefixes:F.SHORT,value:1,offset:0},newton:{name:"newton",base:$.FORCE,prefixes:F.LONG,value:1,offset:0},dyn:{name:"dyn",base:$.FORCE,prefixes:F.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:$.FORCE,prefixes:F.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:$.FORCE,prefixes:F.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:$.FORCE,prefixes:F.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:$.FORCE,prefixes:F.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:$.FORCE,prefixes:F.NONE,value:9.80665,offset:0},J:{name:"J",base:$.ENERGY,prefixes:F.SHORT,value:1,offset:0},joule:{name:"joule",base:$.ENERGY,prefixes:F.SHORT,value:1,offset:0},erg:{name:"erg",base:$.ENERGY,prefixes:F.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:$.ENERGY,prefixes:F.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:$.ENERGY,prefixes:F.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:$.ENERGY,prefixes:F.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:$.ENERGY,prefixes:F.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:$.POWER,prefixes:F.SHORT,value:1,offset:0},watt:{name:"watt",base:$.POWER,prefixes:F.LONG,value:1,offset:0},hp:{name:"hp",base:$.POWER,prefixes:F.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:$.POWER,prefixes:F.SHORT,value:p.I,offset:0},VA:{name:"VA",base:$.POWER,prefixes:F.SHORT,value:1,offset:0},Pa:{name:"Pa",base:$.PRESSURE,prefixes:F.SHORT,value:1,offset:0},psi:{name:"psi",base:$.PRESSURE,prefixes:F.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:$.PRESSURE,prefixes:F.NONE,value:101325,offset:0},bar:{name:"bar",base:$.PRESSURE,prefixes:F.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:$.PRESSURE,prefixes:F.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:$.PRESSURE,prefixes:F.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:$.PRESSURE,prefixes:F.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:$.PRESSURE,prefixes:F.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:$.ELECTRIC_CHARGE,prefixes:F.LONG,value:1,offset:0},C:{name:"C",base:$.ELECTRIC_CHARGE,prefixes:F.SHORT,value:1,offset:0},farad:{name:"farad",base:$.ELECTRIC_CAPACITANCE,prefixes:F.LONG,value:1,offset:0},F:{name:"F",base:$.ELECTRIC_CAPACITANCE,prefixes:F.SHORT,value:1,offset:0},volt:{name:"volt",base:$.ELECTRIC_POTENTIAL,prefixes:F.LONG,value:1,offset:0},V:{name:"V",base:$.ELECTRIC_POTENTIAL,prefixes:F.SHORT,value:1,offset:0},ohm:{name:"ohm",base:$.ELECTRIC_RESISTANCE,prefixes:F.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:$.ELECTRIC_INDUCTANCE,prefixes:F.LONG,value:1,offset:0},H:{name:"H",base:$.ELECTRIC_INDUCTANCE,prefixes:F.SHORT,value:1,offset:0},siemens:{name:"siemens",base:$.ELECTRIC_CONDUCTANCE,prefixes:F.LONG,value:1,offset:0},S:{name:"S",base:$.ELECTRIC_CONDUCTANCE,prefixes:F.SHORT,value:1,offset:0},weber:{name:"weber",base:$.MAGNETIC_FLUX,prefixes:F.LONG,value:1,offset:0},Wb:{name:"Wb",base:$.MAGNETIC_FLUX,prefixes:F.SHORT,value:1,offset:0},tesla:{name:"tesla",base:$.MAGNETIC_FLUX_DENSITY,prefixes:F.LONG,value:1,offset:0},T:{name:"T",base:$.MAGNETIC_FLUX_DENSITY,prefixes:F.SHORT,value:1,offset:0},b:{name:"b",base:$.BIT,prefixes:F.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:$.BIT,prefixes:F.BINARY_LONG,value:1,offset:0},B:{name:"B",base:$.BIT,prefixes:F.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:$.BIT,prefixes:F.BINARY_LONG,value:8,offset:0}},j={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",amps:"ampere",amp:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function ae(V){if(V.number==="BigNumber"){var X=gs(g);L.rad.value=new g(1),L.deg.value=X.div(180),L.grad.value=X.div(200),L.cycle.value=X.times(2),L.arcsec.value=X.div(648e3),L.arcmin.value=X.div(10800)}else L.rad.value=1,L.deg.value=Math.PI/180,L.grad.value=Math.PI/200,L.cycle.value=Math.PI*2,L.arcsec.value=Math.PI/648e3,L.arcmin.value=Math.PI/10800;L.radian.value=L.rad.value,L.degree.value=L.deg.value,L.gradian.value=L.grad.value}ae(t),e&&e("config",function(V,X){V.number!==X.number&&ae(V)});var re={si:{NONE:{unit:K,prefix:F.NONE[""]},LENGTH:{unit:L.m,prefix:F.SHORT[""]},MASS:{unit:L.g,prefix:F.SHORT.k},TIME:{unit:L.s,prefix:F.SHORT[""]},CURRENT:{unit:L.A,prefix:F.SHORT[""]},TEMPERATURE:{unit:L.K,prefix:F.SHORT[""]},LUMINOUS_INTENSITY:{unit:L.cd,prefix:F.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:L.mol,prefix:F.SHORT[""]},ANGLE:{unit:L.rad,prefix:F.SHORT[""]},BIT:{unit:L.bits,prefix:F.SHORT[""]},FORCE:{unit:L.N,prefix:F.SHORT[""]},ENERGY:{unit:L.J,prefix:F.SHORT[""]},POWER:{unit:L.W,prefix:F.SHORT[""]},PRESSURE:{unit:L.Pa,prefix:F.SHORT[""]},ELECTRIC_CHARGE:{unit:L.C,prefix:F.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:L.F,prefix:F.SHORT[""]},ELECTRIC_POTENTIAL:{unit:L.V,prefix:F.SHORT[""]},ELECTRIC_RESISTANCE:{unit:L.ohm,prefix:F.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:L.H,prefix:F.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:L.S,prefix:F.SHORT[""]},MAGNETIC_FLUX:{unit:L.Wb,prefix:F.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:L.T,prefix:F.SHORT[""]},FREQUENCY:{unit:L.Hz,prefix:F.SHORT[""]}}};re.cgs=JSON.parse(JSON.stringify(re.si)),re.cgs.LENGTH={unit:L.m,prefix:F.SHORT.c},re.cgs.MASS={unit:L.g,prefix:F.SHORT[""]},re.cgs.FORCE={unit:L.dyn,prefix:F.SHORT[""]},re.cgs.ENERGY={unit:L.erg,prefix:F.NONE[""]},re.us=JSON.parse(JSON.stringify(re.si)),re.us.LENGTH={unit:L.ft,prefix:F.NONE[""]},re.us.MASS={unit:L.lbm,prefix:F.NONE[""]},re.us.TEMPERATURE={unit:L.degF,prefix:F.NONE[""]},re.us.FORCE={unit:L.lbf,prefix:F.NONE[""]},re.us.ENERGY={unit:L.BTU,prefix:F.BTU[""]},re.us.POWER={unit:L.hp,prefix:F.NONE[""]},re.us.PRESSURE={unit:L.psi,prefix:F.NONE[""]},re.auto=JSON.parse(JSON.stringify(re.si));var fe=re.auto;d.setUnitSystem=function(V){if(Re(re,V))fe=re[V];else throw new Error("Unit system "+V+" does not exist. Choices are: "+Object.keys(re).join(", "))},d.getUnitSystem=function(){for(var V in re)if(Re(re,V)&&re[V]===fe)return V},d.typeConverters={BigNumber:function(X){return new g(X+"")},Fraction:function(X){return new y(X)},Complex:function(X){return X},number:function(X){return X}},d.prototype._numberConverter=function(){var V=d.typeConverters[this.valueType()];if(V)return V;throw new TypeError('Unsupported Unit value type "'+this.valueType()+'"')},d._getNumberConverter=function(V){if(!d.typeConverters[V])throw new TypeError('Unsupported type "'+V+'"');return d.typeConverters[V]};for(var he in L)if(Re(L,he)){var ce=L[he];ce.dimensions=ce.base.dimensions}for(var ie in j)if(Re(j,ie)){var Ae=L[j[ie]],Oe={};for(var Ce in Ae)Re(Ae,Ce)&&(Oe[Ce]=Ae[Ce]);Oe.name=ie,L[ie]=Oe}d.isValidAlpha=function(X){return/^[a-zA-Z]$/.test(X)};function $e(V){for(var X=0;X<V.length;X++){if(b=V.charAt(X),X===0&&!d.isValidAlpha(b))throw new Error('Invalid unit name (must begin with alpha character): "'+V+'"');if(X>0&&!(d.isValidAlpha(b)||S(b)))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+V+'"')}}return d.createUnit=function(V,X){if(typeof V!="object")throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(X&&X.override){for(var oe in V)if(Re(V,oe)&&d.deleteUnit(oe),V[oe].aliases)for(var G=0;G<V[oe].aliases.length;G++)d.deleteUnit(V[oe].aliases[G])}var Y;for(var te in V)Re(V,te)&&(Y=d.createUnitSingle(te,V[te]));return Y},d.createUnitSingle=function(V,X){if((typeof X>"u"||X===null)&&(X={}),typeof V!="string")throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");if(Re(L,V))throw new Error('Cannot create unit "'+V+'": a unit with that name already exists');$e(V);var oe=null,G=[],Y=0,te,ye,me;if(X&&X.type==="Unit")oe=X.clone();else if(typeof X=="string")X!==""&&(te=X);else if(typeof X=="object")te=X.definition,ye=X.prefixes,Y=X.offset,me=X.baseName,X.aliases&&(G=X.aliases.valueOf());else throw new TypeError('Cannot create unit "'+V+'" from "'+X.toString()+'": expecting "string" or "Unit" or "Object"');if(G){for(var z=0;z<G.length;z++)if(Re(L,G[z]))throw new Error('Cannot create alias "'+G[z]+'": a unit with that name already exists')}if(te&&typeof te=="string"&&!oe)try{oe=d.parse(te,{allowNoUnits:!0})}catch(mr){throw mr.message='Could not create unit "'+V+'" from "'+te+'": '+mr.message,mr}else te&&te.type==="Unit"&&(oe=te.clone());G=G||[],Y=Y||0,ye&&ye.toUpperCase?ye=F[ye.toUpperCase()]||F.NONE:ye=F.NONE;var U={};if(oe){U={name:V,value:oe.value,dimensions:oe.dimensions.slice(0),prefixes:ye,offset:Y};var de=!1;for(var be in $)if(Re($,be)){for(var pe=!0,we=0;we<H.length;we++)if(Math.abs((U.dimensions[we]||0)-($[be].dimensions[we]||0))>1e-12){pe=!1;break}if(pe){de=!0,U.base=$[be];break}}if(!de){me=me||V+"_STUFF";var _e={dimensions:oe.dimensions.slice(0)};_e.key=me,$[me]=_e,fe[me]={unit:U,prefix:F.NONE[""]},U.base=$[me]}}else{if(me=me||V+"_STUFF",H.indexOf(me)>=0)throw new Error('Cannot create new base unit "'+V+'": a base unit with that name already exists (and cannot be overridden)');H.push(me);for(var ee in $)Re($,ee)&&($[ee].dimensions[H.length-1]=0);for(var ue={dimensions:[]},ve=0;ve<H.length;ve++)ue.dimensions[ve]=0;ue.dimensions[H.length-1]=1,ue.key=me,$[me]=ue,U={name:V,value:1,dimensions:$[me].dimensions.slice(0),prefixes:ye,offset:Y,base:$[me]},fe[me]={unit:U,prefix:F.NONE[""]}}d.UNITS[V]=U;for(var Le=0;Le<G.length;Le++){var Be=G[Le],ar={};for(var Je in U)Re(U,Je)&&(ar[Je]=U[Je]);ar.name=Be,d.UNITS[Be]=ar}return delete R.cache,new d(null,V)},d.deleteUnit=function(V){delete d.UNITS[V]},d.PREFIXES=F,d.BASE_DIMENSIONS=H,d.BASE_UNITS=$,d.UNIT_SYSTEMS=re,d.UNITS=L,d},{isClass:!0}),vv="unit",SD=["typed","Unit"],CD=q(vv,SD,r=>{var{typed:e,Unit:t}=r;return e(vv,{Unit:function(n){return n.clone()},string:function(n){return t.isValuelessUnit(n)?new t(null,n):t.parse(n,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string | Unit":function(n,i){return new t(n,i)},"number | BigNumber | Fraction":function(n){return new t(n)},"Array | Matrix":e.referToSelf(a=>n=>je(n,a))})}),pv="sparse",MD=["typed","SparseMatrix"],FD=q(pv,MD,r=>{var{typed:e,SparseMatrix:t}=r;return e(pv,{"":function(){return new t([])},string:function(n){return new t([],n)},"Array | Matrix":function(n){return new t(n)},"Array | Matrix, string":function(n,i){return new t(n,i)}})}),hv="createUnit",TD=["typed","Unit"],BD=q(hv,TD,r=>{var{typed:e,Unit:t}=r;return e(hv,{"Object, Object":function(n,i){return t.createUnit(n,i)},Object:function(n){return t.createUnit(n,{})},"string, Unit | string | Object, Object":function(n,i,o){var f={};return f[n]=i,t.createUnit(f,o)},"string, Unit | string | Object":function(n,i){var o={};return o[n]=i,t.createUnit(o,{})},string:function(n){var i={};return i[n]={},t.createUnit(i,{})}})}),dv="acos",$D=["typed","config","Complex"],OD=q(dv,$D,r=>{var{typed:e,config:t,Complex:a}=r;return e(dv,{number:function(i){return i>=-1&&i<=1||t.predictable?Math.acos(i):new a(i,0).acos()},Complex:function(i){return i.acos()},BigNumber:function(i){return i.acos()}})}),gv="acosh",ID=["typed","config","Complex"],RD=q(gv,ID,r=>{var{typed:e,config:t,Complex:a}=r;return e(gv,{number:function(i){return i>=1||t.predictable?Bc(i):i<=-1?new a(Math.log(Math.sqrt(i*i-1)-i),Math.PI):new a(i,0).acosh()},Complex:function(i){return i.acosh()},BigNumber:function(i){return i.acosh()}})}),yv="acot",_D=["typed","BigNumber"],qD=q(yv,_D,r=>{var{typed:e,BigNumber:t}=r;return e(yv,{number:$c,Complex:function(n){return n.acot()},BigNumber:function(n){return new t(1).div(n).atan()}})}),bv="acoth",zD=["typed","config","Complex","BigNumber"],PD=q(bv,zD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(bv,{number:function(o){return o>=1||o<=-1||t.predictable?Oc(o):new a(o,0).acoth()},Complex:function(o){return o.acoth()},BigNumber:function(o){return new n(1).div(o).atanh()}})}),xv="acsc",UD=["typed","config","Complex","BigNumber"],LD=q(xv,UD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(xv,{number:function(o){return o<=-1||o>=1||t.predictable?Ic(o):new a(o,0).acsc()},Complex:function(o){return o.acsc()},BigNumber:function(o){return new n(1).div(o).asin()}})}),wv="acsch",kD=["typed","BigNumber"],VD=q(wv,kD,r=>{var{typed:e,BigNumber:t}=r;return e(wv,{number:Rc,Complex:function(n){return n.acsch()},BigNumber:function(n){return new t(1).div(n).asinh()}})}),Nv="asec",GD=["typed","config","Complex","BigNumber"],HD=q(Nv,GD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(Nv,{number:function(o){return o<=-1||o>=1||t.predictable?_c(o):new a(o,0).asec()},Complex:function(o){return o.asec()},BigNumber:function(o){return new n(1).div(o).acos()}})}),Dv="asech",ZD=["typed","config","Complex","BigNumber"],JD=q(Dv,ZD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(Dv,{number:function(o){if(o<=1&&o>=-1||t.predictable){var f=1/o;if(f>0||t.predictable)return qc(o);var l=Math.sqrt(f*f-1);return new a(Math.log(l-f),Math.PI)}return new a(o,0).asech()},Complex:function(o){return o.asech()},BigNumber:function(o){return new n(1).div(o).acosh()}})}),Av="asin",XD=["typed","config","Complex"],WD=q(Av,XD,r=>{var{typed:e,config:t,Complex:a}=r;return e(Av,{number:function(i){return i>=-1&&i<=1||t.predictable?Math.asin(i):new a(i,0).asin()},Complex:function(i){return i.asin()},BigNumber:function(i){return i.asin()}})}),YD="asinh",QD=["typed"],KD=q(YD,QD,r=>{var{typed:e}=r;return e("asinh",{number:zc,Complex:function(a){return a.asinh()},BigNumber:function(a){return a.asinh()}})}),jD="atan",eA=["typed"],rA=q(jD,eA,r=>{var{typed:e}=r;return e("atan",{number:function(a){return Math.atan(a)},Complex:function(a){return a.atan()},BigNumber:function(a){return a.atan()}})}),Ev="atan2",tA=["typed","matrix","equalScalar","BigNumber","DenseMatrix","concat"],nA=q(Ev,tA,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n,DenseMatrix:i,concat:o}=r,f=wt({typed:e,equalScalar:a}),l=Yr({typed:e}),u=Rf({typed:e,equalScalar:a}),s=Lr({typed:e,equalScalar:a}),c=Ir({typed:e,DenseMatrix:i}),m=dr({typed:e,matrix:t,concat:o});return e(Ev,{"number, number":Math.atan2,"BigNumber, BigNumber":(v,h)=>n.atan2(v,h)},m({scalar:"number | BigNumber",SS:u,DS:l,SD:f,Ss:s,sS:c}))}),Sv="atanh",aA=["typed","config","Complex"],iA=q(Sv,aA,r=>{var{typed:e,config:t,Complex:a}=r;return e(Sv,{number:function(i){return i<=1&&i>=-1||t.predictable?Pc(i):new a(i,0).atanh()},Complex:function(i){return i.atanh()},BigNumber:function(i){return i.atanh()}})}),fa=q("trigUnit",["typed"],r=>{var{typed:e}=r;return{Unit:e.referToSelf(t=>a=>{if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return e.find(t,a.valueType())(a.value)})}}),Cv="cos",oA=["typed"],sA=q(Cv,oA,r=>{var{typed:e}=r,t=fa({typed:e});return e(Cv,{number:Math.cos,"Complex | BigNumber":a=>a.cos()},t)}),Mv="cosh",uA=["typed"],lA=q(Mv,uA,r=>{var{typed:e}=r;return e(Mv,{number:fg,"Complex | BigNumber":t=>t.cosh()})}),Fv="cot",cA=["typed","BigNumber"],fA=q(Fv,cA,r=>{var{typed:e,BigNumber:t}=r,a=fa({typed:e});return e(Fv,{number:Uc,Complex:n=>n.cot(),BigNumber:n=>new t(1).div(n.tan())},a)}),Tv="coth",mA=["typed","BigNumber"],vA=q(Tv,mA,r=>{var{typed:e,BigNumber:t}=r;return e(Tv,{number:Lc,Complex:a=>a.coth(),BigNumber:a=>new t(1).div(a.tanh())})}),Bv="csc",pA=["typed","BigNumber"],hA=q(Bv,pA,r=>{var{typed:e,BigNumber:t}=r,a=fa({typed:e});return e(Bv,{number:kc,Complex:n=>n.csc(),BigNumber:n=>new t(1).div(n.sin())},a)}),$v="csch",dA=["typed","BigNumber"],gA=q($v,dA,r=>{var{typed:e,BigNumber:t}=r;return e($v,{number:Vc,Complex:a=>a.csch(),BigNumber:a=>new t(1).div(a.sinh())})}),Ov="sec",yA=["typed","BigNumber"],bA=q(Ov,yA,r=>{var{typed:e,BigNumber:t}=r,a=fa({typed:e});return e(Ov,{number:Gc,Complex:n=>n.sec(),BigNumber:n=>new t(1).div(n.cos())},a)}),Iv="sech",xA=["typed","BigNumber"],wA=q(Iv,xA,r=>{var{typed:e,BigNumber:t}=r;return e(Iv,{number:Hc,Complex:a=>a.sech(),BigNumber:a=>new t(1).div(a.cosh())})}),Rv="sin",NA=["typed"],DA=q(Rv,NA,r=>{var{typed:e}=r,t=fa({typed:e});return e(Rv,{number:Math.sin,"Complex | BigNumber":a=>a.sin()},t)}),_v="sinh",AA=["typed"],EA=q(_v,AA,r=>{var{typed:e}=r;return e(_v,{number:Zc,"Complex | BigNumber":t=>t.sinh()})}),qv="tan",SA=["typed"],CA=q(qv,SA,r=>{var{typed:e}=r,t=fa({typed:e});return e(qv,{number:Math.tan,"Complex | BigNumber":a=>a.tan()},t)}),MA="tanh",FA=["typed"],TA=q(MA,FA,r=>{var{typed:e}=r;return e("tanh",{number:vg,"Complex | BigNumber":t=>t.tanh()})}),zv="setCartesian",BA=["typed","size","subset","compareNatural","Index","DenseMatrix"],$A=q(zv,BA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:o}=r;return e(zv,{"Array | Matrix, Array | Matrix":function(l,u){var s=[];if(a(t(l),new i(0))!==0&&a(t(u),new i(0))!==0){var c=or(Array.isArray(l)?l:l.toArray()).sort(n),m=or(Array.isArray(u)?u:u.toArray()).sort(n);s=[];for(var v=0;v<c.length;v++)for(var h=0;h<m.length;h++)s.push([c[v],m[h]])}return Array.isArray(l)&&Array.isArray(u)?s:new o(s)}})}),Pv="setDifference",OA=["typed","size","subset","compareNatural","Index","DenseMatrix"],IA=q(Pv,OA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:o}=r;return e(Pv,{"Array | Matrix, Array | Matrix":function(l,u){var s;if(a(t(l),new i(0))===0)s=[];else{if(a(t(u),new i(0))===0)return or(l.toArray());var c=Kn(or(Array.isArray(l)?l:l.toArray()).sort(n)),m=Kn(or(Array.isArray(u)?u:u.toArray()).sort(n));s=[];for(var v,h=0;h<c.length;h++){v=!1;for(var p=0;p<m.length;p++)if(n(c[h].value,m[p].value)===0&&c[h].identifier===m[p].identifier){v=!0;break}v||s.push(c[h])}}return Array.isArray(l)&&Array.isArray(u)?gi(s):new o(gi(s))}})}),Uv="setDistinct",RA=["typed","size","subset","compareNatural","Index","DenseMatrix"],_A=q(Uv,RA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:o}=r;return e(Uv,{"Array | Matrix":function(l){var u;if(a(t(l),new i(0))===0)u=[];else{var s=or(Array.isArray(l)?l:l.toArray()).sort(n);u=[],u.push(s[0]);for(var c=1;c<s.length;c++)n(s[c],s[c-1])!==0&&u.push(s[c])}return Array.isArray(l)?u:new o(u)}})}),Lv="setIntersect",qA=["typed","size","subset","compareNatural","Index","DenseMatrix"],zA=q(Lv,qA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:o}=r;return e(Lv,{"Array | Matrix, Array | Matrix":function(l,u){var s;if(a(t(l),new i(0))===0||a(t(u),new i(0))===0)s=[];else{var c=Kn(or(Array.isArray(l)?l:l.toArray()).sort(n)),m=Kn(or(Array.isArray(u)?u:u.toArray()).sort(n));s=[];for(var v=0;v<c.length;v++)for(var h=0;h<m.length;h++)if(n(c[v].value,m[h].value)===0&&c[v].identifier===m[h].identifier){s.push(c[v]);break}}return Array.isArray(l)&&Array.isArray(u)?gi(s):new o(gi(s))}})}),kv="setIsSubset",PA=["typed","size","subset","compareNatural","Index"],UA=q(kv,PA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(kv,{"Array | Matrix, Array | Matrix":function(f,l){if(a(t(f),new i(0))===0)return!0;if(a(t(l),new i(0))===0)return!1;for(var u=Kn(or(Array.isArray(f)?f:f.toArray()).sort(n)),s=Kn(or(Array.isArray(l)?l:l.toArray()).sort(n)),c,m=0;m<u.length;m++){c=!1;for(var v=0;v<s.length;v++)if(n(u[m].value,s[v].value)===0&&u[m].identifier===s[v].identifier){c=!0;break}if(c===!1)return!1}return!0}})}),Vv="setMultiplicity",LA=["typed","size","subset","compareNatural","Index"],kA=q(Vv,LA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(Vv,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(f,l){if(a(t(l),new i(0))===0)return 0;for(var u=or(Array.isArray(l)?l:l.toArray()),s=0,c=0;c<u.length;c++)n(u[c],f)===0&&s++;return s}})}),Gv="setPowerset",VA=["typed","size","subset","compareNatural","Index"],GA=q(Gv,VA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(Gv,{"Array | Matrix":function(u){if(a(t(u),new i(0))===0)return[];for(var s=or(Array.isArray(u)?u:u.toArray()).sort(n),c=[],m=0;m.toString(2).length<=s.length;)c.push(o(s,m.toString(2).split("").reverse())),m++;return f(c)}});function o(l,u){for(var s=[],c=0;c<u.length;c++)u[c]==="1"&&s.push(l[c]);return s}function f(l){for(var u=[],s=l.length-1;s>0;s--)for(var c=0;c<s;c++)l[c].length>l[c+1].length&&(u=l[c],l[c]=l[c+1],l[c+1]=u);return l}}),Hv="setSize",HA=["typed","compareNatural"],ZA=q(Hv,HA,r=>{var{typed:e,compareNatural:t}=r;return e(Hv,{"Array | Matrix":function(n){return Array.isArray(n)?or(n).length:or(n.toArray()).length},"Array | Matrix, boolean":function(n,i){if(i===!1||n.length===0)return Array.isArray(n)?or(n).length:or(n.toArray()).length;for(var o=or(Array.isArray(n)?n:n.toArray()).sort(t),f=1,l=1;l<o.length;l++)t(o[l],o[l-1])!==0&&f++;return f}})}),Zv="setSymDifference",JA=["typed","size","concat","subset","setDifference","Index"],XA=q(Zv,JA,r=>{var{typed:e,size:t,concat:a,subset:n,setDifference:i,Index:o}=r;return e(Zv,{"Array | Matrix, Array | Matrix":function(l,u){if(n(t(l),new o(0))===0)return or(u);if(n(t(u),new o(0))===0)return or(l);var s=or(l),c=or(u);return a(i(s,c),i(c,s))}})}),Jv="setUnion",WA=["typed","size","concat","subset","setIntersect","setSymDifference","Index"],YA=q(Jv,WA,r=>{var{typed:e,size:t,concat:a,subset:n,setIntersect:i,setSymDifference:o,Index:f}=r;return e(Jv,{"Array | Matrix, Array | Matrix":function(u,s){if(n(t(u),new f(0))===0)return or(s);if(n(t(s),new f(0))===0)return or(u);var c=or(u),m=or(s);return a(o(c,m),i(c,m))}})}),Xv="add",QA=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],KA=q(Xv,QA,r=>{var{typed:e,matrix:t,addScalar:a,equalScalar:n,DenseMatrix:i,SparseMatrix:o,concat:f}=r,l=mn({typed:e}),u=fs({typed:e,equalScalar:n}),s=Tn({typed:e,DenseMatrix:i}),c=dr({typed:e,matrix:t,concat:f});return e(Xv,{"any, any":a,"any, any, ...any":e.referToSelf(m=>(v,h,p)=>{for(var g=m(v,h),y=0;y<p.length;y++)g=m(g,p[y]);return g})},c({elop:a,DS:l,SS:u,Ss:s}))}),Wv="hypot",jA=["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],eE=q(Wv,jA,r=>{var{typed:e,abs:t,addScalar:a,divideScalar:n,multiplyScalar:i,sqrt:o,smaller:f,isPositive:l}=r;return e(Wv,{"... number | BigNumber":u,Array:u,Matrix:s=>u(or(s.toArray()))});function u(s){for(var c=0,m=0,v=0;v<s.length;v++){if(kt(s[v]))throw new TypeError("Unexpected type of argument to hypot");var h=t(s[v]);f(m,h)?(c=i(c,i(n(m,h),n(m,h))),c=a(c,1),m=h):c=a(c,l(h)?i(n(h,m),n(h,m)):h)}return i(m,o(c))}}),Yv="norm",rE=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],tE=q(Yv,rE,r=>{var{typed:e,abs:t,add:a,pow:n,conj:i,sqrt:o,multiply:f,equalScalar:l,larger:u,smaller:s,matrix:c,ctranspose:m,eigs:v}=r;return e(Yv,{number:Math.abs,Complex:function(A){return A.abs()},BigNumber:function(A){return A.abs()},boolean:function(A){return Math.abs(A)},Array:function(A){return b(c(A),2)},Matrix:function(A){return b(A,2)},"Array, number | BigNumber | string":function(A,S){return b(c(A),S)},"Matrix, number | BigNumber | string":function(A,S){return b(A,S)}});function h(E){var A=0;return E.forEach(function(S){var D=t(S);u(D,A)&&(A=D)},!0),A}function p(E){var A;return E.forEach(function(S){var D=t(S);(!A||s(D,A))&&(A=D)},!0),A||0}function g(E,A){if(A===Number.POSITIVE_INFINITY||A==="inf")return h(E);if(A===Number.NEGATIVE_INFINITY||A==="-inf")return p(E);if(A==="fro")return b(E,2);if(typeof A=="number"&&!isNaN(A)){if(!l(A,0)){var S=0;return E.forEach(function(D){S=a(n(t(D),A),S)},!0),n(S,1/A)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}function y(E){var A=0;return E.forEach(function(S,D){A=a(A,f(S,i(S)))}),t(o(A))}function N(E){var A=[],S=0;return E.forEach(function(D,T){var B=T[1],I=a(A[B]||0,t(D));u(I,S)&&(S=I),A[B]=I},!0),S}function d(E){var A=E.size();if(A[0]!==A[1])throw new RangeError("Invalid matrix dimensions");var S=m(E),D=f(S,E),T=v(D).values.toArray(),B=T[T.length-1];return t(o(B))}function w(E){var A=[],S=0;return E.forEach(function(D,T){var B=T[0],I=a(A[B]||0,t(D));u(I,S)&&(S=I),A[B]=I},!0),S}function x(E,A){if(A===1)return N(E);if(A===Number.POSITIVE_INFINITY||A==="inf")return w(E);if(A==="fro")return y(E);if(A===2)return d(E);throw new Error("Unsupported parameter value "+A)}function b(E,A){var S=E.size();if(S.length===1)return g(E,A);if(S.length===2){if(S[0]&&S[1])return x(E,A);throw new RangeError("Invalid matrix dimensions")}}}),Qv="dot",nE=["typed","addScalar","multiplyScalar","conj","size"],aE=q(Qv,nE,r=>{var{typed:e,addScalar:t,multiplyScalar:a,conj:n,size:i}=r;return e(Qv,{"Array | DenseMatrix, Array | DenseMatrix":f,"SparseMatrix, SparseMatrix":l});function o(s,c){var m=u(s),v=u(c),h,p;if(m.length===1)h=m[0];else if(m.length===2&&m[1]===1)h=m[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+m.join(", ")+")");if(v.length===1)p=v[0];else if(v.length===2&&v[1]===1)p=v[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+v.join(", ")+")");if(h!==p)throw new RangeError("Vectors must have equal length ("+h+" != "+p+")");if(h===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return h}function f(s,c){var m=o(s,c),v=Ve(s)?s._data:s,h=Ve(s)?s._datatype:void 0,p=Ve(c)?c._data:c,g=Ve(c)?c._datatype:void 0,y=u(s).length===2,N=u(c).length===2,d=t,w=a;if(h&&g&&h===g&&typeof h=="string"){var x=h;d=e.find(t,[x,x]),w=e.find(a,[x,x])}if(!y&&!N){for(var b=w(n(v[0]),p[0]),E=1;E<m;E++)b=d(b,w(n(v[E]),p[E]));return b}if(!y&&N){for(var A=w(n(v[0]),p[0][0]),S=1;S<m;S++)A=d(A,w(n(v[S]),p[S][0]));return A}if(y&&!N){for(var D=w(n(v[0][0]),p[0]),T=1;T<m;T++)D=d(D,w(n(v[T][0]),p[T]));return D}if(y&&N){for(var B=w(n(v[0][0]),p[0][0]),I=1;I<m;I++)B=d(B,w(n(v[I][0]),p[I][0]));return B}}function l(s,c){o(s,c);for(var m=s._index,v=s._values,h=c._index,p=c._values,g=0,y=t,N=a,d=0,w=0;d<m.length&&w<h.length;){var x=m[d],b=h[w];if(x<b){d++;continue}if(x>b){w++;continue}x===b&&(g=y(g,N(v[d],p[w])),d++,w++)}return g}function u(s){return Ve(s)?s.size():i(s)}}),iE="trace",oE=["typed","matrix","add"],sE=q(iE,oE,r=>{var{typed:e,matrix:t,add:a}=r;return e("trace",{Array:function(f){return n(t(f))},SparseMatrix:i,DenseMatrix:n,any:Ge});function n(o){var f=o._size,l=o._data;switch(f.length){case 1:if(f[0]===1)return Ge(l[0]);throw new RangeError("Matrix must be square (size: "+Ye(f)+")");case 2:{var u=f[0],s=f[1];if(u===s){for(var c=0,m=0;m<u;m++)c=a(c,l[m][m]);return c}else throw new RangeError("Matrix must be square (size: "+Ye(f)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Ye(f)+")")}}function i(o){var f=o._values,l=o._index,u=o._ptr,s=o._size,c=s[0],m=s[1];if(c===m){var v=0;if(f.length>0)for(var h=0;h<m;h++)for(var p=u[h],g=u[h+1],y=p;y<g;y++){var N=l[y];if(N===h){v=a(v,f[y]);break}if(N>h)break}return v}throw new RangeError("Matrix must be square (size: "+Ye(s)+")")}}),Kv="index",uE=["typed","Index"],lE=q(Kv,uE,r=>{var{typed:e,Index:t}=r;return e(Kv,{"...number | string | BigNumber | Range | Array | Matrix":function(n){var i=n.map(function(f){return rr(f)?f.toNumber():Array.isArray(f)||Ve(f)?f.map(function(l){return rr(l)?l.toNumber():l}):f}),o=new t;return t.apply(o,i),o}})}),jv=new Set(["end"]),cE="Node",fE=["mathWithTransform"],mE=q(cE,fE,r=>{var{mathWithTransform:e}=r;function t(n){for(var i of[...jv])if(n.has(i))throw new Error('Scope contains an illegal symbol, "'+i+'" is a reserved keyword')}class a{get type(){return"Node"}get isNode(){return!0}evaluate(i){return this.compile().evaluate(i)}compile(){var i=this._compile(e,{}),o={},f=null;function l(u){var s=ra(u);return t(s),i(s,o,f)}return{evaluate:l}}_compile(i,o){throw new Error("Method _compile must be implemented by type "+this.type)}forEach(i){throw new Error("Cannot run forEach on a Node interface")}map(i){throw new Error("Cannot run map on a Node interface")}_ifNode(i){if(!fr(i))throw new TypeError("Callback function must return a Node");return i}traverse(i){i(this,null,null);function o(f,l){f.forEach(function(u,s,c){l(u,s,c),o(u,l)})}o(this,i)}transform(i){function o(f,l,u){var s=i(f,l,u);return s!==f?s:f.map(o)}return o(this,null,null)}filter(i){var o=[];return this.traverse(function(f,l,u){i(f,l,u)&&o.push(f)}),o}clone(){throw new Error("Cannot clone a Node interface")}cloneDeep(){return this.map(function(i){return i.cloneDeep()})}equals(i){return i?this.type===i.type&&Ua(this,i):!1}toString(i){var o=this._getCustomString(i);return typeof o<"u"?o:this._toString(i)}toJSON(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)}toHTML(i){var o=this._getCustomString(i);return typeof o<"u"?o:this.toHTML(i)}_toString(){throw new Error("_toString not implemented for "+this.type)}toTex(i){var o=this._getCustomString(i);return typeof o<"u"?o:this._toTex(i)}_toTex(i){throw new Error("_toTex not implemented for "+this.type)}_getCustomString(i){if(i&&typeof i=="object")switch(typeof i.handler){case"object":case"undefined":return;case"function":return i.handler(this,i);default:throw new TypeError("Object or function expected as callback")}}getIdentifier(){return this.type}getContent(){return this}}return a},{isClass:!0,isNode:!0});function Kr(r){return r&&r.isIndexError?new dt(r.index+1,r.min+1,r.max!==void 0?r.max+1:void 0):r}function ep(r){var{subset:e}=r;return function(a,n){try{if(Array.isArray(a))return e(a,n);if(a&&typeof a.subset=="function")return a.subset(n);if(typeof a=="string")return e(a,n);if(typeof a=="object"){if(!n.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return lt(a,n.getObjectProperty())}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(i){throw Kr(i)}}}var Gi="AccessorNode",vE=["subset","Node"],pE=q(Gi,vE,r=>{var{subset:e,Node:t}=r,a=ep({subset:e});function n(o){return!(Sn(o)||ot(o)||ir(o)||nn(o)||ci(o)||Gt(o)||qr(o))}class i extends t{constructor(f,l){if(super(),!fr(f))throw new TypeError('Node expected for parameter "object"');if(!Jn(l))throw new TypeError('IndexNode expected for parameter "index"');this.object=f,this.index=l}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return Gi}get isAccessorNode(){return!0}_compile(f,l){var u=this.object._compile(f,l),s=this.index._compile(f,l);if(this.index.isObjectProperty()){var c=this.index.getObjectProperty();return function(v,h,p){return lt(u(v,h,p),c)}}else return function(v,h,p){var g=u(v,h,p),y=s(v,h,g);return a(g,y)}}forEach(f){f(this.object,"object",this),f(this.index,"index",this)}map(f){return new i(this._ifNode(f(this.object,"object",this)),this._ifNode(f(this.index,"index",this)))}clone(){return new i(this.object,this.index)}_toString(f){var l=this.object.toString(f);return n(this.object)&&(l="("+l+")"),l+this.index.toString(f)}toHTML(f){var l=this.object.toHTML(f);return n(this.object)&&(l='<span class="math-parenthesis math-round-parenthesis">(</span>'+l+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+this.index.toHTML(f)}_toTex(f){var l=this.object.toTex(f);return n(this.object)&&(l="\\left(' + object + '\\right)"),l+this.index.toTex(f)}toJSON(){return{mathjs:Gi,object:this.object,index:this.index}}static fromJSON(f){return new i(f.object,f.index)}}return zr(i,"name",Gi),i},{isClass:!0,isNode:!0}),Hi="ArrayNode",hE=["Node"],dE=q(Hi,hE,r=>{var{Node:e}=r;class t extends e{constructor(n){if(super(),this.items=n||[],!Array.isArray(this.items)||!this.items.every(fr))throw new TypeError("Array containing Nodes expected")}get type(){return Hi}get isArrayNode(){return!0}_compile(n,i){var o=Ht(this.items,function(u){return u._compile(n,i)}),f=n.config.matrix!=="Array";if(f){var l=n.matrix;return function(s,c,m){return l(Ht(o,function(v){return v(s,c,m)}))}}else return function(s,c,m){return Ht(o,function(v){return v(s,c,m)})}}forEach(n){for(var i=0;i<this.items.length;i++){var o=this.items[i];n(o,"items["+i+"]",this)}}map(n){for(var i=[],o=0;o<this.items.length;o++)i[o]=this._ifNode(n(this.items[o],"items["+o+"]",this));return new t(i)}clone(){return new t(this.items.slice(0))}_toString(n){var i=this.items.map(function(o){return o.toString(n)});return"["+i.join(", ")+"]"}toJSON(){return{mathjs:Hi,items:this.items}}static fromJSON(n){return new t(n.items)}toHTML(n){var i=this.items.map(function(o){return o.toHTML(n)});return'<span class="math-parenthesis math-square-parenthesis">[</span>'+i.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(n){function i(o,f){var l=o.some(ot)&&!o.every(ot),u=f||l,s=u?"&":"\\\\",c=o.map(function(m){return m.items?i(m.items,!f):m.toTex(n)}).join(s);return l||!u||u&&!f?"\\begin{bmatrix}"+c+"\\end{bmatrix}":c}return i(this.items,!1)}}return zr(t,"name",Hi),t},{isClass:!0,isNode:!0});function gE(r){var{subset:e,matrix:t}=r;return function(n,i,o){try{if(Array.isArray(n))return t(n).subset(i,o).valueOf();if(n&&typeof n.subset=="function")return n.subset(i,o);if(typeof n=="string")return e(n,i,o);if(typeof n=="object"){if(!i.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return jn(n,i.getObjectProperty(),o),n}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(f){throw Kr(f)}}}var Nt=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{op:"or",associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{op:"xor",associativity:"left",associativeWith:[]}},{"OperatorNode:and":{op:"and",associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{op:"|",associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{op:"^|",associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{op:"&",associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{op:"==",associativity:"left",associativeWith:[]},"OperatorNode:unequal":{op:"!=",associativity:"left",associativeWith:[]},"OperatorNode:smaller":{op:"<",associativity:"left",associativeWith:[]},"OperatorNode:larger":{op:">",associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{op:"<=",associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{op:">=",associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{op:"<<",associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{op:">>",associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{op:">>>",associativity:"left",associativeWith:[]}},{"OperatorNode:to":{op:"to",associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{op:"+",associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{op:"-",associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{op:"*",associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{op:"/",associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{op:".*",associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{op:"./",associativity:"left",associativeWith:[]},"OperatorNode:mod":{op:"mod",associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]}},{"OperatorNode:unaryPlus":{op:"+",associativity:"right"},"OperatorNode:unaryMinus":{op:"-",associativity:"right"},"OperatorNode:bitNot":{op:"~",associativity:"right"},"OperatorNode:not":{op:"not",associativity:"right"}},{"OperatorNode:pow":{op:"^",associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{op:".^",associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{op:"!",associativity:"left"}},{"OperatorNode:ctranspose":{op:"'",associativity:"left"}}];function Zi(r,e){if(!e||e!=="auto")return r;for(var t=r;Gt(t);)t=t.content;return t}function pr(r,e,t,a){var n=r;e!=="keep"&&(n=r.getContent());for(var i=n.getIdentifier(),o=null,f=0;f<Nt.length;f++)if(i in Nt[f]){o=f;break}if(i==="OperatorNode:multiply"&&n.implicit&&t!=="show"){var l=Zi(n.args[0],e);!(ir(l)&&a&&a.getIdentifier()==="OperatorNode:divide"&&ko(Zi(a.args[0],e)))&&!(l.getIdentifier()==="OperatorNode:divide"&&ko(Zi(l.args[0],e))&&ir(Zi(l.args[1])))&&(o+=1)}return o}function Xa(r,e){var t=r;e!=="keep"&&(t=r.getContent());var a=t.getIdentifier(),n=pr(t,e);if(n===null)return null;var i=Nt[n][a];if(Re(i,"associativity")){if(i.associativity==="left")return"left";if(i.associativity==="right")return"right";throw Error("'"+a+"' has the invalid associativity '"+i.associativity+"'.")}return null}function bs(r,e,t){var a=t!=="keep"?r.getContent():r,n=t!=="keep"?r.getContent():e,i=a.getIdentifier(),o=n.getIdentifier(),f=pr(a,t);if(f===null)return null;var l=Nt[f][i];if(Re(l,"associativeWith")&&l.associativeWith instanceof Array){for(var u=0;u<l.associativeWith.length;u++)if(l.associativeWith[u]===o)return!0;return!1}return null}function yE(r){var e="OperatorNode:"+r;for(var t of Nt)if(e in t)return t[e].op;return null}var Ji="AssignmentNode",bE=["subset","?matrix","Node"],xE=q(Ji,bE,r=>{var{subset:e,matrix:t,Node:a}=r,n=ep({subset:e}),i=gE({subset:e,matrix:t});function o(l,u,s){u||(u="keep");var c=pr(l,u,s),m=pr(l.value,u,s);return u==="all"||m!==null&&m<=c}class f extends a{constructor(u,s,c){if(super(),this.object=u,this.index=c?s:null,this.value=c||s,!qr(u)&&!Sn(u))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(qr(u)&&u.name==="end")throw new Error('Cannot assign to symbol "end"');if(this.index&&!Jn(this.index))throw new TypeError('IndexNode expected as "index"');if(!fr(this.value))throw new TypeError('Node expected as "value"')}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return Ji}get isAssignmentNode(){return!0}_compile(u,s){var c=this.object._compile(u,s),m=this.index?this.index._compile(u,s):null,v=this.value._compile(u,s),h=this.object.name;if(this.index)if(this.index.isObjectProperty()){var p=this.index.getObjectProperty();return function(w,x,b){var E=c(w,x,b),A=v(w,x,b);return jn(E,p,A),A}}else{if(qr(this.object))return function(w,x,b){var E=c(w,x,b),A=v(w,x,b),S=m(w,x,E);return w.set(h,i(E,S,A)),A};var g=this.object.object._compile(u,s);if(this.object.index.isObjectProperty()){var y=this.object.index.getObjectProperty();return function(w,x,b){var E=g(w,x,b),A=lt(E,y),S=m(w,x,A),D=v(w,x,b);return jn(E,y,i(A,S,D)),D}}else{var N=this.object.index._compile(u,s);return function(w,x,b){var E=g(w,x,b),A=N(w,x,E),S=n(E,A),D=m(w,x,S),T=v(w,x,b);return i(E,A,i(S,D,T)),T}}}else{if(!qr(this.object))throw new TypeError("SymbolNode expected as object");return function(w,x,b){var E=v(w,x,b);return w.set(h,E),E}}}forEach(u){u(this.object,"object",this),this.index&&u(this.index,"index",this),u(this.value,"value",this)}map(u){var s=this._ifNode(u(this.object,"object",this)),c=this.index?this._ifNode(u(this.index,"index",this)):null,m=this._ifNode(u(this.value,"value",this));return new f(s,c,m)}clone(){return new f(this.object,this.index,this.value)}_toString(u){var s=this.object.toString(u),c=this.index?this.index.toString(u):"",m=this.value.toString(u);return o(this,u&&u.parenthesis,u&&u.implicit)&&(m="("+m+")"),s+c+" = "+m}toJSON(){return{mathjs:Ji,object:this.object,index:this.index,value:this.value}}static fromJSON(u){return new f(u.object,u.index,u.value)}toHTML(u){var s=this.object.toHTML(u),c=this.index?this.index.toHTML(u):"",m=this.value.toHTML(u);return o(this,u&&u.parenthesis,u&&u.implicit)&&(m='<span class="math-paranthesis math-round-parenthesis">(</span>'+m+'<span class="math-paranthesis math-round-parenthesis">)</span>'),s+c+'<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+m}_toTex(u){var s=this.object.toTex(u),c=this.index?this.index.toTex(u):"",m=this.value.toTex(u);return o(this,u&&u.parenthesis,u&&u.implicit)&&(m="\\left(".concat(m,"\\right)")),s+c+":="+m}}return zr(f,"name",Ji),f},{isClass:!0,isNode:!0}),Xi="BlockNode",wE=["ResultSet","Node"],NE=q(Xi,wE,r=>{var{ResultSet:e,Node:t}=r;class a extends t{constructor(i){if(super(),!Array.isArray(i))throw new Error("Array expected");this.blocks=i.map(function(o){var f=o&&o.node,l=o&&o.visible!==void 0?o.visible:!0;if(!fr(f))throw new TypeError('Property "node" must be a Node');if(typeof l!="boolean")throw new TypeError('Property "visible" must be a boolean');return{node:f,visible:l}})}get type(){return Xi}get isBlockNode(){return!0}_compile(i,o){var f=Ht(this.blocks,function(l){return{evaluate:l.node._compile(i,o),visible:l.visible}});return function(u,s,c){var m=[];return hi(f,function(h){var p=h.evaluate(u,s,c);h.visible&&m.push(p)}),new e(m)}}forEach(i){for(var o=0;o<this.blocks.length;o++)i(this.blocks[o].node,"blocks["+o+"].node",this)}map(i){for(var o=[],f=0;f<this.blocks.length;f++){var l=this.blocks[f],u=this._ifNode(i(l.node,"blocks["+f+"].node",this));o[f]={node:u,visible:l.visible}}return new a(o)}clone(){var i=this.blocks.map(function(o){return{node:o.node,visible:o.visible}});return new a(i)}_toString(i){return this.blocks.map(function(o){return o.node.toString(i)+(o.visible?"":";")}).join(`
30
+ `)}toJSON(){return{mathjs:Xi,blocks:this.blocks}}static fromJSON(i){return new a(i.blocks)}toHTML(i){return this.blocks.map(function(o){return o.node.toHTML(i)+(o.visible?"":'<span class="math-separator">;</span>')}).join('<span class="math-separator"><br /></span>')}_toTex(i){return this.blocks.map(function(o){return o.node.toTex(i)+(o.visible?"":";")}).join(`\\;\\;
31
+ `)}}return zr(a,"name",Xi),a},{isClass:!0,isNode:!0}),Wi="ConditionalNode",DE=["Node"],AE=q(Wi,DE,r=>{var{Node:e}=r;function t(n){if(typeof n=="number"||typeof n=="boolean"||typeof n=="string")return!!n;if(n){if(rr(n))return!n.isZero();if(kt(n))return!!(n.re||n.im);if(Vt(n))return!!n.value}if(n==null)return!1;throw new TypeError('Unsupported type of condition "'+br(n)+'"')}class a extends e{constructor(i,o,f){if(super(),!fr(i))throw new TypeError("Parameter condition must be a Node");if(!fr(o))throw new TypeError("Parameter trueExpr must be a Node");if(!fr(f))throw new TypeError("Parameter falseExpr must be a Node");this.condition=i,this.trueExpr=o,this.falseExpr=f}get type(){return Wi}get isConditionalNode(){return!0}_compile(i,o){var f=this.condition._compile(i,o),l=this.trueExpr._compile(i,o),u=this.falseExpr._compile(i,o);return function(c,m,v){return t(f(c,m,v))?l(c,m,v):u(c,m,v)}}forEach(i){i(this.condition,"condition",this),i(this.trueExpr,"trueExpr",this),i(this.falseExpr,"falseExpr",this)}map(i){return new a(this._ifNode(i(this.condition,"condition",this)),this._ifNode(i(this.trueExpr,"trueExpr",this)),this._ifNode(i(this.falseExpr,"falseExpr",this)))}clone(){return new a(this.condition,this.trueExpr,this.falseExpr)}_toString(i){var o=i&&i.parenthesis?i.parenthesis:"keep",f=pr(this,o,i&&i.implicit),l=this.condition.toString(i),u=pr(this.condition,o,i&&i.implicit);(o==="all"||this.condition.type==="OperatorNode"||u!==null&&u<=f)&&(l="("+l+")");var s=this.trueExpr.toString(i),c=pr(this.trueExpr,o,i&&i.implicit);(o==="all"||this.trueExpr.type==="OperatorNode"||c!==null&&c<=f)&&(s="("+s+")");var m=this.falseExpr.toString(i),v=pr(this.falseExpr,o,i&&i.implicit);return(o==="all"||this.falseExpr.type==="OperatorNode"||v!==null&&v<=f)&&(m="("+m+")"),l+" ? "+s+" : "+m}toJSON(){return{mathjs:Wi,condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}}static fromJSON(i){return new a(i.condition,i.trueExpr,i.falseExpr)}toHTML(i){var o=i&&i.parenthesis?i.parenthesis:"keep",f=pr(this,o,i&&i.implicit),l=this.condition.toHTML(i),u=pr(this.condition,o,i&&i.implicit);(o==="all"||this.condition.type==="OperatorNode"||u!==null&&u<=f)&&(l='<span class="math-parenthesis math-round-parenthesis">(</span>'+l+'<span class="math-parenthesis math-round-parenthesis">)</span>');var s=this.trueExpr.toHTML(i),c=pr(this.trueExpr,o,i&&i.implicit);(o==="all"||this.trueExpr.type==="OperatorNode"||c!==null&&c<=f)&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>');var m=this.falseExpr.toHTML(i),v=pr(this.falseExpr,o,i&&i.implicit);return(o==="all"||this.falseExpr.type==="OperatorNode"||v!==null&&v<=f)&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+'<span class="math-operator math-conditional-operator">?</span>'+s+'<span class="math-operator math-conditional-operator">:</span>'+m}_toTex(i){return"\\begin{cases} {"+this.trueExpr.toTex(i)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(i)+"}\\\\{"+this.falseExpr.toTex(i)+"}, &\\quad{\\text{otherwise}}\\end{cases}"}}return zr(a,"name",Wi),a},{isClass:!0,isNode:!0}),xs=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=t[a])}return r},EE={"{":"\\{","}":"\\}","\\":"\\textbackslash{}","#":"\\#",$:"\\$","%":"\\%","&":"\\&","^":"\\textasciicircum{}",_:"\\_","~":"\\textasciitilde{}"},SE={"\u2013":"\\--","\u2014":"\\---"," ":"~"," ":"\\qquad{}","\r\n":"\\newline{}","\n":"\\newline{}"},CE=function(e,t){return xs({},e,t)},ME=function(r){for(var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.preserveFormatting,a=t===void 0?!1:t,n=e.escapeMapFn,i=n===void 0?CE:n,o=String(r),f="",l=i(xs({},EE),a?xs({},SE):{}),u=Object.keys(l),s=function(){var m=!1;u.forEach(function(v,h){m||o.length>=v.length&&o.slice(0,v.length)===v&&(f+=l[u[h]],o=o.slice(v.length,o.length),m=!0)}),m||(f+=o.slice(0,1),o=o.slice(1,o.length))};o;)s();return f};const FE=ME;var ws={Alpha:"A",alpha:"\\alpha",Beta:"B",beta:"\\beta",Gamma:"\\Gamma",gamma:"\\gamma",Delta:"\\Delta",delta:"\\delta",Epsilon:"E",epsilon:"\\epsilon",varepsilon:"\\varepsilon",Zeta:"Z",zeta:"\\zeta",Eta:"H",eta:"\\eta",Theta:"\\Theta",theta:"\\theta",vartheta:"\\vartheta",Iota:"I",iota:"\\iota",Kappa:"K",kappa:"\\kappa",varkappa:"\\varkappa",Lambda:"\\Lambda",lambda:"\\lambda",Mu:"M",mu:"\\mu",Nu:"N",nu:"\\nu",Xi:"\\Xi",xi:"\\xi",Omicron:"O",omicron:"o",Pi:"\\Pi",pi:"\\pi",varpi:"\\varpi",Rho:"P",rho:"\\rho",varrho:"\\varrho",Sigma:"\\Sigma",sigma:"\\sigma",varsigma:"\\varsigma",Tau:"T",tau:"\\tau",Upsilon:"\\Upsilon",upsilon:"\\upsilon",Phi:"\\Phi",phi:"\\phi",varphi:"\\varphi",Chi:"X",chi:"\\chi",Psi:"\\Psi",psi:"\\psi",Omega:"\\Omega",omega:"\\omega",true:"\\mathrm{True}",false:"\\mathrm{False}",i:"i",inf:"\\infty",Inf:"\\infty",infinity:"\\infty",Infinity:"\\infty",oo:"\\infty",lim:"\\lim",undefined:"\\mathbf{?}"},sr={transpose:"^\\top",ctranspose:"^H",factorial:"!",pow:"^",dotPow:".^\\wedge",unaryPlus:"+",unaryMinus:"-",bitNot:"\\~",not:"\\neg",multiply:"\\cdot",divide:"\\frac",dotMultiply:".\\cdot",dotDivide:".:",mod:"\\mod",add:"+",subtract:"-",to:"\\rightarrow",leftShift:"<<",rightArithShift:">>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},rp={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(sr.add,"${args[1]}\\right)")},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:"\\left(${args[0]}".concat(sr.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(sr.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(sr.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(sr.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:"\\left(${args[0]}".concat(sr.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(sr.multiply,"${args[1]}\\right)")},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : $y^{args[1]} = {${args[0]}}\\}"},pow:{2:"\\left(${args[0]}\\right)".concat(sr.pow,"{${args[1]}}")},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:"\\left(${args[0]}".concat(sr.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(sr.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(sr.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(sr.bitAnd,"${args[1]}\\right)")},bitNot:{1:sr.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(sr.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(sr.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(sr.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(sr.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(sr.rightLogShift,"${args[1]}\\right)")},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:"\\left(${args[0]}".concat(sr.and,"${args[1]}\\right)")},not:{1:sr.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(sr.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(sr.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(sr.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},pinv:{1:"\\left(${args[0]}\\right)^{+}"},sqrtm:{1:"{${args[0]}}".concat(sr.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(sr.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(sr.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(sr.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(sr.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(sr.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(sr.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(sr.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(sr.unequal,"${args[1]}\\right)")},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:"\\left(${args[0]}".concat(sr.to,"${args[1]}\\right)")},numeric:function(e,t){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(ws.i,"\\cdot\\left(${args[1]}\\right)\\right)")},matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},TE="\\mathrm{${name}}\\left(${args}\\right)",tp={deg:"^\\circ"};function Ns(r){return FE(r,{preserveFormatting:!0})}function np(r,e){return e=typeof e>"u"?!1:e,e?Re(tp,r)?tp[r]:"\\mathrm{"+Ns(r)+"}":Re(ws,r)?ws[r]:Ns(r)}var Yi="ConstantNode",BE=["Node"],$E=q(Yi,BE,r=>{var{Node:e}=r;class t extends e{constructor(n){super(),this.value=n}get type(){return Yi}get isConstantNode(){return!0}_compile(n,i){var o=this.value;return function(){return o}}forEach(n){}map(n){return this.clone()}clone(){return new t(this.value)}_toString(n){return Ye(this.value,n)}toHTML(n){var i=this._toString(n);switch(br(this.value)){case"number":case"BigNumber":case"Fraction":return'<span class="math-number">'+i+"</span>";case"string":return'<span class="math-string">'+i+"</span>";case"boolean":return'<span class="math-boolean">'+i+"</span>";case"null":return'<span class="math-null-symbol">'+i+"</span>";case"undefined":return'<span class="math-undefined">'+i+"</span>";default:return'<span class="math-symbol">'+i+"</span>"}}toJSON(){return{mathjs:Yi,value:this.value}}static fromJSON(n){return new t(n.value)}_toTex(n){var i=this._toString(n);switch(br(this.value)){case"string":return"\\mathtt{"+Ns(i)+"}";case"number":case"BigNumber":{if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var o=i.toLowerCase().indexOf("e");if(o!==-1)return i.substring(0,o)+"\\cdot10^{"+i.substring(o+1)+"}"}return i;case"Fraction":return this.value.toLatex();default:return i}}}return zr(t,"name",Yi),t},{isClass:!0,isNode:!0}),Qi="FunctionAssignmentNode",OE=["typed","Node"],IE=q(Qi,OE,r=>{var{typed:e,Node:t}=r;function a(i,o,f){var l=pr(i,o,f),u=pr(i.expr,o,f);return o==="all"||u!==null&&u<=l}class n extends t{constructor(o,f,l){if(super(),typeof o!="string")throw new TypeError('String expected for parameter "name"');if(!Array.isArray(f))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!fr(l))throw new TypeError('Node expected for parameter "expr"');if(jv.has(o))throw new Error('Illegal function name, "'+o+'" is a reserved keyword');var u=new Set;for(var s of f){var c=typeof s=="string"?s:s.name;if(u.has(c))throw new Error('Duplicate parameter name "'.concat(c,'"'));u.add(c)}this.name=o,this.params=f.map(function(m){return m&&m.name||m}),this.types=f.map(function(m){return m&&m.type||"any"}),this.expr=l}get type(){return Qi}get isFunctionAssignmentNode(){return!0}_compile(o,f){var l=Object.create(f);hi(this.params,function(h){l[h]=!0});var u=this.expr._compile(o,l),s=this.name,c=this.params,m=Cl(this.types,","),v=s+"("+Cl(this.params,", ")+")";return function(p,g,y){var N={};N[m]=function(){for(var w=Object.create(g),x=0;x<c.length;x++)w[c[x]]=arguments[x];return u(p,w,y)};var d=e(s,N);return d.syntax=v,p.set(s,d),d}}forEach(o){o(this.expr,"expr",this)}map(o){var f=this._ifNode(o(this.expr,"expr",this));return new n(this.name,this.params.slice(0),f)}clone(){return new n(this.name,this.params.slice(0),this.expr)}_toString(o){var f=o&&o.parenthesis?o.parenthesis:"keep",l=this.expr.toString(o);return a(this,f,o&&o.implicit)&&(l="("+l+")"),this.name+"("+this.params.join(", ")+") = "+l}toJSON(){var o=this.types;return{mathjs:Qi,name:this.name,params:this.params.map(function(f,l){return{name:f,type:o[l]}}),expr:this.expr}}static fromJSON(o){return new n(o.name,o.params,o.expr)}toHTML(o){for(var f=o&&o.parenthesis?o.parenthesis:"keep",l=[],u=0;u<this.params.length;u++)l.push('<span class="math-symbol math-parameter">'+ut(this.params[u])+"</span>");var s=this.expr.toHTML(o);return a(this,f,o&&o.implicit)&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),'<span class="math-function">'+ut(this.name)+'</span><span class="math-parenthesis math-round-parenthesis">(</span>'+l.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-round-parenthesis">)</span><span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+s}_toTex(o){var f=o&&o.parenthesis?o.parenthesis:"keep",l=this.expr.toTex(o);return a(this,f,o&&o.implicit)&&(l="\\left(".concat(l,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(np).join(",")+"\\right):="+l}}return zr(n,"name",Qi),n},{isClass:!0,isNode:!0}),Ki="IndexNode",RE=["Node","size"],_E=q(Ki,RE,r=>{var{Node:e,size:t}=r;class a extends e{constructor(i,o){if(super(),this.dimensions=i,this.dotNotation=o||!1,!Array.isArray(i)||!i.every(fr))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}get type(){return Ki}get isIndexNode(){return!0}_compile(i,o){var f=Ht(this.dimensions,function(u,s){var c=u.filter(h=>h.isSymbolNode&&h.name==="end").length>0;if(c){var m=Object.create(o);m.end=!0;var v=u._compile(i,m);return function(p,g,y){if(!Ve(y)&&!cr(y)&&!Wr(y))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+br(y));var N=t(y).valueOf(),d=Object.create(g);return d.end=N[s],v(p,d,y)}}else return u._compile(i,o)}),l=lt(i,"index");return function(s,c,m){var v=Ht(f,function(h){return h(s,c,m)});return l(...v)}}forEach(i){for(var o=0;o<this.dimensions.length;o++)i(this.dimensions[o],"dimensions["+o+"]",this)}map(i){for(var o=[],f=0;f<this.dimensions.length;f++)o[f]=this._ifNode(i(this.dimensions[f],"dimensions["+f+"]",this));return new a(o,this.dotNotation)}clone(){return new a(this.dimensions.slice(0),this.dotNotation)}isObjectProperty(){return this.dimensions.length===1&&ir(this.dimensions[0])&&typeof this.dimensions[0].value=="string"}getObjectProperty(){return this.isObjectProperty()?this.dimensions[0].value:null}_toString(i){return this.dotNotation?"."+this.getObjectProperty():"["+this.dimensions.join(", ")+"]"}toJSON(){return{mathjs:Ki,dimensions:this.dimensions,dotNotation:this.dotNotation}}static fromJSON(i){return new a(i.dimensions,i.dotNotation)}toHTML(i){for(var o=[],f=0;f<this.dimensions.length;f++)o[f]=this.dimensions[f].toHTML();return this.dotNotation?'<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">'+ut(this.getObjectProperty())+"</span>":'<span class="math-parenthesis math-square-parenthesis">[</span>'+o.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(i){var o=this.dimensions.map(function(f){return f.toTex(i)});return this.dotNotation?"."+this.getObjectProperty():"_{"+o.join(",")+"}"}}return zr(a,"name",Ki),a},{isClass:!0,isNode:!0}),ji="ObjectNode",qE=["Node"],zE=q(ji,qE,r=>{var{Node:e}=r;class t extends e{constructor(n){if(super(),this.properties=n||{},n&&(typeof n!="object"||!Object.keys(n).every(function(i){return fr(n[i])})))throw new TypeError("Object containing Nodes expected")}get type(){return ji}get isObjectNode(){return!0}_compile(n,i){var o={};for(var f in this.properties)if(Re(this.properties,f)){var l=vi(f),u=JSON.parse(l);if(!Xo(this.properties,u))throw new Error('No access to property "'+u+'"');o[u]=this.properties[f]._compile(n,i)}return function(c,m,v){var h={};for(var p in o)Re(o,p)&&(h[p]=o[p](c,m,v));return h}}forEach(n){for(var i in this.properties)Re(this.properties,i)&&n(this.properties[i],"properties["+vi(i)+"]",this)}map(n){var i={};for(var o in this.properties)Re(this.properties,o)&&(i[o]=this._ifNode(n(this.properties[o],"properties["+vi(o)+"]",this)));return new t(i)}clone(){var n={};for(var i in this.properties)Re(this.properties,i)&&(n[i]=this.properties[i]);return new t(n)}_toString(n){var i=[];for(var o in this.properties)Re(this.properties,o)&&i.push(vi(o)+": "+this.properties[o].toString(n));return"{"+i.join(", ")+"}"}toJSON(){return{mathjs:ji,properties:this.properties}}static fromJSON(n){return new t(n.properties)}toHTML(n){var i=[];for(var o in this.properties)Re(this.properties,o)&&i.push('<span class="math-symbol math-property">'+ut(o)+'</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>'+this.properties[o].toHTML(n));return'<span class="math-parenthesis math-curly-parenthesis">{</span>'+i.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-curly-parenthesis">}</span>'}_toTex(n){var i=[];for(var o in this.properties)Re(this.properties,o)&&i.push("\\mathbf{"+o+":} & "+this.properties[o].toTex(n)+"\\\\");var f="\\left\\{\\begin{array}{ll}"+i.join(`
32
+ `)+"\\end{array}\\right\\}";return f}}return zr(t,"name",ji),t},{isClass:!0,isNode:!0}),eo="OperatorNode",PE=["Node"],UE=q(eo,PE,r=>{var{Node:e}=r;function t(i,o){var f=i;if(o==="auto")for(;Gt(f);)f=f.content;return ir(f)?!0:Br(f)?t(f.args[0],o):!1}function a(i,o,f,l,u){var s=pr(i,o,f),c=Xa(i,o);if(o==="all"||l.length>2&&i.getIdentifier()!=="OperatorNode:add"&&i.getIdentifier()!=="OperatorNode:multiply")return l.map(function(D){switch(D.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}});var m;switch(l.length){case 0:m=[];break;case 1:{var v=pr(l[0],o,f,i);if(u&&v!==null){var h,p;if(o==="keep"?(h=l[0].getIdentifier(),p=i.getIdentifier()):(h=l[0].getContent().getIdentifier(),p=i.getContent().getIdentifier()),Nt[s][p].latexLeftParens===!1){m=[!1];break}if(Nt[v][h].latexParens===!1){m=[!1];break}}if(v===null){m=[!1];break}if(v<=s){m=[!0];break}m=[!1]}break;case 2:{var g,y=pr(l[0],o,f,i),N=bs(i,l[0],o);y===null?g=!1:y===s&&c==="right"&&!N||y<s?g=!0:g=!1;var d,w=pr(l[1],o,f,i),x=bs(i,l[1],o);if(w===null?d=!1:w===s&&c==="left"&&!x||w<s?d=!0:d=!1,u){var b,E,A;o==="keep"?(b=i.getIdentifier(),E=i.args[0].getIdentifier(),A=i.args[1].getIdentifier()):(b=i.getContent().getIdentifier(),E=i.args[0].getContent().getIdentifier(),A=i.args[1].getContent().getIdentifier()),y!==null&&(Nt[s][b].latexLeftParens===!1&&(g=!1),Nt[y][E].latexParens===!1&&(g=!1)),w!==null&&(Nt[s][b].latexRightParens===!1&&(d=!1),Nt[w][A].latexParens===!1&&(d=!1))}m=[g,d]}break;default:(i.getIdentifier()==="OperatorNode:add"||i.getIdentifier()==="OperatorNode:multiply")&&(m=l.map(function(D){var T=pr(D,o,f,i),B=bs(i,D,o),I=Xa(D,o);return T===null?!1:s===T&&c===I&&!B?!0:T<s}));break}if(l.length>=2&&i.getIdentifier()==="OperatorNode:multiply"&&i.implicit&&o!=="all"&&f==="hide")for(var S=1;S<m.length;++S)t(l[S],o)&&!m[S-1]&&(o!=="keep"||!Gt(l[S-1]))&&(m[S]=!0);return m}class n extends e{constructor(o,f,l,u,s){if(super(),typeof o!="string")throw new TypeError('string expected for parameter "op"');if(typeof f!="string")throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(l)||!l.every(fr))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=u===!0,this.isPercentage=s===!0,this.op=o,this.fn=f,this.args=l||[]}get type(){return eo}get isOperatorNode(){return!0}_compile(o,f){if(typeof this.fn!="string"||!Wo(o,this.fn))throw o[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var l=lt(o,this.fn),u=Ht(this.args,function(v){return v._compile(o,f)});if(u.length===1){var s=u[0];return function(h,p,g){return l(s(h,p,g))}}else if(u.length===2){var c=u[0],m=u[1];return function(h,p,g){return l(c(h,p,g),m(h,p,g))}}else return function(h,p,g){return l.apply(null,Ht(u,function(y){return y(h,p,g)}))}}forEach(o){for(var f=0;f<this.args.length;f++)o(this.args[f],"args["+f+"]",this)}map(o){for(var f=[],l=0;l<this.args.length;l++)f[l]=this._ifNode(o(this.args[l],"args["+l+"]",this));return new n(this.op,this.fn,f,this.implicit,this.isPercentage)}clone(){return new n(this.op,this.fn,this.args.slice(0),this.implicit,this.isPercentage)}isUnary(){return this.args.length===1}isBinary(){return this.args.length===2}_toString(o){var f=o&&o.parenthesis?o.parenthesis:"keep",l=o&&o.implicit?o.implicit:"hide",u=this.args,s=a(this,f,l,u,!1);if(u.length===1){var c=Xa(this,f),m=u[0].toString(o);s[0]&&(m="("+m+")");var v=/[a-zA-Z]+/.test(this.op);return c==="right"?this.op+(v?" ":"")+m:c==="left"?m+(v?" ":"")+this.op:m+this.op}else if(u.length===2){var h=u[0].toString(o),p=u[1].toString(o);return s[0]&&(h="("+h+")"),s[1]&&(p="("+p+")"),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?h+" "+p:h+" "+this.op+" "+p}else if(u.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var g=u.map(function(y,N){return y=y.toString(o),s[N]&&(y="("+y+")"),y});return this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?g.join(" "):g.join(" "+this.op+" ")}else return this.fn+"("+this.args.join(", ")+")"}toJSON(){return{mathjs:eo,op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}}static fromJSON(o){return new n(o.op,o.fn,o.args,o.implicit,o.isPercentage)}toHTML(o){var f=o&&o.parenthesis?o.parenthesis:"keep",l=o&&o.implicit?o.implicit:"hide",u=this.args,s=a(this,f,l,u,!1);if(u.length===1){var c=Xa(this,f),m=u[0].toHTML(o);return s[0]&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>'),c==="right"?'<span class="math-operator math-unary-operator math-lefthand-unary-operator">'+ut(this.op)+"</span>"+m:m+'<span class="math-operator math-unary-operator math-righthand-unary-operator">'+ut(this.op)+"</span>"}else if(u.length===2){var v=u[0].toHTML(o),h=u[1].toHTML(o);return s[0]&&(v='<span class="math-parenthesis math-round-parenthesis">(</span>'+v+'<span class="math-parenthesis math-round-parenthesis">)</span>'),s[1]&&(h='<span class="math-parenthesis math-round-parenthesis">(</span>'+h+'<span class="math-parenthesis math-round-parenthesis">)</span>'),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?v+'<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'+h:v+'<span class="math-operator math-binary-operator math-explicit-binary-operator">'+ut(this.op)+"</span>"+h}else{var p=u.map(function(g,y){return g=g.toHTML(o),s[y]&&(g='<span class="math-parenthesis math-round-parenthesis">(</span>'+g+'<span class="math-parenthesis math-round-parenthesis">)</span>'),g});return u.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")?this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?p.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'):p.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">'+ut(this.op)+"</span>"):'<span class="math-function">'+ut(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+p.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}}_toTex(o){var f=o&&o.parenthesis?o.parenthesis:"keep",l=o&&o.implicit?o.implicit:"hide",u=this.args,s=a(this,f,l,u,!0),c=sr[this.fn];if(c=typeof c>"u"?this.op:c,u.length===1){var m=Xa(this,f),v=u[0].toTex(o);return s[0]&&(v="\\left(".concat(v,"\\right)")),m==="right"?c+v:v+c}else if(u.length===2){var h=u[0],p=h.toTex(o);s[0]&&(p="\\left(".concat(p,"\\right)"));var g=u[1],y=g.toTex(o);s[1]&&(y="\\left(".concat(y,"\\right)"));var N;switch(f==="keep"?N=h.getIdentifier():N=h.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return c+"{"+p+"}{"+y+"}";case"OperatorNode:pow":switch(p="{"+p+"}",y="{"+y+"}",N){case"ConditionalNode":case"OperatorNode:divide":p="\\left(".concat(p,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&l==="hide")return p+"~"+y}return p+c+y}else if(u.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var d=u.map(function(w,x){return w=w.toTex(o),s[x]&&(w="\\left(".concat(w,"\\right)")),w});return this.getIdentifier()==="OperatorNode:multiply"&&this.implicit&&l==="hide"?d.join("~"):d.join(c)}else return"\\mathrm{"+this.fn+"}\\left("+u.map(function(w){return w.toTex(o)}).join(",")+"\\right)"}getIdentifier(){return this.type+":"+this.fn}}return zr(n,"name",eo),n},{isClass:!0,isNode:!0}),ro="ParenthesisNode",LE=["Node"],kE=q(ro,LE,r=>{var{Node:e}=r;class t extends e{constructor(n){if(super(),!fr(n))throw new TypeError('Node expected for parameter "content"');this.content=n}get type(){return ro}get isParenthesisNode(){return!0}_compile(n,i){return this.content._compile(n,i)}getContent(){return this.content.getContent()}forEach(n){n(this.content,"content",this)}map(n){var i=n(this.content,"content",this);return new t(i)}clone(){return new t(this.content)}_toString(n){return!n||n&&!n.parenthesis||n&&n.parenthesis==="keep"?"("+this.content.toString(n)+")":this.content.toString(n)}toJSON(){return{mathjs:ro,content:this.content}}static fromJSON(n){return new t(n.content)}toHTML(n){return!n||n&&!n.parenthesis||n&&n.parenthesis==="keep"?'<span class="math-parenthesis math-round-parenthesis">(</span>'+this.content.toHTML(n)+'<span class="math-parenthesis math-round-parenthesis">)</span>':this.content.toHTML(n)}_toTex(n){return!n||n&&!n.parenthesis||n&&n.parenthesis==="keep"?"\\left(".concat(this.content.toTex(n),"\\right)"):this.content.toTex(n)}}return zr(t,"name",ro),t},{isClass:!0,isNode:!0}),to="RangeNode",VE=["Node"],GE=q(to,VE,r=>{var{Node:e}=r;function t(n,i,o){var f=pr(n,i,o),l={},u=pr(n.start,i,o);if(l.start=u!==null&&u<=f||i==="all",n.step){var s=pr(n.step,i,o);l.step=s!==null&&s<=f||i==="all"}var c=pr(n.end,i,o);return l.end=c!==null&&c<=f||i==="all",l}class a extends e{constructor(i,o,f){if(super(),!fr(i))throw new TypeError("Node expected");if(!fr(o))throw new TypeError("Node expected");if(f&&!fr(f))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=i,this.end=o,this.step=f||null}get type(){return to}get isRangeNode(){return!0}needsEnd(){var i=this.filter(function(o){return qr(o)&&o.name==="end"});return i.length>0}_compile(i,o){var f=i.range,l=this.start._compile(i,o),u=this.end._compile(i,o);if(this.step){var s=this.step._compile(i,o);return function(m,v,h){return f(l(m,v,h),u(m,v,h),s(m,v,h))}}else return function(m,v,h){return f(l(m,v,h),u(m,v,h))}}forEach(i){i(this.start,"start",this),i(this.end,"end",this),this.step&&i(this.step,"step",this)}map(i){return new a(this._ifNode(i(this.start,"start",this)),this._ifNode(i(this.end,"end",this)),this.step&&this._ifNode(i(this.step,"step",this)))}clone(){return new a(this.start,this.end,this.step&&this.step)}_toString(i){var o=i&&i.parenthesis?i.parenthesis:"keep",f=t(this,o,i&&i.implicit),l,u=this.start.toString(i);if(f.start&&(u="("+u+")"),l=u,this.step){var s=this.step.toString(i);f.step&&(s="("+s+")"),l+=":"+s}var c=this.end.toString(i);return f.end&&(c="("+c+")"),l+=":"+c,l}toJSON(){return{mathjs:to,start:this.start,end:this.end,step:this.step}}static fromJSON(i){return new a(i.start,i.end,i.step)}toHTML(i){var o=i&&i.parenthesis?i.parenthesis:"keep",f=t(this,o,i&&i.implicit),l,u=this.start.toHTML(i);if(f.start&&(u='<span class="math-parenthesis math-round-parenthesis">(</span>'+u+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l=u,this.step){var s=this.step.toHTML(i);f.step&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+='<span class="math-operator math-range-operator">:</span>'+s}var c=this.end.toHTML(i);return f.end&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+='<span class="math-operator math-range-operator">:</span>'+c,l}_toTex(i){var o=i&&i.parenthesis?i.parenthesis:"keep",f=t(this,o,i&&i.implicit),l=this.start.toTex(i);if(f.start&&(l="\\left(".concat(l,"\\right)")),this.step){var u=this.step.toTex(i);f.step&&(u="\\left(".concat(u,"\\right)")),l+=":"+u}var s=this.end.toTex(i);return f.end&&(s="\\left(".concat(s,"\\right)")),l+=":"+s,l}}return zr(a,"name",to),a},{isClass:!0,isNode:!0}),no="RelationalNode",HE=["Node"],ZE=q(no,HE,r=>{var{Node:e}=r,t={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="};class a extends e{constructor(i,o){if(super(),!Array.isArray(i))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(o))throw new TypeError("Parameter params must be an array");if(i.length!==o.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=i,this.params=o}get type(){return no}get isRelationalNode(){return!0}_compile(i,o){var f=this,l=this.params.map(u=>u._compile(i,o));return function(s,c,m){for(var v,h=l[0](s,c,m),p=0;p<f.conditionals.length;p++){v=h,h=l[p+1](s,c,m);var g=lt(i,f.conditionals[p]);if(!g(v,h))return!1}return!0}}forEach(i){this.params.forEach((o,f)=>i(o,"params["+f+"]",this),this)}map(i){return new a(this.conditionals.slice(),this.params.map((o,f)=>this._ifNode(i(o,"params["+f+"]",this)),this))}clone(){return new a(this.conditionals,this.params)}_toString(i){for(var o=i&&i.parenthesis?i.parenthesis:"keep",f=pr(this,o,i&&i.implicit),l=this.params.map(function(c,m){var v=pr(c,o,i&&i.implicit);return o==="all"||v!==null&&v<=f?"("+c.toString(i)+")":c.toString(i)}),u=l[0],s=0;s<this.conditionals.length;s++)u+=" "+t[this.conditionals[s]],u+=" "+l[s+1];return u}toJSON(){return{mathjs:no,conditionals:this.conditionals,params:this.params}}static fromJSON(i){return new a(i.conditionals,i.params)}toHTML(i){for(var o=i&&i.parenthesis?i.parenthesis:"keep",f=pr(this,o,i&&i.implicit),l=this.params.map(function(c,m){var v=pr(c,o,i&&i.implicit);return o==="all"||v!==null&&v<=f?'<span class="math-parenthesis math-round-parenthesis">(</span>'+c.toHTML(i)+'<span class="math-parenthesis math-round-parenthesis">)</span>':c.toHTML(i)}),u=l[0],s=0;s<this.conditionals.length;s++)u+='<span class="math-operator math-binary-operator math-explicit-binary-operator">'+ut(t[this.conditionals[s]])+"</span>"+l[s+1];return u}_toTex(i){for(var o=i&&i.parenthesis?i.parenthesis:"keep",f=pr(this,o,i&&i.implicit),l=this.params.map(function(c,m){var v=pr(c,o,i&&i.implicit);return o==="all"||v!==null&&v<=f?"\\left("+c.toTex(i)+"\right)":c.toTex(i)}),u=l[0],s=0;s<this.conditionals.length;s++)u+=sr[this.conditionals[s]]+l[s+1];return u}}return zr(a,"name",no),a},{isClass:!0,isNode:!0}),JE="SymbolNode",XE=["math","?Unit","Node"],WE=q(JE,XE,r=>{var{math:e,Unit:t,Node:a}=r;function n(o){return t?t.isValuelessUnit(o):!1}class i extends a{constructor(f){if(super(),typeof f!="string")throw new TypeError('String expected for parameter "name"');this.name=f}get type(){return"SymbolNode"}get isSymbolNode(){return!0}_compile(f,l){var u=this.name;if(l[u]===!0)return function(c,m,v){return m[u]};if(u in f)return function(c,m,v){return c.has(u)?c.get(u):lt(f,u)};var s=n(u);return function(c,m,v){return c.has(u)?c.get(u):s?new t(null,u):i.onUndefinedSymbol(u)}}forEach(f){}map(f){return this.clone()}static onUndefinedSymbol(f){throw new Error("Undefined symbol "+f)}clone(){return new i(this.name)}_toString(f){return this.name}toHTML(f){var l=ut(this.name);return l==="true"||l==="false"?'<span class="math-symbol math-boolean">'+l+"</span>":l==="i"?'<span class="math-symbol math-imaginary-symbol">'+l+"</span>":l==="Infinity"?'<span class="math-symbol math-infinity-symbol">'+l+"</span>":l==="NaN"?'<span class="math-symbol math-nan-symbol">'+l+"</span>":l==="null"?'<span class="math-symbol math-null-symbol">'+l+"</span>":l==="undefined"?'<span class="math-symbol math-undefined-symbol">'+l+"</span>":'<span class="math-symbol">'+l+"</span>"}toJSON(){return{mathjs:"SymbolNode",name:this.name}}static fromJSON(f){return new i(f.name)}_toTex(f){var l=!1;typeof e[this.name]>"u"&&n(this.name)&&(l=!0);var u=np(this.name,l);return u[0]==="\\"?u:" "+u}}return i},{isClass:!0,isNode:!0});function Wa(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),a=1;a<e;a++)t[a-1]=arguments[a];return typeof r.createSubScope=="function"?Fl(r.createSubScope(),...t):Fl(ea(),r,...t)}var ao="FunctionNode",YE=["math","Node","SymbolNode"],QE=q(ao,YE,r=>{var{math:e,Node:t,SymbolNode:a}=r,n=f=>Ye(f,{truncate:78});function i(f,l,u){for(var s="",c=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,m=0,v;(v=c.exec(f))!==null;)if(s+=f.substring(m,v.index),m=v.index,v[0]==="$$")s+="$",m++;else{m+=v[0].length;var h=l[v[1]];if(!h)throw new ReferenceError("Template: Property "+v[1]+" does not exist.");if(v[2]===void 0)switch(typeof h){case"string":s+=h;break;case"object":if(fr(h))s+=h.toTex(u);else if(Array.isArray(h))s+=h.map(function(p,g){if(fr(p))return p.toTex(u);throw new TypeError("Template: "+v[1]+"["+g+"] is not a Node.")}).join(",");else throw new TypeError("Template: "+v[1]+" has to be a Node, String or array of Nodes");break;default:throw new TypeError("Template: "+v[1]+" has to be a Node, String or array of Nodes")}else if(fr(h[v[2]]&&h[v[2]]))s+=h[v[2]].toTex(u);else throw new TypeError("Template: "+v[1]+"["+v[2]+"] is not a Node.")}return s+=f.slice(m),s}class o extends t{constructor(l,u){if(super(),typeof l=="string"&&(l=new a(l)),!fr(l))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(u)||!u.every(fr))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=l,this.args=u||[]}get name(){return this.fn.name||""}get type(){return ao}get isFunctionNode(){return!0}_compile(l,u){var s=this.args.map(E=>E._compile(l,u));if(qr(this.fn)){var c=this.fn.name;if(u[c]){var g=this.args;return function(A,S,D){var T=S[c];if(typeof T!="function")throw new TypeError("Argument '".concat(c,"' was not a function; received: ").concat(n(T)));if(T.rawArgs)return T(g,l,Wa(A,S),A);var B=s.map(I=>I(A,S,D));return T.apply(T,B)}}else{var m=c in l?lt(l,c):void 0,v=typeof m=="function"&&m.rawArgs===!0,h=E=>{var A;if(E.has(c))A=E.get(c);else if(c in l)A=lt(l,c);else return o.onUndefinedFunction(c);if(typeof A=="function")return A;throw new TypeError("'".concat(c,`' is not a function; its value is:
33
+ `).concat(n(A)))};if(v){var p=this.args;return function(A,S,D){var T=h(A);return T(p,l,Wa(A,S),A)}}else switch(s.length){case 0:return function(A,S,D){var T=h(A);return T()};case 1:return function(A,S,D){var T=h(A),B=s[0];return T(B(A,S,D))};case 2:return function(A,S,D){var T=h(A),B=s[0],I=s[1];return T(B(A,S,D),I(A,S,D))};default:return function(A,S,D){var T=h(A),B=s.map(I=>I(A,S,D));return T(...B)}}}}else if(Sn(this.fn)&&Jn(this.fn.index)&&this.fn.index.isObjectProperty()){var y=this.fn.object._compile(l,u),N=this.fn.index.getObjectProperty(),d=this.args;return function(A,S,D){var T=y(A,S,D);Sg(T,N);var B=T[N]&&T[N].rawArgs;if(B)return T[N](d,l,Wa(A,S),A);var I=s.map(P=>P(A,S,D));return T[N].apply(T,I)}}else{var w=this.fn.toString(),x=this.fn._compile(l,u),b=this.args;return function(A,S,D){var T=x(A,S,D);if(typeof T!="function")throw new TypeError("Expression '".concat(w,"' did not evaluate to a function; value is:")+`
34
+ `.concat(n(T)));if(T.rawArgs)return T(b,l,Wa(A,S),A);var B=s.map(I=>I(A,S,D));return T.apply(T,B)}}}forEach(l){l(this.fn,"fn",this);for(var u=0;u<this.args.length;u++)l(this.args[u],"args["+u+"]",this)}map(l){for(var u=this._ifNode(l(this.fn,"fn",this)),s=[],c=0;c<this.args.length;c++)s[c]=this._ifNode(l(this.args[c],"args["+c+"]",this));return new o(u,s)}clone(){return new o(this.fn,this.args.slice(0))}toString(l){var u,s=this.fn.toString(l);return l&&typeof l.handler=="object"&&Re(l.handler,s)&&(u=l.handler[s](this,l)),typeof u<"u"?u:super.toString(l)}_toString(l){var u=this.args.map(function(c){return c.toString(l)}),s=Pa(this.fn)?"("+this.fn.toString(l)+")":this.fn.toString(l);return s+"("+u.join(", ")+")"}toJSON(){return{mathjs:ao,fn:this.fn,args:this.args}}toHTML(l){var u=this.args.map(function(s){return s.toHTML(l)});return'<span class="math-function">'+ut(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+u.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}toTex(l){var u;return l&&typeof l.handler=="object"&&Re(l.handler,this.name)&&(u=l.handler[this.name](this,l)),typeof u<"u"?u:super.toTex(l)}_toTex(l){var u=this.args.map(function(m){return m.toTex(l)}),s;rp[this.name]&&(s=rp[this.name]),e[this.name]&&(typeof e[this.name].toTex=="function"||typeof e[this.name].toTex=="object"||typeof e[this.name].toTex=="string")&&(s=e[this.name].toTex);var c;switch(typeof s){case"function":c=s(this,l);break;case"string":c=i(s,this,l);break;case"object":switch(typeof s[u.length]){case"function":c=s[u.length](this,l);break;case"string":c=i(s[u.length],this,l);break}}return typeof c<"u"?c:i(TE,this,l)}getIdentifier(){return this.type+":"+this.name}}return zr(o,"name",ao),zr(o,"onUndefinedFunction",function(f){throw new Error("Undefined function "+f)}),zr(o,"fromJSON",function(f){return new o(f.fn,f.args)}),o},{isClass:!0,isNode:!0}),ap="parse",KE=["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],jE=q(ap,KE,r=>{var{typed:e,numeric:t,config:a,AccessorNode:n,ArrayNode:i,AssignmentNode:o,BlockNode:f,ConditionalNode:l,ConstantNode:u,FunctionAssignmentNode:s,FunctionNode:c,IndexNode:m,ObjectNode:v,OperatorNode:h,ParenthesisNode:p,RangeNode:g,RelationalNode:y,SymbolNode:N}=r,d=e(ap,{string:function(Z){return k(Z,{})},"Array | Matrix":function(Z){return w(Z,{})},"string, Object":function(Z,se){var Ee=se.nodes!==void 0?se.nodes:{};return k(Z,Ee)},"Array | Matrix, Object":w});function w(C){var Z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},se=Z.nodes!==void 0?Z.nodes:{};return je(C,function(Ee){if(typeof Ee!="string")throw new TypeError("String expected");return k(Ee,se)})}var x={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},b={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},E={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},A={true:!0,false:!1,null:null,undefined:void 0},S=["NaN","Infinity"];function D(){return{extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:x.NULL,nestingLevel:0,conditionalLevel:null}}function T(C,Z){return C.expression.substr(C.index,Z)}function B(C){return T(C,1)}function I(C){C.index++}function P(C){return C.expression.charAt(C.index-1)}function R(C){return C.expression.charAt(C.index+1)}function M(C){for(C.tokenType=x.NULL,C.token="",C.comment="";;){if(B(C)==="#")for(;B(C)!==`
35
+ `&&B(C)!=="";)C.comment+=B(C),I(C);if(d.isWhitespace(B(C),C.nestingLevel))I(C);else break}if(B(C)===""){C.tokenType=x.DELIMITER;return}if(B(C)===`
36
+ `&&!C.nestingLevel){C.tokenType=x.DELIMITER,C.token=B(C),I(C);return}var Z=B(C),se=T(C,2),Ee=T(C,3);if(Ee.length===3&&b[Ee]){C.tokenType=x.DELIMITER,C.token=Ee,I(C),I(C),I(C);return}if(se.length===2&&b[se]){C.tokenType=x.DELIMITER,C.token=se,I(C),I(C);return}if(b[Z]){C.tokenType=x.DELIMITER,C.token=Z,I(C);return}if(d.isDigitDot(Z)){C.tokenType=x.NUMBER;var ze=T(C,2);if(ze==="0b"||ze==="0o"||ze==="0x"){for(C.token+=B(C),I(C),C.token+=B(C),I(C);d.isHexDigit(B(C));)C.token+=B(C),I(C);if(B(C)===".")for(C.token+=".",I(C);d.isHexDigit(B(C));)C.token+=B(C),I(C);else if(B(C)==="i")for(C.token+="i",I(C);d.isDigit(B(C));)C.token+=B(C),I(C);return}if(B(C)==="."){if(C.token+=B(C),I(C),!d.isDigit(B(C))){C.tokenType=x.DELIMITER;return}}else{for(;d.isDigit(B(C));)C.token+=B(C),I(C);d.isDecimalMark(B(C),R(C))&&(C.token+=B(C),I(C))}for(;d.isDigit(B(C));)C.token+=B(C),I(C);if(B(C)==="E"||B(C)==="e"){if(d.isDigit(R(C))||R(C)==="-"||R(C)==="+"){if(C.token+=B(C),I(C),(B(C)==="+"||B(C)==="-")&&(C.token+=B(C),I(C)),!d.isDigit(B(C)))throw Je(C,'Digit expected, got "'+B(C)+'"');for(;d.isDigit(B(C));)C.token+=B(C),I(C);if(d.isDecimalMark(B(C),R(C)))throw Je(C,'Digit expected, got "'+B(C)+'"')}else if(R(C)===".")throw I(C),Je(C,'Digit expected, got "'+B(C)+'"')}return}if(d.isAlpha(B(C),P(C),R(C))){for(;d.isAlpha(B(C),P(C),R(C))||d.isDigit(B(C));)C.token+=B(C),I(C);Re(E,C.token)?C.tokenType=x.DELIMITER:C.tokenType=x.SYMBOL;return}for(C.tokenType=x.UNKNOWN;B(C)!=="";)C.token+=B(C),I(C);throw Je(C,'Syntax error in part "'+C.token+'"')}function F(C){do M(C);while(C.token===`
37
+ `)}function H(C){C.nestingLevel++}function $(C){C.nestingLevel--}d.isAlpha=function(Z,se,Ee){return d.isValidLatinOrGreek(Z)||d.isValidMathSymbol(Z,Ee)||d.isValidMathSymbol(se,Z)},d.isValidLatinOrGreek=function(Z){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(Z)},d.isValidMathSymbol=function(Z,se){return/^[\uD835]$/.test(Z)&&/^[\uDC00-\uDFFF]$/.test(se)&&/^[^\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDFCC\uDFCD]$/.test(se)},d.isWhitespace=function(Z,se){return Z===" "||Z===" "||Z===`
38
+ `&&se>0},d.isDecimalMark=function(Z,se){return Z==="."&&se!=="/"&&se!=="*"&&se!=="^"},d.isDigitDot=function(Z){return Z>="0"&&Z<="9"||Z==="."},d.isDigit=function(Z){return Z>="0"&&Z<="9"},d.isHexDigit=function(Z){return Z>="0"&&Z<="9"||Z>="a"&&Z<="f"||Z>="A"&&Z<="F"};function k(C,Z){var se=D();Sr(se,{expression:C,extraNodes:Z}),M(se);var Ee=Q(se);if(se.token!=="")throw se.tokenType===x.DELIMITER?mr(se,"Unexpected operator "+se.token):Je(se,'Unexpected part "'+se.token+'"');return Ee}function Q(C){var Z,se=[],Ee;for(C.token!==""&&C.token!==`
39
+ `&&C.token!==";"&&(Z=K(C),C.comment&&(Z.comment=C.comment));C.token===`
40
+ `||C.token===";";)se.length===0&&Z&&(Ee=C.token!==";",se.push({node:Z,visible:Ee})),M(C),C.token!==`
41
+ `&&C.token!==";"&&C.token!==""&&(Z=K(C),C.comment&&(Z.comment=C.comment),Ee=C.token!==";",se.push({node:Z,visible:Ee}));return se.length>0?new f(se):(Z||(Z=new u(void 0),C.comment&&(Z.comment=C.comment)),Z)}function K(C){var Z,se,Ee,ze,ke=L(C);if(C.token==="="){if(qr(ke))return Z=ke.name,F(C),Ee=K(C),new o(new N(Z),Ee);if(Sn(ke))return F(C),Ee=K(C),new o(ke.object,ke.index,Ee);if(nn(ke)&&qr(ke.fn)&&(ze=!0,se=[],Z=ke.name,ke.args.forEach(function(Fr,_r){qr(Fr)?se[_r]=Fr.name:ze=!1}),ze))return F(C),Ee=K(C),new s(Z,se,Ee);throw Je(C,"Invalid left hand side of assignment operator =")}return ke}function L(C){for(var Z=j(C);C.token==="?";){var se=C.conditionalLevel;C.conditionalLevel=C.nestingLevel,F(C);var Ee=Z,ze=K(C);if(C.token!==":")throw Je(C,"False part of conditional expression expected");C.conditionalLevel=null,F(C);var ke=K(C);Z=new l(Ee,ze,ke),C.conditionalLevel=se}return Z}function j(C){for(var Z=ae(C);C.token==="or";)F(C),Z=new h("or","or",[Z,ae(C)]);return Z}function ae(C){for(var Z=re(C);C.token==="xor";)F(C),Z=new h("xor","xor",[Z,re(C)]);return Z}function re(C){for(var Z=fe(C);C.token==="and";)F(C),Z=new h("and","and",[Z,fe(C)]);return Z}function fe(C){for(var Z=he(C);C.token==="|";)F(C),Z=new h("|","bitOr",[Z,he(C)]);return Z}function he(C){for(var Z=ce(C);C.token==="^|";)F(C),Z=new h("^|","bitXor",[Z,ce(C)]);return Z}function ce(C){for(var Z=ie(C);C.token==="&";)F(C),Z=new h("&","bitAnd",[Z,ie(C)]);return Z}function ie(C){for(var Z=[Ae(C)],se=[],Ee={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};Re(Ee,C.token);){var ze={name:C.token,fn:Ee[C.token]};se.push(ze),F(C),Z.push(Ae(C))}return Z.length===1?Z[0]:Z.length===2?new h(se[0].name,se[0].fn,Z):new y(se.map(ke=>ke.fn),Z)}function Ae(C){var Z,se,Ee,ze;Z=Oe(C);for(var ke={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Re(ke,C.token);)se=C.token,Ee=ke[se],F(C),ze=[Z,Oe(C)],Z=new h(se,Ee,ze);return Z}function Oe(C){var Z,se,Ee,ze;Z=Ce(C);for(var ke={to:"to",in:"to"};Re(ke,C.token);)se=C.token,Ee=ke[se],F(C),se==="in"&&C.token===""?Z=new h("*","multiply",[Z,new N("in")],!0):(ze=[Z,Ce(C)],Z=new h(se,Ee,ze));return Z}function Ce(C){var Z,se=[];if(C.token===":"?Z=new u(1):Z=$e(C),C.token===":"&&C.conditionalLevel!==C.nestingLevel){for(se.push(Z);C.token===":"&&se.length<3;)F(C),C.token===")"||C.token==="]"||C.token===","||C.token===""?se.push(new N("end")):se.push($e(C));se.length===3?Z=new g(se[0],se[2],se[1]):Z=new g(se[0],se[1])}return Z}function $e(C){var Z,se,Ee,ze;Z=V(C);for(var ke={"+":"add","-":"subtract"};Re(ke,C.token);){se=C.token,Ee=ke[se],F(C);var Fr=V(C);Fr.isPercentage?ze=[Z,new h("*","multiply",[Z,Fr])]:ze=[Z,Fr],Z=new h(se,Ee,ze)}return Z}function V(C){var Z,se,Ee,ze;Z=X(C),se=Z;for(var ke={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};Re(ke,C.token);)Ee=C.token,ze=ke[Ee],F(C),se=X(C),Z=new h(Ee,ze,[Z,se]);return Z}function X(C){var Z,se;for(Z=oe(C),se=Z;C.tokenType===x.SYMBOL||C.token==="in"&&ir(Z)||C.tokenType===x.NUMBER&&!ir(se)&&(!Br(se)||se.op==="!")||C.token==="(";)se=oe(C),Z=new h("*","multiply",[Z,se],!0);return Z}function oe(C){for(var Z=G(C),se=Z,Ee=[];C.token==="/"&&ko(se);)if(Ee.push(Sr({},C)),F(C),C.tokenType===x.NUMBER)if(Ee.push(Sr({},C)),F(C),C.tokenType===x.SYMBOL||C.token==="(")Sr(C,Ee.pop()),Ee.pop(),se=G(C),Z=new h("/","divide",[Z,se]);else{Ee.pop(),Sr(C,Ee.pop());break}else{Sr(C,Ee.pop());break}return Z}function G(C){var Z,se,Ee,ze;Z=Y(C);for(var ke={"%":"mod",mod:"mod"};Re(ke,C.token);)se=C.token,Ee=ke[se],F(C),se==="%"&&C.tokenType===x.DELIMITER&&C.token!=="("?Z=new h("/","divide",[Z,new u(100)],!1,!0):(ze=[Z,Y(C)],Z=new h(se,Ee,ze));return Z}function Y(C){var Z,se,Ee,ze={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Re(ze,C.token)?(Ee=ze[C.token],Z=C.token,F(C),se=[Y(C)],new h(Z,Ee,se)):te(C)}function te(C){var Z,se,Ee,ze;return Z=ye(C),(C.token==="^"||C.token===".^")&&(se=C.token,Ee=se==="^"?"pow":"dotPow",F(C),ze=[Z,Y(C)],Z=new h(se,Ee,ze)),Z}function ye(C){var Z,se,Ee,ze;Z=me(C);for(var ke={"!":"factorial","'":"ctranspose"};Re(ke,C.token);)se=C.token,Ee=ke[se],M(C),ze=[Z],Z=new h(se,Ee,ze),Z=U(C,Z);return Z}function me(C){var Z=[];if(C.tokenType===x.SYMBOL&&Re(C.extraNodes,C.token)){var se=C.extraNodes[C.token];if(M(C),C.token==="("){if(Z=[],H(C),M(C),C.token!==")")for(Z.push(K(C));C.token===",";)M(C),Z.push(K(C));if(C.token!==")")throw Je(C,"Parenthesis ) expected");$(C),M(C)}return new se(Z)}return z(C)}function z(C){var Z,se;return C.tokenType===x.SYMBOL||C.tokenType===x.DELIMITER&&C.token in E?(se=C.token,M(C),Re(A,se)?Z=new u(A[se]):S.indexOf(se)!==-1?Z=new u(t(se,"number")):Z=new N(se),Z=U(C,Z),Z):ee(C)}function U(C,Z,se){for(var Ee;(C.token==="("||C.token==="["||C.token===".")&&(!se||se.indexOf(C.token)!==-1);)if(Ee=[],C.token==="(")if(qr(Z)||Sn(Z)){if(H(C),M(C),C.token!==")")for(Ee.push(K(C));C.token===",";)M(C),Ee.push(K(C));if(C.token!==")")throw Je(C,"Parenthesis ) expected");$(C),M(C),Z=new c(Z,Ee)}else return Z;else if(C.token==="["){if(H(C),M(C),C.token!=="]")for(Ee.push(K(C));C.token===",";)M(C),Ee.push(K(C));if(C.token!=="]")throw Je(C,"Parenthesis ] expected");$(C),M(C),Z=new n(Z,new m(Ee))}else{if(M(C),C.tokenType!==x.SYMBOL)throw Je(C,"Property name expected after dot");Ee.push(new u(C.token)),M(C);var ze=!0;Z=new n(Z,new m(Ee,ze))}return Z}function ee(C){var Z,se;return C.token==='"'?(se=ue(C),Z=new u(se),Z=U(C,Z),Z):ve(C)}function ue(C){for(var Z="";B(C)!==""&&B(C)!=='"';)B(C)==="\\"&&(Z+=B(C),I(C)),Z+=B(C),I(C);if(M(C),C.token!=='"')throw Je(C,'End of string " expected');return M(C),JSON.parse('"'+Z+'"')}function ve(C){var Z,se;return C.token==="'"?(se=de(C),Z=new u(se),Z=U(C,Z),Z):be(C)}function de(C){for(var Z="";B(C)!==""&&B(C)!=="'";)B(C)==="\\"&&(Z+=B(C),I(C)),Z+=B(C),I(C);if(M(C),C.token!=="'")throw Je(C,"End of string ' expected");return M(C),JSON.parse('"'+Z+'"')}function be(C){var Z,se,Ee,ze;if(C.token==="["){if(H(C),M(C),C.token!=="]"){var ke=pe(C);if(C.token===";"){for(Ee=1,se=[ke];C.token===";";)M(C),se[Ee]=pe(C),Ee++;if(C.token!=="]")throw Je(C,"End of matrix ] expected");$(C),M(C),ze=se[0].items.length;for(var Fr=1;Fr<Ee;Fr++)if(se[Fr].items.length!==ze)throw mr(C,"Column dimensions mismatch ("+se[Fr].items.length+" !== "+ze+")");Z=new i(se)}else{if(C.token!=="]")throw Je(C,"End of matrix ] expected");$(C),M(C),Z=ke}}else $(C),M(C),Z=new i([]);return U(C,Z)}return we(C)}function pe(C){for(var Z=[K(C)],se=1;C.token===",";)M(C),Z[se]=K(C),se++;return new i(Z)}function we(C){if(C.token==="{"){H(C);var Z,se={};do if(M(C),C.token!=="}"){if(C.token==='"')Z=ue(C);else if(C.token==="'")Z=de(C);else if(C.tokenType===x.SYMBOL||C.tokenType===x.DELIMITER&&C.token in E)Z=C.token,M(C);else throw Je(C,"Symbol or string expected as object key");if(C.token!==":")throw Je(C,"Colon : expected after object key");M(C),se[Z]=K(C)}while(C.token===",");if(C.token!=="}")throw Je(C,"Comma , or bracket } expected after object value");$(C),M(C);var Ee=new v(se);return Ee=U(C,Ee),Ee}return _e(C)}function _e(C){var Z;return C.tokenType===x.NUMBER?(Z=C.token,M(C),new u(t(Z,a.number))):Le(C)}function Le(C){var Z;if(C.token==="("){if(H(C),M(C),Z=K(C),C.token!==")")throw Je(C,"Parenthesis ) expected");return $(C),M(C),Z=new p(Z),Z=U(C,Z),Z}return Be(C)}function Be(C){throw C.token===""?Je(C,"Unexpected end of expression"):Je(C,"Value expected")}function ar(C){return C.index-C.token.length+1}function Je(C,Z){var se=ar(C),Ee=new SyntaxError(Z+" (char "+se+")");return Ee.char=se,Ee}function mr(C,Z){var se=ar(C),Ee=new SyntaxError(Z+" (char "+se+")");return Ee.char=se,Ee}return e.addConversion({from:"string",to:"Node",convert:d}),d}),ip="compile",eS=["typed","parse"],rS=q(ip,eS,r=>{var{typed:e,parse:t}=r;return e(ip,{string:function(n){return t(n).compile()},"Array | Matrix":function(n){return je(n,function(i){return t(i).compile()})}})}),op="evaluate",tS=["typed","parse"],nS=q(op,tS,r=>{var{typed:e,parse:t}=r;return e(op,{string:function(n){var i=ea();return t(n).compile().evaluate(i)},"string, Map | Object":function(n,i){return t(n).compile().evaluate(i)},"Array | Matrix":function(n){var i=ea();return je(n,function(o){return t(o).compile().evaluate(i)})},"Array | Matrix, Map | Object":function(n,i){return je(n,function(o){return t(o).compile().evaluate(i)})}})}),aS="Parser",iS=["evaluate"],oS=q(aS,iS,r=>{var{evaluate:e}=r;function t(){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:ea(),writable:!1})}return t.prototype.type="Parser",t.prototype.isParser=!0,t.prototype.evaluate=function(a){return e(a,this.scope)},t.prototype.get=function(a){if(this.scope.has(a))return this.scope.get(a)},t.prototype.getAll=function(){return Fg(this.scope)},t.prototype.getAllAsMap=function(){return this.scope},t.prototype.set=function(a,n){return this.scope.set(a,n),n},t.prototype.remove=function(a){this.scope.delete(a)},t.prototype.clear=function(){this.scope.clear()},t},{isClass:!0}),sp="parser",sS=["typed","Parser"],uS=q(sp,sS,r=>{var{typed:e,Parser:t}=r;return e(sp,{"":function(){return new t}})}),up="lup",lS=["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],cS=q(up,lS,r=>{var{typed:e,matrix:t,abs:a,addScalar:n,divideScalar:i,multiplyScalar:o,subtract:f,larger:l,equalScalar:u,unaryMinus:s,DenseMatrix:c,SparseMatrix:m,Spa:v}=r;return e(up,{DenseMatrix:function(y){return h(y)},SparseMatrix:function(y){return p(y)},Array:function(y){var N=t(y),d=h(N);return{L:d.L.valueOf(),U:d.U.valueOf(),p:d.p}}});function h(g){var y=g._size[0],N=g._size[1],d=Math.min(y,N),w=Ge(g._data),x=[],b=[y,d],E=[],A=[d,N],S,D,T,B=[];for(S=0;S<y;S++)B[S]=S;for(D=0;D<N;D++){if(D>0)for(S=0;S<y;S++){var I=Math.min(S,D),P=0;for(T=0;T<I;T++)P=n(P,o(w[S][T],w[T][D]));w[S][D]=f(w[S][D],P)}var R=D,M=0,F=0;for(S=D;S<y;S++){var H=w[S][D],$=a(H);l($,M)&&(R=S,M=$,F=H)}if(D!==R&&(B[D]=[B[R],B[R]=B[D]][0],c._swapRows(D,R,w)),D<y)for(S=D+1;S<y;S++){var k=w[S][D];u(k,0)||(w[S][D]=i(w[S][D],F))}}for(D=0;D<N;D++)for(S=0;S<y;S++){if(D===0&&(S<N&&(E[S]=[]),x[S]=[]),S<D){S<N&&(E[S][D]=w[S][D]),D<y&&(x[S][D]=0);continue}if(S===D){S<N&&(E[S][D]=w[S][D]),D<y&&(x[S][D]=1);continue}S<N&&(E[S][D]=0),D<y&&(x[S][D]=w[S][D])}var Q=new c({data:x,size:b}),K=new c({data:E,size:A}),L=[];for(S=0,d=B.length;S<d;S++)L[B[S]]=S;return{L:Q,U:K,p:L,toString:function(){return"L: "+this.L.toString()+`
42
42
  U: `+this.U.toString()+`
43
- P: `+this.p}}}function h(y){var b=y._size[0],A=y._size[1],d=Math.min(b,A),w=y._values,x=y._index,g=y._ptr,E=[],N=[],S=[],D=[b,d],T=[],B=[],_=[],L=[d,A],G,C,F,Z=[],$=[];for(G=0;G<b;G++)Z[G]=G,$[G]=G;var U=function(P,K){var ne=$[P],re=$[K];Z[ne]=K,Z[re]=P,$[P]=re,$[K]=ne},Y=function(){var P=new v;C<b&&(S.push(E.length),E.push(1),N.push(C)),_.push(T.length);var K=g[C],ne=g[C+1];for(F=K;F<ne;F++)G=x[F],P.set(Z[G],w[F]);C>0&&P.forEach(0,C-1,function(ce,oe){m._forEachRow(ce,E,N,S,function(Ce,Oe){Ce>ce&&P.accumulate(Ce,o(s(Oe,oe)))})});var re=C,fe=P.get(C),pe=a(fe);P.forEach(C+1,b-1,function(ce,oe){var Ce=a(oe);l(Ce,pe)&&(re=ce,pe=Ce,fe=oe)}),C!==re&&(m._swapRows(C,re,D[1],E,N,S),m._swapRows(C,re,L[1],T,B,_),P.swap(C,re),U(C,re)),P.forEach(0,b-1,function(ce,oe){ce<=C?(T.push(oe),B.push(ce)):(oe=i(oe,fe),u(oe,0)||(E.push(oe),N.push(ce)))})};for(C=0;C<A;C++)Y();return _.push(T.length),S.push(E.length),{L:new m({values:E,index:N,ptr:S,size:D}),U:new m({values:T,index:B,ptr:_,size:L}),p:Z,toString:function(){return"L: "+this.L.toString()+`
43
+ P: `+this.p}}}function p(g){var y=g._size[0],N=g._size[1],d=Math.min(y,N),w=g._values,x=g._index,b=g._ptr,E=[],A=[],S=[],D=[y,d],T=[],B=[],I=[],P=[d,N],R,M,F,H=[],$=[];for(R=0;R<y;R++)H[R]=R,$[R]=R;var k=function(L,j){var ae=$[L],re=$[j];H[ae]=j,H[re]=L,$[L]=re,$[j]=ae},Q=function(){var L=new v;M<y&&(S.push(E.length),E.push(1),A.push(M)),I.push(T.length);var j=b[M],ae=b[M+1];for(F=j;F<ae;F++)R=x[F],L.set(H[R],w[F]);M>0&&L.forEach(0,M-1,function(ce,ie){m._forEachRow(ce,E,A,S,function(Ae,Oe){Ae>ce&&L.accumulate(Ae,s(o(Oe,ie)))})});var re=M,fe=L.get(M),he=a(fe);L.forEach(M+1,y-1,function(ce,ie){var Ae=a(ie);l(Ae,he)&&(re=ce,he=Ae,fe=ie)}),M!==re&&(m._swapRows(M,re,D[1],E,A,S),m._swapRows(M,re,P[1],T,B,I),L.swap(M,re),k(M,re)),L.forEach(0,y-1,function(ce,ie){ce<=M?(T.push(ie),B.push(ce)):(ie=i(ie,fe),u(ie,0)||(E.push(ie),A.push(ce)))})};for(M=0;M<N;M++)Q();return I.push(T.length),S.push(E.length),{L:new m({values:E,index:A,ptr:S,size:D}),U:new m({values:T,index:B,ptr:I,size:P}),p:H,toString:function(){return"L: "+this.L.toString()+`
44
44
  U: `+this.U.toString()+`
45
- P: `+this.p}}}}),Yv="qr",OE=["typed","matrix","zeros","identity","isZero","equal","sign","sqrt","conj","unaryMinus","addScalar","divideScalar","multiplyScalar","subtract","complex"],_E=R(Yv,OE,r=>{var{typed:e,matrix:t,zeros:a,identity:n,isZero:i,equal:s,sign:f,sqrt:l,conj:u,unaryMinus:o,addScalar:c,divideScalar:m,multiplyScalar:v,subtract:p,complex:h}=r;return Ar(e(Yv,{DenseMatrix:function(w){return b(w)},SparseMatrix:function(w){return A()},Array:function(w){var x=t(w),g=b(x);return{Q:g.Q.valueOf(),R:g.R.valueOf()}}}),{_denseQRimpl:y});function y(d){var w=d._size[0],x=d._size[1],g=n([w],"dense"),E=g._data,N=d.clone(),S=N._data,D,T,B,_=a([w],"");for(B=0;B<Math.min(x,w);++B){var L=S[B][B],G=o(s(L,0)?1:f(L)),C=u(G),F=0;for(D=B;D<w;D++)F=c(F,v(S[D][B],u(S[D][B])));var Z=v(G,l(F));if(!i(Z)){var $=p(L,Z);for(_[B]=1,D=B+1;D<w;D++)_[D]=m(S[D][B],$);var U=o(u(m($,Z))),Y=void 0;for(T=B;T<x;T++){for(Y=0,D=B;D<w;D++)Y=c(Y,v(u(_[D]),S[D][T]));for(Y=v(Y,U),D=B;D<w;D++)S[D][T]=v(p(S[D][T],v(_[D],Y)),C)}for(D=0;D<w;D++){for(Y=0,T=B;T<w;T++)Y=c(Y,v(E[D][T],_[T]));for(Y=v(Y,U),T=B;T<w;++T)E[D][T]=m(p(E[D][T],v(Y,u(_[T]))),C)}}}return{Q:g,R:N,toString:function(){return"Q: "+this.Q.toString()+`
46
- R: `+this.R.toString()}}}function b(d){var w=y(d),x=w.R._data;if(d._data.length>0)for(var g=x[0][0].type==="Complex"?h(0):0,E=0;E<x.length;++E)for(var N=0;N<E&&N<(x[0]||[]).length;++N)x[E][N]=g;return w}function A(d){throw new Error("qr not implemented for sparse matrices yet")}});function IE(r,e,t,a){for(var n=r._values,i=r._index,s=r._ptr,f=r._size,l=r._datatype,u=f[0],o=f[1],c=a&&r._values?[]:null,m=[],v=[],p=0,h=0;h<o;h++){v[h]=p;for(var y=t?t[h]:h,b=s[y],A=s[y+1],d=b;d<A;d++){var w=e?e[i[d]]:i[d];m[p]=w,c&&(c[p]=n[d]),p++}}return v[o]=p,r.createSparseMatrix({values:c,index:m,ptr:v,size:[u,o],datatype:l})}function Qv(r,e,t,a,n,i,s){var f=0;for(t[s]=r;f>=0;){var l=t[s+f],u=t[a+l];u===-1?(f--,i[e++]=l):(t[a+l]=t[n+u],++f,t[s+f]=u)}return e}function RE(r,e){if(!r)return null;var t=0,a,n=[],i=[],s=0,f=e,l=2*e;for(a=0;a<e;a++)i[s+a]=-1;for(a=e-1;a>=0;a--)r[a]!==-1&&(i[f+a]=i[s+r[a]],i[s+r[a]]=a);for(a=0;a<e;a++)r[a]===-1&&(t=Qv(a,t,i,s,f,n,l));return n}function qE(r,e){if(!r)return null;var t=r._index,a=r._ptr,n=r._size,i=n[0],s=n[1],f=[],l=[],u=0,o=s,c,m;if(e)for(c=0;c<i;c++)l[o+c]=-1;for(var v=0;v<s;v++){f[v]=-1,l[u+v]=-1;for(var p=a[v],h=a[v+1],y=p;y<h;y++){var b=t[y];for(c=e?l[o+b]:b;c!==-1&&c<v;c=m)m=l[u+c],l[u+c]=v,m===-1&&(f[c]=v);e&&(l[o+b]=v)}}return f}function zE(r,e,t){for(var a=r._values,n=r._index,i=r._ptr,s=r._size,f=s[1],l=0,u=0;u<f;u++){var o=i[u];for(i[u]=l;o<i[u+1];o++)e(n[o],u,a?a[o]:1,t)&&(n[l]=n[o],a&&(a[l]=a[o]),l++)}return i[f]=l,n.splice(l,n.length-l),a&&a.splice(l,a.length-l),l}function fn(r){return-r-2}var PE="csAmd",LE=["add","multiply","transpose"],UE=R(PE,LE,r=>{var{add:e,multiply:t,transpose:a}=r;return function(o,c){if(!c||o<=0||o>3)return null;var m=c._size,v=m[0],p=m[1],h=0,y=Math.max(16,10*Math.sqrt(p));y=Math.min(p-2,y);var b=n(o,c,v,p,y);zE(b,l,null);for(var A=b._index,d=b._ptr,w=d[p],x=[],g=[],E=0,N=p+1,S=2*(p+1),D=3*(p+1),T=4*(p+1),B=5*(p+1),_=6*(p+1),L=7*(p+1),G=x,C=i(p,d,g,E,D,G,S,L,N,_,T,B),F=s(p,d,g,B,T,_,y,N,D,G,S),Z=0,$,U,Y,j,P,K,ne,re,fe,pe,ce,oe,Ce,Oe,Me,$e;F<p;){for(Y=-1;Z<p&&(Y=g[D+Z])===-1;Z++);g[S+Y]!==-1&&(G[g[S+Y]]=-1),g[D+Z]=g[S+Y];var k=g[T+Y],W=g[N+Y];F+=W;var ie=0;g[N+Y]=-W;var V=d[Y],Q=k===0?V:w,te=Q;for(j=1;j<=k+1;j++){for(j>k?(K=Y,ne=V,re=g[E+Y]-k):(K=A[V++],ne=d[K],re=g[E+K]),P=1;P<=re;P++)$=A[ne++],!((fe=g[N+$])<=0)&&(ie+=fe,g[N+$]=-fe,A[te++]=$,g[S+$]!==-1&&(G[g[S+$]]=G[$]),G[$]!==-1?g[S+G[$]]=g[S+$]:g[D+g[B+$]]=g[S+$]);K!==Y&&(d[K]=fn(Y),g[_+K]=0)}for(k!==0&&(w=te),g[B+Y]=ie,d[Y]=Q,g[E+Y]=te-Q,g[T+Y]=-2,C=f(C,h,g,_,p),pe=Q;pe<te;pe++)if($=A[pe],!((ce=g[T+$])<=0)){fe=-g[N+$];var ge=C-fe;for(V=d[$],oe=d[$]+ce-1;V<=oe;V++)K=A[V],g[_+K]>=C?g[_+K]-=fe:g[_+K]!==0&&(g[_+K]=g[B+K]+ge)}for(pe=Q;pe<te;pe++){for($=A[pe],oe=d[$],Ce=oe+g[T+$]-1,Oe=oe,Me=0,$e=0,V=oe;V<=Ce;V++)if(K=A[V],g[_+K]!==0){var he=g[_+K]-C;he>0?($e+=he,A[Oe++]=K,Me+=K):(d[K]=fn(Y),g[_+K]=0)}g[T+$]=Oe-oe+1;var q=Oe,z=oe+g[E+$];for(V=Ce+1;V<z;V++){U=A[V];var ee=g[N+U];ee<=0||($e+=ee,A[Oe++]=U,Me+=U)}$e===0?(d[$]=fn(Y),fe=-g[N+$],ie-=fe,W+=fe,F+=fe,g[N+$]=0,g[T+$]=-1):(g[B+$]=Math.min(g[B+$],$e),A[Oe]=A[q],A[q]=A[oe],A[oe]=Y,g[E+$]=Oe-oe+1,Me=(Me<0?-Me:Me)%p,g[S+$]=g[L+Me],g[L+Me]=$,G[$]=Me)}for(g[B+Y]=ie,h=Math.max(h,ie),C=f(C+h,h,g,_,p),pe=Q;pe<te;pe++)if($=A[pe],!(g[N+$]>=0))for(Me=G[$],$=g[L+Me],g[L+Me]=-1;$!==-1&&g[S+$]!==-1;$=g[S+$],C++){for(re=g[E+$],ce=g[T+$],V=d[$]+1;V<=d[$]+re-1;V++)g[_+A[V]]=C;var ue=$;for(U=g[S+$];U!==-1;){var me=g[E+U]===re&&g[T+U]===ce;for(V=d[U]+1;me&&V<=d[U]+re-1;V++)g[_+A[V]]!==C&&(me=0);me?(d[U]=fn($),g[N+$]+=g[N+U],g[N+U]=0,g[T+U]=-1,U=g[S+U],g[S+ue]=U):(ue=U,U=g[S+U])}}for(V=Q,pe=Q;pe<te;pe++)$=A[pe],!((fe=-g[N+$])<=0)&&(g[N+$]=fe,$e=g[B+$]+ie-fe,$e=Math.min($e,p-F-fe),g[D+$e]!==-1&&(G[g[D+$e]]=$),g[S+$]=g[D+$e],G[$]=-1,g[D+$e]=$,Z=Math.min(Z,$e),g[B+$]=$e,A[V++]=$);g[N+Y]=W,(g[E+Y]=V-Q)===0&&(d[Y]=-1,g[_+Y]=0),k!==0&&(w=V)}for($=0;$<p;$++)d[$]=fn(d[$]);for(U=0;U<=p;U++)g[D+U]=-1;for(U=p;U>=0;U--)g[N+U]>0||(g[S+U]=g[D+d[U]],g[D+d[U]]=U);for(K=p;K>=0;K--)g[N+K]<=0||d[K]!==-1&&(g[S+K]=g[D+d[K]],g[D+d[K]]=K);for(Y=0,$=0;$<=p;$++)d[$]===-1&&(Y=Qv($,Y,g,D,S,x,_));return x.splice(x.length-1,1),x};function n(u,o,c,m,v){var p=a(o);if(u===1&&m===c)return e(o,p);if(u===2){for(var h=p._index,y=p._ptr,b=0,A=0;A<c;A++){var d=y[A];if(y[A]=b,!(y[A+1]-d>v))for(var w=y[A+1];d<w;d++)h[b++]=h[d]}return y[c]=b,o=a(p),t(p,o)}return t(p,o)}function i(u,o,c,m,v,p,h,y,b,A,d,w){for(var x=0;x<u;x++)c[m+x]=o[x+1]-o[x];c[m+u]=0;for(var g=0;g<=u;g++)c[v+g]=-1,p[g]=-1,c[h+g]=-1,c[y+g]=-1,c[b+g]=1,c[A+g]=1,c[d+g]=0,c[w+g]=c[m+g];var E=f(0,0,c,A,u);return c[d+u]=-2,o[u]=-1,c[A+u]=0,E}function s(u,o,c,m,v,p,h,y,b,A,d){for(var w=0,x=0;x<u;x++){var g=c[m+x];if(g===0)c[v+x]=-2,w++,o[x]=-1,c[p+x]=0;else if(g>h)c[y+x]=0,c[v+x]=-1,w++,o[x]=fn(u),c[y+u]++;else{var E=c[b+g];E!==-1&&(A[E]=x),c[d+x]=c[b+g],c[b+g]=x}}return w}function f(u,o,c,m,v){if(u<2||u+o<0){for(var p=0;p<v;p++)c[m+p]!==0&&(c[m+p]=1);u=2}return u}function l(u,o){return u!==o}});function kE(r,e,t,a,n,i,s){var f,l,u=0,o;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,o=r;else{for(u=2,o=c;o!==t[s+o];o=t[s+o]);for(f=c;f!==o;f=l)l=t[s+f],t[s+f]=o}return{jleaf:u,q:o}}var VE="csCounts",GE=["transpose"],HE=R(VE,GE,r=>{var{transpose:e}=r;return function(t,a,n,i){if(!t||!a||!n)return null;var s=t._size,f=s[0],l=s[1],u,o,c,m,v,p,h,y=4*l+(i?l+f+1:0),b=[],A=0,d=l,w=2*l,x=3*l,g=4*l,E=5*l+1;for(c=0;c<y;c++)b[c]=-1;var N=[],S=e(t),D=S._index,T=S._ptr;for(c=0;c<l;c++)for(o=n[c],N[o]=b[x+o]===-1?1:0;o!==-1&&b[x+o]===-1;o=a[o])b[x+o]=c;if(i){for(c=0;c<l;c++)b[n[c]]=c;for(u=0;u<f;u++){for(c=l,p=T[u],h=T[u+1],v=p;v<h;v++)c=Math.min(c,b[D[v]]);b[E+u]=b[g+c],b[g+c]=u}}for(u=0;u<l;u++)b[A+u]=u;for(c=0;c<l;c++){for(o=n[c],a[o]!==-1&&N[a[o]]--,m=i?b[g+c]:o;m!==-1;m=i?b[E+m]:-1)for(v=T[m];v<T[m+1];v++){u=D[v];var B=kE(u,o,b,x,d,w,A);B.jleaf>=1&&N[o]++,B.jleaf===2&&N[B.q]--}a[o]!==-1&&(b[A+o]=a[o])}for(o=0;o<l;o++)a[o]!==-1&&(N[a[o]]+=N[o]);return N}}),ZE="csSqr",JE=["add","multiply","transpose"],WE=R(ZE,JE,r=>{var{add:e,multiply:t,transpose:a}=r,n=UE({add:e,multiply:t,transpose:a}),i=HE({transpose:a});return function(l,u,o){var c=u._ptr,m=u._size,v=m[1],p,h={};if(h.q=n(l,u),l&&!h.q)return null;if(o){var y=l?IE(u,null,h.q,0):u;h.parent=qE(y,1);var b=RE(h.parent,v);if(h.cp=i(y,h.parent,b,1),y&&h.parent&&h.cp&&s(y,h))for(h.unz=0,p=0;p<v;p++)h.unz+=h.cp[p]}else h.unz=4*c[v]+v,h.lnz=h.unz;return h};function s(f,l){var u=f._ptr,o=f._index,c=f._size,m=c[0],v=c[1];l.pinv=[],l.leftmost=[];var p=l.parent,h=l.pinv,y=l.leftmost,b=[],A=0,d=m,w=m+v,x=m+2*v,g,E,N,S,D;for(E=0;E<v;E++)b[d+E]=-1,b[w+E]=-1,b[x+E]=0;for(g=0;g<m;g++)y[g]=-1;for(E=v-1;E>=0;E--)for(S=u[E],D=u[E+1],N=S;N<D;N++)y[o[N]]=E;for(g=m-1;g>=0;g--)h[g]=-1,E=y[g],E!==-1&&(b[x+E]++===0&&(b[w+E]=g),b[A+g]=b[d+E],b[d+E]=g);for(l.lnz=0,l.m2=m,E=0;E<v;E++)if(g=b[d+E],l.lnz++,g<0&&(g=l.m2++),h[g]=E,!(--x[E]<=0)){l.lnz+=b[x+E];var T=p[E];T!==-1&&(b[x+T]===0&&(b[w+T]=b[w+E]),b[A+b[w+E]]=b[d+T],b[d+T]=b[A+g],b[x+T]+=b[x+E])}for(g=0;g<m;g++)h[g]<0&&(h[g]=E++);return!0}});function ys(r,e){return r[e]<0}function Kv(r,e){r[e]=fn(r[e])}function jv(r){return r<0?fn(r):r}function XE(r,e,t,a,n){var i=e._index,s=e._ptr,f=e._size,l=f[1],u,o,c,m=0;for(a[0]=r;m>=0;){r=a[m];var v=n?n[r]:r;ys(s,r)||(Kv(s,r),a[l+m]=v<0?0:jv(s[v]));var p=1;for(o=a[l+m],c=v<0?0:jv(s[v+1]);o<c;o++)if(u=i[o],!ys(s,u)){a[l+m]=o,a[++m]=u,p=0;break}p&&(m--,a[--t]=r)}return t}function YE(r,e,t,a,n){var i=r._ptr,s=r._size,f=e._index,l=e._ptr,u=s[1],o,c,m,v=u;for(c=l[t],m=l[t+1],o=c;o<m;o++){var p=f[o];ys(i,p)||(v=XE(p,r,v,a,n))}for(o=v;o<u;o++)Kv(i,a[o]);return v}var QE="csSpsolve",KE=["divideScalar","multiply","subtract"],jE=R(QE,KE,r=>{var{divideScalar:e,multiply:t,subtract:a}=r;return function(i,s,f,l,u,o,c){var m=i._values,v=i._index,p=i._ptr,h=i._size,y=h[1],b=s._values,A=s._index,d=s._ptr,w,x,g,E,N=YE(i,s,f,l,o);for(w=N;w<y;w++)u[l[w]]=0;for(x=d[f],g=d[f+1],w=x;w<g;w++)u[A[w]]=b[w];for(var S=N;S<y;S++){var D=l[S],T=o?o[D]:D;if(!(T<0))for(x=p[T],g=p[T+1],u[D]=e(u[D],m[c?x:g-1]),w=c?x+1:x,E=c?g:g-1;w<E;w++){var B=v[w];u[B]=a(u[B],t(m[w],u[D]))}}return N}}),eS="csLu",rS=["abs","divideScalar","multiply","subtract","larger","largerEq","SparseMatrix"],tS=R(eS,rS,r=>{var{abs:e,divideScalar:t,multiply:a,subtract:n,larger:i,largerEq:s,SparseMatrix:f}=r,l=jE({divideScalar:t,multiply:a,subtract:n});return function(o,c,m){if(!o)return null;var v=o._size,p=v[1],h,y=100,b=100;c&&(h=c.q,y=c.lnz||y,b=c.unz||b);var A=[],d=[],w=[],x=new f({values:A,index:d,ptr:w,size:[p,p]}),g=[],E=[],N=[],S=new f({values:g,index:E,ptr:N,size:[p,p]}),D=[],T,B,_=[],L=[];for(T=0;T<p;T++)_[T]=0,D[T]=-1,w[T+1]=0;y=0,b=0;for(var G=0;G<p;G++){w[G]=y,N[G]=b;var C=h?h[G]:G,F=l(x,o,C,L,_,D,1),Z=-1,$=-1;for(B=F;B<p;B++)if(T=L[B],D[T]<0){var U=e(_[T]);i(U,$)&&($=U,Z=T)}else E[b]=D[T],g[b++]=_[T];if(Z===-1||$<=0)return null;D[C]<0&&s(e(_[C]),a($,m))&&(Z=C);var Y=_[Z];for(E[b]=G,g[b++]=Y,D[Z]=G,d[y]=Z,A[y++]=1,B=F;B<p;B++)T=L[B],D[T]<0&&(d[y]=T,A[y++]=t(_[T],Y)),_[T]=0}for(w[p]=y,N[p]=b,B=0;B<y;B++)d[B]=D[d[B]];return A.splice(y,A.length-y),d.splice(y,d.length-y),g.splice(b,g.length-b),E.splice(b,E.length-b),{L:x,U:S,pinv:D}}}),ep="slu",nS=["typed","abs","add","multiply","transpose","divideScalar","subtract","larger","largerEq","SparseMatrix"],aS=R(ep,nS,r=>{var{typed:e,abs:t,add:a,multiply:n,transpose:i,divideScalar:s,subtract:f,larger:l,largerEq:u,SparseMatrix:o}=r,c=WE({add:a,multiply:n,transpose:i}),m=tS({abs:t,divideScalar:s,multiply:n,subtract:f,larger:l,largerEq:u,SparseMatrix:o});return e(ep,{"SparseMatrix, number, number":function(p,h,y){if(!qe(h)||h<0||h>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(y<0||y>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var b=c(h,p,!1),A=m(p,b,y);return{L:A.L,U:A.U,p:A.pinv,q:b.q,toString:function(){return"L: "+this.L.toString()+`
45
+ P: `+this.p}}}}),lp="qr",fS=["typed","matrix","zeros","identity","isZero","equal","sign","sqrt","conj","unaryMinus","addScalar","divideScalar","multiplyScalar","subtract","complex"],mS=q(lp,fS,r=>{var{typed:e,matrix:t,zeros:a,identity:n,isZero:i,equal:o,sign:f,sqrt:l,conj:u,unaryMinus:s,addScalar:c,divideScalar:m,multiplyScalar:v,subtract:h,complex:p}=r;return Sr(e(lp,{DenseMatrix:function(w){return y(w)},SparseMatrix:function(w){return N()},Array:function(w){var x=t(w),b=y(x);return{Q:b.Q.valueOf(),R:b.R.valueOf()}}}),{_denseQRimpl:g});function g(d){var w=d._size[0],x=d._size[1],b=n([w],"dense"),E=b._data,A=d.clone(),S=A._data,D,T,B,I=a([w],"");for(B=0;B<Math.min(x,w);++B){var P=S[B][B],R=s(o(P,0)?1:f(P)),M=u(R),F=0;for(D=B;D<w;D++)F=c(F,v(S[D][B],u(S[D][B])));var H=v(R,l(F));if(!i(H)){var $=h(P,H);for(I[B]=1,D=B+1;D<w;D++)I[D]=m(S[D][B],$);var k=s(u(m($,H))),Q=void 0;for(T=B;T<x;T++){for(Q=0,D=B;D<w;D++)Q=c(Q,v(u(I[D]),S[D][T]));for(Q=v(Q,k),D=B;D<w;D++)S[D][T]=v(h(S[D][T],v(I[D],Q)),M)}for(D=0;D<w;D++){for(Q=0,T=B;T<w;T++)Q=c(Q,v(E[D][T],I[T]));for(Q=v(Q,k),T=B;T<w;++T)E[D][T]=m(h(E[D][T],v(Q,u(I[T]))),M)}}}return{Q:b,R:A,toString:function(){return"Q: "+this.Q.toString()+`
46
+ R: `+this.R.toString()}}}function y(d){var w=g(d),x=w.R._data;if(d._data.length>0)for(var b=x[0][0].type==="Complex"?p(0):0,E=0;E<x.length;++E)for(var A=0;A<E&&A<(x[0]||[]).length;++A)x[E][A]=b;return w}function N(d){throw new Error("qr not implemented for sparse matrices yet")}});function vS(r,e,t,a){for(var n=r._values,i=r._index,o=r._ptr,f=r._size,l=r._datatype,u=f[0],s=f[1],c=a&&r._values?[]:null,m=[],v=[],h=0,p=0;p<s;p++){v[p]=h;for(var g=t?t[p]:p,y=o[g],N=o[g+1],d=y;d<N;d++){var w=e?e[i[d]]:i[d];m[h]=w,c&&(c[h]=n[d]),h++}}return v[s]=h,r.createSparseMatrix({values:c,index:m,ptr:v,size:[u,s],datatype:l})}function cp(r,e,t,a,n,i,o){var f=0;for(t[o]=r;f>=0;){var l=t[o+f],u=t[a+l];u===-1?(f--,i[e++]=l):(t[a+l]=t[n+u],++f,t[o+f]=u)}return e}function pS(r,e){if(!r)return null;var t=0,a,n=[],i=[],o=0,f=e,l=2*e;for(a=0;a<e;a++)i[o+a]=-1;for(a=e-1;a>=0;a--)r[a]!==-1&&(i[f+a]=i[o+r[a]],i[o+r[a]]=a);for(a=0;a<e;a++)r[a]===-1&&(t=cp(a,t,i,o,f,n,l));return n}function hS(r,e){if(!r)return null;var t=r._index,a=r._ptr,n=r._size,i=n[0],o=n[1],f=[],l=[],u=0,s=o,c,m;if(e)for(c=0;c<i;c++)l[s+c]=-1;for(var v=0;v<o;v++){f[v]=-1,l[u+v]=-1;for(var h=a[v],p=a[v+1],g=h;g<p;g++){var y=t[g];for(c=e?l[s+y]:y;c!==-1&&c<v;c=m)m=l[u+c],l[u+c]=v,m===-1&&(f[c]=v);e&&(l[s+y]=v)}}return f}function dS(r,e,t){for(var a=r._values,n=r._index,i=r._ptr,o=r._size,f=o[1],l=0,u=0;u<f;u++){var s=i[u];for(i[u]=l;s<i[u+1];s++)e(n[s],u,a?a[s]:1,t)&&(n[l]=n[s],a&&(a[l]=a[s]),l++)}return i[f]=l,n.splice(l,n.length-l),a&&a.splice(l,a.length-l),l}function vn(r){return-r-2}var gS="csAmd",yS=["add","multiply","transpose"],bS=q(gS,yS,r=>{var{add:e,multiply:t,transpose:a}=r;return function(s,c){if(!c||s<=0||s>3)return null;var m=c._size,v=m[0],h=m[1],p=0,g=Math.max(16,10*Math.sqrt(h));g=Math.min(h-2,g);var y=n(s,c,v,h,g);dS(y,l,null);for(var N=y._index,d=y._ptr,w=d[h],x=[],b=[],E=0,A=h+1,S=2*(h+1),D=3*(h+1),T=4*(h+1),B=5*(h+1),I=6*(h+1),P=7*(h+1),R=x,M=i(h,d,b,E,D,R,S,P,A,I,T,B),F=o(h,d,b,B,T,I,g,A,D,R,S),H=0,$,k,Q,K,L,j,ae,re,fe,he,ce,ie,Ae,Oe,Ce,$e;F<h;){for(Q=-1;H<h&&(Q=b[D+H])===-1;H++);b[S+Q]!==-1&&(R[b[S+Q]]=-1),b[D+H]=b[S+Q];var V=b[T+Q],X=b[A+Q];F+=X;var oe=0;b[A+Q]=-X;var G=d[Q],Y=V===0?G:w,te=Y;for(K=1;K<=V+1;K++){for(K>V?(j=Q,ae=G,re=b[E+Q]-V):(j=N[G++],ae=d[j],re=b[E+j]),L=1;L<=re;L++)$=N[ae++],!((fe=b[A+$])<=0)&&(oe+=fe,b[A+$]=-fe,N[te++]=$,b[S+$]!==-1&&(R[b[S+$]]=R[$]),R[$]!==-1?b[S+R[$]]=b[S+$]:b[D+b[B+$]]=b[S+$]);j!==Q&&(d[j]=vn(Q),b[I+j]=0)}for(V!==0&&(w=te),b[B+Q]=oe,d[Q]=Y,b[E+Q]=te-Y,b[T+Q]=-2,M=f(M,p,b,I,h),he=Y;he<te;he++)if($=N[he],!((ce=b[T+$])<=0)){fe=-b[A+$];var ye=M-fe;for(G=d[$],ie=d[$]+ce-1;G<=ie;G++)j=N[G],b[I+j]>=M?b[I+j]-=fe:b[I+j]!==0&&(b[I+j]=b[B+j]+ye)}for(he=Y;he<te;he++){for($=N[he],ie=d[$],Ae=ie+b[T+$]-1,Oe=ie,Ce=0,$e=0,G=ie;G<=Ae;G++)if(j=N[G],b[I+j]!==0){var me=b[I+j]-M;me>0?($e+=me,N[Oe++]=j,Ce+=j):(d[j]=vn(Q),b[I+j]=0)}b[T+$]=Oe-ie+1;var z=Oe,U=ie+b[E+$];for(G=Ae+1;G<U;G++){k=N[G];var ee=b[A+k];ee<=0||($e+=ee,N[Oe++]=k,Ce+=k)}$e===0?(d[$]=vn(Q),fe=-b[A+$],oe-=fe,X+=fe,F+=fe,b[A+$]=0,b[T+$]=-1):(b[B+$]=Math.min(b[B+$],$e),N[Oe]=N[z],N[z]=N[ie],N[ie]=Q,b[E+$]=Oe-ie+1,Ce=(Ce<0?-Ce:Ce)%h,b[S+$]=b[P+Ce],b[P+Ce]=$,R[$]=Ce)}for(b[B+Q]=oe,p=Math.max(p,oe),M=f(M+p,p,b,I,h),he=Y;he<te;he++)if($=N[he],!(b[A+$]>=0))for(Ce=R[$],$=b[P+Ce],b[P+Ce]=-1;$!==-1&&b[S+$]!==-1;$=b[S+$],M++){for(re=b[E+$],ce=b[T+$],G=d[$]+1;G<=d[$]+re-1;G++)b[I+N[G]]=M;var ue=$;for(k=b[S+$];k!==-1;){var ve=b[E+k]===re&&b[T+k]===ce;for(G=d[k]+1;ve&&G<=d[k]+re-1;G++)b[I+N[G]]!==M&&(ve=0);ve?(d[k]=vn($),b[A+$]+=b[A+k],b[A+k]=0,b[T+k]=-1,k=b[S+k],b[S+ue]=k):(ue=k,k=b[S+k])}}for(G=Y,he=Y;he<te;he++)$=N[he],!((fe=-b[A+$])<=0)&&(b[A+$]=fe,$e=b[B+$]+oe-fe,$e=Math.min($e,h-F-fe),b[D+$e]!==-1&&(R[b[D+$e]]=$),b[S+$]=b[D+$e],R[$]=-1,b[D+$e]=$,H=Math.min(H,$e),b[B+$]=$e,N[G++]=$);b[A+Q]=X,(b[E+Q]=G-Y)===0&&(d[Q]=-1,b[I+Q]=0),V!==0&&(w=G)}for($=0;$<h;$++)d[$]=vn(d[$]);for(k=0;k<=h;k++)b[D+k]=-1;for(k=h;k>=0;k--)b[A+k]>0||(b[S+k]=b[D+d[k]],b[D+d[k]]=k);for(j=h;j>=0;j--)b[A+j]<=0||d[j]!==-1&&(b[S+j]=b[D+d[j]],b[D+d[j]]=j);for(Q=0,$=0;$<=h;$++)d[$]===-1&&(Q=cp($,Q,b,D,S,x,I));return x.splice(x.length-1,1),x};function n(u,s,c,m,v){var h=a(s);if(u===1&&m===c)return e(s,h);if(u===2){for(var p=h._index,g=h._ptr,y=0,N=0;N<c;N++){var d=g[N];if(g[N]=y,!(g[N+1]-d>v))for(var w=g[N+1];d<w;d++)p[y++]=p[d]}return g[c]=y,s=a(h),t(h,s)}return t(h,s)}function i(u,s,c,m,v,h,p,g,y,N,d,w){for(var x=0;x<u;x++)c[m+x]=s[x+1]-s[x];c[m+u]=0;for(var b=0;b<=u;b++)c[v+b]=-1,h[b]=-1,c[p+b]=-1,c[g+b]=-1,c[y+b]=1,c[N+b]=1,c[d+b]=0,c[w+b]=c[m+b];var E=f(0,0,c,N,u);return c[d+u]=-2,s[u]=-1,c[N+u]=0,E}function o(u,s,c,m,v,h,p,g,y,N,d){for(var w=0,x=0;x<u;x++){var b=c[m+x];if(b===0)c[v+x]=-2,w++,s[x]=-1,c[h+x]=0;else if(b>p)c[g+x]=0,c[v+x]=-1,w++,s[x]=vn(u),c[g+u]++;else{var E=c[y+b];E!==-1&&(N[E]=x),c[d+x]=c[y+b],c[y+b]=x}}return w}function f(u,s,c,m,v){if(u<2||u+s<0){for(var h=0;h<v;h++)c[m+h]!==0&&(c[m+h]=1);u=2}return u}function l(u,s){return u!==s}});function xS(r,e,t,a,n,i,o){var f,l,u=0,s;if(r<=e||t[a+e]<=t[n+r])return-1;t[n+r]=t[a+e];var c=t[i+r];if(t[i+r]=e,c===-1)u=1,s=r;else{for(u=2,s=c;s!==t[o+s];s=t[o+s]);for(f=c;f!==s;f=l)l=t[o+f],t[o+f]=s}return{jleaf:u,q:s}}var wS="csCounts",NS=["transpose"],DS=q(wS,NS,r=>{var{transpose:e}=r;return function(t,a,n,i){if(!t||!a||!n)return null;var o=t._size,f=o[0],l=o[1],u,s,c,m,v,h,p,g=4*l+(i?l+f+1:0),y=[],N=0,d=l,w=2*l,x=3*l,b=4*l,E=5*l+1;for(c=0;c<g;c++)y[c]=-1;var A=[],S=e(t),D=S._index,T=S._ptr;for(c=0;c<l;c++)for(s=n[c],A[s]=y[x+s]===-1?1:0;s!==-1&&y[x+s]===-1;s=a[s])y[x+s]=c;if(i){for(c=0;c<l;c++)y[n[c]]=c;for(u=0;u<f;u++){for(c=l,h=T[u],p=T[u+1],v=h;v<p;v++)c=Math.min(c,y[D[v]]);y[E+u]=y[b+c],y[b+c]=u}}for(u=0;u<l;u++)y[N+u]=u;for(c=0;c<l;c++){for(s=n[c],a[s]!==-1&&A[a[s]]--,m=i?y[b+c]:s;m!==-1;m=i?y[E+m]:-1)for(v=T[m];v<T[m+1];v++){u=D[v];var B=xS(u,s,y,x,d,w,N);B.jleaf>=1&&A[s]++,B.jleaf===2&&A[B.q]--}a[s]!==-1&&(y[N+s]=a[s])}for(s=0;s<l;s++)a[s]!==-1&&(A[a[s]]+=A[s]);return A}}),AS="csSqr",ES=["add","multiply","transpose"],SS=q(AS,ES,r=>{var{add:e,multiply:t,transpose:a}=r,n=bS({add:e,multiply:t,transpose:a}),i=DS({transpose:a});return function(l,u,s){var c=u._ptr,m=u._size,v=m[1],h,p={};if(p.q=n(l,u),l&&!p.q)return null;if(s){var g=l?vS(u,null,p.q,0):u;p.parent=hS(g,1);var y=pS(p.parent,v);if(p.cp=i(g,p.parent,y,1),g&&p.parent&&p.cp&&o(g,p))for(p.unz=0,h=0;h<v;h++)p.unz+=p.cp[h]}else p.unz=4*c[v]+v,p.lnz=p.unz;return p};function o(f,l){var u=f._ptr,s=f._index,c=f._size,m=c[0],v=c[1];l.pinv=[],l.leftmost=[];var h=l.parent,p=l.pinv,g=l.leftmost,y=[],N=0,d=m,w=m+v,x=m+2*v,b,E,A,S,D;for(E=0;E<v;E++)y[d+E]=-1,y[w+E]=-1,y[x+E]=0;for(b=0;b<m;b++)g[b]=-1;for(E=v-1;E>=0;E--)for(S=u[E],D=u[E+1],A=S;A<D;A++)g[s[A]]=E;for(b=m-1;b>=0;b--)p[b]=-1,E=g[b],E!==-1&&(y[x+E]++===0&&(y[w+E]=b),y[N+b]=y[d+E],y[d+E]=b);for(l.lnz=0,l.m2=m,E=0;E<v;E++)if(b=y[d+E],l.lnz++,b<0&&(b=l.m2++),p[b]=E,!(--x[E]<=0)){l.lnz+=y[x+E];var T=h[E];T!==-1&&(y[x+T]===0&&(y[w+T]=y[w+E]),y[N+y[w+E]]=y[d+T],y[d+T]=y[N+b],y[x+T]+=y[x+E])}for(b=0;b<m;b++)p[b]<0&&(p[b]=E++);return!0}});function Ds(r,e){return r[e]<0}function fp(r,e){r[e]=vn(r[e])}function mp(r){return r<0?vn(r):r}function CS(r,e,t,a,n){var i=e._index,o=e._ptr,f=e._size,l=f[1],u,s,c,m=0;for(a[0]=r;m>=0;){r=a[m];var v=n?n[r]:r;Ds(o,r)||(fp(o,r),a[l+m]=v<0?0:mp(o[v]));var h=1;for(s=a[l+m],c=v<0?0:mp(o[v+1]);s<c;s++)if(u=i[s],!Ds(o,u)){a[l+m]=s,a[++m]=u,h=0;break}h&&(m--,a[--t]=r)}return t}function MS(r,e,t,a,n){var i=r._ptr,o=r._size,f=e._index,l=e._ptr,u=o[1],s,c,m,v=u;for(c=l[t],m=l[t+1],s=c;s<m;s++){var h=f[s];Ds(i,h)||(v=CS(h,r,v,a,n))}for(s=v;s<u;s++)fp(i,a[s]);return v}var FS="csSpsolve",TS=["divideScalar","multiply","subtract"],BS=q(FS,TS,r=>{var{divideScalar:e,multiply:t,subtract:a}=r;return function(i,o,f,l,u,s,c){var m=i._values,v=i._index,h=i._ptr,p=i._size,g=p[1],y=o._values,N=o._index,d=o._ptr,w,x,b,E,A=MS(i,o,f,l,s);for(w=A;w<g;w++)u[l[w]]=0;for(x=d[f],b=d[f+1],w=x;w<b;w++)u[N[w]]=y[w];for(var S=A;S<g;S++){var D=l[S],T=s?s[D]:D;if(!(T<0))for(x=h[T],b=h[T+1],u[D]=e(u[D],m[c?x:b-1]),w=c?x+1:x,E=c?b:b-1;w<E;w++){var B=v[w];u[B]=a(u[B],t(m[w],u[D]))}}return A}}),$S="csLu",OS=["abs","divideScalar","multiply","subtract","larger","largerEq","SparseMatrix"],IS=q($S,OS,r=>{var{abs:e,divideScalar:t,multiply:a,subtract:n,larger:i,largerEq:o,SparseMatrix:f}=r,l=BS({divideScalar:t,multiply:a,subtract:n});return function(s,c,m){if(!s)return null;var v=s._size,h=v[1],p,g=100,y=100;c&&(p=c.q,g=c.lnz||g,y=c.unz||y);var N=[],d=[],w=[],x=new f({values:N,index:d,ptr:w,size:[h,h]}),b=[],E=[],A=[],S=new f({values:b,index:E,ptr:A,size:[h,h]}),D=[],T,B,I=[],P=[];for(T=0;T<h;T++)I[T]=0,D[T]=-1,w[T+1]=0;g=0,y=0;for(var R=0;R<h;R++){w[R]=g,A[R]=y;var M=p?p[R]:R,F=l(x,s,M,P,I,D,1),H=-1,$=-1;for(B=F;B<h;B++)if(T=P[B],D[T]<0){var k=e(I[T]);i(k,$)&&($=k,H=T)}else E[y]=D[T],b[y++]=I[T];if(H===-1||$<=0)return null;D[M]<0&&o(e(I[M]),a($,m))&&(H=M);var Q=I[H];for(E[y]=R,b[y++]=Q,D[H]=R,d[g]=H,N[g++]=1,B=F;B<h;B++)T=P[B],D[T]<0&&(d[g]=T,N[g++]=t(I[T],Q)),I[T]=0}for(w[h]=g,A[h]=y,B=0;B<g;B++)d[B]=D[d[B]];return N.splice(g,N.length-g),d.splice(g,d.length-g),b.splice(y,b.length-y),E.splice(y,E.length-y),{L:x,U:S,pinv:D}}}),vp="slu",RS=["typed","abs","add","multiply","transpose","divideScalar","subtract","larger","largerEq","SparseMatrix"],_S=q(vp,RS,r=>{var{typed:e,abs:t,add:a,multiply:n,transpose:i,divideScalar:o,subtract:f,larger:l,largerEq:u,SparseMatrix:s}=r,c=SS({add:a,multiply:n,transpose:i}),m=IS({abs:t,divideScalar:o,multiply:n,subtract:f,larger:l,largerEq:u,SparseMatrix:s});return e(vp,{"SparseMatrix, number, number":function(h,p,g){if(!qe(p)||p<0||p>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(g<0||g>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var y=c(p,h,!1),N=m(h,y,g);return{L:N.L,U:N.U,p:N.pinv,q:y.q,toString:function(){return"L: "+this.L.toString()+`
47
47
  U: `+this.U.toString()+`
48
48
  p: `+this.p.toString()+(this.q?`
49
49
  q: `+this.q.toString():"")+`
50
- `}}}})});function rp(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 tp="lusolve",iS=["typed","matrix","lup","slu","usolve","lsolve","DenseMatrix"],oS=R(tp,iS,r=>{var{typed:e,matrix:t,lup:a,slu:n,usolve:i,lsolve:s,DenseMatrix:f}=r,l=ka({DenseMatrix:f});return e(tp,{"Array, Array | Matrix":function(m,v){m=t(m);var p=a(m),h=o(p.L,p.U,p.p,null,v);return h.valueOf()},"DenseMatrix, Array | Matrix":function(m,v){var p=a(m);return o(p.L,p.U,p.p,null,v)},"SparseMatrix, Array | Matrix":function(m,v){var p=a(m);return o(p.L,p.U,p.p,null,v)},"SparseMatrix, Array | Matrix, number, number":function(m,v,p,h){var y=n(m,p,h);return o(y.L,y.U,y.p,y.q,v)},"Object, Array | Matrix":function(m,v){return o(m.L,m.U,m.p,m.q,v)}});function u(c){if(He(c))return c;if(ur(c))return t(c);throw new TypeError("Invalid Matrix LU decomposition")}function o(c,m,v,p,h){c=u(c),m=u(m),v&&(h=l(c,h,!0),h._data=rp(v,h._data));var y=s(c,h),b=i(m,y);return p&&(b._data=rp(p,b._data)),b}}),sS="Help",uS=["parse"],lS=R(sS,uS,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=`
50
+ `}}}})});function pp(r,e){var t,a=e.length,n=[];if(r)for(t=0;t<a;t++)n[r[t]]=e[t];else for(t=0;t<a;t++)n[t]=e[t];return n}var hp="lusolve",qS=["typed","matrix","lup","slu","usolve","lsolve","DenseMatrix"],zS=q(hp,qS,r=>{var{typed:e,matrix:t,lup:a,slu:n,usolve:i,lsolve:o,DenseMatrix:f}=r,l=Za({DenseMatrix:f});return e(hp,{"Array, Array | Matrix":function(m,v){m=t(m);var h=a(m),p=s(h.L,h.U,h.p,null,v);return p.valueOf()},"DenseMatrix, Array | Matrix":function(m,v){var h=a(m);return s(h.L,h.U,h.p,null,v)},"SparseMatrix, Array | Matrix":function(m,v){var h=a(m);return s(h.L,h.U,h.p,null,v)},"SparseMatrix, Array | Matrix, number, number":function(m,v,h,p){var g=n(m,h,p);return s(g.L,g.U,g.p,g.q,v)},"Object, Array | Matrix":function(m,v){return s(m.L,m.U,m.p,m.q,v)}});function u(c){if(Ve(c))return c;if(cr(c))return t(c);throw new TypeError("Invalid Matrix LU decomposition")}function s(c,m,v,h,p){c=u(c),m=u(m),v&&(p=l(c,p,!0),p._data=pp(v,p._data));var g=o(c,p),y=i(m,g);return h&&(y._data=pp(h,y._data)),y}}),dp="polynomialRoot",PS=["typed","isZero","equalScalar","add","subtract","multiply","divide","sqrt","unaryMinus","cbrt","typeOf","im","re"],US=q(dp,PS,r=>{var{typed:e,isZero:t,equalScalar:a,add:n,subtract:i,multiply:o,divide:f,sqrt:l,unaryMinus:u,cbrt:s,typeOf:c,im:m,re:v}=r;return e(dp,{"number|Complex, ...number|Complex":(h,p)=>{for(var g=[h,...p];g.length>0&&t(g[g.length-1]);)g.pop();if(g.length<2)throw new RangeError("Polynomial [".concat(h,", ").concat(p,"] must have a non-zero non-constant coefficient"));switch(g.length){case 2:return[u(f(g[0],g[1]))];case 3:{var[y,N,d]=g,w=o(2,d),x=o(N,N),b=o(4,d,y);if(a(x,b))return[f(u(N),w)];var E=l(i(x,b));return[f(i(E,N),w),f(i(u(E),N),w)]}case 4:{var[A,S,D,T]=g,B=u(o(3,T)),I=o(D,D),P=o(3,T,S),R=n(o(2,D,D,D),o(27,T,T,A)),M=o(9,T,D,S);if(a(I,P)&&a(R,M))return[f(D,B)];var F=i(I,P),H=i(R,M),$=n(o(18,T,D,S,A),o(D,D,S,S)),k=n(o(4,D,D,D,A),o(4,T,S,S,S),o(27,T,T,A,A));if(a($,k))return[f(i(o(4,T,D,S),n(o(9,T,T,A),o(D,D,D))),o(T,F)),f(i(o(9,T,A),o(D,S)),o(2,F))];var Q;a(I,P)?Q=H:Q=f(n(H,l(i(o(H,H),o(4,F,F,F)))),2);var K=!0,L=s(Q,K).toArray().map(j=>f(n(D,j,f(F,j)),B));return L.map(j=>c(j)==="Complex"&&a(v(j),v(j)+m(j))?v(j):j)}default:throw new RangeError("only implemented for cubic or lower-order polynomials, not ".concat(g))}}})}),LS="Help",kS=["parse"],VS=q(LS,kS,r=>{var{parse:e}=r;function t(a){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(!a)throw new Error('Argument "doc" missing');this.doc=a}return t.prototype.type="Help",t.prototype.isHelp=!0,t.prototype.toString=function(){var a=this.doc||{},n=`
51
51
  `;if(a.name&&(n+="Name: "+a.name+`
52
52
 
53
53
  `),a.category&&(n+="Category: "+a.category+`
@@ -60,26 +60,26 @@ q: `+this.q.toString():"")+`
60
60
  `)+`
61
61
 
62
62
  `),a.examples){n+=`Examples:
63
- `;for(var i={},s=0;s<a.examples.length;s++){var f=a.examples[s];n+=" "+f+`
64
- `;var l=void 0;try{l=e(f).compile().evaluate(i)}catch(u){l=u}l!==void 0&&!Xu(l)&&(n+=" "+Ye(l,{precision:14})+`
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&&!sl(l)&&(n+=" "+Ye(l,{precision:14})+`
65
65
  `)}n+=`
66
66
  `}return a.mayThrow&&a.mayThrow.length&&(n+="Throws: "+a.mayThrow.join(", ")+`
67
67
 
68
68
  `),a.seealso&&a.seealso.length&&(n+="See also: "+a.seealso.join(", ")+`
69
- `),n},t.prototype.toJSON=function(){var a=ke(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}),cS="Chain",fS=["?on","math","typed"],mS=R(cS,fS,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");Yu(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,o){typeof o=="function"&&(n.prototype[u]=f(o))}function s(u,o){N0(n.prototype,u,function(){var m=o();if(typeof m=="function")return f(m)})}function f(u){return function(){if(arguments.length===0)return new n(u(this.value));for(var o=[this.value],c=0;c<arguments.length;c++)o[c+1]=arguments[c];if(a.isTypedFunction(u)){var m=a.resolve(u,o);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,o))}return new n(u.apply(u,o))}}n.createProxy=function(u,o){if(typeof u=="string")i(u,o);else{var c=function(p){Re(u,p)&&l[p]===void 0&&s(p,()=>u[p])};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,o,c){c||s(u,o)}),n},{isClass:!0}),np={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"]},pS={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:[]},dS={name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},gS={name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},yS={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:[]},bS={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:[]},xS={name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},wS={name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},NS={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:[]},ap={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"]},DS={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:[]},AS={name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},ES={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"]},SS={name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},CS={name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},MS={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"]},FS={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"]},TS={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"]},BS={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"]},$S={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"]},OS={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"]},_S={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"]},IS={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"]},RS={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"]},qS={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"]},zS={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"]},PS={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"]},LS={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:[]},US={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:[]},kS={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:[]},VS={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"]},GS={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"]},HS={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"]},ZS={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"]},JS={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"]},WS={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"]},XS={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"]},YS={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"]},QS={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"]},KS={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"]},jS={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"]},eC={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"]},rC={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"]},tC={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"]},nC={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"]},aC={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"]},iC={name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},oC={name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i","3 cm + 2 inch",'"2.3" + "4"'],seealso:["subtract"]},sC={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"]},uC={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"]},cC={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"]},fC={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"]},mC={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"]},vC={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"]},pC={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"]},hC={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"]},dC={name:"expm1",category:"Arithmetic",syntax:["expm1(x)"],description:"Calculate the value of subtracting 1 from the exponential value.",examples:["expm1(2)","pow(e, 2) - 1","log(expm1(2) + 1)"],seealso:["exp","pow","log"]},gC={name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]},yC={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"]},bC={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"]},xC={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"]},wC={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","math.invmod(15151, 15122)=10429"],seealso:["gcd","xgcd"]},NC={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"]},DC={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"]},AC={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"]},EC={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"]},SC={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"]},CC={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"]},MC={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"]},FC={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")']},TC={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"]},BC={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"]},$C={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)","math.pow([[1, 2], [4, 3]], 2)","math.pow([[1, 2], [4, 3]], -1)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},OC={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"]},_C={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"]},IC={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"]},RC={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([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},qC={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"]},zC={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"]},PC={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"]},LC={name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},UC={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"]},kC={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"]},VC={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"]},GC={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"]},HC={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"]},ZC={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"]},JC={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"]},WC={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"]},XC={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"]},YC={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"]},QC={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"]},KC={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"]},jC={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"]},eM={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"]},tM={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"]},nM={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:[]},aM={name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},iM={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:[]},oM={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:[]},sM={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"]},uM={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"]},lM={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"]},cM={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"]},fM={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"]},mM={name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},vM={name:"count",category:"Matrix",syntax:["count(x)"],description:"Count the number of elements of a matrix, array or string.",examples:["a = [1, 2; 3, 4; 5, 6]","count(a)","size(a)",'count("hello world")'],seealso:["size"]},pM={name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},hM={name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},dM={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"]},gM={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"]},yM={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"]},bM={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"]},xM={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"]},wM={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"]},NM={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"]},DM={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"]},AM={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"]},EM={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"]},SM={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"]},CM={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"]},MM={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"]},FM={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"]},TM={name:"matrixFromColumns",category:"Matrix",syntax:["math.matrixFromColumns(...arr)","math.matrixFromColumns(row1, row2)","math.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"]},BM={name:"matrixFromFunction",category:"Matrix",syntax:["math.matrixFromFunction(size, fn)","math.matrixFromFunction(size, fn, format)","math.matrixFromFunction(size, fn, format, datatype)","math.matrixFromFunction(size, format, fn)","math.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"]},$M={name:"matrixFromRows",category:"Matrix",syntax:["math.matrixFromRows(...arr)","math.matrixFromRows(row1, row2)","math.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"]},OM={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"]},_M={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)'],seealso:["sort"]},IM={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"]},RM={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])"],seealso:["size","squeeze","resize"]},qM={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"]},zM={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], math.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"]},PM={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"]},LM={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"]},UM={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"]},kM={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"])',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},VM={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"]},GM={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"]},HM={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"]},ZM={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"]},JM={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"]},WM={name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},XM={name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},YM={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"]},QM={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"]},KM={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"]},jM={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"]},e3={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(math.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:[]},t3={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"]},n3={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"]},a3={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"]},i3={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"]},o3={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"]},s3={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"]},u3={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"]},l3={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"]},c3={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"]},f3={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"]},m3={name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},v3={name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},p3={name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},h3={name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},d3={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"]},g3={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"]},y3={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"]},b3={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"]},x3={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"]},w3={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"]},N3={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"]},D3={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"]},A3={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"]},E3={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"]},S3={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"]},C3={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"]},M3={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:[]},F3={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"]},T3={name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],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"]},B3={name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],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"]},$3={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"]},O3={name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],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"]},_3={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"]},I3={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"]},R3={name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:`Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber.
69
+ `),n},t.prototype.toJSON=function(){var a=Ge(this.doc);return a.mathjs="Help",a},t.fromJSON=function(a){var n={};return Object.keys(a).filter(i=>i!=="mathjs").forEach(i=>{n[i]=a[i]}),new t(n)},t.prototype.valueOf=t.prototype.toString,t},{isClass:!0}),GS="Chain",HS=["?on","math","typed"],ZS=q(GS,HS,r=>{var{on:e,math:t,typed:a}=r;function n(u){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");ul(u)?this.value=u.value:this.value=u}n.prototype.type="Chain",n.prototype.isChain=!0,n.prototype.done=function(){return this.value},n.prototype.valueOf=function(){return this.value},n.prototype.toString=function(){return Ye(this.value)},n.prototype.toJSON=function(){return{mathjs:"Chain",value:this.value}},n.fromJSON=function(u){return new n(u.value)};function i(u,s){typeof s=="function"&&(n.prototype[u]=f(s))}function o(u,s){X0(n.prototype,u,function(){var m=s();if(typeof m=="function")return f(m)})}function f(u){return function(){if(arguments.length===0)return new n(u(this.value));for(var s=[this.value],c=0;c<arguments.length;c++)s[c+1]=arguments[c];if(a.isTypedFunction(u)){var m=a.resolve(u,s);if(m.params.length===1)throw new Error("chain function "+u.name+" cannot match rest parameter between chain value and additional arguments.");return new n(m.implementation.apply(u,s))}return new n(u.apply(u,s))}}n.createProxy=function(u,s){if(typeof u=="string")i(u,s);else{var c=function(h){Re(u,h)&&l[h]===void 0&&o(h,()=>u[h])};for(var m in u)c(m)}};var l={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return n.createProxy(t),e&&e("import",function(u,s,c){c||o(u,s)}),n},{isClass:!0}),gp={name:"e",category:"Constants",syntax:["e"],description:"Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",examples:["e","e ^ 2","exp(2)","log(e)"],seealso:["exp"]},JS={name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},XS={name:"i",category:"Constants",syntax:["i"],description:"Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",examples:["i","i * i","sqrt(-1)"],seealso:[]},WS={name:"Infinity",category:"Constants",syntax:["Infinity"],description:"Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",examples:["Infinity","1 / 0"],seealso:[]},YS={name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},QS={name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},KS={name:"LOG10E",category:"Constants",syntax:["LOG10E"],description:"Returns the base-10 logarithm of E, approximately equal to 0.434",examples:["LOG10E","log(e, 10)"],seealso:[]},jS={name:"LOG2E",category:"Constants",syntax:["LOG2E"],description:"Returns the base-2 logarithm of E, approximately equal to 1.442",examples:["LOG2E","log(e, 2)"],seealso:[]},eC={name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},rC={name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},tC={name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["phi"],seealso:[]},yp={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]},nC={name:"SQRT1_2",category:"Constants",syntax:["SQRT1_2"],description:"Returns the square root of 1/2, approximately equal to 0.707",examples:["SQRT1_2","sqrt(1/2)"],seealso:[]},aC={name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},iC={name:"tau",category:"Constants",syntax:["tau"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]},oC={name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},sC={name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},uC={name:"bignumber",category:"Construction",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","complex","fraction","index","matrix","string","unit"]},lC={name:"boolean",category:"Construction",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]},cC={name:"complex",category:"Construction",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]},fC={name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.",examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]},mC={name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(matrix)","fraction(num,den)","fraction({n: num, d: den})"],description:"Create a fraction from a number or from integer numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)","fraction({n: 333, d: 53})","fraction([sqrt(9), sqrt(10), sqrt(11)])"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},vC={name:"index",category:"Construction",syntax:["[start]","[start:end]","[start:step:end]","[start1, start 2, ...]","[start1:end1, start2:end2, ...]","[start1:step1:end1, start2:step2:end2, ...]"],description:"Create an index to get or replace a subset of a matrix",examples:["[1, 2, 3]","A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[1:2, 1:2] = ones(2, 2)"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]},pC={name:"matrix",category:"Construction",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()",'matrix("dense")',"matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])",'matrix([3, 4; 5, 6], "sparse")','matrix([3, 4; 5, 6], "sparse", "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","sparse"]},hC={name:"number",category:"Construction",syntax:["x","number(x)","number(unit, valuelessUnit)"],description:"Create a number or convert a string or boolean into a number.",examples:["2","2e3","4.05","number(2)",'number("7.2")',"number(true)","number([true, false, true, true])",'number(unit("52cm"), "m")'],seealso:["bignumber","boolean","complex","fraction","index","matrix","string","unit"]},dC={name:"sparse",category:"Construction",syntax:["sparse()","sparse([a1, b1, ...; a1, b2, ...])",'sparse([a1, b1, ...; a1, b2, ...], "number")'],description:"Create a sparse matrix.",examples:["sparse()","sparse([3, 4; 5, 6])",'sparse([3, 0; 5, 0], "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","matrix"]},gC={name:"splitUnit",category:"Construction",syntax:["splitUnit(unit: Unit, parts: Unit[])"],description:"Split a unit in an array of units whose sum is equal to the original unit.",examples:['splitUnit(1 m, ["feet", "inch"])'],seealso:["unit","createUnit"]},yC={name:"string",category:"Construction",syntax:['"text"',"string(x)"],description:"Create a string or convert a value to a string",examples:['"Hello World!"',"string(4.2)","string(3 + 2i)"],seealso:["bignumber","boolean","complex","index","matrix","number","unit"]},bC={name:"unit",category:"Construction",syntax:["value unit","unit(value, unit)","unit(string)"],description:"Create a unit.",examples:["5.5 mm","3 inch",'unit(7.1, "kilogram")','unit("23 deg")'],seealso:["bignumber","boolean","complex","index","matrix","number","string"]},xC={name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},wC={name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},NC={name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},DC={name:"derivative",category:"Algebra",syntax:["derivative(expr, variable)","derivative(expr, variable, {simplify: boolean})"],description:"Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",examples:['derivative("2x^3", "x")','derivative("2x^3", "x", {simplify: false})','derivative("2x^2 + 3x + 4", "x")','derivative("sin(2x)", "x")','f = parse("x^2 + x")','x = parse("x")',"df = derivative(f, x)","df.evaluate({x: 3})"],seealso:["simplify","parse","evaluate"]},AC={name:"leafCount",category:"Algebra",syntax:["leafCount(expr)"],description:"Computes the number of leaves in the parse tree of the given expression",examples:['leafCount("e^(i*pi)-1")','leafCount(parse("{a: 22/7, b: 10^(1/2)}"))'],seealso:["simplify"]},EC={name:"lsolve",category:"Algebra",syntax:["x=lsolve(L, b)"],description:"Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolveAll","lup","lusolve","usolve","matrix","sparse"]},SC={name:"lsolveAll",category:"Algebra",syntax:["x=lsolveAll(L, b)"],description:"Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolve","lup","lusolve","usolve","matrix","sparse"]},CC={name:"lup",category:"Algebra",syntax:["lup(m)"],description:"Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",examples:["lup([[2, 1], [1, 4]])","lup(matrix([[2, 1], [1, 4]]))","lup(sparse([[2, 1], [1, 4]]))"],seealso:["lusolve","lsolve","usolve","matrix","sparse","slu","qr"]},MC={name:"lusolve",category:"Algebra",syntax:["x=lusolve(A, b)","x=lusolve(lu, b)"],description:"Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lusolve(a, b)"],seealso:["lup","slu","lsolve","usolve","matrix","sparse"]},FC={name:"polynomialRoot",category:"Algebra",syntax:["x=polynomialRoot(-6, 3)","x=polynomialRoot(4, -4, 1)","x=polynomialRoot(-8, 12, -6, 1)"],description:"Finds the roots of a univariate polynomial given by its coefficients starting from constant, linear, and so on, increasing in degree.",examples:["a = polynomialRoot(-6, 11, -6 1)"],seealso:["cbrt","sqrt"]},TC={name:"qr",category:"Algebra",syntax:["qr(A)"],description:"Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",examples:["qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])"],seealso:["lup","slu","matrix"]},BC={name:"rationalize",category:"Algebra",syntax:["rationalize(expr)","rationalize(expr, scope)","rationalize(expr, scope, detailed)"],description:"Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",examples:['rationalize("2x/y - y/(x+1)")','rationalize("2x/y - y/(x+1)", true)'],seealso:["simplify"]},$C={name:"resolve",category:"Algebra",syntax:["resolve(node, scope)"],description:"Recursively substitute variables in an expression tree.",examples:['resolve(parse("1 + x"), { x: 7 })','resolve(parse("size(text)"), { text: "Hello World" })','resolve(parse("x + y"), { x: parse("3z") })','resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })'],seealso:["simplify","evaluate"],mayThrow:["ReferenceError"]},OC={name:"simplify",category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["simplifyCore","derivative","evaluate","parse","rationalize","resolve"]},IC={name:"simplifyConstant",category:"Algebra",syntax:["simplifyConstant(expr)","simplifyConstant(expr, options)"],description:"Replace constant subexpressions of node with their values.",examples:['simplifyConatant("(3-3)*x")','simplifyConstant(parse("z-cos(tau/8)"))'],seealso:["simplify","simplifyCore","evaluate"]},RC={name:"simplifyCore",category:"Algebra",syntax:["simplifyCore(node)"],description:"Perform simple one-pass simplifications on an expression tree.",examples:['simplifyCore(parse("0*x"))','simplifyCore(parse("(x+0)*2"))'],seealso:["simplify","simplifyConstant","evaluate"]},_C={name:"slu",category:"Algebra",syntax:["slu(A, order, threshold)"],description:"Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",examples:["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],seealso:["lusolve","lsolve","usolve","matrix","sparse","lup","qr"]},qC={name:"symbolicEqual",category:"Algebra",syntax:["symbolicEqual(expr1, expr2)","symbolicEqual(expr1, expr2, options)"],description:"Returns true if the difference of the expressions simplifies to 0",examples:['symbolicEqual("x*y","y*x")','symbolicEqual("abs(x^2)", "x^2")','symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})'],seealso:["simplify","evaluate"]},zC={name:"usolve",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolveAll","lup","lusolve","lsolve","matrix","sparse"]},PC={name:"usolveAll",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolve","lup","lusolve","lsolve","matrix","sparse"]},UC={name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},LC={name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i","3 cm + 2 inch",'"2.3" + "4"'],seealso:["subtract"]},kC={name:"cbrt",category:"Arithmetic",syntax:["cbrt(x)","cbrt(x, allRoots)"],description:"Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",examples:["cbrt(64)","cube(4)","cbrt(-8)","cbrt(2 + 3i)","cbrt(8i)","cbrt(8i, true)","cbrt(27 m^3)"],seealso:["square","sqrt","cube","multiply"]},VC={name:"ceil",category:"Arithmetic",syntax:["ceil(x)"],description:"Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)"],seealso:["floor","fix","round"]},GC={name:"cube",category:"Arithmetic",syntax:["cube(x)"],description:"Compute the cube of a value. The cube of x is x * x * x.",examples:["cube(2)","2^3","2 * 2 * 2"],seealso:["multiply","square","pow"]},HC={name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["a = 2 / 3","a * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]},ZC={name:"dotDivide",category:"Operators",syntax:["x ./ y","dotDivide(x, y)"],description:"Divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","dotMultiply","divide"]},JC={name:"dotMultiply",category:"Operators",syntax:["x .* y","dotMultiply(x, y)"],description:"Multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","dotDivide"]},XC={name:"dotPow",category:"Operators",syntax:["x .^ y","dotPow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]},WC={name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["expm","expm1","pow","log"]},YC={name:"expm",category:"Arithmetic",syntax:["exp(x)"],description:"Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",examples:["expm([[0,2],[0,0]])"],seealso:["exp"]},QC={name:"expm1",category:"Arithmetic",syntax:["expm1(x)"],description:"Calculate the value of subtracting 1 from the exponential value.",examples:["expm1(2)","pow(e, 2) - 1","log(expm1(2) + 1)"],seealso:["exp","pow","log"]},KC={name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]},jC={name:"floor",category:"Arithmetic",syntax:["floor(x)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)"],seealso:["ceil","fix","round"]},eM={name:"gcd",category:"Arithmetic",syntax:["gcd(a, b)","gcd(a, b, c, ...)"],description:"Compute the greatest common divisor.",examples:["gcd(8, 12)","gcd(-4, 6)","gcd(25, 15, -10)"],seealso:["lcm","xgcd"]},rM={name:"hypot",category:"Arithmetic",syntax:["hypot(a, b, c, ...)","hypot([a, b, c, ...])"],description:"Calculate the hypotenusa of a list with values. ",examples:["hypot(3, 4)","sqrt(3^2 + 4^2)","hypot(-2)","hypot([3, 4, 5])"],seealso:["abs","norm"]},tM={name:"invmod",category:"Arithmetic",syntax:["invmod(a, b)"],description:"Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax \u2263 1 (mod b)",examples:["invmod(8, 12)=NaN","invmod(7, 13)=2","invmod(15151, 15122)=10429"],seealso:["gcd","xgcd"]},nM={name:"lcm",category:"Arithmetic",syntax:["lcm(x, y)"],description:"Compute the least common multiple.",examples:["lcm(4, 6)","lcm(6, 21)","lcm(6, 21, 5)"],seealso:["gcd"]},aM={name:"log",category:"Arithmetic",syntax:["log(x)","log(x, base)"],description:"Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",examples:["log(3.5)","a = log(2.4)","exp(a)","10 ^ 4","log(10000, 10)","log(10000) / log(10)","b = log(1024, 2)","2 ^ b"],seealso:["exp","log1p","log2","log10"]},iM={name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(0.00001)","log10(10000)","10 ^ 4","log(10000) / log(10)","log(10000, 10)"],seealso:["exp","log"]},oM={name:"log1p",category:"Arithmetic",syntax:["log1p(x)","log1p(x, base)"],description:"Calculate the logarithm of a `value+1`",examples:["log1p(2.5)","exp(log1p(1.4))","pow(10, 4)","log1p(9999, 10)","log1p(9999) / log(10)"],seealso:["exp","log","log2","log10"]},sM={name:"log2",category:"Arithmetic",syntax:["log2(x)"],description:"Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",examples:["log2(0.03125)","log2(16)","log2(16) / log2(2)","pow(2, 4)"],seealso:["exp","log1p","log","log10"]},uM={name:"mod",category:"Operators",syntax:["x % y","x mod y","mod(x, y)"],description:"Calculates the modulus, the remainder of an integer division.",examples:["7 % 3","11 % 2","10 mod 4","isOdd(x) = x % 2","isOdd(2)","isOdd(3)"],seealso:["divide"]},lM={name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["a = 2.1 * 3.4","a / 3.4","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]},cM={name:"norm",category:"Arithmetic",syntax:["norm(x)","norm(x, p)"],description:"Calculate the norm of a number, vector or matrix.",examples:["abs(-3.5)","norm(-3.5)","norm(3 - 4i)","norm([1, 2, -3], Infinity)","norm([1, 2, -3], -Infinity)","norm([3, 4], 2)","norm([[1, 2], [3, 4]], 1)",'norm([[1, 2], [3, 4]], "inf")','norm([[1, 2], [3, 4]], "fro")']},fM={name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["nthRoots","pow","sqrt"]},mM={name:"nthRoots",category:"Arithmetic",syntax:["nthRoots(A)","nthRoots(A, root)"],description:'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',examples:["nthRoots(1)","nthRoots(1, 3)"],seealso:["sqrt","pow","nthRoot"]},vM={name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3","2*2*2","1 + e ^ (pi * i)","pow([[1, 2], [4, 3]], 2)","pow([[1, 2], [4, 3]], -1)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},pM={name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)"],seealso:["ceil","floor","fix"]},hM={name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},dM={name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},gM={name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[33, 24], [48, 57]])"],seealso:["sqrt","abs","square","multiply"]},yM={name:"sylvester",category:"Matrix",syntax:["sylvester(A,B,C)"],description:"Solves the real-valued Sylvester equation AX+XB=C for X",examples:["sylvester([[-1, -2], [1, 1]], [[-2, 1], [-1, 2]], [[-3, 2], [3, 0]])","sylvester(A,B,C)"],seealso:["schur","lyap"]},bM={name:"schur",category:"Matrix",syntax:["schur(A)"],description:"Performs a real Schur decomposition of the real matrix A = UTU'",examples:["schur([[1, 0], [-4, 3]])","schur(A)"],seealso:["lyap","sylvester"]},xM={name:"lyap",category:"Matrix",syntax:["lyap(A,Q)"],description:"Solves the Continuous-time Lyapunov equation AP+PA'+Q=0 for P",examples:["lyap([[-2, 0], [1, -4]], [[3, 1], [1, 3]])","lyap(A,Q)"],seealso:["schur","sylvester"]},wM={name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},NM={name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},DM={name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},AM={name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},EM={name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},SM={name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},CM={name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},MM={name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},FM={name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},TM={name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},BM={name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},$M={name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},OM={name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},IM={name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},RM={name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},_M={name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},qM={name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},zM={name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},PM={name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},UM={name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},LM={name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(" + 4 + ")")'],seealso:[]},kM={name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},VM={name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])","distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},GM={name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},HM={name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},ZM={name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},JM={name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},XM={name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},WM={name:"column",category:"Matrix",syntax:["column(x, index)"],description:"Return a column from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","column(A, 1)","column(A, 2)"],seealso:["row","matrixFromColumns"]},YM={name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},QM={name:"count",category:"Matrix",syntax:["count(x)"],description:"Count the number of elements of a matrix, array or string.",examples:["a = [1, 2; 3, 4; 5, 6]","count(a)","size(a)",'count("hello world")'],seealso:["size"]},KM={name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},jM={name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},e3={name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},r3={name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},t3={name:"diff",category:"Matrix",syntax:["diff(arr)","diff(arr, dim)"],description:["Create a new matrix or array with the difference of the passed matrix or array.","Dim parameter is optional and used to indicant the dimension of the array/matrix to apply the difference","If no dimension parameter is passed it is assumed as dimension 0","Dimension is zero-based in javascript and one-based in the parser","Arrays must be 'rectangular' meaning arrays like [1, 2]","If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],examples:["diff([1, 2, 4, 7, 0])","diff([1, 2, 4, 7, 0], 0)","diff(matrix([1, 2, 4, 7, 0]))","diff([[1, 2], [3, 4]])","diff([[1, 2], [3, 4]], 0)","diff([[1, 2], [3, 4]], 1)","diff([[1, 2], [3, 4]], bignumber(1))","diff(matrix([[1, 2], [3, 4]]), 1)","diff([[1, 2], matrix([3, 4])], 1)"],seealso:["subtract","partitionSelect"]},n3={name:"dot",category:"Matrix",syntax:["dot(A, B)","A * B"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]},a3={name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and eigenvectors of a real symmetric matrix",examples:["eigs([[5, 2.3], [2.3, 1]])"],seealso:["inv"]},i3={name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},o3={name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]},s3={name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["numberOfPets = {}","addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;",'forEach(["Dog","Cat","Cat"], addPet)',"numberOfPets"],seealso:["map","sort","filter"]},u3={name:"getMatrixDataType",category:"Matrix",syntax:["getMatrixDataType(x)"],description:'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',examples:["getMatrixDataType([1, 2, 3])","getMatrixDataType([[5 cm], [2 inch]])",'getMatrixDataType([1, "text"])',"getMatrixDataType([1, bignumber(4)])"],seealso:["matrix","sparse","typeOf"]},l3={name:"identity",category:"Matrix",syntax:["identity(n)","identity(m, n)","identity([m, n])"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["identity(3)","identity(3, 5)","a = [1, 2, 3; 4, 5, 6]","identity(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},c3={name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","identity","ones","range","size","squeeze","subset","trace","transpose","zeros"]},f3={name:"pinv",category:"Matrix",syntax:["pinv(x)"],description:"Calculate the Moore\u2013Penrose inverse of a matrix",examples:["pinv([1, 2; 3, 4])","pinv([[1, 0], [0, 1], [0, 1]])","pinv(4)"],seealso:["inv"]},m3={name:"kron",category:"Matrix",syntax:["kron(x, y)"],description:"Calculates the kronecker product of 2 matrices or vectors.",examples:["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])","kron([1,1], [2,3,4])"],seealso:["multiply","dot","cross"]},v3={name:"map",category:"Matrix",syntax:["map(x, callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",examples:["map([1, 2, 3], square)"],seealso:["filter","forEach"]},p3={name:"matrixFromColumns",category:"Matrix",syntax:["matrixFromColumns(...arr)","matrixFromColumns(row1, row2)","matrixFromColumns(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual columns.",examples:["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromRows","matrixFromFunction","zeros"]},h3={name:"matrixFromFunction",category:"Matrix",syntax:["matrixFromFunction(size, fn)","matrixFromFunction(size, fn, format)","matrixFromFunction(size, fn, format, datatype)","matrixFromFunction(size, format, fn)","matrixFromFunction(size, format, datatype, fn)"],description:"Create a matrix by evaluating a generating function at each index.",examples:["f(I) = I[1] - I[2]","matrixFromFunction([3,3], f)","g(I) = I[1] - I[2] == 1 ? 4 : 0",'matrixFromFunction([100, 100], "sparse", g)',"matrixFromFunction([5], random)"],seealso:["matrix","matrixFromRows","matrixFromColumns","zeros"]},d3={name:"matrixFromRows",category:"Matrix",syntax:["matrixFromRows(...arr)","matrixFromRows(row1, row2)","matrixFromRows(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual rows.",examples:["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromColumns","matrixFromFunction","zeros"]},g3={name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","identity","inv","range","size","squeeze","subset","trace","transpose","zeros"]},y3={name:"partitionSelect",category:"Matrix",syntax:["partitionSelect(x, k)","partitionSelect(x, k, compare)"],description:"Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",examples:["partitionSelect([5, 10, 1], 2)",'partitionSelect(["C", "B", "A", "D"], 1, compareText)',"arr = [5, 2, 1]","partitionSelect(arr, 0) # returns 1, arr is now: [1, 2, 5]","arr","partitionSelect(arr, 1, 'desc') # returns 2, arr is now: [5, 2, 1]","arr"],seealso:["sort"]},b3={name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","identity","inv","ones","size","squeeze","subset","trace","transpose","zeros"]},x3={name:"reshape",category:"Matrix",syntax:["reshape(x, sizes)"],description:"Reshape a multi dimensional array to fit the specified dimensions.",examples:["reshape([1, 2, 3, 4, 5, 6], [2, 3])","reshape([[1, 2], [3, 4]], [1, 4])","reshape([[1, 2], [3, 4]], [4])","reshape([1, 2, 3, 4], [-1, 2])"],seealso:["size","squeeze","resize"]},w3={name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze","reshape"]},N3={name:"rotate",category:"Matrix",syntax:["rotate(w, theta)","rotate(w, theta, v)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotate([1, 0], pi / 2)",'rotate(matrix([1, 0]), unit("35deg"))','rotate([1, 0, 0], unit("90deg"), [0, 0, 1])','rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],seealso:["matrix","rotationMatrix"]},D3={name:"rotationMatrix",category:"Matrix",syntax:["rotationMatrix(theta)","rotationMatrix(theta, v)","rotationMatrix(theta, v, format)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotationMatrix(pi / 2)",'rotationMatrix(unit("45deg"), [0, 0, 1])','rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],seealso:["cos","sin"]},A3={name:"row",category:"Matrix",syntax:["row(x, index)"],description:"Return a row from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","row(A, 1)","row(A, 2)"],seealso:["column","matrixFromRows"]},E3={name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","count","det","diag","identity","inv","ones","range","squeeze","subset","trace","transpose","zeros"]},S3={name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"], "natural")',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},C3={name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","identity","inv","ones","range","size","subset","trace","transpose","zeros"]},M3={name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation `l:u`. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]","f[[1,2], [1,3]] = [9, 10; 11, 12]","f"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},F3={name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","transpose","zeros"]},T3={name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},B3={name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose"]},$3={name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},O3={name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},I3={name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},R3={name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"],seealso:["combinations","permutations","factorial"]},_3={name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},q3={name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},z3={name:"lgamma",category:"Probability",syntax:["lgamma(n)"],description:"Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.",examples:["lgamma(4)","lgamma(1/2)","lgamma(i)","lgamma(complex(1.1, 2))"],seealso:["gamma"]},P3={name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},U3={name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},L3={name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},k3={name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)","pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])","pickRandom([1, 3, 1, 6], 2)","pickRandom([1, 3, 1, 6], [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],seealso:["random","randomInt"]},V3={name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]},G3={name:"randomInt",category:"Probability",syntax:["randomInt(max)","randomInt(min, max)","randomInt(size)","randomInt(size, max)","randomInt(size, min, max)"],description:"Return a random integer number",examples:["randomInt(10, 20)","randomInt([2, 3], 10)"],seealso:["pickRandom","random"]},H3={name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compareNatural","compareText"]},Z3={name:"compareNatural",category:"Relational",syntax:["compareNatural(x, y)"],description:"Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compareNatural(2, 3)","compareNatural(3, 2)","compareNatural(2, 2)","compareNatural(5cm, 40mm)",'compareNatural("2", "10")',"compareNatural(2 + 3i, 2 + 4i)","compareNatural([1, 2, 4], [1, 2, 3])","compareNatural([1, 5], [1, 2, 3])","compareNatural([1, 2], [1, 2])","compareNatural({a: 2}, {a: 4})"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare","compareText"]},J3={name:"compareText",category:"Relational",syntax:["compareText(x, y)"],description:"Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:['compareText("B", "A")','compareText("A", "B")','compareText("A", "A")','compareText("2", "10")','compare("2", "10")',"compare(2, 10)",'compareNatural("2", "10")','compareText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural"]},X3={name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["deepEqual([1,3,4], [1,3,4])","deepEqual([1,3,4], [1,3])"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]},W3={name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual","equalText"]},Y3={name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},Q3={name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},K3={name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},j3={name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},eF={name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 <= 1+1","2 < 1+1","a = 3.2","b = 6-2.8","(a <= b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]},rF={name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]},tF={name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays and the values will be sorted in ascending order before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},nF={name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},aF={name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},iF={name:"setIntersect",category:"Set",syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},oF={name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},sF={name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]},uF={name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},lF={name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},cF={name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setDifference"]},fF={name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},mF={name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},vF={name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},pF={name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dimension)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},hF={name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dimension)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},dF={name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},gF={name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dimension)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},yF={name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},bF={name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},xF={name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:`Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber.
70
70
 
71
- In case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.`,examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},q3={name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, 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"]},z3={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"]},P3={name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],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"]},L3={name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, 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"]},U3={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"]},k3={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"]},V3={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"]},G3={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"]},H3={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"]},Z3={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"]},J3={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"]},W3={name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},X3={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"]},Y3={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"]},Q3={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"]},K3={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"]},j3={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"]},eF={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"]},tF={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"]},nF={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"]},aF={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"]},iF={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"]},oF={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"]},sF={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"]},uF={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"]},lF={name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},cF={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"]},fF={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"]},mF={name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},vF={name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},pF={name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},hF={name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},dF={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"]},gF={name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},yF={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"]},bF={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"]},xF={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"]},wF={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"]},NF={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"]},DF={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"]},AF={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"]},EF={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"]},SF={name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},CF={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"]},MF={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"]},FF={bignumber:MS,boolean:FS,complex:TS,createUnit:BS,fraction:$S,index:OS,matrix:_S,number:IS,sparse:RS,splitUnit:qS,string:zS,unit:PS,e:np,E:np,false:vS,i:pS,Infinity:hS,LN2:gS,LN10:dS,LOG2E:bS,LOG10E:yS,NaN:xS,null:wS,pi:ap,PI:ap,phi:NS,SQRT1_2:DS,SQRT2:AS,tau:ES,true:SS,version:CS,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:VS,lsolve:HS,lsolveAll:ZS,lup:JS,lusolve:WS,leafCount:GS,resolve:QS,simplify:KS,simplifyConstant:jS,simplifyCore:eC,symbolicEqual:tC,rationalize:YS,slu:rC,usolve:nC,usolveAll:aC,qr:XS,abs:iC,add:oC,cbrt:sC,ceil:uC,cube:lC,divide:cC,dotDivide:fC,dotMultiply:mC,dotPow:vC,exp:pC,expm:hC,expm1:dC,fix:gC,floor:yC,gcd:bC,hypot:xC,lcm:NC,log:DC,log2:SC,log1p:EC,log10:AC,mod:CC,multiply:MC,norm:FC,nthRoot:TC,nthRoots:BC,pow:$C,round:OC,sign:_C,sqrt:IC,sqrtm:RC,square:qC,subtract:zC,unaryMinus:PC,unaryPlus:LC,xgcd:UC,invmod:wC,bitAnd:kC,bitNot:VC,bitOr:GC,bitXor:HC,leftShift:ZC,rightArithShift:JC,rightLogShift:WC,bellNumbers:XC,catalan:YC,composition:QC,stirlingS2:KC,config:LS,import:US,typed:kS,arg:jC,conj:eM,re:tM,im:rM,evaluate:nM,help:aM,distance:iM,intersect:oM,and:sM,not:uM,or:lM,xor:cM,concat:mM,count:vM,cross:pM,column:fM,ctranspose:hM,det:dM,diag:gM,diff:yM,dot:bM,getMatrixDataType:AM,identity:EM,filter:wM,flatten:NM,forEach:DM,inv:SM,pinv:CM,eigs:xM,kron:MM,matrixFromFunction:BM,matrixFromRows:$M,matrixFromColumns:TM,map:FM,ones:OM,partitionSelect:_M,range:IM,resize:qM,reshape:RM,rotate:zM,rotationMatrix:PM,row:LM,size:UM,sort:kM,squeeze:VM,subset:GM,trace:HM,transpose:ZM,zeros:JM,fft:WM,ifft:XM,combinations:YM,combinationsWithRep:QM,factorial:KM,gamma:jM,kldivergence:r3,lgamma:e3,multinomial:t3,permutations:n3,pickRandom:a3,random:i3,randomInt:o3,compare:s3,compareNatural:u3,compareText:l3,deepEqual:c3,equal:f3,equalText:m3,larger:v3,largerEq:p3,smaller:h3,smallerEq:d3,unequal:g3,setCartesian:y3,setDifference:b3,setDistinct:x3,setIntersect:w3,setIsSubset:N3,setMultiplicity:D3,setPowerset:A3,setSize:E3,setSymDifference:S3,setUnion:C3,erf:M3,cumsum:z3,mad:F3,max:T3,mean:B3,median:$3,min:O3,mode:_3,prod:I3,quantileSeq:R3,std:q3,sum:P3,variance:L3,acos:U3,acosh:k3,acot:V3,acoth:G3,acsc:H3,acsch:Z3,asec:J3,asech:W3,asin:X3,asinh:Y3,atan:Q3,atanh:j3,atan2:K3,cos:eF,cosh:rF,cot:tF,coth:nF,csc:aF,csch:iF,sec:oF,sech:sF,sin:uF,sinh:lF,tan:cF,tanh:fF,to:mF,clone:pF,format:hF,bin:vF,oct:SF,hex:gF,isNaN:bF,isInteger:yF,isNegative:xF,isNumeric:wF,hasNumericValue:dF,isPositive:NF,isPrime:DF,isZero:AF,print:CF,typeOf:MF,numeric:EF},ip="help",TF=["typed","mathWithTransform","Help"],BF=R(ip,TF,r=>{var{typed:e,mathWithTransform:t,Help:a}=r;return e(ip,{any:function(i){var s,f=i;if(typeof i!="string"){for(s in t)if(Re(t,s)&&i===t[s]){f=s;break}}var l=ot(FF,f);if(!l){var u=typeof f=="function"?f.name:f;throw new Error('No documentation found on "'+u+'"')}return new a(l)}})}),op="chain",$F=["typed","Chain"],OF=R(op,$F,r=>{var{typed:e,Chain:t}=r;return e(op,{"":function(){return new t},any:function(n){return new t(n)}})}),sp="det",_F=["typed","matrix","subtract","multiply","divideScalar","isZero","unaryMinus"],IF=R(sp,_F,r=>{var{typed:e,matrix:t,subtract:a,multiply:n,divideScalar:i,isZero:s,unaryMinus:f}=r;return e(sp,{any:function(o){return ke(o)},"Array | Matrix":function(o){var c;switch(He(o)?c=o.size():Array.isArray(o)?(o=t(o),c=o.size()):c=[],c.length){case 0:return ke(o);case 1:if(c[0]===1)return ke(o.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+Ye(c)+")");case 2:{var m=c[0],v=c[1];if(m===v)return l(o.clone().valueOf(),m);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,o,c){if(o===1)return ke(u[0][0]);if(o===2)return a(n(u[0][0],u[1][1]),n(u[1][0],u[0][1]));for(var m=!1,v=new Array(o).fill(0).map((E,N)=>N),p=0;p<o;p++){var h=v[p];if(s(u[h][p])){var y=void 0;for(y=p+1;y<o;y++)if(!s(u[v[y]][p])){h=v[y],v[y]=v[p],v[p]=h,m=!m;break}if(y===o)return u[h][p]}for(var b=u[h][p],A=p===0?1:u[v[p-1]][p-1],d=p+1;d<o;d++)for(var w=v[d],x=p+1;x<o;x++)u[w][x]=i(a(n(u[w][x],b),n(u[w][p],u[h][x])),A)}var g=u[v[o-1]][o-1];return m?f(g):g}}),up="inv",RF=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],qF=R(up,RF,r=>{var{typed:e,matrix:t,divideScalar:a,addScalar:n,multiply:i,unaryMinus:s,det:f,identity:l,abs:u}=r;return e(up,{"Array | Matrix":function(m){var v=He(m)?m.size():er(m);switch(v.length){case 1:if(v[0]===1)return He(m)?t([a(1,m.valueOf()[0])]):[a(1,m[0])];throw new RangeError("Matrix must be square (size: "+Ye(v)+")");case 2:{var p=v[0],h=v[1];if(p===h)return He(m)?t(o(m.valueOf(),p,h),m.storage()):o(m,p,h);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 o(c,m,v){var p,h,y,b,A;if(m===1){if(b=c[0][0],b===0)throw Error("Cannot calculate inverse, determinant is zero");return[[a(1,b)]]}else if(m===2){var d=f(c);if(d===0)throw Error("Cannot calculate inverse, determinant is zero");return[[a(c[1][1],d),a(s(c[0][1]),d)],[a(s(c[1][0]),d),a(c[0][0],d)]]}else{var w=c.concat();for(p=0;p<m;p++)w[p]=w[p].concat();for(var x=l(m).valueOf(),g=0;g<v;g++){var E=u(w[g][g]),N=g;for(p=g+1;p<m;)u(w[p][g])>E&&(E=u(w[p][g]),N=p),p++;if(E===0)throw Error("Cannot calculate inverse, determinant is zero");p=N,p!==g&&(A=w[g],w[g]=w[p],w[p]=A,A=x[g],x[g]=x[p],x[p]=A);var S=w[g],D=x[g];for(p=0;p<m;p++){var T=w[p],B=x[p];if(p!==g){if(T[g]!==0){for(y=a(s(T[g]),S[g]),h=g;h<v;h++)T[h]=n(T[h],i(y,S[h]));for(h=0;h<v;h++)B[h]=n(B[h],i(y,D[h]))}}else{for(y=S[g],h=g;h<v;h++)T[h]=a(T[h],y);for(h=0;h<v;h++)B[h]=a(B[h],y)}}}return x}}}),lp="pinv",zF=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],PF=R(lp,zF,r=>{var{typed:e,matrix:t,inv:a,deepEqual:n,equal:i,dotDivide:s,dot:f,ctranspose:l,divideScalar:u,multiply:o,add:c,Complex:m}=r;return e(lp,{"Array | Matrix":function(d){var w=He(d)?d.size():er(d);switch(w.length){case 1:return b(d)?l(d):w[0]===1?a(d):s(l(d),f(d,d));case 2:{if(b(d))return l(d);var x=w[0],g=w[1];if(x===g)try{return a(d)}catch(E){if(!(E instanceof Error&&E.message.match(/Cannot calculate inverse, determinant is zero/)))throw E}return He(d)?t(v(d.valueOf(),x,g),d.storage()):v(d,x,g)}default:throw new RangeError("Matrix must be two dimensional (size: "+Ye(w)+")")}},any:function(d){return i(d,0)?ke(d):u(1,d)}});function v(A,d,w){var{C:x,F:g}=h(A,d,w),E=o(a(o(l(x),x)),l(x)),N=o(l(g),a(o(g,l(g))));return o(N,E)}function p(A,d,w){for(var x=ke(A),g=0,E=0;E<d;E++){if(w<=g)return x;for(var N=E;y(x[N][g]);)if(N++,d===N&&(N=E,g++,w===g))return x;[x[N],x[E]]=[x[E],x[N]];for(var S=x[E][g],D=0;D<w;D++)x[E][D]=s(x[E][D],S);for(var T=0;T<d;T++)if(T!==E){S=x[T][g];for(var B=0;B<w;B++)x[T][B]=c(x[T][B],o(-1,o(S,x[E][B])))}g++}return x}function h(A,d,w){var x=p(A,d,w),g=A.map((N,S)=>N.filter((D,T)=>T<d&&!y(f(x[T],x[T])))),E=x.filter((N,S)=>!y(f(x[S],x[S])));return{C:g,F:E}}function y(A){return i(c(A,m(1,1)),c(0,m(1,1)))}function b(A){return n(c(A,m(1,1)),c(o(A,0),m(1,1)))}});function LF(r){var{addScalar:e,subtract:t,flatten:a,multiply:n,multiplyScalar:i,divideScalar:s,sqrt:f,abs:l,bignumber:u,diag:o,inv:c,qr:m,usolve:v,usolveAll:p,equal:h,complex:y,larger:b,smaller:A,matrixFromColumns:d,dot:w}=r;function x(U,Y,j,P,K){K===void 0&&(K=!0);var ne=g(U,Y,j,P,K);E(U,Y,j,P,K,ne);var{values:re,C:fe}=N(U,Y,j,P,K),pe;return K&&(pe=S(U,Y,fe,ne,re,j,P),pe=d(...pe)),{values:re,vectors:pe}}function g(U,Y,j,P,K){var ne=P==="BigNumber",re=P==="Complex",fe=ne?u(0):0,pe=ne?u(1):re?y(1):1,ce=ne?u(1):1,oe=ne?u(10):2,Ce=i(oe,oe),Oe;K&&(Oe=Array(Y).fill(pe));for(var Me=!1;!Me;){Me=!0;for(var $e=0;$e<Y;$e++){for(var k=fe,W=fe,ie=0;ie<Y;ie++)if($e!==ie){var V=l(U[$e][ie]);k=e(k,V),W=e(W,V)}if(!h(k,0)&&!h(W,0)){for(var Q=ce,te=k,ge=s(W,oe),he=i(W,oe);A(te,ge);)te=i(te,Ce),Q=i(Q,oe);for(;b(te,he);)te=s(te,Ce),Q=s(Q,oe);var q=A(s(e(te,W),Q),i(e(k,W),.95));if(q){Me=!1;for(var z=s(1,Q),ee=0;ee<Y;ee++)$e!==ee&&(U[$e][ee]=i(U[$e][ee],Q),U[ee][$e]=i(U[ee][$e],z));K&&(Oe[$e]=i(Oe[$e],Q))}}}}return o(Oe)}function E(U,Y,j,P,K,ne){var re=P==="BigNumber",fe=P==="Complex",pe=re?u(0):fe?y(0):0;re&&(j=u(j));for(var ce=0;ce<Y-2;ce++){for(var oe=0,Ce=pe,Oe=ce+1;Oe<Y;Oe++){var Me=U[Oe][ce];A(l(Ce),l(Me))&&(Ce=Me,oe=Oe)}if(!A(l(Ce),j)){if(oe!==ce+1){var $e=U[oe];U[oe]=U[ce+1],U[ce+1]=$e;for(var k=0;k<Y;k++){var W=U[k][oe];U[k][oe]=U[k][ce+1],U[k][ce+1]=W}if(K){var ie=ne[oe];ne[oe]=ne[ce+1],ne[ce+1]=ie}}for(var V=ce+2;V<Y;V++){var Q=s(U[V][ce],Ce);if(Q!==0){for(var te=0;te<Y;te++)U[V][te]=t(U[V][te],i(Q,U[ce+1][te]));for(var ge=0;ge<Y;ge++)U[ge][ce+1]=e(U[ge][ce+1],i(Q,U[ge][V]));if(K)for(var he=0;he<Y;he++)ne[V][he]=t(ne[V][he],i(Q,ne[ce+1][he]))}}}}return ne}function N(U,Y,j,P,K){var ne=P==="BigNumber",re=P==="Complex",fe=ne?u(1):re?y(1):1;ne&&(j=u(j));for(var pe=ke(U),ce=[],oe=Y,Ce=[],Oe=K?o(Array(Y).fill(fe)):void 0,Me=K?o(Array(oe).fill(fe)):void 0,$e=0;$e<=100;){$e+=1;for(var k=0,W=0;W<oe;W++)pe[W][W]=t(pe[W][W],k);var{Q:ie,R:V}=m(pe);pe=n(V,ie);for(var Q=0;Q<oe;Q++)pe[Q][Q]=e(pe[Q][Q],k);if(K&&(Me=n(Me,ie)),oe===1||A(l(pe[oe-1][oe-2]),j)){$e=0,ce.push(pe[oe-1][oe-1]),K&&(Ce.unshift([[1]]),B(Me,Y),Oe=n(Oe,Me),oe>1&&(Me=o(Array(oe-1).fill(fe)))),oe-=1,pe.pop();for(var te=0;te<oe;te++)pe[te].pop()}else if(oe===2||A(l(pe[oe-2][oe-3]),j)){$e=0;var ge=D(pe[oe-2][oe-2],pe[oe-2][oe-1],pe[oe-1][oe-2],pe[oe-1][oe-1]);ce.push(...ge),K&&(Ce.unshift(T(pe[oe-2][oe-2],pe[oe-2][oe-1],pe[oe-1][oe-2],pe[oe-1][oe-1],ge[0],ge[1],j,P)),B(Me,Y),Oe=n(Oe,Me),oe>2&&(Me=o(Array(oe-2).fill(fe)))),oe-=2,pe.pop(),pe.pop();for(var he=0;he<oe;he++)pe[he].pop(),pe[he].pop()}if(oe===0)break}if(ce.sort((ee,ue)=>+t(l(ee),l(ue))),$e>100){var q=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+ce.join(", "));throw q.values=ce,q.vectors=[],q}var z=K?n(Oe,_(Ce,Y)):void 0;return{values:ce,C:z}}function S(U,Y,j,P,K,ne,re){var fe=c(j),pe=n(fe,U,j),ce=re==="BigNumber",oe=re==="Complex",Ce=ce?u(0):oe?y(0):0,Oe=ce?u(1):oe?y(1):1,Me=[],$e=[];for(var k of K){var W=L(Me,k,h);W===-1?(Me.push(k),$e.push(1)):$e[W]+=1}for(var ie=[],V=Me.length,Q=Array(Y).fill(Ce),te=o(Array(Y).fill(Oe)),ge=[],he=function(ue){var me=Me[ue],ye=t(pe,n(me,te)),be=p(ye,Q);for(be.shift();be.length<$e[ue];){var ve=G(ye,Y,be,ne,re);if(ve==null){ge.push(me);break}be.push(ve)}var Ne=n(c(P),j);be=be.map(Ie=>n(Ne,Ie)),ie.push(...be.map(Ie=>a(Ie)))},q=0;q<V;q++)he(q);if(ge.length!==0){var z=new Error("Failed to find eigenvectors for the following eigenvalues: "+ge.join(", "));throw z.values=K,z.vectors=ie,z}return ie}function D(U,Y,j,P){var K=e(U,P),ne=t(i(U,P),i(Y,j)),re=i(K,.5),fe=i(f(t(i(K,K),i(4,ne))),.5);return[e(re,fe),t(re,fe)]}function T(U,Y,j,P,K,ne,re,fe){var pe=fe==="BigNumber",ce=fe==="Complex",oe=pe?u(0):ce?y(0):0,Ce=pe?u(1):ce?y(1):1;if(A(l(j),re))return[[Ce,oe],[oe,Ce]];if(b(l(t(K,ne)),re))return[[t(K,P),t(ne,P)],[j,j]];var Oe=t(U,K),Me=t(Y,K),$e=t(j,K),k=t(P,K);return A(l(Me),re)?[[Oe,Ce],[$e,oe]]:[[Me,oe],[k,Ce]]}function B(U,Y){for(var j=0;j<U.length;j++)U[j].push(...Array(Y-U[j].length).fill(0));for(var P=U.length;P<Y;P++)U.push(Array(Y).fill(0)),U[P][P]=1;return U}function _(U,Y){for(var j=[],P=0;P<Y;P++)j[P]=Array(Y).fill(0);var K=0;for(var ne of U){for(var re=ne.length,fe=0;fe<re;fe++)for(var pe=0;pe<re;pe++)j[K+fe][K+pe]=ne[fe][pe];K+=re}return j}function L(U,Y,j){for(var P=0;P<U.length;P++)if(j(U[P],Y))return P;return-1}function G(U,Y,j,P,K){for(var ne=K==="BigNumber"?u(1e3):1e3,re,fe=0;re=C(Y,j,K),re=v(U,re),!b(Z(re),ne);)if(++fe>=5)return null;for(fe=0;;){var pe=v(U,re);if(A(Z(F(re,[pe])),P))break;if(++fe>=10)return null;re=$(pe)}return re}function C(U,Y,j){var P=j==="BigNumber",K=j==="Complex",ne=Array(U).fill(0).map(re=>2*Math.random()-1);return P&&(ne=ne.map(re=>u(re))),K&&(ne=ne.map(re=>y(re))),ne=F(ne,Y),$(ne,j)}function F(U,Y){for(var j of Y)U=t(U,n(s(w(j,U),w(j,j)),j));return U}function Z(U){return l(f(w(U,U)))}function $(U,Y){var j=Y==="BigNumber",P=Y==="Complex",K=j?u(1):P?y(1):1;return n(s(K,Z(U)),U)}return x}function UF(r){var{config:e,addScalar:t,subtract:a,abs:n,atan:i,cos:s,sin:f,multiplyScalar:l,inv:u,bignumber:o,multiply:c,add:m}=r;function v(D,T){var B=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.epsilon,_=arguments.length>3?arguments[3]:void 0;if(_==="number")return p(D,B);if(_==="BigNumber")return h(D,B);throw TypeError("Unsupported data type: "+_)}function p(D,T){for(var B=D.length,_=Math.abs(T/B),L,G=new Array(B),C=0;C<B;C++)G[C]=S(B,0),G[C][C]=1;for(var F=g(D);Math.abs(F[1])>=Math.abs(_);){var Z=F[0][0],$=F[0][1];L=y(D[Z][Z],D[$][$],D[Z][$]),D=x(D,L,Z,$),G=A(G,L,Z,$),F=g(D)}for(var U=S(B,0),Y=0;Y<B;Y++)U[Y]=D[Y][Y];return N(ke(U),ke(G))}function h(D,T){for(var B=D.length,_=n(T/B),L,G=new Array(B),C=0;C<B;C++)G[C]=S(B,0),G[C][C]=1;for(var F=E(D);n(F[1])>=n(_);){var Z=F[0][0],$=F[0][1];L=b(D[Z][Z],D[$][$],D[Z][$]),D=w(D,L,Z,$),G=d(G,L,Z,$),F=E(D)}for(var U=S(B,0),Y=0;Y<B;Y++)U[Y]=D[Y][Y];return N(ke(U),ke(G))}function y(D,T,B){var _=T-D;return Math.abs(_)<=e.epsilon?Math.PI/4:.5*Math.atan(2*B/(T-D))}function b(D,T,B){var _=a(T,D);return n(_)<=e.epsilon?o(-1).acos().div(4):l(.5,i(c(2,B,u(_))))}function A(D,T,B,_){for(var L=D.length,G=Math.cos(T),C=Math.sin(T),F=S(L,0),Z=S(L,0),$=0;$<L;$++)F[$]=G*D[$][B]-C*D[$][_],Z[$]=C*D[$][B]+G*D[$][_];for(var U=0;U<L;U++)D[U][B]=F[U],D[U][_]=Z[U];return D}function d(D,T,B,_){for(var L=D.length,G=s(T),C=f(T),F=S(L,o(0)),Z=S(L,o(0)),$=0;$<L;$++)F[$]=a(l(G,D[$][B]),l(C,D[$][_])),Z[$]=t(l(C,D[$][B]),l(G,D[$][_]));for(var U=0;U<L;U++)D[U][B]=F[U],D[U][_]=Z[U];return D}function w(D,T,B,_){for(var L=D.length,G=o(s(T)),C=o(f(T)),F=l(G,G),Z=l(C,C),$=S(L,o(0)),U=S(L,o(0)),Y=c(o(2),G,C,D[B][_]),j=t(a(l(F,D[B][B]),Y),l(Z,D[_][_])),P=m(l(Z,D[B][B]),Y,l(F,D[_][_])),K=0;K<L;K++)$[K]=a(l(G,D[B][K]),l(C,D[_][K])),U[K]=t(l(C,D[B][K]),l(G,D[_][K]));D[B][B]=j,D[_][_]=P,D[B][_]=o(0),D[_][B]=o(0);for(var ne=0;ne<L;ne++)ne!==B&&ne!==_&&(D[B][ne]=$[ne],D[ne][B]=$[ne],D[_][ne]=U[ne],D[ne][_]=U[ne]);return D}function x(D,T,B,_){for(var L=D.length,G=Math.cos(T),C=Math.sin(T),F=G*G,Z=C*C,$=S(L,0),U=S(L,0),Y=F*D[B][B]-2*G*C*D[B][_]+Z*D[_][_],j=Z*D[B][B]+2*G*C*D[B][_]+F*D[_][_],P=0;P<L;P++)$[P]=G*D[B][P]-C*D[_][P],U[P]=C*D[B][P]+G*D[_][P];D[B][B]=Y,D[_][_]=j,D[B][_]=0,D[_][B]=0;for(var K=0;K<L;K++)K!==B&&K!==_&&(D[B][K]=$[K],D[K][B]=$[K],D[_][K]=U[K],D[K][_]=U[K]);return D}function g(D){for(var T=D.length,B=0,_=[0,1],L=0;L<T;L++)for(var G=L+1;G<T;G++)Math.abs(B)<Math.abs(D[L][G])&&(B=Math.abs(D[L][G]),_=[L,G]);return[_,B]}function E(D){for(var T=D.length,B=0,_=[0,1],L=0;L<T;L++)for(var G=L+1;G<T;G++)n(B)<n(D[L][G])&&(B=n(D[L][G]),_=[L,G]);return[_,B]}function N(D,T){for(var B=D.length,_=Array(B),L=Array(B),G=0;G<B;G++)L[G]=Array(B);for(var C=0;C<B;C++){for(var F=0,Z=D[0],$=0;$<D.length;$++)n(D[$])<n(Z)&&(F=$,Z=D[F]);_[C]=D.splice(F,1)[0];for(var U=0;U<B;U++)L[U][C]=T[U][F],T[U].splice(F,1)}return{values:_,vectors:L}}function S(D,T){for(var B=new Array(D),_=0;_<D;_++)B[_]=T;return B}return v}var kF="eigs",VF=["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"],GF=R(kF,VF,r=>{var{config:e,typed:t,matrix:a,addScalar:n,subtract:i,equal:s,abs:f,atan:l,cos:u,sin:o,multiplyScalar:c,divideScalar:m,inv:v,bignumber:p,multiply:h,add:y,larger:b,column:A,flatten:d,number:w,complex:x,sqrt:g,diag:E,qr:N,usolve:S,usolveAll:D,im:T,re:B,smaller:_,matrixFromColumns:L,dot:G}=r,C=UF({config:e,addScalar:n,subtract:i,column:A,flatten:d,equal:s,abs:f,atan:l,cos:u,sin:o,multiplyScalar:c,inv:v,bignumber:p,complex:x,multiply:h,add:y}),F=LF({config:e,addScalar:n,subtract:i,multiply:h,multiplyScalar:c,flatten:d,divideScalar:m,sqrt:g,abs:f,bignumber:p,diag:E,qr:N,inv:v,usolve:S,usolveAll:D,equal:s,complex:x,larger:b,smaller:_,matrixFromColumns:L,dot:G});return t("eigs",{Array:function(K){var ne=a(K);return Z(ne)},"Array, number|BigNumber":function(K,ne){var re=a(K);return Z(re,ne)},Matrix:function(K){var{values:ne,vectors:re}=Z(K);return{values:a(ne),vectors:a(re)}},"Matrix, number|BigNumber":function(K,ne){var{values:re,vectors:fe}=Z(K,ne);return{values:a(re),vectors:a(fe)}}});function Z(P,K){K===void 0&&(K=e.epsilon);var ne=P.size();if(ne.length!==2||ne[0]!==ne[1])throw new RangeError("Matrix must be square (size: "+Ye(ne)+")");var re=P.toArray(),fe=ne[0];if(U(re,fe,K)&&(Y(re,fe),$(re,fe,K))){var pe=j(P,re,fe);return C(re,fe,K,pe)}var ce=j(P,re,fe);return F(re,fe,K,ce)}function $(P,K,ne){for(var re=0;re<K;re++)for(var fe=re;fe<K;fe++)if(b(p(f(i(P[re][fe],P[fe][re]))),ne))return!1;return!0}function U(P,K,ne){for(var re=0;re<K;re++)for(var fe=0;fe<K;fe++)if(b(p(f(T(P[re][fe]))),ne))return!1;return!0}function Y(P,K){for(var ne=0;ne<K;ne++)for(var re=0;re<K;re++)P[ne][re]=B(P[ne][re])}function j(P,K,ne){var re=P.datatype();if(re==="number"||re==="BigNumber"||re==="Complex")return re;for(var fe=!1,pe=!1,ce=!1,oe=0;oe<ne;oe++)for(var Ce=0;Ce<ne;Ce++){var Oe=K[oe][Ce];if(tr(Oe)||_a(Oe))fe=!0;else if(rr(Oe))pe=!0;else if(zt(Oe))ce=!0;else throw TypeError("Unsupported type in Matrix: "+gr(Oe))}if(pe&&ce&&console.warn("Complex BigNumbers not supported, this operation will lose precission."),ce){for(var Me=0;Me<ne;Me++)for(var $e=0;$e<ne;$e++)K[Me][$e]=x(K[Me][$e]);return"Complex"}if(pe){for(var k=0;k<ne;k++)for(var W=0;W<ne;W++)K[k][W]=p(K[k][W]);return"BigNumber"}if(fe){for(var ie=0;ie<ne;ie++)for(var V=0;V<ne;V++)K[ie][V]=w(K[ie][V]);return"number"}else throw TypeError("Matrix contains unsupported types only.")}}),cp="expm",HF=["typed","abs","add","identity","inv","multiply"],ZF=R(cp,HF,r=>{var{typed:e,abs:t,add:a,identity:n,inv:i,multiply:s}=r;return e(cp,{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],p=1e-15,h=f(c),y=l(h,p),b=y.q,A=y.j,d=s(c,Math.pow(2,-A)),w=n(v),x=n(v),g=1,E=d,N=-1,S=1;S<=b;S++)S>1&&(E=s(E,d),N=-N),g=g*(b-S+1)/((2*b-S+1)*S),w=a(w,s(g,E)),x=a(x,s(g*N,E));for(var D=s(i(x),w),T=0;T<A;T++)D=s(D,D);return Nn(c)?c.createSparseMatrix(D):D}});function f(o){for(var c=o.size()[0],m=0,v=0;v<c;v++){for(var p=0,h=0;h<c;h++)p+=t(o.get([v,h]));m=Math.max(p,m)}return m}function l(o,c){for(var m=30,v=0;v<m;v++)for(var p=0;p<=v;p++){var h=v-p;if(u(o,p,h)<c)return{q:p,j:h}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}function u(o,c,m){for(var v=1,p=2;p<=c;p++)v*=p;for(var h=v,y=c+1;y<=2*c;y++)h*=y;var b=h*(2*c+1);return 8*Math.pow(o/Math.pow(2,m),2*c)*v*v/(h*b)}}),fp="sqrtm",JF=["typed","abs","add","multiply","map","sqrt","subtract","inv","size","max","identity"],WF=R(fp,JF,r=>{var{typed:e,abs:t,add:a,multiply:n,map:i,sqrt:s,subtract:f,inv:l,size:u,max:o,identity:c}=r,m=1e3,v=1e-6;function p(h){var y,b=0,A=h,d=c(u(h));do{var w=A;if(A=n(.5,a(w,l(d))),d=n(.5,a(d,l(w))),y=o(t(f(A,w))),y>v&&++b>m)throw new Error("computing square root of matrix: iterative method could not converge")}while(y>v);return A}return e(fp,{"Array | Matrix":function(y){var b=He(y)?y.size():er(y);switch(b.length){case 1:if(b[0]===1)return i(y,s);throw new RangeError("Matrix must be square (size: "+Ye(b)+")");case 2:{var A=b[0],d=b[1];if(A===d)return p(y);throw new RangeError("Matrix must be square (size: "+Ye(b)+")")}default:throw new RangeError("Matrix must be at most two dimensional (size: "+Ye(b)+")")}}})}),XF="divide",YF=["typed","matrix","multiply","equalScalar","divideScalar","inv"],QF=R(XF,YF,r=>{var{typed:e,matrix:t,multiply:a,equalScalar:n,divideScalar:i,inv:s}=r,f=Lr({typed:e,equalScalar:n}),l=yt({typed:e});return e("divide",Qu({"Array | Matrix, Array | Matrix":function(o,c){return a(o,s(c))},"DenseMatrix, any":function(o,c){return l(o,c,i,!1)},"SparseMatrix, any":function(o,c){return f(o,c,i,!1)},"Array, any":function(o,c){return l(t(o),c,i,!1).valueOf()},"any, Array | Matrix":function(o,c){return a(o,s(c))}},i.signatures))}),mp="distance",KF=["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],jF=R(mp,KF,r=>{var{typed:e,addScalar:t,subtract:a,multiplyScalar:n,divideScalar:i,unaryMinus:s,sqrt:f,abs:l}=r;return e(mp,{"Array, Array, Array":function(x,g,E){if(x.length===2&&g.length===2&&E.length===2){if(!o(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!o(g))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!o(E))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var N=i(a(E[1],E[0]),a(g[1],g[0])),S=n(n(N,N),g[0]),D=s(n(N,g[0])),T=x[1];return y(x[0],x[1],S,D,T)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(x,g,E){if(Object.keys(x).length===2&&Object.keys(g).length===2&&Object.keys(E).length===2){if(!o(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!o(g))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!o(E))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"lineOnePtX"in g&&"lineOnePtY"in g&&"lineTwoPtX"in E&&"lineTwoPtY"in E){var N=i(a(E.lineTwoPtY,E.lineTwoPtX),a(g.lineOnePtY,g.lineOnePtX)),S=n(n(N,N),g.lineOnePtX),D=s(n(N,g.lineOnePtX)),T=x.pointX;return y(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,g){if(x.length===2&&g.length===3){if(!o(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!c(g))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return y(x[0],x[1],g[0],g[1],g[2])}else if(x.length===3&&g.length===6){if(!c(x))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!v(g))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return b(x[0],x[1],x[2],g[0],g[1],g[2],g[3],g[4],g[5])}else if(x.length===g.length&&x.length>0){if(!m(x))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!m(g))throw new TypeError("All values of an array should be numbers or BigNumbers");return A(x,g)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(x,g){if(Object.keys(x).length===2&&Object.keys(g).length===3){if(!o(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!c(g))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"xCoeffLine"in g&&"yCoeffLine"in g&&"constant"in g)return y(x.pointX,x.pointY,g.xCoeffLine,g.yCoeffLine,g.constant);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===3&&Object.keys(g).length===6){if(!c(x))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!v(g))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 g&&"y0"in g&&"z0"in g&&"a"in g&&"b"in g&&"c"in g)return b(x.pointX,x.pointY,x.pointZ,g.x0,g.y0,g.z0,g.a,g.b,g.c);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===2&&Object.keys(g).length===2){if(!o(x))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!o(g))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in x&&"pointOneY"in x&&"pointTwoX"in g&&"pointTwoY"in g)return A([x.pointOneX,x.pointOneY],[g.pointTwoX,g.pointTwoY]);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===3&&Object.keys(g).length===3){if(!c(x))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!c(g))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 g&&"pointTwoY"in g&&"pointTwoZ"in g)return A([x.pointOneX,x.pointOneY,x.pointOneZ],[g.pointTwoX,g.pointTwoY,g.pointTwoZ]);throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},Array:function(x){if(!h(x))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return d(x)}});function u(w){return typeof w=="number"||rr(w)}function o(w){return w.constructor!==Array&&(w=p(w)),u(w[0])&&u(w[1])}function c(w){return w.constructor!==Array&&(w=p(w)),u(w[0])&&u(w[1])&&u(w[2])}function m(w){return Array.isArray(w)||(w=p(w)),w.every(u)}function v(w){return w.constructor!==Array&&(w=p(w)),u(w[0])&&u(w[1])&&u(w[2])&&u(w[3])&&u(w[4])&&u(w[5])}function p(w){for(var x=Object.keys(w),g=[],E=0;E<x.length;E++)g.push(w[x[E]]);return g}function h(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 y(w,x,g,E,N){var S=l(t(t(n(g,w),n(E,x)),N)),D=f(t(n(g,g),n(E,E)));return i(S,D)}function b(w,x,g,E,N,S,D,T,B){var _=[a(n(a(N,x),B),n(a(S,g),T)),a(n(a(S,g),D),n(a(E,w),B)),a(n(a(E,w),T),n(a(N,x),D))];_=f(t(t(n(_[0],_[0]),n(_[1],_[1])),n(_[2],_[2])));var L=f(t(t(n(D,D),n(T,T)),n(B,B)));return i(_,L)}function A(w,x){for(var g=w.length,E=0,N=0,S=0;S<g;S++)N=a(w[S],x[S]),E=t(n(N,N),E);return f(E)}function d(w){for(var x=[],g=[],E=[],N=0;N<w.length-1;N++)for(var S=N+1;S<w.length;S++)w[0].length===2?(g=[w[N][0],w[N][1]],E=[w[S][0],w[S][1]]):w[0].length===3&&(g=[w[N][0],w[N][1],w[N][2]],E=[w[S][0],w[S][1],w[S][2]]),x.push(A(g,E));return x}}),e4="intersect",r4=["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],t4=R(e4,r4,r=>{var{typed:e,config:t,abs:a,add:n,addScalar:i,matrix:s,multiply:f,multiplyScalar:l,divideScalar:u,subtract:o,smaller:c,equalScalar:m,flatten:v,isZero:p,isNumeric:h}=r;return e("intersect",{"Array, Array, Array":y,"Array, Array, Array, Array":b,"Matrix, Matrix, Matrix":function(T,B,_){var L=y(T.valueOf(),B.valueOf(),_.valueOf());return L===null?null:s(L)},"Matrix, Matrix, Matrix, Matrix":function(T,B,_,L){var G=b(T.valueOf(),B.valueOf(),_.valueOf(),L.valueOf());return G===null?null:s(G)}});function y(D,T,B){if(D=A(D),T=A(T),B=A(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 b(D,T,B,_){if(D=A(D),T=A(T),B=A(B),_=A(_),D.length===2){if(!d(D))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!d(T))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!d(B))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!d(_))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return g(D,T,B,_)}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(_))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return N(D[0],D[1],D[2],T[0],T[1],T[2],B[0],B[1],B[2],_[0],_[1],_[2])}else throw new TypeError("Arrays with two or thee dimensional points expected")}function A(D){return D.length===1?D[0]:D.length>1&&Array.isArray(D[0])&&D.every(T=>Array.isArray(T)&&T.length===1)?v(D):D}function d(D){return D.length===2&&h(D[0])&&h(D[1])}function w(D){return D.length===3&&h(D[0])&&h(D[1])&&h(D[2])}function x(D){return D.length===4&&h(D[0])&&h(D[1])&&h(D[2])&&h(D[3])}function g(D,T,B,_){var L=D,G=B,C=o(L,T),F=o(G,_),Z=o(l(C[0],F[1]),l(F[0],C[1]));if(p(Z)||c(a(Z),t.epsilon))return null;var $=l(F[0],L[1]),U=l(F[1],L[0]),Y=l(F[0],G[1]),j=l(F[1],G[0]),P=u(i(o(o($,U),Y),j),Z);return n(f(C,P),L)}function E(D,T,B,_,L,G,C,F,Z,$,U,Y){var j=l(o(D,T),o(B,_)),P=l(o(L,G),o(C,F)),K=l(o(Z,$),o(U,Y));return i(i(j,P),K)}function N(D,T,B,_,L,G,C,F,Z,$,U,Y){var j=E(D,C,$,C,T,F,U,F,B,Z,Y,Z),P=E($,C,_,D,U,F,L,T,Y,Z,G,B),K=E(D,C,_,D,T,F,L,T,B,Z,G,B),ne=E($,C,$,C,U,F,U,F,Y,Z,Y,Z),re=E(_,D,_,D,L,T,L,T,G,B,G,B),fe=o(l(j,P),l(K,ne)),pe=o(l(re,ne),l(P,P));if(p(pe))return null;var ce=u(fe,pe),oe=u(i(j,l(ce,P)),ne),Ce=i(D,l(ce,o(_,D))),Oe=i(T,l(ce,o(L,T))),Me=i(B,l(ce,o(G,B))),$e=i(C,l(oe,o($,C))),k=i(F,l(oe,o(U,F))),W=i(Z,l(oe,o(Y,Z)));return m(Ce,$e)&&m(Oe,k)&&m(Me,W)?[Ce,Oe,Me]:null}function S(D,T,B,_,L,G,C,F,Z,$){var U=l(D,C),Y=l(_,C),j=l(T,F),P=l(L,F),K=l(B,Z),ne=l(G,Z),re=o(o(o($,U),j),K),fe=o(o(o(i(i(Y,P),ne),U),j),K),pe=u(re,fe),ce=i(D,l(pe,o(_,D))),oe=i(T,l(pe,o(L,T))),Ce=i(B,l(pe,o(G,B)));return[ce,oe,Ce]}}),vp="sum",n4=["typed","config","add","numeric"],pp=R(vp,n4,r=>{var{typed:e,config:t,add:a,numeric:n}=r;return e(vp,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":s,"...":function(l){if(Qn(l))throw new TypeError("Scalar values expected in function sum");return i(l)}});function i(f){var l;return Gt(f,function(u){try{l=l===void 0?u:a(l,u)}catch(o){throw Yr(o,"sum",u)}}),l===void 0&&(l=n(0,t.number)),typeof l=="string"&&(l=n(l,t.number)),l}function s(f,l){try{var u=wi(f,l,a);return u}catch(o){throw Yr(o,"sum")}}}),eo="cumsum",a4=["typed","add","unaryPlus"],hp=R(eo,a4,r=>{var{typed:e,add:t,unaryPlus:a}=r;return e(eo,{Array:n,Matrix:function(u){return u.create(n(u.valueOf()))},"Array, number | BigNumber":s,"Matrix, number | BigNumber":function(u,o){return u.create(s(u.valueOf(),o))},"...":function(u){if(Qn(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 Yr(u,eo)}}function i(l){if(l.length===0)return[];for(var u=[a(l[0])],o=1;o<l.length;++o)u.push(t(u[o-1],l[o]));return u}function s(l,u){var o=er(l);if(u<0||u>=o.length)throw new pt(u,o.length);try{return f(l,u)}catch(c){throw Yr(c,eo)}}function f(l,u){var o,c,m;if(u<=0){var v=l[0][0];if(Array.isArray(v)){for(m=ql(l),c=[],o=0;o<m.length;o++)c[o]=f(m[o],u-1);return c}else return i(l)}else{for(c=[],o=0;o<l.length;o++)c[o]=f(l[o],u-1);return c}}}),dp="mean",i4=["typed","add","divide"],gp=R(dp,i4,r=>{var{typed:e,add:t,divide:a}=r;return e(dp,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":n,"...":function(f){if(Qn(f))throw new TypeError("Scalar values expected in function mean");return i(f)}});function n(s,f){try{var l=wi(s,f,t),u=Array.isArray(s)?er(s):s.size();return a(l,u[f])}catch(o){throw Yr(o,"mean")}}function i(s){var f,l=0;if(Gt(s,function(u){try{f=f===void 0?u:t(f,u),l++}catch(o){throw Yr(o,"mean",u)}}),l===0)throw new Error("Cannot calculate the mean of an empty array");return a(f,l)}}),yp="median",o4=["typed","add","divide","compare","partitionSelect"],s4=R(yp,o4,r=>{var{typed:e,add:t,divide:a,compare:n,partitionSelect:i}=r;function s(u){try{u=ar(u.valueOf());var o=u.length;if(o===0)throw new Error("Cannot calculate median of an empty array");if(o%2===0){for(var c=o/2-1,m=i(u,c+1),v=u[c],p=0;p<c;++p)n(u[p],v)>0&&(v=u[p]);return l(v,m)}else{var h=i(u,(o-1)/2);return f(h)}}catch(y){throw Yr(y,"median")}}var f=e({"number | BigNumber | Complex | Unit":function(o){return o}}),l=e({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(o,c){return a(t(o,c),2)}});return e(yp,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(o,c){throw new Error("median(A, dim) is not yet supported")},"...":function(o){if(Qn(o))throw new TypeError("Scalar values expected in function median");return s(o)}})}),bp="mad",u4=["typed","abs","map","median","subtract"],l4=R(bp,u4,r=>{var{typed:e,abs:t,map:a,median:n,subtract:i}=r;return e(bp,{"Array | Matrix":s,"...":function(l){return s(l)}});function s(f){if(f=ar(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")):Yr(u,"mad")}}}),bs="unbiased",xp="variance",c4=["typed","add","subtract","multiply","divide","apply","isNaN"],wp=R(xp,c4,r=>{var{typed:e,add:t,subtract:a,multiply:n,divide:i,apply:s,isNaN:f}=r;return e(xp,{"Array | Matrix":function(c){return l(c,bs)},"Array | Matrix, string":l,"Array | Matrix, number | BigNumber":function(c,m){return u(c,m,bs)},"Array | Matrix, number | BigNumber, string":u,"...":function(c){return l(c,bs)}});function l(o,c){var m,v=0;if(o.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Gt(o,function(y){try{m=m===void 0?y:t(m,y),v++}catch(b){throw Yr(b,"variance",y)}}),v===0)throw new Error("Cannot calculate variance of an empty array");var p=i(m,v);if(m=void 0,Gt(o,function(y){var b=a(y,p);m=m===void 0?n(b,b):t(m,n(b,b))}),f(m))return m;switch(c){case"uncorrected":return i(m,v);case"biased":return i(m,v+1);case"unbiased":{var h=rr(m)?m.mul(0):0;return v===1?h:i(m,v-1)}default:throw new Error('Unknown normalization "'+c+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function u(o,c,m){try{if(o.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return s(o,c,v=>l(v,m))}catch(v){throw Yr(v,"variance")}}}),f4="quantileSeq",m4=["typed","add","multiply","partitionSelect","compare"],v4=R(f4,m4,r=>{var{typed:e,add:t,multiply:a,partitionSelect:n,compare:i}=r;function s(u,o,c){var m,v,p;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(Lt(u)){if(c=c||!1,typeof c=="boolean"){if(v=u.valueOf(),tr(o)){if(o<0)throw new Error("N/prob must be non-negative");if(o<=1)return f(v,o,c);if(o>1){if(!qe(o))throw new Error("N must be a positive integer");var h=o+1;m=new Array(o);for(var y=0;y<o;)m[y]=f(v,++y/h,c);return m}}if(rr(o)){var b=o.constructor;if(o.isNegative())throw new Error("N/prob must be non-negative");if(p=new b(1),o.lte(p))return new b(f(v,o,c));if(o.gt(p)){if(!o.isInteger())throw new Error("N must be a positive integer");var A=o.toNumber();if(A>4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var d=new b(A+1);m=new Array(A);for(var w=0;w<A;)m[w]=new b(f(v,new b(++w).div(d),c));return m}}if(Array.isArray(o)){m=new Array(o.length);for(var x=0;x<m.length;++x){var g=o[x];if(tr(g)){if(g<0||g>1)throw new Error("Probability must be between 0 and 1, inclusive")}else if(rr(g)){if(p=new g.constructor(1),g.isNegative()||g.gt(p))throw new Error("Probability must be between 0 and 1, inclusive")}else throw new TypeError("Unexpected type of argument in function quantileSeq");m[x]=f(v,g,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,o,c){var m=ar(u),v=m.length;if(v===0)throw new Error("Cannot calculate quantile of an empty sequence");if(tr(o)){var p=o*(v-1),h=p%1;if(h===0){var y=c?m[p]:n(m,p);return l(y),y}var b=Math.floor(p),A,d;if(c)A=m[b],d=m[b+1];else{d=n(m,b+1),A=m[b];for(var w=0;w<b;++w)i(m[w],A)>0&&(A=m[w])}return l(A),l(d),t(a(A,1-h),a(d,h))}var x=o.times(v-1);if(x.isInteger()){x=x.toNumber();var g=c?m[x]:n(m,x);return l(g),g}var E=x.floor(),N=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 _=new N.constructor(1);return t(a(D,_.minus(N)),a(T,N))}var l=e({"number | BigNumber | Unit":function(o){return o}});return s}),Np="std",p4=["typed","map","sqrt","variance"],Dp=R(Np,p4,r=>{var{typed:e,map:t,sqrt:a,variance:n}=r;return e(Np,{"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(s,f){if(s.length===0)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{var l=n.apply(null,arguments);return Lt(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}}}),Ap="combinations",h4=["typed"],d4=R(Ap,h4,r=>{var{typed:e}=r;return e(Ap,{"number, number":fc,"BigNumber, BigNumber":function(a,n){var i=a.constructor,s,f,l=a.minus(n),u=new i(1);if(!Ep(a)||!Ep(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(s=u,n.lt(l))for(f=u;f.lte(l);f=f.plus(u))s=s.times(n.plus(f)).dividedBy(f);else for(f=u;f.lte(n);f=f.plus(u))s=s.times(l.plus(f)).dividedBy(f);return s}})});function Ep(r){return r.isInteger()&&r.gte(0)}var Sp="combinationsWithRep",g4=["typed"],y4=R(Sp,g4,r=>{var{typed:e}=r;return e(Sp,{"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=Ht(a,a+n-1);return i/Ht(1,n)}var s=Ht(n+1,a+n-1);return s/Ht(1,a-1)},"BigNumber, BigNumber":function(a,n){var i=a.constructor,s,f,l=new i(1),u=a.minus(l);if(!Cp(a)||!Cp(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(s=l,n.lt(u))for(f=l;f.lte(u);f=f.plus(l))s=s.times(n.plus(f)).dividedBy(f);else for(f=l;f.lte(n);f=f.plus(l))s=s.times(u.plus(f)).dividedBy(f);return s}})});function Cp(r){return r.isInteger()&&r.gte(0)}var Mp="gamma",b4=["typed","config","multiplyScalar","pow","BigNumber","Complex"],x4=R(Mp,b4,r=>{var{typed:e,config:t,multiplyScalar:a,pow:n,BigNumber:i,Complex:s}=r;function f(u){if(u.im===0)return Di(u.re);if(u.re<.5){var o=new s(1-u.re,-u.im),c=new s(Math.PI*u.re,Math.PI*u.im);return new s(Math.PI).div(c.sin()).div(f(o))}u=new s(u.re-1,u.im);for(var m=new s(jn[0],0),v=1;v<jn.length;++v){var p=new s(jn[v],0);m=m.add(p.div(u.add(v)))}var h=new s(u.re+dc+.5,u.im),y=Math.sqrt(2*Math.PI),b=h.pow(u.add(.5)),A=h.neg().exp();return m.mul(y).mul(b).mul(A)}return e(Mp,{number:Di,Complex:f,BigNumber:function(o){if(o.isInteger())return o.isNegative()||o.isZero()?new i(1/0):l(o.minus(1));if(!o.isFinite())return new i(o.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 o=t.precision+(Math.log(u.toNumber())|0),c=i.clone({precision:o});if(u%2===1)return u.times(l(new i(u-1)));for(var m=u,v=new c(u),p=u.toNumber();m>2;)m-=2,p+=m,v=v.times(p);return new i(v.toPrecision(i.precision))}}),Fp="lgamma",w4=["Complex","typed"],N4=R(Fp,w4,r=>{var{Complex:e,typed:t}=r,a=7,n=7,i=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return t(Fp,{number:Ai,Complex:s,BigNumber:function(){throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function s(u){var o=6.283185307179586,c=1.1447298858494002,m=.1;if(u.isNaN())return new e(NaN,NaN);if(u.im===0)return new e(Ai(u.re),0);if(u.re>=a||Math.abs(u.im)>=n)return f(u);if(u.re<=m){var v=k0(o,u.im)*Math.floor(.5*u.re+.25),p=u.mul(Math.PI).sin().log(),h=s(new e(1-u.re,-u.im));return new e(c,v).sub(p).sub(h)}else return u.im>=0?l(u):l(u.conjugate()).conjugate()}function f(u){for(var o=u.sub(.5).mul(u.log()).sub(u).add(gc),c=new e(1,0).div(u),m=c.div(u),v=i[0],p=i[1],h=2*m.re,y=m.re*m.re+m.im*m.im,b=2;b<8;b++){var A=p;p=-y*v+i[b],v=h*v+A}var d=c.mul(m.mul(v).add(p));return o.add(d)}function l(u){var o=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&&o++,c=v,u=u.add(1)}return f(u).sub(m.log()).sub(new e(0,o*2*Math.PI*1))}}),Tp="factorial",D4=["typed","gamma"],A4=R(Tp,D4,r=>{var{typed:e,gamma:t}=r;return e(Tp,{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))})}),Bp="kldivergence",E4=["typed","matrix","divide","sum","multiply","map","dotDivide","log","isNumeric"],S4=R(Bp,E4,r=>{var{typed:e,matrix:t,divide:a,sum:n,multiply:i,map:s,dotDivide:f,log:l,isNumeric:u}=r;return e(Bp,{"Array, Array":function(m,v){return o(t(m),t(v))},"Matrix, Array":function(m,v){return o(m,t(v))},"Array, Matrix":function(m,v){return o(t(m),v)},"Matrix, Matrix":function(m,v){return o(m,v)}});function o(c,m){var v=m.size().length,p=c.size().length;if(v>1)throw new Error("first object must be one dimensional");if(p>1)throw new Error("second object must be one dimensional");if(v!==p)throw new Error("Length of two vectors must be equal");var h=n(c);if(h===0)throw new Error("Sum of elements in first object must be non zero");var y=n(m);if(y===0)throw new Error("Sum of elements in second object must be non zero");var b=a(c,n(c)),A=a(m,n(m)),d=n(i(b,s(f(b,A),w=>l(w))));return u(d)?d:Number.NaN}}),$p="multinomial",C4=["typed","add","divide","multiply","factorial","isInteger","isPositive"],M4=R($p,C4,r=>{var{typed:e,add:t,divide:a,multiply:n,factorial:i,isInteger:s,isPositive:f}=r;return e($p,{"Array | Matrix":function(u){var o=0,c=1;return Gt(u,function(m){if(!s(m)||!f(m))throw new TypeError("Positive integer value expected in function multinomial");o=t(o,m),c=n(c,i(m))}),a(i(o),c)}})}),Op="permutations",F4=["typed","factorial"],T4=R(Op,F4,r=>{var{typed:e,factorial:t}=r;return e(Op,{"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 Ht(n-i+1,n)},"BigNumber, BigNumber":function(n,i){var s,f;if(!_p(n)||!_p(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(s=l,f=n.minus(i).plus(1);f.lte(n);f=f.plus(1))s=s.times(f);return s}})});function _p(r){return r.isInteger()&&r.gte(0)}var Ip={exports:{}};(function(r){(function(e,t,a){function n(l){var u=this,o=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=o(" "),u.s1=o(" "),u.s2=o(" "),u.s0-=o(l),u.s0<0&&(u.s0+=1),u.s1-=o(l),u.s1<0&&(u.s1+=1),u.s2-=o(l),u.s2<0&&(u.s2+=1),o=null}function i(l,u){return u.c=l.c,u.s0=l.s0,u.s1=l.s1,u.s2=l.s2,u}function s(l,u){var o=new n(l),c=u&&u.state,m=o.next;return m.int32=function(){return o.next()*4294967296|0},m.double=function(){return m()+(m()*2097152|0)*11102230246251565e-32},m.quick=m,c&&(typeof c=="object"&&i(c,o),m.state=function(){return i(o,{})}),m}function f(){var l=4022871197,u=function(o){o=String(o);for(var c=0;c<o.length;c++){l+=o.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=s:a&&a.amd?a(function(){return s}):this.alea=s})(Sn,r,!1)})(Ip);var Rp={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 o=0;o<u.length+64;o++)l.x^=u.charCodeAt(o)|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 s(f,l){var u=new n(f),o=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,p=(m+v)/(1<<21);while(p===0);return p},c.int32=u.next,c.quick=c,o&&(typeof o=="object"&&i(o,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=s:a&&a.amd?a(function(){return s}):this.xor128=s})(Sn,r,!1)})(Rp);var qp={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 o=0;o<u.length+64;o++)l.x^=u.charCodeAt(o)|0,o==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 s(f,l){var u=new n(f),o=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,p=(m+v)/(1<<21);while(p===0);return p},c.int32=u.next,c.quick=c,o&&(typeof o=="object"&&i(o,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=s:a&&a.amd?a(function(){return s}):this.xorwow=s})(Sn,r,!1)})(qp);var zp={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this;l.next=function(){var o=l.x,c=l.i,m,v;return m=o[c],m^=m>>>7,v=m^m<<24,m=o[c+1&7],v^=m^m>>>10,m=o[c+3&7],v^=m^m>>>3,m=o[c+4&7],v^=m^m<<7,m=o[c+7&7],m=m^m<<13,v^=m^m<<9,o[c]=v,l.i=c+1&7,v};function u(o,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],o.x=v,o.i=0,m=256;m>0;--m)o.next()}u(l,f)}function i(f,l){return l.x=f.x.slice(),l.i=f.i,l}function s(f,l){f==null&&(f=+new Date);var u=new n(f),o=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,p=(m+v)/(1<<21);while(p===0);return p},c.int32=u.next,c.quick=c,o&&(o.x&&i(o,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=s:a&&a.amd?a(function(){return s}):this.xorshift7=s})(Sn,r,!1)})(zp);var Pp={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this;l.next=function(){var o=l.w,c=l.X,m=l.i,v,p;return l.w=o=o+1640531527|0,p=c[m+34&127],v=c[m=m+1&127],p^=p<<13,v^=v<<17,p^=p>>>15,v^=v>>>12,p=c[m]=p^v,l.i=m,p+(o^o>>>16)|0};function u(o,c){var m,v,p,h,y,b=[],A=128;for(c===(c|0)?(v=c,c=null):(c=c+"\0",v=0,A=Math.max(A,c.length)),p=0,h=-32;h<A;++h)c&&(v^=c.charCodeAt((h+32)%c.length)),h===0&&(y=v),v^=v<<10,v^=v>>>15,v^=v<<4,v^=v>>>13,h>=0&&(y=y+1640531527|0,m=b[h&127]^=v+y,p=m==0?p+1:0);for(p>=128&&(b[(c&&c.length||0)&127]=-1),p=127,h=4*128;h>0;--h)v=b[p+34&127],m=b[p=p+1&127],v^=v<<13,m^=m<<17,v^=v>>>15,m^=m>>>12,b[p]=v^m;o.w=y,o.X=b,o.i=p}u(l,f)}function i(f,l){return l.i=f.i,l.w=f.w,l.X=f.X.slice(),l}function s(f,l){f==null&&(f=+new Date);var u=new n(f),o=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,p=(m+v)/(1<<21);while(p===0);return p},c.int32=u.next,c.quick=c,o&&(o.X&&i(o,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=s:a&&a.amd?a(function(){return s}):this.xor4096=s})(Sn,r,!1)})(Pp);var Lp={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,p=l.a;return c=c<<25^c>>>7^m,m=m-v|0,v=v<<24^v>>>8^p,p=p-c|0,l.b=c=c<<20^c>>>12^m,l.c=m=m-v|0,l.d=v<<16^m>>>16^p,l.a=p-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 o=0;o<u.length+20;o++)l.b^=u.charCodeAt(o)|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 s(f,l){var u=new n(f),o=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,p=(m+v)/(1<<21);while(p===0);return p},c.int32=u.next,c.quick=c,o&&(typeof o=="object"&&i(o,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=s:a&&a.amd?a(function(){return s}):this.tychei=s})(Sn,r,!1)})(Lp);var Up={exports:{}};const B4=o1(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(r){(function(e,t,a){var n=256,i=6,s=52,f="random",l=a.pow(n,i),u=a.pow(2,s),o=u*2,c=n-1,m;function v(w,x,g){var E=[];x=x==!0?{entropy:!0}:x||{};var N=b(y(x.entropy?[w,d(t)]:w==null?A():w,3),E),S=new p(E),D=function(){for(var T=S.g(i),B=l,_=0;T<u;)T=(T+_)*n,B*=n,_=S.g(1);for(;T>=o;)T/=2,B/=2,_>>>=1;return(T+_)/B};return D.int32=function(){return S.g(4)|0},D.quick=function(){return S.g(4)/4294967296},D.double=D,b(d(S.S),t),(x.pass||g||function(T,B,_,L){return L&&(L.S&&h(L,S),T.state=function(){return h(S,{})}),_?(a[f]=T,B):T})(D,N,"global"in x?x.global:this==a,x.state)}function p(w){var x,g=w.length,E=this,N=0,S=E.i=E.j=0,D=E.S=[];for(g||(w=[g++]);N<n;)D[N]=N++;for(N=0;N<n;N++)D[N]=D[S=c&S+w[N%g]+(x=D[N])],D[S]=x;(E.g=function(T){for(var B,_=0,L=E.i,G=E.j,C=E.S;T--;)B=C[L=c&L+1],_=_*n+C[c&(C[L]=C[G=c&G+B])+(C[G]=B)];return E.i=L,E.j=G,_})(n)}function h(w,x){return x.i=w.i,x.j=w.j,x.S=w.S.slice(),x}function y(w,x){var g=[],E=typeof w,N;if(x&&E=="object")for(N in w)try{g.push(y(w[N],x-1))}catch{}return g.length?g:E=="string"?w:w+"\0"}function b(w,x){for(var g=w+"",E,N=0;N<g.length;)x[c&N]=c&(E^=x[c&N]*19)+g.charCodeAt(N++);return d(x)}function A(){try{var w;return m&&(w=m.randomBytes)?w=w(n):(w=new Uint8Array(n),(e.crypto||e.msCrypto).getRandomValues(w)),d(w)}catch{var x=e.navigator,g=x&&x.plugins;return[+new Date,e,g,e.screen,d(t)]}}function d(w){return String.fromCharCode.apply(0,w)}if(b(a.random(),t),r.exports){r.exports=v;try{m=B4}catch{}}else a["seed"+f]=v})(typeof self<"u"?self:Sn,[],Math)})(Up);var $4=Ip.exports,O4=Rp.exports,_4=qp.exports,I4=zp.exports,R4=Pp.exports,q4=Lp.exports,Fn=Up.exports;Fn.alea=$4,Fn.xor128=O4,Fn.xorwow=_4,Fn.xorshift7=I4,Fn.xor4096=R4,Fn.tychei=q4;var kp=Fn,z4=kp(Date.now());function oa(r){var e;function t(n){e=n===null?z4:kp(String(n))}t(r);function a(){return e()}return a}var Vp="pickRandom",P4=["typed","config","?on"],L4=R(Vp,P4,r=>{var{typed:e,config:t,on:a}=r,n=oa(t.randomSeed);return a&&a("config",function(s,f){s.randomSeed!==f.randomSeed&&(n=oa(s.randomSeed))}),e(Vp,{"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(s,f){var{number:l,weights:u,elementWise:o=!0}=f,c=typeof l>"u";c&&(l=1);var m=He(s)?s.create:He(u)?u.create:null;s=s.valueOf(),u&&(u=u.valueOf()),o===!0&&(s=ar(s),u=ar(u));var v=0;if(typeof u<"u"){if(u.length!==s.length)throw new Error("Weights must have the same length as possibles");for(var p=0,h=u.length;p<h;p++){if(!tr(u[p])||u[p]<0)throw new Error("Weights must be an array of positive numbers");v+=u[p]}}for(var y=s.length,b=[],A;b.length<l;){if(typeof u>"u")A=s[Math.floor(n()*y)];else for(var d=n()*v,w=0,x=s.length;w<x;w++)if(d-=u[w],d<0){A=s[w];break}b.push(A)}return c?b[0]:m?m(b):b}});function xs(r,e){var t=[];if(r=r.slice(0),r.length>1)for(var a=0,n=r.shift();a<n;a++)t.push(xs(r,e));else for(var i=0,s=r.shift();i<s;i++)t.push(e());return t}var Gp="random",U4=["typed","config","?on"],k4=R(Gp,U4,r=>{var{typed:e,config:t,on:a}=r,n=oa(t.randomSeed);return a&&a("config",function(f,l){f.randomSeed!==l.randomSeed&&(n=oa(f.randomSeed))}),e(Gp,{"":()=>s(0,1),number:f=>s(0,f),"number, number":(f,l)=>s(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 o=xs(f.valueOf(),()=>s(l,u));return He(f)?f.create(o):o}function s(f,l){return f+n()*(l-f)}}),Hp="randomInt",V4=["typed","config","?on"],G4=R(Hp,V4,r=>{var{typed:e,config:t,on:a}=r,n=oa(t.randomSeed);return a&&a("config",function(f,l){f.randomSeed!==l.randomSeed&&(n=oa(f.randomSeed))}),e(Hp,{"":()=>s(0,1),number:f=>s(0,f),"number, number":(f,l)=>s(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 o=xs(f.valueOf(),()=>s(l,u));return He(f)?f.create(o):o}function s(f,l){return Math.floor(f+n()*(l-f))}}),Zp="stirlingS2",H4=["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],Z4=R(Zp,H4,r=>{var{typed:e,addScalar:t,subtract:a,multiplyScalar:n,divideScalar:i,pow:s,factorial:f,combinations:l,isNegative:u,isInteger:o,number:c,bignumber:m,larger:v}=r,p=[],h=[];return e(Zp,{"number | BigNumber, number | BigNumber":function(b,A){if(!o(b)||u(b)||!o(A)||u(A))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(v(A,b))throw new TypeError("k must be less than or equal to n in function stirlingS2");var d=!(tr(b)&&tr(A)),w=d?h:p,x=d?m:c,g=c(b),E=c(A);if(w[g]&&w[g].length>E)return w[g][E];for(var N=0;N<=g;++N)if(w[N]||(w[N]=[x(N===0?1:0)]),N!==0)for(var S=w[N],D=w[N-1],T=S.length;T<=N&&T<=E;++T)T===N?S[T]=1:S[T]=t(n(x(T),D[T]),D[T-1]);return w[g][E]}})}),Jp="bellNumbers",J4=["typed","addScalar","isNegative","isInteger","stirlingS2"],W4=R(Jp,J4,r=>{var{typed:e,addScalar:t,isNegative:a,isInteger:n,stirlingS2:i}=r;return e(Jp,{"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}})}),Wp="catalan",X4=["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],Y4=R(Wp,X4,r=>{var{typed:e,addScalar:t,divideScalar:a,multiplyScalar:n,combinations:i,isNegative:s,isInteger:f}=r;return e(Wp,{"number | BigNumber":function(u){if(!f(u)||s(u))throw new TypeError("Non-negative integer value expected in function catalan");return a(i(n(u,2),u),t(u,1))}})}),Xp="composition",Q4=["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],K4=R(Xp,Q4,r=>{var{typed:e,addScalar:t,combinations:a,isPositive:n,isNegative:i,isInteger:s,larger:f}=r;return e(Xp,{"number | BigNumber, number | BigNumber":function(u,o){if(!s(u)||!n(u)||!s(o)||!n(o))throw new TypeError("Positive integer value expected in function composition");if(f(o,u))throw new TypeError("k must be less than or equal to n in function composition");return a(t(u,-1),t(o,-1))}})}),Yp="leafCount",j4=["parse","typed"],eT=R(Yp,j4,r=>{var{parse:e,typed:t}=r;function a(n){var i=0;return n.forEach(s=>{i+=a(s)}),i||1}return t(Yp,{Node:function(i){return a(i)}})});function Qp(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 ws(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Qp(Object(t),!0).forEach(function(a){Ir(r,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Qp(Object(t)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(t,a))})}return r}var rT="simplifyUtil",tT=["FunctionNode","OperatorNode","SymbolNode"],Ns=R(rT,tT,r=>{var{FunctionNode:e,OperatorNode:t,SymbolNode:a}=r,n=!0,i=!1,s="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 o(d,w){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:f,g=s;if(typeof d=="string"?g=d:_r(d)?g=d.fn.toString():An(d)?g=d.name:rn(d)&&(g="paren"),Re(x,g)){var E=x[g];if(Re(E,w))return E[w];if(Re(f,g))return f[g][w]}if(Re(x,s)){var N=x[s];return Re(N,w)?N[w]:f[s][w]}if(Re(f,g)){var S=f[g];if(Re(S,w))return S[w]}return f[s][w]}function c(d){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f;return o(d,"commutative",w)}function m(d){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f;return o(d,"associative",w)}function v(d,w){var x=ws({},d);for(var g in w)Re(d,g)?x[g]=ws(ws({},w[g]),d[g]):x[g]=w[g];return x}function p(d,w){if(!d.args||d.args.length===0)return d;d.args=h(d,w);for(var x=0;x<d.args.length;x++)p(d.args[x],w)}function h(d,w){var x,g=[],E=function N(S){for(var D=0;D<S.args.length;D++){var T=S.args[D];_r(T)&&x===T.op?N(T):g.push(T)}};return m(d,w)?(x=d.op,E(d),g):d.args}function y(d,w){if(!(!d.args||d.args.length===0)){for(var x=A(d),g=d.args.length,E=0;E<g;E++)y(d.args[E],w);if(g>2&&m(d,w)){for(var N=d.args.pop();d.args.length>0;)N=x([d.args.pop(),N]);d.args=N.args}}}function b(d,w){if(!(!d.args||d.args.length===0)){for(var x=A(d),g=d.args.length,E=0;E<g;E++)b(d.args[E],w);if(g>2&&m(d,w)){for(var N=d.args.shift();d.args.length>0;)N=x([N,d.args.shift()]);d.args=N.args}}}function A(d){return _r(d)?function(w){try{return new t(d.op,d.fn,w,d.implicit)}catch(x){return console.error(x),[]}}:function(w){return new e(new a(d.name),w)}}return{createMakeNodeFunction:A,hasProperty:o,isCommutative:c,isAssociative:m,mergeContext:v,flatten:p,allChildren:h,unflattenr:y,unflattenl:b,defaultContext:f,realContext:l,positiveContext:u}}),nT="simplify",aT=["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"],iT=R(nT,aT,r=>{var{config:e,typed:t,parse:a,add:n,subtract:i,multiply:s,divide:f,pow:l,isZero:u,equal:o,resolve:c,simplifyConstant:m,simplifyCore:v,fraction:p,bignumber:h,mathWithTransform:y,matrix:b,AccessorNode:A,ArrayNode:d,ConstantNode:w,FunctionNode:x,IndexNode:g,ObjectNode:E,OperatorNode:N,ParenthesisNode:S,SymbolNode:D}=r,{hasProperty:T,isCommutative:B,isAssociative:_,mergeContext:L,flatten:G,unflattenr:C,unflattenl:F,createMakeNodeFunction:Z,defaultContext:$,realContext:U,positiveContext:Y}=Ns({FunctionNode:x,OperatorNode:N,SymbolNode:D});t.addConversion({from:"Object",to:"Map",convert:Wn});var j=t("simplify",{Node:ce,"Node, Map":(V,Q)=>ce(V,!1,Q),"Node, Map, Object":(V,Q,te)=>ce(V,!1,Q,te),"Node, Array":ce,"Node, Array, Map":ce,"Node, Array, Map, Object":ce});t.removeConversion({from:"Object",to:"Map",convert:Wn}),j.defaultContext=$,j.realContext=U,j.positiveContext=Y;function P(V){return V.transform(function(Q,te,ge){return rn(Q)?P(Q.content):Q})}var K={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};j.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:"-(c*v) -> v * (-c)",assuming:{multiply:{commutative:!0},subtract:{total:!0}}},{s:"-(c*v) -> (-c) * v",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{s:"-(v*c) -> v * (-c)",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:" v * ( v * n1 + n2)",r:"v^2 * n1 + v * n2"},{s:" v * (v^n4 * n1 + n2) -> v^(1+n4) * n1 + v * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * ( v * n1 + n2) -> v^(n3+1) * n1 + v^n3 * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * (v^n4 * n1 + n2) -> v^(n3+n4) * n1 + v^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:"v*n + v",r:"v*(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*v + v -> (n+1)*v",assuming:{multiply:{commutative:!1}}},{s:"n1*n3 + n2*n3 -> (n1+n2)*n3",assuming:{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*c + c",r:"(n+1)*c"},{s:"c*n + c -> c*(n+1)",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:"c+v -> v+c",assuming:{add:{commutative:!0}},imposeContext:{add:{commutative:!1}}},{s:"v*c -> c*v",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 ne(V,Q){var te={};if(V.s){var ge=V.s.split("->");if(ge.length===2)te.l=ge[0],te.r=ge[1];else throw SyntaxError("Could not parse rule: "+V.s)}else te.l=V.l,te.r=V.r;te.l=P(a(te.l)),te.r=P(a(te.r));for(var he of["imposeContext","repeat","assuming"])he in V&&(te[he]=V[he]);if(V.evaluate&&(te.evaluate=a(V.evaluate)),_(te.l,Q)){var q=Z(te.l),z=pe();te.expanded={},te.expanded.l=q([te.l.clone(),z]),G(te.expanded.l,Q),C(te.expanded.l,Q),te.expanded.r=q([te.r,z])}return te}function re(V,Q){for(var te=[],ge=0;ge<V.length;ge++){var he=V[ge],q=void 0,z=typeof he;switch(z){case"string":he={s:he};case"object":q=ne(he,Q);break;case"function":q=he;break;default:throw TypeError("Unsupported type of rule: "+z)}te.push(q)}return te}var fe=0;function pe(){return new D("_p"+fe++)}function ce(V,Q){var te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Jn(),ge=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},he=ge.consoleDebug;Q=re(Q||j.rules,ge.context);var q=c(V,te);q=P(q);for(var z={},ee=q.toString({parenthesis:"all"});!z[ee];){z[ee]=!0,fe=0;var ue=ee;he&&console.log("Working on: ",ee);for(var me=0;me<Q.length;me++){var ye="";if(typeof Q[me]=="function"?(q=Q[me](q,ge),he&&(ye=Q[me].name)):(G(q,ge.context),q=Ce(q,Q[me],ge.context),he&&(ye="".concat(Q[me].l.toString()," -> ").concat(Q[me].r.toString()))),he){var be=q.toString({parenthesis:"all"});be!==ue&&(console.log("Applying",ye,"produced",be),ue=be)}F(q,ge.context)}ee=q.toString({parenthesis:"all"})}return q}function oe(V,Q,te){var ge=V;if(V)for(var he=0;he<V.length;++he){var q=Ce(V[he],Q,te);q!==V[he]&&(ge===V&&(ge=V.slice()),ge[he]=q)}return ge}function Ce(V,Q,te){if(Q.assuming){for(var ge in Q.assuming)for(var he in Q.assuming[ge])if(T(ge,he,te)!==Q.assuming[ge][he])return V}var q=L(Q.imposeContext,te),z=V;if(z instanceof N||z instanceof x){var ee=oe(z.args,Q,te);ee!==z.args&&(z=z.clone(),z.args=ee)}else if(z instanceof S){if(z.content){var ue=Ce(z.content,Q,te);ue!==z.content&&(z=new S(ue))}}else if(z instanceof d){var me=oe(z.items,Q,te);me!==z.items&&(z=new d(me))}else if(z instanceof A){var ye=z.object;z.object&&(ye=Ce(z.object,Q,te));var be=z.index;z.index&&(be=Ce(z.index,Q,te)),(ye!==z.object||be!==z.index)&&(z=new A(ye,be))}else if(z instanceof g){var ve=oe(z.dimensions,Q,te);ve!==z.dimensions&&(z=new g(ve))}else if(z instanceof E){var Ne=!1,Ie={};for(var Ge in z.properties)Ie[Ge]=Ce(z.properties[Ge],Q,te),Ie[Ge]!==z.properties[Ge]&&(Ne=!0);Ne&&(z=new E(Ie))}var Be=Q.r,lr=W(Q.l,z,q)[0];if(!lr&&Q.expanded&&(Be=Q.expanded.r,lr=W(Q.expanded.l,z,q)[0]),lr){var Je=z.implicit;z=Be.clone(),Je&&"implicit"in Be&&(z.implicit=!0),z=z.transform(function(cr){return cr.isSymbolNode&&Re(lr.placeholders,cr.name)?lr.placeholders[cr.name].clone():cr})}return Q.repeat&&z!==V&&(z=Ce(z,Q,te)),z}function Oe(V,Q){var te=[],ge,he,q=Z(V);if(B(V,Q))for(var z=0;z<V.args.length;z++)he=V.args.slice(0),he.splice(z,1),ge=he.length===1?he[0]:q(he),te.push(q([V.args[z],ge]));else for(var ee=1;ee<V.args.length;ee++){var ue=V.args[0];ee>1&&(ue=q(V.args.slice(0,ee))),he=V.args.slice(ee),ge=he.length===1?he[0]:q(he),te.push(q([ue,ge]))}return te}function Me(V,Q){var te={placeholders:{}};if(!V.placeholders&&!Q.placeholders)return te;if(V.placeholders){if(!Q.placeholders)return V}else return Q;for(var ge in V.placeholders)if(Re(V.placeholders,ge)&&(te.placeholders[ge]=V.placeholders[ge],Re(Q.placeholders,ge)&&!ie(V.placeholders[ge],Q.placeholders[ge])))return null;for(var he in Q.placeholders)Re(Q.placeholders,he)&&(te.placeholders[he]=Q.placeholders[he]);return te}function $e(V,Q){var te=[];if(V.length===0||Q.length===0)return te;for(var ge,he=0;he<V.length;he++)for(var q=0;q<Q.length;q++)ge=Me(V[he],Q[q]),ge&&te.push(ge);return te}function k(V){if(V.length===0)return V;for(var Q=V.reduce($e),te=[],ge={},he=0;he<Q.length;he++){var q=JSON.stringify(Q[he]);ge[q]||(ge[q]=!0,te.push(Q[he]))}return te}function W(V,Q,te,ge){var he=[{placeholders:{}}];if(V instanceof N&&Q instanceof N||V instanceof x&&Q instanceof x){if(V instanceof N){if(V.op!==Q.op||V.fn!==Q.fn)return[]}else if(V instanceof x&&V.name!==Q.name)return[];if(Q.args.length===1&&V.args.length===1||!_(Q,te)&&Q.args.length===V.args.length||ge){for(var q=[],z=0;z<V.args.length;z++){var ee=W(V.args[z],Q.args[z],te);if(ee.length===0)break;q.push(ee)}if(q.length!==V.args.length){if(!B(Q,te)||V.args.length===1)return[];if(V.args.length>2)throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");var ue=W(V.args[0],Q.args[1],te);if(ue.length===0)return[];var me=W(V.args[1],Q.args[0],te);if(me.length===0)return[];q=[ue,me]}he=k(q)}else if(Q.args.length>=2&&V.args.length===2){for(var ye=Oe(Q,te),be=[],ve=0;ve<ye.length;ve++){var Ne=W(V,ye[ve],te,!0);be=be.concat(Ne)}return be}else{if(V.args.length>2)throw Error("Unexpected non-binary associative function: "+V.toString());return[]}}else if(V instanceof D){if(V.name.length===0)throw new Error("Symbol in rule has 0 length...!?");if(K[V.name]){if(V.name!==Q.name)return[]}else if(V.name[0]==="n"||V.name.substring(0,2)==="_p")he[0].placeholders[V.name]=Q;else if(V.name[0]==="v")if(!sr(Q))he[0].placeholders[V.name]=Q;else return[];else if(V.name[0]==="c")if(Q instanceof w)he[0].placeholders[V.name]=Q;else return[];else throw new Error("Invalid symbol in rule: "+V.name)}else if(V instanceof w){if(!o(V.value,Q.value))return[]}else return[];return he}function ie(V,Q){if(V instanceof w&&Q instanceof w){if(!o(V.value,Q.value))return!1}else if(V instanceof D&&Q instanceof D){if(V.name!==Q.name)return!1}else if(V instanceof N&&Q instanceof N||V instanceof x&&Q instanceof x){if(V instanceof N){if(V.op!==Q.op||V.fn!==Q.fn)return!1}else if(V instanceof x&&V.name!==Q.name)return!1;if(V.args.length!==Q.args.length)return!1;for(var te=0;te<V.args.length;te++)if(!ie(V.args[te],Q.args[te]))return!1}else return!1;return!0}return j}),oT="simplifyConstant",sT=["typed","parse","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],uT=R(oT,sT,r=>{var{typed:e,parse:t,config:a,mathWithTransform:n,matrix:i,fraction:s,bignumber:f,AccessorNode:l,ArrayNode:u,ConstantNode:o,FunctionNode:c,IndexNode:m,ObjectNode:v,OperatorNode:p,SymbolNode:h}=r,{isCommutative:y,isAssociative:b,allChildren:A,createMakeNodeFunction:d}=Ns({FunctionNode:c,OperatorNode:p,SymbolNode:h}),w=e("simplifyConstant",{Node:C=>N(G(C,{})),"Node, Object":function(F,Z){return N(G(F,Z))}});function x(C){return _a(C)?C.valueOf():C instanceof Array?C.map(x):He(C)?i(x(C.valueOf())):C}function g(C,F,Z){try{return n[C].apply(null,F)}catch{return F=F.map(x),D(n[C].apply(null,F),Z)}}var E=e({Fraction:B,number:function(F){return F<0?T(new o(-F)):new o(F)},BigNumber:function(F){return F<0?T(new o(-F)):new o(F)},Complex:function(F){throw new Error("Cannot convert Complex number to Node")},string:function(F){return new o(F)},Matrix:function(F){return new u(F.valueOf().map(Z=>E(Z)))}});function N(C){return or(C)?C:E(C)}function S(C,F){var Z=F&&F.exactFractions!==!1;if(Z&&isFinite(C)&&s){var $=s(C),U=F&&typeof F.fractionsLimit=="number"?F.fractionsLimit:1/0;if($.valueOf()===C&&$.n<U&&$.d<U)return $}return C}var D=e({"string, Object":function(F,Z){if(a.number==="BigNumber")return f===void 0&&ls(),f(F);if(a.number==="Fraction")return s===void 0&&Kf(),s(F);var $=parseFloat(F);return S($,Z)},"Fraction, Object":function(F,Z){return F},"BigNumber, Object":function(F,Z){return F},"number, Object":function(F,Z){return S(F,Z)},"Complex, Object":function(F,Z){return F.im!==0?F:S(F.re,Z)},"Matrix, Object":function(F,Z){return i(S(F.valueOf()))},"Array, Object":function(F,Z){return F.map(S)}});function T(C){return new p("-","unaryMinus",[C])}function B(C){var F,Z=C.s*C.n;return Z<0?F=new p("-","unaryMinus",[new o(-Z)]):F=new o(Z),C.d===1?F:new p("/","divide",[F,new o(C.d)])}function _(C,F,Z){if(!Ln(F))return new l(N(C),N(F));if(nt(C)||He(C)){for(var $=Array.from(F.dimensions);$.length>0;)if(sr($[0])&&typeof $[0].value!="string"){var U=D($.shift().value,Z);nt(C)?C=C.items[U-1]:(C=C.valueOf()[U-1],C instanceof Array&&(C=i(C)))}else if($.length>1&&sr($[1])&&typeof $[1].value!="string"){var Y=D($[1].value,Z),j=[],P=nt(C)?C.items:C.valueOf();for(var K of P)if(nt(K))j.push(K.items[Y-1]);else if(He(C))j.push(K[Y-1]);else break;if(j.length===P.length)nt(C)?C=new u(j):C=i(j),$.splice(1,1);else break}else break;return $.length===F.dimensions.length?new l(N(C),F):$.length>0?(F=new m($),new l(N(C),F)):C}if(ii(C)&&F.dimensions.length===1&&sr(F.dimensions[0])){var ne=F.dimensions[0].value;return ne in C.properties?C.properties[ne]:new o}return new l(N(C),F)}function L(C,F,Z,$){return F.reduce(function(U,Y){if(!or(U)&&!or(Y)){try{return g(C,[U,Y],$)}catch{}U=E(U),Y=E(Y)}else or(U)?or(Y)||(Y=E(Y)):U=E(U);return Z([U,Y])})}function G(C,F){switch(C.type){case"SymbolNode":return C;case"ConstantNode":switch(typeof C.value){case"number":return D(C.value,F);case"string":return C.value;default:if(!isNaN(C.value))return D(C.value,F)}return C;case"FunctionNode":if(n[C.name]&&n[C.name].rawArgs)return C;{var Z=["add","multiply"];if(Z.indexOf(C.name)===-1){var $=C.args.map(Oe=>G(Oe,F));if(!$.some(or))try{return g(C.name,$,F)}catch{}if(C.name==="size"&&$.length===1&&nt($[0])){for(var U=[],Y=$[0];nt(Y);)U.push(Y.items.length),Y=Y.items[0];return i(U)}return new c(C.name,$.map(N))}}case"OperatorNode":{var j=C.fn.toString(),P,K,ne=d(C);if(_r(C)&&C.isUnary())P=[G(C.args[0],F)],or(P[0])?K=ne(P):K=g(j,P,F);else if(b(C,F.context))if(P=A(C,F.context),P=P.map(Oe=>G(Oe,F)),y(j,F.context)){for(var re=[],fe=[],pe=0;pe<P.length;pe++)or(P[pe])?fe.push(P[pe]):re.push(P[pe]);re.length>1?(K=L(j,re,ne,F),fe.unshift(K),K=L(j,fe,ne,F)):K=L(j,P,ne,F)}else K=L(j,P,ne,F);else P=C.args.map(Oe=>G(Oe,F)),K=L(j,P,ne,F);return K}case"ParenthesisNode":return G(C.content,F);case"AccessorNode":return _(G(C.object,F),G(C.index,F),F);case"ArrayNode":{var ce=C.items.map(Oe=>G(Oe,F));return ce.some(or)?new u(ce.map(N)):i(ce)}case"IndexNode":return new m(C.dimensions.map(Oe=>w(Oe,F)));case"ObjectNode":{var oe={};for(var Ce in C.properties)oe[Ce]=w(C.properties[Ce],F);return new v(oe)}case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"RangeNode":case"ConditionalNode":default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(C.type))}}return w}),Kp="simplifyCore",lT=["typed","parse","equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],cT=R(Kp,lT,r=>{var{typed:e,parse:t,equal:a,isZero:n,add:i,subtract:s,multiply:f,divide:l,pow:u,AccessorNode:o,ArrayNode:c,ConstantNode:m,FunctionNode:v,IndexNode:p,ObjectNode:h,OperatorNode:y,ParenthesisNode:b,SymbolNode:A}=r,d=new m(0),w=new m(1),x=new m(!0),g=new m(!1);function E(T){return _r(T)&&["and","not","or"].includes(T.op)}var{hasProperty:N,isCommutative:S}=Ns({FunctionNode:v,OperatorNode:y,SymbolNode:A});function D(T){var B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},_=B?B.context:void 0;if(N(T,"trivial",_)){if(An(T)&&T.args.length===1)return D(T.args[0],B);var L=!1,G=0;if(T.forEach(re=>{++G,G===1&&(L=D(re,B))}),G===1)return L}var C=T;if(An(C)){var F=LA(C.name);if(F){if(C.args.length>2&&N(C,"associative",_))for(;C.args.length>2;){var Z=C.args.pop(),$=C.args.pop();C.args.push(new y(F,C.name,[Z,$]))}C=new y(F,C.name,C.args)}else return new v(D(C.fn),C.args.map(re=>D(re,B)))}if(_r(C)&&C.isUnary()){var U=D(C.args[0],B);if(C.op==="~"&&_r(U)&&U.isUnary()&&U.op==="~"||C.op==="not"&&_r(U)&&U.isUnary()&&U.op==="not"&&E(U.args[0]))return U.args[0];var Y=!0;if(C.op==="-"&&_r(U)&&(U.isBinary()&&U.fn==="subtract"&&(C=new y("-","subtract",[U.args[1],U.args[0]]),Y=!1),U.isUnary()&&U.op==="-"))return U.args[0];if(Y)return new y(C.op,C.fn,[U])}if(_r(C)&&C.isBinary()){var j=D(C.args[0],B),P=D(C.args[1],B);if(C.op==="+"){if(sr(j)&&n(j.value))return P;if(sr(P)&&n(P.value))return j;_r(P)&&P.isUnary()&&P.op==="-"&&(P=P.args[0],C=new y("-","subtract",[j,P]))}if(C.op==="-")return _r(P)&&P.isUnary()&&P.op==="-"?D(new y("+","add",[j,P.args[0]]),B):sr(j)&&n(j.value)?D(new y("-","unaryMinus",[P])):sr(P)&&n(P.value)?j:new y(C.op,C.fn,[j,P]);if(C.op==="*"){if(sr(j)){if(n(j.value))return d;if(a(j.value,1))return P}if(sr(P)){if(n(P.value))return d;if(a(P.value,1))return j;if(S(C,_))return new y(C.op,C.fn,[P,j],C.implicit)}return new y(C.op,C.fn,[j,P],C.implicit)}if(C.op==="/")return sr(j)&&n(j.value)?d:sr(P)&&a(P.value,1)?j:new y(C.op,C.fn,[j,P]);if(C.op==="^"&&sr(P)){if(n(P.value))return w;if(a(P.value,1))return j}if(C.op==="and"){if(sr(j))if(j.value){if(E(P))return P}else return g;if(sr(P))if(P.value){if(E(j))return j}else return g}if(C.op==="or"){if(sr(j)){if(j.value)return x;if(E(P))return P}if(sr(P)){if(P.value)return x;if(E(j))return j}}return new y(C.op,C.fn,[j,P])}if(_r(C))return new y(C.op,C.fn,C.args.map(re=>D(re,B)));if(nt(C))return new c(C.items.map(re=>D(re,B)));if(Dn(C))return new o(D(C.object,B),D(C.index,B));if(Ln(C))return new p(C.dimensions.map(re=>D(re,B)));if(ii(C)){var K={};for(var ne in C.properties)K[ne]=D(C.properties[ne],B);return new h(K)}return C}return e(Kp,{Node:D,"Node,Object":D})}),fT="resolve",mT=["typed","parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],vT=R(fT,mT,r=>{var{typed:e,parse:t,ConstantNode:a,FunctionNode:n,OperatorNode:i,ParenthesisNode:s}=r;function f(l,u){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;if(!u)return l;if(qr(l)){if(o.has(l.name)){var c=Array.from(o).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(c,"}"))}var m=u.get(l.name);if(or(m)){var v=new Set(o);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(_r(l)){var p=l.args.map(function(y){return f(y,u,o)});return new i(l.op,l.fn,p,l.implicit)}else{if(rn(l))return new s(f(l.content,u,o));if(An(l)){var h=l.args.map(function(y){return f(y,u,o)});return new n(l.name,h)}}return l.map(y=>f(y,u,o))}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(o=>l(o))),"Array | Matrix, null | undefined":e.referToSelf(l=>u=>u.map(o=>l(o))),"Array, Object":e.referTo("Array,Map",l=>(u,o)=>l(u,Wn(o))),"Matrix, Object":e.referTo("Matrix,Map",l=>(u,o)=>l(u,Wn(o))),"Array | Matrix, Map":e.referToSelf(l=>(u,o)=>u.map(c=>l(c,o)))})}),jp="symbolicEqual",pT=["parse","simplify","typed","OperatorNode"],hT=R(jp,pT,r=>{var{parse:e,simplify:t,typed:a,OperatorNode:n}=r;function i(s,f){var l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},u=new n("-","subtract",[s,f]),o=t(u,{},l);return sr(o)&&!o.value}return a(jp,{"Node, Node":i,"Node, Node, Object":i})}),eh="derivative",dT=["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],gT=R(eh,dT,r=>{var{typed:e,config:t,parse:a,simplify:n,equal:i,isZero:s,numeric:f,ConstantNode:l,FunctionNode:u,OperatorNode:o,ParenthesisNode:c,SymbolNode:m}=r;function v(w,x){var g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{simplify:!0},E={};y(E,w,x.name);var N=b(w,E);return g.simplify?n(N):N}e.addConversion({from:"identifier",to:"SymbolNode",convert:a});var p=e(eh,{"Node, SymbolNode":v,"Node, SymbolNode, Object":v});e.removeConversion({from:"identifier",to:"SymbolNode",convert:a}),p._simplify=!0,p.toTex=function(w){return h.apply(null,w.args)};var h=e("_derivTex",{"Node, SymbolNode":function(x,g){return sr(x)&&gr(x.value)==="string"?h(a(x.value).toString(),g.toString(),1):h(x.toTex(),g.toString(),1)},"Node, ConstantNode":function(x,g){if(gr(g.value)==="string")return h(x,a(g.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(x,g,E){return h(x.toString(),g.name,E.value)},"string, string, number":function(x,g,E){var N;return E===1?N="{d\\over d"+g+"}":N="{d^{"+E+"}\\over d"+g+"^{"+E+"}}",N+"\\left[".concat(x,"\\right]")}}),y=e("constTag",{"Object, ConstantNode, string":function(x,g){return x[g]=!0,!0},"Object, SymbolNode, string":function(x,g,E){return g.name!==E?(x[g]=!0,!0):!1},"Object, ParenthesisNode, string":function(x,g,E){return y(x,g.content,E)},"Object, FunctionAssignmentNode, string":function(x,g,E){return g.params.indexOf(E)===-1?(x[g]=!0,!0):y(x,g.expr,E)},"Object, FunctionNode | OperatorNode, string":function(x,g,E){if(g.args.length>0){for(var N=y(x,g.args[0],E),S=1;S<g.args.length;++S)N=y(x,g.args[S],E)&&N;if(N)return x[g]=!0,!0}return!1}}),b=e("_derivative",{"ConstantNode, Object":function(x){return d(0)},"SymbolNode, Object":function(x,g){return g[x]!==void 0?d(0):d(1)},"ParenthesisNode, Object":function(x,g){return new c(b(x.content,g))},"FunctionAssignmentNode, Object":function(x,g){return g[x]!==void 0?d(0):b(x.expr,g)},"FunctionNode, Object":function(x,g){if(x.args.length!==1&&A(x),g[x]!==void 0)return d(0);var E=x.args[0],N,S=!1,D=!1,T;switch(x.name){case"cbrt":S=!0,T=new o("*","multiply",[d(3),new o("^","pow",[E,new o("/","divide",[d(2),d(3)])])]);break;case"sqrt":case"nthRoot":if(x.args.length===1)S=!0,T=new o("*","multiply",[d(2),new u("sqrt",[E])]);else if(x.args.length===2)return N=new o("/","divide",[d(1),x.args[1]]),g[N]=g[x.args[1]],b(new o("^","pow",[E,N]),g);break;case"log10":N=d(10);case"log":if(!N&&x.args.length===1)T=E.clone(),S=!0;else if(x.args.length===1&&N||x.args.length===2&&g[x.args[1]]!==void 0)T=new o("*","multiply",[E.clone(),new u("log",[N||x.args[1]])]),S=!0;else if(x.args.length===2)return b(new o("/","divide",[new u("log",[E]),new u("log",[x.args[1]])]),g);break;case"pow":return g[N]=g[x.args[1]],b(new o("^","pow",[E,x.args[1]]),g);case"exp":T=new u("exp",[E.clone()]);break;case"sin":T=new u("cos",[E.clone()]);break;case"cos":T=new o("-","unaryMinus",[new u("sin",[E.clone()])]);break;case"tan":T=new o("^","pow",[new u("sec",[E.clone()]),d(2)]);break;case"sec":T=new o("*","multiply",[x,new u("tan",[E.clone()])]);break;case"csc":D=!0,T=new o("*","multiply",[x,new u("cot",[E.clone()])]);break;case"cot":D=!0,T=new o("^","pow",[new u("csc",[E.clone()]),d(2)]);break;case"asin":S=!0,T=new u("sqrt",[new o("-","subtract",[d(1),new o("^","pow",[E.clone(),d(2)])])]);break;case"acos":S=!0,D=!0,T=new u("sqrt",[new o("-","subtract",[d(1),new o("^","pow",[E.clone(),d(2)])])]);break;case"atan":S=!0,T=new o("+","add",[new o("^","pow",[E.clone(),d(2)]),d(1)]);break;case"asec":S=!0,T=new o("*","multiply",[new u("abs",[E.clone()]),new u("sqrt",[new o("-","subtract",[new o("^","pow",[E.clone(),d(2)]),d(1)])])]);break;case"acsc":S=!0,D=!0,T=new o("*","multiply",[new u("abs",[E.clone()]),new u("sqrt",[new o("-","subtract",[new o("^","pow",[E.clone(),d(2)]),d(1)])])]);break;case"acot":S=!0,D=!0,T=new o("+","add",[new o("^","pow",[E.clone(),d(2)]),d(1)]);break;case"sinh":T=new u("cosh",[E.clone()]);break;case"cosh":T=new u("sinh",[E.clone()]);break;case"tanh":T=new o("^","pow",[new u("sech",[E.clone()]),d(2)]);break;case"sech":D=!0,T=new o("*","multiply",[x,new u("tanh",[E.clone()])]);break;case"csch":D=!0,T=new o("*","multiply",[x,new u("coth",[E.clone()])]);break;case"coth":D=!0,T=new o("^","pow",[new u("csch",[E.clone()]),d(2)]);break;case"asinh":S=!0,T=new u("sqrt",[new o("+","add",[new o("^","pow",[E.clone(),d(2)]),d(1)])]);break;case"acosh":S=!0,T=new u("sqrt",[new o("-","subtract",[new o("^","pow",[E.clone(),d(2)]),d(1)])]);break;case"atanh":S=!0,T=new o("-","subtract",[d(1),new o("^","pow",[E.clone(),d(2)])]);break;case"asech":S=!0,D=!0,T=new o("*","multiply",[E.clone(),new u("sqrt",[new o("-","subtract",[d(1),new o("^","pow",[E.clone(),d(2)])])])]);break;case"acsch":S=!0,D=!0,T=new o("*","multiply",[new u("abs",[E.clone()]),new u("sqrt",[new o("+","add",[new o("^","pow",[E.clone(),d(2)]),d(1)])])]);break;case"acoth":S=!0,D=!0,T=new o("-","subtract",[d(1),new o("^","pow",[E.clone(),d(2)])]);break;case"abs":T=new o("/","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,_;S?(B="/",_="divide"):(B="*",_="multiply");var L=b(E,g);return D&&(L=new o("-","unaryMinus",[L])),new o(B,_,[L,T])},"OperatorNode, Object":function(x,g){if(g[x]!==void 0)return d(0);if(x.op==="+")return new o(x.op,x.fn,x.args.map(function(C){return b(C,g)}));if(x.op==="-"){if(x.isUnary())return new o(x.op,x.fn,[b(x.args[0],g)]);if(x.isBinary())return new o(x.op,x.fn,[b(x.args[0],g),b(x.args[1],g)])}if(x.op==="*"){var E=x.args.filter(function(C){return g[C]!==void 0});if(E.length>0){var N=x.args.filter(function(C){return g[C]===void 0}),S=N.length===1?N[0]:new o("*","multiply",N),D=E.concat(b(S,g));return new o("*","multiply",D)}return new o("+","add",x.args.map(function(C){return new o("*","multiply",x.args.map(function(F){return F===C?b(F,g):F.clone()}))}))}if(x.op==="/"&&x.isBinary()){var T=x.args[0],B=x.args[1];return g[B]!==void 0?new o("/","divide",[b(T,g),B]):g[T]!==void 0?new o("*","multiply",[new o("-","unaryMinus",[T]),new o("/","divide",[b(B,g),new o("^","pow",[B.clone(),d(2)])])]):new o("/","divide",[new o("-","subtract",[new o("*","multiply",[b(T,g),B.clone()]),new o("*","multiply",[T.clone(),b(B,g)])]),new o("^","pow",[B.clone(),d(2)])])}if(x.op==="^"&&x.isBinary()){var _=x.args[0],L=x.args[1];if(g[_]!==void 0)return sr(_)&&(s(_.value)||i(_.value,1))?d(0):new o("*","multiply",[x,new o("*","multiply",[new u("log",[_.clone()]),b(L.clone(),g)])]);if(g[L]!==void 0){if(sr(L)){if(s(L.value))return d(0);if(i(L.value,1))return b(_,g)}var G=new o("^","pow",[_.clone(),new o("-","subtract",[L,d(1)])]);return new o("*","multiply",[L.clone(),new o("*","multiply",[b(_,g),G])])}return new o("*","multiply",[new o("^","pow",[_.clone(),L.clone()]),new o("+","add",[new o("*","multiply",[b(_,g),new o("/","divide",[L.clone(),_.clone()])]),new o("*","multiply",[b(L,g),new u("log",[_.clone()])])])])}throw new Error('Operator "'+x.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function A(w){if(!((w.name==="log"||w.name==="nthRoot"||w.name==="pow")&&w.args.length===2)){for(var x=0;x<w.args.length;++x)w.args[x]=d(0);throw w.compile().evaluate(),new Error("Expected TypeError, but none found")}}function d(w,x){return new l(f(w,x||t.number))}return p}),rh="rationalize",yT=["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"],bT=R(rh,yT,r=>{var{config:e,typed:t,equal:a,isZero:n,add:i,subtract:s,multiply:f,divide:l,pow:u,parse:o,simplifyConstant:c,simplifyCore:m,simplify:v,fraction:p,bignumber:h,mathWithTransform:y,matrix:b,AccessorNode:A,ArrayNode:d,ConstantNode:w,FunctionNode:x,IndexNode:g,ObjectNode:E,OperatorNode:N,SymbolNode:S,ParenthesisNode:D}=r;function T(C){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Z=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,$=_(),U=B(C,F,!0,$.firstRules),Y=U.variables.length,j={exactFractions:!1},P={exactFractions:!0};if(C=U.expression,Y>=1){C=L(C);var K,ne,re=!0,fe=!1;C=v(C,$.firstRules,{},j);for(var pe;ne=re?$.distrDivRules:$.sucDivRules,C=v(C,ne,{},P),re=!re,pe=C.toString(),pe!==K;)fe=!0,K=pe;fe&&(C=v(C,$.firstRulesAgain,{},j)),C=v(C,$.finalRules,{},j)}var ce=[],oe={};return C.type==="OperatorNode"&&C.isBinary()&&C.op==="/"?(Y===1&&(C.args[0]=G(C.args[0],ce),C.args[1]=G(C.args[1])),Z&&(oe.numerator=C.args[0],oe.denominator=C.args[1])):(Y===1&&(C=G(C,ce)),Z&&(oe.numerator=C,oe.denominator=null)),Z?(oe.coefficients=ce,oe.variables=U.variables,oe.expression=C,oe):C}return t(rh,{Node:T,"Node, boolean":(C,F)=>T(C,{},F),"Node, Object":T,"Node, Object, boolean":T});function B(C,F,Z,$){var U=[],Y=v(C,$,F,{exactFractions:!1});Z=!!Z;var j="+-*"+(Z?"/":"");K(Y);var P={};return P.expression=Y,P.variables=U,P;function K(ne){var re=ne.type;if(re==="FunctionNode")throw new Error("There is an unsolved function call");if(re==="OperatorNode")if(ne.op==="^"){if(ne.args[1].type!=="ConstantNode"||!qe(parseFloat(ne.args[1].value)))throw new Error("There is a non-integer exponent");K(ne.args[0])}else{if(j.indexOf(ne.op)===-1)throw new Error("Operator "+ne.op+" invalid in polynomial expression");for(var fe=0;fe<ne.args.length;fe++)K(ne.args[fe])}else if(re==="SymbolNode"){var pe=ne.name,ce=U.indexOf(pe);ce===-1&&U.push(pe)}else if(re==="ParenthesisNode")K(ne.content);else if(re!=="ConstantNode")throw new Error("type "+re+" is not allowed in polynomial expression")}}function _(){var C=[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)"}],Z=[{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))"}],U={};return U.firstRules=C.concat(F,$),U.distrDivRules=Z,U.sucDivRules=$,U.firstRulesAgain=C.concat(F),U.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))"}],U}function L(C,F,Z){var $=C.type,U=arguments.length>1;if($==="OperatorNode"&&C.isBinary()){var Y=!1,j;if(C.op==="^"&&(C.args[0].type==="ParenthesisNode"||C.args[0].type==="OperatorNode")&&C.args[1].type==="ConstantNode"&&(j=parseFloat(C.args[1].value),Y=j>=2&&qe(j)),Y){if(j>2){var P=C.args[0],K=new N("^","pow",[C.args[0].cloneDeep(),new w(j-1)]);C=new N("*","multiply",[P,K])}else C=new N("*","multiply",[C.args[0],C.args[0].cloneDeep()]);U&&(Z==="content"?F.content=C:F.args[Z]=C)}}if($==="ParenthesisNode")L(C.content,C,"content");else if($!=="ConstantNode"&&$!=="SymbolNode")for(var ne=0;ne<C.args.length;ne++)L(C.args[ne],C,ne);if(!U)return C}function G(C,F){F===void 0&&(F=[]),F[0]=0;var Z={};Z.cte=1,Z.oper="+",Z.fire="";var $=0,U="";pe(C,null,Z),$=F.length-1;for(var Y=!0,j,P=$;P>=0;P--)if(F[P]!==0){var K=new w(Y?F[P]:Math.abs(F[P])),ne=F[P]<0?"-":"+";if(P>0){var re=new S(U);if(P>1){var fe=new w(P);re=new N("^","pow",[re,fe])}F[P]===-1&&Y?K=new N("-","unaryMinus",[re]):Math.abs(F[P])===1?K=re:K=new N("*","multiply",[K,re])}Y?j=K:ne==="+"?j=new N("+","add",[j,K]):j=new N("-","subtract",[j,K]),Y=!1}if(Y)return new w(0);return j;function pe(ce,oe,Ce){var Oe=ce.type;if(Oe==="FunctionNode")throw new Error("There is an unsolved function call");if(Oe==="OperatorNode"){if("+-*^".indexOf(ce.op)===-1)throw new Error("Operator "+ce.op+" invalid");if(oe!==null){if((ce.fn==="unaryMinus"||ce.fn==="pow")&&oe.fn!=="add"&&oe.fn!=="subtract"&&oe.fn!=="multiply")throw new Error("Invalid "+ce.op+" placing");if((ce.fn==="subtract"||ce.fn==="add"||ce.fn==="multiply")&&oe.fn!=="add"&&oe.fn!=="subtract")throw new Error("Invalid "+ce.op+" placing");if((ce.fn==="subtract"||ce.fn==="add"||ce.fn==="unaryMinus")&&Ce.noFil!==0)throw new Error("Invalid "+ce.op+" placing")}(ce.op==="^"||ce.op==="*")&&(Ce.fire=ce.op);for(var Me=0;Me<ce.args.length;Me++)ce.fn==="unaryMinus"&&(Ce.oper="-"),(ce.op==="+"||ce.fn==="subtract")&&(Ce.fire="",Ce.cte=1,Ce.oper=Me===0?"+":ce.op),Ce.noFil=Me,pe(ce.args[Me],ce,Ce)}else if(Oe==="SymbolNode"){if(ce.name!==U&&U!=="")throw new Error("There is more than one variable");if(U=ce.name,oe===null){F[1]=1;return}if(oe.op==="^"&&Ce.noFil!==0)throw new Error("In power the variable should be the first parameter");if(oe.op==="*"&&Ce.noFil!==1)throw new Error("In multiply the variable should be the second parameter");(Ce.fire===""||Ce.fire==="*")&&($<1&&(F[1]=0),F[1]+=Ce.cte*(Ce.oper==="+"?1:-1),$=Math.max(1,$))}else if(Oe==="ConstantNode"){var $e=parseFloat(ce.value);if(oe===null){F[0]=$e;return}if(oe.op==="^"){if(Ce.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 k=$+1;k<$e;k++)F[k]=0;$e>$&&(F[$e]=0),F[$e]+=Ce.cte*(Ce.oper==="+"?1:-1),$=Math.max($e,$);return}Ce.cte=$e,Ce.fire===""&&(F[0]+=Ce.cte*(Ce.oper==="+"?1:-1))}else throw new Error("Type "+Oe+" is not allowed")}}}),xT="reviver",wT=["classes"],NT=R(xT,wT,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}}),DT="replacer",AT=[],ET=R(DT,AT,()=>function(e,t){return typeof t=="number"&&(!isFinite(t)||isNaN(t))?{mathjs:"number",value:String(t)}:t}),ST="11.3.1",CT=R("true",[],()=>!0),MT=R("false",[],()=>!1),FT=R("null",[],()=>null),TT=rt("Infinity",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1/0):1/0}),BT=rt("NaN",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(NaN):NaN}),$T=rt("pi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?ms(t):F1}),OT=rt("tau",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?G2(t):T1}),_T=rt("e",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?k2(t):B1}),IT=rt("phi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?V2(t):$1}),RT=rt("LN2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).ln():Math.LN2}),qT=rt("LN10",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(10).ln():Math.LN10}),zT=rt("LOG2E",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1).div(new t(2).ln()):Math.LOG2E}),PT=rt("LOG10E",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1).div(new t(10).ln()):Math.LOG10E}),LT=rt("SQRT1_2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t("0.5").sqrt():Math.SQRT1_2}),UT=rt("SQRT2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).sqrt():Math.SQRT2}),kT=rt("i",["Complex"],r=>{var{Complex:e}=r;return e.I}),VT=R("version",[],()=>ST);function rt(r,e,t){return R(r,e,t,{recreateOnConfigChange:!0})}var GT=Xe("speedOfLight","299792458","m s^-1"),HT=Xe("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),ZT=Xe("planckConstant","6.62607015e-34","J s"),JT=Xe("reducedPlanckConstant","1.0545718176461565e-34","J s"),WT=Xe("magneticConstant","1.25663706212e-6","N A^-2"),XT=Xe("electricConstant","8.8541878128e-12","F m^-1"),YT=Xe("vacuumImpedance","376.730313667","ohm"),QT=Xe("coulomb","8.987551792261171e9","N m^2 C^-2"),KT=Xe("elementaryCharge","1.602176634e-19","C"),jT=Xe("bohrMagneton","9.2740100783e-24","J T^-1"),eB=Xe("conductanceQuantum","7.748091729863649e-5","S"),rB=Xe("inverseConductanceQuantum","12906.403729652257","ohm"),tB=Xe("magneticFluxQuantum","2.0678338484619295e-15","Wb"),nB=Xe("nuclearMagneton","5.0507837461e-27","J T^-1"),aB=Xe("klitzing","25812.807459304513","ohm"),iB=Xe("bohrRadius","5.29177210903e-11","m"),oB=Xe("classicalElectronRadius","2.8179403262e-15","m"),sB=Xe("electronMass","9.1093837015e-31","kg"),uB=Xe("fermiCoupling","1.1663787e-5","GeV^-2"),lB=ro("fineStructure",.0072973525693),cB=Xe("hartreeEnergy","4.3597447222071e-18","J"),fB=Xe("protonMass","1.67262192369e-27","kg"),mB=Xe("deuteronMass","3.3435830926e-27","kg"),vB=Xe("neutronMass","1.6749271613e-27","kg"),pB=Xe("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),hB=Xe("rydberg","10973731.568160","m^-1"),dB=Xe("thomsonCrossSection","6.6524587321e-29","m^2"),gB=ro("weakMixingAngle",.2229),yB=ro("efimovFactor",22.7),bB=Xe("atomicMass","1.66053906660e-27","kg"),xB=Xe("avogadro","6.02214076e23","mol^-1"),wB=Xe("boltzmann","1.380649e-23","J K^-1"),NB=Xe("faraday","96485.33212331001","C mol^-1"),DB=Xe("firstRadiation","3.7417718521927573e-16","W m^2"),AB=Xe("loschmidt","2.686780111798444e25","m^-3"),EB=Xe("gasConstant","8.31446261815324","J K^-1 mol^-1"),SB=Xe("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),CB=Xe("molarVolume","0.022413969545014137","m^3 mol^-1"),MB=ro("sackurTetrode",-1.16487052358),FB=Xe("secondRadiation","0.014387768775039337","m K"),TB=Xe("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),BB=Xe("wienDisplacement","2.897771955e-3","m K"),$B=Xe("molarMass","0.99999999965e-3","kg mol^-1"),OB=Xe("molarMassC12","11.9999999958e-3","kg mol^-1"),_B=Xe("gravity","9.80665","m s^-2"),IB=Xe("planckLength","1.616255e-35","m"),RB=Xe("planckMass","2.176435e-8","kg"),qB=Xe("planckTime","5.391245e-44","s"),zB=Xe("planckCharge","1.87554603778e-18","C"),PB=Xe("planckTemperature","1.416785e+32","K");function Xe(r,e,t){var a=["config","Unit","BigNumber"];return R(r,a,n=>{var{config:i,Unit:s,BigNumber:f}=n,l=i.number==="BigNumber"?new f(e):parseFloat(e),u=new s(l,t);return u.fixPrefix=!0,u})}function ro(r,e){var t=["config","BigNumber"];return R(r,t,a=>{var{config:n,BigNumber:i}=a;return n.number==="BigNumber"?new i(e):e})}var LB="apply",UB=["typed","isInteger"],kB=R(LB,UB,r=>{var{typed:e,isInteger:t}=r,a=nf({typed:e,isInteger:t});return e("apply",{"...any":function(i){var s=i[1];tr(s)?i[1]=s-1:rr(s)&&(i[1]=s.minus(1));try{return a.apply(null,i)}catch(f){throw Qr(f)}}})},{isTransformFunction:!0}),VB="column",GB=["typed","Index","matrix","range"],HB=R(VB,GB,r=>{var{typed:e,Index:t,matrix:a,range:n}=r,i=Pf({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(o){throw Qr(o)}}})},{isTransformFunction:!0});function Ds(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=Ga(t),s=r.compile();return function(l){return i.set(n,l),s.evaluate(i)}}var ZB="filter",JB=["typed"],WB=R(ZB,JB,r=>{var{typed:e}=r;function t(n,i,s){var f,l;return n[0]&&(f=n[0].compile().evaluate(s)),n[1]&&(qr(n[1])||Ia(n[1])?l=n[1].compile().evaluate(s):l=Ds(n[1],i,s)),a(f,l)}t.rawArgs=!0;var a=e("filter",{"Array, function":th,"Matrix, function":function(i,s){return i.create(th(i.toArray(),s))},"Array, RegExp":fi,"Matrix, RegExp":function(i,s){return i.create(fi(i.toArray(),s))}});return t},{isTransformFunction:!0});function th(r,e){var t=ln(e);return pl(r,function(a,n,i){return t===1?e(a):t===2?e(a,[n+1]):e(a,[n+1],i)})}var XB="forEach",YB=["typed"],QB=R(XB,YB,r=>{var{typed:e}=r;function t(n,i,s){var f,l;return n[0]&&(f=n[0].compile().evaluate(s)),n[1]&&(qr(n[1])||Ia(n[1])?l=n[1].compile().evaluate(s):l=Ds(n[1],i,s)),a(f,l)}t.rawArgs=!0;var a=e("forEach",{"Array | Matrix, function":function(i,s){var f=ln(s),l=function u(o,c){Array.isArray(o)?ci(o,function(m,v){u(m,c.concat(v+1))}):f===1?s(o):f===2?s(o,c):s(o,c,i)};l(i.valueOf(),[])}});return t},{isTransformFunction:!0}),KB="index",jB=["Index"],e$=R(KB,jB,r=>{var{Index:e}=r;return function(){for(var a=[],n=0,i=arguments.length;n<i;n++){var s=arguments[n];if(Ro(s))s.start--,s.end-=s.step>0?0:2;else if(s&&s.isSet===!0)s=s.map(function(l){return l-1});else if(ur(s)||He(s))s=s.map(function(l){return l-1});else if(tr(s))s--;else if(rr(s))s=s.toNumber()-1;else if(typeof s!="string")throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");a[n]=s}var f=new e;return e.apply(f,a),f}},{isTransformFunction:!0}),r$="map",t$=["typed"],n$=R(r$,t$,r=>{var{typed:e}=r;function t(n,i,s){var f,l;return n[0]&&(f=n[0].compile().evaluate(s)),n[1]&&(qr(n[1])||Ia(n[1])?l=n[1].compile().evaluate(s):l=Ds(n[1],i,s)),a(f,l)}t.rawArgs=!0;var a=e("map",{"Array, function":function(i,s){return nh(i,s,i)},"Matrix, function":function(i,s){return i.create(nh(i.valueOf(),s,i))}});return t},{isTransformFunction:!0});function nh(r,e,t){var a=ln(e);function n(i,s){return Array.isArray(i)?Ut(i,function(f,l){return n(f,s.concat(l+1))}):a===1?e(i):a===2?e(i,s):e(i,s,t)}return n(r,[])}function Tn(r){if(r.length===2&&Lt(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 a$="max",i$=["typed","config","numeric","larger"],o$=R(a$,i$,r=>{var{typed:e,config:t,numeric:a,larger:n}=r,i=Ym({typed:e,config:t,numeric:a,larger:n});return e("max",{"...any":function(f){f=Tn(f);try{return i.apply(null,f)}catch(l){throw Qr(l)}}})},{isTransformFunction:!0}),s$="mean",u$=["typed","add","divide"],l$=R(s$,u$,r=>{var{typed:e,add:t,divide:a}=r,n=gp({typed:e,add:t,divide:a});return e("mean",{"...any":function(s){s=Tn(s);try{return n.apply(null,s)}catch(f){throw Qr(f)}}})},{isTransformFunction:!0}),c$="min",f$=["typed","config","numeric","smaller"],m$=R(c$,f$,r=>{var{typed:e,config:t,numeric:a,smaller:n}=r,i=Km({typed:e,config:t,numeric:a,smaller:n});return e("min",{"...any":function(f){f=Tn(f);try{return i.apply(null,f)}catch(l){throw Qr(l)}}})},{isTransformFunction:!0}),v$="range",p$=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],h$=R(v$,p$,r=>{var{typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:s,larger:f,largerEq:l}=r,u=rm({typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:s,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}),d$="row",g$=["typed","Index","matrix","range"],y$=R(d$,g$,r=>{var{typed:e,Index:t,matrix:a,range:n}=r,i=om({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(o){throw Qr(o)}}})},{isTransformFunction:!0}),b$="subset",x$=["typed","matrix"],w$=R(b$,x$,r=>{var{typed:e,matrix:t}=r,a=cm({typed:e,matrix:t});return e("subset",{"...any":function(i){try{return a.apply(null,i)}catch(s){throw Qr(s)}}})},{isTransformFunction:!0}),N$="concat",D$=["typed","matrix","isInteger"],A$=R(N$,D$,r=>{var{typed:e,matrix:t,isInteger:a}=r,n=Rf({typed:e,matrix:t,isInteger:a});return e("concat",{"...any":function(s){var f=s.length-1,l=s[f];tr(l)?s[f]=l-1:rr(l)&&(s[f]=l.minus(1));try{return n.apply(null,s)}catch(u){throw Qr(u)}}})},{isTransformFunction:!0}),ah="diff",E$=["typed","matrix","subtract","number","bignumber"],S$=R(ah,E$,r=>{var{typed:e,matrix:t,subtract:a,number:n,bignumber:i}=r,s=Qf({typed:e,matrix:t,subtract:a,number:n,bignumber:i});return e(ah,{"...any":function(l){l=Tn(l);try{return s.apply(null,l)}catch(u){throw Qr(u)}}})},{isTransformFunction:!0}),C$="std",M$=["typed","map","sqrt","variance"],F$=R(C$,M$,r=>{var{typed:e,map:t,sqrt:a,variance:n}=r,i=Dp({typed:e,map:t,sqrt:a,variance:n});return e("std",{"...any":function(f){f=Tn(f);try{return i.apply(null,f)}catch(l){throw Qr(l)}}})},{isTransformFunction:!0}),ih="sum",T$=["typed","config","add","numeric"],B$=R(ih,T$,r=>{var{typed:e,config:t,add:a,numeric:n}=r,i=pp({typed:e,config:t,add:a,numeric:n});return e(ih,{"...any":function(f){f=Tn(f);try{return i.apply(null,f)}catch(l){throw Qr(l)}}})},{isTransformFunction:!0}),oh="cumsum",$$=["typed","add","unaryPlus"],O$=R(oh,$$,r=>{var{typed:e,add:t,unaryPlus:a}=r,n=hp({typed:e,add:t,unaryPlus:a});return e(oh,{"...any":function(s){if(s.length===2&&Lt(s[0])){var f=s[1];tr(f)?s[1]=f-1:rr(f)&&(s[1]=f.minus(1))}try{return n.apply(null,s)}catch(l){throw Qr(l)}}})},{isTransformFunction:!0}),sh="variance",_$=["typed","add","subtract","multiply","divide","apply","isNaN"],I$=R(sh,_$,r=>{var{typed:e,add:t,subtract:a,multiply:n,divide:i,apply:s,isNaN:f}=r,l=wp({typed:e,add:t,subtract:a,multiply:n,divide:i,apply:s,isNaN:f});return e(sh,{"...any":function(o){o=Tn(o);try{return l.apply(null,o)}catch(c){throw Qr(c)}}})},{isTransformFunction:!0}),Se=i1({config:de}),yr=l1({}),uh=_T({BigNumber:Se,config:de}),R$=MT({}),q$=lB({BigNumber:Se,config:de}),Bn=m1({}),lh=kT({Complex:yr}),z$=TT({BigNumber:Se,config:de}),P$=qT({BigNumber:Se,config:de}),L$=PT({BigNumber:Se,config:de}),to=y1({}),U$=BT({BigNumber:Se,config:de}),k$=FT({}),V$=IT({BigNumber:Se,config:de}),G$=h1({}),ch=lg({}),H$=LT({BigNumber:Se,config:de}),Z$=MB({BigNumber:Se,config:de}),fh=OT({BigNumber:Se,config:de}),J$=CT({}),W$=VT({}),Qe=N1({Matrix:to}),X$=yB({BigNumber:Se,config:de}),Y$=RT({BigNumber:Se,config:de}),mh=$T({BigNumber:Se,config:de}),Q$=ET({}),K$=UT({BigNumber:Se,config:de}),J=ig({BigNumber:Se,Complex:yr,DenseMatrix:Qe,Fraction:Bn}),As=Oy({BigNumber:Se,config:de,typed:J}),j$=gB({BigNumber:Se,config:de}),tt=Iy({typed:J}),eO=rD({Complex:yr,config:de,typed:J}),rO=iD({BigNumber:Se,typed:J}),tO=lD({BigNumber:Se,Complex:yr,config:de,typed:J}),Fr=Py({typed:J}),nO=Ax({typed:J}),aO=hD({BigNumber:Se,Complex:yr,config:de,typed:J}),iO=xD({typed:J}),vh=DD({typed:J}),oO=CD({Complex:yr,config:de,typed:J}),Ft=vy({BigNumber:Se,typed:J}),sO=dx({typed:J}),uO=cy({typed:J}),lO=A1({typed:J}),no=d4({typed:J}),ao=dy({Complex:yr,typed:J}),sa=Sx({typed:J}),cO=BD({typed:J}),fO=ID({BigNumber:Se,typed:J}),mO=qD({BigNumber:Se,typed:J}),vO=Ky({typed:J}),nr=K1({config:de,typed:J}),pO=Vw({typed:J}),ph=eb({typed:J}),hO=tb({Complex:yr,typed:J}),dO=Jx({typed:J}),gO=Qx({typed:J}),Ha=Kw({typed:J}),yO=ew({typed:J}),bO=aN({format:Ha,typed:J}),hh=Mx({typed:J}),st=S1({typed:J}),ua=q1({typed:J}),io=V1({typed:J}),Tt=H1({typed:J}),xO=zT({BigNumber:Se,config:de}),wO=N4({Complex:yr,typed:J}),NO=Fb({Complex:yr,config:de,typed:J}),DO=Bb({Complex:yr,config:de,typed:J}),la=ow({typed:J}),Er=Lb({typed:J}),dh=$x({typed:J}),mn=oy({typed:J}),AO=tN({format:Ha,typed:J}),EO=L4({config:de,typed:J}),SO=oN({typed:J}),CO=k4({config:de,typed:J}),gh=Tx({typed:J}),MO=UD({BigNumber:Se,typed:J}),yh=Zb({BigNumber:Se,Fraction:Bn,complex:ao,typed:J}),Es=HD({typed:J}),Jt=ry({Matrix:to,equalScalar:nr,typed:J}),FO=Fy({typed:J}),TO=Qb({typed:J}),BO=uy({typed:J}),$O=XD({typed:J}),OO=X1({typed:J}),_O=nD({Complex:yr,config:de,typed:J}),IO=fD({BigNumber:Se,typed:J}),Ss=nf({isInteger:st,typed:J}),RO=vD({BigNumber:Se,Complex:yr,config:de,typed:J}),qO=eN({format:Ha,typed:J}),zO=y4({typed:J}),Cs=FD({typed:J}),PO=PD({BigNumber:Se,typed:J}),Za=J1({typed:J}),LO=cN({typed:J}),UO=G4({config:de,typed:J}),kO=VD({BigNumber:Se,typed:J}),VO=JD({typed:J}),GO=Q2({SparseMatrix:Jt,typed:J}),Wt=Xb({Complex:yr,config:de,typed:J}),HO=KD({typed:J}),Xt=By({typed:J}),ZO=sD({BigNumber:Se,Complex:yr,config:de,typed:J}),JO=OD({BigNumber:Se,typed:J}),ca=by({Fraction:Bn,typed:J}),$n=P1({typed:J}),Te=wy({DenseMatrix:Qe,Matrix:to,SparseMatrix:Jt,typed:J}),WO=Dy({isZero:Tt,matrix:Te,typed:J}),bh=qb({DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J}),XO=Gb({BigNumber:Se,equalScalar:nr,matrix:Te,typed:J}),wt=vN({bignumber:Ft,fraction:ca,number:mn}),YO=_x({DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J}),xh=Yw({config:de,multiplyScalar:Er,numeric:wt,typed:J}),QO=pw({isInteger:st,matrix:Te,typed:J}),Hr=Aw({matrix:Te,config:de,typed:J}),ut=u2({DenseMatrix:Qe,config:de,matrix:Te,typed:J}),KO=Sw({matrix:Te,typed:J}),lt=cm({matrix:Te,typed:J}),br=jb({DenseMatrix:Qe,addScalar:Fr,equalScalar:nr,matrix:Te,typed:J,unaryMinus:Xt}),jO=uN({matrix:Te,typed:J}),Ms=$w({matrix:Te,typed:J}),wh=rx({BigNumber:Se,config:de,matrix:Te,typed:J}),Bt=Rw({BigNumber:Se,config:de,matrix:Te,typed:J}),e5=JN({equalScalar:nr,matrix:Te,not:dh,typed:J,zeros:Bt}),r5=px({equalScalar:nr,matrix:Te,typed:J}),t5=Nx({DenseMatrix:Qe,matrix:Te,typed:J}),n5=Uy({BigNumber:Se,Complex:yr,Fraction:Bn,config:de,isNegative:ua,matrix:Te,typed:J,unaryMinus:Xt}),fa=XN({BigNumber:Se,DenseMatrix:Qe,Fraction:Bn,config:de,equalScalar:nr,matrix:Te,typed:J}),Nh=r2({matrix:Te,typed:J}),Fs=Rf({isInteger:st,matrix:Te,typed:J}),a5=Lx({prod:xh,size:Hr,typed:J}),Ts=_w({conj:sa,transpose:Ms,typed:J}),Dh=Gx({DenseMatrix:Qe,SparseMatrix:Jt,matrix:Te,typed:J}),xr=hN({numeric:wt,typed:J}),oo=FN({DenseMatrix:Qe,divideScalar:xr,equalScalar:nr,matrix:Te,typed:J}),Nt=n2({DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J}),Ah=zw({addScalar:Fr,divideScalar:xr,exp:ph,i:lh,matrix:Te,multiplyScalar:Er,tau:fh,typed:J}),Ja=Xx({matrix:Te,typed:J}),i5=wb({BigNumber:Se,DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J}),o5=U1({isNumeric:$n,typed:J}),s5=NA({abs:tt,addScalar:Fr,divideScalar:xr,isPositive:io,multiplyScalar:Er,smaller:ut,sqrt:Wt,typed:J}),u5=Lw({conj:sa,dotDivide:oo,fft:Ah,typed:J}),l5=aw({matrix:Te,multiplyScalar:Er,typed:J}),so=g2({DenseMatrix:Qe,config:de,matrix:Te,typed:J}),c5=UN({DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J,zeros:Bt}),Eh=BN({DenseMatrix:Qe,divideScalar:xr,equalScalar:nr,matrix:Te,multiplyScalar:Er,subtract:br,typed:J}),Sh=Cy({flatten:Ja,matrix:Te,size:Hr,typed:J}),f5=Km({config:de,numeric:wt,smaller:ut,typed:J}),m5=Ww({isNaN:Za,isNumeric:$n,typed:J}),v5=EN({Complex:yr,config:de,divideScalar:xr,typed:J}),p5=fw({BigNumber:Se,config:de,matrix:Te,typed:J}),Bs=E2({compare:fa,isNaN:Za,isNumeric:$n,typed:J}),h5=gw({config:de,matrix:Te}),d5=VN({DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J,zeros:Bt}),uo=bN({BigNumber:Se,DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J,zeros:Bt}),$s=f2({DenseMatrix:Qe,config:de,matrix:Te,typed:J}),g5=N2({DenseMatrix:Qe,config:de,equalScalar:nr,matrix:Te,typed:J}),Os=ON({DenseMatrix:Qe,divideScalar:xr,equalScalar:nr,matrix:Te,multiplyScalar:Er,subtract:br,typed:J}),y5=Rx({DenseMatrix:Qe,matrix:Te,typed:J}),wr=xA({DenseMatrix:Qe,SparseMatrix:Jt,addScalar:Fr,equalScalar:nr,matrix:Te,typed:J}),b5=ED({BigNumber:Se,DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J}),x5=yx({DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J}),w5=Y4({addScalar:Fr,combinations:no,divideScalar:xr,isInteger:st,isNegative:ua,multiplyScalar:Er,typed:J}),$t=KN({compare:fa,typed:J}),N5=hp({add:wr,typed:J,unaryPlus:As}),Ch=x2({equal:Nt,typed:J}),D5=Qf({matrix:Te,number:mn,subtract:br,typed:J}),lo=SA({addScalar:Fr,conj:sa,multiplyScalar:Er,size:Hr,typed:J}),A5=o2({compareText:Nh,isZero:Tt,typed:J}),Mh=ub({DenseMatrix:Qe,config:de,equalScalar:nr,matrix:Te,round:uo,typed:J,zeros:Bt}),ma=tw({BigNumber:Se,DenseMatrix:Qe,SparseMatrix:Jt,config:de,matrix:Te,typed:J}),E5=nx({BigNumber:Se,add:wr,config:de,equal:Nt,isInteger:st,mod:bh,smaller:ut,typed:J,xgcd:wh}),ct=p2({DenseMatrix:Qe,config:de,matrix:Te,typed:J}),_s=wN({Complex:yr,config:de,divideScalar:xr,typed:J}),S5=IN({DenseMatrix:Qe,divideScalar:xr,equalScalar:nr,matrix:Te,multiplyScalar:Er,subtract:br,typed:J}),C5=Ey({flatten:Ja,matrix:Te,size:Hr,typed:J}),Sr=kb({addScalar:Fr,dot:lo,equalScalar:nr,matrix:Te,multiplyScalar:Er,typed:J}),Fh=_E({addScalar:Fr,complex:ao,conj:sa,divideScalar:xr,equal:Nt,identity:ma,isZero:Tt,matrix:Te,multiplyScalar:Er,sign:yh,sqrt:Wt,subtract:br,typed:J,unaryMinus:Xt,zeros:Bt}),Wa=rm({bignumber:Ft,matrix:Te,config:de,larger:ct,largerEq:so,smaller:ut,smallerEq:$s,typed:J}),M5=HN({DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J,zeros:Bt}),F5=pA({compareNatural:$t,typed:J}),Th=aS({SparseMatrix:Jt,abs:tt,add:wr,divideScalar:xr,larger:ct,largerEq:so,multiply:Sr,subtract:br,transpose:Ms,typed:J}),Bh=pp({add:wr,config:de,numeric:wt,typed:J}),T5=FA({add:wr,matrix:Te,typed:J}),$h=qN({DenseMatrix:Qe,divideScalar:xr,equalScalar:nr,matrix:Te,multiplyScalar:Er,subtract:br,typed:J}),B5=gD({Complex:yr,config:de,typed:J}),Oh=Yy({DenseMatrix:Qe,config:de,equalScalar:nr,matrix:Te,round:uo,typed:J,zeros:Bt}),$5=K4({addScalar:Fr,combinations:no,isInteger:st,isNegative:ua,isPositive:io,larger:ct,typed:J}),O5=kx({matrix:Te,multiply:Sr,subtract:br,typed:J}),_h=IF({divideScalar:xr,isZero:Tt,matrix:Te,multiply:Sr,subtract:br,typed:J,unaryMinus:Xt}),_5=jF({abs:tt,addScalar:Fr,divideScalar:xr,multiplyScalar:Er,sqrt:Wt,subtract:br,typed:J,unaryMinus:Xt}),I5=sx({equalScalar:nr,matrix:Te,multiplyScalar:Er,typed:J}),Ih=z2({larger:ct,smaller:ut}),Rh=ib({Complex:yr,DenseMatrix:Qe,ceil:Oh,equalScalar:nr,floor:Mh,matrix:Te,typed:J,zeros:Bt}),qh=$2({DenseMatrix:Qe,smaller:ut}),Zr=I2({ImmutableDenseMatrix:qh}),R5=t4({abs:tt,add:wr,addScalar:Fr,config:de,divideScalar:xr,equalScalar:nr,flatten:Ja,isNumeric:$n,isZero:Tt,matrix:Te,multiply:Sr,multiplyScalar:Er,smaller:ut,subtract:br,typed:J}),q5=Cb({equalScalar:nr,matrix:Te,typed:J}),z5=DN({Complex:yr,config:de,divideScalar:xr,log:_s,typed:J}),zh=Ym({config:de,larger:ct,numeric:wt,typed:J}),P5=v4({add:wr,compare:fa,multiply:Sr,partitionSelect:Bs,typed:J}),L5=om({Index:Zr,matrix:Te,range:Wa,typed:J}),U5=eA({DenseMatrix:Qe,Index:Zr,compareNatural:$t,size:Hr,subset:lt,typed:J}),k5=aA({DenseMatrix:Qe,Index:Zr,compareNatural:$t,size:Hr,subset:lt,typed:J}),V5=uA({Index:Zr,compareNatural:$t,size:Hr,subset:lt,typed:J}),G5=mA({Index:Zr,compareNatural:$t,size:Hr,subset:lt,typed:J}),H5=C2({compare:fa,compareNatural:$t,matrix:Te,typed:J}),Ph=Pf({Index:Zr,matrix:Te,range:Wa,typed:J}),Z5=BA({Index:Zr,typed:J}),On=qF({abs:tt,addScalar:Fr,det:_h,divideScalar:xr,identity:ma,matrix:Te,multiply:Sr,typed:J,unaryMinus:Xt}),J5=PF({Complex:yr,add:wr,ctranspose:Ts,deepEqual:Ch,divideScalar:xr,dot:lo,dotDivide:oo,equal:Nt,inv:On,matrix:Te,multiply:Sr,typed:J}),Yt=gN({Complex:yr,config:de,fraction:ca,identity:ma,inv:On,matrix:Te,multiply:Sr,number:mn,typed:J}),Lh=tA({DenseMatrix:Qe,Index:Zr,compareNatural:$t,size:Hr,subset:lt,typed:J}),W5=cA({Index:Zr,compareNatural:$t,size:Hr,subset:lt,typed:J}),Uh=U2({FibonacciHeap:Ih,addScalar:Fr,equalScalar:nr}),X5=WF({abs:tt,add:wr,identity:ma,inv:On,map:la,max:zh,multiply:Sr,size:Hr,sqrt:Wt,subtract:br,typed:J}),Ze=J2({BigNumber:Se,Complex:yr,Fraction:Bn,abs:tt,addScalar:Fr,config:de,divideScalar:xr,equal:Nt,fix:Rh,format:Ha,isNumeric:$n,multiplyScalar:Er,number:mn,pow:Yt,round:uo,subtract:br}),Y5=YT({BigNumber:Se,Unit:Ze,config:de}),Q5=BB({BigNumber:Se,Unit:Ze,config:de}),K5=bB({BigNumber:Se,Unit:Ze,config:de}),j5=jT({BigNumber:Se,Unit:Ze,config:de}),e8=wB({BigNumber:Se,Unit:Ze,config:de}),r8=eB({BigNumber:Se,Unit:Ze,config:de}),t8=j2({Unit:Ze,typed:J}),n8=mB({BigNumber:Se,Unit:Ze,config:de}),a8=CN({DenseMatrix:Qe,equalScalar:nr,matrix:Te,pow:Yt,typed:J}),i8=XT({BigNumber:Se,Unit:Ze,config:de}),o8=KT({BigNumber:Se,Unit:Ze,config:de}),s8=ZF({abs:tt,add:wr,identity:ma,inv:On,multiply:Sr,typed:J}),u8=NB({BigNumber:Se,Unit:Ze,config:de}),l8=DB({BigNumber:Se,Unit:Ze,config:de}),kh=x4({BigNumber:Se,Complex:yr,config:de,multiplyScalar:Er,pow:Yt,typed:J}),c8=HT({BigNumber:Se,Unit:Ze,config:de}),f8=cB({BigNumber:Se,Unit:Ze,config:de}),m8=aB({BigNumber:Se,Unit:Ze,config:de}),v8=AB({BigNumber:Se,Unit:Ze,config:de}),p8=WT({BigNumber:Se,Unit:Ze,config:de}),h8=$B({BigNumber:Se,Unit:Ze,config:de}),d8=SB({BigNumber:Se,Unit:Ze,config:de}),g8=vB({BigNumber:Se,Unit:Ze,config:de}),y8=nB({BigNumber:Se,Unit:Ze,config:de}),b8=zB({BigNumber:Se,Unit:Ze,config:de}),x8=IB({BigNumber:Se,Unit:Ze,config:de}),w8=PB({BigNumber:Se,Unit:Ze,config:de}),N8=fB({BigNumber:Se,Unit:Ze,config:de}),D8=JT({BigNumber:Se,Unit:Ze,config:de}),A8=hB({BigNumber:Se,Unit:Ze,config:de}),Vh=oA({DenseMatrix:Qe,Index:Zr,compareNatural:$t,size:Hr,subset:lt,typed:J}),E8=GT({BigNumber:Se,Unit:Ze,config:de}),S8=TB({BigNumber:Se,Unit:Ze,config:de}),C8=dB({BigNumber:Se,Unit:Ze,config:de}),M8=xB({BigNumber:Se,Unit:Ze,config:de}),F8=iB({BigNumber:Se,Unit:Ze,config:de}),T8=QT({BigNumber:Se,Unit:Ze,config:de}),Dt=QF({divideScalar:xr,equalScalar:nr,inv:On,matrix:Te,multiply:Sr,typed:J}),B8=sB({BigNumber:Se,Unit:Ze,config:de}),co=A4({gamma:kh,typed:J}),$8=_B({BigNumber:Se,Unit:Ze,config:de}),O8=rB({BigNumber:Se,Unit:Ze,config:de}),Gh=$E({DenseMatrix:Qe,Spa:Uh,SparseMatrix:Jt,abs:tt,addScalar:Fr,divideScalar:xr,equalScalar:nr,larger:ct,matrix:Te,multiplyScalar:Er,subtract:br,typed:J,unaryMinus:Xt}),_8=tB({BigNumber:Se,Unit:Ze,config:de}),I8=OB({BigNumber:Se,Unit:Ze,config:de}),R8=M4({add:wr,divide:Dt,factorial:co,isInteger:st,isPositive:io,multiply:Sr,typed:J}),q8=T4({factorial:co,typed:J}),z8=RB({BigNumber:Se,Unit:Ze,config:de}),P8=pB({BigNumber:Se,Unit:Ze,config:de}),L8=FB({BigNumber:Se,Unit:Ze,config:de}),Hh=Z4({bignumber:Ft,addScalar:Fr,combinations:no,divideScalar:xr,factorial:co,isInteger:st,isNegative:ua,larger:ct,multiplyScalar:Er,number:mn,pow:Yt,subtract:br,typed:J}),U8=X2({Unit:Ze,typed:J}),k8=W4({addScalar:Fr,isInteger:st,isNegative:ua,stirlingS2:Hh,typed:J}),Zh=GF({abs:tt,add:wr,addScalar:Fr,atan:vh,bignumber:Ft,column:Ph,complex:ao,config:de,cos:Cs,diag:Dh,divideScalar:xr,dot:lo,equal:Nt,flatten:Ja,im:hh,inv:On,larger:ct,matrix:Te,matrixFromColumns:Sh,multiply:Sr,multiplyScalar:Er,number:mn,qr:Fh,re:gh,sin:Es,smaller:ut,sqrt:Wt,subtract:br,typed:J,usolve:Os,usolveAll:$h}),V8=uB({BigNumber:Se,Unit:Ze,config:de}),G8=gp({add:wr,divide:Dt,typed:J}),H8=CB({BigNumber:Se,Unit:Ze,config:de}),Z8=ZT({BigNumber:Se,Unit:Ze,config:de}),Jh=dA({Index:Zr,concat:Fs,setDifference:Lh,size:Hr,subset:lt,typed:J}),Is=wp({add:wr,apply:Ss,divide:Dt,isNaN:Za,multiply:Sr,subtract:br,typed:J}),J8=oB({BigNumber:Se,Unit:Ze,config:de}),W8=oS({DenseMatrix:Qe,lsolve:Eh,lup:Gh,matrix:Te,slu:Th,typed:J,usolve:Os}),Wh=s4({add:wr,compare:fa,divide:Dt,partitionSelect:Bs,typed:J}),X8=yA({Index:Zr,concat:Fs,setIntersect:Vh,setSymDifference:Jh,size:Hr,subset:lt,typed:J}),Y8=Dp({map:la,sqrt:Wt,typed:J,variance:Is}),Q8=EB({BigNumber:Se,Unit:Ze,config:de}),K8=l4({abs:tt,map:la,median:Wh,subtract:br,typed:J}),Xh=AA({abs:tt,add:wr,conj:sa,ctranspose:Ts,eigs:Zh,equalScalar:nr,larger:ct,matrix:Te,multiply:Sr,pow:Yt,smaller:ut,sqrt:Wt,typed:J}),Yh=ww({BigNumber:Se,DenseMatrix:Qe,SparseMatrix:Jt,addScalar:Fr,config:de,cos:Cs,matrix:Te,multiplyScalar:Er,norm:Xh,sin:Es,typed:J,unaryMinus:Xt}),j8=S4({divide:Dt,dotDivide:oo,isNumeric:$n,log:_s,map:la,matrix:Te,multiply:Sr,sum:Bh,typed:J}),e6=bw({multiply:Sr,rotationMatrix:Yh,typed:J}),r6=qB({BigNumber:Se,Unit:Ze,config:de}),va={},pa={},Qh={},Jr=_A({mathWithTransform:pa}),ha=oE({Node:Jr}),Qt=uE({Node:Jr}),_n=cE({Node:Jr}),Kh=pE({Node:Jr}),da=zA({Node:Jr}),jh=GA({Node:Jr,ResultSet:ch}),ed=ZA({Node:Jr}),vn=eE({Node:Jr}),rd=mE({Node:Jr}),t6=NT({classes:Qh}),Rs=mS({math:va,typed:J}),td=tE({Node:Jr,typed:J}),n6=OF({Chain:Rs,typed:J}),ga=RA({Node:Jr,subset:lt}),nd=kA({matrix:Te,Node:Jr,subset:lt}),ya=aE({Node:Jr,size:Hr}),pn=gE({Unit:Ze,Node:Jr,math:va}),hn=bE({Node:Jr,SymbolNode:pn,math:va}),ft=wE({AccessorNode:ga,ArrayNode:da,AssignmentNode:nd,BlockNode:jh,ConditionalNode:ed,ConstantNode:vn,FunctionAssignmentNode:td,FunctionNode:hn,IndexNode:ya,ObjectNode:ha,OperatorNode:Qt,ParenthesisNode:_n,RangeNode:rd,RelationalNode:Kh,SymbolNode:pn,config:de,numeric:wt,typed:J}),ad=vT({ConstantNode:vn,FunctionNode:hn,OperatorNode:Qt,ParenthesisNode:_n,parse:ft,typed:J}),qs=uT({bignumber:Ft,fraction:ca,AccessorNode:ga,ArrayNode:da,ConstantNode:vn,FunctionNode:hn,IndexNode:ya,ObjectNode:ha,OperatorNode:Qt,SymbolNode:pn,config:de,mathWithTransform:pa,matrix:Te,parse:ft,typed:J}),a6=DE({parse:ft,typed:J}),id=lS({parse:ft}),i6=eT({parse:ft,typed:J}),zs=cT({AccessorNode:ga,ArrayNode:da,ConstantNode:vn,FunctionNode:hn,IndexNode:ya,ObjectNode:ha,OperatorNode:Qt,ParenthesisNode:_n,SymbolNode:pn,add:wr,divide:Dt,equal:Nt,isZero:Tt,multiply:Sr,parse:ft,pow:Yt,subtract:br,typed:J}),Ps=EE({parse:ft,typed:J}),o6=BF({Help:id,mathWithTransform:pa,typed:J}),od=ME({evaluate:Ps}),s6=TE({Parser:od,typed:J}),fo=iT({bignumber:Ft,fraction:ca,AccessorNode:ga,ArrayNode:da,ConstantNode:vn,FunctionNode:hn,IndexNode:ya,ObjectNode:ha,OperatorNode:Qt,ParenthesisNode:_n,SymbolNode:pn,add:wr,config:de,divide:Dt,equal:Nt,isZero:Tt,mathWithTransform:pa,matrix:Te,multiply:Sr,parse:ft,pow:Yt,resolve:ad,simplifyConstant:qs,simplifyCore:zs,subtract:br,typed:J}),u6=hT({OperatorNode:Qt,parse:ft,simplify:fo,typed:J}),l6=gT({ConstantNode:vn,FunctionNode:hn,OperatorNode:Qt,ParenthesisNode:_n,SymbolNode:pn,config:de,equal:Nt,isZero:Tt,numeric:wt,parse:ft,simplify:fo,typed:J}),c6=bT({bignumber:Ft,fraction:ca,AccessorNode:ga,ArrayNode:da,ConstantNode:vn,FunctionNode:hn,IndexNode:ya,ObjectNode:ha,OperatorNode:Qt,ParenthesisNode:_n,SymbolNode:pn,add:wr,config:de,divide:Dt,equal:Nt,isZero:Tt,mathWithTransform:pa,matrix:Te,multiply:Sr,parse:ft,pow:Yt,simplify:fo,simplifyConstant:qs,simplifyCore:zs,subtract:br,typed:J});Ar(va,{e:uh,false:R$,fineStructure:q$,i:lh,Infinity:z$,LN10:P$,LOG10E:L$,NaN:U$,null:k$,phi:V$,SQRT1_2:H$,sackurTetrode:Z$,tau:fh,true:J$,E:uh,version:W$,efimovFactor:X$,LN2:Y$,pi:mh,replacer:Q$,reviver:t6,SQRT2:K$,typed:J,unaryPlus:As,PI:mh,weakMixingAngle:j$,abs:tt,acos:eO,acot:rO,acsc:tO,addScalar:Fr,arg:nO,asech:aO,asinh:iO,atan:vh,atanh:oO,bignumber:Ft,bitNot:sO,boolean:uO,clone:lO,combinations:no,complex:ao,conj:sa,cosh:cO,coth:fO,csc:mO,cube:vO,equalScalar:nr,erf:pO,exp:ph,expm1:hO,filter:dO,forEach:gO,format:Ha,getMatrixDataType:yO,hex:bO,im:hh,isInteger:st,isNegative:ua,isPositive:io,isZero:Tt,LOG2E:xO,lgamma:wO,log10:NO,log2:DO,map:la,multiplyScalar:Er,not:dh,number:mn,oct:AO,pickRandom:EO,print:SO,random:CO,re:gh,sec:MO,sign:yh,sin:Es,splitUnit:FO,square:TO,string:BO,tan:$O,typeOf:OO,acosh:_O,acsch:IO,apply:Ss,asec:RO,bin:qO,chain:n6,combinationsWithRep:zO,cos:Cs,csch:PO,isNaN:Za,isPrime:LO,randomInt:UO,sech:kO,sinh:VO,sparse:GO,sqrt:Wt,tanh:HO,unaryMinus:Xt,acoth:ZO,cot:JO,fraction:ca,isNumeric:$n,matrix:Te,matrixFromFunction:WO,mod:bh,nthRoot:XO,numeric:wt,or:YO,prod:xh,reshape:QO,size:Hr,smaller:ut,squeeze:KO,subset:lt,subtract:br,to:jO,transpose:Ms,xgcd:wh,zeros:Bt,and:e5,bitAnd:r5,bitXor:t5,cbrt:n5,compare:fa,compareText:Nh,concat:Fs,count:a5,ctranspose:Ts,diag:Dh,divideScalar:xr,dotDivide:oo,equal:Nt,fft:Ah,flatten:Ja,gcd:i5,hasNumericValue:o5,hypot:s5,ifft:u5,kron:l5,largerEq:so,leftShift:c5,lsolve:Eh,matrixFromColumns:Sh,min:f5,mode:m5,nthRoots:v5,ones:p5,partitionSelect:Bs,resize:h5,rightArithShift:d5,round:uo,smallerEq:$s,unequal:g5,usolve:Os,xor:y5,add:wr,atan2:b5,bitOr:x5,catalan:w5,compareNatural:$t,cumsum:N5,deepEqual:Ch,diff:D5,dot:lo,equalText:A5,floor:Mh,identity:ma,invmod:E5,larger:ct,log:_s,lsolveAll:S5,matrixFromRows:C5,multiply:Sr,qr:Fh,range:Wa,rightLogShift:M5,setSize:F5,slu:Th,sum:Bh,trace:T5,usolveAll:$h,asin:B5,ceil:Oh,composition:$5,cross:O5,det:_h,distance:_5,dotMultiply:I5,fix:Rh,intersect:R5,lcm:q5,log1p:z5,max:zh,quantileSeq:P5,row:L5,setCartesian:U5,setDistinct:k5,setIsSubset:V5,setPowerset:G5,sort:H5,column:Ph,index:Z5,inv:On,pinv:J5,pow:Yt,setDifference:Lh,setMultiplicity:W5,sqrtm:X5,vacuumImpedance:Y5,wienDisplacement:Q5,atomicMass:K5,bohrMagneton:j5,boltzmann:e8,conductanceQuantum:r8,createUnit:t8,deuteronMass:n8,dotPow:a8,electricConstant:i8,elementaryCharge:o8,expm:s8,faraday:u8,firstRadiation:l8,gamma:kh,gravitationConstant:c8,hartreeEnergy:f8,klitzing:m8,loschmidt:v8,magneticConstant:p8,molarMass:h8,molarPlanckConstant:d8,neutronMass:g8,nuclearMagneton:y8,planckCharge:b8,planckLength:x8,planckTemperature:w8,protonMass:N8,reducedPlanckConstant:D8,rydberg:A8,setIntersect:Vh,speedOfLight:E8,stefanBoltzmann:S8,thomsonCrossSection:C8,avogadro:M8,bohrRadius:F8,coulomb:T8,divide:Dt,electronMass:B8,factorial:co,gravity:$8,inverseConductanceQuantum:O8,lup:Gh,magneticFluxQuantum:_8,molarMassC12:I8,multinomial:R8,parse:ft,permutations:q8,planckMass:z8,quantumOfCirculation:P8,resolve:ad,secondRadiation:L8,simplifyConstant:qs,stirlingS2:Hh,unit:U8,bellNumbers:k8,compile:a6,eigs:Zh,fermiCoupling:V8,leafCount:i6,mean:G8,molarVolume:H8,planckConstant:Z8,setSymDifference:Jh,simplifyCore:zs,variance:Is,classicalElectronRadius:J8,evaluate:Ps,help:o6,lusolve:W8,median:Wh,setUnion:X8,std:Y8,gasConstant:Q8,mad:K8,parser:s6,simplify:fo,symbolicEqual:u6,derivative:l6,norm:Xh,rationalize:c6,rotationMatrix:Yh,kldivergence:j8,rotate:e6,planckTime:r6,config:de}),Ar(pa,va,{filter:WB({typed:J}),forEach:QB({typed:J}),map:n$({typed:J}),apply:kB({isInteger:st,typed:J}),diff:S$({bignumber:Ft,matrix:Te,number:mn,subtract:br,typed:J}),subset:w$({matrix:Te,typed:J}),concat:A$({isInteger:st,matrix:Te,typed:J}),max:o$({config:de,larger:ct,numeric:wt,typed:J}),min:m$({config:de,numeric:wt,smaller:ut,typed:J}),range:h$({bignumber:Ft,matrix:Te,config:de,larger:ct,largerEq:so,smaller:ut,smallerEq:$s,typed:J}),sum:B$({add:wr,config:de,numeric:wt,typed:J}),cumsum:O$({add:wr,typed:J,unaryPlus:As}),row:y$({Index:Zr,matrix:Te,range:Wa,typed:J}),column:HB({Index:Zr,matrix:Te,range:Wa,typed:J}),index:e$({Index:Zr}),mean:l$({add:wr,divide:Dt,typed:J}),variance:I$({add:wr,apply:Ss,divide:Dt,isNaN:Za,multiply:Sr,subtract:br,typed:J}),std:F$({map:la,sqrt:Wt,typed:J,variance:Is})}),Ar(Qh,{BigNumber:Se,Complex:yr,Fraction:Bn,Matrix:to,Node:Jr,ObjectNode:ha,OperatorNode:Qt,ParenthesisNode:_n,Range:G$,RelationalNode:Kh,ResultSet:ch,ArrayNode:da,BlockNode:jh,ConditionalNode:ed,ConstantNode:vn,DenseMatrix:Qe,RangeNode:rd,Chain:Rs,FunctionAssignmentNode:td,SparseMatrix:Jt,AccessorNode:ga,AssignmentNode:nd,IndexNode:ya,FibonacciHeap:Ih,ImmutableDenseMatrix:qh,Index:Zr,Spa:Uh,Unit:Ze,SymbolNode:pn,FunctionNode:hn,Help:id,Parser:od}),Rs.createProxy(va);/**
71
+ In case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.`,examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},wF={name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, dimension)","std(A, normalization)","std(A, dimension, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},NF={name:"cumsum",category:"Statistics",syntax:["cumsum(a, b, c, ...)","cumsum(A)"],description:"Compute the cumulative sum of all values.",examples:["cumsum(2, 3, 4, 1)","cumsum([2, 3, 4, 1])","cumsum([1, 2; 3, 4])","cumsum([1, 2; 3, 4], 1)","cumsum([1, 2; 3, 4], 2)"],seealso:["max","mean","median","min","prod","std","sum","variance"]},DF={name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)","sum(A, dimension)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},AF={name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, dimension)","variance(A, normalization)","variance(A, dimension, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},EF={name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},SF={name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},CF={name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},MF={name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},FF={name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},TF={name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},BF={name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},$F={name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},OF={name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},IF={name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},RF={name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},_F={name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},qF={name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},zF={name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},PF={name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},UF={name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},LF={name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},kF={name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},VF={name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},GF={name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},HF={name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},ZF={name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},JF={name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},XF={name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},WF={name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},YF={name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},QF={name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},KF={name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},jF={name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},e4={name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},r4={name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},t4={name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},n4={name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},a4={name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},i4={name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},o4={name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},s4={name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},u4={name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},l4={name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "BigNumber")','numeric("4", "Fraction)','numeric(4, "Fraction")','numeric(fraction(2, 5), "number)'],seealso:["number","fraction","bignumber","string","format"]},c4={name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},f4={name:"print",category:"Utils",syntax:["print(template, values)","print(template, values, precision)"],description:"Interpolate values into a string template.",examples:['print("Lucy is $age years old", {age: 5})','print("The value of pi is $pi", {pi: pi}, 3)','print("Hello, $user.name!", {user: {name: "John"}})','print("Values: $0, $1, $2", [6, 9, 4])'],seealso:["format"]},m4={name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},v4={bignumber:uC,boolean:lC,complex:cC,createUnit:fC,fraction:mC,index:vC,matrix:pC,number:hC,sparse:dC,splitUnit:gC,string:yC,unit:bC,e:gp,E:gp,false:JS,i:XS,Infinity:WS,LN2:QS,LN10:YS,LOG2E:jS,LOG10E:KS,NaN:eC,null:rC,pi:yp,PI:yp,phi:tC,SQRT1_2:nC,SQRT2:aC,tau:iC,true:oC,version:sC,speedOfLight:{description:"Speed of light in vacuum",examples:["speedOfLight"]},gravitationConstant:{description:"Newtonian constant of gravitation",examples:["gravitationConstant"]},planckConstant:{description:"Planck constant",examples:["planckConstant"]},reducedPlanckConstant:{description:"Reduced Planck constant",examples:["reducedPlanckConstant"]},magneticConstant:{description:"Magnetic constant (vacuum permeability)",examples:["magneticConstant"]},electricConstant:{description:"Electric constant (vacuum permeability)",examples:["electricConstant"]},vacuumImpedance:{description:"Characteristic impedance of vacuum",examples:["vacuumImpedance"]},coulomb:{description:"Coulomb's constant",examples:["coulomb"]},elementaryCharge:{description:"Elementary charge",examples:["elementaryCharge"]},bohrMagneton:{description:"Borh magneton",examples:["bohrMagneton"]},conductanceQuantum:{description:"Conductance quantum",examples:["conductanceQuantum"]},inverseConductanceQuantum:{description:"Inverse conductance quantum",examples:["inverseConductanceQuantum"]},magneticFluxQuantum:{description:"Magnetic flux quantum",examples:["magneticFluxQuantum"]},nuclearMagneton:{description:"Nuclear magneton",examples:["nuclearMagneton"]},klitzing:{description:"Von Klitzing constant",examples:["klitzing"]},bohrRadius:{description:"Borh radius",examples:["bohrRadius"]},classicalElectronRadius:{description:"Classical electron radius",examples:["classicalElectronRadius"]},electronMass:{description:"Electron mass",examples:["electronMass"]},fermiCoupling:{description:"Fermi coupling constant",examples:["fermiCoupling"]},fineStructure:{description:"Fine-structure constant",examples:["fineStructure"]},hartreeEnergy:{description:"Hartree energy",examples:["hartreeEnergy"]},protonMass:{description:"Proton mass",examples:["protonMass"]},deuteronMass:{description:"Deuteron Mass",examples:["deuteronMass"]},neutronMass:{description:"Neutron mass",examples:["neutronMass"]},quantumOfCirculation:{description:"Quantum of circulation",examples:["quantumOfCirculation"]},rydberg:{description:"Rydberg constant",examples:["rydberg"]},thomsonCrossSection:{description:"Thomson cross section",examples:["thomsonCrossSection"]},weakMixingAngle:{description:"Weak mixing angle",examples:["weakMixingAngle"]},efimovFactor:{description:"Efimov factor",examples:["efimovFactor"]},atomicMass:{description:"Atomic mass constant",examples:["atomicMass"]},avogadro:{description:"Avogadro's number",examples:["avogadro"]},boltzmann:{description:"Boltzmann constant",examples:["boltzmann"]},faraday:{description:"Faraday constant",examples:["faraday"]},firstRadiation:{description:"First radiation constant",examples:["firstRadiation"]},loschmidt:{description:"Loschmidt constant at T=273.15 K and p=101.325 kPa",examples:["loschmidt"]},gasConstant:{description:"Gas constant",examples:["gasConstant"]},molarPlanckConstant:{description:"Molar Planck constant",examples:["molarPlanckConstant"]},molarVolume:{description:"Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",examples:["molarVolume"]},sackurTetrode:{description:"Sackur-Tetrode constant at T=1 K and p=101.325 kPa",examples:["sackurTetrode"]},secondRadiation:{description:"Second radiation constant",examples:["secondRadiation"]},stefanBoltzmann:{description:"Stefan-Boltzmann constant",examples:["stefanBoltzmann"]},wienDisplacement:{description:"Wien displacement law constant",examples:["wienDisplacement"]},molarMass:{description:"Molar mass constant",examples:["molarMass"]},molarMassC12:{description:"Molar mass constant of carbon-12",examples:["molarMassC12"]},gravity:{description:"Standard acceleration of gravity (standard acceleration of free-fall on Earth)",examples:["gravity"]},planckLength:{description:"Planck length",examples:["planckLength"]},planckMass:{description:"Planck mass",examples:["planckMass"]},planckTime:{description:"Planck time",examples:["planckTime"]},planckCharge:{description:"Planck charge",examples:["planckCharge"]},planckTemperature:{description:"Planck temperature",examples:["planckTemperature"]},derivative:DC,lsolve:EC,lsolveAll:SC,lup:CC,lusolve:MC,leafCount:AC,polynomialRoot:FC,resolve:$C,simplify:OC,simplifyConstant:IC,simplifyCore:RC,symbolicEqual:qC,rationalize:BC,slu:_C,usolve:zC,usolveAll:PC,qr:TC,abs:UC,add:LC,cbrt:kC,ceil:VC,cube:GC,divide:HC,dotDivide:ZC,dotMultiply:JC,dotPow:XC,exp:WC,expm:YC,expm1:QC,fix:KC,floor:jC,gcd:eM,hypot:rM,lcm:nM,log:aM,log2:sM,log1p:oM,log10:iM,mod:uM,multiply:lM,norm:cM,nthRoot:fM,nthRoots:mM,pow:vM,round:pM,sign:hM,sqrt:dM,sqrtm:gM,square:wM,subtract:NM,unaryMinus:DM,unaryPlus:AM,xgcd:EM,invmod:tM,bitAnd:SM,bitNot:CM,bitOr:MM,bitXor:FM,leftShift:TM,rightArithShift:BM,rightLogShift:$M,bellNumbers:OM,catalan:IM,composition:RM,stirlingS2:_M,config:xC,import:wC,typed:NC,arg:qM,conj:zM,re:UM,im:PM,evaluate:LM,help:kM,distance:VM,intersect:GM,and:HM,not:ZM,or:JM,xor:XM,concat:YM,count:QM,cross:KM,column:WM,ctranspose:jM,det:e3,diag:r3,diff:t3,dot:n3,getMatrixDataType:u3,identity:l3,filter:i3,flatten:o3,forEach:s3,inv:c3,pinv:f3,eigs:a3,kron:m3,matrixFromFunction:h3,matrixFromRows:d3,matrixFromColumns:p3,map:v3,ones:g3,partitionSelect:y3,range:b3,resize:w3,reshape:x3,rotate:N3,rotationMatrix:D3,row:A3,size:E3,sort:S3,squeeze:C3,subset:M3,trace:F3,transpose:T3,zeros:B3,fft:$3,ifft:O3,sylvester:yM,schur:bM,lyap:xM,combinations:I3,combinationsWithRep:R3,factorial:_3,gamma:q3,kldivergence:P3,lgamma:z3,multinomial:U3,permutations:L3,pickRandom:k3,random:V3,randomInt:G3,compare:H3,compareNatural:Z3,compareText:J3,deepEqual:X3,equal:W3,equalText:Y3,larger:Q3,largerEq:K3,smaller:j3,smallerEq:eF,unequal:rF,setCartesian:tF,setDifference:nF,setDistinct:aF,setIntersect:iF,setIsSubset:oF,setMultiplicity:sF,setPowerset:uF,setSize:lF,setSymDifference:cF,setUnion:fF,erf:mF,cumsum:NF,mad:vF,max:pF,mean:hF,median:dF,min:gF,mode:yF,prod:bF,quantileSeq:xF,std:wF,sum:DF,variance:AF,acos:EF,acosh:SF,acot:CF,acoth:MF,acsc:FF,acsch:TF,asec:BF,asech:$F,asin:OF,asinh:IF,atan:RF,atanh:qF,atan2:_F,cos:zF,cosh:PF,cot:UF,coth:LF,csc:kF,csch:VF,sec:GF,sech:HF,sin:ZF,sinh:JF,tan:XF,tanh:WF,to:YF,clone:KF,format:jF,bin:QF,oct:c4,hex:r4,isNaN:n4,isInteger:t4,isNegative:a4,isNumeric:i4,hasNumericValue:e4,isPositive:o4,isPrime:s4,isZero:u4,print:f4,typeOf:m4,numeric:l4},bp="help",p4=["typed","mathWithTransform","Help"],h4=q(bp,p4,r=>{var{typed:e,mathWithTransform:t,Help:a}=r;return e(bp,{any:function(i){var o,f=i;if(typeof i!="string"){for(o in t)if(Re(t,o)&&i===t[o]){f=o;break}}var l=lt(v4,f);if(!l){var u=typeof f=="function"?f.name:f;throw new Error('No documentation found on "'+u+'"')}return new a(l)}})}),xp="chain",d4=["typed","Chain"],g4=q(xp,d4,r=>{var{typed:e,Chain:t}=r;return e(xp,{"":function(){return new t},any:function(n){return new t(n)}})}),wp="det",y4=["typed","matrix","subtract","multiply","divideScalar","isZero","unaryMinus"],b4=q(wp,y4,r=>{var{typed:e,matrix:t,subtract:a,multiply:n,divideScalar:i,isZero:o,unaryMinus:f}=r;return e(wp,{any:function(s){return Ge(s)},"Array | Matrix":function(s){var c;switch(Ve(s)?c=s.size():Array.isArray(s)?(s=t(s),c=s.size()):c=[],c.length){case 0:return Ge(s);case 1:if(c[0]===1)return Ge(s.valueOf()[0]);if(c[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+Ye(c)+")");case 2:{var m=c[0],v=c[1];if(m===v)return l(s.clone().valueOf(),m);if(v===0)return 1;throw new RangeError("Matrix must be square (size: "+Ye(c)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Ye(c)+")")}}});function l(u,s,c){if(s===1)return Ge(u[0][0]);if(s===2)return a(n(u[0][0],u[1][1]),n(u[1][0],u[0][1]));for(var m=!1,v=new Array(s).fill(0).map((E,A)=>A),h=0;h<s;h++){var p=v[h];if(o(u[p][h])){var g=void 0;for(g=h+1;g<s;g++)if(!o(u[v[g]][h])){p=v[g],v[g]=v[h],v[h]=p,m=!m;break}if(g===s)return u[p][h]}for(var y=u[p][h],N=h===0?1:u[v[h-1]][h-1],d=h+1;d<s;d++)for(var w=v[d],x=h+1;x<s;x++)u[w][x]=i(a(n(u[w][x],y),n(u[w][h],u[p][x])),N)}var b=u[v[s-1]][s-1];return m?f(b):b}}),Np="inv",x4=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],w4=q(Np,x4,r=>{var{typed:e,matrix:t,divideScalar:a,addScalar:n,multiply:i,unaryMinus:o,det:f,identity:l,abs:u}=r;return e(Np,{"Array | Matrix":function(m){var v=Ve(m)?m.size():er(m);switch(v.length){case 1:if(v[0]===1)return Ve(m)?t([a(1,m.valueOf()[0])]):[a(1,m[0])];throw new RangeError("Matrix must be square (size: "+Ye(v)+")");case 2:{var h=v[0],p=v[1];if(h===p)return Ve(m)?t(s(m.valueOf(),h,p),m.storage()):s(m,h,p);throw new RangeError("Matrix must be square (size: "+Ye(v)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Ye(v)+")")}},any:function(m){return a(1,m)}});function s(c,m,v){var h,p,g,y,N;if(m===1){if(y=c[0][0],y===0)throw Error("Cannot calculate inverse, determinant is zero");return[[a(1,y)]]}else if(m===2){var d=f(c);if(d===0)throw Error("Cannot calculate inverse, determinant is zero");return[[a(c[1][1],d),a(o(c[0][1]),d)],[a(o(c[1][0]),d),a(c[0][0],d)]]}else{var w=c.concat();for(h=0;h<m;h++)w[h]=w[h].concat();for(var x=l(m).valueOf(),b=0;b<v;b++){var E=u(w[b][b]),A=b;for(h=b+1;h<m;)u(w[h][b])>E&&(E=u(w[h][b]),A=h),h++;if(E===0)throw Error("Cannot calculate inverse, determinant is zero");h=A,h!==b&&(N=w[b],w[b]=w[h],w[h]=N,N=x[b],x[b]=x[h],x[h]=N);var S=w[b],D=x[b];for(h=0;h<m;h++){var T=w[h],B=x[h];if(h!==b){if(T[b]!==0){for(g=a(o(T[b]),S[b]),p=b;p<v;p++)T[p]=n(T[p],i(g,S[p]));for(p=0;p<v;p++)B[p]=n(B[p],i(g,D[p]))}}else{for(g=S[b],p=b;p<v;p++)T[p]=a(T[p],g);for(p=0;p<v;p++)B[p]=a(B[p],g)}}}return x}}}),Dp="pinv",N4=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],D4=q(Dp,N4,r=>{var{typed:e,matrix:t,inv:a,deepEqual:n,equal:i,dotDivide:o,dot:f,ctranspose:l,divideScalar:u,multiply:s,add:c,Complex:m}=r;return e(Dp,{"Array | Matrix":function(d){var w=Ve(d)?d.size():er(d);switch(w.length){case 1:return y(d)?l(d):w[0]===1?a(d):o(l(d),f(d,d));case 2:{if(y(d))return l(d);var x=w[0],b=w[1];if(x===b)try{return a(d)}catch(E){if(!(E instanceof Error&&E.message.match(/Cannot calculate inverse, determinant is zero/)))throw E}return Ve(d)?t(v(d.valueOf(),x,b),d.storage()):v(d,x,b)}default:throw new RangeError("Matrix must be two dimensional (size: "+Ye(w)+")")}},any:function(d){return i(d,0)?Ge(d):u(1,d)}});function v(N,d,w){var{C:x,F:b}=p(N,d,w),E=s(a(s(l(x),x)),l(x)),A=s(l(b),a(s(b,l(b))));return s(A,E)}function h(N,d,w){for(var x=Ge(N),b=0,E=0;E<d;E++){if(w<=b)return x;for(var A=E;g(x[A][b]);)if(A++,d===A&&(A=E,b++,w===b))return x;[x[A],x[E]]=[x[E],x[A]];for(var S=x[E][b],D=0;D<w;D++)x[E][D]=o(x[E][D],S);for(var T=0;T<d;T++)if(T!==E){S=x[T][b];for(var B=0;B<w;B++)x[T][B]=c(x[T][B],s(-1,s(S,x[E][B])))}b++}return x}function p(N,d,w){var x=h(N,d,w),b=N.map((A,S)=>A.filter((D,T)=>T<d&&!g(f(x[T],x[T])))),E=x.filter((A,S)=>!g(f(x[S],x[S])));return{C:b,F:E}}function g(N){return i(c(N,m(1,1)),c(0,m(1,1)))}function y(N){return n(c(N,m(1,1)),c(s(N,0),m(1,1)))}});function A4(r){var{addScalar:e,subtract:t,flatten:a,multiply:n,multiplyScalar:i,divideScalar:o,sqrt:f,abs:l,bignumber:u,diag:s,inv:c,qr:m,usolve:v,usolveAll:h,equal:p,complex:g,larger:y,smaller:N,matrixFromColumns:d,dot:w}=r;function x(k,Q,K,L,j){j===void 0&&(j=!0);var ae=b(k,Q,K,L,j);E(k,Q,K,L,j,ae);var{values:re,C:fe}=A(k,Q,K,L,j),he;return j&&(he=S(k,Q,fe,ae,re,K,L),he=d(...he)),{values:re,vectors:he}}function b(k,Q,K,L,j){var ae=L==="BigNumber",re=L==="Complex",fe=ae?u(0):0,he=ae?u(1):re?g(1):1,ce=ae?u(1):1,ie=ae?u(10):2,Ae=i(ie,ie),Oe;j&&(Oe=Array(Q).fill(he));for(var Ce=!1;!Ce;){Ce=!0;for(var $e=0;$e<Q;$e++){for(var V=fe,X=fe,oe=0;oe<Q;oe++)if($e!==oe){var G=l(k[$e][oe]);V=e(V,G),X=e(X,G)}if(!p(V,0)&&!p(X,0)){for(var Y=ce,te=V,ye=o(X,ie),me=i(X,ie);N(te,ye);)te=i(te,Ae),Y=i(Y,ie);for(;y(te,me);)te=o(te,Ae),Y=o(Y,ie);var z=N(o(e(te,X),Y),i(e(V,X),.95));if(z){Ce=!1;for(var U=o(1,Y),ee=0;ee<Q;ee++)$e!==ee&&(k[$e][ee]=i(k[$e][ee],Y),k[ee][$e]=i(k[ee][$e],U));j&&(Oe[$e]=i(Oe[$e],Y))}}}}return s(Oe)}function E(k,Q,K,L,j,ae){var re=L==="BigNumber",fe=L==="Complex",he=re?u(0):fe?g(0):0;re&&(K=u(K));for(var ce=0;ce<Q-2;ce++){for(var ie=0,Ae=he,Oe=ce+1;Oe<Q;Oe++){var Ce=k[Oe][ce];N(l(Ae),l(Ce))&&(Ae=Ce,ie=Oe)}if(!N(l(Ae),K)){if(ie!==ce+1){var $e=k[ie];k[ie]=k[ce+1],k[ce+1]=$e;for(var V=0;V<Q;V++){var X=k[V][ie];k[V][ie]=k[V][ce+1],k[V][ce+1]=X}if(j){var oe=ae[ie];ae[ie]=ae[ce+1],ae[ce+1]=oe}}for(var G=ce+2;G<Q;G++){var Y=o(k[G][ce],Ae);if(Y!==0){for(var te=0;te<Q;te++)k[G][te]=t(k[G][te],i(Y,k[ce+1][te]));for(var ye=0;ye<Q;ye++)k[ye][ce+1]=e(k[ye][ce+1],i(Y,k[ye][G]));if(j)for(var me=0;me<Q;me++)ae[G][me]=t(ae[G][me],i(Y,ae[ce+1][me]))}}}}return ae}function A(k,Q,K,L,j){var ae=L==="BigNumber",re=L==="Complex",fe=ae?u(1):re?g(1):1;ae&&(K=u(K));for(var he=Ge(k),ce=[],ie=Q,Ae=[],Oe=j?s(Array(Q).fill(fe)):void 0,Ce=j?s(Array(ie).fill(fe)):void 0,$e=0;$e<=100;){$e+=1;for(var V=0,X=0;X<ie;X++)he[X][X]=t(he[X][X],V);var{Q:oe,R:G}=m(he);he=n(G,oe);for(var Y=0;Y<ie;Y++)he[Y][Y]=e(he[Y][Y],V);if(j&&(Ce=n(Ce,oe)),ie===1||N(l(he[ie-1][ie-2]),K)){$e=0,ce.push(he[ie-1][ie-1]),j&&(Ae.unshift([[1]]),B(Ce,Q),Oe=n(Oe,Ce),ie>1&&(Ce=s(Array(ie-1).fill(fe)))),ie-=1,he.pop();for(var te=0;te<ie;te++)he[te].pop()}else if(ie===2||N(l(he[ie-2][ie-3]),K)){$e=0;var ye=D(he[ie-2][ie-2],he[ie-2][ie-1],he[ie-1][ie-2],he[ie-1][ie-1]);ce.push(...ye),j&&(Ae.unshift(T(he[ie-2][ie-2],he[ie-2][ie-1],he[ie-1][ie-2],he[ie-1][ie-1],ye[0],ye[1],K,L)),B(Ce,Q),Oe=n(Oe,Ce),ie>2&&(Ce=s(Array(ie-2).fill(fe)))),ie-=2,he.pop(),he.pop();for(var me=0;me<ie;me++)he[me].pop(),he[me].pop()}if(ie===0)break}if(ce.sort((ee,ue)=>+t(l(ee),l(ue))),$e>100){var z=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+ce.join(", "));throw z.values=ce,z.vectors=[],z}var U=j?n(Oe,I(Ae,Q)):void 0;return{values:ce,C:U}}function S(k,Q,K,L,j,ae,re){var fe=c(K),he=n(fe,k,K),ce=re==="BigNumber",ie=re==="Complex",Ae=ce?u(0):ie?g(0):0,Oe=ce?u(1):ie?g(1):1,Ce=[],$e=[];for(var V of j){var X=P(Ce,V,p);X===-1?(Ce.push(V),$e.push(1)):$e[X]+=1}for(var oe=[],G=Ce.length,Y=Array(Q).fill(Ae),te=s(Array(Q).fill(Oe)),ye=[],me=function(){var ue=Ce[z],ve=t(he,n(ue,te)),de=h(ve,Y);for(de.shift();de.length<$e[z];){var be=R(ve,Q,de,ae,re);if(be==null){ye.push(ue);break}de.push(be)}var pe=n(c(L),K);de=de.map(we=>n(pe,we)),oe.push(...de.map(we=>a(we)))},z=0;z<G;z++)me();if(ye.length!==0){var U=new Error("Failed to find eigenvectors for the following eigenvalues: "+ye.join(", "));throw U.values=j,U.vectors=oe,U}return oe}function D(k,Q,K,L){var j=e(k,L),ae=t(i(k,L),i(Q,K)),re=i(j,.5),fe=i(f(t(i(j,j),i(4,ae))),.5);return[e(re,fe),t(re,fe)]}function T(k,Q,K,L,j,ae,re,fe){var he=fe==="BigNumber",ce=fe==="Complex",ie=he?u(0):ce?g(0):0,Ae=he?u(1):ce?g(1):1;if(N(l(K),re))return[[Ae,ie],[ie,Ae]];if(y(l(t(j,ae)),re))return[[t(j,L),t(ae,L)],[K,K]];var Oe=t(k,j),Ce=t(Q,j),$e=t(K,j),V=t(L,j);return N(l(Ce),re)?[[Oe,Ae],[$e,ie]]:[[Ce,ie],[V,Ae]]}function B(k,Q){for(var K=0;K<k.length;K++)k[K].push(...Array(Q-k[K].length).fill(0));for(var L=k.length;L<Q;L++)k.push(Array(Q).fill(0)),k[L][L]=1;return k}function I(k,Q){for(var K=[],L=0;L<Q;L++)K[L]=Array(Q).fill(0);var j=0;for(var ae of k){for(var re=ae.length,fe=0;fe<re;fe++)for(var he=0;he<re;he++)K[j+fe][j+he]=ae[fe][he];j+=re}return K}function P(k,Q,K){for(var L=0;L<k.length;L++)if(K(k[L],Q))return L;return-1}function R(k,Q,K,L,j){for(var ae=j==="BigNumber"?u(1e3):1e3,re,fe=0;re=M(Q,K,j),re=v(k,re),!y(H(re),ae);)if(++fe>=5)return null;for(fe=0;;){var he=v(k,re);if(N(H(F(re,[he])),L))break;if(++fe>=10)return null;re=$(he)}return re}function M(k,Q,K){var L=K==="BigNumber",j=K==="Complex",ae=Array(k).fill(0).map(re=>2*Math.random()-1);return L&&(ae=ae.map(re=>u(re))),j&&(ae=ae.map(re=>g(re))),ae=F(ae,Q),$(ae,K)}function F(k,Q){for(var K of Q)k=t(k,n(o(w(K,k),w(K,K)),K));return k}function H(k){return l(f(w(k,k)))}function $(k,Q){var K=Q==="BigNumber",L=Q==="Complex",j=K?u(1):L?g(1):1;return n(o(j,H(k)),k)}return x}function E4(r){var{config:e,addScalar:t,subtract:a,abs:n,atan:i,cos:o,sin:f,multiplyScalar:l,inv:u,bignumber:s,multiply:c,add:m}=r;function v(D,T){var B=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.epsilon,I=arguments.length>3?arguments[3]:void 0;if(I==="number")return h(D,B);if(I==="BigNumber")return p(D,B);throw TypeError("Unsupported data type: "+I)}function h(D,T){for(var B=D.length,I=Math.abs(T/B),P,R=new Array(B),M=0;M<B;M++)R[M]=S(B,0),R[M][M]=1;for(var F=b(D);Math.abs(F[1])>=Math.abs(I);){var H=F[0][0],$=F[0][1];P=g(D[H][H],D[$][$],D[H][$]),D=x(D,P,H,$),R=N(R,P,H,$),F=b(D)}for(var k=S(B,0),Q=0;Q<B;Q++)k[Q]=D[Q][Q];return A(Ge(k),Ge(R))}function p(D,T){for(var B=D.length,I=n(T/B),P,R=new Array(B),M=0;M<B;M++)R[M]=S(B,0),R[M][M]=1;for(var F=E(D);n(F[1])>=n(I);){var H=F[0][0],$=F[0][1];P=y(D[H][H],D[$][$],D[H][$]),D=w(D,P,H,$),R=d(R,P,H,$),F=E(D)}for(var k=S(B,0),Q=0;Q<B;Q++)k[Q]=D[Q][Q];return A(Ge(k),Ge(R))}function g(D,T,B){var I=T-D;return Math.abs(I)<=e.epsilon?Math.PI/4:.5*Math.atan(2*B/(T-D))}function y(D,T,B){var I=a(T,D);return n(I)<=e.epsilon?s(-1).acos().div(4):l(.5,i(c(2,B,u(I))))}function N(D,T,B,I){for(var P=D.length,R=Math.cos(T),M=Math.sin(T),F=S(P,0),H=S(P,0),$=0;$<P;$++)F[$]=R*D[$][B]-M*D[$][I],H[$]=M*D[$][B]+R*D[$][I];for(var k=0;k<P;k++)D[k][B]=F[k],D[k][I]=H[k];return D}function d(D,T,B,I){for(var P=D.length,R=o(T),M=f(T),F=S(P,s(0)),H=S(P,s(0)),$=0;$<P;$++)F[$]=a(l(R,D[$][B]),l(M,D[$][I])),H[$]=t(l(M,D[$][B]),l(R,D[$][I]));for(var k=0;k<P;k++)D[k][B]=F[k],D[k][I]=H[k];return D}function w(D,T,B,I){for(var P=D.length,R=s(o(T)),M=s(f(T)),F=l(R,R),H=l(M,M),$=S(P,s(0)),k=S(P,s(0)),Q=c(s(2),R,M,D[B][I]),K=t(a(l(F,D[B][B]),Q),l(H,D[I][I])),L=m(l(H,D[B][B]),Q,l(F,D[I][I])),j=0;j<P;j++)$[j]=a(l(R,D[B][j]),l(M,D[I][j])),k[j]=t(l(M,D[B][j]),l(R,D[I][j]));D[B][B]=K,D[I][I]=L,D[B][I]=s(0),D[I][B]=s(0);for(var ae=0;ae<P;ae++)ae!==B&&ae!==I&&(D[B][ae]=$[ae],D[ae][B]=$[ae],D[I][ae]=k[ae],D[ae][I]=k[ae]);return D}function x(D,T,B,I){for(var P=D.length,R=Math.cos(T),M=Math.sin(T),F=R*R,H=M*M,$=S(P,0),k=S(P,0),Q=F*D[B][B]-2*R*M*D[B][I]+H*D[I][I],K=H*D[B][B]+2*R*M*D[B][I]+F*D[I][I],L=0;L<P;L++)$[L]=R*D[B][L]-M*D[I][L],k[L]=M*D[B][L]+R*D[I][L];D[B][B]=Q,D[I][I]=K,D[B][I]=0,D[I][B]=0;for(var j=0;j<P;j++)j!==B&&j!==I&&(D[B][j]=$[j],D[j][B]=$[j],D[I][j]=k[j],D[j][I]=k[j]);return D}function b(D){for(var T=D.length,B=0,I=[0,1],P=0;P<T;P++)for(var R=P+1;R<T;R++)Math.abs(B)<Math.abs(D[P][R])&&(B=Math.abs(D[P][R]),I=[P,R]);return[I,B]}function E(D){for(var T=D.length,B=0,I=[0,1],P=0;P<T;P++)for(var R=P+1;R<T;R++)n(B)<n(D[P][R])&&(B=n(D[P][R]),I=[P,R]);return[I,B]}function A(D,T){for(var B=D.length,I=Array(B),P=Array(B),R=0;R<B;R++)P[R]=Array(B);for(var M=0;M<B;M++){for(var F=0,H=D[0],$=0;$<D.length;$++)n(D[$])<n(H)&&(F=$,H=D[F]);I[M]=D.splice(F,1)[0];for(var k=0;k<B;k++)P[k][M]=T[k][F],T[k].splice(F,1)}return{values:I,vectors:P}}function S(D,T){for(var B=new Array(D),I=0;I<D;I++)B[I]=T;return B}return v}var S4="eigs",C4=["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","divideScalar","inv","bignumber","multiply","add","larger","column","flatten","number","complex","sqrt","diag","qr","usolve","usolveAll","im","re","smaller","matrixFromColumns","dot"],M4=q(S4,C4,r=>{var{config:e,typed:t,matrix:a,addScalar:n,subtract:i,equal:o,abs:f,atan:l,cos:u,sin:s,multiplyScalar:c,divideScalar:m,inv:v,bignumber:h,multiply:p,add:g,larger:y,column:N,flatten:d,number:w,complex:x,sqrt:b,diag:E,qr:A,usolve:S,usolveAll:D,im:T,re:B,smaller:I,matrixFromColumns:P,dot:R}=r,M=E4({config:e,addScalar:n,subtract:i,column:N,flatten:d,equal:o,abs:f,atan:l,cos:u,sin:s,multiplyScalar:c,inv:v,bignumber:h,complex:x,multiply:p,add:g}),F=A4({config:e,addScalar:n,subtract:i,multiply:p,multiplyScalar:c,flatten:d,divideScalar:m,sqrt:b,abs:f,bignumber:h,diag:E,qr:A,inv:v,usolve:S,usolveAll:D,equal:o,complex:x,larger:y,smaller:I,matrixFromColumns:P,dot:R});return t("eigs",{Array:function(j){var ae=a(j);return H(ae)},"Array, number|BigNumber":function(j,ae){var re=a(j);return H(re,ae)},Matrix:function(j){var{values:ae,vectors:re}=H(j);return{values:a(ae),vectors:a(re)}},"Matrix, number|BigNumber":function(j,ae){var{values:re,vectors:fe}=H(j,ae);return{values:a(re),vectors:a(fe)}}});function H(L,j){j===void 0&&(j=e.epsilon);var ae=L.size();if(ae.length!==2||ae[0]!==ae[1])throw new RangeError("Matrix must be square (size: "+Ye(ae)+")");var re=L.toArray(),fe=ae[0];if(k(re,fe,j)&&(Q(re,fe),$(re,fe,j))){var he=K(L,re,fe);return M(re,fe,j,he)}var ce=K(L,re,fe);return F(re,fe,j,ce)}function $(L,j,ae){for(var re=0;re<j;re++)for(var fe=re;fe<j;fe++)if(y(h(f(i(L[re][fe],L[fe][re]))),ae))return!1;return!0}function k(L,j,ae){for(var re=0;re<j;re++)for(var fe=0;fe<j;fe++)if(y(h(f(T(L[re][fe]))),ae))return!1;return!0}function Q(L,j){for(var ae=0;ae<j;ae++)for(var re=0;re<j;re++)L[ae][re]=B(L[ae][re])}function K(L,j,ae){var re=L.datatype();if(re==="number"||re==="BigNumber"||re==="Complex")return re;for(var fe=!1,he=!1,ce=!1,ie=0;ie<ae;ie++)for(var Ae=0;Ae<ae;Ae++){var Oe=j[ie][Ae];if(tr(Oe)||za(Oe))fe=!0;else if(rr(Oe))he=!0;else if(kt(Oe))ce=!0;else throw TypeError("Unsupported type in Matrix: "+br(Oe))}if(he&&ce&&console.warn("Complex BigNumbers not supported, this operation will lose precission."),ce){for(var Ce=0;Ce<ae;Ce++)for(var $e=0;$e<ae;$e++)j[Ce][$e]=x(j[Ce][$e]);return"Complex"}if(he){for(var V=0;V<ae;V++)for(var X=0;X<ae;X++)j[V][X]=h(j[V][X]);return"BigNumber"}if(fe){for(var oe=0;oe<ae;oe++)for(var G=0;G<ae;G++)j[oe][G]=w(j[oe][G]);return"number"}else throw TypeError("Matrix contains unsupported types only.")}}),Ap="expm",F4=["typed","abs","add","identity","inv","multiply"],T4=q(Ap,F4,r=>{var{typed:e,abs:t,add:a,identity:n,inv:i,multiply:o}=r;return e(Ap,{Matrix:function(c){var m=c.size();if(m.length!==2||m[0]!==m[1])throw new RangeError("Matrix must be square (size: "+Ye(m)+")");for(var v=m[0],h=1e-15,p=f(c),g=l(p,h),y=g.q,N=g.j,d=o(c,Math.pow(2,-N)),w=n(v),x=n(v),b=1,E=d,A=-1,S=1;S<=y;S++)S>1&&(E=o(E,d),A=-A),b=b*(y-S+1)/((2*y-S+1)*S),w=a(w,o(b,E)),x=a(x,o(b*A,E));for(var D=o(i(x),w),T=0;T<N;T++)D=o(D,D);return En(c)?c.createSparseMatrix(D):D}});function f(s){for(var c=s.size()[0],m=0,v=0;v<c;v++){for(var h=0,p=0;p<c;p++)h+=t(s.get([v,p]));m=Math.max(h,m)}return m}function l(s,c){for(var m=30,v=0;v<m;v++)for(var h=0;h<=v;h++){var p=v-h;if(u(s,h,p)<c)return{q:h,j:p}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}function u(s,c,m){for(var v=1,h=2;h<=c;h++)v*=h;for(var p=v,g=c+1;g<=2*c;g++)p*=g;var y=p*(2*c+1);return 8*Math.pow(s/Math.pow(2,m),2*c)*v*v/(p*y)}}),Ep="sqrtm",B4=["typed","abs","add","multiply","map","sqrt","subtract","inv","size","max","identity"],$4=q(Ep,B4,r=>{var{typed:e,abs:t,add:a,multiply:n,map:i,sqrt:o,subtract:f,inv:l,size:u,max:s,identity:c}=r,m=1e3,v=1e-6;function h(p){var g,y=0,N=p,d=c(u(p));do{var w=N;if(N=n(.5,a(w,l(d))),d=n(.5,a(d,l(w))),g=s(t(f(N,w))),g>v&&++y>m)throw new Error("computing square root of matrix: iterative method could not converge")}while(g>v);return N}return e(Ep,{"Array | Matrix":function(g){var y=Ve(g)?g.size():er(g);switch(y.length){case 1:if(y[0]===1)return i(g,o);throw new RangeError("Matrix must be square (size: "+Ye(y)+")");case 2:{var N=y[0],d=y[1];if(N===d)return h(g);throw new RangeError("Matrix must be square (size: "+Ye(y)+")")}default:throw new RangeError("Matrix must be at most two dimensional (size: "+Ye(y)+")")}}})}),Sp="sylvester",O4=["typed","schur","matrixFromColumns","matrix","multiply","range","concat","transpose","index","subset","add","subtract","identity","lusolve","abs"],I4=q(Sp,O4,r=>{var{typed:e,schur:t,matrixFromColumns:a,matrix:n,multiply:i,range:o,concat:f,transpose:l,index:u,subset:s,add:c,subtract:m,identity:v,lusolve:h,abs:p}=r;return e(Sp,{"Matrix, Matrix, Matrix":g,"Array, Matrix, Matrix":function(N,d,w){return g(n(N),d,w)},"Array, Array, Matrix":function(N,d,w){return g(n(N),n(d),w)},"Array, Matrix, Array":function(N,d,w){return g(n(N),d,n(w))},"Matrix, Array, Matrix":function(N,d,w){return g(N,n(d),w)},"Matrix, Array, Array":function(N,d,w){return g(N,n(d),n(w))},"Matrix, Matrix, Array":function(N,d,w){return g(N,d,n(w))},"Array, Array, Array":function(N,d,w){return g(n(N),n(d),n(w)).toArray()}});function g(y,N,d){for(var w=N.size()[0],x=y.size()[0],b=t(y),E=b.T,A=b.U,S=t(i(-1,N)),D=S.T,T=S.U,B=i(i(l(A),d),T),I=o(0,x),P=[],R=(Oe,Ce)=>f(Oe,Ce,1),M=(Oe,Ce)=>f(Oe,Ce,0),F=0;F<w;F++)if(F<w-1&&p(s(D,u(F+1,F)))>1e-5){for(var H=M(s(B,u(I,F)),s(B,u(I,F+1))),$=0;$<F;$++)H=c(H,M(i(P[$],s(D,u($,F))),i(P[$],s(D,u($,F+1)))));var k=i(v(x),i(-1,s(D,u(F,F)))),Q=i(v(x),i(-1,s(D,u(F+1,F)))),K=i(v(x),i(-1,s(D,u(F,F+1)))),L=i(v(x),i(-1,s(D,u(F+1,F+1)))),j=M(R(c(E,k),Q),R(K,c(E,L))),ae=h(j,H);P[F]=ae.subset(u(o(0,x),0)),P[F+1]=ae.subset(u(o(x,2*x),0)),F++}else{for(var re=s(B,u(I,F)),fe=0;fe<F;fe++)re=c(re,i(P[fe],s(D,u(fe,F))));var he=s(D,u(F,F)),ce=m(E,i(he,v(x)));P[F]=h(ce,re)}var ie=n(a(...P)),Ae=i(A,i(ie,l(T)));return Ae}}),Cp="schur",R4=["typed","matrix","identity","multiply","qr","norm","subtract"],_4=q(Cp,R4,r=>{var{typed:e,matrix:t,identity:a,multiply:n,qr:i,norm:o,subtract:f}=r;return e(Cp,{Array:function(s){var c=l(t(s));return{U:c.U.valueOf(),T:c.T.valueOf()}},Matrix:function(s){return l(s)}});function l(u){var s=u.size()[0],c=u,m=a(s),v=0,h;do{h=c;var p=i(c),g=p.Q,y=p.R;if(c=n(y,g),m=n(m,g),v++>100)break}while(o(f(c,h))>1e-4);return{U:m,T:c}}}),Mp="lyap",q4=["typed","matrix","sylvester","multiply","transpose"],z4=q(Mp,q4,r=>{var{typed:e,matrix:t,sylvester:a,multiply:n,transpose:i}=r;return e(Mp,{"Matrix, Matrix":function(f,l){return a(f,i(f),n(-1,l))},"Array, Matrix":function(f,l){return a(t(f),i(t(f)),n(-1,l))},"Matrix, Array":function(f,l){return a(f,i(t(f)),t(n(-1,l)))},"Array, Array":function(f,l){return a(t(f),i(t(f)),t(n(-1,l))).toArray()}})}),P4="divide",U4=["typed","matrix","multiply","equalScalar","divideScalar","inv"],L4=q(P4,U4,r=>{var{typed:e,matrix:t,multiply:a,equalScalar:n,divideScalar:i,inv:o}=r,f=Lr({typed:e,equalScalar:n}),l=xt({typed:e});return e("divide",ll({"Array | Matrix, Array | Matrix":function(s,c){return a(s,o(c))},"DenseMatrix, any":function(s,c){return l(s,c,i,!1)},"SparseMatrix, any":function(s,c){return f(s,c,i,!1)},"Array, any":function(s,c){return l(t(s),c,i,!1).valueOf()},"any, Array | Matrix":function(s,c){return a(s,o(c))}},i.signatures))}),Fp="distance",k4=["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],V4=q(Fp,k4,r=>{var{typed:e,addScalar:t,subtract:a,multiplyScalar:n,divideScalar:i,unaryMinus:o,sqrt:f,abs:l}=r;return e(Fp,{"Array, Array, Array":function(x,b,E){if(x.length===2&&b.length===2&&E.length===2){if(!s(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!s(b))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!s(E))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var A=i(a(E[1],E[0]),a(b[1],b[0])),S=n(n(A,A),b[0]),D=o(n(A,b[0])),T=x[1];return g(x[0],x[1],S,D,T)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(x,b,E){if(Object.keys(x).length===2&&Object.keys(b).length===2&&Object.keys(E).length===2){if(!s(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!s(b))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!s(E))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"lineOnePtX"in b&&"lineOnePtY"in b&&"lineTwoPtX"in E&&"lineTwoPtY"in E){var A=i(a(E.lineTwoPtY,E.lineTwoPtX),a(b.lineOnePtY,b.lineOnePtX)),S=n(n(A,A),b.lineOnePtX),D=o(n(A,b.lineOnePtX)),T=x.pointX;return g(x.pointX,x.pointY,S,D,T)}else throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(x,b){if(x.length===2&&b.length===3){if(!s(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!c(b))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return g(x[0],x[1],b[0],b[1],b[2])}else if(x.length===3&&b.length===6){if(!c(x))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!v(b))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return y(x[0],x[1],x[2],b[0],b[1],b[2],b[3],b[4],b[5])}else if(x.length===b.length&&x.length>0){if(!m(x))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!m(b))throw new TypeError("All values of an array should be numbers or BigNumbers");return N(x,b)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(x,b){if(Object.keys(x).length===2&&Object.keys(b).length===3){if(!s(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!c(b))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"xCoeffLine"in b&&"yCoeffLine"in b&&"constant"in b)return g(x.pointX,x.pointY,b.xCoeffLine,b.yCoeffLine,b.constant);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===3&&Object.keys(b).length===6){if(!c(x))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!v(b))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"x0"in b&&"y0"in b&&"z0"in b&&"a"in b&&"b"in b&&"c"in b)return y(x.pointX,x.pointY,x.pointZ,b.x0,b.y0,b.z0,b.a,b.b,b.c);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===2&&Object.keys(b).length===2){if(!s(x))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!s(b))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in x&&"pointOneY"in x&&"pointTwoX"in b&&"pointTwoY"in b)return N([x.pointOneX,x.pointOneY],[b.pointTwoX,b.pointTwoY]);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===3&&Object.keys(b).length===3){if(!c(x))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!c(b))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in x&&"pointOneY"in x&&"pointOneZ"in x&&"pointTwoX"in b&&"pointTwoY"in b&&"pointTwoZ"in b)return N([x.pointOneX,x.pointOneY,x.pointOneZ],[b.pointTwoX,b.pointTwoY,b.pointTwoZ]);throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},Array:function(x){if(!p(x))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return d(x)}});function u(w){return typeof w=="number"||rr(w)}function s(w){return w.constructor!==Array&&(w=h(w)),u(w[0])&&u(w[1])}function c(w){return w.constructor!==Array&&(w=h(w)),u(w[0])&&u(w[1])&&u(w[2])}function m(w){return Array.isArray(w)||(w=h(w)),w.every(u)}function v(w){return w.constructor!==Array&&(w=h(w)),u(w[0])&&u(w[1])&&u(w[2])&&u(w[3])&&u(w[4])&&u(w[5])}function h(w){for(var x=Object.keys(w),b=[],E=0;E<x.length;E++)b.push(w[x[E]]);return b}function p(w){if(w[0].length===2&&u(w[0][0])&&u(w[0][1])){if(w.some(x=>x.length!==2||!u(x[0])||!u(x[1])))return!1}else if(w[0].length===3&&u(w[0][0])&&u(w[0][1])&&u(w[0][2])){if(w.some(x=>x.length!==3||!u(x[0])||!u(x[1])||!u(x[2])))return!1}else return!1;return!0}function g(w,x,b,E,A){var S=l(t(t(n(b,w),n(E,x)),A)),D=f(t(n(b,b),n(E,E)));return i(S,D)}function y(w,x,b,E,A,S,D,T,B){var I=[a(n(a(A,x),B),n(a(S,b),T)),a(n(a(S,b),D),n(a(E,w),B)),a(n(a(E,w),T),n(a(A,x),D))];I=f(t(t(n(I[0],I[0]),n(I[1],I[1])),n(I[2],I[2])));var P=f(t(t(n(D,D),n(T,T)),n(B,B)));return i(I,P)}function N(w,x){for(var b=w.length,E=0,A=0,S=0;S<b;S++)A=a(w[S],x[S]),E=t(n(A,A),E);return f(E)}function d(w){for(var x=[],b=[],E=[],A=0;A<w.length-1;A++)for(var S=A+1;S<w.length;S++)w[0].length===2?(b=[w[A][0],w[A][1]],E=[w[S][0],w[S][1]]):w[0].length===3&&(b=[w[A][0],w[A][1],w[A][2]],E=[w[S][0],w[S][1],w[S][2]]),x.push(N(b,E));return x}}),G4="intersect",H4=["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],Z4=q(G4,H4,r=>{var{typed:e,config:t,abs:a,add:n,addScalar:i,matrix:o,multiply:f,multiplyScalar:l,divideScalar:u,subtract:s,smaller:c,equalScalar:m,flatten:v,isZero:h,isNumeric:p}=r;return e("intersect",{"Array, Array, Array":g,"Array, Array, Array, Array":y,"Matrix, Matrix, Matrix":function(T,B,I){var P=g(T.valueOf(),B.valueOf(),I.valueOf());return P===null?null:o(P)},"Matrix, Matrix, Matrix, Matrix":function(T,B,I,P){var R=y(T.valueOf(),B.valueOf(),I.valueOf(),P.valueOf());return R===null?null:o(R)}});function g(D,T,B){if(D=N(D),T=N(T),B=N(B),!w(D))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!w(T))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!x(B))throw new TypeError("Array with 4 numbers expected as third argument");return S(D[0],D[1],D[2],T[0],T[1],T[2],B[0],B[1],B[2],B[3])}function y(D,T,B,I){if(D=N(D),T=N(T),B=N(B),I=N(I),D.length===2){if(!d(D))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!d(T))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!d(B))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!d(I))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return b(D,T,B,I)}else if(D.length===3){if(!w(D))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!w(T))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!w(B))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!w(I))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return A(D[0],D[1],D[2],T[0],T[1],T[2],B[0],B[1],B[2],I[0],I[1],I[2])}else throw new TypeError("Arrays with two or thee dimensional points expected")}function N(D){return D.length===1?D[0]:D.length>1&&Array.isArray(D[0])&&D.every(T=>Array.isArray(T)&&T.length===1)?v(D):D}function d(D){return D.length===2&&p(D[0])&&p(D[1])}function w(D){return D.length===3&&p(D[0])&&p(D[1])&&p(D[2])}function x(D){return D.length===4&&p(D[0])&&p(D[1])&&p(D[2])&&p(D[3])}function b(D,T,B,I){var P=D,R=B,M=s(P,T),F=s(R,I),H=s(l(M[0],F[1]),l(F[0],M[1]));if(h(H)||c(a(H),t.epsilon))return null;var $=l(F[0],P[1]),k=l(F[1],P[0]),Q=l(F[0],R[1]),K=l(F[1],R[0]),L=u(i(s(s($,k),Q),K),H);return n(f(M,L),P)}function E(D,T,B,I,P,R,M,F,H,$,k,Q){var K=l(s(D,T),s(B,I)),L=l(s(P,R),s(M,F)),j=l(s(H,$),s(k,Q));return i(i(K,L),j)}function A(D,T,B,I,P,R,M,F,H,$,k,Q){var K=E(D,M,$,M,T,F,k,F,B,H,Q,H),L=E($,M,I,D,k,F,P,T,Q,H,R,B),j=E(D,M,I,D,T,F,P,T,B,H,R,B),ae=E($,M,$,M,k,F,k,F,Q,H,Q,H),re=E(I,D,I,D,P,T,P,T,R,B,R,B),fe=s(l(K,L),l(j,ae)),he=s(l(re,ae),l(L,L));if(h(he))return null;var ce=u(fe,he),ie=u(i(K,l(ce,L)),ae),Ae=i(D,l(ce,s(I,D))),Oe=i(T,l(ce,s(P,T))),Ce=i(B,l(ce,s(R,B))),$e=i(M,l(ie,s($,M))),V=i(F,l(ie,s(k,F))),X=i(H,l(ie,s(Q,H)));return m(Ae,$e)&&m(Oe,V)&&m(Ce,X)?[Ae,Oe,Ce]:null}function S(D,T,B,I,P,R,M,F,H,$){var k=l(D,M),Q=l(I,M),K=l(T,F),L=l(P,F),j=l(B,H),ae=l(R,H),re=s(s(s($,k),K),j),fe=s(s(s(i(i(Q,L),ae),k),K),j),he=u(re,fe),ce=i(D,l(he,s(I,D))),ie=i(T,l(he,s(P,T))),Ae=i(B,l(he,s(R,B)));return[ce,ie,Ae]}}),Tp="sum",J4=["typed","config","add","numeric"],Bp=q(Tp,J4,r=>{var{typed:e,config:t,add:a,numeric:n}=r;return e(Tp,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":o,"...":function(l){if(aa(l))throw new TypeError("Scalar values expected in function sum");return i(l)}});function i(f){var l;return Xt(f,function(u){try{l=l===void 0?u:a(l,u)}catch(s){throw Qr(s,"sum",u)}}),l===void 0&&(l=n(0,t.number)),typeof l=="string"&&(l=n(l,t.number)),l}function o(f,l){try{var u=Si(f,l,a);return u}catch(s){throw Qr(s,"sum")}}}),io="cumsum",X4=["typed","add","unaryPlus"],$p=q(io,X4,r=>{var{typed:e,add:t,unaryPlus:a}=r;return e(io,{Array:n,Matrix:function(u){return u.create(n(u.valueOf()))},"Array, number | BigNumber":o,"Matrix, number | BigNumber":function(u,s){return u.create(o(u.valueOf(),s))},"...":function(u){if(aa(u))throw new TypeError("All values expected to be scalar in function cumsum");return n(u)}});function n(l){try{return i(l)}catch(u){throw Qr(u,io)}}function i(l){if(l.length===0)return[];for(var u=[a(l[0])],s=1;s<l.length;++s)u.push(t(u[s-1],l[s]));return u}function o(l,u){var s=er(l);if(u<0||u>=s.length)throw new dt(u,s.length);try{return f(l,u)}catch(c){throw Qr(c,io)}}function f(l,u){var s,c,m;if(u<=0){var v=l[0][0];if(Array.isArray(v)){for(m=Wl(l),c=[],s=0;s<m.length;s++)c[s]=f(m[s],u-1);return c}else return i(l)}else{for(c=[],s=0;s<l.length;s++)c[s]=f(l[s],u-1);return c}}}),Op="mean",W4=["typed","add","divide"],Ip=q(Op,W4,r=>{var{typed:e,add:t,divide:a}=r;return e(Op,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":n,"...":function(f){if(aa(f))throw new TypeError("Scalar values expected in function mean");return i(f)}});function n(o,f){try{var l=Si(o,f,t),u=Array.isArray(o)?er(o):o.size();return a(l,u[f])}catch(s){throw Qr(s,"mean")}}function i(o){var f,l=0;if(Xt(o,function(u){try{f=f===void 0?u:t(f,u),l++}catch(s){throw Qr(s,"mean",u)}}),l===0)throw new Error("Cannot calculate the mean of an empty array");return a(f,l)}}),Rp="median",Y4=["typed","add","divide","compare","partitionSelect"],Q4=q(Rp,Y4,r=>{var{typed:e,add:t,divide:a,compare:n,partitionSelect:i}=r;function o(u){try{u=or(u.valueOf());var s=u.length;if(s===0)throw new Error("Cannot calculate median of an empty array");if(s%2===0){for(var c=s/2-1,m=i(u,c+1),v=u[c],h=0;h<c;++h)n(u[h],v)>0&&(v=u[h]);return l(v,m)}else{var p=i(u,(s-1)/2);return f(p)}}catch(g){throw Qr(g,"median")}}var f=e({"number | BigNumber | Complex | Unit":function(s){return s}}),l=e({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(s,c){return a(t(s,c),2)}});return e(Rp,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(s,c){throw new Error("median(A, dim) is not yet supported")},"...":function(s){if(aa(s))throw new TypeError("Scalar values expected in function median");return o(s)}})}),_p="mad",K4=["typed","abs","map","median","subtract"],j4=q(_p,K4,r=>{var{typed:e,abs:t,map:a,median:n,subtract:i}=r;return e(_p,{"Array | Matrix":o,"...":function(l){return o(l)}});function o(f){if(f=or(f.valueOf()),f.length===0)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var l=n(f);return n(a(f,function(u){return t(i(u,l))}))}catch(u){throw u instanceof TypeError&&u.message.indexOf("median")!==-1?new TypeError(u.message.replace("median","mad")):Qr(u,"mad")}}}),As="unbiased",qp="variance",eT=["typed","add","subtract","multiply","divide","apply","isNaN"],zp=q(qp,eT,r=>{var{typed:e,add:t,subtract:a,multiply:n,divide:i,apply:o,isNaN:f}=r;return e(qp,{"Array | Matrix":function(c){return l(c,As)},"Array | Matrix, string":l,"Array | Matrix, number | BigNumber":function(c,m){return u(c,m,As)},"Array | Matrix, number | BigNumber, string":u,"...":function(c){return l(c,As)}});function l(s,c){var m,v=0;if(s.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Xt(s,function(g){try{m=m===void 0?g:t(m,g),v++}catch(y){throw Qr(y,"variance",g)}}),v===0)throw new Error("Cannot calculate variance of an empty array");var h=i(m,v);if(m=void 0,Xt(s,function(g){var y=a(g,h);m=m===void 0?n(y,y):t(m,n(y,y))}),f(m))return m;switch(c){case"uncorrected":return i(m,v);case"biased":return i(m,v+1);case"unbiased":{var p=rr(m)?m.mul(0):0;return v===1?p:i(m,v-1)}default:throw new Error('Unknown normalization "'+c+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function u(s,c,m){try{if(s.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return o(s,c,v=>l(v,m))}catch(v){throw Qr(v,"variance")}}}),rT="quantileSeq",tT=["typed","add","multiply","partitionSelect","compare"],nT=q(rT,tT,r=>{var{typed:e,add:t,multiply:a,partitionSelect:n,compare:i}=r;function o(u,s,c){var m,v,h;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(Ft(u)){if(c=c||!1,typeof c=="boolean"){if(v=u.valueOf(),tr(s)){if(s<0)throw new Error("N/prob must be non-negative");if(s<=1)return f(v,s,c);if(s>1){if(!qe(s))throw new Error("N must be a positive integer");var p=s+1;m=new Array(s);for(var g=0;g<s;)m[g]=f(v,++g/p,c);return m}}if(rr(s)){var y=s.constructor;if(s.isNegative())throw new Error("N/prob must be non-negative");if(h=new y(1),s.lte(h))return new y(f(v,s,c));if(s.gt(h)){if(!s.isInteger())throw new Error("N must be a positive integer");var N=s.toNumber();if(N>4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var d=new y(N+1);m=new Array(N);for(var w=0;w<N;)m[w]=new y(f(v,new y(++w).div(d),c));return m}}if(Ft(s)){var x=s.valueOf();m=new Array(x.length);for(var b=0;b<m.length;++b){var E=x[b];if(tr(E)){if(E<0||E>1)throw new Error("Probability must be between 0 and 1, inclusive")}else if(rr(E)){if(h=new E.constructor(1),E.isNegative()||E.gt(h))throw new Error("Probability must be between 0 and 1, inclusive")}else throw new TypeError("Unexpected type of argument in function quantileSeq");m[b]=f(v,E,c)}return m}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}function f(u,s,c){var m=or(u),v=m.length;if(v===0)throw new Error("Cannot calculate quantile of an empty sequence");if(tr(s)){var h=s*(v-1),p=h%1;if(p===0){var g=c?m[h]:n(m,h);return l(g),g}var y=Math.floor(h),N,d;if(c)N=m[y],d=m[y+1];else{d=n(m,y+1),N=m[y];for(var w=0;w<y;++w)i(m[w],N)>0&&(N=m[w])}return l(N),l(d),t(a(N,1-p),a(d,p))}var x=s.times(v-1);if(x.isInteger()){x=x.toNumber();var b=c?m[x]:n(m,x);return l(b),b}var E=x.floor(),A=x.minus(E),S=E.toNumber(),D,T;if(c)D=m[S],T=m[S+1];else{T=n(m,S+1),D=m[S];for(var B=0;B<S;++B)i(m[B],D)>0&&(D=m[B])}l(D),l(T);var I=new A.constructor(1);return t(a(D,I.minus(A)),a(T,A))}var l=e({"number | BigNumber | Unit":function(s){return s}});return o}),Pp="std",aT=["typed","map","sqrt","variance"],Up=q(Pp,aT,r=>{var{typed:e,map:t,sqrt:a,variance:n}=r;return e(Pp,{"Array | Matrix":i,"Array | Matrix, string":i,"Array | Matrix, number | BigNumber":i,"Array | Matrix, number | BigNumber, string":i,"...":function(f){return i(f)}});function i(o,f){if(o.length===0)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{var l=n.apply(null,arguments);return Ft(l)?t(l,a):a(l)}catch(u){throw u instanceof TypeError&&u.message.indexOf(" variance")!==-1?new TypeError(u.message.replace(" variance"," std")):u}}}),Lp="combinations",iT=["typed"],oT=q(Lp,iT,r=>{var{typed:e}=r;return e(Lp,{"number, number":Dc,"BigNumber, BigNumber":function(a,n){var i=a.constructor,o,f,l=a.minus(n),u=new i(1);if(!kp(a)||!kp(n))throw new TypeError("Positive integer value expected in function combinations");if(n.gt(a))throw new TypeError("k must be less than n in function combinations");if(o=u,n.lt(l))for(f=u;f.lte(l);f=f.plus(u))o=o.times(n.plus(f)).dividedBy(f);else for(f=u;f.lte(n);f=f.plus(u))o=o.times(l.plus(f)).dividedBy(f);return o}})});function kp(r){return r.isInteger()&&r.gte(0)}var Vp="combinationsWithRep",sT=["typed"],uT=q(Vp,sT,r=>{var{typed:e}=r;return e(Vp,{"number, number":function(a,n){if(!qe(a)||a<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!qe(n)||n<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(a<1)throw new TypeError("k must be less than or equal to n + k - 1");if(n<a-1){var i=Wt(a,a+n-1);return i/Wt(1,n)}var o=Wt(n+1,a+n-1);return o/Wt(1,a-1)},"BigNumber, BigNumber":function(a,n){var i=a.constructor,o,f,l=new i(1),u=a.minus(l);if(!Gp(a)||!Gp(n))throw new TypeError("Positive integer value expected in function combinationsWithRep");if(a.lt(l))throw new TypeError("k must be less than or equal to n + k - 1 in function combinationsWithRep");if(o=l,n.lt(u))for(f=l;f.lte(u);f=f.plus(l))o=o.times(n.plus(f)).dividedBy(f);else for(f=l;f.lte(n);f=f.plus(l))o=o.times(u.plus(f)).dividedBy(f);return o}})});function Gp(r){return r.isInteger()&&r.gte(0)}var Hp="gamma",lT=["typed","config","multiplyScalar","pow","BigNumber","Complex"],cT=q(Hp,lT,r=>{var{typed:e,config:t,multiplyScalar:a,pow:n,BigNumber:i,Complex:o}=r;function f(u){if(u.im===0)return Mi(u.re);if(u.re<.5){var s=new o(1-u.re,-u.im),c=new o(Math.PI*u.re,Math.PI*u.im);return new o(Math.PI).div(c.sin()).div(f(s))}u=new o(u.re-1,u.im);for(var m=new o(oa[0],0),v=1;v<oa.length;++v){var h=new o(oa[v],0);m=m.add(h.div(u.add(v)))}var p=new o(u.re+Mc+.5,u.im),g=Math.sqrt(2*Math.PI),y=p.pow(u.add(.5)),N=p.neg().exp();return m.mul(g).mul(y).mul(N)}return e(Hp,{number:Mi,Complex:f,BigNumber:function(s){if(s.isInteger())return s.isNegative()||s.isZero()?new i(1/0):l(s.minus(1));if(!s.isFinite())return new i(s.isNegative()?NaN:1/0);throw new Error("Integer BigNumber expected")}});function l(u){if(u<8)return new i([1,1,2,6,24,120,720,5040][u]);var s=t.precision+(Math.log(u.toNumber())|0),c=i.clone({precision:s});if(u%2===1)return u.times(l(new i(u-1)));for(var m=u,v=new c(u),h=u.toNumber();m>2;)m-=2,h+=m,v=v.times(h);return new i(v.toPrecision(i.precision))}}),Zp="lgamma",fT=["Complex","typed"],mT=q(Zp,fT,r=>{var{Complex:e,typed:t}=r,a=7,n=7,i=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return t(Zp,{number:Fi,Complex:o,BigNumber:function(){throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function o(u){var s=6.283185307179586,c=1.1447298858494002,m=.1;if(u.isNaN())return new e(NaN,NaN);if(u.im===0)return new e(Fi(u.re),0);if(u.re>=a||Math.abs(u.im)>=n)return f(u);if(u.re<=m){var v=pg(s,u.im)*Math.floor(.5*u.re+.25),h=u.mul(Math.PI).sin().log(),p=o(new e(1-u.re,-u.im));return new e(c,v).sub(h).sub(p)}else return u.im>=0?l(u):l(u.conjugate()).conjugate()}function f(u){for(var s=u.sub(.5).mul(u.log()).sub(u).add(Fc),c=new e(1,0).div(u),m=c.div(u),v=i[0],h=i[1],p=2*m.re,g=m.re*m.re+m.im*m.im,y=2;y<8;y++){var N=h;h=-g*v+i[y],v=p*v+N}var d=c.mul(m.mul(v).add(h));return s.add(d)}function l(u){var s=0,c=0,m=u;for(u=u.add(1);u.re<=a;){m=m.mul(u);var v=m.im<0?1:0;v!==0&&c===0&&s++,c=v,u=u.add(1)}return f(u).sub(m.log()).sub(new e(0,s*2*Math.PI*1))}}),Jp="factorial",vT=["typed","gamma"],pT=q(Jp,vT,r=>{var{typed:e,gamma:t}=r;return e(Jp,{number:function(n){if(n<0)throw new Error("Value must be non-negative");return t(n+1)},BigNumber:function(n){if(n.isNegative())throw new Error("Value must be non-negative");return t(n.plus(1))},"Array | Matrix":e.referToSelf(a=>n=>je(n,a))})}),Xp="kldivergence",hT=["typed","matrix","divide","sum","multiply","map","dotDivide","log","isNumeric"],dT=q(Xp,hT,r=>{var{typed:e,matrix:t,divide:a,sum:n,multiply:i,map:o,dotDivide:f,log:l,isNumeric:u}=r;return e(Xp,{"Array, Array":function(m,v){return s(t(m),t(v))},"Matrix, Array":function(m,v){return s(m,t(v))},"Array, Matrix":function(m,v){return s(t(m),v)},"Matrix, Matrix":function(m,v){return s(m,v)}});function s(c,m){var v=m.size().length,h=c.size().length;if(v>1)throw new Error("first object must be one dimensional");if(h>1)throw new Error("second object must be one dimensional");if(v!==h)throw new Error("Length of two vectors must be equal");var p=n(c);if(p===0)throw new Error("Sum of elements in first object must be non zero");var g=n(m);if(g===0)throw new Error("Sum of elements in second object must be non zero");var y=a(c,n(c)),N=a(m,n(m)),d=n(i(y,o(f(y,N),w=>l(w))));return u(d)?d:Number.NaN}}),Wp="multinomial",gT=["typed","add","divide","multiply","factorial","isInteger","isPositive"],yT=q(Wp,gT,r=>{var{typed:e,add:t,divide:a,multiply:n,factorial:i,isInteger:o,isPositive:f}=r;return e(Wp,{"Array | Matrix":function(u){var s=0,c=1;return Xt(u,function(m){if(!o(m)||!f(m))throw new TypeError("Positive integer value expected in function multinomial");s=t(s,m),c=n(c,i(m))}),a(i(s),c)}})}),Yp="permutations",bT=["typed","factorial"],xT=q(Yp,bT,r=>{var{typed:e,factorial:t}=r;return e(Yp,{"number | BigNumber":t,"number, number":function(n,i){if(!qe(n)||n<0)throw new TypeError("Positive integer value expected in function permutations");if(!qe(i)||i<0)throw new TypeError("Positive integer value expected in function permutations");if(i>n)throw new TypeError("second argument k must be less than or equal to first argument n");return Wt(n-i+1,n)},"BigNumber, BigNumber":function(n,i){var o,f;if(!Qp(n)||!Qp(i))throw new TypeError("Positive integer value expected in function permutations");if(i.gt(n))throw new TypeError("second argument k must be less than or equal to first argument n");var l=n.mul(0).add(1);for(o=l,f=n.minus(i).plus(1);f.lte(n);f=f.plus(1))o=o.times(f);return o}})});function Qp(r){return r.isInteger()&&r.gte(0)}var Kp={exports:{}};(function(r){(function(e,t,a){function n(l){var u=this,s=f();u.next=function(){var c=2091639*u.s0+u.c*23283064365386963e-26;return u.s0=u.s1,u.s1=u.s2,u.s2=c-(u.c=c|0)},u.c=1,u.s0=s(" "),u.s1=s(" "),u.s2=s(" "),u.s0-=s(l),u.s0<0&&(u.s0+=1),u.s1-=s(l),u.s1<0&&(u.s1+=1),u.s2-=s(l),u.s2<0&&(u.s2+=1),s=null}function i(l,u){return u.c=l.c,u.s0=l.s0,u.s1=l.s1,u.s2=l.s2,u}function o(l,u){var s=new n(l),c=u&&u.state,m=s.next;return m.int32=function(){return s.next()*4294967296|0},m.double=function(){return m()+(m()*2097152|0)*11102230246251565e-32},m.quick=m,c&&(typeof c=="object"&&i(c,s),m.state=function(){return i(s,{})}),m}function f(){var l=4022871197,u=function(s){s=String(s);for(var c=0;c<s.length;c++){l+=s.charCodeAt(c);var m=.02519603282416938*l;l=m>>>0,m-=l,m*=l,l=m>>>0,m-=l,l+=m*4294967296}return(l>>>0)*23283064365386963e-26};return u}t&&t.exports?t.exports=o:a&&a.amd?a(function(){return o}):this.alea=o})(Mn,r,!1)})(Kp);var jp={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this,u="";l.x=0,l.y=0,l.z=0,l.w=0,l.next=function(){var c=l.x^l.x<<11;return l.x=l.y,l.y=l.z,l.z=l.w,l.w^=l.w>>>19^c^c>>>8},f===(f|0)?l.x=f:u+=f;for(var s=0;s<u.length+64;s++)l.x^=u.charCodeAt(s)|0,l.next()}function i(f,l){return l.x=f.x,l.y=f.y,l.z=f.z,l.w=f.w,l}function o(f,l){var u=new n(f),s=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,h=(m+v)/(1<<21);while(h===0);return h},c.int32=u.next,c.quick=c,s&&(typeof s=="object"&&i(s,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=o:a&&a.amd?a(function(){return o}):this.xor128=o})(Mn,r,!1)})(jp);var eh={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this,u="";l.next=function(){var c=l.x^l.x>>>2;return l.x=l.y,l.y=l.z,l.z=l.w,l.w=l.v,(l.d=l.d+362437|0)+(l.v=l.v^l.v<<4^(c^c<<1))|0},l.x=0,l.y=0,l.z=0,l.w=0,l.v=0,f===(f|0)?l.x=f:u+=f;for(var s=0;s<u.length+64;s++)l.x^=u.charCodeAt(s)|0,s==u.length&&(l.d=l.x<<10^l.x>>>4),l.next()}function i(f,l){return l.x=f.x,l.y=f.y,l.z=f.z,l.w=f.w,l.v=f.v,l.d=f.d,l}function o(f,l){var u=new n(f),s=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,h=(m+v)/(1<<21);while(h===0);return h},c.int32=u.next,c.quick=c,s&&(typeof s=="object"&&i(s,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=o:a&&a.amd?a(function(){return o}):this.xorwow=o})(Mn,r,!1)})(eh);var rh={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this;l.next=function(){var s=l.x,c=l.i,m,v;return m=s[c],m^=m>>>7,v=m^m<<24,m=s[c+1&7],v^=m^m>>>10,m=s[c+3&7],v^=m^m>>>3,m=s[c+4&7],v^=m^m<<7,m=s[c+7&7],m=m^m<<13,v^=m^m<<9,s[c]=v,l.i=c+1&7,v};function u(s,c){var m,v=[];if(c===(c|0))v[0]=c;else for(c=""+c,m=0;m<c.length;++m)v[m&7]=v[m&7]<<15^c.charCodeAt(m)+v[m+1&7]<<13;for(;v.length<8;)v.push(0);for(m=0;m<8&&v[m]===0;++m);for(m==8?v[7]=-1:v[m],s.x=v,s.i=0,m=256;m>0;--m)s.next()}u(l,f)}function i(f,l){return l.x=f.x.slice(),l.i=f.i,l}function o(f,l){f==null&&(f=+new Date);var u=new n(f),s=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,h=(m+v)/(1<<21);while(h===0);return h},c.int32=u.next,c.quick=c,s&&(s.x&&i(s,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=o:a&&a.amd?a(function(){return o}):this.xorshift7=o})(Mn,r,!1)})(rh);var th={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this;l.next=function(){var s=l.w,c=l.X,m=l.i,v,h;return l.w=s=s+1640531527|0,h=c[m+34&127],v=c[m=m+1&127],h^=h<<13,v^=v<<17,h^=h>>>15,v^=v>>>12,h=c[m]=h^v,l.i=m,h+(s^s>>>16)|0};function u(s,c){var m,v,h,p,g,y=[],N=128;for(c===(c|0)?(v=c,c=null):(c=c+"\0",v=0,N=Math.max(N,c.length)),h=0,p=-32;p<N;++p)c&&(v^=c.charCodeAt((p+32)%c.length)),p===0&&(g=v),v^=v<<10,v^=v>>>15,v^=v<<4,v^=v>>>13,p>=0&&(g=g+1640531527|0,m=y[p&127]^=v+g,h=m==0?h+1:0);for(h>=128&&(y[(c&&c.length||0)&127]=-1),h=127,p=4*128;p>0;--p)v=y[h+34&127],m=y[h=h+1&127],v^=v<<13,m^=m<<17,v^=v>>>15,m^=m>>>12,y[h]=v^m;s.w=g,s.X=y,s.i=h}u(l,f)}function i(f,l){return l.i=f.i,l.w=f.w,l.X=f.X.slice(),l}function o(f,l){f==null&&(f=+new Date);var u=new n(f),s=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,h=(m+v)/(1<<21);while(h===0);return h},c.int32=u.next,c.quick=c,s&&(s.X&&i(s,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=o:a&&a.amd?a(function(){return o}):this.xor4096=o})(Mn,r,!1)})(th);var nh={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this,u="";l.next=function(){var c=l.b,m=l.c,v=l.d,h=l.a;return c=c<<25^c>>>7^m,m=m-v|0,v=v<<24^v>>>8^h,h=h-c|0,l.b=c=c<<20^c>>>12^m,l.c=m=m-v|0,l.d=v<<16^m>>>16^h,l.a=h-c|0},l.a=0,l.b=0,l.c=-1640531527,l.d=1367130551,f===Math.floor(f)?(l.a=f/4294967296|0,l.b=f|0):u+=f;for(var s=0;s<u.length+20;s++)l.b^=u.charCodeAt(s)|0,l.next()}function i(f,l){return l.a=f.a,l.b=f.b,l.c=f.c,l.d=f.d,l}function o(f,l){var u=new n(f),s=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,h=(m+v)/(1<<21);while(h===0);return h},c.int32=u.next,c.quick=c,s&&(typeof s=="object"&&i(s,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=o:a&&a.amd?a(function(){return o}):this.tychei=o})(Mn,r,!1)})(nh);var ah={exports:{}};const wT=$1(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(r){(function(e,t,a){var n=256,i=6,o=52,f="random",l=a.pow(n,i),u=a.pow(2,o),s=u*2,c=n-1,m;function v(w,x,b){var E=[];x=x==!0?{entropy:!0}:x||{};var A=y(g(x.entropy?[w,d(t)]:w==null?N():w,3),E),S=new h(E),D=function(){for(var T=S.g(i),B=l,I=0;T<u;)T=(T+I)*n,B*=n,I=S.g(1);for(;T>=s;)T/=2,B/=2,I>>>=1;return(T+I)/B};return D.int32=function(){return S.g(4)|0},D.quick=function(){return S.g(4)/4294967296},D.double=D,y(d(S.S),t),(x.pass||b||function(T,B,I,P){return P&&(P.S&&p(P,S),T.state=function(){return p(S,{})}),I?(a[f]=T,B):T})(D,A,"global"in x?x.global:this==a,x.state)}function h(w){var x,b=w.length,E=this,A=0,S=E.i=E.j=0,D=E.S=[];for(b||(w=[b++]);A<n;)D[A]=A++;for(A=0;A<n;A++)D[A]=D[S=c&S+w[A%b]+(x=D[A])],D[S]=x;(E.g=function(T){for(var B,I=0,P=E.i,R=E.j,M=E.S;T--;)B=M[P=c&P+1],I=I*n+M[c&(M[P]=M[R=c&R+B])+(M[R]=B)];return E.i=P,E.j=R,I})(n)}function p(w,x){return x.i=w.i,x.j=w.j,x.S=w.S.slice(),x}function g(w,x){var b=[],E=typeof w,A;if(x&&E=="object")for(A in w)try{b.push(g(w[A],x-1))}catch{}return b.length?b:E=="string"?w:w+"\0"}function y(w,x){for(var b=w+"",E,A=0;A<b.length;)x[c&A]=c&(E^=x[c&A]*19)+b.charCodeAt(A++);return d(x)}function N(){try{var w;return m&&(w=m.randomBytes)?w=w(n):(w=new Uint8Array(n),(e.crypto||e.msCrypto).getRandomValues(w)),d(w)}catch{var x=e.navigator,b=x&&x.plugins;return[+new Date,e,b,e.screen,d(t)]}}function d(w){return String.fromCharCode.apply(0,w)}if(y(a.random(),t),r.exports){r.exports=v;try{m=wT}catch{}}else a["seed"+f]=v})(typeof self<"u"?self:Mn,[],Math)})(ah);var NT=Kp.exports,DT=jp.exports,AT=eh.exports,ET=rh.exports,ST=th.exports,CT=nh.exports,$n=ah.exports;$n.alea=NT,$n.xor128=DT,$n.xorwow=AT,$n.xorshift7=ET,$n.xor4096=ST,$n.tychei=CT;var ih=$n,MT=ih(Date.now());function ma(r){var e;function t(n){e=n===null?MT:ih(String(n))}t(r);function a(){return e()}return a}var oh="pickRandom",FT=["typed","config","?on"],TT=q(oh,FT,r=>{var{typed:e,config:t,on:a}=r,n=ma(t.randomSeed);return a&&a("config",function(o,f){o.randomSeed!==f.randomSeed&&(n=ma(o.randomSeed))}),e(oh,{"Array | Matrix":function(f){return i(f,{})},"Array | Matrix, Object":function(f,l){return i(f,l)},"Array | Matrix, number":function(f,l){return i(f,{number:l})},"Array | Matrix, Array | Matrix":function(f,l){return i(f,{weights:l})},"Array | Matrix, Array | Matrix, number":function(f,l,u){return i(f,{number:u,weights:l})},"Array | Matrix, number, Array | Matrix":function(f,l,u){return i(f,{number:l,weights:u})}});function i(o,f){var{number:l,weights:u,elementWise:s=!0}=f,c=typeof l>"u";c&&(l=1);var m=Ve(o)?o.create:Ve(u)?u.create:null;o=o.valueOf(),u&&(u=u.valueOf()),s===!0&&(o=or(o),u=or(u));var v=0;if(typeof u<"u"){if(u.length!==o.length)throw new Error("Weights must have the same length as possibles");for(var h=0,p=u.length;h<p;h++){if(!tr(u[h])||u[h]<0)throw new Error("Weights must be an array of positive numbers");v+=u[h]}}for(var g=o.length,y=[],N;y.length<l;){if(typeof u>"u")N=o[Math.floor(n()*g)];else for(var d=n()*v,w=0,x=o.length;w<x;w++)if(d-=u[w],d<0){N=o[w];break}y.push(N)}return c?y[0]:m?m(y):y}});function Es(r,e){var t=[];if(r=r.slice(0),r.length>1)for(var a=0,n=r.shift();a<n;a++)t.push(Es(r,e));else for(var i=0,o=r.shift();i<o;i++)t.push(e());return t}var sh="random",BT=["typed","config","?on"],$T=q(sh,BT,r=>{var{typed:e,config:t,on:a}=r,n=ma(t.randomSeed);return a&&a("config",function(f,l){f.randomSeed!==l.randomSeed&&(n=ma(f.randomSeed))}),e(sh,{"":()=>o(0,1),number:f=>o(0,f),"number, number":(f,l)=>o(f,l),"Array | Matrix":f=>i(f,0,1),"Array | Matrix, number":(f,l)=>i(f,0,l),"Array | Matrix, number, number":(f,l,u)=>i(f,l,u)});function i(f,l,u){var s=Es(f.valueOf(),()=>o(l,u));return Ve(f)?f.create(s):s}function o(f,l){return f+n()*(l-f)}}),uh="randomInt",OT=["typed","config","?on"],IT=q(uh,OT,r=>{var{typed:e,config:t,on:a}=r,n=ma(t.randomSeed);return a&&a("config",function(f,l){f.randomSeed!==l.randomSeed&&(n=ma(f.randomSeed))}),e(uh,{"":()=>o(0,1),number:f=>o(0,f),"number, number":(f,l)=>o(f,l),"Array | Matrix":f=>i(f,0,1),"Array | Matrix, number":(f,l)=>i(f,0,l),"Array | Matrix, number, number":(f,l,u)=>i(f,l,u)});function i(f,l,u){var s=Es(f.valueOf(),()=>o(l,u));return Ve(f)?f.create(s):s}function o(f,l){return Math.floor(f+n()*(l-f))}}),lh="stirlingS2",RT=["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],_T=q(lh,RT,r=>{var{typed:e,addScalar:t,subtract:a,multiplyScalar:n,divideScalar:i,pow:o,factorial:f,combinations:l,isNegative:u,isInteger:s,number:c,bignumber:m,larger:v}=r,h=[],p=[];return e(lh,{"number | BigNumber, number | BigNumber":function(y,N){if(!s(y)||u(y)||!s(N)||u(N))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(v(N,y))throw new TypeError("k must be less than or equal to n in function stirlingS2");var d=!(tr(y)&&tr(N)),w=d?p:h,x=d?m:c,b=c(y),E=c(N);if(w[b]&&w[b].length>E)return w[b][E];for(var A=0;A<=b;++A)if(w[A]||(w[A]=[x(A===0?1:0)]),A!==0)for(var S=w[A],D=w[A-1],T=S.length;T<=A&&T<=E;++T)T===A?S[T]=1:S[T]=t(n(x(T),D[T]),D[T-1]);return w[b][E]}})}),ch="bellNumbers",qT=["typed","addScalar","isNegative","isInteger","stirlingS2"],zT=q(ch,qT,r=>{var{typed:e,addScalar:t,isNegative:a,isInteger:n,stirlingS2:i}=r;return e(ch,{"number | BigNumber":function(f){if(!n(f)||a(f))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var l=0,u=0;u<=f;u++)l=t(l,i(f,u));return l}})}),fh="catalan",PT=["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],UT=q(fh,PT,r=>{var{typed:e,addScalar:t,divideScalar:a,multiplyScalar:n,combinations:i,isNegative:o,isInteger:f}=r;return e(fh,{"number | BigNumber":function(u){if(!f(u)||o(u))throw new TypeError("Non-negative integer value expected in function catalan");return a(i(n(u,2),u),t(u,1))}})}),mh="composition",LT=["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],kT=q(mh,LT,r=>{var{typed:e,addScalar:t,combinations:a,isPositive:n,isNegative:i,isInteger:o,larger:f}=r;return e(mh,{"number | BigNumber, number | BigNumber":function(u,s){if(!o(u)||!n(u)||!o(s)||!n(s))throw new TypeError("Positive integer value expected in function composition");if(f(s,u))throw new TypeError("k must be less than or equal to n in function composition");return a(t(u,-1),t(s,-1))}})}),vh="leafCount",VT=["parse","typed"],GT=q(vh,VT,r=>{var{parse:e,typed:t}=r;function a(n){var i=0;return n.forEach(o=>{i+=a(o)}),i||1}return t(vh,{Node:function(i){return a(i)}})});function ph(r){return ir(r)||Br(r)&&r.isUnary()&&ir(r.args[0])}function oo(r){return!!(ir(r)||(nn(r)||Br(r))&&r.args.every(oo)||Gt(r)&&oo(r.content))}function hh(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);e&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,a)}return t}function Ss(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?hh(Object(t),!0).forEach(function(a){zr(r,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):hh(Object(t)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(t,a))})}return r}var HT="simplifyUtil",ZT=["FunctionNode","OperatorNode","SymbolNode"],Cs=q(HT,ZT,r=>{var{FunctionNode:e,OperatorNode:t,SymbolNode:a}=r,n=!0,i=!1,o="defaultF",f={add:{trivial:n,total:n,commutative:n,associative:n},unaryPlus:{trivial:n,total:n,commutative:n,associative:n},subtract:{trivial:i,total:n,commutative:i,associative:i},multiply:{trivial:n,total:n,commutative:n,associative:n},divide:{trivial:i,total:n,commutative:i,associative:i},paren:{trivial:n,total:n,commutative:n,associative:i},defaultF:{trivial:i,total:n,commutative:i,associative:i}},l={divide:{total:i},log:{total:i}},u={subtract:{total:i},abs:{trivial:n},log:{total:n}};function s(d,w){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:f,b=o;if(typeof d=="string"?b=d:Br(d)?b=d.fn.toString():nn(d)?b=d.name:Gt(d)&&(b="paren"),Re(x,b)){var E=x[b];if(Re(E,w))return E[w];if(Re(f,b))return f[b][w]}if(Re(x,o)){var A=x[o];return Re(A,w)?A[w]:f[o][w]}if(Re(f,b)){var S=f[b];if(Re(S,w))return S[w]}return f[o][w]}function c(d){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f;return s(d,"commutative",w)}function m(d){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f;return s(d,"associative",w)}function v(d,w){var x=Ss({},d);for(var b in w)Re(d,b)?x[b]=Ss(Ss({},w[b]),d[b]):x[b]=w[b];return x}function h(d,w){if(!d.args||d.args.length===0)return d;d.args=p(d,w);for(var x=0;x<d.args.length;x++)h(d.args[x],w)}function p(d,w){var x,b=[],E=function A(S){for(var D=0;D<S.args.length;D++){var T=S.args[D];Br(T)&&x===T.op?A(T):b.push(T)}};return m(d,w)?(x=d.op,E(d),b):d.args}function g(d,w){if(!(!d.args||d.args.length===0)){for(var x=N(d),b=d.args.length,E=0;E<b;E++)g(d.args[E],w);if(b>2&&m(d,w)){for(var A=d.args.pop();d.args.length>0;)A=x([d.args.pop(),A]);d.args=A.args}}}function y(d,w){if(!(!d.args||d.args.length===0)){for(var x=N(d),b=d.args.length,E=0;E<b;E++)y(d.args[E],w);if(b>2&&m(d,w)){for(var A=d.args.shift();d.args.length>0;)A=x([A,d.args.shift()]);d.args=A.args}}}function N(d){return Br(d)?function(w){try{return new t(d.op,d.fn,w,d.implicit)}catch(x){return console.error(x),[]}}:function(w){return new e(new a(d.name),w)}}return{createMakeNodeFunction:N,hasProperty:s,isCommutative:c,isAssociative:m,mergeContext:v,flatten:h,allChildren:p,unflattenr:g,unflattenl:y,defaultContext:f,realContext:l,positiveContext:u}}),JT="simplify",XT=["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","resolve","simplifyConstant","simplifyCore","?fraction","?bignumber","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],WT=q(JT,XT,r=>{var{config:e,typed:t,parse:a,add:n,subtract:i,multiply:o,divide:f,pow:l,isZero:u,equal:s,resolve:c,simplifyConstant:m,simplifyCore:v,fraction:h,bignumber:p,mathWithTransform:g,matrix:y,AccessorNode:N,ArrayNode:d,ConstantNode:w,FunctionNode:x,IndexNode:b,ObjectNode:E,OperatorNode:A,ParenthesisNode:S,SymbolNode:D}=r,{hasProperty:T,isCommutative:B,isAssociative:I,mergeContext:P,flatten:R,unflattenr:M,unflattenl:F,createMakeNodeFunction:H,defaultContext:$,realContext:k,positiveContext:Q}=Cs({FunctionNode:x,OperatorNode:A,SymbolNode:D});t.addConversion({from:"Object",to:"Map",convert:ra});var K=t("simplify",{Node:ce,"Node, Map":(G,Y)=>ce(G,!1,Y),"Node, Map, Object":(G,Y,te)=>ce(G,!1,Y,te),"Node, Array":ce,"Node, Array, Map":ce,"Node, Array, Map, Object":ce});t.removeConversion({from:"Object",to:"Map",convert:ra}),K.defaultContext=$,K.realContext=k,K.positiveContext=Q;function L(G){return G.transform(function(Y,te,ye){return Gt(Y)?L(Y.content):Y})}var j={true:!0,false:!0,e:!0,i:!0,Infinity:!0,LN2:!0,LN10:!0,LOG2E:!0,LOG10E:!0,NaN:!0,phi:!0,pi:!0,SQRT1_2:!0,SQRT2:!0,tau:!0};K.rules=[v,{l:"log(e)",r:"1"},{s:"n-n1 -> n+-n1",assuming:{subtract:{total:!0}}},{s:"n-n -> 0",assuming:{subtract:{total:!1}}},{s:"-(cl*v) -> v * (-cl)",assuming:{multiply:{commutative:!0},subtract:{total:!0}}},{s:"-(cl*v) -> (-cl) * v",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{s:"-(v*cl) -> v * (-cl)",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{l:"-(n1/n2)",r:"-n1/n2"},{l:"-v",r:"v * (-1)"},{l:"(n1 + n2)*(-1)",r:"n1*(-1) + n2*(-1)",repeat:!0},{l:"n/n1^n2",r:"n*n1^-n2"},{l:"n/n1",r:"n*n1^-1"},{s:"(n1*n2)^n3 -> n1^n3 * n2^n3",assuming:{multiply:{commutative:!0}}},{s:"(n1*n2)^(-1) -> n2^(-1) * n1^(-1)",assuming:{multiply:{commutative:!1}}},{s:"(n ^ n1) ^ n2 -> n ^ (n1 * n2)",assuming:{divide:{total:!0}}},{l:" vd * ( vd * n1 + n2)",r:"vd^2 * n1 + vd * n2"},{s:" vd * (vd^n4 * n1 + n2) -> vd^(1+n4) * n1 + vd * n2",assuming:{divide:{total:!0}}},{s:"vd^n3 * ( vd * n1 + n2) -> vd^(n3+1) * n1 + vd^n3 * n2",assuming:{divide:{total:!0}}},{s:"vd^n3 * (vd^n4 * n1 + n2) -> vd^(n3+n4) * n1 + vd^n3 * n2",assuming:{divide:{total:!0}}},{l:"n*n",r:"n^2"},{s:"n * n^n1 -> n^(n1+1)",assuming:{divide:{total:!0}}},{s:"n^n1 * n^n2 -> n^(n1+n2)",assuming:{divide:{total:!0}}},m,{s:"n+n -> 2*n",assuming:{add:{total:!0}}},{l:"n+-n",r:"0"},{l:"vd*n + vd",r:"vd*(n+1)"},{l:"n3*n1 + n3*n2",r:"n3*(n1+n2)"},{l:"n3^(-n4)*n1 + n3 * n2",r:"n3^(-n4)*(n1 + n3^(n4+1) *n2)"},{l:"n3^(-n4)*n1 + n3^n5 * n2",r:"n3^(-n4)*(n1 + n3^(n4+n5)*n2)"},{s:"n*vd + vd -> (n+1)*vd",assuming:{multiply:{commutative:!1}}},{s:"vd + n*vd -> (1+n)*vd",assuming:{multiply:{commutative:!1}}},{s:"n1*n3 + n2*n3 -> (n1+n2)*n3",assuming:{multiply:{commutative:!1}}},{s:"n^n1 * n -> n^(n1+1)",assuming:{divide:{total:!0},multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3 -> (n1 + n2*n3^(n4 + 1))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3^n5 -> (n1 + n2*n3^(n4 + n5))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{l:"n*cd + cd",r:"(n+1)*cd"},{s:"cd*n + cd -> cd*(n+1)",assuming:{multiply:{commutative:!1}}},{s:"cd + cd*n -> cd*(1+n)",assuming:{multiply:{commutative:!1}}},m,{s:"(-n)*n1 -> -(n*n1)",assuming:{subtract:{total:!0}}},{s:"n1*(-n) -> -(n1*n)",assuming:{subtract:{total:!0},multiply:{commutative:!1}}},{s:"ce+ve -> ve+ce",assuming:{add:{commutative:!0}},imposeContext:{add:{commutative:!1}}},{s:"vd*cd -> cd*vd",assuming:{multiply:{commutative:!0}},imposeContext:{multiply:{commutative:!1}}},{l:"n+-n1",r:"n-n1"},{s:"n*(n1^-1) -> n/n1",assuming:{multiply:{commutative:!0}}},{s:"n*n1^-n2 -> n/n1^n2",assuming:{multiply:{commutative:!0}}},{s:"n^-1 -> 1/n",assuming:{multiply:{commutative:!0}}},{l:"n^1",r:"n"},{s:"n*(n1/n2) -> (n*n1)/n2",assuming:{multiply:{associative:!0}}},{s:"n-(n1+n2) -> n-n1-n2",assuming:{addition:{associative:!0,commutative:!0}}},{l:"1*n",r:"n",imposeContext:{multiply:{commutative:!0}}},{s:"n1/(n2/n3) -> (n1*n3)/n2",assuming:{multiply:{associative:!0}}},{l:"n1/(-n2)",r:"-n1/n2"}];function ae(G,Y){var te={};if(G.s){var ye=G.s.split("->");if(ye.length===2)te.l=ye[0],te.r=ye[1];else throw SyntaxError("Could not parse rule: "+G.s)}else te.l=G.l,te.r=G.r;te.l=L(a(te.l)),te.r=L(a(te.r));for(var me of["imposeContext","repeat","assuming"])me in G&&(te[me]=G[me]);if(G.evaluate&&(te.evaluate=a(G.evaluate)),I(te.l,Y)){var z=!B(te.l,Y),U;z&&(U=he());var ee=H(te.l),ue=he();te.expanded={},te.expanded.l=ee([te.l,ue]),R(te.expanded.l,Y),M(te.expanded.l,Y),te.expanded.r=ee([te.r,ue]),z&&(te.expandedNC1={},te.expandedNC1.l=ee([U,te.l]),te.expandedNC1.r=ee([U,te.r]),te.expandedNC2={},te.expandedNC2.l=ee([U,te.expanded.l]),te.expandedNC2.r=ee([U,te.expanded.r]))}return te}function re(G,Y){for(var te=[],ye=0;ye<G.length;ye++){var me=G[ye],z=void 0,U=typeof me;switch(U){case"string":me={s:me};case"object":z=ae(me,Y);break;case"function":z=me;break;default:throw TypeError("Unsupported type of rule: "+U)}te.push(z)}return te}var fe=0;function he(){return new D("_p"+fe++)}function ce(G,Y){var te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ea(),ye=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},me=ye.consoleDebug;Y=re(Y||K.rules,ye.context);var z=c(G,te);z=L(z);for(var U={},ee=z.toString({parenthesis:"all"});!U[ee];){U[ee]=!0,fe=0;var ue=ee;me&&console.log("Working on: ",ee);for(var ve=0;ve<Y.length;ve++){var de="";if(typeof Y[ve]=="function"?(z=Y[ve](z,ye),me&&(de=Y[ve].name)):(R(z,ye.context),z=Ae(z,Y[ve],ye.context),me&&(de="".concat(Y[ve].l.toString()," -> ").concat(Y[ve].r.toString()))),me){var be=z.toString({parenthesis:"all"});be!==ue&&(console.log("Applying",de,"produced",be),ue=be)}F(z,ye.context)}ee=z.toString({parenthesis:"all"})}return z}function ie(G,Y,te){var ye=G;if(G)for(var me=0;me<G.length;++me){var z=Ae(G[me],Y,te);z!==G[me]&&(ye===G&&(ye=G.slice()),ye[me]=z)}return ye}function Ae(G,Y,te){if(Y.assuming){for(var ye in Y.assuming)for(var me in Y.assuming[ye])if(T(ye,me,te)!==Y.assuming[ye][me])return G}var z=P(Y.imposeContext,te),U=G;if(U instanceof A||U instanceof x){var ee=ie(U.args,Y,te);ee!==U.args&&(U=U.clone(),U.args=ee)}else if(U instanceof S){if(U.content){var ue=Ae(U.content,Y,te);ue!==U.content&&(U=new S(ue))}}else if(U instanceof d){var ve=ie(U.items,Y,te);ve!==U.items&&(U=new d(ve))}else if(U instanceof N){var de=U.object;U.object&&(de=Ae(U.object,Y,te));var be=U.index;U.index&&(be=Ae(U.index,Y,te)),(de!==U.object||be!==U.index)&&(U=new N(de,be))}else if(U instanceof b){var pe=ie(U.dimensions,Y,te);pe!==U.dimensions&&(U=new b(pe))}else if(U instanceof E){var we=!1,_e={};for(var Le in U.properties)_e[Le]=Ae(U.properties[Le],Y,te),_e[Le]!==U.properties[Le]&&(we=!0);we&&(U=new E(_e))}var Be=Y.r,ar=X(Y.l,U,z)[0];if(!ar&&Y.expanded&&(Be=Y.expanded.r,ar=X(Y.expanded.l,U,z)[0]),!ar&&Y.expandedNC1&&(Be=Y.expandedNC1.r,ar=X(Y.expandedNC1.l,U,z)[0],ar||(Be=Y.expandedNC2.r,ar=X(Y.expandedNC2.l,U,z)[0])),ar){var Je=U.implicit;U=Be.clone(),Je&&"implicit"in Be&&(U.implicit=!0),U=U.transform(function(mr){return mr.isSymbolNode&&Re(ar.placeholders,mr.name)?ar.placeholders[mr.name].clone():mr})}return Y.repeat&&U!==G&&(U=Ae(U,Y,te)),U}function Oe(G,Y){var te=[],ye,me,z=H(G);if(B(G,Y))for(var U=0;U<G.args.length;U++)me=G.args.slice(0),me.splice(U,1),ye=me.length===1?me[0]:z(me),te.push(z([G.args[U],ye]));else for(var ee=1;ee<G.args.length;ee++){var ue=G.args[0];ee>1&&(ue=z(G.args.slice(0,ee))),me=G.args.slice(ee),ye=me.length===1?me[0]:z(me),te.push(z([ue,ye]))}return te}function Ce(G,Y){var te={placeholders:{}};if(!G.placeholders&&!Y.placeholders)return te;if(G.placeholders){if(!Y.placeholders)return G}else return Y;for(var ye in G.placeholders)if(Re(G.placeholders,ye)&&(te.placeholders[ye]=G.placeholders[ye],Re(Y.placeholders,ye)&&!oe(G.placeholders[ye],Y.placeholders[ye])))return null;for(var me in Y.placeholders)Re(Y.placeholders,me)&&(te.placeholders[me]=Y.placeholders[me]);return te}function $e(G,Y){var te=[];if(G.length===0||Y.length===0)return te;for(var ye,me=0;me<G.length;me++)for(var z=0;z<Y.length;z++)ye=Ce(G[me],Y[z]),ye&&te.push(ye);return te}function V(G){if(G.length===0)return G;for(var Y=G.reduce($e),te=[],ye={},me=0;me<Y.length;me++){var z=JSON.stringify(Y[me]);ye[z]||(ye[z]=!0,te.push(Y[me]))}return te}function X(G,Y,te,ye){var me=[{placeholders:{}}];if(G instanceof A&&Y instanceof A||G instanceof x&&Y instanceof x){if(G instanceof A){if(G.op!==Y.op||G.fn!==Y.fn)return[]}else if(G instanceof x&&G.name!==Y.name)return[];if(Y.args.length===1&&G.args.length===1||!I(Y,te)&&Y.args.length===G.args.length||ye){for(var z=[],U=0;U<G.args.length;U++){var ee=X(G.args[U],Y.args[U],te);if(ee.length===0)break;z.push(ee)}if(z.length!==G.args.length){if(!B(Y,te)||G.args.length===1)return[];if(G.args.length>2)throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");var ue=X(G.args[0],Y.args[1],te);if(ue.length===0)return[];var ve=X(G.args[1],Y.args[0],te);if(ve.length===0)return[];z=[ue,ve]}me=V(z)}else if(Y.args.length>=2&&G.args.length===2){for(var de=Oe(Y,te),be=[],pe=0;pe<de.length;pe++){var we=X(G,de[pe],te,!0);be=be.concat(we)}return be}else{if(G.args.length>2)throw Error("Unexpected non-binary associative function: "+G.toString());return[]}}else if(G instanceof D){if(G.name.length===0)throw new Error("Symbol in rule has 0 length...!?");if(j[G.name]){if(G.name!==Y.name)return[]}else switch(G.name[1]>="a"&&G.name[1]<="z"?G.name.substring(0,2):G.name[0]){case"n":case"_p":me[0].placeholders[G.name]=Y;break;case"c":case"cl":if(ir(Y))me[0].placeholders[G.name]=Y;else return[];break;case"v":if(!ir(Y))me[0].placeholders[G.name]=Y;else return[];break;case"vl":if(qr(Y))me[0].placeholders[G.name]=Y;else return[];break;case"cd":if(ph(Y))me[0].placeholders[G.name]=Y;else return[];break;case"vd":if(!ph(Y))me[0].placeholders[G.name]=Y;else return[];break;case"ce":if(oo(Y))me[0].placeholders[G.name]=Y;else return[];break;case"ve":if(!oo(Y))me[0].placeholders[G.name]=Y;else return[];break;default:throw new Error("Invalid symbol in rule: "+G.name)}}else if(G instanceof w){if(!s(G.value,Y.value))return[]}else return[];return me}function oe(G,Y){if(G instanceof w&&Y instanceof w){if(!s(G.value,Y.value))return!1}else if(G instanceof D&&Y instanceof D){if(G.name!==Y.name)return!1}else if(G instanceof A&&Y instanceof A||G instanceof x&&Y instanceof x){if(G instanceof A){if(G.op!==Y.op||G.fn!==Y.fn)return!1}else if(G instanceof x&&G.name!==Y.name)return!1;if(G.args.length!==Y.args.length)return!1;for(var te=0;te<G.args.length;te++)if(!oe(G.args[te],Y.args[te]))return!1}else return!1;return!0}return K}),YT="simplifyConstant",QT=["typed","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],KT=q(YT,QT,r=>{var{typed:e,config:t,mathWithTransform:a,matrix:n,fraction:i,bignumber:o,AccessorNode:f,ArrayNode:l,ConstantNode:u,FunctionNode:s,IndexNode:c,ObjectNode:m,OperatorNode:v,SymbolNode:h}=r,{isCommutative:p,isAssociative:g,allChildren:y,createMakeNodeFunction:N}=Cs({FunctionNode:s,OperatorNode:v,SymbolNode:h}),d=e("simplifyConstant",{Node:R=>E(P(R,{})),"Node, Object":function(M,F){return E(P(M,F))}});function w(R){return za(R)?R.valueOf():R instanceof Array?R.map(w):Ve(R)?n(w(R.valueOf())):R}function x(R,M,F){try{return a[R].apply(null,M)}catch{return M=M.map(w),S(a[R].apply(null,M),F)}}var b=e({Fraction:T,number:function(M){return M<0?D(new u(-M)):new u(M)},BigNumber:function(M){return M<0?D(new u(-M)):new u(M)},Complex:function(M){throw new Error("Cannot convert Complex number to Node")},string:function(M){return new u(M)},Matrix:function(M){return new l(M.valueOf().map(F=>b(F)))}});function E(R){return fr(R)?R:b(R)}function A(R,M){var F=M&&M.exactFractions!==!1;if(F&&isFinite(R)&&i){var H=i(R),$=M&&typeof M.fractionsLimit=="number"?M.fractionsLimit:1/0;if(H.valueOf()===R&&H.n<$&&H.d<$)return H}return R}var S=e({"string, Object":function(M,F){if(t.number==="BigNumber")return o===void 0&&ps(),o(M);if(t.number==="Fraction")return i===void 0&&fm(),i(M);var H=parseFloat(M);return A(H,F)},"Fraction, Object":function(M,F){return M},"BigNumber, Object":function(M,F){return M},"number, Object":function(M,F){return A(M,F)},"Complex, Object":function(M,F){return M.im!==0?M:A(M.re,F)},"Matrix, Object":function(M,F){return n(A(M.valueOf()))},"Array, Object":function(M,F){return M.map(A)}});function D(R){return new v("-","unaryMinus",[R])}function T(R){var M,F=R.s*R.n;return F<0?M=new v("-","unaryMinus",[new u(-F)]):M=new u(F),R.d===1?M:new v("/","divide",[M,new u(R.d)])}function B(R,M,F){if(!Jn(M))return new f(E(R),E(M));if(ot(R)||Ve(R)){for(var H=Array.from(M.dimensions);H.length>0;)if(ir(H[0])&&typeof H[0].value!="string"){var $=S(H.shift().value,F);ot(R)?R=R.items[$-1]:(R=R.valueOf()[$-1],R instanceof Array&&(R=n(R)))}else if(H.length>1&&ir(H[1])&&typeof H[1].value!="string"){var k=S(H[1].value,F),Q=[],K=ot(R)?R.items:R.valueOf();for(var L of K)if(ot(L))Q.push(L.items[k-1]);else if(Ve(R))Q.push(L[k-1]);else break;if(Q.length===K.length)ot(R)?R=new l(Q):R=n(Q),H.splice(1,1);else break}else break;return H.length===M.dimensions.length?new f(E(R),M):H.length>0?(M=new c(H),new f(E(R),M)):R}if(ci(R)&&M.dimensions.length===1&&ir(M.dimensions[0])){var j=M.dimensions[0].value;return j in R.properties?R.properties[j]:new u}return new f(E(R),M)}function I(R,M,F,H){var $=M.shift(),k=M.reduce((Q,K)=>{if(!fr(K)){var L=Q.pop();if(fr(L))return[L,K];try{return Q.push(x(R,[L,K],H)),Q}catch{Q.push(L)}}Q.push(E(Q.pop()));var j=Q.length===1?Q[0]:F(Q);return[F([j,E(K)])]},[$]);return k.length===1?k[0]:F([k[0],b(k[1])])}function P(R,M){switch(R.type){case"SymbolNode":return R;case"ConstantNode":switch(typeof R.value){case"number":return S(R.value,M);case"string":return R.value;default:if(!isNaN(R.value))return S(R.value,M)}return R;case"FunctionNode":if(a[R.name]&&a[R.name].rawArgs)return R;{var F=["add","multiply"];if(F.indexOf(R.name)===-1){var H=R.args.map(Ae=>P(Ae,M));if(!H.some(fr))try{return x(R.name,H,M)}catch{}if(R.name==="size"&&H.length===1&&ot(H[0])){for(var $=[],k=H[0];ot(k);)$.push(k.items.length),k=k.items[0];return n($)}return new s(R.name,H.map(E))}}case"OperatorNode":{var Q=R.fn.toString(),K,L,j=N(R);if(Br(R)&&R.isUnary())K=[P(R.args[0],M)],fr(K[0])?L=j(K):L=x(Q,K,M);else if(g(R,M.context))if(K=y(R,M.context),K=K.map(Ae=>P(Ae,M)),p(Q,M.context)){for(var ae=[],re=[],fe=0;fe<K.length;fe++)fr(K[fe])?re.push(K[fe]):ae.push(K[fe]);ae.length>1?(L=I(Q,ae,j,M),re.unshift(L),L=I(Q,re,j,M)):L=I(Q,K,j,M)}else L=I(Q,K,j,M);else K=R.args.map(Ae=>P(Ae,M)),L=I(Q,K,j,M);return L}case"ParenthesisNode":return P(R.content,M);case"AccessorNode":return B(P(R.object,M),P(R.index,M),M);case"ArrayNode":{var he=R.items.map(Ae=>P(Ae,M));return he.some(fr)?new l(he.map(E)):n(he)}case"IndexNode":return new c(R.dimensions.map(Ae=>d(Ae,M)));case"ObjectNode":{var ce={};for(var ie in R.properties)ce[ie]=d(R.properties[ie],M);return new m(ce)}case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"RangeNode":case"ConditionalNode":default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(R.type))}}return d}),dh="simplifyCore",jT=["typed","parse","equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],eB=q(dh,jT,r=>{var{typed:e,parse:t,equal:a,isZero:n,add:i,subtract:o,multiply:f,divide:l,pow:u,AccessorNode:s,ArrayNode:c,ConstantNode:m,FunctionNode:v,IndexNode:h,ObjectNode:p,OperatorNode:g,ParenthesisNode:y,SymbolNode:N}=r,d=new m(0),w=new m(1),x=new m(!0),b=new m(!1);function E(T){return Br(T)&&["and","not","or"].includes(T.op)}var{hasProperty:A,isCommutative:S}=Cs({FunctionNode:v,OperatorNode:g,SymbolNode:N});function D(T){var B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},I=B?B.context:void 0;if(A(T,"trivial",I)){if(nn(T)&&T.args.length===1)return D(T.args[0],B);var P=!1,R=0;if(T.forEach(re=>{++R,R===1&&(P=D(re,B))}),R===1)return P}var M=T;if(nn(M)){var F=yE(M.name);if(F){if(M.args.length>2&&A(M,"associative",I))for(;M.args.length>2;){var H=M.args.pop(),$=M.args.pop();M.args.push(new g(F,M.name,[H,$]))}M=new g(F,M.name,M.args)}else return new v(D(M.fn),M.args.map(re=>D(re,B)))}if(Br(M)&&M.isUnary()){var k=D(M.args[0],B);if(M.op==="~"&&Br(k)&&k.isUnary()&&k.op==="~"||M.op==="not"&&Br(k)&&k.isUnary()&&k.op==="not"&&E(k.args[0]))return k.args[0];var Q=!0;if(M.op==="-"&&Br(k)&&(k.isBinary()&&k.fn==="subtract"&&(M=new g("-","subtract",[k.args[1],k.args[0]]),Q=!1),k.isUnary()&&k.op==="-"))return k.args[0];if(Q)return new g(M.op,M.fn,[k])}if(Br(M)&&M.isBinary()){var K=D(M.args[0],B),L=D(M.args[1],B);if(M.op==="+"){if(ir(K)&&n(K.value))return L;if(ir(L)&&n(L.value))return K;Br(L)&&L.isUnary()&&L.op==="-"&&(L=L.args[0],M=new g("-","subtract",[K,L]))}if(M.op==="-")return Br(L)&&L.isUnary()&&L.op==="-"?D(new g("+","add",[K,L.args[0]]),B):ir(K)&&n(K.value)?D(new g("-","unaryMinus",[L])):ir(L)&&n(L.value)?K:new g(M.op,M.fn,[K,L]);if(M.op==="*"){if(ir(K)){if(n(K.value))return d;if(a(K.value,1))return L}if(ir(L)){if(n(L.value))return d;if(a(L.value,1))return K;if(S(M,I))return new g(M.op,M.fn,[L,K],M.implicit)}return new g(M.op,M.fn,[K,L],M.implicit)}if(M.op==="/")return ir(K)&&n(K.value)?d:ir(L)&&a(L.value,1)?K:new g(M.op,M.fn,[K,L]);if(M.op==="^"&&ir(L)){if(n(L.value))return w;if(a(L.value,1))return K}if(M.op==="and"){if(ir(K))if(K.value){if(E(L))return L}else return b;if(ir(L))if(L.value){if(E(K))return K}else return b}if(M.op==="or"){if(ir(K)){if(K.value)return x;if(E(L))return L}if(ir(L)){if(L.value)return x;if(E(K))return K}}return new g(M.op,M.fn,[K,L])}if(Br(M))return new g(M.op,M.fn,M.args.map(re=>D(re,B)));if(ot(M))return new c(M.items.map(re=>D(re,B)));if(Sn(M))return new s(D(M.object,B),D(M.index,B));if(Jn(M))return new h(M.dimensions.map(re=>D(re,B)));if(ci(M)){var j={};for(var ae in M.properties)j[ae]=D(M.properties[ae],B);return new p(j)}return M}return e(dh,{Node:D,"Node,Object":D})}),rB="resolve",tB=["typed","parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],nB=q(rB,tB,r=>{var{typed:e,parse:t,ConstantNode:a,FunctionNode:n,OperatorNode:i,ParenthesisNode:o}=r;function f(l,u){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;if(!u)return l;if(qr(l)){if(s.has(l.name)){var c=Array.from(s).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(c,"}"))}var m=u.get(l.name);if(fr(m)){var v=new Set(s);return v.add(l.name),f(m,u,v)}else return typeof m=="number"?t(String(m)):m!==void 0?new a(m):l}else if(Br(l)){var h=l.args.map(function(g){return f(g,u,s)});return new i(l.op,l.fn,h,l.implicit)}else{if(Gt(l))return new o(f(l.content,u,s));if(nn(l)){var p=l.args.map(function(g){return f(g,u,s)});return new n(l.name,p)}}return l.map(g=>f(g,u,s))}return e("resolve",{Node:f,"Node, Map | null | undefined":f,"Node, Object":(l,u)=>f(l,ra(u)),"Array | Matrix":e.referToSelf(l=>u=>u.map(s=>l(s))),"Array | Matrix, null | undefined":e.referToSelf(l=>u=>u.map(s=>l(s))),"Array, Object":e.referTo("Array,Map",l=>(u,s)=>l(u,ra(s))),"Matrix, Object":e.referTo("Matrix,Map",l=>(u,s)=>l(u,ra(s))),"Array | Matrix, Map":e.referToSelf(l=>(u,s)=>u.map(c=>l(c,s)))})}),gh="symbolicEqual",aB=["parse","simplify","typed","OperatorNode"],iB=q(gh,aB,r=>{var{parse:e,simplify:t,typed:a,OperatorNode:n}=r;function i(o,f){var l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},u=new n("-","subtract",[o,f]),s=t(u,{},l);return ir(s)&&!s.value}return a(gh,{"Node, Node":i,"Node, Node, Object":i})}),yh="derivative",oB=["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],sB=q(yh,oB,r=>{var{typed:e,config:t,parse:a,simplify:n,equal:i,isZero:o,numeric:f,ConstantNode:l,FunctionNode:u,OperatorNode:s,ParenthesisNode:c,SymbolNode:m}=r;function v(w,x){var b=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{simplify:!0},E={};g(E,w,x.name);var A=y(w,E);return b.simplify?n(A):A}e.addConversion({from:"identifier",to:"SymbolNode",convert:a});var h=e(yh,{"Node, SymbolNode":v,"Node, SymbolNode, Object":v});e.removeConversion({from:"identifier",to:"SymbolNode",convert:a}),h._simplify=!0,h.toTex=function(w){return p.apply(null,w.args)};var p=e("_derivTex",{"Node, SymbolNode":function(x,b){return ir(x)&&br(x.value)==="string"?p(a(x.value).toString(),b.toString(),1):p(x.toTex(),b.toString(),1)},"Node, ConstantNode":function(x,b){if(br(b.value)==="string")return p(x,a(b.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(x,b,E){return p(x.toString(),b.name,E.value)},"string, string, number":function(x,b,E){var A;return E===1?A="{d\\over d"+b+"}":A="{d^{"+E+"}\\over d"+b+"^{"+E+"}}",A+"\\left[".concat(x,"\\right]")}}),g=e("constTag",{"Object, ConstantNode, string":function(x,b){return x[b]=!0,!0},"Object, SymbolNode, string":function(x,b,E){return b.name!==E?(x[b]=!0,!0):!1},"Object, ParenthesisNode, string":function(x,b,E){return g(x,b.content,E)},"Object, FunctionAssignmentNode, string":function(x,b,E){return b.params.indexOf(E)===-1?(x[b]=!0,!0):g(x,b.expr,E)},"Object, FunctionNode | OperatorNode, string":function(x,b,E){if(b.args.length>0){for(var A=g(x,b.args[0],E),S=1;S<b.args.length;++S)A=g(x,b.args[S],E)&&A;if(A)return x[b]=!0,!0}return!1}}),y=e("_derivative",{"ConstantNode, Object":function(x){return d(0)},"SymbolNode, Object":function(x,b){return b[x]!==void 0?d(0):d(1)},"ParenthesisNode, Object":function(x,b){return new c(y(x.content,b))},"FunctionAssignmentNode, Object":function(x,b){return b[x]!==void 0?d(0):y(x.expr,b)},"FunctionNode, Object":function(x,b){if(x.args.length!==1&&N(x),b[x]!==void 0)return d(0);var E=x.args[0],A,S=!1,D=!1,T;switch(x.name){case"cbrt":S=!0,T=new s("*","multiply",[d(3),new s("^","pow",[E,new s("/","divide",[d(2),d(3)])])]);break;case"sqrt":case"nthRoot":if(x.args.length===1)S=!0,T=new s("*","multiply",[d(2),new u("sqrt",[E])]);else if(x.args.length===2)return A=new s("/","divide",[d(1),x.args[1]]),b[A]=b[x.args[1]],y(new s("^","pow",[E,A]),b);break;case"log10":A=d(10);case"log":if(!A&&x.args.length===1)T=E.clone(),S=!0;else if(x.args.length===1&&A||x.args.length===2&&b[x.args[1]]!==void 0)T=new s("*","multiply",[E.clone(),new u("log",[A||x.args[1]])]),S=!0;else if(x.args.length===2)return y(new s("/","divide",[new u("log",[E]),new u("log",[x.args[1]])]),b);break;case"pow":return b[A]=b[x.args[1]],y(new s("^","pow",[E,x.args[1]]),b);case"exp":T=new u("exp",[E.clone()]);break;case"sin":T=new u("cos",[E.clone()]);break;case"cos":T=new s("-","unaryMinus",[new u("sin",[E.clone()])]);break;case"tan":T=new s("^","pow",[new u("sec",[E.clone()]),d(2)]);break;case"sec":T=new s("*","multiply",[x,new u("tan",[E.clone()])]);break;case"csc":D=!0,T=new s("*","multiply",[x,new u("cot",[E.clone()])]);break;case"cot":D=!0,T=new s("^","pow",[new u("csc",[E.clone()]),d(2)]);break;case"asin":S=!0,T=new u("sqrt",[new s("-","subtract",[d(1),new s("^","pow",[E.clone(),d(2)])])]);break;case"acos":S=!0,D=!0,T=new u("sqrt",[new s("-","subtract",[d(1),new s("^","pow",[E.clone(),d(2)])])]);break;case"atan":S=!0,T=new s("+","add",[new s("^","pow",[E.clone(),d(2)]),d(1)]);break;case"asec":S=!0,T=new s("*","multiply",[new u("abs",[E.clone()]),new u("sqrt",[new s("-","subtract",[new s("^","pow",[E.clone(),d(2)]),d(1)])])]);break;case"acsc":S=!0,D=!0,T=new s("*","multiply",[new u("abs",[E.clone()]),new u("sqrt",[new s("-","subtract",[new s("^","pow",[E.clone(),d(2)]),d(1)])])]);break;case"acot":S=!0,D=!0,T=new s("+","add",[new s("^","pow",[E.clone(),d(2)]),d(1)]);break;case"sinh":T=new u("cosh",[E.clone()]);break;case"cosh":T=new u("sinh",[E.clone()]);break;case"tanh":T=new s("^","pow",[new u("sech",[E.clone()]),d(2)]);break;case"sech":D=!0,T=new s("*","multiply",[x,new u("tanh",[E.clone()])]);break;case"csch":D=!0,T=new s("*","multiply",[x,new u("coth",[E.clone()])]);break;case"coth":D=!0,T=new s("^","pow",[new u("csch",[E.clone()]),d(2)]);break;case"asinh":S=!0,T=new u("sqrt",[new s("+","add",[new s("^","pow",[E.clone(),d(2)]),d(1)])]);break;case"acosh":S=!0,T=new u("sqrt",[new s("-","subtract",[new s("^","pow",[E.clone(),d(2)]),d(1)])]);break;case"atanh":S=!0,T=new s("-","subtract",[d(1),new s("^","pow",[E.clone(),d(2)])]);break;case"asech":S=!0,D=!0,T=new s("*","multiply",[E.clone(),new u("sqrt",[new s("-","subtract",[d(1),new s("^","pow",[E.clone(),d(2)])])])]);break;case"acsch":S=!0,D=!0,T=new s("*","multiply",[new u("abs",[E.clone()]),new u("sqrt",[new s("+","add",[new s("^","pow",[E.clone(),d(2)]),d(1)])])]);break;case"acoth":S=!0,D=!0,T=new s("-","subtract",[d(1),new s("^","pow",[E.clone(),d(2)])]);break;case"abs":T=new s("/","divide",[new u(new m("abs"),[E.clone()]),E.clone()]);break;case"gamma":default:throw new Error('Function "'+x.name+'" is not supported by derivative, or a wrong number of arguments is passed')}var B,I;S?(B="/",I="divide"):(B="*",I="multiply");var P=y(E,b);return D&&(P=new s("-","unaryMinus",[P])),new s(B,I,[P,T])},"OperatorNode, Object":function(x,b){if(b[x]!==void 0)return d(0);if(x.op==="+")return new s(x.op,x.fn,x.args.map(function(M){return y(M,b)}));if(x.op==="-"){if(x.isUnary())return new s(x.op,x.fn,[y(x.args[0],b)]);if(x.isBinary())return new s(x.op,x.fn,[y(x.args[0],b),y(x.args[1],b)])}if(x.op==="*"){var E=x.args.filter(function(M){return b[M]!==void 0});if(E.length>0){var A=x.args.filter(function(M){return b[M]===void 0}),S=A.length===1?A[0]:new s("*","multiply",A),D=E.concat(y(S,b));return new s("*","multiply",D)}return new s("+","add",x.args.map(function(M){return new s("*","multiply",x.args.map(function(F){return F===M?y(F,b):F.clone()}))}))}if(x.op==="/"&&x.isBinary()){var T=x.args[0],B=x.args[1];return b[B]!==void 0?new s("/","divide",[y(T,b),B]):b[T]!==void 0?new s("*","multiply",[new s("-","unaryMinus",[T]),new s("/","divide",[y(B,b),new s("^","pow",[B.clone(),d(2)])])]):new s("/","divide",[new s("-","subtract",[new s("*","multiply",[y(T,b),B.clone()]),new s("*","multiply",[T.clone(),y(B,b)])]),new s("^","pow",[B.clone(),d(2)])])}if(x.op==="^"&&x.isBinary()){var I=x.args[0],P=x.args[1];if(b[I]!==void 0)return ir(I)&&(o(I.value)||i(I.value,1))?d(0):new s("*","multiply",[x,new s("*","multiply",[new u("log",[I.clone()]),y(P.clone(),b)])]);if(b[P]!==void 0){if(ir(P)){if(o(P.value))return d(0);if(i(P.value,1))return y(I,b)}var R=new s("^","pow",[I.clone(),new s("-","subtract",[P,d(1)])]);return new s("*","multiply",[P.clone(),new s("*","multiply",[y(I,b),R])])}return new s("*","multiply",[new s("^","pow",[I.clone(),P.clone()]),new s("+","add",[new s("*","multiply",[y(I,b),new s("/","divide",[P.clone(),I.clone()])]),new s("*","multiply",[y(P,b),new u("log",[I.clone()])])])])}throw new Error('Operator "'+x.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function N(w){if(!((w.name==="log"||w.name==="nthRoot"||w.name==="pow")&&w.args.length===2)){for(var x=0;x<w.args.length;++x)w.args[x]=d(0);throw w.compile().evaluate(),new Error("Expected TypeError, but none found")}}function d(w,x){return new l(f(w,x||t.number))}return h}),bh="rationalize",uB=["config","typed","equal","isZero","add","subtract","multiply","divide","pow","parse","simplifyConstant","simplifyCore","simplify","?bignumber","?fraction","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode","ParenthesisNode"],lB=q(bh,uB,r=>{var{config:e,typed:t,equal:a,isZero:n,add:i,subtract:o,multiply:f,divide:l,pow:u,parse:s,simplifyConstant:c,simplifyCore:m,simplify:v,fraction:h,bignumber:p,mathWithTransform:g,matrix:y,AccessorNode:N,ArrayNode:d,ConstantNode:w,FunctionNode:x,IndexNode:b,ObjectNode:E,OperatorNode:A,SymbolNode:S,ParenthesisNode:D}=r;function T(M){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},H=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,$=I(),k=B(M,F,!0,$.firstRules),Q=k.variables.length,K={exactFractions:!1},L={exactFractions:!0};if(M=k.expression,Q>=1){M=P(M);var j,ae,re=!0,fe=!1;M=v(M,$.firstRules,{},K);for(var he;ae=re?$.distrDivRules:$.sucDivRules,M=v(M,ae,{},L),re=!re,he=M.toString(),he!==j;)fe=!0,j=he;fe&&(M=v(M,$.firstRulesAgain,{},K)),M=v(M,$.finalRules,{},K)}var ce=[],ie={};return M.type==="OperatorNode"&&M.isBinary()&&M.op==="/"?(Q===1&&(M.args[0]=R(M.args[0],ce),M.args[1]=R(M.args[1])),H&&(ie.numerator=M.args[0],ie.denominator=M.args[1])):(Q===1&&(M=R(M,ce)),H&&(ie.numerator=M,ie.denominator=null)),H?(ie.coefficients=ce,ie.variables=k.variables,ie.expression=M,ie):M}return t(bh,{Node:T,"Node, boolean":(M,F)=>T(M,{},F),"Node, Object":T,"Node, Object, boolean":T});function B(M,F,H,$){var k=[],Q=v(M,$,F,{exactFractions:!1});H=!!H;var K="+-*"+(H?"/":"");j(Q);var L={};return L.expression=Q,L.variables=k,L;function j(ae){var re=ae.type;if(re==="FunctionNode")throw new Error("There is an unsolved function call");if(re==="OperatorNode")if(ae.op==="^"){if(ae.args[1].type!=="ConstantNode"||!qe(parseFloat(ae.args[1].value)))throw new Error("There is a non-integer exponent");j(ae.args[0])}else{if(K.indexOf(ae.op)===-1)throw new Error("Operator "+ae.op+" invalid in polynomial expression");for(var fe=0;fe<ae.args.length;fe++)j(ae.args[fe])}else if(re==="SymbolNode"){var he=ae.name,ce=k.indexOf(he);ce===-1&&k.push(he)}else if(re==="ParenthesisNode")j(ae.content);else if(re!=="ConstantNode")throw new Error("type "+re+" is not allowed in polynomial expression")}}function I(){var M=[m,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},c,{l:"n*(n1^-1)",r:"n/n1"},{l:"n*n1^-n2",r:"n/n1^n2"},{l:"n1^-1",r:"1/n1"},{l:"n*(n1/n2)",r:"(n*n1)/n2"},{l:"1*n",r:"n"}],F=[{l:"(-n1)/(-n2)",r:"n1/n2"},{l:"(-n1)*(-n2)",r:"n1*n2"},{l:"n1--n2",r:"n1+n2"},{l:"n1-n2",r:"n1+(-n2)"},{l:"(n1+n2)*n3",r:"(n1*n3 + n2*n3)"},{l:"n1*(n2+n3)",r:"(n1*n2+n1*n3)"},{l:"c1*n + c2*n",r:"(c1+c2)*n"},{l:"c1*n + n",r:"(c1+1)*n"},{l:"c1*n - c2*n",r:"(c1-c2)*n"},{l:"c1*n - n",r:"(c1-1)*n"},{l:"v/c",r:"(1/c)*v"},{l:"v/-c",r:"-(1/c)*v"},{l:"-v*-c",r:"c*v"},{l:"-v*c",r:"-c*v"},{l:"v*-c",r:"-c*v"},{l:"v*c",r:"c*v"},{l:"-(-n1*n2)",r:"(n1*n2)"},{l:"-(n1*n2)",r:"(-n1*n2)"},{l:"-(-n1+n2)",r:"(n1-n2)"},{l:"-(n1+n2)",r:"(-n1-n2)"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"},{l:"-(-n1/n2)",r:"(n1/n2)"},{l:"-(n1/n2)",r:"(-n1/n2)"}],H=[{l:"(n1/n2 + n3/n4)",r:"((n1*n4 + n3*n2)/(n2*n4))"},{l:"(n1/n2 + n3)",r:"((n1 + n3*n2)/n2)"},{l:"(n1 + n2/n3)",r:"((n1*n3 + n2)/n3)"}],$=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],k={};return k.firstRules=M.concat(F,$),k.distrDivRules=H,k.sucDivRules=$,k.firstRulesAgain=M.concat(F),k.finalRules=[m,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},c,{l:"n*-n^n1",r:"-n^(n1+1)"},{l:"n*n^n1",r:"n^(n1+1)"},{l:"n^n1*-n^n2",r:"-n^(n1+n2)"},{l:"n^n1*n^n2",r:"n^(n1+n2)"},{l:"n^n1*-n",r:"-n^(n1+1)"},{l:"n^n1*n",r:"n^(n1+1)"},{l:"n^n1/-n",r:"-n^(n1-1)"},{l:"n^n1/n",r:"n^(n1-1)"},{l:"n/-n^n1",r:"-n^(1-n1)"},{l:"n/n^n1",r:"n^(1-n1)"},{l:"n^n1/-n^n2",r:"n^(n1-n2)"},{l:"n^n1/n^n2",r:"n^(n1-n2)"},{l:"n1+(-n2*n3)",r:"n1-n2*n3"},{l:"v*(-c)",r:"-c*v"},{l:"n1+-n2",r:"n1-n2"},{l:"v*c",r:"c*v"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"}],k}function P(M,F,H){var $=M.type,k=arguments.length>1;if($==="OperatorNode"&&M.isBinary()){var Q=!1,K;if(M.op==="^"&&(M.args[0].type==="ParenthesisNode"||M.args[0].type==="OperatorNode")&&M.args[1].type==="ConstantNode"&&(K=parseFloat(M.args[1].value),Q=K>=2&&qe(K)),Q){if(K>2){var L=M.args[0],j=new A("^","pow",[M.args[0].cloneDeep(),new w(K-1)]);M=new A("*","multiply",[L,j])}else M=new A("*","multiply",[M.args[0],M.args[0].cloneDeep()]);k&&(H==="content"?F.content=M:F.args[H]=M)}}if($==="ParenthesisNode")P(M.content,M,"content");else if($!=="ConstantNode"&&$!=="SymbolNode")for(var ae=0;ae<M.args.length;ae++)P(M.args[ae],M,ae);if(!k)return M}function R(M,F){F===void 0&&(F=[]),F[0]=0;var H={};H.cte=1,H.oper="+",H.fire="";var $=0,k="";he(M,null,H),$=F.length-1;for(var Q=!0,K,L=$;L>=0;L--)if(F[L]!==0){var j=new w(Q?F[L]:Math.abs(F[L])),ae=F[L]<0?"-":"+";if(L>0){var re=new S(k);if(L>1){var fe=new w(L);re=new A("^","pow",[re,fe])}F[L]===-1&&Q?j=new A("-","unaryMinus",[re]):Math.abs(F[L])===1?j=re:j=new A("*","multiply",[j,re])}Q?K=j:ae==="+"?K=new A("+","add",[K,j]):K=new A("-","subtract",[K,j]),Q=!1}if(Q)return new w(0);return K;function he(ce,ie,Ae){var Oe=ce.type;if(Oe==="FunctionNode")throw new Error("There is an unsolved function call");if(Oe==="OperatorNode"){if("+-*^".indexOf(ce.op)===-1)throw new Error("Operator "+ce.op+" invalid");if(ie!==null){if((ce.fn==="unaryMinus"||ce.fn==="pow")&&ie.fn!=="add"&&ie.fn!=="subtract"&&ie.fn!=="multiply")throw new Error("Invalid "+ce.op+" placing");if((ce.fn==="subtract"||ce.fn==="add"||ce.fn==="multiply")&&ie.fn!=="add"&&ie.fn!=="subtract")throw new Error("Invalid "+ce.op+" placing");if((ce.fn==="subtract"||ce.fn==="add"||ce.fn==="unaryMinus")&&Ae.noFil!==0)throw new Error("Invalid "+ce.op+" placing")}(ce.op==="^"||ce.op==="*")&&(Ae.fire=ce.op);for(var Ce=0;Ce<ce.args.length;Ce++)ce.fn==="unaryMinus"&&(Ae.oper="-"),(ce.op==="+"||ce.fn==="subtract")&&(Ae.fire="",Ae.cte=1,Ae.oper=Ce===0?"+":ce.op),Ae.noFil=Ce,he(ce.args[Ce],ce,Ae)}else if(Oe==="SymbolNode"){if(ce.name!==k&&k!=="")throw new Error("There is more than one variable");if(k=ce.name,ie===null){F[1]=1;return}if(ie.op==="^"&&Ae.noFil!==0)throw new Error("In power the variable should be the first parameter");if(ie.op==="*"&&Ae.noFil!==1)throw new Error("In multiply the variable should be the second parameter");(Ae.fire===""||Ae.fire==="*")&&($<1&&(F[1]=0),F[1]+=Ae.cte*(Ae.oper==="+"?1:-1),$=Math.max(1,$))}else if(Oe==="ConstantNode"){var $e=parseFloat(ce.value);if(ie===null){F[0]=$e;return}if(ie.op==="^"){if(Ae.noFil!==1)throw new Error("Constant cannot be powered");if(!qe($e)||$e<=0)throw new Error("Non-integer exponent is not allowed");for(var V=$+1;V<$e;V++)F[V]=0;$e>$&&(F[$e]=0),F[$e]+=Ae.cte*(Ae.oper==="+"?1:-1),$=Math.max($e,$);return}Ae.cte=$e,Ae.fire===""&&(F[0]+=Ae.cte*(Ae.oper==="+"?1:-1))}else throw new Error("Type "+Oe+" is not allowed")}}}),cB="reviver",fB=["classes"],mB=q(cB,fB,r=>{var{classes:e}=r;return function(a,n){var i=e[n&&n.mathjs];return i&&typeof i.fromJSON=="function"?i.fromJSON(n):n}}),vB="replacer",pB=[],hB=q(vB,pB,()=>function(e,t){return typeof t=="number"&&(!isFinite(t)||isNaN(t))?{mathjs:"number",value:String(t)}:t}),dB="11.8.0",gB=q("true",[],()=>!0),yB=q("false",[],()=>!1),bB=q("null",[],()=>null),xB=at("Infinity",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1/0):1/0}),wB=at("NaN",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(NaN):NaN}),NB=at("pi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?gs(t):ry}),DB=at("tau",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?ND(t):ty}),AB=at("e",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?xD(t):ny}),EB=at("phi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?wD(t):ay}),SB=at("LN2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).ln():Math.LN2}),CB=at("LN10",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(10).ln():Math.LN10}),MB=at("LOG2E",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1).div(new t(2).ln()):Math.LOG2E}),FB=at("LOG10E",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1).div(new t(10).ln()):Math.LOG10E}),TB=at("SQRT1_2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t("0.5").sqrt():Math.SQRT1_2}),BB=at("SQRT2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).sqrt():Math.SQRT2}),$B=at("i",["Complex"],r=>{var{Complex:e}=r;return e.I}),OB=q("version",[],()=>dB);function at(r,e,t){return q(r,e,t,{recreateOnConfigChange:!0})}var IB=We("speedOfLight","299792458","m s^-1"),RB=We("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),_B=We("planckConstant","6.62607015e-34","J s"),qB=We("reducedPlanckConstant","1.0545718176461565e-34","J s"),zB=We("magneticConstant","1.25663706212e-6","N A^-2"),PB=We("electricConstant","8.8541878128e-12","F m^-1"),UB=We("vacuumImpedance","376.730313667","ohm"),LB=We("coulomb","8.987551792261171e9","N m^2 C^-2"),kB=We("elementaryCharge","1.602176634e-19","C"),VB=We("bohrMagneton","9.2740100783e-24","J T^-1"),GB=We("conductanceQuantum","7.748091729863649e-5","S"),HB=We("inverseConductanceQuantum","12906.403729652257","ohm"),ZB=We("magneticFluxQuantum","2.0678338484619295e-15","Wb"),JB=We("nuclearMagneton","5.0507837461e-27","J T^-1"),XB=We("klitzing","25812.807459304513","ohm"),WB=We("bohrRadius","5.29177210903e-11","m"),YB=We("classicalElectronRadius","2.8179403262e-15","m"),QB=We("electronMass","9.1093837015e-31","kg"),KB=We("fermiCoupling","1.1663787e-5","GeV^-2"),jB=so("fineStructure",.0072973525693),e$=We("hartreeEnergy","4.3597447222071e-18","J"),r$=We("protonMass","1.67262192369e-27","kg"),t$=We("deuteronMass","3.3435830926e-27","kg"),n$=We("neutronMass","1.6749271613e-27","kg"),a$=We("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),i$=We("rydberg","10973731.568160","m^-1"),o$=We("thomsonCrossSection","6.6524587321e-29","m^2"),s$=so("weakMixingAngle",.2229),u$=so("efimovFactor",22.7),l$=We("atomicMass","1.66053906660e-27","kg"),c$=We("avogadro","6.02214076e23","mol^-1"),f$=We("boltzmann","1.380649e-23","J K^-1"),m$=We("faraday","96485.33212331001","C mol^-1"),v$=We("firstRadiation","3.7417718521927573e-16","W m^2"),p$=We("loschmidt","2.686780111798444e25","m^-3"),h$=We("gasConstant","8.31446261815324","J K^-1 mol^-1"),d$=We("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),g$=We("molarVolume","0.022413969545014137","m^3 mol^-1"),y$=so("sackurTetrode",-1.16487052358),b$=We("secondRadiation","0.014387768775039337","m K"),x$=We("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),w$=We("wienDisplacement","2.897771955e-3","m K"),N$=We("molarMass","0.99999999965e-3","kg mol^-1"),D$=We("molarMassC12","11.9999999958e-3","kg mol^-1"),A$=We("gravity","9.80665","m s^-2"),E$=We("planckLength","1.616255e-35","m"),S$=We("planckMass","2.176435e-8","kg"),C$=We("planckTime","5.391245e-44","s"),M$=We("planckCharge","1.87554603778e-18","C"),F$=We("planckTemperature","1.416785e+32","K");function We(r,e,t){var a=["config","Unit","BigNumber"];return q(r,a,n=>{var{config:i,Unit:o,BigNumber:f}=n,l=i.number==="BigNumber"?new f(e):parseFloat(e),u=new o(l,t);return u.fixPrefix=!0,u})}function so(r,e){var t=["config","BigNumber"];return q(r,t,a=>{var{config:n,BigNumber:i}=a;return n.number==="BigNumber"?new i(e):e})}var T$="apply",B$=["typed","isInteger"],$$=q(T$,B$,r=>{var{typed:e,isInteger:t}=r,a=df({typed:e,isInteger:t});return e("apply",{"...any":function(i){var o=i[1];tr(o)?i[1]=o-1:rr(o)&&(i[1]=o.minus(1));try{return a.apply(null,i)}catch(f){throw Kr(f)}}})},{isTransformFunction:!0}),O$="column",I$=["typed","Index","matrix","range"],R$=q(O$,I$,r=>{var{typed:e,Index:t,matrix:a,range:n}=r,i=Kf({typed:e,Index:t,matrix:a,range:n});return e("column",{"...any":function(f){var l=f.length-1,u=f[l];tr(u)&&(f[l]=u-1);try{return i.apply(null,f)}catch(s){throw Kr(s)}}})},{isTransformFunction:!0});function Ms(r,e,t){var a=r.filter(function(f){return qr(f)&&!(f.name in e)&&!t.has(f.name)})[0];if(!a)throw new Error('No undefined variable found in inline expression "'+r+'"');var n=a.name,i=Wa(t),o=r.compile();return function(l){return i.set(n,l),o.evaluate(i)}}var _$="filter",q$=["typed"],z$=q(_$,q$,r=>{var{typed:e}=r;function t(n,i,o){var f,l;return n[0]&&(f=n[0].compile().evaluate(o)),n[1]&&(qr(n[1])||Pa(n[1])?l=n[1].compile().evaluate(o):l=Ms(n[1],i,o)),a(f,l)}t.rawArgs=!0;var a=e("filter",{"Array, function":xh,"Matrix, function":function(i,o){return i.create(xh(i.toArray(),o))},"Array, RegExp":di,"Matrix, RegExp":function(i,o){return i.create(di(i.toArray(),o))}});return t},{isTransformFunction:!0});function xh(r,e){var t=fn(e);return Sl(r,function(a,n,i){return t===1?e(a):t===2?e(a,[n+1]):e(a,[n+1],i)})}var P$="forEach",U$=["typed"],L$=q(P$,U$,r=>{var{typed:e}=r;function t(n,i,o){var f,l;return n[0]&&(f=n[0].compile().evaluate(o)),n[1]&&(qr(n[1])||Pa(n[1])?l=n[1].compile().evaluate(o):l=Ms(n[1],i,o)),a(f,l)}t.rawArgs=!0;var a=e("forEach",{"Array | Matrix, function":function(i,o){var f=fn(o),l=function u(s,c){Array.isArray(s)?hi(s,function(m,v){u(m,c.concat(v+1))}):f===1?o(s):f===2?o(s,c):o(s,c,i)};l(i.valueOf(),[])}});return t},{isTransformFunction:!0}),k$="index",V$=["Index"],G$=q(k$,V$,r=>{var{Index:e}=r;return function(){for(var a=[],n=0,i=arguments.length;n<i;n++){var o=arguments[n];if(Uo(o))o.start--,o.end-=o.step>0?0:2;else if(o&&o.isSet===!0)o=o.map(function(l){return l-1});else if(cr(o)||Ve(o))o=o.map(function(l){return l-1});else if(tr(o))o--;else if(rr(o))o=o.toNumber()-1;else if(typeof o!="string")throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");a[n]=o}var f=new e;return e.apply(f,a),f}},{isTransformFunction:!0}),H$="map",Z$=["typed"],J$=q(H$,Z$,r=>{var{typed:e}=r;function t(n,i,o){var f,l;return n[0]&&(f=n[0].compile().evaluate(o)),n[1]&&(qr(n[1])||Pa(n[1])?l=n[1].compile().evaluate(o):l=Ms(n[1],i,o)),a(f,l)}t.rawArgs=!0;var a=e("map",{"Array, function":function(i,o){return wh(i,o,i)},"Matrix, function":function(i,o){return i.create(wh(i.valueOf(),o,i))}});return t},{isTransformFunction:!0});function wh(r,e,t){var a=fn(e);function n(i,o){return Array.isArray(i)?Ht(i,function(f,l){return n(f,o.concat(l+1))}):a===1?e(i):a===2?e(i,o):e(i,o,t)}return n(r,[])}function On(r){if(r.length===2&&Ft(r[0])){r=r.slice();var e=r[1];tr(e)?r[1]=e-1:rr(e)&&(r[1]=e.minus(1))}return r}var X$="max",W$=["typed","config","numeric","larger"],Y$=q(X$,W$,r=>{var{typed:e,config:t,numeric:a,larger:n}=r,i=lv({typed:e,config:t,numeric:a,larger:n});return e("max",{"...any":function(f){f=On(f);try{return i.apply(null,f)}catch(l){throw Kr(l)}}})},{isTransformFunction:!0}),Q$="mean",K$=["typed","add","divide"],j$=q(Q$,K$,r=>{var{typed:e,add:t,divide:a}=r,n=Ip({typed:e,add:t,divide:a});return e("mean",{"...any":function(o){o=On(o);try{return n.apply(null,o)}catch(f){throw Kr(f)}}})},{isTransformFunction:!0}),eO="min",rO=["typed","config","numeric","smaller"],tO=q(eO,rO,r=>{var{typed:e,config:t,numeric:a,smaller:n}=r,i=fv({typed:e,config:t,numeric:a,smaller:n});return e("min",{"...any":function(f){f=On(f);try{return i.apply(null,f)}catch(l){throw Kr(l)}}})},{isTransformFunction:!0}),nO="range",aO=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],iO=q(nO,aO,r=>{var{typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:o,larger:f,largerEq:l}=r,u=pm({typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:o,larger:f,largerEq:l});return e("range",{"...any":function(c){var m=c.length-1,v=c[m];return typeof v!="boolean"&&c.push(!0),u.apply(null,c)}})},{isTransformFunction:!0}),oO="row",sO=["typed","Index","matrix","range"],uO=q(oO,sO,r=>{var{typed:e,Index:t,matrix:a,range:n}=r,i=bm({typed:e,Index:t,matrix:a,range:n});return e("row",{"...any":function(f){var l=f.length-1,u=f[l];tr(u)&&(f[l]=u-1);try{return i.apply(null,f)}catch(s){throw Kr(s)}}})},{isTransformFunction:!0}),lO="subset",cO=["typed","matrix"],fO=q(lO,cO,r=>{var{typed:e,matrix:t}=r,a=Dm({typed:e,matrix:t});return e("subset",{"...any":function(i){try{return a.apply(null,i)}catch(o){throw Kr(o)}}})},{isTransformFunction:!0}),mO="concat",vO=["typed","matrix","isInteger"],pO=q(mO,vO,r=>{var{typed:e,matrix:t,isInteger:a}=r,n=Wf({typed:e,matrix:t,isInteger:a});return e("concat",{"...any":function(o){var f=o.length-1,l=o[f];tr(l)?o[f]=l-1:rr(l)&&(o[f]=l.minus(1));try{return n.apply(null,o)}catch(u){throw Kr(u)}}})},{isTransformFunction:!0}),Nh="diff",hO=["typed","matrix","subtract","number","bignumber"],dO=q(Nh,hO,r=>{var{typed:e,matrix:t,subtract:a,number:n,bignumber:i}=r,o=cm({typed:e,matrix:t,subtract:a,number:n,bignumber:i});return e(Nh,{"...any":function(l){l=On(l);try{return o.apply(null,l)}catch(u){throw Kr(u)}}})},{isTransformFunction:!0}),gO="std",yO=["typed","map","sqrt","variance"],bO=q(gO,yO,r=>{var{typed:e,map:t,sqrt:a,variance:n}=r,i=Up({typed:e,map:t,sqrt:a,variance:n});return e("std",{"...any":function(f){f=On(f);try{return i.apply(null,f)}catch(l){throw Kr(l)}}})},{isTransformFunction:!0}),Dh="sum",xO=["typed","config","add","numeric"],wO=q(Dh,xO,r=>{var{typed:e,config:t,add:a,numeric:n}=r,i=Bp({typed:e,config:t,add:a,numeric:n});return e(Dh,{"...any":function(f){f=On(f);try{return i.apply(null,f)}catch(l){throw Kr(l)}}})},{isTransformFunction:!0}),Ah="cumsum",NO=["typed","add","unaryPlus"],DO=q(Ah,NO,r=>{var{typed:e,add:t,unaryPlus:a}=r,n=$p({typed:e,add:t,unaryPlus:a});return e(Ah,{"...any":function(o){if(o.length===2&&Ft(o[0])){var f=o[1];tr(f)?o[1]=f-1:rr(f)&&(o[1]=f.minus(1))}try{return n.apply(null,o)}catch(l){throw Kr(l)}}})},{isTransformFunction:!0}),Eh="variance",AO=["typed","add","subtract","multiply","divide","apply","isNaN"],EO=q(Eh,AO,r=>{var{typed:e,add:t,subtract:a,multiply:n,divide:i,apply:o,isNaN:f}=r,l=zp({typed:e,add:t,subtract:a,multiply:n,divide:i,apply:o,isNaN:f});return e(Eh,{"...any":function(s){s=On(s);try{return l.apply(null,s)}catch(c){throw Kr(c)}}})},{isTransformFunction:!0}),Me=B1({config:ge}),xr=R1({}),Sh=AB({BigNumber:Me,config:ge}),SO=yB({}),CO=jB({BigNumber:Me,config:ge}),In=z1({}),Ch=$B({Complex:xr}),MO=xB({BigNumber:Me,config:ge}),FO=CB({BigNumber:Me,config:ge}),TO=FB({BigNumber:Me,config:ge}),uo=G1({}),BO=wB({BigNumber:Me,config:ge}),$O=bB({}),OO=EB({BigNumber:Me,config:ge}),IO=L1({}),Mh=Rg({}),RO=TB({BigNumber:Me,config:ge}),_O=y$({BigNumber:Me,config:ge}),Fh=DB({BigNumber:Me,config:ge}),qO=gB({}),zO=OB({}),Qe=X1({Matrix:uo}),PO=u$({BigNumber:Me,config:ge}),UO=SB({BigNumber:Me,config:ge}),Th=NB({BigNumber:Me,config:ge}),LO=hB({}),kO=BB({BigNumber:Me,config:ge}),J=Bg({BigNumber:Me,Complex:xr,DenseMatrix:Qe,Fraction:In}),Fs=ib({BigNumber:Me,config:ge,typed:J}),VO=s$({BigNumber:Me,config:ge}),rt=sb({typed:J}),GO=OD({Complex:xr,config:ge,typed:J}),HO=qD({BigNumber:Me,typed:J}),ZO=LD({BigNumber:Me,Complex:xr,config:ge,typed:J}),$r=fb({typed:J}),JO=ew({typed:J}),XO=JD({BigNumber:Me,Complex:xr,config:ge,typed:J}),WO=KD({typed:J}),Bh=rA({typed:J}),YO=iA({Complex:xr,config:ge,typed:J}),Ot=Py({BigNumber:Me,typed:J}),QO=Zx({typed:J}),KO=_y({typed:J}),jO=Y1({typed:J}),lo=oT({typed:J}),co=ky({Complex:xr,typed:J}),Rn=tw({typed:J}),e5=lA({typed:J}),r5=vA({BigNumber:Me,typed:J}),t5=hA({BigNumber:Me,typed:J}),n5=Ab({typed:J}),nr=Ay({config:ge,typed:J}),a5=bN({typed:J}),$h=Sb({typed:J}),i5=Mb({Complex:xr,typed:J}),o5=Dw({typed:J}),s5=Cw({typed:J}),Ya=MN({typed:J}),u5=Tw({typed:J}),l5=IN({format:Ya,typed:J}),Ts=aw({typed:J}),ct=K1({typed:J}),va=ly({typed:J}),fo=hy({typed:J}),Dt=gy({typed:J}),c5=MB({BigNumber:Me,config:ge}),f5=mT({Complex:xr,typed:J}),m5=ix({Complex:xr,config:ge,typed:J}),Oh=sx({Complex:xr,config:ge,typed:J}),pa=_w({typed:J}),Cr=dx({typed:J}),Ih=uw({typed:J}),pn=$y({typed:J}),v5=$N({format:Ya,typed:J}),p5=TT({config:ge,typed:J}),h5=_N({typed:J}),d5=$T({config:ge,typed:J}),Bs=ow({typed:J}),g5=bA({BigNumber:Me,typed:J}),Rh=Nx({BigNumber:Me,Fraction:In,complex:co,typed:J}),$s=DA({typed:J}),Qt=Cy({Matrix:uo,equalScalar:nr,typed:J}),y5=rb({typed:J}),b5=Cx({typed:J}),x5=Iy({typed:J}),w5=CA({typed:J}),_h=wy({typed:J}),N5=RD({Complex:xr,config:ge,typed:J}),D5=VD({BigNumber:Me,typed:J}),Os=df({isInteger:ct,typed:J}),A5=HD({BigNumber:Me,Complex:xr,config:ge,typed:J}),E5=TN({format:Ya,typed:J}),S5=uT({typed:J}),Is=sA({typed:J}),C5=gA({BigNumber:Me,typed:J}),Qa=by({typed:J}),M5=UN({typed:J}),F5=IT({config:ge,typed:J}),T5=wA({BigNumber:Me,typed:J}),B5=EA({typed:J}),$5=FD({SparseMatrix:Qt,typed:J}),It=Ex({Complex:xr,config:ge,typed:J}),O5=TA({typed:J}),Rt=nb({typed:J}),I5=PD({BigNumber:Me,Complex:xr,config:ge,typed:J}),R5=fA({BigNumber:Me,typed:J}),ha=Hy({Fraction:In,typed:J}),_n=fy({typed:J}),Te=Jy({DenseMatrix:Qe,Matrix:uo,SparseMatrix:Qt,typed:J}),_5=Wy({isZero:Dt,matrix:Te,typed:J}),q5=AN({isNaN:Qa,isNumeric:_n,typed:J}),At=VN({bignumber:Ot,fraction:ha,number:pn}),qh=SN({config:ge,multiplyScalar:Cr,numeric:At,typed:J}),z5=Gw({isInteger:ct,matrix:Te,typed:J}),Zr=eN({matrix:Te,config:ge,typed:J}),P5=tN({matrix:Te,typed:J}),it=Dm({matrix:Te,typed:J}),Ka=uN({matrix:Te,typed:J}),zh=Bx({BigNumber:Me,config:ge,matrix:Te,typed:J}),_t=mN({BigNumber:Me,config:ge,matrix:Te,typed:J}),U5=WD({Complex:xr,config:ge,typed:J}),Ph=vb({BigNumber:Me,Complex:xr,Fraction:In,config:ge,isNegative:va,matrix:Te,typed:J,unaryMinus:Rt}),ur=Wf({isInteger:ct,matrix:Te,typed:J}),L5=dw({prod:qh,size:Zr,typed:J}),Rs=cN({conj:Rn,transpose:Ka,typed:J}),Uh=xw({DenseMatrix:Qe,SparseMatrix:Qt,matrix:Te,typed:J}),Dr=HN({numeric:At,typed:J}),ja=i2({DenseMatrix:Qe,concat:ur,divideScalar:Dr,equalScalar:nr,matrix:Te,typed:J}),Et=O2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),ei=Ew({matrix:Te,typed:J}),k5=Qb({BigNumber:Me,DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),V5=vy({isNumeric:_n,typed:J}),hn=$w({BigNumber:Me,DenseMatrix:Qe,SparseMatrix:Qt,config:ge,matrix:Te,typed:J}),G5=Iw({matrix:Te,multiplyScalar:Cr,typed:J}),mo=J2({DenseMatrix:Qe,concat:ur,config:ge,matrix:Te,typed:J}),H5=g2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J,zeros:_t}),_s=jy({flatten:ei,matrix:Te,size:Zr,typed:J}),Lh=vx({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),Z5=xx({BigNumber:Me,concat:ur,equalScalar:nr,matrix:Te,typed:J}),J5=Lw({BigNumber:Me,config:ge,matrix:Te,typed:J}),X5=Jw({config:ge,matrix:Te}),W5=b2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J,zeros:_t}),vo=WN({BigNumber:Me,DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J,zeros:_t}),ft=z2({DenseMatrix:Qe,concat:ur,config:ge,matrix:Te,typed:J}),Y5=zN({concat:ur,matrix:Te,typed:J}),Q5=K2({DenseMatrix:Qe,concat:ur,config:ge,equalScalar:nr,matrix:Te,typed:J}),K5=mw({DenseMatrix:Qe,concat:ur,matrix:Te,typed:J}),wr=KA({DenseMatrix:Qe,SparseMatrix:Qt,addScalar:$r,concat:ur,equalScalar:nr,matrix:Te,typed:J}),j5=Gx({concat:ur,equalScalar:nr,matrix:Te,typed:J}),e8=Kx({DenseMatrix:Qe,concat:ur,matrix:Te,typed:J}),r8=UT({addScalar:$r,combinations:lo,divideScalar:Dr,isInteger:ct,isNegative:va,multiplyScalar:Cr,typed:J}),da=E2({BigNumber:Me,DenseMatrix:Qe,Fraction:In,concat:ur,config:ge,equalScalar:nr,matrix:Te,typed:J}),kh=B2({concat:ur,matrix:Te,typed:J}),t8=$p({add:wr,typed:J,unaryPlus:Fs}),Vh=Y2({equal:Et,typed:J}),po=aE({addScalar:$r,conj:Rn,multiplyScalar:Cr,size:Zr,typed:J}),n8=_2({compareText:kh,isZero:Dt,typed:J}),Gh=Ib({DenseMatrix:Qe,config:ge,equalScalar:nr,matrix:Te,round:vo,typed:J,zeros:_t}),a8=eE({abs:rt,addScalar:$r,divideScalar:Dr,isPositive:fo,multiplyScalar:Cr,smaller:ft,sqrt:It,typed:J}),Hh=uD({DenseMatrix:Qe,smaller:ft}),Jr=fD({ImmutableDenseMatrix:Hh}),i8=Ox({BigNumber:Me,add:wr,config:ge,equal:Et,isInteger:ct,mod:Lh,smaller:ft,typed:J,xgcd:zh}),mt=G2({DenseMatrix:Qe,concat:ur,config:ge,matrix:Te,typed:J}),qs=QN({Complex:xr,config:ge,divideScalar:Dr,typed:J}),o8=Qy({flatten:ei,matrix:Te,size:Zr,typed:J}),s8=fv({config:ge,numeric:At,smaller:ft,typed:J}),Nr=yx({addScalar:$r,dot:po,equalScalar:nr,matrix:Te,multiplyScalar:Cr,typed:J}),u8=r2({Complex:xr,config:ge,divideScalar:Dr,typed:J}),l8=cw({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),zs=rD({compare:da,isNaN:Qa,isNumeric:_n,typed:J}),c8=nT({add:wr,compare:da,multiply:Nr,partitionSelect:zs,typed:J}),f8=w2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J,zeros:_t}),Ps=L2({DenseMatrix:Qe,concat:ur,config:ge,matrix:Te,typed:J}),yr=Fx({DenseMatrix:Qe,addScalar:$r,concat:ur,equalScalar:nr,matrix:Te,typed:J,unaryMinus:Rt}),m8=sE({add:wr,matrix:Te,typed:J}),Us=l2({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J}),v8=D2({concat:ur,equalScalar:nr,matrix:Te,not:Ih,typed:J,zeros:_t}),p8=Xx({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),Ls=Nb({DenseMatrix:Qe,config:ge,equalScalar:nr,matrix:Te,round:vo,typed:J,zeros:_t}),qt=M2({compare:da,typed:J}),h8=kT({addScalar:$r,combinations:lo,isInteger:ct,isNegative:va,isPositive:fo,larger:mt,typed:J}),d8=yw({matrix:Te,multiply:Nr,subtract:yr,typed:J}),Zh=b4({divideScalar:Dr,isZero:Dt,matrix:Te,multiply:Nr,subtract:yr,typed:J,unaryMinus:Rt}),g8=cm({matrix:Te,number:pn,subtract:yr,typed:J}),y8=V4({abs:rt,addScalar:$r,divideScalar:Dr,multiplyScalar:Cr,sqrt:It,subtract:yr,typed:J,unaryMinus:Rt}),b8=qx({concat:ur,equalScalar:nr,matrix:Te,multiplyScalar:Cr,typed:J}),Jh=pD({larger:mt,smaller:ft}),Xh=Bb({Complex:xr,DenseMatrix:Qe,ceil:Ls,equalScalar:nr,floor:Gh,matrix:Te,typed:J,zeros:_t}),Wh=lE({Index:Jr,typed:J}),x8=Z4({abs:rt,add:wr,addScalar:$r,config:ge,divideScalar:Dr,equalScalar:nr,flatten:ei,isNumeric:_n,isZero:Dt,matrix:Te,multiply:Nr,multiplyScalar:Cr,smaller:ft,subtract:yr,typed:J}),w8=nx({concat:ur,equalScalar:nr,matrix:Te,typed:J}),N8=jN({Complex:xr,config:ge,divideScalar:Dr,log:qs,typed:J}),Yh=s2({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J}),Qh=lv({config:ge,larger:mt,numeric:At,typed:J}),ks=mS({addScalar:$r,complex:co,conj:Rn,divideScalar:Dr,equal:Et,identity:hn,isZero:Dt,matrix:Te,multiplyScalar:Cr,sign:Rh,sqrt:It,subtract:yr,typed:J,unaryMinus:Rt,zeros:_t}),ga=pm({bignumber:Ot,matrix:Te,config:ge,larger:mt,largerEq:mo,smaller:ft,smallerEq:Ps,typed:J}),D8=bm({Index:Jr,matrix:Te,range:ga,typed:J}),A8=$A({DenseMatrix:Qe,Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),E8=_A({DenseMatrix:Qe,Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),S8=UA({Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),C8=GA({Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),Kh=_S({SparseMatrix:Qt,abs:rt,add:wr,divideScalar:Dr,larger:mt,largerEq:mo,multiply:Nr,subtract:yr,transpose:Ka,typed:J}),jh=gD({FibonacciHeap:Jh,addScalar:$r,equalScalar:nr}),ed=Bp({add:wr,config:ge,numeric:At,typed:J}),rd=v2({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J}),M8=nA({BigNumber:Me,DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,typed:J}),td=Kf({Index:Jr,matrix:Te,range:ga,typed:J}),F8=f2({DenseMatrix:Qe,divideScalar:Dr,equalScalar:nr,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J}),nd=IA({DenseMatrix:Qe,Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),T8=kA({Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),ad=XA({Index:Jr,concat:ur,setDifference:nd,size:Zr,subset:it,typed:J}),B8=nD({compare:da,compareNatural:qt,matrix:Te,typed:J}),qn=w4({abs:rt,addScalar:$r,det:Zh,divideScalar:Dr,identity:hn,matrix:Te,multiply:Nr,typed:J,unaryMinus:Rt}),id=cS({DenseMatrix:Qe,Spa:jh,SparseMatrix:Qt,abs:rt,addScalar:$r,divideScalar:Dr,equalScalar:nr,larger:mt,matrix:Te,multiplyScalar:Cr,subtract:yr,typed:J,unaryMinus:Rt}),$8=D4({Complex:xr,add:wr,ctranspose:Rs,deepEqual:Vh,divideScalar:Dr,dot:po,dotDivide:ja,equal:Et,inv:qn,matrix:Te,multiply:Nr,typed:J}),zt=JN({Complex:xr,config:ge,fraction:ha,identity:hn,inv:qn,matrix:Te,multiply:Nr,number:pn,typed:J}),od=zA({DenseMatrix:Qe,Index:Jr,compareNatural:qt,size:Zr,subset:it,typed:J}),O8=YA({Index:Jr,concat:ur,setIntersect:od,setSymDifference:ad,size:Zr,subset:it,typed:J}),I8=$4({abs:rt,add:wr,identity:hn,inv:qn,map:pa,max:Qh,multiply:Nr,size:Zr,sqrt:It,subtract:yr,typed:J}),Ze=ED({BigNumber:Me,Complex:xr,Fraction:In,abs:rt,addScalar:$r,config:ge,divideScalar:Dr,equal:Et,fix:Xh,format:Ya,isNumeric:_n,multiplyScalar:Cr,number:pn,pow:zt,round:vo,subtract:yr}),R8=UB({BigNumber:Me,Unit:Ze,config:ge}),_8=w$({BigNumber:Me,Unit:Ze,config:ge}),q8=l$({BigNumber:Me,Unit:Ze,config:ge}),z8=VB({BigNumber:Me,Unit:Ze,config:ge}),P8=f$({BigNumber:Me,Unit:Ze,config:ge}),U8=GB({BigNumber:Me,Unit:Ze,config:ge}),L8=BD({Unit:Ze,typed:J}),k8=t$({BigNumber:Me,Unit:Ze,config:ge}),V8=n2({DenseMatrix:Qe,concat:ur,equalScalar:nr,matrix:Te,pow:zt,typed:J}),G8=PB({BigNumber:Me,Unit:Ze,config:ge}),H8=kB({BigNumber:Me,Unit:Ze,config:ge}),Z8=T4({abs:rt,add:wr,identity:hn,inv:qn,multiply:Nr,typed:J}),J8=m$({BigNumber:Me,Unit:Ze,config:ge}),sd=pN({addScalar:$r,ceil:Ls,conj:Rn,divideScalar:Dr,dotDivide:ja,exp:$h,i:Ch,log2:Oh,matrix:Te,multiplyScalar:Cr,pow:zt,tau:Fh,typed:J}),ud=cT({BigNumber:Me,Complex:xr,config:ge,multiplyScalar:Cr,pow:zt,typed:J}),X8=RB({BigNumber:Me,Unit:Ze,config:ge}),W8=e$({BigNumber:Me,Unit:Ze,config:ge}),Y8=dN({conj:Rn,dotDivide:ja,fft:sd,typed:J}),Q8=XB({BigNumber:Me,Unit:Ze,config:ge}),K8=p$({BigNumber:Me,Unit:Ze,config:ge}),j8=zB({BigNumber:Me,Unit:Ze,config:ge}),e6=N$({BigNumber:Me,Unit:Ze,config:ge}),r6=d$({BigNumber:Me,Unit:Ze,config:ge}),t6=n$({BigNumber:Me,Unit:Ze,config:ge}),n6=JB({BigNumber:Me,Unit:Ze,config:ge}),a6=M$({BigNumber:Me,Unit:Ze,config:ge}),i6=E$({BigNumber:Me,Unit:Ze,config:ge}),o6=F$({BigNumber:Me,Unit:Ze,config:ge}),s6=r$({BigNumber:Me,Unit:Ze,config:ge}),u6=qB({BigNumber:Me,Unit:Ze,config:ge}),l6=i$({BigNumber:Me,Unit:Ze,config:ge}),c6=b$({BigNumber:Me,Unit:Ze,config:ge}),f6=IB({BigNumber:Me,Unit:Ze,config:ge}),m6=x$({BigNumber:Me,Unit:Ze,config:ge}),v6=o$({BigNumber:Me,Unit:Ze,config:ge}),p6=c$({BigNumber:Me,Unit:Ze,config:ge}),h6=WB({BigNumber:Me,Unit:Ze,config:ge}),d6=LB({BigNumber:Me,Unit:Ze,config:ge}),vt=L4({divideScalar:Dr,equalScalar:nr,inv:qn,matrix:Te,multiply:Nr,typed:J}),g6=QB({BigNumber:Me,Unit:Ze,config:ge}),ho=pT({gamma:ud,typed:J}),y6=v$({BigNumber:Me,Unit:Ze,config:ge}),b6=h$({BigNumber:Me,Unit:Ze,config:ge}),x6=HB({BigNumber:Me,Unit:Ze,config:ge}),ld=zS({DenseMatrix:Qe,lsolve:Yh,lup:id,matrix:Te,slu:Kh,typed:J,usolve:Us}),w6=ZB({BigNumber:Me,Unit:Ze,config:ge}),N6=D$({BigNumber:Me,Unit:Ze,config:ge}),D6=yT({add:wr,divide:vt,factorial:ho,isInteger:ct,isPositive:fo,multiply:Nr,typed:J}),A6=xT({factorial:ho,typed:J}),E6=S$({BigNumber:Me,Unit:Ze,config:ge}),S6=US({add:wr,cbrt:Ph,divide:vt,equalScalar:nr,im:Ts,isZero:Dt,multiply:Nr,re:Bs,sqrt:It,subtract:yr,typeOf:_h,typed:J,unaryMinus:Rt}),C6=ZA({compareNatural:qt,typed:J}),cd=_T({bignumber:Ot,addScalar:$r,combinations:lo,divideScalar:Dr,factorial:ho,isInteger:ct,isNegative:va,larger:mt,multiplyScalar:Cr,number:pn,pow:zt,subtract:yr,typed:J}),M6=CD({Unit:Ze,typed:J}),F6=zT({addScalar:$r,isInteger:ct,isNegative:va,stirlingS2:cd,typed:J}),fd=M4({abs:rt,add:wr,addScalar:$r,atan:Bh,bignumber:Ot,column:td,complex:co,config:ge,cos:Is,diag:Uh,divideScalar:Dr,dot:po,equal:Et,flatten:ei,im:Ts,inv:qn,larger:mt,matrix:Te,matrixFromColumns:_s,multiply:Nr,multiplyScalar:Cr,number:pn,qr:ks,re:Bs,sin:$s,smaller:ft,sqrt:It,subtract:yr,typed:J,usolve:Us,usolveAll:rd}),T6=KB({BigNumber:Me,Unit:Ze,config:ge}),B6=A$({BigNumber:Me,Unit:Ze,config:ge}),$6=dT({divide:vt,dotDivide:ja,isNumeric:_n,log:qs,map:pa,matrix:Te,multiply:Nr,sum:ed,typed:J}),O6=Ip({add:wr,divide:vt,typed:J}),I6=g$({BigNumber:Me,Unit:Ze,config:ge}),R6=_B({BigNumber:Me,Unit:Ze,config:ge}),_6=a$({BigNumber:Me,Unit:Ze,config:ge}),Vs=zp({add:wr,apply:Os,divide:vt,isNaN:Qa,multiply:Nr,subtract:yr,typed:J}),q6=YB({BigNumber:Me,Unit:Ze,config:ge}),md=Q4({add:wr,compare:da,divide:vt,partitionSelect:zs,typed:J}),z6=C$({BigNumber:Me,Unit:Ze,config:ge}),P6=Up({map:pa,sqrt:It,typed:J,variance:Vs}),U6=j4({abs:rt,map:pa,median:md,subtract:yr,typed:J}),Gs=tE({abs:rt,add:wr,conj:Rn,ctranspose:Rs,eigs:fd,equalScalar:nr,larger:mt,matrix:Te,multiply:Nr,pow:zt,smaller:ft,sqrt:It,typed:J}),vd=Qw({BigNumber:Me,DenseMatrix:Qe,SparseMatrix:Qt,addScalar:$r,config:ge,cos:Is,matrix:Te,multiplyScalar:Cr,norm:Gs,sin:$s,typed:J,unaryMinus:Rt}),L6=Ww({multiply:Nr,rotationMatrix:vd,typed:J}),pd=_4({identity:hn,matrix:Te,multiply:Nr,norm:Gs,qr:ks,subtract:yr,typed:J}),hd=I4({abs:rt,add:wr,concat:ur,identity:hn,index:Wh,lusolve:ld,matrix:Te,matrixFromColumns:_s,multiply:Nr,range:ga,schur:pd,subset:it,subtract:yr,transpose:Ka,typed:J}),k6=z4({matrix:Te,multiply:Nr,sylvester:hd,transpose:Ka,typed:J}),ya={},ba={},dd={},Xr=mE({mathWithTransform:ba}),xa=zE({Node:Xr}),Kt=UE({Node:Xr}),zn=kE({Node:Xr}),gd=ZE({Node:Xr}),wa=dE({Node:Xr}),yd=NE({Node:Xr,ResultSet:Mh}),bd=AE({Node:Xr}),dn=$E({Node:Xr}),xd=GE({Node:Xr}),V6=mB({classes:dd}),Hs=ZS({math:ya,typed:J}),wd=IE({Node:Xr,typed:J}),G6=g4({Chain:Hs,typed:J}),Na=pE({Node:Xr,subset:it}),Da=_E({Node:Xr,size:Zr}),Nd=xE({matrix:Te,Node:Xr,subset:it}),gn=WE({Unit:Ze,Node:Xr,math:ya}),yn=QE({Node:Xr,SymbolNode:gn,math:ya}),St=jE({AccessorNode:Na,ArrayNode:wa,AssignmentNode:Nd,BlockNode:yd,ConditionalNode:bd,ConstantNode:dn,FunctionAssignmentNode:wd,FunctionNode:yn,IndexNode:Da,ObjectNode:xa,OperatorNode:Kt,ParenthesisNode:zn,RangeNode:xd,RelationalNode:gd,SymbolNode:gn,config:ge,numeric:At,typed:J}),Dd=nB({ConstantNode:dn,FunctionNode:yn,OperatorNode:Kt,ParenthesisNode:zn,parse:St,typed:J}),Zs=KT({bignumber:Ot,fraction:ha,AccessorNode:Na,ArrayNode:wa,ConstantNode:dn,FunctionNode:yn,IndexNode:Da,ObjectNode:xa,OperatorNode:Kt,SymbolNode:gn,config:ge,mathWithTransform:ba,matrix:Te,typed:J}),H6=rS({parse:St,typed:J}),Js=nS({parse:St,typed:J}),Ad=VS({parse:St}),Ed=oS({evaluate:Js}),Xs=eB({AccessorNode:Na,ArrayNode:wa,ConstantNode:dn,FunctionNode:yn,IndexNode:Da,ObjectNode:xa,OperatorNode:Kt,ParenthesisNode:zn,SymbolNode:gn,add:wr,divide:vt,equal:Et,isZero:Dt,multiply:Nr,parse:St,pow:zt,subtract:yr,typed:J}),Z6=h4({Help:Ad,mathWithTransform:ba,typed:J}),go=WT({bignumber:Ot,fraction:ha,AccessorNode:Na,ArrayNode:wa,ConstantNode:dn,FunctionNode:yn,IndexNode:Da,ObjectNode:xa,OperatorNode:Kt,ParenthesisNode:zn,SymbolNode:gn,add:wr,config:ge,divide:vt,equal:Et,isZero:Dt,mathWithTransform:ba,matrix:Te,multiply:Nr,parse:St,pow:zt,resolve:Dd,simplifyConstant:Zs,simplifyCore:Xs,subtract:yr,typed:J}),J6=iB({OperatorNode:Kt,parse:St,simplify:go,typed:J}),X6=sB({ConstantNode:dn,FunctionNode:yn,OperatorNode:Kt,ParenthesisNode:zn,SymbolNode:gn,config:ge,equal:Et,isZero:Dt,numeric:At,parse:St,simplify:go,typed:J}),W6=uS({Parser:Ed,typed:J}),Y6=GT({parse:St,typed:J}),Q6=lB({bignumber:Ot,fraction:ha,AccessorNode:Na,ArrayNode:wa,ConstantNode:dn,FunctionNode:yn,IndexNode:Da,ObjectNode:xa,OperatorNode:Kt,ParenthesisNode:zn,SymbolNode:gn,add:wr,config:ge,divide:vt,equal:Et,isZero:Dt,mathWithTransform:ba,matrix:Te,multiply:Nr,parse:St,pow:zt,simplify:go,simplifyConstant:Zs,simplifyCore:Xs,subtract:yr,typed:J});Sr(ya,{e:Sh,false:SO,fineStructure:CO,i:Ch,Infinity:MO,LN10:FO,LOG10E:TO,NaN:BO,null:$O,phi:OO,SQRT1_2:RO,sackurTetrode:_O,tau:Fh,true:qO,E:Sh,version:zO,efimovFactor:PO,LN2:UO,pi:Th,replacer:LO,reviver:V6,SQRT2:kO,typed:J,unaryPlus:Fs,PI:Th,weakMixingAngle:VO,abs:rt,acos:GO,acot:HO,acsc:ZO,addScalar:$r,arg:JO,asech:XO,asinh:WO,atan:Bh,atanh:YO,bignumber:Ot,bitNot:QO,boolean:KO,clone:jO,combinations:lo,complex:co,conj:Rn,cosh:e5,coth:r5,csc:t5,cube:n5,equalScalar:nr,erf:a5,exp:$h,expm1:i5,filter:o5,forEach:s5,format:Ya,getMatrixDataType:u5,hex:l5,im:Ts,isInteger:ct,isNegative:va,isPositive:fo,isZero:Dt,LOG2E:c5,lgamma:f5,log10:m5,log2:Oh,map:pa,multiplyScalar:Cr,not:Ih,number:pn,oct:v5,pickRandom:p5,print:h5,random:d5,re:Bs,sec:g5,sign:Rh,sin:$s,splitUnit:y5,square:b5,string:x5,tan:w5,typeOf:_h,acosh:N5,acsch:D5,apply:Os,asec:A5,bin:E5,chain:G6,combinationsWithRep:S5,cos:Is,csch:C5,isNaN:Qa,isPrime:M5,randomInt:F5,sech:T5,sinh:B5,sparse:$5,sqrt:It,tanh:O5,unaryMinus:Rt,acoth:I5,cot:R5,fraction:ha,isNumeric:_n,matrix:Te,matrixFromFunction:_5,mode:q5,numeric:At,prod:qh,reshape:z5,size:Zr,squeeze:P5,subset:it,transpose:Ka,xgcd:zh,zeros:_t,asin:U5,cbrt:Ph,concat:ur,count:L5,ctranspose:Rs,diag:Uh,divideScalar:Dr,dotDivide:ja,equal:Et,flatten:ei,gcd:k5,hasNumericValue:V5,identity:hn,kron:G5,largerEq:mo,leftShift:H5,matrixFromColumns:_s,mod:Lh,nthRoot:Z5,ones:J5,resize:X5,rightArithShift:W5,round:vo,smaller:ft,to:Y5,unequal:Q5,xor:K5,add:wr,bitAnd:j5,bitXor:e8,catalan:r8,compare:da,compareText:kh,cumsum:t8,deepEqual:Vh,dot:po,equalText:n8,floor:Gh,hypot:a8,invmod:i8,larger:mt,log:qs,matrixFromRows:o8,min:s8,multiply:Nr,nthRoots:u8,or:l8,partitionSelect:zs,quantileSeq:c8,rightLogShift:f8,smallerEq:Ps,subtract:yr,trace:m8,usolve:Us,and:v8,bitOr:p8,ceil:Ls,compareNatural:qt,composition:h8,cross:d8,det:Zh,diff:g8,distance:y8,dotMultiply:b8,fix:Xh,index:Wh,intersect:x8,lcm:w8,log1p:N8,lsolve:Yh,max:Qh,qr:ks,range:ga,row:D8,setCartesian:A8,setDistinct:E8,setIsSubset:S8,setPowerset:C8,slu:Kh,sum:ed,usolveAll:rd,atan2:M8,column:td,lsolveAll:F8,setDifference:nd,setMultiplicity:T8,setSymDifference:ad,sort:B8,inv:qn,lup:id,pinv:$8,pow:zt,setIntersect:od,setUnion:O8,sqrtm:I8,vacuumImpedance:R8,wienDisplacement:_8,atomicMass:q8,bohrMagneton:z8,boltzmann:P8,conductanceQuantum:U8,createUnit:L8,deuteronMass:k8,dotPow:V8,electricConstant:G8,elementaryCharge:H8,expm:Z8,faraday:J8,fft:sd,gamma:ud,gravitationConstant:X8,hartreeEnergy:W8,ifft:Y8,klitzing:Q8,loschmidt:K8,magneticConstant:j8,molarMass:e6,molarPlanckConstant:r6,neutronMass:t6,nuclearMagneton:n6,planckCharge:a6,planckLength:i6,planckTemperature:o6,protonMass:s6,reducedPlanckConstant:u6,rydberg:l6,secondRadiation:c6,speedOfLight:f6,stefanBoltzmann:m6,thomsonCrossSection:v6,avogadro:p6,bohrRadius:h6,coulomb:d6,divide:vt,electronMass:g6,factorial:ho,firstRadiation:y6,gasConstant:b6,inverseConductanceQuantum:x6,lusolve:ld,magneticFluxQuantum:w6,molarMassC12:N6,multinomial:D6,permutations:A6,planckMass:E6,polynomialRoot:S6,setSize:C6,stirlingS2:cd,unit:M6,bellNumbers:F6,eigs:fd,fermiCoupling:T6,gravity:B6,kldivergence:$6,mean:O6,molarVolume:I6,planckConstant:R6,quantumOfCirculation:_6,variance:Vs,classicalElectronRadius:q6,median:md,parse:St,planckTime:z6,resolve:Dd,simplifyConstant:Zs,std:P6,compile:H6,evaluate:Js,mad:U6,simplifyCore:Xs,help:Z6,norm:Gs,rotationMatrix:vd,simplify:go,symbolicEqual:J6,derivative:X6,parser:W6,rotate:L6,leafCount:Y6,rationalize:Q6,schur:pd,sylvester:hd,lyap:k6,config:ge}),Sr(ba,ya,{filter:z$({typed:J}),forEach:L$({typed:J}),map:J$({typed:J}),apply:$$({isInteger:ct,typed:J}),subset:fO({matrix:Te,typed:J}),concat:pO({isInteger:ct,matrix:Te,typed:J}),max:Y$({config:ge,larger:mt,numeric:At,typed:J}),sum:wO({add:wr,config:ge,numeric:At,typed:J}),min:tO({config:ge,numeric:At,smaller:ft,typed:J}),cumsum:DO({add:wr,typed:J,unaryPlus:Fs}),diff:dO({bignumber:Ot,matrix:Te,number:pn,subtract:yr,typed:J}),index:G$({Index:Jr}),range:iO({bignumber:Ot,matrix:Te,config:ge,larger:mt,largerEq:mo,smaller:ft,smallerEq:Ps,typed:J}),row:uO({Index:Jr,matrix:Te,range:ga,typed:J}),column:R$({Index:Jr,matrix:Te,range:ga,typed:J}),mean:j$({add:wr,divide:vt,typed:J}),variance:EO({add:wr,apply:Os,divide:vt,isNaN:Qa,multiply:Nr,subtract:yr,typed:J}),std:bO({map:pa,sqrt:It,typed:J,variance:Vs})}),Sr(dd,{BigNumber:Me,Complex:xr,Fraction:In,Matrix:uo,Node:Xr,ObjectNode:xa,OperatorNode:Kt,ParenthesisNode:zn,Range:IO,RelationalNode:gd,ResultSet:Mh,ArrayNode:wa,BlockNode:yd,ConditionalNode:bd,ConstantNode:dn,DenseMatrix:Qe,RangeNode:xd,Chain:Hs,FunctionAssignmentNode:wd,SparseMatrix:Qt,AccessorNode:Na,IndexNode:Da,AssignmentNode:Nd,ImmutableDenseMatrix:Hh,Index:Jr,FibonacciHeap:Jh,Spa:jh,Unit:Ze,SymbolNode:gn,FunctionNode:yn,Help:Ad,Parser:Ed}),Hs.createProxy(ya);/**
72
72
  * @dice-roller/rpg-dice-roller - An advanced JS based dice roller that can roll various types of dice and modifiers, along with mathematical equations.
73
73
  *
74
- * @version 5.2.0
74
+ * @version 5.5.0
75
75
  * @license MIT
76
- * @author GreenImp Media <info@greenimp.co.uk> (http://greenimp.co.uk)
76
+ * @author GreenImp Media <info@greenimp.co.uk> (https://greenimp.co.uk)
77
77
  * @link https://dice-roller.github.io/documentation
78
- */class Ls extends TypeError{constructor(e){super(`Operator "${e}" is invalid`),TypeError.captureStackTrace&&TypeError.captureStackTrace(this,Ls),this.name="CompareOperatorError",this.operator=e}}class Us extends Error{constructor(e){super(`Invalid data format: ${e}`),Error.captureStackTrace&&Error.captureStackTrace(this,Us),this.name="ImportError",this.data=e}}class mo 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,mo),this.name="DieActionValueError",this.action=t,this.die=e}}class vo extends Error{constructor(e){super(`Notation "${e}" is invalid`),Error.captureStackTrace&&Error.captureStackTrace(this,vo),this.name="NotationError",this.notation=e}}class Ot extends Error{constructor(e=null){super(`Missing argument${e?` "${e}"`:""}`),Error.captureStackTrace&&Error.captureStackTrace(this,Ot),this.argumentName=e}}const f6=(r,e,t)=>{const a=Number(r),n=Number(e);let i;if(Number.isNaN(a)||Number.isNaN(n))return!1;switch(t){case"=":case"==":i=a===n;break;case"<":i=a<n;break;case">":i=a>n;break;case"<=":i=a<=n;break;case">=":i=a>=n;break;case"!":case"!=":case"<>":i=a!==n;break;default:i=!1;break}return i},sd=r=>Ps(r),Cr=r=>typeof r!="number"&&typeof r!="string"?!1:!Number.isNaN(r)&&Number.isFinite(Number(r)),ks=r=>{if(!Cr(r))return!1;const e=Number(r);return e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER},m6=r=>Array.isArray(r)?r.reduce((e,t)=>e+(Cr(t)?parseFloat(`${t}`):0),0):0,v6=(r,e=0)=>parseFloat(parseFloat(`${r}`).toFixed(e||0)),$r=9007199254740992,Xa=$r-1,po=-1>>>0,mt=po+1,Kt=mt/2,Vs=Kt-1,Ya=1<<21,In=Ya-1;function Gs(r){return r.next()|0}function dn(r,e){return e===0?r:t=>r(t)+e}function Hs(r){const e=r.next()|0,t=r.next()>>>0;return(e&In)*mt+t+(e&Ya?-$r:0)}function ud(r){for(;;){const e=r.next()|0;if(e&4194304){if((e&8388607)===4194304&&(r.next()|0)===0)return $r}else{const t=r.next()>>>0;return(e&In)*mt+t+(e&Ya?-$r:0)}}}function ld(r){return r.next()>>>0}function ho(r){const e=r.next()&In,t=r.next()>>>0;return e*mt+t}function Zs(r){for(;;){const e=r.next()|0;if(e&Ya){if((e&In)===0&&(r.next()|0)===0)return $r}else{const t=r.next()>>>0;return(e&In)*mt+t}}}function cd(r){return(r+1&r)===0}function p6(r){return e=>e.next()&r}function h6(r){const e=r+1,t=e*Math.floor(mt/e);return a=>{let n=0;do n=a.next()>>>0;while(n>=t);return n%e}}function d6(r){return cd(r)?p6(r):h6(r)}function g6(r){return(r|0)===0}function y6(r){return e=>{const t=e.next()&r,a=e.next()>>>0;return t*mt+a}}function b6(r){const e=r*Math.floor($r/r);return t=>{let a=0;do{const n=t.next()&In,i=t.next()>>>0;a=n*mt+i}while(a>=e);return a%r}}function x6(r){const e=r+1;if(g6(e)){const t=(e/mt|0)-1;if(cd(t))return y6(t)}return b6(e)}function fd(r,e){return t=>{let a=0;do{const n=t.next()|0,i=t.next()>>>0;a=(n&In)*mt+i+(n&Ya?-$r:0)}while(a<r||a>e);return a}}function Rn(r,e){if(r=Math.floor(r),e=Math.floor(e),r<-$r||!isFinite(r))throw new RangeError(`Expected min to be at least ${-$r}`);if(e>$r||!isFinite(e))throw new RangeError(`Expected max to be at most ${$r}`);const t=e-r;return t<=0||!isFinite(t)?()=>r:t===po?r===0?ld:dn(Gs,r+Kt):t<po?dn(d6(t),r):t===Xa?dn(ho,r):t<Xa?dn(x6(t),r):e-1-r===Xa?dn(Zs,r):r===-$r&&e===$r?ud:r===-$r&&e===Xa?Hs:r===-Xa&&e===$r?dn(Hs,1):e===$r?dn(fd(r-1,e-1),1):fd(r,e)}function w6(r){return(r.next()&1)===1}function Js(r,e){return t=>r(t)<e}function N6(r){if(r<=0)return()=>!1;if(r>=1)return()=>!0;{const e=r*mt;return e%1===0?Js(Gs,e-Kt|0):Js(ho,Math.round(r*$r))}}function D6(r,e){return e==null?r==null?w6:N6(r):r<=0?()=>!1:r>=e?()=>!0:Js(Rn(0,e-1),r)}function A6(r,e){const t=Rn(+r,+e);return a=>new Date(t(a))}function md(r){return Rn(1,r)}function E6(r,e){const t=md(r);return a=>{const n=[];for(let i=0;i<e;++i)n.push(t(a));return n}}const S6="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-";function Ws(r=S6){const e=r.length;if(!e)throw new Error("Expected pool not to be an empty string");const t=Rn(0,e-1);return(a,n)=>{let i="";for(let s=0;s<n;++s){const f=t(a);i+=r.charAt(f)}return i}}const vd="0123456789abcdef",C6=Ws(vd),M6=Ws(vd.toUpperCase());function F6(r){return r?M6:C6}function pd(r,e){return r<0?Math.max(r+e,0):Math.min(r,e)}function hd(r){const e=+r;return e<0?Math.ceil(e):Math.floor(e)}function T6(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:pd(hd(t),n),s=a===void 0?n:pd(hd(a),n);if(i>=s)throw new RangeError(`Cannot pick between bounds ${i} and ${s}`);const f=Rn(i,s-1);return e[f(r)]}function B6(r,e){return e===1?r:e===0?()=>0:t=>r(t)*e}function dd(r){return ho(r)/$r}function gd(r){return Zs(r)/$r}function $6(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(B6(t?gd:dd,e-r),r)}const O6=Array.prototype.slice;function Xs(r,e,t=0){const a=e.length;if(a)for(let n=a-1>>>0;n>t;--n){const s=Rn(0,n)(r);if(n!==s){const f=e[n];e[n]=e[s],e[s]=f}}return e}function _6(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=O6.call(e),n=a.length;if(n===t)return Xs(r,a,0);const i=n-t;return Xs(r,a,i-1).slice(i)}const I6=(()=>{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 ba(r,e){return I6("0",e-r.length)+r}function R6(r){const e=r.next()>>>0,t=r.next()|0,a=r.next()|0,n=r.next()>>>0;return ba(e.toString(16),8)+"-"+ba((t&65535).toString(16),4)+"-"+ba((t>>4&4095|16384).toString(16),4)+"-"+ba((a&16383|32768).toString(16),4)+"-"+ba((a>>4&65535).toString(16),4)+ba(n.toString(16),8)}const xa={next(){return Math.random()*mt|0}};class q6{constructor(e=xa){this.engine=e}int32(){return Gs(this.engine)}uint32(){return ld(this.engine)}uint53(){return ho(this.engine)}uint53Full(){return Zs(this.engine)}int53(){return Hs(this.engine)}int53Full(){return ud(this.engine)}integer(e,t){return Rn(e,t)(this.engine)}realZeroToOneInclusive(){return gd(this.engine)}realZeroToOneExclusive(){return dd(this.engine)}real(e,t,a=!1){return $6(e,t,a)(this.engine)}bool(e,t){return D6(e,t)(this.engine)}pick(e,t,a){return T6(this.engine,e,t,a)}shuffle(e){return Xs(this.engine,e)}sample(e,t){return _6(this.engine,e,t)}die(e){return md(e)(this.engine)}dice(e,t){return E6(e,t)(this.engine)}uuid4(){return R6(this.engine)}string(e,t){return Ws(t)(this.engine,e)}hex(e,t){return F6(t)(this.engine,e)}date(e,t){return A6(e,t)(this.engine)}}const yd=(()=>{try{const r=new ArrayBuffer(4),e=new Int32Array(r);if(e[0]=Kt,e[0]===-Kt)return Int32Array}catch{}return Array})();let go=null;const Ys=128;let Qs=Ys;const z6={next(){return Qs>=Ys&&(go===null&&(go=new yd(Ys)),crypto.getRandomValues(go),Qs=0),go[Qs++]|0}};function P6(r=xa,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 Ks=(()=>{try{if(Math.imul(po,5)===-5)return Math.imul}catch{}const r=65535;return(e,t)=>{const a=e>>>16&r,n=e&r,i=t>>>16&r,s=t&r;return n*s+(a*s+n*i<<16>>>0)|0}})(),_t=624,gn=_t-1,js=397,bd=_t-js,eu=2567483615;class Qa{constructor(){this.data=new yd(_t),this.index=0,this.uses=0}static seed(e){return new Qa().seed(e)}static seedWithArray(e){return new Qa().seedWithArray(e)}static autoSeed(){return Qa.seedWithArray(P6())}next(){(this.index|0)>=_t&&(ru(this.data),this.index=0);const e=this.data[this.index];return this.index=this.index+1|0,this.uses+=1,L6(e)|0}getUseCount(){return this.uses}discard(e){if(e<=0)return this;for(this.uses+=e,(this.index|0)>=_t&&(ru(this.data),this.index=0);e+this.index>_t;)e-=_t-this.index,ru(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<_t;a=a+1|0)this.data[a]=t=Ks(t^t>>>30,1812433253)+a|0;return this.index=_t,this.uses=0,this}seedWithArray(e){return this.seed(19650218),U6(this.data,e),this}}function ru(r){let e=0,t=0;for(;(e|0)<bd;e=e+1|0)t=r[e]&Kt|r[e+1|0]&Vs,r[e]=r[e+js|0]^t>>>1^(t&1?eu:0);for(;(e|0)<gn;e=e+1|0)t=r[e]&Kt|r[e+1|0]&Vs,r[e]=r[e-bd|0]^t>>>1^(t&1?eu:0);t=r[gn]&Kt|r[0]&Vs,r[gn]=r[js-1]^t>>>1^(t&1?eu:0)}function L6(r){return r^=r>>>11,r^=r<<7&2636928640,r^=r<<15&4022730752,r^r>>>18}function U6(r,e){let t=1,a=0;const n=e.length;let i=Math.max(n,_t)|0,s=r[0]|0;for(;(i|0)>0;--i)r[t]=s=(r[t]^Ks(s^s>>>30,1664525))+(e[a]|0)+(a|0)|0,t=t+1|0,++a,(t|0)>gn&&(r[0]=r[gn],t=1),a>=n&&(a=0);for(i=gn;(i|0)>0;--i)r[t]=s=(r[t]^Ks(s^s>>>30,1566083941))-t|0,t=t+1|0,(t|0)>gn&&(r[0]=r[gn],t=1);r[0]=Kt}let xd=null;const tu=128;let nu=tu;const k6={next(){return nu>=tu&&(xd=new Int32Array(new Int8Array(require("crypto").randomBytes(4*tu)).buffer),nu=0),xd[nu++]|0}},Ka=Symbol("engine"),au=Symbol("random"),wd={browserCrypto:z6,nodeCrypto:k6,MersenneTwister19937:Qa,nativeMath:xa,min:{next(){return 0}},max:{range:[],next(){return this.range[1]-this.range[0]}}};class V6{constructor(e=xa){this.engine=e||xa}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||xa,this[au]=new q6(this[Ka])}integer(e,t){return this[Ka].range=[e,t],this[au].integer(e,t)}real(e,t,a=!1){return this[Ka].range=[e,t],this[au].real(e,t,a)}}const wa=new V6,Nd=Symbol("operator"),Dd=Symbol("value");class ja{constructor(e,t){if(e){if(!t&&t!==0)throw new Ot("value")}else throw new Ot("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 Ls(e);this[Nd]=e}get operator(){return this[Nd]}set value(e){if(!Cr(e))throw new TypeError("value must be a finite number");this[Dd]=Number(e)}get value(){return this[Dd]}isMatch(e){return f6(e,this.value,this.operator)}toJSON(){const{operator:e,value:t}=this;return{operator:e,type:"compare-point",value:t}}toString(){return`${this.operator}${this.value}`}}class yn{constructor(){this.order=999}get name(){return"modifier"}get notation(){return""}get maxIterations(){return 1e3}run(e,t){return e}toJSON(){const{notation:e,name:t}=this;return{name:t,notation:e,type:"modifier"}}toString(){return this.notation}}const Ad=Symbol("compare-point");class ei extends yn{constructor(e){super(),e&&(this.comparePoint=e)}get comparePoint(){return this[Ad]}set comparePoint(e){if(!(e instanceof ja))throw new TypeError("comparePoint must be instance of ComparePoint");this[Ad]=e}get name(){return"comparison"}get notation(){return`${this.comparePoint||""}`}isComparePoint(e){return this.comparePoint?this.comparePoint.isMatch(e):!1}toJSON(){const{comparePoint:e}=this;return Object.assign(super.toJSON(),{comparePoint:e})}}const Ed=Symbol("compound"),Sd=Symbol("penetrate");class Cd extends ei{constructor(e=null,t=!1,a=!1){super(e),this[Ed]=!!t,this[Sd]=!!a,this.order=3}get compound(){return this[Ed]}get name(){return"explode"}get notation(){return`!${this.compound?"!":""}${this.penetrate?"p":""}${super.notation}`}get penetrate(){return this[Sd]}run(e,t){if(t.min===t.max)throw new mo(t,"explode");const a=e;return a.rolls=e.rolls.map(n=>{const i=[n];let s=n.value;for(let f=0;f<this.maxIterations&&this.isComparePoint(s);f++){const l=i[i.length-1],u=t.rollOnce();s=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=m6(i.map(f=>f.value)),n.modifiers=["explode","compound"],this.penetrate&&n.modifiers.add("penetrate"),n):i}).flat(),a}toJSON(){const{compound:e,penetrate:t}=this;return Object.assign(super.toJSON(),{compound:e,penetrate:t})}}const Md=Symbol("text"),Fd=Symbol("type");class At{constructor(e,t=this.constructor.types.INLINE){this.text=e,this.type=t}get text(){return this[Md]}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[Md]=`${e}`.trim()}get type(){return this[Fd]}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[Fd]=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}]`}}u0(At,"types",{MULTILINE:"multiline",INLINE:"inline"});const yo=Symbol("description");class Td{constructor(e=null){this.description=e}get description(){return this[yo]||null}set description(e){if(!e&&e!==0)this[yo]=null;else if(e instanceof At)this[yo]=e;else if(typeof e=="string")this[yo]=new At(e);else throw new TypeError(`description must be of type Description, string or null. Received ${typeof e}`)}toJSON(){const{description:e}=this;return{description:e}}toString(){return this.description?`${this.description}`:""}}const G6={compound:"!",explode:"!","critical-failure":"__","critical-success":"**",drop:"d",max:"v",min:"^",penetrate:"p","re-roll":"r","re-roll-once":"ro","target-failure":"_","target-success":"*"},Bd=(...r)=>[...r].reduce((e,t)=>{let a;return t instanceof yn?a=t.name:a=t,e+(G6[a]||a)},""),iu=Symbol("calculation-value"),ou=Symbol("modifiers"),ri=Symbol("initial-value"),$d=Symbol("use-in-total"),su=Symbol("value");class bo{constructor(e,t=[],a=!0){if(Cr(e))this[ri]=Number(e),this.modifiers=t||[],this.useInTotal=a;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[ri]=Number(n),Cr(e.value)&&Number(e.value)!==this[ri]&&(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: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 Cr(this[iu])?parseFloat(this[iu]):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[iu]=t?parseFloat(`${e}`):null}get initialValue(){return this[ri]}get modifierFlags(){return Bd(...this.modifiers)}get modifiers(){return this[ou]}set modifiers(e){if((Array.isArray(e)||e instanceof Set)&&[...e].every(t=>typeof t=="string")){this[ou]=new Set([...e]);return}if(!e&&e!==0){this[ou]=new Set;return}throw new TypeError(`modifiers must be a Set or array of modifier names: ${e}`)}get useInTotal(){return!!this[$d]}set useInTotal(e){this[$d]=!!e}get value(){return Cr(this[su])?this[su]:this[ri]}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[su]=Number(e)}toJSON(){const{calculationValue:e,initialValue:t,modifierFlags:a,modifiers:n,useInTotal:i,value:s}=this;return{calculationValue:e,initialValue:t,modifierFlags:a,modifiers:[...n],type:"result",useInTotal:i,value:s}}toString(){return this.value+this.modifierFlags}}const uu=Symbol("rolls");class jt{constructor(e=[]){this.rolls=e}get length(){return this.rolls.length||0}get rolls(){return[...this[uu]]}set rolls(e){if(!e||!Array.isArray(e))throw new TypeError(`rolls must be an array: ${e}`);this[uu]=[],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 bo?e:new bo(e);this[uu].push(t)}toJSON(){const{rolls:e,value:t}=this;return{rolls:e,type:"roll-results",value:t}}toString(){return`[${this.rolls.join(", ")}]`}}const Od=Symbol("once");class _d extends ei{constructor(e=!1,t=null){super(t),this.once=!!e,this.order=4}get name(){return"re-roll"}get notation(){return`r${this.once?"o":""}${super.notation}`}get once(){return!!this[Od]}set once(e){this[Od]=!!e}run(e,t){if(t.min===t.max)throw new mo(t,"re-roll");return e.rolls.map(a=>{for(let n=0;n<this.maxIterations&&this.isComparePoint(a.value);n++){const i=t.rollOnce();if(a.value=i.value,a.modifiers.add(`re-roll${this.once?"-once":""}`),this.once)break}return a}),e}toJSON(){const{once:e}=this;return Object.assign(super.toJSON(),{once:e})}}const xo=Symbol("modifiers"),Id=Symbol("qty"),Rd=Symbol("sides"),qd=Symbol("min-value"),zd=Symbol("max-value");class Na extends Td{constructor(e,t=1,a=null,n=1,i=null,s=null){if(super(s),!e&&e!==0)throw new Ot("sides");if(e===1/0)throw new RangeError("numerical sides must be finite number");if(Cr(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(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(!ks(f))throw new RangeError("min must a finite number")}else throw new TypeError("min must a finite number");if(i&&!Cr(i))throw new TypeError("max must a finite number");if(i&&!ks(i))throw new RangeError("max must a finite number");this[Id]=parseInt(`${t}`,10),this[Rd]=e,a&&(this.modifiers=a),this[qd]=parseInt(f,10),this[zd]=i?parseInt(`${i}`,10):e}get average(){return(this.min+this.max)/2}get modifiers(){return this[xo]?new Map([...this[xo]].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 yn)))throw new TypeError("modifiers must only contain Modifier instances");this[xo]=t,this[xo].forEach(a=>{a instanceof Cd&&!a.comparePoint?a.comparePoint=new ja("=",this.max):a instanceof _d&&!a.comparePoint&&(a.comparePoint=new ja("=",this.min))})}get max(){return this[zd]}get min(){return this[qd]}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[Id]}get sides(){return this[Rd]}roll(){const e=new jt;for(let t=0;t<this.qty;t++)e.addRoll(this.rollOnce());return(this.modifiers||[]).forEach(t=>{t.run(e,this)}),e}rollOnce(){return new bo(wa.integer(this.min,this.max))}toJSON(){const{average:e,max:t,min:a,modifiers:n,name:i,notation:s,qty:f,sides:l}=this;return Object.assign(super.toJSON(),{average:e,max:t,min:a,modifiers:n,name:i,notation:s,qty:f,sides:l,type:"die"})}toString(){return`${this.notation}${this.description?` ${this.description}`:""}`}}class H6 extends Na{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=wa.integer(1,3)-2;else if(this.nonBlanks===1){const t=wa.integer(1,6);t===1?e=-1:t===6&&(e=1)}return new bo(e)}}class Z6 extends Na{constructor(e=1,t=null,a=!1,n=null){super(100,e,t,null,null,n),this.sidesAsNumber=!!a}get name(){return"percentile"}get sides(){return this.sidesAsNumber?super.sides:"%"}}class J6 extends ei{constructor(e){super(e),this.order=9}get name(){return"critical-failure"}get notation(){return`cf${super.notation}`}run(e,t){return e.rolls.forEach(a=>(this.isComparePoint(a.value)&&a.modifiers.add("critical-failure"),a)),e}}class W6 extends ei{constructor(e){super(e),this.order=8}get name(){return"critical-success"}get notation(){return`cs${super.notation}`}run(e,t){return e.rolls.forEach(a=>(this.isComparePoint(a.value)&&a.modifiers.add("critical-success"),a)),e}}const lu=Symbol("calculation-value"),Pd=Symbol("is-roll-group"),cu=Symbol("modifiers"),fu=Symbol("results"),Ld=Symbol("use-in-total");class Ur{constructor(e=[],t=[],a=!1,n=!0){this.isRollGroup=a,this.modifiers=t,this.results=e,this.useInTotal=n}get calculationValue(){return Cr(this[lu])?parseFloat(this[lu]):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[lu]=t?parseFloat(`${e}`):null}get isRollGroup(){return this[Pd]}set isRollGroup(e){this[Pd]=!!e}get length(){return this.results.length||0}get modifierFlags(){return Bd(...this.modifiers)}get modifiers(){return this[cu]}set modifiers(e){if((Array.isArray(e)||e instanceof Set)&&[...e].every(t=>typeof t=="string"))this[cu]=new Set([...e]);else if(!e&&e!==0)this[cu]=new Set;else throw new TypeError(`modifiers must be a Set or array of modifier names: ${e}`)}get results(){return[...this[fu]]}set results(e){if(!e||!Array.isArray(e))throw new TypeError(`results must be an array: ${e}`);this[fu]=[],e.forEach(t=>{this.addResult(t)})}get useInTotal(){return!!this[Ld]}set useInTotal(e){this[Ld]=!!e}get value(){if(!this.results.length)return 0;const e=this.results.reduce((t,a)=>{let n=a;return a instanceof Ur?n=a.useInTotal?a.calculationValue:0:a instanceof jt&&(n=a.value),t+n},typeof this.results[0]=="string"?"":0);return typeof e=="string"?sd(e):e}addResult(e){let t;if(e instanceof Ur||e instanceof jt)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[fu].push(t)}toJSON(){const{calculationValue:e,isRollGroup:t,modifierFlags:a,modifiers:n,results:i,useInTotal:s,value:f}=this;return{calculationValue:e,isRollGroup:t,modifierFlags:a,modifiers:[...n],results:i,type:"result-group",useInTotal:s,value:f}}toString(){let e;return this.isRollGroup?e=`{${this.results.join(", ")}}`:e=this.results.join(""),this.modifierFlags&&(e=`(${e})${this.modifierFlags}`),e}}const Ud=Symbol("end"),kd=Symbol("qty");class Vd extends yn{constructor(e="h",t=1){super(),this.end=e,this.qty=t,this.order=5}get end(){return this[Ud]}set end(e){if(e!=="h"&&e!=="l")throw new RangeError('End must be "h" or "l"');this[Ud]=e}get name(){return`keep-${this.end}`}get notation(){return`k${this.end}${this.qty}`}get qty(){return this[kd]}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[kd]=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 Ur?(a=e.results,a.length===1&&a[0]instanceof Ur?n=a[0].results.map((i,s)=>i instanceof jt?i.rolls.map((f,l)=>({value:f.value,index:[s,l]})):null).flat().filter(Boolean):n=[...a].map((i,s)=>({value:i.value,index:s}))):(a=e.rolls,n=[...a].map((i,s)=>({value:i.value,index:s}))),n=n.sort((i,s)=>i.value-s.value).map(i=>i.index).slice(...this.rangeToDrop(n)),n.forEach(i=>{let s;Array.isArray(i)?s=a[0].results[i[0]].rolls[i[1]]:s=a[i],s.modifiers.add("drop"),s.useInTotal=!1}),e}toJSON(){const{end:e,qty:t}=this;return Object.assign(super.toJSON(),{end:e,qty:t})}}class X6 extends Vd{constructor(e="l",t=1){super(e,t),this.order=6}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 Gd=Symbol("max");class Y6 extends yn{constructor(e){super(),this.max=e,this.order=2}get max(){return this[Gd]}set max(e){if(!Cr(e))throw new TypeError("max must be a number");this[Gd]=parseFloat(`${e}`)}get name(){return"max"}get notation(){return`max${this.max}`}run(e,t){const a=e;return a.rolls=e.rolls.map(n=>{const i=n;return n.value>this.max&&(i.value=this.max,i.modifiers.add("max")),i}),a}toJSON(){const{max:e}=this;return Object.assign(super.toJSON(),{max:e})}}const Hd=Symbol("min");class Q6 extends yn{constructor(e){super(),this.min=e,this.order=1}get min(){return this[Hd]}set min(e){if(!Cr(e))throw new TypeError("min must be a number");this[Hd]=parseFloat(`${e}`)}get name(){return"min"}get notation(){return`min${this.min}`}run(e,t){const a=e;return a.rolls=e.rolls.map(n=>{const i=n;return n.value<this.min&&(i.value=this.min,i.modifiers.add("min")),i}),a}toJSON(){const{min:e}=this;return Object.assign(super.toJSON(),{min:e})}}const Zd=Symbol("direction");class K6 extends yn{constructor(e="a"){super(),this.direction=e,this.order=10}get direction(){return this[Zd]}set direction(e){if(e!=="a"&&e!=="d")throw new RangeError('Direction must be "a" (Ascending) or "d" (Descending)');this[Zd]=e}get name(){return"sorting"}get notation(){return`s${this.direction}`}run(e,t){let a;return e instanceof Ur?a="results":a="rolls",e[a]=e[a].sort((n,i)=>this.direction==="d"?i.value-n.value:n.value-i.value),e instanceof Ur&&(e[a]=e[a].map(n=>n instanceof Ur||n instanceof jt?this.run(n,t):n)),e}toJSON(){const{direction:e}=this;return Object.assign(super.toJSON(),{direction:e})}}const Jd=Symbol("failure-cp");class j6 extends ei{constructor(e,t=null){super(e),this.failureComparePoint=t,this.order=7}get failureComparePoint(){return this[Jd]}set failureComparePoint(e){if(e&&!(e instanceof ja))throw new TypeError("failure comparePoint must be instance of ComparePoint or null");this[Jd]=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 Ur?a=e.results:a=e.rolls,a.forEach(n=>{this.isSuccess(n.value)?n.modifiers.add("target-success"):this.isFailure(n.value)&&n.modifiers.add("target-failure"),n.calculationValue=this.getStateValue(n.value)}),e}toJSON(){const{failureComparePoint:e,successComparePoint:t}=this,a=super.toJSON();return delete a.comparePoint,Object.assign(a,{failureComparePoint:e,successComparePoint:t})}}const e9=r=>{try{return!!(r&&btoa(atob(r))===r)}catch{return!1}},r9=r=>{try{const e=r?JSON.parse(r):!1;return!!(e&&typeof e=="object")}catch{return!1}},mu=Symbol("expressions"),vu=Symbol("modifiers");class Wd extends Td{constructor(e=[],t=[],a=null){super(a),this.expressions=e,this.modifiers=t}get expressions(){return[...this[mu]||[]]}set expressions(e){if(!e)throw new Ot("expressions");if(!Array.isArray(e))throw new TypeError(`expressions must be an array: ${e}`);this[mu]=[],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 Na||typeof a=="string"||typeof a=="number"))throw new TypeError("Sub expression items must be Dice, numbers, or strings");this[mu].push(t)})}get modifiers(){return this[vu]?new Map([...this[vu]].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 yn)))throw new TypeError("modifiers must only contain Modifier instances");this[vu]=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 Ur(this.expressions.map(t=>{const a=t.map(n=>n instanceof Na?n.roll():n);return new Ur(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 t9(r,e){function t(){this.constructor=r}t.prototype=e.prototype,r.prototype=new t}function Da(r,e,t,a){var n=Error.call(this,r);return Object.setPrototypeOf&&Object.setPrototypeOf(n,Da.prototype),n.expected=e,n.found=t,n.location=a,n.name="SyntaxError",n}t9(Da,Error);function pu(r,e,t){return t=t||" ",r.length>e?r:(e-=r.length,t+=t.repeat(e),r+t.slice(0,e))}Da.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+":"+n.line+":"+n.column;if(t){var s=this.location.end,f=pu("",n.line.toString().length," "),l=t[n.line-1],u=n.line===s.line?s.column:l.length+1,o=u-n.column||1;e+=`
79
- --> `+i+`
80
- `+f+` |
81
- `+n.line+" | "+l+`
82
- `+f+" | "+pu("",n.column-1," ")+pu("",o,"^")}else e+=`
83
- at `+i}return e},Da.buildMessage=function(r,e){var t={literal:function(u){return'"'+n(u.text)+'"'},class:function(u){var o=u.parts.map(function(c){return Array.isArray(c)?i(c[0])+"-"+i(c[1]):i(c)});return"["+(u.inverted?"^":"")+o.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(o){return"\\x0"+a(o)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(o){return"\\x"+a(o)})}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(o){return"\\x0"+a(o)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(o){return"\\x"+a(o)})}function s(u){return t[u.type](u)}function f(u){var o=u.map(s),c,m;if(o.sort(),o.length>0){for(c=1,m=1;c<o.length;c++)o[c-1]!==o[c]&&(o[m]=o[c],m++);o.length=m}switch(o.length){case 1:return o[0];case 2:return o[0]+" or "+o[1];default:return o.slice(0,-1).join(", ")+", or "+o[o.length-1]}}function l(u){return u?'"'+n(u)+'"':"end of input"}return"Expected "+f(r)+" but "+l(e)+" found."};function n9(r,e){e=e!==void 0?e:{};var t={},a=e.grammarSource,n={Main:n0},i=n0,s="{",f=",",l="}",u="d",o="d%",c="dF",m=".",v="!",p="p",h="k",y="max",b="min",A="r",d="o",w="cs",x="cf",g="s",E="a",N="f",S="!=",D="<=",T=">=",B="=",_="<>",L=">",G="<",C="(",F=")",Z="abs",$="ceil",U="cos",Y="exp",j="floor",P="log",K="round",ne="sign",re="sin",fe="sqrt",pe="tan",ce="pow",oe="-",Ce="**",Oe="*",Me="^",$e="%",k="/",W="+",ie="/*",V="*/",Q="[",te="]",ge="//",he="#",q=/^[12]/,z=/^[lh]/,ee=/^[.]/,ue=/^[1-9]/,me=/^[0-9]/,ye=/^[^\]]/,be=/^[\n\r\u2028\u2029]/,ve=/^[ \t\n\r]/,Ne=Ue("{",!1),Ie=Ue(",",!1),Ge=Ue("}",!1),Be=Ue("d",!1),lr=Ue("d%",!1),Je=Ue("dF",!1),cr=Ue(".",!1),M=xn(["1","2"],!1,!1),H=Ue("!",!1),se=Ue("p",!1),De=xn(["l","h"],!1,!1),ze=Ue("k",!1),Le=Ue("max",!1),Mr=Ue("min",!1),Rr=Ue("r",!1),en=Ue("o",!1),Ca=Ue("cs",!1),qn=Ue("cf",!1),xu=Ue("s",!1),wu=Ue("a",!1),Nu=Ue("f",!1),Du=Ue("!=",!1),Au=Ue("<=",!1),Eu=Ue(">=",!1),Su=Ue("=",!1),Cu=Ue("<>",!1),Mu=Ue(">",!1),zn=Ue("<",!1),Ma=Ue("(",!1),Fa=Ue(")",!1),Fu=Ue("abs",!1),Tu=Ue("ceil",!1),Bu=Ue("cos",!1),$u=Ue("exp",!1),Ou=Ue("floor",!1),_u=Ue("log",!1),Iu=Ue("round",!1),Ru=Ue("sign",!1),qu=Ue("sin",!1),zu=Ue("sqrt",!1),Pu=Ue("tan",!1),Lu=Ue("pow",!1),Ao=Ue("-",!1),Uu=xn(["."],!1,!1),ku=xn([["1","9"]],!1,!1),It=xn([["0","9"]],!1,!1),Kr=Ue("**",!1),Or=Ue("*",!1),Eo=Ue("^",!1),Vu=Ue("%",!1),Ta=Ue("/",!1),Ba=Ue("+",!1),So=Hu("comment"),Co=Ue("/*",!1),Rt=Ue("*/",!1),Mo=v7(),T9=Ue("[",!1),e0=xn(["]"],!0,!1),B9=Ue("]",!1),$9=Ue("//",!1),O9=Ue("#",!1),_9=xn([`
84
- `,"\r","\u2028","\u2029"],!1,!1),I9=Hu("whitespace"),R9=xn([" "," ",`
85
- `,"\r"],!1,!1),q9=Hu("whitespace or comment"),z9=function(O,X,ae,le){return new Wd([O,...X.map(Ee=>Ee[3])],Object.assign({},...ae.map(Ee=>({[Ee.name]:Ee}))),le.find(Ee=>Ee instanceof At))},P9=function(O,X,ae){return O.modifiers=Object.assign({},...X.map(le=>({[le.name]:le}))),O.description=ae.find(le=>le instanceof At),O},L9=function(O,X){return new Na(X,O||1)},U9=function(O){return new Z6(O||1)},k9=function(O,X){return new H6(X?parseInt(X[1],10):2,O||1)},V9=function(O,X,ae){return new Cd(ae,!!O,!!X)},G9=function(O,X){return new j6(O,X)},H9=function(O,X){return new X6(O||"l",X)},Z9=function(O,X){return new Vd(O||"h",X)},J9=function(O){return new Y6(O)},W9=function(O){return new Q6(O)},X9=function(O,X){return new _d(!!O,X)},Y9=function(O){return new W6(O)},Q9=function(O){return new J6(O)},K9=function(O){return new K6(O||"a")},j9=function(O){return O},e7=function(O,X){return new ja(O,X)},r7=function(O,X,ae){return sd(Bo())},t7=function(O,X){return O=Array.isArray(O)?O:[O],[...O,...X.map(([,ae,,le])=>[ae,le]).flat(2)]},n7=function(O,X,ae){return[O,...X,ae]},a7=function(O,X){return[`${O}(`,...X,")"]},i7=function(O,X,ae){return[`${O}(`,...X,",",...ae,")"]},o7=function(){return parseFloat(Bo())},s7=function(){return parseInt(Bo(),10)},u7=function(){return parseInt(Bo(),10)},l7=function(){return"^"},c7=function(O){return new At(O.flat().join(""),At.types.MULTILINE)},f7=function(O){return new At(O.flat().join(""),At.types.MULTILINE)},m7=function(O){return new At(O.flat().join(""),At.types.INLINE)},I=0,fr=0,Fo=[{line:1,column:1}],qt=0,Gu=[],Ae=0,To;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 Bo(){return r.substring(fr,I)}function Ue(O,X){return{type:"literal",text:O,ignoreCase:X}}function xn(O,X,ae){return{type:"class",parts:O,inverted:X,ignoreCase:ae}}function v7(){return{type:"any"}}function p7(){return{type:"end"}}function Hu(O){return{type:"other",description:O}}function r0(O){var X=Fo[O],ae;if(X)return X;for(ae=O-1;!Fo[ae];)ae--;for(X=Fo[ae],X={line:X.line,column:X.column};ae<O;)r.charCodeAt(ae)===10?(X.line++,X.column=1):X.column++,ae++;return Fo[O]=X,X}function t0(O,X){var ae=r0(O),le=r0(X);return{source:a,start:{offset:O,line:ae.line,column:ae.column},end:{offset:X,line:le.line,column:le.column}}}function Fe(O){I<qt||(I>qt&&(qt=I,Gu=[]),Gu.push(O))}function h7(O,X,ae){return new Da(Da.buildMessage(O,X),O,X,ae)}function n0(){var O;return O=wn(),O}function d7(){var O,X,ae,le,Ee,_e,pr,Dr,Et;if(O=I,r.charCodeAt(I)===123?(X=s,I++):(X=t,Ae===0&&Fe(Ne)),X!==t)if(Nr(),ae=wn(),ae!==t){for(le=[],Ee=I,_e=Nr(),r.charCodeAt(I)===44?(pr=f,I++):(pr=t,Ae===0&&Fe(Ie)),pr!==t?(Dr=Nr(),Et=wn(),Et!==t?(_e=[_e,pr,Dr,Et],Ee=_e):(I=Ee,Ee=t)):(I=Ee,Ee=t);Ee!==t;)le.push(Ee),Ee=I,_e=Nr(),r.charCodeAt(I)===44?(pr=f,I++):(pr=t,Ae===0&&Fe(Ie)),pr!==t?(Dr=Nr(),Et=wn(),Et!==t?(_e=[_e,pr,Dr,Et],Ee=_e):(I=Ee,Ee=t)):(I=Ee,Ee=t);if(Ee=Nr(),r.charCodeAt(I)===125?(_e=l,I++):(_e=t,Ae===0&&Fe(Ge)),_e!==t){for(pr=[],Dr=$o();Dr!==t;)pr.push(Dr),Dr=$o();Dr=s0(),fr=O,O=z9(ae,le,pr,Dr)}else I=O,O=t}else I=O,O=t;else I=O,O=t;return O}function g7(){var O,X,ae,le;if(O=I,X=y7(),X===t&&(X=b7(),X===t&&(X=x7())),X!==t){for(ae=[],le=$o();le!==t;)ae.push(le),le=$o();le=s0(),fr=O,O=P9(X,ae,le)}else I=O,O=t;return O}function y7(){var O,X,ae,le;return O=I,X=Oo(),X===t&&(X=null),r.charCodeAt(I)===100?(ae=u,I++):(ae=t,Ae===0&&Fe(Be)),ae!==t?(le=Oo(),le!==t?(fr=O,O=L9(X,le)):(I=O,O=t)):(I=O,O=t),O}function b7(){var O,X,ae;return O=I,X=Oo(),X===t&&(X=null),r.substr(I,2)===o?(ae=o,I+=2):(ae=t,Ae===0&&Fe(lr)),ae!==t?(fr=O,O=U9(X)):(I=O,O=t),O}function x7(){var O,X,ae,le,Ee,_e;return O=I,X=Oo(),X===t&&(X=null),r.substr(I,2)===c?(ae=c,I+=2):(ae=t,Ae===0&&Fe(Je)),ae!==t?(le=I,r.charCodeAt(I)===46?(Ee=m,I++):(Ee=t,Ae===0&&Fe(cr)),Ee!==t?(q.test(r.charAt(I))?(_e=r.charAt(I),I++):(_e=t,Ae===0&&Fe(M)),_e!==t?(Ee=[Ee,_e],le=Ee):(I=le,le=t)):(I=le,le=t),le===t&&(le=null),fr=O,O=k9(X,le)):(I=O,O=t),O}function $o(){var O;return O=w7(),O===t&&(O=N7(),O===t&&(O=D7(),O===t&&(O=A7(),O===t&&(O=C7(),O===t&&(O=M7(),O===t&&(O=F7(),O===t&&(O=T7(),O===t&&(O=E7(),O===t&&(O=S7()))))))))),O}function w7(){var O,X,ae,le,Ee;return O=I,r.charCodeAt(I)===33?(X=v,I++):(X=t,Ae===0&&Fe(H)),X!==t?(r.charCodeAt(I)===33?(ae=v,I++):(ae=t,Ae===0&&Fe(H)),ae===t&&(ae=null),r.charCodeAt(I)===112?(le=p,I++):(le=t,Ae===0&&Fe(se)),le===t&&(le=null),Ee=$a(),Ee===t&&(Ee=null),fr=O,O=V9(ae,le,Ee)):(I=O,O=t),O}function N7(){var O,X,ae;return O=I,X=$a(),X!==t?(ae=B7(),ae===t&&(ae=null),fr=O,O=G9(X,ae)):(I=O,O=t),O}function D7(){var O,X,ae,le;return O=I,r.charCodeAt(I)===100?(X=u,I++):(X=t,Ae===0&&Fe(Be)),X!==t?(z.test(r.charAt(I))?(ae=r.charAt(I),I++):(ae=t,Ae===0&&Fe(De)),ae===t&&(ae=null),le=Ju(),le!==t?(fr=O,O=H9(ae,le)):(I=O,O=t)):(I=O,O=t),O}function A7(){var O,X,ae,le;return O=I,r.charCodeAt(I)===107?(X=h,I++):(X=t,Ae===0&&Fe(ze)),X!==t?(z.test(r.charAt(I))?(ae=r.charAt(I),I++):(ae=t,Ae===0&&Fe(De)),ae===t&&(ae=null),le=Ju(),le!==t?(fr=O,O=Z9(ae,le)):(I=O,O=t)):(I=O,O=t),O}function E7(){var O,X,ae;return O=I,r.substr(I,3)===y?(X=y,I+=3):(X=t,Ae===0&&Fe(Le)),X!==t?(ae=Pn(),ae!==t?(fr=O,O=J9(ae)):(I=O,O=t)):(I=O,O=t),O}function S7(){var O,X,ae;return O=I,r.substr(I,3)===b?(X=b,I+=3):(X=t,Ae===0&&Fe(Mr)),X!==t?(ae=Pn(),ae!==t?(fr=O,O=W9(ae)):(I=O,O=t)):(I=O,O=t),O}function C7(){var O,X,ae,le;return O=I,r.charCodeAt(I)===114?(X=A,I++):(X=t,Ae===0&&Fe(Rr)),X!==t?(r.charCodeAt(I)===111?(ae=d,I++):(ae=t,Ae===0&&Fe(en)),ae===t&&(ae=null),le=$a(),le===t&&(le=null),fr=O,O=X9(ae,le)):(I=O,O=t),O}function M7(){var O,X,ae;return O=I,r.substr(I,2)===w?(X=w,I+=2):(X=t,Ae===0&&Fe(Ca)),X!==t?(ae=$a(),ae!==t?(fr=O,O=Y9(ae)):(I=O,O=t)):(I=O,O=t),O}function F7(){var O,X,ae;return O=I,r.substr(I,2)===x?(X=x,I+=2):(X=t,Ae===0&&Fe(qn)),X!==t?(ae=$a(),ae!==t?(fr=O,O=Q9(ae)):(I=O,O=t)):(I=O,O=t),O}function T7(){var O,X,ae;return O=I,r.charCodeAt(I)===115?(X=g,I++):(X=t,Ae===0&&Fe(xu)),X!==t?(r.charCodeAt(I)===97?(ae=E,I++):(ae=t,Ae===0&&Fe(wu)),ae===t&&(r.charCodeAt(I)===100?(ae=u,I++):(ae=t,Ae===0&&Fe(Be))),ae===t&&(ae=null),fr=O,O=K9(ae)):(I=O,O=t),O}function B7(){var O,X,ae;return O=I,r.charCodeAt(I)===102?(X=N,I++):(X=t,Ae===0&&Fe(Nu)),X!==t?(ae=$a(),ae!==t?(fr=O,O=j9(ae)):(I=O,O=t)):(I=O,O=t),O}function $a(){var O,X,ae;return O=I,X=$7(),X!==t?(ae=Pn(),ae!==t?(fr=O,O=e7(X,ae)):(I=O,O=t)):(I=O,O=t),O}function $7(){var O;return r.substr(I,2)===S?(O=S,I+=2):(O=t,Ae===0&&Fe(Du)),O===t&&(r.substr(I,2)===D?(O=D,I+=2):(O=t,Ae===0&&Fe(Au)),O===t&&(r.substr(I,2)===T?(O=T,I+=2):(O=t,Ae===0&&Fe(Eu)),O===t&&(r.charCodeAt(I)===61?(O=B,I++):(O=t,Ae===0&&Fe(Su)),O===t&&(r.substr(I,2)===_?(O=_,I+=2):(O=t,Ae===0&&Fe(Cu)),O===t&&(r.charCodeAt(I)===62?(O=L,I++):(O=t,Ae===0&&Fe(Mu)),O===t&&(r.charCodeAt(I)===60?(O=G,I++):(O=t,Ae===0&&Fe(zn)))))))),O}function Oo(){var O,X,ae,le,Ee,_e,pr,Dr,Et,Oa;if(O=Ju(),O===t)if(O=I,r.charCodeAt(I)===40?(X=C,I++):(X=t,Ae===0&&Fe(Ma)),X!==t){if(Nr(),ae=I,le=Pn(),le!==t){if(Ee=[],_e=I,pr=Nr(),Dr=_o(),Dr!==t?(Et=Nr(),Oa=Pn(),Oa!==t?(pr=[pr,Dr,Et,Oa],_e=pr):(I=_e,_e=t)):(I=_e,_e=t),_e!==t)for(;_e!==t;)Ee.push(_e),_e=I,pr=Nr(),Dr=_o(),Dr!==t?(Et=Nr(),Oa=Pn(),Oa!==t?(pr=[pr,Dr,Et,Oa],_e=pr):(I=_e,_e=t)):(I=_e,_e=t);else Ee=t;Ee!==t?(le=[le,Ee],ae=le):(I=ae,ae=t)}else I=ae,ae=t;ae!==t?(le=Nr(),r.charCodeAt(I)===41?(Ee=F,I++):(Ee=t,Ae===0&&Fe(Fa)),Ee!==t?(fr=O,O=r7()):(I=O,O=t)):(I=O,O=t)}else I=O,O=t;return O}function wn(){var O,X,ae,le,Ee,_e,pr,Dr;if(O=I,X=Zu(),X!==t){for(ae=[],le=I,Ee=Nr(),_e=_o(),_e!==t?(pr=Nr(),Dr=Zu(),Dr!==t?(Ee=[Ee,_e,pr,Dr],le=Ee):(I=le,le=t)):(I=le,le=t);le!==t;)ae.push(le),le=I,Ee=Nr(),_e=_o(),_e!==t?(pr=Nr(),Dr=Zu(),Dr!==t?(Ee=[Ee,_e,pr,Dr],le=Ee):(I=le,le=t)):(I=le,le=t);fr=O,O=t7(X,ae)}else I=O,O=t;return O}function Zu(){var O,X,ae,le;return O=O7(),O===t&&(O=g7(),O===t&&(O=Pn(),O===t&&(O=I,r.charCodeAt(I)===40?(X=C,I++):(X=t,Ae===0&&Fe(Ma)),X!==t?(Nr(),ae=wn(),ae!==t?(Nr(),r.charCodeAt(I)===41?(le=F,I++):(le=t,Ae===0&&Fe(Fa)),le!==t?(fr=O,O=n7(X,ae,le)):(I=O,O=t)):(I=O,O=t)):(I=O,O=t),O===t&&(O=d7())))),O}function O7(){var O,X,ae,le,Ee,_e,pr;return O=I,r.substr(I,3)===Z?(X=Z,I+=3):(X=t,Ae===0&&Fe(Fu)),X===t&&(r.substr(I,4)===$?(X=$,I+=4):(X=t,Ae===0&&Fe(Tu)),X===t&&(r.substr(I,3)===U?(X=U,I+=3):(X=t,Ae===0&&Fe(Bu)),X===t&&(r.substr(I,3)===Y?(X=Y,I+=3):(X=t,Ae===0&&Fe($u)),X===t&&(r.substr(I,5)===j?(X=j,I+=5):(X=t,Ae===0&&Fe(Ou)),X===t&&(r.substr(I,3)===P?(X=P,I+=3):(X=t,Ae===0&&Fe(_u)),X===t&&(r.substr(I,5)===K?(X=K,I+=5):(X=t,Ae===0&&Fe(Iu)),X===t&&(r.substr(I,4)===ne?(X=ne,I+=4):(X=t,Ae===0&&Fe(Ru)),X===t&&(r.substr(I,3)===re?(X=re,I+=3):(X=t,Ae===0&&Fe(qu)),X===t&&(r.substr(I,4)===fe?(X=fe,I+=4):(X=t,Ae===0&&Fe(zu)),X===t&&(r.substr(I,3)===pe?(X=pe,I+=3):(X=t,Ae===0&&Fe(Pu)))))))))))),X!==t?(r.charCodeAt(I)===40?(ae=C,I++):(ae=t,Ae===0&&Fe(Ma)),ae!==t?(Nr(),le=wn(),le!==t?(Nr(),r.charCodeAt(I)===41?(Ee=F,I++):(Ee=t,Ae===0&&Fe(Fa)),Ee!==t?(fr=O,O=a7(X,le)):(I=O,O=t)):(I=O,O=t)):(I=O,O=t)):(I=O,O=t),O===t&&(O=I,r.substr(I,3)===ce?(X=ce,I+=3):(X=t,Ae===0&&Fe(Lu)),X===t&&(r.substr(I,3)===y?(X=y,I+=3):(X=t,Ae===0&&Fe(Le)),X===t&&(r.substr(I,3)===b?(X=b,I+=3):(X=t,Ae===0&&Fe(Mr)))),X!==t?(r.charCodeAt(I)===40?(ae=C,I++):(ae=t,Ae===0&&Fe(Ma)),ae!==t?(Nr(),le=wn(),le!==t?(Nr(),r.charCodeAt(I)===44?(Ee=f,I++):(Ee=t,Ae===0&&Fe(Ie)),Ee!==t?(Nr(),_e=wn(),_e!==t?(Nr(),r.charCodeAt(I)===41?(pr=F,I++):(pr=t,Ae===0&&Fe(Fa)),pr!==t?(fr=O,O=i7(X,le,_e)):(I=O,O=t)):(I=O,O=t)):(I=O,O=t)):(I=O,O=t)):(I=O,O=t)):(I=O,O=t)),O}function Pn(){var O,X,ae,le,Ee;return O=I,r.charCodeAt(I)===45?I++:Ae===0&&Fe(Ao),X=a0(),X!==t?(ae=I,ee.test(r.charAt(I))?(le=r.charAt(I),I++):(le=t,Ae===0&&Fe(Uu)),le!==t?(Ee=a0(),Ee!==t?(le=[le,Ee],ae=le):(I=ae,ae=t)):(I=ae,ae=t),ae===t&&(ae=null),fr=O,O=o7()):(I=O,O=t),O}function Ju(){var O,X,ae,le;if(O=I,ue.test(r.charAt(I))?(X=r.charAt(I),I++):(X=t,Ae===0&&Fe(ku)),X!==t){for(ae=[],me.test(r.charAt(I))?(le=r.charAt(I),I++):(le=t,Ae===0&&Fe(It));le!==t;)ae.push(le),me.test(r.charAt(I))?(le=r.charAt(I),I++):(le=t,Ae===0&&Fe(It));fr=O,O=s7()}else I=O,O=t;return O}function a0(){var O,X,ae;if(O=I,X=[],me.test(r.charAt(I))?(ae=r.charAt(I),I++):(ae=t,Ae===0&&Fe(It)),ae!==t)for(;ae!==t;)X.push(ae),me.test(r.charAt(I))?(ae=r.charAt(I),I++):(ae=t,Ae===0&&Fe(It));else X=t;return X!==t&&(fr=O,X=u7()),O=X,O}function _o(){var O,X;return O=I,r.substr(I,2)===Ce?(X=Ce,I+=2):(X=t,Ae===0&&Fe(Kr)),X!==t&&(fr=O,X=l7()),O=X,O===t&&(r.charCodeAt(I)===42?(O=Oe,I++):(O=t,Ae===0&&Fe(Or)),O===t&&(r.charCodeAt(I)===94?(O=Me,I++):(O=t,Ae===0&&Fe(Eo)),O===t&&(r.charCodeAt(I)===37?(O=$e,I++):(O=t,Ae===0&&Fe(Vu)),O===t&&(r.charCodeAt(I)===47?(O=k,I++):(O=t,Ae===0&&Fe(Ta)),O===t&&(r.charCodeAt(I)===43?(O=W,I++):(O=t,Ae===0&&Fe(Ba)),O===t&&(r.charCodeAt(I)===45?(O=oe,I++):(O=t,Ae===0&&Fe(Ao)))))))),O}function i0(){var O;return Ae++,O=_7(),O===t&&(O=I7()),Ae--,O===t&&Ae===0&&Fe(So),O}function _7(){var O,X,ae,le,Ee,_e;if(O=I,r.substr(I,2)===ie?(X=ie,I+=2):(X=t,Ae===0&&Fe(Co)),X!==t){for(ae=[],le=I,Ee=I,Ae++,r.substr(I,2)===V?(_e=V,I+=2):(_e=t,Ae===0&&Fe(Rt)),Ae--,_e===t?Ee=void 0:(I=Ee,Ee=t),Ee!==t?(r.length>I?(_e=r.charAt(I),I++):(_e=t,Ae===0&&Fe(Mo)),_e!==t?(Ee=[Ee,_e],le=Ee):(I=le,le=t)):(I=le,le=t);le!==t;)ae.push(le),le=I,Ee=I,Ae++,r.substr(I,2)===V?(_e=V,I+=2):(_e=t,Ae===0&&Fe(Rt)),Ae--,_e===t?Ee=void 0:(I=Ee,Ee=t),Ee!==t?(r.length>I?(_e=r.charAt(I),I++):(_e=t,Ae===0&&Fe(Mo)),_e!==t?(Ee=[Ee,_e],le=Ee):(I=le,le=t)):(I=le,le=t);r.substr(I,2)===V?(le=V,I+=2):(le=t,Ae===0&&Fe(Rt)),le!==t?(fr=O,O=c7(ae)):(I=O,O=t)}else I=O,O=t;if(O===t)if(O=I,r.charCodeAt(I)===91?(X=Q,I++):(X=t,Ae===0&&Fe(T9)),X!==t){for(ae=[],ye.test(r.charAt(I))?(le=r.charAt(I),I++):(le=t,Ae===0&&Fe(e0));le!==t;)ae.push(le),ye.test(r.charAt(I))?(le=r.charAt(I),I++):(le=t,Ae===0&&Fe(e0));r.charCodeAt(I)===93?(le=te,I++):(le=t,Ae===0&&Fe(B9)),le!==t?(fr=O,O=f7(ae)):(I=O,O=t)}else I=O,O=t;return O}function I7(){var O,X,ae,le,Ee,_e;if(O=I,r.substr(I,2)===ge?(X=ge,I+=2):(X=t,Ae===0&&Fe($9)),X===t&&(r.charCodeAt(I)===35?(X=he,I++):(X=t,Ae===0&&Fe(O9))),X!==t){for(ae=[],le=I,Ee=I,Ae++,_e=o0(),Ae--,_e===t?Ee=void 0:(I=Ee,Ee=t),Ee!==t?(r.length>I?(_e=r.charAt(I),I++):(_e=t,Ae===0&&Fe(Mo)),_e!==t?(Ee=[Ee,_e],le=Ee):(I=le,le=t)):(I=le,le=t);le!==t;)ae.push(le),le=I,Ee=I,Ae++,_e=o0(),Ae--,_e===t?Ee=void 0:(I=Ee,Ee=t),Ee!==t?(r.length>I?(_e=r.charAt(I),I++):(_e=t,Ae===0&&Fe(Mo)),_e!==t?(Ee=[Ee,_e],le=Ee):(I=le,le=t)):(I=le,le=t);fr=O,O=m7(ae)}else I=O,O=t;return O}function o0(){var O;return be.test(r.charAt(I))?(O=r.charAt(I),I++):(O=t,Ae===0&&Fe(_9)),O}function Io(){var O;return Ae++,ve.test(r.charAt(I))?(O=r.charAt(I),I++):(O=t,Ae===0&&Fe(R9)),Ae--,O===t&&Ae===0&&Fe(I9),O}function Nr(){var O,X;for(O=[],X=Io();X!==t;)O.push(X),X=Io();return O}function s0(){var O,X;for(Ae++,O=[],X=Io(),X===t&&(X=i0());X!==t;)O.push(X),X=Io(),X===t&&(X=i0());return Ae--,X=t,Ae===0&&Fe(q9),O}if(To=i(),To!==t&&I===r.length)return To;throw To!==t&&I<r.length&&Fe(p7()),h7(Gu,qt<r.length?r.charAt(qt):null,qt<r.length?t0(qt,qt+1):t0(qt,qt))}class Xd{static parse(e){if(!e)throw new Ot("notation");if(typeof e!="string")throw new TypeError("Notation must be a string");return n9(e)}}const Aa=Object.freeze({BASE_64:1,JSON:0,OBJECT:2}),hu=Symbol("notation"),du=Symbol("maxTotal"),gu=Symbol("minTotal"),Ea=Symbol("expressions"),wo=Symbol("roll-method"),bn=Symbol("rolls"),Yd=Symbol("set-rolls"),No=Symbol("total"),yu=r=>v6(r.calculationValue,2);class ti{constructor(e){if(!e)throw new Ot("notation");if(this[Ea]=[],e instanceof Object&&!Array.isArray(e)){if(e.notation){if(typeof e.notation!="string")throw new vo(e.notation);e.rolls&&this[Yd](e.rolls)}else throw new Ot("notation");this[hu]=e.notation,this[Ea]=Xd.parse(this.notation),this.hasRolls()||this.roll()}else if(typeof e=="string")this[hu]=e,this[Ea]=Xd.parse(this.notation),this.roll();else throw new vo(e)}get averageTotal(){return(this.maxTotal+this.minTotal)/2}get maxTotal(){if(!this.hasExpressions())return 0;if(!this[du]){const e=this[wo](wd.max);this[du]=yu(e)}return this[du]}get minTotal(){if(!this.hasExpressions())return 0;if(!this[gu]){const e=this[wo](wd.min);this[gu]=yu(e)}return this[gu]}get notation(){return this[hu]}get output(){let e=`${this.notation}: `;return this.hasRolls()?e+=`${this[bn]} = ${this.total}`:e+="No dice rolled",e}get rolls(){return this[bn]?this[bn].results:[]}get total(){return!this[No]&&this.hasRolls()&&(this[No]=yu(this[bn])),this[No]||0}export(e=Aa.JSON){switch(e){case Aa.BASE_64:return btoa(this.export(Aa.JSON));case Aa.JSON:return JSON.stringify(this);case Aa.OBJECT:return JSON.parse(this.export(Aa.JSON));default:throw new TypeError(`Invalid export format "${e}"`)}}hasExpressions(){return this[Ea]&&this[Ea].length>0}hasRolls(){return this.hasExpressions()&&this.rolls.length>0}roll(){return this[No]=0,this[bn]=this[wo](),this.rolls}toJSON(){const{averageTotal:e,maxTotal:t,minTotal:a,notation:n,output:i,rolls:s,total:f}=this;return{averageTotal:e,maxTotal:t,minTotal:a,notation:n,output:i,rolls:s,total:f,type:"dice-roll"}}toString(){return this.output}static import(e){if(e){if(r9(e))return ti.import(JSON.parse(e));if(e9(e))return ti.import(atob(e));if(typeof e=="object")return new ti(e);throw new Us(e)}else throw new Ot("data")}[wo](e){let t;e&&(t=wa.engine,wa.engine=e);const a=new Ur(this[Ea].map(n=>n instanceof Na||n instanceof Wd?n.roll():n).filter(n=>!!n||n===0));return e&&(wa.engine=t),a}[Yd](e){if(e instanceof Ur)this[bn]=e;else if(e instanceof jt)this[bn]=new Ur([e]);else if(Array.isArray(e))this[bn]=new Ur(e.map(t=>{if(t instanceof Ur||t instanceof jt)return t;if(Array.isArray(t))return new jt(t);if(typeof t=="object"){if(Array.isArray(t.results))return new Ur(t.results,t.modifiers||[],t.isRollGroup||!1,typeof t.useInTotal=="boolean"?t.useInTotal:!0);if(Array.isArray(t.rolls))return new jt(t.rolls)}return t}));else throw new TypeError("Rolls must be a valid result object, or an array")}}const Do={__name:"DiceRollerRenderless",props:{notation:String},emits:["notation:change","roll"],setup(r,{emit:e}){const t=r,a=xe.ref(`${t.notation||""}`),n=xe.ref(null),i=xe.ref(null),s=async()=>{n.value=null;try{i.value=a.value?new ti(xe.unref(a)):null}catch(l){i.value=null,l.name==="SyntaxError"?n.value=`Invalid notation; ${l.message}`:n.value=`An error has occurred: ${l.message}`}finally{e("roll",xe.unref(a),xe.unref(i))}},f=l=>{a.value=l,e("notation:change",l)};return(l,u)=>xe.renderSlot(l.$slots,"default",{currentNotation:a.value,error:n.value,output:i.value,roll:s,bind:{value:a.value},on:{input:o=>f(o.target.value),change:o=>f(o.target.value),keyup:o=>o.keyCode===13?s():void 0}})}},a9=()=>typeof crypto<"u"&&crypto&&crypto.randomUUID,i9=()=>a9()?crypto.randomUUID():`${Date.now().toString(32)}-${Math.random().toString(36).substring(2)}`;function bu(r){const e=xe.ref(null);return e.value=`${r}${i9()}`,{id:e}}const o9=["id"],s9=["for"],u9=["for"],l9=["id","placeholder"],c9=["onClick"],f9={__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}=bu(`${e.id||"dice-roller"}-`);return(a,n)=>(xe.openBlock(),xe.createBlock(Do,{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:xe.withCtx(({error:i,output:s,roll:f,on:l,bind:u})=>[xe.createElementVNode("section",{id:r.id,class:xe.normalizeClass(r.className)},[s?(xe.openBlock(),xe.createElementBlock("output",{key:0,name:"output",for:xe.unref(t),class:xe.normalizeClass(`${r.className}-output`)},xe.toDisplayString(s),11,s9)):xe.createCommentVNode("",!0),xe.createElementVNode("div",{class:xe.normalizeClass(`${r.className}-input-group`)},[xe.createElementVNode("label",{for:xe.unref(t),class:xe.normalizeClass(`${r.className}-label`)}," Notation ",10,u9),xe.createElementVNode("input",xe.mergeProps({type:"text",name:"notation",id:xe.unref(t),placeholder:`e.g. ${r.notation||"4d6"}`,class:[`${r.className}-input`,i?`${r.className}-input-invalid`:null]},xe.toHandlers(l,!0),u),null,16,l9),xe.createElementVNode("button",{type:"button",class:xe.normalizeClass(`${r.className}-button`),onClick:f},[xe.renderSlot(a.$slots,"button",{},()=>[xe.createTextVNode(xe.toDisplayString(r.btnLabel),1)])],10,c9)],2),i?(xe.openBlock(),xe.createElementBlock("span",{key:1,class:xe.normalizeClass(`${r.className}-error`)},xe.toDisplayString(i),3)):xe.createCommentVNode("",!0)],10,o9)]),_:3},8,["notation"]))}},m9=["id"],v9=["for"],p9={class:"flex flex-col sm:flex-row gap-y-4"},h9=["for"],d9=["id","placeholder"],g9=["onClick"],y9={key:1,class:"block mt-4 text-red-600 text-sm dark:text-red-200"},b9={__name:"DiceRollerTailwind",props:{btnLabel:{type:String,default:"Roll"},id:String,notation:String},emits:["notation:change","roll"],setup(r){const e=r,{id:t}=bu(`${e.id||"dice-roller"}-`);return(a,n)=>(xe.openBlock(),xe.createBlock(Do,{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:xe.withCtx(({error:i,output:s,roll:f,on:l,bind:u})=>[xe.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"},[s?(xe.openBlock(),xe.createElementBlock("output",{key:0,name:"output",for:xe.unref(t),class:"block mb-8 p-4 text-2xl rounded bg-white text-black dark:bg-gray-300 dark:text-gray-800 border-l-8 border-[#d4f4c6]"},xe.toDisplayString(s),9,v9)):xe.createCommentVNode("",!0),xe.createElementVNode("div",p9,[xe.createElementVNode("label",{for:xe.unref(t),class:"sr-only"}," Notation ",8,h9),xe.createElementVNode("input",xe.mergeProps({type:"text",name:"notation",id:xe.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"]},xe.toHandlers(l,!0),u),null,16,d9),xe.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},[xe.renderSlot(a.$slots,"button",{},()=>[xe.createTextVNode(xe.toDisplayString(r.btnLabel),1)])],8,g9)]),i?(xe.openBlock(),xe.createElementBlock("span",y9,xe.toDisplayString(i),1)):xe.createCommentVNode("",!0)],8,m9)]),_:3},8,["notation"]))}},x9=["id"],w9={class:"card-body"},N9=["for"],D9=["for"],A9={class:"input-group"},E9=["id","placeholder"],S9=["onClick"],C9={key:1,class:"d-block mt-3 invalid-feedback"},Sa=["primary","secondary","success","danger","warning","info","light","dark"],Qd=[...Sa,"body","white","transparent"],Kd=[...Sa,"body","muted","white","black-50","white-50"],M9=[...Sa,"link","outline-primary","outline-secondary","outline-success","outline-danger","outline-warning","outline-info","outline-light","outline-dark"],jd=[...Sa,"white"],F9={__name:"DiceRollerBootstrap",props:{bgVariant:{type:String,validator(r){return Qd.includes(r)}},borderVariant:{type:String,validator(r){return jd.includes(r)}},btnLabel:{type:String,default:"Roll"},btnVariant:{type:String,default:"primary",validator(r){return M9.includes(r)}},id:String,notation:String,outputBgVariant:{type:String,validator(r){return Qd.includes(r)}},outputBorderVariant:{type:String,validator(r){return jd.includes(r)}},outputTextVariant:{type:String,validator(r){return Kd.includes(r)}},outputVariant:{type:String,validator(r){return Sa.includes(r)}},textVariant:{type:String,validator(r){return Kd.includes(r)}},variant:{type:String,validator(r){return Sa.includes(r)}}},emits:["notation:change","roll"],setup(r){const e=r,t=xe.computed(()=>({[`text-bg-${e.variant}`]:e.variant,[`bg-${e.bgVariant}`]:e.bgVariant,[`text-${e.textVariant}`]:e.textVariant,[`border-${e.borderVariant}`]:e.borderVariant})),a=xe.computed(()=>({[`text-bg-${e.outputVariant}`]:e.outputVariant,[`bg-${e.outputBgVariant}`]:e.outputBgVariant,[`text-${e.outputTextVariant}`]:e.outputTextVariant,[`border-${e.outputBorderVariant}`]:e.outputBorderVariant})),n=xe.computed(()=>`btn-${e.btnVariant||"primary"}`),{id:i}=bu(`${e.id||"dice-roller"}-`);return(s,f)=>(xe.openBlock(),xe.createBlock(Do,{notation:r.notation,"onNotation:change":f[0]||(f[0]=l=>s.$emit("notation:change",l)),onRoll:f[1]||(f[1]=l=>s.$emit("roll",l))},{default:xe.withCtx(({error:l,output:u,roll:o,on:c,bind:m})=>[xe.createElementVNode("div",{id:r.id,class:xe.normalizeClass(["dice-roller card",xe.unref(t)])},[xe.createElementVNode("div",w9,[u?(xe.openBlock(),xe.createElementBlock("output",{key:0,name:"output",for:xe.unref(i),class:xe.normalizeClass(["d-block mb-4 p-3 fs-4 rounded border",xe.unref(a)])},xe.toDisplayString(u),11,N9)):xe.createCommentVNode("",!0),xe.createElementVNode("label",{for:xe.unref(i),class:"form-label visually-hidden"}," Notation ",8,D9),xe.createElementVNode("div",A9,[xe.createElementVNode("input",xe.mergeProps({type:"text",name:"notation",id:xe.unref(i),placeholder:`e.g. ${r.notation||"4d6"}`,class:["form-control",l?"is-invalid":""]},xe.toHandlers(c,!0),m),null,16,E9),xe.createElementVNode("button",{type:"button",class:xe.normalizeClass(["btn",xe.unref(n)]),onClick:o},[xe.renderSlot(s.$slots,"button",{},()=>[xe.createTextVNode(xe.toDisplayString(r.btnLabel),1)])],10,S9)]),l?(xe.openBlock(),xe.createElementBlock("span",C9,xe.toDisplayString(l),1)):xe.createCommentVNode("",!0)])],10,x9)]),_:3},8,["notation"]))}};kr.DiceRoller=f9,kr.DiceRollerBootstrap=F9,kr.DiceRollerRenderless=Do,kr.DiceRollerTailwind=b9,Object.defineProperties(kr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
78
+ */class Ws extends TypeError{constructor(e){super(`Operator "${e}" is invalid`),TypeError.captureStackTrace&&TypeError.captureStackTrace(this,Ws),this.name="CompareOperatorError",this.operator=e}}class Ys extends Error{constructor(e){super(`Invalid data format: ${e}`),Error.captureStackTrace&&Error.captureStackTrace(this,Ys),this.name="ImportError",this.data=e}}class ri extends Error{constructor(e,t=null){super(`Die "${e}" must have more than 1 possible value to ${t||"do this action"}`),Error.captureStackTrace&&Error.captureStackTrace(this,ri),this.name="DieActionValueError",this.action=t,this.die=e}}class yo extends Error{constructor(e){super(`Notation "${e}" is invalid`),Error.captureStackTrace&&Error.captureStackTrace(this,yo),this.name="NotationError",this.notation=e}}class Pt extends Error{constructor(e=null){super(`Missing argument${e?` "${e}"`:""}`),Error.captureStackTrace&&Error.captureStackTrace(this,Pt),this.argumentName=e}}const K6=(r,e,t)=>{const a=Number(r),n=Number(e);let i;if(Number.isNaN(a)||Number.isNaN(n))return!1;switch(t){case"=":case"==":i=a===n;break;case"<":i=a<n;break;case">":i=a>n;break;case"<=":i=a<=n;break;case">=":i=a>=n;break;case"!":case"!=":case"<>":i=a!==n;break;default:i=!1;break}return i},Sd=r=>Js(r),Mr=r=>typeof r!="number"&&typeof r!="string"?!1:!Number.isNaN(r)&&Number.isFinite(Number(r)),Qs=r=>{if(!Mr(r))return!1;const e=Number(r);return e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER},j6=r=>Array.isArray(r)?r.reduce((e,t)=>e+(Mr(t)?parseFloat(`${t}`):0),0):0,e9=(r,e=0)=>parseFloat(parseFloat(`${r}`).toFixed(e||0)),Rr=9007199254740992,ti=Rr-1,bo=-1>>>0,pt=bo+1,jt=pt/2,Ks=jt-1,ni=1<<21,Pn=ni-1;function js(r){return r.next()|0}function bn(r,e){return e===0?r:t=>r(t)+e}function eu(r){const e=r.next()|0,t=r.next()>>>0;return(e&Pn)*pt+t+(e&ni?-Rr:0)}function Cd(r){for(;;){const e=r.next()|0;if(e&4194304){if((e&8388607)===4194304&&(r.next()|0)===0)return Rr}else{const t=r.next()>>>0;return(e&Pn)*pt+t+(e&ni?-Rr:0)}}}function Md(r){return r.next()>>>0}function xo(r){const e=r.next()&Pn,t=r.next()>>>0;return e*pt+t}function ru(r){for(;;){const e=r.next()|0;if(e&ni){if((e&Pn)===0&&(r.next()|0)===0)return Rr}else{const t=r.next()>>>0;return(e&Pn)*pt+t}}}function Fd(r){return(r+1&r)===0}function r9(r){return e=>e.next()&r}function t9(r){const e=r+1,t=e*Math.floor(pt/e);return a=>{let n=0;do n=a.next()>>>0;while(n>=t);return n%e}}function n9(r){return Fd(r)?r9(r):t9(r)}function a9(r){return(r|0)===0}function i9(r){return e=>{const t=e.next()&r,a=e.next()>>>0;return t*pt+a}}function o9(r){const e=r*Math.floor(Rr/r);return t=>{let a=0;do{const n=t.next()&Pn,i=t.next()>>>0;a=n*pt+i}while(a>=e);return a%r}}function s9(r){const e=r+1;if(a9(e)){const t=(e/pt|0)-1;if(Fd(t))return i9(t)}return o9(e)}function Td(r,e){return t=>{let a=0;do{const n=t.next()|0,i=t.next()>>>0;a=(n&Pn)*pt+i+(n&ni?-Rr:0)}while(a<r||a>e);return a}}function Un(r,e){if(r=Math.floor(r),e=Math.floor(e),r<-Rr||!isFinite(r))throw new RangeError(`Expected min to be at least ${-Rr}`);if(e>Rr||!isFinite(e))throw new RangeError(`Expected max to be at most ${Rr}`);const t=e-r;return t<=0||!isFinite(t)?()=>r:t===bo?r===0?Md:bn(js,r+jt):t<bo?bn(n9(t),r):t===ti?bn(xo,r):t<ti?bn(s9(t),r):e-1-r===ti?bn(ru,r):r===-Rr&&e===Rr?Cd:r===-Rr&&e===ti?eu:r===-ti&&e===Rr?bn(eu,1):e===Rr?bn(Td(r-1,e-1),1):Td(r,e)}function u9(r){return(r.next()&1)===1}function tu(r,e){return t=>r(t)<e}function l9(r){if(r<=0)return()=>!1;if(r>=1)return()=>!0;{const e=r*pt;return e%1===0?tu(js,e-jt|0):tu(xo,Math.round(r*Rr))}}function c9(r,e){return e==null?r==null?u9:l9(r):r<=0?()=>!1:r>=e?()=>!0:tu(Un(0,e-1),r)}function f9(r,e){const t=Un(+r,+e);return a=>new Date(t(a))}function Bd(r){return Un(1,r)}function m9(r,e){const t=Bd(r);return a=>{const n=[];for(let i=0;i<e;++i)n.push(t(a));return n}}const v9="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-";function nu(r=v9){const e=r.length;if(!e)throw new Error("Expected pool not to be an empty string");const t=Un(0,e-1);return(a,n)=>{let i="";for(let o=0;o<n;++o){const f=t(a);i+=r.charAt(f)}return i}}const $d="0123456789abcdef",p9=nu($d),h9=nu($d.toUpperCase());function d9(r){return r?h9:p9}function Od(r,e){return r<0?Math.max(r+e,0):Math.min(r,e)}function Id(r){const e=+r;return e<0?Math.ceil(e):Math.floor(e)}function g9(r,e,t,a){const n=e.length;if(n===0)throw new RangeError("Cannot pick from an empty array");const i=t==null?0:Od(Id(t),n),o=a===void 0?n:Od(Id(a),n);if(i>=o)throw new RangeError(`Cannot pick between bounds ${i} and ${o}`);const f=Un(i,o-1);return e[f(r)]}function y9(r,e){return e===1?r:e===0?()=>0:t=>r(t)*e}function Rd(r){return xo(r)/Rr}function _d(r){return ru(r)/Rr}function b9(r,e,t=!1){if(isFinite(r)){if(!isFinite(e))throw new RangeError("Expected max to be a finite number")}else throw new RangeError("Expected min to be a finite number");return bn(y9(t?_d:Rd,e-r),r)}const x9=Array.prototype.slice;function au(r,e,t=0){const a=e.length;if(a)for(let n=a-1>>>0;n>t;--n){const o=Un(0,n)(r);if(n!==o){const f=e[n];e[n]=e[o],e[o]=f}}return e}function w9(r,e,t){if(t<0||t>e.length||!isFinite(t))throw new RangeError("Expected sampleSize to be within 0 and the length of the population");if(t===0)return[];const a=x9.call(e),n=a.length;if(n===t)return au(r,a,0);const i=n-t;return au(r,a,i-1).slice(i)}const N9=(()=>{try{if("x".repeat(3)==="xxx")return(r,e)=>r.repeat(e)}catch{}return(r,e)=>{let t="";for(;e>0;)e&1&&(t+=r),e>>=1,r+=r;return t}})();function Aa(r,e){return N9("0",e-r.length)+r}function D9(r){const e=r.next()>>>0,t=r.next()|0,a=r.next()|0,n=r.next()>>>0;return Aa(e.toString(16),8)+"-"+Aa((t&65535).toString(16),4)+"-"+Aa((t>>4&4095|16384).toString(16),4)+"-"+Aa((a&16383|32768).toString(16),4)+"-"+Aa((a>>4&65535).toString(16),4)+Aa(n.toString(16),8)}const Ea={next(){return Math.random()*pt|0}};class A9{constructor(e=Ea){this.engine=e}int32(){return js(this.engine)}uint32(){return Md(this.engine)}uint53(){return xo(this.engine)}uint53Full(){return ru(this.engine)}int53(){return eu(this.engine)}int53Full(){return Cd(this.engine)}integer(e,t){return Un(e,t)(this.engine)}realZeroToOneInclusive(){return _d(this.engine)}realZeroToOneExclusive(){return Rd(this.engine)}real(e,t,a=!1){return b9(e,t,a)(this.engine)}bool(e,t){return c9(e,t)(this.engine)}pick(e,t,a){return g9(this.engine,e,t,a)}shuffle(e){return au(this.engine,e)}sample(e,t){return w9(this.engine,e,t)}die(e){return Bd(e)(this.engine)}dice(e,t){return m9(e,t)(this.engine)}uuid4(){return D9(this.engine)}string(e,t){return nu(t)(this.engine,e)}hex(e,t){return d9(t)(this.engine,e)}date(e,t){return f9(e,t)(this.engine)}}const qd=(()=>{try{const r=new ArrayBuffer(4),e=new Int32Array(r);if(e[0]=jt,e[0]===-jt)return Int32Array}catch{}return Array})();let wo=null;const iu=128;let ou=iu;const E9={next(){return ou>=iu&&(wo===null&&(wo=new qd(iu)),crypto.getRandomValues(wo),ou=0),wo[ou++]|0}};function S9(r=Ea,e=16){const t=[];t.push(new Date().getTime()|0);for(let a=1;a<e;++a)t[a]=r.next()|0;return t}const su=(()=>{try{if(Math.imul(bo,5)===-5)return Math.imul}catch{}const r=65535;return(e,t)=>{const a=e>>>16&r,n=e&r,i=t>>>16&r,o=t&r;return n*o+(a*o+n*i<<16>>>0)|0}})(),Ut=624,xn=Ut-1,uu=397,zd=Ut-uu,lu=2567483615;class ai{constructor(){this.data=new qd(Ut),this.index=0,this.uses=0}static seed(e){return new ai().seed(e)}static seedWithArray(e){return new ai().seedWithArray(e)}static autoSeed(){return ai.seedWithArray(S9())}next(){(this.index|0)>=Ut&&(cu(this.data),this.index=0);const e=this.data[this.index];return this.index=this.index+1|0,this.uses+=1,C9(e)|0}getUseCount(){return this.uses}discard(e){if(e<=0)return this;for(this.uses+=e,(this.index|0)>=Ut&&(cu(this.data),this.index=0);e+this.index>Ut;)e-=Ut-this.index,cu(this.data),this.index=0;return this.index=this.index+e|0,this}seed(e){let t=0;this.data[0]=t=e|0;for(let a=1;a<Ut;a=a+1|0)this.data[a]=t=su(t^t>>>30,1812433253)+a|0;return this.index=Ut,this.uses=0,this}seedWithArray(e){return this.seed(19650218),M9(this.data,e),this}}function cu(r){let e=0,t=0;for(;(e|0)<zd;e=e+1|0)t=r[e]&jt|r[e+1|0]&Ks,r[e]=r[e+uu|0]^t>>>1^(t&1?lu:0);for(;(e|0)<xn;e=e+1|0)t=r[e]&jt|r[e+1|0]&Ks,r[e]=r[e-zd|0]^t>>>1^(t&1?lu:0);t=r[xn]&jt|r[0]&Ks,r[xn]=r[uu-1]^t>>>1^(t&1?lu:0)}function C9(r){return r^=r>>>11,r^=r<<7&2636928640,r^=r<<15&4022730752,r^r>>>18}function M9(r,e){let t=1,a=0;const n=e.length;let i=Math.max(n,Ut)|0,o=r[0]|0;for(;(i|0)>0;--i)r[t]=o=(r[t]^su(o^o>>>30,1664525))+(e[a]|0)+(a|0)|0,t=t+1|0,++a,(t|0)>xn&&(r[0]=r[xn],t=1),a>=n&&(a=0);for(i=xn;(i|0)>0;--i)r[t]=o=(r[t]^su(o^o>>>30,1566083941))-t|0,t=t+1|0,(t|0)>xn&&(r[0]=r[xn],t=1);r[0]=jt}let Pd=null;const fu=128;let mu=fu;const F9={next(){return mu>=fu&&(Pd=new Int32Array(new Int8Array(require("crypto").randomBytes(4*fu)).buffer),mu=0),Pd[mu++]|0}},ii=Symbol("engine"),vu=Symbol("random"),Ud={browserCrypto:E9,nodeCrypto:F9,MersenneTwister19937:ai,nativeMath:Ea,min:{next(){return 0}},max:{range:[],next(){return this.range[1]-this.range[0]}}};class T9{constructor(e=Ea){this.engine=e||Ea}get engine(){return this[ii]}set engine(e){if(e&&typeof e.next!="function")throw new TypeError("engine must have function `next()`");this[ii]=e||Ea,this[vu]=new A9(this[ii])}integer(e,t){return this[ii].range=[e,t],this[vu].integer(e,t)}real(e,t,a=!1){return this[ii].range=[e,t],this[vu].real(e,t,a)}}const Sa=new T9,Ld=Symbol("text"),kd=Symbol("type");class Ct{constructor(e,t=this.constructor.types.INLINE){this.text=e,this.type=t}get text(){return this[Ld]}set text(e){if(typeof e=="object")throw new TypeError("Description text is invalid");if(!e&&e!==0||`${e}`.trim()==="")throw new TypeError("Description text cannot be empty");this[Ld]=`${e}`.trim()}get type(){return this[kd]}set type(e){const t=Object.values(this.constructor.types);if(typeof e!="string")throw new TypeError("Description type must be a string");if(!t.includes(e))throw new RangeError(`Description type must be one of; ${t.join(", ")}`);this[kd]=e}toJSON(){const{text:e,type:t}=this;return{text:e,type:t}}toString(){return this.type===this.constructor.types.INLINE?`# ${this.text}`:`[${this.text}]`}}tt(Ct,"types",{MULTILINE:"multiline",INLINE:"inline"});const No=Symbol("description");class Vd{constructor(e=null){this.description=e}get description(){return this[No]||null}set description(e){if(!e&&e!==0)this[No]=null;else if(e instanceof Ct)this[No]=e;else if(typeof e=="string")this[No]=new Ct(e);else throw new TypeError(`description must be of type Description, string or null. Received ${typeof e}`)}toJSON(){const{description:e}=this;return{description:e}}toString(){return this.description?`${this.description}`:""}}class en{constructor(){this.order=this.constructor.order}get name(){return"modifier"}get notation(){return""}get maxIterations(){return 1e3}defaults(e){return{}}useDefaultsIfNeeded(e){Object.entries(this.defaults(e)).forEach(([t,a])=>{typeof this[t]>"u"&&(this[t]=a)})}run(e,t){return this.useDefaultsIfNeeded(t),e}toJSON(){const{notation:e,name:t}=this;return{name:t,notation:e,type:"modifier"}}toString(){return this.notation}}tt(en,"order",999);const B9={compound:"!",explode:"!","critical-failure":"__","critical-success":"**",drop:"d",max:"v",min:"^",penetrate:"p","re-roll":"r","re-roll-once":"ro","target-failure":"_","target-success":"*",unique:"u","unique-once":"uo"},Gd=(...r)=>[...r].reduce((e,t)=>{let a;return t instanceof en?a=t.name:a=t,e+(B9[a]||a)},""),pu=Symbol("calculation-value"),hu=Symbol("modifiers"),oi=Symbol("initial-value"),Hd=Symbol("use-in-total"),du=Symbol("value");class Do{constructor(e,t=[],a=!0){if(Mr(e))this[oi]=Number(e),this.modifiers=t||[],this.useInTotal=a;else if(e&&typeof e=="object"&&!Array.isArray(e)){const n=Mr(e.initialValue)?e.initialValue:e.value;if(!Mr(n))throw new TypeError(`Result value is invalid: ${n}`);this[oi]=Number(n),Mr(e.value)&&Number(e.value)!==this[oi]&&(this.value=e.value),Mr(e.calculationValue)&&parseFloat(`${e.calculationValue}`)!==this.value&&(this.calculationValue=e.calculationValue),this.modifiers=e.modifiers||t||[],this.useInTotal=typeof e.useInTotal=="boolean"?e.useInTotal:a||!1}else throw e===1/0?new RangeError("Result value must be a finite number"):new TypeError(`Result value is invalid: ${e}`)}get calculationValue(){return Mr(this[pu])?parseFloat(this[pu]):this.value}set calculationValue(e){const t=Mr(e);if(e===1/0)throw new RangeError("Result calculation value must be a finite number");if(e&&!t)throw new TypeError(`Result calculation value is invalid: ${e}`);this[pu]=t?parseFloat(`${e}`):null}get initialValue(){return this[oi]}get modifierFlags(){return Gd(...this.modifiers)}get modifiers(){return this[hu]}set modifiers(e){if((Array.isArray(e)||e instanceof Set)&&[...e].every(t=>typeof t=="string")){this[hu]=new Set([...e]);return}if(!e&&e!==0){this[hu]=new Set;return}throw new TypeError(`modifiers must be a Set or array of modifier names: ${e}`)}get useInTotal(){return!!this[Hd]}set useInTotal(e){this[Hd]=!!e}get value(){return Mr(this[du])?this[du]:this[oi]}set value(e){if(e===1/0)throw new RangeError("Result value must be a finite number");if(!Mr(e))throw new TypeError(`Result value is invalid: ${e}`);this[du]=Number(e)}toJSON(){const{calculationValue:e,initialValue:t,modifierFlags:a,modifiers:n,useInTotal:i,value:o}=this;return{calculationValue:e,initialValue:t,modifierFlags:a,modifiers:[...n],type:"result",useInTotal:i,value:o}}toString(){return this.value+this.modifierFlags}}const gu=Symbol("rolls");class rn{constructor(e=[]){this.rolls=e}get length(){return this.rolls.length||0}get rolls(){return[...this[gu]]}set rolls(e){if(!e||!Array.isArray(e))throw new TypeError(`rolls must be an array: ${e}`);this[gu]=[],e.forEach(t=>{this.addRoll(t)})}get value(){return this.rolls.reduce((e,t)=>e+(t.useInTotal?t.calculationValue:0),0)}addRoll(e){const t=e instanceof Do?e:new Do(e);this[gu].push(t)}toJSON(){const{rolls:e,value:t}=this;return{rolls:e,type:"roll-results",value:t}}toString(){return`[${this.rolls.join(", ")}]`}}const yu=Symbol("modifiers"),Zd=Symbol("qty"),Jd=Symbol("sides"),Xd=Symbol("min-value"),Wd=Symbol("max-value");class Ca extends Vd{constructor(e,t=1,a=null,n=1,i=null,o=null){if(super(o),!e&&e!==0)throw new Pt("sides");if(e===1/0)throw new RangeError("numerical sides must be finite number");if(Mr(e)){if(e<1||!Qs(e))throw new RangeError("numerical sides must be a positive finite number")}else if(typeof e!="string")throw new TypeError("non-numerical sides must be a string");if(Mr(t)){if(t<1||t>999)throw new RangeError("qty must be between 1 and 999")}else throw new TypeError("qty must be a positive finite integer");let f=n;if(f==null)f=1;else if(Mr(f)){if(!Qs(f))throw new RangeError("min must a finite number")}else throw new TypeError("min must a finite number");if(i&&!Mr(i))throw new TypeError("max must a finite number");if(i&&!Qs(i))throw new RangeError("max must a finite number");this[Zd]=parseInt(`${t}`,10),this[Jd]=e,a&&(this.modifiers=a),this[Xd]=parseInt(f,10),this[Wd]=i?parseInt(`${i}`,10):e}get average(){return(this.min+this.max)/2}get modifiers(){return this[yu]?new Map([...this[yu]].sort((e,t)=>e[1].order-t[1].order)):null}set modifiers(e){let t;if(e instanceof Map)t=e;else if(Array.isArray(e))t=new Map(e.map(a=>[a.name,a]));else if(typeof e=="object")t=new Map(Object.entries(e));else throw new TypeError("modifiers should be a Map, array, or an Object containing Modifiers");if(t.size&&[...t.entries()].some(a=>!(a[1]instanceof en)))throw new TypeError("modifiers must only contain Modifier instances");this[yu]=t}get max(){return this[Wd]}get min(){return this[Xd]}get name(){return"standard"}get notation(){let e=`${this.qty}d${this.sides}`;return this.modifiers&&this.modifiers.size&&(e+=[...this.modifiers.values()].reduce((t,a)=>t+a.notation,"")),e}get qty(){return this[Zd]}get sides(){return this[Jd]}roll(){const e=new rn;for(let t=0;t<this.qty;t++)e.addRoll(this.rollOnce());return(this.modifiers||[]).forEach(t=>{t.run(e,this)}),e}rollOnce(){return new Do(Sa.integer(this.min,this.max))}toJSON(){const{average:e,max:t,min:a,modifiers:n,name:i,notation:o,qty:f,sides:l}=this;return Object.assign(super.toJSON(),{average:e,max:t,min:a,modifiers:n,name:i,notation:o,qty:f,sides:l,type:"die"})}toString(){return`${this.notation}${this.description?` ${this.description}`:""}`}}class $9 extends Ca{constructor(e=2,t=1,a=null,n=null){let i=e;if(!i&&i!==0)i=2;else if(i!==1&&i!==2)throw new RangeError("nonBlanks must be 1 or 2");super(i,t,a,-1,1,n)}get name(){return"fudge"}get nonBlanks(){return super.sides}get sides(){return`F.${this.nonBlanks}`}rollOnce(){let e=0;if(this.nonBlanks===2)e=Sa.integer(1,3)-2;else if(this.nonBlanks===1){const t=Sa.integer(1,6);t===1?e=-1:t===6&&(e=1)}return new Do(e)}}class O9 extends Ca{constructor(e=1,t=null,a=!1,n=null){super(100,e,t,null,null,n),this.sidesAsNumber=!!a}get name(){return"percentile"}get sides(){return this.sidesAsNumber?super.sides:"%"}}const Yd=Symbol("operator"),Qd=Symbol("value");class Ao{constructor(e,t){if(e){if(!t&&t!==0)throw new Pt("value")}else throw new Pt("operator");this.operator=e,this.value=t}static isValidOperator(e){return typeof e=="string"&&/^(?:[<>!]?=|[<>]|<>)$/.test(e)}set operator(e){if(!this.constructor.isValidOperator(e))throw new Ws(e);this[Yd]=e}get operator(){return this[Yd]}set value(e){if(!Mr(e))throw new TypeError("value must be a finite number");this[Qd]=Number(e)}get value(){return this[Qd]}isMatch(e){return K6(e,this.value,this.operator)}toJSON(){const{operator:e,value:t}=this;return{operator:e,type:"compare-point",value:t}}toString(){return`${this.operator}${this.value}`}}const Kd=Symbol("compare-point");class Ma extends en{constructor(e){super(),e&&(this.comparePoint=e)}get comparePoint(){return this[Kd]}set comparePoint(e){if(!(e instanceof Ao))throw new TypeError("comparePoint must be instance of ComparePoint");this[Kd]=e}get name(){return"comparison"}get notation(){return`${this.comparePoint||""}`}defaultComparePoint(e){return{}}defaults(e){const t=this.defaultComparePoint(e);return typeof t=="object"&&t.length===2?{comparePoint:new Ao(...t)}:{}}isComparePoint(e){return this.comparePoint?this.comparePoint.isMatch(e):!1}toJSON(){const{comparePoint:e}=this;return Object.assign(super.toJSON(),{comparePoint:e})}}class jd extends Ma{constructor(e){super(e)}get name(){return"critical-failure"}get notation(){return`cf${super.notation}`}defaultComparePoint(e){return["=",e.min]}run(e,t){return super.run(e,t),e.rolls.forEach(a=>(this.isComparePoint(a.value)&&a.modifiers.add("critical-failure"),a)),e}}tt(jd,"order",10);class e0 extends Ma{constructor(e){super(e)}get name(){return"critical-success"}get notation(){return`cs${super.notation}`}defaultComparePoint(e){return["=",e.max]}run(e,t){return super.run(e,t),e.rolls.forEach(a=>(this.isComparePoint(a.value)&&a.modifiers.add("critical-success"),a)),e}}tt(e0,"order",9);const bu=Symbol("calculation-value"),r0=Symbol("is-roll-group"),xu=Symbol("modifiers"),wu=Symbol("results"),t0=Symbol("use-in-total");class kr{constructor(e=[],t=[],a=!1,n=!0){this.isRollGroup=a,this.modifiers=t,this.results=e,this.useInTotal=n}get calculationValue(){return Mr(this[bu])?parseFloat(this[bu]):this.value}set calculationValue(e){const t=Mr(e);if(e===1/0)throw new RangeError("Results calculation value must be a finite number");if(e&&!t)throw new TypeError(`Results calculation value is invalid: ${e}`);this[bu]=t?parseFloat(`${e}`):null}get isRollGroup(){return this[r0]}set isRollGroup(e){this[r0]=!!e}get length(){return this.results.length||0}get modifierFlags(){return Gd(...this.modifiers)}get modifiers(){return this[xu]}set modifiers(e){if((Array.isArray(e)||e instanceof Set)&&[...e].every(t=>typeof t=="string"))this[xu]=new Set([...e]);else if(!e&&e!==0)this[xu]=new Set;else throw new TypeError(`modifiers must be a Set or array of modifier names: ${e}`)}get results(){return[...this[wu]]}set results(e){if(!e||!Array.isArray(e))throw new TypeError(`results must be an array: ${e}`);this[wu]=[],e.forEach(t=>{this.addResult(t)})}get useInTotal(){return!!this[t0]}set useInTotal(e){this[t0]=!!e}get value(){if(!this.results.length)return 0;const e=this.results.reduce((t,a)=>{let n=a;return a instanceof kr?n=a.useInTotal?a.calculationValue:0:a instanceof rn&&(n=a.value),t+n},typeof this.results[0]=="string"?"":0);return typeof e=="string"?Sd(e):e}addResult(e){let t;if(e instanceof kr||e instanceof rn)t=e;else if(typeof e=="string"||Mr(e))t=e;else throw new TypeError("value must be one of ResultGroup, RollResults, string, or number");this[wu].push(t)}toJSON(){const{calculationValue:e,isRollGroup:t,modifierFlags:a,modifiers:n,results:i,useInTotal:o,value:f}=this;return{calculationValue:e,isRollGroup:t,modifierFlags:a,modifiers:[...n],results:i,type:"result-group",useInTotal:o,value:f}}toString(){let e;return this.isRollGroup?e=`{${this.results.join(", ")}}`:e=this.results.join(""),this.modifierFlags&&(e=`(${e})${this.modifierFlags}`),e}}const n0=Symbol("end"),a0=Symbol("qty");class Nu extends en{constructor(e="h",t=1){super(),this.end=e,this.qty=t}get end(){return this[n0]}set end(e){if(e!=="h"&&e!=="l")throw new RangeError('End must be "h" or "l"');this[n0]=e}get name(){return`keep-${this.end}`}get notation(){return`k${this.end}${this.qty}`}get qty(){return this[a0]}set qty(e){if(e===1/0)throw new RangeError("qty must be a finite number");if(!Mr(e)||e<1)throw new TypeError("qty must be a positive finite integer");this[a0]=Math.floor(e)}rangeToDrop(e){return this.end==="h"?[0,e.length-this.qty]:[this.qty,e.length]}run(e,t){let a,n;return e instanceof kr?(a=e.results,a.length===1&&a[0]instanceof kr?n=a[0].results.map((i,o)=>i instanceof rn?i.rolls.map((f,l)=>({value:f.value,index:[o,l]})):null).flat().filter(Boolean):n=[...a].map((i,o)=>({value:i.value,index:o}))):(a=e.rolls,n=[...a].map((i,o)=>({value:i.value,index:o}))),n=n.sort((i,o)=>i.value-o.value).map(i=>i.index).slice(...this.rangeToDrop(n)),n.forEach(i=>{let o;Array.isArray(i)?o=a[0].results[i[0]].rolls[i[1]]:o=a[i],o.modifiers.add("drop"),o.useInTotal=!1}),e}toJSON(){const{end:e,qty:t}=this;return Object.assign(super.toJSON(),{end:e,qty:t})}}tt(Nu,"order",6);class i0 extends Nu{constructor(e="l",t=1){super(e,t)}get name(){return`drop-${this.end}`}get notation(){return`d${this.end}${this.qty}`}rangeToDrop(e){return this.end==="h"?[e.length-this.qty,e.length]:[0,this.qty]}}tt(i0,"order",7);const o0=Symbol("compound"),s0=Symbol("penetrate");class u0 extends Ma{constructor(e=null,t=!1,a=!1){super(e),this[o0]=!!t,this[s0]=!!a}get compound(){return this[o0]}get name(){return"explode"}get notation(){return`!${this.compound?"!":""}${this.penetrate?"p":""}${super.notation}`}get penetrate(){return this[s0]}defaultComparePoint(e){return["=",e.max]}run(e,t){if(super.run(e,t),t.min===t.max)throw new ri(t,"explode");const a=e;return a.rolls=e.rolls.map(n=>{const i=[n];let o=n.value;for(let f=0;f<this.maxIterations&&this.isComparePoint(o);f++){const l=i[i.length-1],u=t.rollOnce();o=u.value,l.modifiers.add("explode"),this.penetrate&&(l.modifiers.add("penetrate"),u.value-=1),i.push(u)}return this.compound&&i.length>1?(n.value=j6(i.map(f=>f.value)),n.modifiers=["explode","compound"],this.penetrate&&n.modifiers.add("penetrate"),n):i}).flat(),a}toJSON(){const{compound:e,penetrate:t}=this;return Object.assign(super.toJSON(),{compound:e,penetrate:t})}}tt(u0,"order",3);const l0=Symbol("max");class c0 extends en{constructor(e){super(),this.max=e}get max(){return this[l0]}set max(e){if(!Mr(e))throw new TypeError("max must be a number");this[l0]=parseFloat(`${e}`)}get name(){return"max"}get notation(){return`max${this.max}`}run(e,t){const a=e;return a.rolls=e.rolls.map(n=>{const i=n;return n.value>this.max&&(i.value=this.max,i.modifiers.add("max")),i}),a}toJSON(){const{max:e}=this;return Object.assign(super.toJSON(),{max:e})}}tt(c0,"order",2);const f0=Symbol("min");class m0 extends en{constructor(e){super(),this.min=e}get min(){return this[f0]}set min(e){if(!Mr(e))throw new TypeError("min must be a number");this[f0]=parseFloat(`${e}`)}get name(){return"min"}get notation(){return`min${this.min}`}run(e,t){const a=e;return a.rolls=e.rolls.map(n=>{const i=n;return n.value<this.min&&(i.value=this.min,i.modifiers.add("min")),i}),a}toJSON(){const{min:e}=this;return Object.assign(super.toJSON(),{min:e})}}tt(m0,"order",1);const v0=Symbol("once");class p0 extends Ma{constructor(e=!1,t=null){super(t),this.once=!!e}get name(){return"re-roll"}get notation(){return`r${this.once?"o":""}${super.notation}`}get once(){return!!this[v0]}set once(e){this[v0]=!!e}defaultComparePoint(e){return["=",e.min]}run(e,t){if(super.run(e,t),t.min===t.max)throw new ri(t,"re-roll");return e.rolls.map(a=>{for(let n=0;n<this.maxIterations&&this.isComparePoint(a.value);n++){const i=t.rollOnce();if(a.value=i.value,a.modifiers.add(`re-roll${this.once?"-once":""}`),this.once)break}return a}),e}toJSON(){const{once:e}=this;return Object.assign(super.toJSON(),{once:e})}}tt(p0,"order",4);const h0=Symbol("direction");class d0 extends en{constructor(e="a"){super(),this.direction=e}get direction(){return this[h0]}set direction(e){if(e!=="a"&&e!=="d")throw new RangeError('Direction must be "a" (Ascending) or "d" (Descending)');this[h0]=e}get name(){return"sorting"}get notation(){return`s${this.direction}`}run(e,t){let a;return e instanceof kr?a="results":a="rolls",e[a]=e[a].sort((n,i)=>this.direction==="d"?i.value-n.value:n.value-i.value),e instanceof kr&&(e[a]=e[a].map(n=>n instanceof kr||n instanceof rn?this.run(n,t):n)),e}toJSON(){const{direction:e}=this;return Object.assign(super.toJSON(),{direction:e})}}tt(d0,"order",11);const g0=Symbol("failure-cp");class y0 extends Ma{constructor(e,t=null){super(e),this.failureComparePoint=t}get failureComparePoint(){return this[g0]}set failureComparePoint(e){if(e&&!(e instanceof Ao))throw new TypeError("failure comparePoint must be instance of ComparePoint or null");this[g0]=e||null}get name(){return"target"}get notation(){return`${super.notation}${this.failureComparePoint?`f${this.failureComparePoint}`:""}`}get successComparePoint(){return this.comparePoint}set successComparePoint(e){super.comparePoint=e}getStateValue(e){return this.isSuccess(e)?1:this.isFailure(e)?-1:0}isFailure(e){return this.failureComparePoint?this.failureComparePoint.isMatch(e):!1}isNeutral(e){return!this.isSuccess(e)&&!this.isFailure(e)}isSuccess(e){return this.isComparePoint(e)}run(e,t){let a;return e instanceof kr?a=e.results:a=e.rolls,a.forEach(n=>{this.isSuccess(n.value)?n.modifiers.add("target-success"):this.isFailure(n.value)&&n.modifiers.add("target-failure"),n.calculationValue=this.getStateValue(n.value)}),e}toJSON(){const{failureComparePoint:e,successComparePoint:t}=this,a=super.toJSON();return delete a.comparePoint,Object.assign(a,{failureComparePoint:e,successComparePoint:t})}}tt(y0,"order",8);const b0=Symbol("once"),I9=(r,e,t,a=!1)=>{const n=t.map(i=>i.value).indexOf(r.value);return a?n<e:n!==e};class x0 extends Ma{constructor(e=!1,t=null){super(t),this.once=!!e}get name(){return"unique"}get notation(){return`u${this.once?"o":""}${super.notation}`}get once(){return!!this[b0]}set once(e){this[b0]=!!e}run(e,t){if(t.min===t.max)throw new ri(t,"re-roll");return e.rolls.forEach((a,n,i)=>{if(n!==0)for(let o=0;o<this.maxIterations&&(!this.comparePoint||this.isComparePoint(a.value))&&I9(a,n,i,!0);o++){const f=t.rollOnce();if(a.value=f.value,a.modifiers.add(`unique${this.once?"-once":""}`),this.once)break}}),e}toJSON(){const{once:e}=this;return Object.assign(super.toJSON(),{once:e})}}tt(x0,"order",5);const R9=r=>{try{return!!(r&&btoa(atob(r))===r)}catch{return!1}},_9=r=>{try{const e=r?JSON.parse(r):!1;return!!(e&&typeof e=="object")}catch{return!1}},Du=Symbol("expressions"),Au=Symbol("modifiers");class w0 extends Vd{constructor(e=[],t=[],a=null){super(a),this.expressions=e,this.modifiers=t}get expressions(){return[...this[Du]||[]]}set expressions(e){if(!e)throw new Pt("expressions");if(!Array.isArray(e))throw new TypeError(`expressions must be an array: ${e}`);this[Du]=[],e.forEach(t=>{if(!t||!Array.isArray(t))throw new TypeError(`Expressions must be an array of arrays: ${e}`);if(t.length===0)throw new TypeError(`Sub expressions cannot be empty: ${e}`);if(!t.every(a=>a instanceof Ca||typeof a=="string"||typeof a=="number"))throw new TypeError("Sub expression items must be Dice, numbers, or strings");this[Du].push(t)})}get modifiers(){return this[Au]?new Map([...this[Au]].sort((e,t)=>e[1].order-t[1].order)):null}set modifiers(e){let t;if(e instanceof Map)t=e;else if(Array.isArray(e))t=new Map(e.map(a=>[a.name,a]));else if(typeof e=="object")t=new Map(Object.entries(e));else throw new TypeError("modifiers should be a Map, array, or an Object containing Modifiers");if(t.size&&[...t.entries()].some(a=>!(a[1]instanceof en)))throw new TypeError("modifiers must only contain Modifier instances");this[Au]=t}get notation(){let e=this.expressions.map(t=>t.reduce((a,n)=>a+n,"")).join(", ");return e=`{${e}}`,this.modifiers&&this.modifiers.size&&(e+=[...this.modifiers.values()].reduce((t,a)=>t+a.notation,"")),e}roll(){const e=new kr(this.expressions.map(t=>{const a=t.map(n=>n instanceof Ca?n.roll():n);return new kr(a)}));return e.isRollGroup=!0,(this.modifiers||[]).forEach(t=>{t.run(e,this)}),e}toJSON(){const{modifiers:e,notation:t,expressions:a}=this;return Object.assign(super.toJSON(),{expressions:a,modifiers:e,notation:t,type:"group"})}toString(){return`${this.notation}${this.description?` ${this.description}`:""}`}}function q9(r,e){function t(){this.constructor=r}t.prototype=e.prototype,r.prototype=new t}function Fa(r,e,t,a){var n=Error.call(this,r);return Object.setPrototypeOf&&Object.setPrototypeOf(n,Fa.prototype),n.expected=e,n.found=t,n.location=a,n.name="SyntaxError",n}q9(Fa,Error);function Eu(r,e,t){return t=t||" ",r.length>e?r:(e-=r.length,t+=t.repeat(e),r+t.slice(0,e))}Fa.prototype.format=function(r){var e="Error: "+this.message;if(this.location){var t=null,a;for(a=0;a<r.length;a++)if(r[a].source===this.location.source){t=r[a].text.split(/\r\n|\n|\r/g);break}var n=this.location.start,i=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(n):n,o=this.location.source+":"+i.line+":"+i.column;if(t){var f=this.location.end,l=Eu("",i.line.toString().length," "),u=t[n.line-1],s=n.line===f.line?f.column:u.length+1,c=s-n.column||1;e+=`
79
+ --> `+o+`
80
+ `+l+` |
81
+ `+i.line+" | "+u+`
82
+ `+l+" | "+Eu("",n.column-1," ")+Eu("",c,"^")}else e+=`
83
+ at `+o}return e},Fa.buildMessage=function(r,e){var t={literal:function(u){return'"'+n(u.text)+'"'},class:function(u){var s=u.parts.map(function(c){return Array.isArray(c)?i(c[0])+"-"+i(c[1]):i(c)});return"["+(u.inverted?"^":"")+s.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(u){return u.description}};function a(u){return u.charCodeAt(0).toString(16).toUpperCase()}function n(u){return u.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(s){return"\\x0"+a(s)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(s){return"\\x"+a(s)})}function i(u){return u.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(s){return"\\x0"+a(s)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(s){return"\\x"+a(s)})}function o(u){return t[u.type](u)}function f(u){var s=u.map(o),c,m;if(s.sort(),s.length>0){for(c=1,m=1;c<s.length;c++)s[c-1]!==s[c]&&(s[m]=s[c],m++);s.length=m}switch(s.length){case 1:return s[0];case 2:return s[0]+" or "+s[1];default:return s.slice(0,-1).join(", ")+", or "+s[s.length-1]}}function l(u){return u?'"'+n(u)+'"':"end of input"}return"Expected "+f(r)+" but "+l(e)+" found."};function z9(r,e){e=e!==void 0?e:{};var t={},a=e.grammarSource,n={Main:T0},i=T0,o="{",f=",",l="}",u="d",s="d%",c="dF",m=".",v="!",h="p",p="k",g="max",y="min",N="r",d="o",w="u",x="cs",b="cf",E="s",A="a",S="f",D="!=",T="<=",B=">=",I="=",P="<>",R=">",M="<",F="(",H=")",$="abs",k="ceil",Q="cos",K="exp",L="floor",j="log",ae="round",re="sign",fe="sin",he="sqrt",ce="tan",ie="pow",Ae="-",Oe="**",Ce="*",$e="^",V="%",X="/",oe="+",G="/*",Y="*/",te="[",ye="]",me="//",z="#",U=/^[12]/,ee=/^[lh]/,ue=/^[.]/,ve=/^[1-9]/,de=/^[0-9]/,be=/^[^\]]/,pe=/^[\n\r\u2028\u2029]/,we=/^[ \t\n\r]/,_e=Ue("{",!1),Le=Ue(",",!1),Be=Ue("}",!1),ar=Ue("d",!1),Je=Ue("d%",!1),mr=Ue("dF",!1),C=Ue(".",!1),Z=Dn(["1","2"],!1,!1),se=Ue("!",!1),Ee=Ue("p",!1),ze=Dn(["l","h"],!1,!1),ke=Ue("k",!1),Fr=Ue("max",!1),_r=Ue("min",!1),tn=Ue("r",!1),Ln=Ue("o",!1),kn=Ue("u",!1),Bu=Ue("cs",!1),$u=Ue("cf",!1),Ou=Ue("s",!1),Iu=Ue("a",!1),Ru=Ue("f",!1),_u=Ue("!=",!1),qu=Ue("<=",!1),zu=Ue(">=",!1),Pu=Ue("=",!1),Vn=Ue("<>",!1),Uu=Ue(">",!1),Lu=Ue("<",!1),Oa=Ue("(",!1),Ia=Ue(")",!1),ku=Ue("abs",!1),Vu=Ue("ceil",!1),Gu=Ue("cos",!1),Hu=Ue("exp",!1),Zu=Ue("floor",!1),Ju=Ue("log",!1),Xu=Ue("round",!1),Wu=Ue("sign",!1),Yu=Ue("sin",!1),Qu=Ue("sqrt",!1),Ku=Ue("tan",!1),ju=Ue("pow",!1),Mo=Ue("-",!1),Gn=Dn(["."],!1,!1),jr=Dn([["1","9"]],!1,!1),Tr=Dn([["0","9"]],!1,!1),Fo=Ue("**",!1),el=Ue("*",!1),Ra=Ue("^",!1),_a=Ue("%",!1),To=Ue("/",!1),Bo=Ue("+",!1),Nn=nl("comment"),f7=Ue("/*",!1),rl=Ue("*/",!1),$o=Y7(),m7=Ue("[",!1),C0=Dn(["]"],!0,!1),v7=Ue("]",!1),p7=Ue("//",!1),h7=Ue("#",!1),d7=Dn([`
84
+ `,"\r","\u2028","\u2029"],!1,!1),g7=nl("whitespace"),y7=Dn([" "," ",`
85
+ `,"\r"],!1,!1),b7=nl("whitespace or comment"),x7=function(O,W,ne,le){return new w0([O,...W.map(Se=>Se[3])],Object.assign({},...ne.map(Se=>({[Se.name]:Se}))),le.find(Se=>Se instanceof Ct))},w7=function(O,W,ne){return O.modifiers=Object.assign({},...W.map(le=>({[le.name]:le}))),O.description=ne.find(le=>le instanceof Ct),O},N7=function(O,W){return new Ca(W,O||1)},D7=function(O){return new O9(O||1)},A7=function(O,W){return new $9(W?parseInt(W[1],10):2,O||1)},E7=function(O,W,ne){return new u0(ne,!!O,!!W)},S7=function(O,W){return new y0(O,W)},C7=function(O,W){return new i0(O||"l",W)},M7=function(O,W){return new Nu(O||"h",W)},F7=function(O){return new c0(O)},T7=function(O){return new m0(O)},B7=function(O,W){return new p0(!!O,W)},$7=function(O,W){return new x0(!!O,W)},O7=function(O){return new e0(O)},I7=function(O){return new jd(O)},R7=function(O){return new d0(O||"a")},_7=function(O){return O},q7=function(O,W){return new Ao(O,W)},z7=function(O,W,ne){return Sd(Ro())},P7=function(O,W){return O=Array.isArray(O)?O:[O],[...O,...W.map(([,ne,,le])=>[ne,le]).flat(2)]},U7=function(O,W,ne){return[O,...W,ne]},L7=function(O,W){return[`${O}(`,...W,")"]},k7=function(O,W,ne){return[`${O}(`,...W,",",...ne,")"]},V7=function(){return parseFloat(Ro())},G7=function(){return parseInt(Ro(),10)},H7=function(){return parseInt(Ro(),10)},Z7=function(){return"^"},J7=function(O){return new Ct(O.flat().join(""),Ct.types.MULTILINE)},X7=function(O){return new Ct(O.flat().join(""),Ct.types.MULTILINE)},W7=function(O){return new Ct(O.flat().join(""),Ct.types.INLINE)},_=0,lr=0,Oo=[{line:1,column:1}],Lt=0,tl=[],De=0,Io;if("startRule"in e){if(!(e.startRule in n))throw new Error(`Can't start parsing from rule "`+e.startRule+'".');i=n[e.startRule]}function Ro(){return r.substring(lr,_)}function Ue(O,W){return{type:"literal",text:O,ignoreCase:W}}function Dn(O,W,ne){return{type:"class",parts:O,inverted:W,ignoreCase:ne}}function Y7(){return{type:"any"}}function Q7(){return{type:"end"}}function nl(O){return{type:"other",description:O}}function M0(O){var W=Oo[O],ne;if(W)return W;for(ne=O-1;!Oo[ne];)ne--;for(W=Oo[ne],W={line:W.line,column:W.column};ne<O;)r.charCodeAt(ne)===10?(W.line++,W.column=1):W.column++,ne++;return Oo[O]=W,W}function F0(O,W,ne){var le=M0(O),Se=M0(W),Ie={source:a,start:{offset:O,line:le.line,column:le.column},end:{offset:W,line:Se.line,column:Se.column}};return ne&&a&&typeof a.offset=="function"&&(Ie.start=a.offset(Ie.start),Ie.end=a.offset(Ie.end)),Ie}function Fe(O){_<Lt||(_>Lt&&(Lt=_,tl=[]),tl.push(O))}function K7(O,W,ne){return new Fa(Fa.buildMessage(O,W),O,W,ne)}function T0(){var O;return O=An(),O}function j7(){var O,W,ne,le,Se,Ie,hr,Er,Mt;if(O=_,r.charCodeAt(_)===123?(W=o,_++):(W=t,De===0&&Fe(_e)),W!==t)if(Ar(),ne=An(),ne!==t){for(le=[],Se=_,Ie=Ar(),r.charCodeAt(_)===44?(hr=f,_++):(hr=t,De===0&&Fe(Le)),hr!==t?(Er=Ar(),Mt=An(),Mt!==t?(Ie=[Ie,hr,Er,Mt],Se=Ie):(_=Se,Se=t)):(_=Se,Se=t);Se!==t;)le.push(Se),Se=_,Ie=Ar(),r.charCodeAt(_)===44?(hr=f,_++):(hr=t,De===0&&Fe(Le)),hr!==t?(Er=Ar(),Mt=An(),Mt!==t?(Ie=[Ie,hr,Er,Mt],Se=Ie):(_=Se,Se=t)):(_=Se,Se=t);if(Se=Ar(),r.charCodeAt(_)===125?(Ie=l,_++):(Ie=t,De===0&&Fe(Be)),Ie!==t){for(hr=[],Er=_o();Er!==t;)hr.push(Er),Er=_o();Er=I0(),lr=O,O=x7(ne,le,hr,Er)}else _=O,O=t}else _=O,O=t;else _=O,O=t;return O}function eI(){var O,W,ne,le;if(O=_,W=rI(),W===t&&(W=tI(),W===t&&(W=nI())),W!==t){for(ne=[],le=_o();le!==t;)ne.push(le),le=_o();le=I0(),lr=O,O=w7(W,ne,le)}else _=O,O=t;return O}function rI(){var O,W,ne,le;return O=_,W=qo(),W===t&&(W=null),r.charCodeAt(_)===100?(ne=u,_++):(ne=t,De===0&&Fe(ar)),ne!==t?(le=qo(),le!==t?(lr=O,O=N7(W,le)):(_=O,O=t)):(_=O,O=t),O}function tI(){var O,W,ne;return O=_,W=qo(),W===t&&(W=null),r.substr(_,2)===s?(ne=s,_+=2):(ne=t,De===0&&Fe(Je)),ne!==t?(lr=O,O=D7(W)):(_=O,O=t),O}function nI(){var O,W,ne,le,Se,Ie;return O=_,W=qo(),W===t&&(W=null),r.substr(_,2)===c?(ne=c,_+=2):(ne=t,De===0&&Fe(mr)),ne!==t?(le=_,r.charCodeAt(_)===46?(Se=m,_++):(Se=t,De===0&&Fe(C)),Se!==t?(U.test(r.charAt(_))?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe(Z)),Ie!==t?(Se=[Se,Ie],le=Se):(_=le,le=t)):(_=le,le=t),le===t&&(le=null),lr=O,O=A7(W,le)):(_=O,O=t),O}function _o(){var O;return O=aI(),O===t&&(O=iI(),O===t&&(O=oI(),O===t&&(O=sI(),O===t&&(O=cI(),O===t&&(O=fI(),O===t&&(O=mI(),O===t&&(O=vI(),O===t&&(O=pI(),O===t&&(O=uI(),O===t&&(O=lI())))))))))),O}function aI(){var O,W,ne,le,Se;return O=_,r.charCodeAt(_)===33?(W=v,_++):(W=t,De===0&&Fe(se)),W!==t?(r.charCodeAt(_)===33?(ne=v,_++):(ne=t,De===0&&Fe(se)),ne===t&&(ne=null),r.charCodeAt(_)===112?(le=h,_++):(le=t,De===0&&Fe(Ee)),le===t&&(le=null),Se=Hn(),Se===t&&(Se=null),lr=O,O=E7(ne,le,Se)):(_=O,O=t),O}function iI(){var O,W,ne;return O=_,W=Hn(),W!==t?(ne=hI(),ne===t&&(ne=null),lr=O,O=S7(W,ne)):(_=O,O=t),O}function oI(){var O,W,ne,le;return O=_,r.charCodeAt(_)===100?(W=u,_++):(W=t,De===0&&Fe(ar)),W!==t?(ee.test(r.charAt(_))?(ne=r.charAt(_),_++):(ne=t,De===0&&Fe(ze)),ne===t&&(ne=null),le=il(),le!==t?(lr=O,O=C7(ne,le)):(_=O,O=t)):(_=O,O=t),O}function sI(){var O,W,ne,le;return O=_,r.charCodeAt(_)===107?(W=p,_++):(W=t,De===0&&Fe(ke)),W!==t?(ee.test(r.charAt(_))?(ne=r.charAt(_),_++):(ne=t,De===0&&Fe(ze)),ne===t&&(ne=null),le=il(),le!==t?(lr=O,O=M7(ne,le)):(_=O,O=t)):(_=O,O=t),O}function uI(){var O,W,ne;return O=_,r.substr(_,3)===g?(W=g,_+=3):(W=t,De===0&&Fe(Fr)),W!==t?(ne=Zn(),ne!==t?(lr=O,O=F7(ne)):(_=O,O=t)):(_=O,O=t),O}function lI(){var O,W,ne;return O=_,r.substr(_,3)===y?(W=y,_+=3):(W=t,De===0&&Fe(_r)),W!==t?(ne=Zn(),ne!==t?(lr=O,O=T7(ne)):(_=O,O=t)):(_=O,O=t),O}function cI(){var O,W,ne,le;return O=_,r.charCodeAt(_)===114?(W=N,_++):(W=t,De===0&&Fe(tn)),W!==t?(r.charCodeAt(_)===111?(ne=d,_++):(ne=t,De===0&&Fe(Ln)),ne===t&&(ne=null),le=Hn(),le===t&&(le=null),lr=O,O=B7(ne,le)):(_=O,O=t),O}function fI(){var O,W,ne,le;return O=_,r.charCodeAt(_)===117?(W=w,_++):(W=t,De===0&&Fe(kn)),W!==t?(r.charCodeAt(_)===111?(ne=d,_++):(ne=t,De===0&&Fe(Ln)),ne===t&&(ne=null),le=Hn(),le===t&&(le=null),lr=O,O=$7(ne,le)):(_=O,O=t),O}function mI(){var O,W,ne;return O=_,r.substr(_,2)===x?(W=x,_+=2):(W=t,De===0&&Fe(Bu)),W!==t?(ne=Hn(),ne===t&&(ne=null),lr=O,O=O7(ne)):(_=O,O=t),O}function vI(){var O,W,ne;return O=_,r.substr(_,2)===b?(W=b,_+=2):(W=t,De===0&&Fe($u)),W!==t?(ne=Hn(),ne===t&&(ne=null),lr=O,O=I7(ne)):(_=O,O=t),O}function pI(){var O,W,ne;return O=_,r.charCodeAt(_)===115?(W=E,_++):(W=t,De===0&&Fe(Ou)),W!==t?(r.charCodeAt(_)===97?(ne=A,_++):(ne=t,De===0&&Fe(Iu)),ne===t&&(r.charCodeAt(_)===100?(ne=u,_++):(ne=t,De===0&&Fe(ar))),ne===t&&(ne=null),lr=O,O=R7(ne)):(_=O,O=t),O}function hI(){var O,W,ne;return O=_,r.charCodeAt(_)===102?(W=S,_++):(W=t,De===0&&Fe(Ru)),W!==t?(ne=Hn(),ne!==t?(lr=O,O=_7(ne)):(_=O,O=t)):(_=O,O=t),O}function Hn(){var O,W,ne;return O=_,W=dI(),W!==t?(ne=Zn(),ne!==t?(lr=O,O=q7(W,ne)):(_=O,O=t)):(_=O,O=t),O}function dI(){var O;return r.substr(_,2)===D?(O=D,_+=2):(O=t,De===0&&Fe(_u)),O===t&&(r.substr(_,2)===T?(O=T,_+=2):(O=t,De===0&&Fe(qu)),O===t&&(r.substr(_,2)===B?(O=B,_+=2):(O=t,De===0&&Fe(zu)),O===t&&(r.charCodeAt(_)===61?(O=I,_++):(O=t,De===0&&Fe(Pu)),O===t&&(r.substr(_,2)===P?(O=P,_+=2):(O=t,De===0&&Fe(Vn)),O===t&&(r.charCodeAt(_)===62?(O=R,_++):(O=t,De===0&&Fe(Uu)),O===t&&(r.charCodeAt(_)===60?(O=M,_++):(O=t,De===0&&Fe(Lu)))))))),O}function qo(){var O,W,ne,le,Se,Ie,hr,Er,Mt,qa;if(O=il(),O===t)if(O=_,r.charCodeAt(_)===40?(W=F,_++):(W=t,De===0&&Fe(Oa)),W!==t){if(Ar(),ne=_,le=Zn(),le!==t){if(Se=[],Ie=_,hr=Ar(),Er=zo(),Er!==t?(Mt=Ar(),qa=Zn(),qa!==t?(hr=[hr,Er,Mt,qa],Ie=hr):(_=Ie,Ie=t)):(_=Ie,Ie=t),Ie!==t)for(;Ie!==t;)Se.push(Ie),Ie=_,hr=Ar(),Er=zo(),Er!==t?(Mt=Ar(),qa=Zn(),qa!==t?(hr=[hr,Er,Mt,qa],Ie=hr):(_=Ie,Ie=t)):(_=Ie,Ie=t);else Se=t;Se!==t?(le=[le,Se],ne=le):(_=ne,ne=t)}else _=ne,ne=t;ne!==t?(le=Ar(),r.charCodeAt(_)===41?(Se=H,_++):(Se=t,De===0&&Fe(Ia)),Se!==t?(lr=O,O=z7()):(_=O,O=t)):(_=O,O=t)}else _=O,O=t;return O}function An(){var O,W,ne,le,Se,Ie,hr,Er;if(O=_,W=al(),W!==t){for(ne=[],le=_,Se=Ar(),Ie=zo(),Ie!==t?(hr=Ar(),Er=al(),Er!==t?(Se=[Se,Ie,hr,Er],le=Se):(_=le,le=t)):(_=le,le=t);le!==t;)ne.push(le),le=_,Se=Ar(),Ie=zo(),Ie!==t?(hr=Ar(),Er=al(),Er!==t?(Se=[Se,Ie,hr,Er],le=Se):(_=le,le=t)):(_=le,le=t);lr=O,O=P7(W,ne)}else _=O,O=t;return O}function al(){var O,W,ne,le;return O=gI(),O===t&&(O=eI(),O===t&&(O=Zn(),O===t&&(O=_,r.charCodeAt(_)===40?(W=F,_++):(W=t,De===0&&Fe(Oa)),W!==t?(Ar(),ne=An(),ne!==t?(Ar(),r.charCodeAt(_)===41?(le=H,_++):(le=t,De===0&&Fe(Ia)),le!==t?(lr=O,O=U7(W,ne,le)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t),O===t&&(O=j7())))),O}function gI(){var O,W,ne,le,Se,Ie,hr;return O=_,r.substr(_,3)===$?(W=$,_+=3):(W=t,De===0&&Fe(ku)),W===t&&(r.substr(_,4)===k?(W=k,_+=4):(W=t,De===0&&Fe(Vu)),W===t&&(r.substr(_,3)===Q?(W=Q,_+=3):(W=t,De===0&&Fe(Gu)),W===t&&(r.substr(_,3)===K?(W=K,_+=3):(W=t,De===0&&Fe(Hu)),W===t&&(r.substr(_,5)===L?(W=L,_+=5):(W=t,De===0&&Fe(Zu)),W===t&&(r.substr(_,3)===j?(W=j,_+=3):(W=t,De===0&&Fe(Ju)),W===t&&(r.substr(_,5)===ae?(W=ae,_+=5):(W=t,De===0&&Fe(Xu)),W===t&&(r.substr(_,4)===re?(W=re,_+=4):(W=t,De===0&&Fe(Wu)),W===t&&(r.substr(_,3)===fe?(W=fe,_+=3):(W=t,De===0&&Fe(Yu)),W===t&&(r.substr(_,4)===he?(W=he,_+=4):(W=t,De===0&&Fe(Qu)),W===t&&(r.substr(_,3)===ce?(W=ce,_+=3):(W=t,De===0&&Fe(Ku)))))))))))),W!==t?(r.charCodeAt(_)===40?(ne=F,_++):(ne=t,De===0&&Fe(Oa)),ne!==t?(Ar(),le=An(),le!==t?(Ar(),r.charCodeAt(_)===41?(Se=H,_++):(Se=t,De===0&&Fe(Ia)),Se!==t?(lr=O,O=L7(W,le)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t),O===t&&(O=_,r.substr(_,3)===ie?(W=ie,_+=3):(W=t,De===0&&Fe(ju)),W===t&&(r.substr(_,3)===g?(W=g,_+=3):(W=t,De===0&&Fe(Fr)),W===t&&(r.substr(_,3)===y?(W=y,_+=3):(W=t,De===0&&Fe(_r)))),W!==t?(r.charCodeAt(_)===40?(ne=F,_++):(ne=t,De===0&&Fe(Oa)),ne!==t?(Ar(),le=An(),le!==t?(Ar(),r.charCodeAt(_)===44?(Se=f,_++):(Se=t,De===0&&Fe(Le)),Se!==t?(Ar(),Ie=An(),Ie!==t?(Ar(),r.charCodeAt(_)===41?(hr=H,_++):(hr=t,De===0&&Fe(Ia)),hr!==t?(lr=O,O=k7(W,le,Ie)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)):(_=O,O=t)),O}function Zn(){var O,W,ne,le,Se;return O=_,r.charCodeAt(_)===45?_++:De===0&&Fe(Mo),W=B0(),W!==t?(ne=_,ue.test(r.charAt(_))?(le=r.charAt(_),_++):(le=t,De===0&&Fe(Gn)),le!==t?(Se=B0(),Se!==t?(le=[le,Se],ne=le):(_=ne,ne=t)):(_=ne,ne=t),ne===t&&(ne=null),lr=O,O=V7()):(_=O,O=t),O}function il(){var O,W,ne,le;if(O=_,ve.test(r.charAt(_))?(W=r.charAt(_),_++):(W=t,De===0&&Fe(jr)),W!==t){for(ne=[],de.test(r.charAt(_))?(le=r.charAt(_),_++):(le=t,De===0&&Fe(Tr));le!==t;)ne.push(le),de.test(r.charAt(_))?(le=r.charAt(_),_++):(le=t,De===0&&Fe(Tr));lr=O,O=G7()}else _=O,O=t;return O}function B0(){var O,W,ne;if(O=_,W=[],de.test(r.charAt(_))?(ne=r.charAt(_),_++):(ne=t,De===0&&Fe(Tr)),ne!==t)for(;ne!==t;)W.push(ne),de.test(r.charAt(_))?(ne=r.charAt(_),_++):(ne=t,De===0&&Fe(Tr));else W=t;return W!==t&&(lr=O,W=H7()),O=W,O}function zo(){var O,W;return O=_,r.substr(_,2)===Oe?(W=Oe,_+=2):(W=t,De===0&&Fe(Fo)),W!==t&&(lr=O,W=Z7()),O=W,O===t&&(r.charCodeAt(_)===42?(O=Ce,_++):(O=t,De===0&&Fe(el)),O===t&&(r.charCodeAt(_)===94?(O=$e,_++):(O=t,De===0&&Fe(Ra)),O===t&&(r.charCodeAt(_)===37?(O=V,_++):(O=t,De===0&&Fe(_a)),O===t&&(r.charCodeAt(_)===47?(O=X,_++):(O=t,De===0&&Fe(To)),O===t&&(r.charCodeAt(_)===43?(O=oe,_++):(O=t,De===0&&Fe(Bo)),O===t&&(r.charCodeAt(_)===45?(O=Ae,_++):(O=t,De===0&&Fe(Mo)))))))),O}function $0(){var O;return De++,O=yI(),O===t&&(O=bI()),De--,O===t&&De===0&&Fe(Nn),O}function yI(){var O,W,ne,le,Se,Ie;if(O=_,r.substr(_,2)===G?(W=G,_+=2):(W=t,De===0&&Fe(f7)),W!==t){for(ne=[],le=_,Se=_,De++,r.substr(_,2)===Y?(Ie=Y,_+=2):(Ie=t,De===0&&Fe(rl)),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe($o)),Ie!==t?(Se=[Se,Ie],le=Se):(_=le,le=t)):(_=le,le=t);le!==t;)ne.push(le),le=_,Se=_,De++,r.substr(_,2)===Y?(Ie=Y,_+=2):(Ie=t,De===0&&Fe(rl)),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe($o)),Ie!==t?(Se=[Se,Ie],le=Se):(_=le,le=t)):(_=le,le=t);r.substr(_,2)===Y?(le=Y,_+=2):(le=t,De===0&&Fe(rl)),le!==t?(lr=O,O=J7(ne)):(_=O,O=t)}else _=O,O=t;if(O===t)if(O=_,r.charCodeAt(_)===91?(W=te,_++):(W=t,De===0&&Fe(m7)),W!==t){for(ne=[],be.test(r.charAt(_))?(le=r.charAt(_),_++):(le=t,De===0&&Fe(C0));le!==t;)ne.push(le),be.test(r.charAt(_))?(le=r.charAt(_),_++):(le=t,De===0&&Fe(C0));r.charCodeAt(_)===93?(le=ye,_++):(le=t,De===0&&Fe(v7)),le!==t?(lr=O,O=X7(ne)):(_=O,O=t)}else _=O,O=t;return O}function bI(){var O,W,ne,le,Se,Ie;if(O=_,r.substr(_,2)===me?(W=me,_+=2):(W=t,De===0&&Fe(p7)),W===t&&(r.charCodeAt(_)===35?(W=z,_++):(W=t,De===0&&Fe(h7))),W!==t){for(ne=[],le=_,Se=_,De++,Ie=O0(),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe($o)),Ie!==t?(Se=[Se,Ie],le=Se):(_=le,le=t)):(_=le,le=t);le!==t;)ne.push(le),le=_,Se=_,De++,Ie=O0(),De--,Ie===t?Se=void 0:(_=Se,Se=t),Se!==t?(r.length>_?(Ie=r.charAt(_),_++):(Ie=t,De===0&&Fe($o)),Ie!==t?(Se=[Se,Ie],le=Se):(_=le,le=t)):(_=le,le=t);lr=O,O=W7(ne)}else _=O,O=t;return O}function O0(){var O;return pe.test(r.charAt(_))?(O=r.charAt(_),_++):(O=t,De===0&&Fe(d7)),O}function Po(){var O;return De++,we.test(r.charAt(_))?(O=r.charAt(_),_++):(O=t,De===0&&Fe(y7)),De--,O===t&&De===0&&Fe(g7),O}function Ar(){var O,W;for(O=[],W=Po();W!==t;)O.push(W),W=Po();return O}function I0(){var O,W;for(De++,O=[],W=Po(),W===t&&(W=$0());W!==t;)O.push(W),W=Po(),W===t&&(W=$0());return De--,W=t,De===0&&Fe(b7),O}if(Io=i(),Io!==t&&_===r.length)return Io;throw Io!==t&&_<r.length&&Fe(Q7()),K7(tl,Lt<r.length?r.charAt(Lt):null,Lt<r.length?F0(Lt,Lt+1):F0(Lt,Lt))}class N0{static parse(e){if(!e)throw new Pt("notation");if(typeof e!="string")throw new TypeError("Notation must be a string");return z9(e)}}const Ta=Object.freeze({BASE_64:1,JSON:0,OBJECT:2}),Su=Symbol("notation"),Cu=Symbol("maxTotal"),Mu=Symbol("minTotal"),Ba=Symbol("expressions"),Eo=Symbol("roll-method"),wn=Symbol("rolls"),D0=Symbol("set-rolls"),So=Symbol("total"),Fu=r=>e9(r.calculationValue,2);class si{constructor(e){if(!e)throw new Pt("notation");if(this[Ba]=[],e instanceof Object&&!Array.isArray(e)){if(e.notation){if(typeof e.notation!="string")throw new yo(e.notation);e.rolls&&this[D0](e.rolls)}else throw new Pt("notation");this[Su]=e.notation,this[Ba]=N0.parse(this.notation),this.hasRolls()||this.roll()}else if(typeof e=="string")this[Su]=e,this[Ba]=N0.parse(this.notation),this.roll();else throw new yo(e)}get averageTotal(){return(this.maxTotal+this.minTotal)/2}get maxTotal(){if(!this.hasExpressions())return 0;if(!this[Cu]){const e=this[Eo](Ud.max);this[Cu]=Fu(e)}return this[Cu]}get minTotal(){if(!this.hasExpressions())return 0;if(!this[Mu]){const e=this[Eo](Ud.min);this[Mu]=Fu(e)}return this[Mu]}get notation(){return this[Su]}get output(){let e=`${this.notation}: `;return this.hasRolls()?e+=`${this[wn]} = ${this.total}`:e+="No dice rolled",e}get rolls(){return this[wn]?this[wn].results:[]}get total(){return!this[So]&&this.hasRolls()&&(this[So]=Fu(this[wn])),this[So]||0}export(e=Ta.JSON){switch(e){case Ta.BASE_64:return btoa(this.export(Ta.JSON));case Ta.JSON:return JSON.stringify(this);case Ta.OBJECT:return JSON.parse(this.export(Ta.JSON));default:throw new TypeError(`Invalid export format "${e}"`)}}hasExpressions(){return this[Ba]&&this[Ba].length>0}hasRolls(){return this.hasExpressions()&&this.rolls.length>0}roll(){return this[So]=0,this[wn]=this[Eo](),this.rolls}toJSON(){const{averageTotal:e,maxTotal:t,minTotal:a,notation:n,output:i,rolls:o,total:f}=this;return{averageTotal:e,maxTotal:t,minTotal:a,notation:n,output:i,rolls:o,total:f,type:"dice-roll"}}toString(){return this.output}static import(e){if(e){if(_9(e))return si.import(JSON.parse(e));if(R9(e))return si.import(atob(e));if(typeof e=="object")return new si(e);throw new Ys(e)}else throw new Pt("data")}[Eo](e){let t;e&&(t=Sa.engine,Sa.engine=e);const a=new kr(this[Ba].map(n=>n instanceof Ca||n instanceof w0?n.roll():n).filter(n=>!!n||n===0));return e&&(Sa.engine=t),a}[D0](e){if(e instanceof kr)this[wn]=e;else if(e instanceof rn)this[wn]=new kr([e]);else if(Array.isArray(e))this[wn]=new kr(e.map(t=>{if(t instanceof kr||t instanceof rn)return t;if(Array.isArray(t))return new rn(t);if(typeof t=="object"){if(Array.isArray(t.results))return new kr(t.results,t.modifiers||[],t.isRollGroup||!1,typeof t.useInTotal=="boolean"?t.useInTotal:!0);if(Array.isArray(t.rolls))return new rn(t.rolls)}return t}));else throw new TypeError("Rolls must be a valid result object, or an array")}}const Co={__name:"DiceRollerRenderless",props:{notation:String},emits:["notation:change","roll"],setup(r,{emit:e}){const t=r,a=Ne.ref(`${t.notation||""}`),n=Ne.ref(null),i=Ne.ref(null),o=async()=>{n.value=null;try{i.value=a.value?new si(Ne.unref(a)):null}catch(l){i.value=null,l.name==="SyntaxError"?n.value=`Invalid notation; ${l.message}`:n.value=`An error has occurred: ${l.message}`}finally{e("roll",Ne.unref(a),Ne.unref(i))}},f=l=>{a.value=l,e("notation:change",l)};return(l,u)=>Ne.renderSlot(l.$slots,"default",{currentNotation:a.value,error:n.value,output:i.value,roll:o,bind:{value:a.value},on:{input:s=>f(s.target.value),change:s=>f(s.target.value),keyup:s=>s.keyCode===13?o():void 0}})}},P9=()=>typeof crypto<"u"&&crypto&&crypto.randomUUID,U9=()=>P9()?crypto.randomUUID():`${Date.now().toString(32)}-${Math.random().toString(36).substring(2)}`;function Tu(r){const e=Ne.ref(null);return e.value=`${r}${U9()}`,{id:e}}const L9=["id"],k9=["for"],V9=["for"],G9=["id","placeholder"],H9=["onClick"],Z9={__name:"DiceRoller",props:{btnLabel:{type:String,default:"Roll"},className:{type:String,default:"dice-roller"},id:String,notation:String},emits:["notation:change","roll"],setup(r){const e=r,{id:t}=Tu(`${e.id||"dice-roller"}-`);return(a,n)=>(Ne.openBlock(),Ne.createBlock(Co,{notation:r.notation,"onNotation:change":n[0]||(n[0]=i=>a.$emit("notation:change",i)),onRoll:n[1]||(n[1]=i=>a.$emit("roll",i))},{default:Ne.withCtx(({error:i,output:o,roll:f,on:l,bind:u})=>[Ne.createElementVNode("section",{id:r.id,class:Ne.normalizeClass(r.className)},[o?(Ne.openBlock(),Ne.createElementBlock("output",{key:0,name:"output",for:Ne.unref(t),class:Ne.normalizeClass(`${r.className}-output`)},Ne.toDisplayString(o),11,k9)):Ne.createCommentVNode("",!0),Ne.createElementVNode("div",{class:Ne.normalizeClass(`${r.className}-input-group`)},[Ne.createElementVNode("label",{for:Ne.unref(t),class:Ne.normalizeClass(`${r.className}-label`)}," Notation ",10,V9),Ne.createElementVNode("input",Ne.mergeProps({type:"text",name:"notation",id:Ne.unref(t),placeholder:`e.g. ${r.notation||"4d6"}`,class:[`${r.className}-input`,i?`${r.className}-input-invalid`:null]},Ne.toHandlers(l,!0),u),null,16,G9),Ne.createElementVNode("button",{type:"button",class:Ne.normalizeClass(`${r.className}-button`),onClick:f},[Ne.renderSlot(a.$slots,"button",{},()=>[Ne.createTextVNode(Ne.toDisplayString(r.btnLabel),1)])],10,H9)],2),i?(Ne.openBlock(),Ne.createElementBlock("span",{key:1,class:Ne.normalizeClass(`${r.className}-error`)},Ne.toDisplayString(i),3)):Ne.createCommentVNode("",!0)],10,L9)]),_:3},8,["notation"]))}},J9=["id"],X9=["for"],W9={class:"flex flex-col sm:flex-row gap-y-4"},Y9=["for"],Q9=["id","placeholder"],K9=["onClick"],j9={key:1,class:"block mt-4 text-red-600 text-sm dark:text-red-200"},e7={__name:"DiceRollerTailwind",props:{btnLabel:{type:String,default:"Roll"},id:String,notation:String},emits:["notation:change","roll"],setup(r){const e=r,{id:t}=Tu(`${e.id||"dice-roller"}-`);return(a,n)=>(Ne.openBlock(),Ne.createBlock(Co,{notation:r.notation,"onNotation:change":n[0]||(n[0]=i=>a.$emit("notation:change",i)),onRoll:n[1]||(n[1]=i=>a.$emit("roll",i))},{default:Ne.withCtx(({error:i,output:o,roll:f,on:l,bind:u})=>[Ne.createElementVNode("div",{id:r.id,class:"dice-roller p-4 rounded bg-slate-100 text-gray-800 dark:bg-gray-600 dark:text-gray-200"},[o?(Ne.openBlock(),Ne.createElementBlock("output",{key:0,name:"output",for:Ne.unref(t),class:"block mb-8 p-4 text-2xl rounded bg-white text-black dark:bg-gray-300 dark:text-gray-800 border-l-8 border-[#d4f4c6]"},Ne.toDisplayString(o),9,X9)):Ne.createCommentVNode("",!0),Ne.createElementVNode("div",W9,[Ne.createElementVNode("label",{for:Ne.unref(t),class:"sr-only"}," Notation ",8,Y9),Ne.createElementVNode("input",Ne.mergeProps({type:"text",name:"notation",id:Ne.unref(t),placeholder:`e.g. ${r.notation||"4d6"}`,class:["flex-auto block w-full h-11 py-2 px-4 text-base border shadow-sm rounded placeholder-gray-500 focus:ring-[#d4f4c6] focus:border-[#d4f4c6] focus:outline-none focus:placeholder-gray-400 dark:focus:placeholder-gray-400 invalid:text-red-600 invalid:border-red-200 invalid:bg-red-50 sm:border-r-0 sm:rounded-r-none",i?"text-red-600 border-red-200 bg-red-50":"bg-white text-gray-900 border-gray-300 dark:text-gray-600 dark:bg-gray-50 dark:border-gray-700"]},Ne.toHandlers(l,!0),u),null,16,Q9),Ne.createElementVNode("button",{type:"button",class:"block px-8 h-11 font-bold text-gray-600 bg-gradient-to-br from-[#eda18b] to-[#d4f4c6] border border-l-0 border-gray-300 rounded transition dark:border-gray-700 focus:from-[#e88c71] focus:to-[#bbf0a3] focus:text-gray-800 focus:ring-[#d4f4c6] focus:border-[#d4f4c6] focus:outline-none hover:from-[#e88c71] hover:to-[#bbf0a3] hover:text-gray-800 sm:rounded-l-none",onClick:f},[Ne.renderSlot(a.$slots,"button",{},()=>[Ne.createTextVNode(Ne.toDisplayString(r.btnLabel),1)])],8,K9)]),i?(Ne.openBlock(),Ne.createElementBlock("span",j9,Ne.toDisplayString(i),1)):Ne.createCommentVNode("",!0)],8,J9)]),_:3},8,["notation"]))}},r7=["id"],t7={class:"card-body"},n7=["for"],a7=["for"],i7={class:"input-group"},o7=["id","placeholder"],s7=["onClick"],u7={key:1,class:"d-block mt-3 invalid-feedback"},$a=["primary","secondary","success","danger","warning","info","light","dark"],A0=[...$a,"body","white","transparent"],E0=[...$a,"body","muted","white","black-50","white-50"],l7=[...$a,"link","outline-primary","outline-secondary","outline-success","outline-danger","outline-warning","outline-info","outline-light","outline-dark"],S0=[...$a,"white"],c7={__name:"DiceRollerBootstrap",props:{bgVariant:{type:String,validator(r){return A0.includes(r)}},borderVariant:{type:String,validator(r){return S0.includes(r)}},btnLabel:{type:String,default:"Roll"},btnVariant:{type:String,default:"primary",validator(r){return l7.includes(r)}},id:String,notation:String,outputBgVariant:{type:String,validator(r){return A0.includes(r)}},outputBorderVariant:{type:String,validator(r){return S0.includes(r)}},outputTextVariant:{type:String,validator(r){return E0.includes(r)}},outputVariant:{type:String,validator(r){return $a.includes(r)}},textVariant:{type:String,validator(r){return E0.includes(r)}},variant:{type:String,validator(r){return $a.includes(r)}}},emits:["notation:change","roll"],setup(r){const e=r,t=Ne.computed(()=>({[`text-bg-${e.variant}`]:e.variant,[`bg-${e.bgVariant}`]:e.bgVariant,[`text-${e.textVariant}`]:e.textVariant,[`border-${e.borderVariant}`]:e.borderVariant})),a=Ne.computed(()=>({[`text-bg-${e.outputVariant}`]:e.outputVariant,[`bg-${e.outputBgVariant}`]:e.outputBgVariant,[`text-${e.outputTextVariant}`]:e.outputTextVariant,[`border-${e.outputBorderVariant}`]:e.outputBorderVariant})),n=Ne.computed(()=>`btn-${e.btnVariant||"primary"}`),{id:i}=Tu(`${e.id||"dice-roller"}-`);return(o,f)=>(Ne.openBlock(),Ne.createBlock(Co,{notation:r.notation,"onNotation:change":f[0]||(f[0]=l=>o.$emit("notation:change",l)),onRoll:f[1]||(f[1]=l=>o.$emit("roll",l))},{default:Ne.withCtx(({error:l,output:u,roll:s,on:c,bind:m})=>[Ne.createElementVNode("div",{id:r.id,class:Ne.normalizeClass(["dice-roller card",t.value])},[Ne.createElementVNode("div",t7,[u?(Ne.openBlock(),Ne.createElementBlock("output",{key:0,name:"output",for:Ne.unref(i),class:Ne.normalizeClass(["d-block mb-4 p-3 fs-4 rounded border",a.value])},Ne.toDisplayString(u),11,n7)):Ne.createCommentVNode("",!0),Ne.createElementVNode("label",{for:Ne.unref(i),class:"form-label visually-hidden"}," Notation ",8,a7),Ne.createElementVNode("div",i7,[Ne.createElementVNode("input",Ne.mergeProps({type:"text",name:"notation",id:Ne.unref(i),placeholder:`e.g. ${r.notation||"4d6"}`,class:["form-control",l?"is-invalid":""]},Ne.toHandlers(c,!0),m),null,16,o7),Ne.createElementVNode("button",{type:"button",class:Ne.normalizeClass(["btn",n.value]),onClick:s},[Ne.renderSlot(o.$slots,"button",{},()=>[Ne.createTextVNode(Ne.toDisplayString(r.btnLabel),1)])],10,s7)]),l?(Ne.openBlock(),Ne.createElementBlock("span",u7,Ne.toDisplayString(l),1)):Ne.createCommentVNode("",!0)])],10,r7)]),_:3},8,["notation"]))}};Vr.DiceRoller=Z9,Vr.DiceRollerBootstrap=c7,Vr.DiceRollerRenderless=Co,Vr.DiceRollerTailwind=e7,Object.defineProperties(Vr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});