lido-player 0.0.2-beta-24-dev → 0.0.2-beta-24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{decode-B7mZm_nK.js → decode-BCvdWRyT.js} +1 -1
- package/dist/cjs/{index-BCRDjbaz.js → index-DjM03fsg.js} +5 -5
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/lido-avatar_22.cjs.entry.js +9 -49
- package/dist/collection/components/container/lido-container.css +0 -24
- package/dist/collection/components/container/lido-container.js +1 -32
- package/dist/collection/components/flashCard/lido-flash-card.js +5 -14
- package/dist/components/index.js +1 -1
- package/dist/components/lido-container.js +1 -1
- package/dist/components/lido-flash-card.js +1 -1
- package/dist/components/lido-home.js +1 -1
- package/dist/components/lido-root.js +1 -1
- package/dist/components/{p-DfjbSSI2.js → p-CgBwmr9A.js} +2 -2
- package/dist/components/p-Ckb8QhUV.js +1 -0
- package/dist/components/p-DDwqmTYM.js +1 -0
- package/dist/esm/{decode-CyhHNDvT.js → decode-BxzUG5XP.js} +1 -1
- package/dist/esm/{index-CndbFQ5I.js → index-C_uxZLF-.js} +5 -5
- package/dist/esm/index.js +1 -1
- package/dist/esm/lido-avatar_22.entry.js +9 -49
- package/dist/lido-player/index.esm.js +1 -1
- package/dist/lido-player/lido-player.esm.js +1 -1
- package/dist/lido-player/{p-d760e67b.entry.js → p-00993d1a.entry.js} +2 -2
- package/dist/lido-player/{p-etMb7U6W.js → p-CsCr7DlS.js} +1 -1
- package/dist/lido-player/p-v3GBrpv9.js +1 -0
- package/dist/types/components/container/lido-container.d.ts +0 -4
- package/package.json +1 -1
- package/dist/components/p-B-mIxynb.js +0 -1
- package/dist/components/p-uuyVO2B1.js +0 -1
- package/dist/lido-player/p-77iyGppv.js +0 -1
package/dist/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e="@font-face{font-family:'Baloo Bhai 2';font-style:normal;font-weight:400 800;font-display:swap;src:url('../assets/offline-assets/fonts/Baloo-Bhai-2/Baloo-Bhai-2-Variable.woff2') format('woff2')}body{overflow:hidden;background-position:center;background-size:cover;background-repeat:no-repeat;height:100vh}*{user-select:none}.lido-disable-check-button{pointer-events:none;background-color:#9393935c !important;color:white}.lido-element-selected{border:2px solid;background-color:#ffdf7d !important}.diagonal-target,.diagonal-drop *{transform:scale(0.8) !important;opacity:1 !important}.cloned-element{display:flex !important;position:absolute !important;filter:grayscale(100%);pointer-events:none}.removeShadow{box-shadow:0px 0px 0px 0px #ff8900 !important}.highlight-element{border:2px solid white;box-shadow:rgb(243, 77, 8) 0px 0px 40px !important}.drop-element.empty{border:4px dashed #f34d08 !important}.drop-element.filled{border:'none' !important}.drag-element{box-shadow:0px 15px 11px rgba(43, 0, 0, 0.3) !important}.drag-element.dropped{box-shadow:none !important}.click-element{background-color:var(--btn-bg-color, rgba(255, 172, 76, 1)) !important;box-shadow:var(--btn-shadow-px) var(--btn-shadow-color, rgba(225, 121, 76, 1)) !important;cursor:pointer;transition:box-shadow 0.1s ease-out, transform 0.2s ease-out;}.click-element:active{box-shadow:0px 0px 0px var(--btn-shadow-color, rgba(225, 121, 76, 1)) !important;transform:translateY(var(--btn-active));}.click-element:focus{outline:2px solid dodgerblue;outline-offset:3px}.after-drop-popup-container{width:200%;height:200%;background-color:rgba(0, 0, 0, 0.8);position:absolute;display:flex;flex-direction:row-reverse;align-items:center;justify-content:center !important;gap:80px}.after-drop-popup-drag-element{scale:1.5;border-radius:8px;transform:none !important;position:unset !important}.after-drop-popup-drop-element{scale:1.5;border:unset;border-radius:8px;transform:none !important;position:unset !important}@keyframes zoomFadeIn{0%{transform:scale(0.6);opacity:0}100%{transform:scale(1);opacity:1}}.zoom-fade-in{animation:zoomFadeIn 0.8s ease-out forwards}@keyframes zoomFadeOut{0%{transform:scale(1);opacity:1}100%{transform:scale(0.6);opacity:0}}.zoom-fade-out{animation:zoomFadeOut 0.8s ease-in forwards}.slide-numbers{width:70px;height:70px;border:1px solid #f57139;background-color:white;font-weight:500;color:#f57139;font-size:44px;border-radius:40px;display:flex;align-items:center;justify-content:center;font-family:'Baloo Bhai 2', serif}.slide-numbers-bottom{position:absolute;display:flex;justify-content:space-around;align-items:center;bottom:-25px;width:100%;height:50px}.slide-numbers-left{position:absolute;display:flex;flex-direction:column;justify-content:space-around;height:100%;width:50px;left:-25px;bottom:0px}.lido-speak-icon{width:56px;height:56px;position:absolute;top:-25px;right:-25px;z-index:10;background-color:white;border:4px solid #F34D08;border-radius:16px;box-shadow:0px 4px 0px 0px #F34D08;background-size:contain;background-repeat:no-repeat;cursor:pointer}.lido-speak-icon:active{transform:translateY(8px);box-shadow:0px 0px 0px 0px !important}.lido-strong-shake{animation:strongShake 0.3s ease}.lido-scaled-shake{animation:scaledShake 0.6s ease-in-out}.lido-horizontal-shake{animation:horizontalShake 0.6s ease-in-out;border-radius:20px}.lido-vertical-shake{animation:verticalShake 0.6s ease-in-out;border-radius:20px}.lido-diagonal-shake{animation:diagonalShake 0.5s ease-in-out;border-radius:20px;will-change:transform}.lido-glow{animation:glowPulse 1s infinite alternate;transition:opacity 0.5s ease-in-out}.lido-box-highlight{animation:topToPlace 0.3s linear}.lido-display-hiddenvalue{position:absolute;top:0;left:0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:80px;font-weight:1000;color:brown;-webkit-text-stroke:2px white;font-family:'Baloo Bhai 2', sans-serif;pointer-events:none}.lido-image-colorize{position:relative;display:inline-block}.lido-image-colorize::after{content:'';position:absolute;inset:0;background:var(--tint-color);mix-blend-mode:multiply;opacity:0.8;pointer-events:none;mask-image:var(--mask-url);mask-size:cover;mask-repeat:no-repeat;mask-position:center}.lido-tts-highlight-overlay{position:fixed;left:0;top:0;pointer-events:none;z-index:9999;background:linear-gradient(\n 180deg,\n rgba(255, 235, 59, 0.95),\n rgba(255, 214, 0, 0.95)\n );border-radius:6px;box-shadow:0 2px 6px rgba(0, 0, 0, 0.18),\n inset 0 -1px 0 rgba(255, 255, 255, 0.25);transition:width 25ms ease-out,\n height 25ms ease-out,\n opacity 80ms ease-out;opacity:0.95;will-change:transform, width, height;contain:layout paint style}.category-dropped-onCorrect{box-shadow:rgba(129, 193, 39, 1) 0px 8px 8px 0px !important}.category-dropped-onInCorrect{box-shadow:rgba(255, 4, 16, 1) 0px 8px 8px 0px !important}";function r(e,r,t){const n="undefined"!=typeof HTMLElement?HTMLElement.prototype:null;for(;e&&e!==n;){const n=Object.getOwnPropertyDescriptor(e,r);if(n&&(!t||n.get))return n;e=Object.getPrototypeOf(e)}}var t,n=(e,t)=>{var n;Object.entries(null!=(n=t.D.o)?n:{}).map((([n,[i]])=>{if(31&i||32&i){const i=e[n],a=r(Object.getPrototypeOf(e),n,!0)||Object.getOwnPropertyDescriptor(e,n);a&&Object.defineProperty(e,n,{get(){return a.get.call(this)},set(e){a.set.call(this,e)},configurable:!0,enumerable:!0}),t.O.has(n)?e[n]=t.O.get(n):void 0!==i&&(e[n]=i)}}))},i=e=>{if(e.__stencil__getHostRef)return e.__stencil__getHostRef()},a=(e,r)=>r in e,o=(e,r)=>(0,console.error)(e,r),u=new Map,s="http://www.w3.org/1999/xlink",c="undefined"!=typeof window?window:{},l=c.HTMLElement||class{},f={ee:0,te:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,r,t,n)=>e.addEventListener(r,t,n),rel:(e,r,t,n)=>e.removeEventListener(r,t,n),ce:(e,r)=>new CustomEvent(e,r)},m=(()=>{try{return!!c.document.adoptedStyleSheets&&(new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync)}catch(e){}return!1})(),d=!!m&&(()=>!!c.document&&Object.getOwnPropertyDescriptor(c.document.adoptedStyleSheets,"length").writable)(),p=!1,h=[],v=[],y=(e,r)=>t=>{e.push(t),p||(p=!0,r&&4&f.ee?x(g):f.raf(g))},b=e=>{for(let r=0;r<e.length;r++)try{e[r](performance.now())}catch(e){o(e)}e.length=0},g=()=>{b(h),b(v),(p=h.length>0)&&f.raf(g)},x=e=>Promise.resolve(void 0).then(e),w=y(v,!0),D=e=>{const r=new URL(e,f.te);return r.origin!==c.location.origin?r.href:r.pathname},N=e=>f.te=e;function A(){var r;const n=this.attachShadow({mode:"open"});if(void 0===t&&(t=null!=(r=function(e){if(!m)return;const r=new CSSStyleSheet;return r.replaceSync(e),r}(e))?r:null),t)d?n.adoptedStyleSheets.push(t):n.adoptedStyleSheets=[...n.adoptedStyleSheets,t];else if(!m){const r=document.createElement("style");r.innerHTML=e,n.prepend(r)}}var M=e=>{const r=B(e,"childNodes");e.tagName&&e.tagName.includes("-")&&e["s-cr"]&&"SLOT-FB"!==e.tagName&&C(r,e.tagName).forEach((e=>{1===e.nodeType&&"SLOT-FB"===e.tagName&&(e.hidden=!!E(e,F(e),!1).length)}));let t=0;for(t=0;t<r.length;t++){const e=r[t];1===e.nodeType&&B(e,"childNodes").length&&M(e)}};function C(e,r,t){let n,i=0,a=[];for(;i<e.length;i++){if(n=e[i],n["s-sr"]&&(!r||n["s-hn"]===r)&&(void 0===t||F(n)===t)&&(a.push(n),void 0!==t))return a;a=[...a,...C(n.childNodes,r,t)]}return a}var E=(e,r,t=!0)=>{const n=[];(t&&e["s-sr"]||!e["s-sr"])&&n.push(e);let i=e;for(;i=i.nextSibling;)F(i)!==r||!t&&i["s-sr"]||n.push(i);return n},S=(e,r)=>1===e.nodeType?null===e.getAttribute("slot")&&""===r||e.getAttribute("slot")===r:e["s-sn"]===r||""===r,F=e=>"string"==typeof e["s-sn"]?e["s-sn"]:1===e.nodeType&&e.getAttribute("slot")||void 0;function B(e,r){if("__"+r in e){const t=e["__"+r];return"function"!=typeof t?t:t.bind(e)}return"function"!=typeof e[r]?e[r]:e[r].bind(e)}var q,T,k=new WeakMap,O=e=>"sc-"+e.ne,I=e=>"object"==(e=typeof e)||"function"===e,z=(e,r,...t)=>{let n=null,i=null,a=null,o=!1,u=!1;const s=[],c=r=>{for(let t=0;t<r.length;t++)n=r[t],Array.isArray(n)?c(n):null!=n&&"boolean"!=typeof n&&((o="function"!=typeof e&&!I(n))&&(n+=""),o&&u?s[s.length-1].ie+=n:s.push(o?j(null,n):n),u=o)};if(c(t),r){r.key&&(i=r.key),r.name&&(a=r.name);{const e=r.className||r.class;e&&(r.class="object"!=typeof e?e:Object.keys(e).filter((r=>e[r])).join(" "))}}const l=j(e,null);return l.ae=r,s.length>0&&(l.oe=s),l.ue=i,l.se=a,l},j=(e,r)=>({ee:0,le:e,ie:null!=r?r:null,fe:null,oe:null,ae:null,ue:null,se:null}),R={},U=e=>{if(!e)return;const r=Object.keys(e);if(0===r.length)return;let t=!1;for(const n of r){if(t)break;for(const r of e[n])if("string"==typeof r){t=!0;break}}if(!t)return e;const n={};for(const t of r)n[t]=e[t].map((e=>"string"==typeof e?{[e]:0}:e));return n},$=(e,r)=>null==e||I(e)?e:4&r?"false"!==e&&(""===e||!!e):2&r?"string"==typeof e?parseFloat(e):"number"==typeof e?e:NaN:1&r?e+"":e,P=(e,r)=>{const t=e;return{emit:e=>L(t,r,{bubbles:!0,composed:!0,cancelable:!0,detail:e})}},L=(e,r,t)=>{const n=f.ce(r,t);return e.dispatchEvent(n),n},_=(e,r,t,n,o,u)=>{if(t===n)return;let l=a(e,r),m=r.toLowerCase();if("class"===r){const r=e.classList,i=J(t);let a=J(n);r.remove(...i.filter((e=>e&&!a.includes(e)))),r.add(...a.filter((e=>e&&!i.includes(e))))}else if("style"===r){for(const r in t)n&&null!=n[r]||(r.includes("-")?e.style.removeProperty(r):e.style[r]="");for(const r in n)t&&n[r]===t[r]||(r.includes("-")?e.style.setProperty(r,n[r]):e.style[r]=n[r])}else if("key"===r);else if("ref"===r)n&&de(n,e);else if(e.__lookupSetter__(r)||"o"!==r[0]||"n"!==r[1]){if("a"===r[0]&&r.startsWith("attr:")){const t=r.slice(5);let a;{const r=i(e);if(r&&r.D&&r.D.o){const e=r.D.o[t];e&&e[1]&&(a=e[1])}}return a||(a=t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()),void(null==n||!1===n?!1===n&&""!==e.getAttribute(a)||e.removeAttribute(a):e.setAttribute(a,!0===n?"":n))}if("p"===r[0]&&r.startsWith("prop:")){const t=r.slice(5);try{e[t]=n}catch(e){}return}{const i=I(n);if((l||i&&null!==n)&&!o)try{if(e.tagName.includes("-"))e[r]!==n&&(e[r]=n);else{const i=null==n?"":n;"list"===r?l=!1:null!=t&&e[r]===i||("function"==typeof e.__lookupSetter__(r)?e[r]=i:e.setAttribute(r,i))}}catch(e){}let a=!1;m!==(m=m.replace(/^xlink\:?/,""))&&(r=m,a=!0),null==n||!1===n?!1===n&&""!==e.getAttribute(r)||(a?e.removeAttributeNS(s,r):e.removeAttribute(r)):(!l||4&u||o)&&!i&&1===e.nodeType&&(n=!0===n?"":n,a?e.setAttributeNS(s,r,n):e.setAttribute(r,n))}}else if(r="-"===r[2]?r.slice(3):a(c,m)?m.slice(2):m[2]+r.slice(3),t||n){const i=r.endsWith(V);r=r.replace(H,""),t&&f.rel(e,r,t,i),n&&f.ael(e,r,n,i)}},W=/\s/,J=e=>("object"==typeof e&&e&&"baseVal"in e&&(e=e.baseVal),e&&"string"==typeof e?e.split(W):[]),V="Capture",H=RegExp(V+"$"),Z=(e,r,t)=>{const n=11===r.fe.nodeType&&r.fe.host?r.fe.host:r.fe,i=e&&e.ae||{},a=r.ae||{};for(const e of G(Object.keys(i)))e in a||_(n,e,i[e],void 0,t,r.ee);for(const e of G(Object.keys(a)))_(n,e,i[e],a[e],t,r.ee)};function G(e){return e.includes("ref")?[...e.filter((e=>"ref"!==e)),"ref"]:e}var X=!1,Y=!1,Q=!1,K=!1,ee=[],re=[],te=(e,r,t)=>{var n;const i=r.oe[t];let a,o,u,s=0;if(X||(Q=!0,"slot"===i.le&&(i.ee|=i.oe?2:1)),null!=i.ie)a=i.fe=c.document.createTextNode(i.ie);else if(1&i.ee)a=i.fe=c.document.createTextNode(""),Z(null,i,K);else{if(!c.document)throw Error("You are trying to render a Stencil component in an environment that doesn't support the DOM.");if(a=i.fe=c.document.createElement(!X&&2&i.ee?"slot-fb":i.le),Z(null,i,K),i.oe){const r="template"===i.le?a.content:a;for(s=0;s<i.oe.length;++s)o=te(e,i,s),o&&r.appendChild(o)}}return a["s-hn"]=T,3&i.ee&&(a["s-sr"]=!0,a["s-cr"]=q,a["s-sn"]=i.se||"",a["s-rf"]=null==(n=i.ae)?void 0:n.ref,function(e){if(e.assignedElements||e.assignedNodes||!e["s-sr"])return;const r=r=>function(e){const t=[],n=this["s-sn"];(null==e?void 0:e.flatten)&&console.error("\n Flattening is not supported for Stencil non-shadow slots.\n You can use `.childNodes` to nested slot fallback content.\n If you have a particular use case, please open an issue on the Stencil repo.\n ");const i=this["s-cr"].parentElement;return(i.__childNodes?i.childNodes:(e=>{const r=[];for(let t=0;t<e.length;t++){const n=e[t]["s-nr"]||void 0;n&&n.isConnected&&r.push(n)}return r})(i.childNodes)).forEach((e=>{n===F(e)&&t.push(e)})),r?t.filter((e=>1===e.nodeType)):t}.bind(e);e.assignedElements=r(!0),e.assignedNodes=r(!1)}(a),u=e&&e.oe&&e.oe[t],u&&u.le===i.le&&e.fe&&ne(e.fe)),a},ne=e=>{f.ee|=1;const r=e.closest(T.toLowerCase());if(null!=r){const t=Array.from(r.__childNodes||r.childNodes).find((e=>e["s-cr"])),n=Array.from(e.__childNodes||e.childNodes);for(const e of t?n.reverse():n)null!=e["s-sh"]&&(pe(r,e,null!=t?t:null),e["s-sh"]=void 0,Q=!0)}f.ee&=-2},ie=(e,r)=>{f.ee|=1;const t=Array.from(e.__childNodes||e.childNodes);if(e["s-sr"]){let r=e;for(;r=r.nextSibling;)r&&r["s-sn"]===e["s-sn"]&&r["s-sh"]===T&&t.push(r)}for(let e=t.length-1;e>=0;e--){const n=t[e];n["s-hn"]!==T&&n["s-ol"]&&(pe(se(n).parentNode,n,se(n)),n["s-ol"].remove(),n["s-ol"]=void 0,n["s-sh"]=void 0,Q=!0),r&&ie(n,r)}f.ee&=-2},ae=(e,r,t,n,i,a)=>{let o,u=e["s-cr"]&&e["s-cr"].parentNode||e;for(u.shadowRoot&&u.tagName===T&&(u=u.shadowRoot),"template"===t.le&&(u=u.content);i<=a;++i)n[i]&&(o=te(null,t,i),o&&(n[i].fe=o,pe(u,o,se(r))))},oe=(e,r,t)=>{for(let n=r;n<=t;++n){const r=e[n];if(r){const e=r.fe;me(r),e&&(Y=!0,e["s-ol"]?e["s-ol"].remove():ie(e,!0),e.remove())}}},ue=(e,r,t=!1)=>e.le===r.le&&("slot"===e.le?e.se===r.se:t?(t&&!e.ue&&r.ue&&(e.ue=r.ue),!0):e.ue===r.ue),se=e=>e&&e["s-ol"]||e,ce=(e,r,t=!1)=>{const n=r.fe=e.fe,i=e.oe,a=r.oe,o=r.ie;let u;null==o?("slot"!==r.le||X||e.se!==r.se&&(r.fe["s-sn"]=r.se||"",ne(r.fe.parentElement)),Z(e,r,K),null!==i&&null!==a?((e,r,t,n,i=!1)=>{let a,o,u=0,s=0,c=0,l=0,f=r.length-1,m=r[0],d=r[f],p=n.length-1,h=n[0],v=n[p];const y="template"===t.le?e.content:e;for(;u<=f&&s<=p;)if(null==m)m=r[++u];else if(null==d)d=r[--f];else if(null==h)h=n[++s];else if(null==v)v=n[--p];else if(ue(m,h,i))ce(m,h,i),m=r[++u],h=n[++s];else if(ue(d,v,i))ce(d,v,i),d=r[--f],v=n[--p];else if(ue(m,v,i))"slot"!==m.le&&"slot"!==v.le||ie(m.fe.parentNode,!1),ce(m,v,i),pe(y,m.fe,d.fe.nextSibling),m=r[++u],v=n[--p];else if(ue(d,h,i))"slot"!==m.le&&"slot"!==v.le||ie(d.fe.parentNode,!1),ce(d,h,i),pe(y,d.fe,m.fe),d=r[--f],h=n[++s];else{for(c=-1,l=u;l<=f;++l)if(r[l]&&null!==r[l].ue&&r[l].ue===h.ue){c=l;break}c>=0?(o=r[c],o.le!==h.le?a=te(r&&r[s],t,c):(ce(o,h,i),r[c]=void 0,a=o.fe),h=n[++s]):(a=te(r&&r[s],t,s),h=n[++s]),a&&pe(se(m.fe).parentNode,a,se(m.fe))}u>f?ae(e,null==n[p+1]?null:n[p+1].fe,t,n,s,p):s>p&&oe(r,u,f)})(n,i,r,a,t):null!==a?(null!==e.ie&&(n.textContent=""),ae(n,null,r,a,0,a.length-1)):!t&&null!==i&&oe(i,0,i.length-1)):(u=n["s-cr"])?u.parentNode.textContent=o:e.ie!==o&&(n.data=o)},le=[],fe=e=>{let r,t,n;const i=e.__childNodes||e.childNodes;for(const e of i){if(e["s-sr"]&&(r=e["s-cr"])&&r.parentNode){t=r.parentNode.__childNodes||r.parentNode.childNodes;const i=e["s-sn"];for(n=t.length-1;n>=0;n--)if(r=t[n],!(r["s-cn"]||r["s-nr"]||r["s-hn"]===e["s-hn"]||r["s-sh"]&&r["s-sh"]===e["s-hn"]))if(S(r,i)){let t=le.find((e=>e.me===r));Y=!0,r["s-sn"]=r["s-sn"]||i,t?(t.me["s-sh"]=e["s-hn"],t.de=e):(r["s-sh"]=e["s-hn"],le.push({de:e,me:r})),r["s-sr"]&&le.map((e=>{S(e.me,r["s-sn"])&&(t=le.find((e=>e.me===r)),t&&!e.de&&(e.de=t.de))}))}else le.some((e=>e.me===r))||le.push({me:r})}1===e.nodeType&&fe(e)}},me=e=>{e.ae&&e.ae.ref&&ee.push((()=>e.ae.ref(null))),e.oe&&e.oe.map(me)},de=(e,r)=>{re.push((()=>e(r)))},pe=(e,r,t,n)=>{if("string"==typeof r["s-sn"]){e.insertBefore(r,t);const{slotNode:i}=function(e,r){var t;if(!(r=r||(null==(t=e["s-ol"])?void 0:t.parentElement)))return{slotNode:null,slotName:""};const n=e["s-sn"]=F(e)||"";return{slotNode:C(B(r,"childNodes"),r.tagName,n)[0],slotName:n}}(r);return i&&!n&&function(e){e.dispatchEvent(new CustomEvent("slotchange",{bubbles:!1,cancelable:!1,composed:!1}))}(i),r}return e.__insertBefore?e.__insertBefore(r,t):null==e?void 0:e.insertBefore(r,t)},he=(e,r,t=!1)=>{var n,i,a,o,u;const s=e.$hostElement$,l=e.D,m=e.pe||j(null,null),d=(e=>e&&e.le===R)(r)?r:z(null,null,r);if(T=s.tagName,l.he&&(d.ae=d.ae||{},l.he.forEach((([e,r])=>{d.ae[r]=s[e]}))),t&&d.ae)for(const e of Object.keys(d.ae))s.hasAttribute(e)&&!["key","ref","style","class"].includes(e)&&(d.ae[e]=s[e]);if(d.le=null,d.ee|=4,e.pe=d,d.fe=m.fe=s.shadowRoot||s,X=!(!(1&l.ee)||128&l.ee),q=s["s-cr"],Y=!1,ce(m,d,t),f.ee|=1,Q){fe(d.fe);for(const e of le){const r=e.me;if(!r["s-ol"]&&c.document){const e=c.document.createTextNode("");e["s-nr"]=r,pe(r.parentNode,r["s-ol"]=e,r,t)}}for(const e of le){const r=e.me,u=e.de;if(1===r.nodeType&&t&&(r["s-ih"]=null!=(n=r.hidden)&&n),u){const e=u.parentNode;let n=u.nextSibling;if(n&&1===n.nodeType){let t=null==(i=r["s-ol"])?void 0:i.previousSibling;for(;t;){let i=null!=(a=t["s-nr"])?a:null;if(i&&i["s-sn"]===r["s-sn"]&&e===(i.__parentNode||i.parentNode)){for(i=i.nextSibling;i===r||(null==i?void 0:i["s-sr"]);)i=null==i?void 0:i.nextSibling;if(!i||!i["s-nr"]){n=i;break}}t=t.previousSibling}}if((!n&&e!==(r.__parentNode||r.parentNode)||(r.__nextSibling||r.nextSibling)!==n)&&r!==n){if(pe(e,r,n,t),8===r.nodeType&&r.nodeValue.startsWith("s-nt-")){const e=c.document.createTextNode(r.nodeValue.replace(/^s-nt-/,""));e["s-hn"]=r["s-hn"],e["s-sn"]=r["s-sn"],e["s-sh"]=r["s-sh"],e["s-sr"]=r["s-sr"],e["s-ol"]=r["s-ol"],e["s-ol"]["s-nr"]=e,pe(r.parentNode,e,r,t),r.parentNode.removeChild(r)}1===r.nodeType&&"SLOT-FB"!==r.tagName&&(r.hidden=null!=(o=r["s-ih"])&&o)}r&&"function"==typeof u["s-rf"]&&u["s-rf"](u)}else 1===r.nodeType&&(r.hidden=!0)}}if(Y&&M(d.fe),f.ee&=-2,le.length=0,!X&&!(1&l.ee)&&s["s-cr"]){const e=d.fe.__childNodes||d.fe.childNodes;for(const r of e)if(r["s-hn"]!==T&&!r["s-sh"])if(t&&null==r["s-ih"]&&(r["s-ih"]=null!=(u=r.hidden)&&u),1===r.nodeType)r.hidden=!0;else if(3===r.nodeType&&r.nodeValue.trim()){const e=c.document.createComment("s-nt-"+r.nodeValue);e["s-sn"]=r["s-sn"],pe(r.parentNode,e,r,t),r.parentNode.removeChild(r)}}q=void 0,ee.forEach((e=>e())),ee.length=0,re.forEach((e=>e())),re.length=0},ve=(e,r)=>{if(r&&!e.ve&&r["s-p"]){const t=r["s-p"].push(new Promise((n=>e.ve=()=>{r["s-p"].splice(t-1,1),n()})))}},ye=(e,r)=>{if(e.ee|=16,4&e.ee)return void(e.ee|=512);ve(e,e.ye);const t=()=>be(e,r);if(!r)return w(t);queueMicrotask((()=>{t()}))},be=(e,r)=>{const t=e.$hostElement$,n=t;if(!n)throw Error(`Can't render component <${t.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`);let i;return i=Me(n,r?"componentWillLoad":"componentWillUpdate",void 0,t),i=ge(i,(()=>Me(n,"componentWillRender",void 0,t))),ge(i,(()=>we(e,n,r)))},ge=(e,r)=>xe(e)?e.then(r).catch((e=>{console.error(e),r()})):r(),xe=e=>e instanceof Promise||e&&e.then&&"function"==typeof e.then,we=async(e,r,t)=>{var n;const i=e.$hostElement$,a=i["s-rc"];t&&(e=>{const r=e.D,t=e.$hostElement$,n=r.ee,i=((e,r)=>{var t,n,i;const a=O(r),o=u.get(a);if(!c.document)return a;if(e=11===e.nodeType?e:c.document,o)if("string"==typeof o){let i,u=k.get(e=e.head||e);if(u||k.set(e,u=new Set),!u.has(a)){i=c.document.createElement("style"),i.textContent=o;const s=null!=(t=f.be)?t:function(){var e,r,t;return null!=(t=null==(r=null==(e=c.document.head)?void 0:e.querySelector('meta[name="csp-nonce"]'))?void 0:r.getAttribute("content"))?t:void 0}();if(null!=s&&i.setAttribute("nonce",s),!(1&r.ee))if("HEAD"===e.nodeName){const r=e.querySelectorAll("link[rel=preconnect]"),t=r.length>0?r[r.length-1].nextSibling:e.querySelector("style");e.insertBefore(i,(null==t?void 0:t.parentNode)===e?t:null)}else if("host"in e)if(m){const r=new(null!=(n=e.defaultView)?n:e.ownerDocument.defaultView).CSSStyleSheet;r.replaceSync(o),d?e.adoptedStyleSheets.unshift(r):e.adoptedStyleSheets=[r,...e.adoptedStyleSheets]}else{const r=e.querySelector("style");r?r.textContent=o+r.textContent:e.prepend(i)}else e.append(i);1&r.ee&&e.insertBefore(i,null),4&r.ee&&(i.textContent+="slot-fb{display:contents}slot-fb[hidden]{display:none}"),u&&u.add(a)}}else{let r=k.get(e);if(r||k.set(e,r=new Set),!r.has(a)){const t=null!=(i=e.defaultView)?i:e.ownerDocument.defaultView;let n;if(o.constructor===t.CSSStyleSheet)n=o;else{n=new t.CSSStyleSheet;for(let e=0;e<o.cssRules.length;e++)n.insertRule(o.cssRules[e].cssText,e)}d?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n],r.add(a)}}return a})(t.shadowRoot?t.shadowRoot:t.getRootNode(),r);10&n&&(t["s-sc"]=i,t.classList.add(i+"-h"))})(e);De(e,r,i,t),a&&(a.map((e=>e())),i["s-rc"]=void 0);{const r=null!=(n=i["s-p"])?n:[],t=()=>Ne(e);0===r.length?t():(Promise.all(r).then(t).catch(t),e.ee|=4,r.length=0)}},De=(e,r,t,n)=>{try{r=r.render(),e.ee&=-17,e.ee|=2,he(e,r,n)}catch(r){o(r,e.$hostElement$)}return null},Ne=e=>{const r=e.$hostElement$,t=r,n=e.ye;Me(t,"componentDidRender",void 0,r),64&e.ee?Me(t,"componentDidUpdate",void 0,r):(e.ee|=64,Ce(r),Me(t,"componentDidLoad",void 0,r),e.ge(r),n||Ae()),e.ve&&(e.ve(),e.ve=void 0),512&e.ee&&x((()=>ye(e,!1))),e.ee&=-517},Ae=()=>{x((()=>L(c,"appload",{detail:{namespace:"lido-player"}})))},Me=(e,r,t,n)=>{if(e&&e[r])try{return e[r](t)}catch(e){o(e,n)}},Ce=e=>e.classList.add("hydrated"),Ee=(e,r,t,n)=>{const a=i(e);if(!a)return;const u=e,s=a.O.get(r),c=a.ee,l=u;if(!((t=$(t,n.o[r][0]))===s||Number.isNaN(s)&&Number.isNaN(t))){if(a.O.set(r,t),n.xe){const e=n.xe[r];e&&e.map((e=>{try{const[[n,i]]=Object.entries(e);(128&c||1&i)&&(l?l[n](t,s,r):a.we.push((()=>{a.De[n](t,s,r)})))}catch(e){o(e,u)}}))}if(2&c){if(l.componentShouldUpdate&&!1===l.componentShouldUpdate(t,s,r)&&!(16&c))return;16&c||ye(a,!1)}}},Se=(e,t)=>{var n,a;const o=e.prototype;{e.watchers&&!t.xe&&(t.xe=U(e.watchers)),e.deserializers&&!t.Ne&&(t.Ne=e.deserializers),e.serializers&&!t.Ae&&(t.Ae=e.serializers);const u=Object.entries(null!=(n=t.o)?n:{});u.map((([e,[n]])=>{if(31&n||32&n){const{get:a,set:u}=r(o,e)||{};a&&(t.o[e][0]|=2048),u&&(t.o[e][0]|=4096),Object.defineProperty(o,e,{get(){return a?a.apply(this):((e,r)=>i(this).O.get(r))(0,e)},configurable:!0,enumerable:!0}),Object.defineProperty(o,e,{set(r){const a=i(this);if(a){if(u)return void 0===(32&n?this[e]:a.$hostElement$[e])&&a.O.get(e)&&(r=a.O.get(e)),u.call(this,$(r,n)),void Ee(this,e,r=32&n?this[e]:a.$hostElement$[e],t);Ee(this,e,r,t)}}})}}));{const r=new Map;o.attributeChangedCallback=function(e,n,a){f.jmp((()=>{var s;const c=r.get(e),l=i(this);if(this.hasOwnProperty(c),o.hasOwnProperty(c)&&"number"==typeof this[c]&&this[c]==a)return;if(null==c){const r=null==l?void 0:l.ee;if(l&&r&&!(8&r)&&a!==n){const i=this,o=null==(s=t.xe)?void 0:s[e];null==o||o.forEach((t=>{const[[o,u]]=Object.entries(t);null!=i[o]&&(128&r||1&u)&&i[o].call(i,a,n,e)}))}return}const f=u.find((([e])=>e===c)),m=f&&4&f[1][0],d=m&&null===a&&void 0===this[c];m&&(a=null!==a&&"false"!==a);const p=Object.getOwnPropertyDescriptor(o,c);d||a==this[c]||p.get&&!p.set||(this[c]=a)}))},e.observedAttributes=Array.from(new Set([...Object.keys(null!=(a=t.xe)?a:{}),...u.filter((([e,r])=>31&r[0])).map((([e,n])=>{var i;const a=n[1]||e;return r.set(a,e),512&n[0]&&(null==(i=t.he)||i.push([e,a])),a}))]))}}return e},Fe=(e,r)=>{const t={ee:r[0],ne:r[1]};try{t.o=r[2],t.xe=U(e.xe),t.Ne=e.Ne,t.Ae=e.Ae,t.he=[];const a=e.prototype.connectedCallback,s=e.prototype.disconnectedCallback;return Object.assign(e.prototype,{__hasHostListenerAttached:!1,__registerHost(){((e,r)=>{const t={ee:0,$hostElement$:e,D:r,O:new Map,Me:new Map};t.Ce=new Promise((e=>t.ge=e)),e["s-p"]=[],e["s-rc"]=[];const i=t;e.__stencil__getHostRef=()=>i,512&r.ee&&n(e,t)})(this,t)},connectedCallback(){if(!this.__hasHostListenerAttached){if(!i(this))return;this.__hasHostListenerAttached=!0}(e=>{if(!(1&f.ee)){const r=i(e);if(!r)return;const t=r.D,n=()=>{};if(1&r.ee)(null==r?void 0:r.De)||(null==r?void 0:r.Ce)&&r.Ce.then((()=>{}));else{r.ee|=1,12&t.ee&&(e=>{if(!c.document)return;const r=e["s-cr"]=c.document.createComment("");r["s-cn"]=!0,pe(e,r,e.firstChild)})(e);{let t=e;for(;t=t.parentNode||t.host;)if(t["s-p"]){ve(r,r.ye=t);break}}t.o&&Object.entries(t.o).map((([r,[t]])=>{if(31&t&&Object.prototype.hasOwnProperty.call(e,r)){const t=e[r];delete e[r],e[r]=t}})),(async(e,r,t)=>{let n;try{if(!(32&r.ee)&&(r.ee|=32,n=e.constructor,customElements.whenDefined(e.localName).then((()=>r.ee|=128)),n&&n.style)){let e;"string"==typeof n.style&&(e=n.style);const r=O(t);if(!u.has(r)){const n=()=>{};((e,r,t)=>{let n=u.get(e);m&&t?(n=n||new CSSStyleSheet,"string"==typeof n?n=r:n.replaceSync(r)):n=r,u.set(e,n)})(r,e,!!(1&t.ee)),n()}}const i=r.ye,a=()=>ye(r,!0);i&&i["s-rc"]?i["s-rc"].push(a):a()}catch(t){o(t,e),r.ve&&(r.ve(),r.ve=void 0),r.ge&&r.ge(e)}})(e,r,t)}n()}})(this),a&&a.call(this)},disconnectedCallback(){(async e=>{k.has(e)&&k.delete(e),e.shadowRoot&&k.has(e.shadowRoot)&&k.delete(e.shadowRoot)})(this),s&&s.call(this)},__attachShadow(){if(this.shadowRoot){if("open"!==this.shadowRoot.mode)throw Error(`Unable to re-use existing shadow root for ${t.ne}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`)}else A.call(this,t)}}),Object.defineProperty(e,"is",{value:t.ne,configurable:!0}),Se(e,t)}catch(r){return o(r),e}},Be=e=>f.be=e,qe=e=>Object.assign(f,e),Te=new WeakMap;function ke(e,r){let t=Te.get(r);t||(t={ee:0,D:{ee:0,ne:r.tagName},$hostElement$:r},Te.set(r,t)),he(t,e)}function Oe(e){return e}const Ie="lidoSelectedValues",ze="data-animation-vanished-values",je="lidoActivityScore",Re="lidoActivityEnd",Ue="lidoLessonEnd",$e="lidoNextContainer",Pe="lidoPrevContainer",Le="lidoActivityChange",_e="lidoGameCompleted",We="lidoGameExit",Je="dropLength",Ve="drop-to",He="drop-time",Ze="lido-container",Ge="__LIDO_COMMON_AUDIO_PATH__",Xe="lidoCommonAudioPathReady",Ye="lido:interaction-cleanup",Qe="template-id",Ke="calculator-ok",er="problemEnd",rr="lessonEnd",tr="gameEnd",nr="gameExit";var ir,ar,or;!function(e){e.NoFlow="noFlow",e.ShowFlow="showFlow",e.FreeTrace="freeTrace",e.BlindTracing="blindTracing",e.BlindFreeTrace="blindFreeTrace"}(ir||(ir={}));class ur{constructor(){this.totalRightMovesCount=0,this.totalWrongMovesCount=0,this.rightMoves=0,this.wrongMoves=0,this.finalScore=0}}!function(e){e.Diagonal="diagonal",e.Stretch="stretch",e.InfiniteDrop="infinite-drop",e.EnableAnimation="enableanimation"}(ar||(ar={})),function(e){e.InfiniteDrop="infinite-drop",e.Move="move",e.Hide="hide"}(or||(or={}));const sr="https://aeakbcdznktpsbrfsgys.supabase.co/storage/v1/object/public/template-assets/Navbar-buttons/Close.png",cr="https://aeakbcdznktpsbrfsgys.supabase.co/storage/v1/object/public/template-assets/Navbar-buttons/Previous.png",lr="https://aeakbcdznktpsbrfsgys.supabase.co/storage/v1/object/public/template-assets/Navbar-buttons/Next.png",fr="https://aeakbcdznktpsbrfsgys.supabase.co/storage/v1/object/public/template-assets/Navbar-buttons/NavAudio.png",mr="https://aeakbcdznktpsbrfsgys.supabase.co/storage/v1/object/public/template-assets/trace/Tracing-hand.png",dr={en:new Set(["a","an","the","on","in","at","to","of","for","into","up","or","is","are","were"]),hi:new Set(["का","की","के","में","पर","से","तो","को","है","था","थे"]),kn:new Set(["ಅದು","ಇದು","ನಲ್ಲಿ","ಮೇಲೆ","ಮತ್ತು","ಇದೆ","ಆಗಿತ್ತು"])},pr={en:{expectedWPM:135,minWordMs:80,syllableWeight:1.28,punctuationPauseWeight:.45,preemptiveOffsetMs:55,smoothingMs:25,fastWordMultiplier:.65,fastClusterMultiplier:.65},hi:{expectedWPM:155,minWordMs:40,syllableWeight:1.3,punctuationPauseWeight:.3,preemptiveOffsetMs:20,smoothingMs:45,fastWordMultiplier:.9,fastClusterMultiplier:.9},kn:{expectedWPM:85,minWordMs:35,syllableWeight:1.75,punctuationPauseWeight:.5,preemptiveOffsetMs:15,smoothingMs:50,fastWordMultiplier:1,fastClusterMultiplier:1}};function hr(e,r){var t;const n=new CustomEvent(e,{detail:r});window.dispatchEvent(n),e!==Re&&e!==Ue&&e!==_e&&e!==We&&e!==tr&&e!==nr&&e!==rr&&e!==er||null===(t=window.parent)||void 0===t||t.postMessage({eventName:e,detail:vr(r)},"*")}function vr(e){return e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter((([,e])=>null===e||["string","number","boolean","undefined"].includes(typeof e)||Array.isArray(e)||"object"==typeof e&&e.constructor===Object))):e}function yr(){hr(nr,{}),"blank"!==$F().end&&"complete"!==$F().end&&"completed"!==$F().end&&hr(We,{})}function br(e){hr(Le,{index:e})}function gr(e,r){hr("lidoElementClick",{element:e,isCorrect:r,createdAt:(new Date).toISOString()})}class xr{constructor(){}static getInstance(){return xr.instance||(xr.instance=new xr),xr.instance}setRiveInstance(e){this.riveInstance=e}getRiveInstance(){return this.riveInstance}}function wr(){var e,r;const t=document.querySelector("lido-balance");if(!t)return;const n=Array.from(document.querySelectorAll('[drop-to^="lefthandle"]')),i=Array.from(document.querySelectorAll('[drop-to^="righthandle"]'));t.leftVal=Dr(n,t.operation),t.rightVal=Dr(i,t.operation);const a=document.getElementById("lido-container"),o=null!==(r=null!==(e=null==a?void 0:a.objective)&&void 0!==e?e:null==a?void 0:a.getAttribute("objective"))&&void 0!==r?r:"",u=!!a&&Nr(a,o),s=a?Array.from(a.querySelectorAll('[type="drop"]')):[],c=s.filter((e=>!!(null==a?void 0:a.querySelector(`[drop-to="${e.id}"]`)))).length,l=s.length>0&&c===s.length;if(t.setFeedbackColor&&t.setFeedbackColor(l&&u?"#81C127":l?"#FF0410":""),t.updateTilt){if(!u)return void t.updateTilt(0,0);t.updateTilt(t.leftVal,t.rightVal)}}function Dr(e,r){if(0===e.length)return null;if("count"===r)return e.length;const t=e.map((e=>e.getAttribute("value")||"0")).join(["add","+"].includes(r)?" + ":["subtract","-"].includes(r)?" - ":["multiply","*"].includes(r)?" * ":["divide","/"].includes(r)?" / ":" + ");try{const e=tB(t);return"number"==typeof e?e:"boolean"==typeof e?e?1:0:parseFloat(t)||0}catch(e){return console.warn("invalid exp",t),0}}function Nr(e,r){if(!e.getAttribute("equationCheck"))return!1;const t=document.querySelector("lido-balance");if(!t)return!1;const n=t.leftVal,i=t.rightVal;return null!=n&&null!=i&&r===(n>i?">":n<i?"<":"=")}function Ar(e,r,t){e.style.pointerEvents="none",setTimeout((async()=>{var n,i;const a=document.createElement("div");e.append(a),a.classList.add("after-drop-popup-container"),r.style.scale="1",t.style.scale="1";const o=e.querySelectorAll('[type="drag"]'),u=Array.from(o).map((e=>e.parentElement)).every((e=>e===r.parentElement)),s=(e=>{var r;try{const t=JSON.parse(null!==(r=e.getAttribute(ze))&&void 0!==r?r:"[]");return Array.isArray(t)?t:[]}catch(e){return[]}})(e),c=null!==(n=r.getAttribute("value"))&&void 0!==n?n:null===(i=r.textContent)||void 0===i?void 0:i.trim();c&&(s.push(c),e.setAttribute(ze,JSON.stringify(s))),u?(r.remove(),t.remove()):(r.parentElement.parentElement.remove(),t.parentElement.parentElement.remove()),r.classList.add("zoom-fade-in","after-drop-popup-drag-element"),t.classList.add("zoom-fade-in","after-drop-popup-drop-element"),a.appendChild(r),a.appendChild(t),t.classList.remove("empty");const l=e.getAttribute("objective"),f=s.map((e=>e.trim())).sort().join(","),m=null==l?void 0:l.split(",").map((e=>e.trim())).sort().join(","),d=!!l&&f===m;if("drop"===t.getAttribute("type")){const e=t.getAttribute("onCorrect")||"";await qF(e,t,r)}if(d){const r=(null==e?void 0:e.getAttribute("onCorrect"))||"";await qF(r,e)}r.classList.remove("zoom-fade-in"),t.classList.remove("zoom-fade-in"),r.classList.add("zoom-fade-out"),t.classList.add("zoom-fade-out");const p=()=>{a.remove(),e.style.pointerEvents="auto",d&&(RF(),HF(),e.removeAttribute(ze))},h=(e.getAttribute("template-id")||"").toLowerCase();"letterpairing"===h||"numberpair"===h?p():setTimeout(p,800)}),250)}const Mr=e=>"blender"===(null==e?void 0:e.getAttribute("template-id"));function Cr(){const e={};return document.querySelectorAll("[type='drop']").forEach((r=>{const t=r.getAttribute("tab-index")||r.id,n=!!document.querySelector(`[${Ve}="${r.id}"]`);r.setAttribute("is-full",n+""),e[t]={drop:r.id,isFull:n}})),e}const Er=e=>{e.style.animation="unset";const r=window.getComputedStyle(e).transform;if("none"===r)return 1;{const e=r.match(/matrix\(([^)]+)\)/);if(e){const r=e[1].split(", ");return parseFloat(r[0])}}return 1};let Sr=!1;const Fr=e=>{Sr=e};const Br=(e,r)=>{const t=e.getBoundingClientRect(),n=document.querySelectorAll(`[type="${r}"]`);let i=null,a=0;return n.forEach((n=>{if(n===e)return;const o=n.getBoundingClientRect(),u=Math.max(0,Math.min(t.right,o.right)-Math.max(t.left,o.left))*Math.max(0,Math.min(t.bottom,o.bottom)-Math.max(t.top,o.top));0!==u&&("slide"===r?u>=.1*Math.min(t.width*t.height,o.width*o.height)&&u>a&&(a=u,i=n):u>a&&(a=u,i=n))})),i};function qr(e,r,t){if(!r||!e||!t)return;const n=r.getBoundingClientRect(),i=e.getBoundingClientRect(),a=window.getComputedStyle(e),o=new DOMMatrixReadOnly(a.transform),u=o.m42||0,s=n.top-i.top,c=(o.m41||0)+(n.left-i.left)*(1/cB()),l=u+s*(1/cB());e.style.transition="transform 1s ease",e.style.transform=`translate(${c}px, ${l}px)`}async function Tr(e,r,t,n,i){var a;e.classList.remove("dropped");const o=document.getElementById(Ze),u=o.querySelectorAll("#"+e.id),s=e.__lidoBalanceHome,c=(null==s?void 0:s.isConnected)?s:Array.from(u).find((r=>e!==r&&!r.classList.contains("dropped")));e.style.transition="transform 0.5s ease",c?(qr(e,c,o),setTimeout((()=>{o.getAttribute("drop-action")===or.InfiniteDrop?(e.removeAttribute("hasDummy"),e.style.width=c.style.width,e.style.height=c.style.height):(c.style.width=e.style.width,c.style.height=e.style.height),e.style.transform="translate(0,0)",e.style.position="unset",c.replaceWith(e),delete e.__lidoBalanceHome}),500)):e.style.transform="translate(0,0)";let l=zr.get(e);if(l){if(zr.delete(e),Or(l),(null===(a=null==l?void 0:l.getAttribute("drop-attr"))||void 0===a?void 0:a.toLowerCase())===ar.Stretch){const e=l.getAttribute("data-original-width");e?(l.style.width=e,l.removeAttribute("data-original-width")):(l.style.width="",l.removeAttribute("data-original-width"))}let r=Object.values(t).find((e=>document.getElementById(e.drop)===l));if(r){r.isFull=!1,_r();const e=document.getElementById(r.drop);e&&e.removeAttribute("is-full")}zr.delete(e)}if(n){const e=EF(CF());o.setAttribute(Ie,JSON.stringify(e))}if(i){let r=JSON.parse(i);const t=o.querySelector("#"+e.getAttribute(Ve));t&&delete r[t.getAttribute("tab-index")],e.removeAttribute(Ve),Or(l);const n=EF(CF());n&&n.length>0?o.setAttribute(Ie,JSON.stringify(n)):o.removeAttribute(Ie),wr()}document.querySelectorAll("[type='drop']").forEach((e=>{var r;const t=CF();Object.keys(t).map(Number).includes(JSON.parse(e.getAttribute("tab-index")))?(null===(r=e.getAttribute("dropAttr"))||void 0===r?void 0:r.toLowerCase())!==ar.Diagonal&&"lido-text"===e.tagName.toLowerCase()&&(e.style.opacity="1"):e&&(e.style.opacity="1")})),await qF("this.updateCountBlender='true'",o),_F(),_r()}async function kr(e,r){var t,n,i,a,o,u,s,c,l;const f=document.getElementById(Ze),m=null!==(t=f.getAttribute(Ie))&&void 0!==t?t:"[]",d=JSON.stringify(CF()),p=CF();JSON.stringify(p);let h,v=Cr();if(r||Tr(e,0,v,m,d),r){h=r.getAttribute("tab-index");const t="false"===r.getAttribute("is-allow-only-one-drop");if((null===(n=v[h])||void 0===n?void 0:n.isFull)&&!t)return void Tr(e,0,v,m,d)}if("true"===f.getAttribute("is-allow-only-correct")){if(!r)return e.style.transition="transform 0.5s ease",e.style.transform="translate(0, 0)",void Tr(e,0,v,m,d);let t;const n=(null===(i=e.getAttribute("value"))||void 0===i?void 0:i.trim())||"",o=(null===(a=r.getAttribute("value"))||void 0===a?void 0:a.trim())||"";if(Number(n)){const e=Number(n);t=o.includes(",")?o.split(",").some((r=>Number(r)===e)):Number(o)===e}else t=o.includes(",")?o.toLowerCase().includes(n.toLowerCase()):o.toLowerCase()===n.toLowerCase();if(!t){e.style.transition="transform 0.5s ease",qr(e,r,f);const t=r.getAttribute("onInCorrect");return await qF(t,r,e),jF(!1),setTimeout((()=>{e.style.transform="translate(0, 0)",Tr(e,0,v,m,d)}),500),void("option"===e.type&&Array.from(f.querySelectorAll(`[value="${e.value}"]`)).forEach((r=>{r!==e&&r.getAttribute("value")===e.getAttribute("value")&&r.replaceWith(e)})))}{const t=f.getAttribute("dropAttr");t&&t.toLowerCase()===ar.EnableAnimation.toLowerCase()&&Ar(f,e,r)}}else{const t=f.getAttribute("dropAttr");t&&t.toLowerCase()===ar.EnableAnimation.toLowerCase()&&Ar(f,e,r)}if(r){let t=JSON.parse(null!==(o=f.getAttribute(Ie))&&void 0!==o?o:"[]");const n=e.getAttribute("value");if(n&&!t.includes(n)&&t.push(n),f.setAttribute(Ie,JSON.stringify(t)),"stretch"===r.getAttribute("drop-attr")){if(!r.hasAttribute("data-original-width")){const e=window.getComputedStyle(r);r.setAttribute("data-original-width",e.width)}r.style.width=e.offsetWidth+"px"}if((null===(u=r.getAttribute("dropAttr"))||void 0===u?void 0:u.toLowerCase())!==ar.Diagonal&&("1"===r.getAttribute("minDrops")||!r.getAttribute("minDrops"))){const t=Object.values(v).find((e=>document.getElementById(e.drop)===r));if("true"===r.getAttribute("is-allow-only-one-drop")&&t?(t.isFull=!0,r.setAttribute("is-full","true"),_r()):console.warn("No matching drop item found for",r),d){let r=JSON.parse(d);for(const t in r)if(r[t].includes(e.value)&&e.classList.contains("dropped")){const t=e.getAttribute("drop-to"),n=f.querySelector("#"+t).getAttribute("tab-index");n&&delete r[n]}}if(e.classList.add("dropped"),e&&(r?e.setAttribute(Ve,null==r?void 0:r.id):e.removeAttribute(Ve),e.setAttribute(He,""+(new Date).getTime())),r&&!(null===(s=v[h])||void 0===s?void 0:s.isFull)){let t=Br(e,"drag");if("true"===r.getAttribute("is-allow-only-one-drop")&&t)return e.style.transform="translate(0,0)",e.style.transition="transform 0.5s ease",void document.querySelectorAll("[type='drop']").forEach((e=>{var r;const t=CF();Object.keys(t).map(Number).includes(JSON.parse(e.getAttribute("tab-index")))?(null===(r=e.getAttribute("dropAttr"))||void 0===r?void 0:r.toLowerCase())!==ar.Diagonal&&e&&(e.style.opacity="0"):e&&(e.style.opacity="1")}))}}}if(!r)return void Tr(e,0,v,m,d);if(wr(),d){let r=zr.get(e);if(r){let e=Object.values(v).find((e=>document.getElementById(e.drop)===r));e&&(e.isFull=!1,Rr())}}let y=parseInt(null!==(c=f.getAttribute(Je))&&void 0!==c?c:"0");if(y+=1,f.setAttribute(Je,y+""),y===IF(r.value)){const e=Object.values(v).find((e=>document.getElementById(e.drop)===r));e?e.isFull=!0:console.warn("No matching drop item found for",r),y=0,f.setAttribute(Je,y+"")}zr.set(e,r);const b=r.value.toLowerCase().includes(e.value.toLowerCase());if(function(e,r,t){hr("lidoElementDrop",{dragElement:e,dropElement:r,isCorrect:t,createdAt:(new Date).toISOString()})}(e,r,b),Mr(f)||jF(b),e.style.opacity="1",document.querySelectorAll(".drop-element").forEach((e=>Or(e))),Mr(f)){const t=Number(null!==(l=r.getAttribute("required-drops"))&&void 0!==l?l:0),n=document.querySelectorAll(`[${Ve}="${r.id}"]`).length,i=r.getAttribute(n>0&&n<=t?"onCorrect":"onInCorrect");i&&await qF(i,r,e)}_r(),await UF(e,r);const g=f.getAttribute("drop-action");f.querySelector("lido-balance")&&g!==or.Move&&g!==or.InfiniteDrop&&function(e,r){var t;const n=document.querySelector("lido-balance"),i=null==r?void 0:r.parentElement;if(!n||!i)return;const a=e;if(!(null===(t=a.__lidoBalanceHome)||void 0===t?void 0:t.isConnected)){const e=document.createElement("div");e.className="lido-balance-source-placeholder",e.setAttribute("aria-hidden","true"),a.replaceWith(e),a.__lidoBalanceHome=e}i.append(a),a.style.position="absolute",a.style.zIndex="1",a.style.transition="none",a.style.transform="translate(0, 0)";const o=r.getBoundingClientRect(),u=a.getBoundingClientRect(),s=cB()||1;a.style.transform=`translate(${(o.left+o.width/2-(u.left+u.width/2))/s}px, ${(o.top+o.height/2-(u.top+u.height/2))/s}px)`,requestAnimationFrame((()=>{a.style.transition=""}))}(e,r)}function Or(e){var r;if(!e||!e.classList.contains("drop-element"))return;const t=document.getElementById(Ze);if(!t)return;if("true"!==t.getAttribute("show-drop-border")&&!Mr(t))return;const n=document.querySelectorAll(`[${Ve}="${e.id}"]`);if(Mr(t)){const t=Number(null!==(r=e.getAttribute("required-drops"))&&void 0!==r?r:0),i=n.length,a=i>0&&i<=t;return e.classList.toggle("empty",!a),e.classList.remove("filled"),void e.style.setProperty("border",a?"5px dashed green":"5px dashed #f34d08","important")}n.length>0&&!Mr(t)?(e.classList.add("filled"),e.classList.remove("empty"),e.classList.remove("highlight-element")):(e.classList.contains("math-matrix")||e.classList.add("empty"),e.classList.remove("filled"))}async function Ir(e,r){const t=document.getElementById(Ze);if("false"===t.getAttribute("canplay")||"true"===t.getAttribute("game-completed"))return;if(document.querySelectorAll(`[type='${r}']`).forEach((e=>{e.style.pointerEvents="",$r(e)})),!document.querySelector("#dynamic-highlight-style")){const e=document.createElement("style");e.id="dynamic-highlight-style",e.innerHTML="\n .highlight {\n // border: 4px solid #e74c3c; /* Thicker red border for more visibility */\n // border-radius: 12px; /* Larger rounded corners */\n // background-color: rgba(231, 76, 60, 0.3); /* Stronger, more noticeable background */\n // box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2), 0 12px 40px rgba(0, 0, 0, 0.2); /* Stronger shadow */\n // outline: 4px solid rgba(231, 76, 60, 0.6); /* Glow effect */\n }\n ",document.head.appendChild(e)}null==e||e.classList.add("highlight-element"),e.style.pointerEvents="none",e.ariaPressed="true";const n="drop"===r?e:document.querySelector("[type='drop'].highlight-element"),i="drag"===r?e:document.querySelector("[type='drag'].highlight-element");if(setTimeout((()=>{e.style.pointerEvents=""}),1e3),n&&!e.classList.contains("dropped")){if(!e.classList.contains("drop-element")&&n&&i){if(n.style.pointerEvents="none",i.style.pointerEvents="none",i.getAttribute("drop-to"))return;i.style.transition="transform 0.5s ease",i.style.transform="";const e=document.getElementById(Ze),r=Er(e),t=n.getBoundingClientRect(),a=i.getBoundingClientRect();i.style.transform=`translate(${(t.left-a.left)/r}px, ${(t.top-a.top)/r}px)`,Mr(e)||document.querySelectorAll("*").forEach((e=>{$r(e)})),await kr(i,n),e.getAttribute("drop-action")!==or.InfiniteDrop&&e.getAttribute("drop-action")!==or.Move&&(i.style.pointerEvents=""),n.style.pointerEvents="",await qF("this.updateCountBlender='true'",e)}}else!async function(e){const r=e.getAttribute("audio");r&&r.trim().length>0&&Wr.getI().stop();const t=Cr(),n=e;if(!n)return void console.error("Element not found");const i=getComputedStyle(n).transform;if($r(e),i&&"none"!==i&&"matrix(1, 0, 0, 1, 0, 0)"!==i)return void kr(n,null);let a=Object.values(t).find((e=>!e.isFull));if(a){const e=document.querySelector("#"+a.drop);n.style.transition="transform 0.5s ease",await kr(n,e);const r=document.getElementById(Ze);await qF("this.updateCountBlender='true'",r)}}(e)}const zr=new Map,jr=document.getElementById(Ze),Rr=()=>{const e=document.querySelectorAll("[type='drop']");let r=CF();e&&jr&&r&&e&&e.forEach((e=>{var t;const n=e,i=n.getAttribute("tab-index");if((null===(t=null==n?void 0:n.getAttribute("drop-attr"))||void 0===t?void 0:t.toLowerCase())===ar.Stretch&&!1===r[i].isFull){const r=n.getAttribute("data-original-width");e.removeAttribute("is-full"),r&&(n.style.width=r,n.removeAttribute("data-original-width"))}}))},Ur=e=>{var r,t;const n=document.getElementById("lido-container").querySelector("#beedsText");if(!n)return;const i=null!==(r=e.getAttribute("cols"))&&void 0!==r?r:"";if(""===i.trim())return;const a=(null!==(t=n.textContent)&&void 0!==t?t:"").trim();if(""===a)return void(n.textContent=i);const o=a.split("=")[0].trim(),u=o?`${o}+${i}`:i,s=u.split("+").map((e=>Number(e.trim()))).reduce(((e,r)=>Number.isNaN(r)?NaN:e+r),0);n.textContent=Number.isNaN(s)?u:`${u}=${s}`};function $r(e){e.classList.remove("highlight-element"),e.ariaPressed="false"}function Pr(e){if(!e)return;e.classList.add("speaking-highlight");const r="speaking-highlight-style";if(!document.getElementById(r)){const t=document.createElement("style");t.id=r,t.innerHTML=`\n .speaking-highlight {\n --base-transform: ${e.style.transform};\n box-shadow: 0 0 20px 10px rgba(255, 165, 0, 0.9) !important; /* Stronger orange glow effect */\n // border: 3px solid green !important;\n // transition: box-shadow 0.5s ease-in-out, transform 0.5s ease-in-out;\n // transform: scale(1.05); /* Subtle scale effect to pop the element */\n // animation: pulseEffect 1.5s infinite; /* Pulsing animation */\n \n }\n\n @keyframes pulseEffect {\n 0% {\n box-shadow: 0 0 20px 10px rgba(255, 165, 0, 0.9);\n // transform: var(--base-transform) scale(1.05);\n // background-color: #FFFF0B;\n }\n 50% {\n box-shadow: 0 0 30px 15px rgba(255, 165, 0, 1);\n // transform: var(--base-transform) scale(1.1);\n // background-color: #FFFF0B;\n }\n 100% {\n box-shadow: 0 0 20px 10px rgba(255, 165, 0, 0.9);\n // transform: var(--base-transform) scale(1.05);\n // background-color: #FFFF0B;\n }\n }\n `,document.head.appendChild(t)}}function Lr(e){e&&e.classList.remove("speaking-highlight")}function _r(){const e=document.querySelector(Ze);if(!e)return;if("blender"===e.getAttribute("template-id"))return;const r=Cr();e.querySelectorAll('[type="drop"]').forEach((e=>{e.classList.remove("highlight-element")}));let t=Object.values(r).find((e=>!e.isFull));if(t){const r=e.querySelector("#"+t.drop);r&&r.classList.add("highlight-element");const n=e.querySelectorAll('[type="drag"]');zF>2&&"true"===e.getAttribute("is-continue-on-correct")?n.forEach((e=>{e.classList.remove("highlight-element"),e.getAttribute("value")===r.getAttribute("value")&&(e.classList.add("highlight-element"),e.classList.remove("drag-element"))})):n.forEach((e=>{e.classList.remove("highlight-element"),e.classList.add("drag-element")}))}else{if(zF<=2||"false"===e.getAttribute("is-continue-on-correct"))return;e.querySelectorAll("[type='click']").forEach((r=>{r.getAttribute("value")===e.getAttribute("objective")&&(r.classList.contains("highlight-element")||r.classList.add("highlight-element"))}))}}class Wr{resolvePlaybackWait(){if(!this.endPromiseResolve)return;const e=this.endPromiseResolve;this.endPromiseResolve=null,e()}constructor(){this.currentTargetElement=null,this.pendingReplayElement=null,this.playbackHasStarted=!1,this.playbackSequence=0,this.highlightOverlay=null,this.wordRects=[],this.activeWordIndex=-1,this.highlightRAF=null,this.endPromiseResolve=null,this.visibilityWaitResolvers=[],this.isVisibilityChangeRegistered=!1,this.stopEvents=[$e,Pe,Ue,Le,Re,_e,We],this.handleGlobalStopEvent=()=>this.stop(),this.handleUserClick=e=>{const r=document.getElementById(Ze);r&&(null==e?void 0:e.target)===r||"true"!==(null==r?void 0:r.getAttribute("game-completed"))&&this.stop()},this.handleVisibilityChange=async()=>{this.isWindowVisible()?this.resolveVisibilityWaiters():this.currentTargetElement&&(this.pendingReplayElement=this.currentTargetElement,await this.stop(!0))},this.audioElement=document.createElement("audio"),this.registerGlobalStopEvents(),this.registerVisibilityEvents()}static getI(){return Wr.instance||(Wr.instance=new Wr),Wr.instance}static destroyI(){Wr.instance&&Wr.instance.destroy()}stop(e=!1){const r=document.getElementById(Ze);r&&"true"===r.getAttribute("highlight-word-by-word")&&this.stopOverlayHighlightLoop(),(null===window||void 0===window?void 0:window.speechSynthesis)&&window.speechSynthesis.cancel(),this.resolvePlaybackWait(),e||(this.pendingReplayElement=null),this.currentTargetElement=null,this.playbackHasStarted=!1,this.audioElement.pause(),this.audioElement.currentTime=0,this.audioElement.src="",r&&"true"!==r.getAttribute("highlight-word-by-word")&&document.querySelectorAll(".speaking-highlight").forEach((e=>Lr(e)));const t=document.querySelector("#play"),n=document.querySelector("#pause");t&&n&&(t.style.visibility="visible",n.style.visibility="hidden")}isWindowVisible(){return"visible"===document.visibilityState&&!document.hidden}waitUntilWindowIsVisible(){return this.isWindowVisible()?Promise.resolve():(this.registerVisibilityEvents(),new Promise((e=>{this.visibilityWaitResolvers.push(e)})))}resolveVisibilityWaiters(){this.visibilityWaitResolvers.splice(0).forEach((e=>e()))}getLidoTextElement(e){return"lido-text"===e.tagName.toLowerCase()?e:e.closest("lido-text")}async play(e,r=!1,t){if(this.registerVisibilityEvents(),this.playbackHasStarted=!1,!this.isWindowVisible()){if(this.pendingReplayElement=e,await this.stop(!0),await this.waitUntilWindowIsVisible(),this.pendingReplayElement!==e)return;this.pendingReplayElement=null}const n=++this.playbackSequence;try{await Wr.getI().stop()}catch(e){console.error("Error stopping audio before speak action:",e)}const i=document.getElementById(Ze);if(!i)return void console.warn("[AudioPlayer] No lido-container found");if("true"===i.getAttribute("highlight-word-by-word")){const r=this.getLidoTextElement(e);if(!r)return void console.warn("[AudioPlayer] No lido-text found");this.stopOverlayHighlightLoop(),e=r}this.currentTargetElement=e,window.dispatchEvent(new CustomEvent("lidoAudioStarted",{detail:{target:e,playbackId:n,playbackContext:t}}));let a=e.getAttribute("audio")||"";if(!a){const r=e.children;for(let e=0;e<r.length;e++){const t=r[e].getAttribute("audio");if(t){a=t;break}}}if(a){a=QF(a),this.audioElement.src=a,this.audioElement.onplaying=()=>{this.playbackHasStarted=!0,window.dispatchEvent(new CustomEvent("lidoAudioPlaying",{detail:{target:e,playbackId:n,playbackContext:t}}))},this.audioElement.onpause=()=>{this.playbackHasStarted&&!this.audioElement.ended&&this.resolvePlaybackWait()},this.audioElement.onstalled=null,this.audioElement.onerror=()=>{this.playbackHasStarted&&this.resolvePlaybackWait()};try{const t=i.getAttribute("Lang")||"en",n=pr[t]||pr[t.split("-")[0]]||pr.en;let a=[];const o="true"===i.getAttribute("highlight-word-by-word");this.audioElement.onloadedmetadata=null,this.audioElement.onended=null,o?(await this.waitForAudioMetadata(),a=this.buildWordTimeline(e.textContent||"",1e3*this.audioElement.duration,n,t),this.wordRects=this.computeWordRects(e)):r||Pr(e),await this.audioElement.play(),o&&this.startOverlayHighlightLoop(a,n),await new Promise((e=>{this.endPromiseResolve=e,this.audioElement.onended=()=>{this.resolvePlaybackWait()}}))}catch(e){}finally{this.audioElement.onended=null,this.audioElement.onloadedmetadata=null,this.stopOverlayHighlightLoop(),window.removeEventListener("click",this.handleUserClick,!0),this.audioElement.onended=null,Fr(!1),"true"!==i.getAttribute("highlight-word-by-word")&&(r||Lr(e))}}else if(e.textContent)try{r||Pr(e),await async function(e,r){return new Promise(((t,n)=>{if(!("speechSynthesis"in window))return void n(Error("Speech synthesis is not supported in this browser."));const i=window.speechSynthesis;setTimeout((()=>{const n=new SpeechSynthesisUtterance(e);n.onend=()=>{t(!0)},i.speak(n),i.speaking||Lr(r)}),50)}))}(e.textContent,e)}catch(e){}finally{Fr(!1)}if(this.pendingReplayElement===e&&(await this.waitUntilWindowIsVisible(),this.pendingReplayElement===e))return this.pendingReplayElement=null,this.play(e,r,t);this.currentTargetElement===e&&(this.currentTargetElement=null),window.dispatchEvent(new CustomEvent("lidoAudioEnded",{detail:{target:e,playbackId:n,playbackContext:t}}))}registerGlobalStopEvents(){this.stopEvents.forEach((e=>{window.addEventListener(e,this.handleGlobalStopEvent)}))}unregisterGlobalStopEvents(){this.stopEvents.forEach((e=>{window.removeEventListener(e,this.handleGlobalStopEvent)}))}registerVisibilityEvents(){this.isVisibilityChangeRegistered||(document.addEventListener("visibilitychange",this.handleVisibilityChange),this.isVisibilityChangeRegistered=!0)}unregisterVisibilityEvents(){this.isVisibilityChangeRegistered&&(document.removeEventListener("visibilitychange",this.handleVisibilityChange),this.isVisibilityChangeRegistered=!1,this.resolveVisibilityWaiters())}destroy(){this.stop(),this.unregisterGlobalStopEvents(),this.unregisterVisibilityEvents(),this.audioElement.parentNode&&this.audioElement.parentNode.removeChild(this.audioElement),Wr.instance=void 0}countSyllables(e,r){if("en"!==r)return Math.max(2,Math.ceil(e.length/3));const t=e.toLowerCase().replace(/[^a-z]/g,"");if(t.length<=3)return 1;const n=t.match(/[aeiouy]{1,2}/g);return n?n.length:1}tokenize(e){return e.split(/(\s+)/).filter(Boolean)}isFastCluster(e,r,t){if(!e||!r||!t)return!1;const n=dr[t];return(null==n?void 0:n.has(e))&&(null==n?void 0:n.has(r))}buildWordTimeline(e,r,t,n){const i=this.tokenize(e).filter((e=>e.trim())),a=i.map(((e,r)=>{var a,o;const u=null===(a=i[r-1])||void 0===a?void 0:a.toLowerCase(),s=e.toLowerCase();let c=this.countSyllables(e,n)*t.syllableWeight;return/[.,!?]$/.test(e)&&(c+=t.punctuationPauseWeight),(null===(o=dr[n])||void 0===o?void 0:o.has(s))&&(c*=t.fastWordMultiplier),this.isFastCluster(u,s,n)&&(c*=t.fastClusterMultiplier),c})),o=a.reduce(((e,r)=>e+r),0);let u=0;const s=i.map(((e,n)=>{let i=a[n]/o*r;i=Math.max(t.minWordMs,i);const s={word:e,index:n,startMs:u,endMs:u+i};return u+=i,s})),c=s[s.length-1];if(c&&c.endMs!==r){const e=r/c.endMs;s.forEach((r=>{r.startMs*=e,r.endMs*=e}))}return s}waitForAudioMetadata(){return Number.isFinite(this.audioElement.duration)&&this.audioElement.duration>0?Promise.resolve():new Promise(((e,r)=>{const t=()=>{this.audioElement.removeEventListener("loadedmetadata",n),this.audioElement.removeEventListener("error",i)},n=()=>{t(),e()},i=()=>{t(),r(Error("Audio metadata failed to load"))};this.audioElement.addEventListener("loadedmetadata",n,{once:!0}),this.audioElement.addEventListener("error",i,{once:!0})}))}ensureOverlay(){if(this.highlightOverlay)return;const e=document.createElement("div");e.className="lido-tts-highlight-overlay",document.body.appendChild(e),this.highlightOverlay=e}clearOverlay(){this.highlightOverlay&&(this.highlightOverlay.remove(),this.highlightOverlay=null)}computeWordRects(e){const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),t=[];let n,i=0;for(;n=r.nextNode();){const e=n.textContent||"",r=e.split(/\s+/).filter(Boolean);let a=0;r.forEach((r=>{const o=e.indexOf(r,a),u=o+r.length;if(o>=0){const e=document.createRange();e.setStart(n,o),e.setEnd(n,u);const r=e.getBoundingClientRect();r.width>0&&r.height>0&&(t[i++]=r)}a=u}))}return t}moveOverlay(e){this.highlightOverlay&&(this.highlightOverlay.style.transform=`translate3d(${e.left}px, ${e.top}px, 0)`,this.highlightOverlay.style.width=e.width+"px",this.highlightOverlay.style.height=e.height+"px")}getHighlightLeadMs(e,r){if(!e.length)return r.preemptiveOffsetMs;const t=(e[e.length-1].endMs-e[0].startMs)/e.length;return Math.max(r.preemptiveOffsetMs,t<190?120:t<260?90:60)}getTimelineIndex(e,r){if(!e.length)return-1;if(r<=e[0].startMs)return 0;for(let t=0;t<e.length;t++){if(r>=e[t].startMs&&r<e[t].endMs)return t;if(e[t+1]&&r<e[t+1].startMs)return t}return e.length-1}startOverlayHighlightLoop(e,r){this.ensureOverlay(),this.activeWordIndex=-1;const t=this.getHighlightLeadMs(e,r),n=()=>{if(this.audioElement.paused||this.audioElement.ended)return void this.stopOverlayHighlightLoop();const r=this.getTimelineIndex(e,1e3*this.audioElement.currentTime+t);if(r>=0&&this.activeWordIndex>=0&&r-this.activeWordIndex>=2){const e=this.activeWordIndex+1;this.wordRects[e]&&(this.moveOverlay(this.wordRects[e]),this.activeWordIndex=e)}r!==this.activeWordIndex&&this.wordRects[r]&&(this.moveOverlay(this.wordRects[r]),this.activeWordIndex=r),this.highlightRAF=requestAnimationFrame(n)};this.highlightRAF=requestAnimationFrame(n)}stopOverlayHighlightLoop(){null!==this.highlightRAF&&(cancelAnimationFrame(this.highlightRAF),this.highlightRAF=null),this.clearOverlay(),this.activeWordIndex=-1}}let Jr;const Vr=e=>{const r=document.createElement("div");if("option"===e.getAttribute("type"))return r.style.width=e.style.width,r.style.height=e.style.height,r;const t=e.style.width,n=e.style.padding;return e.style.width="auto",e.style.padding="0 20px",r.style.width=e.offsetWidth+20+"px",r.style.height=e.offsetHeight+20+"px",r.style.border="1px solid",r.style.backgroundColor="#00000021",r.style.borderRadius="10px",e.style.width=t,e.style.padding=n,r.setAttribute("value",""+e.getAttribute("value")),r};const Hr=e=>{e.style.opacity="",e.style.cursor="move",e.style.zIndex="",e.style.transform="",e.style.position="",e.style.left="",e.style.top=""};function Zr(e,r){const t=Array.from(document.querySelectorAll(`[type="${r}"]`));let n=0,i=null;const a=e.getBoundingClientRect();for(const r of t){if(r===e)continue;const t=Xr(a,r.getBoundingClientRect());t>n&&(n=t,i=r)}return i}function Gr(e){return e instanceof MouseEvent?{clientX:e.clientX,clientY:e.clientY}:{clientX:e.touches[0].clientX,clientY:e.touches[0].clientY}}function Xr(e,r){return Math.max(0,Math.min(e.right,r.right)-Math.max(e.left,r.left))*Math.max(0,Math.min(e.bottom,r.bottom)-Math.max(e.top,r.top))}const Yr=(e,r)=>{var t;const n=document.getElementById(Ze),i=n.getAttribute("objective").split(",");let a=JSON.parse(null!==(t=n.getAttribute(Ie))&&void 0!==t?t:"[]");a=Array.from(e.children).map((e=>e.getAttribute("value"))),n.setAttribute(Ie,JSON.stringify(a));const o=a.indexOf(r.value);if(o>=0){const e=OF(r.value,[i[o].trim()]);!e&&n.getAttribute("is-allow-only-correct")&&Array.from(n.querySelectorAll(`[value="${r.value}"]`)).find((e=>e!==r)).replaceWith(r),jF(e),_F()}},Qr=new WeakMap;async function Kr(e,r){let t=CF(),n=t[r.getAttribute("tab-index")];if(!Array.isArray(n)||!n.includes(e.value)){for(const r in t){const n=t[r].indexOf(e.value);-1!==n&&t[r].splice(n,1)}(null==r?void 0:r.id)&&e.setAttribute(Ve,r.id),await UF(e,r)}}const et=e=>new Promise((r=>setTimeout(r,e))),rt=e=>"arrangeLetters"===e.getAttribute("template-id"),tt=e=>"reorder"===e.getAttribute("template-id"),nt=(e,r)=>tt(e)?r.map((e=>e.id)):r.map((e=>e.value)),it=async()=>{const e=document.getElementById(Ze);if(!e)return;e.style.pointerEvents="none";const r=Array.from(e.querySelectorAll('[type="slide"]')),t=Er(e),n=r.length,i=n%2==0?n:n-1;for(let e=0;e<i;e+=2){const n=r[e],i=r[e+1],a=n.getBoundingClientRect(),o=i.getBoundingClientRect(),u=(o.left+o.width/2-(a.left+a.width/2))/t,s=(o.top+o.height/2-(a.top+a.height/2))/t;n.style.transition=i.style.transition="transform 0.5s ease",n.style.transform=`translate(${u}px, ${s}px)`,i.style.transform=`translate(${-u}px, ${-s}px)`}await et(800);for(let e=0;e<i;e++)r[e].style.transform="translate(0, 0)";await et(500);for(let e=0;e<i;e++)r[e].style.transition="";e.style.pointerEvents=""};const at=async e=>{var r;const t=document.getElementById(Ze),n=JSON.parse(null!==(r=t.getAttribute(Ie))&&void 0!==r?r:"[]"),i=Array.from(document.querySelectorAll("[type='slide']")),a=nt(t,i);a.forEach(((e,r)=>{n[r]=e})),t.setAttribute(Ie,JSON.stringify(n));const o=document.getElementById(Ze).objective.split(","),u=i.indexOf(e),s=u>=0&&u<o.length&&OF(a[u],[o[u].trim()]);(rt(t)||tt(t))&&((e,r,t)=>{Array.from(e.querySelectorAll('[type="slide"]')).forEach(((e,n)=>{n<t.length&&r[n]===t[n].trim()?uB(e,"#65BC46"):e.style.removeProperty("box-shadow")}))})(t,a,o),"true"===t.getAttribute("is-continue-on-correct")?jF(!0):jF(s),(rt(t)||tt(t))&&await ot(a)},ot=async e=>{const r=document.getElementById(Ze);if(!r||!rt(r)&&!tt(r)||"true"===r.getAttribute("game-completed"))return;const t=document.getElementById(Ze).objective,n=rt(r)?((e,r)=>{if(!r)return!1;const t=r.split(",").map((e=>e.trim()));return e.length===t.length&&e.every(((e,r)=>e===t[r]))})(e,t):((e,r)=>{if(!r)return!1;const t=r.split(",").map((e=>e.trim()));return e.length===t.length&&e.every(((e,r)=>e===t[r]))})(e,t);n&&await JF()},ut=(e,r)=>{const t=parseFloat(e);return Number.isFinite(t)?t:r};function st(e){return st="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},st(e)}var ct=/^\s+/,lt=/\s+$/;function ft(e,r){if(r=r||{},(e=e||"")instanceof ft)return e;if(!(this instanceof ft))return new ft(e,r);var t=function(e){var r={r:0,g:0,b:0},t=1,n=null,i=null,a=null,o=!1,u=!1;return"string"==typeof e&&(e=function(e){e=e.replace(ct,"").replace(lt,"").toLowerCase();var r,t=!1;if(St[e])e=St[e],t=!0;else if("transparent"==e)return{r:0,g:0,b:0,a:0,format:"name"};return(r=Rt.rgb.exec(e))?{r:r[1],g:r[2],b:r[3]}:(r=Rt.rgba.exec(e))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=Rt.hsl.exec(e))?{h:r[1],s:r[2],l:r[3]}:(r=Rt.hsla.exec(e))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=Rt.hsv.exec(e))?{h:r[1],s:r[2],v:r[3]}:(r=Rt.hsva.exec(e))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=Rt.hex8.exec(e))?{r:kt(r[1]),g:kt(r[2]),b:kt(r[3]),a:jt(r[4]),format:t?"name":"hex8"}:(r=Rt.hex6.exec(e))?{r:kt(r[1]),g:kt(r[2]),b:kt(r[3]),format:t?"name":"hex"}:(r=Rt.hex4.exec(e))?{r:kt(r[1]+""+r[1]),g:kt(r[2]+""+r[2]),b:kt(r[3]+""+r[3]),a:jt(r[4]+""+r[4]),format:t?"name":"hex8"}:!!(r=Rt.hex3.exec(e))&&{r:kt(r[1]+""+r[1]),g:kt(r[2]+""+r[2]),b:kt(r[3]+""+r[3]),format:t?"name":"hex"}}(e)),"object"==st(e)&&(Ut(e.r)&&Ut(e.g)&&Ut(e.b)?(r=function(e,r,t){return{r:255*qt(e,255),g:255*qt(r,255),b:255*qt(t,255)}}(e.r,e.g,e.b),o=!0,u="%"===(e.r+"").substr(-1)?"prgb":"rgb"):Ut(e.h)&&Ut(e.s)&&Ut(e.v)?(n=It(e.s),i=It(e.v),r=function(e,r,t){e=6*qt(e,360),r=qt(r,100),t=qt(t,100);var n=Math.floor(e),i=e-n,a=t*(1-r),o=t*(1-i*r),u=t*(1-(1-i)*r),s=n%6;return{r:255*[t,o,a,a,u,t][s],g:255*[u,t,t,o,a,a][s],b:255*[a,a,u,t,t,o][s]}}(e.h,n,i),o=!0,u="hsv"):Ut(e.h)&&Ut(e.s)&&Ut(e.l)&&(n=It(e.s),a=It(e.l),r=function(e,r,t){var n,i,a;function o(e,r,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?e+6*(r-e)*t:t<.5?r:t<2/3?e+(r-e)*(2/3-t)*6:e}if(e=qt(e,360),r=qt(r,100),t=qt(t,100),0===r)n=i=a=t;else{var u=t<.5?t*(1+r):t+r-t*r,s=2*t-u;n=o(s,u,e+1/3),i=o(s,u,e),a=o(s,u,e-1/3)}return{r:255*n,g:255*i,b:255*a}}(e.h,n,a),o=!0,u="hsl"),e.hasOwnProperty("a")&&(t=e.a)),t=Bt(t),{ok:o,format:e.format||u,r:Math.min(255,Math.max(r.r,0)),g:Math.min(255,Math.max(r.g,0)),b:Math.min(255,Math.max(r.b,0)),a:t}}(e);this._originalInput=e,this._r=t.r,this._g=t.g,this._b=t.b,this._a=t.a,this._roundA=Math.round(100*this._a)/100,this._format=r.format||t.format,this._gradientType=r.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=t.ok}function mt(e,r,t){e=qt(e,255),r=qt(r,255),t=qt(t,255);var n,i,a=Math.max(e,r,t),o=Math.min(e,r,t),u=(a+o)/2;if(a==o)n=i=0;else{var s=a-o;switch(i=u>.5?s/(2-a-o):s/(a+o),a){case e:n=(r-t)/s+(r<t?6:0);break;case r:n=(t-e)/s+2;break;case t:n=(e-r)/s+4}n/=6}return{h:n,s:i,l:u}}function dt(e,r,t){e=qt(e,255),r=qt(r,255),t=qt(t,255);var n,i,a=Math.max(e,r,t),o=Math.min(e,r,t),u=a,s=a-o;if(i=0===a?0:s/a,a==o)n=0;else{switch(a){case e:n=(r-t)/s+(r<t?6:0);break;case r:n=(t-e)/s+2;break;case t:n=(e-r)/s+4}n/=6}return{h:n,s:i,v:u}}function pt(e,r,t,n){var i=[Ot(Math.round(e).toString(16)),Ot(Math.round(r).toString(16)),Ot(Math.round(t).toString(16))];return n&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function ht(e,r,t,n){return""+Ot(zt(n))+Ot(Math.round(e).toString(16))+Ot(Math.round(r).toString(16))+Ot(Math.round(t).toString(16))}function vt(e,r){r=0===r?0:r||10;var t=ft(e).toHsl();return t.s-=r/100,t.s=Tt(t.s),ft(t)}function yt(e,r){r=0===r?0:r||10;var t=ft(e).toHsl();return t.s+=r/100,t.s=Tt(t.s),ft(t)}function bt(e){return ft(e).desaturate(100)}function gt(e,r){r=0===r?0:r||10;var t=ft(e).toHsl();return t.l+=r/100,t.l=Tt(t.l),ft(t)}function xt(e,r){r=0===r?0:r||10;var t=ft(e).toRgb();return t.r=Math.max(0,Math.min(255,t.r-Math.round(-r/100*255))),t.g=Math.max(0,Math.min(255,t.g-Math.round(-r/100*255))),t.b=Math.max(0,Math.min(255,t.b-Math.round(-r/100*255))),ft(t)}function wt(e,r){r=0===r?0:r||10;var t=ft(e).toHsl();return t.l-=r/100,t.l=Tt(t.l),ft(t)}function Dt(e,r){var t=ft(e).toHsl(),n=(t.h+r)%360;return t.h=n<0?360+n:n,ft(t)}function Nt(e){var r=ft(e).toHsl();return r.h=(r.h+180)%360,ft(r)}function At(e,r){if(isNaN(r)||r<=0)throw Error("Argument to polyad must be a positive number");for(var t=ft(e).toHsl(),n=[ft(e)],i=360/r,a=1;a<r;a++)n.push(ft({h:(t.h+a*i)%360,s:t.s,l:t.l}));return n}function Mt(e){var r=ft(e).toHsl(),t=r.h;return[ft(e),ft({h:(t+72)%360,s:r.s,l:r.l}),ft({h:(t+216)%360,s:r.s,l:r.l})]}function Ct(e,r,t){r=r||6,t=t||30;var n=ft(e).toHsl(),i=360/t,a=[ft(e)];for(n.h=(n.h-(i*r>>1)+720)%360;--r;)n.h=(n.h+i)%360,a.push(ft(n));return a}function Et(e,r){r=r||6;for(var t=ft(e).toHsv(),n=t.h,i=t.s,a=t.v,o=[],u=1/r;r--;)o.push(ft({h:n,s:i,v:a})),a=(a+u)%1;return o}ft.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(299*e.r+587*e.g+114*e.b)/1e3},getLuminance:function(){var e,r,t,n=this.toRgb();return r=n.g/255,t=n.b/255,.2126*((e=n.r/255)<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.0722*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))},setAlpha:function(e){return this._a=Bt(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=dt(this._r,this._g,this._b);return{h:360*e.h,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=dt(this._r,this._g,this._b),r=Math.round(360*e.h),t=Math.round(100*e.s),n=Math.round(100*e.v);return 1==this._a?"hsv("+r+", "+t+"%, "+n+"%)":"hsva("+r+", "+t+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var e=mt(this._r,this._g,this._b);return{h:360*e.h,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=mt(this._r,this._g,this._b),r=Math.round(360*e.h),t=Math.round(100*e.s),n=Math.round(100*e.l);return 1==this._a?"hsl("+r+", "+t+"%, "+n+"%)":"hsla("+r+", "+t+"%, "+n+"%, "+this._roundA+")"},toHex:function(e){return pt(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return function(e,r,t,n,i){var a=[Ot(Math.round(e).toString(16)),Ot(Math.round(r).toString(16)),Ot(Math.round(t).toString(16)),Ot(zt(n))];return i&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)&&a[3].charAt(0)==a[3].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0)+a[3].charAt(0):a.join("")}(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(100*qt(this._r,255))+"%",g:Math.round(100*qt(this._g,255))+"%",b:Math.round(100*qt(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*qt(this._r,255))+"%, "+Math.round(100*qt(this._g,255))+"%, "+Math.round(100*qt(this._b,255))+"%)":"rgba("+Math.round(100*qt(this._r,255))+"%, "+Math.round(100*qt(this._g,255))+"%, "+Math.round(100*qt(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(Ft[pt(this._r,this._g,this._b,!0)]||!1)},toFilter:function(e){var r="#"+ht(this._r,this._g,this._b,this._a),t=r,n=this._gradientType?"GradientType = 1, ":"";if(e){var i=ft(e);t="#"+ht(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+r+",endColorstr="+t+")"},toString:function(e){var r=!!e;e=e||this._format;var t=!1;return r||!(this._a<1&&this._a>=0)||"hex"!==e&&"hex6"!==e&&"hex3"!==e&&"hex4"!==e&&"hex8"!==e&&"name"!==e?("rgb"===e&&(t=this.toRgbString()),"prgb"===e&&(t=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(t=this.toHexString()),"hex3"===e&&(t=this.toHexString(!0)),"hex4"===e&&(t=this.toHex8String(!0)),"hex8"===e&&(t=this.toHex8String()),"name"===e&&(t=this.toName()),"hsl"===e&&(t=this.toHslString()),"hsv"===e&&(t=this.toHsvString()),t||this.toHexString()):"name"===e&&0===this._a?this.toName():this.toRgbString()},clone:function(){return ft(""+this)},_applyModification:function(e,r){var t=e.apply(null,[this].concat([].slice.call(r)));return this._r=t._r,this._g=t._g,this._b=t._b,this.setAlpha(t._a),this},lighten:function(){return this._applyModification(gt,arguments)},brighten:function(){return this._applyModification(xt,arguments)},darken:function(){return this._applyModification(wt,arguments)},desaturate:function(){return this._applyModification(vt,arguments)},saturate:function(){return this._applyModification(yt,arguments)},greyscale:function(){return this._applyModification(bt,arguments)},spin:function(){return this._applyModification(Dt,arguments)},_applyCombination:function(e,r){return e.apply(null,[this].concat([].slice.call(r)))},analogous:function(){return this._applyCombination(Ct,arguments)},complement:function(){return this._applyCombination(Nt,arguments)},monochromatic:function(){return this._applyCombination(Et,arguments)},splitcomplement:function(){return this._applyCombination(Mt,arguments)},triad:function(){return this._applyCombination(At,[3])},tetrad:function(){return this._applyCombination(At,[4])}},ft.fromRatio=function(e,r){if("object"==st(e)){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]="a"===n?e[n]:It(e[n]));e=t}return ft(e,r)},ft.equals=function(e,r){return!(!e||!r)&&ft(e).toRgbString()==ft(r).toRgbString()},ft.random=function(){return ft.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},ft.mix=function(e,r,t){t=0===t?0:t||50;var n=ft(e).toRgb(),i=ft(r).toRgb(),a=t/100;return ft({r:(i.r-n.r)*a+n.r,g:(i.g-n.g)*a+n.g,b:(i.b-n.b)*a+n.b,a:(i.a-n.a)*a+n.a})},ft.readability=function(e,r){var t=ft(e),n=ft(r);return(Math.max(t.getLuminance(),n.getLuminance())+.05)/(Math.min(t.getLuminance(),n.getLuminance())+.05)},ft.isReadable=function(e,r,t){var n,i,a=ft.readability(e,r);switch(i=!1,n=function(e){var r,t;return"AA"!==(r=((e=e||{level:"AA",size:"small"}).level||"AA").toUpperCase())&&"AAA"!==r&&(r="AA"),"small"!==(t=(e.size||"small").toLowerCase())&&"large"!==t&&(t="small"),{level:r,size:t}}(t),n.level+n.size){case"AAsmall":case"AAAlarge":i=a>=4.5;break;case"AAlarge":i=a>=3;break;case"AAAsmall":i=a>=7}return i},ft.mostReadable=function(e,r,t){var n,i,a,o,u=null,s=0;i=(t=t||{}).includeFallbackColors,a=t.level,o=t.size;for(var c=0;c<r.length;c++)(n=ft.readability(e,r[c]))>s&&(s=n,u=ft(r[c]));return ft.isReadable(e,u,{level:a,size:o})||!i?u:(t.includeFallbackColors=!1,ft.mostReadable(e,["#fff","#000"],t))};var St=ft.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},Ft=ft.hexNames=function(e){var r={};for(var t in e)e.hasOwnProperty(t)&&(r[e[t]]=t);return r}(St);function Bt(e){return(isNaN(e=parseFloat(e))||e<0||e>1)&&(e=1),e}function qt(e,r){(function(e){return"string"==typeof e&&-1!=e.indexOf(".")&&1===parseFloat(e)})(e)&&(e="100%");var t=function(e){return"string"==typeof e&&-1!=e.indexOf("%")}(e);return e=Math.min(r,Math.max(0,parseFloat(e))),t&&(e=parseInt(e*r,10)/100),Math.abs(e-r)<1e-6?1:e%r/parseFloat(r)}function Tt(e){return Math.min(1,Math.max(0,e))}function kt(e){return parseInt(e,16)}function Ot(e){return 1==e.length?"0"+e:""+e}function It(e){return e<=1&&(e=100*e+"%"),e}function zt(e){return Math.round(255*parseFloat(e)).toString(16)}function jt(e){return kt(e)/255}var Rt=function(){var e="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",r="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?",t="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?";return{CSS_UNIT:RegExp(e),rgb:RegExp("rgb"+r),rgba:RegExp("rgba"+t),hsl:RegExp("hsl"+r),hsla:RegExp("hsla"+t),hsv:RegExp("hsv"+r),hsva:RegExp("hsva"+t),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function Ut(e){return!!Rt.CSS_UNIT.exec(e)}const $t=e=>{var r;const t=.08*(Number.isFinite(e.offsetHeight)?e.offsetHeight:0),n=(null===(r=e.style)||void 0===r?void 0:r.backgroundColor)||"#FFB742";e.style.setProperty("--btn-bg-color",n),e.style.setProperty("--btn-shadow-px",`0px ${t}px 0px`),e.style.setProperty("--btn-active",t+"px"),e.style.setProperty("--btn-shadow-color",""+ft(n).darken(17)),e.classList.add("click-element")};function Pt(){return Pt=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},Pt.apply(null,arguments)}var Lt={relTol:1e-12,absTol:1e-15,matrix:"Matrix",number:"number",numberFallback:"number",precision:64,predictable:!1,randomSeed:null};function _t(e,r){if(Jt(e,r))return e[r];if("function"==typeof e[r]&&Vt(e,r))throw Error('Cannot access method "'+r+'" as a property');throw Error('No access to property "'+r+'"')}function Wt(e,r,t){if(Jt(e,r))return e[r]=t,t;throw Error('No access to property "'+r+'"')}function Jt(e,r){return!(!function(e){return"object"==typeof e&&e&&e.constructor===Object}(e)&&!Array.isArray(e)||!Hn(Ht,r)&&(r in Object.prototype||r in Function.prototype))}function Vt(e,r){return!(null==e||"function"!=typeof e[r]||Hn(e,r)&&Object.getPrototypeOf&&r in Object.getPrototypeOf(e)||!Hn(Zt,r)&&(r in Object.prototype||r in Function.prototype))}var Ht={length:!0,name:!0},Zt={toString:!0,valueOf:!0,toLocaleString:!0};class Gt{constructor(e){this.wrappedObject=e,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).filter((e=>this.has(e))).values()}get(e){return _t(this.wrappedObject,e)}set(e,r){return Wt(this.wrappedObject,e,r),this}has(e){return Jt(this.wrappedObject,e)&&e in this.wrappedObject}entries(){return Yt(this.keys(),(e=>[e,this.get(e)]))}forEach(e){for(var r of this.keys())e(this.get(r),r,this)}delete(e){Jt(this.wrappedObject,e)&&delete this.wrappedObject[e]}clear(){for(var e of this.keys())this.delete(e)}get size(){return Object.keys(this.wrappedObject).length}}class Xt{constructor(e,r,t){this.a=e,this.b=r,this.bKeys=t,this[Symbol.iterator]=this.entries}get(e){return this.bKeys.has(e)?this.b.get(e):this.a.get(e)}set(e,r){return this.bKeys.has(e)?this.b.set(e,r):this.a.set(e,r),this}has(e){return this.b.has(e)||this.a.has(e)}keys(){return new Set([...this.a.keys(),...this.b.keys()])[Symbol.iterator]()}entries(){return Yt(this.keys(),(e=>[e,this.get(e)]))}forEach(e){for(var r of this.keys())e(this.get(r),r,this)}delete(e){return this.bKeys.has(e)?this.b.delete(e):this.a.delete(e)}clear(){this.a.clear(),this.b.clear()}get size(){return[...this.keys()].length}}function Yt(e,r){return{next:()=>{var t=e.next();return t.done?t:{value:r(t.value),done:!1}}}}function Qt(){return new Map}function Kt(e){if(!e)return Qt();if(Dn(e))return e;if(wn(e))return new Gt(e);throw Error("createMap can create maps from objects or Maps")}function en(e){return"number"==typeof e}function rn(e){return!(!e||"object"!=typeof e||"function"!=typeof e.constructor)&&(!0===e.isBigNumber&&"object"==typeof e.constructor.prototype&&!0===e.constructor.prototype.isBigNumber||"function"==typeof e.constructor.isDecimal&&!0===e.constructor.isDecimal(e))}function tn(e){return"bigint"==typeof e}function nn(e){return e&&"object"==typeof e&&!0===Object.getPrototypeOf(e).isComplex||!1}function an(e){return e&&"object"==typeof e&&!0===Object.getPrototypeOf(e).isFraction||!1}function on(e){return e&&!0===e.constructor.prototype.isUnit||!1}function un(e){return"string"==typeof e}var sn=Array.isArray;function cn(e){return e&&!0===e.constructor.prototype.isMatrix||!1}function ln(e){return Array.isArray(e)||cn(e)}function fn(e){return e&&e.isDenseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function mn(e){return e&&e.isSparseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function dn(e){return e&&!0===e.constructor.prototype.isRange||!1}function pn(e){return e&&!0===e.constructor.prototype.isIndex||!1}function hn(e){return"boolean"==typeof e}function vn(e){return e&&!0===e.constructor.prototype.isResultSet||!1}function yn(e){return e&&!0===e.constructor.prototype.isHelp||!1}function bn(e){return"function"==typeof e}function gn(e){return e instanceof Date}function xn(e){return e instanceof RegExp}function wn(e){return!(!e||"object"!=typeof e||e.constructor!==Object||nn(e)||an(e))}function Dn(e){return!!e&&(e instanceof Map||e instanceof Gt||"function"==typeof e.set&&"function"==typeof e.get&&"function"==typeof e.keys&&"function"==typeof e.has)}function Nn(e){return null===e}function An(e){return void 0===e}function Mn(e){return e&&!0===e.isAccessorNode&&!0===e.constructor.prototype.isNode||!1}function Cn(e){return e&&!0===e.isArrayNode&&!0===e.constructor.prototype.isNode||!1}function En(e){return e&&!0===e.isAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function Sn(e){return e&&!0===e.isBlockNode&&!0===e.constructor.prototype.isNode||!1}function Fn(e){return e&&!0===e.isConditionalNode&&!0===e.constructor.prototype.isNode||!1}function Bn(e){return e&&!0===e.isConstantNode&&!0===e.constructor.prototype.isNode||!1}function qn(e){return Bn(e)||jn(e)&&1===e.args.length&&Bn(e.args[0])&&"-+~".includes(e.op)}function Tn(e){return e&&!0===e.isFunctionAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function kn(e){return e&&!0===e.isFunctionNode&&!0===e.constructor.prototype.isNode||!1}function On(e){return e&&!0===e.isIndexNode&&!0===e.constructor.prototype.isNode||!1}function In(e){return e&&!0===e.isNode&&!0===e.constructor.prototype.isNode||!1}function zn(e){return e&&!0===e.isObjectNode&&!0===e.constructor.prototype.isNode||!1}function jn(e){return e&&!0===e.isOperatorNode&&!0===e.constructor.prototype.isNode||!1}function Rn(e){return e&&!0===e.isParenthesisNode&&!0===e.constructor.prototype.isNode||!1}function Un(e){return e&&!0===e.isRangeNode&&!0===e.constructor.prototype.isNode||!1}function $n(e){return e&&!0===e.isRelationalNode&&!0===e.constructor.prototype.isNode||!1}function Pn(e){return e&&!0===e.isSymbolNode&&!0===e.constructor.prototype.isNode||!1}function Ln(e){return e&&!0===e.constructor.prototype.isChain||!1}function _n(e){var r=typeof e;return"object"===r?null===e?"null":rn(e)?"BigNumber":e.constructor&&e.constructor.name?e.constructor.name:"Object":r}function Wn(e){var r=typeof e;if("number"===r||"bigint"===r||"string"===r||"boolean"===r||null==e)return e;if("function"==typeof e.clone)return e.clone();if(Array.isArray(e))return e.map((function(e){return Wn(e)}));if(e instanceof Date)return new Date(e.valueOf());if(rn(e))return e;if(wn(e))return function(e,r){var t={};for(var n in e)Hn(e,n)&&(t[n]=r(e[n]));return t}(e,Wn);if("function"===r)return e;throw new TypeError("Cannot clone: unknown type of value (value: ".concat(e,")"))}function Jn(e,r){for(var t in r)Hn(r,t)&&(e[t]=r[t]);return e}function Vn(e,r){var t,n,i;if(Array.isArray(e)){if(!Array.isArray(r))return!1;if(e.length!==r.length)return!1;for(n=0,i=e.length;n<i;n++)if(!Vn(e[n],r[n]))return!1;return!0}if("function"==typeof e)return e===r;if(e instanceof Object){if(Array.isArray(r)||!(r instanceof Object))return!1;for(t in e)if(!(t in r)||!Vn(e[t],r[t]))return!1;for(t in r)if(!(t in e))return!1;return!0}return e===r}function Hn(e,r){return e&&Object.hasOwnProperty.call(e,r)}var Zn=function(e){if(e)throw Error("The global config is readonly. \nPlease create a mathjs instance if you want to change the default configuration. \nExample:\n\n import { create, all } from 'mathjs';\n const mathjs = create(all);\n mathjs.config({ number: 'BigNumber' });\n");return Object.freeze(Lt)};Pt(Zn,Lt,{MATRIX_OPTIONS:["Matrix","Array"],NUMBER_OPTIONS:["number","BigNumber","bigint","Fraction"]});var Gn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Xn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Yn(e){if(e.__esModule)return e;var r=e.default;if("function"==typeof r){var t=function e(){return this instanceof e?Reflect.construct(r,arguments,this.constructor):r.apply(this,arguments)};t.prototype=r.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(e).forEach((function(r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})})),t}var Qn,Kn={exports:{}},ei=(Qn||(Qn=1,Kn.exports=function(){function e(){return!0}function r(){return!1}function t(){}const n="Argument is not a typed-function.";var i=function i(){function a(e){return"object"==typeof e&&null!==e&&e.constructor===Object}const o=[{name:"number",test:function(e){return"number"==typeof e}},{name:"string",test:function(e){return"string"==typeof e}},{name:"boolean",test:function(e){return"boolean"==typeof e}},{name:"Function",test:function(e){return"function"==typeof e}},{name:"Array",test:Array.isArray},{name:"Date",test:function(e){return e instanceof Date}},{name:"RegExp",test:function(e){return e instanceof RegExp}},{name:"Object",test:a},{name:"null",test:function(e){return null===e}},{name:"undefined",test:function(e){return void 0===e}}],u={name:"any",test:e,isAny:!0};let s,c,l=0,f={createCount:0};function m(e){const r=s.get(e);if(r)return r;let t='Unknown type "'+e+'"';const n=e.toLowerCase();let i;for(i of c)if(i.toLowerCase()===n){t+='. Did you mean "'+i+'" ?';break}throw new TypeError(t)}function d(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"any";const t=r?m(r).index:c.length,n=[];for(let r=0;r<e.length;++r){if(!e[r]||"string"!=typeof e[r].name||"function"!=typeof e[r].test)throw new TypeError("Object with properties {name: string, test: function} expected");const i=e[r].name;if(s.has(i))throw new TypeError('Duplicate type name "'+i+'"');n.push(i),s.set(i,{name:i,test:e[r].test,isAny:e[r].isAny,index:t+r,conversionsTo:[]})}const i=c.slice(t);c=c.slice(0,t).concat(n).concat(i);for(let e=t+n.length;e<c.length;++e)s.get(c[e]).index=e}function p(){s=new Map,c=[],l=0,d([u],!1)}function h(e){const r=c.filter((r=>{const t=s.get(r);return!t.isAny&&t.test(e)}));return r.length?r:["any"]}function v(e){return e&&"function"==typeof e&&"_typedFunctionData"in e}function y(e,r,t){if(!v(e))throw new TypeError(n);const i=t&&t.exact,a=D(Array.isArray(r)?r.join(","):r),o=b(a);if(!i||o in e.signatures){const r=e._typedFunctionData.signatureMap.get(o);if(r)return r}const u=a.length;let s,c;if(i){let r;for(r in s=[],e.signatures)s.push(e._typedFunctionData.signatureMap.get(r))}else s=e._typedFunctionData.signatures;for(let e=0;e<u;++e){const r=a[e],t=[];let n;for(n of s){const i=C(n.params,e);if(i&&(!r.restParam||i.restParam)){if(!i.hasAny){const e=w(i);if(r.types.some((r=>!e.has(r.name))))continue}t.push(n)}}if(s=t,0===s.length)break}for(c of s)if(c.params.length<=u)return c;throw new TypeError("Signature not found (signature: "+(e.name||"unnamed")+"("+b(a,", ")+"))")}function b(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:",";return e.map((e=>e.name)).join(r)}function g(e){const r=0===e.indexOf("..."),t=(r?e.length>3?e.slice(3):"any":e).split("|").map((e=>m(e.trim())));let n=!1,i=r?"...":"";return{types:t.map((function(e){return n=e.isAny||n,i+=e.name+"|",{name:e.name,typeIndex:e.index,test:e.test,isAny:e.isAny,conversion:null,conversionIndex:-1}})),name:i.slice(0,-1),hasAny:n,hasConversion:!1,restParam:r}}function x(e){const r=function(e){if(0===e.length)return[];const r=e.map(m);if(1===e.length)return r[0].conversionsTo;const t=new Set(e),n=new Set;for(let e=0;e<r.length;++e)for(const i of r[e].conversionsTo)t.has(i.from)||n.add(i.from);const i=[];for(const e of n){let t=l+1,n=null;for(let i=0;i<r.length;++i)for(const a of r[i].conversionsTo)a.from===e&&a.index<t&&(t=a.index,n=a);i.push(n)}return i}(e.types.map((e=>e.name)));let t=e.hasAny,n=e.name;const i=r.map((function(e){const r=m(e.from);return t=r.isAny||t,n+="|"+e.from,{name:e.from,typeIndex:r.index,test:r.test,isAny:r.isAny,conversion:e,conversionIndex:e.index}}));return{types:e.types.concat(i),name:n,hasAny:t,hasConversion:i.length>0,restParam:e.restParam}}function w(e){return e.typeSet||(e.typeSet=new Set,e.types.forEach((r=>e.typeSet.add(r.name)))),e.typeSet}function D(e){const r=[];if("string"!=typeof e)throw new TypeError("Signatures must be strings");const t=e.trim();if(""===t)return r;const n=t.split(",");for(let e=0;e<n.length;++e){const t=g(n[e].trim());if(t.restParam&&e!==n.length-1)throw new SyntaxError('Unexpected rest parameter "'+n[e]+'": only allowed for the last parameter');if(0===t.types.length)return null;r.push(t)}return r}function N(e){const r=W(e);return!!r&&r.restParam}function A(r){if(r&&0!==r.types.length){if(1===r.types.length)return m(r.types[0].name).test;if(2===r.types.length){const e=m(r.types[0].name).test,t=m(r.types[1].name).test;return function(r){return e(r)||t(r)}}{const e=r.types.map((function(e){return m(e.name).test}));return function(r){for(let t=0;t<e.length;t++)if(e[t](r))return!0;return!1}}}return e}function M(e){let r,t,n;if(N(e)){r=_(e).map(A);const t=r.length,n=A(W(e)),i=function(e){for(let r=t;r<e.length;r++)if(!n(e[r]))return!1;return!0};return function(e){for(let t=0;t<r.length;t++)if(!r[t](e[t]))return!1;return i(e)&&e.length>=t+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(t=A(e[0]),function(e){return t(e[0])&&1===e.length}):2===e.length?(t=A(e[0]),n=A(e[1]),function(e){return t(e[0])&&n(e[1])&&2===e.length}):(r=e.map(A),function(e){for(let t=0;t<r.length;t++)if(!r[t](e[t]))return!1;return e.length===r.length})}function C(e,r){return r<e.length?e[r]:N(e)?W(e):null}function E(e,r){const t=C(e,r);return t?w(t):new Set}function S(e){return null==e.conversion}function F(e,r){const t=new Set;return e.forEach((e=>{const n=E(e.params,r);let i;for(i of n)t.add(i)})),t.has("any")?["any"]:Array.from(t)}function B(e,r,t){let n,i;const a=e||"unnamed";let o,u=t;for(o=0;o<r.length;o++){const e=[];if(u.forEach((t=>{const n=A(C(t.params,o));(o<t.params.length||N(t.params))&&n(r[o])&&e.push(t)})),0===e.length){if(i=F(u,o),i.length>0){const e=h(r[o]);return n=new TypeError("Unexpected type of argument in function "+a+" (expected: "+i.join(" or ")+", actual: "+e.join(" | ")+", index: "+o+")"),n.data={category:"wrongType",fn:a,index:o,actual:e,expected:i},n}}else u=e}const s=u.map((function(e){return N(e.params)?1/0:e.params.length}));if(r.length<Math.min.apply(null,s))return i=F(u,o),n=new TypeError("Too few arguments in function "+a+" (expected: "+i.join(" or ")+", index: "+r.length+")"),n.data={category:"tooFewArgs",fn:a,index:r.length,expected:i},n;const c=Math.max.apply(null,s);if(r.length>c)return n=new TypeError("Too many arguments in function "+a+" (expected: "+c+", actual: "+r.length+")"),n.data={category:"tooManyArgs",fn:a,index:r.length,expectedLength:c},n;const l=[];for(let e=0;e<r.length;++e)l.push(h(r[e]).join("|"));return n=new TypeError('Arguments of type "'+l.join(", ")+'" do not match any of the defined signatures of function '+a+"."),n.data={category:"mismatch",actual:l},n}function q(e){let r=c.length+1;for(let t=0;t<e.types.length;t++)r=Math.min(r,e.types[t].typeIndex);return r}function T(e){let r=l+1;for(let t=0;t<e.types.length;t++)S(e.types[t])||(r=Math.min(r,e.types[t].conversionIndex));return r}function k(e,r){if(e.hasAny){if(!r.hasAny)return.1}else if(r.hasAny)return-.1;if(e.restParam){if(!r.restParam)return.01}else if(r.restParam)return-.01;const t=q(e)-q(r);if(t<0)return-.001;if(t>0)return.001;const n=T(e),i=T(r);if(e.hasConversion){if(!r.hasConversion)return 1e-6*(1+n)}else if(r.hasConversion)return 1e-6*-(1+i);const a=n-i;return a<0?-1e-7:a>0?1e-7:0}function O(e,r){const t=e.params,n=r.params,i=W(t),a=W(n),o=N(t),u=N(n);if(o&&i.hasAny){if(!u||!a.hasAny)return 1e7}else if(u&&a.hasAny)return-1e7;let s,c=0,l=0;for(s of t)s.hasAny&&++c,s.hasConversion&&++l;let f=0,m=0;for(s of n)s.hasAny&&++f,s.hasConversion&&++m;if(c!==f)return 1e6*(c-f);if(o&&i.hasConversion){if(!u||!a.hasConversion)return 1e5}else if(u&&a.hasConversion)return-1e5;if(l!==m)return 1e4*(l-m);if(o){if(!u)return 1e3}else if(u)return-1e3;const d=(t.length-n.length)*(o?-100:100);if(0!==d)return d;const p=[];let h,v=0;for(let e=0;e<t.length;++e){const r=k(t[e],n[e]);p.push(r),v+=r}if(0!==v)return(v<0?-10:10)+v;let y=9;const b=y/(p.length+1);for(h of p){if(0!==h)return(h<0?-y:y)+h;y-=b}return 0}function I(e,r){let t=r,n="";if(e.some((e=>e.hasConversion))){const i=N(e),a=e.map(z);n=a.map((e=>e.name)).join(";"),t=function(){const e=[],t=i?arguments.length-1:arguments.length;for(let r=0;r<t;r++)e[r]=a[r](arguments[r]);return i&&(e[t]=arguments[t].map(a[t])),r.apply(this,e)}}let i=t;if(N(e)){const r=e.length-1;i=function(){return t.apply(this,J(arguments,0,r).concat([J(arguments,r)]))}}return n&&Object.defineProperty(i,"name",{value:n}),i}function z(e){let r,t,n,i;const a=[],o=[];let u="";e.types.forEach((function(e){e.conversion&&(u+=e.conversion.from+"~>"+e.conversion.to+",",a.push(m(e.conversion.from).test),o.push(e.conversion.convert))})),u=u?u.slice(0,-1):"pass";let s=e=>e;switch(o.length){case 0:break;case 1:r=a[0],n=o[0],s=function(e){return r(e)?n(e):e};break;case 2:r=a[0],t=a[1],n=o[0],i=o[1],s=function(e){return r(e)?n(e):t(e)?i(e):e};break;default:s=function(e){for(let r=0;r<o.length;r++)if(a[r](e))return o[r](e);return e}}return Object.defineProperty(s,"name",{value:u}),s}function j(e){return function e(r,t,n){if(t<r.length){const i=r[t];let a=[];if(i.restParam){const e=i.types.filter(S);e.length<i.types.length&&a.push({types:e,name:"..."+e.map((e=>e.name)).join("|"),hasAny:e.some((e=>e.isAny)),hasConversion:!1,restParam:!0}),a.push(i)}else a=i.types.map((function(e){return{types:[e],name:e.name,hasAny:e.isAny,hasConversion:e.conversion,restParam:!1}}));return function(e,r){return Array.prototype.concat.apply([],e.map(r))}(a,(function(i){return e(r,t+1,n.concat([i]))}))}return[n]}(e,0,[])}function R(e,r){const t=Math.max(e.length,r.length);for(let n=0;n<t;n++){const t=E(e,n),i=E(r,n);let a,o=!1;for(a of i)if(t.has(a)){o=!0;break}if(!o)return!1}const n=e.length,i=r.length,a=N(e),o=N(r);return a?o?n===i:i>=n:o?n>=i:n===i}function U(e,r,t){const n=[];let i;for(i of e){let e=t[i];if("number"!=typeof e)throw new TypeError('No definition for referenced signature "'+i+'"');if(e=r[e],"function"!=typeof e)return!1;n.push(e)}return n}function $(e,r,t){const n=function(e){return e.map((e=>G(e)?H(e.referToSelf.callback):Z(e)?V(e.referTo.references,e.referTo.callback):e))}(e),i=Array(n.length).fill(!1);let a=!0;for(;a;){a=!1;let e=!0;for(let o=0;o<n.length;++o){if(i[o])continue;const u=n[o];if(G(u))n[o]=u.referToSelf.callback(t),n[o].referToSelf=u.referToSelf,i[o]=!0,e=!1;else if(Z(u)){const t=U(u.referTo.references,n,r);t?(n[o]=u.referTo.callback.apply(this,t),n[o].referTo=u.referTo,i[o]=!0,e=!1):a=!0}}if(e&&a)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return n}function P(e,n){if(f.createCount++,0===Object.keys(n).length)throw new SyntaxError("No signatures provided");f.warnAgainstDeprecatedThis&&function(e){const r=/\bthis(\(|\.signatures\b)/;Object.keys(e).forEach((t=>{if(r.test(""+e[t]))throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")}))}(n);const i=[],a=[],o={},u=[];let s;for(s in n){if(!Object.prototype.hasOwnProperty.call(n,s))continue;const e=D(s);if(!e)continue;i.forEach((function(r){if(R(r,e))throw new TypeError('Conflicting signatures "'+b(r)+'" and "'+b(e)+'".')})),i.push(e);const r=a.length;a.push(n[s]);const t=e.map(x);let c;for(c of j(t)){const e=b(c);u.push({params:c,name:e,fn:r}),c.every((e=>!e.hasConversion))&&(o[e]=r)}}u.sort(O);const c=$(a,o,ue);let l;for(l in o)Object.prototype.hasOwnProperty.call(o,l)&&(o[l]=c[o[l]]);const m=[],d=new Map;for(l of u)d.has(l.name)||(l.fn=c[l.fn],m.push(l),d.set(l.name,l));const p=m[0]&&m[0].params.length<=2&&!N(m[0].params),h=m[1]&&m[1].params.length<=2&&!N(m[1].params),v=m[2]&&m[2].params.length<=2&&!N(m[2].params),y=m[3]&&m[3].params.length<=2&&!N(m[3].params),g=m[4]&&m[4].params.length<=2&&!N(m[4].params),w=m[5]&&m[5].params.length<=2&&!N(m[5].params),C=p&&h&&v&&y&&g&&w;for(let e=0;e<m.length;++e)m[e].test=M(m[e].params);const E=p?A(m[0].params[0]):r,S=h?A(m[1].params[0]):r,F=v?A(m[2].params[0]):r,B=y?A(m[3].params[0]):r,q=g?A(m[4].params[0]):r,T=w?A(m[5].params[0]):r,k=p?A(m[0].params[1]):r,z=h?A(m[1].params[1]):r,U=v?A(m[2].params[1]):r,P=y?A(m[3].params[1]):r,L=g?A(m[4].params[1]):r,_=w?A(m[5].params[1]):r;for(let e=0;e<m.length;++e)m[e].implementation=I(m[e].params,m[e].fn);const W=p?m[0].implementation:t,J=h?m[1].implementation:t,V=v?m[2].implementation:t,H=y?m[3].implementation:t,Z=g?m[4].implementation:t,G=w?m[5].implementation:t,X=p?m[0].params.length:-1,Y=h?m[1].params.length:-1,Q=v?m[2].params.length:-1,K=y?m[3].params.length:-1,ee=g?m[4].params.length:-1,re=w?m[5].params.length:-1,te=C?6:0,ne=m.length,ie=m.map((e=>e.test)),ae=m.map((e=>e.implementation)),oe=function(){for(let e=te;e<ne;e++)if(ie[e](arguments))return ae[e].apply(this,arguments);return f.onMismatch(e,arguments,m)};function ue(e,r){return arguments.length===X&&E(e)&&k(r)?W.apply(this,arguments):arguments.length===Y&&S(e)&&z(r)?J.apply(this,arguments):arguments.length===Q&&F(e)&&U(r)?V.apply(this,arguments):arguments.length===K&&B(e)&&P(r)?H.apply(this,arguments):arguments.length===ee&&q(e)&&L(r)?Z.apply(this,arguments):arguments.length===re&&T(e)&&_(r)?G.apply(this,arguments):oe.apply(this,arguments)}try{Object.defineProperty(ue,"name",{value:e})}catch(e){}return ue.signatures=o,ue._typedFunctionData={signatures:m,signatureMap:d},ue}function L(e,r,t){throw B(e,r,t)}function _(e){return J(e,0,e.length-1)}function W(e){return e[e.length-1]}function J(e,r,t){return Array.prototype.slice.call(e,r,t)}function V(e,r){return{referTo:{references:e,callback:r}}}function H(e){if("function"!=typeof e)throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:e}}}function Z(e){return e&&"object"==typeof e.referTo&&Array.isArray(e.referTo.references)&&"function"==typeof e.referTo.callback}function G(e){return e&&"object"==typeof e.referToSelf&&"function"==typeof e.referToSelf.callback}function X(e,r){if(!e)return r;if(r&&r!==e){const t=Error("Function names do not match (expected: "+e+", actual: "+r+")");throw t.data={actual:r,expected:e},t}return e}function Y(e){let r;for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(v(e[t])||"string"==typeof e[t].signature)&&(r=X(r,e[t].name));return r}function Q(e,r){let t;for(t in r)if(Object.prototype.hasOwnProperty.call(r,t)){if(t in e&&r[t]!==e[t]){const n=Error('Signature "'+t+'" is defined twice');throw n.data={signature:t,sourceFunction:r[t],destFunction:e[t]},n}e[t]=r[t]}}p(),d(o);const K=f;function ee(e){if(!e||"string"!=typeof e.from||"string"!=typeof e.to||"function"!=typeof e.convert)throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(e.to===e.from)throw new SyntaxError('Illegal to define conversion from "'+e.from+'" to itself.')}return f=function(e){const r="string"==typeof e;let t=r?e:"";const n={};for(let e=r?1:0;e<arguments.length;++e){const i=arguments[e];let o,u={};if("function"==typeof i?(o=i.name,"string"==typeof i.signature?u[i.signature]=i:v(i)&&(u=i.signatures)):a(i)&&(u=i,r||(o=Y(i))),0===Object.keys(u).length){const r=new TypeError("Argument to 'typed' at index "+e+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw r.data={index:e,argument:i},r}r||(t=X(t,o)),Q(n,u)}return P(t||"",n)},f.create=i,f.createCount=K.createCount,f.onMismatch=L,f.throwMismatchError=L,f.createError=B,f.clear=p,f.clearConversions=function(){let e;for(e of c)s.get(e).conversionsTo=[];l=0},f.addTypes=d,f._findType=m,f.referTo=function(){const e=_(arguments).map((e=>b(D(e)))),r=W(arguments);if("function"!=typeof r)throw new TypeError("Callback function expected as last argument");return V(e,r)},f.referToSelf=H,f.convert=function(e,r){const t=m(r);if(t.test(e))return e;const n=t.conversionsTo;if(0===n.length)throw Error("There are no conversions to "+r+" defined.");for(let r=0;r<n.length;r++)if(m(n[r].from).test(e))return n[r].convert(e);throw Error("Cannot convert "+e+" to "+r)},f.findSignature=y,f.find=function(e,r,t){return y(e,r,t).implementation},f.isTypedFunction=v,f.warnAgainstDeprecatedThis=!0,f.addType=function(e,r){let t="any";!1!==r&&s.has("Object")&&(t="Object"),f.addTypes([e],t)},f.addConversion=function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{override:!1};ee(e);const t=m(e.to),n=t.conversionsTo.find((r=>r.from===e.from));if(n){if(!r||!r.override)throw Error('There is already a conversion from "'+e.from+'" to "'+t.name+'"');f.removeConversion({from:n.from,to:e.to,convert:n.convert})}t.conversionsTo.push({from:e.from,to:t.name,convert:e.convert,index:l++})},f.addConversions=function(e,r){e.forEach((e=>f.addConversion(e,r)))},f.removeConversion=function(e){ee(e);const r=m(e.to),t=function(e,r){for(let t=0;t<e.length;t++)if(r(e[t]))return e[t]}(r.conversionsTo,(r=>r.from===e.from));if(!t)throw Error("Attempt to remove nonexistent conversion from "+e.from+" to "+e.to);if(t.convert!==e.convert)throw Error("Conversion to remove does not match existing conversion");const n=r.conversionsTo.indexOf(t);r.conversionsTo.splice(n,1)},f.resolve=function(e,r){if(!v(e))throw new TypeError(n);const t=e._typedFunctionData.signatures;for(let e=0;e<t.length;++e)if(t[e].test(r))return t[e];return null},f}();return i}()),Kn.exports),ri=Xn(ei);function ti(e,r,t,n){function i(n){var i=function(e,r){for(var t={},n=0;n<r.length;n++){var i=r[n],a=e[i];void 0!==a&&(t[i]=a)}return t}(n,r.map(ni));return function(e,r,t){if(!r.filter((e=>!function(e){return e&&"?"===e[0]}(e))).every((e=>void 0!==t[e]))){var n=r.filter((e=>void 0===t[e]));throw Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(n.map((e=>'"'.concat(e,'"'))).join(", "),"."))}}(e,r,n),t(i)}return i.isFactory=!0,i.fn=e,i.dependencies=r.slice().sort(),n&&(i.meta=n),i}function ni(e){return e&&"?"===e[0]?e.slice(1):e}function ii(e){return"boolean"==typeof e||!!isFinite(e)&&e===Math.round(e)}function ai(e,r){if("bigint"===r.number)try{BigInt(e)}catch(e){return r.numberFallback}return r.number}var oi=Math.sign||function(e){return e>0?1:e<0?-1:0},ui=Math.log2||function(e){return Math.log(e)/Math.LN2},si=Math.log10||function(e){return Math.log(e)/Math.LN10},ci=Math.log1p||function(e){return Math.log(e+1)},li=Math.cbrt||function(e){if(0===e)return e;var r,t=e<0;return t&&(e=-e),r=isFinite(e)?(e/((r=Math.exp(Math.log(e)/3))*r)+2*r)/3:e,t?-r:r},fi=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function mi(e,r,t){var n={2:"0b",8:"0o",16:"0x"}[r],i="";if(t){if(t<1)throw Error("size must be in greater than 0");if(!ii(t))throw Error("size must be an integer");if(e>2**(t-1)-1||e<-(2**(t-1)))throw Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!ii(e))throw Error("Value must be an integer");e<0&&(e+=2**t),i="i".concat(t)}var a="";return e<0&&(e=-e,a="-"),"".concat(a).concat(n).concat(e.toString(r)).concat(i)}function di(e,r){if("function"==typeof r)return r(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var{notation:t,precision:n,wordSize:i}=pi(r);switch(t){case"fixed":return vi(e,n);case"exponential":return yi(e,n);case"engineering":return function(e,r){if(isNaN(e)||!isFinite(e))return e+"";var t=bi(hi(e),r),n=t.exponent,i=t.coefficients,a=n%3==0?n:n<0?n-3-n%3:n-n%3;if(en(r))for(;r>i.length||n-a+1>i.length;)i.push(0);else for(var o=Math.abs(n-a)-(i.length-1),u=0;u<o;u++)i.push(0);for(var s=Math.abs(n-a),c=1;s>0;)c++,s--;var l=i.slice(c).join(""),f=en(r)&&l.length||l.match(/[1-9]/)?"."+l:"",m=i.slice(0,c).join("")+f+"e"+(n>=0?"+":"")+a;return t.sign+m}(e,n);case"bin":return mi(e,2,i);case"oct":return mi(e,8,i);case"hex":return mi(e,16,i);case"auto":return function(e,r,t){if(isNaN(e)||!isFinite(e))return e+"";var n=Si(null==t?void 0:t.lowerExp,-3),i=Si(null==t?void 0:t.upperExp,5),a=hi(e),o=r?bi(a,r):a;if(o.exponent<n||o.exponent>=i)return yi(e,r);var u=o.coefficients,s=o.exponent;u.length<r&&(u=u.concat(gi(r-u.length))),u=u.concat(gi(s-u.length+1+(u.length<r?r-u.length:0)));var c=s>0?s:0;return c<(u=gi(-s).concat(u)).length-1&&u.splice(c+1,0,"."),o.sign+u.join("")}(e,n,r).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],r=arguments[4];return"."!==e?e+r:r}));default:throw Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function pi(e){var r,t,n="auto";if(void 0!==e)if(en(e))r=e;else if(rn(e))r=e.toNumber();else{if(!wn(e))throw Error("Unsupported type of options, number, BigNumber, or object expected");void 0!==e.precision&&(r=Ei(e.precision,(()=>{throw Error('Option "precision" must be a number or BigNumber')}))),void 0!==e.wordSize&&(t=Ei(e.wordSize,(()=>{throw Error('Option "wordSize" must be a number or BigNumber')}))),e.notation&&(n=e.notation)}return{notation:n,precision:r,wordSize:t}}function hi(e){var r=(e+"").toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!r)throw new SyntaxError("Invalid number "+e);var t=r[1],n=r[2],i=parseFloat(r[4]||"0"),a=n.indexOf(".");i+=-1!==a?a-1:n.length-1;var o=n.replace(".","").replace(/^0*/,(function(e){return i-=e.length,""})).replace(/0*$/,"").split("").map((function(e){return parseInt(e)}));return 0===o.length&&(o.push(0),i++),{sign:t,coefficients:o,exponent:i}}function vi(e,r){if(isNaN(e)||!isFinite(e))return e+"";var t=hi(e),n="number"==typeof r?bi(t,t.exponent+1+r):t,i=n.coefficients,a=n.exponent+1,o=a+(r||0);return i.length<o&&(i=i.concat(gi(o-i.length))),a<0&&(i=gi(1-a).concat(i),a=1),a<i.length&&i.splice(a,0,0===a?"0.":"."),n.sign+i.join("")}function yi(e,r){if(isNaN(e)||!isFinite(e))return e+"";var t=hi(e),n=r?bi(t,r):t,i=n.coefficients,a=n.exponent;i.length<r&&(i=i.concat(gi(r-i.length)));var o=i.shift();return n.sign+o+(i.length>0?"."+i.join(""):"")+"e"+(a>=0?"+":"")+a}function bi(e,r){for(var t={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},n=t.coefficients;r<=0;)n.unshift(0),t.exponent++,r++;if(n.length>r&&n.splice(r,n.length-r)[0]>=5){var i=r-1;for(n[i]++;10===n[i];)n.pop(),0===i&&(n.unshift(0),t.exponent++,i++),n[--i]++}return t}function gi(e){for(var r=[],t=0;t<e;t++)r.push(0);return r}function xi(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e-8,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(t<=0)throw Error("Relative tolerance must be greater than 0");if(n<0)throw Error("Absolute tolerance must be at least 0");return!isNaN(e)&&!isNaN(r)&&(isFinite(e)&&isFinite(r)?e===r||Math.abs(e-r)<=Math.max(t*Math.max(Math.abs(e),Math.abs(r)),n):e===r)}var wi=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)},Di=Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},Ni=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2},Ai=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2},Mi=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2},Ci=Math.tanh||function(e){var r=Math.exp(2*e);return(r-1)/(r+1)};function Ei(e,r){return en(e)?e:rn(e)?e.toNumber():void r()}function Si(e,r){return en(e)?e:rn(e)?e.toNumber():r}var Fi=function(){return Fi=ri.create,ri},Bi=ti("typed",["?BigNumber","?Complex","?DenseMatrix","?Fraction"],(function(e){var{BigNumber:r,Complex:t,DenseMatrix:n,Fraction:i}=e,a=Fi();return a.clear(),a.addTypes([{name:"number",test:en},{name:"Complex",test:nn},{name:"BigNumber",test:rn},{name:"bigint",test:tn},{name:"Fraction",test:an},{name:"Unit",test:on},{name:"identifier",test:e=>un&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC4\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC4\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])*$/.test(e)},{name:"string",test:un},{name:"Chain",test:Ln},{name:"Array",test:sn},{name:"Matrix",test:cn},{name:"DenseMatrix",test:fn},{name:"SparseMatrix",test:mn},{name:"Range",test:dn},{name:"Index",test:pn},{name:"boolean",test:hn},{name:"ResultSet",test:vn},{name:"Help",test:yn},{name:"function",test:bn},{name:"Date",test:gn},{name:"RegExp",test:xn},{name:"null",test:Nn},{name:"undefined",test:An},{name:"AccessorNode",test:Mn},{name:"ArrayNode",test:Cn},{name:"AssignmentNode",test:En},{name:"BlockNode",test:Sn},{name:"ConditionalNode",test:Fn},{name:"ConstantNode",test:Bn},{name:"FunctionNode",test:kn},{name:"FunctionAssignmentNode",test:Tn},{name:"IndexNode",test:On},{name:"Node",test:In},{name:"ObjectNode",test:zn},{name:"OperatorNode",test:jn},{name:"ParenthesisNode",test:Rn},{name:"RangeNode",test:Un},{name:"RelationalNode",test:$n},{name:"SymbolNode",test:Pn},{name:"Map",test:Dn},{name:"Object",test:wn}]),a.addConversions([{from:"number",to:"BigNumber",convert:function(e){if(r||qi(e),function(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}(e)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new r(e)}},{from:"number",to:"Complex",convert:function(e){return t||Ti(e),new t(e,0)}},{from:"BigNumber",to:"Complex",convert:function(e){return t||Ti(e),new t(e.toNumber(),0)}},{from:"bigint",to:"number",convert:function(e){if(e>Number.MAX_SAFE_INTEGER)throw new TypeError("Cannot implicitly convert bigint to number: value exceeds the max safe integer value (value: "+e+")");return Number(e)}},{from:"bigint",to:"BigNumber",convert:function(e){return r||qi(e),new r(""+e)}},{from:"bigint",to:"Fraction",convert:function(e){return i||ki(e),new i(e)}},{from:"Fraction",to:"BigNumber",convert:function(){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(e){return t||Ti(e),new t(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){i||ki(e);var r=new i(e);if(r.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return r}},{from:"string",to:"number",convert:function(e){var r=Number(e);if(isNaN(r))throw Error('Cannot convert "'+e+'" to a number');return r}},{from:"string",to:"BigNumber",convert:function(e){r||qi(e);try{return new r(e)}catch(r){throw Error('Cannot convert "'+e+'" to BigNumber')}}},{from:"string",to:"bigint",convert:function(e){try{return BigInt(e)}catch(r){throw Error('Cannot convert "'+e+'" to BigInt')}}},{from:"string",to:"Fraction",convert:function(e){i||ki(e);try{return new i(e)}catch(r){throw Error('Cannot convert "'+e+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(e){t||Ti(e);try{return new t(e)}catch(r){throw Error('Cannot convert "'+e+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return r||qi(e),new r(+e)}},{from:"boolean",to:"bigint",convert:function(e){return BigInt(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return i||ki(e),new i(+e)}},{from:"boolean",to:"string",convert:function(e){return e+""}},{from:"Array",to:"Matrix",convert:function(e){return n||function(){throw Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}(),new n(e)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}]),a.onMismatch=(e,r,t)=>{var n=a.createError(e,r,t);if(["wrongType","mismatch"].includes(n.data.category)&&1===r.length&&ln(r[0])&&t.some((e=>!e.params.includes(",")))){var i=new TypeError("Function '".concat(e,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(e,")'."));throw i.data=n.data,i}throw n},a.onMismatch=(e,r,t)=>{var n=a.createError(e,r,t);if(["wrongType","mismatch"].includes(n.data.category)&&1===r.length&&ln(r[0])&&t.some((e=>!e.params.includes(",")))){var i=new TypeError("Function '".concat(e,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(e,")'."));throw i.data=n.data,i}throw n},a}));function qi(e){throw Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function Ti(e){throw Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function ki(e){throw Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var Oi,Ii,zi=ti("ResultSet",[],(()=>{function e(r){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=r||[]}return e.prototype.type="ResultSet",e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return"["+this.entries.map(String).join(", ")+"]"},e.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},e.fromJSON=function(r){return new e(r.entries)},e}),{isClass:!0}),ji=9e15,Ri=1e9,Ui="0123456789abcdef",$i="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Pi="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Li={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ji,maxE:ji,crypto:!1},_i=!0,Wi="[DecimalError] ",Ji=Wi+"Invalid argument: ",Vi=Wi+"Precision limit exceeded",Hi=Wi+"crypto unavailable",Zi="[object Decimal]",Gi=Math.floor,Xi=Math.pow,Yi=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Qi=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ki=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,ea=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,ra=1e7,ta=$i.length-1,na=Pi.length-1,ia={toStringTag:Zi};function aa(e){var r,t,n,i=e.length-1,a="",o=e[0];if(i>0){for(a+=o,r=1;r<i;r++)(t=7-(n=e[r]+"").length)&&(a+=va(t)),a+=n;(t=7-(n=(o=e[r])+"").length)&&(a+=va(t))}else if(0===o)return"0";for(;o%10==0;)o/=10;return a+o}function oa(e,r,t){if(e!==~~e||e<r||e>t)throw Error(Ji+e)}function ua(e,r,t,n){var i,a,o,u;for(a=e[0];a>=10;a/=10)--r;return--r<0?(r+=7,i=0):(i=Math.ceil((r+1)/7),r%=7),a=Xi(10,7-r),u=e[i]%a|0,null==n?r<3?(0==r?u=u/100|0:1==r&&(u=u/10|0),o=t<4&&99999==u||t>3&&49999==u||5e4==u||0==u):o=(t<4&&u+1==a||t>3&&u+1==a/2)&&(e[i+1]/a/100|0)==Xi(10,r-2)-1||(u==a/2||0==u)&&!(e[i+1]/a/100|0):r<4?(0==r?u=u/1e3|0:1==r?u=u/100|0:2==r&&(u=u/10|0),o=(n||t<4)&&9999==u||!n&&t>3&&4999==u):o=((n||t<4)&&u+1==a||!n&&t>3&&u+1==a/2)&&(e[i+1]/a/1e3|0)==Xi(10,r-3)-1,o}function sa(e,r,t){for(var n,i,a=[0],o=0,u=e.length;o<u;){for(i=a.length;i--;)a[i]*=r;for(a[0]+=Ui.indexOf(e.charAt(o++)),n=0;n<a.length;n++)a[n]>t-1&&(void 0===a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/t|0,a[n]%=t)}return a.reverse()}ia.absoluteValue=ia.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),la(e)},ia.ceil=function(){return la(new this.constructor(this),this.e+1,2)},ia.clampedTo=ia.clamp=function(e,r){var t=this,n=t.constructor;if(e=new n(e),r=new n(r),!e.s||!r.s)return new n(NaN);if(e.gt(r))throw Error(Ji+r);return t.cmp(e)<0?e:t.cmp(r)>0?r:new n(t)},ia.comparedTo=ia.cmp=function(e){var r,t,n,i,a=this,o=a.d,u=(e=new a.constructor(e)).d,s=a.s,c=e.s;if(!o||!u)return s&&c?s!==c?s:o===u?0:!o^s<0?1:-1:NaN;if(!o[0]||!u[0])return o[0]?s:u[0]?-c:0;if(s!==c)return s;if(a.e!==e.e)return a.e>e.e^s<0?1:-1;for(r=0,t=(n=o.length)<(i=u.length)?n:i;r<t;++r)if(o[r]!==u[r])return o[r]>u[r]^s<0?1:-1;return n===i?0:n>i^s<0?1:-1},ia.cosine=ia.cos=function(){var e,r,t=this,n=t.constructor;return t.d?t.d[0]?(r=n.rounding,n.precision=(e=n.precision)+Math.max(t.e,t.sd())+7,n.rounding=1,t=function(e,r){var t,n,i;if(r.isZero())return r;(n=r.d.length)<32?i=""+1/Ca(4,t=Math.ceil(n/3)):(t=16,i="2.3283064365386962890625e-10"),e.precision+=t,r=Ma(e,1,r.times(i),new e(1));for(var a=t;a--;){var o=r.times(r);r=o.times(o).minus(o).times(8).plus(1)}return e.precision-=t,r}(n,Ea(n,t)),n.precision=e,n.rounding=r,la(2==Ii||3==Ii?t.neg():t,e,r,!0)):new n(1):new n(NaN)},ia.cubeRoot=ia.cbrt=function(){var e,r,t,n,i,a,o,u,s,c,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(_i=!1,(a=l.s*Xi(l.s*l,1/3))&&Math.abs(a)!=1/0?n=new f(""+a):(t=aa(l.d),(a=((e=l.e)-t.length+1)%3)&&(t+=1==a||-2==a?"0":"00"),a=Xi(t,1/3),e=Gi((e+1)/3)-(e%3==(e<0?-1:2)),(n=new f(t=a==1/0?"5e"+e:(t=a.toExponential()).slice(0,t.indexOf("e")+1)+e)).s=l.s),o=(e=f.precision)+3;;)if(c=(s=(u=n).times(u).times(u)).plus(l),n=ca(c.plus(l).times(u),c.plus(s),o+2,1),aa(u.d).slice(0,o)===(t=aa(n.d)).slice(0,o)){if("9999"!=(t=t.slice(o-3,o+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(la(n,e+1,1),r=!n.times(n).times(n).eq(l));break}if(!i&&(la(u,e+1,0),u.times(u).times(u).eq(l))){n=u;break}o+=4,i=1}return _i=!0,la(n,e,f.rounding,r)},ia.decimalPlaces=ia.dp=function(){var e,r=this.d,t=NaN;if(r){if(t=7*((e=r.length-1)-Gi(this.e/7)),e=r[e])for(;e%10==0;e/=10)t--;t<0&&(t=0)}return t},ia.dividedBy=ia.div=function(e){return ca(this,new this.constructor(e))},ia.dividedToIntegerBy=ia.divToInt=function(e){var r=this.constructor;return la(ca(this,new r(e),0,1,1),r.precision,r.rounding)},ia.equals=ia.eq=function(e){return 0===this.cmp(e)},ia.floor=function(){return la(new this.constructor(this),this.e+1,3)},ia.greaterThan=ia.gt=function(e){return this.cmp(e)>0},ia.greaterThanOrEqualTo=ia.gte=function(e){var r=this.cmp(e);return 1==r||0===r},ia.hyperbolicCosine=ia.cosh=function(){var e,r,t,n,i,a=this,o=a.constructor,u=new o(1);if(!a.isFinite())return new o(a.s?1/0:NaN);if(a.isZero())return u;n=o.rounding,o.precision=(t=o.precision)+Math.max(a.e,a.sd())+4,o.rounding=1,(i=a.d.length)<32?r=""+1/Ca(4,e=Math.ceil(i/3)):(e=16,r="2.3283064365386962890625e-10"),a=Ma(o,1,a.times(r),new o(1),!0);for(var s,c=e,l=new o(8);c--;)s=a.times(a),a=u.minus(s.times(l.minus(s.times(l))));return la(a,o.precision=t,o.rounding=n,!0)},ia.hyperbolicSine=ia.sinh=function(){var e,r,t,n,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.rounding,a.precision=(r=a.precision)+Math.max(i.e,i.sd())+4,a.rounding=1,(n=i.d.length)<3)i=Ma(a,2,i,i,!0);else{i=Ma(a,2,i=i.times(1/Ca(5,e=(e=1.4*Math.sqrt(n))>16?16:0|e)),i,!0);for(var o,u=new a(5),s=new a(16),c=new a(20);e--;)o=i.times(i),i=i.times(u.plus(o.times(s.times(o).plus(c))))}return a.precision=r,a.rounding=t,la(i,r,t,!0)},ia.hyperbolicTangent=ia.tanh=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.rounding,n.precision=(e=n.precision)+7,n.rounding=1,ca(t.sinh(),t.cosh(),n.precision=e,n.rounding=r)):new n(t.s)},ia.inverseCosine=ia.acos=function(){var e=this,r=e.constructor,t=e.abs().cmp(1),n=r.precision,i=r.rounding;return-1!==t?0===t?e.isNeg()?pa(r,n,i):new r(0):new r(NaN):e.isZero()?pa(r,n+4,i).times(.5):(r.precision=n+6,r.rounding=1,e=new r(1).minus(e).div(e.plus(1)).sqrt().atan(),r.precision=n,r.rounding=i,e.times(2))},ia.inverseHyperbolicCosine=ia.acosh=function(){var e,r,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(r=n.rounding,n.precision=(e=n.precision)+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,_i=!1,t=t.times(t).minus(1).sqrt().plus(t),_i=!0,n.precision=e,n.rounding=r,t.ln()):new n(t)},ia.inverseHyperbolicSine=ia.asinh=function(){var e,r,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(r=n.rounding,n.precision=(e=n.precision)+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,_i=!1,t=t.times(t).plus(1).sqrt().plus(t),_i=!0,n.precision=e,n.rounding=r,t.ln())},ia.inverseHyperbolicTangent=ia.atanh=function(){var e,r,t,n,i=this,a=i.constructor;return i.isFinite()?i.e>=0?new a(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=a.precision,r=a.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?la(new a(i),e,r,!0):(a.precision=t=n-i.e,i=ca(i.plus(1),new a(1).minus(i),t+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=r,i.times(.5))):new a(NaN)},ia.inverseSine=ia.asin=function(){var e,r,t,n,i=this,a=i.constructor;return i.isZero()?new a(i):(r=i.abs().cmp(1),t=a.precision,n=a.rounding,-1!==r?0===r?((e=pa(a,t+4,n).times(.5)).s=i.s,e):new a(NaN):(a.precision=t+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=t,a.rounding=n,i.times(2)))},ia.inverseTangent=ia.atan=function(){var e,r,t,n,i,a,o,u,s,c=this,l=c.constructor,f=l.precision,m=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&f+4<=na)return(o=pa(l,f+4,m).times(.25)).s=c.s,o}else{if(!c.s)return new l(NaN);if(f+4<=na)return(o=pa(l,f+4,m).times(.5)).s=c.s,o}for(l.precision=u=f+10,l.rounding=1,e=t=Math.min(28,u/7+2|0);e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(_i=!1,r=Math.ceil(u/7),n=1,s=c.times(c),o=new l(c),i=c;-1!==e;)if(i=i.times(s),a=o.minus(i.div(n+=2)),i=i.times(s),void 0!==(o=a.plus(i.div(n+=2))).d[r])for(e=r;o.d[e]===a.d[e]&&e--;);return t&&(o=o.times(2<<t-1)),_i=!0,la(o,l.precision=f,l.rounding=m,!0)},ia.isFinite=function(){return!!this.d},ia.isInteger=ia.isInt=function(){return!!this.d&&Gi(this.e/7)>this.d.length-2},ia.isNaN=function(){return!this.s},ia.isNegative=ia.isNeg=function(){return this.s<0},ia.isPositive=ia.isPos=function(){return this.s>0},ia.isZero=function(){return!!this.d&&0===this.d[0]},ia.lessThan=ia.lt=function(e){return this.cmp(e)<0},ia.lessThanOrEqualTo=ia.lte=function(e){return this.cmp(e)<1},ia.logarithm=ia.log=function(e){var r,t,n,i,a,o,u,s,c=this,l=c.constructor,f=l.precision,m=l.rounding;if(null==e)e=new l(10),r=!0;else{if(t=(e=new l(e)).d,e.s<0||!t||!t[0]||e.eq(1))return new l(NaN);r=e.eq(10)}if(t=c.d,c.s<0||!t||!t[0]||c.eq(1))return new l(t&&!t[0]?-1/0:1!=c.s?NaN:t?0:1/0);if(r)if(t.length>1)a=!0;else{for(i=t[0];i%10==0;)i/=10;a=1!==i}if(_i=!1,o=wa(c,u=f+5),n=r?da(l,u+10):wa(e,u),ua((s=ca(o,n,u,1)).d,i=f,m))do{if(o=wa(c,u+=10),n=r?da(l,u+10):wa(e,u),s=ca(o,n,u,1),!a){+aa(s.d).slice(i+1,i+15)+1==1e14&&(s=la(s,f+1,0));break}}while(ua(s.d,i+=10,m));return _i=!0,la(s,f,m)},ia.minus=ia.sub=function(e){var r,t,n,i,a,o,u,s,c,l,f,m,d=this,p=d.constructor;if(e=new p(e),!d.d||!e.d)return d.s&&e.s?d.d?e.s=-e.s:e=new p(e.d||d.s!==e.s?d:NaN):e=new p(NaN),e;if(d.s!=e.s)return e.s=-e.s,d.plus(e);if(m=e.d,u=p.precision,s=p.rounding,!(c=d.d)[0]||!m[0]){if(m[0])e.s=-e.s;else{if(!c[0])return new p(3===s?-0:0);e=new p(d)}return _i?la(e,u,s):e}if(t=Gi(e.e/7),l=Gi(d.e/7),c=c.slice(),a=l-t){for((f=a<0)?(r=c,a=-a,o=m.length):(r=m,t=l,o=c.length),a>(n=Math.max(Math.ceil(u/7),o)+2)&&(a=n,r.length=1),r.reverse(),n=a;n--;)r.push(0);r.reverse()}else{for((f=(n=c.length)<(o=m.length))&&(o=n),n=0;n<o;n++)if(c[n]!=m[n]){f=c[n]<m[n];break}a=0}for(f&&(r=c,c=m,m=r,e.s=-e.s),n=m.length-(o=c.length);n>0;--n)c[o++]=0;for(n=m.length;n>a;){if(c[--n]<m[n]){for(i=n;i&&0===c[--i];)c[i]=ra-1;--c[i],c[n]+=ra}c[n]-=m[n]}for(;0===c[--o];)c.pop();for(;0===c[0];c.shift())--t;return c[0]?(e.d=c,e.e=ma(c,t),_i?la(e,u,s):e):new p(3===s?-0:0)},ia.modulo=ia.mod=function(e){var r,t=this,n=t.constructor;return e=new n(e),!t.d||!e.s||e.d&&!e.d[0]?new n(NaN):!e.d||t.d&&!t.d[0]?la(new n(t),n.precision,n.rounding):(_i=!1,9==n.modulo?(r=ca(t,e.abs(),0,3,1)).s*=e.s:r=ca(t,e,0,n.modulo,1),r=r.times(e),_i=!0,t.minus(r))},ia.naturalExponential=ia.exp=function(){return xa(this)},ia.naturalLogarithm=ia.ln=function(){return wa(this)},ia.negated=ia.neg=function(){var e=new this.constructor(this);return e.s=-e.s,la(e)},ia.plus=ia.add=function(e){var r,t,n,i,a,o,u,s,c,l,f=this,m=f.constructor;if(e=new m(e),!f.d||!e.d)return f.s&&e.s?f.d||(e=new m(e.d||f.s===e.s?f:NaN)):e=new m(NaN),e;if(f.s!=e.s)return e.s=-e.s,f.minus(e);if(l=e.d,u=m.precision,s=m.rounding,!(c=f.d)[0]||!l[0])return l[0]||(e=new m(f)),_i?la(e,u,s):e;if(a=Gi(f.e/7),n=Gi(e.e/7),c=c.slice(),i=a-n){for(i<0?(t=c,i=-i,o=l.length):(t=l,n=a,o=c.length),i>(o=(a=Math.ceil(u/7))>o?a+1:o+1)&&(i=o,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for((o=c.length)-(i=l.length)<0&&(i=o,t=l,l=c,c=t),r=0;i;)r=(c[--i]=c[i]+l[i]+r)/ra|0,c[i]%=ra;for(r&&(c.unshift(r),++n),o=c.length;0==c[--o];)c.pop();return e.d=c,e.e=ma(c,n),_i?la(e,u,s):e},ia.precision=ia.sd=function(e){var r,t=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(Ji+e);return t.d?(r=ha(t.d),e&&t.e+1>r&&(r=t.e+1)):r=NaN,r},ia.round=function(){var e=this,r=e.constructor;return la(new r(e),e.e+1,r.rounding)},ia.sine=ia.sin=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.rounding,n.precision=(e=n.precision)+Math.max(t.e,t.sd())+7,n.rounding=1,t=function(e,r){var t,n=r.d.length;if(n<3)return r.isZero()?r:Ma(e,2,r,r);r=Ma(e,2,r=r.times(1/Ca(5,t=(t=1.4*Math.sqrt(n))>16?16:0|t)),r);for(var i,a=new e(5),o=new e(16),u=new e(20);t--;)i=r.times(r),r=r.times(a.plus(i.times(o.times(i).minus(u))));return r}(n,Ea(n,t)),n.precision=e,n.rounding=r,la(Ii>2?t.neg():t,e,r,!0)):new n(NaN)},ia.squareRoot=ia.sqrt=function(){var e,r,t,n,i,a,o=this,u=o.d,s=o.e,c=o.s,l=o.constructor;if(1!==c||!u||!u[0])return new l(!c||c<0&&(!u||u[0])?NaN:u?o:1/0);for(_i=!1,0==(c=Math.sqrt(+o))||c==1/0?(((r=aa(u)).length+s)%2==0&&(r+="0"),c=Math.sqrt(r),s=Gi((s+1)/2)-(s<0||s%2),n=new l(r=c==1/0?"5e"+s:(r=c.toExponential()).slice(0,r.indexOf("e")+1)+s)):n=new l(""+c),t=(s=l.precision)+3;;)if(n=(a=n).plus(ca(o,a,t+2,1)).times(.5),aa(a.d).slice(0,t)===(r=aa(n.d)).slice(0,t)){if("9999"!=(r=r.slice(t-3,t+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(la(n,s+1,1),e=!n.times(n).eq(o));break}if(!i&&(la(a,s+1,0),a.times(a).eq(o))){n=a;break}t+=4,i=1}return _i=!0,la(n,s,l.rounding,e)},ia.tangent=ia.tan=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.rounding,n.precision=(e=n.precision)+10,n.rounding=1,(t=t.sin()).s=1,t=ca(t,new n(1).minus(t.times(t)).sqrt(),e+10,0),n.precision=e,n.rounding=r,la(2==Ii||4==Ii?t.neg():t,e,r,!0)):new n(NaN)},ia.times=ia.mul=function(e){var r,t,n,i,a,o,u,s,c,l=this,f=l.constructor,m=l.d,d=(e=new f(e)).d;if(e.s*=l.s,!(m&&m[0]&&d&&d[0]))return new f(!e.s||m&&!m[0]&&!d||d&&!d[0]&&!m?NaN:m&&d?0*e.s:e.s/0);for(t=Gi(l.e/7)+Gi(e.e/7),(s=m.length)<(c=d.length)&&(a=m,m=d,d=a,o=s,s=c,c=o),a=[],n=o=s+c;n--;)a.push(0);for(n=c;--n>=0;){for(r=0,i=s+n;i>n;)u=a[i]+d[n]*m[i-n-1]+r,a[i--]=u%ra|0,r=u/ra|0;a[i]=(a[i]+r)%ra|0}for(;!a[--o];)a.pop();return r?++t:a.shift(),e.d=a,e.e=ma(a,t),_i?la(e,f.precision,f.rounding):e},ia.toBinary=function(e,r){return Sa(this,2,e,r)},ia.toDecimalPlaces=ia.toDP=function(e,r){var t=this,n=t.constructor;return t=new n(t),void 0===e?t:(oa(e,0,Ri),void 0===r?r=n.rounding:oa(r,0,8),la(t,e+t.e+1,r))},ia.toExponential=function(e,r){var t,n=this,i=n.constructor;return void 0===e?t=fa(n,!0):(oa(e,0,Ri),void 0===r?r=i.rounding:oa(r,0,8),t=fa(n=la(new i(n),e+1,r),!0,e+1)),n.isNeg()&&!n.isZero()?"-"+t:t},ia.toFixed=function(e,r){var t,n,i=this,a=i.constructor;return void 0===e?t=fa(i):(oa(e,0,Ri),void 0===r?r=a.rounding:oa(r,0,8),t=fa(n=la(new a(i),e+i.e+1,r),!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t},ia.toFraction=function(e){var r,t,n,i,a,o,u,s,c,l,f,m,d=this,p=d.d,h=d.constructor;if(!p)return new h(d);if(c=t=new h(1),n=s=new h(0),a=(r=new h(n)).e=ha(p)-d.e-1,r.d[0]=Xi(10,(o=a%7)<0?7+o:o),null==e)e=a>0?r:c;else{if(!(u=new h(e)).isInt()||u.lt(c))throw Error(Ji+u);e=u.gt(r)?a>0?r:c:u}for(_i=!1,u=new h(aa(p)),l=h.precision,h.precision=a=7*p.length*2;f=ca(u,r,0,1,1),1!=(i=t.plus(f.times(n))).cmp(e);)t=n,n=i,c=s.plus(f.times(i=c)),s=i,r=u.minus(f.times(i=r)),u=i;return i=ca(e.minus(t),n,0,1,1),s=s.plus(i.times(c)),t=t.plus(i.times(n)),s.s=c.s=d.s,m=ca(c,n,a,1).minus(d).abs().cmp(ca(s,t,a,1).minus(d).abs())<1?[c,n]:[s,t],h.precision=l,_i=!0,m},ia.toHexadecimal=ia.toHex=function(e,r){return Sa(this,16,e,r)},ia.toNearest=function(e,r){var t=this,n=t.constructor;if(t=new n(t),null==e){if(!t.d)return t;e=new n(1),r=n.rounding}else{if(e=new n(e),void 0===r?r=n.rounding:oa(r,0,8),!t.d)return e.s?t:e;if(!e.d)return e.s&&(e.s=t.s),e}return e.d[0]?(_i=!1,t=ca(t,e,0,r,1).times(e),_i=!0,la(t)):(e.s=t.s,t=e),t},ia.toNumber=function(){return+this},ia.toOctal=function(e,r){return Sa(this,8,e,r)},ia.toPower=ia.pow=function(e){var r,t,n,i,a,o,u=this,s=u.constructor,c=+(e=new s(e));if(!(u.d&&e.d&&u.d[0]&&e.d[0]))return new s(Xi(+u,c));if((u=new s(u)).eq(1))return u;if(n=s.precision,a=s.rounding,e.eq(1))return la(u,n,a);if((r=Gi(e.e/7))>=e.d.length-1&&(t=c<0?-c:c)<=9007199254740991)return i=ya(s,u,t,n),e.s<0?new s(1).div(i):la(i,n,a);if((o=u.s)<0){if(r<e.d.length-1)return new s(NaN);if(1&e.d[r]||(o=1),0==u.e&&1==u.d[0]&&1==u.d.length)return u.s=o,u}return(r=0!=(t=Xi(+u,c))&&isFinite(t)?new s(t+"").e:Gi(c*(Math.log("0."+aa(u.d))/Math.LN10+u.e+1)))>s.maxE+1||r<s.minE-1?new s(r>0?o/0:0):(_i=!1,s.rounding=u.s=1,(i=xa(e.times(wa(u,n+(t=Math.min(12,(r+"").length)))),n)).d&&ua((i=la(i,n+5,1)).d,n,a)&&+aa((i=la(xa(e.times(wa(u,(r=n+10)+t)),r),r+5,1)).d).slice(n+1,n+15)+1==1e14&&(i=la(i,n+1,0)),i.s=o,_i=!0,s.rounding=a,la(i,n,a))},ia.toPrecision=function(e,r){var t,n=this,i=n.constructor;return void 0===e?t=fa(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(oa(e,1,Ri),void 0===r?r=i.rounding:oa(r,0,8),t=fa(n=la(new i(n),e,r),e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+t:t},ia.toSignificantDigits=ia.toSD=function(e,r){var t=this.constructor;return void 0===e?(e=t.precision,r=t.rounding):(oa(e,1,Ri),void 0===r?r=t.rounding:oa(r,0,8)),la(new t(this),e,r)},ia.toString=function(){var e=this,r=e.constructor,t=fa(e,e.e<=r.toExpNeg||e.e>=r.toExpPos);return e.isNeg()&&!e.isZero()?"-"+t:t},ia.truncated=ia.trunc=function(){return la(new this.constructor(this),this.e+1,1)},ia.valueOf=ia.toJSON=function(){var e=this,r=e.constructor,t=fa(e,e.e<=r.toExpNeg||e.e>=r.toExpPos);return e.isNeg()?"-"+t:t};var ca=function(){function e(e,r,t){var n,i=0,a=e.length;for(e=e.slice();a--;)e[a]=(n=e[a]*r+i)%t|0,i=n/t|0;return i&&e.unshift(i),e}function r(e,r,t,n){var i,a;if(t!=n)a=t>n?1:-1;else for(i=a=0;i<t;i++)if(e[i]!=r[i]){a=e[i]>r[i]?1:-1;break}return a}function t(e,r,t,n){for(var i=0;t--;)e[t]-=i,e[t]=(i=e[t]<r[t]?1:0)*n+e[t]-r[t];for(;!e[0]&&e.length>1;)e.shift()}return function(n,i,a,o,u,s){var c,l,f,m,d,p,h,v,y,b,g,x,w,D,N,A,M,C,E,S,F=n.constructor,B=n.s==i.s?1:-1,q=n.d,T=i.d;if(!(q&&q[0]&&T&&T[0]))return new F(n.s&&i.s&&(q?!T||q[0]!=T[0]:T)?q&&0==q[0]||!T?0*B:B/0:NaN);for(s?(d=1,l=n.e-i.e):(s=ra,l=Gi(n.e/(d=7))-Gi(i.e/d)),E=T.length,M=q.length,b=(y=new F(B)).d=[],f=0;T[f]==(q[f]||0);f++);if(T[f]>(q[f]||0)&&l--,null==a?(D=a=F.precision,o=F.rounding):D=u?a+(n.e-i.e)+1:a,D<0)b.push(1),p=!0;else{if(D=D/d+2|0,f=0,1==E){for(m=0,T=T[0],D++;(f<M||m)&&D--;f++)b[f]=(N=m*s+(q[f]||0))/T|0,m=N%T|0;p=m||f<M}else{for((m=s/(T[0]+1)|0)>1&&(T=e(T,m,s),q=e(q,m,s),E=T.length,M=q.length),A=E,x=(g=q.slice(0,E)).length;x<E;)g[x++]=0;(S=T.slice()).unshift(0),C=T[0],T[1]>=s/2&&++C;do{m=0,(c=r(T,g,E,x))<0?(w=g[0],E!=x&&(w=w*s+(g[1]||0)),(m=w/C|0)>1?(m>=s&&(m=s-1),1==(c=r(h=e(T,m,s),g,v=h.length,x=g.length))&&(m--,t(h,E<v?S:T,v,s))):(0==m&&(c=m=1),h=T.slice()),(v=h.length)<x&&h.unshift(0),t(g,h,x,s),-1==c&&(c=r(T,g,E,x=g.length))<1&&(m++,t(g,E<x?S:T,x,s)),x=g.length):0===c&&(m++,g=[0]),b[f++]=m,c&&g[0]?g[x++]=q[A]||0:(g=[q[A]],x=1)}while((A++<M||void 0!==g[0])&&D--);p=void 0!==g[0]}b[0]||b.shift()}if(1==d)y.e=l,Oi=p;else{for(f=1,m=b[0];m>=10;m/=10)f++;y.e=f+l*d-1,la(y,u?a+y.e+1:a,o,p)}return y}}();function la(e,r,t,n){var i,a,o,u,s,c,l,f,m,d=e.constructor;e:if(null!=r){if(!(f=e.d))return e;for(i=1,u=f[0];u>=10;u/=10)i++;if((a=r-i)<0)a+=7,s=(l=f[m=0])/Xi(10,i-(o=r)-1)%10|0;else if((m=Math.ceil((a+1)/7))>=(u=f.length)){if(!n)break e;for(;u++<=m;)f.push(0);l=s=0,i=1,o=(a%=7)-7+1}else{for(l=u=f[m],i=1;u>=10;u/=10)i++;s=(o=(a%=7)-7+i)<0?0:l/Xi(10,i-o-1)%10|0}if(n=n||r<0||void 0!==f[m+1]||(o<0?l:l%Xi(10,i-o-1)),c=t<4?(s||n)&&(0==t||t==(e.s<0?3:2)):s>5||5==s&&(4==t||n||6==t&&(a>0?o>0?l/Xi(10,i-o):0:f[m-1])%10&1||t==(e.s<0?8:7)),r<1||!f[0])return f.length=0,c?(f[0]=Xi(10,(7-(r-=e.e+1)%7)%7),e.e=-r||0):f[0]=e.e=0,e;if(0==a?(f.length=m,u=1,m--):(f.length=m+1,u=Xi(10,7-a),f[m]=o>0?(l/Xi(10,i-o)%Xi(10,o)|0)*u:0),c)for(;;){if(0==m){for(a=1,o=f[0];o>=10;o/=10)a++;for(o=f[0]+=u,u=1;o>=10;o/=10)u++;a!=u&&(e.e++,f[0]==ra&&(f[0]=1));break}if(f[m]+=u,f[m]!=ra)break;f[m--]=0,u=1}for(a=f.length;0===f[--a];)f.pop()}return _i&&(e.e>d.maxE?(e.d=null,e.e=NaN):e.e<d.minE&&(e.e=0,e.d=[0])),e}function fa(e,r,t){if(!e.isFinite())return Da(e);var n,i=e.e,a=aa(e.d),o=a.length;return r?(t&&(n=t-o)>0?a=a.charAt(0)+"."+a.slice(1)+va(n):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(e.e<0?"e":"e+")+e.e):i<0?(a="0."+va(-i-1)+a,t&&(n=t-o)>0&&(a+=va(n))):i>=o?(a+=va(i+1-o),t&&(n=t-i-1)>0&&(a=a+"."+va(n))):((n=i+1)<o&&(a=a.slice(0,n)+"."+a.slice(n)),t&&(n=t-o)>0&&(i+1===o&&(a+="."),a+=va(n))),a}function ma(e,r){var t=e[0];for(r*=7;t>=10;t/=10)r++;return r}function da(e,r,t){if(r>ta)throw _i=!0,t&&(e.precision=t),Error(Vi);return la(new e($i),r,1,!0)}function pa(e,r,t){if(r>na)throw Error(Vi);return la(new e(Pi),r,t,!0)}function ha(e){var r=e.length-1,t=7*r+1;if(r=e[r]){for(;r%10==0;r/=10)t--;for(r=e[0];r>=10;r/=10)t++}return t}function va(e){for(var r="";e--;)r+="0";return r}function ya(e,r,t,n){var i,a=new e(1),o=Math.ceil(n/7+4);for(_i=!1;;){if(t%2&&Fa((a=a.times(r)).d,o)&&(i=!0),0===(t=Gi(t/2))){t=a.d.length-1,i&&0===a.d[t]&&++a.d[t];break}Fa((r=r.times(r)).d,o)}return _i=!0,a}function ba(e){return 1&e.d[e.d.length-1]}function ga(e,r,t){for(var n,i,a=new e(r[0]),o=0;++o<r.length;){if(!(i=new e(r[o])).s){a=i;break}((n=a.cmp(i))===t||0===n&&a.s===t)&&(a=i)}return a}function xa(e,r){var t,n,i,a,o,u,s,c=0,l=0,f=0,m=e.constructor,d=m.rounding,p=m.precision;if(!e.d||!e.d[0]||e.e>17)return new m(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==r?(_i=!1,s=p):s=r,u=new m(.03125);e.e>-2;)e=e.times(u),f+=5;for(s+=n=Math.log(Xi(2,f))/Math.LN10*2+5|0,t=a=o=new m(1),m.precision=s;;){if(a=la(a.times(e),s,1),t=t.times(++l),aa((u=o.plus(ca(a,t,s,1))).d).slice(0,s)===aa(o.d).slice(0,s)){for(i=f;i--;)o=la(o.times(o),s,1);if(null!=r)return m.precision=p,o;if(!(c<3&&ua(o.d,s-n,d,c)))return la(o,m.precision=p,d,_i=!0);m.precision=s+=10,t=a=u=new m(1),l=0,c++}o=u}}function wa(e,r){var t,n,i,a,o,u,s,c,l,f,m,d=1,p=e,h=p.d,v=p.constructor,y=v.rounding,b=v.precision;if(p.s<0||!h||!h[0]||!p.e&&1==h[0]&&1==h.length)return new v(h&&!h[0]?-1/0:1!=p.s?NaN:h?0:p);if(null==r?(_i=!1,l=b):l=r,v.precision=l+=10,n=(t=aa(h)).charAt(0),!(Math.abs(a=p.e)<15e14))return c=da(v,l+2,b).times(a+""),p=wa(new v(n+"."+t.slice(1)),l-10).plus(c),v.precision=b,null==r?la(p,b,y,_i=!0):p;for(;n<7&&1!=n||1==n&&t.charAt(1)>3;)n=(t=aa((p=p.times(e)).d)).charAt(0),d++;for(a=p.e,n>1?(p=new v("0."+t),a++):p=new v(n+"."+t.slice(1)),f=p,s=o=p=ca(p.minus(1),p.plus(1),l,1),m=la(p.times(p),l,1),i=3;;){if(o=la(o.times(m),l,1),aa((c=s.plus(ca(o,new v(i),l,1))).d).slice(0,l)===aa(s.d).slice(0,l)){if(s=s.times(2),0!==a&&(s=s.plus(da(v,l+2,b).times(a+""))),s=ca(s,new v(d),l,1),null!=r)return v.precision=b,s;if(!ua(s.d,l-10,y,u))return la(s,v.precision=b,y,_i=!0);v.precision=l+=10,c=o=p=ca(f.minus(1),f.plus(1),l,1),m=la(p.times(p),l,1),i=u=1}s=c,i+=2}}function Da(e){return e.s*e.s/0+""}function Na(e,r){var t,n,i;for((t=r.indexOf("."))>-1&&(r=r.replace(".","")),(n=r.search(/e/i))>0?(t<0&&(t=n),t+=+r.slice(n+1),r=r.substring(0,n)):t<0&&(t=r.length),n=0;48===r.charCodeAt(n);n++);for(i=r.length;48===r.charCodeAt(i-1);--i);if(r=r.slice(n,i)){if(i-=n,e.e=t=t-n-1,e.d=[],n=(t+1)%7,t<0&&(n+=7),n<i){for(n&&e.d.push(+r.slice(0,n)),i-=7;n<i;)e.d.push(+r.slice(n,n+=7));n=7-(r=r.slice(n)).length}else n-=i;for(;n--;)r+="0";e.d.push(+r),_i&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function Aa(e,r){var t,n,i,a,o,u,s,c,l;if(r.indexOf("_")>-1){if(r=r.replace(/(\d)_(?=\d)/g,"$1"),ea.test(r))return Na(e,r)}else if("Infinity"===r||"NaN"===r)return+r||(e.s=NaN),e.e=NaN,e.d=null,e;if(Qi.test(r))t=16,r=r.toLowerCase();else if(Yi.test(r))t=2;else{if(!Ki.test(r))throw Error(Ji+r);t=8}for((a=r.search(/p/i))>0?(s=+r.slice(a+1),r=r.substring(2,a)):r=r.slice(2),a=r.indexOf("."),n=e.constructor,(o=a>=0)&&(a=(u=(r=r.replace(".","")).length)-a,i=ya(n,new n(t),a,2*a)),a=l=(c=sa(r,t,ra)).length-1;0===c[a];--a)c.pop();return a<0?new n(0*e.s):(e.e=ma(c,l),e.d=c,_i=!1,o&&(e=ca(e,i,4*u)),s&&(e=e.times(Math.abs(s)<54?Xi(2,s):yo.pow(2,s))),_i=!0,e)}function Ma(e,r,t,n,i){var a,o,u,s,c=e.precision,l=Math.ceil(c/7);for(_i=!1,s=t.times(t),u=new e(n);;){if(o=ca(u.times(s),new e(r++*r++),c,1),u=i?n.plus(o):n.minus(o),n=ca(o.times(s),new e(r++*r++),c,1),void 0!==(o=u.plus(n)).d[l]){for(a=l;o.d[a]===u.d[a]&&a--;);if(-1==a)break}a=u,u=n,n=o,o=a}return _i=!0,o.d.length=l+1,o}function Ca(e,r){for(var t=e;--r;)t*=e;return t}function Ea(e,r){var t,n=r.s<0,i=pa(e,e.precision,1),a=i.times(.5);if((r=r.abs()).lte(a))return Ii=n?4:1,r;if((t=r.divToInt(i)).isZero())Ii=n?3:2;else{if((r=r.minus(t.times(i))).lte(a))return Ii=ba(t)?n?2:3:n?4:1,r;Ii=ba(t)?n?1:4:n?3:2}return r.minus(i).abs()}function Sa(e,r,t,n){var i,a,o,u,s,c,l,f,m,d=e.constructor,p=void 0!==t;if(p?(oa(t,1,Ri),void 0===n?n=d.rounding:oa(n,0,8)):(t=d.precision,n=d.rounding),e.isFinite()){for(p?(i=2,16==r?t=4*t-3:8==r&&(t=3*t-2)):i=r,(o=(l=fa(e)).indexOf("."))>=0&&(l=l.replace(".",""),(m=new d(1)).e=l.length-o,m.d=sa(fa(m),10,i),m.e=m.d.length),a=s=(f=sa(l,10,i)).length;0==f[--s];)f.pop();if(f[0]){if(o<0?a--:((e=new d(e)).d=f,e.e=a,f=(e=ca(e,m,t,n,0,i)).d,a=e.e,c=Oi),o=f[t],u=i/2,c=c||void 0!==f[t+1],c=n<4?(void 0!==o||c)&&(0===n||n===(e.s<0?3:2)):o>u||o===u&&(4===n||c||6===n&&1&f[t-1]||n===(e.s<0?8:7)),f.length=t,c)for(;++f[--t]>i-1;)f[t]=0,t||(++a,f.unshift(1));for(s=f.length;!f[s-1];--s);for(o=0,l="";o<s;o++)l+=Ui.charAt(f[o]);if(p){if(s>1)if(16==r||8==r){for(o=16==r?4:3,--s;s%o;s++)l+="0";for(s=(f=sa(l,i,r)).length;!f[s-1];--s);for(o=1,l="1.";o<s;o++)l+=Ui.charAt(f[o])}else l=l.charAt(0)+"."+l.slice(1);l=l+(a<0?"p":"p+")+a}else if(a<0){for(;++a;)l="0"+l;l="0."+l}else if(++a>s)for(a-=s;a--;)l+="0";else a<s&&(l=l.slice(0,a)+"."+l.slice(a))}else l=p?"0p+0":"0";l=(16==r?"0x":2==r?"0b":8==r?"0o":"")+l}else l=Da(e);return e.s<0?"-"+l:l}function Fa(e,r){if(e.length>r)return e.length=r,!0}function Ba(e){return new this(e).abs()}function qa(e){return new this(e).acos()}function Ta(e){return new this(e).acosh()}function ka(e,r){return new this(e).plus(r)}function Oa(e){return new this(e).asin()}function Ia(e){return new this(e).asinh()}function za(e){return new this(e).atan()}function ja(e){return new this(e).atanh()}function Ra(e,r){e=new this(e),r=new this(r);var t,n=this.precision,i=this.rounding,a=n+4;return e.s&&r.s?e.d||r.d?!r.d||e.isZero()?(t=r.s<0?pa(this,n,i):new this(0)).s=e.s:!e.d||r.isZero()?(t=pa(this,a,1).times(.5)).s=e.s:r.s<0?(this.precision=a,this.rounding=1,t=this.atan(ca(e,r,a,1)),r=pa(this,a,1),this.precision=n,this.rounding=i,t=e.s<0?t.minus(r):t.plus(r)):t=this.atan(ca(e,r,a,1)):(t=pa(this,a,1).times(r.s>0?.25:.75)).s=e.s:t=new this(NaN),t}function Ua(e){return new this(e).cbrt()}function $a(e){return la(e=new this(e),e.e+1,2)}function Pa(e,r,t){return new this(e).clamp(r,t)}function La(e){if(!e||"object"!=typeof e)throw Error(Wi+"Object expected");var r,t,n,i=!0===e.defaults,a=["precision",1,Ri,"rounding",0,8,"toExpNeg",-ji,0,"toExpPos",0,ji,"maxE",0,ji,"minE",-ji,0,"modulo",0,9];for(r=0;r<a.length;r+=3)if(t=a[r],i&&(this[t]=Li[t]),void 0!==(n=e[t])){if(!(Gi(n)===n&&n>=a[r+1]&&n<=a[r+2]))throw Error(Ji+t+": "+n);this[t]=n}if(t="crypto",i&&(this[t]=Li[t]),void 0!==(n=e[t])){if(!0!==n&&!1!==n&&0!==n&&1!==n)throw Error(Ji+t+": "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(Hi);this[t]=!0}else this[t]=!1}return this}function _a(e){return new this(e).cos()}function Wa(e){return new this(e).cosh()}function Ja(e,r){return new this(e).div(r)}function Va(e){return new this(e).exp()}function Ha(e){return la(e=new this(e),e.e+1,3)}function Za(){var e,r,t=new this(0);for(_i=!1,e=0;e<arguments.length;)if((r=new this(arguments[e++])).d)t.d&&(t=t.plus(r.times(r)));else{if(r.s)return _i=!0,new this(1/0);t=r}return _i=!0,t.sqrt()}function Ga(e){return e instanceof yo||e&&e.toStringTag===Zi||!1}function Xa(e){return new this(e).ln()}function Ya(e,r){return new this(e).log(r)}function Qa(e){return new this(e).log(2)}function Ka(e){return new this(e).log(10)}function eo(){return ga(this,arguments,-1)}function ro(){return ga(this,arguments,1)}function to(e,r){return new this(e).mod(r)}function no(e,r){return new this(e).mul(r)}function io(e,r){return new this(e).pow(r)}function ao(e){var r,t,n,i,a=0,o=new this(1),u=[];if(void 0===e?e=this.precision:oa(e,1,Ri),n=Math.ceil(e/7),this.crypto)if(crypto.getRandomValues)for(r=crypto.getRandomValues(new Uint32Array(n));a<n;)(i=r[a])>=429e7?r[a]=crypto.getRandomValues(new Uint32Array(1))[0]:u[a++]=i%1e7;else{if(!crypto.randomBytes)throw Error(Hi);for(r=crypto.randomBytes(n*=4);a<n;)(i=r[a]+(r[a+1]<<8)+(r[a+2]<<16)+((127&r[a+3])<<24))>=214e7?crypto.randomBytes(4).copy(r,a):(u.push(i%1e7),a+=4);a=n/4}else for(;a<n;)u[a++]=1e7*Math.random()|0;for(e%=7,(n=u[--a])&&e&&(i=Xi(10,7-e),u[a]=(n/i|0)*i);0===u[a];a--)u.pop();if(a<0)t=0,u=[0];else{for(t=-1;0===u[0];t-=7)u.shift();for(n=1,i=u[0];i>=10;i/=10)n++;n<7&&(t-=7-n)}return o.e=t,o.d=u,o}function oo(e){return la(e=new this(e),e.e+1,this.rounding)}function uo(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function so(e){return new this(e).sin()}function co(e){return new this(e).sinh()}function lo(e){return new this(e).sqrt()}function fo(e,r){return new this(e).sub(r)}function mo(){var e=0,r=arguments,t=new this(r[e]);for(_i=!1;t.s&&++e<r.length;)t=t.plus(r[e]);return _i=!0,la(t,this.precision,this.rounding)}function po(e){return new this(e).tan()}function ho(e){return new this(e).tanh()}function vo(e){return la(e=new this(e),e.e+1,1)}ia[Symbol.for("nodejs.util.inspect.custom")]=ia.toString,ia[Symbol.toStringTag]="Decimal";var yo=ia.constructor=function e(r){var t,n,i;function a(e){var r,t,n,i=this;if(!(i instanceof a))return new a(e);if(i.constructor=a,Ga(e))return i.s=e.s,void(_i?!e.d||e.e>a.maxE?(i.e=NaN,i.d=null):e.e<a.minE?(i.e=0,i.d=[0]):(i.e=e.e,i.d=e.d.slice()):(i.e=e.e,i.d=e.d?e.d.slice():e.d));if("number"==(n=typeof e)){if(0===e)return i.s=1/e<0?-1:1,i.e=0,void(i.d=[0]);if(e<0?(e=-e,i.s=-1):i.s=1,e===~~e&&e<1e7){for(r=0,t=e;t>=10;t/=10)r++;return void(_i?r>a.maxE?(i.e=NaN,i.d=null):r<a.minE?(i.e=0,i.d=[0]):(i.e=r,i.d=[e]):(i.e=r,i.d=[e]))}return 0*e!=0?(e||(i.s=NaN),i.e=NaN,void(i.d=null)):Na(i,""+e)}if("string"===n)return 45===(t=e.charCodeAt(0))?(e=e.slice(1),i.s=-1):(43===t&&(e=e.slice(1)),i.s=1),ea.test(e)?Na(i,e):Aa(i,e);if("bigint"===n)return e<0?(e=-e,i.s=-1):i.s=1,Na(i,""+e);throw Error(Ji+e)}if(a.prototype=ia,a.ROUND_UP=0,a.ROUND_DOWN=1,a.ROUND_CEIL=2,a.ROUND_FLOOR=3,a.ROUND_HALF_UP=4,a.ROUND_HALF_DOWN=5,a.ROUND_HALF_EVEN=6,a.ROUND_HALF_CEIL=7,a.ROUND_HALF_FLOOR=8,a.EUCLID=9,a.config=a.set=La,a.clone=e,a.isDecimal=Ga,a.abs=Ba,a.acos=qa,a.acosh=Ta,a.add=ka,a.asin=Oa,a.asinh=Ia,a.atan=za,a.atanh=ja,a.atan2=Ra,a.cbrt=Ua,a.ceil=$a,a.clamp=Pa,a.cos=_a,a.cosh=Wa,a.div=Ja,a.exp=Va,a.floor=Ha,a.hypot=Za,a.ln=Xa,a.log=Ya,a.log10=Ka,a.log2=Qa,a.max=eo,a.min=ro,a.mod=to,a.mul=no,a.pow=io,a.random=ao,a.round=oo,a.sign=uo,a.sin=so,a.sinh=co,a.sqrt=lo,a.sub=fo,a.sum=mo,a.tan=po,a.tanh=ho,a.trunc=vo,void 0===r&&(r={}),r&&!0!==r.defaults)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<i.length;)r.hasOwnProperty(n=i[t++])||(r[n]=this[n]);return a.config(r),a}(Li);$i=new yo($i),Pi=new yo(Pi);var bo,go=ti("BigNumber",["?on","config"],(e=>{var{on:r,config:t}=e,n=yo.clone({precision:t.precision,modulo:yo.EUCLID});return n.prototype=Object.create(n.prototype),n.prototype.type="BigNumber",n.prototype.isBigNumber=!0,n.prototype.toJSON=function(){return{mathjs:"BigNumber",value:""+this}},n.fromJSON=function(e){return new n(e.value)},r&&r("config",(function(e,r){e.precision!==r.precision&&n.config({precision:e.precision})})),n}),{isClass:!0}),xo={exports:{}},wo=(bo||(bo=1,function(e){const r=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:.5*(Math.exp(e)+Math.exp(-e))},t=Math.sinh||function(e){return Math.abs(e)<1e-9?e:.5*(Math.exp(e)-Math.exp(-e))},n=function(e,r){return(e=Math.abs(e))<(r=Math.abs(r))&&([e,r]=[r,e]),e<1e8?Math.sqrt(e*e+r*r):e*Math.sqrt(1+(r/=e)*r)},i=function(){throw SyntaxError("Invalid Param")};function a(e,r){const t=Math.abs(e),n=Math.abs(r);return 0===e?Math.log(n):0===r?Math.log(t):t<3e3&&n<3e3?.5*Math.log(e*e+r*r):.5*Math.log((e*=.5)*e+(r*=.5)*r)+Math.LN2}const o={re:0,im:0},u=function(e,r){const t=o;if(null==e)t.re=t.im=0;else if(void 0!==r)t.re=e,t.im=r;else switch(typeof e){case"object":if("im"in e&&"re"in e)t.re=e.re,t.im=e.im;else if("abs"in e&&"arg"in e){if(!isFinite(e.abs)&&isFinite(e.arg))return s.INFINITY;t.re=e.abs*Math.cos(e.arg),t.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!isFinite(e.r)&&isFinite(e.phi))return s.INFINITY;t.re=e.r*Math.cos(e.phi),t.im=e.r*Math.sin(e.phi)}else 2===e.length?(t.re=e[0],t.im=e[1]):i();break;case"string":t.im=t.re=0;const r=e.replace(/_/g,"").match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g);let n=1,a=0;null===r&&i();for(let e=0;e<r.length;e++){const o=r[e];" "===o||"\t"===o||"\n"===o||("+"===o?n++:"-"===o?a++:"i"===o||"I"===o?(n+a===0&&i()," "===r[e+1]||isNaN(r[e+1])?t.im+=parseFloat((a%2?"-":"")+"1"):(t.im+=parseFloat((a%2?"-":"")+r[e+1]),e++),n=a=0):((n+a===0||isNaN(o))&&i(),"i"===r[e+1]||"I"===r[e+1]?(t.im+=parseFloat((a%2?"-":"")+o),e++):t.re+=parseFloat((a%2?"-":"")+o),n=a=0))}n+a>0&&i();break;case"number":t.im=0,t.re=e;break;default:i()}return t};function s(e,r){if(!(this instanceof s))return new s(e,r);const t=u(e,r);this.re=t.re,this.im=t.im}s.prototype={re:0,im:0,sign:function(){const e=n(this.re,this.im);return new s(this.re/e,this.im/e)},add:function(e,r){const t=u(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n||i?n&&i?s.NAN:s.INFINITY:new s(this.re+t.re,this.im+t.im)},sub:function(e,r){const t=u(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n||i?n&&i?s.NAN:s.INFINITY:new s(this.re-t.re,this.im-t.im)},mul:function(e,r){const t=u(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n&&0===t.re&&0===t.im||i&&0===this.re&&0===this.im?s.NAN:n||i?s.INFINITY:0===t.im&&0===this.im?new s(this.re*t.re,0):new s(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)},div:function(e,r){const t=u(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im)),a=0===this.re&&0===this.im,o=0===t.re&&0===t.im;if(a&&o||n&&i)return s.NAN;if(o||n)return s.INFINITY;if(a||i)return s.ZERO;if(0===t.im)return new s(this.re/t.re,this.im/t.re);if(Math.abs(t.re)<Math.abs(t.im)){const e=t.re/t.im,r=t.re*e+t.im;return new s((this.re*e+this.im)/r,(this.im*e-this.re)/r)}{const e=t.im/t.re,r=t.im*e+t.re;return new s((this.re+this.im*e)/r,(this.im-this.re*e)/r)}},pow:function(e,r){const t=u(e,r),n=0===this.re&&0===this.im;if(0===t.re&&0===t.im)return s.ONE;if(0===t.im){if(0===this.im&&this.re>0)return new s(Math.pow(this.re,t.re),0);if(0===this.re)switch((t.re%4+4)%4){case 0:return new s(Math.pow(this.im,t.re),0);case 1:return new s(0,Math.pow(this.im,t.re));case 2:return new s(-Math.pow(this.im,t.re),0);case 3:return new s(0,-Math.pow(this.im,t.re))}}if(n&&t.re>0)return s.ZERO;const i=Math.atan2(this.im,this.re),o=a(this.re,this.im);let c=Math.exp(t.re*o-t.im*i),l=t.im*o+t.re*i;return new s(c*Math.cos(l),c*Math.sin(l))},sqrt:function(){const e=this.re,r=this.im;if(0===r)return e>=0?new s(Math.sqrt(e),0):new s(0,Math.sqrt(-e));const t=n(e,r);let i=Math.sqrt(.5*(t+Math.abs(e))),a=Math.abs(r)/(2*i);return e>=0?new s(i,r<0?-a:a):new s(a,r<0?-i:i)},exp:function(){const e=Math.exp(this.re);return 0===this.im?new s(e,0):new s(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){const e=this.re,r=this.im;return new s(Math.expm1(e)*Math.cos(r)+(e=>{const r=Math.sin(.5*e);return-2*r*r})(r),Math.exp(e)*Math.sin(r))},log:function(){const e=this.re,r=this.im;return 0===r&&e>0?new s(Math.log(e),0):new s(a(e,r),Math.atan2(r,e))},abs:function(){return n(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){const e=this.re,n=this.im;return new s(Math.sin(e)*r(n),Math.cos(e)*t(n))},cos:function(){const e=this.re,n=this.im;return new s(Math.cos(e)*r(n),-Math.sin(e)*t(n))},tan:function(){const e=2*this.re,n=2*this.im,i=Math.cos(e)+r(n);return new s(Math.sin(e)/i,t(n)/i)},cot:function(){const e=2*this.re,n=2*this.im,i=Math.cos(e)-r(n);return new s(-Math.sin(e)/i,t(n)/i)},sec:function(){const e=this.re,n=this.im,i=.5*r(2*n)+.5*Math.cos(2*e);return new s(Math.cos(e)*r(n)/i,Math.sin(e)*t(n)/i)},csc:function(){const e=this.re,n=this.im,i=.5*r(2*n)-.5*Math.cos(2*e);return new s(Math.sin(e)*r(n)/i,-Math.cos(e)*t(n)/i)},asin:function(){const e=this.re,r=this.im,t=new s(r*r-e*e+1,-2*e*r).sqrt(),n=new s(t.re-r,t.im+e).log();return new s(n.im,-n.re)},acos:function(){const e=this.re,r=this.im,t=new s(r*r-e*e+1,-2*e*r).sqrt(),n=new s(t.re-r,t.im+e).log();return new s(Math.PI/2-n.im,n.re)},atan:function(){const e=this.re,r=this.im;if(0===e){if(1===r)return new s(0,1/0);if(-1===r)return new s(0,-1/0)}const t=e*e+(1-r)*(1-r),n=new s((1-r*r-e*e)/t,-2*e/t).log();return new s(-.5*n.im,.5*n.re)},acot:function(){const e=this.re,r=this.im;if(0===r)return new s(Math.atan2(1,e),0);const t=e*e+r*r;return 0!==t?new s(e/t,-r/t).atan():new s(0!==e?e/0:0,0!==r?-r/0:0).atan()},asec:function(){const e=this.re,r=this.im;if(0===e&&0===r)return new s(0,1/0);const t=e*e+r*r;return 0!==t?new s(e/t,-r/t).acos():new s(0!==e?e/0:0,0!==r?-r/0:0).acos()},acsc:function(){const e=this.re,r=this.im;if(0===e&&0===r)return new s(Math.PI/2,1/0);const t=e*e+r*r;return 0!==t?new s(e/t,-r/t).asin():new s(0!==e?e/0:0,0!==r?-r/0:0).asin()},sinh:function(){const e=this.re,n=this.im;return new s(t(e)*Math.cos(n),r(e)*Math.sin(n))},cosh:function(){const e=this.re,n=this.im;return new s(r(e)*Math.cos(n),t(e)*Math.sin(n))},tanh:function(){const e=2*this.re,n=2*this.im,i=r(e)+Math.cos(n);return new s(t(e)/i,Math.sin(n)/i)},coth:function(){const e=2*this.re,n=2*this.im,i=r(e)-Math.cos(n);return new s(t(e)/i,-Math.sin(n)/i)},csch:function(){const e=this.re,n=this.im,i=Math.cos(2*n)-r(2*e);return new s(-2*t(e)*Math.cos(n)/i,2*r(e)*Math.sin(n)/i)},sech:function(){const e=this.re,n=this.im,i=Math.cos(2*n)+r(2*e);return new s(2*r(e)*Math.cos(n)/i,-2*t(e)*Math.sin(n)/i)},asinh:function(){const e=this.re,r=this.im;if(0===r){if(0===e)return new s(0,0);const r=Math.abs(e),t=Math.log(r+Math.sqrt(r*r+1));return new s(e<0?-t:t,0)}const t=new s(e*e-r*r+1,2*e*r).sqrt();return new s(e+t.re,r+t.im).log()},acosh:function(){const e=this.re,r=this.im;if(0===r)return e>1?new s(Math.log(e+Math.sqrt(e-1)*Math.sqrt(e+1)),0):e<-1?new s(Math.log(-e+Math.sqrt(e*e-1)),Math.PI):new s(0,Math.acos(e));const t=new s(e-1,r).sqrt(),n=new s(e+1,r).sqrt();return new s(e+t.re*n.re-t.im*n.im,r+t.re*n.im+t.im*n.re).log()},atanh:function(){const e=this.re,r=this.im;if(0===r)return 0===e?new s(0,0):1===e?new s(1/0,0):-1===e?new s(-1/0,0):-1<e&&e<1?new s(.5*Math.log((1+e)/(1-e)),0):e>1?new s(.5*Math.log((e+1)/(e-1)),-Math.PI/2):new s(.5*Math.log(-(1+e)/(1-e)),Math.PI/2);const t=1-e,n=1+e,i=t*t+r*r;if(0===i)return new s(-1!==e?e/0:0,0!==r?r/0:0);const o=(n*t-r*r)/i,u=(r*t+n*r)/i;return new s(a(o,u)/2,Math.atan2(u,o)/2)},acoth:function(){const e=this.re,r=this.im;if(0===e&&0===r)return new s(0,Math.PI/2);const t=e*e+r*r;return 0!==t?new s(e/t,-r/t).atanh():new s(0!==e?e/0:0,0!==r?-r/0:0).atanh()},acsch:function(){const e=this.re,r=this.im;if(0===r){if(0===e)return new s(1/0,0);const r=1/e;return new s(Math.log(r+Math.sqrt(r*r+1)),0)}const t=e*e+r*r;return 0!==t?new s(e/t,-r/t).asinh():new s(0!==e?e/0:0,0!==r?-r/0:0).asinh()},asech:function(){const e=this.re,r=this.im;if(this.isZero())return s.INFINITY;const t=e*e+r*r;return 0!==t?new s(e/t,-r/t).acosh():new s(0!==e?e/0:0,0!==r?-r/0:0).acosh()},inverse:function(){if(this.isZero())return s.INFINITY;if(this.isInfinite())return s.ZERO;const e=this.re,r=this.im,t=e*e+r*r;return new s(e/t,-r/t)},conjugate:function(){return new s(this.re,-this.im)},neg:function(){return new s(-this.re,-this.im)},ceil:function(e){return new s(Math.ceil(this.re*(e=Math.pow(10,e||0)))/e,Math.ceil(this.im*e)/e)},floor:function(e){return new s(Math.floor(this.re*(e=Math.pow(10,e||0)))/e,Math.floor(this.im*e)/e)},round:function(e){return new s(Math.round(this.re*(e=Math.pow(10,e||0)))/e,Math.round(this.im*e)/e)},equals:function(e,r){const t=u(e,r);return Math.abs(t.re-this.re)<=s.EPSILON&&Math.abs(t.im-this.im)<=s.EPSILON},clone:function(){return new s(this.re,this.im)},toString:function(){let e=this.re,r=this.im,t="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<s.EPSILON&&(e=0),Math.abs(r)<s.EPSILON&&(r=0),0===r?t+e:(0!==e?(t+=e,t+=" ",r<0?(r=-r,t+="-"):t+="+",t+=" "):r<0&&(r=-r,t+="-"),1!==r&&(t+=r),t+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return 0===this.im?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return 0===this.im&&0===this.re},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!this.isFinite()}},s.ZERO=new s(0,0),s.ONE=new s(1,0),s.I=new s(0,1),s.PI=new s(Math.PI,0),s.E=new s(Math.E,0),s.INFINITY=new s(1/0,1/0),s.NAN=new s(NaN,NaN),s.EPSILON=1e-15,Object.defineProperty(s,"__esModule",{value:!0}),s.default=s,s.Complex=s,e.exports=s}(xo)),xo.exports),Do=Xn(wo),No=ti("Complex",[],(()=>(Object.defineProperty(Do,"name",{value:"Complex"}),Do.prototype.constructor=Do,Do.prototype.type="Complex",Do.prototype.isComplex=!0,Do.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Do.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Do.prototype.format=function(e){var r=this.im,t=this.re,n=di(this.re,e),i=di(this.im,e),a=en(e)?e:e?e.precision:null;if(null!==a){var o=Math.pow(10,-a);Math.abs(t/r)<o&&(t=0),Math.abs(r/t)<o&&(r=0)}return 0===r?n:0===t?1===r?"i":-1===r?"-i":i+"i":r<0?-1===r?n+" - i":n+" - "+i.substring(1)+"i":1===r?n+" + i":n+" + "+i+"i"},Do.fromPolar=function(e){switch(arguments.length){case 1:var r=arguments[0];if("object"==typeof r)return Do(r);throw new TypeError("Input has to be an object with r and phi keys.");case 2:var t=arguments[0],n=arguments[1];if(en(t)){if(on(n)&&n.hasBase("ANGLE")&&(n=n.toNumber("rad")),en(n))return new Do({r:t,phi:n});throw new TypeError("Phi is not a number nor an angle unit.")}throw new TypeError("Radius r is not a number.");default:throw new SyntaxError("Wrong number of arguments in function fromPolar")}},Do.prototype.valueOf=Do.prototype.toString,Do.fromJSON=function(e){return new Do(e)},Do.compare=function(e,r){return e.re>r.re?1:e.re<r.re?-1:e.im>r.im?1:e.im<r.im?-1:0},Do)),{isClass:!0});"undefined"==typeof BigInt&&(BigInt=function(e){if(isNaN(e))throw Error("");return e});const Ao=BigInt(0),Mo=BigInt(1),Co=BigInt(2),Eo=BigInt(3),So=BigInt(5),Fo=BigInt(10);BigInt(Number.MAX_SAFE_INTEGER);const Bo={s:Mo,n:Ao,d:Mo};function qo(e,r){try{e=BigInt(e)}catch(e){throw $o()}return e*r}function To(e){return"bigint"==typeof e?e:Math.floor(e)}function ko(e,r){if(r===Ao)throw Uo();const t=Object.create(Ro.prototype);t.s=e<Ao?-Mo:Mo;const n=jo(e=e<Ao?-e:e,r);return t.n=e/n,t.d=r/n,t}const Oo=[Co*Co,Co,Co*Co,Co,Co*Co,Co*Eo,Co,Co*Eo];function Io(e){const r=Object.create(null);if(e<=Mo)return r[e]=Mo,r;const t=e=>{r[e]=(r[e]||Ao)+Mo};for(;e%Co===Ao;)t(Co),e/=Co;for(;e%Eo===Ao;)t(Eo),e/=Eo;for(;e%So===Ao;)t(So),e/=So;for(let r=0,n=Co+So;n*n<=e;){for(;e%n===Ao;)t(n),e/=n;n+=Oo[r],r=r+1&7}return e>Mo&&t(e),r}const zo=function(e,r){let t=Ao,n=Mo,i=Mo;if(null==e);else if(void 0!==r){if("bigint"==typeof e)t=e;else{if(isNaN(e))throw $o();if(e%1!=0)throw Po();t=BigInt(e)}if("bigint"==typeof r)n=r;else{if(isNaN(r))throw $o();if(r%1!=0)throw Po();n=BigInt(r)}i=t*n}else if("object"==typeof e){if("d"in e&&"n"in e)t=BigInt(e.n),n=BigInt(e.d),"s"in e&&(t*=BigInt(e.s));else if(0 in e)t=BigInt(e[0]),1 in e&&(n=BigInt(e[1]));else{if("bigint"!=typeof e)throw $o();t=e}i=t*n}else if("number"==typeof e){if(isNaN(e))throw $o();if(e<0&&(i=-Mo,e=-e),e%1==0)t=BigInt(e);else{let r=1,i=0,a=1,o=1,u=1,s=1e7;for(e>=1&&(r=10**Math.floor(1+Math.log10(e)),e/=r);a<=s&&u<=s;){let r=(i+o)/(a+u);if(e===r){a+u<=s?(t=i+o,n=a+u):u>a?(t=o,n=u):(t=i,n=a);break}e>r?(i+=o,a+=u):(o+=i,u+=a),a>s?(t=o,n=u):(t=i,n=a)}t=BigInt(t)*BigInt(r),n=BigInt(n)}}else if("string"==typeof e){let r=0,a=Ao,o=Ao,u=Ao,s=Mo,c=Mo,l=e.replace(/_/g,"").match(/\d+|./g);if(null===l)throw $o();if("-"===l[r]?(i=-Mo,r++):"+"===l[r]&&r++,l.length===r+1?o=qo(l[r++],i):"."===l[r+1]||"."===l[r]?("."!==l[r]&&(a=qo(l[r++],i)),r++,(r+1===l.length||"("===l[r+1]&&")"===l[r+3]||"'"===l[r+1]&&"'"===l[r+3])&&(o=qo(l[r],i),s=Fo**BigInt(l[r].length),r++),("("===l[r]&&")"===l[r+2]||"'"===l[r]&&"'"===l[r+2])&&(u=qo(l[r+1],i),c=Fo**BigInt(l[r+1].length)-Mo,r+=3)):"/"===l[r+1]||":"===l[r+1]?(o=qo(l[r],i),s=qo(l[r+2],Mo),r+=3):"/"===l[r+3]&&" "===l[r+1]&&(a=qo(l[r],i),o=qo(l[r+2],i),s=qo(l[r+4],Mo),r+=5),!(l.length<=r))throw $o();n=s*c,i=t=u+n*a+c*o}else{if("bigint"!=typeof e)throw $o();t=e,i=e,n=Mo}if(n===Ao)throw Uo();Bo.s=i<Ao?-Mo:Mo,Bo.n=t<Ao?-t:t,Bo.d=n<Ao?-n:n};function jo(e,r){if(!e)return r;if(!r)return e;for(;;){if(!(e%=r))return r;if(!(r%=e))return e}}function Ro(e,r){if(zo(e,r),!(this instanceof Ro))return ko(Bo.s*Bo.n,Bo.d);e=jo(Bo.d,Bo.n),this.s=Bo.s,this.n=Bo.n/e,this.d=Bo.d/e}const Uo=function(){return Error("Division by Zero")},$o=function(){return Error("Invalid argument")},Po=function(){return Error("Parameters must be integer")};Ro.prototype={s:Mo,n:Ao,d:Mo,abs:function(){return ko(this.n,this.d)},neg:function(){return ko(-this.s*this.n,this.d)},add:function(e,r){return zo(e,r),ko(this.s*this.n*Bo.d+Bo.s*this.d*Bo.n,this.d*Bo.d)},sub:function(e,r){return zo(e,r),ko(this.s*this.n*Bo.d-Bo.s*this.d*Bo.n,this.d*Bo.d)},mul:function(e,r){return zo(e,r),ko(this.s*Bo.s*this.n*Bo.n,this.d*Bo.d)},div:function(e,r){return zo(e,r),ko(this.s*Bo.s*this.n*Bo.d,this.d*Bo.n)},clone:function(){return ko(this.s*this.n,this.d)},mod:function(e,r){if(void 0===e)return ko(this.s*this.n%this.d,Mo);if(zo(e,r),Ao===Bo.n*this.d)throw Uo();return ko(this.s*(Bo.d*this.n)%(Bo.n*this.d),Bo.d*this.d)},gcd:function(e,r){return zo(e,r),ko(jo(Bo.n,this.n)*jo(Bo.d,this.d),Bo.d*this.d)},lcm:function(e,r){return zo(e,r),Bo.n===Ao&&this.n===Ao?ko(Ao,Mo):ko(Bo.n*this.n,jo(Bo.n,this.n)*jo(Bo.d,this.d))},inverse:function(){return ko(this.s*this.d,this.n)},pow:function(e,r){if(zo(e,r),Bo.d===Mo)return Bo.s<Ao?ko((this.s*this.d)**Bo.n,this.n**Bo.n):ko((this.s*this.n)**Bo.n,this.d**Bo.n);if(this.s<Ao)return null;let t=Io(this.n),n=Io(this.d),i=Mo,a=Mo;for(let e in t)if("1"!==e){if("0"===e){i=Ao;break}if(t[e]*=Bo.n,t[e]%Bo.d!==Ao)return null;t[e]/=Bo.d,i*=BigInt(e)**t[e]}for(let e in n)if("1"!==e){if(n[e]*=Bo.n,n[e]%Bo.d!==Ao)return null;n[e]/=Bo.d,a*=BigInt(e)**n[e]}return Bo.s<Ao?ko(a,i):ko(i,a)},log:function(e,r){if(zo(e,r),this.s<=Ao||Bo.s<=Ao)return null;const t=Object.create(null),n=Io(Bo.n),i=Io(Bo.d),a=Io(this.n),o=Io(this.d);for(const e in i)n[e]=(n[e]||Ao)-i[e];for(const e in o)a[e]=(a[e]||Ao)-o[e];for(const e in n)"1"!==e&&(t[e]=!0);for(const e in a)"1"!==e&&(t[e]=!0);let u=null,s=null;for(const e in t){const r=n[e]||Ao,t=a[e]||Ao;if(r===Ao){if(t!==Ao)return null;continue}let i=t,o=r;const c=jo(i,o);if(i/=c,o/=c,null===u&&null===s)u=i,s=o;else if(i*s!=u*o)return null}return null!==u&&null!==s?ko(u,s):null},equals:function(e,r){return zo(e,r),this.s*this.n*Bo.d==Bo.s*Bo.n*this.d},lt:function(e,r){return zo(e,r),this.s*this.n*Bo.d<Bo.s*Bo.n*this.d},lte:function(e,r){return zo(e,r),this.s*this.n*Bo.d<=Bo.s*Bo.n*this.d},gt:function(e,r){return zo(e,r),this.s*this.n*Bo.d>Bo.s*Bo.n*this.d},gte:function(e,r){return zo(e,r),this.s*this.n*Bo.d>=Bo.s*Bo.n*this.d},compare:function(e,r){zo(e,r);let t=this.s*this.n*Bo.d-Bo.s*Bo.n*this.d;return(Ao<t)-(t<Ao)},ceil:function(e){return e=Fo**BigInt(e||0),ko(To(this.s*e*this.n/this.d)+(e*this.n%this.d>Ao&&this.s>=Ao?Mo:Ao),e)},floor:function(e){return e=Fo**BigInt(e||0),ko(To(this.s*e*this.n/this.d)-(e*this.n%this.d>Ao&&this.s<Ao?Mo:Ao),e)},round:function(e){return e=Fo**BigInt(e||0),ko(To(this.s*e*this.n/this.d)+this.s*((this.s>=Ao?Mo:Ao)+Co*(e*this.n%this.d)>this.d?Mo:Ao),e)},roundTo:function(e,r){zo(e,r);const t=this.n*Bo.d,n=this.d*Bo.n,i=t%n;let a=To(t/n);return i+i>=n&&a++,ko(this.s*a*Bo.n,Bo.d)},divisible:function(e,r){return zo(e,r),Bo.n!==Ao&&this.n*Bo.d%(Bo.n*this.d)===Ao},valueOf:function(){return Number(this.s*this.n)/Number(this.d)},toString:function(e=15){let r=this.n,t=this.d,n=function(e,r){for(;r%Co===Ao;r/=Co);for(;r%So===Ao;r/=So);if(r===Mo)return Ao;let t=Fo%r,n=1;for(;t!==Mo;n++)if(t=t*Fo%r,n>2e3)return Ao;return BigInt(n)}(0,t),i=function(e,r,t){let n=Mo,i=function(e,r,t){let n=Mo;for(;r>Ao;e=e*e%t,r>>=Mo)r&Mo&&(n=n*e%t);return n}(Fo,t,r);for(let e=0;e<300;e++){if(n===i)return BigInt(e);n=n*Fo%r,i=i*Fo%r}return 0}(0,t,n),a=this.s<Ao?"-":"";if(a+=To(r/t),r%=t,r*=Fo,r&&(a+="."),n){for(let e=i;e--;)a+=To(r/t),r%=t,r*=Fo;a+="(";for(let e=n;e--;)a+=To(r/t),r%=t,r*=Fo;a+=")"}else for(let n=e;r&&n--;)a+=To(r/t),r%=t,r*=Fo;return a},toFraction:function(e=!1){let r=this.n,t=this.d,n=this.s<Ao?"-":"";if(t===Mo)n+=r;else{const i=To(r/t);e&&i>Ao&&(n+=i,n+=" ",r%=t),n+=r,n+="/",n+=t}return n},toLatex:function(e=!1){let r=this.n,t=this.d,n=this.s<Ao?"-":"";if(t===Mo)n+=r;else{const i=To(r/t);e&&i>Ao&&(n+=i,r%=t),n+="\\frac{",n+=r,n+="}{",n+=t,n+="}"}return n},toContinued:function(){let e=this.n,r=this.d;const t=[];for(;r;){t.push(To(e/r));const n=e%r;e=r,r=n}return t},simplify:function(e=.001){const r=BigInt(Math.ceil(1/e)),t=this.abs(),n=t.toContinued();for(let e=1;e<n.length;e++){let i=ko(n[e-1],Mo);for(let r=e-2;r>=0;r--)i=i.inverse().add(n[r]);let a=i.sub(t);if(a.n*r<a.d)return i.mul(this.s)}return this}};var Lo=ti("Fraction",[],(()=>(Object.defineProperty(Ro,"name",{value:"Fraction"}),Ro.prototype.constructor=Ro,Ro.prototype.type="Fraction",Ro.prototype.isFraction=!0,Ro.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n+"",d:this.d+""}},Ro.fromJSON=function(e){return new Ro(e)},Ro)),{isClass:!0}),_o=ti("Range",[],(()=>{function e(r,t,n){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var i=null!=r,a=null!=t,o=null!=n;if(i)if(rn(r))r=r.toNumber();else if("number"!=typeof r&&!tn(r))throw new TypeError("Parameter start must be a number or bigint");if(a)if(rn(t))t=t.toNumber();else if("number"!=typeof t&&!tn(t))throw new TypeError("Parameter end must be a number or bigint");if(o)if(rn(n))n=n.toNumber();else if("number"!=typeof n&&!tn(n))throw new TypeError("Parameter step must be a number or bigint");if(this.start=i?parseFloat(r):0,this.end=a?parseFloat(t):0,this.step=o?parseFloat(n):1,o&&xi(this.step,0))throw Error("Step must not be zero")}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(r){if("string"!=typeof r)return null;var t=r.split(":").map((function(e){return parseFloat(e)}));if(t.some((function(e){return isNaN(e)})))return null;switch(t.length){case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[2],t[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var e=0,r=this.step,t=this.end-this.start;return oi(r)===oi(t)?e=Math.ceil(t/r):0===t&&(e=0),isNaN(e)&&(e=0),[e]},e.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},e.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},e.prototype.forEach=function(e){var r=this.start,t=this.step,n=this.end,i=0;if(t>0)for(;r<n;)e(r,[i],this),r+=t,i++;else if(t<0)for(;r>n;)e(r,[i],this),r+=t,i++},e.prototype.map=function(e){var r=[];return this.forEach((function(t,n,i){r[n[0]]=e(t,n,i)})),r},e.prototype.toArray=function(){var e=[];return this.forEach((function(r,t){e[t[0]]=r})),e},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(e){var r=di(this.start,e);return 1!==this.step&&(r+=":"+di(this.step,e)),r+":"+di(this.end,e)},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},e.fromJSON=function(r){return new e(r.start,r.end,r.step)},e}),{isClass:!0}),Wo=ti("Matrix",[],(()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(){throw Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(){throw Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(){throw Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(){throw Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(){throw Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(){throw Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(){throw Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(){throw Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(){throw Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw Error("Cannot invoke toString on a Matrix interface")},e}),{isClass:!0});function Jo(e,r,t){var n=new(0,e.constructor)(2),i="";if(t){if(t<1)throw Error("size must be in greater than 0");if(!ii(t))throw Error("size must be an integer");if(e.greaterThan(n.pow(t-1).sub(1))||e.lessThan(n.pow(t-1).mul(-1)))throw Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!e.isInteger())throw Error("Value must be an integer");e.lessThan(0)&&(e=e.add(n.pow(t))),i="i".concat(t)}switch(r){case 2:return"".concat(e.toBinary()).concat(i);case 8:return"".concat(e.toOctal()).concat(i);case 16:return"".concat(e.toHexadecimal()).concat(i);default:throw Error("Base ".concat(r," not supported "))}}function Vo(e,r){return void 0!==r?e.toExponential(r-1):e.toExponential()}function Ho(e,r){return en(e)?e:rn(e)?e.toNumber():r}function Zo(e,r){return e.substring(e.length-r.length,e.length)===r}function Go(e,r){var t=function(e,r){return"number"==typeof e?di(e,r):rn(e)?function(e,r){if("function"==typeof r)return r(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var{notation:t,precision:n,wordSize:i}=pi(r);switch(t){case"fixed":return function(e,r){return e.toFixed(r)}(e,n);case"exponential":return Vo(e,n);case"engineering":return function(e,r){var t=e.e,n=t%3==0?t:t<0?t-3-t%3:t-t%3,i=e.mul(Math.pow(10,-n)).toPrecision(r);return i.includes("e")&&(i=new(0,e.constructor)(i).toFixed()),i+"e"+(t>=0?"+":"")+n}(e,n);case"bin":return Jo(e,2,i);case"oct":return Jo(e,8,i);case"hex":return Jo(e,16,i);case"auto":var a=Ho(null==r?void 0:r.lowerExp,-3),o=Ho(null==r?void 0:r.upperExp,5);if(e.isZero())return"0";var u=e.toSignificantDigits(n),s=u.e;return(s>=a&&s<o?u.toFixed():Vo(e,n)).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],r=arguments[4];return"."!==e?e+r:r}));default:throw Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}(e,r):function(e){return e&&"object"==typeof e&&"bigint"==typeof e.s&&"bigint"==typeof e.n&&"bigint"==typeof e.d||!1}(e)?r&&"decimal"===r.fraction?""+e:"".concat(e.s*e.n,"/").concat(e.d):Array.isArray(e)?Ko(e,r):un(e)?Xo(e):"function"==typeof e?e.syntax?e.syntax+"":"function":e&&"object"==typeof e?"function"==typeof e.format?e.format(r):e&&e.toString(r)!==""+{}?e.toString(r):"{"+Object.keys(e).map((t=>Xo(t)+": "+Go(e[t],r))).join(", ")+"}":e+""}(e,r);return r&&"object"==typeof r&&"truncate"in r&&t.length>r.truncate?t.substring(0,r.truncate-3)+"...":t}function Xo(e){for(var r=e+"",t="",n=0;n<r.length;){var i=r.charAt(n);t+=i in Yo?Yo[i]:i,n++}return'"'+t+'"'}var Yo={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"};function Qo(e){var r=e+"";return r.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function Ko(e,r){if(Array.isArray(e)){for(var t="[",n=e.length,i=0;i<n;i++)0!==i&&(t+=", "),t+=Ko(e[i],r);return t+"]"}return Go(e,r)}function eu(e,r){if(!un(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+_n(e)+", index: 0)");if(!un(r))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+_n(r)+", index: 1)");return e===r?0:e>r?1:-1}function ru(e,r,t){if(!(this instanceof ru))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=r,this.relation=t,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(r)?"["+r.join(", ")+"]":r)+")",this.stack=Error().stack}function tu(e,r,t){if(!(this instanceof tu))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=r):(this.min=r,this.max=t),this.message=void 0!==this.min&&this.index<this.min?"Index out of range ("+this.index+" < "+this.min+")":void 0!==this.max&&this.index>=this.max?"Index out of range ("+this.index+" > "+(this.max-1)+")":"Index out of range ("+this.index+")",this.stack=Error().stack}function nu(e){for(var r=[];Array.isArray(e);)r.push(e.length),e=e[0];return r}function iu(e,r,t){var n,i=e.length;if(i!==r[t])throw new ru(i,r[t]);if(t<r.length-1){var a=t+1;for(n=0;n<i;n++){if(!Array.isArray(e[n]))throw new ru(r.length-1,r.length,"<");iu(e[n],r,a)}}else for(n=0;n<i;n++)if(Array.isArray(e[n]))throw new ru(r.length+1,r.length,">")}function au(e,r){if(0===r.length){if(Array.isArray(e))throw new ru(e.length,0)}else iu(e,r,0)}function ou(e,r){var t=e.isMatrix?e._size:nu(e);r._sourceSize.forEach(((e,r)=>{if(null!==e&&e!==t[r])throw new ru(e,t[r])}))}function uu(e,r){if(void 0!==e){if(!en(e)||!ii(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof r&&e>=r)throw new tu(e,r)}}function su(e){for(var r=0;r<e._dimensions.length;++r){var t=e._dimensions[r];if(t._data&&sn(t._data)){if(0===t._size[0])return!0}else if(t.isRange){if(t.start===t.end)return!0}else if(un(t)&&0===t.length)return!0}return!1}function cu(e,r,t){if(!Array.isArray(r))throw new TypeError("Array expected");if(0===r.length)throw Error("Resizing to scalar is not supported");return r.forEach((function(e){if(!en(e)||!ii(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Go(r)+")")})),(en(e)||rn(e))&&(e=[e]),lu(e,r,0,void 0!==t?t:0),e}function lu(e,r,t,n){var i,a,o=r[t],u=Math.min(e.length,o);if(e.length=o,t<r.length-1){var s=t+1;for(i=0;i<u;i++)Array.isArray(a=e[i])||(e[i]=a=[a]),lu(a,r,s,n);for(i=u;i<o;i++)e[i]=a=[],lu(a,r,s,n)}else{for(i=0;i<u;i++)for(;Array.isArray(e[i]);)e[i]=e[i][0];for(i=u;i<o;i++)e[i]=n}}function fu(e,r){var t=bu(e,!0),n=t.length;if(!Array.isArray(e)||!Array.isArray(r))throw new TypeError("Array expected");if(0===r.length)throw new ru(0,n,"!=");var i=du(r=mu(r,n));if(n!==i)throw new ru(i,n,"!=");try{return function(e,r){for(var t,n=e,i=r.length-1;i>0;i--){var a=r[i];t=[];for(var o=n.length/a,u=0;u<o;u++)t.push(n.slice(u*a,(u+1)*a));n=t}return n}(t,r)}catch(e){if(e instanceof ru)throw new ru(i,n,"!=");throw e}}function mu(e,r){var t=du(e),n=e.slice(),i=e.indexOf(-1);if(e.indexOf(-1,i+1)>=0)throw Error("More than one wildcard in sizes");if(i>=0){if(r%t!=0)throw Error("Could not replace wildcard, since "+r+" is no multiple of "+-t);n[i]=-r/t}return n}function du(e){return e.reduce(((e,r)=>e*r),1)}function pu(e){for(var r=nu(e);Array.isArray(e)&&1===e.length;)e=e[0],r.shift();for(var t=r.length;1===r[t-1];)t--;return t<r.length&&(e=hu(e,t,0),r.length=t),e}function hu(e,r,t){var n,i;if(t<r){var a=t+1;for(n=0,i=e.length;n<i;n++)e[n]=hu(e[n],r,a)}else for(;Array.isArray(e);)e=e[0];return e}function vu(e,r,t,n){var i=n||nu(e);if(t)for(var a=0;a<t;a++)e=[e],i.unshift(1);for(e=yu(e,r,0);i.length<r;)i.push(1);return e}function yu(e,r,t){var n,i;if(Array.isArray(e)){var a=t+1;for(n=0,i=e.length;n<i;n++)e[n]=yu(e[n],r,a)}else for(var o=t;o<r;o++)e=[e];return e}function bu(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!Array.isArray(e))return e;if("boolean"!=typeof r)throw new TypeError("Boolean expected for second argument of flatten");var t=[];return r?function e(r){if(Array.isArray(r[0]))for(var n=0;n<r.length;n++)e(r[n]);else for(var i=0;i<r.length;i++)t.push(r[i])}(e):function e(r){for(var n=0;n<r.length;n++){var i=r[n];Array.isArray(i)?e(i):t.push(i)}}(e),t}function gu(e,r){return Array.prototype.map.call(e,r)}function xu(e,r){Array.prototype.forEach.call(e,r)}function wu(e,r){if(1!==nu(e).length)throw Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,(e=>r.test(e)))}function Du(e,r){return Array.prototype.join.call(e,r)}function Nu(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;var r=[],t=0;r[0]={value:e[0],identifier:0};for(var n=1;n<e.length;n++)e[n]===e[n-1]?t++:t=0,r.push({value:e[n],identifier:t});return r}function Au(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;for(var r=[],t=0;t<e.length;t++)r.push(e[t].value);return r}function Mu(e,r){for(var t,n=0,i=0;i<e.length;i++){var a=e[i],o=Array.isArray(a);if(0===i&&o&&(n=a.length),o&&a.length!==n)return;var u=o?Mu(a,r):r(a);if(void 0===t)t=u;else if(t!==u)return"mixed"}return t}function Cu(e,r,t,n){if(n<t){if(e.length!==r.length)throw new ru(e.length,r.length);for(var i=[],a=0;a<e.length;a++)i[a]=Cu(e[a],r[a],t,n+1);return i}return e.concat(r)}function Eu(){var e=Array.prototype.slice.call(arguments,0,-1),r=Array.prototype.slice.call(arguments,-1);if(1===e.length)return e[0];if(e.length>1)return e.slice(1).reduce((function(e,t){return Cu(e,t,r,0)}),e[0]);throw Error("Wrong number of arguments in function concat")}function Su(){for(var e=arguments.length,r=Array(e),t=0;t<e;t++)r[t]=arguments[t];for(var n=r.map((e=>e.length)),i=Math.max(...n),a=Array(i).fill(null),o=0;o<r.length;o++)for(var u=r[o],s=n[o],c=0;c<s;c++){var l=i-s+c;u[c]>a[l]&&(a[l]=u[c])}for(var f=0;f<r.length;f++)Fu(r[f],a);return a}function Fu(e,r){for(var t=r.length,n=e.length,i=0;i<n;i++){var a=t-n+i;if(e[i]<r[a]&&e[i]>1||e[i]>r[a])throw Error("shape mismatch: mismatch is found in arg with shape (".concat(e,") not possible to broadcast dimension ").concat(n," with size ").concat(e[i]," to size ").concat(r[a]))}}function Bu(e,r){var t=nu(e);if(Vn(t,r))return e;Fu(t,r);var n=Su(t,r),i=n.length,a=[...Array(i-t.length).fill(1),...t],o=function(e){return Pt([],e)}(e);t.length<i&&(t=nu(o=fu(o,a)));for(var u=0;u<i;u++)t[u]<n[u]&&(t=nu(o=qu(o,n[u],u)));return o}function qu(e,r,t){return Eu(...Array(r).fill(e),t)}function Tu(e,r){if(!Array.isArray(e))throw Error("Array expected");var t=nu(e);if(r.length!==t.length)throw new ru(r.length,t.length);for(var n=0;n<r.length;n++)uu(r[n],t[n]);return r.reduce(((e,r)=>e[r]),e)}function ku(e,r){if(0===e.length)return[];if(arguments.length>2&&void 0!==arguments[2]&&arguments[2])return function e(t){if(Array.isArray(t)){for(var n=t.length,i=Array(n),a=0;a<n;a++)i[a]=e(t[a]);return i}return r(t)}(e);var t=[];return function n(i,a){if(Array.isArray(i)){for(var o=i.length,u=Array(o),s=0;s<o;s++)t[a]=s,u[s]=n(i[s],a+1);return u}return r(i,t.slice(0,a),e)}(e,0)}function Ou(e,r){if(0!==e.length)if(arguments.length>2&&void 0!==arguments[2]&&arguments[2])!function e(t){if(Array.isArray(t))for(var n=t.length,i=0;i<n;i++)e(t[i]);else r(t)}(e);else{var t=[];!function n(i,a){if(Array.isArray(i))for(var o=i.length,u=0;u<o;u++)t[a]=u,n(i[u],a+1);else r(i,t.slice(0,a),e)}(e,0)}}function Iu(e,r,t,n){if(ri.isTypedFunction(e)){var i,a;if(n)i=1;else{var o=(r.isMatrix?r.size():nu(r)).map((()=>0)),u=r.isMatrix?r.get(o):Tu(r,o);i=function(e,r,t,n){for(var i=[r,t,n],a=3;a>0;a--){var o=i.slice(0,a);if(null!==ri.resolve(e,o))return a}}(e,u,o,r)}if(r.isMatrix&&"mixed"!==r.dataType&&void 0!==r.dataType){var s=function(e,r){var t=[];if(Object.entries(e.signatures).forEach((e=>{var[n,i]=e;n.split(",").length===r&&t.push(i)})),1===t.length)return t[0]}(e,i);a=void 0!==s?s:e}else a=e;return i>=1&&i<=3?{isUnary:1===i,fn:function(){for(var r=arguments.length,n=Array(r),o=0;o<r;o++)n[o]=arguments[o];return ju(a,n.slice(0,i),t,e.name)}}:{isUnary:!1,fn:function(){for(var r=arguments.length,n=Array(r),i=0;i<r;i++)n[i]=arguments[i];return ju(a,n,t,e.name)}}}return void 0===n?{isUnary:zu(e),fn:e}:{isUnary:n,fn:e}}function zu(e){if(1!==e.length)return!1;var r=""+e;if(/arguments/.test(r))return!1;var t=r.match(/\(.*?\)/);return!/\.\.\./.test(t)}function ju(e,r,t,n){try{return e(...r)}catch(e){!function(e,r,t,n){var i;if(e instanceof TypeError&&"wrongType"===(null===(i=e.data)||void 0===i?void 0:i.category)){var a=[];throw a.push("value: ".concat(_n(r[0]))),r.length>=2&&a.push("index: ".concat(_n(r[1]))),r.length>=3&&a.push("array: ".concat(_n(r[2]))),new TypeError("Function ".concat(t," cannot apply callback arguments ")+"".concat(n,"(").concat(a.join(", "),") at index ").concat(JSON.stringify(r[1])))}throw new TypeError("Function ".concat(t," cannot apply callback arguments ")+"to function ".concat(n,": ").concat(e.message))}(e,r,t,n)}}(ru.prototype=new RangeError).constructor=RangeError,ru.prototype.name="DimensionError",ru.prototype.isDimensionError=!0,(tu.prototype=new RangeError).constructor=RangeError,tu.prototype.name="IndexError",tu.prototype.isIndexError=!0;var Ru=ti("DenseMatrix",["Matrix"],(e=>{var{Matrix:r}=e;function t(e,r){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(r&&!un(r))throw Error("Invalid datatype: "+r);if(cn(e))"DenseMatrix"===e.type?(this._data=Wn(e._data),this._size=Wn(e._size),this._datatype=r||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=r||e._datatype);else if(e&&sn(e.data)&&sn(e.size))this._data=e.data,this._size=e.size,au(this._data,this._size),this._datatype=r||e.datatype;else if(sn(e))this._data=a(e),this._size=nu(this._data),au(this._data,this._size),this._datatype=r;else{if(e)throw new TypeError("Unsupported type of data ("+_n(e)+")");this._data=[],this._size=[0],this._datatype=r}}function n(e,r,t){if(0===r.length){for(var n=e._data;sn(n);)n=n[0];return n}return e._size=r.slice(0),e._data=cu(e._data,e._size,t),e}function i(e,r,t){for(var i=e._size.slice(0),a=!1;i.length<r.length;)i.push(0),a=!0;for(var o=0,u=r.length;o<u;o++)r[o]>i[o]&&(i[o]=r[o],a=!0);a&&n(e,i,t)}function a(e){return cn(e)?a(e.valueOf()):sn(e)?e.map(a):e}return(t.prototype=new r).createDenseMatrix=function(e,r){return new t(e,r)},Object.defineProperty(t,"name",{value:"DenseMatrix"}),t.prototype.constructor=t,t.prototype.type="DenseMatrix",t.prototype.isDenseMatrix=!0,t.prototype.getDataType=function(){return Mu(this._data,_n)},t.prototype.storage=function(){return"dense"},t.prototype.datatype=function(){return this._datatype},t.prototype.create=function(e,r){return new t(e,r)},t.prototype.subset=function(e,r,n){switch(arguments.length){case 1:return function(e,r){if(!pn(r))throw new TypeError("Invalid index");if(r.isScalar())return e.get(r.min());var n=r.size();if(n.length!==e._size.length)throw new ru(n.length,e._size.length);for(var i=r.min(),a=r.max(),o=0,u=e._size.length;o<u;o++)uu(i[o],e._size[o]),uu(a[o],e._size[o]);var s=new t([]),c=function(e,r){var t=r.size().length-1,n=Array(t);return{data:function e(i){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=r.dimension(a);return n[a]=o.size()[0],a<t?o.map((r=>(uu(r,i.length),e(i[r],a+1)))).valueOf():o.map((e=>(uu(e,i.length),i[e]))).valueOf()}(e),size:n}}(e._data,r);return s._size=c.size,s._datatype=e._datatype,s._data=c.data,s}(this,e);case 2:case 3:return function(e,r,t,n){if(!r||!0!==r.isIndex)throw new TypeError("Invalid index");var a,o=r.size(),u=r.isScalar();if(cn(t)?(a=t.size(),t=t.valueOf()):a=nu(t),u){if(0!==a.length)throw new TypeError("Scalar expected");e.set(r.min(),t,n)}else{if(!Vn(a,o))try{a=nu(t=Bu(0===a.length?[t]:t,o))}catch(e){}if(o.length<e._size.length)throw new ru(o.length,e._size.length,"<");if(a.length<o.length){for(var s=0,c=0;1===o[s]&&1===a[s];)s++;for(;1===o[s];)c++,s++;t=vu(t,o.length,c,a)}if(!Vn(o,a))throw new ru(o,a,">");var l=r.max().map((function(e){return e+1}));i(e,l,n),function(e,r,t){var n=r.size().length-1;!function e(t,i){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;r.dimension(a).forEach(a<n?(r,n)=>{uu(r,t.length),e(t[r],i[n[0]],a+1)}:(e,r)=>{uu(e,t.length),t[e]=i[r[0]]})}(e,t)}(e._data,r,t)}return e}(this,e,r,n);default:throw new SyntaxError("Wrong number of arguments")}},t.prototype.get=function(e){return Tu(this._data,e)},t.prototype.set=function(e,r,t){if(!sn(e))throw new TypeError("Array expected");if(e.length<this._size.length)throw new ru(e.length,this._size.length,"<");var n,a,o,u=e.map((function(e){return e+1}));i(this,u,t);var s=this._data;for(n=0,a=e.length-1;n<a;n++)uu(o=e[n],s.length),s=s[o];return uu(o=e[e.length-1],s.length),s[o]=r,this},t.prototype.resize=function(e,r,t){if(!ln(e))throw new TypeError("Array or Matrix expected");var i=e.valueOf().map((e=>Array.isArray(e)&&1===e.length?e[0]:e));return n(t?this.clone():this,i,r)},t.prototype.reshape=function(e,r){var t=r?this.clone():this;t._data=fu(t._data,e);var n=t._size.reduce(((e,r)=>e*r));return t._size=mu(e,n),t},t.prototype.clone=function(){return new t({data:Wn(this._data),size:Wn(this._size),datatype:this._datatype})},t.prototype.size=function(){return this._size.slice(0)},t.prototype.map=function(e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],t=this,n=t._size.length-1;if(n<0)return t.clone();var i=Iu(e,t,"map",r),a=i.fn,o=t.create(void 0,t._datatype);if(o._size=t._size,r||i.isUnary)return o._data=function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=Array(r.length);if(t<n)for(var o=0;o<r.length;o++)i[o]=e(r[o],t+1);else for(var u=0;u<r.length;u++)i[u]=a(r[u]);return i}(t._data),o;if(0===n){for(var u=t.valueOf(),s=Array(u.length),c=0;c<u.length;c++)s[c]=a(u[c],[c],t);return o._data=s,o}var l=[];return o._data=function e(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=Array(r.length);if(i<n)for(var u=0;u<r.length;u++)l[i]=u,o[u]=e(r[u],i+1);else for(var s=0;s<r.length;s++)l[i]=s,o[s]=a(r[s],l.slice(),t);return o}(t._data),o},t.prototype.forEach=function(e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],t=this,n=t._size.length-1;if(!(n<0)){var i=Iu(e,t,"map",r),a=i.fn;if(r||i.isUnary)!function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(t<n)for(var i=0;i<r.length;i++)e(r[i],t+1);else for(var o=0;o<r.length;o++)a(r[o])}(t._data);else if(0!==n){var o=[];!function e(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(i<n)for(var u=0;u<r.length;u++)o[i]=u,e(r[u],i+1);else for(var s=0;s<r.length;s++)o[i]=s,a(r[s],o.slice(),t)}(t._data)}else for(var u=0;u<t._data.length;u++)a(t._data[u],[u],t)}},t.prototype[Symbol.iterator]=function*(){var e=this._size.length-1;if(!(e<0))if(0!==e)for(var r=Array(e+1).fill(0),t=this._size.reduce(((e,r)=>e*r),1),n=0;n<t;n++){for(var i=this._data,a=0;a<e;a++)i=i[r[a]];yield{value:i[r[e]],index:r.slice()};for(var o=e;o>=0&&(r[o]++,!(r[o]<this._size[o]));o--)r[o]=0}else for(var u=0;u<this._data.length;u++)yield{value:this._data[u],index:[u]}},t.prototype.rows=function(){var e=[];if(2!==this.size().length)throw new TypeError("Rows can only be returned for a 2D matrix.");var r=this._data;for(var n of r)e.push(new t([n],this._datatype));return e},t.prototype.columns=function(){var e=this,r=[],n=this.size();if(2!==n.length)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var i=this._data,a=function(n){var a=i.map((e=>[e[n]]));r.push(new t(a,e._datatype))},o=0;o<n[1];o++)a(o);return r},t.prototype.toArray=function(){return Wn(this._data)},t.prototype.valueOf=function(){return this._data},t.prototype.format=function(e){return Go(this._data,e)},t.prototype.toString=function(){return Go(this._data)},t.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},t.prototype.diagonal=function(e){if(e){if(rn(e)&&(e=e.toNumber()),!en(e)||!ii(e))throw new TypeError("The parameter k must be an integer number")}else e=0;for(var r=e>0?e:0,n=e<0?-e:0,i=Math.min(this._size[0]-n,this._size[1]-r),a=[],o=0;o<i;o++)a[o]=this._data[o+n][o+r];return new t({data:a,size:[i],datatype:this._datatype})},t.diagonal=function(e,r,n,i){if(!sn(e))throw new TypeError("Array expected, size parameter");if(2!==e.length)throw Error("Only two dimensions matrix are supported");if(e=e.map((function(e){if(rn(e)&&(e=e.toNumber()),!en(e)||!ii(e)||e<1)throw Error("Size values must be positive integers");return e})),n){if(rn(n)&&(n=n.toNumber()),!en(n)||!ii(n))throw new TypeError("The parameter k must be an integer number")}else n=0;var a,o=n>0?n:0,u=n<0?-n:0,s=e[0],c=e[1],l=Math.min(s-u,c-o);if(sn(r)){if(r.length!==l)throw Error("Invalid value array length");a=function(e){return r[e]}}else if(cn(r)){var f=r.size();if(1!==f.length||f[0]!==l)throw Error("Invalid matrix length");a=function(e){return r.get([e])}}else a=function(){return r};i||(i=rn(a(0))?a(0).mul(0):0);var m=[];if(e.length>0){m=cu(m,e,i);for(var d=0;d<l;d++)m[d+u][d+o]=a(d)}return new t({data:m,size:[s,c]})},t.fromJSON=function(e){return new t(e)},t.prototype.swapRows=function(e,r){if(!(en(e)&&ii(e)&&en(r)&&ii(r)))throw Error("Row index must be positive integers");if(2!==this._size.length)throw Error("Only two dimensional matrix is supported");return uu(e,this._size[0]),uu(r,this._size[0]),t._swapRows(e,r,this._data),this},t._swapRows=function(e,r,t){var n=t[e];t[e]=t[r],t[r]=n},t}),{isClass:!0}),Uu="clone",$u=ti(Uu,["typed"],(e=>{var{typed:r}=e;return r(Uu,{any:Wn})}));function Pu(e){var r,t,n=e.length,i=e[0].length,a=[];for(t=0;t<i;t++){var o=[];for(r=0;r<n;r++)o.push(e[r][t]);a.push(o)}return a}function Lu(e){for(var r=0;r<e.length;r++)if(ln(e[r]))return!0;return!1}function _u(e,r){cn(e)?e.forEach((e=>r(e)),!1,!0):Ou(e,r,!0)}function Wu(e,r,t){if(!t)return cn(e)?e.map((e=>r(e)),!1,!0):ku(e,r,!0);var n=e=>0===e?e:r(e);return cn(e)?e.map((e=>n(e)),!1,!0):ku(e,n,!0)}function Ju(e,r,t){var n=Array.isArray(e)?nu(e):e.size();if(r<0||r>=n.length)throw new tu(r,n.length);return cn(e)?e.create(Vu(e.valueOf(),r,t),e.datatype()):Vu(e,r,t)}function Vu(e,r,t){var n,i,a,o;if(r<=0){if(Array.isArray(e[0])){for(o=Pu(e),i=[],n=0;n<o.length;n++)i[n]=Vu(o[n],r-1,t);return i}for(a=e[0],n=1;n<e.length;n++)a=t(a,e[n]);return a}for(i=[],n=0;n<e.length;n++)i[n]=Vu(e[n],r-1,t);return i}function Hu(e,r,t,n,i,a,o,u){var s,c,l,f=e._values,m=e._index,d=e._ptr;if(n)for(c=d[r+1],s=d[r];s<c;s++)t[l=m[s]]!==a?(t[l]=a,o.push(l),n[l]=f[s]):(n[l]=u(n[l],f[s]),i[l]=a);else for(c=d[r+1],s=d[r];s<c;s++)t[l=m[s]]!==a?(t[l]=a,o.push(l)):i[l]=a}var Zu="isInteger",Gu=ti(Zu,["typed"],(e=>{var{typed:r}=e;return r(Zu,{number:ii,BigNumber:function(e){return e.isInt()},bigint:function(){return!0},Fraction:function(e){return 1n===e.d},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Xu="number",Yu="number, number";function Qu(e){return Math.abs(e)}function Ku(e,r){return e+r}function es(e,r){return e-r}function rs(e,r){return e*r}function ts(e){return-e}function ns(e){return e}function is(e){return li(e)}function as(e){return e*e*e}function os(e){return Math.exp(e)}function us(e){return fi(e)}function ss(e,r){if(!ii(e)||!ii(r))throw Error("Parameters in function lcm must be integer numbers");if(0===e||0===r)return 0;for(var t,n=e*r;0!==r;)r=e%(t=r),e=t;return Math.abs(n/e)}function cs(e,r){return r?Math.log(e)/Math.log(r):Math.log(e)}function ls(e){return si(e)}function fs(e){return ui(e)}function ms(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,t=r<0;if(t&&(r=-r),0===r)throw Error("Root must be non-zero");if(e<0&&Math.abs(r)%2!=1)throw Error("Root must be odd when a is negative.");if(0===e)return t?1/0:0;if(!isFinite(e))return t?0:e;var n=Math.pow(Math.abs(e),1/r);return n=e<0?-n:n,t?1/n:n}function ds(e){return oi(e)}function ps(e){return e*e}function hs(e,r){var t,n,i,a=0,o=1,u=1,s=0;if(!ii(e)||!ii(r))throw Error("Parameters in function xgcd must be integer numbers");for(;r;)i=e-(n=Math.floor(e/r))*r,t=a,a=o-n*a,o=t,t=u,u=s-n*u,s=t,e=r,r=i;return e<0?[-e,-o,-s]:[e,e?o:0,s]}function vs(e,r){return e*e<1&&r===1/0||e*e>1&&r===-1/0?0:Math.pow(e,r)}function ys(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!ii(r)||r<0||r>15)throw Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(vi(e,r))}Qu.signature=Xu,Ku.signature=Yu,es.signature=Yu,rs.signature=Yu,ts.signature=Xu,ns.signature=Xu,is.signature=Xu,as.signature=Xu,os.signature=Xu,us.signature=Xu,ss.signature=Yu,ls.signature=Xu,fs.signature=Xu,ds.signature=Xu,ps.signature=Xu,hs.signature=Yu,vs.signature=Yu;var bs="number, number";function gs(e,r){if(!ii(e)||!ii(r))throw Error("Integers expected in function bitAnd");return e&r}function xs(e){if(!ii(e))throw Error("Integer expected in function bitNot");return~e}function ws(e,r){if(!ii(e)||!ii(r))throw Error("Integers expected in function bitOr");return e|r}function Ds(e,r){if(!ii(e)||!ii(r))throw Error("Integers expected in function bitXor");return e^r}function Ns(e,r){if(!ii(e)||!ii(r))throw Error("Integers expected in function leftShift");return e<<r}function As(e,r){if(!ii(e)||!ii(r))throw Error("Integers expected in function rightArithShift");return e>>r}function Ms(e,r){if(!ii(e)||!ii(r))throw Error("Integers expected in function rightLogShift");return e>>>r}function Cs(e,r){if(r<e)return 1;if(r===e)return r;var t=r+e>>1;return Cs(e,t)*Cs(t+1,r)}function Es(e,r){if(!ii(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!ii(r)||r<0)throw new TypeError("Positive integer value expected in function combinations");if(r>e)throw new TypeError("k must be less than or equal to n");for(var t=e-r,n=1,i=2,a=r<t?r:t,o=r<t?t+1:r+1;o<=e;++o)for(n*=o;i<=a&&n%i==0;)n/=i,++i;return i<=a&&(n/=Cs(i,a)),n}gs.signature=bs,xs.signature="number",ws.signature=bs,Ds.signature=bs,Ns.signature=bs,As.signature=bs,Ms.signature=bs,Es.signature="number, number";var Ss=Math.PI,Fs=2*Math.PI,Bs=Math.E,qs="number, number";function Ts(e){return!e}function ks(e,r){return!(!e&&!r)}function Os(e,r){return!!e!=!!r}function Is(e,r){return!(!e||!r)}function zs(e){var r;if(ii(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:Cs(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*zs(1-e));if(e>=171.35)return 1/0;if(e>85){var t=e*e,n=t*e,i=n*e,a=i*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*t)-139/(51840*n)-571/(2488320*i)+163879/(209018880*a)+5246819/(75246796800*a*e))}--e,r=Rs[0];for(var o=1;o<Rs.length;++o)r+=Rs[o]/(e+o);var u=e+js+.5;return 2.5066282746310002*Math.pow(u,e+.5)*Math.exp(-u)*r}Ts.signature="number",ks.signature=qs,Os.signature=qs,Is.signature=qs,zs.signature="number";var js=4.7421875,Rs=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],Us=.9189385332046728,$s=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function Ps(e){if(e<0)return NaN;if(0===e)return 1/0;if(!isFinite(e))return e;if(e<.5)return Math.log(Math.PI/Math.sin(Math.PI*e))-Ps(1-e);for(var r=5+(e-=1)+.5,t=$s[0],n=6;n>=1;n--)t+=$s[n]/(e+n);return Us+(e+.5)*Math.log(r)-r+Math.log(t)}Ps.signature="number";var Ls="number";function _s(e){return wi(e)}function Ws(e){return Math.atan(1/e)}function Js(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}function Vs(e){return Math.asin(1/e)}function Hs(e){var r=1/e;return Math.log(r+Math.sqrt(r*r+1))}function Zs(e){return Math.acos(1/e)}function Gs(e){var r=1/e;return Math.log(Math.sqrt(r*r-1)+r)}function Xs(e){return Di(e)}function Ys(e){return Ni(e)}function Qs(e){return 1/Math.tan(e)}function Ks(e){var r=Math.exp(2*e);return(r+1)/(r-1)}function ec(e){return 1/Math.sin(e)}function rc(e){return 0===e?1/0:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*oi(e)}function tc(e){return 1/Math.cos(e)}function nc(e){return 2/(Math.exp(e)+Math.exp(-e))}function ic(e){return Mi(e)}_s.signature=Ls,Ws.signature=Ls,Js.signature=Ls,Vs.signature=Ls,Hs.signature=Ls,Zs.signature=Ls,Gs.signature=Ls,Xs.signature=Ls,Ys.signature=Ls,Qs.signature=Ls,Ks.signature=Ls,ec.signature=Ls,rc.signature=Ls,tc.signature=Ls,nc.signature=Ls,ic.signature=Ls;var ac="number";function oc(e){return e<0}function uc(e){return e>0}function sc(e){return Number.isNaN(e)}function cc(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e-9,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(t<=0)throw Error("Relative tolerance must be greater than 0");if(n<0)throw Error("Absolute tolerance must be at least 0");return!e.isNaN()&&!r.isNaN()&&(e.isFinite()&&r.isFinite()?!!e.eq(r)||e.minus(r).abs().lte(e.constructor.max(e.constructor.max(e.abs(),r.abs()).mul(t),n)):e.eq(r))}oc.signature=ac,uc.signature=ac,sc.signature=ac;var lc="isNegative",fc=ti(lc,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(lc,{number:e=>!xi(e,0,t.relTol,t.absTol)&&oc(e),BigNumber:e=>!cc(e,new e.constructor(0),t.relTol,t.absTol)&&e.isNeg()&&!e.isZero()&&!e.isNaN(),bigint:e=>e<0n,Fraction:e=>e.s<0n,Unit:r.referToSelf((e=>t=>r.find(e,t.valueType())(t.value))),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),mc="isNumeric",dc=ti(mc,["typed"],(e=>{var{typed:r}=e;return r(mc,{"number | BigNumber | bigint | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),pc="hasNumericValue",hc=ti(pc,["typed","isNumeric"],(e=>{var{typed:r,isNumeric:t}=e;return r(pc,{boolean:()=>!0,string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return t(e)}})})),vc="isPositive",yc=ti(vc,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(vc,{number:e=>!xi(e,0,t.relTol,t.absTol)&&uc(e),BigNumber:e=>!(cc(e,new e.constructor(0),t.relTol,t.absTol)||e.isNeg()||e.isZero()||e.isNaN()),bigint:e=>e>0n,Fraction:e=>e.s>0n&&e.n>0n,Unit:r.referToSelf((e=>t=>r.find(e,t.valueType())(t.value))),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),bc="isZero",gc=ti(bc,["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return r(bc,{"number | BigNumber | Complex | Fraction":e=>t(e,0),bigint:e=>0n===e,Unit:r.referToSelf((e=>t=>r.find(e,t.valueType())(t.value))),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),xc="isNaN",wc=ti(xc,["typed"],(e=>{var{typed:r}=e;return r(xc,{number:sc,BigNumber:function(e){return e.isNaN()},bigint:function(){return!1},Fraction:function(){return!1},Complex:function(e){return e.isNaN()},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Dc="typeOf",Nc=ti(Dc,["typed"],(e=>{var{typed:r}=e;return r(Dc,{any:_n})})),Ac=ti("compareUnits",["typed"],(e=>{var{typed:r}=e;return{"Unit, Unit":r.referToSelf((e=>(t,n)=>{if(!t.equalBase(n))throw Error("Cannot compare units with different base");return r.find(e,[t.valueType(),n.valueType()])(t.value,n.value)}))}})),Mc="equalScalar",Cc=ti(Mc,["typed","config"],(e=>{var{typed:r,config:t}=e,n=Ac({typed:r});return r(Mc,{"boolean, boolean":function(e,r){return e===r},"number, number":function(e,r){return xi(e,r,t.relTol,t.absTol)},"BigNumber, BigNumber":function(e,r){return e.eq(r)||cc(e,r,t.relTol,t.absTol)},"bigint, bigint":function(e,r){return e===r},"Fraction, Fraction":function(e,r){return e.equals(r)},"Complex, Complex":function(e,r){return function(e,r,t,n){return xi(e.re,r.re,t,n)&&xi(e.im,r.im,t,n)}(e,r,t.relTol,t.absTol)}},n)}));ti(Mc,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(Mc,{"number, number":function(e,r){return xi(e,r,t.relTol,t.absTol)}})}));var Ec=ti("SparseMatrix",["typed","equalScalar","Matrix"],(e=>{var{typed:r,equalScalar:t,Matrix:n}=e;function i(e,r){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(r&&!un(r))throw Error("Invalid datatype: "+r);if(cn(e))!function(e,r,t){"SparseMatrix"===r.type?(e._values=r._values?Wn(r._values):void 0,e._index=Wn(r._index),e._ptr=Wn(r._ptr),e._size=Wn(r._size),e._datatype=t||r._datatype):a(e,r.valueOf(),t||r._datatype)}(this,e,r);else if(e&&sn(e.index)&&sn(e.ptr)&&sn(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=r||e.datatype;else if(sn(e))a(this,e,r);else{if(e)throw new TypeError("Unsupported type of data ("+_n(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=r}}function a(e,n,i){e._values=[],e._index=[],e._ptr=[],e._datatype=i;var a=n.length,o=0,u=t,s=0;if(un(i)&&(u=r.find(t,[i,i])||t,s=r.convert(0,i)),a>0){var c=0;do{e._ptr.push(e._index.length);for(var l=0;l<a;l++){var f=n[l];if(sn(f)){if(0===c&&o<f.length&&(o=f.length),c<f.length){var m=f[c];u(m,s)||(e._values.push(m),e._index.push(l))}}else 0===c&&o<1&&(o=1),u(f,s)||(e._values.push(f),e._index.push(l))}c++}while(c<o)}e._ptr.push(e._index.length),e._size=[a,o]}function o(e,r,t,n){if(t-r==0)return t;for(var i=r;i<t;i++)if(n[i]===e)return i;return r}function u(e,r,t,n,i,a,o){i.splice(e,0,n),a.splice(e,0,r);for(var u=t+1;u<o.length;u++)o[u]++}function s(e,n,i,a){var o=a||0,u=t,s=0;un(e._datatype)&&(u=r.find(t,[e._datatype,e._datatype])||t,s=r.convert(0,e._datatype),o=r.convert(o,e._datatype));var c,l,f,m=!u(o,s),d=e._size[0],p=e._size[1];if(i>p){for(l=p;l<i;l++)if(e._ptr[l]=e._values.length,m)for(c=0;c<d;c++)e._values.push(o),e._index.push(c);e._ptr[i]=e._values.length}else i<p&&(e._ptr.splice(i+1,p-i),e._values.splice(e._ptr[i],e._values.length),e._index.splice(e._ptr[i],e._index.length));if(p=i,n>d){if(m){var h=0;for(l=0;l<p;l++){e._ptr[l]=e._ptr[l]+h,f=e._ptr[l+1]+h;var v=0;for(c=d;c<n;c++,v++)e._values.splice(f+v,0,o),e._index.splice(f+v,0,c),h++}e._ptr[p]=e._values.length}}else if(n<d){var y=0;for(l=0;l<p;l++){e._ptr[l]=e._ptr[l]-y;var b=e._ptr[l+1]-y;for(f=e._ptr[l];f<b;f++)(c=e._index[f])>n-1&&(e._values.splice(f,1),e._index.splice(f,1),y++)}e._ptr[l]=e._values.length}return e._size[0]=n,e._size[1]=i,e}function c(e,r,t,n,i){var a,o,u=n[0],s=n[1],c=[];for(a=0;a<u;a++)for(c[a]=[],o=0;o<s;o++)c[a][o]=0;for(o=0;o<s;o++)for(var l=t[o+1],f=t[o];f<l;f++)c[a=r[f]][o]=e?i?Wn(e[f]):e[f]:1;return c}return(i.prototype=new n).createSparseMatrix=function(e,r){return new i(e,r)},Object.defineProperty(i,"name",{value:"SparseMatrix"}),i.prototype.constructor=i,i.prototype.type="SparseMatrix",i.prototype.isSparseMatrix=!0,i.prototype.getDataType=function(){return Mu(this._values,_n)},i.prototype.storage=function(){return"sparse"},i.prototype.datatype=function(){return this._datatype},i.prototype.create=function(e,r){return new i(e,r)},i.prototype.density=function(){var e=this._size[0],r=this._size[1];return 0!==e&&0!==r?this._index.length/(e*r):0},i.prototype.subset=function(e,r,t){if(!this._values)throw Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return function(e,r){if(!pn(r))throw new TypeError("Invalid index");if(r.isScalar())return e.get(r.min());var t,n,a,o,u=r.size();if(u.length!==e._size.length)throw new ru(u.length,e._size.length);var s=r.min(),c=r.max();for(t=0,n=e._size.length;t<n;t++)uu(s[t],e._size[t]),uu(c[t],e._size[t]);var l=e._values,f=e._index,m=e._ptr,d=r.dimension(0),p=r.dimension(1),h=[],v=[];d.forEach((function(e,r){v[e]=r[0],h[e]=!0}));var y=l?[]:void 0,b=[],g=[];return p.forEach((function(e){for(g.push(b.length),a=m[e],o=m[e+1];a<o;a++)!0===h[t=f[a]]&&(b.push(v[t]),y&&y.push(l[a]))})),g.push(b.length),new i({values:y,index:b,ptr:g,size:u,datatype:e._datatype})}(this,e);case 2:case 3:return function(e,r,t,n){if(!r||!0!==r.isIndex)throw new TypeError("Invalid index");var i,a=r.size(),o=r.isScalar();if(cn(t)?(i=t.size(),t=t.toArray()):i=nu(t),o){if(0!==i.length)throw new TypeError("Scalar expected");e.set(r.min(),t,n)}else{if(1!==a.length&&2!==a.length)throw new ru(a.length,e._size.length,"<");if(i.length<a.length){for(var u=0,s=0;1===a[u]&&1===i[u];)u++;for(;1===a[u];)s++,u++;t=vu(t,a.length,s,i)}if(!Vn(a,i))throw new ru(a,i,">");if(1===a.length)r.dimension(0).forEach((function(r,i){uu(r),e.set([r,0],t[i[0]],n)}));else{var c=r.dimension(0),l=r.dimension(1);c.forEach((function(r,i){uu(r),l.forEach((function(a,o){uu(a),e.set([r,a],t[i[0]][o[0]],n)}))}))}}return e}(this,e,r,t);default:throw new SyntaxError("Wrong number of arguments")}},i.prototype.get=function(e){if(!sn(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new ru(e.length,this._size.length);if(!this._values)throw Error("Cannot invoke get on a Pattern only matrix");var r=e[0],t=e[1];uu(r,this._size[0]),uu(t,this._size[1]);var n=o(r,this._ptr[t],this._ptr[t+1],this._index);return n<this._ptr[t+1]&&this._index[n]===r?this._values[n]:0},i.prototype.set=function(e,n,i){if(!sn(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new ru(e.length,this._size.length);if(!this._values)throw Error("Cannot invoke set on a Pattern only matrix");var a=e[0],c=e[1],l=this._size[0],f=this._size[1],m=t,d=0;un(this._datatype)&&(m=r.find(t,[this._datatype,this._datatype])||t,d=r.convert(0,this._datatype)),(a>l-1||c>f-1)&&(s(this,Math.max(a+1,l),Math.max(c+1,f),i),l=this._size[0],f=this._size[1]),uu(a,l),uu(c,f);var p=o(a,this._ptr[c],this._ptr[c+1],this._index);return p<this._ptr[c+1]&&this._index[p]===a?m(n,d)?function(e,r,t,n,i){t.splice(e,1),n.splice(e,1);for(var a=r+1;a<i.length;a++)i[a]--}(p,c,this._values,this._index,this._ptr):this._values[p]=n:m(n,d)||u(p,a,c,n,this._values,this._index,this._ptr),this},i.prototype.resize=function(e,r,t){if(!ln(e))throw new TypeError("Array or Matrix expected");var n=e.valueOf().map((e=>Array.isArray(e)&&1===e.length?e[0]:e));if(2!==n.length)throw Error("Only two dimensions matrix are supported");return n.forEach((function(e){if(!en(e)||!ii(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Go(n)+")")})),s(t?this.clone():this,n[0],n[1],r)},i.prototype.reshape=function(e,r){if(!sn(e))throw new TypeError("Array expected");if(2!==e.length)throw Error("Sparse matrices can only be reshaped in two dimensions");e.forEach((function(r){if(!en(r)||!ii(r)||r<=-2||0===r)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Go(e)+")")}));var t=this._size[0]*this._size[1];if(t!==(e=mu(e,t))[0]*e[1])throw Error("Reshaping sparse matrix will result in the wrong number of elements");var n=r?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return n;for(var i=[],a=0;a<n._ptr.length;a++)for(var s=0;s<n._ptr[a+1]-n._ptr[a];s++)i.push(a);for(var c=n._values.slice(),l=n._index.slice(),f=0;f<n._index.length;f++){var m=l[f]*n._size[1]+i[f];i[f]=m%e[1],l[f]=Math.floor(m/e[1])}n._values.length=0,n._index.length=0,n._ptr.length=e[1]+1,n._size=e.slice();for(var d=0;d<n._ptr.length;d++)n._ptr[d]=0;for(var p=0;p<c.length;p++){var h=l[p],v=i[p],y=c[p];u(o(h,n._ptr[v],n._ptr[v+1],n._index),h,v,y,n._values,n._index,n._ptr)}return n},i.prototype.clone=function(){return new i({values:this._values?Wn(this._values):void 0,index:Wn(this._index),ptr:Wn(this._ptr),size:Wn(this._size),datatype:this._datatype})},i.prototype.size=function(){return this._size.slice(0)},i.prototype.map=function(e,n){if(!this._values)throw Error("Cannot invoke map on a Pattern only matrix");var a=this,o=this._size[0],u=this._size[1],s=Iu(e,a,"map");return function(e,n,o,u,c,l,f){var m=[],d=[],p=[],h=t,v=0;un(e._datatype)&&(h=r.find(t,[e._datatype,e._datatype])||t,v=r.convert(0,e._datatype));for(var y=function(e,r,t){var n=function(e,r,t){return s.fn(e,[r,t],a)}(e,r,t);h(n,v)||(m.push(n),d.push(r))},b=0;b<=c;b++){p.push(m.length);var g=e._ptr[b],x=e._ptr[b+1];if(f)for(var w=g;w<x;w++){var D=e._index[w];D>=0&&D<=o&&y(e._values[w],D-0,b-0)}else{for(var N={},A=g;A<x;A++)N[e._index[A]]=e._values[A];for(var M=0;M<=o;M++)y(M in N?N[M]:0,M-0,b-0)}}return p.push(m.length),new i({values:m,index:d,ptr:p,size:[o-0+1,c-0+1]})}(this,0,o-1,0,u-1,0,n)},i.prototype.forEach=function(e,r){if(!this._values)throw Error("Cannot invoke forEach on a Pattern only matrix");for(var t=this,n=this._size[0],i=this._size[1],a=Iu(e,t,"forEach"),o=0;o<i;o++){var u=this._ptr[o],s=this._ptr[o+1];if(r)for(var c=u;c<s;c++)a.fn(this._values[c],[this._index[c],o],t);else{for(var l={},f=u;f<s;f++)l[this._index[f]]=this._values[f];for(var m=0;m<n;m++)a.fn(m in l?l[m]:0,[m,o],t)}}},i.prototype[Symbol.iterator]=function*(){if(!this._values)throw Error("Cannot iterate a Pattern only matrix");for(var e=this._size[1],r=0;r<e;r++)for(var t=this._ptr[r+1],n=this._ptr[r];n<t;n++){var i=this._index[n];yield{value:this._values[n],index:[i,r]}}},i.prototype.toArray=function(){return c(this._values,this._index,this._ptr,this._size,!0)},i.prototype.valueOf=function(){return c(this._values,this._index,this._ptr,this._size,!1)},i.prototype.format=function(e){for(var r=this._size[0],t=this._size[1],n=this.density(),i="Sparse Matrix ["+Go(r,e)+" x "+Go(t,e)+"] density: "+Go(n,e)+"\n",a=0;a<t;a++)for(var o=this._ptr[a+1],u=this._ptr[a];u<o;u++)i+="\n ("+Go(this._index[u],e)+", "+Go(a,e)+") ==> "+(this._values?Go(this._values[u],e):"X");return i},i.prototype.toString=function(){return Go(this.toArray())},i.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},i.prototype.diagonal=function(e){if(e){if(rn(e)&&(e=e.toNumber()),!en(e)||!ii(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var r=e>0?e:0,t=e<0?-e:0,n=this._size[1],a=Math.min(this._size[0]-t,n-r),o=[],u=[],s=[];s[0]=0;for(var c=r;c<n&&o.length<a;c++)for(var l=this._ptr[c+1],f=this._ptr[c];f<l;f++){var m=this._index[f];if(m===c-r+t){o.push(this._values[f]),u[o.length-1]=m-t;break}}return s.push(o.length),new i({values:o,index:u,ptr:s,size:[a,1]})},i.fromJSON=function(e){return new i(e)},i.diagonal=function(e,n,a,o,u){if(!sn(e))throw new TypeError("Array expected, size parameter");if(2!==e.length)throw Error("Only two dimensions matrix are supported");if(e=e.map((function(e){if(rn(e)&&(e=e.toNumber()),!en(e)||!ii(e)||e<1)throw Error("Size values must be positive integers");return e})),a){if(rn(a)&&(a=a.toNumber()),!en(a)||!ii(a))throw new TypeError("The parameter k must be an integer number")}else a=0;var s=t,c=0;un(u)&&(s=r.find(t,[u,u])||t,c=r.convert(0,u));var l,f=a>0?a:0,m=a<0?-a:0,d=e[0],p=e[1],h=Math.min(d-m,p-f);if(sn(n)){if(n.length!==h)throw Error("Invalid value array length");l=function(e){return n[e]}}else if(cn(n)){var v=n.size();if(1!==v.length||v[0]!==h)throw Error("Invalid matrix length");l=function(e){return n.get([e])}}else l=function(){return n};for(var y=[],b=[],g=[],x=0;x<p;x++){g.push(y.length);var w=x-f;if(w>=0&&w<h){var D=l(w);s(D,c)||(b.push(w+m),y.push(D))}}return g.push(y.length),new i({values:y,index:b,ptr:g,size:[d,p]})},i.prototype.swapRows=function(e,r){if(!(en(e)&&ii(e)&&en(r)&&ii(r)))throw Error("Row index must be positive integers");if(2!==this._size.length)throw Error("Only two dimensional matrix is supported");return uu(e,this._size[0]),uu(r,this._size[0]),i._swapRows(e,r,this._size[1],this._values,this._index,this._ptr),this},i._forEachRow=function(e,r,t,n,i){for(var a=n[e+1],o=n[e];o<a;o++)i(t[o],r[o])},i._swapRows=function(e,r,t,n,i,a){for(var u=0;u<t;u++){var s=a[u],c=a[u+1],l=o(e,s,c,i),f=o(r,s,c,i);if(l<c&&f<c&&i[l]===e&&i[f]===r){if(n){var m=n[l];n[l]=n[f],n[f]=m}}else if(l<c&&i[l]===e&&(f>=c||i[f]!==r)){var d=n?n[l]:void 0;i.splice(f,0,r),n&&n.splice(f,0,d),i.splice(f<=l?l+1:l,1),n&&n.splice(f<=l?l+1:l,1)}else if(f<c&&i[f]===r&&(l>=c||i[l]!==e)){var p=n?n[f]:void 0;i.splice(l,0,e),n&&n.splice(l,0,p),i.splice(l<=f?f+1:f,1),n&&n.splice(l<=f?f+1:f,1)}}},i}),{isClass:!0}),Sc=ti("number",["typed"],(e=>{var{typed:r}=e,t=r("number",{"":function(){return 0},number:function(e){return e},string:function(e){if("NaN"===e)return NaN;var r=function(e){var r=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);return r?{input:e,radix:{"0b":2,"0o":8,"0x":16}[r[1]],integerPart:r[2],fractionalPart:r[3]}:null}(e);if(r)return function(e){for(var r=parseInt(e.integerPart,e.radix),t=0,n=0;n<e.fractionalPart.length;n++)t+=parseInt(e.fractionalPart[n],e.radix)/Math.pow(e.radix,n+1);var i=r+t;if(isNaN(i))throw new SyntaxError('String "'+e.input+'" is not a valid number');return i}(r);var t=0,n=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);n&&(t=Number(n[2]),e=n[1]);var i=Number(e);if(isNaN(i))throw new SyntaxError('String "'+e+'" is not a valid number');if(n){if(i>2**t-1)throw new SyntaxError('String "'.concat(e,'" is out of range'));i>=2**(t-1)&&(i-=2**t)}return i},BigNumber:function(e){return e.toNumber()},bigint:function(e){return Number(e)},Fraction:function(e){return e.valueOf()},Unit:r.referToSelf((e=>r=>{var t=r.clone();return t.value=e(r.value),t})),null:function(){return 0},"Unit, string | Unit":function(e,r){return e.toNumber(r)},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))});return t.fromJSON=function(e){return parseFloat(e.value)},t})),Fc=ti("bigint",["typed"],(e=>{var{typed:r}=e,t=r("bigint",{"":function(){return 0n},bigint:function(e){return e},number:function(e){return BigInt(e.toFixed())},BigNumber:function(e){return BigInt(""+e.round())},Fraction:function(e){return BigInt(e.valueOf().toFixed())},"string | boolean":function(e){return BigInt(e)},null:function(){return 0n},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))});return t.fromJSON=function(e){return BigInt(e.value)},t})),Bc="string",qc=ti(Bc,["typed"],(e=>{var{typed:r}=e;return r(Bc,{"":function(){return""},number:di,null:function(){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e))),any:function(e){return e+""}})})),Tc="boolean",kc=ti(Tc,["typed"],(e=>{var{typed:r}=e;return r(Tc,{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var r=e.toLowerCase();if("true"===r)return!0;if("false"===r)return!1;var t=Number(e);if(""!==e&&!isNaN(t))return!!t;throw Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Oc=ti("bignumber",["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r("bignumber",{"":function(){return new t(0)},number:function(e){return new t(e+"")},string:function(e){var r=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(r){var n=r[2],i=t(r[1]),a=new t(2).pow(Number(n));if(i.gt(a.sub(1)))throw new SyntaxError('String "'.concat(e,'" is out of range'));var o=new t(2).pow(Number(n)-1);return i.gte(o)?i.sub(a):i}return new t(e)},BigNumber:function(e){return e},bigint:function(e){return new t(""+e)},Unit:r.referToSelf((e=>r=>{var t=r.clone();return t.value=e(r.value),t})),Fraction:function(e){return new t(e.n+"").div(e.d+"").times(e.s+"")},null:function(){return new t(0)},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Ic=ti("complex",["typed","Complex"],(e=>{var{typed:r,Complex:t}=e;return r("complex",{"":function(){return t.ZERO},number:function(e){return new t(e,0)},"number, number":function(e,r){return new t(e,r)},"BigNumber, BigNumber":function(e,r){return new t(e.toNumber(),r.toNumber())},Fraction:function(e){return new t(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return t(e)},null:function(){return t(0)},Object:function(e){if("re"in e&&"im"in e)return new t(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new t(e);throw Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),zc=ti("fraction",["typed","Fraction"],(e=>{var{typed:r,Fraction:t}=e;return r("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw Error(e+" cannot be represented as a fraction");return new t(e)},string:function(e){return new t(e)},"number, number":function(e,r){return new t(e,r)},"bigint, bigint":function(e,r){return new t(e,r)},null:function(){return new t(0)},BigNumber:function(e){return new t(""+e)},bigint:function(e){return new t(""+e)},Fraction:function(e){return e},Unit:r.referToSelf((e=>r=>{var t=r.clone();return t.value=e(r.value),t})),Object:function(e){return new t(e)},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),jc="matrix",Rc=ti(jc,["typed","Matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:r,DenseMatrix:t,SparseMatrix:n}=e;return r(jc,{"":function(){return i([])},string:function(e){return i([],e)},"string, string":function(e,r){return i([],e,r)},Array:function(e){return i(e)},Matrix:function(e){return i(e,e.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(e,r,i){if("dense"===r||"default"===r||void 0===r)return new t(e,i);if("sparse"===r)return new n(e,i);throw new TypeError("Unknown matrix type "+JSON.stringify(r)+".")}})),Uc="matrixFromFunction",$c=ti(Uc,["typed","matrix","isZero"],(e=>{var{typed:r,matrix:t,isZero:n}=e;return r(Uc,{"Array | Matrix, function, string, string":function(e,r,t,n){return i(e,r,t,n)},"Array | Matrix, function, string":function(e,r,t){return i(e,r,t)},"Matrix, function":function(e,r){return i(e,r,"dense")},"Array, function":function(e,r){return i(e,r,"dense").toArray()},"Array | Matrix, string, function":function(e,r,t){return i(e,t,r)},"Array | Matrix, string, string, function":function(e,r,t,n){return i(e,n,r,t)}});function i(e,r,i,a){var o;return(o=void 0!==a?t(i,a):t(i)).resize(e),o.forEach((function(e,t){var i=r(t);n(i)||o.set(t,i)})),o}})),Pc="matrixFromRows",Lc=ti(Pc,["typed","matrix","flatten","size"],(e=>{var{typed:r,matrix:t,flatten:n,size:i}=e;return r(Pc,{"...Array":function(e){return a(e)},"...Matrix":function(e){return t(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one row is needed to construct a matrix.");var r=o(e[0]),t=[];for(var i of e){var a=o(i);if(a!==r)throw new TypeError("The vectors had different length: "+(0|r)+" ≠ "+(0|a));t.push(n(i))}return t}function o(e){var r=i(e);if(1===r.length)return r[0];if(2===r.length){if(1===r[0])return r[1];if(1===r[1])return r[0];throw new TypeError("At least one of the arguments is not a vector.")}throw new TypeError("Only one- or two-dimensional vectors are supported.")}})),_c="matrixFromColumns",Wc=ti(_c,["typed","matrix","flatten","size"],(e=>{var{typed:r,matrix:t,flatten:n,size:i}=e;return r(_c,{"...Array":function(e){return a(e)},"...Matrix":function(e){return t(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one column is needed to construct a matrix.");for(var r=o(e[0]),t=[],i=0;i<r;i++)t[i]=[];for(var a of e){var u=o(a);if(u!==r)throw new TypeError("The vectors had different length: "+(0|r)+" ≠ "+(0|u));for(var s=n(a),c=0;c<r;c++)t[c].push(s[c])}return t}function o(e){var r=i(e);if(1===r.length)return r[0];if(2===r.length){if(1===r[0])return r[1];if(1===r[1])return r[0];throw new TypeError("At least one of the arguments is not a vector.")}throw new TypeError("Only one- or two-dimensional vectors are supported.")}})),Jc="splitUnit",Vc=ti(Jc,["typed"],(e=>{var{typed:r}=e;return r(Jc,{"Unit, Array":function(e,r){return e.splitUnit(r)}})})),Hc="unaryMinus",Zc=ti(Hc,["typed"],(e=>{var{typed:r}=e;return r(Hc,{number:ts,"Complex | BigNumber | Fraction":e=>e.neg(),bigint:e=>-e,Unit:r.referToSelf((e=>t=>{var n=t.clone();return n.value=r.find(e,n.valueType())(t.value),n})),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e,!0)))})})),Gc="unaryPlus",Xc=ti(Gc,["typed","config","numeric"],(e=>{var{typed:r,config:t,numeric:n}=e;return r(Gc,{number:ns,Complex:function(e){return e},BigNumber:function(e){return e},bigint:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e,!0))),boolean:function(e){return n(e?1:0,t.number)},string:function(e){return n(e,ai(e,t))}})})),Yc=ti("abs",["typed"],(e=>{var{typed:r}=e;return r("abs",{number:Qu,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),bigint:e=>e<0n?-e:e,"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e,!0)))})})),Qc="mapSlices",Kc=ti(Qc,["typed","isInteger"],(e=>{var{typed:r,isInteger:t}=e;return r(Qc,{"Array | Matrix, number | BigNumber, function":function(e,r,n){if(!t(r))throw new TypeError("Integer number expected for dimension");var i=Array.isArray(e)?nu(e):e.size();if(r<0||r>=i.length)throw new tu(r,i.length);return cn(e)?e.create(el(e.valueOf(),r,n),e.datatype()):el(e,r,n)}})}),{formerly:"apply"});function el(e,r,t){var n,i,a;if(r<=0){if(Array.isArray(e[0])){for(a=function(e){var r,t,n=e.length,i=e[0].length,a=[];for(t=0;t<i;t++){var o=[];for(r=0;r<n;r++)o.push(e[r][t]);a.push(o)}return a}(e),i=[],n=0;n<a.length;n++)i[n]=el(a[n],r-1,t);return i}return t(e)}for(i=[],n=0;n<e.length;n++)i[n]=el(e[n],r-1,t);return i}var rl="addScalar",tl=ti(rl,["typed"],(e=>{var{typed:r}=e;return r(rl,{"number, number":Ku,"Complex, Complex":function(e,r){return e.add(r)},"BigNumber, BigNumber":function(e,r){return e.plus(r)},"bigint, bigint":function(e,r){return e+r},"Fraction, Fraction":function(e,r){return e.add(r)},"Unit, Unit":r.referToSelf((e=>(t,n)=>{if(null==t.value)throw Error("Parameter x contains a unit with undefined value");if(null==n.value)throw Error("Parameter y contains a unit with undefined value");if(!t.equalBase(n))throw Error("Units do not match");var i=t.clone();return i.value=r.find(e,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i}))})})),nl="subtractScalar",il=ti(nl,["typed"],(e=>{var{typed:r}=e;return r(nl,{"number, number":es,"Complex, Complex":function(e,r){return e.sub(r)},"BigNumber, BigNumber":function(e,r){return e.minus(r)},"bigint, bigint":function(e,r){return e-r},"Fraction, Fraction":function(e,r){return e.sub(r)},"Unit, Unit":r.referToSelf((e=>(t,n)=>{if(null==t.value)throw Error("Parameter x contains a unit with undefined value");if(null==n.value)throw Error("Parameter y contains a unit with undefined value");if(!t.equalBase(n))throw Error("Units do not match");var i=t.clone();return i.value=r.find(e,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i}))})})),al="cbrt",ol=ti(al,["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],(e=>{var{config:r,typed:t,isNegative:n,unaryMinus:i,matrix:a,Complex:o,BigNumber:u,Fraction:s}=e;return t(al,{number:is,Complex:c,"Complex, boolean":c,BigNumber:function(e){return e.cbrt()},Unit:function(e){if(e.value&&nn(e.value)){var r=e.clone();return r.value=1,(r=r.pow(1/3)).value=c(e.value),r}var t,a=n(e.value);a&&(e.value=i(e.value)),t=rn(e.value)?new u(1).div(3):an(e.value)?new s(1,3):1/3;var o=e.pow(t);return a&&(o.value=i(o.value)),o}});function c(e,t){var n=e.arg()/3,i=e.abs(),u=new o(is(i),0).mul(new o(0,n).exp());if(t){var s=[u,new o(is(i),0).mul(new o(0,n+2*Math.PI/3).exp()),new o(is(i),0).mul(new o(0,n-2*Math.PI/3).exp())];return"Array"===r.matrix?s:a(s)}return u}})),ul=ti("matAlgo11xS0s",["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return function(e,n,i,a){var o=e._values,u=e._index,s=e._ptr,c=e._size,l=e._datatype;if(!o)throw Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,m=c[0],d=c[1],p=t,h=0,v=i;"string"==typeof l&&(p=r.find(t,[f=l,f]),h=r.convert(0,f),n=r.convert(n,f),v=r.find(i,[f,f]));for(var y=[],b=[],g=[],x=0;x<d;x++){g[x]=b.length;for(var w=s[x+1],D=s[x];D<w;D++){var N=u[D],A=a?v(n,o[D]):v(o[D],n);p(A,h)||(b.push(N),y.push(A))}}return g[d]=b.length,e.createSparseMatrix({values:y,index:b,ptr:g,size:[m,d],datatype:f})}})),sl=ti("matAlgo12xSfs",["typed","DenseMatrix"],(e=>{var{typed:r,DenseMatrix:t}=e;return function(e,n,i,a){var o=e._values,u=e._index,s=e._ptr,c=e._size,l=e._datatype;if(!o)throw Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,m=c[0],d=c[1],p=i;"string"==typeof l&&(n=r.convert(n,f=l),p=r.find(i,[f,f]));for(var h=[],v=[],y=[],b=0;b<d;b++){for(var g=b+1,x=s[b+1],w=s[b];w<x;w++){var D=u[w];v[D]=o[w],y[D]=g}for(var N=0;N<m;N++)0===b&&(h[N]=[]),h[N][b]=y[N]===g?a?p(n,v[N]):p(v[N],n):a?p(n,0):p(0,n)}return new t({data:h,size:[m,d],datatype:f})}})),cl=ti("matAlgo14xDs",["typed"],(e=>{var{typed:r}=e;return function(e,n,i,a){var o,u=e._data,s=e._size,c=e._datatype,l=i;"string"==typeof c&&(n=r.convert(n,o=c),l=r.find(i,[o,o]));var f=s.length>0?t(l,0,s,s[0],u,n,a):[];return e.createDenseMatrix({data:f,size:Wn(s),datatype:o})};function t(e,r,n,i,a,o,u){var s=[];if(r===n.length-1)for(var c=0;c<i;c++)s[c]=u?e(o,a[c]):e(a[c],o);else for(var l=0;l<i;l++)s[l]=t(e,r+1,n,n[r+1],a[l],o,u);return s}})),ll="ceil",fl=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],ml=new yo(10),dl=ti(ll,["typed","config","round"],(e=>{var{typed:r,config:t,round:n}=e;function i(e){var r=Math.ceil(e),i=n(e);return r===i?r:xi(e,i,t.relTol,t.absTol)&&!xi(e,r,t.relTol,t.absTol)?i:r}return r(ll,{number:i,"number, number":function(e,r){if(!ii(r))throw new RangeError("number of decimals in function ceil must be an integer");if(r<0||r>15)throw new RangeError("number of decimals in ceil number must be in range 0-15");var t=10**r;return i(e*t)/t}})})),pl=ti(ll,fl,(e=>{var{typed:r,config:t,round:n,matrix:i,equalScalar:a,zeros:o,DenseMatrix:u}=e,s=ul({typed:r,equalScalar:a}),c=sl({typed:r,DenseMatrix:u}),l=cl({typed:r}),f=dl({typed:r,config:t,round:n});function m(e){var r=(e,r)=>cc(e,r,t.relTol,t.absTol),i=e.ceil(),a=n(e);return i.eq(a)?i:r(e,a)&&!r(e,i)?a:i}return r("ceil",{number:f.signatures.number,"number,number":f.signatures["number,number"],Complex:function(e){return e.ceil()},"Complex, number":function(e,r){return e.ceil(r)},"Complex, BigNumber":function(e,r){return e.ceil(r.toNumber())},BigNumber:m,"BigNumber, BigNumber":function(e,r){var t=ml.pow(r);return m(e.mul(t)).div(t)},bigint:e=>e,"bigint, number":e=>e,"bigint, BigNumber":e=>e,Fraction:function(e){return e.ceil()},"Fraction, number":function(e,r){return e.ceil(r)},"Fraction, BigNumber":function(e,r){return e.ceil(r.toNumber())},"Unit, number, Unit":r.referToSelf((e=>function(r,t,n){var i=r.toNumeric(n);return n.multiply(e(i,t))})),"Unit, BigNumber, Unit":r.referToSelf((e=>(r,t,n)=>e(r,t.toNumber(),n))),"Array | Matrix, number | BigNumber, Unit":r.referToSelf((e=>(r,t,n)=>Wu(r,(r=>e(r,t,n)),!0))),"Array | Matrix | Unit, Unit":r.referToSelf((e=>(r,t)=>e(r,0,t))),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e,!0))),"Array, number | BigNumber":r.referToSelf((e=>(r,t)=>Wu(r,(r=>e(r,t)),!0))),"SparseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>s(r,t,e,!1))),"DenseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>l(r,t,e,!1))),"number | Complex | Fraction | BigNumber, Array":r.referToSelf((e=>(r,t)=>l(i(t),r,e,!0).valueOf())),"number | Complex | Fraction | BigNumber, Matrix":r.referToSelf((e=>(r,t)=>a(r,0)?o(t.size(),t.storage()):"dense"===t.storage()?l(t,r,e,!0):c(t,r,e,!0)))})})),hl="cube",vl=ti(hl,["typed"],(e=>{var{typed:r}=e;return r(hl,{number:as,Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},bigint:function(e){return e*e*e},Fraction:function(e){return e.pow(3)},Unit:function(e){return e.pow(3)}})})),yl=ti("exp",["typed"],(e=>{var{typed:r}=e;return r("exp",{number:os,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()}})})),bl="expm1",gl=ti(bl,["typed","Complex"],(e=>{var{typed:r,Complex:t}=e;return r(bl,{number:us,Complex:function(e){var r=Math.exp(e.re);return new t(r*Math.cos(e.im)-1,r*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)}})})),xl="fix",wl=["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],Dl=ti(xl,["typed","ceil","floor"],(e=>{var{typed:r,ceil:t,floor:n}=e;return r(xl,{number:function(e){return e>0?n(e):t(e)},"number, number":function(e,r){return e>0?n(e,r):t(e,r)}})})),Nl=ti(xl,wl,(e=>{var{typed:r,Complex:t,matrix:n,ceil:i,floor:a,equalScalar:o,zeros:u,DenseMatrix:s}=e,c=sl({typed:r,DenseMatrix:s}),l=cl({typed:r}),f=Dl({typed:r,ceil:i,floor:a});return r("fix",{number:f.signatures.number,"number, number | BigNumber":f.signatures["number,number"],Complex:function(e){return new t(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},"Complex, number":function(e,r){return new t(e.re>0?a(e.re,r):i(e.re,r),e.im>0?a(e.im,r):i(e.im,r))},"Complex, BigNumber":function(e,r){var n=r.toNumber();return new t(e.re>0?a(e.re,n):i(e.re,n),e.im>0?a(e.im,n):i(e.im,n))},BigNumber:function(e){return e.isNegative()?i(e):a(e)},"BigNumber, number | BigNumber":function(e,r){return e.isNegative()?i(e,r):a(e,r)},bigint:e=>e,"bigint, number":e=>e,"bigint, BigNumber":e=>e,Fraction:function(e){return e.s<0n?e.ceil():e.floor()},"Fraction, number | BigNumber":function(e,r){return e.s<0n?i(e,r):a(e,r)},"Unit, number, Unit":r.referToSelf((e=>function(r,t,n){var i=r.toNumeric(n);return n.multiply(e(i,t))})),"Unit, BigNumber, Unit":r.referToSelf((e=>(r,t,n)=>e(r,t.toNumber(),n))),"Array | Matrix, number | BigNumber, Unit":r.referToSelf((e=>(r,t,n)=>Wu(r,(r=>e(r,t,n)),!0))),"Array | Matrix | Unit, Unit":r.referToSelf((e=>(r,t)=>e(r,0,t))),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e,!0))),"Array | Matrix, number | BigNumber":r.referToSelf((e=>(r,t)=>Wu(r,(r=>e(r,t)),!0))),"number | Complex | Fraction | BigNumber, Array":r.referToSelf((e=>(r,t)=>l(n(t),r,e,!0).valueOf())),"number | Complex | Fraction | BigNumber, Matrix":r.referToSelf((e=>(r,t)=>o(r,0)?u(t.size(),t.storage()):"dense"===t.storage()?l(t,r,e,!0):c(t,r,e,!0)))})})),Al="floor",Ml=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],Cl=new yo(10),El=ti(Al,["typed","config","round"],(e=>{var{typed:r,config:t,round:n}=e;function i(e){var r=Math.floor(e),i=n(e);return r===i?r:xi(e,i,t.relTol,t.absTol)&&!xi(e,r,t.relTol,t.absTol)?i:r}return r(Al,{number:i,"number, number":function(e,r){if(!ii(r))throw new RangeError("number of decimals in function floor must be an integer");if(r<0||r>15)throw new RangeError("number of decimals in floor number must be in range 0 - 15");var t=10**r;return i(e*t)/t}})})),Sl=ti(Al,Ml,(e=>{var{typed:r,config:t,round:n,matrix:i,equalScalar:a,zeros:o,DenseMatrix:u}=e,s=ul({typed:r,equalScalar:a}),c=sl({typed:r,DenseMatrix:u}),l=cl({typed:r}),f=El({typed:r,config:t,round:n});function m(e){var r=(e,r)=>cc(e,r,t.relTol,t.absTol),i=e.floor(),a=n(e);return i.eq(a)?i:r(e,a)&&!r(e,i)?a:i}return r("floor",{number:f.signatures.number,"number,number":f.signatures["number,number"],Complex:function(e){return e.floor()},"Complex, number":function(e,r){return e.floor(r)},"Complex, BigNumber":function(e,r){return e.floor(r.toNumber())},BigNumber:m,"BigNumber, BigNumber":function(e,r){var t=Cl.pow(r);return m(e.mul(t)).div(t)},bigint:e=>e,"bigint, number":e=>e,"bigint, BigNumber":e=>e,Fraction:function(e){return e.floor()},"Fraction, number":function(e,r){return e.floor(r)},"Fraction, BigNumber":function(e,r){return e.floor(r.toNumber())},"Unit, number, Unit":r.referToSelf((e=>function(r,t,n){var i=r.toNumeric(n);return n.multiply(e(i,t))})),"Unit, BigNumber, Unit":r.referToSelf((e=>(r,t,n)=>e(r,t.toNumber(),n))),"Array | Matrix, number | BigNumber, Unit":r.referToSelf((e=>(r,t,n)=>Wu(r,(r=>e(r,t,n)),!0))),"Array | Matrix | Unit, Unit":r.referToSelf((e=>(r,t)=>e(r,0,t))),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e,!0))),"Array, number | BigNumber":r.referToSelf((e=>(r,t)=>Wu(r,(r=>e(r,t)),!0))),"SparseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>s(r,t,e,!1))),"DenseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>l(r,t,e,!1))),"number | Complex | Fraction | BigNumber, Array":r.referToSelf((e=>(r,t)=>l(i(t),r,e,!0).valueOf())),"number | Complex | Fraction | BigNumber, Matrix":r.referToSelf((e=>(r,t)=>a(r,0)?o(t.size(),t.storage()):"dense"===t.storage()?l(t,r,e,!0):c(t,r,e,!0)))})})),Fl=ti("matAlgo02xDS0",["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return function(e,n,i,a){var o=e._data,u=e._size,s=e._datatype||e.getDataType(),c=n._values,l=n._index,f=n._ptr,m=n._size,d=n._datatype||void 0===n._data?n._datatype:n.getDataType();if(u.length!==m.length)throw new ru(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");if(!c)throw Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var p,h=u[0],v=u[1],y=t,b=0,g=i;"string"==typeof s&&s===d&&"mixed"!==s&&(y=r.find(t,[p=s,p]),b=r.convert(0,p),g=r.find(i,[p,p]));for(var x=[],w=[],D=[],N=0;N<v;N++){D[N]=w.length;for(var A=f[N+1],M=f[N];M<A;M++){var C=l[M],E=a?g(c[M],o[C][N]):g(o[C][N],c[M]);y(E,b)||(w.push(C),x.push(E))}}return D[v]=w.length,n.createSparseMatrix({values:x,index:w,ptr:D,size:[h,v],datatype:s===e._datatype&&d===n._datatype?p:void 0})}})),Bl=ti("matAlgo03xDSf",["typed"],(e=>{var{typed:r}=e;return function(e,t,n,i){var a=e._data,o=e._size,u=e._datatype||e.getDataType(),s=t._values,c=t._index,l=t._ptr,f=t._size,m=t._datatype||void 0===t._data?t._datatype:t.getDataType();if(o.length!==f.length)throw new ru(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!s)throw Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var d,p=o[0],h=o[1],v=0,y=n;"string"==typeof u&&u===m&&"mixed"!==u&&(v=r.convert(0,d=u),y=r.find(n,[d,d]));for(var b=[],g=0;g<p;g++)b[g]=[];for(var x=[],w=[],D=0;D<h;D++){for(var N=D+1,A=l[D+1],M=l[D];M<A;M++){var C=c[M];x[C]=i?y(s[M],a[C][D]):y(a[C][D],s[M]),w[C]=N}for(var E=0;E<p;E++)b[E][D]=w[E]===N?x[E]:i?y(v,a[E][D]):y(a[E][D],v)}return e.createDenseMatrix({data:b,size:[p,h],datatype:u===e._datatype&&m===t._datatype?d:void 0})}})),ql=ti("matAlgo05xSfSf",["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return function(e,n,i){var a=e._values,o=e._index,u=e._ptr,s=e._size,c=e._datatype||void 0===e._data?e._datatype:e.getDataType(),l=n._values,f=n._index,m=n._ptr,d=n._size,p=n._datatype||void 0===n._data?n._datatype:n.getDataType();if(s.length!==d.length)throw new ru(s.length,d.length);if(s[0]!==d[0]||s[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+d+")");var h,v=s[0],y=s[1],b=t,g=0,x=i;"string"==typeof c&&c===p&&"mixed"!==c&&(b=r.find(t,[h=c,h]),g=r.convert(0,h),x=r.find(i,[h,h]));var w,D,N,A,M=a&&l?[]:void 0,C=[],E=[],S=M?[]:void 0,F=M?[]:void 0,B=[],q=[];for(D=0;D<y;D++){E[D]=C.length;var T=D+1;for(N=u[D],A=u[D+1];N<A;N++)C.push(w=o[N]),B[w]=T,S&&(S[w]=a[N]);for(N=m[D],A=m[D+1];N<A;N++)B[w=f[N]]!==T&&C.push(w),q[w]=T,F&&(F[w]=l[N]);if(M)for(N=E[D];N<C.length;){var k=B[w=C[N]],O=q[w];if(k===T||O===T){var I=x(k===T?S[w]:g,O===T?F[w]:g);b(I,g)?C.splice(N,1):(M.push(I),N++)}}}return E[y]=C.length,e.createSparseMatrix({values:M,index:C,ptr:E,size:[v,y],datatype:c===e._datatype&&p===n._datatype?h:void 0})}})),Tl=ti("matAlgo13xDD",["typed"],(e=>{var{typed:r}=e;return function(e,n,i){var a,o=e._data,u=e._size,s=e._datatype,c=n._data,l=n._size,f=n._datatype,m=[];if(u.length!==l.length)throw new ru(u.length,l.length);for(var d=0;d<u.length;d++){if(u[d]!==l[d])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+l+")");m[d]=u[d]}var p=i;"string"==typeof s&&s===f&&(p=r.find(i,[a=s,a]));var h=m.length>0?t(p,0,m,m[0],o,c):[];return e.createDenseMatrix({data:h,size:m,datatype:a})};function t(e,r,n,i,a,o){var u=[];if(r===n.length-1)for(var s=0;s<i;s++)u[s]=e(a[s],o[s]);else for(var c=0;c<i;c++)u[c]=t(e,r+1,n,n[r+1],a[c],o[c]);return u}}));function kl(e,r){if(Vn(e.size(),r.size()))return[e,r];var t=Su(e.size(),r.size());return[e,r].map((e=>function(e,r){return Vn(e.size(),r)?e:e.create(Bu(e.valueOf(),r),e.datatype())}(e,t)))}var Ol=ti("matrixAlgorithmSuite",["typed","matrix"],(e=>{var{typed:r,matrix:t}=e,n=Tl({typed:r}),i=cl({typed:r});return function(e){var a,o=e.elop,u=e.SD||e.DS;o?(a={"DenseMatrix, DenseMatrix":(e,r)=>n(...kl(e,r),o),"Array, Array":(e,r)=>n(...kl(t(e),t(r)),o).valueOf(),"Array, DenseMatrix":(e,r)=>n(...kl(t(e),r),o),"DenseMatrix, Array":(e,r)=>n(...kl(e,t(r)),o)},e.SS&&(a["SparseMatrix, SparseMatrix"]=(r,t)=>e.SS(...kl(r,t),o,!1)),e.DS&&(a["DenseMatrix, SparseMatrix"]=(r,t)=>e.DS(...kl(r,t),o,!1),a["Array, SparseMatrix"]=(r,n)=>e.DS(...kl(t(r),n),o,!1)),u&&(a["SparseMatrix, DenseMatrix"]=(e,r)=>u(...kl(r,e),o,!0),a["SparseMatrix, Array"]=(e,r)=>u(...kl(t(r),e),o,!0))):(a={"DenseMatrix, DenseMatrix":r.referToSelf((e=>(r,t)=>n(...kl(r,t),e))),"Array, Array":r.referToSelf((e=>(r,i)=>n(...kl(t(r),t(i)),e).valueOf())),"Array, DenseMatrix":r.referToSelf((e=>(r,i)=>n(...kl(t(r),i),e))),"DenseMatrix, Array":r.referToSelf((e=>(r,i)=>n(...kl(r,t(i)),e)))},e.SS&&(a["SparseMatrix, SparseMatrix"]=r.referToSelf((r=>(t,n)=>e.SS(...kl(t,n),r,!1)))),e.DS&&(a["DenseMatrix, SparseMatrix"]=r.referToSelf((r=>(t,n)=>e.DS(...kl(t,n),r,!1))),a["Array, SparseMatrix"]=r.referToSelf((r=>(n,i)=>e.DS(...kl(t(n),i),r,!1)))),u&&(a["SparseMatrix, DenseMatrix"]=r.referToSelf((e=>(r,t)=>u(...kl(t,r),e,!0))),a["SparseMatrix, Array"]=r.referToSelf((e=>(r,n)=>u(...kl(t(n),r),e,!0)))));var s=e.scalar||"any";(e.Ds||e.Ss)&&(o?(a["DenseMatrix,"+s]=(e,r)=>i(e,r,o,!1),a[s+", DenseMatrix"]=(e,r)=>i(r,e,o,!0),a["Array,"+s]=(e,r)=>i(t(e),r,o,!1).valueOf(),a[s+", Array"]=(e,r)=>i(t(r),e,o,!0).valueOf()):(a["DenseMatrix,"+s]=r.referToSelf((e=>(r,t)=>i(r,t,e,!1))),a[s+", DenseMatrix"]=r.referToSelf((e=>(r,t)=>i(t,r,e,!0))),a["Array,"+s]=r.referToSelf((e=>(r,n)=>i(t(r),n,e,!1).valueOf())),a[s+", Array"]=r.referToSelf((e=>(r,n)=>i(t(n),r,e,!0).valueOf()))));var c=void 0!==e.sS?e.sS:e.Ss;return o?(e.Ss&&(a["SparseMatrix,"+s]=(r,t)=>e.Ss(r,t,o,!1)),c&&(a[s+", SparseMatrix"]=(e,r)=>c(r,e,o,!0))):(e.Ss&&(a["SparseMatrix,"+s]=r.referToSelf((r=>(t,n)=>e.Ss(t,n,r,!1)))),c&&(a[s+", SparseMatrix"]=r.referToSelf((e=>(r,t)=>c(t,r,e,!0))))),o&&o.signatures&&Jn(a,o.signatures),a}})),Il=ti("mod",["typed","config","round","matrix","equalScalar","zeros","DenseMatrix","concat"],(e=>{var{typed:r,config:t,round:n,matrix:i,equalScalar:a,zeros:o,DenseMatrix:u,concat:s}=e,c=Sl({typed:r,config:t,round:n,matrix:i,equalScalar:a,zeros:o,DenseMatrix:u}),l=Fl({typed:r,equalScalar:a}),f=Bl({typed:r}),m=ql({typed:r,equalScalar:a}),d=ul({typed:r,equalScalar:a}),p=sl({typed:r,DenseMatrix:u});return r("mod",{"number, number":function(e,r){return 0===r?e:e-r*c(e/r)},"BigNumber, BigNumber":function(e,r){return r.isZero()?e:e.sub(r.mul(c(e.div(r))))},"bigint, bigint":function(e,r){if(0n===r)return e;if(e<0){var t=e%r;return 0n===t?t:t+r}return e%r},"Fraction, Fraction":function(e,r){return r.equals(0)?e:e.sub(r.mul(c(e.div(r))))}},Ol({typed:r,matrix:i,concat:s})({SS:m,DS:f,SD:l,Ss:d,sS:p}))})),zl=ti("matAlgo01xDSid",["typed"],(e=>{var{typed:r}=e;return function(e,t,n,i){var a=e._data,o=e._size,u=e._datatype||e.getDataType(),s=t._values,c=t._index,l=t._ptr,f=t._size,m=t._datatype||void 0===t._data?t._datatype:t.getDataType();if(o.length!==f.length)throw new ru(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!s)throw Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var d,p,h=o[0],v=o[1],y="string"==typeof u&&"mixed"!==u&&u===m?u:void 0,b=y?r.find(n,[y,y]):n,g=[];for(d=0;d<h;d++)g[d]=[];var x=[],w=[];for(p=0;p<v;p++){for(var D=p+1,N=l[p+1],A=l[p];A<N;A++)x[d=c[A]]=i?b(s[A],a[d][p]):b(a[d][p],s[A]),w[d]=D;for(d=0;d<h;d++)g[d][p]=w[d]===D?x[d]:a[d][p]}return e.createDenseMatrix({data:g,size:[h,v],datatype:u===e._datatype&&m===t._datatype?y:void 0})}})),jl=ti("matAlgo04xSidSid",["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return function(e,n,i){var a=e._values,o=e._index,u=e._ptr,s=e._size,c=e._datatype||void 0===e._data?e._datatype:e.getDataType(),l=n._values,f=n._index,m=n._ptr,d=n._size,p=n._datatype||void 0===n._data?n._datatype:n.getDataType();if(s.length!==d.length)throw new ru(s.length,d.length);if(s[0]!==d[0]||s[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+d+")");var h,v=s[0],y=s[1],b=t,g=0,x=i;"string"==typeof c&&c===p&&"mixed"!==c&&(b=r.find(t,[h=c,h]),g=r.convert(0,h),x=r.find(i,[h,h]));var w,D,N,A,M=a&&l?[]:void 0,C=[],E=[],S=a&&l?[]:void 0,F=a&&l?[]:void 0,B=[],q=[];for(D=0;D<y;D++){E[D]=C.length;var T=D+1;for(A=u[D+1],N=u[D];N<A;N++)C.push(w=o[N]),B[w]=T,S&&(S[w]=a[N]);for(A=m[D+1],N=m[D];N<A;N++)if(B[w=f[N]]===T){if(S){var k=x(S[w],l[N]);b(k,g)?B[w]=null:S[w]=k}}else C.push(w),q[w]=T,F&&(F[w]=l[N]);if(S&&F)for(N=E[D];N<C.length;)B[w=C[N]]===T?(M[N]=S[w],N++):q[w]===T?(M[N]=F[w],N++):C.splice(N,1)}return E[y]=C.length,e.createSparseMatrix({values:M,index:C,ptr:E,size:[v,y],datatype:c===e._datatype&&p===n._datatype?h:void 0})}})),Rl=ti("matAlgo10xSids",["typed","DenseMatrix"],(e=>{var{typed:r,DenseMatrix:t}=e;return function(e,n,i,a){var o=e._values,u=e._index,s=e._ptr,c=e._size,l=e._datatype;if(!o)throw Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,m=c[0],d=c[1],p=i;"string"==typeof l&&(n=r.convert(n,f=l),p=r.find(i,[f,f]));for(var h=[],v=[],y=[],b=0;b<d;b++){for(var g=b+1,x=s[b+1],w=s[b];w<x;w++){var D=u[w];v[D]=o[w],y[D]=g}for(var N=0;N<m;N++)0===b&&(h[N]=[]),h[N][b]=y[N]===g?a?p(n,v[N]):p(v[N],n):n}return new t({data:h,size:[m,d],datatype:f})}}));function Ul(e,r,t,n){if(!(this instanceof Ul))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=r,this.min=t,this.max=n,this.message="Wrong number of arguments in function "+e+" ("+r+" provided, "+t+(null!=n?"-"+n:"")+" expected)",this.stack=Error().stack}(Ul.prototype=Error()).constructor=Error,Ul.prototype.name="ArgumentsError",Ul.prototype.isArgumentsError=!0;var $l=["typed","config","round","matrix","equalScalar","zeros","BigNumber","DenseMatrix","concat"],Pl="number | BigNumber | Fraction | Matrix | Array",Ll="".concat(Pl,", ").concat(Pl,", ...").concat(Pl);function _l(e){return!e.some((e=>Array.isArray(e)))}var Wl=ti("gcd",$l,(e=>{var{typed:r,matrix:t,config:n,round:i,equalScalar:a,zeros:o,BigNumber:u,DenseMatrix:s,concat:c}=e,l=Il({typed:r,config:n,round:i,matrix:t,equalScalar:a,zeros:o,DenseMatrix:s,concat:c}),f=zl({typed:r}),m=jl({typed:r,equalScalar:a}),d=Rl({typed:r,DenseMatrix:s});return r("gcd",{"number, number":function(e,r){if(!ii(e)||!ii(r))throw Error("Parameters in function gcd must be integer numbers");for(var t;0!==r;)t=l(e,r),e=r,r=t;return e<0?-e:e},"BigNumber, BigNumber":function(e,r){if(!e.isInt()||!r.isInt())throw Error("Parameters in function gcd must be integer numbers");for(var t=new u(0);!r.isZero();){var n=l(e,r);e=r,r=n}return e.lt(t)?e.neg():e},"Fraction, Fraction":(e,r)=>e.gcd(r)},Ol({typed:r,matrix:t,concat:c})({SS:m,DS:f,Ss:d}),{[Ll]:r.referToSelf((e=>(r,t,n)=>{for(var i=e(r,t),a=0;a<n.length;a++)i=e(i,n[a]);return i})),Array:r.referToSelf((e=>r=>{if(1===r.length&&Array.isArray(r[0])&&_l(r[0]))return e(...r[0]);if(_l(r))return e(...r);throw new Ul("gcd() supports only 1d matrices!")})),Matrix:r.referToSelf((e=>r=>e(r.toArray())))})})),Jl=ti("matAlgo06xS0S0",["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return function(e,n,i){var a=e._values,o=e._size,u=e._datatype||void 0===e._data?e._datatype:e.getDataType(),s=n._values,c=n._size,l=n._datatype||void 0===n._data?n._datatype:n.getDataType();if(o.length!==c.length)throw new ru(o.length,c.length);if(o[0]!==c[0]||o[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+c+")");var f,m=o[0],d=o[1],p=t,h=0,v=i;"string"==typeof u&&u===l&&"mixed"!==u&&(p=r.find(t,[f=u,f]),h=r.convert(0,f),v=r.find(i,[f,f]));for(var y=a&&s?[]:void 0,b=[],g=[],x=y?[]:void 0,w=[],D=[],N=0;N<d;N++){g[N]=b.length;var A=N+1;if(Hu(e,N,w,x,D,A,b,v),Hu(n,N,w,x,D,A,b,v),x)for(var M=g[N];M<b.length;){var C=b[M];if(D[C]===A){var E=x[C];p(E,h)?b.splice(M,1):(y.push(E),M++)}else b.splice(M,1)}else for(var S=g[N];S<b.length;)D[b[S]]!==A?b.splice(S,1):S++}return g[d]=b.length,e.createSparseMatrix({values:y,index:b,ptr:g,size:[m,d],datatype:u===e._datatype&&l===n._datatype?f:void 0})}})),Vl=ti("lcm",["typed","matrix","equalScalar","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,concat:i}=e,a=Fl({typed:r,equalScalar:n}),o=Jl({typed:r,equalScalar:n}),u=ul({typed:r,equalScalar:n}),s=Ol({typed:r,matrix:t,concat:i}),c="number | BigNumber | Fraction | Matrix | Array",l={};return l["".concat(c,", ").concat(c,", ...").concat(c)]=r.referToSelf((e=>(r,t,n)=>{for(var i=e(r,t),a=0;a<n.length;a++)i=e(i,n[a]);return i})),r("lcm",{"number, number":ss,"BigNumber, BigNumber":function(e,r){if(!e.isInt()||!r.isInt())throw Error("Parameters in function lcm must be integer numbers");if(e.isZero())return e;if(r.isZero())return r;for(var t=e.times(r);!r.isZero();){var n=r;r=e.mod(n),e=n}return t.div(e).abs()},"Fraction, Fraction":(e,r)=>e.lcm(r)},s({SS:o,DS:a,Ss:u}),l)}));function Hl(e,r,t,n){return function(i){if(i>0||t.predictable){if(i<=0)return NaN;var a=i.toString(16),o=a.substring(0,15);return e*(a.length-o.length)+r(Number("0x"+o))}return n(i.toNumber())}}var Zl="log10",Gl=["typed","config","Complex"],Xl=ls(16),Yl=ti(Zl,Gl,(e=>{var{typed:r,config:t,Complex:n}=e;function i(e){return e.log().div(Math.LN10)}function a(e){return i(new n(e,0))}return r(Zl,{number:function(e){return e>=0||t.predictable?ls(e):a(e)},bigint:Hl(Xl,ls,t,a),Complex:i,BigNumber:function(e){return!e.isNegative()||t.predictable?e.log():a(e.toNumber())},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Ql="log2",Kl=ti(Ql,["typed","config","Complex"],(e=>{var{typed:r,config:t,Complex:n}=e;function i(e){return a(new n(e,0))}return r(Ql,{number:function(e){return e>=0||t.predictable?fs(e):i(e)},bigint:Hl(4,fs,t,i),Complex:a,BigNumber:function(e){return!e.isNegative()||t.predictable?e.log(2):i(e.toNumber())},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))});function a(e){var r=Math.sqrt(e.re*e.re+e.im*e.im);return new n(Math.log2?Math.log2(r):Math.log(r)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}})),ef=ti("multiplyScalar",["typed"],(e=>{var{typed:r}=e;return r("multiplyScalar",{"number, number":rs,"Complex, Complex":function(e,r){return e.mul(r)},"BigNumber, BigNumber":function(e,r){return e.times(r)},"bigint, bigint":function(e,r){return e*r},"Fraction, Fraction":function(e,r){return e.mul(r)},"number | Fraction | BigNumber | Complex, Unit":(e,r)=>r.multiply(e),"Unit, number | Fraction | BigNumber | Complex | Unit":(e,r)=>e.multiply(r)})})),rf="multiply",tf=ti(rf,["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],(e=>{var{typed:r,matrix:t,addScalar:n,multiplyScalar:i,equalScalar:a,dot:o}=e,u=ul({typed:r,equalScalar:a}),s=cl({typed:r});function c(e,r){switch(e.length){case 1:switch(r.length){case 1:if(e[0]!==r[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==r[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+r[0]+")");break;default:throw Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+r.length+" dimensions)")}break;case 2:switch(r.length){case 1:if(e[1]!==r[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+r[0]+")");break;case 2:if(e[1]!==r[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+r[0]+")");break;default:throw Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+r.length+" dimensions)")}break;default:throw Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}}var l=r("_multiplyMatrixVector",{"DenseMatrix, any":function(e,t){var a,o=e._data,u=e._size,s=e._datatype||e.getDataType(),c=t._data,l=t._datatype||t.getDataType(),f=u[0],m=u[1],d=n,p=i;s&&l&&s===l&&"string"==typeof s&&"mixed"!==s&&(d=r.find(n,[a=s,a]),p=r.find(i,[a,a]));for(var h=[],v=0;v<f;v++){for(var y=o[v],b=p(y[0],c[0]),g=1;g<m;g++)b=d(b,p(y[g],c[g]));h[v]=b}return e.createDenseMatrix({data:h,size:[f],datatype:s===e._datatype&&l===t._datatype?a:void 0})},"SparseMatrix, any":function(e,t){var o=e._values,u=e._index,s=e._ptr,c=e._datatype||void 0===e._data?e._datatype:e.getDataType();if(!o)throw Error("Cannot multiply Pattern only Matrix times Dense Matrix");var l,f=t._data,m=t._datatype||t.getDataType(),d=e._size[0],p=t._size[0],h=[],v=[],y=[],b=n,g=i,x=a,w=0;c&&m&&c===m&&"string"==typeof c&&"mixed"!==c&&(b=r.find(n,[l=c,l]),g=r.find(i,[l,l]),x=r.find(a,[l,l]),w=r.convert(0,l));var D=[],N=[];y[0]=0;for(var A=0;A<p;A++){var M=f[A];if(!x(M,w))for(var C=s[A+1],E=s[A];E<C;E++){var S=u[E];N[S]?D[S]=b(D[S],g(M,o[E])):(N[S]=!0,v.push(S),D[S]=g(M,o[E]))}}for(var F=v.length,B=0;B<F;B++)h[B]=D[v[B]];return y[1]=v.length,e.createSparseMatrix({values:h,index:v,ptr:y,size:[d,1],datatype:c===e._datatype&&m===t._datatype?l:void 0})}}),f=r("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":function(e,t){var a,o=e._data,u=e._size,s=e._datatype||e.getDataType(),c=t._data,l=t._size,f=t._datatype||t.getDataType(),m=u[0],d=u[1],p=l[1],h=n,v=i;s&&f&&s===f&&"string"==typeof s&&"mixed"!==s&&"mixed"!==s&&(h=r.find(n,[a=s,a]),v=r.find(i,[a,a]));for(var y=[],b=0;b<m;b++){var g=o[b];y[b]=[];for(var x=0;x<p;x++){for(var w=v(g[0],c[0][x]),D=1;D<d;D++)w=h(w,v(g[D],c[D][x]));y[b][x]=w}}return e.createDenseMatrix({data:y,size:[m,p],datatype:s===e._datatype&&f===t._datatype?a:void 0})},"DenseMatrix, SparseMatrix":function(e,t){var o=e._data,u=e._size,s=e._datatype||e.getDataType(),c=t._values,l=t._index,f=t._ptr,m=t._size,d=t._datatype||void 0===t._data?t._datatype:t.getDataType();if(!c)throw Error("Cannot multiply Dense Matrix times Pattern only Matrix");var p,h=u[0],v=m[1],y=n,b=i,g=a,x=0;s&&d&&s===d&&"string"==typeof s&&"mixed"!==s&&(y=r.find(n,[p=s,p]),b=r.find(i,[p,p]),g=r.find(a,[p,p]),x=r.convert(0,p));for(var w=[],D=[],N=[],A=t.createSparseMatrix({values:w,index:D,ptr:N,size:[h,v],datatype:s===e._datatype&&d===t._datatype?p:void 0}),M=0;M<v;M++){N[M]=D.length;var C=f[M],E=f[M+1];if(E>C)for(var S=0,F=0;F<h;F++){for(var B=F+1,q=void 0,T=C;T<E;T++){var k=l[T];S!==B?(q=b(o[F][k],c[T]),S=B):q=y(q,b(o[F][k],c[T]))}S!==B||g(q,x)||(D.push(F),w.push(q))}}return N[v]=D.length,A},"SparseMatrix, DenseMatrix":function(e,t){var o=e._values,u=e._index,s=e._ptr,c=e._datatype||void 0===e._data?e._datatype:e.getDataType();if(!o)throw Error("Cannot multiply Pattern only Matrix times Dense Matrix");var l,f=t._data,m=t._datatype||t.getDataType(),d=e._size[0],p=t._size[0],h=t._size[1],v=n,y=i,b=a,g=0;c&&m&&c===m&&"string"==typeof c&&"mixed"!==c&&(v=r.find(n,[l=c,l]),y=r.find(i,[l,l]),b=r.find(a,[l,l]),g=r.convert(0,l));for(var x=[],w=[],D=[],N=e.createSparseMatrix({values:x,index:w,ptr:D,size:[d,h],datatype:c===e._datatype&&m===t._datatype?l:void 0}),A=[],M=[],C=0;C<h;C++){D[C]=w.length;for(var E=C+1,S=0;S<p;S++){var F=f[S][C];if(!b(F,g))for(var B=s[S+1],q=s[S];q<B;q++){var T=u[q];M[T]!==E?(M[T]=E,w.push(T),A[T]=y(F,o[q])):A[T]=v(A[T],y(F,o[q]))}}for(var k=w.length,O=D[C];O<k;O++)x[O]=A[w[O]]}return D[h]=w.length,N},"SparseMatrix, SparseMatrix":function(e,t){var a,o=e._values,u=e._index,s=e._ptr,c=e._datatype||void 0===e._data?e._datatype:e.getDataType(),l=t._values,f=t._index,m=t._ptr,d=t._datatype||void 0===t._data?t._datatype:t.getDataType(),p=e._size[0],h=t._size[1],v=o&&l,y=n,b=i;c&&d&&c===d&&"string"==typeof c&&"mixed"!==c&&(y=r.find(n,[a=c,a]),b=r.find(i,[a,a]));for(var g,x,w,D,N,A,M=v?[]:void 0,C=[],E=[],S=e.createSparseMatrix({values:M,index:C,ptr:E,size:[p,h],datatype:c===e._datatype&&d===t._datatype?a:void 0}),F=v?[]:void 0,B=[],q=0;q<h;q++){E[q]=C.length;var T=q+1;for(D=m[q+1],w=m[q];w<D;w++)if(A=f[w],v)for(x=s[A+1],g=s[A];g<x;g++)B[N=u[g]]!==T?(B[N]=T,C.push(N),F[N]=b(l[w],o[g])):F[N]=y(F[N],b(l[w],o[g]));else for(x=s[A+1],g=s[A];g<x;g++)B[N=u[g]]!==T&&(B[N]=T,C.push(N));if(v)for(var k=C.length,O=E[q];O<k;O++)M[O]=F[C[O]]}return E[h]=C.length,S}});return r(rf,i,{"Array, Array":r.referTo("Matrix, Matrix",(e=>(r,n)=>{c(nu(r),nu(n));var i=e(t(r),t(n));return cn(i)?i.valueOf():i})),"Matrix, Matrix":function(e,t){var a=e.size(),u=t.size();return c(a,u),1===a.length?1===u.length?function(e,r,t){if(0===t)throw Error("Cannot multiply two empty vectors");return o(e,r)}(e,t,a[0]):function(e,t){if("dense"!==t.storage())throw Error("Support for SparseMatrix not implemented");return function(e,t){var a,o=e._data,u=e._size,s=e._datatype||e.getDataType(),c=t._data,l=t._size,f=t._datatype||t.getDataType(),m=u[0],d=l[1],p=n,h=i;s&&f&&s===f&&"string"==typeof s&&"mixed"!==s&&(p=r.find(n,[a=s,a]),h=r.find(i,[a,a]));for(var v=[],y=0;y<d;y++){for(var b=h(o[0],c[0][y]),g=1;g<m;g++)b=p(b,h(o[g],c[g][y]));v[y]=b}return e.createDenseMatrix({data:v,size:[d],datatype:s===e._datatype&&f===t._datatype?a:void 0})}(e,t)}(e,t):1===u.length?l(e,t):f(e,t)},"Matrix, Array":r.referTo("Matrix,Matrix",(e=>(r,n)=>e(r,t(n)))),"Array, Matrix":r.referToSelf((e=>(r,n)=>e(t(r,n.storage()),n))),"SparseMatrix, any":function(e,r){return u(e,r,i,!1)},"DenseMatrix, any":function(e,r){return s(e,r,i,!1)},"any, SparseMatrix":function(e,r){return u(r,e,i,!0)},"any, DenseMatrix":function(e,r){return s(r,e,i,!0)},"Array, any":function(e,r){return s(t(e),r,i,!1).valueOf()},"any, Array":function(e,r){return s(t(r),e,i,!0).valueOf()},"any, any":i,"any, any, ...any":r.referToSelf((e=>(r,t,n)=>{for(var i=e(r,t),a=0;a<n.length;a++)i=e(i,n[a]);return i}))})})),nf="nthRoot",af=ti(nf,["typed","matrix","equalScalar","BigNumber","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,BigNumber:i,concat:a}=e,o=zl({typed:r}),u=Fl({typed:r,equalScalar:n}),s=Jl({typed:r,equalScalar:n}),c=ul({typed:r,equalScalar:n}),l=Ol({typed:r,matrix:t,concat:a});function f(){throw Error("Complex number not supported in function nthRoot. Use nthRoots instead.")}return r(nf,{number:ms,"number, number":ms,BigNumber:e=>m(e,new i(2)),"BigNumber, BigNumber":m,Complex:f,"Complex, number":f,Array:r.referTo("DenseMatrix,number",(e=>r=>e(t(r),2).valueOf())),DenseMatrix:r.referTo("DenseMatrix,number",(e=>r=>e(r,2))),SparseMatrix:r.referTo("SparseMatrix,number",(e=>r=>e(r,2))),"SparseMatrix, SparseMatrix":r.referToSelf((e=>(r,t)=>{if(1===t.density())return s(r,t,e);throw Error("Root must be non-zero")})),"DenseMatrix, SparseMatrix":r.referToSelf((e=>(r,t)=>{if(1===t.density())return o(r,t,e,!1);throw Error("Root must be non-zero")})),"Array, SparseMatrix":r.referTo("DenseMatrix,SparseMatrix",(e=>(r,n)=>e(t(r),n))),"number | BigNumber, SparseMatrix":r.referToSelf((e=>(r,t)=>{if(1===t.density())return c(t,r,e,!0);throw Error("Root must be non-zero")}))},l({scalar:"number | BigNumber",SD:u,Ss:c,sS:!1}));function m(e,r){var t=i.precision,n=i.clone({precision:t+2}),a=new i(0),o=new n(1),u=r.isNegative();if(u&&(r=r.neg()),r.isZero())throw Error("Root must be non-zero");if(e.isNegative()&&!r.abs().mod(2).equals(1))throw Error("Root must be odd when a is negative.");if(e.isZero())return u?new n(1/0):0;if(!e.isFinite())return u?a:e;var s=e.abs().pow(o.div(r));return s=e.isNeg()?s.neg():s,new i((u?o.div(s):s).toPrecision(t))}})),of="sign",uf=ti(of,["typed","BigNumber","Fraction","complex"],(e=>{var{typed:r,BigNumber:t,complex:n,Fraction:i}=e;return r(of,{number:ds,Complex:function(e){return 0===e.im?n(ds(e.re)):e.sign()},BigNumber:function(e){return new t(e.cmp(0))},bigint:function(e){return e>0n?1n:e<0n?-1n:0n},Fraction:function(e){return new i(0n===e.n?0:e.s)},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e,!0))),Unit:r.referToSelf((e=>t=>{if(!t._isDerived()&&0!==t.units[0].unit.offset)throw new TypeError("sign is ambiguous for units with offset");return r.find(e,t.valueType())(t.value)}))})})),sf=ti("sqrt",["config","typed","Complex"],(e=>{var{config:r,typed:t,Complex:n}=e;return t("sqrt",{number:i,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||r.predictable?e.sqrt():i(e.toNumber())},Unit:function(e){return e.pow(.5)}});function i(e){return isNaN(e)?NaN:e>=0||r.predictable?Math.sqrt(e):new n(e,0).sqrt()}})),cf="square",lf=ti(cf,["typed"],(e=>{var{typed:r}=e;return r(cf,{number:ps,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},bigint:function(e){return e*e},Fraction:function(e){return e.mul(e)},Unit:function(e){return e.pow(2)}})})),ff="subtract",mf=ti(ff,["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,subtractScalar:i,DenseMatrix:a,concat:o}=e,u=zl({typed:r}),s=Bl({typed:r}),c=ql({typed:r,equalScalar:n}),l=Rl({typed:r,DenseMatrix:a}),f=sl({typed:r,DenseMatrix:a}),m=Ol({typed:r,matrix:t,concat:o});return r(ff,{"any, any":i},m({elop:i,SS:c,DS:u,SD:s,Ss:f,sS:l}))})),df="xgcd",pf=ti(df,["typed","config","matrix","BigNumber"],(e=>{var{typed:r,config:t,matrix:n,BigNumber:i}=e;return r(df,{"number, number":function(e,r){var i=hs(e,r);return"Array"===t.matrix?i:n(i)},"BigNumber, BigNumber":function(e,r){var a,o,u,s,c=new i(0),l=new i(1),f=c,m=l,d=l,p=c;if(!e.isInt()||!r.isInt())throw Error("Parameters in function xgcd must be integer numbers");for(;!r.isZero();)o=e.div(r).floor(),u=e.mod(r),a=f,f=m.minus(o.times(f)),m=a,a=d,d=p.minus(o.times(d)),p=a,e=r,r=u;return s=e.lt(c)?[e.neg(),m.neg(),p.neg()]:[e,e.isZero()?0:m,p],"Array"===t.matrix?s:n(s)}})})),hf="invmod",vf=ti(hf,["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],(e=>{var{typed:r,BigNumber:t,xgcd:n,equal:i,smaller:a,mod:o,add:u,isInteger:s}=e;return r(hf,{"number, number":c,"BigNumber, BigNumber":c});function c(e,r){if(!s(e)||!s(r))throw Error("Parameters in function invmod must be integer numbers");if(e=o(e,r),i(r,0))throw Error("Divisor must be non zero");var c=n(e,r);c=c.valueOf();var[l,f]=c;return i(l,t(1))?(f=o(f,r),a(f,t(0))&&(f=u(f,r)),f):NaN}})),yf=ti("matAlgo09xS0Sf",["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return function(e,n,i){var a=e._values,o=e._index,u=e._ptr,s=e._size,c=e._datatype||void 0===e._data?e._datatype:e.getDataType(),l=n._values,f=n._index,m=n._ptr,d=n._size,p=n._datatype||void 0===n._data?n._datatype:n.getDataType();if(s.length!==d.length)throw new ru(s.length,d.length);if(s[0]!==d[0]||s[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+d+")");var h,v=s[0],y=s[1],b=t,g=0,x=i;"string"==typeof c&&c===p&&"mixed"!==c&&(b=r.find(t,[h=c,h]),g=r.convert(0,h),x=r.find(i,[h,h]));var w,D,N,A,M=a&&l?[]:void 0,C=[],E=[],S=M?[]:void 0,F=[];for(D=0;D<y;D++){E[D]=C.length;var B=D+1;if(S)for(A=m[D+1],N=m[D];N<A;N++)F[w=f[N]]=B,S[w]=l[N];for(A=u[D+1],N=u[D];N<A;N++)if(w=o[N],S){var q=x(a[N],F[w]===B?S[w]:g);b(q,g)||(C.push(w),M.push(q))}else C.push(w)}return E[y]=C.length,e.createSparseMatrix({values:M,index:C,ptr:E,size:[v,y],datatype:c===e._datatype&&p===n._datatype?h:void 0})}})),bf="dotMultiply",gf=ti(bf,["typed","matrix","equalScalar","multiplyScalar","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,multiplyScalar:i,concat:a}=e,o=Fl({typed:r,equalScalar:n}),u=yf({typed:r,equalScalar:n}),s=ul({typed:r,equalScalar:n}),c=Ol({typed:r,matrix:t,concat:a});return r(bf,c({elop:i,SS:u,DS:o,Ss:s}))}));function xf(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw Error("Integers expected in function bitAnd");var t=e.constructor;if(e.isNaN()||r.isNaN())return new t(NaN);if(e.isZero()||r.eq(-1)||e.eq(r))return e;if(r.isZero()||e.eq(-1))return r;if(!e.isFinite()||!r.isFinite()){if(!e.isFinite()&&!r.isFinite())return e.isNegative()===r.isNegative()?e:new t(0);if(!e.isFinite())return r.isNegative()?e:e.isNegative()?new t(0):r;if(!r.isFinite())return e.isNegative()?r:r.isNegative()?new t(0):e}return Nf(e,r,(function(e,r){return e&r}))}function wf(e){if(e.isFinite()&&!e.isInteger())throw Error("Integer expected in function bitNot");var r=e.constructor,t=r.precision;r.config({precision:1e9});var n=e.plus(new r(1));return n.s=-n.s||null,r.config({precision:t}),n}function Df(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw Error("Integers expected in function bitOr");var t=e.constructor;if(e.isNaN()||r.isNaN())return new t(NaN);var n=new t(-1);return e.isZero()||r.eq(n)||e.eq(r)?r:r.isZero()||e.eq(n)?e:e.isFinite()&&r.isFinite()?Nf(e,r,(function(e,r){return e|r})):!e.isFinite()&&!e.isNegative()&&r.isNegative()||e.isNegative()&&!r.isNegative()&&!r.isFinite()?n:e.isNegative()&&r.isNegative()?e.isFinite()?e:r:e.isFinite()?r:e}function Nf(e,r,t){var n,i,a,o,u,s=e.constructor,c=+(e.s<0),l=+(r.s<0);if(c){n=Af(wf(e));for(var f=0;f<n.length;++f)n[f]^=1}else n=Af(e);if(l){i=Af(wf(r));for(var m=0;m<i.length;++m)i[m]^=1}else i=Af(r);n.length<=i.length?(a=n,o=i,u=c):(a=i,o=n,u=l);var d=a.length,p=o.length,h=1^t(c,l),v=new s(1^h),y=new s(1),b=new s(2),g=s.precision;for(s.config({precision:1e9});d>0;)t(a[--d],o[--p])===h&&(v=v.plus(y)),y=y.times(b);for(;p>0;)t(u,o[--p])===h&&(v=v.plus(y)),y=y.times(b);return s.config({precision:g}),0===h&&(v.s=-v.s),v}function Af(e){for(var r=e.d,t=r[0]+"",n=1;n<r.length;++n){for(var i=r[n]+"",a=7-i.length;a--;)i="0"+i;t+=i}for(var o=t.length;"0"===t.charAt(o);)o--;var u=e.e,s=t.slice(0,o+1||1),c=s.length;if(u>0)if(++u>c)for(u-=c;u--;)s+="0";else u<c&&(s=s.slice(0,u)+"."+s.slice(u));for(var l=[0],f=0;f<s.length;){for(var m=l.length;m--;)l[m]*=10;l[0]+=parseInt(s.charAt(f++));for(var d=0;d<l.length;++d)l[d]>1&&(null==l[d+1]&&(l[d+1]=0),l[d+1]+=l[d]>>1,l[d]&=1)}return l.reverse()}function Mf(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw Error("Integers expected in function bitXor");var t=e.constructor;if(e.isNaN()||r.isNaN())return new t(NaN);if(e.isZero())return r;if(r.isZero())return e;if(e.eq(r))return new t(0);var n=new t(-1);return e.eq(n)?wf(r):r.eq(n)?wf(e):e.isFinite()&&r.isFinite()?Nf(e,r,(function(e,r){return e^r})):e.isFinite()||r.isFinite()?new t(e.isNegative()===r.isNegative()?1/0:-1/0):n}function Cf(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw Error("Integers expected in function leftShift");var t=e.constructor;return e.isNaN()||r.isNaN()||r.isNegative()&&!r.isZero()?new t(NaN):e.isZero()||r.isZero()?e:e.isFinite()||r.isFinite()?r.lt(55)?e.times(Math.pow(2,r.toNumber())+""):e.times(new t(2).pow(r)):new t(NaN)}function Ef(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw Error("Integers expected in function rightArithShift");var t=e.constructor;return e.isNaN()||r.isNaN()||r.isNegative()&&!r.isZero()?new t(NaN):e.isZero()||r.isZero()?e:r.isFinite()?r.lt(55)?e.div(Math.pow(2,r.toNumber())+"").floor():e.div(new t(2).pow(r)).floor():e.isNegative()?new t(-1):e.isFinite()?new t(0):new t(NaN)}var Sf="bitAnd",Ff=ti(Sf,["typed","matrix","equalScalar","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,concat:i}=e,a=Fl({typed:r,equalScalar:n}),o=Jl({typed:r,equalScalar:n}),u=ul({typed:r,equalScalar:n}),s=Ol({typed:r,matrix:t,concat:i});return r(Sf,{"number, number":gs,"BigNumber, BigNumber":xf,"bigint, bigint":(e,r)=>e&r},s({SS:o,DS:a,Ss:u}))})),Bf="bitNot",qf=ti(Bf,["typed"],(e=>{var{typed:r}=e;return r(Bf,{number:xs,BigNumber:wf,bigint:e=>~e,"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Tf="bitOr",kf=ti(Tf,["typed","matrix","equalScalar","DenseMatrix","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,DenseMatrix:i,concat:a}=e,o=zl({typed:r}),u=jl({typed:r,equalScalar:n}),s=Rl({typed:r,DenseMatrix:i}),c=Ol({typed:r,matrix:t,concat:a});return r(Tf,{"number, number":ws,"BigNumber, BigNumber":Df,"bigint, bigint":(e,r)=>e|r},c({SS:u,DS:o,Ss:s}))})),Of=ti("matAlgo07xSSf",["typed","SparseMatrix"],(e=>{var{typed:r,SparseMatrix:t}=e;return function(e,i,a){var o=e._size,u=e._datatype||void 0===e._data?e._datatype:e.getDataType(),s=i._size,c=i._datatype||void 0===i._data?i._datatype:i.getDataType();if(o.length!==s.length)throw new ru(o.length,s.length);if(o[0]!==s[0]||o[1]!==s[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+s+")");var l,f=o[0],m=o[1],d=0,p=a;"string"==typeof u&&u===c&&"mixed"!==u&&(d=r.convert(0,l=u),p=r.find(a,[l,l]));for(var h=[],v=[],y=Array(m+1).fill(0),b=[],g=[],x=[],w=[],D=0;D<m;D++){var N=D+1,A=0;n(e,D,x,b,N),n(i,D,w,g,N);for(var M=0;M<f;M++){var C=p(x[M]===N?b[M]:d,w[M]===N?g[M]:d);0!==C&&!1!==C&&(v.push(M),h.push(C),A++)}y[D+1]=y[D]+A}return new t({values:h,index:v,ptr:y,size:[f,m],datatype:u===e._datatype&&c===i._datatype?l:void 0})};function n(e,r,t,n,i){for(var a=e._values,o=e._index,u=e._ptr,s=u[r],c=u[r+1];s<c;s++){var l=o[s];t[l]=i,n[l]=a[s]}}})),If="bitXor",zf=ti(If,["typed","matrix","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,matrix:t,DenseMatrix:n,concat:i,SparseMatrix:a}=e,o=Bl({typed:r}),u=Of({typed:r,SparseMatrix:a}),s=sl({typed:r,DenseMatrix:n}),c=Ol({typed:r,matrix:t,concat:i});return r(If,{"number, number":Ds,"BigNumber, BigNumber":Mf,"bigint, bigint":(e,r)=>e^r},c({SS:u,DS:o,Ss:s}))})),jf=ti("arg",["typed"],(e=>{var{typed:r}=e;return r("arg",{number:function(e){return Math.atan2(0,e)},BigNumber:function(e){return e.constructor.atan2(0,e)},Complex:function(e){return e.arg()},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Rf="conj",Uf=ti(Rf,["typed"],(e=>{var{typed:r}=e;return r(Rf,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),Unit:r.referToSelf((e=>r=>new r.constructor(e(r.toNumeric()),r.formatUnits()))),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),$f=ti("im",["typed"],(e=>{var{typed:r}=e;return r("im",{number:()=>0,"BigNumber | Fraction":e=>e.mul(0),Complex:e=>e.im,"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Pf=ti("re",["typed"],(e=>{var{typed:r}=e;return r("re",{"number | BigNumber | Fraction":e=>e,Complex:e=>e.re,"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Lf=ti("not",["typed"],(e=>{var{typed:r}=e;return r("not",{"null | undefined":()=>!0,number:Ts,Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},bigint:e=>!e,Unit:r.referToSelf((e=>t=>r.find(e,t.valueType())(t.value))),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),_f="nullish",Wf=ti(_f,["typed","matrix","size","flatten","deepEqual"],(e=>{var{typed:r,matrix:t,size:n,flatten:i,deepEqual:a}=e,o=Bl({typed:r}),u=cl({typed:r}),s=Tl({typed:r});return r(_f,{"number|bigint|Complex|BigNumber|Fraction|Unit|string|boolean|SparseMatrix, any":e=>e,"null, any":(e,r)=>r,"undefined, any":(e,r)=>r,"SparseMatrix, Array | Matrix":(e,r)=>{var t=i(n(e).valueOf()),o=i(n(r).valueOf());if(a(t,o))return e;throw new ru(t,o)},"DenseMatrix, DenseMatrix":r.referToSelf((e=>(r,t)=>s(r,t,e))),"DenseMatrix, SparseMatrix":r.referToSelf((e=>(r,t)=>o(r,t,e,!1))),"DenseMatrix, Array":r.referToSelf((e=>(r,n)=>s(r,t(n),e))),"DenseMatrix, any":r.referToSelf((e=>(r,t)=>u(r,t,e,!1))),"Array, Array":r.referToSelf((e=>(r,n)=>s(t(r),t(n),e).valueOf())),"Array, DenseMatrix":r.referToSelf((e=>(r,n)=>s(t(r),n,e))),"Array, SparseMatrix":r.referToSelf((e=>(r,n)=>o(t(r),n,e,!1))),"Array, any":r.referToSelf((e=>(r,n)=>u(t(r),n,e,!1).valueOf()))})})),Jf=ti("or",["typed","matrix","equalScalar","DenseMatrix","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,DenseMatrix:i,concat:a}=e,o=Bl({typed:r}),u=ql({typed:r,equalScalar:n}),s=sl({typed:r,DenseMatrix:i}),c=Ol({typed:r,matrix:t,concat:a});return r("or",{"number, number":ks,"Complex, Complex":function(e,r){return 0!==e.re||0!==e.im||0!==r.re||0!==r.im},"BigNumber, BigNumber":function(e,r){return!e.isZero()&&!e.isNaN()||!r.isZero()&&!r.isNaN()},"bigint, bigint":ks,"Unit, Unit":r.referToSelf((e=>(r,t)=>e(r.value||0,t.value||0)))},c({SS:u,DS:o,Ss:s}))})),Vf=ti("xor",["typed","matrix","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,matrix:t,DenseMatrix:n,concat:i,SparseMatrix:a}=e,o=Bl({typed:r}),u=Of({typed:r,SparseMatrix:a}),s=sl({typed:r,DenseMatrix:n}),c=Ol({typed:r,matrix:t,concat:i});return r("xor",{"number, number":Os,"Complex, Complex":function(e,r){return(0!==e.re||0!==e.im)!=(0!==r.re||0!==r.im)},"bigint, bigint":Os,"BigNumber, BigNumber":function(e,r){return(!e.isZero()&&!e.isNaN())!=(!r.isZero()&&!r.isNaN())},"Unit, Unit":r.referToSelf((e=>(r,t)=>e(r.value||0,t.value||0)))},c({SS:u,DS:o,Ss:s}))})),Hf="concat",Zf=ti(Hf,["typed","matrix","isInteger"],(e=>{var{typed:r,matrix:t,isInteger:n}=e;return r(Hf,{"...Array | Matrix | number | BigNumber":function(e){var r,i,a=e.length,o=-1,u=!1,s=[];for(r=0;r<a;r++){var c=e[r];if(cn(c)&&(u=!0),en(c)||rn(c)){if(r!==a-1)throw Error("Dimension must be specified as last argument");if(i=o,!n(o=c.valueOf()))throw new TypeError("Integer number expected for dimension");if(o<0||r>0&&o>i)throw new tu(o,i+1)}else{var l=Wn(c).valueOf(),f=nu(l);if(s[r]=l,i=o,o=f.length-1,r>0&&o!==i)throw new ru(i+1,o+1)}}if(0===s.length)throw new SyntaxError("At least one matrix expected");for(var m=s.shift();s.length;)m=Eu(m,s.shift(),o);return u?t(m):m},"...string":function(e){return e.join("")}})})),Gf="column",Xf=ti(Gf,["typed","Index","matrix","range"],(e=>{var{typed:r,Index:t,matrix:n,range:i}=e;return r(Gf,{"Matrix, number":a,"Array, number":function(e,r){return a(n(Wn(e)),r).valueOf()}});function a(e,r){if(2!==e.size().length)throw Error("Only two dimensional matrix is supported");uu(r,e.size()[1]);var a=i(0,e.size()[0]),o=new t(a,r),u=e.subset(o);return cn(u)?u:n([[u]])}})),Yf="count",Qf=ti(Yf,["typed","size","prod"],(e=>{var{typed:r,size:t,prod:n}=e;return r(Yf,{string:function(e){return e.length},"Matrix | Array":function(e){return n(t(e))}})})),Kf="cross",em=ti(Kf,["typed","matrix","subtract","multiply"],(e=>{var{typed:r,matrix:t,subtract:n,multiply:i}=e;return r(Kf,{"Matrix, Matrix":function(e,r){return t(a(e.toArray(),r.toArray()))},"Matrix, Array":function(e,r){return t(a(e.toArray(),r))},"Array, Matrix":function(e,r){return t(a(e,r.toArray()))},"Array, Array":a});function a(e,r){var t=Math.max(nu(e).length,nu(r).length);e=pu(e),r=pu(r);var a=nu(e),o=nu(r);if(1!==a.length||1!==o.length||3!==a[0]||3!==o[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+a.join(", ")+"], B = ["+o.join(", ")+"])");var u=[n(i(e[1],r[2]),i(e[2],r[1])),n(i(e[2],r[0]),i(e[0],r[2])),n(i(e[0],r[1]),i(e[1],r[0]))];return t>1?[u]:u}})),rm="diag",tm=ti(rm,["typed","matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:r,matrix:t,DenseMatrix:n,SparseMatrix:i}=e;return r(rm,{Array:function(e){return a(e,0,nu(e),null)},"Array, number":function(e,r){return a(e,r,nu(e),null)},"Array, BigNumber":function(e,r){return a(e,r.toNumber(),nu(e),null)},"Array, string":function(e,r){return a(e,0,nu(e),r)},"Array, number, string":function(e,r,t){return a(e,r,nu(e),t)},"Array, BigNumber, string":function(e,r,t){return a(e,r.toNumber(),nu(e),t)},Matrix:function(e){return a(e,0,e.size(),e.storage())},"Matrix, number":function(e,r){return a(e,r,e.size(),e.storage())},"Matrix, BigNumber":function(e,r){return a(e,r.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,r){return a(e,0,e.size(),r)},"Matrix, number, string":function(e,r,t){return a(e,r,e.size(),t)},"Matrix, BigNumber, string":function(e,r,t){return a(e,r.toNumber(),e.size(),t)}});function a(e,r,a,o){if(!ii(r))throw new TypeError("Second parameter in function diag must be an integer");var u=r>0?r:0,s=r<0?-r:0;switch(a.length){case 1:return function(e,r,t,a,o,u){var s=[a+o,a+u];if(t&&"sparse"!==t&&"dense"!==t)throw new TypeError("Unknown matrix type ".concat(t,'"'));var c="sparse"===t?i.diagonal(s,e,r):n.diagonal(s,e,r);return null!==t?c:c.valueOf()}(e,r,o,a[0],s,u);case 2:return function(e,r,n,i,a,o){if(cn(e)){var u=e.diagonal(r);return null!==n?n!==u.storage()?t(u,n):u:u.valueOf()}for(var s=Math.min(i[0]-a,i[1]-o),c=[],l=0;l<s;l++)c[l]=e[l+a][l+o];return null!==n?t(c):c}(e,r,o,a,s,u)}throw new RangeError("Matrix for function diag must be 2 dimensional")}})),nm=ti("filter",["typed"],(e=>{var{typed:r}=e;return r("filter",{"Array, function":im,"Matrix, function":function(e,r){return e.create(im(e.valueOf(),r),e.datatype())},"Array, RegExp":wu,"Matrix, RegExp":function(e,r){return e.create(wu(e.valueOf(),r),e.datatype())}})}));function im(e,r){var t=Iu(r,e,"filter");return function(e,r){if(1!==nu(e).length)throw Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,r)}(e,t.isUnary?t.fn:function(e,r,n){return t.fn(e,[r],n)})}var am="flatten",om=ti(am,["typed"],(e=>{var{typed:r}=e;return r(am,{Array:function(e){return bu(e)},Matrix:function(e){return e.create(bu(e.valueOf(),!0),e.datatype())}})})),um="forEach",sm=ti(um,["typed"],(e=>{var{typed:r}=e;return r(um,{"Array, function":cm,"Matrix, function":function(e,r){e.forEach(r)}})}));function cm(e,r){var t=Iu(r,e,um);Ou(e,t.fn,t.isUnary)}var lm="getMatrixDataType",fm=ti(lm,["typed"],(e=>{var{typed:r}=e;return r(lm,{Array:function(e){return Mu(e,_n)},Matrix:function(e){return e.getDataType()}})})),mm="identity",dm=ti(mm,["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],(e=>{var{typed:r,config:t,matrix:n,BigNumber:i,DenseMatrix:a,SparseMatrix:o}=e;return r(mm,{"":function(){return"Matrix"===t.matrix?n([]):[]},string:function(e){return n(e)},"number | BigNumber":function(e){return s(e,e,"Matrix"===t.matrix?"dense":void 0)},"number | BigNumber, string":function(e,r){return s(e,e,r)},"number | BigNumber, number | BigNumber":function(e,r){return s(e,r,"Matrix"===t.matrix?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(e,r,t){return s(e,r,t)},Array:function(e){return u(e)},"Array, string":function(e,r){return u(e,r)},Matrix:function(e){return u(e.valueOf(),e.storage())},"Matrix, string":function(e,r){return u(e.valueOf(),r)}});function u(e,r){switch(e.length){case 0:return r?n(r):[];case 1:return s(e[0],e[0],r);case 2:return s(e[0],e[1],r);default:throw Error("Vector containing two values expected")}}function s(e,r,t){var n=rn(e)||rn(r)?i:null;if(rn(e)&&(e=e.toNumber()),rn(r)&&(r=r.toNumber()),!ii(e)||e<1)throw Error("Parameters in function identity must be positive integers");if(!ii(r)||r<1)throw Error("Parameters in function identity must be positive integers");var u=n?new i(1):1,s=n?new n(0):0,c=[e,r];if(t){if("sparse"===t)return o.diagonal(c,u,0,s);if("dense"===t)return a.diagonal(c,u,0,s);throw new TypeError('Unknown matrix type "'.concat(t,'"'))}for(var l=cu([],c,s),f=e<r?e:r,m=0;m<f;m++)l[m][m]=u;return l}})),pm="kron",hm=ti(pm,["typed","matrix","multiplyScalar"],(e=>{var{typed:r,matrix:t,multiplyScalar:n}=e;return r(pm,{"Matrix, Matrix":function(e,r){return t(i(e.toArray(),r.toArray()))},"Matrix, Array":function(e,r){return t(i(e.toArray(),r))},"Array, Matrix":function(e,r){return t(i(e,r.toArray()))},"Array, Array":i});function i(e,r){if(1===nu(e).length&&(e=[e]),1===nu(r).length&&(r=[r]),nu(e).length>2||nu(r).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(e.length)+", y = "+JSON.stringify(r.length)+")");var t=[],i=[];return e.map((function(e){return r.map((function(r){return t.push(i=[]),e.map((function(e){return r.map((function(r){return i.push(n(e,r))}))}))}))}))&&t}})),vm="map",ym=ti(vm,["typed"],(e=>{var{typed:r}=e;return r(vm,{"Array, function":n,"Matrix, function":function(e,r){return e.map(r)},"Array|Matrix, Array|Matrix, ...Array|Matrix|function":(e,i,a)=>function(e,i){if("function"!=typeof i)throw Error("Last argument must be a callback function");var a=e[0].isMatrix,o=e.map((e=>e.isMatrix?e.size():nu(e))),u=Su(...o),s=e.length,c=a?(e,r)=>e.get(r):Tu,l=e.map(((e,r)=>{var t=o[r].map((()=>0));return e.isMatrix?e.get(t):Tu(e,t)})),f=r.isTypedFunction(i)?function(e,t,n,i){return null!==r.resolve(e,[...t,n,...i])?2:null!==r.resolve(e,[...t,n])?1:(r.resolve(e,t),0)}(i,l,u.map((()=>0)),e):function(e,r){var t=""+e;if(/arguments/.test(t))return 2;var n=t.match(/\(.*?\)/);return/\.\.\./.test(n)||e.length>r+1?2:e.length===r+1?1:0}(i,s);if(f<2){var m=t(f,i,null);return function(e,r){var t=e[0],n=e.map((e=>e.isMatrix?e.valueOf():e)),i=e.map((e=>e.isMatrix?e.size():nu(e))),a=Su(...i),o=i.map((e=>a.length-e.length)),u=a.length-1,s=r.length>1?[]:null,c=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=a[n],c=Array(i);if(n<u)for(var l=function(r){s&&(s[n]=r),c[r]=e(t.map(((e,t)=>o[t]>n?e:1===e.length?e[0]:e[r])),n+1)},f=0;f<i;f++)l(f);else for(var m=function(e){s&&(s[n]=e),c[e]=r(t.map((r=>1===r.length?r[0]:r[e])),s?s.slice():void 0)},d=0;d<i;d++)m(d);return c}(n,0);if(t.isMatrix){var l=t.create();return l._data=c,l._size=a,l}return c}(e,m)}var d=e.map(a?r=>r.isMatrix?r.create(Bu(r.toArray(),u),r.datatype()):e[0].create(Bu(r.valueOf(),u)):e=>Bu(e.isMatrix?e.toArray():e,u)),p=t(f,i,d),h=(e,r)=>p([e,...d.slice(1).map((e=>c(e,r)))],r);return a?d[0].map(h):n(d[0],h)}([e,i,...a.slice(0,a.length-1)],a[a.length-1])});function t(e,r,t){switch(e){case 0:return e=>r(...e);case 1:return(e,t)=>r(...e,t);case 2:return(e,n)=>r(...e,n,...t)}}function n(e,r){var t=Iu(r,e,vm);return ku(e,t.fn,t.isUnary)}})),bm="diff",gm=ti(bm,["typed","matrix","subtract","number"],(e=>{var{typed:r,matrix:t,subtract:n,number:i}=e;return r(bm,{"Array | Matrix":function(e){return cn(e)?t(o(e.toArray())):o(e)},"Array | Matrix, number":function(e,r){if(!ii(r))throw new RangeError("Dimension must be a whole number");return cn(e)?t(a(e.toArray(),r)):a(e,r)},"Array, BigNumber":r.referTo("Array,number",(e=>(r,t)=>e(r,i(t)))),"Matrix, BigNumber":r.referTo("Matrix,number",(e=>(r,t)=>e(r,i(t))))});function a(e,r){if(cn(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError("Array/Matrix does not have that many dimensions");if(r>0){var t=[];return e.forEach((e=>{t.push(a(e,r-1))})),t}if(0===r)return o(e);throw RangeError("Cannot have negative dimension")}function o(e){for(var r=[],t=e.length,n=1;n<t;n++)r.push(u(e[n-1],e[n]));return r}function u(e,r){cn(e)&&(e=e.toArray()),cn(r)&&(r=r.toArray());var t=Array.isArray(e),i=Array.isArray(r);if(t&&i)return function(e,r){if(e.length!==r.length)throw RangeError("Not all sub-arrays have the same length");for(var t=[],n=e.length,i=0;i<n;i++)t.push(u(e[i],r[i]));return t}(e,r);if(!t&&!i)return n(r,e);throw TypeError("Cannot calculate difference between 1 array and 1 non-array")}})),xm=ti("ones",["typed","config","matrix","BigNumber"],(e=>{var{typed:r,config:t,matrix:n,BigNumber:i}=e;return r("ones",{"":function(){return"Array"===t.matrix?a([]):a([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var r=e.pop();return a(e,r)}return"Array"===t.matrix?a(e):a(e,"default")},Array:a,Matrix:function(e){var r=e.storage();return a(e.valueOf(),r)},"Array | Matrix, string":function(e,r){return a(e.valueOf(),r)}});function a(e,r){var t=function(e){var r=!1;return e.forEach((function(e,t,n){rn(e)&&(r=!0,n[t]=e.toNumber())})),r}(e),a=t?new i(1):1;if(function(e){e.forEach((function(e){if("number"!=typeof e||!ii(e)||e<0)throw Error("Parameters in function ones must be positive integers")}))}(e),r){var o=n(r);return e.length>0?o.resize(e,a):o}var u=[];return e.length>0?cu(u,e,a):u}}));function wm(){throw Error('No "bignumber" implementation available')}function Dm(){throw Error('No "fraction" implementation available')}function Nm(){throw Error('No "matrix" implementation available')}var Am="range",Mm=ti(Am,["typed","config","?matrix","?bignumber","equal","smaller","smallerEq","larger","largerEq","add","isZero","isPositive"],(e=>{var{typed:r,config:t,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:u,largerEq:s,add:c,isZero:l,isPositive:f}=e;return r(Am,{string:d,"string, boolean":d,number:function(e){throw new TypeError("Too few arguments to function range(): ".concat(e))},boolean:function(e){throw new TypeError("Unexpected type of argument 1 to function range(): ".concat(e,", number|bigint|BigNumber|Fraction"))},"number, number":function(e,r){return m(p(e,r,1,!1))},"number, number, number":function(e,r,t){return m(p(e,r,t,!1))},"number, number, boolean":function(e,r,t){return m(p(e,r,1,t))},"number, number, number, boolean":function(e,r,t,n){return m(p(e,r,t,n))},"bigint, bigint|number":function(e,r){return m(p(e,r,1n,!1))},"number, bigint":function(e,r){return m(p(BigInt(e),r,1n,!1))},"bigint, bigint|number, bigint|number":function(e,r,t){return m(p(e,r,BigInt(t),!1))},"number, bigint, bigint|number":function(e,r,t){return m(p(BigInt(e),r,BigInt(t),!1))},"bigint, bigint|number, boolean":function(e,r,t){return m(p(e,r,1n,t))},"number, bigint, boolean":function(e,r,t){return m(p(BigInt(e),r,1n,t))},"bigint, bigint|number, bigint|number, boolean":function(e,r,t,n){return m(p(e,r,BigInt(t),n))},"number, bigint, bigint|number, boolean":function(e,r,t,n){return m(p(BigInt(e),r,BigInt(t),n))},"BigNumber, BigNumber":function(e,r){return m(p(e,r,new(0,e.constructor)(1),!1))},"BigNumber, BigNumber, BigNumber":function(e,r,t){return m(p(e,r,t,!1))},"BigNumber, BigNumber, boolean":function(e,r,t){return m(p(e,r,new(0,e.constructor)(1),t))},"BigNumber, BigNumber, BigNumber, boolean":function(e,r,t,n){return m(p(e,r,t,n))},"Fraction, Fraction":function(e,r){return m(p(e,r,1,!1))},"Fraction, Fraction, Fraction":function(e,r,t){return m(p(e,r,t,!1))},"Fraction, Fraction, boolean":function(e,r,t){return m(p(e,r,1,t))},"Fraction, Fraction, Fraction, boolean":function(e,r,t,n){return m(p(e,r,t,n))},"Unit, Unit, Unit":function(e,r,t){return m(p(e,r,t,!1))},"Unit, Unit, Unit, boolean":function(e,r,t,n){return m(p(e,r,t,n))}});function m(e){return"Matrix"===t.matrix?n?n(e):Nm():e}function d(e,r){var n=function(e){var r=e.split(":").map((function(e){return Number(e)}));if(r.some((function(e){return isNaN(e)})))return null;switch(r.length){case 2:return{start:r[0],end:r[1],step:1};case 3:return{start:r[0],end:r[2],step:r[1]};default:return null}}(e);if(!n)throw new SyntaxError('String "'+e+'" is no valid range');return"BigNumber"===t.number?(void 0===i&&wm(),m(p(i(n.start),i(n.end),i(n.step)))):m(p(n.start,n.end,n.step,r))}function p(e,r,t,n){var i=[];if(l(t))throw Error("Step must be non-zero");for(var m=f(t)?n?o:a:n?s:u,d=e;m(d,r);)i.push(d),d=c(d,t);return i}})),Cm="reshape",Em=ti(Cm,["typed","isInteger","matrix"],(e=>{var{typed:r,isInteger:t}=e;return r(Cm,{"Matrix, Array":function(e,r){return e.reshape(r,!0)},"Array, Array":function(e,r){return r.forEach((function(e){if(!t(e))throw new TypeError("Invalid size for dimension: "+e)})),fu(e,r)}})})),Sm=ti("resize",["config","matrix"],(e=>{var{config:r,matrix:t}=e;return function(e,n,i){if(2!==arguments.length&&3!==arguments.length)throw new Ul("resize",arguments.length,2,3);if(cn(n)&&(n=n.valueOf()),rn(n[0])&&(n=n.map((function(e){return rn(e)?e.toNumber():e}))),cn(e))return e.resize(n,i,!0);if("string"==typeof e)return function(e,r,t){if(void 0!==t){if("string"!=typeof t||1!==t.length)throw new TypeError("Single character expected as defaultValue")}else t=" ";if(1!==r.length)throw new ru(r.length,1);var n=r[0];if("number"!=typeof n||!ii(n))throw new TypeError("Invalid size, must contain positive integers (size: "+Go(r)+")");if(e.length>n)return e.substring(0,n);if(e.length<n){for(var i=e,a=0,o=n-e.length;a<o;a++)i+=t;return i}return e}(e,n,i);var a=!Array.isArray(e)&&"Array"!==r.matrix;if(0===n.length){for(;Array.isArray(e);)e=e[0];return Wn(e)}Array.isArray(e)||(e=[e]);var o=cu(e=Wn(e),n,i);return a?t(o):o}})),Fm="rotate",Bm=ti(Fm,["typed","multiply","rotationMatrix"],(e=>{var{typed:r,multiply:t,rotationMatrix:n}=e;return r(Fm,{"Array , number | BigNumber | Complex | Unit":function(e,r){return i(e,2),t(n(r),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,r){return i(e,2),t(n(r),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,r,a){return i(e,3),t(n(r,a),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,r,a){return i(e,3),t(n(r,a),e)}});function i(e,r){var t=Array.isArray(e)?nu(e):e.size();if(t.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(r));if(2===t.length&&1!==t[1])throw new RangeError("Vector must be of dimensions 1x".concat(r));if(t[0]!==r)throw new RangeError("Vector must be of dimensions 1x".concat(r))}})),qm="rotationMatrix",Tm=ti(qm,["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],(e=>{var{typed:r,config:t,multiplyScalar:n,addScalar:i,unaryMinus:a,norm:o,BigNumber:u,matrix:s,DenseMatrix:c,SparseMatrix:l,cos:f,sin:m}=e;return r(qm,{"":function(){return"Matrix"===t.matrix?s([]):[]},string:function(e){return s(e)},"number | BigNumber | Complex | Unit":function(e){return d(e,"Matrix"===t.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(e,r){return d(e,r)},"number | BigNumber | Complex | Unit, Array":function(e,r){var t=s(r);return p(t),y(e,t,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,r){p(r);var n=r.storage()||("Matrix"===t.matrix?"dense":void 0);return y(e,r,n)},"number | BigNumber | Complex | Unit, Array, string":function(e,r,t){var n=s(r);return p(n),y(e,n,t)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,r,t){return p(r),y(e,r,t)}});function d(e,r){var t=rn(e)?new u(-1):-1,i=f(e),a=m(e);return v([[i,n(t,a)],[a,i]],r)}function p(e){var r=e.size();if(r.length<1||3!==r[0])throw new RangeError("Vector must be of dimensions 1x3")}function h(e){return e.reduce(((e,r)=>n(e,r)))}function v(e,r){if(r){if("sparse"===r)return new l(e);if("dense"===r)return new c(e);throw new TypeError('Unknown matrix type "'.concat(r,'"'))}return e}function y(e,r,t){var n=o(r);if(0===n)throw new RangeError("Rotation around zero vector");var s=rn(e)?u:null,c=s?new s(1):1,l=s?new s(-1):-1,d=s?new s(r.get([0])/n):r.get([0])/n,p=s?new s(r.get([1])/n):r.get([1])/n,y=s?new s(r.get([2])/n):r.get([2])/n,b=f(e),g=i(c,a(b)),x=m(e);return v([[i(b,h([d,d,g])),i(h([d,p,g]),h([l,y,x])),i(h([d,y,g]),h([p,x]))],[i(h([d,p,g]),h([y,x])),i(b,h([p,p,g])),i(h([p,y,g]),h([l,d,x]))],[i(h([d,y,g]),h([l,p,x])),i(h([p,y,g]),h([d,x])),i(b,h([y,y,g]))]],t)}})),km=ti("row",["typed","Index","matrix","range"],(e=>{var{typed:r,Index:t,matrix:n,range:i}=e;return r("row",{"Matrix, number":a,"Array, number":function(e,r){return a(n(Wn(e)),r).valueOf()}});function a(e,r){if(2!==e.size().length)throw Error("Only two dimensional matrix is supported");uu(r,e.size()[0]);var a=i(0,e.size()[1]),o=new t(r,a),u=e.subset(o);return cn(u)?u:n([[u]])}})),Om="size",Im=ti(Om,["typed","config","?matrix"],(e=>{var{typed:r,config:t,matrix:n}=e;return r(Om,{Matrix:function(e){return e.create(e.size(),"number")},Array:nu,string:function(e){return"Array"===t.matrix?[e.length]:n([e.length],"dense","number")},"number | Complex | BigNumber | Unit | boolean | null":function(){return"Array"===t.matrix?[]:n?n([],"dense","number"):Nm()}})})),zm="squeeze",jm=ti(zm,["typed"],(e=>{var{typed:r}=e;return r(zm,{Array:function(e){return pu(Wn(e))},Matrix:function(e){var r=pu(e.toArray());return Array.isArray(r)?e.create(r,e.datatype()):r},any:function(e){return Wn(e)}})})),Rm="subset",Um=ti(Rm,["typed","matrix","zeros","add"],(e=>{var{typed:r,matrix:t,zeros:n,add:i}=e;return r(Rm,{"Matrix, Index":function(e,r){return su(r)?t():(ou(e,r),e.subset(r))},"Array, Index":r.referTo("Matrix, Index",(function(e){return function(r,n){var i=e(t(r),n);return n.isScalar()?i:i.valueOf()}})),"Object, Index":Lm,"string, Index":$m,"Matrix, Index, any, any":function(e,r,t,a){return su(r)?e:(ou(e,r),e.clone().subset(r,function(e,r){if("string"==typeof e)throw Error("can't boradcast a string");if(r._isScalar)return e;var t=r.size();if(!t.every((e=>e>0)))return e;try{return i(e,n(t))}catch(r){return e}}(t,r),a))},"Array, Index, any, any":r.referTo("Matrix, Index, any, any",(function(e){return function(r,n,i,a){var o=e(t(r),n,i,a);return o.isMatrix?o.valueOf():o}})),"Array, Index, any":r.referTo("Matrix, Index, any, any",(function(e){return function(r,n,i){return e(t(r),n,i,void 0).valueOf()}})),"Matrix, Index, any":r.referTo("Matrix, Index, any, any",(function(e){return function(r,t,n){return e(r,t,n,void 0)}})),"string, Index, string":Pm,"string, Index, string, string":Pm,"Object, Index, any":_m})}));function $m(e,r){if(!pn(r))throw new TypeError("Index expected");if(su(r))return"";if(ou(Array.from(e),r),1!==r.size().length)throw new ru(r.size().length,1);var t=e.length;uu(r.min()[0],t),uu(r.max()[0],t);var n=r.dimension(0),i="";return n.forEach((function(r){i+=e.charAt(r)})),i}function Pm(e,r,t,n){if(!r||!0!==r.isIndex)throw new TypeError("Index expected");if(su(r))return e;if(ou(Array.from(e),r),1!==r.size().length)throw new ru(r.size().length,1);if(void 0!==n){if("string"!=typeof n||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";var i=r.dimension(0);if(i.size()[0]!==t.length)throw new ru(i.size()[0],t.length);var a=e.length;uu(r.min()[0]),uu(r.max()[0]);for(var o=[],u=0;u<a;u++)o[u]=e.charAt(u);if(i.forEach((function(e,r){o[e]=t.charAt(r[0])})),o.length>a)for(var s=a-1,c=o.length;s<c;s++)o[s]||(o[s]=n);return o.join("")}function Lm(e,r){if(!su(r)){if(1!==r.size().length)throw new ru(r.size(),1);var t=r.dimension(0);if("string"!=typeof t)throw new TypeError("String expected as index to retrieve an object property");return _t(e,t)}}function _m(e,r,t){if(su(r))return e;if(1!==r.size().length)throw new ru(r.size(),1);var n=r.dimension(0);if("string"!=typeof n)throw new TypeError("String expected as index to retrieve an object property");var i=Wn(e);return Wt(i,n,t),i}var Wm="transpose",Jm=ti(Wm,["typed","matrix"],(e=>{var{typed:r,matrix:t}=e;return r(Wm,{Array:e=>n(t(e)).valueOf(),Matrix:n,any:Wn});function n(e){var r,t=e.size();switch(t.length){case 1:r=e.clone();break;case 2:var n=t[0],i=t[1];if(0===i)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+Go(t)+")");switch(e.storage()){case"dense":r=function(e,r,t){for(var n,i=e._data,a=[],o=0;o<t;o++){n=a[o]=[];for(var u=0;u<r;u++)n[u]=Wn(i[u][o])}return e.createDenseMatrix({data:a,size:[t,r],datatype:e._datatype})}(e,n,i);break;case"sparse":r=function(e,r,t){for(var n,i,a,o=e._values,u=e._index,s=e._ptr,c=o?[]:void 0,l=[],f=[],m=[],d=0;d<r;d++)m[d]=0;for(n=0,i=u.length;n<i;n++)m[u[n]]++;for(var p=0,h=0;h<r;h++)f.push(p),p+=m[h],m[h]=f[h];for(f.push(p),a=0;a<t;a++)for(var v=s[a+1],y=s[a];y<v;y++){var b=m[u[y]]++;l[b]=a,o&&(c[b]=Wn(o[y]))}return e.createSparseMatrix({values:c,index:l,ptr:f,size:[t,r],datatype:e._datatype})}(e,n,i)}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+Go(t)+")")}return r}})),Vm="ctranspose",Hm=ti(Vm,["typed","transpose","conj"],(e=>{var{typed:r,transpose:t,conj:n}=e;return r(Vm,{any:function(e){return n(t(e))}})})),Zm="zeros",Gm=ti(Zm,["typed","config","matrix","BigNumber"],(e=>{var{typed:r,config:t,matrix:n,BigNumber:i}=e;return r(Zm,{"":function(){return"Array"===t.matrix?a([]):a([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var r=e.pop();return a(e,r)}return"Array"===t.matrix?a(e):a(e,"default")},Array:a,Matrix:function(e){var r=e.storage();return a(e.valueOf(),r)},"Array | Matrix, string":function(e,r){return a(e.valueOf(),r)}});function a(e,r){var t=function(e){var r=!1;return e.forEach((function(e,t,n){rn(e)&&(r=!0,n[t]=e.toNumber())})),r}(e),a=t?new i(0):0;if(function(e){e.forEach((function(e){if("number"!=typeof e||!ii(e)||e<0)throw Error("Parameters in function zeros must be positive integers")}))}(e),r){var o=n(r);return e.length>0?o.resize(e,a):o}var u=[];return e.length>0?cu(u,e,a):u}})),Xm=ti("fft",["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i","dotDivide","conj","pow","ceil","log2"],(e=>{var{typed:r,addScalar:t,multiplyScalar:n,divideScalar:i,exp:a,tau:o,i:u,dotDivide:s,conj:c,pow:l,ceil:f,log2:m}=e;return r("fft",{Array:d,Matrix:function(e){return e.create(d(e.valueOf()),e.datatype())}});function d(e){var r=nu(e);return 1===r.length?h(e):p(e.map((e=>d(e,r.slice(1)))),0)}function p(e,r){var t=nu(e);if(0!==r)return Array(t[0]).fill(0).map(((t,n)=>p(e[n],r-1)));if(1===t.length)return h(e);function n(e){var r=nu(e);return Array(r[1]).fill(0).map(((t,n)=>Array(r[0]).fill(0).map(((r,t)=>e[t][n]))))}return n(p(n(e),1))}function h(e){var r=e.length;if(1===r)return[e[0]];if(r%2==0){for(var p=[...h(e.filter(((e,r)=>r%2==0))),...h(e.filter(((e,r)=>r%2==1)))],v=0;v<r/2;v++){var y=p[v],b=n(p[v+r/2],a(n(n(o,u),i(-v,r))));p[v]=t(y,b),p[v+r/2]=t(y,n(-1,b))}return p}return function(e){for(var r=e.length,t=a(i(n(-1,n(u,o)),r)),p=[],v=1-r;v<r;v++)p.push(l(t,i(l(v,2),2)));for(var y=l(2,f(m(r+r-1))),b=[...Array(r).fill(0).map(((t,i)=>n(e[i],p[r-1+i]))),...Array(y-r).fill(0)],g=[...Array(r+r-1).fill(0).map(((e,r)=>i(1,p[r]))),...Array(y-(r+r-1)).fill(0)],x=h(b),w=h(g),D=Array(y).fill(0).map(((e,r)=>n(x[r],w[r]))),N=s(c(d(c(D))),y),A=[],M=r-1;M<r+r-1;M++)A.push(n(N[M],p[M]));return A}(e)}})),Ym="ifft",Qm=ti(Ym,["typed","fft","dotDivide","conj"],(e=>{var{typed:r,fft:t,dotDivide:n,conj:i}=e;return r(Ym,{"Array | Matrix":function(e){var r=cn(e)?e.size():nu(e);return n(i(t(i(e))),r.reduce(((e,r)=>e*r),1))}})}));function Km(e){return Km="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Km(e)}function ed(e,r,t){return(r=function(e){var r=function(e,r){if("object"!=Km(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r);if("object"!=Km(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return e+""}(e,"string");return"symbol"==Km(r)?r:r+""}(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function rd(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}var td=ti("solveODE",["typed","add","subtract","multiply","divide","max","map","abs","isPositive","isNegative","larger","smaller","matrix","bignumber","unaryMinus"],(e=>{var{typed:r,add:t,subtract:n,multiply:i,divide:a,max:o,map:u,abs:s,isPositive:c,isNegative:l,larger:f,smaller:m,matrix:d,bignumber:p,unaryMinus:h}=e;function v(e){return function(r,d,v,y){if(2!==d.length||!d.every(x)&&!d.every(on))throw Error('"tspan" must be an Array of two numeric values or two units [tStart, tEnd]');var b=d[0],g=d[1],w=f(g,b),D=y.firstStep;if(void 0!==D&&!c(D))throw Error('"firstStep" must be positive');var N=y.maxStep;if(void 0!==N&&!c(N))throw Error('"maxStep" must be positive');var A=y.minStep;if(A&&l(A))throw Error('"minStep" must be positive or zero');var M=[b,g,D,A,N].filter((e=>void 0!==e));if(!M.every(x)&&!M.every(on))throw Error('Inconsistent type of "t" dependant variables');for(var C=y.tol?y.tol:1e-4,E=y.minDelta?y.minDelta:.2,S=y.maxDelta?y.maxDelta:5,F=y.maxIter?y.maxIter:1e4,B=[b,g,...v,N,A].some(rn),[q,T,k,O]=B?[p(e.a),p(e.c),p(e.b),p(e.bp)]:[e.a,e.c,e.b,e.bp],I=D?w?D:h(D):a(n(g,b),1),z=[b],j=[v],R=n(k,O),U=0,$=0,P=function(e){return e?m:f}(w),L=function(e){var r=e?f:m;return function(e,i,a){var o=t(e,a);return r(o,i)?n(i,e):a}}(w);P(z[U],g);){var _=[];I=L(z[U],g,I),_.push(r(z[U],j[U]));for(var W=1;W<T.length;++W)_.push(r(t(z[U],i(T[W],I)),t(j[U],i(I,q[W],_))));var J=o(s(u(i(R,_),(e=>on(e)?e.value:e))));J<C&&C/J>1/4&&(z.push(t(z[U],I)),j.push(t(j[U],i(I,k,_))),U++);var V=.84*(C/J)**.2;if(m(V,E)?V=E:f(V,S)&&(V=S),V=B?p(V):V,I=i(I,V),N&&f(s(I),N)?I=w?N:h(N):A&&m(s(I),A)&&(I=w?A:h(A)),++$>F)throw Error("Maximum number of iterations reached, try changing options")}return{t:z,y:j}}}function y(e,r,t,n){return v({a:[[],[.5],[0,3/4],[2/9,1/3,4/9]],c:[null,.5,3/4,1],b:[2/9,1/3,4/9,0],bp:[7/24,1/4,1/3,1/8]})(e,r,t,n)}function b(e,r,t,n){return v({a:[[],[.2],[3/40,9/40],[44/45,-56/15,32/9],[19372/6561,-25360/2187,64448/6561,-212/729],[9017/3168,-355/33,46732/5247,49/176,-5103/18656],[35/384,0,500/1113,125/192,-2187/6784,11/84]],c:[null,.2,.3,.8,8/9,1,1],b:[35/384,0,500/1113,125/192,-2187/6784,11/84,0],bp:[5179/57600,0,7571/16695,393/640,-92097/339200,187/2100,1/40]})(e,r,t,n)}function g(e,r,t,n){var i=n.method?n.method:"RK45",a={RK23:y,RK45:b};if(i.toUpperCase()in a){var o=function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?rd(Object(t),!0).forEach((function(r){ed(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):rd(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}({},n);return delete o.method,a[i.toUpperCase()](e,r,t,o)}var u=Object.keys(a).map((e=>'"'.concat(e,'"'))),s="".concat(u.slice(0,-1).join(", ")," and ").concat(u.slice(-1));throw Error('Unavailable method "'.concat(i,'". Available methods are ').concat(s))}function x(e){return rn(e)||en(e)}function w(e,r,t,n){var i=g(e,r.toArray(),t.toArray(),n);return{t:d(i.t),y:d(i.y)}}return r("solveODE",{"function, Array, Array, Object":g,"function, Matrix, Matrix, Object":w,"function, Array, Array":(e,r,t)=>g(e,r,t,{}),"function, Matrix, Matrix":(e,r,t)=>w(e,r,t,{}),"function, Array, number | BigNumber | Unit":(e,r,t)=>{var n=g(e,r,[t],{});return{t:n.t,y:n.y.map((e=>e[0]))}},"function, Matrix, number | BigNumber | Unit":(e,r,t)=>{var n=g(e,r.toArray(),[t],{});return{t:d(n.t),y:d(n.y.map((e=>e[0])))}},"function, Array, number | BigNumber | Unit, Object":(e,r,t,n)=>{var i=g(e,r,[t],n);return{t:i.t,y:i.y.map((e=>e[0]))}},"function, Matrix, number | BigNumber | Unit, Object":(e,r,t,n)=>{var i=g(e,r.toArray(),[t],n);return{t:d(i.t),y:d(i.y.map((e=>e[0])))}}})})),nd=ti("erf",["typed"],(e=>{var{typed:r}=e;return r("name",{number:function(e){var r=Math.abs(e);return r>=sd?oi(e):r<=id?oi(e)*function(e){var r,t=e*e,n=od[0][4]*t,i=t;for(r=0;r<3;r+=1)n=(n+od[0][r])*t,i=(i+ud[0][r])*t;return e*(n+od[0][3])/(i+ud[0][3])}(r):r<=4?oi(e)*(1-function(e){var r,t=od[1][8]*e,n=e;for(r=0;r<7;r+=1)t=(t+od[1][r])*e,n=(n+ud[1][r])*e;var i=(t+od[1][7])/(n+ud[1][7]),a=parseInt(16*e)/16,o=(e-a)*(e+a);return Math.exp(-a*a)*Math.exp(-o)*i}(r)):oi(e)*(1-function(e){var r,t=1/(e*e),n=od[2][5]*t,i=t;for(r=0;r<4;r+=1)n=(n+od[2][r])*t,i=(i+ud[2][r])*t;var a=t*(n+od[2][4])/(i+ud[2][4]);a=(ad-a)/e;var o=(e-(t=parseInt(16*e)/16))*(e+t);return Math.exp(-t*t)*Math.exp(-o)*a}(r))},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),id=.46875,ad=.5641895835477563,od=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],ud=[[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]],sd=Math.pow(2,53),cd="zeta",ld=ti(cd,["typed","config","multiply","pow","divide","factorial","equal","smallerEq","isNegative","gamma","sin","subtract","add","?Complex","?BigNumber","pi"],(e=>{var{typed:r,config:t,multiply:n,pow:i,divide:a,factorial:o,equal:u,smallerEq:s,isNegative:c,gamma:l,sin:f,subtract:m,add:d,Complex:p,BigNumber:h,pi:v}=e;return r(cd,{number:e=>y(e,(e=>e),(()=>20)),BigNumber:e=>y(e,(e=>new h(e)),(()=>Math.abs(Math.log10(t.relTol)))),Complex:function(e){return 0===e.re&&0===e.im?new p(-.5):1===e.re?new p(NaN,NaN):e.re===1/0&&0===e.im?new p(1):e.im===1/0||e.re===-1/0?new p(NaN,NaN):b(e,(e=>e),(e=>Math.round(19.5+.9*Math.abs(e.im))),(e=>e.re))}});function y(e,r,t){return u(e,0)?r(-.5):u(e,1)?r(NaN):isFinite(e)?b(e,r,t,(e=>e)):c(e)?r(NaN):r(1)}function b(e,r,t,o){var u=t(e);if(o(e)>-(u-1)/2)return function(e,r,t){for(var o=a(1,n(g(t(0),r),m(1,i(2,m(1,e))))),u=t(0),c=t(1);s(c,r);c=d(c,1))u=d(u,a(n((-1)**(c-1),g(c,r)),i(c,e)));return n(o,u)}(e,r(u),r);var c=n(i(2,e),i(r(v),m(e,1)));return c=n(c,f(n(a(r(v),2),e))),c=n(c,l(m(1,e))),n(c,b(m(1,e),r,t,o))}function g(e,r){for(var t=e,u=e;s(u,r);u=d(u,1)){var c=a(n(o(d(r,m(u,1))),i(4,u)),n(o(m(r,u)),o(n(2,u))));t=d(t,c)}return n(r,t)}})),fd="mode",md=ti(fd,["typed","isNaN","isNumeric"],(e=>{var{typed:r,isNaN:t,isNumeric:n}=e;return r(fd,{"Array | Matrix":i,"...":function(e){return i(e)}});function i(e){if(0===(e=bu(e.valueOf())).length)throw Error("Cannot calculate mode of an empty array");for(var r={},i=[],a=0,o=0;o<e.length;o++){var u=e[o];if(n(u)&&t(u))throw Error("Cannot calculate mode of an array containing NaN values");u in r||(r[u]=0),r[u]++,r[u]===a?i.push(u):r[u]>a&&(a=r[u],i=[u])}return i}}));function dd(e,r,t){var n;return(e+"").includes("Unexpected type")?(n=arguments.length>2?" (type: "+_n(t)+", value: "+JSON.stringify(t)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+r+", unexpected type of argument"+n)):(e+"").includes("complex numbers")?(n=arguments.length>2?" (type: "+_n(t)+", value: "+JSON.stringify(t)+")":"",new TypeError("Cannot calculate "+r+", no ordering relation is defined for complex numbers"+n)):e}var pd="prod",hd=ti(pd,["typed","config","multiplyScalar","numeric"],(e=>{var{typed:r,config:t,multiplyScalar:n,numeric:i}=e;return r(pd,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(){throw Error("prod(A, dim) is not yet supported")},"...":function(e){return a(e)}});function a(e){var r;if(_u(e,(function(e){try{r=void 0===r?e:n(r,e)}catch(r){throw dd(r,"prod",e)}})),"string"==typeof r&&(r=i(r,ai(r,t))),void 0===r)throw Error("Cannot calculate prod of an empty array");return r}})),vd="format",yd=ti(vd,["typed"],(e=>{var{typed:r}=e;return r(vd,{any:Go,"any, Object | function | number | BigNumber":Go})})),bd=ti("bin",["typed","format"],(e=>{var{typed:r,format:t}=e;return r("bin",{"number | BigNumber":function(e){return t(e,{notation:"bin"})},"number | BigNumber, number | BigNumber":function(e,r){return t(e,{notation:"bin",wordSize:r})}})})),gd=ti("oct",["typed","format"],(e=>{var{typed:r,format:t}=e;return r("oct",{"number | BigNumber":function(e){return t(e,{notation:"oct"})},"number | BigNumber, number | BigNumber":function(e,r){return t(e,{notation:"oct",wordSize:r})}})})),xd=ti("hex",["typed","format"],(e=>{var{typed:r,format:t}=e;return r("hex",{"number | BigNumber":function(e){return t(e,{notation:"hex"})},"number | BigNumber, number | BigNumber":function(e,r){return t(e,{notation:"hex",wordSize:r})}})})),wd=/\$([\w.]+)/g,Dd="print",Nd=ti(Dd,["typed"],(e=>{var{typed:r}=e;return r(Dd,{"string, Object | Array":Ad,"string, Object | Array, number | Object":Ad})}));function Ad(e,r,t){return e.replace(wd,(function(e,n){var i=n.split("."),a=r[i.shift()];for(void 0!==a&&a.isMatrix&&(a=a.toArray());i.length&&void 0!==a;){var o=i.shift();a=o?a[o]:a+"."}return void 0!==a?un(a)?a:Go(a,t):e}))}var Md=ti("to",["typed","matrix","concat"],(e=>{var{typed:r,matrix:t,concat:n}=e;return r("to",{"Unit, Unit | string":(e,r)=>e.to(r)},Ol({typed:r,matrix:t,concat:n})({Ds:!0}))})),Cd="toBest",Ed=ti(Cd,["typed"],(e=>{var{typed:r}=e;return r(Cd,{Unit:e=>e.toBest(),"Unit, string":(e,r)=>e.toBest(r.split(",")),"Unit, string, Object":(e,r,t)=>e.toBest(r.split(","),t),"Unit, Array":(e,r)=>e.toBest(r),"Unit, Array, Object":(e,r,t)=>e.toBest(r,t)})})),Sd="isPrime",Fd=ti(Sd,["typed"],(e=>{var{typed:r}=e;return r(Sd,{number:function(e){if(e<=3)return e>1;if(e%2==0||e%3==0)return!1;for(var r=5;r*r<=e;r+=6)if(e%r==0||e%(r+2)==0)return!1;return!0},bigint:function(e){if(e<=3n)return e>1n;if(e%2n===0n||e%3n===0n)return!1;for(var r=5n;r*r<=e;r+=6n)if(e%r===0n||e%(r+2n)===0n)return!1;return!0},BigNumber:function(e){if(e.lte(3))return e.gt(1);if(e.mod(2).eq(0)||e.mod(3).eq(0))return!1;if(e.lt(4294967296)){for(var r=e.toNumber(),t=5;t*t<=r;t+=6)if(r%t==0||r%(t+2)==0)return!1;return!0}function n(e,r,t){for(var n=1;!r.eq(0);)r.mod(2).eq(0)?(r=r.div(2),e=e.mul(e).mod(t)):(r=r.sub(1),n=e.mul(n).mod(t));return n}for(var i=e.constructor.clone({precision:2*e.toFixed(0).length}),a=0,o=(e=new i(e)).sub(1);o.mod(2).eq(0);)o=o.div(2),a+=1;var u=null;if(e.lt("3317044064679887385961981"))u=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter((r=>r<e));else{var s=Math.min(e.toNumber()-2,Math.floor(2*Math.pow(e.toFixed(0).length*Math.log(10),2)));u=[];for(var c=2;c<=s;c+=1)u.push(s)}for(var l=0;l<u.length;l+=1){var f=u[l],m=n(e.sub(e).add(f),o,e);if(!m.eq(1))for(var d=0,p=m;!p.eq(e.sub(1));d+=1,p=p.mul(p).mod(e))if(d===a-1)return!1}return!0},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Bd=ti("numeric",["number","?bignumber","?fraction"],(e=>{var{number:r,bignumber:t,fraction:n}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},a={number:e=>r(e),BigNumber:t?e=>t(e):wm,bigint:e=>BigInt(e),Fraction:n?e=>n(e):Dm};return function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"number";if(void 0!==(arguments.length>2?arguments[2]:void 0))throw new SyntaxError("numeric() takes one or two arguments");var t=_n(e);if(!(t in i))throw new TypeError("Cannot convert "+e+' of type "'+t+'"; valid input types are '+Object.keys(i).join(", "));if(!(r in a))throw new TypeError("Cannot convert "+e+' to type "'+r+'"; valid output types are '+Object.keys(a).join(", "));return r===t?e:a[r](e)}})),qd="divideScalar",Td=ti(qd,["typed","numeric"],(e=>{var{typed:r}=e;return r(qd,{"number, number":function(e,r){return e/r},"Complex, Complex":function(e,r){return e.div(r)},"BigNumber, BigNumber":function(e,r){return e.div(r)},"bigint, bigint":function(e,r){return e/r},"Fraction, Fraction":function(e,r){return e.div(r)},"Unit, number | Complex | Fraction | BigNumber | Unit":(e,r)=>e.divide(r),"number | Fraction | Complex | BigNumber, Unit":(e,r)=>r.divideInto(e)})})),kd=ti("pow",["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],(e=>{var{typed:r,config:t,identity:n,multiply:i,matrix:a,inv:o,number:u,fraction:s,Complex:c}=e;return r("pow",{"number, number":l,"Complex, Complex":function(e,r){return e.pow(r)},"BigNumber, BigNumber":function(e,r){return r.isInteger()||e>=0||t.predictable?e.pow(r):new c(e.toNumber(),0).pow(r.toNumber(),0)},"bigint, bigint":(e,r)=>e**r,"Fraction, Fraction":function(e,r){var n=e.pow(r);if(null!=n)return n;if(t.predictable)throw Error("Result of pow is non-rational and cannot be expressed as a fraction");return l(e.valueOf(),r.valueOf())},"Array, number":f,"Array, BigNumber":function(e,r){return f(e,r.toNumber())},"Matrix, number":m,"Matrix, BigNumber":function(e,r){return m(e,r.toNumber())},"Unit, number | BigNumber":function(e,r){return e.pow(r)}});function l(e,r){if(t.predictable&&!ii(r)&&e<0)try{var n=s(r),i=u(n);if((r===i||Math.abs((r-i)/r)<1e-14)&&n.d%2n===1n)return(n.n%2n===0n?1:-1)*Math.pow(-e,r)}catch(e){}return t.predictable&&(e<-1&&r===1/0||e>-1&&e<0&&r===-1/0)?NaN:ii(r)||e>=0||t.predictable?vs(e,r):e*e<1&&r===1/0||e*e>1&&r===-1/0?0:new c(e,0).pow(r,0)}function f(e,r){if(!ii(r))throw new TypeError("For A^b, b must be an integer (value is "+r+")");var t=nu(e);if(2!==t.length)throw Error("For A^b, A must be 2 dimensional (A has "+t.length+" dimensions)");if(t[0]!==t[1])throw Error("For A^b, A must be square (size is "+t[0]+"x"+t[1]+")");if(r<0)try{return f(o(e),-r)}catch(e){if("Cannot calculate inverse, determinant is zero"===e.message)throw new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+r+")");throw e}for(var a=n(t[0]).valueOf(),u=e;r>=1;)1&~r||(a=i(u,a)),r>>=1,u=i(u,u);return a}function m(e,r){return a(f(e.valueOf(),r))}})),Od="Number of decimals in function round must be an integer",Id="round",zd=ti(Id,["typed","config","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],(e=>{var{typed:r,config:t,matrix:n,equalScalar:i,zeros:a,BigNumber:o,DenseMatrix:u}=e,s=ul({typed:r,equalScalar:i}),c=sl({typed:r,DenseMatrix:u}),l=cl({typed:r});function f(e){return Math.abs(hi(e).exponent)}return r(Id,{number:function(e){var r=ys(e,f(t.relTol));return ys(xi(e,r,t.relTol,t.absTol)?r:e)},"number, number":function(e,r){var n=f(t.relTol);if(r>=n)return ys(e,r);var i=ys(e,n);return ys(xi(e,i,t.relTol,t.absTol)?i:e,r)},"number, BigNumber":function(e,r){if(!r.isInteger())throw new TypeError(Od);return new o(e).toDecimalPlaces(r.toNumber())},Complex:function(e){return e.round()},"Complex, number":function(e,r){if(r%1)throw new TypeError(Od);return e.round(r)},"Complex, BigNumber":function(e,r){if(!r.isInteger())throw new TypeError(Od);var t=r.toNumber();return e.round(t)},BigNumber:function(e){var r=new o(e).toDecimalPlaces(f(t.relTol));return(cc(e,r,t.relTol,t.absTol)?r:e).toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,r){if(!r.isInteger())throw new TypeError(Od);var n=f(t.relTol);if(r>=n)return e.toDecimalPlaces(r.toNumber());var i=e.toDecimalPlaces(n);return(cc(e,i,t.relTol,t.absTol)?i:e).toDecimalPlaces(r.toNumber())},bigint:e=>e,"bigint, number":e=>e,"bigint, BigNumber":e=>e,Fraction:function(e){return e.round()},"Fraction, number":function(e,r){if(r%1)throw new TypeError(Od);return e.round(r)},"Fraction, BigNumber":function(e,r){if(!r.isInteger())throw new TypeError(Od);return e.round(r.toNumber())},"Unit, number, Unit":r.referToSelf((e=>function(r,t,n){var i=r.toNumeric(n);return n.multiply(e(i,t))})),"Unit, BigNumber, Unit":r.referToSelf((e=>(r,t,n)=>e(r,t.toNumber(),n))),"Array | Matrix, number | BigNumber, Unit":r.referToSelf((e=>(r,t,n)=>Wu(r,(r=>e(r,t,n)),!0))),"Array | Matrix | Unit, Unit":r.referToSelf((e=>(r,t)=>e(r,0,t))),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e,!0))),"SparseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>s(r,t,e,!1))),"DenseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>l(r,t,e,!1))),"Array, number | BigNumber":r.referToSelf((e=>(r,t)=>l(n(r),t,e,!1).valueOf())),"number | Complex | BigNumber | Fraction, SparseMatrix":r.referToSelf((e=>(r,t)=>i(r,0)?a(t.size(),t.storage()):c(t,r,e,!0))),"number | Complex | BigNumber | Fraction, DenseMatrix":r.referToSelf((e=>(r,t)=>i(r,0)?a(t.size(),t.storage()):l(t,r,e,!0))),"number | Complex | BigNumber | Fraction, Array":r.referToSelf((e=>(r,t)=>l(n(t),r,e,!0).valueOf()))})})),jd=["config","typed","typeOf","divideScalar","Complex"],Rd=Math.log(16),Ud=ti("log",jd,(e=>{var{typed:r,typeOf:t,config:n,divideScalar:i,Complex:a}=e;function o(e){return e.log()}function u(e){return o(new a(e,0))}return r("log",{number:function(e){return e>=0||n.predictable?cs(e):u(e)},bigint:Hl(Rd,cs,n,u),Complex:o,BigNumber:function(e){return!e.isNegative()||n.predictable?e.ln():u(e.toNumber())},"any, any":r.referToSelf((e=>(r,n)=>{if("Fraction"===t(r)&&"Fraction"===t(n)){var a=r.log(n);if(null!==a)return a}return i(e(r),e(n))}))})})),$d="log1p",Pd=ti($d,["typed","config","divideScalar","log","Complex"],(e=>{var{typed:r,config:t,divideScalar:n,log:i,Complex:a}=e;return r($d,{number:function(e){return e>=-1||t.predictable?ci(e):o(new a(e,0))},Complex:o,BigNumber:function(e){var r=e.plus(1);return!r.isNegative()||t.predictable?r.ln():o(new a(e.toNumber(),0))},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e))),"any, any":r.referToSelf((e=>(r,t)=>n(e(r),i(t))))});function o(e){var r=e.re+1;return new a(Math.log(Math.sqrt(r*r+e.im*e.im)),Math.atan2(e.im,r))}})),Ld="nthRoots",_d=ti(Ld,["config","typed","divideScalar","Complex"],(e=>{var{typed:r,Complex:t}=e,n=[function(e){return new t(e,0)},function(e){return new t(0,e)},function(e){return new t(-e,0)},function(e){return new t(0,-e)}];function i(e,r){if(r<0)throw Error("Root must be greater than zero");if(0===r)throw Error("Root must be non-zero");if(r%1!=0)throw Error("Root must be an integer");if(0===e||0===e.abs())return[new t(0,0)];var i,a="number"==typeof e;(a||0===e.re||0===e.im)&&(i=a?2*+(e<0):0===e.im?2*+(e.re<0):2*+(e.im<0)+1);for(var o=e.arg(),u=e.abs(),s=[],c=Math.pow(u,1/r),l=0;l<r;l++){var f=(i+4*l)/r;s.push(f!==Math.round(f)?new t({r:c,phi:(o+2*Math.PI*l)/r}):n[f%4](c))}return s}return r(Ld,{Complex:function(e){return i(e,2)},"Complex, number":i})})),Wd="dotPow",Jd=ti(Wd,["typed","equalScalar","matrix","pow","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,equalScalar:t,matrix:n,pow:i,DenseMatrix:a,concat:o,SparseMatrix:u}=e,s=Bl({typed:r}),c=Of({typed:r,SparseMatrix:u}),l=ul({typed:r,equalScalar:t}),f=sl({typed:r,DenseMatrix:a}),m=Ol({typed:r,matrix:n,concat:o}),d={};for(var p in i.signatures)Object.prototype.hasOwnProperty.call(i.signatures,p)&&(p.includes("Matrix")||p.includes("Array")||(d[p]=i.signatures[p]));var h=r(d);return r(Wd,m({elop:h,SS:c,DS:s,Ss:l,sS:f}))})),Vd="dotDivide",Hd=ti(Vd,["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,matrix:t,equalScalar:n,divideScalar:i,DenseMatrix:a,concat:o,SparseMatrix:u}=e,s=Fl({typed:r,equalScalar:n}),c=Bl({typed:r}),l=Of({typed:r,SparseMatrix:u}),f=ul({typed:r,equalScalar:n}),m=sl({typed:r,DenseMatrix:a}),d=Ol({typed:r,matrix:t,concat:o});return r(Vd,d({elop:i,SS:l,DS:c,SD:s,Ss:f,sS:m}))}));function Zd(e){var{DenseMatrix:r}=e;return function(e,t,n){var i=e.size();if(2!==i.length)throw new RangeError("Matrix must be two dimensional (size: "+Go(i)+")");var a=i[0];if(a!==i[1])throw new RangeError("Matrix must be square (size: "+Go(i)+")");var o=[];if(cn(t)){var u=t.size(),s=t._data;if(1===u.length){if(u[0]!==a)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var c=0;c<a;c++)o[c]=[s[c]];return new r({data:o,size:[a,1],datatype:t._datatype})}if(2===u.length){if(u[0]!==a||1!==u[1])throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");if(fn(t)){if(n){o=[];for(var l=0;l<a;l++)o[l]=[s[l][0]];return new r({data:o,size:[a,1],datatype:t._datatype})}return t}if(mn(t)){for(var f=0;f<a;f++)o[f]=[0];for(var m=t._values,d=t._index,p=t._ptr,h=p[1],v=p[0];v<h;v++)o[d[v]][0]=m[v];return new r({data:o,size:[a,1],datatype:t._datatype})}}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}if(sn(t)){var y=nu(t);if(1===y.length){if(y[0]!==a)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var b=0;b<a;b++)o[b]=[t[b]];return new r({data:o,size:[a,1]})}if(2===y.length){if(y[0]!==a||1!==y[1])throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var g=0;g<a;g++)o[g]=[t[g][0]];return new r({data:o,size:[a,1]})}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}}}var Gd,Xd,Yd="lsolve",Qd=ti(Yd,["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],(e=>{var{typed:r,matrix:t,divideScalar:n,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:u}=e,s=Zd({DenseMatrix:u});return r(Yd,{"SparseMatrix, Array | Matrix":function(e,r){return function(e,r){for(var t=(r=s(e,r,!0))._data,c=e._size[0],l=e._size[1],f=e._values,m=e._index,d=e._ptr,p=[],h=0;h<l;h++){var v=t[h][0]||0;if(o(v,0))p[h]=[0];else{for(var y=0,b=[],g=[],x=d[h+1],w=d[h];w<x;w++){var D=m[w];D===h?y=f[w]:D>h&&(b.push(f[w]),g.push(D))}if(o(y,0))throw Error("Linear system cannot be solved since matrix is singular");for(var N=n(v,y),A=0,M=g.length;A<M;A++){var C=g[A];t[C]=[a(t[C][0]||0,i(N,b[A]))]}p[h]=[N]}}return new u({data:p,size:[c,1]})}(e,r)},"DenseMatrix, Array | Matrix":function(e,r){return c(e,r)},"Array, Array | Matrix":function(e,r){return c(t(e),r).valueOf()}});function c(e,r){for(var t=(r=s(e,r,!0))._data,c=e._size[0],l=e._size[1],f=[],m=e._data,d=0;d<l;d++){var p=t[d][0]||0,h=void 0;if(o(p,0))h=0;else{var v=m[d][d];if(o(v,0))throw Error("Linear system cannot be solved since matrix is singular");h=n(p,v);for(var y=d+1;y<c;y++)t[y]=[a(t[y][0]||0,i(h,m[y][d]))]}f[d]=[h]}return new u({data:f,size:[c,1]})}})),Kd="usolve",ep=ti(Kd,["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],(e=>{var{typed:r,matrix:t,divideScalar:n,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:u}=e,s=Zd({DenseMatrix:u});return r(Kd,{"SparseMatrix, Array | Matrix":function(e,r){return function(e,r){for(var t=(r=s(e,r,!0))._data,c=e._size[0],l=e._values,f=e._index,m=e._ptr,d=[],p=e._size[1]-1;p>=0;p--){var h=t[p][0]||0;if(o(h,0))d[p]=[0];else{for(var v=0,y=[],b=[],g=m[p],x=m[p+1]-1;x>=g;x--){var w=f[x];w===p?v=l[x]:w<p&&(y.push(l[x]),b.push(w))}if(o(v,0))throw Error("Linear system cannot be solved since matrix is singular");for(var D=n(h,v),N=0,A=b.length;N<A;N++){var M=b[N];t[M]=[a(t[M][0],i(D,y[N]))]}d[p]=[D]}}return new u({data:d,size:[c,1]})}(e,r)},"DenseMatrix, Array | Matrix":function(e,r){return c(e,r)},"Array, Array | Matrix":function(e,r){return c(t(e),r).valueOf()}});function c(e,r){for(var t=(r=s(e,r,!0))._data,c=e._size[0],l=[],f=e._data,m=e._size[1]-1;m>=0;m--){var d=t[m][0]||0,p=void 0;if(o(d,0))p=0;else{var h=f[m][m];if(o(h,0))throw Error("Linear system cannot be solved since matrix is singular");p=n(d,h);for(var v=m-1;v>=0;v--)t[v]=[a(t[v][0]||0,i(p,f[v][m]))]}l[m]=[p]}return new u({data:l,size:[c,1]})}})),rp="lsolveAll",tp=ti(rp,["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],(e=>{var{typed:r,matrix:t,divideScalar:n,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:u}=e,s=Zd({DenseMatrix:u});return r(rp,{"SparseMatrix, Array | Matrix":function(e,r){return function(e,r){for(var t=[s(e,r,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._size[1],f=e._values,m=e._index,d=e._ptr,p=0;p<l;p++)for(var h=t.length,v=0;v<h;v++){for(var y=t[v],b=[],g=[],x=d[p+1],w=0,D=d[p];D<x;D++){var N=m[D];N===p?w=f[D]:N>p&&(b.push(f[D]),g.push(N))}if(o(w,0))if(o(y[p],0)){if(0===v){var A=[...y];A[p]=1;for(var M=0,C=g.length;M<C;M++){var E=g[M];A[E]=a(A[E],b[M])}t.push(A)}}else{if(0===v)return[];t.splice(v,1),v-=1,h-=1}else{y[p]=n(y[p],w);for(var S=0,F=g.length;S<F;S++){var B=g[S];y[B]=a(y[B],i(y[p],b[S]))}}}return t.map((e=>new u({data:e.map((e=>[e])),size:[c,1]})))}(e,r)},"DenseMatrix, Array | Matrix":function(e,r){return c(e,r)},"Array, Array | Matrix":function(e,r){return c(t(e),r).map((e=>e.valueOf()))}});function c(e,r){for(var t=[s(e,r,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1],m=0;m<f;m++)for(var d=t.length,p=0;p<d;p++){var h=t[p];if(o(c[m][m],0))if(o(h[m],0)){if(0===p){var v=[...h];v[m]=1;for(var y=m+1;y<f;y++)v[y]=a(v[y],c[y][m]);t.push(v)}}else{if(0===p)return[];t.splice(p,1),p-=1,d-=1}else{h[m]=n(h[m],c[m][m]);for(var b=m+1;b<f;b++)h[b]=a(h[b],i(h[m],c[b][m]))}}return t.map((e=>new u({data:e.map((e=>[e])),size:[l,1]})))}})),np="usolveAll",ip=ti(np,["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],(e=>{var{typed:r,matrix:t,divideScalar:n,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:u}=e,s=Zd({DenseMatrix:u});return r(np,{"SparseMatrix, Array | Matrix":function(e,r){return function(e,r){for(var t=[s(e,r,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._values,f=e._index,m=e._ptr,d=e._size[1]-1;d>=0;d--)for(var p=t.length,h=0;h<p;h++){for(var v=t[h],y=[],b=[],g=m[d],x=0,w=m[d+1]-1;w>=g;w--){var D=f[w];D===d?x=l[w]:D<d&&(y.push(l[w]),b.push(D))}if(o(x,0))if(o(v[d],0)){if(0===h){var N=[...v];N[d]=1;for(var A=0,M=b.length;A<M;A++){var C=b[A];N[C]=a(N[C],y[A])}t.push(N)}}else{if(0===h)return[];t.splice(h,1),h-=1,p-=1}else{v[d]=n(v[d],x);for(var E=0,S=b.length;E<S;E++){var F=b[E];v[F]=a(v[F],i(v[d],y[E]))}}}return t.map((e=>new u({data:e.map((e=>[e])),size:[c,1]})))}(e,r)},"DenseMatrix, Array | Matrix":function(e,r){return c(e,r)},"Array, Array | Matrix":function(e,r){return c(t(e),r).map((e=>e.valueOf()))}});function c(e,r){for(var t=[s(e,r,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1]-1;f>=0;f--)for(var m=t.length,d=0;d<m;d++){var p=t[d];if(o(c[f][f],0))if(o(p[f],0)){if(0===d){var h=[...p];h[f]=1;for(var v=f-1;v>=0;v--)h[v]=a(h[v],c[v][f]);t.push(h)}}else{if(0===d)return[];t.splice(d,1),d-=1,m-=1}else{p[f]=n(p[f],c[f][f]);for(var y=f-1;y>=0;y--)p[y]=a(p[y],i(p[f],c[y][f]))}}return t.map((e=>new u({data:e.map((e=>[e])),size:[l,1]})))}})),ap=ti("matAlgo08xS0Sid",["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return function(e,n,i){var a=e._values,o=e._index,u=e._ptr,s=e._size,c=e._datatype||void 0===e._data?e._datatype:e.getDataType(),l=n._values,f=n._index,m=n._ptr,d=n._size,p=n._datatype||void 0===n._data?n._datatype:n.getDataType();if(s.length!==d.length)throw new ru(s.length,d.length);if(s[0]!==d[0]||s[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+d+")");if(!a||!l)throw Error("Cannot perform operation on Pattern Sparse Matrices");var h,v=s[0],y=s[1],b=t,g=0,x=i;"string"==typeof c&&c===p&&"mixed"!==c&&(b=r.find(t,[h=c,h]),g=r.convert(0,h),x=r.find(i,[h,h]));for(var w,D,N,A=[],M=[],C=[],E=[],S=[],F=0;F<y;F++){C[F]=M.length;var B=F+1;for(D=u[F+1],w=u[F];w<D;w++)S[N=o[w]]=B,E[N]=a[w],M.push(N);for(D=m[F+1],w=m[F];w<D;w++)S[N=f[w]]===B&&(E[N]=x(E[N],l[w]));for(w=C[F];w<M.length;){var q=E[N=M[w]];b(q,g)?M.splice(w,1):(A.push(q),w++)}}return C[y]=M.length,e.createSparseMatrix({values:A,index:M,ptr:C,size:[v,y],datatype:c===e._datatype&&p===n._datatype?h:void 0})}})),op=ti("useMatrixForArrayScalar",["typed","matrix"],(e=>{var{typed:r,matrix:t}=e;return{"Array, number":r.referTo("DenseMatrix, number",(e=>(r,n)=>e(t(r),n).valueOf())),"Array, BigNumber":r.referTo("DenseMatrix, BigNumber",(e=>(r,n)=>e(t(r),n).valueOf())),"number, Array":r.referTo("number, DenseMatrix",(e=>(r,n)=>e(r,t(n)).valueOf())),"BigNumber, Array":r.referTo("BigNumber, DenseMatrix",(e=>(r,n)=>e(r,t(n)).valueOf()))}})),up="leftShift",sp=ti(up,["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,zeros:i,DenseMatrix:a,concat:o}=e,u=zl({typed:r}),s=Fl({typed:r,equalScalar:n}),c=ap({typed:r,equalScalar:n}),l=Rl({typed:r,DenseMatrix:a}),f=ul({typed:r,equalScalar:n}),m=cl({typed:r}),d=Ol({typed:r,matrix:t,concat:o}),p=op({typed:r,matrix:t});return r(up,{"number, number":Ns,"BigNumber, BigNumber":Cf,"bigint, bigint":(e,r)=>e<<r,"SparseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>n(t,0)?r.clone():f(r,t,e,!1))),"DenseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>n(t,0)?r.clone():m(r,t,e,!1))),"number | BigNumber, SparseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):l(t,r,e,!0))),"number | BigNumber, DenseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):m(t,r,e,!0)))},p,d({SS:c,DS:u,SD:s}))})),cp="rightArithShift",lp=ti(cp,["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,zeros:i,DenseMatrix:a,concat:o}=e,u=zl({typed:r}),s=Fl({typed:r,equalScalar:n}),c=ap({typed:r,equalScalar:n}),l=Rl({typed:r,DenseMatrix:a}),f=ul({typed:r,equalScalar:n}),m=cl({typed:r}),d=Ol({typed:r,matrix:t,concat:o}),p=op({typed:r,matrix:t});return r(cp,{"number, number":As,"BigNumber, BigNumber":Ef,"bigint, bigint":(e,r)=>e>>r,"SparseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>n(t,0)?r.clone():f(r,t,e,!1))),"DenseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>n(t,0)?r.clone():m(r,t,e,!1))),"number | BigNumber, SparseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):l(t,r,e,!0))),"number | BigNumber, DenseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):m(t,r,e,!0)))},p,d({SS:c,DS:u,SD:s}))})),fp="rightLogShift",mp=ti(fp,["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,zeros:i,DenseMatrix:a,concat:o}=e,u=zl({typed:r}),s=Fl({typed:r,equalScalar:n}),c=ap({typed:r,equalScalar:n}),l=Rl({typed:r,DenseMatrix:a}),f=ul({typed:r,equalScalar:n}),m=cl({typed:r}),d=Ol({typed:r,matrix:t,concat:o}),p=op({typed:r,matrix:t});return r(fp,{"number, number":Ms,"SparseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>n(t,0)?r.clone():f(r,t,e,!1))),"DenseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>n(t,0)?r.clone():m(r,t,e,!1))),"number | BigNumber, SparseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):l(t,r,e,!0))),"number | BigNumber, DenseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):m(t,r,e,!0)))},p,d({SS:c,DS:u,SD:s}))})),dp=ti("and",["typed","matrix","equalScalar","zeros","not","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,zeros:i,not:a,concat:o}=e,u=Fl({typed:r,equalScalar:n}),s=Jl({typed:r,equalScalar:n}),c=ul({typed:r,equalScalar:n}),l=cl({typed:r}),f=Ol({typed:r,matrix:t,concat:o});return r("and",{"number, number":Is,"Complex, Complex":function(e,r){return!(0===e.re&&0===e.im||0===r.re&&0===r.im)},"BigNumber, BigNumber":function(e,r){return!(e.isZero()||r.isZero()||e.isNaN()||r.isNaN())},"bigint, bigint":Is,"Unit, Unit":r.referToSelf((e=>(r,t)=>e(r.value||0,t.value||0))),"SparseMatrix, any":r.referToSelf((e=>(r,t)=>a(t)?i(r.size(),r.storage()):c(r,t,e,!1))),"DenseMatrix, any":r.referToSelf((e=>(r,t)=>a(t)?i(r.size(),r.storage()):l(r,t,e,!1))),"any, SparseMatrix":r.referToSelf((e=>(r,t)=>a(r)?i(r.size(),r.storage()):c(t,r,e,!0))),"any, DenseMatrix":r.referToSelf((e=>(r,t)=>a(r)?i(r.size(),r.storage()):l(t,r,e,!0))),"Array, any":r.referToSelf((e=>(r,n)=>e(t(r),n).valueOf())),"any, Array":r.referToSelf((e=>(r,n)=>e(r,t(n)).valueOf()))},f({SS:s,DS:u}))})),pp="compare",hp=ti(pp,["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],(e=>{var{typed:r,config:t,equalScalar:n,matrix:i,BigNumber:a,Fraction:o,DenseMatrix:u,concat:s}=e,c=Bl({typed:r}),l=ql({typed:r,equalScalar:n}),f=sl({typed:r,DenseMatrix:u}),m=Ol({typed:r,matrix:i,concat:s}),d=Ac({typed:r});return r(pp,vp({typed:r,config:t}),{"boolean, boolean":function(e,r){return e===r?0:e>r?1:-1},"BigNumber, BigNumber":function(e,r){return cc(e,r,t.relTol,t.absTol)?new a(0):new a(e.cmp(r))},"bigint, bigint":function(e,r){return e===r?0n:e>r?1n:-1n},"Fraction, Fraction":function(e,r){return new o(e.compare(r))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},d,m({SS:l,DS:c,Ss:f}))})),vp=ti(pp,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(pp,{"number, number":function(e,r){return xi(e,r,t.relTol,t.absTol)?0:e>r?1:-1}})})),yp=(Xd||(Xd=1,Gd=function e(r,t){var n,i,a=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,o=/(^[ ]*|[ ]*$)/g,u=/(^([\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,c=/^0/,l=function(r){return e.insensitive&&(""+r).toLowerCase()||""+r},f=l(r).replace(o,"")||"",m=l(t).replace(o,"")||"",d=f.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),p=m.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),h=parseInt(f.match(s),16)||1!==d.length&&f.match(u)&&Date.parse(f),v=parseInt(m.match(s),16)||h&&m.match(u)&&Date.parse(m)||null;if(v){if(h<v)return-1;if(h>v)return 1}for(var y=0,b=Math.max(d.length,p.length);y<b;y++){if(n=!(d[y]||"").match(c)&&parseFloat(d[y])||d[y]||0,i=!(p[y]||"").match(c)&&parseFloat(p[y])||p[y]||0,isNaN(n)!==isNaN(i))return isNaN(n)?1:-1;if(typeof n!=typeof i&&(n+="",i+=""),n<i)return-1;if(n>i)return 1}return 0}),Gd),bp=Xn(yp),gp="compareNatural",xp=ti(gp,["typed","compare"],(e=>{var{typed:r,compare:t}=e,n=t.signatures["boolean,boolean"];return r(gp,{"any, any":function e(r,o){var u,s=_n(r),c=_n(o);if(!("number"!==s&&"BigNumber"!==s&&"Fraction"!==s||"number"!==c&&"BigNumber"!==c&&"Fraction"!==c))return""+(u=t(r,o))!="0"?u>0?1:-1:bp(s,c);var l=["Array","DenseMatrix","SparseMatrix"];if(l.includes(s)||l.includes(c))return 0!==(u=i(e,r,o))?u:bp(s,c);if(s!==c)return bp(s,c);if("Complex"===s)return function(e,r){return e.re>r.re?1:e.re<r.re?-1:e.im>r.im?1:e.im<r.im?-1:0}(r,o);if("Unit"===s)return r.equalBase(o)?e(r.value,o.value):a(e,r.formatUnits(),o.formatUnits());if("boolean"===s)return n(r,o);if("string"===s)return bp(r,o);if("Object"===s)return function(e,r,t){var n=Object.keys(r),i=Object.keys(t);n.sort(bp),i.sort(bp);var o=a(e,n,i);if(0!==o)return o;for(var u=0;u<n.length;u++){var s=e(r[n[u]],t[i[u]]);if(0!==s)return s}return 0}(e,r,o);if("null"===s)return 0;if("undefined"===s)return 0;throw new TypeError('Unsupported type of value "'+s+'"')}});function i(e,r,t){return mn(r)&&mn(t)?a(e,r.toJSON().values,t.toJSON().values):mn(r)?i(e,r.toArray(),t):mn(t)?i(e,r,t.toArray()):fn(r)?i(e,r.toJSON().data,t):fn(t)?i(e,r,t.toJSON().data):Array.isArray(r)?Array.isArray(t)?a(e,r,t):i(e,r,[t]):i(e,[r],t)}function a(e,r,t){for(var n=0,i=Math.min(r.length,t.length);n<i;n++){var a=e(r[n],t[n]);if(0!==a)return a}return r.length>t.length?1:r.length<t.length?-1:0}})),wp="compareText",Dp=["typed","matrix","concat"];eu.signature="any, any";var Np=ti(wp,Dp,(e=>{var{typed:r,matrix:t,concat:n}=e,i=Ol({typed:r,matrix:t,concat:n});return r(wp,eu,i({elop:eu,Ds:!0}))})),Ap="equal",Mp=ti(Ap,["typed","matrix","equalScalar","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,matrix:t,equalScalar:n,DenseMatrix:i,concat:a,SparseMatrix:o}=e,u=Bl({typed:r}),s=Of({typed:r,SparseMatrix:o}),c=sl({typed:r,DenseMatrix:i}),l=Ol({typed:r,matrix:t,concat:a});return r(Ap,Cp({typed:r,equalScalar:n}),l({elop:n,SS:s,DS:u,Ss:c}))})),Cp=ti(Ap,["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return r(Ap,{"any, any":function(e,r){return null===e?null===r:null===r?null===e:void 0===e?void 0===r:void 0===r?void 0===e:t(e,r)}})})),Ep="equalText",Sp=ti(Ep,["typed","compareText","isZero"],(e=>{var{typed:r,compareText:t,isZero:n}=e;return r(Ep,{"any, any":function(e,r){return n(t(e,r))}})})),Fp="smaller",Bp=ti(Fp,["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,config:t,bignumber:n,matrix:i,DenseMatrix:a,concat:o,SparseMatrix:u}=e,s=Bl({typed:r}),c=Of({typed:r,SparseMatrix:u}),l=sl({typed:r,DenseMatrix:a}),f=Ol({typed:r,matrix:i,concat:o}),m=Ac({typed:r});function d(e,r){return e.lt(r)&&!cc(e,r,t.relTol,t.absTol)}return r(Fp,qp({typed:r,config:t}),{"boolean, boolean":(e,r)=>e<r,"BigNumber, BigNumber":d,"bigint, bigint":(e,r)=>e<r,"Fraction, Fraction":(e,r)=>-1===e.compare(r),"Fraction, BigNumber":function(e,r){return d(n(e),r)},"BigNumber, Fraction":function(e,r){return d(e,n(r))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},m,f({SS:c,DS:s,Ss:l}))})),qp=ti(Fp,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(Fp,{"number, number":function(e,r){return e<r&&!xi(e,r,t.relTol,t.absTol)}})})),Tp="smallerEq",kp=ti(Tp,["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i,concat:a,SparseMatrix:o}=e,u=Bl({typed:r}),s=Of({typed:r,SparseMatrix:o}),c=sl({typed:r,DenseMatrix:i}),l=Ol({typed:r,matrix:n,concat:a}),f=Ac({typed:r});return r(Tp,Op({typed:r,config:t}),{"boolean, boolean":(e,r)=>e<=r,"BigNumber, BigNumber":function(e,r){return e.lte(r)||cc(e,r,t.relTol,t.absTol)},"bigint, bigint":(e,r)=>e<=r,"Fraction, Fraction":(e,r)=>1!==e.compare(r),"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},f,l({SS:s,DS:u,Ss:c}))})),Op=ti(Tp,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(Tp,{"number, number":function(e,r){return e<=r||xi(e,r,t.relTol,t.absTol)}})})),Ip="larger",zp=ti(Ip,["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,config:t,bignumber:n,matrix:i,DenseMatrix:a,concat:o,SparseMatrix:u}=e,s=Bl({typed:r}),c=Of({typed:r,SparseMatrix:u}),l=sl({typed:r,DenseMatrix:a}),f=Ol({typed:r,matrix:i,concat:o}),m=Ac({typed:r});function d(e,r){return e.gt(r)&&!cc(e,r,t.relTol,t.absTol)}return r(Ip,jp({typed:r,config:t}),{"boolean, boolean":(e,r)=>e>r,"BigNumber, BigNumber":d,"bigint, bigint":(e,r)=>e>r,"Fraction, Fraction":(e,r)=>1===e.compare(r),"Fraction, BigNumber":function(e,r){return d(n(e),r)},"BigNumber, Fraction":function(e,r){return d(e,n(r))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},m,f({SS:c,DS:s,Ss:l}))})),jp=ti(Ip,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(Ip,{"number, number":function(e,r){return e>r&&!xi(e,r,t.relTol,t.absTol)}})})),Rp="largerEq",Up=ti(Rp,["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i,concat:a,SparseMatrix:o}=e,u=Bl({typed:r}),s=Of({typed:r,SparseMatrix:o}),c=sl({typed:r,DenseMatrix:i}),l=Ol({typed:r,matrix:n,concat:a}),f=Ac({typed:r});return r(Rp,$p({typed:r,config:t}),{"boolean, boolean":(e,r)=>e>=r,"BigNumber, BigNumber":function(e,r){return e.gte(r)||cc(e,r,t.relTol,t.absTol)},"bigint, bigint":function(e,r){return e>=r},"Fraction, Fraction":(e,r)=>-1!==e.compare(r),"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},f,l({SS:s,DS:u,Ss:c}))})),$p=ti(Rp,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(Rp,{"number, number":function(e,r){return e>=r||xi(e,r,t.relTol,t.absTol)}})})),Pp="deepEqual",Lp=ti(Pp,["typed","equal"],(e=>{var{typed:r,equal:t}=e;return r(Pp,{"any, any":function(e,r){return n(e.valueOf(),r.valueOf())}});function n(e,r){if(Array.isArray(e)){if(Array.isArray(r)){var i=e.length;if(i!==r.length)return!1;for(var a=0;a<i;a++)if(!n(e[a],r[a]))return!1;return!0}return!1}return!Array.isArray(r)&&t(e,r)}})),_p="unequal",Wp=ti(_p,["typed","config","equalScalar","matrix","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,equalScalar:t,matrix:n,DenseMatrix:i,concat:a,SparseMatrix:o}=e,u=Bl({typed:r}),s=Of({typed:r,SparseMatrix:o}),c=sl({typed:r,DenseMatrix:i}),l=Ol({typed:r,matrix:n,concat:a});return r(_p,Jp({typed:r,equalScalar:t}),l({elop:function(e,r){return!t(e,r)},SS:s,DS:u,Ss:c}))})),Jp=ti(_p,["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return r(_p,{"any, any":function(e,r){return null===e?null!==r:null===r?null!==e:void 0===e?void 0!==r:void 0===r?void 0!==e:!t(e,r)}})})),Vp="partitionSelect",Hp=ti(Vp,["typed","isNumeric","isNaN","compare"],(e=>{var{typed:r,isNumeric:t,isNaN:n,compare:i}=e,a=i,o=(e,r)=>-i(e,r);return r(Vp,{"Array | Matrix, number":function(e,r){return u(e,r,a)},"Array | Matrix, number, string":function(e,r,t){if("asc"===t)return u(e,r,a);if("desc"===t)return u(e,r,o);throw Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":u});function u(e,r,t){if(!ii(r)||r<0)throw Error("k must be a non-negative integer");if(cn(e)){if(e.size().length>1)throw Error("Only one dimensional matrices supported");return s(e.valueOf(),r,t)}if(Array.isArray(e))return s(e,r,t)}function s(e,r,i){if(r>=e.length)throw Error("k out of bounds");for(var a=0;a<e.length;a++)if(t(e[a])&&n(e[a]))return e[a];for(var o=0,u=e.length-1;o<u;){for(var s=o,c=u,l=e[Math.floor(Math.random()*(u-o+1))+o];s<c;)if(i(e[s],l)>=0){var f=e[c];e[c]=e[s],e[s]=f,--c}else++s;i(e[s],l)>0&&--s,r<=s?u=s:o=s+1}return e[r]}})),Zp="sort",Gp=ti(Zp,["typed","matrix","compare","compareNatural"],(e=>{var{typed:r,matrix:t,compare:n,compareNatural:i}=e,a=n,o=(e,r)=>-n(e,r);return r(Zp,{Array:function(e){return s(e),e.sort(a)},Matrix:function(e){return c(e),t(e.toArray().sort(a),e.storage())},"Array, function":function(e,r){return s(e),e.sort(r)},"Matrix, function":function(e,r){return c(e),t(e.toArray().sort(r),e.storage())},"Array, string":function(e,r){return s(e),e.sort(u(r))},"Matrix, string":function(e,r){return c(e),t(e.toArray().sort(u(r)),e.storage())}});function u(e){if("asc"===e)return a;if("desc"===e)return o;if("natural"===e)return i;throw Error('String "asc", "desc", or "natural" expected')}function s(e){if(1!==nu(e).length)throw Error("One dimensional array expected")}function c(e){if(1!==e.size().length)throw Error("One dimensional matrix expected")}})),Xp=ti("max",["typed","config","numeric","larger","isNaN"],(e=>{var{typed:r,config:t,numeric:n,larger:i,isNaN:a}=e;return r("max",{"Array | Matrix":u,"Array | Matrix, number | BigNumber":function(e,r){return Ju(e,r.valueOf(),o)},"...":function(e){if(Lu(e))throw new TypeError("Scalar values expected in function max");return u(e)}});function o(e,r){try{return i(e,r)?e:r}catch(e){throw dd(e,"max",r)}}function u(e){var r;if(_u(e,(function(e){try{(a(e)||void 0===r||i(e,r))&&(r=e)}catch(r){throw dd(r,"max",e)}})),void 0===r)throw Error("Cannot calculate max of an empty array");return"string"==typeof r&&(r=n(r,ai(r,t))),r}})),Yp=ti("min",["typed","config","numeric","smaller","isNaN"],(e=>{var{typed:r,config:t,numeric:n,smaller:i,isNaN:a}=e;return r("min",{"Array | Matrix":u,"Array | Matrix, number | BigNumber":function(e,r){return Ju(e,r.valueOf(),o)},"...":function(e){if(Lu(e))throw new TypeError("Scalar values expected in function min");return u(e)}});function o(e,r){try{return i(e,r)?e:r}catch(e){throw dd(e,"min",r)}}function u(e){var r;if(_u(e,(function(e){try{(a(e)||void 0===r||i(e,r))&&(r=e)}catch(r){throw dd(r,"min",e)}})),void 0===r)throw Error("Cannot calculate min of an empty array");return"string"==typeof r&&(r=n(r,ai(r,t))),r}})),Qp=ti("ImmutableDenseMatrix",["smaller","DenseMatrix"],(e=>{var{smaller:r,DenseMatrix:t}=e;function n(e,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(r&&!un(r))throw Error("Invalid datatype: "+r);if(cn(e)||sn(e)){var i=new t(e,r);this._data=i._data,this._size=i._size,this._datatype=i._datatype,this._min=null,this._max=null}else if(e&&sn(e.data)&&sn(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=void 0!==e.min?e.min:null,this._max=void 0!==e.max?e.max:null;else{if(e)throw new TypeError("Unsupported type of data ("+_n(e)+")");this._data=[],this._size=[0],this._datatype=r,this._min=null,this._max=null}}return(n.prototype=new t).type="ImmutableDenseMatrix",n.prototype.isImmutableDenseMatrix=!0,n.prototype.subset=function(e){switch(arguments.length){case 1:var r=t.prototype.subset.call(this,e);return cn(r)?new n({data:r._data,size:r._size,datatype:r._datatype}):r;case 2:case 3:throw Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.set=function(){throw Error("Cannot invoke set on an Immutable Matrix instance")},n.prototype.resize=function(){throw Error("Cannot invoke resize on an Immutable Matrix instance")},n.prototype.reshape=function(){throw Error("Cannot invoke reshape on an Immutable Matrix instance")},n.prototype.clone=function(){return new n({data:Wn(this._data),size:Wn(this._size),datatype:this._datatype})},n.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.fromJSON=function(e){return new n(e)},n.prototype.swapRows=function(){throw Error("Cannot invoke swapRows on an Immutable Matrix instance")},n.prototype.min=function(){if(null===this._min){var e=null;this.forEach((function(t){(null===e||r(t,e))&&(e=t)})),this._min=null!==e?e:void 0}return this._min},n.prototype.max=function(){if(null===this._max){var e=null;this.forEach((function(t){(null===e||r(e,t))&&(e=t)})),this._max=null!==e?e:void 0}return this._max},n}),{isClass:!0}),Kp=ti("Index",["ImmutableDenseMatrix","getMatrixDataType"],(e=>{var{ImmutableDenseMatrix:r,getMatrixDataType:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._sourceSize=[],this._isScalar=!0;for(var r=0,a=arguments.length;r<a;r++){var o=arguments[r],u=sn(o),s=cn(o),c=typeof o,l=null;if(dn(o))this._dimensions.push(o),this._isScalar=!1;else if(u||s){var f=void 0;"boolean"===t(o)?(u&&(f=i(eh(o).valueOf())),s&&(f=i(eh(o._data).valueOf())),l=o.valueOf().length):f=i(o.valueOf()),this._dimensions.push(f);var m=f.size();1===m.length&&1===m[0]&&null===l||(this._isScalar=!1)}else if("number"===c)this._dimensions.push(i([o]));else if("bigint"===c)this._dimensions.push(i([Number(o)]));else{if("string"!==c)throw new TypeError("Dimension must be an Array, Matrix, number, bigint, string, or Range");this._dimensions.push(o)}this._sourceSize.push(l)}}function i(e){for(var t=0,n=e.length;t<n;t++)if("number"!=typeof e[t]||!ii(e[t]))throw new TypeError("Index parameters must be positive integer numbers");return new r(e)}return n.prototype.type="Index",n.prototype.isIndex=!0,n.prototype.clone=function(){var e=new n;return e._dimensions=Wn(this._dimensions),e._isScalar=this._isScalar,e._sourceSize=this._sourceSize,e},n.create=function(e){var r=new n;return n.apply(r,e),r},n.prototype.size=function(){for(var e=[],r=0,t=this._dimensions.length;r<t;r++){var n=this._dimensions[r];e[r]="string"==typeof n?1:n.size()[0]}return e},n.prototype.max=function(){for(var e=[],r=0,t=this._dimensions.length;r<t;r++){var n=this._dimensions[r];e[r]="string"==typeof n?n:n.max()}return e},n.prototype.min=function(){for(var e=[],r=0,t=this._dimensions.length;r<t;r++){var n=this._dimensions[r];e[r]="string"==typeof n?n:n.min()}return e},n.prototype.forEach=function(e){for(var r=0,t=this._dimensions.length;r<t;r++)e(this._dimensions[r],r,this)},n.prototype.dimension=function(e){return"number"!=typeof e?null:this._dimensions[e]||null},n.prototype.isObjectProperty=function(){return 1===this._dimensions.length&&"string"==typeof this._dimensions[0]},n.prototype.getObjectProperty=function(){return this.isObjectProperty()?this._dimensions[0]:null},n.prototype.isScalar=function(){return this._isScalar},n.prototype.toArray=function(){for(var e=[],r=0,t=this._dimensions.length;r<t;r++){var n=this._dimensions[r];e.push("string"==typeof n?n:n.toArray())}return e},n.prototype.valueOf=n.prototype.toArray,n.prototype.toString=function(){for(var e=[],r=0,t=this._dimensions.length;r<t;r++){var n=this._dimensions[r];e.push("string"==typeof n?JSON.stringify(n):""+n)}return"["+e.join(", ")+"]"},n.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},n.fromJSON=function(e){return n.create(e.dimensions)},n}),{isClass:!0});function eh(e){var r=[];return e.forEach(((e,t)=>{e&&r.push(t)})),r}var rh=ti("FibonacciHeap",["smaller","larger"],(e=>{var{smaller:r,larger:t}=e;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}function i(e,r,t){r.left.right=r.right,r.right.left=r.left,t.degree--,t.child===r&&(t.child=r.right),0===t.degree&&(t.child=null),r.left=e,r.right=e.right,e.right=r,r.right.left=r,r.parent=null,r.mark=!1}function a(e,r){var t=r.parent;t&&(r.mark?(i(e,r,t),a(t)):r.mark=!0)}n.prototype.type="FibonacciHeap",n.prototype.isFibonacciHeap=!0,n.prototype.insert=function(e,t){var n={key:e,value:t,degree:0};if(this._minimum){var i=this._minimum;n.left=i,n.right=i.right,i.right=n,n.right.left=n,r(e,i.key)&&(this._minimum=n)}else n.left=n,n.right=n,this._minimum=n;return this._size++,n},n.prototype.size=function(){return this._size},n.prototype.clear=function(){this._minimum=null,this._size=0},n.prototype.isEmpty=function(){return 0===this._size},n.prototype.extractMinimum=function(){var e=this._minimum;if(null===e)return e;for(var n=this._minimum,i=e.degree,a=e.child;i>0;){var u=a.right;a.left.right=a.right,a.right.left=a.left,a.left=n,a.right=n.right,n.right=a,a.right.left=a,a.parent=null,a=u,i--}return e.left.right=e.right,e.right.left=e.left,n=e===e.right?null:function(e,n){var i,a=Math.floor(2.0780869212350273*Math.log(n))+1,u=Array(a),s=0,c=e;if(c)for(s++,c=c.right;c!==e;)s++,c=c.right;for(;s>0;){for(var l=c.degree,f=c.right;i=u[l];){if(t(c.key,i.key)){var m=i;i=c,c=m}o(i,c),u[l]=null,l++}u[l]=c,c=f,s--}e=null;for(var d=0;d<a;d++)(i=u[d])&&(e?(i.left.right=i.right,i.right.left=i.left,i.left=e,i.right=e.right,e.right=i,i.right.left=i,r(i.key,e.key)&&(e=i)):e=i);return e}(n=e.right,this._size),this._size--,this._minimum=n,e},n.prototype.remove=function(e){this._minimum=function(e,t){t.key=-1;var n=t.parent;return n&&r(t.key,n.key)&&(i(e,t,n),a(e,n)),r(t.key,e.key)&&(e=t),e}(this._minimum,e),this.extractMinimum()};var o=function(e,r){e.left.right=e.right,e.right.left=e.left,e.parent=r,r.child?(e.left=r.child,e.right=r.child.right,r.child.right=e,e.right.left=e):(r.child=e,e.right=e,e.left=e),r.degree++,e.mark=!1};return n}),{isClass:!0}),th=ti("Spa",["addScalar","equalScalar","FibonacciHeap"],(e=>{var{addScalar:r,equalScalar:t,FibonacciHeap:n}=e;function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new n}return i.prototype.type="Spa",i.prototype.isSpa=!0,i.prototype.set=function(e,r){if(this._values[e])this._values[e].value=r;else{var t=this._heap.insert(e,r);this._values[e]=t}},i.prototype.get=function(e){var r=this._values[e];return r?r.value:0},i.prototype.accumulate=function(e,t){var n=this._values[e];n?n.value=r(n.value,t):(n=this._heap.insert(e,t),this._values[e]=n)},i.prototype.forEach=function(e,r,n){var i=this._heap,a=this._values,o=[],u=i.extractMinimum();for(u&&o.push(u);u&&u.key<=r;)u.key>=e&&(t(u.value,0)||n(u.key,u.value,this)),(u=i.extractMinimum())&&o.push(u);for(var s=0;s<o.length;s++){var c=o[s];a[(u=i.insert(c.key,c.value)).key]=u}},i.prototype.swap=function(e,r){var t=this._values[e],n=this._values[r];if(!t&&n)t=this._heap.insert(e,n.value),this._heap.remove(n),this._values[e]=t,this._values[r]=void 0;else if(t&&!n)n=this._heap.insert(r,t.value),this._heap.remove(t),this._values[r]=n,this._values[e]=void 0;else if(t&&n){var i=t.value;t.value=n.value,n.value=i}},i}),{isClass:!0});function nh(e){var r=0,t=1,n=Object.create(null),i=Object.create(null),a=0,o=function(e){var o=i[e];if(o&&(delete n[o],delete i[e],--r,t===o)){if(!r)return a=0,void(t=1);for(;!Object.prototype.hasOwnProperty.call(n,++t););}};return e=Math.abs(e),{hit:function(u){var s=i[u],c=++a;if(n[c]=u,i[u]=c,!s){if(++r<=e)return;return o(u=n[t]),u}if(delete n[s],t===s)for(;!Object.prototype.hasOwnProperty.call(n,++t););},delete:o,clear:function(){r=a=0,t=1,n=Object.create(null),i=Object.create(null)}}}function ih(e){var{hasher:r,limit:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t=null==t?1/0:t,r=null==r?JSON.stringify:r,function n(){"object"!=typeof n.cache&&(n.cache={values:new Map,lru:nh(t||1/0)});for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];var o=r(i);if(n.cache.values.has(o))return n.cache.lru.hit(o),n.cache.values.get(o);var u=e.apply(e,i);return n.cache.values.set(o,u),n.cache.values.delete(n.cache.lru.hit(o)),u}}var ah=ih((function(e){return new e(1).exp()}),{hasher:ch}),oh=ih((function(e){return new e(1).plus(new e(5).sqrt()).div(2)}),{hasher:ch}),uh=ih((function(e){return e.acos(-1)}),{hasher:ch}),sh=ih((function(e){return uh(e).times(2)}),{hasher:ch});function ch(e){return e[0].precision}function lh(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function fh(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?lh(Object(t),!0).forEach((function(r){ed(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):lh(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var mh=ti("Unit",["?on","config","addScalar","subtractScalar","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","toBest","number","Complex","BigNumber","Fraction"],(e=>{var r,t,n,{on:i,config:a,addScalar:o,subtractScalar:u,multiplyScalar:s,divideScalar:c,pow:l,abs:f,fix:m,round:d,equal:p,isNumeric:h,format:v,number:y,Complex:b,BigNumber:g,Fraction:x}=e,w=y;function D(e,r){if(!(this instanceof D))throw Error("Constructor must be called with the new operator");if(null!=e&&!h(e)&&!nn(e))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(this.fixPrefix=!1,this.skipAutomaticSimplification=!0,void 0===r)this.units=[],this.dimensions=I.map((()=>0));else if("string"==typeof r){var t=D.parse(r);this.units=t.units,this.dimensions=t.dimensions}else{if(!on(r)||null!==r.value)throw new TypeError("Second parameter in Unit constructor must be a string or valueless Unit");this.fixPrefix=r.fixPrefix,this.skipAutomaticSimplification=r.skipAutomaticSimplification,this.dimensions=r.dimensions.slice(0),this.units=r.units.map((e=>Pt({},e)))}this.value=this._normalize(e)}function N(){for(;" "===n||"\t"===n;)M()}function A(e){return e>="0"&&e<="9"}function M(){t++,n=r.charAt(t)}function C(e){n=r.charAt(t=e)}function E(){var e="",r=t;if("+"===n?M():"-"===n&&(e+=n,M()),!function(e){return e>="0"&&e<="9"||"."===e}(n))return C(r),null;if("."===n){if(e+=n,M(),!A(n))return C(r),null}else{for(;A(n);)e+=n,M();"."===n&&(e+=n,M())}for(;A(n);)e+=n,M();if("E"===n||"e"===n){var i="",a=t;if(i+=n,M(),"+"!==n&&"-"!==n||(i+=n,M()),!A(n))return C(a),e;for(e+=i;A(n);)e+=n,M()}return e}function S(){for(var e="";A(n)||D.isValidAlpha(n);)e+=n,M();var r=e.charAt(0);return D.isValidAlpha(r)?e:null}function F(e){return n===e?(M(),e):null}Object.defineProperty(D,"name",{value:"Unit"}),D.prototype.constructor=D,D.prototype.type="Unit",D.prototype.isUnit=!0,D.parse=function(e,i){if(i=i||{},t=-1,n="","string"!=typeof(r=e))throw new TypeError("Invalid argument in Unit.parse, string expected");var o=new D;o.units=[];var u=1,s=!1;M(),N();var c=E(),l=null;if(c){if("BigNumber"===a.number)l=new g(c);else if("Fraction"===a.number)try{l=new x(c)}catch(e){l=parseFloat(c)}else l=parseFloat(c);N(),F("*")?(u=1,s=!0):F("/")&&(u=-1,s=!0)}for(var f=[],m=1;;){for(N();"("===n;)f.push(u),m*=u,u=1,M(),N();var d;if(!n)break;var p=n;if(null===(d=S()))throw new SyntaxError('Unexpected "'+p+'" in "'+r+'" at index '+t);var h=B(d);if(null===h)throw new SyntaxError('Unit "'+d+'" not found.');var v=u*m;if(N(),F("^")){N();var y=E();if(null===y)throw new SyntaxError('In "'+e+'", "^" must be followed by a floating-point number');v*=y}o.units.push({unit:h.unit,prefix:h.prefix,power:v});for(var b=0;b<I.length;b++)o.dimensions[b]+=(h.unit.dimensions[b]||0)*v;for(N();")"===n;){if(0===f.length)throw new SyntaxError('Unmatched ")" in "'+r+'" at index '+t);m/=f.pop(),M(),N()}s=!1,F("*")?(u=1,s=!0):F("/")?(u=-1,s=!0):u=1,h.unit.base&&(L.auto[h.unit.base.key]={unit:h.unit,prefix:h.prefix})}if(N(),n)throw new SyntaxError('Could not parse: "'+e+'"');if(s)throw new SyntaxError('Trailing characters: "'+e+'"');if(0!==f.length)throw new SyntaxError('Unmatched "(" in "'+r+'"');if(0===o.units.length&&!i.allowNoUnits)throw new SyntaxError('"'+e+'" contains no units');return o.value=void 0!==l?o._normalize(l):null,o},D.prototype.clone=function(){var e=new D;e.fixPrefix=this.fixPrefix,e.skipAutomaticSimplification=this.skipAutomaticSimplification,e.value=Wn(this.value),e.dimensions=this.dimensions.slice(0),e.units=[];for(var r=0;r<this.units.length;r++)for(var t in e.units[r]={},this.units[r])Hn(this.units[r],t)&&(e.units[r][t]=this.units[r][t]);return e},D.prototype.valueType=function(){return _n(this.value)},D.prototype._isDerived=function(){return 0!==this.units.length&&(this.units.length>1||Math.abs(this.units[0].power-1)>1e-15)},D.prototype._normalize=function(e){if(null==e||0===this.units.length)return e;for(var r=e,t=D._getNumberConverter(_n(e)),n=0;n<this.units.length;n++){var i=t(this.units[n].unit.value),a=t(this.units[n].prefix.value),o=t(this.units[n].power);r=s(r,l(s(i,a),o))}return r},D.prototype._denormalize=function(e){if(null==e||0===this.units.length)return e;for(var r=e,t=D._getNumberConverter(_n(e)),n=0;n<this.units.length;n++){var i=t(this.units[n].unit.value),a=t(this.units[n].prefix.value),o=t(this.units[n].power);r=c(r,l(s(i,a),o))}return r};var B=ih((e=>{if(Hn(U,e)){var r=U[e];return{unit:r,prefix:r.prefixes[""]}}for(var t in U)if(Hn(U,t)&&Zo(e,t)){var n=U[t],i=e.substring(0,e.length-t.length),a=Hn(n.prefixes,i)?n.prefixes[i]:void 0;if(void 0!==a)return{unit:n,prefix:a}}return null}),{hasher:e=>e[0],limit:100});function q(e){return e.equalBase(z.NONE)&&null!==e.value&&!a.predictable?e.value:e}function T(e){return D._getNumberConverter(_n(e))(1)}function k(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=e.skipAutomaticSimplification||null===e.value?e.clone():e.simplify();!function(e){var r=!1;for(var t in null!=e.value&&nn(e.value)&&(r=Math.abs(e.value.re)<1e-14),e.units)Hn(e.units,t)&&e.units[t].unit&&("VA"===e.units[t].unit.name&&r?e.units[t].unit=U.VAR:"VAR"!==e.units[t].unit.name||r||(e.units[t].unit=U.VA))}(t),function(e,r){1!==e.units.length||e.fixPrefix||Math.abs(e.units[0].power-Math.round(e.units[0].power))<1e-14&&(e.units[0].prefix=e._bestPrefix(r))}(t,r.offset);var n=t._denormalize(t.value),i=null!==t.value?v(n,r||{}):"",a=t.formatUnits();return{simp:t,valueStr:i,unitStr:a}}D.isValuelessUnit=function(e){return null!==B(e)},D.prototype.hasBase=function(e){if("string"==typeof e&&(e=z[e]),!e)return!1;for(var r=0;r<I.length;r++)if(Math.abs((this.dimensions[r]||0)-(e.dimensions[r]||0))>1e-12)return!1;return!0},D.prototype.equalBase=function(e){for(var r=0;r<I.length;r++)if(Math.abs((this.dimensions[r]||0)-(e.dimensions[r]||0))>1e-12)return!1;return!0},D.prototype.equals=function(e){return this.equalBase(e)&&p(this.value,e.value)},D.prototype.multiply=function(e){for(var r=this.clone(),t=on(e)?e:new D(e),n=0;n<I.length;n++)r.dimensions[n]=(this.dimensions[n]||0)+(t.dimensions[n]||0);for(var i=0;i<t.units.length;i++){var a=fh({},t.units[i]);r.units.push(a)}if(null!==this.value||null!==t.value){var o=null===this.value?this._normalize(T(t.value)):this.value,u=null===t.value?t._normalize(T(this.value)):t.value;r.value=s(o,u)}else r.value=null;return on(e)&&(r.skipAutomaticSimplification=!1),q(r)},D.prototype.divideInto=function(e){return new D(e).divide(this)},D.prototype.divide=function(e){for(var r=this.clone(),t=on(e)?e:new D(e),n=0;n<I.length;n++)r.dimensions[n]=(this.dimensions[n]||0)-(t.dimensions[n]||0);for(var i=0;i<t.units.length;i++){var a=fh(fh({},t.units[i]),{},{power:-t.units[i].power});r.units.push(a)}if(null!==this.value||null!==t.value){var o=null===this.value?this._normalize(T(t.value)):this.value,u=null===t.value?t._normalize(T(this.value)):t.value;r.value=c(o,u)}else r.value=null;return on(e)&&(r.skipAutomaticSimplification=!1),q(r)},D.prototype.pow=function(e){for(var r=this.clone(),t=0;t<I.length;t++)r.dimensions[t]=(this.dimensions[t]||0)*e;for(var n=0;n<r.units.length;n++)r.units[n].power*=e;return r.value=null!==r.value?l(r.value,e):null,r.skipAutomaticSimplification=!1,q(r)},D.prototype.abs=function(){var e=this.clone();if(null!==e.value)if(e._isDerived()||0===e.units.length||0===e.units[0].unit.offset)e.value=f(e.value);else{var r=e._numberConverter(),t=r(e.units[0].unit.value),n=r(e.units[0].unit.offset),i=s(t,n);e.value=u(f(o(e.value,i)),i)}for(var a in e.units)"VA"!==e.units[a].unit.name&&"VAR"!==e.units[a].unit.name||(e.units[a].unit=U.W);return e},D.prototype.to=function(e){var r,t=null===this.value?this._normalize(1):this.value;if("string"==typeof e)r=D.parse(e);else{if(!on(e))throw Error("String or Unit expected as parameter");r=e.clone()}if(!this.equalBase(r))throw Error("Units do not match ('".concat(""+r,"' != '").concat(""+this,"')"));if(null!==r.value)throw Error("Cannot convert to a unit with a value");if(null===this.value||this._isDerived()||0===this.units.length||0===r.units.length||this.units[0].unit.offset===r.units[0].unit.offset)r.value=Wn(t);else{var n=D._getNumberConverter(_n(t)),i=s(this.units[0].unit.value,this.units[0].unit.offset),a=s(r.units[0].unit.value,r.units[0].unit.offset);r.value=o(t,n(u(i,a)))}return r.fixPrefix=!0,r.skipAutomaticSimplification=!0,r},D.prototype.toNumber=function(e){return w(this.toNumeric(e))},D.prototype.toNumeric=function(e){var r;return(r=e?this.to(e):this.clone())._isDerived()||0===r.units.length?r._denormalize(r.value):r._denormalize(r.value,r.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.units.length>0?this.formatUnits():null,fixPrefix:this.fixPrefix}},D.fromJSON=function(e){var r,t=new D(e.value,null!==(r=e.unit)&&void 0!==r?r:void 0);return t.fixPrefix=e.fixPrefix||!1,t},D.prototype.valueOf=D.prototype.toString,D.prototype.simplify=function(){var e,r,t=this.clone(),n=[];for(var i in _)if(Hn(_,i)&&t.hasBase(z[i])){e=i;break}if("NONE"===e)t.units=[];else if(e&&Hn(_,e)&&(r=_[e]),r)t.units=[{unit:r.unit,prefix:r.prefix,power:1}];else{for(var a=!1,o=0;o<I.length;o++){var u=I[o];Math.abs(t.dimensions[o]||0)>1e-12&&(Hn(_,u)?n.push({unit:_[u].unit,prefix:_[u].prefix,power:t.dimensions[o]||0}):a=!0)}n.length<t.units.length&&!a&&(t.units=n)}return t},D.prototype.toSI=function(){for(var e=this.clone(),r=[],t=0;t<I.length;t++){var n=I[t];if(Math.abs(e.dimensions[t]||0)>1e-12){if(!Hn(L.si,n))throw Error("Cannot express custom unit "+n+" in SI units");r.push({unit:L.si[n].unit,prefix:L.si[n].prefix,power:e.dimensions[t]||0})}}return e.units=r,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,null!==this.value?(e.value=null,this.to(e)):e},D.prototype.formatUnits=function(){for(var e="",r="",t=0,n=0,i=0;i<this.units.length;i++)this.units[i].power>0?(t++,e+=" "+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power-1)>1e-15&&(e+="^"+this.units[i].power)):this.units[i].power<0&&n++;if(n>0)for(var a=0;a<this.units.length;a++)this.units[a].power<0&&(t>0?(r+=" "+this.units[a].prefix.name+this.units[a].unit.name,Math.abs(this.units[a].power+1)>1e-15&&(r+="^"+-this.units[a].power)):(r+=" "+this.units[a].prefix.name+this.units[a].unit.name,r+="^"+this.units[a].power));e=e.substr(1),r=r.substr(1),t>1&&n>0&&(e="("+e+")"),n>1&&t>0&&(r="("+r+")");var o=e;return t>0&&n>0&&(o+=" / "),o+r},D.prototype.toBest=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e&&!Array.isArray(e))throw Error("Invalid unit type. Expected string or Unit.");var t=this.units[0].unit.prefixes;if(e&&e.length>0){var n=e.map((e=>{var r=null;if("string"==typeof e){if(!(r=D.parse(e)))throw Error("Invalid unit type. Expected compatible string or Unit.")}else if(!on(e))throw Error("Invalid unit type. Expected compatible string or Unit.");null===r&&(r=e.clone());try{return this.to(r.formatUnits()),r}catch(e){throw Error("Invalid unit type. Expected compatible string or Unit.")}})),i=n.map((e=>e.units[0].prefix));this.units[0].unit.prefixes=i.reduce(((e,r)=>(e[r.name]=r,e)),{}),this.units[0].prefix=i[0]}var a=k(this,r).simp;return this.units[0].unit.prefixes=t,a.fixPrefix=!0,a},D.prototype.format=function(e){var{simp:r,valueStr:t,unitStr:n}=k(this,e),i=t;return r.value&&nn(r.value)&&(i="("+i+")"),n.length>0&&i.length>0&&(i+=" "),i+n},D.prototype._bestPrefix=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1.2;if(1!==this.units.length)throw 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 Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var r=null!==this.value?f(this.value):0,t=f(this.units[0].unit.value),n=this.units[0].prefix;if(0===r)return n;var i=this.units[0].power,a=Math.log(r/Math.pow(n.value*t,i))/Math.LN10-e;if(a>-2.200001&&a<1.800001)return n;a=Math.abs(a);var o=this.units[0].unit.prefixes;for(var u in o)if(Hn(o,u)){var s=o[u];if(s.scientific){var c=Math.abs(Math.log(r/Math.pow(s.value*t,i))/Math.LN10-e);(c<a||c===a&&s.name.length<n.name.length)&&(n=s,a=c)}}return n},D.prototype.splitUnit=function(e){for(var r=this.clone(),t=[],n=0;n<e.length&&(r=r.to(e[n]),n!==e.length-1);n++){var i=r.toNumeric(),a=d(i),s=new D(p(a,i)?a:m(r.toNumeric()),""+e[n]);t.push(s),r=u(r,s)}for(var c=0,l=0;l<t.length;l++)c=o(c,t[l].value);return p(c,this.value)&&(r.value=0),t.push(r),t};var O={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},R:{name:"R",value:1e27,scientific:!0},Q:{name:"Q",value:1e30,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},r:{name:"r",value:1e-27,scientific:!0},q:{name:"q",value:1e-30,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},ronna:{name:"ronna",value:1e27,scientific:!0},quetta:{name:"quetta",value:1e30,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},ronto:{name:"ronto",value:1e-27,scientific:!0},quecto:{name:"quecto",value:1e-30,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},R:{name:"R",value:1e54,scientific:!0},Q:{name:"Q",value:1e60,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},r:{name:"r",value:1e-54,scientific:!0},q:{name:"q",value:1e-60,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},R:{name:"R",value:1e81,scientific:!0},Q:{name:"Q",value:1e90,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},r:{name:"r",value:1e-81,scientific:!0},q:{name:"q",value:1e-90,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:1048576,scientific:!0},Gi:{name:"Gi",value:1073741824,scientific:!0},Ti:{name:"Ti",value:1099511627776,scientific:!0},Pi:{name:"Pi",value:0x4000000000000,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:1048576,scientific:!0},gibi:{name:"gibi",value:1073741824,scientific:!0},tebi:{name:"tebi",value:1099511627776,scientific:!0},pebi:{name:"pebi",value:0x4000000000000,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}}};O.SHORTLONG=Pt({},O.SHORT,O.LONG),O.BINARY_SHORT=Pt({},O.BINARY_SHORT_SI,O.BINARY_SHORT_IEC),O.BINARY_LONG=Pt({},O.BINARY_LONG_SI,O.BINARY_LONG_IEC);var I=["MASS","LENGTH","TIME","CURRENT","TEMPERATURE","LUMINOUS_INTENSITY","AMOUNT_OF_SUBSTANCE","ANGLE","BIT"],z={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 j in z)Hn(z,j)&&(z[j].key=j);var R={name:"",base:{},value:1,offset:0,dimensions:I.map((()=>0))},U={meter:{name:"meter",base:z.LENGTH,prefixes:O.LONG,value:1,offset:0},inch:{name:"inch",base:z.LENGTH,prefixes:O.NONE,value:.0254,offset:0},foot:{name:"foot",base:z.LENGTH,prefixes:O.NONE,value:.3048,offset:0},yard:{name:"yard",base:z.LENGTH,prefixes:O.NONE,value:.9144,offset:0},mile:{name:"mile",base:z.LENGTH,prefixes:O.NONE,value:1609.344,offset:0},link:{name:"link",base:z.LENGTH,prefixes:O.NONE,value:.201168,offset:0},rod:{name:"rod",base:z.LENGTH,prefixes:O.NONE,value:5.0292,offset:0},chain:{name:"chain",base:z.LENGTH,prefixes:O.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:z.LENGTH,prefixes:O.NONE,value:1e-10,offset:0},m:{name:"m",base:z.LENGTH,prefixes:O.SHORT,value:1,offset:0},in:{name:"in",base:z.LENGTH,prefixes:O.NONE,value:.0254,offset:0},ft:{name:"ft",base:z.LENGTH,prefixes:O.NONE,value:.3048,offset:0},yd:{name:"yd",base:z.LENGTH,prefixes:O.NONE,value:.9144,offset:0},mi:{name:"mi",base:z.LENGTH,prefixes:O.NONE,value:1609.344,offset:0},li:{name:"li",base:z.LENGTH,prefixes:O.NONE,value:.201168,offset:0},rd:{name:"rd",base:z.LENGTH,prefixes:O.NONE,value:5.02921,offset:0},ch:{name:"ch",base:z.LENGTH,prefixes:O.NONE,value:20.1168,offset:0},mil:{name:"mil",base:z.LENGTH,prefixes:O.NONE,value:254e-7,offset:0},m2:{name:"m2",base:z.SURFACE,prefixes:O.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:z.SURFACE,prefixes:O.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:z.SURFACE,prefixes:O.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:z.SURFACE,prefixes:O.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:z.SURFACE,prefixes:O.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:z.SURFACE,prefixes:O.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:z.SURFACE,prefixes:O.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:z.SURFACE,prefixes:O.NONE,value:6.4516e-10,offset:0},acre:{name:"acre",base:z.SURFACE,prefixes:O.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:z.SURFACE,prefixes:O.NONE,value:1e4,offset:0},m3:{name:"m3",base:z.VOLUME,prefixes:O.CUBIC,value:1,offset:0},L:{name:"L",base:z.VOLUME,prefixes:O.SHORT,value:.001,offset:0},l:{name:"l",base:z.VOLUME,prefixes:O.SHORT,value:.001,offset:0},litre:{name:"litre",base:z.VOLUME,prefixes:O.LONG,value:.001,offset:0},cuin:{name:"cuin",base:z.VOLUME,prefixes:O.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:z.VOLUME,prefixes:O.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:z.VOLUME,prefixes:O.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:z.VOLUME,prefixes:O.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:z.VOLUME,prefixes:O.NONE,value:15e-6,offset:0},drop:{name:"drop",base:z.VOLUME,prefixes:O.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:z.VOLUME,prefixes:O.NONE,value:5e-8,offset:0},minim:{name:"minim",base:z.VOLUME,prefixes:O.NONE,value:6.1611519921875e-8,offset:0},fluiddram:{name:"fluiddram",base:z.VOLUME,prefixes:O.NONE,value:36966911953125e-19,offset:0},fluidounce:{name:"fluidounce",base:z.VOLUME,prefixes:O.NONE,value:295735295625e-16,offset:0},gill:{name:"gill",base:z.VOLUME,prefixes:O.NONE,value:.00011829411825,offset:0},cc:{name:"cc",base:z.VOLUME,prefixes:O.NONE,value:1e-6,offset:0},cup:{name:"cup",base:z.VOLUME,prefixes:O.NONE,value:.0002365882365,offset:0},pint:{name:"pint",base:z.VOLUME,prefixes:O.NONE,value:.000473176473,offset:0},quart:{name:"quart",base:z.VOLUME,prefixes:O.NONE,value:.000946352946,offset:0},gallon:{name:"gallon",base:z.VOLUME,prefixes:O.NONE,value:.003785411784,offset:0},beerbarrel:{name:"beerbarrel",base:z.VOLUME,prefixes:O.NONE,value:.117347765304,offset:0},oilbarrel:{name:"oilbarrel",base:z.VOLUME,prefixes:O.NONE,value:.158987294928,offset:0},hogshead:{name:"hogshead",base:z.VOLUME,prefixes:O.NONE,value:.238480942392,offset:0},g:{name:"g",base:z.MASS,prefixes:O.SHORT,value:.001,offset:0},gram:{name:"gram",base:z.MASS,prefixes:O.LONG,value:.001,offset:0},ton:{name:"ton",base:z.MASS,prefixes:O.SHORT,value:907.18474,offset:0},t:{name:"t",base:z.MASS,prefixes:O.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:z.MASS,prefixes:O.LONG,value:1e3,offset:0},grain:{name:"grain",base:z.MASS,prefixes:O.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:z.MASS,prefixes:O.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:z.MASS,prefixes:O.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:z.MASS,prefixes:O.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:z.MASS,prefixes:O.NONE,value:45.359237,offset:0},stick:{name:"stick",base:z.MASS,prefixes:O.NONE,value:.115,offset:0},stone:{name:"stone",base:z.MASS,prefixes:O.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:z.MASS,prefixes:O.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:z.MASS,prefixes:O.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:z.MASS,prefixes:O.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:z.MASS,prefixes:O.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:z.MASS,prefixes:O.NONE,value:45.359237,offset:0},s:{name:"s",base:z.TIME,prefixes:O.SHORT,value:1,offset:0},min:{name:"min",base:z.TIME,prefixes:O.NONE,value:60,offset:0},h:{name:"h",base:z.TIME,prefixes:O.NONE,value:3600,offset:0},second:{name:"second",base:z.TIME,prefixes:O.LONG,value:1,offset:0},sec:{name:"sec",base:z.TIME,prefixes:O.LONG,value:1,offset:0},minute:{name:"minute",base:z.TIME,prefixes:O.NONE,value:60,offset:0},hour:{name:"hour",base:z.TIME,prefixes:O.NONE,value:3600,offset:0},day:{name:"day",base:z.TIME,prefixes:O.NONE,value:86400,offset:0},week:{name:"week",base:z.TIME,prefixes:O.NONE,value:604800,offset:0},month:{name:"month",base:z.TIME,prefixes:O.NONE,value:2629800,offset:0},year:{name:"year",base:z.TIME,prefixes:O.NONE,value:31557600,offset:0},decade:{name:"decade",base:z.TIME,prefixes:O.NONE,value:315576e3,offset:0},century:{name:"century",base:z.TIME,prefixes:O.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:z.TIME,prefixes:O.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:z.FREQUENCY,prefixes:O.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:z.FREQUENCY,prefixes:O.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:z.ANGLE,prefixes:O.SHORT,value:1,offset:0},radian:{name:"radian",base:z.ANGLE,prefixes:O.LONG,value:1,offset:0},deg:{name:"deg",base:z.ANGLE,prefixes:O.SHORT,value:null,offset:0},degree:{name:"degree",base:z.ANGLE,prefixes:O.LONG,value:null,offset:0},grad:{name:"grad",base:z.ANGLE,prefixes:O.SHORT,value:null,offset:0},gradian:{name:"gradian",base:z.ANGLE,prefixes:O.LONG,value:null,offset:0},cycle:{name:"cycle",base:z.ANGLE,prefixes:O.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:z.ANGLE,prefixes:O.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:z.ANGLE,prefixes:O.NONE,value:null,offset:0},A:{name:"A",base:z.CURRENT,prefixes:O.SHORT,value:1,offset:0},ampere:{name:"ampere",base:z.CURRENT,prefixes:O.LONG,value:1,offset:0},K:{name:"K",base:z.TEMPERATURE,prefixes:O.SHORT,value:1,offset:0},degC:{name:"degC",base:z.TEMPERATURE,prefixes:O.SHORT,value:1,offset:273.15},degF:{name:"degF",base:z.TEMPERATURE,prefixes:O.SHORT,value:new x(5,9),offset:459.67},degR:{name:"degR",base:z.TEMPERATURE,prefixes:O.SHORT,value:new x(5,9),offset:0},kelvin:{name:"kelvin",base:z.TEMPERATURE,prefixes:O.LONG,value:1,offset:0},celsius:{name:"celsius",base:z.TEMPERATURE,prefixes:O.LONG,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:z.TEMPERATURE,prefixes:O.LONG,value:new x(5,9),offset:459.67},rankine:{name:"rankine",base:z.TEMPERATURE,prefixes:O.LONG,value:new x(5,9),offset:0},mol:{name:"mol",base:z.AMOUNT_OF_SUBSTANCE,prefixes:O.SHORT,value:1,offset:0},mole:{name:"mole",base:z.AMOUNT_OF_SUBSTANCE,prefixes:O.LONG,value:1,offset:0},cd:{name:"cd",base:z.LUMINOUS_INTENSITY,prefixes:O.SHORT,value:1,offset:0},candela:{name:"candela",base:z.LUMINOUS_INTENSITY,prefixes:O.LONG,value:1,offset:0},N:{name:"N",base:z.FORCE,prefixes:O.SHORT,value:1,offset:0},newton:{name:"newton",base:z.FORCE,prefixes:O.LONG,value:1,offset:0},dyn:{name:"dyn",base:z.FORCE,prefixes:O.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:z.FORCE,prefixes:O.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:z.FORCE,prefixes:O.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:z.FORCE,prefixes:O.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:z.FORCE,prefixes:O.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:z.FORCE,prefixes:O.NONE,value:9.80665,offset:0},J:{name:"J",base:z.ENERGY,prefixes:O.SHORT,value:1,offset:0},joule:{name:"joule",base:z.ENERGY,prefixes:O.LONG,value:1,offset:0},erg:{name:"erg",base:z.ENERGY,prefixes:O.SHORTLONG,value:1e-7,offset:0},Wh:{name:"Wh",base:z.ENERGY,prefixes:O.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:z.ENERGY,prefixes:O.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:z.ENERGY,prefixes:O.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:z.ENERGY,prefixes:O.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:z.POWER,prefixes:O.SHORT,value:1,offset:0},watt:{name:"watt",base:z.POWER,prefixes:O.LONG,value:1,offset:0},hp:{name:"hp",base:z.POWER,prefixes:O.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:z.POWER,prefixes:O.SHORT,value:b.I,offset:0},VA:{name:"VA",base:z.POWER,prefixes:O.SHORT,value:1,offset:0},Pa:{name:"Pa",base:z.PRESSURE,prefixes:O.SHORT,value:1,offset:0},psi:{name:"psi",base:z.PRESSURE,prefixes:O.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:z.PRESSURE,prefixes:O.NONE,value:101325,offset:0},bar:{name:"bar",base:z.PRESSURE,prefixes:O.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:z.PRESSURE,prefixes:O.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:z.PRESSURE,prefixes:O.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:z.PRESSURE,prefixes:O.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:z.PRESSURE,prefixes:O.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:z.ELECTRIC_CHARGE,prefixes:O.LONG,value:1,offset:0},C:{name:"C",base:z.ELECTRIC_CHARGE,prefixes:O.SHORT,value:1,offset:0},farad:{name:"farad",base:z.ELECTRIC_CAPACITANCE,prefixes:O.LONG,value:1,offset:0},F:{name:"F",base:z.ELECTRIC_CAPACITANCE,prefixes:O.SHORT,value:1,offset:0},volt:{name:"volt",base:z.ELECTRIC_POTENTIAL,prefixes:O.LONG,value:1,offset:0},V:{name:"V",base:z.ELECTRIC_POTENTIAL,prefixes:O.SHORT,value:1,offset:0},ohm:{name:"ohm",base:z.ELECTRIC_RESISTANCE,prefixes:O.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:z.ELECTRIC_INDUCTANCE,prefixes:O.LONG,value:1,offset:0},H:{name:"H",base:z.ELECTRIC_INDUCTANCE,prefixes:O.SHORT,value:1,offset:0},siemens:{name:"siemens",base:z.ELECTRIC_CONDUCTANCE,prefixes:O.LONG,value:1,offset:0},S:{name:"S",base:z.ELECTRIC_CONDUCTANCE,prefixes:O.SHORT,value:1,offset:0},weber:{name:"weber",base:z.MAGNETIC_FLUX,prefixes:O.LONG,value:1,offset:0},Wb:{name:"Wb",base:z.MAGNETIC_FLUX,prefixes:O.SHORT,value:1,offset:0},tesla:{name:"tesla",base:z.MAGNETIC_FLUX_DENSITY,prefixes:O.LONG,value:1,offset:0},T:{name:"T",base:z.MAGNETIC_FLUX_DENSITY,prefixes:O.SHORT,value:1,offset:0},b:{name:"b",base:z.BIT,prefixes:O.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:z.BIT,prefixes:O.BINARY_LONG,value:1,offset:0},B:{name:"B",base:z.BIT,prefixes:O.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:z.BIT,prefixes:O.BINARY_LONG,value:8,offset:0}},$={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",fldr:"fluiddram",fluiddrams:"fluiddram",floz:"fluidounce",fluidounces:"fluidounce",gi:"gill",gills:"gill",cp:"cup",cups:"cup",pt:"pint",pints:"pint",qt:"quart",quarts:"quart",gal:"gallon",gallons:"gallon",bbl:"beerbarrel",beerbarrels:"beerbarrel",obl:"oilbarrel",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 P(e){if("BigNumber"===e.number){var r=uh(g);U.rad.value=new g(1),U.deg.value=r.div(180),U.grad.value=r.div(200),U.cycle.value=r.times(2),U.arcsec.value=r.div(648e3),U.arcmin.value=r.div(10800)}else U.rad.value=1,U.deg.value=Math.PI/180,U.grad.value=Math.PI/200,U.cycle.value=2*Math.PI,U.arcsec.value=Math.PI/648e3,U.arcmin.value=Math.PI/10800;U.radian.value=U.rad.value,U.degree.value=U.deg.value,U.gradian.value=U.grad.value}P(a),i&&i("config",(function(e,r){e.number!==r.number&&P(e)}));var L={si:{NONE:{unit:R,prefix:O.NONE[""]},LENGTH:{unit:U.m,prefix:O.SHORT[""]},MASS:{unit:U.g,prefix:O.SHORT.k},TIME:{unit:U.s,prefix:O.SHORT[""]},CURRENT:{unit:U.A,prefix:O.SHORT[""]},TEMPERATURE:{unit:U.K,prefix:O.SHORT[""]},LUMINOUS_INTENSITY:{unit:U.cd,prefix:O.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:U.mol,prefix:O.SHORT[""]},ANGLE:{unit:U.rad,prefix:O.SHORT[""]},BIT:{unit:U.bits,prefix:O.SHORT[""]},FORCE:{unit:U.N,prefix:O.SHORT[""]},ENERGY:{unit:U.J,prefix:O.SHORT[""]},POWER:{unit:U.W,prefix:O.SHORT[""]},PRESSURE:{unit:U.Pa,prefix:O.SHORT[""]},ELECTRIC_CHARGE:{unit:U.C,prefix:O.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:U.F,prefix:O.SHORT[""]},ELECTRIC_POTENTIAL:{unit:U.V,prefix:O.SHORT[""]},ELECTRIC_RESISTANCE:{unit:U.ohm,prefix:O.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:U.H,prefix:O.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:U.S,prefix:O.SHORT[""]},MAGNETIC_FLUX:{unit:U.Wb,prefix:O.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:U.T,prefix:O.SHORT[""]},FREQUENCY:{unit:U.Hz,prefix:O.SHORT[""]}}};L.cgs=JSON.parse(JSON.stringify(L.si)),L.cgs.LENGTH={unit:U.m,prefix:O.SHORT.c},L.cgs.MASS={unit:U.g,prefix:O.SHORT[""]},L.cgs.FORCE={unit:U.dyn,prefix:O.SHORT[""]},L.cgs.ENERGY={unit:U.erg,prefix:O.NONE[""]},L.us=JSON.parse(JSON.stringify(L.si)),L.us.LENGTH={unit:U.ft,prefix:O.NONE[""]},L.us.MASS={unit:U.lbm,prefix:O.NONE[""]},L.us.TEMPERATURE={unit:U.degF,prefix:O.NONE[""]},L.us.FORCE={unit:U.lbf,prefix:O.NONE[""]},L.us.ENERGY={unit:U.BTU,prefix:O.BTU[""]},L.us.POWER={unit:U.hp,prefix:O.NONE[""]},L.us.PRESSURE={unit:U.psi,prefix:O.NONE[""]},L.auto=JSON.parse(JSON.stringify(L.si));var _=L.auto;for(var W in D.setUnitSystem=function(e){if(!Hn(L,e))throw Error("Unit system "+e+" does not exist. Choices are: "+Object.keys(L).join(", "));_=L[e]},D.getUnitSystem=function(){for(var e in L)if(Hn(L,e)&&L[e]===_)return e},D.typeConverters={BigNumber:function(e){return null!=e&&e.isFraction?new g(e.n+"").div(e.d+"").times(e.s+""):new g(e+"")},Fraction:function(e){return new x(e)},Complex:function(e){return e},number:function(e){return null!=e&&e.isFraction?y(e):e}},D.prototype._numberConverter=function(){var e=D.typeConverters[this.valueType()];if(e)return e;throw new TypeError('Unsupported Unit value type "'+this.valueType()+'"')},D._getNumberConverter=function(e){if(!D.typeConverters[e])throw new TypeError('Unsupported type "'+e+'"');return D.typeConverters[e]},U)if(Hn(U,W)){var J=U[W];J.dimensions=J.base.dimensions}for(var V in $)if(Hn($,V)){var H=U[$[V]],Z={};for(var G in H)Hn(H,G)&&(Z[G]=H[G]);Z.name=V,U[V]=Z}return D.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)},D.createUnit=function(e,r){if("object"!=typeof e)throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(r&&r.override)for(var t in e)if(Hn(e,t)&&D.deleteUnit(t),e[t].aliases)for(var n=0;n<e[t].aliases.length;n++)D.deleteUnit(e[t].aliases[n]);var i;for(var a in e)Hn(e,a)&&(i=D.createUnitSingle(a,e[a]));return i},D.createUnitSingle=function(e,r){if(null==r&&(r={}),"string"!=typeof e)throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");if(Hn(U,e))throw Error('Cannot create unit "'+e+'": a unit with that name already exists');!function(e){for(var r=0;r<e.length;r++){if(n=e.charAt(r),0===r&&!D.isValidAlpha(n))throw Error('Invalid unit name (must begin with alpha character): "'+e+'"');if(r>0&&!D.isValidAlpha(n)&&!A(n))throw Error('Invalid unit name (only alphanumeric characters are allowed): "'+e+'"')}}(e);var t,i,a,o=null,u=[],s=0;if(r&&"Unit"===r.type)o=r.clone();else if("string"==typeof r)""!==r&&(t=r);else{if("object"!=typeof r)throw new TypeError('Cannot create unit "'+e+'" from "'+r+'": expecting "string" or "Unit" or "Object"');t=r.definition,i=r.prefixes,s=r.offset,a=r.baseName,r.aliases&&(u=r.aliases.valueOf())}if(u)for(var c=0;c<u.length;c++)if(Hn(U,u[c]))throw Error('Cannot create alias "'+u[c]+'": a unit with that name already exists');if(t&&"string"==typeof t&&!o)try{o=D.parse(t,{allowNoUnits:!0})}catch(r){throw r.message='Could not create unit "'+e+'" from "'+t+'": '+r.message,r}else t&&"Unit"===t.type&&(o=t.clone());u=u||[],s=s||0,i=i&&i.toUpperCase&&O[i.toUpperCase()]||O.NONE;var l={};if(o){l={name:e,value:o.value,dimensions:o.dimensions.slice(0),prefixes:i,offset:s};var f=!1;for(var m in z)if(Hn(z,m)){for(var d=!0,p=0;p<I.length;p++)if(Math.abs((l.dimensions[p]||0)-(z[m].dimensions[p]||0))>1e-12){d=!1;break}if(d){f=!0,l.base=z[m];break}}if(!f){a=a||e+"_STUFF";var h={dimensions:o.dimensions.slice(0)};h.key=a,z[a]=h,_[a]={unit:l,prefix:O.NONE[""]},l.base=z[a]}}else{if(I.indexOf(a=a||e+"_STUFF")>=0)throw Error('Cannot create new base unit "'+e+'": a base unit with that name already exists (and cannot be overridden)');for(var v in I.push(a),z)Hn(z,v)&&(z[v].dimensions[I.length-1]=0);for(var y={dimensions:[]},b=0;b<I.length;b++)y.dimensions[b]=0;y.dimensions[I.length-1]=1,y.key=a,z[a]=y,l={name:e,value:1,dimensions:z[a].dimensions.slice(0),prefixes:i,offset:s,base:z[a]},_[a]={unit:l,prefix:O.NONE[""]}}D.UNITS[e]=l;for(var g=0;g<u.length;g++){var x=u[g],w={};for(var N in l)Hn(l,N)&&(w[N]=l[N]);w.name=x,D.UNITS[x]=w}return delete B.cache,new D(null,e)},D.deleteUnit=function(e){delete D.UNITS[e],delete B.cache},D.PREFIXES=O,D.BASE_DIMENSIONS=I,D.BASE_UNITS=z,D.UNIT_SYSTEMS=L,D.UNITS=U,D}),{isClass:!0}),dh="unit",ph=ti(dh,["typed","Unit"],(e=>{var{typed:r,Unit:t}=e;return r(dh,{Unit:function(e){return e.clone()},string:function(e){return t.isValuelessUnit(e)?new t(null,e):t.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string | Unit":function(e,r){return new t(e,r)},"number | BigNumber | Fraction":function(e){return new t(e)},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),hh="sparse",vh=ti(hh,["typed","SparseMatrix"],(e=>{var{typed:r,SparseMatrix:t}=e;return r(hh,{"":function(){return new t([])},string:function(e){return new t([],e)},"Array | Matrix":function(e){return new t(e)},"Array | Matrix, string":function(e,r){return new t(e,r)}})})),yh="createUnit",bh=ti(yh,["typed","Unit"],(e=>{var{typed:r,Unit:t}=e;return r(yh,{"Object, Object":function(e,r){return t.createUnit(e,r)},Object:function(e){return t.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,r,n){var i={};return i[e]=r,t.createUnit(i,n)},"string, Unit | string | Object":function(e,r){var n={};return n[e]=r,t.createUnit(n,{})},string:function(e){var r={};return r[e]={},t.createUnit(r,{})}})})),gh="acos",xh=ti(gh,["typed","config","Complex"],(e=>{var{typed:r,config:t,Complex:n}=e;return r(gh,{number:function(e){return e>=-1&&e<=1||t.predictable?Math.acos(e):new n(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()}})})),wh="acosh",Dh=ti(wh,["typed","config","Complex"],(e=>{var{typed:r,config:t,Complex:n}=e;return r(wh,{number:function(e){return e>=1||t.predictable?_s(e):e<=-1?new n(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new n(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()}})})),Nh="acot",Ah=ti(Nh,["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r(Nh,{number:Ws,Complex:function(e){return e.acot()},BigNumber:function(e){return new t(1).div(e).atan()}})})),Mh="acoth",Ch=ti(Mh,["typed","config","Complex","BigNumber"],(e=>{var{typed:r,config:t,Complex:n,BigNumber:i}=e;return r(Mh,{number:function(e){return e>=1||e<=-1||t.predictable?Js(e):new n(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new i(1).div(e).atanh()}})})),Eh="acsc",Sh=ti(Eh,["typed","config","Complex","BigNumber"],(e=>{var{typed:r,config:t,Complex:n,BigNumber:i}=e;return r(Eh,{number:function(e){return e<=-1||e>=1||t.predictable?Vs(e):new n(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new i(1).div(e).asin()}})})),Fh="acsch",Bh=ti(Fh,["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r(Fh,{number:Hs,Complex:function(e){return e.acsch()},BigNumber:function(e){return new t(1).div(e).asinh()}})})),qh="asec",Th=ti(qh,["typed","config","Complex","BigNumber"],(e=>{var{typed:r,config:t,Complex:n,BigNumber:i}=e;return r(qh,{number:function(e){return e<=-1||e>=1||t.predictable?Zs(e):new n(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new i(1).div(e).acos()}})})),kh="asech",Oh=ti(kh,["typed","config","Complex","BigNumber"],(e=>{var{typed:r,config:t,Complex:n,BigNumber:i}=e;return r(kh,{number:function(e){if(e<=1&&e>=-1||t.predictable){var r=1/e;return r>0||t.predictable?Gs(e):new n(Math.log(Math.sqrt(r*r-1)-r),Math.PI)}return new n(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new i(1).div(e).acosh()}})})),Ih="asin",zh=ti(Ih,["typed","config","Complex"],(e=>{var{typed:r,config:t,Complex:n}=e;return r(Ih,{number:function(e){return e>=-1&&e<=1||t.predictable?Math.asin(e):new n(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()}})})),jh=ti("asinh",["typed"],(e=>{var{typed:r}=e;return r("asinh",{number:Xs,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()}})})),Rh=ti("atan",["typed"],(e=>{var{typed:r}=e;return r("atan",{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()}})})),Uh="atan2",$h=ti(Uh,["typed","matrix","equalScalar","BigNumber","DenseMatrix","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,BigNumber:i,DenseMatrix:a,concat:o}=e,u=Fl({typed:r,equalScalar:n}),s=Bl({typed:r}),c=yf({typed:r,equalScalar:n}),l=ul({typed:r,equalScalar:n}),f=sl({typed:r,DenseMatrix:a}),m=Ol({typed:r,matrix:t,concat:o});return r(Uh,{"number, number":Math.atan2,"BigNumber, BigNumber":(e,r)=>i.atan2(e,r)},m({scalar:"number | BigNumber",SS:c,DS:s,SD:u,Ss:l,sS:f}))})),Ph="atanh",Lh=ti(Ph,["typed","config","Complex"],(e=>{var{typed:r,config:t,Complex:n}=e;return r(Ph,{number:function(e){return e<=1&&e>=-1||t.predictable?Ys(e):new n(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()}})})),_h=ti("trigUnit",["typed"],(e=>{var{typed:r}=e;return{Unit:r.referToSelf((e=>t=>{if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return r.find(e,t.valueType())(t.value)}))}})),Wh=ti("cos",["typed"],(e=>{var{typed:r}=e,t=_h({typed:r});return r("cos",{number:Math.cos,"Complex | BigNumber":e=>e.cos()},t)})),Jh="cosh",Vh=ti(Jh,["typed"],(e=>{var{typed:r}=e;return r(Jh,{number:Ai,"Complex | BigNumber":e=>e.cosh()})})),Hh=ti("cot",["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r("cot",{number:Qs,Complex:e=>e.cot(),BigNumber:e=>new t(1).div(e.tan())},_h({typed:r}))})),Zh="coth",Gh=ti(Zh,["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r(Zh,{number:Ks,Complex:e=>e.coth(),BigNumber:e=>new t(1).div(e.tanh())})})),Xh=ti("csc",["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r("csc",{number:ec,Complex:e=>e.csc(),BigNumber:e=>new t(1).div(e.sin())},_h({typed:r}))})),Yh="csch",Qh=ti(Yh,["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r(Yh,{number:rc,Complex:e=>e.csch(),BigNumber:e=>new t(1).div(e.sinh())})})),Kh=ti("sec",["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r("sec",{number:tc,Complex:e=>e.sec(),BigNumber:e=>new t(1).div(e.cos())},_h({typed:r}))})),ev="sech",rv=ti(ev,["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r(ev,{number:nc,Complex:e=>e.sech(),BigNumber:e=>new t(1).div(e.cosh())})})),tv=ti("sin",["typed"],(e=>{var{typed:r}=e,t=_h({typed:r});return r("sin",{number:Math.sin,"Complex | BigNumber":e=>e.sin()},t)})),nv="sinh",iv=ti(nv,["typed"],(e=>{var{typed:r}=e;return r(nv,{number:ic,"Complex | BigNumber":e=>e.sinh()})})),av=ti("tan",["typed"],(e=>{var{typed:r}=e,t=_h({typed:r});return r("tan",{number:Math.tan,"Complex | BigNumber":e=>e.tan()},t)})),ov=ti("tanh",["typed"],(e=>{var{typed:r}=e;return r("tanh",{number:Ci,"Complex | BigNumber":e=>e.tanh()})})),uv="setCartesian",sv=ti(uv,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:r,size:t,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return r(uv,{"Array | Matrix, Array | Matrix":function(e,r){var u=[];if(0!==n(t(e),new a(0))&&0!==n(t(r),new a(0))){var s=bu(Array.isArray(e)?e:e.toArray()).sort(i),c=bu(Array.isArray(r)?r:r.toArray()).sort(i);u=[];for(var l=0;l<s.length;l++)for(var f=0;f<c.length;f++)u.push([s[l],c[f]])}return Array.isArray(e)&&Array.isArray(r)?u:new o(u)}})})),cv="setDifference",lv=ti(cv,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:r,size:t,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return r(cv,{"Array | Matrix, Array | Matrix":function(e,r){var u;if(0===n(t(e),new a(0)))u=[];else{if(0===n(t(r),new a(0)))return bu(e.toArray());var s,c=Nu(bu(Array.isArray(e)?e:e.toArray()).sort(i)),l=Nu(bu(Array.isArray(r)?r:r.toArray()).sort(i));u=[];for(var f=0;f<c.length;f++){s=!1;for(var m=0;m<l.length;m++)if(0===i(c[f].value,l[m].value)&&c[f].identifier===l[m].identifier){s=!0;break}s||u.push(c[f])}}return Array.isArray(e)&&Array.isArray(r)?Au(u):new o(Au(u))}})})),fv="setDistinct",mv=ti(fv,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:r,size:t,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return r(fv,{"Array | Matrix":function(e){var r;if(0===n(t(e),new a(0)))r=[];else{var u=bu(Array.isArray(e)?e:e.toArray()).sort(i);(r=[]).push(u[0]);for(var s=1;s<u.length;s++)0!==i(u[s],u[s-1])&&r.push(u[s])}return Array.isArray(e)?r:new o(r)}})})),dv="setIntersect",pv=ti(dv,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:r,size:t,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return r(dv,{"Array | Matrix, Array | Matrix":function(e,r){var u;if(0===n(t(e),new a(0))||0===n(t(r),new a(0)))u=[];else{var s=Nu(bu(Array.isArray(e)?e:e.toArray()).sort(i)),c=Nu(bu(Array.isArray(r)?r:r.toArray()).sort(i));u=[];for(var l=0;l<s.length;l++)for(var f=0;f<c.length;f++)if(0===i(s[l].value,c[f].value)&&s[l].identifier===c[f].identifier){u.push(s[l]);break}}return Array.isArray(e)&&Array.isArray(r)?Au(u):new o(Au(u))}})})),hv="setIsSubset",vv=ti(hv,["typed","size","subset","compareNatural","Index"],(e=>{var{typed:r,size:t,subset:n,compareNatural:i,Index:a}=e;return r(hv,{"Array | Matrix, Array | Matrix":function(e,r){if(0===n(t(e),new a(0)))return!0;if(0===n(t(r),new a(0)))return!1;for(var o,u=Nu(bu(Array.isArray(e)?e:e.toArray()).sort(i)),s=Nu(bu(Array.isArray(r)?r:r.toArray()).sort(i)),c=0;c<u.length;c++){o=!1;for(var l=0;l<s.length;l++)if(0===i(u[c].value,s[l].value)&&u[c].identifier===s[l].identifier){o=!0;break}if(!1===o)return!1}return!0}})})),yv="setMultiplicity",bv=ti(yv,["typed","size","subset","compareNatural","Index"],(e=>{var{typed:r,size:t,subset:n,compareNatural:i,Index:a}=e;return r(yv,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,r){if(0===n(t(r),new a(0)))return 0;for(var o=bu(Array.isArray(r)?r:r.toArray()),u=0,s=0;s<o.length;s++)0===i(o[s],e)&&u++;return u}})})),gv="setPowerset",xv=ti(gv,["typed","size","subset","compareNatural","Index"],(e=>{var{typed:r,size:t,subset:n,compareNatural:i,Index:a}=e;return r(gv,{"Array | Matrix":function(e){if(0===n(t(e),new a(0)))return[];for(var r=bu(Array.isArray(e)?e:e.toArray()).sort(i),u=[],s=0;s.toString(2).length<=r.length;)u.push(o(r,s.toString(2).split("").reverse())),s++;return function(e){for(var r=[],t=e.length-1;t>0;t--)for(var n=0;n<t;n++)e[n].length>e[n+1].length&&(r=e[n],e[n]=e[n+1],e[n+1]=r);return e}(u)}});function o(e,r){for(var t=[],n=0;n<r.length;n++)"1"===r[n]&&t.push(e[n]);return t}})),wv="setSize",Dv=ti(wv,["typed","compareNatural"],(e=>{var{typed:r,compareNatural:t}=e;return r(wv,{"Array | Matrix":function(e){return Array.isArray(e)?bu(e).length:bu(e.toArray()).length},"Array | Matrix, boolean":function(e,r){if(!1===r||0===e.length)return Array.isArray(e)?bu(e).length:bu(e.toArray()).length;for(var n=bu(Array.isArray(e)?e:e.toArray()).sort(t),i=1,a=1;a<n.length;a++)0!==t(n[a],n[a-1])&&i++;return i}})})),Nv="setSymDifference",Av=ti(Nv,["typed","size","concat","subset","setDifference","Index"],(e=>{var{typed:r,size:t,concat:n,subset:i,setDifference:a,Index:o}=e;return r(Nv,{"Array | Matrix, Array | Matrix":function(e,r){if(0===i(t(e),new o(0)))return bu(r);if(0===i(t(r),new o(0)))return bu(e);var u=bu(e),s=bu(r);return n(a(u,s),a(s,u))}})})),Mv="setUnion",Cv=ti(Mv,["typed","size","concat","subset","setIntersect","setSymDifference","Index"],(e=>{var{typed:r,size:t,concat:n,subset:i,setIntersect:a,setSymDifference:o,Index:u}=e;return r(Mv,{"Array | Matrix, Array | Matrix":function(e,r){if(0===i(t(e),new u(0)))return bu(r);if(0===i(t(r),new u(0)))return bu(e);var s=bu(e),c=bu(r);return n(o(s,c),a(s,c))}})})),Ev=ti("add",["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],(e=>{var{typed:r,matrix:t,addScalar:n,equalScalar:i,DenseMatrix:a,concat:o}=e,u=zl({typed:r}),s=jl({typed:r,equalScalar:i}),c=Rl({typed:r,DenseMatrix:a}),l=Ol({typed:r,matrix:t,concat:o});return r("add",{"any, any":n,"any, any, ...any":r.referToSelf((e=>(r,t,n)=>{for(var i=e(r,t),a=0;a<n.length;a++)i=e(i,n[a]);return i}))},l({elop:n,DS:u,SS:s,Ss:c}))})),Sv="hypot",Fv=ti(Sv,["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],(e=>{var{typed:r,abs:t,addScalar:n,divideScalar:i,multiplyScalar:a,sqrt:o,smaller:u,isPositive:s}=e;return r(Sv,{"... number | BigNumber":c,Array:c,Matrix:e=>c(bu(e.toArray(),!0))});function c(e){for(var r=0,c=0,l=0;l<e.length;l++){if(nn(e[l]))throw new TypeError("Unexpected type of argument to hypot");var f=t(e[l]);u(c,f)?(r=a(r,a(i(c,f),i(c,f))),r=n(r,1),c=f):r=n(r,s(f)?a(i(f,c),i(f,c)):f)}return a(c,o(r))}})),Bv="norm",qv=ti(Bv,["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],(e=>{var{typed:r,abs:t,add:n,pow:i,conj:a,sqrt:o,multiply:u,equalScalar:s,larger:c,smaller:l,matrix:f,ctranspose:m,eigs:d}=e;return r(Bv,{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},boolean:function(e){return Math.abs(e)},Array:function(e){return p(f(e),2)},Matrix:function(e){return p(e,2)},"Array, number | BigNumber | string":function(e,r){return p(f(e),r)},"Matrix, number | BigNumber | string":function(e,r){return p(e,r)}});function p(e,r){var f=e.size();if(1===f.length)return function(e,r){if(r===1/0||"inf"===r)return function(e){var r=0;return e.forEach((function(e){var n=t(e);c(n,r)&&(r=n)}),!0),r}(e);if(r===-1/0||"-inf"===r)return function(e){var r;return e.forEach((function(e){var n=t(e);r&&!l(n,r)||(r=n)}),!0),r||0}(e);if("fro"===r)return p(e,2);if("number"==typeof r&&!isNaN(r)){if(!s(r,0)){var a=0;return e.forEach((function(e){a=n(i(t(e),r),a)}),!0),i(a,1/r)}return 1/0}throw Error("Unsupported parameter value")}(e,r);if(2===f.length){if(f[0]&&f[1])return function(e,r){if(1===r)return function(e){var r=[],i=0;return e.forEach((function(e,a){var o=a[1],u=n(r[o]||0,t(e));c(u,i)&&(i=u),r[o]=u}),!0),i}(e);if(r===1/0||"inf"===r)return function(e){var r=[],i=0;return e.forEach((function(e,a){var o=a[0],u=n(r[o]||0,t(e));c(u,i)&&(i=u),r[o]=u}),!0),i}(e);if("fro"===r)return function(e){var r=0;return e.forEach((function(e){r=n(r,u(e,a(e)))})),t(o(r))}(e);if(2===r)return function(e){var r=e.size();if(r[0]!==r[1])throw new RangeError("Invalid matrix dimensions");var n=m(e),i=u(n,e),a=d(i).values.toArray();return t(o(a[a.length-1]))}(e);throw Error("Unsupported parameter value "+r)}(e,r);throw new RangeError("Invalid matrix dimensions")}}})),Tv=ti("dot",["typed","addScalar","multiplyScalar","conj","size"],(e=>{var{typed:r,addScalar:t,multiplyScalar:n,conj:i,size:a}=e;return r("dot",{"Array | DenseMatrix, Array | DenseMatrix":function(e,a){var s=o(e,a),c=cn(e)?e._data:e,l=cn(e)?e._datatype||e.getDataType():void 0,f=cn(a)?a._data:a,m=cn(a)?a._datatype||a.getDataType():void 0,d=2===u(e).length,p=2===u(a).length,h=t,v=n;if(l&&m&&l===m&&"string"==typeof l&&"mixed"!==l){var y=l;h=r.find(t,[y,y]),v=r.find(n,[y,y])}if(!d&&!p){for(var b=v(i(c[0]),f[0]),g=1;g<s;g++)b=h(b,v(i(c[g]),f[g]));return b}if(!d&&p){for(var x=v(i(c[0]),f[0][0]),w=1;w<s;w++)x=h(x,v(i(c[w]),f[w][0]));return x}if(d&&!p){for(var D=v(i(c[0][0]),f[0]),N=1;N<s;N++)D=h(D,v(i(c[N][0]),f[N]));return D}if(d&&p){for(var A=v(i(c[0][0]),f[0][0]),M=1;M<s;M++)A=h(A,v(i(c[M][0]),f[M][0]));return A}},"SparseMatrix, SparseMatrix":function(e,r){o(e,r);for(var i=e._index,a=e._values,u=r._index,s=r._values,c=0,l=t,f=n,m=0,d=0;m<i.length&&d<u.length;){var p=i[m],h=u[d];p<h?m++:p>h?d++:p===h&&(c=l(c,f(a[m],s[d])),m++,d++)}return c}});function o(e,r){var t,n,i=u(e),a=u(r);if(1===i.length)t=i[0];else{if(2!==i.length||1!==i[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+i.join(", ")+")");t=i[0]}if(1===a.length)n=a[0];else{if(2!==a.length||1!==a[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+a.join(", ")+")");n=a[0]}if(t!==n)throw new RangeError("Vectors must have equal length ("+t+" != "+n+")");if(0===t)throw new RangeError("Cannot calculate the dot product of empty vectors");return t}function u(e){return cn(e)?e.size():a(e)}})),kv=ti("trace",["typed","matrix","add"],(e=>{var{typed:r,matrix:t,add:n}=e;return r("trace",{Array:function(e){return i(t(e))},SparseMatrix:function(e){var r=e._values,t=e._index,i=e._ptr,a=e._size,o=a[1];if(a[0]===o){var u=0;if(r.length>0)for(var s=0;s<o;s++)for(var c=i[s+1],l=i[s];l<c;l++){var f=t[l];if(f===s){u=n(u,r[l]);break}if(f>s)break}return u}throw new RangeError("Matrix must be square (size: "+Go(a)+")")},DenseMatrix:i,any:Wn});function i(e){var r=e._size,t=e._data;switch(r.length){case 1:if(1===r[0])return Wn(t[0]);throw new RangeError("Matrix must be square (size: "+Go(r)+")");case 2:var i=r[0];if(i===r[1]){for(var a=0,o=0;o<i;o++)a=n(a,t[o][o]);return a}throw new RangeError("Matrix must be square (size: "+Go(r)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+Go(r)+")")}}})),Ov="index",Iv=ti(Ov,["typed","Index"],(e=>{var{typed:r,Index:t}=e;return r(Ov,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var r=e.map((function(e){return rn(e)?e.toNumber():sn(e)||cn(e)?e.map((function(e){return rn(e)?e.toNumber():e})):e})),n=new t;return t.apply(n,r),n}})})),zv=new Set(["end"]),jv=ti("Node",["mathWithTransform"],(e=>{var{mathWithTransform:r}=e;return class{get type(){return"Node"}get isNode(){return!0}evaluate(e){return this.compile().evaluate(e)}compile(){var e=this._compile(r,{}),t={};return{evaluate:function(r){var n=Kt(r);return function(e){for(var r of[...zv])if(e.has(r))throw Error('Scope contains an illegal symbol, "'+r+'" is a reserved keyword')}(n),e(n,t,null)}}}_compile(e,r){throw Error("Method _compile must be implemented by type "+this.type)}forEach(e){throw Error("Cannot run forEach on a Node interface")}map(e){throw Error("Cannot run map on a Node interface")}_ifNode(e){if(!In(e))throw new TypeError("Callback function must return a Node");return e}traverse(e){e(this,null,null),function e(r,t){r.forEach((function(r,n,i){t(r,n,i),e(r,t)}))}(this,e)}transform(e){return function r(t,n,i){var a=e(t,n,i);return a!==t?a:t.map(r)}(this,null,null)}filter(e){var r=[];return this.traverse((function(t,n,i){e(t,n,i)&&r.push(t)})),r}clone(){throw Error("Cannot clone a Node interface")}cloneDeep(){return this.map((function(e){return e.cloneDeep()}))}equals(e){return!!e&&this.type===e.type&&Vn(this,e)}toString(e){var r=this._getCustomString(e);return void 0!==r?r:this._toString(e)}_toString(){throw Error("_toString not implemented for "+this.type)}toJSON(){throw Error("Cannot serialize object: toJSON not implemented by "+this.type)}toHTML(e){var r=this._getCustomString(e);return void 0!==r?r:this._toHTML(e)}_toHTML(){throw Error("_toHTML not implemented for "+this.type)}toTex(e){var r=this._getCustomString(e);return void 0!==r?r:this._toTex(e)}_toTex(e){throw Error("_toTex not implemented for "+this.type)}_getCustomString(e){if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":return;case"function":return e.handler(this,e);default:throw new TypeError("Object or function expected as callback")}}getIdentifier(){return this.type}getContent(){return this}}}),{isClass:!0,isNode:!0});function Rv(e){return e&&e.isIndexError?new tu(e.index+1,e.min+1,void 0!==e.max?e.max+1:void 0):e}function Uv(e){var{subset:r}=e;return function(e,t){try{if(Array.isArray(e))return r(e,t);if(e&&"function"==typeof e.subset)return e.subset(t);if("string"==typeof e)return r(e,t);if("object"==typeof e){if(!t.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return _t(e,t.getObjectProperty())}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Rv(e)}}}var $v="AccessorNode",Pv=ti($v,["subset","Node"],(e=>{var{subset:r,Node:t}=e,n=Uv({subset:r});function i(e){return!(Mn(e)||Cn(e)||Bn(e)||kn(e)||zn(e)||Rn(e)||Pn(e))}class a extends t{constructor(e,r){if(super(),!In(e))throw new TypeError('Node expected for parameter "object"');if(!On(r))throw new TypeError('IndexNode expected for parameter "index"');this.object=e,this.index=r}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return $v}get isAccessorNode(){return!0}_compile(e,r){var t=this.object._compile(e,r),i=this.index._compile(e,r);if(this.index.isObjectProperty()){var a=this.index.getObjectProperty();return function(e,r,n){return _t(t(e,r,n),a)}}return function(e,r,a){var o=t(e,r,a),u=i(e,r,o);return n(o,u)}}forEach(e){e(this.object,"object",this),e(this.index,"index",this)}map(e){return new a(this._ifNode(e(this.object,"object",this)),this._ifNode(e(this.index,"index",this)))}clone(){return new a(this.object,this.index)}_toString(e){var r=this.object.toString(e);return i(this.object)&&(r="("+r+")"),r+this.index.toString(e)}_toHTML(e){var r=this.object.toHTML(e);return i(this.object)&&(r='<span class="math-parenthesis math-round-parenthesis">(</span>'+r+'<span class="math-parenthesis math-round-parenthesis">)</span>'),r+this.index.toHTML(e)}_toTex(e){var r=this.object.toTex(e);return i(this.object)&&(r="\\left(' + object + '\\right)"),r+this.index.toTex(e)}toJSON(){return{mathjs:$v,object:this.object,index:this.index}}static fromJSON(e){return new a(e.object,e.index)}}return ed(a,"name",$v),a}),{isClass:!0,isNode:!0}),Lv="ArrayNode",_v=ti(Lv,["Node"],(e=>{var{Node:r}=e;class t extends r{constructor(e){if(super(),this.items=e||[],!Array.isArray(this.items)||!this.items.every(In))throw new TypeError("Array containing Nodes expected")}get type(){return Lv}get isArrayNode(){return!0}_compile(e,r){var t=gu(this.items,(function(t){return t._compile(e,r)}));if("Array"!==e.config.matrix){var n=e.matrix;return function(e,r,i){return n(gu(t,(function(t){return t(e,r,i)})))}}return function(e,r,n){return gu(t,(function(t){return t(e,r,n)}))}}forEach(e){for(var r=0;r<this.items.length;r++)e(this.items[r],"items["+r+"]",this)}map(e){for(var r=[],n=0;n<this.items.length;n++)r[n]=this._ifNode(e(this.items[n],"items["+n+"]",this));return new t(r)}clone(){return new t(this.items.slice(0))}_toString(e){return"["+this.items.map((function(r){return r.toString(e)})).join(", ")+"]"}toJSON(){return{mathjs:Lv,items:this.items}}static fromJSON(e){return new t(e.items)}_toHTML(e){return'<span class="math-parenthesis math-square-parenthesis">[</span>'+this.items.map((function(r){return r.toHTML(e)})).join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(e){return function r(t,n){var i=t.some(Cn)&&!t.every(Cn),a=n||i,o=a?"&":"\\\\",u=t.map((function(t){return t.items?r(t.items,!n):t.toTex(e)})).join(o);return i||!a||a&&!n?"\\begin{bmatrix}"+u+"\\end{bmatrix}":u}(this.items,!1)}}return ed(t,"name",Lv),t}),{isClass:!0,isNode:!0}),Wv=[{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:nullish":{op:"??",associativity:"left",associativeWith:[]}},{"OperatorNode:factorial":{op:"!",associativity:"left"}},{"OperatorNode:ctranspose":{op:"'",associativity:"left"}}];function Jv(e,r){if(!r||"auto"!==r)return e;for(var t=e;Rn(t);)t=t.content;return t}function Vv(e,r,t,n){var i=e;"keep"!==r&&(i=e.getContent());for(var a=i.getIdentifier(),o=null,u=0;u<Wv.length;u++)if(a in Wv[u]){o=u;break}if("OperatorNode:multiply"===a&&i.implicit&&"show"!==t){var s=Jv(i.args[0],r);Bn(s)&&n&&"OperatorNode:divide"===n.getIdentifier()&&qn(Jv(n.args[0],r))||"OperatorNode:divide"===s.getIdentifier()&&qn(Jv(s.args[0],r))&&Bn(Jv(s.args[1]))||(o+=1)}return o}function Hv(e,r){var t=e;"keep"!==r&&(t=e.getContent());var n=t.getIdentifier(),i=Vv(t,r);if(null===i)return null;var a=Wv[i][n];if(Hn(a,"associativity")){if("left"===a.associativity)return"left";if("right"===a.associativity)return"right";throw Error("'"+n+"' has the invalid associativity '"+a.associativity+"'.")}return null}function Zv(e,r,t){var n="keep"!==t?e.getContent():e,i="keep"!==t?e.getContent():r,a=n.getIdentifier(),o=i.getIdentifier(),u=Vv(n,t);if(null===u)return null;var s=Wv[u][a];if(Hn(s,"associativeWith")&&s.associativeWith instanceof Array){for(var c=0;c<s.associativeWith.length;c++)if(s.associativeWith[c]===o)return!0;return!1}return null}var Gv,Xv,Yv="AssignmentNode",Qv=ti(Yv,["subset","?matrix","Node"],(e=>{var{subset:r,matrix:t,Node:n}=e,i=Uv({subset:r}),a=function(e){var{subset:r,matrix:t}=e;return function(e,n,i){try{if(Array.isArray(e))return t(e).subset(n,i).valueOf().forEach(((r,t)=>{e[t]=r})),e;if(e&&"function"==typeof e.subset)return e.subset(n,i);if("string"==typeof e)return r(e,n,i);if("object"==typeof e){if(!n.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return Wt(e,n.getObjectProperty(),i),e}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Rv(e)}}}({subset:r,matrix:t});function o(e,r,t){r||(r="keep");var n=Vv(e,r,t),i=Vv(e.value,r,t);return"all"===r||null!==i&&i<=n}class u extends n{constructor(e,r,t){if(super(),this.object=e,this.index=t?r:null,this.value=t||r,!Pn(e)&&!Mn(e))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(Pn(e)&&"end"===e.name)throw Error('Cannot assign to symbol "end"');if(this.index&&!On(this.index))throw new TypeError('IndexNode expected as "index"');if(!In(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 Yv}get isAssignmentNode(){return!0}_compile(e,r){var t=this.object._compile(e,r),n=this.index?this.index._compile(e,r):null,o=this.value._compile(e,r),u=this.object.name;if(this.index){if(this.index.isObjectProperty()){var s=this.index.getObjectProperty();return function(e,r,n){var i=t(e,r,n),a=o(e,r,n);return Wt(i,s,a),a}}if(Pn(this.object))return function(e,r,i){var s=t(e,r,i),c=o(e,r,i),l=n(e,r,s);return e.set(u,a(s,l,c)),c};var c=this.object.object._compile(e,r);if(this.object.index.isObjectProperty()){var l=this.object.index.getObjectProperty();return function(e,r,t){var i=c(e,r,t),u=_t(i,l),s=n(e,r,u),f=o(e,r,t);return Wt(i,l,a(u,s,f)),f}}var f=this.object.index._compile(e,r);return function(e,r,t){var u=c(e,r,t),s=f(e,r,u),l=i(u,s),m=n(e,r,l),d=o(e,r,t);return a(u,s,a(l,m,d)),d}}if(!Pn(this.object))throw new TypeError("SymbolNode expected as object");return function(e,r,t){var n=o(e,r,t);return e.set(u,n),n}}forEach(e){e(this.object,"object",this),this.index&&e(this.index,"index",this),e(this.value,"value",this)}map(e){var r=this._ifNode(e(this.object,"object",this)),t=this.index?this._ifNode(e(this.index,"index",this)):null,n=this._ifNode(e(this.value,"value",this));return new u(r,t,n)}clone(){return new u(this.object,this.index,this.value)}_toString(e){var r=this.object.toString(e),t=this.index?this.index.toString(e):"",n=this.value.toString(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(n="("+n+")"),r+t+" = "+n}toJSON(){return{mathjs:Yv,object:this.object,index:this.index,value:this.value}}static fromJSON(e){return new u(e.object,e.index,e.value)}_toHTML(e){var r=this.object.toHTML(e),t=this.index?this.index.toHTML(e):"",n=this.value.toHTML(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(n='<span class="math-paranthesis math-round-parenthesis">(</span>'+n+'<span class="math-paranthesis math-round-parenthesis">)</span>'),r+t+'<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+n}_toTex(e){var r=this.object.toTex(e),t=this.index?this.index.toTex(e):"",n=this.value.toTex(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(n="\\left(".concat(n,"\\right)")),r+t+"="+n}}return ed(u,"name",Yv),u}),{isClass:!0,isNode:!0}),Kv="BlockNode",ey=ti(Kv,["ResultSet","Node"],(e=>{var{ResultSet:r,Node:t}=e;class n extends t{constructor(e){if(super(),!Array.isArray(e))throw Error("Array expected");this.blocks=e.map((function(e){var r=e&&e.node,t=!e||void 0===e.visible||e.visible;if(!In(r))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof t)throw new TypeError('Property "visible" must be a boolean');return{node:r,visible:t}}))}get type(){return Kv}get isBlockNode(){return!0}_compile(e,t){var n=gu(this.blocks,(function(r){return{evaluate:r.node._compile(e,t),visible:r.visible}}));return function(e,t,i){var a=[];return xu(n,(function(r){var n=r.evaluate(e,t,i);r.visible&&a.push(n)})),new r(a)}}forEach(e){for(var r=0;r<this.blocks.length;r++)e(this.blocks[r].node,"blocks["+r+"].node",this)}map(e){for(var r=[],t=0;t<this.blocks.length;t++){var i=this.blocks[t],a=this._ifNode(e(i.node,"blocks["+t+"].node",this));r[t]={node:a,visible:i.visible}}return new n(r)}clone(){var e=this.blocks.map((function(e){return{node:e.node,visible:e.visible}}));return new n(e)}_toString(e){return this.blocks.map((function(r){return r.node.toString(e)+(r.visible?"":";")})).join("\n")}toJSON(){return{mathjs:Kv,blocks:this.blocks}}static fromJSON(e){return new n(e.blocks)}_toHTML(e){return this.blocks.map((function(r){return r.node.toHTML(e)+(r.visible?"":'<span class="math-separator">;</span>')})).join('<span class="math-separator"><br /></span>')}_toTex(e){return this.blocks.map((function(r){return r.node.toTex(e)+(r.visible?"":";")})).join("\\;\\;\n")}}return ed(n,"name",Kv),n}),{isClass:!0,isNode:!0}),ry="ConditionalNode",ty=ti(ry,["Node"],(e=>{var{Node:r}=e;class t extends r{constructor(e,r,t){if(super(),!In(e))throw new TypeError("Parameter condition must be a Node");if(!In(r))throw new TypeError("Parameter trueExpr must be a Node");if(!In(t))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=r,this.falseExpr=t}get type(){return ry}get isConditionalNode(){return!0}_compile(e,r){var t=this.condition._compile(e,r),n=this.trueExpr._compile(e,r),i=this.falseExpr._compile(e,r);return function(e,r,a){return function(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return!!e;if(e){if(rn(e))return!e.isZero();if(nn(e))return!(!e.re&&!e.im);if(on(e))return!!e.value}if(null==e)return!1;throw new TypeError('Unsupported type of condition "'+_n(e)+'"')}(t(e,r,a))?n(e,r,a):i(e,r,a)}}forEach(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)}map(e){return new t(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))}clone(){return new t(this.condition,this.trueExpr,this.falseExpr)}_toString(e){var r=e&&e.parenthesis?e.parenthesis:"keep",t=Vv(this,r,e&&e.implicit),n=this.condition.toString(e),i=Vv(this.condition,r,e&&e.implicit);("all"===r||"OperatorNode"===this.condition.type||null!==i&&i<=t)&&(n="("+n+")");var a=this.trueExpr.toString(e),o=Vv(this.trueExpr,r,e&&e.implicit);("all"===r||"OperatorNode"===this.trueExpr.type||null!==o&&o<=t)&&(a="("+a+")");var u=this.falseExpr.toString(e),s=Vv(this.falseExpr,r,e&&e.implicit);return("all"===r||"OperatorNode"===this.falseExpr.type||null!==s&&s<=t)&&(u="("+u+")"),n+" ? "+a+" : "+u}toJSON(){return{mathjs:ry,condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}}static fromJSON(e){return new t(e.condition,e.trueExpr,e.falseExpr)}_toHTML(e){var r=e&&e.parenthesis?e.parenthesis:"keep",t=Vv(this,r,e&&e.implicit),n=this.condition.toHTML(e),i=Vv(this.condition,r,e&&e.implicit);("all"===r||"OperatorNode"===this.condition.type||null!==i&&i<=t)&&(n='<span class="math-parenthesis math-round-parenthesis">(</span>'+n+'<span class="math-parenthesis math-round-parenthesis">)</span>');var a=this.trueExpr.toHTML(e),o=Vv(this.trueExpr,r,e&&e.implicit);("all"===r||"OperatorNode"===this.trueExpr.type||null!==o&&o<=t)&&(a='<span class="math-parenthesis math-round-parenthesis">(</span>'+a+'<span class="math-parenthesis math-round-parenthesis">)</span>');var u=this.falseExpr.toHTML(e),s=Vv(this.falseExpr,r,e&&e.implicit);return("all"===r||"OperatorNode"===this.falseExpr.type||null!==s&&s<=t)&&(u='<span class="math-parenthesis math-round-parenthesis">(</span>'+u+'<span class="math-parenthesis math-round-parenthesis">)</span>'),n+'<span class="math-operator math-conditional-operator">?</span>'+a+'<span class="math-operator math-conditional-operator">:</span>'+u}_toTex(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"}}return ed(t,"name",ry),t}),{isClass:!0,isNode:!0}),ny=function(){if(Xv)return Gv;Xv=1;var e=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},r={"{":"\\{","}":"\\}","\\":"\\textbackslash{}","#":"\\#",$:"\\$","%":"\\%","&":"\\&","^":"\\textasciicircum{}",_:"\\_","~":"\\textasciitilde{}"},t={"–":"\\--","—":"\\---"," ":"~","\t":"\\qquad{}","\r\n":"\\newline{}","\n":"\\newline{}"},n=function(r,t){return e({},r,t)};return Gv=function(i){for(var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=a.preserveFormatting,u=void 0!==o&&o,s=a.escapeMapFn,c=i+"",l="",f=(void 0===s?n:s)(e({},r),u?e({},t):{}),m=Object.keys(f),d=function(){var e=!1;m.forEach((function(r,t){e||c.length>=r.length&&c.slice(0,r.length)===r&&(l+=f[m[t]],c=c.slice(r.length,c.length),e=!0)})),e||(l+=c.slice(0,1),c=c.slice(1,c.length))};c;)d();return l},Gv}(),iy=Xn(ny),ay={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{?}"},oy={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"},uy={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(oy.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(oy.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(oy.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(oy.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(oy.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},fraction:{2:"\\frac{${args[0]}}{${args[1]}}"},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(oy.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(oy.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(oy.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(oy.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(oy.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(oy.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(oy.bitAnd,"${args[1]}\\right)")},bitNot:{1:oy.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(oy.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(oy.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(oy.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(oy.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(oy.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(oy.and,"${args[1]}\\right)")},not:{1:oy.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(oy.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(oy.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(oy.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(oy.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(oy.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(oy.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(oy.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(oy.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(oy.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(oy.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(oy.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(oy.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(oy.to,"${args[1]}\\right)")},numeric:function(e){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)"},bigint:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(ay.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)"}},sy={deg:"^\\circ"};function cy(e){return iy(e,{preserveFormatting:!0})}function ly(e,r){return(r=void 0!==r&&r)?Hn(sy,e)?sy[e]:"\\mathrm{"+cy(e)+"}":Hn(ay,e)?ay[e]:cy(e)}var fy="ConstantNode",my=ti(fy,["Node"],(e=>{var{Node:r}=e;class t extends r{constructor(e){super(),this.value=e}get type(){return fy}get isConstantNode(){return!0}_compile(e,r){var t=this.value;return function(){return t}}forEach(e){}map(e){return this.clone()}clone(){return new t(this.value)}_toString(e){return Go(this.value,e)}_toHTML(e){var r=this._toString(e);switch(_n(this.value)){case"number":case"bigint":case"BigNumber":case"Fraction":return'<span class="math-number">'+r+"</span>";case"string":return'<span class="math-string">'+r+"</span>";case"boolean":return'<span class="math-boolean">'+r+"</span>";case"null":return'<span class="math-null-symbol">'+r+"</span>";case"undefined":return'<span class="math-undefined">'+r+"</span>";default:return'<span class="math-symbol">'+r+"</span>"}}toJSON(){return{mathjs:fy,value:this.value}}static fromJSON(e){return new t(e.value)}_toTex(e){var r=this._toString(e),t=_n(this.value);switch(t){case"string":return"\\mathtt{"+cy(r)+"}";case"number":case"BigNumber":if(!("BigNumber"===t?this.value.isFinite():isFinite(this.value)))return this.value.valueOf()<0?"-\\infty":"\\infty";var n=r.toLowerCase().indexOf("e");return-1!==n?r.substring(0,n)+"\\cdot10^{"+r.substring(n+1)+"}":r;case"bigint":return""+r;case"Fraction":return this.value.toLatex();default:return r}}}return ed(t,"name",fy),t}),{isClass:!0,isNode:!0}),dy="FunctionAssignmentNode",py=ti(dy,["typed","Node"],(e=>{var{typed:r,Node:t}=e;function n(e,r,t){var n=Vv(e,r,t),i=Vv(e.expr,r,t);return"all"===r||null!==i&&i<=n}class i extends t{constructor(e,r,t){if(super(),"string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(r))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!In(t))throw new TypeError('Node expected for parameter "expr"');if(zv.has(e))throw Error('Illegal function name, "'+e+'" is a reserved keyword');var n=new Set;for(var i of r){var a="string"==typeof i?i:i.name;if(n.has(a))throw Error('Duplicate parameter name "'.concat(a,'"'));n.add(a)}this.name=e,this.params=r.map((function(e){return e&&e.name||e})),this.types=r.map((function(e){return e&&e.type||"any"})),this.expr=t}get type(){return dy}get isFunctionAssignmentNode(){return!0}_compile(e,t){var n=Object.create(t);xu(this.params,(function(e){n[e]=!0}));var i=this.expr,a=i._compile(e,n),o=this.name,u=this.params,s=Du(this.types,","),c=o+"("+Du(this.params,", ")+")";return function(e,t,n){var l={};l[s]=function(){for(var r=Object.create(t),i=0;i<u.length;i++)r[u[i]]=arguments[i];return a(e,r,n)};var f=r(o,l);return f.syntax=c,f.expr=""+i,e.set(o,f),f}}forEach(e){e(this.expr,"expr",this)}map(e){var r=this._ifNode(e(this.expr,"expr",this));return new i(this.name,this.params.slice(0),r)}clone(){return new i(this.name,this.params.slice(0),this.expr)}_toString(e){var r=e&&e.parenthesis?e.parenthesis:"keep",t=this.expr.toString(e);return n(this,r,e&&e.implicit)&&(t="("+t+")"),this.name+"("+this.params.join(", ")+") = "+t}toJSON(){var e=this.types;return{mathjs:dy,name:this.name,params:this.params.map((function(r,t){return{name:r,type:e[t]}})),expr:this.expr}}static fromJSON(e){return new i(e.name,e.params,e.expr)}_toHTML(e){for(var r=e&&e.parenthesis?e.parenthesis:"keep",t=[],i=0;i<this.params.length;i++)t.push('<span class="math-symbol math-parameter">'+Qo(this.params[i])+"</span>");var a=this.expr.toHTML(e);return n(this,r,e&&e.implicit)&&(a='<span class="math-parenthesis math-round-parenthesis">(</span>'+a+'<span class="math-parenthesis math-round-parenthesis">)</span>'),'<span class="math-function">'+Qo(this.name)+'</span><span class="math-parenthesis math-round-parenthesis">(</span>'+t.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>'+a}_toTex(e){var r=e&&e.parenthesis?e.parenthesis:"keep",t=this.expr.toTex(e);return n(this,r,e&&e.implicit)&&(t="\\left(".concat(t,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(ly).join(",")+"\\right)="+t}}return ed(i,"name",dy),i}),{isClass:!0,isNode:!0}),hy="IndexNode",vy=ti(hy,["Node","size"],(e=>{var{Node:r,size:t}=e;class n extends r{constructor(e,r){if(super(),this.dimensions=e,this.dotNotation=r||!1,!Array.isArray(e)||!e.every(In))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw Error("dotNotation only applicable for object properties")}get type(){return hy}get isIndexNode(){return!0}_compile(e,r){var n=gu(this.dimensions,(function(n,i){if(n.filter((e=>e.isSymbolNode&&"end"===e.name)).length>0){var a=Object.create(r);a.end=!0;var o=n._compile(e,a);return function(e,r,n){if(!cn(n)&&!sn(n)&&!un(n))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+_n(n));var a=t(n).valueOf(),u=Object.create(r);return u.end=a[i],o(e,u,n)}}return n._compile(e,r)})),i=_t(e,"index");return function(e,r,t){var a=gu(n,(function(n){return n(e,r,t)}));return i(...a)}}forEach(e){for(var r=0;r<this.dimensions.length;r++)e(this.dimensions[r],"dimensions["+r+"]",this)}map(e){for(var r=[],t=0;t<this.dimensions.length;t++)r[t]=this._ifNode(e(this.dimensions[t],"dimensions["+t+"]",this));return new n(r,this.dotNotation)}clone(){return new n(this.dimensions.slice(0),this.dotNotation)}isObjectProperty(){return 1===this.dimensions.length&&Bn(this.dimensions[0])&&"string"==typeof this.dimensions[0].value}getObjectProperty(){return this.isObjectProperty()?this.dimensions[0].value:null}_toString(e){return this.dotNotation?"."+this.getObjectProperty():"["+this.dimensions.join(", ")+"]"}toJSON(){return{mathjs:hy,dimensions:this.dimensions,dotNotation:this.dotNotation}}static fromJSON(e){return new n(e.dimensions,e.dotNotation)}_toHTML(e){for(var r=[],t=0;t<this.dimensions.length;t++)r[t]=this.dimensions[t].toHTML();return this.dotNotation?'<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">'+Qo(this.getObjectProperty())+"</span>":'<span class="math-parenthesis math-square-parenthesis">[</span>'+r.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(e){var r=this.dimensions.map((function(r){return r.toTex(e)}));return this.dotNotation?"."+this.getObjectProperty():"_{"+r.join(",")+"}"}}return ed(n,"name",hy),n}),{isClass:!0,isNode:!0}),yy="ObjectNode",by=ti(yy,["Node"],(e=>{var{Node:r}=e;class t extends r{constructor(e){if(super(),this.properties=e||{},e&&("object"!=typeof e||!Object.keys(e).every((function(r){return In(e[r])}))))throw new TypeError("Object containing Nodes expected")}get type(){return yy}get isObjectNode(){return!0}_compile(e,r){var t={};for(var n in this.properties)if(Hn(this.properties,n)){var i=Xo(n),a=JSON.parse(i),o=_t(this.properties,n);t[a]=o._compile(e,r)}return function(e,r,n){var i={};for(var a in t)Hn(t,a)&&(i[a]=t[a](e,r,n));return i}}forEach(e){for(var r in this.properties)Hn(this.properties,r)&&e(this.properties[r],"properties["+Xo(r)+"]",this)}map(e){var r={};for(var n in this.properties)Hn(this.properties,n)&&(r[n]=this._ifNode(e(this.properties[n],"properties["+Xo(n)+"]",this)));return new t(r)}clone(){var e={};for(var r in this.properties)Hn(this.properties,r)&&(e[r]=this.properties[r]);return new t(e)}_toString(e){var r=[];for(var t in this.properties)Hn(this.properties,t)&&r.push(Xo(t)+": "+this.properties[t].toString(e));return"{"+r.join(", ")+"}"}toJSON(){return{mathjs:yy,properties:this.properties}}static fromJSON(e){return new t(e.properties)}_toHTML(e){var r=[];for(var t in this.properties)Hn(this.properties,t)&&r.push('<span class="math-symbol math-property">'+Qo(t)+'</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>'+this.properties[t].toHTML(e));return'<span class="math-parenthesis math-curly-parenthesis">{</span>'+r.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-curly-parenthesis">}</span>'}_toTex(e){var r=[];for(var t in this.properties)Hn(this.properties,t)&&r.push("\\mathbf{"+t+":} & "+this.properties[t].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}"+r.join("\n")+"\\end{array}\\right\\}"}}return ed(t,"name",yy),t}),{isClass:!0,isNode:!0});function gy(e,r){return new Xt(e,new Gt(r),new Set(Object.keys(r)))}var xy="OperatorNode",wy=ti(xy,["Node"],(e=>{var{Node:r}=e;function t(e,r){var n=e;if("auto"===r)for(;Rn(n);)n=n.content;return!!Bn(n)||!!jn(n)&&t(n.args[0],r)}function n(e,r,n,i,a){var o,u=Vv(e,r,n),s=Hv(e,r);if("all"===r||i.length>2&&"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier())return i.map((function(e){switch(e.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}}));switch(i.length){case 0:o=[];break;case 1:var c=Vv(i[0],r,n,e);if(a&&null!==c){var l,f;if("keep"===r?(l=i[0].getIdentifier(),f=e.getIdentifier()):(l=i[0].getContent().getIdentifier(),f=e.getContent().getIdentifier()),!1===Wv[u][f].latexLeftParens){o=[!1];break}if(!1===Wv[c][l].latexParens){o=[!1];break}}if(null===c){o=[!1];break}if(c<=u){o=[!0];break}o=[!1];break;case 2:var m,d,p=Vv(i[0],r,n,e),h=Zv(e,i[0],r);m=null!==p&&(p===u&&"right"===s&&!h||p<u);var v,y,b,g=Vv(i[1],r,n,e),x=Zv(e,i[1],r);d=null!==g&&(g===u&&"left"===s&&!x||g<u),a&&("keep"===r?(v=e.getIdentifier(),y=e.args[0].getIdentifier(),b=e.args[1].getIdentifier()):(v=e.getContent().getIdentifier(),y=e.args[0].getContent().getIdentifier(),b=e.args[1].getContent().getIdentifier()),null!==p&&(!1===Wv[u][v].latexLeftParens&&(m=!1),!1===Wv[p][y].latexParens&&(m=!1)),null!==g&&(!1===Wv[u][v].latexRightParens&&(d=!1),!1===Wv[g][b].latexParens&&(d=!1))),o=[m,d];break;default:"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier()||(o=i.map((function(t){var i=Vv(t,r,n,e),a=Zv(e,t,r),o=Hv(t,r);return null!==i&&(u===i&&s===o&&!a||i<u)})))}if(i.length>=2&&"OperatorNode:multiply"===e.getIdentifier()&&e.implicit&&"all"!==r&&"hide"===n)for(var w=1;w<o.length;++w)!t(i[w],r)||o[w-1]||"keep"===r&&Rn(i[w-1])||(o[w]=!0);return o}class i extends r{constructor(e,r,t,n,i){if(super(),"string"!=typeof e)throw new TypeError('string expected for parameter "op"');if("string"!=typeof r)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(t)||!t.every(In))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=!0===n,this.isPercentage=!0===i,this.op=e,this.fn=r,this.args=t||[]}get type(){return xy}get isOperatorNode(){return!0}_compile(e,r){if("string"!=typeof this.fn||!Vt(e,this.fn))throw Error(e[this.fn]?'No access to function "'+this.fn+'"':"Function "+this.fn+' missing in provided namespace "math"');var t=_t(e,this.fn),n=gu(this.args,(function(t){return t._compile(e,r)}));if("function"==typeof t&&!0===t.rawArgs){var i=this.args;return function(r,n){return t(i,e,gy(r,n))}}if(1===n.length){var a=n[0];return function(e,r,n){return t(a(e,r,n))}}if(2===n.length){var o=n[0],u=n[1];return function(e,r,n){return t(o(e,r,n),u(e,r,n))}}return function(e,r,i){return t.apply(null,gu(n,(function(t){return t(e,r,i)})))}}forEach(e){for(var r=0;r<this.args.length;r++)e(this.args[r],"args["+r+"]",this)}map(e){for(var r=[],t=0;t<this.args.length;t++)r[t]=this._ifNode(e(this.args[t],"args["+t+"]",this));return new i(this.op,this.fn,r,this.implicit,this.isPercentage)}clone(){return new i(this.op,this.fn,this.args.slice(0),this.implicit,this.isPercentage)}isUnary(){return 1===this.args.length}isBinary(){return 2===this.args.length}_toString(e){var r=e&&e.parenthesis?e.parenthesis:"keep",t=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,r,t,i,!1);if(1===i.length){var o=Hv(this,r),u=i[0].toString(e);a[0]&&(u="("+u+")");var s=/[a-zA-Z]+/.test(this.op);return"right"===o?this.op+(s?" ":"")+u:"left"===o?u+(s?" ":"")+this.op:u+this.op}if(2===i.length){var c=i[0].toString(e),l=i[1].toString(e);return a[0]&&(c="("+c+")"),a[1]&&(l="("+l+")"),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===t?c+" "+l:c+" "+this.op+" "+l}if(i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var f=i.map((function(r,t){return r=r.toString(e),a[t]&&(r="("+r+")"),r}));return this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===t?f.join(" "):f.join(" "+this.op+" ")}return this.fn+"("+this.args.join(", ")+")"}toJSON(){return{mathjs:xy,op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}}static fromJSON(e){return new i(e.op,e.fn,e.args,e.implicit,e.isPercentage)}_toHTML(e){var r=e&&e.parenthesis?e.parenthesis:"keep",t=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,r,t,i,!1);if(1===i.length){var o=Hv(this,r),u=i[0].toHTML(e);return a[0]&&(u='<span class="math-parenthesis math-round-parenthesis">(</span>'+u+'<span class="math-parenthesis math-round-parenthesis">)</span>'),"right"===o?'<span class="math-operator math-unary-operator math-lefthand-unary-operator">'+Qo(this.op)+"</span>"+u:u+'<span class="math-operator math-unary-operator math-righthand-unary-operator">'+Qo(this.op)+"</span>"}if(2===i.length){var s=i[0].toHTML(e),c=i[1].toHTML(e);return a[0]&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),a[1]&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===t?s+'<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'+c:s+'<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Qo(this.op)+"</span>"+c}var l=i.map((function(r,t){return r=r.toHTML(e),a[t]&&(r='<span class="math-parenthesis math-round-parenthesis">(</span>'+r+'<span class="math-parenthesis math-round-parenthesis">)</span>'),r}));return i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())?this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===t?l.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'):l.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Qo(this.op)+"</span>"):'<span class="math-function">'+Qo(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+l.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}_toTex(e){var r=e&&e.parenthesis?e.parenthesis:"keep",t=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,r,t,i,!0),o=oy[this.fn];if(o=void 0===o?this.op:o,1===i.length){var u=Hv(this,r),s=i[0].toTex(e);return a[0]&&(s="\\left(".concat(s,"\\right)")),"right"===u?o+s:s+o}if(2===i.length){var c=i[0],l=c.toTex(e);a[0]&&(l="\\left(".concat(l,"\\right)"));var f,m=i[1].toTex(e);switch(a[1]&&(m="\\left(".concat(m,"\\right)")),f="keep"===r?c.getIdentifier():c.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return o+"{"+l+"}{"+m+"}";case"OperatorNode:pow":switch(l="{"+l+"}",m="{"+m+"}",f){case"ConditionalNode":case"OperatorNode:divide":l="\\left(".concat(l,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&"hide"===t)return l+"~"+m}return l+o+m}if(i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var d=i.map((function(r,t){return r=r.toTex(e),a[t]&&(r="\\left(".concat(r,"\\right)")),r}));return"OperatorNode:multiply"===this.getIdentifier()&&this.implicit&&"hide"===t?d.join("~"):d.join(o)}return"\\mathrm{"+this.fn+"}\\left("+i.map((function(r){return r.toTex(e)})).join(",")+"\\right)"}getIdentifier(){return this.type+":"+this.fn}}return ed(i,"name",xy),i}),{isClass:!0,isNode:!0}),Dy="ParenthesisNode",Ny=ti(Dy,["Node"],(e=>{var{Node:r}=e;class t extends r{constructor(e){if(super(),!In(e))throw new TypeError('Node expected for parameter "content"');this.content=e}get type(){return Dy}get isParenthesisNode(){return!0}_compile(e,r){return this.content._compile(e,r)}getContent(){return this.content.getContent()}forEach(e){e(this.content,"content",this)}map(e){var r=e(this.content,"content",this);return new t(r)}clone(){return new t(this.content)}_toString(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)}toJSON(){return{mathjs:Dy,content:this.content}}static fromJSON(e){return new t(e.content)}_toHTML(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?'<span class="math-parenthesis math-round-parenthesis">(</span>'+this.content.toHTML(e)+'<span class="math-parenthesis math-round-parenthesis">)</span>':this.content.toHTML(e)}_toTex(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)}}return ed(t,"name",Dy),t}),{isClass:!0,isNode:!0}),Ay="RangeNode",My=ti(Ay,["Node"],(e=>{var{Node:r}=e;function t(e,r,t){var n=Vv(e,r,t),i={},a=Vv(e.start,r,t);if(i.start=null!==a&&a<=n||"all"===r,e.step){var o=Vv(e.step,r,t);i.step=null!==o&&o<=n||"all"===r}var u=Vv(e.end,r,t);return i.end=null!==u&&u<=n||"all"===r,i}class n extends r{constructor(e,r,t){if(super(),!In(e))throw new TypeError("Node expected");if(!In(r))throw new TypeError("Node expected");if(t&&!In(t))throw new TypeError("Node expected");if(arguments.length>3)throw Error("Too many arguments");this.start=e,this.end=r,this.step=t||null}get type(){return Ay}get isRangeNode(){return!0}needsEnd(){return this.filter((function(e){return Pn(e)&&"end"===e.name})).length>0}_compile(e,r){var t=e.range,n=this.start._compile(e,r),i=this.end._compile(e,r);if(this.step){var a=this.step._compile(e,r);return function(e,r,o){return t(n(e,r,o),i(e,r,o),a(e,r,o))}}return function(e,r,a){return t(n(e,r,a),i(e,r,a))}}forEach(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)}map(e){return new n(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))}clone(){return new n(this.start,this.end,this.step&&this.step)}_toString(e){var r,n=t(this,e&&e.parenthesis?e.parenthesis:"keep",e&&e.implicit),i=this.start.toString(e);if(n.start&&(i="("+i+")"),r=i,this.step){var a=this.step.toString(e);n.step&&(a="("+a+")"),r+=":"+a}var o=this.end.toString(e);return n.end&&(o="("+o+")"),r+":"+o}toJSON(){return{mathjs:Ay,start:this.start,end:this.end,step:this.step}}static fromJSON(e){return new n(e.start,e.end,e.step)}_toHTML(e){var r,n=t(this,e&&e.parenthesis?e.parenthesis:"keep",e&&e.implicit),i=this.start.toHTML(e);if(n.start&&(i='<span class="math-parenthesis math-round-parenthesis">(</span>'+i+'<span class="math-parenthesis math-round-parenthesis">)</span>'),r=i,this.step){var a=this.step.toHTML(e);n.step&&(a='<span class="math-parenthesis math-round-parenthesis">(</span>'+a+'<span class="math-parenthesis math-round-parenthesis">)</span>'),r+='<span class="math-operator math-range-operator">:</span>'+a}var o=this.end.toHTML(e);return n.end&&(o='<span class="math-parenthesis math-round-parenthesis">(</span>'+o+'<span class="math-parenthesis math-round-parenthesis">)</span>'),r+'<span class="math-operator math-range-operator">:</span>'+o}_toTex(e){var r=t(this,e&&e.parenthesis?e.parenthesis:"keep",e&&e.implicit),n=this.start.toTex(e);if(r.start&&(n="\\left(".concat(n,"\\right)")),this.step){var i=this.step.toTex(e);r.step&&(i="\\left(".concat(i,"\\right)")),n+=":"+i}var a=this.end.toTex(e);return r.end&&(a="\\left(".concat(a,"\\right)")),n+":"+a}}return ed(n,"name",Ay),n}),{isClass:!0,isNode:!0}),Cy="RelationalNode",Ey=ti(Cy,["Node"],(e=>{var{Node:r}=e,t={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="};class n extends r{constructor(e,r){if(super(),!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(r))throw new TypeError("Parameter params must be an array");if(e.length!==r.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=r}get type(){return Cy}get isRelationalNode(){return!0}_compile(e,r){var t=this,n=this.params.map((t=>t._compile(e,r)));return function(r,i,a){for(var o,u=n[0](r,i,a),s=0;s<t.conditionals.length;s++)if(o=u,u=n[s+1](r,i,a),!_t(e,t.conditionals[s])(o,u))return!1;return!0}}forEach(e){this.params.forEach(((r,t)=>e(r,"params["+t+"]",this)),this)}map(e){return new n(this.conditionals.slice(),this.params.map(((r,t)=>this._ifNode(e(r,"params["+t+"]",this))),this))}clone(){return new n(this.conditionals,this.params)}_toString(e){for(var r=e&&e.parenthesis?e.parenthesis:"keep",n=Vv(this,r,e&&e.implicit),i=this.params.map((function(t){var i=Vv(t,r,e&&e.implicit);return"all"===r||null!==i&&i<=n?"("+t.toString(e)+")":t.toString(e)})),a=i[0],o=0;o<this.conditionals.length;o++)a+=" "+t[this.conditionals[o]],a+=" "+i[o+1];return a}toJSON(){return{mathjs:Cy,conditionals:this.conditionals,params:this.params}}static fromJSON(e){return new n(e.conditionals,e.params)}_toHTML(e){for(var r=e&&e.parenthesis?e.parenthesis:"keep",n=Vv(this,r,e&&e.implicit),i=this.params.map((function(t){var i=Vv(t,r,e&&e.implicit);return"all"===r||null!==i&&i<=n?'<span class="math-parenthesis math-round-parenthesis">(</span>'+t.toHTML(e)+'<span class="math-parenthesis math-round-parenthesis">)</span>':t.toHTML(e)})),a=i[0],o=0;o<this.conditionals.length;o++)a+='<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Qo(t[this.conditionals[o]])+"</span>"+i[o+1];return a}_toTex(e){for(var r=e&&e.parenthesis?e.parenthesis:"keep",t=Vv(this,r,e&&e.implicit),n=this.params.map((function(n){var i=Vv(n,r,e&&e.implicit);return"all"===r||null!==i&&i<=t?"\\left("+n.toTex(e)+"\right)":n.toTex(e)})),i=n[0],a=0;a<this.conditionals.length;a++)i+=oy[this.conditionals[a]]+n[a+1];return i}}return ed(n,"name",Cy),n}),{isClass:!0,isNode:!0}),Sy=ti("SymbolNode",["math","?Unit","Node"],(e=>{var{math:r,Unit:t,Node:n}=e;function i(e){return!!t&&t.isValuelessUnit(e)}class a extends n{constructor(e){if(super(),"string"!=typeof e)throw new TypeError('String expected for parameter "name"');this.name=e}get type(){return"SymbolNode"}get isSymbolNode(){return!0}_compile(e,r){var n=this.name;if(!0===r[n])return function(e,r){return _t(r,n)};if(n in e)return function(r){return r.has(n)?r.get(n):_t(e,n)};var o=i(n);return function(e){return e.has(n)?e.get(n):o?new t(null,n):a.onUndefinedSymbol(n)}}forEach(e){}map(e){return this.clone()}static onUndefinedSymbol(e){throw Error("Undefined symbol "+e)}clone(){return new a(this.name)}_toString(e){return this.name}_toHTML(e){var r=Qo(this.name);return"true"===r||"false"===r?'<span class="math-symbol math-boolean">'+r+"</span>":"i"===r?'<span class="math-symbol math-imaginary-symbol">'+r+"</span>":"Infinity"===r?'<span class="math-symbol math-infinity-symbol">'+r+"</span>":"NaN"===r?'<span class="math-symbol math-nan-symbol">'+r+"</span>":"null"===r?'<span class="math-symbol math-null-symbol">'+r+"</span>":"undefined"===r?'<span class="math-symbol math-undefined-symbol">'+r+"</span>":'<span class="math-symbol">'+r+"</span>"}toJSON(){return{mathjs:"SymbolNode",name:this.name}}static fromJSON(e){return new a(e.name)}_toTex(e){var t=!1;void 0===r[this.name]&&i(this.name)&&(t=!0);var n=ly(this.name,t);return"\\"===n[0]?n:" "+n}}return a}),{isClass:!0,isNode:!0}),Fy="FunctionNode",By=ti(Fy,["math","Node","SymbolNode"],(e=>{var r,{math:t,Node:n,SymbolNode:i}=e,a=e=>Go(e,{truncate:78});function o(e,r,t){for(var n,i="",a=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,o=0;null!==(n=a.exec(e));)if(i+=e.substring(o,n.index),o=n.index,"$$"===n[0])i+="$",o++;else{o+=n[0].length;var u=r[n[1]];if(!u)throw new ReferenceError("Template: Property "+n[1]+" does not exist.");if(void 0===n[2])switch(typeof u){case"string":i+=u;break;case"object":if(In(u))i+=u.toTex(t);else{if(!Array.isArray(u))throw new TypeError("Template: "+n[1]+" has to be a Node, String or array of Nodes");i+=u.map((function(e,r){if(In(e))return e.toTex(t);throw new TypeError("Template: "+n[1]+"["+r+"] is not a Node.")})).join(",")}break;default:throw new TypeError("Template: "+n[1]+" has to be a Node, String or array of Nodes")}else{if(!In(u[n[2]]&&u[n[2]]))throw new TypeError("Template: "+n[1]+"["+n[2]+"] is not a Node.");i+=u[n[2]].toTex(t)}}return i+e.slice(o)}class u extends n{constructor(e,r){if(super(),"string"==typeof e&&(e=new i(e)),!In(e))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(r)||!r.every(In))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=e,this.args=r||[]}get name(){return this.fn.name||""}get type(){return Fy}get isFunctionNode(){return!0}_compile(e,r){var t=this.args.map((t=>t._compile(e,r)));if(!Pn(this.fn)){if(Mn(this.fn)&&On(this.fn.index)&&this.fn.index.isObjectProperty()){var n=this.fn.object._compile(e,r),i=this.fn.index.getObjectProperty(),o=this.args;return function(r,a,u){var s=n(r,a,u),c=function(e,r){if(!Vt(e,r))throw Error('No access to method "'+r+'"');return e[r]}(s,i);if(null!=c&&c.rawArgs)return c(o,e,gy(r,a));var l=t.map((e=>e(r,a,u)));return c.apply(s,l)}}var s=""+this.fn,c=this.fn._compile(e,r),l=this.args;return function(r,n,i){var o=c(r,n,i);if("function"!=typeof o)throw new TypeError("Expression '".concat(s,"' did not evaluate to a function; value is:")+"\n ".concat(a(o)));if(o.rawArgs)return o(l,e,gy(r,n));var u=t.map((e=>e(r,n,i)));return o.apply(o,u)}}var f=this.fn.name;if(r[f]){var m=this.args;return function(r,n,i){var o=_t(n,f);if("function"!=typeof o)throw new TypeError("Argument '".concat(f,"' was not a function; received: ").concat(a(o)));if(o.rawArgs)return o(m,e,gy(r,n));var u=t.map((e=>e(r,n,i)));return o.apply(o,u)}}var d=f in e?_t(e,f):void 0,p=r=>{var t;if(r.has(f))t=r.get(f);else{if(!(f in e))return u.onUndefinedFunction(f);t=_t(e,f)}if("function"==typeof t)return t;throw new TypeError("'".concat(f,"' is not a function; its value is:\n ").concat(a(t)))};if("function"==typeof d&&!0===d.rawArgs){var h=this.args;return function(r,n,i){var a=p(r);return!0===a.rawArgs?a(h,e,gy(r,n)):a(...t.map((e=>e(r,n,i))))}}switch(t.length){case 0:return function(e){return p(e)()};case 1:return function(e,r,n){return p(e)((0,t[0])(e,r,n))};case 2:return function(e,r,n){var i=p(e),a=t[1];return i((0,t[0])(e,r,n),a(e,r,n))};default:return function(e,r,n){return p(e)(...t.map((t=>t(e,r,n))))}}}forEach(e){e(this.fn,"fn",this);for(var r=0;r<this.args.length;r++)e(this.args[r],"args["+r+"]",this)}map(e){for(var r=this._ifNode(e(this.fn,"fn",this)),t=[],n=0;n<this.args.length;n++)t[n]=this._ifNode(e(this.args[n],"args["+n+"]",this));return new u(r,t)}clone(){return new u(this.fn,this.args.slice(0))}toString(e){var r,t=this.fn.toString(e);return e&&"object"==typeof e.handler&&Hn(e.handler,t)&&(r=e.handler[t](this,e)),void 0!==r?r:super.toString(e)}_toString(e){var r=this.args.map((function(r){return r.toString(e)}));return(Tn(this.fn)?"("+this.fn.toString(e)+")":this.fn.toString(e))+"("+r.join(", ")+")"}toJSON(){return{mathjs:Fy,fn:this.fn,args:this.args}}_toHTML(e){var r=this.args.map((function(r){return r.toHTML(e)}));return'<span class="math-function">'+Qo(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+r.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}toTex(e){var r;return e&&"object"==typeof e.handler&&Hn(e.handler,this.name)&&(r=e.handler[this.name](this,e)),void 0!==r?r:super.toTex(e)}_toTex(e){var r,n,i=this.args.map((function(r){return r.toTex(e)}));switch(uy[this.name]&&(r=uy[this.name]),!t[this.name]||"function"!=typeof t[this.name].toTex&&"object"!=typeof t[this.name].toTex&&"string"!=typeof t[this.name].toTex||(r=t[this.name].toTex),typeof r){case"function":n=r(this,e);break;case"string":n=o(r,this,e);break;case"object":switch(typeof r[i.length]){case"function":n=r[i.length](this,e);break;case"string":n=o(r[i.length],this,e)}}return void 0!==n?n:o("\\mathrm{${name}}\\left(${args}\\right)",this,e)}getIdentifier(){return this.type+":"+this.name}}return r=u,ed(u,"name",Fy),ed(u,"onUndefinedFunction",(function(e){throw Error("Undefined function "+e)})),ed(u,"fromJSON",(function(e){return new r(e.fn,e.args)})),u}),{isClass:!0,isNode:!0}),qy="parse",Ty=ti(qy,["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],(e=>{var{typed:r,numeric:t,config:n,AccessorNode:i,ArrayNode:a,AssignmentNode:o,BlockNode:u,ConditionalNode:s,ConstantNode:c,FunctionAssignmentNode:l,FunctionNode:f,IndexNode:m,ObjectNode:d,OperatorNode:p,ParenthesisNode:h,RangeNode:v,RelationalNode:y,SymbolNode:b}=e,g=r(qy,{string:function(e){return z(e,{})},"Array | Matrix":function(e){return x(e,{})},"string, Object":function(e,r){return z(e,void 0!==r.nodes?r.nodes:{})},"Array | Matrix, Object":x});function x(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=void 0!==r.nodes?r.nodes:{};return Wu(e,(function(e){if("string"!=typeof e)throw new TypeError("String expected");return z(e,t)}))}var w={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},D={",":!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,">>>":!0},N={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},A={true:!0,false:!1,null:null,undefined:void 0},M=["NaN","Infinity"],C={'"':'"',"'":"'","\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function E(e,r){return e.expression.substr(e.index,r)}function S(e){return E(e,1)}function F(e){e.index++}function B(e){return e.expression.charAt(e.index-1)}function q(e){return e.expression.charAt(e.index+1)}function T(e){for(e.tokenType=w.NULL,e.token="",e.comment="";;){if("#"===S(e))for(;"\n"!==S(e)&&""!==S(e);)e.comment+=S(e),F(e);if(!g.isWhitespace(S(e),e.nestingLevel))break;F(e)}if(""!==S(e)){if("\n"===S(e)&&!e.nestingLevel)return e.tokenType=w.DELIMITER,e.token=S(e),void F(e);var r=S(e),t=E(e,2),n=E(e,3);if(3===n.length&&D[n])return e.tokenType=w.DELIMITER,e.token=n,F(e),F(e),void F(e);if(2===t.length&&D[t])return e.tokenType=w.DELIMITER,e.token=t,F(e),void F(e);if(D[r])return e.tokenType=w.DELIMITER,e.token=r,void F(e);if(g.isDigitDot(r)){e.tokenType=w.NUMBER;var i=E(e,2);if("0b"===i||"0o"===i||"0x"===i){for(e.token+=S(e),F(e),e.token+=S(e),F(e);g.isHexDigit(S(e));)e.token+=S(e),F(e);if("."===S(e))for(e.token+=".",F(e);g.isHexDigit(S(e));)e.token+=S(e),F(e);else if("i"===S(e))for(e.token+="i",F(e);g.isDigit(S(e));)e.token+=S(e),F(e);return}if("."===S(e)){if(e.token+=S(e),F(e),!g.isDigit(S(e)))return void(e.tokenType=w.DELIMITER)}else{for(;g.isDigit(S(e));)e.token+=S(e),F(e);g.isDecimalMark(S(e),q(e))&&(e.token+=S(e),F(e))}for(;g.isDigit(S(e));)e.token+=S(e),F(e);if("E"===S(e)||"e"===S(e))if(g.isDigit(q(e))||"-"===q(e)||"+"===q(e)){if(e.token+=S(e),F(e),"+"!==S(e)&&"-"!==S(e)||(e.token+=S(e),F(e)),!g.isDigit(S(e)))throw ne(e,'Digit expected, got "'+S(e)+'"');for(;g.isDigit(S(e));)e.token+=S(e),F(e);if(g.isDecimalMark(S(e),q(e)))throw ne(e,'Digit expected, got "'+S(e)+'"')}else if(g.isDecimalMark(q(e),e.expression.charAt(e.index+2)))throw F(e),ne(e,'Digit expected, got "'+S(e)+'"')}else{if(!g.isAlpha(S(e),B(e),q(e))){for(e.tokenType=w.UNKNOWN;""!==S(e);)e.token+=S(e),F(e);throw ne(e,'Syntax error in part "'+e.token+'"')}for(;g.isAlpha(S(e),B(e),q(e))||g.isDigit(S(e));)e.token+=S(e),F(e);e.tokenType=Hn(N,e.token)?w.DELIMITER:w.SYMBOL}}else e.tokenType=w.DELIMITER}function k(e){do{T(e)}while("\n"===e.token)}function O(e){e.nestingLevel++}function I(e){e.nestingLevel--}function z(e,r){var t={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:w.NULL,nestingLevel:0,conditionalLevel:null};Pt(t,{expression:e,extraNodes:r}),T(t);var n=function(e){var r,t=[];for(""!==e.token&&"\n"!==e.token&&";"!==e.token&&(r=j(e),e.comment&&(r.comment=e.comment));"\n"===e.token||";"===e.token;)0===t.length&&r&&t.push({node:r,visible:";"!==e.token}),T(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&(r=j(e),e.comment&&(r.comment=e.comment),t.push({node:r,visible:";"!==e.token}));return t.length>0?new u(t):(r||(r=new c(void 0),e.comment&&(r.comment=e.comment)),r)}(t);if(""!==t.token)throw t.tokenType===w.DELIMITER?ie(t,"Unexpected operator "+t.token):ne(t,'Unexpected part "'+t.token+'"');return n}function j(e){var r,t,n,i,a=function(e){for(var r=function(e){for(var r=R(e);"or"===e.token;)k(e),r=new p("or","or",[r,R(e)]);return r}(e);"?"===e.token;){var t=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,k(e);var n=r,i=j(e);if(":"!==e.token)throw ne(e,"False part of conditional expression expected");e.conditionalLevel=null,k(e);var a=j(e);r=new s(n,i,a),e.conditionalLevel=t}return r}(e);if("="===e.token){if(Pn(a))return r=a.name,k(e),n=j(e),new o(new b(r),n);if(Mn(a))return k(e),n=j(e),new o(a.object,a.index,n);if(kn(a)&&Pn(a.fn)&&(i=!0,t=[],r=a.name,a.args.forEach((function(e,r){Pn(e)?t[r]=e.name:i=!1})),i))return k(e),n=j(e),new l(r,t,n);throw ne(e,"Invalid left hand side of assignment operator =")}return a}function R(e){for(var r=U(e);"xor"===e.token;)k(e),r=new p("xor","xor",[r,U(e)]);return r}function U(e){for(var r=$(e);"and"===e.token;)k(e),r=new p("and","and",[r,$(e)]);return r}function $(e){for(var r=P(e);"|"===e.token;)k(e),r=new p("|","bitOr",[r,P(e)]);return r}function P(e){for(var r=L(e);"^|"===e.token;)k(e),r=new p("^|","bitXor",[r,L(e)]);return r}function L(e){for(var r=_(e);"&"===e.token;)k(e),r=new p("&","bitAnd",[r,_(e)]);return r}function _(e){for(var r=[W(e)],t=[],n={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};Hn(n,e.token);)t.push({name:e.token,fn:n[e.token]}),k(e),r.push(W(e));return 1===r.length?r[0]:2===r.length?new p(t[0].name,t[0].fn,r):new y(t.map((e=>e.fn)),r)}function W(e){var r,t,n,i;r=J(e);for(var a={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Hn(a,e.token);)n=a[t=e.token],k(e),i=[r,J(e)],r=new p(t,n,i);return r}function J(e){var r,t,n,i;r=V(e);for(var a={to:"to",in:"to"};Hn(a,e.token);)n=a[t=e.token],k(e),"in"===t&&"])},;".includes(e.token)?r=new p("*","multiply",[r,new b("in")],!0):(i=[r,V(e)],r=new p(t,n,i));return r}function V(e){var r,t=[];if(r=":"===e.token?new c(1):H(e),":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(t.push(r);":"===e.token&&t.length<3;)k(e),t.push(")"===e.token||"]"===e.token||","===e.token||""===e.token?new b("end"):H(e));r=3===t.length?new v(t[0],t[2],t[1]):new v(t[0],t[1])}return r}function H(e){var r,t,n,i;r=Z(e);for(var a={"+":"add","-":"subtract"};Hn(a,e.token);){n=a[t=e.token],k(e);var o=Z(e);i=o.isPercentage?[r,new p("*","multiply",[r,o])]:[r,o],r=new p(t,n,i)}return r}function Z(e){var r,t,n,i;t=r=G(e);for(var a={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"};Hn(a,e.token);)if(i=a[n=e.token],k(e),"%"===n&&e.tokenType===w.DELIMITER&&"("!==e.token)if(""!==e.token&&a[e.token]){var o=new p("/","divide",[r,new c(100)],!1,!0);i=a[n=e.token],k(e),t=G(e),r=new p(n,i,[o,t])}else r=new p("/","divide",[r,new c(100)],!1,!0);else t=G(e),r=new p(n,i,[r,t]);return r}function G(e){var r,t;for(t=r=X(e);e.tokenType===w.SYMBOL||"in"===e.token&&Bn(r)||"in"===e.token&&jn(r)&&"unaryMinus"===r.fn&&Bn(r.args[0])||!(e.tokenType!==w.NUMBER||Bn(t)||jn(t)&&"!"!==t.op)||"("===e.token;)t=X(e),r=new p("*","multiply",[r,t],!0);return r}function X(e){for(var r=Y(e),t=r,n=[];"/"===e.token&&qn(t);){if(n.push(Pt({},e)),k(e),e.tokenType!==w.NUMBER){Pt(e,n.pop());break}if(n.push(Pt({},e)),k(e),e.tokenType!==w.SYMBOL&&"("!==e.token&&"in"!==e.token){n.pop(),Pt(e,n.pop());break}Pt(e,n.pop()),n.pop(),t=Y(e),r=new p("/","divide",[r,t])}return r}function Y(e){var r,t,n,i={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Hn(i,e.token)?(n=i[e.token],r=e.token,k(e),t=[Y(e)],new p(r,n,t)):function(e){var r,t,n,i;return r=function(e){for(var r=Q(e);"??"===e.token;)k(e),r=new p("??","nullish",[r,Q(e)]);return r}(e),("^"===e.token||".^"===e.token)&&(n="^"===(t=e.token)?"pow":"dotPow",k(e),i=[r,Y(e)],r=new p(t,n,i)),r}(e)}function Q(e){var r,i,o;r=function(e){var r=[];if(e.tokenType===w.SYMBOL&&Hn(e.extraNodes,e.token)){var i=e.extraNodes[e.token];if(T(e),"("===e.token){if(r=[],O(e),T(e),")"!==e.token)for(r.push(j(e));","===e.token;)T(e),r.push(j(e));if(")"!==e.token)throw ne(e,"Parenthesis ) expected");I(e),T(e)}return new i(r)}return function(e){var r;return e.tokenType===w.SYMBOL||e.tokenType===w.DELIMITER&&e.token in N?(r=e.token,T(e),K(e,Hn(A,r)?new c(A[r]):M.includes(r)?new c(t(r,"number")):new b(r))):function(e){var r;return'"'===e.token||"'"===e.token?(r=ee(e,e.token),K(e,new c(r))):function(e){var r,i,o,u;if("["===e.token){if(O(e),T(e),"]"!==e.token){var s=re(e);if(";"===e.token){for(o=1,i=[s];";"===e.token;)T(e),"]"!==e.token&&(i[o]=re(e),o++);if("]"!==e.token)throw ne(e,"End of matrix ] expected");I(e),T(e),u=i[0].items.length;for(var l=1;l<o;l++)if(i[l].items.length!==u)throw ie(e,"Column dimensions mismatch ("+i[l].items.length+" !== "+u+")");r=new a(i)}else{if("]"!==e.token)throw ne(e,"End of matrix ] expected");I(e),T(e),r=s}}else I(e),T(e),r=new a([]);return K(e,r)}return function(e){if("{"===e.token){var r;O(e);var i={};do{if(T(e),"}"!==e.token){if('"'===e.token||"'"===e.token)r=ee(e,e.token);else{if(!(e.tokenType===w.SYMBOL||e.tokenType===w.DELIMITER&&e.token in N))throw ne(e,"Symbol or string expected as object key");r=e.token,T(e)}if(":"!==e.token)throw ne(e,"Colon : expected after object key");T(e),i[r]=j(e)}}while(","===e.token);if("}"!==e.token)throw ne(e,"Comma , or bracket } expected after object value");I(e),T(e);var a=new d(i);return K(e,a)}return function(e){var r;if(e.tokenType===w.NUMBER){r=e.token,T(e);var i=ai(r,n),a=t(r,i);return new c(a)}return function(e){var r;if("("===e.token){if(O(e),T(e),r=j(e),")"!==e.token)throw ne(e,"Parenthesis ) expected");return I(e),T(e),K(e,r=new h(r))}return function(e){throw ne(e,""===e.token?"Unexpected end of expression":"Value expected")}(e)}(e)}(e)}(e)}(e)}(e)}(e)}(e);for(var u={"!":"factorial","'":"ctranspose"};Hn(u,e.token);)o=u[i=e.token],T(e),r=K(e,r=new p(i,o,[r]));return r}function K(e,r){for(var t;"("===e.token||"["===e.token||"."===e.token;)if(t=[],"("===e.token){if(!Pn(r)&&!Mn(r))return r;if(O(e),T(e),")"!==e.token)for(t.push(j(e));","===e.token;)T(e),t.push(j(e));if(")"!==e.token)throw ne(e,"Parenthesis ) expected");I(e),T(e),r=new f(r,t)}else if("["===e.token){if(O(e),T(e),"]"!==e.token)for(t.push(j(e));","===e.token;)T(e),t.push(j(e));if("]"!==e.token)throw ne(e,"Parenthesis ] expected");I(e),T(e),r=new i(r,new m(t))}else{if(T(e),!(e.tokenType===w.SYMBOL||e.tokenType===w.DELIMITER&&e.token in N))throw ne(e,"Property name expected after dot");t.push(new c(e.token)),T(e),r=new i(r,new m(t,!0))}return r}function ee(e,r){for(var t="";""!==S(e)&&S(e)!==r;)if("\\"===S(e)){F(e);var n=S(e),i=C[n];if(void 0!==i)t+=i,e.index+=1;else{if("u"!==n)throw ne(e,"Bad escape character \\".concat(n));var a=e.expression.slice(e.index+1,e.index+5);if(!/^[0-9A-Fa-f]{4}$/.test(a))throw ne(e,"Invalid unicode character \\u".concat(a));t+=String.fromCharCode(parseInt(a,16)),e.index+=5}}else t+=S(e),F(e);if(T(e),e.token!==r)throw ne(e,"End of string ".concat(r," expected"));return T(e),t}function re(e){for(var r=[j(e)],t=1;","===e.token;)T(e),"]"!==e.token&&";"!==e.token&&(r[t]=j(e),t++);return new a(r)}function te(e){return e.index-e.token.length+1}function ne(e,r){var t=te(e),n=new SyntaxError(r+" (char "+t+")");return n.char=t,n}function ie(e,r){var t=te(e),n=new SyntaxError(r+" (char "+t+")");return n.char=t,n}return g.isAlpha=function(e,r,t){return g.isValidLatinOrGreek(e)||g.isValidMathSymbol(e,t)||g.isValidMathSymbol(r,e)},g.isValidLatinOrGreek=function(e){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(e)},g.isValidMathSymbol=function(e,r){return/^[\uD835]$/.test(e)&&/^[\uDC00-\uDFFF]$/.test(r)&&/^[^\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(r)},g.isWhitespace=function(e,r){return" "===e||"\t"===e||" "===e||"\n"===e&&r>0},g.isDecimalMark=function(e,r){return"."===e&&"/"!==r&&"*"!==r&&"^"!==r},g.isDigitDot=function(e){return e>="0"&&e<="9"||"."===e},g.isDigit=function(e){return e>="0"&&e<="9"},g.isHexDigit=function(e){return e>="0"&&e<="9"||e>="a"&&e<="f"||e>="A"&&e<="F"},r.addConversion({from:"string",to:"Node",convert:g}),g})),ky="compile",Oy=ti(ky,["typed","parse"],(e=>{var{typed:r,parse:t}=e;return r(ky,{string:function(e){return t(e).compile()},"Array | Matrix":function(e){return Wu(e,(function(e){return t(e).compile()}))}})})),Iy="evaluate",zy=ti(Iy,["typed","parse"],(e=>{var{typed:r,parse:t}=e;return r(Iy,{string:function(e){var r=Qt();return t(e).compile().evaluate(r)},"string, Map | Object":function(e,r){return t(e).compile().evaluate(r)},"Array | Matrix":function(e){var r=Qt();return Wu(e,(function(e){return t(e).compile().evaluate(r)}))},"Array | Matrix, Map | Object":function(e,r){return Wu(e,(function(e){return t(e).compile().evaluate(r)}))}})})),jy=ti("Parser",["evaluate","parse"],(e=>{var{evaluate:r,parse:t}=e;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:Qt(),writable:!1})}return n.prototype.type="Parser",n.prototype.isParser=!0,n.prototype.evaluate=function(e){return r(e,this.scope)},n.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},n.prototype.getAll=function(){return function(e){if(e instanceof Gt)return e.wrappedObject;var r={};for(var t of e.keys())Wt(r,t,e.get(t));return r}(this.scope)},n.prototype.getAllAsMap=function(){return this.scope},n.prototype.set=function(e,r){if(!function(e){if(0===e.length)return!1;for(var r=0;r<e.length;r++){var n=e.charAt(r-1),i=e.charAt(r),a=e.charAt(r+1);if(!(t.isAlpha(i,n,a)||r>0&&t.isDigit(i)))return!1}return!0}(e))throw Error("Invalid variable name: '".concat(e,"'. Variable names must follow the specified rules."));return this.scope.set(e,r),r},n.prototype.remove=function(e){this.scope.delete(e)},n.prototype.clear=function(){this.scope.clear()},n.prototype.toJSON=function(){var e={mathjs:"Parser",variables:{},functions:{}};for(var[r,t]of this.scope)if(bn(t)){if(!Ry(t))throw Error("Cannot serialize external function ".concat(r));e.functions[r]="".concat(t.syntax," = ").concat(t.expr)}else e.variables[r]=t;return e},n.fromJSON=function(e){var r=new n;return Object.entries(e.variables).forEach((e=>{var[t,n]=e;return r.set(t,n)})),Object.entries(e.functions).forEach((e=>{var[t,n]=e;return r.evaluate(n)})),r},n}),{isClass:!0});function Ry(e){return"function"==typeof e&&"string"==typeof e.syntax&&"string"==typeof e.expr}var Uy="parser",$y=ti(Uy,["typed","Parser"],(e=>{var{typed:r,Parser:t}=e;return r(Uy,{"":function(){return new t}})})),Py=ti("lup",["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtractScalar","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],(e=>{var{typed:r,matrix:t,abs:n,addScalar:i,divideScalar:a,multiplyScalar:o,subtractScalar:u,larger:s,equalScalar:c,unaryMinus:l,DenseMatrix:f,SparseMatrix:m,Spa:d}=e;return r("lup",{DenseMatrix:function(e){return p(e)},SparseMatrix:function(e){return function(e){var r,t,i,u=e._size[0],f=e._size[1],p=Math.min(u,f),h=e._values,v=e._index,y=e._ptr,b=[],g=[],x=[],w=[u,p],D=[],N=[],A=[],M=[p,f],C=[],E=[];for(r=0;r<u;r++)C[r]=r,E[r]=r;var S=function(){var e=new d;t<u&&(x.push(b.length),b.push(1),g.push(t)),A.push(D.length);var f=y[t+1];for(i=y[t];i<f;i++)e.set(C[r=v[i]],h[i]);t>0&&e.forEach(0,t-1,(function(r,t){m._forEachRow(r,b,g,x,(function(n,i){n>r&&e.accumulate(n,l(o(i,t)))}))}));var p=t,S=e.get(t),F=n(S);e.forEach(t+1,u-1,(function(e,r){var t=n(r);s(t,F)&&(p=e,F=t,S=r)})),t!==p&&(m._swapRows(t,p,w[1],b,g,x),m._swapRows(t,p,M[1],D,N,A),e.swap(t,p),function(e,r){var t=E[e],n=E[r];C[t]=r,C[n]=e,E[e]=n,E[r]=t}(t,p)),e.forEach(0,u-1,(function(e,r){e<=t?(D.push(r),N.push(e)):(r=a(r,S),c(r,0)||(b.push(r),g.push(e)))}))};for(t=0;t<f;t++)S();return A.push(D.length),x.push(b.length),{L:new m({values:b,index:g,ptr:x,size:w}),U:new m({values:D,index:N,ptr:A,size:M}),p:C,toString:function(){return"L: "+this.L+"\nU: "+this.U+"\nP: "+this.p}}}(e)},Array:function(e){var r=p(t(e));return{L:r.L.valueOf(),U:r.U.valueOf(),p:r.p}}});function p(e){var r,t,l,m=e._size[0],d=e._size[1],p=Math.min(m,d),h=Wn(e._data),v=[],y=[m,p],b=[],g=[p,d],x=[];for(r=0;r<m;r++)x[r]=r;for(t=0;t<d;t++){if(t>0)for(r=0;r<m;r++){var w=Math.min(r,t),D=0;for(l=0;l<w;l++)D=i(D,o(h[r][l],h[l][t]));h[r][t]=u(h[r][t],D)}var N=t,A=0,M=0;for(r=t;r<m;r++){var C=h[r][t],E=n(C);s(E,A)&&(N=r,A=E,M=C)}if(t!==N&&(x[t]=[x[N],x[N]=x[t]][0],f._swapRows(t,N,h)),t<m)for(r=t+1;r<m;r++)c(h[r][t],0)||(h[r][t]=a(h[r][t],M))}for(t=0;t<d;t++)for(r=0;r<m;r++)0===t&&(r<d&&(b[r]=[]),v[r]=[]),r<t?(r<d&&(b[r][t]=h[r][t]),t<m&&(v[r][t]=0)):r!==t?(r<d&&(b[r][t]=0),t<m&&(v[r][t]=h[r][t])):(r<d&&(b[r][t]=h[r][t]),t<m&&(v[r][t]=1));var S=new f({data:v,size:y}),F=new f({data:b,size:g}),B=[];for(r=0,p=x.length;r<p;r++)B[x[r]]=r;return{L:S,U:F,p:B,toString:function(){return"L: "+this.L+"\nU: "+this.U+"\nP: "+this.p}}}})),Ly=ti("qr",["typed","matrix","zeros","identity","isZero","equal","sign","sqrt","conj","unaryMinus","addScalar","divideScalar","multiplyScalar","subtractScalar","complex"],(e=>{var{typed:r,matrix:t,zeros:n,identity:i,isZero:a,equal:o,sign:u,sqrt:s,conj:c,unaryMinus:l,addScalar:f,divideScalar:m,multiplyScalar:d,subtractScalar:p,complex:h}=e;return Pt(r("qr",{DenseMatrix:function(e){return y(e)},SparseMatrix:function(){return function(){throw Error("qr not implemented for sparse matrices yet")}()},Array:function(e){var r=y(t(e));return{Q:r.Q.valueOf(),R:r.R.valueOf()}}}),{_denseQRimpl:v});function v(e){var r,t,h,v=e._size[0],y=e._size[1],b=i([v],"dense"),g=b._data,x=e.clone(),w=x._data,D=n([v],"");for(h=0;h<Math.min(y,v);++h){var N=w[h][h],A=l(o(N,0)?1:u(N)),M=c(A),C=0;for(r=h;r<v;r++)C=f(C,d(w[r][h],c(w[r][h])));var E=d(A,s(C));if(!a(E)){var S=p(N,E);for(D[h]=1,r=h+1;r<v;r++)D[r]=m(w[r][h],S);var F=l(c(m(S,E))),B=void 0;for(t=h;t<y;t++){for(B=0,r=h;r<v;r++)B=f(B,d(c(D[r]),w[r][t]));for(B=d(B,F),r=h;r<v;r++)w[r][t]=d(p(w[r][t],d(D[r],B)),M)}for(r=0;r<v;r++){for(B=0,t=h;t<v;t++)B=f(B,d(g[r][t],D[t]));for(B=d(B,F),t=h;t<v;++t)g[r][t]=m(p(g[r][t],d(B,c(D[t]))),M)}}}return{Q:b,R:x,toString:function(){return"Q: "+this.Q+"\nR: "+this.R}}}function y(e){var r=v(e),t=r.R._data;if(e._data.length>0)for(var n="Complex"===t[0][0].type?h(0):0,i=0;i<t.length;++i)for(var a=0;a<i&&a<(t[0]||[]).length;++a)t[i][a]=n;return r}}));function _y(e,r,t,n,i,a,o){var u=0;for(t[o]=e;u>=0;){var s=t[o+u],c=t[n+s];-1===c?(u--,a[r++]=s):(t[n+s]=t[i+c],t[o+ ++u]=c)}return r}function Wy(e){return-e-2}var Jy=ti("csAmd",["add","multiply","transpose"],(e=>{var{add:r,multiply:t,transpose:n}=e;return function(e,o){if(!o||e<=0||e>3)return null;var u=o._size,s=u[0],c=u[1],l=0,f=Math.max(16,10*Math.sqrt(c)),m=function(e,i,a,o,u){var s=n(i);if(1===e&&o===a)return r(i,s);if(2===e){for(var c=s._index,l=s._ptr,f=0,m=0;m<a;m++){var d=l[m];if(l[m]=f,!(l[m+1]-d>u))for(var p=l[m+1];d<p;d++)c[f++]=c[d]}return l[a]=f,i=n(s),t(s,i)}return t(s,i)}(e,o,s,c,f=Math.min(c-2,f));!function(e,r){for(var t=e._values,n=e._index,i=e._ptr,a=e._size[1],o=0,u=0;u<a;u++){var s=i[u];for(i[u]=o;s<i[u+1];s++)r(n[s],u,t?t[s]:1,null)&&(n[o]=n[s],t&&(t[o]=t[s]),o++)}i[a]=o,n.splice(o,n.length-o),t&&t.splice(o,t.length-o)}(m,a);for(var d,p,h,v,y,b,g,x,w,D,N,A,M,C,E,S,F=m._index,B=m._ptr,q=B[c],T=[],k=[],O=c+1,I=2*(c+1),z=3*(c+1),j=4*(c+1),R=5*(c+1),U=6*(c+1),$=7*(c+1),P=T,L=function(e,r,t,n,a,o,u,s,c,l,f,m){for(var d=0;d<e;d++)t[0+d]=r[d+1]-r[d];t[0+e]=0;for(var p=0;p<=e;p++)t[a+p]=-1,o[p]=-1,t[u+p]=-1,t[s+p]=-1,t[c+p]=1,t[l+p]=1,t[f+p]=0,t[m+p]=t[0+p];var h=i(0,0,t,l,e);return t[f+e]=-2,r[e]=-1,t[l+e]=0,h}(c,B,k,0,z,P,I,$,O,U,j,R),_=function(e,r,t,n,i,a,o,u,s,c,l){for(var f=0,m=0;m<e;m++){var d=t[n+m];if(0===d)t[i+m]=-2,f++,r[m]=-1,t[a+m]=0;else if(d>o)t[u+m]=0,t[i+m]=-1,f++,r[m]=Wy(e),t[u+e]++;else{var p=t[s+d];-1!==p&&(c[p]=m),t[l+m]=t[s+d],t[s+d]=m}}return f}(c,B,k,R,j,U,f,O,z,P,I),W=0;_<c;){for(h=-1;W<c&&-1===(h=k[z+W]);W++);-1!==k[I+h]&&(P[k[I+h]]=-1),k[z+W]=k[I+h];var J=k[j+h],V=k[O+h];_+=V;var H=0;k[O+h]=-V;var Z=B[h],G=0===J?Z:q,X=G;for(v=1;v<=J+1;v++){for(v>J?(b=h,g=Z,x=k[0+h]-J):(g=B[b=F[Z++]],x=k[0+b]),y=1;y<=x;y++)(w=k[O+(d=F[g++])])<=0||(H+=w,k[O+d]=-w,F[X++]=d,-1!==k[I+d]&&(P[k[I+d]]=P[d]),-1!==P[d]?k[I+P[d]]=k[I+d]:k[z+k[R+d]]=k[I+d]);b!==h&&(B[b]=Wy(h),k[U+b]=0)}for(0!==J&&(q=X),k[R+h]=H,B[h]=G,k[0+h]=X-G,k[j+h]=-2,L=i(L,l,k,U,c),D=G;D<X;D++)if(!((N=k[j+(d=F[D])])<=0)){var Y=L-(w=-k[O+d]);for(Z=B[d],A=B[d]+N-1;Z<=A;Z++)k[U+(b=F[Z])]>=L?k[U+b]-=w:0!==k[U+b]&&(k[U+b]=k[R+b]+Y)}for(D=G;D<X;D++){for(M=(A=B[d=F[D]])+k[j+d]-1,C=A,E=0,S=0,Z=A;Z<=M;Z++)if(0!==k[U+(b=F[Z])]){var Q=k[U+b]-L;Q>0?(S+=Q,F[C++]=b,E+=b):(B[b]=Wy(h),k[U+b]=0)}k[j+d]=C-A+1;var K=C,ee=A+k[0+d];for(Z=M+1;Z<ee;Z++){var re=k[O+(p=F[Z])];re<=0||(S+=re,F[C++]=p,E+=p)}0===S?(B[d]=Wy(h),H-=w=-k[O+d],V+=w,_+=w,k[O+d]=0,k[j+d]=-1):(k[R+d]=Math.min(k[R+d],S),F[C]=F[K],F[K]=F[A],F[A]=h,k[0+d]=C-A+1,k[I+d]=k[$+(E=(E<0?-E:E)%c)],k[$+E]=d,P[d]=E)}for(k[R+h]=H,L=i(L+(l=Math.max(l,H)),l,k,U,c),D=G;D<X;D++)if(!(k[O+(d=F[D])]>=0))for(d=k[$+(E=P[d])],k[$+E]=-1;-1!==d&&-1!==k[I+d];d=k[I+d],L++){for(x=k[0+d],N=k[j+d],Z=B[d]+1;Z<=B[d]+x-1;Z++)k[U+F[Z]]=L;var te=d;for(p=k[I+d];-1!==p;){var ne=k[0+p]===x&&k[j+p]===N;for(Z=B[p]+1;ne&&Z<=B[p]+x-1;Z++)k[U+F[Z]]!==L&&(ne=0);ne?(B[p]=Wy(d),k[O+d]+=k[O+p],k[O+p]=0,k[j+p]=-1,k[I+te]=p=k[I+p]):(te=p,p=k[I+p])}}for(Z=G,D=G;D<X;D++)(w=-k[O+(d=F[D])])<=0||(k[O+d]=w,-1!==k[z+(S=Math.min(S=k[R+d]+H-w,c-_-w))]&&(P[k[z+S]]=d),k[I+d]=k[z+S],P[d]=-1,k[z+S]=d,W=Math.min(W,S),k[R+d]=S,F[Z++]=d);k[O+h]=V,0==(k[0+h]=Z-G)&&(B[h]=-1,k[U+h]=0),0!==J&&(q=Z)}for(d=0;d<c;d++)B[d]=Wy(B[d]);for(p=0;p<=c;p++)k[z+p]=-1;for(p=c;p>=0;p--)k[O+p]>0||(k[I+p]=k[z+B[p]],k[z+B[p]]=p);for(b=c;b>=0;b--)k[O+b]<=0||-1!==B[b]&&(k[I+b]=k[z+B[b]],k[z+B[b]]=b);for(h=0,d=0;d<=c;d++)-1===B[d]&&(h=_y(d,h,k,z,I,T,U));return T.splice(T.length-1,1),T};function i(e,r,t,n,i){if(e<2||e+r<0){for(var a=0;a<i;a++)0!==t[n+a]&&(t[n+a]=1);e=2}return e}function a(e,r){return e!==r}}));function Vy(e,r,t,n,i,a,o){var u,s,c,l=0;if(e<=r||t[n+r]<=t[i+e])return-1;t[i+e]=t[n+r];var f=t[a+e];if(t[a+e]=r,-1===f)l=1,c=e;else{for(l=2,c=f;c!==t[o+c];c=t[o+c]);for(u=f;u!==c;u=s)s=t[o+u],t[o+u]=c}return{jleaf:l,q:c}}var Hy=ti("csCounts",["transpose"],(e=>{var{transpose:r}=e;return function(e,t,n,i){if(!e||!t||!n)return null;var a,o,u,s,c,l,f=e._size,m=f[0],d=f[1],p=4*d+(i?d+m+1:0),h=[],v=d,y=2*d,b=3*d,g=4*d,x=5*d+1;for(u=0;u<p;u++)h[u]=-1;var w=[],D=r(e),N=D._index,A=D._ptr;for(u=0;u<d;u++)for(w[o=n[u]]=-1===h[b+o]?1:0;-1!==o&&-1===h[b+o];o=t[o])h[b+o]=u;if(i){for(u=0;u<d;u++)h[n[u]]=u;for(a=0;a<m;a++){for(u=d,l=A[a+1],c=A[a];c<l;c++)u=Math.min(u,h[N[c]]);h[x+a]=h[g+u],h[g+u]=a}}for(a=0;a<d;a++)h[0+a]=a;for(u=0;u<d;u++){for(-1!==t[o=n[u]]&&w[t[o]]--,s=i?h[g+u]:o;-1!==s;s=i?h[x+s]:-1)for(c=A[s];c<A[s+1];c++){var M=Vy(a=N[c],o,h,b,v,y,0);M.jleaf>=1&&w[o]++,2===M.jleaf&&w[M.q]--}-1!==t[o]&&(h[0+o]=t[o])}for(o=0;o<d;o++)-1!==t[o]&&(w[t[o]]+=w[o]);return w}})),Zy=ti("csSqr",["add","multiply","transpose"],(e=>{var{add:r,multiply:t,transpose:n}=e,i=Jy({add:r,multiply:t,transpose:n}),a=Hy({transpose:n});return function(e,r,t){var n,o=r._ptr,u=r._size[1],s={};if(s.q=i(e,r),e&&!s.q)return null;if(t){var c=e?function(e,r,t){for(var n=e._index,i=e._ptr,a=e._size,o=e._datatype,u=a[0],s=a[1],c=[],l=[],f=0,m=0;m<s;m++){l[m]=f;for(var d=t?t[m]:m,p=i[d+1],h=i[d];h<p;h++)c[f]=n[h],f++}return l[s]=f,e.createSparseMatrix({values:null,index:c,ptr:l,size:[u,s],datatype:o})}(r,0,s.q):r;s.parent=function(e){if(!e)return null;var r,t,n=e._index,i=e._ptr,a=e._size,o=a[0],u=a[1],s=[],c=[],l=u;for(r=0;r<o;r++)c[l+r]=-1;for(var f=0;f<u;f++){s[f]=-1,c[0+f]=-1;for(var m=i[f+1],d=i[f];d<m;d++){var p=n[d];for(r=c[l+p];-1!==r&&r<f;r=t)t=c[0+r],c[0+r]=f,-1===t&&(s[r]=f);c[l+p]=f}}return s}(c);var l=function(e,r){if(!e)return null;var t,n=0,i=[],a=[],o=r,u=2*r;for(t=0;t<r;t++)a[0+t]=-1;for(t=r-1;t>=0;t--)-1!==e[t]&&(a[o+t]=a[0+e[t]],a[0+e[t]]=t);for(t=0;t<r;t++)-1===e[t]&&(n=_y(t,n,a,0,o,i,u));return i}(s.parent,u);if(s.cp=a(c,s.parent,l,1),c&&s.parent&&s.cp&&function(e,r){var t=e._ptr,n=e._index,i=e._size,a=i[0],o=i[1];r.pinv=[],r.leftmost=[];var u,s,c,l,f=r.parent,m=r.pinv,d=r.leftmost,p=[],h=a,v=a+o,y=a+2*o;for(s=0;s<o;s++)p[h+s]=-1,p[v+s]=-1,p[y+s]=0;for(u=0;u<a;u++)d[u]=-1;for(s=o-1;s>=0;s--)for(l=t[s+1],c=t[s];c<l;c++)d[n[c]]=s;for(u=a-1;u>=0;u--)m[u]=-1,-1!==(s=d[u])&&(0==p[y+s]++&&(p[v+s]=u),p[0+u]=p[h+s],p[h+s]=u);for(r.lnz=0,r.m2=a,s=0;s<o;s++)if(u=p[h+s],r.lnz++,u<0&&(u=r.m2++),m[u]=s,!(--y[s]<=0)){r.lnz+=p[y+s];var b=f[s];-1!==b&&(0===p[y+b]&&(p[v+b]=p[v+s]),p[0+p[v+s]]=p[h+b],p[h+b]=p[0+u],p[y+b]+=p[y+s])}for(u=0;u<a;u++)m[u]<0&&(m[u]=s++);return!0}(c,s))for(s.unz=0,n=0;n<u;n++)s.unz+=s.cp[n]}else s.unz=4*o[u]+u,s.lnz=s.unz;return s}}));function Gy(e,r){return e[r]<0}function Xy(e,r){e[r]=Wy(e[r])}function Yy(e){return e<0?Wy(e):e}function Qy(e,r,t,n,i){var a,o,u,s=r._index,c=r._ptr,l=r._size[1],f=0;for(n[0]=e;f>=0;){e=n[f];var m=i?i[e]:e;Gy(c,e)||(Xy(c,e),n[l+f]=m<0?0:Yy(c[m]));var d=1;for(o=n[l+f],u=m<0?0:Yy(c[m+1]);o<u;o++)if(!Gy(c,a=s[o])){n[l+f]=o,n[++f]=a,d=0;break}d&&(f--,n[--t]=e)}return t}var Ky=ti("csSpsolve",["divideScalar","multiply","subtract"],(e=>{var{divideScalar:r,multiply:t,subtract:n}=e;return function(e,i,a,o,u,s,c){var l,f,m,d,p=e._values,h=e._index,v=e._ptr,y=e._size[1],b=i._values,g=i._index,x=i._ptr,w=function(e,r,t,n,i){var a,o,u=e._ptr,s=r._index,c=r._ptr,l=e._size[1],f=l;for(o=c[t+1],a=c[t];a<o;a++){var m=s[a];Gy(u,m)||(f=Qy(m,e,f,n,i))}for(a=f;a<l;a++)Xy(u,n[a]);return f}(e,i,a,o,s);for(l=w;l<y;l++)u[o[l]]=0;for(m=x[a+1],l=f=x[a];l<m;l++)u[g[l]]=b[l];for(var D=w;D<y;D++){var N=o[D],A=s?s[N]:N;if(!(A<0))for(f=v[A],m=v[A+1],u[N]=r(u[N],p[c?f:m-1]),l=c?f+1:f,d=c?m:m-1;l<d;l++){var M=h[l];u[M]=n(u[M],t(p[l],u[N]))}}return w}})),eb=ti("csLu",["abs","divideScalar","multiply","subtract","larger","largerEq","SparseMatrix"],(e=>{var{abs:r,divideScalar:t,multiply:n,subtract:i,larger:a,largerEq:o,SparseMatrix:u}=e,s=Ky({divideScalar:t,multiply:n,subtract:i});return function(e,i,c){if(!e)return null;var l,f=e._size[1],m=100,d=100;i&&(l=i.q,m=i.lnz||m,d=i.unz||d);var p,h,v=[],y=[],b=[],g=new u({values:v,index:y,ptr:b,size:[f,f]}),x=[],w=[],D=[],N=new u({values:x,index:w,ptr:D,size:[f,f]}),A=[],M=[],C=[];for(p=0;p<f;p++)M[p]=0,A[p]=-1,b[p+1]=0;m=0,d=0;for(var E=0;E<f;E++){b[E]=m,D[E]=d;var S=l?l[E]:E,F=s(g,e,S,C,M,A,1),B=-1,q=-1;for(h=F;h<f;h++)if(A[p=C[h]]<0){var T=r(M[p]);a(T,q)&&(q=T,B=p)}else w[d]=A[p],x[d++]=M[p];if(-1===B||q<=0)return null;A[S]<0&&o(r(M[S]),n(q,c))&&(B=S);var k=M[B];for(w[d]=E,x[d++]=k,A[B]=E,y[m]=B,v[m++]=1,h=F;h<f;h++)A[p=C[h]]<0&&(y[m]=p,v[m++]=t(M[p],k)),M[p]=0}for(b[f]=m,D[f]=d,h=0;h<m;h++)y[h]=A[y[h]];return v.splice(m,v.length-m),y.splice(m,y.length-m),x.splice(d,x.length-d),w.splice(d,w.length-d),{L:g,U:N,pinv:A}}})),rb=ti("slu",["typed","abs","add","multiply","transpose","divideScalar","subtract","larger","largerEq","SparseMatrix"],(e=>{var{typed:r,abs:t,add:n,multiply:i,transpose:a,divideScalar:o,subtract:u,larger:s,largerEq:c,SparseMatrix:l}=e,f=Zy({add:n,multiply:i,transpose:a}),m=eb({abs:t,divideScalar:o,multiply:i,subtract:u,larger:s,largerEq:c,SparseMatrix:l});return r("slu",{"SparseMatrix, number, number":function(e,r,t){if(!ii(r)||r<0||r>3)throw Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(t<0||t>1)throw Error("Partial pivoting threshold must be a number from 0 to 1");var n=f(r,e,!1),i=m(e,n,t);return{L:i.L,U:i.U,p:i.pinv,q:n.q,toString:function(){return"L: "+this.L+"\nU: "+this.U+"\np: "+this.p+(this.q?"\nq: "+this.q:"")+"\n"}}}})}));function tb(e,r){var t,n=r.length,i=[];if(e)for(t=0;t<n;t++)i[e[t]]=r[t];else for(t=0;t<n;t++)i[t]=r[t];return i}var nb="lusolve",ib=ti(nb,["typed","matrix","lup","slu","usolve","lsolve","DenseMatrix"],(e=>{var{typed:r,matrix:t,lup:n,slu:i,usolve:a,lsolve:o,DenseMatrix:u}=e,s=Zd({DenseMatrix:u});return r(nb,{"Array, Array | Matrix":function(e,r){e=t(e);var i=n(e);return l(i.L,i.U,i.p,null,r).valueOf()},"DenseMatrix, Array | Matrix":function(e,r){var t=n(e);return l(t.L,t.U,t.p,null,r)},"SparseMatrix, Array | Matrix":function(e,r){var t=n(e);return l(t.L,t.U,t.p,null,r)},"SparseMatrix, Array | Matrix, number, number":function(e,r,t,n){var a=i(e,t,n);return l(a.L,a.U,a.p,a.q,r)},"Object, Array | Matrix":function(e,r){return l(e.L,e.U,e.p,e.q,r)}});function c(e){if(cn(e))return e;if(sn(e))return t(e);throw new TypeError("Invalid Matrix LU decomposition")}function l(e,r,t,n,i){e=c(e),r=c(r),t&&((i=s(e,i,!0))._data=tb(t,i._data));var u=o(e,i),l=a(r,u);return n&&(l._data=tb(n,l._data)),l}})),ab="polynomialRoot",ob=ti(ab,["typed","isZero","equalScalar","add","subtract","multiply","divide","sqrt","unaryMinus","cbrt","typeOf","im","re"],(e=>{var{typed:r,isZero:t,equalScalar:n,add:i,subtract:a,multiply:o,divide:u,sqrt:s,unaryMinus:c,cbrt:l,typeOf:f,im:m,re:d}=e;return r(ab,{"number|Complex, ...number|Complex":(e,r)=>{for(var p=[e,...r];p.length>0&&t(p[p.length-1]);)p.pop();if(p.length<2)throw new RangeError("Polynomial [".concat(e,", ").concat(r,"] must have a non-zero non-constant coefficient"));switch(p.length){case 2:return[c(u(p[0],p[1]))];case 3:var[h,v,y]=p,b=o(2,y),g=o(v,v),x=o(4,y,h);if(n(g,x))return[u(c(v),b)];var w=s(a(g,x));return[u(a(w,v),b),u(a(c(w),v),b)];case 4:var[D,N,A,M]=p,C=c(o(3,M)),E=o(A,A),S=o(3,M,N),F=i(o(2,A,A,A),o(27,M,M,D)),B=o(9,M,A,N);if(n(E,S)&&n(F,B))return[u(A,C)];var q,T=a(E,S),k=a(F,B),O=i(o(18,M,A,N,D),o(A,A,N,N)),I=i(o(4,A,A,A,D),o(4,M,N,N,N),o(27,M,M,D,D));return n(O,I)?[u(a(o(4,M,A,N),i(o(9,M,M,D),o(A,A,A))),o(M,T)),u(a(o(9,M,D),o(A,N)),o(2,T))]:(q=n(E,S)?k:u(i(k,s(a(o(k,k),o(4,T,T,T)))),2),l(q,!0).toArray().map((e=>u(i(A,e,u(T,e)),C))).map((e=>"Complex"===f(e)&&n(d(e),d(e)+m(e))?d(e):e)));default:throw new RangeError("only implemented for cubic or lower-order polynomials, not ".concat(p))}}})})),ub=ti("Help",["evaluate"],(e=>{var{evaluate:r}=e;function t(e){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw Error('Argument "doc" missing');this.doc=e}return t.prototype.type="Help",t.prototype.isHelp=!0,t.prototype.toString=function(){var e=this.doc||{},t="\n";if(e.name&&(t+="Name: "+e.name+"\n\n"),e.category&&(t+="Category: "+e.category+"\n\n"),e.description&&(t+="Description:\n "+e.description+"\n\n"),e.syntax&&(t+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){t+="Examples:\n";for(var n=!1,i=r("config()"),a={config:e=>(n=!0,r("config(newConfig)",{newConfig:e}))},o=0;o<e.examples.length;o++){var u=e.examples[o];t+=" "+u+"\n";var s=void 0;try{s=r(u,a)}catch(e){s=e}void 0===s||yn(s)||(t+=" "+Go(s,{precision:14})+"\n")}t+="\n",n&&r("config(originalConfig)",{originalConfig:i})}return e.mayThrow&&e.mayThrow.length&&(t+="Throws: "+e.mayThrow.join(", ")+"\n\n"),e.seealso&&e.seealso.length&&(t+="See also: "+e.seealso.join(", ")+"\n"),t},t.prototype.toJSON=function(){var e=Wn(this.doc);return e.mathjs="Help",e},t.fromJSON=function(e){var r={};return Object.keys(e).filter((e=>"mathjs"!==e)).forEach((t=>{r[t]=e[t]})),new t(r)},t.prototype.valueOf=t.prototype.toString,t}),{isClass:!0}),sb=ti("Chain",["?on","math","typed"],(e=>{var{on:r,math:t,typed:n}=e;function i(e){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this.value=Ln(e)?e.value:e}function a(e,r){!function(e,t){var n,i=!0;Object.defineProperty(e,t,{get:function(){return i&&(n=function(){var e=r();if("function"==typeof e)return o(e)}(),i=!1),n},set:function(e){n=e,i=!1},configurable:!0,enumerable:!0})}(i.prototype,e)}function o(e){return function(){if(0===arguments.length)return new i(e(this.value));for(var r=[this.value],t=0;t<arguments.length;t++)r[t+1]=arguments[t];if(n.isTypedFunction(e)){var a=n.resolve(e,r);if(1===a.params.length)throw Error("chain function "+e.name+" cannot match rest parameter between chain value and additional arguments.");return new i(a.implementation.apply(e,r))}return new i(e.apply(e,r))}}i.prototype.type="Chain",i.prototype.isChain=!0,i.prototype.done=function(){return this.value},i.prototype.valueOf=function(){return this.value},i.prototype.toString=function(){return Go(this.value)},i.prototype.toJSON=function(){return{mathjs:"Chain",value:this.value}},i.fromJSON=function(e){return new i(e.value)},i.createProxy=function(e,r){if("string"==typeof e)!function(e,r){"function"==typeof r&&(i.prototype[e]=o(r))}(e,r);else{var t=function(r){Hn(e,r)&&void 0===u[r]&&a(r,(()=>e[r]))};for(var n in e)t(n)}};var u={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return i.createProxy(t),r&&r("import",(function(e,r,t){t||a(e,r)})),i}),{isClass:!0}),cb={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"]},lb={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"]},fb={bignumber:{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","bigint","complex","fraction","index","matrix","string","unit"]},bigint:{name:"bigint",category:"Construction",syntax:["bigint(x)"],description:"Create a bigint, an integer with an arbitrary number of digits, from a number or string.",examples:["123123123123123123 # a large number will lose digits",'bigint("123123123123123123")','bignumber(["1", "3", "5"])'],seealso:["boolean","bignumber","number","complex","fraction","index","matrix","string","unit"]},boolean:{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"]},complex:{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"]},createUnit:{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"]},fraction:{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"]},index:{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:["A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[1:2, 1:2] = 1","B = [1, 2, 3]","B[B>1 and B<3]"],seealso:["bignumber","boolean","complex","matrix","number","range","string","unit"]},matrix:{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"]},number:{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","bigint","boolean","complex","fraction","index","matrix","string","unit"]},sparse:{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"]},splitUnit:{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"]},string:{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"]},unit:{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"]},e:cb,E:cb,false:{name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},i:{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:[]},Infinity:{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:[]},LN2:{name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},LN10:{name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},LOG2E:{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:[]},LOG10E:{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:[]},NaN:{name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},null:{name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},pi:lb,PI:lb,phi:{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:[]},SQRT1_2:{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:[]},SQRT2:{name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},tau:{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"]},true:{name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},version:{name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},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. Deprecated in favor of coulombConstant",examples:["coulombConstant"]},coulombConstant:{description:"Coulomb's constant",examples:["coulombConstant"]},elementaryCharge:{description:"Elementary charge",examples:["elementaryCharge"]},bohrMagneton:{description:"Bohr 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:"Bohr 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:{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"]},lsolve:{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"]},lsolveAll:{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"]},lup:{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"]},lusolve:{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"]},leafCount:{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"]},polynomialRoot:{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"]},resolve:{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"]},simplify:{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"]},simplifyConstant:{name:"simplifyConstant",category:"Algebra",syntax:["simplifyConstant(expr)","simplifyConstant(expr, options)"],description:"Replace constant subexpressions of node with their values.",examples:['simplifyConstant("(3-3)*x")','simplifyConstant(parse("z-cos(tau/8)"))'],seealso:["simplify","simplifyCore","evaluate"]},simplifyCore:{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"]},symbolicEqual:{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"]},rationalize:{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"]},slu:{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"]},usolve:{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"]},usolveAll:{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"]},qr:{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"]},abs:{name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},add:{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"]},cbrt:{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"]},ceil:{name:"ceil",category:"Arithmetic",syntax:["ceil(x)","ceil(x, n)","ceil(unit, valuelessUnit)","ceil(unit, n, valuelessUnit)"],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)","ceil(3.241cm, cm)","ceil(3.241cm, 2, cm)"],seealso:["floor","fix","round"]},cube:{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"]},divide:{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"]},dotDivide:{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"]},dotMultiply:{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"]},dotPow:{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"]},exp:{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"]},expm:{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"]},expm1:{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"]},fix:{name:"fix",category:"Arithmetic",syntax:["fix(x)","fix(x, n)","fix(unit, valuelessUnit)","fix(unit, n, valuelessUnit)"],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)","fix(3.241cm, cm)","fix(3.241cm, 2, cm)"],seealso:["ceil","floor","round"]},floor:{name:"floor",category:"Arithmetic",syntax:["floor(x)","floor(x, n)","floor(unit, valuelessUnit)","floor(unit, n, valuelessUnit)"],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)","floor(3.241cm, cm)","floor(3.241cm, 2, cm)"],seealso:["ceil","fix","round"]},gcd:{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"]},hypot:{name:"hypot",category:"Arithmetic",syntax:["hypot(a, b, c, ...)","hypot([a, b, c, ...])"],description:"Calculate the hypotenuse of a list with values.",examples:["hypot(3, 4)","sqrt(3^2 + 4^2)","hypot(-2)","hypot([3, 4, 5])"],seealso:["abs","norm"]},lcm:{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"]},log:{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"]},log2:{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"]},log1p:{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"]},log10:{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"]},mod:{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"]},multiply:{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"]},norm:{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")']},nthRoot:{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"]},nthRoots:{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"]},pow:{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"]},round:{name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)","round(unit, valuelessUnit)","round(unit, n, valuelessUnit)"],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)","round(3.241cm, 2, cm)","round([3.2, 3.8, -4.7])"],seealso:["ceil","floor","fix"]},sign:{name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>0, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},sqrt:{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"]},sqrtm:{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"]},square:{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"]},subtract:{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"]},unaryMinus:{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"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{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"]},invmod:{name:"invmod",category:"Arithmetic",syntax:["invmod(a, b)"],description:"Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)",examples:["invmod(8, 12)","invmod(7, 13)","invmod(15151, 15122)"],seealso:["gcd","xgcd"]},bitAnd:{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"]},bitNot:{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"]},bitOr:{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"]},bitXor:{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"]},leftShift:{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"]},rightArithShift:{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"]},rightLogShift:{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"]},bellNumbers:{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"]},catalan:{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"]},composition:{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"]},stirlingS2:{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"]},config:{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:[]},import:{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:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number": f(x)=x+x, "string": f(x)=concat(x,x) })',"double(2)",'double("hello")'],seealso:[]},arg:{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"]},conj:{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"]},re:{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"]},im:{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"]},evaluate:{name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate(expression, scope)","evaluate([expr1, expr2, expr3, ...])","evaluate([expr1, expr2, expr3, ...], scope)"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(16)")','evaluate("2 inch to cm")','evaluate("sin(x * pi)", { "x": 1/2 })','evaluate(["width=2", "height=4","width*height"])'],seealso:["parser","parse","compile"]},help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},parse:{name:"parse",category:"Expression",syntax:["parse(expr)","parse(expr, options)","parse([expr1, expr2, expr3, ...])","parse([expr1, expr2, expr3, ...], options)"],description:"Parse an expression. Returns a node tree, which can be evaluated by invoking node.evaluate() or transformed into a functional object via node.compile().",examples:['node1 = parse("sqrt(3^2 + 4^2)")',"node1.evaluate()","code1 = node1.compile()","code1.evaluate()","scope = {a: 3, b: 4}",'node2 = parse("a * b")',"node2.evaluate(scope)","code2 = node2.compile()","code2.evaluate(scope)"],seealso:["parser","evaluate","compile"]},parser:{name:"parser",category:"Expression",syntax:["parser()"],description:"Create a parser object that keeps a context of variables and their values, allowing the evaluation of expressions in that context.",examples:["myParser = parser()",'myParser.evaluate("sqrt(3^2 + 4^2)")','myParser.set("x", 3)','myParser.evaluate("y = x + 3")','myParser.evaluate(["y = x + 3", "y = y + 1"])','myParser.get("y")'],seealso:["evaluate","parse","compile"]},compile:{name:"compile",category:"Expression",syntax:["compile(expr) ","compile([expr1, expr2, expr3, ...])"],description:"Parse and compile an expression. Returns a an object with a function evaluate([scope]) to evaluate the compiled expression.",examples:['code1 = compile("sqrt(3^2 + 4^2)")',"code1.evaluate() ",'code2 = compile("a * b")',"code2.evaluate({a: 3, b: 4})"],seealso:["parser","parse","evaluate"]},distance:{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:[]},intersect:{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:[]},and:{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"]},not:{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"]},nullish:{name:"nullish",category:"Logical",syntax:["x ?? y","nullish(x, y)"],description:"Nullish coalescing operator. Returns the right-hand operand when the left-hand operand is null or undefined, and otherwise returns the left-hand operand.",examples:["null ?? 42","undefined ?? 42","0 ?? 42","false ?? 42","null ?? undefined ?? 42"],seealso:["and","or","not"]},or:{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"]},xor:{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"]},mapSlices:{name:"mapSlices",category:"Matrix",syntax:["mapSlices(A, dim, callback)"],description:"Generate a matrix one dimension less than A by applying callback to each slice of A along dimension dim.",examples:["A = [[1, 2], [3, 4]]","mapSlices(A, 1, sum)","mapSlices(A, 2, prod)"],seealso:["map","forEach"]},concat:{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"]},count:{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"]},cross:{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"]},column:{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"]},ctranspose:{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"]},det:{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"]},diag:{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"]},diff:{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 indicate 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:["A = [1, 2, 4, 7, 0]","diff(A)","diff(A, 1)","B = [[1, 2], [3, 4]]","diff(B)","diff(B, 1)","diff(B, 2)","diff(B, bignumber(2))","diff([[1, 2], matrix([3, 4])], 2)"],seealso:["subtract","partitionSelect"]},dot:{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"]},getMatrixDataType:{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"]},identity:{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"]},filter:{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"]},flatten:{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"]},forEach:{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"]},inv:{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"]},pinv:{name:"pinv",category:"Matrix",syntax:["pinv(x)"],description:"Calculate the Moore–Penrose inverse of a matrix",examples:["pinv([1, 2; 3, 4])","pinv([[1, 0], [0, 1], [0, 1]])","pinv(4)"],seealso:["inv"]},eigs:{name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and optionally eigenvectors of a square matrix",examples:["eigs([[5, 2.3], [2.3, 1]])","eigs([[1, 2, 3], [4, 5, 6], [7, 8, 9]], { precision: 1e-6, eigenvectors: false })"],seealso:["inv"]},kron:{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"]},matrixFromFunction:{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"]},matrixFromRows:{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"]},matrixFromColumns:{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"]},map:{name:"map",category:"Matrix",syntax:["map(x, callback)","map(x, y, ..., callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array or the matrices/arrays.",examples:["map([1, 2, 3], square)","map([1, 2], [3, 4], f(a,b) = a + b)"],seealso:["filter","forEach"]},ones:{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"]},partitionSelect:{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"]},range:{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")',"range(1m, 1m, 3m)","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"]},resize:{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"]},reshape:{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"]},rotate:{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"]},rotationMatrix:{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"]},row:{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"]},size:{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"]},sort:{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"]},squeeze:{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"]},subset:{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"]},trace:{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"]},transpose:{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"]},zeros:{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"]},fft:{name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional Fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},ifft:{name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse Fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},sylvester:{name:"sylvester",category:"Algebra",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]])","A = [[-1, -2], [1, 1]]; B = [[2, -1], [1, -2]]; C = [[-3, 2], [3, 0]]","sylvester(A, B, C)"],seealso:["schur","lyap"]},schur:{name:"schur",category:"Algebra",syntax:["schur(A)"],description:"Performs a real Schur decomposition of the real matrix A = UTU'",examples:["schur([[1, 0], [-4, 3]])","A = [[1, 0], [-4, 3]]","schur(A)"],seealso:["lyap","sylvester"]},lyap:{name:"lyap",category:"Algebra",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]])","A = [[-2, 0], [1, -4]]","Q = [[3, 1], [1, 3]]","lyap(A,Q)"],seealso:["schur","sylvester"]},solveODE:{name:"solveODE",category:"Numeric",syntax:["solveODE(func, tspan, y0)","solveODE(func, tspan, y0, options)"],description:"Numerical Integration of Ordinary Differential Equations.",examples:["f(t,y) = y","tspan = [0, 4]","solveODE(f, tspan, 1)","solveODE(f, tspan, [1, 2])",'solveODE(f, tspan, 1, { method:"RK23", maxStep:0.1 })'],seealso:["derivative","simplifyCore"]},combinations:{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"]},combinationsWithRep:{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"]},factorial:{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"]},gamma:{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"]},kldivergence:{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:[]},lgamma:{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"]},multinomial:{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"]},permutations:{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"]},pickRandom:{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"]},random:{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"]},randomInt:{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"]},compare:{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"]},compareNatural:{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"]},compareText:{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"]},deepEqual:{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"]},equal:{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"]},equalText:{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"]},larger:{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. Comparing a value with NaN returns false.",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"]},largerEq:{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"]},smaller:{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. Comparing a value with NaN returns false.",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"]},smallerEq:{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"]},unequal:{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"]},setCartesian:{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"]},setDifference:{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"]},setDistinct:{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"]},setIntersect:{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"]},setIsSubset:{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"]},setMultiplicity:{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"]},setPowerset:{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"]},setSize:{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"]},setSymDifference:{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"]},setUnion:{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"]},zpk2tf:{name:"zpk2tf",category:"Signal",syntax:["zpk2tf(z, p, k)"],description:"Compute the transfer function of a zero-pole-gain model.",examples:["zpk2tf([1, 2], [-1, -2], 1)","zpk2tf([1, 2], [-1, -2])","zpk2tf([1 - 3i, 2 + 2i], [-1, -2])"],seealso:[]},freqz:{name:"freqz",category:"Signal",syntax:["freqz(b, a)","freqz(b, a, w)"],description:"Calculates the frequency response of a filter given its numerator and denominator coefficients.",examples:["freqz([1, 2], [1, 2, 3])","freqz([1, 2], [1, 2, 3], [0, 1])","freqz([1, 2], [1, 2, 3], 512)"],seealso:[]},erf:{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:[]},zeta:{name:"zeta",category:"Special",syntax:["zeta(s)"],description:"Compute the Riemann Zeta Function using an infinite series and Riemann's Functional Equation for the entire complex plane",examples:["zeta(0.2)","zeta(-0.5)","zeta(4)"],seealso:[]},cumsum:{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"]},mad:{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"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dimension)"],description:"Compute the maximum value of a list of values. If any NaN values are found, the function yields the last NaN in the input.",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"]},mean:{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"]},median:{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"]},min:{name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dimension)"],description:"Compute the minimum value of a list of values. If any NaN values are found, the function yields the last NaN in the input.",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"]},mode:{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"]},prod:{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"]},quantileSeq:{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 probability are: Number, BigNumber. \n\nIn 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"]},std:{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"]},sum:{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","variance"]},variance:{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"]},corr:{name:"corr",category:"Statistics",syntax:["corr(A,B)"],description:"Compute the correlation coefficient of a two list with values, For matrices, the matrix correlation coefficient is calculated.",examples:["corr([2, 4, 6, 8],[1, 2, 3, 6])","corr(matrix([[1, 2.2, 3, 4.8, 5], [1, 2, 3, 4, 5]]), matrix([[4, 5.3, 6.6, 7, 8], [1, 2, 3, 4, 5]]))"],seealso:["max","mean","min","median","min","prod","std","sum"]},acos:{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"]},acosh:{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"]},acot:{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"]},acoth:{name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the inverse hyperbolic tangent 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"]},acsc:{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"]},acsch:{name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the inverse hyperbolic cosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},asec:{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"]},asech:{name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},asin:{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"]},asinh:{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"]},atan:{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"]},atanh:{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"]},atan2:{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"]},cos:{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"]},cosh:{name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},cot:{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"]},coth:{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"]},csc:{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"]},csch:{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"]},sec:{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"]},sech:{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"]},sin:{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"]},sinh:{name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},tan:{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"]},tanh:{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"]},to:{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:[]},toBest:{name:"toBest",category:"Units",syntax:["toBest(x)","toBest(x, unitList)","toBest(x, unitList, options)"],description:"Converts to the most appropriate display unit.",examples:['toBest(unit(5000, "m"))','toBest(unit(3500000, "W"))','toBest(unit(0.000000123, "A"))','toBest(unit(10, "m"), "cm")','toBest(unit(10, "m"), "mm,km", {offset: 1.5})'],seealso:[]},clone:{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:[]},format:{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"]},bin:{name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},oct:{name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},hex:{name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},isNaN:{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"]},isInteger:{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"]},isNegative:{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"]},isNumeric:{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"]},hasNumericValue:{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"]},isPositive:{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"]},isPrime:{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"]},isZero:{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"]},print:{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: $1, $2, $3", [6, 9, 4])'],seealso:["format"]},typeOf:{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"]},numeric:{name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, bigint, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "bigint")','numeric("4", "BigNumber")','numeric("4", "Fraction")','numeric(4, "Fraction")','numeric(fraction(2, 5), "number")'],seealso:["number","bigint","fraction","bignumber","string","format"]}},mb="help",db=ti(mb,["typed","mathWithTransform","Help"],(e=>{var{typed:r,mathWithTransform:t,Help:n}=e;return r(mb,{any:function(e){var r,i=e;if("string"!=typeof e)for(r in t)if(Hn(t,r)&&e===t[r]){i=r;break}var a=_t(fb,i);if(!a)throw Error('No documentation found on "'+("function"==typeof i?i.name:i)+'"');return new n(a)}})})),pb="chain",hb=ti(pb,["typed","Chain"],(e=>{var{typed:r,Chain:t}=e;return r(pb,{"":function(){return new t},any:function(e){return new t(e)}})})),vb=ti("det",["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],(e=>{var{typed:r,matrix:t,subtractScalar:n,multiply:i,divideScalar:a,isZero:o,unaryMinus:u}=e;return r("det",{any:function(e){return Wn(e)},"Array | Matrix":function(e){var r;switch((r=cn(e)?e.size():Array.isArray(e)?(e=t(e)).size():[]).length){case 0:return Wn(e);case 1:if(1===r[0])return Wn(e.valueOf()[0]);if(0===r[0])return 1;throw new RangeError("Matrix must be square (size: "+Go(r)+")");case 2:var s=r[0],c=r[1];if(s===c)return function(e,r){if(1===r)return Wn(e[0][0]);if(2===r)return n(i(e[0][0],e[1][1]),i(e[1][0],e[0][1]));for(var t=!1,s=Array(r).fill(0).map(((e,r)=>r)),c=0;c<r;c++){var l=s[c];if(o(e[l][c])){var f=void 0;for(f=c+1;f<r;f++)if(!o(e[s[f]][c])){l=s[f],s[f]=s[c],s[c]=l,t=!t;break}if(f===r)return e[l][c]}for(var m=e[l][c],d=0===c?1:e[s[c-1]][c-1],p=c+1;p<r;p++)for(var h=s[p],v=c+1;v<r;v++)e[h][v]=a(n(i(e[h][v],m),i(e[h][c],e[l][v])),d)}var y=e[s[r-1]][r-1];return t?u(y):y}(e.clone().valueOf(),s);if(0===c)return 1;throw new RangeError("Matrix must be square (size: "+Go(r)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+Go(r)+")")}}})})),yb=ti("inv",["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],(e=>{var{typed:r,matrix:t,divideScalar:n,addScalar:i,multiply:a,unaryMinus:o,det:u,identity:s,abs:c}=e;return r("inv",{"Array | Matrix":function(e){var r=cn(e)?e.size():nu(e);switch(r.length){case 1:if(1===r[0])return cn(e)?t([n(1,e.valueOf()[0])]):[n(1,e[0])];throw new RangeError("Matrix must be square (size: "+Go(r)+")");case 2:var i=r[0],a=r[1];if(i===a)return cn(e)?t(l(e.valueOf(),i,a),e.storage()):l(e,i,a);throw new RangeError("Matrix must be square (size: "+Go(r)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+Go(r)+")")}},any:function(e){return n(1,e)}});function l(e,r,t){var l,f,m,d,p;if(1===r){if(0===(d=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero");return[[n(1,d)]]}if(2===r){var h=u(e);if(0===h)throw Error("Cannot calculate inverse, determinant is zero");return[[n(e[1][1],h),n(o(e[0][1]),h)],[n(o(e[1][0]),h),n(e[0][0],h)]]}var v=e.concat();for(l=0;l<r;l++)v[l]=v[l].concat();for(var y=s(r).valueOf(),b=0;b<t;b++){var g=c(v[b][b]),x=b;for(l=b+1;l<r;)c(v[l][b])>g&&(g=c(v[l][b]),x=l),l++;if(0===g)throw Error("Cannot calculate inverse, determinant is zero");(l=x)!==b&&(p=v[b],v[b]=v[l],v[l]=p,p=y[b],y[b]=y[l],y[l]=p);var w=v[b],D=y[b];for(l=0;l<r;l++){var N=v[l],A=y[l];if(l!==b){if(0!==N[b]){for(m=n(o(N[b]),w[b]),f=b;f<t;f++)N[f]=i(N[f],a(m,w[f]));for(f=0;f<t;f++)A[f]=i(A[f],a(m,D[f]))}}else{for(m=w[b],f=b;f<t;f++)N[f]=n(N[f],m);for(f=0;f<t;f++)A[f]=n(A[f],m)}}}return y}})),bb="pinv",gb=ti(bb,["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],(e=>{var{typed:r,matrix:t,inv:n,deepEqual:i,equal:a,dotDivide:o,dot:u,ctranspose:s,divideScalar:c,multiply:l,add:f,Complex:m}=e;return r(bb,{"Array | Matrix":function(e){var r=cn(e)?e.size():nu(e);switch(r.length){case 1:return h(e)?s(e):1===r[0]?n(e):o(s(e),u(e,e));case 2:if(h(e))return s(e);var i=r[0],a=r[1];if(i===a)try{return n(e)}catch(e){if(!(e instanceof Error&&e.message.match(/Cannot calculate inverse, determinant is zero/)))throw e}return cn(e)?t(d(e.valueOf(),i,a),e.storage()):d(e,i,a);default:throw new RangeError("Matrix must be two dimensional (size: "+Go(r)+")")}},any:function(e){return a(e,0)?Wn(e):c(1,e)}});function d(e,r,t){var{C:i,F:a}=function(e,r,t){var n=function(e,r,t){for(var n=Wn(e),i=0,a=0;a<r;a++){if(t<=i)return n;for(var u=a;p(n[u][i]);)if(r===++u&&(u=a,t===++i))return n;[n[u],n[a]]=[n[a],n[u]];for(var s=n[a][i],c=0;c<t;c++)n[a][c]=o(n[a][c],s);for(var m=0;m<r;m++)if(m!==a){s=n[m][i];for(var d=0;d<t;d++)n[m][d]=f(n[m][d],l(-1,l(s,n[a][d])))}i++}return n}(e,r,t),i=e.map((e=>e.filter(((e,t)=>t<r&&!p(u(n[t],n[t])))))),a=n.filter(((e,r)=>!p(u(n[r],n[r]))));return{C:i,F:a}}(e,r,t),c=l(n(l(s(i),i)),s(i)),m=l(s(a),n(l(a,s(a))));return l(m,c)}function p(e){return a(f(e,m(1,1)),f(0,m(1,1)))}function h(e){return i(f(e,m(1,1)),f(l(e,0),m(1,1)))}}));var xb=ti("eigs",["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","divideScalar","inv","bignumber","multiply","add","larger","column","flatten","number","complex","sqrt","diag","size","reshape","qr","usolve","usolveAll","im","re","smaller","matrixFromColumns","dot"],(e=>{var{config:r,typed:t,matrix:n,addScalar:i,subtract:a,equal:o,abs:u,atan:s,cos:c,sin:l,multiplyScalar:f,divideScalar:m,inv:d,bignumber:p,multiply:h,add:v,larger:y,flatten:b,number:g,complex:x,sqrt:w,diag:D,size:N,reshape:A,qr:M,usolve:C,usolveAll:E,im:S,re:F,smaller:B,dot:q}=e,T=function(e){var{config:r,addScalar:t,subtract:n,abs:i,atan:a,cos:o,sin:u,multiplyScalar:s,inv:c,bignumber:l,multiply:f,add:m}=e;function d(e,t,n){return Math.abs(t-e)<=r.relTol?Math.PI/4:.5*Math.atan(2*n/(t-e))}function p(e,t,o){var u=n(t,e);return i(u)<=r.relTol?l(-1).acos().div(4):s(.5,a(f(2,o,c(u))))}function h(e,r,t,n){for(var i=e.length,a=Math.cos(r),o=Math.sin(r),u=Array(i).fill(0),s=Array(i).fill(0),c=0;c<i;c++)u[c]=a*e[c][t]-o*e[c][n],s[c]=o*e[c][t]+a*e[c][n];for(var l=0;l<i;l++)e[l][t]=u[l],e[l][n]=s[l];return e}function v(e,r,i,a){for(var c=e.length,f=o(r),m=u(r),d=Array(c).fill(l(0)),p=Array(c).fill(l(0)),h=0;h<c;h++)d[h]=n(s(f,e[h][i]),s(m,e[h][a])),p[h]=t(s(m,e[h][i]),s(f,e[h][a]));for(var v=0;v<c;v++)e[v][i]=d[v],e[v][a]=p[v];return e}function y(e,r,i,a){for(var c=e.length,d=l(o(r)),p=l(u(r)),h=s(d,d),v=s(p,p),y=Array(c).fill(l(0)),b=Array(c).fill(l(0)),g=f(l(2),d,p,e[i][a]),x=t(n(s(h,e[i][i]),g),s(v,e[a][a])),w=m(s(v,e[i][i]),g,s(h,e[a][a])),D=0;D<c;D++)y[D]=n(s(d,e[i][D]),s(p,e[a][D])),b[D]=t(s(p,e[i][D]),s(d,e[a][D]));e[i][i]=x,e[a][a]=w,e[i][a]=l(0),e[a][i]=l(0);for(var N=0;N<c;N++)N!==i&&N!==a&&(e[i][N]=y[N],e[N][i]=y[N],e[a][N]=b[N],e[N][a]=b[N]);return e}function b(e,r,t,n){for(var i=e.length,a=Math.cos(r),o=Math.sin(r),u=a*a,s=o*o,c=Array(i).fill(0),l=Array(i).fill(0),f=u*e[t][t]-2*a*o*e[t][n]+s*e[n][n],m=s*e[t][t]+2*a*o*e[t][n]+u*e[n][n],d=0;d<i;d++)c[d]=a*e[t][d]-o*e[n][d],l[d]=o*e[t][d]+a*e[n][d];e[t][t]=f,e[n][n]=m,e[t][n]=0,e[n][t]=0;for(var p=0;p<i;p++)p!==t&&p!==n&&(e[t][p]=c[p],e[p][t]=c[p],e[n][p]=l[p],e[p][n]=l[p]);return e}function g(e){for(var r=e.length,t=0,n=[0,1],i=0;i<r;i++)for(var a=i+1;a<r;a++)Math.abs(t)<Math.abs(e[i][a])&&(t=Math.abs(e[i][a]),n=[i,a]);return[n,t]}function x(e){for(var r=e.length,t=0,n=[0,1],a=0;a<r;a++)for(var o=a+1;o<r;o++)i(t)<i(e[a][o])&&(t=i(e[a][o]),n=[a,o]);return[n,t]}function w(e,r,t){var n,a=e.length,o=Array(a);if(t){n=Array(a);for(var u=0;u<a;u++)n[u]=Array(a)}for(var s=0;s<a;s++){for(var c=0,l=e[0],f=0;f<e.length;f++)i(e[f])<i(l)&&(l=e[c=f]);if(o[s]=e.splice(c,1)[0],t)for(var m=0;m<a;m++)n[s][m]=r[m][c],r[m].splice(c,1)}if(!t)return{values:o};var d=n.map(((e,r)=>({value:o[r],vector:e})));return{values:o,eigenvectors:d}}return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r.relTol,a=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0;if("number"===a)return function(e,r,t){var n,i,a=e.length,o=Math.abs(r/a);if(t){i=Array(a);for(var u=0;u<a;u++)i[u]=Array(a).fill(0),i[u][u]=1}for(var s=g(e);Math.abs(s[1])>=Math.abs(o);){var c=s[0][0],l=s[0][1];e=b(e,n=d(e[c][c],e[l][l],e[c][l]),c,l),t&&(i=h(i,n,c,l)),s=g(e)}for(var f=Array(a).fill(0),m=0;m<a;m++)f[m]=e[m][m];return w(Wn(f),i,t)}(e,n,o);if("BigNumber"===a)return function(e,r,t){var n,a,o=e.length,u=i(r/o);if(t){a=Array(o);for(var s=0;s<o;s++)a[s]=Array(o).fill(0),a[s][s]=1}for(var c=x(e);i(c[1])>=i(u);){var l=c[0][0],f=c[0][1];e=y(e,n=p(e[l][l],e[f][f],e[l][f]),l,f),t&&(a=v(a,n,l,f)),c=x(e)}for(var m=Array(o).fill(0),d=0;d<o;d++)m[d]=e[d][d];return w(Wn(m),a,t)}(e,n,o);throw TypeError("Unsupported data type: "+a)}}({config:r,addScalar:i,subtract:a,abs:u,atan:s,cos:c,sin:l,multiplyScalar:f,inv:d,bignumber:p,multiply:h,add:v}),k=function(e){var{addScalar:r,subtract:t,flatten:n,multiply:i,multiplyScalar:a,divideScalar:o,sqrt:u,abs:s,bignumber:c,diag:l,size:f,reshape:m,inv:d,qr:p,usolve:h,usolveAll:v,equal:y,complex:b,larger:g,smaller:x,dot:w}=e;function D(e,n,i,o){var s=r(e,o),c=t(a(e,o),a(n,i)),l=a(s,.5),f=a(u(t(a(s,s),a(4,c))),.5);return[r(l,f),t(l,f)]}function N(e,r,n,i,a,o,u,l){var f="BigNumber"===l,m="Complex"===l,d=f?c(0):m?b(0):0,p=f?c(1):m?b(1):1;if(x(s(n),u))return[[p,d],[d,p]];if(g(s(t(a,o)),u))return[[t(a,i),t(o,i)],[n,n]];var h=t(e,a),v=t(i,a);return x(s(r),u)&&x(s(v),u)?[[h,p],[n,d]]:[[r,d],[v,p]]}function A(e,r){for(var t=0;t<e.length;t++)e[t].push(...Array(r-e[t].length).fill(0));for(var n=e.length;n<r;n++)e.push(Array(r).fill(0)),e[n][n]=1;return e}function M(e,r,t){for(var n=0;n<e.length;n++)if(t(e[n],r))return n;return-1}function C(e,r,t,n,i){for(var a,o="BigNumber"===i?c(1e3):1e3,u=0;u<5;++u){a=E(r,t,i);try{a=h(e,a)}catch(e){continue}if(g(F(a),o))break}if(u>=5)return null;for(u=0;;){var s=h(e,a);if(x(F(S(a,[s])),n))break;if(++u>=10)return null;a=B(s)}return a}function E(e,r,t){var n="BigNumber"===t,i="Complex"===t,a=Array(e).fill(0).map((()=>2*Math.random()-1));return n&&(a=a.map((e=>c(e)))),i&&(a=a.map((e=>b(e)))),B(a=S(a,r),t)}function S(e,r){var n=f(e);for(var a of r)a=m(a,n),e=t(e,i(o(w(a,e),w(a,a)),a));return e}function F(e){return s(u(w(e,e)))}function B(e,r){var t="Complex"===r,n="BigNumber"===r?c(1):t?b(1):1;return i(o(n,F(e)),e)}return function(e,u,f,m){var h=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],w=function(e,t,n,i,u){var f,m="BigNumber"===i,d="Complex"===i,p=m?c(0):0,h=m?c(1):d?b(1):1,v=m?c(1):1,w=m?c(10):2,D=a(w,w);u&&(f=Array(t).fill(h));for(var N=!1;!N;){N=!0;for(var A=0;A<t;A++){for(var M=p,C=p,E=0;E<t;E++)A!==E&&(M=r(M,s(e[E][A])),C=r(C,s(e[A][E])));if(!y(M,0)&&!y(C,0)){for(var S=v,F=M,B=o(C,w),q=a(C,w);x(F,B);)F=a(F,D),S=a(S,w);for(;g(F,q);)F=o(F,D),S=o(S,w);if(x(o(r(F,C),S),a(r(M,C),.95))){N=!1;for(var T=o(1,S),k=0;k<t;k++)A!==k&&(e[A][k]=a(e[A][k],T),e[k][A]=a(e[k][A],S));u&&(f[A]=a(f[A],T))}}}}return u?l(f):null}(e,u,0,m,h);!function(e,n,i,u,l,f){var m="BigNumber"===u,d="Complex"===u,p=m?c(0):d?b(0):0;m&&(i=c(i));for(var h=0;h<n-2;h++){for(var v=0,y=p,g=h+1;g<n;g++){var w=e[g][h];x(s(y),s(w))&&(y=w,v=g)}if(!x(s(y),i)){if(v!==h+1){var D=e[v];e[v]=e[h+1],e[h+1]=D;for(var N=0;N<n;N++){var A=e[N][v];e[N][v]=e[N][h+1],e[N][h+1]=A}if(l){var M=f[v];f[v]=f[h+1],f[h+1]=M}}for(var C=h+2;C<n;C++){var E=o(e[C][h],y);if(0!==E){for(var S=0;S<n;S++)e[C][S]=t(e[C][S],a(E,e[h+1][S]));for(var F=0;F<n;F++)e[F][h+1]=r(e[F][h+1],a(E,e[F][C]));if(l)for(var B=0;B<n;B++)f[C][B]=t(f[C][B],a(E,f[h+1][B]))}}}}}(e,u,f,m,h,w);var{values:E,C:S}=function(e,n,a,o,u){var f="BigNumber"===o,m="Complex"===o,d=f?c(1):m?b(1):1;f&&(a=c(a));for(var h=Wn(e),v=[],y=n,g=[],w=u?l(Array(n).fill(d)):void 0,M=u?l(Array(y).fill(d)):void 0,C=0;C<=100;){C+=1;for(var E=h[y-1][y-1],S=0;S<y;S++)h[S][S]=t(h[S][S],E);var{Q:F,R:B}=p(h);h=i(B,F);for(var q=0;q<y;q++)h[q][q]=r(h[q][q],E);if(u&&(M=i(M,F)),1===y||x(s(h[y-1][y-2]),a)){C=0,v.push(h[y-1][y-1]),u&&(g.unshift([[1]]),A(M,n),w=i(w,M),y>1&&(M=l(Array(y-1).fill(d)))),y-=1,h.pop();for(var T=0;T<y;T++)h[T].pop()}else if(2===y||x(s(h[y-2][y-3]),a)){C=0;var k=D(h[y-2][y-2],h[y-2][y-1],h[y-1][y-2],h[y-1][y-1]);v.push(...k),u&&(g.unshift(N(h[y-2][y-2],h[y-2][y-1],h[y-1][y-2],h[y-1][y-1],k[0],k[1],a,o)),A(M,n),w=i(w,M),y>2&&(M=l(Array(y-2).fill(d)))),y-=2,h.pop(),h.pop();for(var O=0;O<y;O++)h[O].pop(),h[O].pop()}if(0===y)break}if(v.sort(((e,r)=>+t(s(e),s(r)))),C>100){var I=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+v.join(", "));throw I.values=v,I.vectors=[],I}var z=u?i(w,function(e,r){for(var t=[],n=0;n<r;n++)t[n]=Array(r).fill(0);var i=0;for(var a of e){for(var o=a.length,u=0;u<o;u++)for(var s=0;s<o;s++)t[i+u][i+s]=a[u][s];i+=o}return t}(g,n)):void 0;return{values:v,C:z}}(e,u,f,m,h);if(h){var F=function(e,r,a,o,u,s,f){var m=d(a),p=i(m,e,a),h="BigNumber"===f,g="Complex"===f,x=h?c(0):g?b(0):0,w=h?c(1):g?b(1):1,D=[],N=[];for(var A of u){var E=M(D,A,y);-1===E?(D.push(A),N.push(1)):N[E]+=1}for(var S=[],F=D.length,B=Array(r).fill(x),q=l(Array(r).fill(w)),T=function(){var e=D[k],u=t(p,i(e,q)),c=v(u,B);for(c.shift();c.length<N[k];){var l=C(u,r,c,s,f);if(null===l)break;c.push(l)}var m=i(d(o),a);c=c.map((e=>i(m,e))),S.push(...c.map((r=>({value:e,vector:n(r)}))))},k=0;k<F;k++)T();return S}(e,u,S,w,E,f,m);return{values:E,eigenvectors:F}}return{values:E}}}({addScalar:i,subtract:a,multiply:h,multiplyScalar:f,flatten:b,divideScalar:m,sqrt:w,abs:u,bignumber:p,diag:D,size:N,reshape:A,qr:M,inv:d,usolve:C,usolveAll:E,equal:o,complex:x,larger:y,smaller:B,dot:q});return t("eigs",{Array:function(e){return O(n(e))},"Array, number|BigNumber":function(e,r){return O(n(e),{precision:r})},"Array, Object":(e,r)=>O(n(e),r),Matrix:function(e){return O(e,{matricize:!0})},"Matrix, number|BigNumber":function(e,r){return O(e,{precision:r,matricize:!0})},"Matrix, Object":function(e,r){var t={matricize:!0};return Pt(t,r),O(e,t)}});function O(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=!("eigenvectors"in i)||i.eigenvectors,s=function(e,r,t){var n=e.toArray(),i=e.size();if(2!==i.length||i[0]!==i[1])throw new RangeError("Matrix must be square (size: ".concat(Go(i),")"));var o=i[0];if(function(e,r,t){for(var n=0;n<r;n++)for(var i=0;i<r;i++)if(y(p(u(S(e[n][i]))),t))return!1;return!0}(n,o,r)&&(function(e,r){for(var t=0;t<r;t++)for(var n=0;n<r;n++)e[t][n]=F(e[t][n])}(n,o),function(e,r,t){for(var n=0;n<r;n++)for(var i=n;i<r;i++)if(y(p(u(a(e[n][i],e[i][n]))),t))return!1;return!0}(n,o,r))){var s=I(e,n,o);return T(n,o,r,s,t)}var c=I(e,n,o);return k(n,o,r,c,t)}(e,null!==(t=i.precision)&&void 0!==t?t:r.relTol,o);return i.matricize&&(s.values=n(s.values),o&&(s.eigenvectors=s.eigenvectors.map((e=>{var{value:r,vector:t}=e;return{value:r,vector:n(t)}})))),o&&Object.defineProperty(s,"vectors",{enumerable:!1,get:()=>{throw Error("eigs(M).vectors replaced with eigs(M).eigenvectors")}}),s}function I(e,r,t){var n=e.datatype();if("number"===n||"BigNumber"===n||"Complex"===n)return n;for(var i=!1,a=!1,o=!1,u=0;u<t;u++)for(var s=0;s<t;s++){var c=r[u][s];if(en(c)||an(c))i=!0;else if(rn(c))a=!0;else{if(!nn(c))throw TypeError("Unsupported type in Matrix: "+_n(c));o=!0}}if(a&&o&&console.warn("Complex BigNumbers not supported, this operation will lose precission."),o){for(var l=0;l<t;l++)for(var f=0;f<t;f++)r[l][f]=x(r[l][f]);return"Complex"}if(a){for(var m=0;m<t;m++)for(var d=0;d<t;d++)r[m][d]=p(r[m][d]);return"BigNumber"}if(i){for(var h=0;h<t;h++)for(var v=0;v<t;v++)r[h][v]=g(r[h][v]);return"number"}throw TypeError("Matrix contains unsupported types only.")}})),wb="expm",Db=ti(wb,["typed","abs","add","identity","inv","multiply"],(e=>{var{typed:r,abs:t,add:n,identity:i,inv:a,multiply:o}=e;return r(wb,{Matrix:function(e){var r=e.size();if(2!==r.length||r[0]!==r[1])throw new RangeError("Matrix must be square (size: "+Go(r)+")");for(var s=r[0],c=function(e){for(var r=e.size()[0],n=0,i=0;i<r;i++){for(var a=0,o=0;o<r;o++)a+=t(e.get([i,o]));n=Math.max(a,n)}return n}(e),l=function(e){for(var r=0;r<30;r++)for(var t=0;t<=r;t++){var n=r-t;if(u(e,t,n)<1e-15)return{q:t,j:n}}throw Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}(c),f=l.q,m=l.j,d=o(e,Math.pow(2,-m)),p=i(s),h=i(s),v=1,y=d,b=-1,g=1;g<=f;g++)g>1&&(y=o(y,d),b=-b),p=n(p,o(v=v*(f-g+1)/((2*f-g+1)*g),y)),h=n(h,o(v*b,y));for(var x=o(a(h),p),w=0;w<m;w++)x=o(x,x);return mn(e)?e.createSparseMatrix(x):x}});function u(e,r,t){for(var n=1,i=2;i<=r;i++)n*=i;for(var a=n,o=r+1;o<=2*r;o++)a*=o;var u=a*(2*r+1);return 8*Math.pow(e/Math.pow(2,t),2*r)*n*n/(a*u)}})),Nb="sqrtm",Ab=ti(Nb,["typed","abs","add","multiply","map","sqrt","subtract","inv","size","max","identity"],(e=>{var{typed:r,abs:t,add:n,multiply:i,map:a,sqrt:o,subtract:u,inv:s,size:c,max:l,identity:f}=e,m=1e-6;function d(e){var r,a=0,o=e,d=f(c(e));do{var p=o;if(o=i(.5,n(p,s(d))),d=i(.5,n(d,s(p))),(r=l(t(u(o,p))))>m&&++a>1e3)throw Error("computing square root of matrix: iterative method could not converge")}while(r>m);return o}return r(Nb,{"Array | Matrix":function(e){var r=cn(e)?e.size():nu(e);switch(r.length){case 1:if(1===r[0])return a(e,o);throw new RangeError("Matrix must be square (size: "+Go(r)+")");case 2:if(r[0]===r[1])return d(e);throw new RangeError("Matrix must be square (size: "+Go(r)+")");default:throw new RangeError("Matrix must be at most two dimensional (size: "+Go(r)+")")}}})})),Mb="sylvester",Cb=ti(Mb,["typed","schur","matrixFromColumns","matrix","multiply","range","concat","transpose","index","subset","add","subtract","identity","lusolve","abs"],(e=>{var{typed:r,schur:t,matrixFromColumns:n,matrix:i,multiply:a,range:o,concat:u,transpose:s,index:c,subset:l,add:f,subtract:m,identity:d,lusolve:p,abs:h}=e;return r(Mb,{"Matrix, Matrix, Matrix":v,"Array, Matrix, Matrix":function(e,r,t){return v(i(e),r,t)},"Array, Array, Matrix":function(e,r,t){return v(i(e),i(r),t)},"Array, Matrix, Array":function(e,r,t){return v(i(e),r,i(t))},"Matrix, Array, Matrix":function(e,r,t){return v(e,i(r),t)},"Matrix, Array, Array":function(e,r,t){return v(e,i(r),i(t))},"Matrix, Matrix, Array":function(e,r,t){return v(e,r,i(t))},"Array, Array, Array":function(e,r,t){return v(i(e),i(r),i(t)).toArray()}});function v(e,r,v){for(var y=r.size()[0],b=e.size()[0],g=t(e),x=g.T,w=g.U,D=t(a(-1,r)),N=D.T,A=D.U,M=a(a(s(w),v),A),C=o(0,b),E=[],S=(e,r)=>u(e,r,1),F=(e,r)=>u(e,r,0),B=0;B<y;B++)if(B<y-1&&h(l(N,c(B+1,B)))>1e-5){for(var q=F(l(M,c(C,B)),l(M,c(C,B+1))),T=0;T<B;T++)q=f(q,F(a(E[T],l(N,c(T,B))),a(E[T],l(N,c(T,B+1)))));var k=a(d(b),a(-1,l(N,c(B,B)))),O=a(d(b),a(-1,l(N,c(B+1,B)))),I=a(d(b),a(-1,l(N,c(B,B+1)))),z=a(d(b),a(-1,l(N,c(B+1,B+1)))),j=F(S(f(x,k),O),S(I,f(x,z))),R=p(j,q);E[B]=R.subset(c(o(0,b),0)),E[B+1]=R.subset(c(o(b,2*b),0)),B++}else{for(var U=l(M,c(C,B)),$=0;$<B;$++)U=f(U,a(E[$],l(N,c($,B))));var P=l(N,c(B,B)),L=m(x,a(P,d(b)));E[B]=p(L,U)}var _=i(n(...E));return a(w,a(_,s(A)))}})),Eb="schur",Sb=ti(Eb,["typed","matrix","identity","multiply","qr","norm","subtract"],(e=>{var{typed:r,matrix:t,identity:n,multiply:i,qr:a,norm:o,subtract:u}=e;return r(Eb,{Array:function(e){var r=s(t(e));return{U:r.U.valueOf(),T:r.T.valueOf()}},Matrix:function(e){return s(e)}});function s(e){var r,t=e.size()[0],s=e,c=n(t),l=0;do{r=s;var f=a(s),m=f.Q;if(s=i(f.R,m),c=i(c,m),l++>100)break}while(o(u(s,r))>1e-4);return{U:c,T:s}}})),Fb="lyap",Bb=ti(Fb,["typed","matrix","sylvester","multiply","transpose"],(e=>{var{typed:r,matrix:t,sylvester:n,multiply:i,transpose:a}=e;return r(Fb,{"Matrix, Matrix":function(e,r){return n(e,a(e),i(-1,r))},"Array, Matrix":function(e,r){return n(t(e),a(t(e)),i(-1,r))},"Matrix, Array":function(e,r){return n(e,a(t(e)),t(i(-1,r)))},"Array, Array":function(e,r){return n(t(e),a(t(e)),t(i(-1,r))).toArray()}})})),qb=ti("divide",["typed","matrix","multiply","equalScalar","divideScalar","inv"],(e=>{var{typed:r,matrix:t,multiply:n,equalScalar:i,divideScalar:a,inv:o}=e,u=ul({typed:r,equalScalar:i}),s=cl({typed:r});return r("divide",Jn({"Array | Matrix, Array | Matrix":function(e,r){return n(e,o(r))},"DenseMatrix, any":function(e,r){return s(e,r,a,!1)},"SparseMatrix, any":function(e,r){return u(e,r,a,!1)},"Array, any":function(e,r){return s(t(e),r,a,!1).valueOf()},"any, Array | Matrix":function(e,r){return n(e,o(r))}},a.signatures))})),Tb="distance",kb=ti(Tb,["typed","addScalar","subtractScalar","divideScalar","multiplyScalar","deepEqual","sqrt","abs"],(e=>{var{typed:r,addScalar:t,subtractScalar:n,multiplyScalar:i,divideScalar:a,deepEqual:o,sqrt:u,abs:s}=e;return r(Tb,{"Array, Array, Array":function(e,r,t){if(2===e.length&&2===r.length&&2===t.length){if(!l(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!l(r))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!l(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(o(r,t))throw new TypeError("LinePoint1 should not be same with LinePoint2");var a=n(t[1],r[1]),u=n(r[0],t[0]),s=n(i(t[0],r[1]),i(r[0],t[1]));return h(e[0],e[1],a,u,s)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(e,r,t){if(2===Object.keys(e).length&&2===Object.keys(r).length&&2===Object.keys(t).length){if(!l(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!l(r))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!l(t))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if(o(p(r),p(t)))throw new TypeError("LinePoint1 should not be same with LinePoint2");if("pointX"in e&&"pointY"in e&&"lineOnePtX"in r&&"lineOnePtY"in r&&"lineTwoPtX"in t&&"lineTwoPtY"in t){var a=n(t.lineTwoPtY,r.lineOnePtY),u=n(r.lineOnePtX,t.lineTwoPtX),s=n(i(t.lineTwoPtX,r.lineOnePtY),i(r.lineOnePtX,t.lineTwoPtY));return h(e.pointX,e.pointY,a,u,s)}throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(e,r){if(2===e.length&&3===r.length){if(!l(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!f(r))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return h(e[0],e[1],r[0],r[1],r[2])}if(3===e.length&&6===r.length){if(!f(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!d(r))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return v(e[0],e[1],e[2],r[0],r[1],r[2],r[3],r[4],r[5])}if(e.length===r.length&&e.length>0){if(!m(e))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!m(r))throw new TypeError("All values of an array should be numbers or BigNumbers");return y(e,r)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,r){if(2===Object.keys(e).length&&3===Object.keys(r).length){if(!l(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!f(r))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"xCoeffLine"in r&&"yCoeffLine"in r&&"constant"in r)return h(e.pointX,e.pointY,r.xCoeffLine,r.yCoeffLine,r.constant);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&6===Object.keys(r).length){if(!f(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!d(r))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"x0"in r&&"y0"in r&&"z0"in r&&"a"in r&&"b"in r&&"c"in r)return v(e.pointX,e.pointY,e.pointZ,r.x0,r.y0,r.z0,r.a,r.b,r.c);throw new TypeError("Key names do not match")}if(2===Object.keys(e).length&&2===Object.keys(r).length){if(!l(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!l(r))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointTwoX"in r&&"pointTwoY"in r)return y([e.pointOneX,e.pointOneY],[r.pointTwoX,r.pointTwoY]);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&3===Object.keys(r).length){if(!f(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!f(r))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointOneZ"in e&&"pointTwoX"in r&&"pointTwoY"in r&&"pointTwoZ"in r)return y([e.pointOneX,e.pointOneY,e.pointOneZ],[r.pointTwoX,r.pointTwoY,r.pointTwoZ]);throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},Array:function(e){if(!function(e){if(2===e[0].length&&c(e[0][0])&&c(e[0][1])){if(e.some((e=>2!==e.length||!c(e[0])||!c(e[1]))))return!1}else{if(!(3===e[0].length&&c(e[0][0])&&c(e[0][1])&&c(e[0][2])))return!1;if(e.some((e=>3!==e.length||!c(e[0])||!c(e[1])||!c(e[2]))))return!1}return!0}(e))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return function(e){for(var r=[],t=[],n=[],i=0;i<e.length-1;i++)for(var a=i+1;a<e.length;a++)2===e[0].length?(t=[e[i][0],e[i][1]],n=[e[a][0],e[a][1]]):3===e[0].length&&(t=[e[i][0],e[i][1],e[i][2]],n=[e[a][0],e[a][1],e[a][2]]),r.push(y(t,n));return r}(e)}});function c(e){return"number"==typeof e||rn(e)}function l(e){return e.constructor!==Array&&(e=p(e)),c(e[0])&&c(e[1])}function f(e){return e.constructor!==Array&&(e=p(e)),c(e[0])&&c(e[1])&&c(e[2])}function m(e){return Array.isArray(e)||(e=p(e)),e.every(c)}function d(e){return e.constructor!==Array&&(e=p(e)),c(e[0])&&c(e[1])&&c(e[2])&&c(e[3])&&c(e[4])&&c(e[5])}function p(e){for(var r=Object.keys(e),t=[],n=0;n<r.length;n++)t.push(e[r[n]]);return t}function h(e,r,n,o,c){var l=s(t(t(i(n,e),i(o,r)),c)),f=u(t(i(n,n),i(o,o)));return a(l,f)}function v(e,r,o,s,c,l,f,m,d){var p=[n(i(n(c,r),d),i(n(l,o),m)),n(i(n(l,o),f),i(n(s,e),d)),n(i(n(s,e),m),i(n(c,r),f))];p=u(t(t(i(p[0],p[0]),i(p[1],p[1])),i(p[2],p[2])));var h=u(t(t(i(f,f),i(m,m)),i(d,d)));return a(p,h)}function y(e,r){for(var a=e.length,o=0,s=0,c=0;c<a;c++)s=n(e[c],r[c]),o=t(i(s,s),o);return u(o)}})),Ob=ti("intersect",["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],(e=>{var{typed:r,config:t,abs:n,add:i,addScalar:a,matrix:o,multiply:u,multiplyScalar:s,divideScalar:c,subtract:l,smaller:f,equalScalar:m,flatten:d,isZero:p,isNumeric:h}=e;return r("intersect",{"Array, Array, Array":v,"Array, Array, Array, Array":y,"Matrix, Matrix, Matrix":function(e,r,t){var n=v(e.valueOf(),r.valueOf(),t.valueOf());return null===n?null:o(n)},"Matrix, Matrix, Matrix, Matrix":function(e,r,t,n){var i=y(e.valueOf(),r.valueOf(),t.valueOf(),n.valueOf());return null===i?null:o(i)}});function v(e,r,t){if(e=b(e),r=b(r),t=b(t),!x(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!x(r))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!function(e){return 4===e.length&&h(e[0])&&h(e[1])&&h(e[2])&&h(e[3])}(t))throw new TypeError("Array with 4 numbers expected as third argument");return function(e,r,t,n,i,o,u,f,m,d){var p=s(e,u),h=s(n,u),v=s(r,f),y=s(i,f),b=s(t,m),g=s(o,m),x=l(l(l(d,p),v),b),w=l(l(l(a(a(h,y),g),p),v),b),D=c(x,w);return[a(e,s(D,l(n,e))),a(r,s(D,l(i,r))),a(t,s(D,l(o,t)))]}(e[0],e[1],e[2],r[0],r[1],r[2],t[0],t[1],t[2],t[3])}function y(e,r,o,d){if(e=b(e),r=b(r),o=b(o),d=b(d),2===e.length){if(!g(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!g(r))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!g(o))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!g(d))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return function(e,r,o,m){var d=e,h=o,v=l(d,r),y=l(h,m),b=l(s(v[0],y[1]),s(y[0],v[1]));if(p(b))return null;if(f(n(b),t.relTol))return null;var g=s(y[0],d[1]),x=s(y[1],d[0]),w=s(y[0],h[1]),D=s(y[1],h[0]),N=c(a(l(l(g,x),w),D),b);return i(u(v,N),d)}(e,r,o,d)}if(3===e.length){if(!x(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!x(r))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!x(o))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!x(d))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return function(e,r,t,n,i,o,u,f,d,h,v,y){var b=w(e,u,h,u,r,f,v,f,t,d,y,d),g=w(h,u,n,e,v,f,i,r,y,d,o,t),x=w(e,u,n,e,r,f,i,r,t,d,o,t),D=w(h,u,h,u,v,f,v,f,y,d,y,d),N=w(n,e,n,e,i,r,i,r,o,t,o,t),A=l(s(b,g),s(x,D)),M=l(s(N,D),s(g,g));if(p(M))return null;var C=c(A,M),E=c(a(b,s(C,g)),D),S=a(e,s(C,l(n,e))),F=a(r,s(C,l(i,r))),B=a(t,s(C,l(o,t))),q=a(u,s(E,l(h,u))),T=a(f,s(E,l(v,f))),k=a(d,s(E,l(y,d)));return m(S,q)&&m(F,T)&&m(B,k)?[S,F,B]:null}(e[0],e[1],e[2],r[0],r[1],r[2],o[0],o[1],o[2],d[0],d[1],d[2])}throw new TypeError("Arrays with two or thee dimensional points expected")}function b(e){return 1===e.length?e[0]:e.length>1&&Array.isArray(e[0])&&e.every((e=>Array.isArray(e)&&1===e.length))?d(e):e}function g(e){return 2===e.length&&h(e[0])&&h(e[1])}function x(e){return 3===e.length&&h(e[0])&&h(e[1])&&h(e[2])}function w(e,r,t,n,i,o,u,c,f,m,d,p){var h=s(l(e,r),l(t,n)),v=s(l(i,o),l(u,c)),y=s(l(f,m),l(d,p));return a(a(h,v),y)}})),Ib=ti("sum",["typed","config","add","numeric"],(e=>{var{typed:r,config:t,add:n,numeric:i}=e;return r("sum",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,r){try{return Ju(e,r,n)}catch(e){throw dd(e,"sum")}},"...":function(e){if(Lu(e))throw new TypeError("Scalar values expected in function sum");return a(e)}});function a(e){var r;return _u(e,(function(e){try{r=void 0===r?e:n(r,e)}catch(r){throw dd(r,"sum",e)}})),void 0===r&&(r=i(0,t.number)),"string"==typeof r&&(r=i(r,ai(r,t))),r}})),zb="cumsum",jb=ti(zb,["typed","add","unaryPlus"],(e=>{var{typed:r,add:t,unaryPlus:n}=e;return r(zb,{Array:i,Matrix:function(e){return e.create(i(e.valueOf(),e.datatype()))},"Array, number | BigNumber":o,"Matrix, number | BigNumber":function(e,r){return e.create(o(e.valueOf(),r),e.datatype())},"...":function(e){if(Lu(e))throw new TypeError("All values expected to be scalar in function cumsum");return i(e)}});function i(e){try{return a(e)}catch(e){throw dd(e,zb)}}function a(e){if(0===e.length)return[];for(var r=[n(e[0])],i=1;i<e.length;++i)r.push(t(r[i-1],e[i]));return r}function o(e,r){var t=nu(e);if(r<0||r>=t.length)throw new tu(r,t.length);try{return u(e,r)}catch(e){throw dd(e,zb)}}function u(e,r){var t,n,i;if(r<=0){if(Array.isArray(e[0][0])){for(i=Pu(e),n=[],t=0;t<i.length;t++)n[t]=u(i[t],r-1);return n}return a(e)}for(n=[],t=0;t<e.length;t++)n[t]=u(e[t],r-1);return n}})),Rb="mean",Ub=ti(Rb,["typed","add","divide"],(e=>{var{typed:r,add:t,divide:n}=e;return r(Rb,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,r){try{var i=Ju(e,r,t),a=Array.isArray(e)?nu(e):e.size();return n(i,a[r])}catch(e){throw dd(e,"mean")}},"...":function(e){if(Lu(e))throw new TypeError("Scalar values expected in function mean");return i(e)}});function i(e){var r,i=0;if(_u(e,(function(e){try{r=void 0===r?e:t(r,e),i++}catch(r){throw dd(r,"mean",e)}})),0===i)throw Error("Cannot calculate the mean of an empty array");return n(r,i)}})),$b="median",Pb=ti($b,["typed","add","divide","compare","partitionSelect"],(e=>{var{typed:r,add:t,divide:n,compare:i,partitionSelect:a}=e;function o(e){try{var r=(e=bu(e.valueOf())).length;if(0===r)throw Error("Cannot calculate median of an empty array");if(r%2==0){for(var t=r/2-1,n=a(e,t+1),o=e[t],c=0;c<t;++c)i(e[c],o)>0&&(o=e[c]);return s(o,n)}var l=a(e,(r-1)/2);return u(l)}catch(e){throw dd(e,"median")}}var u=r({"number | BigNumber | Complex | Unit":function(e){return e}}),s=r({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,r){return n(t(e,r),2)}});return r($b,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(){throw Error("median(A, dim) is not yet supported")},"...":function(e){if(Lu(e))throw new TypeError("Scalar values expected in function median");return o(e)}})})),Lb=ti("mad",["typed","abs","map","median","subtract"],(e=>{var{typed:r,abs:t,map:n,median:i,subtract:a}=e;return r("mad",{"Array | Matrix":o,"...":function(e){return o(e)}});function o(e){if(0===(e=bu(e.valueOf())).length)throw Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var r=i(e);return i(n(e,(function(e){return t(a(e,r))})))}catch(e){throw e instanceof TypeError&&e.message.includes("median")?new TypeError(e.message.replace("median","mad")):dd(e,"mad")}}})),_b="unbiased",Wb="variance",Jb=ti(Wb,["typed","add","subtract","multiply","divide","mapSlices","isNaN"],(e=>{var{typed:r,add:t,subtract:n,multiply:i,divide:a,mapSlices:o,isNaN:u}=e;return r(Wb,{"Array | Matrix":function(e){return s(e,_b)},"Array | Matrix, string":s,"Array | Matrix, number | BigNumber":function(e,r){return c(e,r,_b)},"Array | Matrix, number | BigNumber, string":c,"...":function(e){return s(e,_b)}});function s(e,r){var o,s=0;if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(_u(e,(function(e){try{o=void 0===o?e:t(o,e),s++}catch(r){throw dd(r,"variance",e)}})),0===s)throw Error("Cannot calculate variance of an empty array");var c=a(o,s);if(o=void 0,_u(e,(function(e){var r=n(e,c);o=void 0===o?i(r,r):t(o,i(r,r))})),u(o))return o;switch(r){case"uncorrected":return a(o,s);case"biased":return a(o,s+1);case"unbiased":var l=rn(o)?o.mul(0):0;return 1===s?l:a(o,s-1);default:throw Error('Unknown normalization "'+r+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function c(e,r,t){try{if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return o(e,r,(e=>s(e,t)))}catch(e){throw dd(e,"variance")}}})),Vb="quantileSeq",Hb=ti(Vb,["typed","?bignumber","add","subtract","divide","multiply","partitionSelect","compare","isInteger","smaller","smallerEq","larger","mapSlices"],(e=>{var{typed:r,bignumber:t,add:n,subtract:i,divide:a,multiply:o,partitionSelect:u,compare:s,isInteger:c,smaller:l,smallerEq:f,larger:m,mapSlices:d}=e;return r(Vb,{"Array | Matrix, number | BigNumber":(e,r)=>h(e,r,!1),"Array | Matrix, number | BigNumber, number":(e,r,t)=>p(e,r,!1,t,h),"Array | Matrix, number | BigNumber, boolean":h,"Array | Matrix, number | BigNumber, boolean, number":(e,r,t,n)=>p(e,r,t,n,h),"Array | Matrix, Array | Matrix":(e,r)=>v(e,r,!1),"Array | Matrix, Array | Matrix, number":(e,r,t)=>p(e,r,!1,t,v),"Array | Matrix, Array | Matrix, boolean":v,"Array | Matrix, Array | Matrix, boolean, number":(e,r,t,n)=>p(e,r,t,n,v)});function p(e,r,t,n,i){return d(e,n,(e=>i(e,r,t)))}function h(e,r,i){var o,u=e.valueOf();if(l(r,0))throw Error("N/prob must be non-negative");if(f(r,1))return en(r)?y(u,r,i):t(y(u,r,i));if(m(r,1)){if(!c(r))throw Error("N must be a positive integer");if(m(r,4294967295))throw Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var s=n(r,1);o=[];for(var d=0;l(d,r);d++){var p=a(d+1,s);o.push(y(u,p,i))}return en(r)?o:t(o)}}function v(e,r,t){for(var n=e.valueOf(),i=r.valueOf(),a=[],o=0;o<i.length;++o)a.push(y(n,i[o],t));return a}function y(e,r,t){var a=bu(e),l=a.length;if(0===l)throw Error("Cannot calculate quantile of an empty sequence");var f,m,d=en(r)?r*(l-1):r.times(l-1),p=en(r)?Math.floor(d):d.floor().toNumber(),h=en(r)?d%1:d.minus(p);if(c(d))return t?a[d]:u(a,en(r)?d:d.valueOf());if(t)f=a[p],m=a[p+1];else{m=u(a,p+1),f=a[p];for(var v=0;v<p;++v)s(a[v],f)>0&&(f=a[v])}return n(o(f,i(1,h)),o(m,h))}})),Zb=ti("std",["typed","map","sqrt","variance"],(e=>{var{typed:r,map:t,sqrt:n,variance:i}=e;return r("std",{"Array | Matrix":a,"Array | Matrix, string":a,"Array | Matrix, number | BigNumber":a,"Array | Matrix, number | BigNumber, string":a,"...":function(e){return a(e)}});function a(e,r){if(0===e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{var a=i.apply(null,arguments);return ln(a)?t(a,n):n(a)}catch(e){throw e instanceof TypeError&&e.message.includes(" variance")?new TypeError(e.message.replace(" variance"," std")):e}}})),Gb="corr",Xb=ti(Gb,["typed","matrix","mean","sqrt","sum","add","subtract","multiply","pow","divide"],(e=>{var{typed:r,matrix:t,sqrt:n,sum:i,add:a,subtract:o,multiply:u,pow:s,divide:c}=e;return r(Gb,{"Array, Array":function(e,r){return l(e,r)},"Matrix, Matrix":function(e,r){var n=l(e.toArray(),r.toArray());return Array.isArray(n)?t(n):n}});function l(e,r){var t=[];if(Array.isArray(e[0])&&Array.isArray(r[0])){if(e.length!==r.length)throw new SyntaxError("Dimension mismatch. Array A and B must have the same length.");for(var n=0;n<e.length;n++){if(e[n].length!==r[n].length)throw new SyntaxError("Dimension mismatch. Array A and B must have the same number of elements.");t.push(f(e[n],r[n]))}return t}if(e.length!==r.length)throw new SyntaxError("Dimension mismatch. Array A and B must have the same number of elements.");return f(e,r)}function f(e,r){var t=e.length,l=i(e),f=i(r),m=e.reduce(((e,t,n)=>a(e,u(t,r[n]))),0),d=i(e.map((e=>s(e,2)))),p=i(r.map((e=>s(e,2)))),h=o(u(t,m),u(l,f)),v=n(u(o(u(t,d),s(l,2)),o(u(t,p),s(f,2))));return c(h,v)}})),Yb="combinations",Qb=ti(Yb,["typed"],(e=>{var{typed:r}=e;return r(Yb,{"number, number":Es,"BigNumber, BigNumber":function(e,r){var t,n,i=e.constructor,a=e.minus(r),o=new i(1);if(!Kb(e)||!Kb(r))throw new TypeError("Positive integer value expected in function combinations");if(r.gt(e))throw new TypeError("k must be less than n in function combinations");if(t=o,r.lt(a))for(n=o;n.lte(a);n=n.plus(o))t=t.times(r.plus(n)).dividedBy(n);else for(n=o;n.lte(r);n=n.plus(o))t=t.times(a.plus(n)).dividedBy(n);return t}})}));function Kb(e){return e.isInteger()&&e.gte(0)}var eg="combinationsWithRep",rg=ti(eg,["typed"],(e=>{var{typed:r}=e;return r(eg,{"number, number":function(e,r){if(!ii(e)||e<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!ii(r)||r<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e<1)throw new TypeError("k must be less than or equal to n + k - 1");return r<e-1?Cs(e,e+r-1)/Cs(1,r):Cs(r+1,e+r-1)/Cs(1,e-1)},"BigNumber, BigNumber":function(e,r){var t,n,i=new(0,e.constructor)(1),a=e.minus(i);if(!tg(e)||!tg(r))throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e.lt(i))throw new TypeError("k must be less than or equal to n + k - 1 in function combinationsWithRep");if(t=i,r.lt(a))for(n=i;n.lte(a);n=n.plus(i))t=t.times(r.plus(n)).dividedBy(n);else for(n=i;n.lte(r);n=n.plus(i))t=t.times(a.plus(n)).dividedBy(n);return t}})}));function tg(e){return e.isInteger()&&e.gte(0)}var ng="gamma",ig=ti(ng,["typed","config","multiplyScalar","pow","BigNumber","Complex"],(e=>{var{typed:r,config:t,BigNumber:n,Complex:i}=e;return r(ng,{number:zs,Complex:function e(r){if(0===r.im)return zs(r.re);if(r.re<.5){var t=new i(1-r.re,-r.im),n=new i(Math.PI*r.re,Math.PI*r.im);return new i(Math.PI).div(n.sin()).div(e(t))}r=new i(r.re-1,r.im);for(var a=new i(Rs[0],0),o=1;o<Rs.length;++o){var u=new i(Rs[o],0);a=a.add(u.div(r.add(o)))}var s=new i(r.re+js+.5,r.im),c=s.pow(r.add(.5)),l=s.neg().exp();return a.mul(2.5066282746310002).mul(c).mul(l)},BigNumber:function(e){if(e.isInteger())return e.isNegative()||e.isZero()?new n(1/0):a(e.minus(1));if(!e.isFinite())return new n(e.isNegative()?NaN:1/0);throw Error("Integer BigNumber expected")}});function a(e){if(e<8)return new n([1,1,2,6,24,120,720,5040][e]);var r=t.precision+(0|Math.log(e.toNumber())),i=n.clone({precision:r});if(e%2==1)return e.times(a(new n(e-1)));for(var o=e,u=new i(e),s=e.toNumber();o>2;)u=u.times(s+=o-=2);return new n(u.toPrecision(n.precision))}})),ag="lgamma",og=ti(ag,["Complex","typed"],(e=>{var{Complex:r,typed:t}=e,n=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return t(ag,{number:Ps,Complex:function e(t){if(t.isNaN())return new r(NaN,NaN);if(0===t.im)return new r(Ps(t.re),0);if(t.re>=7||Math.abs(t.im)>=7)return i(t);if(t.re<=.1){var n=function(e,r){return!0^(r>0||!(r<0)&&1/r==1/0)?-e:e}(6.283185307179586,t.im)*Math.floor(.5*t.re+.25),o=t.mul(Math.PI).sin().log(),u=e(new r(1-t.re,-t.im));return new r(1.1447298858494002,n).sub(o).sub(u)}return t.im>=0?a(t):a(t.conjugate()).conjugate()},BigNumber:function(){throw Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function i(e){for(var t=e.sub(.5).mul(e.log()).sub(e).add(Us),i=new r(1,0).div(e),a=i.div(e),o=n[0],u=n[1],s=2*a.re,c=a.re*a.re+a.im*a.im,l=2;l<8;l++){var f=u;u=-c*o+n[l],o=s*o+f}var m=i.mul(a.mul(o).add(u));return t.add(m)}function a(e){var t=0,n=0,a=e;for(e=e.add(1);e.re<=7;){var o=(a=a.mul(e)).im<0?1:0;0!==o&&0===n&&t++,n=o,e=e.add(1)}return i(e).sub(a.log()).sub(new r(0,2*t*Math.PI*1))}})),ug="factorial",sg=ti(ug,["typed","gamma"],(e=>{var{typed:r,gamma:t}=e;return r(ug,{number:function(e){if(e<0)throw Error("Value must be non-negative");return t(e+1)},BigNumber:function(e){if(e.isNegative())throw Error("Value must be non-negative");return t(e.plus(1))},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),cg="kldivergence",lg=ti(cg,["typed","matrix","divide","sum","multiply","map","dotDivide","log","isNumeric"],(e=>{var{typed:r,matrix:t,divide:n,sum:i,multiply:a,map:o,dotDivide:u,log:s,isNumeric:c}=e;return r(cg,{"Array, Array":function(e,r){return l(t(e),t(r))},"Matrix, Array":function(e,r){return l(e,t(r))},"Array, Matrix":function(e,r){return l(t(e),r)},"Matrix, Matrix":function(e,r){return l(e,r)}});function l(e,r){var t=r.size().length,l=e.size().length;if(t>1)throw Error("first object must be one dimensional");if(l>1)throw Error("second object must be one dimensional");if(t!==l)throw Error("Length of two vectors must be equal");if(0===i(e))throw Error("Sum of elements in first object must be non zero");if(0===i(r))throw Error("Sum of elements in second object must be non zero");var f=n(e,i(e)),m=n(r,i(r)),d=i(a(f,o(u(f,m),(e=>s(e)))));return c(d)?d:NaN}})),fg="multinomial",mg=ti(fg,["typed","add","divide","multiply","factorial","isInteger","isPositive"],(e=>{var{typed:r,add:t,divide:n,multiply:i,factorial:a,isInteger:o,isPositive:u}=e;return r(fg,{"Array | Matrix":function(e){var r=0,s=1;return _u(e,(function(e){if(!o(e)||!u(e))throw new TypeError("Positive integer value expected in function multinomial");r=t(r,e),s=i(s,a(e))})),n(a(r),s)}})})),dg="permutations",pg=ti(dg,["typed","factorial"],(e=>{var{typed:r,factorial:t}=e;return r(dg,{"number | BigNumber":t,"number, number":function(e,r){if(!ii(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!ii(r)||r<0)throw new TypeError("Positive integer value expected in function permutations");if(r>e)throw new TypeError("second argument k must be less than or equal to first argument n");return Cs(e-r+1,e)},"BigNumber, BigNumber":function(e,r){var t,n;if(!hg(e)||!hg(r))throw new TypeError("Positive integer value expected in function permutations");if(r.gt(e))throw new TypeError("second argument k must be less than or equal to first argument n");for(t=e.mul(0).add(1),n=e.minus(r).plus(1);n.lte(e);n=n.plus(1))t=t.times(n);return t}})}));function hg(e){return e.isInteger()&&e.gte(0)}var vg,yg={exports:{}};var bg,gg={exports:{}};var xg,wg={exports:{}};var Dg,Ng={exports:{}};var Ag,Mg={exports:{}};var Cg,Eg={exports:{}};var Sg,Fg,Bg,qg={exports:{}},Tg=Yn(Object.freeze({__proto__:null,default:{}})),kg=qg.exports;function Og(){return Sg||(Sg=1,function(e){!function(r,t,n){var i,a=256,o="random",u=n.pow(a,6),s=n.pow(2,52),c=2*s,l=255;function f(e,l,f){var y=[],b=h(p((l=1==l?{entropy:!0}:l||{}).entropy?[e,v(t)]:null==e?function(){try{var e;return i&&(e=i.randomBytes)?e=e(a):(e=new Uint8Array(a),(r.crypto||r.msCrypto).getRandomValues(e)),v(e)}catch(e){var n=r.navigator,o=n&&n.plugins;return[+new Date,r,o,r.screen,v(t)]}}():e,3),y),g=new m(y),x=function(){for(var e=g.g(6),r=u,t=0;e<s;)e=(e+t)*a,r*=a,t=g.g(1);for(;e>=c;)e/=2,r/=2,t>>>=1;return(e+t)/r};return x.int32=function(){return 0|g.g(4)},x.quick=function(){return g.g(4)/4294967296},x.double=x,h(v(g.S),t),(l.pass||f||function(e,r,t,i){return i&&(i.S&&d(i,g),e.state=function(){return d(g,{})}),t?(n[o]=e,r):e})(x,b,"global"in l?l.global:this==n,l.state)}function m(e){var r,t=e.length,n=this,i=0,o=n.i=n.j=0,u=n.S=[];for(t||(e=[t++]);i<a;)u[i]=i++;for(i=0;i<a;i++)u[i]=u[o=l&o+e[i%t]+(r=u[i])],u[o]=r;(n.g=function(e){for(var r,t=0,i=n.i,o=n.j,u=n.S;e--;)r=u[i=l&i+1],t=t*a+u[l&(u[i]=u[o=l&o+r])+(u[o]=r)];return n.i=i,n.j=o,t})(a)}function d(e,r){return r.i=e.i,r.j=e.j,r.S=e.S.slice(),r}function p(e,r){var t,n=[],i=typeof e;if(r&&"object"==i)for(t in e)try{n.push(p(e[t],r-1))}catch(e){}return n.length?n:"string"==i?e:e+"\0"}function h(e,r){for(var t,n=e+"",i=0;i<n.length;)r[l&i]=l&(t^=19*r[l&i])+n.charCodeAt(i++);return v(r)}function v(e){return String.fromCharCode.apply(0,e)}if(h(n.random(),t),e.exports){e.exports=f;try{i=Tg}catch(e){}}else n["seed"+o]=f}("undefined"!=typeof self?self:kg,[],Math)}(qg)),qg.exports}var Ig=function(){if(Bg)return Fg;Bg=1;var e=(vg||(vg=1,function(){function e(e){var r=this,t=function(){var e=4022871197;return function(r){r+="";for(var t=0;t<r.length;t++){var n=.02519603282416938*(e+=r.charCodeAt(t));n-=e=n>>>0,e=(n*=e)>>>0,e+=4294967296*(n-=e)}return 2.3283064365386963e-10*(e>>>0)}}();r.next=function(){var e=2091639*r.s0+2.3283064365386963e-10*r.c;return r.s0=r.s1,r.s1=r.s2,r.s2=e-(r.c=0|e)},r.c=1,r.s0=t(" "),r.s1=t(" "),r.s2=t(" "),r.s0-=t(e),r.s0<0&&(r.s0+=1),r.s1-=t(e),r.s1<0&&(r.s1+=1),r.s2-=t(e),r.s2<0&&(r.s2+=1),t=null}function r(e,r){return r.c=e.c,r.s0=e.s0,r.s1=e.s1,r.s2=e.s2,r}function t(t,n){var i=new e(t),a=n&&n.state,o=i.next;return o.int32=function(){return 4294967296*i.next()|0},o.double=function(){return o()+11102230246251565e-32*(2097152*o()|0)},o.quick=o,a&&("object"==typeof a&&r(a,i),o.state=function(){return r(i,{})}),o}yg&&yg.exports?yg.exports=t:this.alea=t}()),yg.exports),r=(bg||(bg=1,function(){function e(e){var r=this,t="";r.x=0,r.y=0,r.z=0,r.w=0,r.next=function(){var e=r.x^r.x<<11;return r.x=r.y,r.y=r.z,r.z=r.w,r.w^=r.w>>>19^e^e>>>8},e===(0|e)?r.x=e:t+=e;for(var n=0;n<t.length+64;n++)r.x^=0|t.charCodeAt(n),r.next()}function r(e,r){return r.x=e.x,r.y=e.y,r.z=e.z,r.w=e.w,r}function t(t,n){var i=new e(t),a=n&&n.state,o=function(){return(i.next()>>>0)/4294967296};return o.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=i.next,o.quick=o,a&&("object"==typeof a&&r(a,i),o.state=function(){return r(i,{})}),o}gg&&gg.exports?gg.exports=t:this.xor128=t}()),gg.exports),t=(xg||(xg=1,function(){function e(e){var r=this,t="";r.next=function(){var e=r.x^r.x>>>2;return r.x=r.y,r.y=r.z,r.z=r.w,r.w=r.v,(r.d=r.d+362437|0)+(r.v=r.v^r.v<<4^e^e<<1)|0},r.x=0,r.y=0,r.z=0,r.w=0,r.v=0,e===(0|e)?r.x=e:t+=e;for(var n=0;n<t.length+64;n++)r.x^=0|t.charCodeAt(n),n==t.length&&(r.d=r.x<<10^r.x>>>4),r.next()}function r(e,r){return r.x=e.x,r.y=e.y,r.z=e.z,r.w=e.w,r.v=e.v,r.d=e.d,r}function t(t,n){var i=new e(t),a=n&&n.state,o=function(){return(i.next()>>>0)/4294967296};return o.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=i.next,o.quick=o,a&&("object"==typeof a&&r(a,i),o.state=function(){return r(i,{})}),o}wg&&wg.exports?wg.exports=t:this.xorwow=t}()),wg.exports),n=(Dg||(Dg=1,function(){function e(e){var r=this;r.next=function(){var e,t,n=r.x,i=r.i;return e=n[i],t=(e^=e>>>7)^e<<24,t^=(e=n[i+1&7])^e>>>10,t^=(e=n[i+3&7])^e>>>3,t^=(e=n[i+4&7])^e<<7,e=n[i+7&7],n[i]=t^=(e^=e<<13)^e<<9,r.i=i+1&7,t},function(e,r){var t,n=[];if(r===(0|r))n[0]=r;else for(r=""+r,t=0;t<r.length;++t)n[7&t]=n[7&t]<<15^r.charCodeAt(t)+n[t+1&7]<<13;for(;n.length<8;)n.push(0);for(t=0;t<8&&0===n[t];++t);for(8==t&&(n[7]=-1),e.x=n,e.i=0,t=256;t>0;--t)e.next()}(r,e)}function r(e,r){return r.x=e.x.slice(),r.i=e.i,r}function t(t,n){null==t&&(t=+new Date);var i=new e(t),a=n&&n.state,o=function(){return(i.next()>>>0)/4294967296};return o.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=i.next,o.quick=o,a&&(a.x&&r(a,i),o.state=function(){return r(i,{})}),o}Ng&&Ng.exports?Ng.exports=t:this.xorshift7=t}()),Ng.exports),i=(Ag||(Ag=1,function(){function e(e){var r=this;r.next=function(){var e,t,n=r.w,i=r.X,a=r.i;return r.w=n=n+1640531527|0,t=i[a+34&127],e=i[a=a+1&127],t^=t<<13,e^=e<<17,t=i[a]=(t^=t>>>15)^(e^=e>>>12),r.i=a,t+(n^n>>>16)|0},function(e,r){var t,n,i,a,o,u=[],s=128;for(r===(0|r)?(n=r,r=null):(n=0,s=Math.max(s,(r+="\0").length)),i=0,a=-32;a<s;++a)r&&(n^=r.charCodeAt((a+32)%r.length)),0===a&&(o=n),n^=n<<10,n^=n>>>15,n^=n<<4,n^=n>>>13,a>=0&&(i=0==(t=u[127&a]^=n+(o=o+1640531527|0))?i+1:0);for(i>=128&&(u[127&(r&&r.length||0)]=-1),i=127,a=512;a>0;--a)n=u[i+34&127],t=u[i=i+1&127],n^=n<<13,t^=t<<17,u[i]=(n^=n>>>15)^(t^=t>>>12);e.w=o,e.X=u,e.i=i}(r,e)}function r(e,r){return r.i=e.i,r.w=e.w,r.X=e.X.slice(),r}function t(t,n){null==t&&(t=+new Date);var i=new e(t),a=n&&n.state,o=function(){return(i.next()>>>0)/4294967296};return o.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=i.next,o.quick=o,a&&(a.X&&r(a,i),o.state=function(){return r(i,{})}),o}Mg&&Mg.exports?Mg.exports=t:this.xor4096=t}()),Mg.exports),a=(Cg||(Cg=1,function(){function e(e){var r=this,t="";r.next=function(){var e=r.b,t=r.c,n=r.d,i=r.a;return e=e<<25^e>>>7^t,t=t-n|0,n=n<<24^n>>>8^i,i=i-e|0,r.b=e=e<<20^e>>>12^t,r.c=t=t-n|0,r.d=n<<16^t>>>16^i,r.a=i-e|0},r.a=0,r.b=0,r.c=-1640531527,r.d=1367130551,e===Math.floor(e)?(r.a=e/4294967296|0,r.b=0|e):t+=e;for(var n=0;n<t.length+20;n++)r.b^=0|t.charCodeAt(n),r.next()}function r(e,r){return r.a=e.a,r.b=e.b,r.c=e.c,r.d=e.d,r}function t(t,n){var i=new e(t),a=n&&n.state,o=function(){return(i.next()>>>0)/4294967296};return o.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=i.next,o.quick=o,a&&("object"==typeof a&&r(a,i),o.state=function(){return r(i,{})}),o}Eg&&Eg.exports?Eg.exports=t:this.tychei=t}()),Eg.exports),o=Og();return o.alea=e,o.xor128=r,o.xorwow=t,o.xorshift7=n,o.xor4096=i,o.tychei=a,Fg=o}(),zg=Xn(Ig),jg=zg(Date.now());function Rg(e){var r;return function(e){r=null===e?jg:zg(e+"")}(e),function(){return r()}}var Ug="pickRandom",$g=ti(Ug,["typed","config","?on"],(e=>{var{typed:r,config:t,on:n}=e,i=Rg(t.randomSeed);return n&&n("config",(function(e,r){e.randomSeed!==r.randomSeed&&(i=Rg(e.randomSeed))})),r(Ug,{"Array | Matrix":function(e){return a(e,{})},"Array | Matrix, Object":function(e,r){return a(e,r)},"Array | Matrix, number":function(e,r){return a(e,{number:r})},"Array | Matrix, Array | Matrix":function(e,r){return a(e,{weights:r})},"Array | Matrix, Array | Matrix, number":function(e,r,t){return a(e,{number:t,weights:r})},"Array | Matrix, number, Array | Matrix":function(e,r,t){return a(e,{number:r,weights:t})}});function a(e,r){var{number:t,weights:n,elementWise:a=!0}=r,o=void 0===t;o&&(t=1);var u=cn(e)?e.create:cn(n)?n.create:null;e=e.valueOf(),n&&(n=n.valueOf()),!0===a&&(e=bu(e),n=bu(n));var s=0;if(void 0!==n){if(n.length!==e.length)throw Error("Weights must have the same length as possibles");for(var c=0,l=n.length;c<l;c++){if(!en(n[c])||n[c]<0)throw Error("Weights must be an array of positive numbers");s+=n[c]}}for(var f,m=e.length,d=[];d.length<t;){if(void 0===n)f=e[Math.floor(i()*m)];else for(var p=i()*s,h=0,v=e.length;h<v;h++)if((p-=n[h])<0){f=e[h];break}d.push(f)}return o?d[0]:u?u(d):d}}));function Pg(e,r){var t=[];if((e=e.slice(0)).length>1)for(var n=0,i=e.shift();n<i;n++)t.push(Pg(e,r));else for(var a=0,o=e.shift();a<o;a++)t.push(r());return t}var Lg="random",_g=ti(Lg,["typed","config","?on"],(e=>{var{typed:r,config:t,on:n}=e,i=Rg(t.randomSeed);return n&&n("config",(function(e,r){e.randomSeed!==r.randomSeed&&(i=Rg(e.randomSeed))})),r(Lg,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,r)=>o(e,r),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,r)=>a(e,0,r),"Array | Matrix, number, number":(e,r,t)=>a(e,r,t)});function a(e,r,t){var n=Pg(e.valueOf(),(()=>o(r,t)));return cn(e)?e.create(n,"number"):n}function o(e,r){return e+i()*(r-e)}})),Wg="randomInt",Jg=ti(Wg,["typed","config","log2","?on"],(e=>{var{typed:r,config:t,log2:n,on:i}=e,a=Rg(t.randomSeed);return i&&i("config",(function(e,r){e.randomSeed!==r.randomSeed&&(a=Rg(e.randomSeed))})),r(Wg,{"":()=>u(0,2),number:e=>u(0,e),"number, number":(e,r)=>u(e,r),bigint:e=>s(0n,e),"bigint, bigint":s,"Array | Matrix":e=>o(e,0,1),"Array | Matrix, number":(e,r)=>o(e,0,r),"Array | Matrix, number, number":(e,r,t)=>o(e,r,t)});function o(e,r,t){var n=Pg(e.valueOf(),(()=>u(r,t)));return cn(e)?e.create(n,"number"):n}function u(e,r){return Math.floor(e+a()*(r-e))}function s(e,r){var t=r-e;if(t<=2n**30n)return e+BigInt(u(0,Number(t)));for(var i=n(t),o=t;o>=t;){o=0n;for(var s=0;s<i;++s)o=2n*o+(a()<.5?0n:1n)}return e+o}})),Vg="stirlingS2",Hg=ti(Vg,["typed","addScalar","subtractScalar","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],(e=>{var{typed:r,addScalar:t,multiplyScalar:n,isNegative:i,isInteger:a,number:o,bignumber:u,larger:s}=e,c=[],l=[];return r(Vg,{"number | BigNumber, number | BigNumber":function(e,r){if(!a(e)||i(e)||!a(r)||i(r))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(s(r,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");var f=!(en(e)&&en(r)),m=f?l:c,d=f?u:o,p=o(e),h=o(r);if(m[p]&&m[p].length>h)return m[p][h];for(var v=0;v<=p;++v)if(m[v]||(m[v]=[d(0===v?1:0)]),0!==v)for(var y=m[v],b=m[v-1],g=y.length;g<=v&&g<=h;++g)y[g]=g===v?1:t(n(d(g),b[g]),b[g-1]);return m[p][h]}})})),Zg="bellNumbers",Gg=ti(Zg,["typed","addScalar","isNegative","isInteger","stirlingS2"],(e=>{var{typed:r,addScalar:t,isNegative:n,isInteger:i,stirlingS2:a}=e;return r(Zg,{"number | BigNumber":function(e){if(!i(e)||n(e))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var r=0,o=0;o<=e;o++)r=t(r,a(e,o));return r}})})),Xg="catalan",Yg=ti(Xg,["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],(e=>{var{typed:r,addScalar:t,divideScalar:n,multiplyScalar:i,combinations:a,isNegative:o,isInteger:u}=e;return r(Xg,{"number | BigNumber":function(e){if(!u(e)||o(e))throw new TypeError("Non-negative integer value expected in function catalan");return n(a(i(e,2),e),t(e,1))}})})),Qg="composition",Kg=ti(Qg,["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],(e=>{var{typed:r,addScalar:t,combinations:n,isPositive:i,isInteger:a,larger:o}=e;return r(Qg,{"number | BigNumber, number | BigNumber":function(e,r){if(!(a(e)&&i(e)&&a(r)&&i(r)))throw new TypeError("Positive integer value expected in function composition");if(o(r,e))throw new TypeError("k must be less than or equal to n in function composition");return n(t(e,-1),t(r,-1))}})})),ex="leafCount",rx=ti(ex,["parse","typed"],(e=>{var{typed:r}=e;function t(e){var r=0;return e.forEach((e=>{r+=t(e)})),r||1}return r(ex,{Node:function(e){return t(e)}})}));function tx(e){return Bn(e)||jn(e)&&e.isUnary()&&Bn(e.args[0])}function nx(e){return!!Bn(e)||!(!kn(e)&&!jn(e)||!e.args.every(nx))||!(!Rn(e)||!nx(e.content))}function ix(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function ax(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ix(Object(t),!0).forEach((function(r){ed(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ix(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var ox=ti("simplifyUtil",["FunctionNode","OperatorNode","SymbolNode"],(e=>{var{FunctionNode:r,OperatorNode:t,SymbolNode:n}=e,i=!0,a=!1,o="defaultF",u={add:{trivial:i,total:i,commutative:i,associative:i},unaryPlus:{trivial:i,total:i,commutative:i,associative:i},subtract:{trivial:a,total:i,commutative:a,associative:a},multiply:{trivial:i,total:i,commutative:i,associative:i},divide:{trivial:a,total:i,commutative:a,associative:a},paren:{trivial:i,total:i,commutative:i,associative:a},defaultF:{trivial:a,total:i,commutative:a,associative:a}};function s(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:u,n=o;if("string"==typeof e?n=e:jn(e)?n=""+e.fn:kn(e)?n=e.name:Rn(e)&&(n="paren"),Hn(t,n)){var i=t[n];if(Hn(i,r))return i[r];if(Hn(u,n))return u[n][r]}if(Hn(t,o)){var a=t[o];return Hn(a,r)?a[r]:u[o][r]}if(Hn(u,n)){var s=u[n];if(Hn(s,r))return s[r]}return u[o][r]}function c(e){return s(e,"associative",arguments.length>1&&void 0!==arguments[1]?arguments[1]:u)}function l(e,r){var t,n=[],i=function(e){for(var r=0;r<e.args.length;r++){var a=e.args[r];jn(a)&&t===a.op?i(a):n.push(a)}};return c(e,r)?(t=e.op,i(e),n):e.args}function f(e){return jn(e)?function(r){try{return new t(e.op,e.fn,r,e.implicit)}catch(e){return console.error(e),[]}}:function(t){return new r(new n(e.name),t)}}return{createMakeNodeFunction:f,hasProperty:s,isCommutative:function(e){return s(e,"commutative",arguments.length>1&&void 0!==arguments[1]?arguments[1]:u)},isAssociative:c,mergeContext:function(e,r){var t=ax({},e);for(var n in r)t[n]=Hn(e,n)?ax(ax({},r[n]),e[n]):r[n];return t},flatten:function e(r,t){if(!r.args||0===r.args.length)return r;r.args=l(r,t);for(var n=0;n<r.args.length;n++)e(r.args[n],t)},allChildren:l,unflattenr:function e(r,t){if(r.args&&0!==r.args.length){for(var n=f(r),i=r.args.length,a=0;a<i;a++)e(r.args[a],t);if(i>2&&c(r,t)){for(var o=r.args.pop();r.args.length>0;)o=n([r.args.pop(),o]);r.args=o.args}}},unflattenl:function e(r,t){if(r.args&&0!==r.args.length){for(var n=f(r),i=r.args.length,a=0;a<i;a++)e(r.args[a],t);if(i>2&&c(r,t)){for(var o=r.args.shift();r.args.length>0;)o=n([o,r.args.shift()]);r.args=o.args}}},defaultContext:u,realContext:{divide:{total:a},log:{total:a}},positiveContext:{subtract:{total:a},abs:{trivial:i},log:{total:i}}}})),ux=ti("simplify",["typed","parse","equal","resolve","simplifyConstant","simplifyCore","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode","replacer"],(e=>{var{typed:r,parse:t,equal:n,resolve:i,simplifyConstant:a,simplifyCore:o,AccessorNode:u,ArrayNode:s,ConstantNode:c,FunctionNode:l,IndexNode:f,ObjectNode:m,OperatorNode:d,ParenthesisNode:p,SymbolNode:h,replacer:v}=e,{hasProperty:y,isCommutative:b,isAssociative:g,mergeContext:x,flatten:w,unflattenr:D,unflattenl:N,createMakeNodeFunction:A,defaultContext:M,realContext:C,positiveContext:E}=ox({FunctionNode:l,OperatorNode:d,SymbolNode:h});r.addConversion({from:"Object",to:"Map",convert:Kt});var S=r("simplify",{Node:O,"Node, Map":(e,r)=>O(e,!1,r),"Node, Map, Object":(e,r,t)=>O(e,!1,r,t),"Node, Array":O,"Node, Array, Map":O,"Node, Array, Map, Object":O});function F(e){return e.transform((function(e){return Rn(e)?F(e.content):e}))}r.removeConversion({from:"Object",to:"Map",convert:Kt}),S.defaultContext=M,S.realContext=C,S.positiveContext=E;var B={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};function q(e,r){var n={};if(e.s){var i=e.s.split("->");if(2!==i.length)throw SyntaxError("Could not parse rule: "+e.s);n.l=i[0],n.r=i[1]}else n.l=e.l,n.r=e.r;for(var a of(n.l=F(t(n.l)),n.r=F(t(n.r)),["imposeContext","repeat","assuming"]))a in e&&(n[a]=e[a]);if(e.evaluate&&(n.evaluate=t(e.evaluate)),g(n.l,r)){var o,u=!b(n.l,r);u&&(o=k());var s=A(n.l),c=k();n.expanded={},n.expanded.l=s([n.l,c]),w(n.expanded.l,r),D(n.expanded.l,r),n.expanded.r=s([n.r,c]),u&&(n.expandedNC1={},n.expandedNC1.l=s([o,n.l]),n.expandedNC1.r=s([o,n.r]),n.expandedNC2={},n.expandedNC2.l=s([o,n.expanded.l]),n.expandedNC2.r=s([o,n.expanded.r]))}return n}S.rules=[o,{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}}},a,{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}}},a,{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"},{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"}];var T=0;function k(){return new h("_p"+T++)}function O(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Qt(),n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=n.consoleDebug;r=function(e,r){for(var t=[],n=0;n<e.length;n++){var i=e[n],a=void 0,o=typeof i;switch(o){case"string":i={s:i};case"object":a=q(i,r);break;case"function":a=i;break;default:throw TypeError("Unsupported type of rule: "+o)}t.push(a)}return t}(r||S.rules,n.context);for(var o=i(e,t),u={},s=(o=F(o)).toString({parenthesis:"all"});!u[s];){u[s]=!0,T=0;var c=s;a&&console.log("Working on: ",s);for(var l=0;l<r.length;l++){var f="";if("function"==typeof r[l]?(o=r[l](o,n),a&&(f=r[l].name)):(w(o,n.context),o=z(o,r[l],n.context),a&&(f="".concat(""+r[l].l," -> ").concat(""+r[l].r))),a){var m=o.toString({parenthesis:"all"});m!==c&&(console.log("Applying",f,"produced",m),c=m)}N(o,n.context)}s=o.toString({parenthesis:"all"})}return o}function I(e,r,t){var n=e;if(e)for(var i=0;i<e.length;++i){var a=z(e[i],r,t);a!==e[i]&&(n===e&&(n=e.slice()),n[i]=a)}return n}function z(e,r,t){if(r.assuming)for(var n in r.assuming)for(var i in r.assuming[n])if(y(n,i,t)!==r.assuming[n][i])return e;var a=x(r.imposeContext,t),o=e;if(o instanceof d||o instanceof l){var c=I(o.args,r,t);c!==o.args&&((o=o.clone()).args=c)}else if(o instanceof p){if(o.content){var h=z(o.content,r,t);h!==o.content&&(o=new p(h))}}else if(o instanceof s){var v=I(o.items,r,t);v!==o.items&&(o=new s(v))}else if(o instanceof u){var b=o.object;o.object&&(b=z(o.object,r,t));var g=o.index;o.index&&(g=z(o.index,r,t)),b===o.object&&g===o.index||(o=new u(b,g))}else if(o instanceof f){var w=I(o.dimensions,r,t);w!==o.dimensions&&(o=new f(w))}else if(o instanceof m){var D=!1,N={};for(var A in o.properties)N[A]=z(o.properties[A],r,t),N[A]!==o.properties[A]&&(D=!0);D&&(o=new m(N))}var M=r.r,C=U(r.l,o,a)[0];if(!C&&r.expanded&&(M=r.expanded.r,C=U(r.expanded.l,o,a)[0]),!C&&r.expandedNC1&&(M=r.expandedNC1.r,(C=U(r.expandedNC1.l,o,a)[0])||(M=r.expandedNC2.r,C=U(r.expandedNC2.l,o,a)[0])),C){var E=o.implicit;o=M.clone(),E&&"implicit"in M&&(o.implicit=!0),o=o.transform((function(e){return e.isSymbolNode&&Hn(C.placeholders,e.name)?C.placeholders[e.name].clone():e}))}return r.repeat&&o!==e&&(o=z(o,r,t)),o}function j(e,r){var t={placeholders:{}};if(!e.placeholders&&!r.placeholders)return t;if(!e.placeholders)return r;if(!r.placeholders)return e;for(var n in e.placeholders)if(Hn(e.placeholders,n)&&(t.placeholders[n]=e.placeholders[n],Hn(r.placeholders,n)&&!$(e.placeholders[n],r.placeholders[n])))return null;for(var i in r.placeholders)Hn(r.placeholders,i)&&(t.placeholders[i]=r.placeholders[i]);return t}function R(e,r){var t,n=[];if(0===e.length||0===r.length)return n;for(var i=0;i<e.length;i++)for(var a=0;a<r.length;a++)(t=j(e[i],r[a]))&&n.push(t);return n}function U(e,r,t,i){var a=[{placeholders:{}}];if(e instanceof d&&r instanceof d||e instanceof l&&r instanceof l){if(e instanceof d){if(e.op!==r.op||e.fn!==r.fn)return[]}else if(e instanceof l&&e.name!==r.name)return[];if(!(1===r.args.length&&1===e.args.length||!g(r,t)&&r.args.length===e.args.length||i)){if(r.args.length>=2&&2===e.args.length){for(var o=function(e,r){var t,n,i=[],a=A(e);if(b(e,r))for(var o=0;o<e.args.length;o++)(n=e.args.slice(0)).splice(o,1),t=1===n.length?n[0]:a(n),i.push(a([e.args[o],t]));else for(var u=1;u<e.args.length;u++){var s=e.args[0];u>1&&(s=a(e.args.slice(0,u))),t=1===(n=e.args.slice(u)).length?n[0]:a(n),i.push(a([s,t]))}return i}(r,t),u=[],s=0;s<o.length;s++){var f=U(e,o[s],t,!0);u=u.concat(f)}return u}if(e.args.length>2)throw Error("Unexpected non-binary associative function: "+e);return[]}for(var m=[],p=0;p<e.args.length;p++){var y=U(e.args[p],r.args[p],t);if(0===y.length)break;m.push(y)}if(m.length!==e.args.length){if(!b(r,t)||1===e.args.length)return[];if(e.args.length>2)throw Error("permuting >2 commutative non-associative rule arguments not yet implemented");var x=U(e.args[0],r.args[1],t);if(0===x.length)return[];var w=U(e.args[1],r.args[0],t);if(0===w.length)return[];m=[x,w]}a=function(e){if(0===e.length)return e;for(var r=e.reduce(R),t=[],n={},i=0;i<r.length;i++){var a=JSON.stringify(r[i],v);n[a]||(n[a]=!0,t.push(r[i]))}return t}(m)}else if(e instanceof h){if(0===e.name.length)throw Error("Symbol in rule has 0 length...!?");if(B[e.name]){if(e.name!==r.name)return[]}else switch(e.name[1]>="a"&&e.name[1]<="z"?e.name.substring(0,2):e.name[0]){case"n":case"_p":a[0].placeholders[e.name]=r;break;case"c":case"cl":if(!Bn(r))return[];a[0].placeholders[e.name]=r;break;case"v":if(Bn(r))return[];a[0].placeholders[e.name]=r;break;case"vl":if(!Pn(r))return[];a[0].placeholders[e.name]=r;break;case"cd":if(!tx(r))return[];a[0].placeholders[e.name]=r;break;case"vd":if(tx(r))return[];a[0].placeholders[e.name]=r;break;case"ce":if(!nx(r))return[];a[0].placeholders[e.name]=r;break;case"ve":if(nx(r))return[];a[0].placeholders[e.name]=r;break;default:throw Error("Invalid symbol in rule: "+e.name)}}else{if(!(e instanceof c))return[];if(!n(e.value,r.value))return[]}return a}function $(e,r){if(e instanceof c&&r instanceof c){if(!n(e.value,r.value))return!1}else if(e instanceof h&&r instanceof h){if(e.name!==r.name)return!1}else{if(!(e instanceof d&&r instanceof d||e instanceof l&&r instanceof l))return!1;if(e instanceof d){if(e.op!==r.op||e.fn!==r.fn)return!1}else if(e instanceof l&&e.name!==r.name)return!1;if(e.args.length!==r.args.length)return!1;for(var t=0;t<e.args.length;t++)if(!$(e.args[t],r.args[t]))return!1}return!0}return S})),sx=ti("simplifyConstant",["typed","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],(e=>{var{typed:r,config:t,mathWithTransform:n,matrix:i,fraction:a,bignumber:o,AccessorNode:u,ArrayNode:s,ConstantNode:c,FunctionNode:l,IndexNode:f,ObjectNode:m,OperatorNode:d,SymbolNode:p}=e,{isCommutative:h,isAssociative:v,allChildren:y,createMakeNodeFunction:b}=ox({FunctionNode:l,OperatorNode:d,SymbolNode:p}),g=r("simplifyConstant",{Node:e=>N(S(e,{})),"Node, Object":function(e,r){return N(S(e,r))}});function x(e){return an(e)?e.valueOf():e instanceof Array?e.map(x):cn(e)?i(x(e.valueOf())):e}function w(e,r,t){try{return n[e].apply(null,r)}catch(i){return r=r.map(x),M(n[e].apply(null,r),t)}}var D=r({Fraction:function(e){var r=e=>"BigNumber"===t.number&&o?o(e):Number(e),n=e.s*e.n,i=n<0n?new d("-","unaryMinus",[new c(-r(n))]):new c(r(n));return 1n===e.d?i:new d("/","divide",[i,new c(r(e.d))])},number:function(e){return e<0?C(new c(-e)):new c(e)},BigNumber:function(e){return e<0?C(new c(-e)):new c(e)},bigint:function(e){return e<0n?C(new c(-e)):new c(e)},Complex:function(){throw Error("Cannot convert Complex number to Node")},string:function(e){return new c(e)},Matrix:function(e){return new s(e.valueOf().map((e=>D(e))))}});function N(e){return In(e)?e:D(e)}function A(e,r){if(r&&!1!==r.exactFractions&&isFinite(e)&&a){var t=a(e),n=r&&"number"==typeof r.fractionsLimit?r.fractionsLimit:1/0;if(t.valueOf()===e&&t.n<n&&t.d<n)return t}return e}var M=r({"string, Object":function(e,r){var n=ai(e,t);return"BigNumber"===n?(void 0===o&&wm(),o(e)):"bigint"===n?BigInt(e):"Fraction"===n?(void 0===a&&Dm(),a(e)):A(parseFloat(e),r)},"Fraction, Object":function(e){return e},"BigNumber, Object":function(e){return e},"number, Object":function(e,r){return A(e,r)},"bigint, Object":function(e){return e},"Complex, Object":function(e,r){return 0!==e.im?e:A(e.re,r)},"Matrix, Object":function(e){return i(A(e.valueOf()))},"Array, Object":function(e){return e.map(A)}});function C(e){return new d("-","unaryMinus",[e])}function E(e,r,t,n){var i=r.shift(),a=r.reduce(((r,i)=>{if(!In(i)){var a=r.pop();if(In(a))return[a,i];try{return r.push(w(e,[a,i],n)),r}catch(e){r.push(a)}}r.push(N(r.pop()));var o=1===r.length?r[0]:t(r);return[t([o,N(i)])]}),[i]);return 1===a.length?a[0]:t([a[0],D(a[1])])}function S(e,r){switch(e.type){case"SymbolNode":return e;case"ConstantNode":switch(typeof e.value){case"number":case"bigint":return M(e.value,r);case"string":return e.value;default:if(!isNaN(e.value))return M(e.value,r)}return e;case"FunctionNode":if(n[e.name]&&n[e.name].rawArgs)return e;if(!["add","multiply"].includes(e.name)){var t=e.args.map((e=>S(e,r)));if(!t.some(In))try{return w(e.name,t,r)}catch(e){}if("size"===e.name&&1===t.length&&Cn(t[0])){for(var a=[],o=t[0];Cn(o);)a.push(o.items.length),o=o.items[0];return i(a)}return new l(e.name,t.map(N))}case"OperatorNode":var d,p,x=""+e.fn,D=b(e);if(jn(e)&&e.isUnary())p=In((d=[S(e.args[0],r)])[0])?D(d):w(x,d,r);else if(v(e,r.context))if(d=(d=y(e,r.context)).map((e=>S(e,r))),h(x,r.context)){for(var A=[],C=[],F=0;F<d.length;F++)In(d[F])?C.push(d[F]):A.push(d[F]);A.length>1?(p=E(x,A,D,r),C.unshift(p),p=E(x,C,D,r)):p=E(x,d,D,r)}else p=E(x,d,D,r);else d=e.args.map((e=>S(e,r))),p=E(x,d,D,r);return p;case"ParenthesisNode":return S(e.content,r);case"AccessorNode":return function(e,r,t){if(!On(r))return new u(N(e),N(r));if(Cn(e)||cn(e)){for(var n=Array.from(r.dimensions);n.length>0;)if(Bn(n[0])&&"string"!=typeof n[0].value){var a=M(n.shift().value,t);Cn(e)?e=e.items[a-1]:(e=e.valueOf()[a-1])instanceof Array&&(e=i(e))}else{if(!(n.length>1&&Bn(n[1])&&"string"!=typeof n[1].value))break;var o=M(n[1].value,t),l=[],m=Cn(e)?e.items:e.valueOf();for(var d of m)if(Cn(d))l.push(d.items[o-1]);else{if(!cn(e))break;l.push(d[o-1])}if(l.length!==m.length)break;e=Cn(e)?new s(l):i(l),n.splice(1,1)}return n.length===r.dimensions.length?new u(N(e),r):n.length>0?(r=new f(n),new u(N(e),r)):e}if(zn(e)&&1===r.dimensions.length&&Bn(r.dimensions[0])){var p=r.dimensions[0].value;return p in e.properties?e.properties[p]:new c}return new u(N(e),r)}(S(e.object,r),S(e.index,r),r);case"ArrayNode":var B=e.items.map((e=>S(e,r)));return B.some(In)?new s(B.map(N)):i(B);case"IndexNode":return new f(e.dimensions.map((e=>g(e,r))));case"ObjectNode":var q={};for(var T in e.properties)q[T]=g(e.properties[T],r);return new m(q);default:throw Error("Unimplemented node type in simplifyConstant: ".concat(e.type))}}return g})),cx="simplifyCore",lx=ti(cx,["typed","parse","equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:r,equal:t,isZero:n,AccessorNode:i,ArrayNode:a,ConstantNode:o,FunctionNode:u,IndexNode:s,ObjectNode:c,OperatorNode:l,SymbolNode:f}=e,m=new o(0),d=new o(1),p=new o(!0),h=new o(!1);function v(e){return jn(e)&&["and","not","or"].includes(e.op)}var{hasProperty:y,isCommutative:b}=ox({FunctionNode:u,OperatorNode:l,SymbolNode:f});function g(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r?r.context:void 0;if(y(e,"trivial",o)){if(kn(e)&&1===e.args.length)return g(e.args[0],r);var f=!1,x=0;if(e.forEach((e=>{1==++x&&(f=g(e,r))})),1===x)return f}var w=e;if(kn(w)){var D=function(e){var r="OperatorNode:"+e;for(var t of Wv)if(r in t)return t[r].op;return null}(w.name);if(!D)return new u(g(w.fn),w.args.map((e=>g(e,r))));if(w.args.length>2&&y(w,"associative",o))for(;w.args.length>2;){var N=w.args.pop(),A=w.args.pop();w.args.push(new l(D,w.name,[N,A]))}w=new l(D,w.name,w.args)}if(jn(w)&&w.isUnary()){var M=g(w.args[0],r);if("~"===w.op&&jn(M)&&M.isUnary()&&"~"===M.op)return M.args[0];if("not"===w.op&&jn(M)&&M.isUnary()&&"not"===M.op&&v(M.args[0]))return M.args[0];var C=!0;if("-"===w.op&&jn(M)&&(M.isBinary()&&"subtract"===M.fn&&(w=new l("-","subtract",[M.args[1],M.args[0]]),C=!1),M.isUnary()&&"-"===M.op))return M.args[0];if(C)return new l(w.op,w.fn,[M])}if(jn(w)&&w.isBinary()){var E=g(w.args[0],r),S=g(w.args[1],r);if("+"===w.op){if(Bn(E)&&n(E.value))return S;if(Bn(S)&&n(S.value))return E;jn(S)&&S.isUnary()&&"-"===S.op&&(w=new l("-","subtract",[E,S=S.args[0]]))}if("-"===w.op)return jn(S)&&S.isUnary()&&"-"===S.op?g(new l("+","add",[E,S.args[0]]),r):Bn(E)&&n(E.value)?g(new l("-","unaryMinus",[S])):Bn(S)&&n(S.value)?E:new l(w.op,w.fn,[E,S]);if("*"===w.op){if(Bn(E)){if(n(E.value))return m;if(t(E.value,1))return S}if(Bn(S)){if(n(S.value))return m;if(t(S.value,1))return E;if(b(w,o))return new l(w.op,w.fn,[S,E],w.implicit)}return new l(w.op,w.fn,[E,S],w.implicit)}if("/"===w.op)return Bn(E)&&n(E.value)?m:Bn(S)&&t(S.value,1)?E:new l(w.op,w.fn,[E,S]);if("^"===w.op&&Bn(S)){if(n(S.value))return d;if(t(S.value,1))return E}if("and"===w.op){if(Bn(E)){if(!E.value)return h;if(v(S))return S;if(Bn(S))return S.value?p:h}if(Bn(S)){if(!S.value)return h;if(v(E))return E}}if("or"===w.op){if(Bn(E)){if(E.value)return p;if(v(S))return S}if(Bn(S)){if(S.value)return p;if(v(E))return E}}return new l(w.op,w.fn,[E,S])}if(jn(w))return new l(w.op,w.fn,w.args.map((e=>g(e,r))));if(Cn(w))return new a(w.items.map((e=>g(e,r))));if(Mn(w))return new i(g(w.object,r),g(w.index,r));if(On(w))return new s(w.dimensions.map((e=>g(e,r))));if(zn(w)){var F={};for(var B in w.properties)F[B]=g(w.properties[B],r);return new c(F)}return w}return r(cx,{Node:g,"Node,Object":g})})),fx=ti("resolve",["typed","parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],(e=>{var{typed:r,parse:t,ConstantNode:n,FunctionNode:i,OperatorNode:a,ParenthesisNode:o}=e;function u(e,r){var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set;if(!r)return e;if(Pn(e)){if(s.has(e.name)){var c=Array.from(s).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(c,"}"))}var l=r.get(e.name);if(In(l)){var f=new Set(s);return f.add(e.name),u(l,r,f)}return"number"==typeof l?t(l+""):void 0!==l?new n(l):e}if(jn(e)){var m=e.args.map((function(e){return u(e,r,s)}));return new a(e.op,e.fn,m,e.implicit)}if(Rn(e))return new o(u(e.content,r,s));if(kn(e)){var d=e.args.map((function(e){return u(e,r,s)}));return new i(e.name,d)}return e.map((e=>u(e,r,s)))}return r("resolve",{Node:u,"Node, Map | null | undefined":u,"Node, Object":(e,r)=>u(e,Kt(r)),"Array | Matrix":r.referToSelf((e=>r=>r.map((r=>e(r))))),"Array | Matrix, null | undefined":r.referToSelf((e=>r=>r.map((r=>e(r))))),"Array, Object":r.referTo("Array,Map",(e=>(r,t)=>e(r,Kt(t)))),"Matrix, Object":r.referTo("Matrix,Map",(e=>(r,t)=>e(r,Kt(t)))),"Array | Matrix, Map":r.referToSelf((e=>(r,t)=>r.map((r=>e(r,t)))))})})),mx="symbolicEqual",dx=ti(mx,["parse","simplify","typed","OperatorNode"],(e=>{var{simplify:r,typed:t,OperatorNode:n}=e;function i(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=new n("-","subtract",[e,t]),o=r(a,{},i);return Bn(o)&&!o.value}return t(mx,{"Node, Node":i,"Node, Node, Object":i})})),px="derivative",hx=ti(px,["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:r,config:t,parse:n,simplify:i,equal:a,isZero:o,numeric:u,ConstantNode:s,FunctionNode:c,OperatorNode:l,ParenthesisNode:f,SymbolNode:m}=e;function d(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{simplify:!0},n=new Map,a=r.name,o=b(e,(function e(r){var t=n.get(r);if(void 0!==t)return t;var i=y(e,r,a);return n.set(r,i),i}));return t.simplify?i(o):o}function p(e){var r=n(e);if(!r.isSymbolNode)throw new TypeError("Invalid variable. "+"Cannot parse ".concat(JSON.stringify(e)," into a variable in function derivative"));return r}var h=r(px,{"Node, SymbolNode":d,"Node, SymbolNode, Object":d,"Node, string":(e,r)=>d(e,p(r)),"Node, string, Object":(e,r,t)=>d(e,p(r),t)});h._simplify=!0,h.toTex=function(e){return v.apply(null,e.args)};var v=r("_derivTex",{"Node, SymbolNode":function(e,r){return Bn(e)&&"string"===_n(e.value)?v(""+n(e.value),""+r,1):v(e.toTex(),""+r,1)},"Node, ConstantNode":function(e,r){if("string"===_n(r.value))return v(e,n(r.value));throw Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(e,r,t){return v(""+e,r.name,t.value)},"string, string, number":function(e,r,t){return(1===t?"{d\\over d"+r+"}":"{d^{"+t+"}\\over d"+r+"^{"+t+"}}")+"\\left[".concat(e,"\\right]")}}),y=r("_isConst",{"function, ConstantNode, string":function(){return!0},"function, SymbolNode, string":function(e,r,t){return r.name!==t},"function, ParenthesisNode, string":function(e,r,t){return e(r.content,t)},"function, FunctionAssignmentNode, string":function(e,r,t){return!r.params.includes(t)||e(r.expr,t)},"function, FunctionNode | OperatorNode, string":function(e,r,t){return r.args.every((r=>e(r,t)))}}),b=r("_derivative",{"ConstantNode, function":function(){return g(0)},"SymbolNode, function":function(e,r){return r(e)?g(0):g(1)},"ParenthesisNode, function":function(e,r){return new f(b(e.content,r))},"FunctionAssignmentNode, function":function(e,r){return r(e)?g(0):b(e.expr,r)},"FunctionNode, function":function(e,r){if(r(e))return g(0);var t,n,i,a,o=e.args[0],u=!1,s=!1;switch(e.name){case"cbrt":u=!0,n=new l("*","multiply",[g(3),new l("^","pow",[o,new l("/","divide",[g(2),g(3)])])]);break;case"sqrt":case"nthRoot":if(1===e.args.length)u=!0,n=new l("*","multiply",[g(2),new c("sqrt",[o])]);else if(2===e.args.length)return t=new l("/","divide",[g(1),e.args[1]]),b(new l("^","pow",[o,t]),r);break;case"log10":t=g(10);case"log":if(t||1!==e.args.length){if(1===e.args.length&&t||2===e.args.length&&r(e.args[1]))n=new l("*","multiply",[o.clone(),new c("log",[t||e.args[1]])]),u=!0;else if(2===e.args.length)return b(new l("/","divide",[new c("log",[o]),new c("log",[e.args[1]])]),r)}else n=o.clone(),u=!0;break;case"pow":if(2===e.args.length)return b(new l("^","pow",[o,e.args[1]]),r);break;case"exp":n=new c("exp",[o.clone()]);break;case"sin":n=new c("cos",[o.clone()]);break;case"cos":n=new l("-","unaryMinus",[new c("sin",[o.clone()])]);break;case"tan":n=new l("^","pow",[new c("sec",[o.clone()]),g(2)]);break;case"sec":n=new l("*","multiply",[e,new c("tan",[o.clone()])]);break;case"csc":s=!0,n=new l("*","multiply",[e,new c("cot",[o.clone()])]);break;case"cot":s=!0,n=new l("^","pow",[new c("csc",[o.clone()]),g(2)]);break;case"asin":u=!0,n=new c("sqrt",[new l("-","subtract",[g(1),new l("^","pow",[o.clone(),g(2)])])]);break;case"acos":u=!0,s=!0,n=new c("sqrt",[new l("-","subtract",[g(1),new l("^","pow",[o.clone(),g(2)])])]);break;case"atan":u=!0,n=new l("+","add",[new l("^","pow",[o.clone(),g(2)]),g(1)]);break;case"asec":u=!0,n=new l("*","multiply",[new c("abs",[o.clone()]),new c("sqrt",[new l("-","subtract",[new l("^","pow",[o.clone(),g(2)]),g(1)])])]);break;case"acsc":u=!0,s=!0,n=new l("*","multiply",[new c("abs",[o.clone()]),new c("sqrt",[new l("-","subtract",[new l("^","pow",[o.clone(),g(2)]),g(1)])])]);break;case"acot":u=!0,s=!0,n=new l("+","add",[new l("^","pow",[o.clone(),g(2)]),g(1)]);break;case"sinh":n=new c("cosh",[o.clone()]);break;case"cosh":n=new c("sinh",[o.clone()]);break;case"tanh":n=new l("^","pow",[new c("sech",[o.clone()]),g(2)]);break;case"sech":s=!0,n=new l("*","multiply",[e,new c("tanh",[o.clone()])]);break;case"csch":s=!0,n=new l("*","multiply",[e,new c("coth",[o.clone()])]);break;case"coth":s=!0,n=new l("^","pow",[new c("csch",[o.clone()]),g(2)]);break;case"asinh":u=!0,n=new c("sqrt",[new l("+","add",[new l("^","pow",[o.clone(),g(2)]),g(1)])]);break;case"acosh":u=!0,n=new c("sqrt",[new l("-","subtract",[new l("^","pow",[o.clone(),g(2)]),g(1)])]);break;case"atanh":u=!0,n=new l("-","subtract",[g(1),new l("^","pow",[o.clone(),g(2)])]);break;case"asech":u=!0,s=!0,n=new l("*","multiply",[o.clone(),new c("sqrt",[new l("-","subtract",[g(1),new l("^","pow",[o.clone(),g(2)])])])]);break;case"acsch":u=!0,s=!0,n=new l("*","multiply",[new c("abs",[o.clone()]),new c("sqrt",[new l("+","add",[new l("^","pow",[o.clone(),g(2)]),g(1)])])]);break;case"acoth":u=!0,s=!0,n=new l("-","subtract",[g(1),new l("^","pow",[o.clone(),g(2)])]);break;case"abs":n=new l("/","divide",[new c(new m("abs"),[o.clone()]),o.clone()]);break;default:throw Error('Cannot process function "'+e.name+'" in derivative: the function is not supported, undefined, or the number of arguments passed to it are not supported')}u?(i="/",a="divide"):(i="*",a="multiply");var f=b(o,r);return s&&(f=new l("-","unaryMinus",[f])),new l(i,a,[f,n])},"OperatorNode, function":function(e,r){if(r(e))return g(0);if("+"===e.op)return new l(e.op,e.fn,e.args.map((function(e){return b(e,r)})));if("-"===e.op){if(e.isUnary())return new l(e.op,e.fn,[b(e.args[0],r)]);if(e.isBinary())return new l(e.op,e.fn,[b(e.args[0],r),b(e.args[1],r)])}if("*"===e.op){var t=e.args.filter((function(e){return r(e)}));if(t.length>0){var n=e.args.filter((function(e){return!r(e)})),i=1===n.length?n[0]:new l("*","multiply",n),u=t.concat(b(i,r));return new l("*","multiply",u)}return new l("+","add",e.args.map((function(t){return new l("*","multiply",e.args.map((function(e){return e===t?b(e,r):e.clone()})))})))}if("/"===e.op&&e.isBinary()){var s=e.args[0],f=e.args[1];return r(f)?new l("/","divide",[b(s,r),f]):r(s)?new l("*","multiply",[new l("-","unaryMinus",[s]),new l("/","divide",[b(f,r),new l("^","pow",[f.clone(),g(2)])])]):new l("/","divide",[new l("-","subtract",[new l("*","multiply",[b(s,r),f.clone()]),new l("*","multiply",[s.clone(),b(f,r)])]),new l("^","pow",[f.clone(),g(2)])])}if("^"===e.op&&e.isBinary()){var m=e.args[0],d=e.args[1];if(r(m))return Bn(m)&&(o(m.value)||a(m.value,1))?g(0):new l("*","multiply",[e,new l("*","multiply",[new c("log",[m.clone()]),b(d.clone(),r)])]);if(r(d)){if(Bn(d)){if(o(d.value))return g(0);if(a(d.value,1))return b(m,r)}var p=new l("^","pow",[m.clone(),new l("-","subtract",[d,g(1)])]);return new l("*","multiply",[d.clone(),new l("*","multiply",[b(m,r),p])])}return new l("*","multiply",[new l("^","pow",[m.clone(),d.clone()]),new l("+","add",[new l("*","multiply",[b(m,r),new l("/","divide",[d.clone(),m.clone()])]),new l("*","multiply",[b(d,r),new c("log",[m.clone()])])])])}throw Error('Cannot process operator "'+e.op+'" in derivative: the operator is not supported, undefined, or the number of arguments passed to it are not supported')}});function g(e){return new s(u(e,ai(e+"",t)))}return h})),vx="rationalize",yx=ti(vx,["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"],(e=>{var{typed:r,simplifyConstant:t,simplifyCore:n,simplify:i,ConstantNode:a,OperatorNode:o,SymbolNode:u}=e;function s(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=function(){var e=[n,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},t,{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"}],r=[{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)"}],i=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],a={};return a.firstRules=e.concat(r,i),a.distrDivRules=[{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)"}],a.sucDivRules=i,a.firstRulesAgain=e.concat(r),a.finalRules=[n,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},t,{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))"}],a}(),u=function(e,r,t,n){var a=[],o=i(e,n,r,{exactFractions:!1}),u="+-*"+((t=!!t)?"/":"");!function e(r){var t=r.type;if("FunctionNode"===t)throw Error("There is an unsolved function call");if("OperatorNode"===t)if("^"===r.op){if("ConstantNode"!==r.args[1].type||!ii(parseFloat(r.args[1].value)))throw Error("There is a non-integer exponent");e(r.args[0])}else{if(!u.includes(r.op))throw Error("Operator "+r.op+" invalid in polynomial expression");for(var n=0;n<r.args.length;n++)e(r.args[n])}else if("SymbolNode"===t){var i=r.name;-1===a.indexOf(i)&&a.push(i)}else if("ParenthesisNode"===t)e(r.content);else if("ConstantNode"!==t)throw Error("type "+t+" is not allowed in polynomial expression")}(o);var s={};return s.expression=o,s.variables=a,s}(e,r,!0,o.firstRules),s=u.variables.length,f={exactFractions:!1},m={exactFractions:!0};if(e=u.expression,s>=1){var d,p;e=c(e);var h,v=!0,y=!1;for(e=i(e,o.firstRules,{},f);p=v?o.distrDivRules:o.sucDivRules,v=!v,(h=""+(e=i(e,p,{},m)))!==d;)y=!0,d=h;y&&(e=i(e,o.firstRulesAgain,{},f)),e=i(e,o.finalRules,{},f)}var b=[],g={};return"OperatorNode"===e.type&&e.isBinary()&&"/"===e.op?(1===s&&(e.args[0]=l(e.args[0],b),e.args[1]=l(e.args[1])),a&&(g.numerator=e.args[0],g.denominator=e.args[1])):(1===s&&(e=l(e,b)),a&&(g.numerator=e,g.denominator=null)),a?(g.coefficients=b,g.variables=u.variables,g.expression=e,g):e}return r(vx,{Node:s,"Node, boolean":(e,r)=>s(e,{},r),"Node, Object":s,"Node, Object, boolean":s});function c(e,r,t){var n=e.type,i=arguments.length>1;if("OperatorNode"===n&&e.isBinary()){var u,s=!1;if("^"===e.op&&("ParenthesisNode"!==e.args[0].type&&"OperatorNode"!==e.args[0].type||"ConstantNode"!==e.args[1].type||(s=(u=parseFloat(e.args[1].value))>=2&&ii(u))),s){if(u>2){var l=e.args[0],f=new o("^","pow",[e.args[0].cloneDeep(),new a(u-1)]);e=new o("*","multiply",[l,f])}else e=new o("*","multiply",[e.args[0],e.args[0].cloneDeep()]);i&&("content"===t?r.content=e:r.args[t]=e)}}if("ParenthesisNode"===n)c(e.content,e,"content");else if("ConstantNode"!==n&&"SymbolNode"!==n)for(var m=0;m<e.args.length;m++)c(e.args[m],e,m);if(!i)return e}function l(e,r){void 0===r&&(r=[]),r[0]=0;var t=0,n="";!function e(i,a,o){var u=i.type;if("FunctionNode"===u)throw Error("There is an unsolved function call");if("OperatorNode"===u){if(!"+-*^".includes(i.op))throw Error("Operator "+i.op+" invalid");if(null!==a){if(("unaryMinus"===i.fn||"pow"===i.fn)&&"add"!==a.fn&&"subtract"!==a.fn&&"multiply"!==a.fn)throw Error("Invalid "+i.op+" placing");if(("subtract"===i.fn||"add"===i.fn||"multiply"===i.fn)&&"add"!==a.fn&&"subtract"!==a.fn)throw Error("Invalid "+i.op+" placing");if(("subtract"===i.fn||"add"===i.fn||"unaryMinus"===i.fn)&&0!==o.noFil)throw Error("Invalid "+i.op+" placing")}"^"!==i.op&&"*"!==i.op||(o.fire=i.op);for(var s=0;s<i.args.length;s++)"unaryMinus"===i.fn&&(o.oper="-"),"+"!==i.op&&"subtract"!==i.fn||(o.fire="",o.cte=1,o.oper=0===s?"+":i.op),o.noFil=s,e(i.args[s],i,o)}else if("SymbolNode"===u){if(i.name!==n&&""!==n)throw Error("There is more than one variable");if(n=i.name,null===a)return void(r[1]=1);if("^"===a.op&&0!==o.noFil)throw Error("In power the variable should be the first parameter");if("*"===a.op&&1!==o.noFil)throw Error("In multiply the variable should be the second parameter");""!==o.fire&&"*"!==o.fire||(t<1&&(r[1]=0),r[1]+=o.cte*("+"===o.oper?1:-1),t=Math.max(1,t))}else{if("ConstantNode"!==u)throw Error("Type "+u+" is not allowed");var c=parseFloat(i.value);if(null===a)return void(r[0]=c);if("^"===a.op){if(1!==o.noFil)throw Error("Constant cannot be powered");if(!ii(c)||c<=0)throw Error("Non-integer exponent is not allowed");for(var l=t+1;l<c;l++)r[l]=0;return c>t&&(r[c]=0),r[c]+=o.cte*("+"===o.oper?1:-1),void(t=Math.max(c,t))}o.cte=c,""===o.fire&&(r[0]+=o.cte*("+"===o.oper?1:-1))}}(e,null,{cte:1,oper:"+",fire:""});for(var i,s=!0,c=t=r.length-1;c>=0;c--)if(0!==r[c]){var l=new a(s?r[c]:Math.abs(r[c])),f=r[c]<0?"-":"+";if(c>0){var m=new u(n);if(c>1){var d=new a(c);m=new o("^","pow",[m,d])}l=-1===r[c]&&s?new o("-","unaryMinus",[m]):1===Math.abs(r[c])?m:new o("*","multiply",[l,m])}i=s?l:"+"===f?new o("+","add",[i,l]):new o("-","subtract",[i,l]),s=!1}return s?new a(0):i}})),bx="zpk2tf",gx=ti(bx,["typed","add","multiply","Complex","number"],(e=>{var{typed:r,add:t,multiply:n,Complex:i,number:a}=e;return r(bx,{"Array,Array,number":function(e,r,t){return o(e,r,t)},"Array,Array":function(e,r){return o(e,r,1)},"Matrix,Matrix,number":function(e,r,t){return o(e.valueOf(),r.valueOf(),t)},"Matrix,Matrix":function(e,r){return o(e.valueOf(),r.valueOf(),1)}});function o(e,r,t){e.some((e=>"BigNumber"===e.type))&&(e=e.map((e=>a(e)))),r.some((e=>"BigNumber"===e.type))&&(r=r.map((e=>a(e))));for(var o=[i(1,0)],s=[i(1,0)],c=0;c<e.length;c++){var l=e[c];"number"==typeof l&&(l=i(l,0)),o=u(o,[i(1,0),i(-l.re,-l.im)])}for(var f=0;f<r.length;f++){var m=r[f];"number"==typeof m&&(m=i(m,0)),s=u(s,[i(1,0),i(-m.re,-m.im)])}for(var d=0;d<o.length;d++)o[d]=n(o[d],t);return[o,s]}function u(e,r){for(var a=[],o=0;o<e.length+r.length-1;o++){a[o]=i(0,0);for(var u=0;u<e.length;u++)o-u>=0&&o-u<r.length&&(a[o]=t(a[o],n(e[u],r[o-u])))}return a}})),xx="freqz",wx=ti(xx,["typed","add","multiply","Complex","divide","matrix"],(e=>{var{typed:r,add:t,multiply:n,Complex:i,divide:a,matrix:o}=e;return r(xx,{"Array, Array":function(e,r){return u(e,r,s(512))},"Array, Array, Array":function(e,r,t){return u(e,r,t)},"Array, Array, number":function(e,r,t){if(t<0)throw Error("w must be a positive number");return u(e,r,s(t))},"Matrix, Matrix":function(e,r){var t=s(512),{w:n,h:i}=u(e.valueOf(),r.valueOf(),t);return{w:o(n),h:o(i)}},"Matrix, Matrix, Matrix":function(e,r,t){var{h:n}=u(e.valueOf(),r.valueOf(),t.valueOf());return{h:o(n),w:o(t)}},"Matrix, Matrix, number":function(e,r,t){if(t<0)throw Error("w must be a positive number");var n=s(t),{h:i}=u(e.valueOf(),r.valueOf(),n);return{h:o(i),w:o(n)}}});function u(e,r,o){for(var u=[],s=[],c=0;c<o.length;c++){for(var l=i(0,0),f=i(0,0),m=0;m<e.length;m++)l=t(l,n(e[m],i(Math.cos(-m*o[c]),Math.sin(-m*o[c]))));for(var d=0;d<r.length;d++)f=t(f,n(r[d],i(Math.cos(-d*o[c]),Math.sin(-d*o[c]))));u.push(l),s.push(f)}for(var p=[],h=0;h<u.length;h++)p.push(a(u[h],s[h]));return{h:p,w:o}}function s(e){for(var r=[],t=0;t<e;t++)r.push(t/e*Math.PI);return r}})),Dx=ti("reviver",["classes"],(e=>{var{classes:r}=e;return function(e,t){var n=r[t&&t.mathjs];return n&&"function"==typeof n.fromJSON?n.fromJSON(t):t}})),Nx=ti("replacer",[],(()=>function(e,r){return"number"!=typeof r||isFinite(r)&&!isNaN(r)?"bigint"==typeof r?{mathjs:"bigint",value:r+""}:r:{mathjs:"number",value:r+""}})),Ax=ti("true",[],(()=>!0)),Mx=ti("false",[],(()=>!1)),Cx=ti("null",[],(()=>null)),Ex=Px("Infinity",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(1/0):1/0})),Sx=Px("NaN",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(NaN):NaN})),Fx=Px("pi",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?uh(t):Ss})),Bx=Px("tau",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?sh(t):Fs})),qx=Px("e",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?ah(t):Bs})),Tx=Px("phi",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?oh(t):1.618033988749895})),kx=Px("LN2",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(2).ln():Math.LN2})),Ox=Px("LN10",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(10).ln():Math.LN10})),Ix=Px("LOG2E",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(1).div(new t(2).ln()):Math.LOG2E})),zx=Px("LOG10E",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(1).div(new t(10).ln()):Math.LOG10E})),jx=Px("SQRT1_2",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t("0.5").sqrt():Math.SQRT1_2})),Rx=Px("SQRT2",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(2).sqrt():Math.SQRT2})),Ux=Px("i",["Complex"],(e=>{var{Complex:r}=e;return r.I})),$x=ti("version",[],(()=>"14.9.1"));function Px(e,r,t){return ti(e,r,t,{recreateOnConfigChange:!0})}var Lx=Uw("speedOfLight","299792458","m s^-1"),_x=Uw("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),Wx=Uw("planckConstant","6.62607015e-34","J s"),Jx=Uw("reducedPlanckConstant","1.0545718176461565e-34","J s"),Vx=Uw("magneticConstant","1.25663706212e-6","N A^-2"),Hx=Uw("electricConstant","8.8541878128e-12","F m^-1"),Zx=Uw("vacuumImpedance","376.730313667","ohm"),Gx=Uw("coulomb","8.987551792261171e9","N m^2 C^-2"),Xx=Uw("coulombConstant","8.987551792261171e9","N m^2 C^-2"),Yx=Uw("elementaryCharge","1.602176634e-19","C"),Qx=Uw("bohrMagneton","9.2740100783e-24","J T^-1"),Kx=Uw("conductanceQuantum","7.748091729863649e-5","S"),ew=Uw("inverseConductanceQuantum","12906.403729652257","ohm"),rw=Uw("magneticFluxQuantum","2.0678338484619295e-15","Wb"),tw=Uw("nuclearMagneton","5.0507837461e-27","J T^-1"),nw=Uw("klitzing","25812.807459304513","ohm"),iw=Uw("bohrRadius","5.29177210903e-11","m"),aw=Uw("classicalElectronRadius","2.8179403262e-15","m"),ow=Uw("electronMass","9.1093837015e-31","kg"),uw=Uw("fermiCoupling","1.1663787e-5","GeV^-2"),sw=$w("fineStructure",.0072973525693),cw=Uw("hartreeEnergy","4.3597447222071e-18","J"),lw=Uw("protonMass","1.67262192369e-27","kg"),fw=Uw("deuteronMass","3.3435830926e-27","kg"),mw=Uw("neutronMass","1.6749271613e-27","kg"),dw=Uw("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),pw=Uw("rydberg","10973731.568160","m^-1"),hw=Uw("thomsonCrossSection","6.6524587321e-29","m^2"),vw=$w("weakMixingAngle",.2229),yw=$w("efimovFactor",22.7),bw=Uw("atomicMass","1.66053906660e-27","kg"),gw=Uw("avogadro","6.02214076e23","mol^-1"),xw=Uw("boltzmann","1.380649e-23","J K^-1"),ww=Uw("faraday","96485.33212331001","C mol^-1"),Dw=Uw("firstRadiation","3.7417718521927573e-16","W m^2"),Nw=Uw("loschmidt","2.686780111798444e25","m^-3"),Aw=Uw("gasConstant","8.31446261815324","J K^-1 mol^-1"),Mw=Uw("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),Cw=Uw("molarVolume","0.022413969545014137","m^3 mol^-1"),Ew=$w("sackurTetrode",-1.16487052358),Sw=Uw("secondRadiation","0.014387768775039337","m K"),Fw=Uw("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),Bw=Uw("wienDisplacement","2.897771955e-3","m K"),qw=Uw("molarMass","0.99999999965e-3","kg mol^-1"),Tw=Uw("molarMassC12","11.9999999958e-3","kg mol^-1"),kw=Uw("gravity","9.80665","m s^-2"),Ow=Uw("planckLength","1.616255e-35","m"),Iw=Uw("planckMass","2.176435e-8","kg"),zw=Uw("planckTime","5.391245e-44","s"),jw=Uw("planckCharge","1.87554603778e-18","C"),Rw=Uw("planckTemperature","1.416785e+32","K");function Uw(e,r,t){return ti(e,["config","Unit","BigNumber"],(e=>{var{config:n,Unit:i,BigNumber:a}=e,o=new i("BigNumber"===n.number?new a(r):parseFloat(r),t);return o.fixPrefix=!0,o}))}function $w(e,r){return ti(e,["config","BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(r):r}))}function Pw(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}var Lw=ti("mapSlices",["typed","isInteger"],(e=>{var{typed:r,isInteger:t}=e,n=Kc({typed:r,isInteger:t});return r("mapSlices",{"...any":function(e){var r=e[1];en(r)?e[1]=r-1:rn(r)&&(e[1]=r.minus(1));try{return n.apply(null,e)}catch(e){throw Rv(e)}}})}),function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?Pw(Object(t),!0).forEach((function(r){ed(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Pw(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}({isTransformFunction:!0},Kc.meta)),_w=ti("column",["typed","Index","matrix","range"],(e=>{var{typed:r,Index:t,matrix:n,range:i}=e,a=Xf({typed:r,Index:t,matrix:n,range:i});return r("column",{"...any":function(e){var r=e.length-1,t=e[r];en(t)&&(e[r]=t-1);try{return a.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0});function Ww(e,r,t){var n=e.filter((function(e){return Pn(e)&&!(e.name in r)&&!t.has(e.name)}))[0];if(!n)throw Error('No undefined variable found in inline expression "'+e+'"');var i=n.name,a=new Map,o=new Xt(t,a,new Set([i])),u=e.compile();return function(e){return a.set(i,e),u.evaluate(o)}}var Jw=ti("transformCallback",["typed"],(e=>{var{typed:r}=e;return function(e,n){return r.isTypedFunction(e)?t(e,n):Vw(e,e.length,n)};function t(e,n){var i=Object.fromEntries(Object.entries(e.signatures).map((e=>{var[i,a]=e,o=i.split(",").length;return r.isTypedFunction(a)?[i,t(a,n)]:[i,Vw(a,o,n)]})));return"string"==typeof e.name?r(e.name,i):r(i)}}));function Vw(e,r,t){return r===t?e:r===t+1?function(){for(var r=arguments.length,n=Array(r),i=0;i<r;i++)n[i]=arguments[i];var a=n.slice(0,t),o=Hw(n[t]);return e(...a,o)}:r>t+1?function(){for(var r=arguments.length,n=Array(r),i=0;i<r;i++)n[i]=arguments[i];var a=n.slice(0,t),o=Hw(n[t]),u=n.slice(t+1);return e(...a,o,...u)}:e}function Hw(e){return e.map((e=>e+1))}var Zw=ti("filter",["typed"],(e=>{var{typed:r}=e;function t(e,t,i){var a=nm({typed:r}),o=Jw({typed:r});if(0===e.length)return a();var u=e[0];if(1===e.length)return a(u);var s=e.length-1,c=e[s];return u&&(u=n(u,i)),c&&(c=Pn(c)||Tn(c)?n(c,i):Ww(c,t,i)),a(u,o(c,s))}function n(e,r){return e.compile().evaluate(r)}return t.rawArgs=!0,t}),{isTransformFunction:!0}),Gw=ti("forEach",["typed"],(e=>{var{typed:r}=e,t=sm({typed:r}),n=Jw({typed:r});function i(e,r,i){if(0===e.length)return t();var o=e[0];if(1===e.length)return t(o);var u=e.length-1,s=e[u];return o&&(o=a(o,i)),s&&(s=Pn(s)||Tn(s)?a(s,i):Ww(s,r,i)),t(o,n(s,u))}function a(e,r){return e.compile().evaluate(r)}return i.rawArgs=!0,i}),{isTransformFunction:!0}),Xw=ti("index",["Index","getMatrixDataType"],(e=>{var{Index:r,getMatrixDataType:t}=e;return function(){for(var e=[],n=0,i=arguments.length;n<i;n++){var a=arguments[n];if(dn(a))a.start--,a.end-=a.step>0?0:2;else if(a&&!0===a.isSet)a=a.map((function(e){return e-1}));else if(sn(a)||cn(a))"boolean"!==t(a)&&(a=a.map((function(e){return e-1})));else if(en(a)||tn(a))a--;else if(rn(a))a=a.toNumber()-1;else if("string"!=typeof a)throw new TypeError("Dimension must be an Array, Matrix, number, bigint, string, or Range");e[n]=a}var o=new r;return r.apply(o,e),o}}),{isTransformFunction:!0}),Yw=ti("map",["typed"],(e=>{var{typed:r}=e,t=ym({typed:r}),n=Jw({typed:r});function i(e,r,i){if(0===e.length)return t();if(1===e.length)return t(e[0]);var a=e.length-1,o=e.slice(0,a),u=e[a];return o=o.map((e=>s(e,i))),u&&(u=Pn(u)||Tn(u)?s(u,i):Ww(u,r,i)),t(...o,n(u,a));function s(e,r){return e.compile().evaluate(r)}}return i.rawArgs=!0,i}),{isTransformFunction:!0});function Qw(e){if(2===e.length&&ln(e[0])){var r=(e=e.slice())[1];(function(e){return en(e)||rn(e)})(r)&&(e[1]=function(e){return en(e)?e-1:rn(e)?e.minus(1):e}(r))}return e}var Kw=["typed","config","numeric","larger","isNaN"],eD=ti("max",Kw,(e=>{var{typed:r,config:t,numeric:n,larger:i,isNaN:a}=e,o=Xp({typed:r,config:t,numeric:n,larger:i,isNaN:a});return r("max",{"...any":function(e){e=Qw(e);try{return o.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),rD=["typed","add","divide"],tD=ti("mean",rD,(e=>{var{typed:r,add:t,divide:n}=e,i=Ub({typed:r,add:t,divide:n});return r("mean",{"...any":function(e){e=Qw(e);try{return i.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),nD=["typed","config","numeric","smaller","isNaN"],iD=ti("min",nD,(e=>{var{typed:r,config:t,numeric:n,smaller:i,isNaN:a}=e,o=Yp({typed:r,config:t,numeric:n,smaller:i,isNaN:a});return r("min",{"...any":function(e){e=Qw(e);try{return o.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),aD=["typed","config","?matrix","?bignumber","equal","smaller","smallerEq","larger","largerEq","add","isZero","isPositive"],oD=ti("range",aD,(e=>{var{typed:r,config:t,matrix:n,bignumber:i,equal:a,smaller:o,smallerEq:u,larger:s,largerEq:c,add:l,isZero:f,isPositive:m}=e,d=Mm({typed:r,config:t,matrix:n,bignumber:i,equal:a,smaller:o,smallerEq:u,larger:s,largerEq:c,add:l,isZero:f,isPositive:m});return r("range",{"...any":function(e){return"boolean"!=typeof e[e.length-1]&&e.push(!0),d.apply(null,e)}})}),{isTransformFunction:!0}),uD=["typed","Index","matrix","range"],sD=ti("row",uD,(e=>{var{typed:r,Index:t,matrix:n,range:i}=e,a=km({typed:r,Index:t,matrix:n,range:i});return r("row",{"...any":function(e){var r=e.length-1,t=e[r];en(t)&&(e[r]=t-1);try{return a.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),cD=["typed","matrix","zeros","add"],lD=ti("subset",cD,(e=>{var{typed:r,matrix:t,zeros:n,add:i}=e,a=Um({typed:r,matrix:t,zeros:n,add:i});return r("subset",{"...any":function(e){try{return a.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),fD=["typed","matrix","isInteger"],mD=ti("concat",fD,(e=>{var{typed:r,matrix:t,isInteger:n}=e,i=Zf({typed:r,matrix:t,isInteger:n});return r("concat",{"...any":function(e){var r=e.length-1,t=e[r];en(t)?e[r]=t-1:rn(t)&&(e[r]=t.minus(1));try{return i.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),dD="diff",pD=["typed","matrix","subtract","number","bignumber"],hD=ti(dD,pD,(e=>{var{typed:r,matrix:t,subtract:n,number:i,bignumber:a}=e,o=gm({typed:r,matrix:t,subtract:n,number:i,bignumber:a});return r(dD,{"...any":function(e){e=Qw(e);try{return o.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),vD=["typed","map","sqrt","variance"],yD=ti("std",vD,(e=>{var{typed:r,map:t,sqrt:n,variance:i}=e,a=Zb({typed:r,map:t,sqrt:n,variance:i});return r("std",{"...any":function(e){e=Qw(e);try{return a.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),bD=["typed","config","add","numeric"],gD=ti("sum",bD,(e=>{var{typed:r,config:t,add:n,numeric:i}=e,a=Ib({typed:r,config:t,add:n,numeric:i});return r("sum",{"...any":function(e){e=Qw(e);try{return a.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),xD=["typed","bignumber","add","subtract","divide","multiply","partitionSelect","compare","isInteger","smaller","smallerEq","larger","mapSlices"],wD=ti("quantileSeq",xD,(e=>{var{typed:r,bignumber:t,add:n,subtract:i,divide:a,multiply:o,partitionSelect:u,compare:s,isInteger:c,smaller:l,smallerEq:f,larger:m,mapSlices:d}=e,p=Hb({typed:r,bignumber:t,add:n,subtract:i,divide:a,multiply:o,partitionSelect:u,compare:s,isInteger:c,smaller:l,smallerEq:f,larger:m,mapSlices:d});return r("quantileSeq",{"Array | Matrix, number | BigNumber":p,"Array | Matrix, number | BigNumber, number":(e,r,t)=>p(e,r,h(t)),"Array | Matrix, number | BigNumber, boolean":p,"Array | Matrix, number | BigNumber, boolean, number":(e,r,t,n)=>p(e,r,t,h(n)),"Array | Matrix, Array | Matrix":p,"Array | Matrix, Array | Matrix, number":(e,r,t)=>p(e,r,h(t)),"Array | Matrix, Array | Matrix, boolean":p,"Array | Matrix, Array | Matrix, boolean, number":(e,r,t,n)=>p(e,r,t,h(n))});function h(e){return Qw([[],e])[1]}}),{isTransformFunction:!0}),DD="cumsum",ND=["typed","add","unaryPlus"],AD=ti(DD,ND,(e=>{var{typed:r,add:t,unaryPlus:n}=e,i=jb({typed:r,add:t,unaryPlus:n});return r(DD,{"...any":function(e){if(2===e.length&&ln(e[0])){var r=e[1];en(r)?e[1]=r-1:rn(r)&&(e[1]=r.minus(1))}try{return i.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),MD="variance",CD=["typed","add","subtract","multiply","divide","mapSlices","isNaN"],ED=ti(MD,CD,(e=>{var{typed:r,add:t,subtract:n,multiply:i,divide:a,mapSlices:o,isNaN:u}=e,s=Jb({typed:r,add:t,subtract:n,multiply:i,divide:a,mapSlices:o,isNaN:u});return r(MD,{"...any":function(e){e=Qw(e);try{return s.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),SD="print",FD=["typed","matrix","zeros","add"],BD=ti(SD,FD,(e=>{var{typed:r,matrix:t,zeros:n,add:i}=e,a=Nd({typed:r,matrix:t,zeros:n,add:i});return r(SD,{"string, Object | Array":function(e,r){return a(o(e),r)},"string, Object | Array, number | Object":function(e,r,t){return a(o(e),r,t)}});function o(e){return e.replace(wd,(e=>"$"+e.slice(1).split(".").map((function(e){return!isNaN(e)&&e.length>0?parseInt(e)-1:e})).join(".")))}}),{isTransformFunction:!0}),qD=["typed","matrix","zeros","add","equalScalar","not","concat"],TD=ti("and",qD,(e=>{var{typed:r,matrix:t,equalScalar:n,zeros:i,not:a,concat:o}=e,u=dp({typed:r,matrix:t,equalScalar:n,zeros:i,not:a,concat:o});function s(e,r,t){var n=e[0].compile().evaluate(t);if(!ln(n)&&!u(n,!0))return!1;var i=e[1].compile().evaluate(t);return u(n,i)}return s.rawArgs=!0,s}),{isTransformFunction:!0}),kD=["typed","matrix","equalScalar","DenseMatrix","concat"],OD=ti("or",kD,(e=>{var{typed:r,matrix:t,equalScalar:n,DenseMatrix:i,concat:a}=e,o=Jf({typed:r,matrix:t,equalScalar:n,DenseMatrix:i,concat:a});function u(e,r,t){var n=e[0].compile().evaluate(t);if(!ln(n)&&o(n,!1))return!0;var i=e[1].compile().evaluate(t);return o(n,i)}return u.rawArgs=!0,u}),{isTransformFunction:!0}),ID=["typed","matrix","size","flatten","deepEqual"],zD=ti("nullish",ID,(e=>{var{typed:r,matrix:t,size:n,flatten:i,deepEqual:a}=e,o=Wf({typed:r,matrix:t,size:n,flatten:i,deepEqual:a});function u(e,r,t){var n=e[0].compile().evaluate(t);if(!ln(n)&&null!=n&&void 0!==n)return n;var i=e[1].compile().evaluate(t);return o(n,i)}return u.rawArgs=!0,u}),{isTransformFunction:!0}),jD=["typed","matrix","zeros","add","equalScalar","not","concat"],RD=ti("bitAnd",jD,(e=>{var{typed:r,matrix:t,equalScalar:n,zeros:i,not:a,concat:o}=e,u=Ff({typed:r,matrix:t,equalScalar:n,zeros:i,not:a,concat:o});function s(e,r,t){var n=e[0].compile().evaluate(t);if(!ln(n)){if(isNaN(n))return NaN;if(0===n||!1===n)return 0}var i=e[1].compile().evaluate(t);return u(n,i)}return s.rawArgs=!0,s}),{isTransformFunction:!0}),UD=["typed","matrix","equalScalar","DenseMatrix","concat"],$D=ti("bitOr",UD,(e=>{var{typed:r,matrix:t,equalScalar:n,DenseMatrix:i,concat:a}=e,o=kf({typed:r,matrix:t,equalScalar:n,DenseMatrix:i,concat:a});function u(e,r,t){var n=e[0].compile().evaluate(t);if(!ln(n)){if(isNaN(n))return NaN;if(-1===n)return-1;if(!0===n)return 1}var i=e[1].compile().evaluate(t);return o(n,i)}return u.rawArgs=!0,u}),{isTransformFunction:!0}),PD=go({config:Zn}),LD=No({}),_D=qx({BigNumber:PD,config:Zn}),WD=Mx({}),JD=sw({BigNumber:PD,config:Zn}),VD=Lo({}),HD=Ux({Complex:LD}),ZD=Ex({BigNumber:PD,config:Zn}),GD=Ox({BigNumber:PD,config:Zn}),XD=zx({BigNumber:PD,config:Zn}),YD=Wo({}),QD=Sx({BigNumber:PD,config:Zn}),KD=Cx({}),eN=Tx({BigNumber:PD,config:Zn}),rN=_o({}),tN=zi({}),nN=jx({BigNumber:PD,config:Zn}),iN=Ew({BigNumber:PD,config:Zn}),aN=Bx({BigNumber:PD,config:Zn}),oN=Ax({}),uN=$x({}),sN=Ru({Matrix:YD}),cN=yw({BigNumber:PD,config:Zn}),lN=kx({BigNumber:PD,config:Zn}),fN=Fx({BigNumber:PD,config:Zn}),mN=Nx({}),dN=Rx({BigNumber:PD,config:Zn}),pN=Bi({BigNumber:PD,Complex:LD,DenseMatrix:sN,Fraction:VD}),hN=vw({BigNumber:PD,config:Zn}),vN=Yc({typed:pN}),yN=xh({Complex:LD,config:Zn,typed:pN}),bN=Ah({BigNumber:PD,typed:pN}),gN=Sh({BigNumber:PD,Complex:LD,config:Zn,typed:pN}),xN=tl({typed:pN}),wN=jf({typed:pN}),DN=Oh({BigNumber:PD,Complex:LD,config:Zn,typed:pN}),NN=jh({typed:pN}),AN=Rh({typed:pN}),MN=Lh({Complex:LD,config:Zn,typed:pN}),CN=Fc({typed:pN}),EN=qf({typed:pN}),SN=kc({typed:pN}),FN=$u({typed:pN}),BN=Qb({typed:pN}),qN=Ic({Complex:LD,typed:pN}),TN=Uf({typed:pN}),kN=Wh({typed:pN}),ON=Hh({BigNumber:PD,typed:pN}),IN=Xh({BigNumber:PD,typed:pN}),zN=vl({typed:pN}),jN=Cc({config:Zn,typed:pN}),RN=nd({typed:pN}),UN=yl({typed:pN}),$N=gl({Complex:LD,typed:pN}),PN=nm({typed:pN}),LN=om({typed:pN}),_N=sm({typed:pN}),WN=yd({typed:pN}),JN=fm({typed:pN}),VN=xd({format:WN,typed:pN}),HN=$f({typed:pN}),ZN=Gu({typed:pN}),GN=fc({config:Zn,typed:pN}),XN=yc({config:Zn,typed:pN}),YN=gc({equalScalar:jN,typed:pN}),QN=Ix({BigNumber:PD,config:Zn}),KN=og({Complex:LD,typed:pN}),eA=Yl({Complex:LD,config:Zn,typed:pN}),rA=Kl({Complex:LD,config:Zn,typed:pN}),tA=ym({typed:pN}),nA=ef({typed:pN}),iA=Lf({typed:pN}),aA=Sc({typed:pN}),oA=gd({format:WN,typed:pN}),uA=$g({config:Zn,typed:pN}),sA=Nd({typed:pN}),cA=_g({config:Zn,typed:pN}),lA=Pf({typed:pN}),fA=Kh({BigNumber:PD,typed:pN}),mA=uf({BigNumber:PD,Fraction:VD,complex:qN,typed:pN}),dA=tv({typed:pN}),pA=Ec({Matrix:YD,equalScalar:jN,typed:pN}),hA=Vc({typed:pN}),vA=lf({typed:pN}),yA=qc({typed:pN}),bA=il({typed:pN}),gA=av({typed:pN}),xA=Ed({typed:pN}),wA=Nc({typed:pN}),DA=Dh({Complex:LD,config:Zn,typed:pN}),NA=Bh({BigNumber:PD,typed:pN}),AA=Th({BigNumber:PD,Complex:LD,config:Zn,typed:pN}),MA=Oc({BigNumber:PD,typed:pN}),CA=rg({typed:pN}),EA=Vh({typed:pN}),SA=Qh({BigNumber:PD,typed:pN}),FA=wc({typed:pN}),BA=Fd({typed:pN}),qA=Kc({isInteger:ZN,typed:pN}),TA=Rc({DenseMatrix:sN,Matrix:YD,SparseMatrix:pA,typed:pN}),kA=$c({isZero:YN,matrix:TA,typed:pN}),OA=xm({BigNumber:PD,config:Zn,matrix:TA,typed:pN}),IA=Jg({config:Zn,log2:rA,typed:pN}),zA=Em({isInteger:ZN,matrix:TA,typed:pN}),jA=rv({BigNumber:PD,typed:pN}),RA=iv({typed:pN}),UA=vh({SparseMatrix:pA,typed:pN}),$A=sf({Complex:LD,config:Zn,typed:pN}),PA=jm({typed:pN}),LA=ov({typed:pN}),_A=Jm({matrix:TA,typed:pN}),WA=pf({BigNumber:PD,config:Zn,matrix:TA,typed:pN}),JA=Gm({BigNumber:PD,config:Zn,matrix:TA,typed:pN}),VA=Ch({BigNumber:PD,Complex:LD,config:Zn,typed:pN}),HA=zh({Complex:LD,config:Zn,typed:pN}),ZA=bd({format:WN,typed:pN}),GA=Zf({isInteger:ZN,matrix:TA,typed:pN}),XA=Gh({BigNumber:PD,typed:pN}),YA=Hm({conj:TN,transpose:_A,typed:pN}),QA=tm({DenseMatrix:sN,SparseMatrix:pA,matrix:TA,typed:pN}),KA=gf({concat:GA,equalScalar:jN,matrix:TA,multiplyScalar:nA,typed:pN}),eM=Mp({DenseMatrix:sN,SparseMatrix:pA,concat:GA,equalScalar:jN,matrix:TA,typed:pN}),rM=zc({Fraction:VD,typed:pN}),tM=dm({BigNumber:PD,DenseMatrix:sN,SparseMatrix:pA,config:Zn,matrix:TA,typed:pN}),nM=dc({typed:pN}),iM=hm({matrix:TA,multiplyScalar:nA,typed:pN}),aM=Up({DenseMatrix:sN,SparseMatrix:pA,concat:GA,config:Zn,matrix:TA,typed:pN}),oM=sp({DenseMatrix:sN,concat:GA,equalScalar:jN,matrix:TA,typed:pN,zeros:JA}),uM=md({isNaN:FA,isNumeric:nM,typed:pN}),sM=af({BigNumber:PD,concat:GA,equalScalar:jN,matrix:TA,typed:pN}),cM=Bd({bignumber:MA,fraction:rM,number:aA}),lM=hd({config:Zn,multiplyScalar:nA,numeric:cM,typed:pN}),fM=Sm({config:Zn,matrix:TA}),mM=lp({DenseMatrix:sN,concat:GA,equalScalar:jN,matrix:TA,typed:pN,zeros:JA}),dM=zd({BigNumber:PD,DenseMatrix:sN,config:Zn,equalScalar:jN,matrix:TA,typed:pN,zeros:JA}),pM=Im({matrix:TA,config:Zn,typed:pN}),hM=Bp({DenseMatrix:sN,SparseMatrix:pA,bignumber:MA,concat:GA,config:Zn,matrix:TA,typed:pN}),vM=Md({concat:GA,matrix:TA,typed:pN}),yM=Zc({typed:pN}),bM=Wp({DenseMatrix:sN,SparseMatrix:pA,concat:GA,config:Zn,equalScalar:jN,matrix:TA,typed:pN}),gM=Vf({DenseMatrix:sN,SparseMatrix:pA,concat:GA,matrix:TA,typed:pN}),xM=Ev({DenseMatrix:sN,SparseMatrix:pA,addScalar:xN,concat:GA,equalScalar:jN,matrix:TA,typed:pN}),wM=$h({BigNumber:PD,DenseMatrix:sN,concat:GA,equalScalar:jN,matrix:TA,typed:pN}),DM=Ff({concat:GA,equalScalar:jN,matrix:TA,typed:pN}),NM=kf({DenseMatrix:sN,concat:GA,equalScalar:jN,matrix:TA,typed:pN}),AM=zf({DenseMatrix:sN,SparseMatrix:pA,concat:GA,matrix:TA,typed:pN}),MM=ol({BigNumber:PD,Complex:LD,Fraction:VD,config:Zn,isNegative:GN,matrix:TA,typed:pN,unaryMinus:yM}),CM=hp({BigNumber:PD,DenseMatrix:sN,Fraction:VD,concat:GA,config:Zn,equalScalar:jN,matrix:TA,typed:pN}),EM=Np({concat:GA,matrix:TA,typed:pN}),SM=Qf({prod:lM,size:pM,typed:pN}),FM=Lp({equal:eM,typed:pN}),BM=Td({numeric:cM,typed:pN}),qM=Hd({DenseMatrix:sN,SparseMatrix:pA,concat:GA,divideScalar:BM,equalScalar:jN,matrix:TA,typed:pN}),TM=Sp({compareText:EM,isZero:YN,typed:pN}),kM=Sl({DenseMatrix:sN,config:Zn,equalScalar:jN,matrix:TA,round:dM,typed:pN,zeros:JA}),OM=Wl({BigNumber:PD,DenseMatrix:sN,concat:GA,config:Zn,equalScalar:jN,matrix:TA,round:dM,typed:pN,zeros:JA}),IM=hc({isNumeric:nM,typed:pN}),zM=Fv({abs:vN,addScalar:xN,divideScalar:BM,isPositive:XN,multiplyScalar:nA,smaller:hM,sqrt:$A,typed:pN}),jM=Qp({DenseMatrix:sN,smaller:hM}),RM=Kp({ImmutableDenseMatrix:jM,getMatrixDataType:JN}),UM=zp({DenseMatrix:sN,SparseMatrix:pA,bignumber:MA,concat:GA,config:Zn,matrix:TA,typed:pN}),$M=Ud({Complex:LD,config:Zn,divideScalar:BM,typeOf:wA,typed:pN}),PM=Qd({DenseMatrix:sN,divideScalar:BM,equalScalar:jN,matrix:TA,multiplyScalar:nA,subtractScalar:bA,typed:pN}),LM=Wc({flatten:LN,matrix:TA,size:pM,typed:pN}),_M=Xp({config:Zn,isNaN:FA,larger:UM,numeric:cM,typed:pN}),WM=Yp({config:Zn,isNaN:FA,numeric:cM,smaller:hM,typed:pN}),JM=Il({DenseMatrix:sN,concat:GA,config:Zn,equalScalar:jN,matrix:TA,round:dM,typed:pN,zeros:JA}),VM=_d({Complex:LD,config:Zn,divideScalar:BM,typed:pN}),HM=Wf({deepEqual:FM,flatten:LN,matrix:TA,size:pM,typed:pN}),ZM=Jf({DenseMatrix:sN,concat:GA,equalScalar:jN,matrix:TA,typed:pN}),GM=Hp({compare:CM,isNaN:FA,isNumeric:nM,typed:pN}),XM=Ly({addScalar:xN,complex:qN,conj:TN,divideScalar:BM,equal:eM,identity:tM,isZero:YN,matrix:TA,multiplyScalar:nA,sign:mA,sqrt:$A,subtractScalar:bA,typed:pN,unaryMinus:yM,zeros:JA}),YM=mp({DenseMatrix:sN,concat:GA,equalScalar:jN,matrix:TA,typed:pN,zeros:JA}),QM=kp({DenseMatrix:sN,SparseMatrix:pA,concat:GA,config:Zn,matrix:TA,typed:pN}),KM=Um({add:xM,matrix:TA,typed:pN,zeros:JA}),eC=mf({DenseMatrix:sN,concat:GA,equalScalar:jN,matrix:TA,subtractScalar:bA,typed:pN,unaryMinus:yM}),rC=kv({add:xM,matrix:TA,typed:pN}),tC=ep({DenseMatrix:sN,divideScalar:BM,equalScalar:jN,matrix:TA,multiplyScalar:nA,subtractScalar:bA,typed:pN}),nC=Yg({addScalar:xN,combinations:BN,divideScalar:BM,isInteger:ZN,isNegative:GN,multiplyScalar:nA,typed:pN}),iC=xp({compare:CM,typed:pN}),aC=Kg({addScalar:xN,combinations:BN,isInteger:ZN,isNegative:GN,isPositive:XN,larger:UM,typed:pN}),oC=gm({matrix:TA,number:aA,subtract:eC,typed:pN}),uC=kb({abs:vN,addScalar:xN,deepEqual:FM,divideScalar:BM,multiplyScalar:nA,sqrt:$A,subtractScalar:bA,typed:pN}),sC=Tv({addScalar:xN,conj:TN,multiplyScalar:nA,size:pM,typed:pN}),cC=rh({larger:UM,smaller:hM}),lC=Iv({Index:RM,typed:pN}),fC=vf({BigNumber:PD,add:xM,config:Zn,equal:eM,isInteger:ZN,mod:JM,smaller:hM,typed:pN,xgcd:WA}),mC=Vl({concat:GA,equalScalar:jN,matrix:TA,typed:pN}),dC=Pd({Complex:LD,config:Zn,divideScalar:BM,log:$M,typed:pN}),pC=tp({DenseMatrix:sN,divideScalar:BM,equalScalar:jN,matrix:TA,multiplyScalar:nA,subtractScalar:bA,typed:pN}),hC=Lc({flatten:LN,matrix:TA,size:pM,typed:pN}),vC=tf({addScalar:xN,dot:sC,equalScalar:jN,matrix:TA,multiplyScalar:nA,typed:pN}),yC=Mm({bignumber:MA,matrix:TA,add:xM,config:Zn,equal:eM,isPositive:XN,isZero:YN,larger:UM,largerEq:aM,smaller:hM,smallerEq:QM,typed:pN}),bC=km({Index:RM,matrix:TA,range:yC,typed:pN}),gC=sv({DenseMatrix:sN,Index:RM,compareNatural:iC,size:pM,subset:KM,typed:pN}),xC=mv({DenseMatrix:sN,Index:RM,compareNatural:iC,size:pM,subset:KM,typed:pN}),wC=vv({Index:RM,compareNatural:iC,size:pM,subset:KM,typed:pN}),DC=xv({Index:RM,compareNatural:iC,size:pM,subset:KM,typed:pN}),NC=rb({SparseMatrix:pA,abs:vN,add:xM,divideScalar:BM,larger:UM,largerEq:aM,multiply:vC,subtract:eC,transpose:_A,typed:pN}),AC=Gp({compare:CM,compareNatural:iC,matrix:TA,typed:pN}),MC=Xc({config:Zn,numeric:cM,typed:pN}),CC=ip({DenseMatrix:sN,divideScalar:BM,equalScalar:jN,matrix:TA,multiplyScalar:nA,subtractScalar:bA,typed:pN}),EC=gx({Complex:LD,add:xM,multiply:vC,number:aA,typed:pN}),SC=dp({concat:GA,equalScalar:jN,matrix:TA,not:iA,typed:pN,zeros:JA}),FC=pl({DenseMatrix:sN,config:Zn,equalScalar:jN,matrix:TA,round:dM,typed:pN,zeros:JA}),BC=Xf({Index:RM,matrix:TA,range:yC,typed:pN}),qC=em({matrix:TA,multiply:vC,subtract:eC,typed:pN}),TC=vb({divideScalar:BM,isZero:YN,matrix:TA,multiply:vC,subtractScalar:bA,typed:pN,unaryMinus:yM}),kC=Nl({Complex:LD,DenseMatrix:sN,ceil:FC,equalScalar:jN,floor:kM,matrix:TA,typed:pN,zeros:JA}),OC=yb({abs:vN,addScalar:xN,det:TC,divideScalar:BM,identity:tM,matrix:TA,multiply:vC,typed:pN,unaryMinus:yM}),IC=gb({Complex:LD,add:xM,ctranspose:YA,deepEqual:FM,divideScalar:BM,dot:sC,dotDivide:qM,equal:eM,inv:OC,matrix:TA,multiply:vC,typed:pN}),zC=kd({Complex:LD,config:Zn,fraction:rM,identity:tM,inv:OC,matrix:TA,multiply:vC,number:aA,typed:pN}),jC=lv({DenseMatrix:sN,Index:RM,compareNatural:iC,size:pM,subset:KM,typed:pN}),RC=bv({Index:RM,compareNatural:iC,size:pM,subset:KM,typed:pN}),UC=Av({Index:RM,concat:GA,setDifference:jC,size:pM,subset:KM,typed:pN}),$C=th({FibonacciHeap:cC,addScalar:xN,equalScalar:jN}),PC=Ab({abs:vN,add:xM,identity:tM,inv:OC,map:tA,max:_M,multiply:vC,size:pM,sqrt:$A,subtract:eC,typed:pN}),LC=Ib({add:xM,config:Zn,numeric:cM,typed:pN}),_C=mh({BigNumber:PD,Complex:LD,Fraction:VD,abs:vN,addScalar:xN,config:Zn,divideScalar:BM,equal:eM,fix:kC,format:WN,isNumeric:nM,multiplyScalar:nA,number:aA,pow:zC,round:dM,subtractScalar:bA,toBest:xA}),WC=Zx({BigNumber:PD,Unit:_C,config:Zn}),JC=Bw({BigNumber:PD,Unit:_C,config:Zn}),VC=bw({BigNumber:PD,Unit:_C,config:Zn}),HC=Qx({BigNumber:PD,Unit:_C,config:Zn}),ZC=xw({BigNumber:PD,Unit:_C,config:Zn}),GC=Kx({BigNumber:PD,Unit:_C,config:Zn}),XC=Gx({BigNumber:PD,Unit:_C,config:Zn}),YC=bh({Unit:_C,typed:pN}),QC=fw({BigNumber:PD,Unit:_C,config:Zn}),KC=Jd({DenseMatrix:sN,SparseMatrix:pA,concat:GA,equalScalar:jN,matrix:TA,pow:zC,typed:pN}),eE=Hx({BigNumber:PD,Unit:_C,config:Zn}),rE=Yx({BigNumber:PD,Unit:_C,config:Zn}),tE=Db({abs:vN,add:xM,identity:tM,inv:OC,multiply:vC,typed:pN}),nE=ww({BigNumber:PD,Unit:_C,config:Zn}),iE=Xm({addScalar:xN,ceil:FC,conj:TN,divideScalar:BM,dotDivide:qM,exp:UN,i:HD,log2:rA,matrix:TA,multiplyScalar:nA,pow:zC,tau:aN,typed:pN}),aE=ig({BigNumber:PD,Complex:LD,config:Zn,multiplyScalar:nA,pow:zC,typed:pN}),oE=_x({BigNumber:PD,Unit:_C,config:Zn}),uE=cw({BigNumber:PD,Unit:_C,config:Zn}),sE=Qm({conj:TN,dotDivide:qM,fft:iE,typed:pN}),cE=ew({BigNumber:PD,Unit:_C,config:Zn}),lE=nw({BigNumber:PD,Unit:_C,config:Zn}),fE=Nw({BigNumber:PD,Unit:_C,config:Zn}),mE=Vx({BigNumber:PD,Unit:_C,config:Zn}),dE=qw({BigNumber:PD,Unit:_C,config:Zn}),pE=Mw({BigNumber:PD,Unit:_C,config:Zn}),hE=mw({BigNumber:PD,Unit:_C,config:Zn}),vE=tw({BigNumber:PD,Unit:_C,config:Zn}),yE=jw({BigNumber:PD,Unit:_C,config:Zn}),bE=Ow({BigNumber:PD,Unit:_C,config:Zn}),gE=Rw({BigNumber:PD,Unit:_C,config:Zn}),xE=lw({BigNumber:PD,Unit:_C,config:Zn}),wE=dw({BigNumber:PD,Unit:_C,config:Zn}),DE=Jx({BigNumber:PD,Unit:_C,config:Zn}),NE=pw({BigNumber:PD,Unit:_C,config:Zn}),AE=Sw({BigNumber:PD,Unit:_C,config:Zn}),ME=Dv({compareNatural:iC,typed:pN}),CE=Lx({BigNumber:PD,Unit:_C,config:Zn}),EE=Fw({BigNumber:PD,Unit:_C,config:Zn}),SE=hw({BigNumber:PD,Unit:_C,config:Zn}),FE=gw({BigNumber:PD,Unit:_C,config:Zn}),BE=iw({BigNumber:PD,Unit:_C,config:Zn}),qE=Xx({BigNumber:PD,Unit:_C,config:Zn}),TE=qb({divideScalar:BM,equalScalar:jN,inv:OC,matrix:TA,multiply:vC,typed:pN}),kE=ow({BigNumber:PD,Unit:_C,config:Zn}),OE=sg({gamma:aE,typed:pN}),IE=Dw({BigNumber:PD,Unit:_C,config:Zn}),zE=kw({BigNumber:PD,Unit:_C,config:Zn}),jE=Ob({abs:vN,add:xM,addScalar:xN,config:Zn,divideScalar:BM,equalScalar:jN,flatten:LN,isNumeric:nM,isZero:YN,matrix:TA,multiply:vC,multiplyScalar:nA,smaller:hM,subtract:eC,typed:pN}),RE=Py({DenseMatrix:sN,Spa:$C,SparseMatrix:pA,abs:vN,addScalar:xN,divideScalar:BM,equalScalar:jN,larger:UM,matrix:TA,multiplyScalar:nA,subtractScalar:bA,typed:pN,unaryMinus:yM}),UE=rw({BigNumber:PD,Unit:_C,config:Zn}),$E=Tw({BigNumber:PD,Unit:_C,config:Zn}),PE=mg({add:xM,divide:TE,factorial:OE,isInteger:ZN,isPositive:XN,multiply:vC,typed:pN}),LE=pg({factorial:OE,typed:pN}),_E=Iw({BigNumber:PD,Unit:_C,config:Zn}),WE=ob({add:xM,cbrt:MM,divide:TE,equalScalar:jN,im:HN,isZero:YN,multiply:vC,re:lA,sqrt:$A,subtract:eC,typeOf:wA,typed:pN,unaryMinus:yM}),JE=pv({DenseMatrix:sN,Index:RM,compareNatural:iC,size:pM,subset:KM,typed:pN}),VE=td({abs:vN,add:xM,bignumber:MA,divide:TE,isNegative:GN,isPositive:XN,larger:UM,map:tA,matrix:TA,max:_M,multiply:vC,smaller:hM,subtract:eC,typed:pN,unaryMinus:yM}),HE=Hg({bignumber:MA,addScalar:xN,combinations:BN,divideScalar:BM,factorial:OE,isInteger:ZN,isNegative:GN,larger:UM,multiplyScalar:nA,number:aA,pow:zC,subtractScalar:bA,typed:pN}),ZE=ph({Unit:_C,typed:pN}),GE=Gg({addScalar:xN,isInteger:ZN,isNegative:GN,stirlingS2:HE,typed:pN}),XE=jb({add:xM,typed:pN,unaryPlus:MC}),YE=xb({abs:vN,add:xM,addScalar:xN,atan:AN,bignumber:MA,column:BC,complex:qN,config:Zn,cos:kN,diag:QA,divideScalar:BM,dot:sC,equal:eM,flatten:LN,im:HN,inv:OC,larger:UM,matrix:TA,matrixFromColumns:LM,multiply:vC,multiplyScalar:nA,number:aA,qr:XM,re:lA,reshape:zA,sin:dA,size:pM,smaller:hM,sqrt:$A,subtract:eC,typed:pN,usolve:tC,usolveAll:CC}),QE=uw({BigNumber:PD,Unit:_C,config:Zn}),KE=Aw({BigNumber:PD,Unit:_C,config:Zn}),eS=lg({divide:TE,dotDivide:qM,isNumeric:nM,log:$M,map:tA,matrix:TA,multiply:vC,sum:LC,typed:pN}),rS=ib({DenseMatrix:sN,lsolve:PM,lup:RE,matrix:TA,slu:NC,typed:pN,usolve:tC}),tS=Ub({add:xM,divide:TE,typed:pN}),nS=Cw({BigNumber:PD,Unit:_C,config:Zn}),iS=Wx({BigNumber:PD,Unit:_C,config:Zn}),aS=Hb({bignumber:MA,add:xM,compare:CM,divide:TE,isInteger:ZN,larger:UM,mapSlices:qA,multiply:vC,partitionSelect:GM,smaller:hM,smallerEq:QM,subtract:eC,typed:pN}),oS=Cv({Index:RM,concat:GA,setIntersect:JE,setSymDifference:UC,size:pM,subset:KM,typed:pN}),uS=Jb({add:xM,divide:TE,isNaN:FA,mapSlices:qA,multiply:vC,subtract:eC,typed:pN}),sS=aw({BigNumber:PD,Unit:_C,config:Zn}),cS=Pb({add:xM,compare:CM,divide:TE,partitionSelect:GM,typed:pN}),lS=Xb({add:xM,divide:TE,matrix:TA,mean:tS,multiply:vC,pow:zC,sqrt:$A,subtract:eC,sum:LC,typed:pN}),fS=wx({Complex:LD,add:xM,divide:TE,matrix:TA,multiply:vC,typed:pN}),mS=Lb({abs:vN,map:tA,median:cS,subtract:eC,typed:pN}),dS=Zb({map:tA,sqrt:$A,typed:pN,variance:uS}),pS=ld({BigNumber:PD,Complex:LD,add:xM,config:Zn,divide:TE,equal:eM,factorial:OE,gamma:aE,isNegative:GN,multiply:vC,pi:fN,pow:zC,sin:dA,smallerEq:QM,subtract:eC,typed:pN}),hS=qv({abs:vN,add:xM,conj:TN,ctranspose:YA,eigs:YE,equalScalar:jN,larger:UM,matrix:TA,multiply:vC,pow:zC,smaller:hM,sqrt:$A,typed:pN}),vS=Tm({BigNumber:PD,DenseMatrix:sN,SparseMatrix:pA,addScalar:xN,config:Zn,cos:kN,matrix:TA,multiplyScalar:nA,norm:hS,sin:dA,typed:pN,unaryMinus:yM}),yS=zw({BigNumber:PD,Unit:_C,config:Zn}),bS=Sb({identity:tM,matrix:TA,multiply:vC,norm:hS,qr:XM,subtract:eC,typed:pN}),gS=Bm({multiply:vC,rotationMatrix:vS,typed:pN}),xS=Cb({abs:vN,add:xM,concat:GA,identity:tM,index:lC,lusolve:rS,matrix:TA,matrixFromColumns:LM,multiply:vC,range:yC,schur:bS,subset:KM,subtract:eC,transpose:_A,typed:pN}),wS=Bb({matrix:TA,multiply:vC,sylvester:xS,transpose:_A,typed:pN}),DS={},NS={},AS={},MS=jv({mathWithTransform:NS}),CS=by({Node:MS}),ES=wy({Node:MS}),SS=Ny({Node:MS}),FS=Ey({Node:MS}),BS=_v({Node:MS}),qS=ey({Node:MS,ResultSet:tN}),TS=ty({Node:MS}),kS=my({Node:MS}),OS=My({Node:MS}),IS=Dx({classes:AS}),zS=sb({math:DS,typed:pN}),jS=py({Node:MS,typed:pN}),RS=hb({Chain:zS,typed:pN}),US=Pv({Node:MS,subset:KM}),$S=Qv({matrix:TA,Node:MS,subset:KM}),PS=vy({Node:MS,size:pM}),LS=Sy({Unit:_C,Node:MS,math:DS}),_S=By({Node:MS,SymbolNode:LS,math:DS}),WS=Ty({AccessorNode:US,ArrayNode:BS,AssignmentNode:$S,BlockNode:qS,ConditionalNode:TS,ConstantNode:kS,FunctionAssignmentNode:jS,FunctionNode:_S,IndexNode:PS,ObjectNode:CS,OperatorNode:ES,ParenthesisNode:SS,RangeNode:OS,RelationalNode:FS,SymbolNode:LS,config:Zn,numeric:cM,typed:pN}),JS=fx({ConstantNode:kS,FunctionNode:_S,OperatorNode:ES,ParenthesisNode:SS,parse:WS,typed:pN}),VS=sx({bignumber:MA,fraction:rM,AccessorNode:US,ArrayNode:BS,ConstantNode:kS,FunctionNode:_S,IndexNode:PS,ObjectNode:CS,OperatorNode:ES,SymbolNode:LS,config:Zn,mathWithTransform:NS,matrix:TA,typed:pN}),HS=Oy({parse:WS,typed:pN}),ZS=lx({AccessorNode:US,ArrayNode:BS,ConstantNode:kS,FunctionNode:_S,IndexNode:PS,ObjectNode:CS,OperatorNode:ES,ParenthesisNode:SS,SymbolNode:LS,add:xM,divide:TE,equal:eM,isZero:YN,multiply:vC,parse:WS,pow:zC,subtract:eC,typed:pN}),GS=zy({parse:WS,typed:pN}),XS=ub({evaluate:GS}),YS=jy({evaluate:GS,parse:WS}),QS=ux({AccessorNode:US,ArrayNode:BS,ConstantNode:kS,FunctionNode:_S,IndexNode:PS,ObjectNode:CS,OperatorNode:ES,ParenthesisNode:SS,SymbolNode:LS,equal:eM,parse:WS,replacer:mN,resolve:JS,simplifyConstant:VS,simplifyCore:ZS,typed:pN}),KS=dx({OperatorNode:ES,parse:WS,simplify:QS,typed:pN}),eF=rx({parse:WS,typed:pN}),rF=$y({Parser:YS,typed:pN}),tF=yx({bignumber:MA,fraction:rM,AccessorNode:US,ArrayNode:BS,ConstantNode:kS,FunctionNode:_S,IndexNode:PS,ObjectNode:CS,OperatorNode:ES,ParenthesisNode:SS,SymbolNode:LS,add:xM,config:Zn,divide:TE,equal:eM,isZero:YN,mathWithTransform:NS,matrix:TA,multiply:vC,parse:WS,pow:zC,simplify:QS,simplifyConstant:VS,simplifyCore:ZS,subtract:eC,typed:pN}),nF=hx({ConstantNode:kS,FunctionNode:_S,OperatorNode:ES,ParenthesisNode:SS,SymbolNode:LS,config:Zn,equal:eM,isZero:YN,numeric:cM,parse:WS,simplify:QS,typed:pN}),iF=db({Help:XS,mathWithTransform:NS,typed:pN});Pt(DS,{e:_D,false:WD,fineStructure:JD,i:HD,Infinity:ZD,LN10:GD,LOG10E:XD,NaN:QD,null:KD,phi:eN,SQRT1_2:nN,sackurTetrode:iN,tau:aN,true:oN,E:_D,version:uN,efimovFactor:cN,LN2:lN,pi:fN,replacer:mN,reviver:IS,SQRT2:dN,typed:pN,PI:fN,weakMixingAngle:hN,abs:vN,acos:yN,acot:bN,acsc:gN,addScalar:xN,arg:wN,asech:DN,asinh:NN,atan:AN,atanh:MN,bigint:CN,bitNot:EN,boolean:SN,clone:FN,combinations:BN,complex:qN,conj:TN,cos:kN,cot:ON,csc:IN,cube:zN,equalScalar:jN,erf:RN,exp:UN,expm1:$N,filter:PN,flatten:LN,forEach:_N,format:WN,getMatrixDataType:JN,hex:VN,im:HN,isInteger:ZN,isNegative:GN,isPositive:XN,isZero:YN,LOG2E:QN,lgamma:KN,log10:eA,log2:rA,map:tA,multiplyScalar:nA,not:iA,number:aA,oct:oA,pickRandom:uA,print:sA,random:cA,re:lA,sec:fA,sign:mA,sin:dA,splitUnit:hA,square:vA,string:yA,subtractScalar:bA,tan:gA,toBest:xA,typeOf:wA,acosh:DA,acsch:NA,asec:AA,bignumber:MA,chain:RS,combinationsWithRep:CA,cosh:EA,csch:SA,isNaN:FA,isPrime:BA,mapSlices:qA,matrix:TA,matrixFromFunction:kA,ones:OA,randomInt:IA,reshape:zA,sech:jA,sinh:RA,sparse:UA,sqrt:$A,squeeze:PA,tanh:LA,transpose:_A,xgcd:WA,zeros:JA,acoth:VA,asin:HA,bin:ZA,concat:GA,coth:XA,ctranspose:YA,diag:QA,dotMultiply:KA,equal:eM,fraction:rM,identity:tM,isNumeric:nM,kron:iM,largerEq:aM,leftShift:oM,mode:uM,nthRoot:sM,numeric:cM,prod:lM,resize:fM,rightArithShift:mM,round:dM,size:pM,smaller:hM,to:vM,unaryMinus:yM,unequal:bM,xor:gM,add:xM,atan2:wM,bitAnd:DM,bitOr:NM,bitXor:AM,cbrt:MM,compare:CM,compareText:EM,count:SM,deepEqual:FM,divideScalar:BM,dotDivide:qM,equalText:TM,floor:kM,gcd:OM,hasNumericValue:IM,hypot:zM,larger:UM,log:$M,lsolve:PM,matrixFromColumns:LM,max:_M,min:WM,mod:JM,nthRoots:VM,nullish:HM,or:ZM,partitionSelect:GM,qr:XM,rightLogShift:YM,smallerEq:QM,subset:KM,subtract:eC,trace:rC,usolve:tC,catalan:nC,compareNatural:iC,composition:aC,diff:oC,distance:uC,dot:sC,index:lC,invmod:fC,lcm:mC,log1p:dC,lsolveAll:pC,matrixFromRows:hC,multiply:vC,range:yC,row:bC,setCartesian:gC,setDistinct:xC,setIsSubset:wC,setPowerset:DC,slu:NC,sort:AC,unaryPlus:MC,usolveAll:CC,zpk2tf:EC,and:SC,ceil:FC,column:BC,cross:qC,det:TC,fix:kC,inv:OC,pinv:IC,pow:zC,setDifference:jC,setMultiplicity:RC,setSymDifference:UC,sqrtm:PC,sum:LC,vacuumImpedance:WC,wienDisplacement:JC,atomicMass:VC,bohrMagneton:HC,boltzmann:ZC,conductanceQuantum:GC,coulomb:XC,createUnit:YC,deuteronMass:QC,dotPow:KC,electricConstant:eE,elementaryCharge:rE,expm:tE,faraday:nE,fft:iE,gamma:aE,gravitationConstant:oE,hartreeEnergy:uE,ifft:sE,inverseConductanceQuantum:cE,klitzing:lE,loschmidt:fE,magneticConstant:mE,molarMass:dE,molarPlanckConstant:pE,neutronMass:hE,nuclearMagneton:vE,planckCharge:yE,planckLength:bE,planckTemperature:gE,protonMass:xE,quantumOfCirculation:wE,reducedPlanckConstant:DE,rydberg:NE,secondRadiation:AE,setSize:ME,speedOfLight:CE,stefanBoltzmann:EE,thomsonCrossSection:SE,avogadro:FE,bohrRadius:BE,coulombConstant:qE,divide:TE,electronMass:kE,factorial:OE,firstRadiation:IE,gravity:zE,intersect:jE,lup:RE,magneticFluxQuantum:UE,molarMassC12:$E,multinomial:PE,parse:WS,permutations:LE,planckMass:_E,polynomialRoot:WE,resolve:JS,setIntersect:JE,simplifyConstant:VS,solveODE:VE,stirlingS2:HE,unit:ZE,bellNumbers:GE,compile:HS,cumsum:XE,eigs:YE,fermiCoupling:QE,gasConstant:KE,kldivergence:eS,lusolve:rS,mean:tS,molarVolume:nS,planckConstant:iS,quantileSeq:aS,setUnion:oS,simplifyCore:ZS,variance:uS,classicalElectronRadius:sS,evaluate:GS,median:cS,simplify:QS,symbolicEqual:KS,corr:lS,freqz:fS,leafCount:eF,mad:mS,parser:rF,rationalize:tF,std:dS,zeta:pS,derivative:nF,norm:hS,rotationMatrix:vS,help:iF,planckTime:yS,schur:bS,rotate:gS,sylvester:xS,lyap:wS,config:Zn}),Pt(NS,DS,{mapSlices:Lw({isInteger:ZN,typed:pN}),filter:Zw({typed:pN}),forEach:Gw({typed:pN}),map:Yw({typed:pN}),or:OD({DenseMatrix:sN,concat:GA,equalScalar:jN,matrix:TA,typed:pN}),and:TD({add:xM,concat:GA,equalScalar:jN,matrix:TA,not:iA,typed:pN,zeros:JA}),concat:mD({isInteger:ZN,matrix:TA,typed:pN}),index:Xw({Index:RM,getMatrixDataType:JN}),print:BD({add:xM,matrix:TA,typed:pN,zeros:JA}),sum:gD({add:xM,config:Zn,numeric:cM,typed:pN}),bitAnd:RD({add:xM,concat:GA,equalScalar:jN,matrix:TA,not:iA,typed:pN,zeros:JA}),min:iD({config:Zn,isNaN:FA,numeric:cM,smaller:hM,typed:pN}),nullish:zD({deepEqual:FM,flatten:LN,matrix:TA,size:pM,typed:pN}),subset:lD({add:xM,matrix:TA,typed:pN,zeros:JA}),bitOr:$D({DenseMatrix:sN,concat:GA,equalScalar:jN,matrix:TA,typed:pN}),cumsum:AD({add:xM,typed:pN,unaryPlus:MC}),diff:hD({bignumber:MA,matrix:TA,number:aA,subtract:eC,typed:pN}),max:eD({config:Zn,isNaN:FA,larger:UM,numeric:cM,typed:pN}),range:oD({bignumber:MA,matrix:TA,add:xM,config:Zn,equal:eM,isPositive:XN,isZero:YN,larger:UM,largerEq:aM,smaller:hM,smallerEq:QM,typed:pN}),row:sD({Index:RM,matrix:TA,range:yC,typed:pN}),column:_w({Index:RM,matrix:TA,range:yC,typed:pN}),mean:tD({add:xM,divide:TE,typed:pN}),quantileSeq:wD({add:xM,bignumber:MA,compare:CM,divide:TE,isInteger:ZN,larger:UM,mapSlices:qA,multiply:vC,partitionSelect:GM,smaller:hM,smallerEq:QM,subtract:eC,typed:pN}),variance:ED({add:xM,divide:TE,isNaN:FA,mapSlices:qA,multiply:vC,subtract:eC,typed:pN}),std:yD({map:tA,sqrt:$A,typed:pN,variance:uS})}),Pt(AS,{BigNumber:PD,Complex:LD,Fraction:VD,Matrix:YD,Node:MS,ObjectNode:CS,OperatorNode:ES,ParenthesisNode:SS,Range:rN,RelationalNode:FS,ResultSet:tN,ArrayNode:BS,BlockNode:qS,ConditionalNode:TS,ConstantNode:kS,DenseMatrix:sN,RangeNode:OS,Chain:zS,FunctionAssignmentNode:jS,SparseMatrix:pA,ImmutableDenseMatrix:jM,Index:RM,AccessorNode:US,AssignmentNode:$S,FibonacciHeap:cC,IndexNode:PS,Spa:$C,Unit:_C,SymbolNode:LS,FunctionNode:_S,Help:XS,Parser:YS}),zS.createProxy(DS);let aF=!1;async function oF(e){Wr.getI().play(e),Lr(e),e.style.animation="none",mF(e);const r=document.getElementById(Ze);if(!r)return void console.error("No container found with id: lido-container");const t=r.objective,n=r.querySelector(".lido-slide-fill");if(!n)return;const i=OF(e.value,[t]);if(jF(i),i){const e=r.onCorrect;await qF(e,r),100!==JSON.parse(n.fill)||aF?aF=!1:(aF=!0,r.style.pointerEvents="none",r.getAttribute("game-completed")&&"false"!==r.getAttribute("game-completed")&&null!==r.getAttribute("game-completed")&&void 0!==r.getAttribute("game-completed")&&""!==r.getAttribute("game-completed")||(r.setAttribute("game-completed","true"),RF(),HF()))}else{const e=r.onInCorrect;await qF(e,r)}}let uF=0;const sF=[],cF=12,lF=.5;function fF(){aF=!1,uF=0,sF.length=0}function mF(e){const r=document.getElementById(Ze);if(!r)return void console.error("No container found with id: lido-container");Lr(e);const t=r.querySelector(".lido-float");if(!t)return;const n=t.getAttribute("float-direction")||"bottomToTop",i=5*Math.random();if(e.style.position="absolute","leftToRight"===n){const n=t.offsetHeight;e.classList.add("bubble-element"),e.style.left="unset",e.style.right=1600-window.innerWidth+window.innerWidth+e.offsetWidth+"px";const i=Math.max(1,Math.floor(n/Math.max(1,e.clientHeight+cF)));sF.length>i&&(sF.length=i);const a=performance.now(),o=[];for(let e=0;e<i;e++)(sF[e]||0)<=a&&o.push(e);let u=0;u=o.length>0?o[Math.floor(Math.random()*o.length)]:function(e){let r=0,t=1/0;for(let n=0;n<e;n++){const e=sF[n]||0;e<t&&(t=e,r=n)}return r}(i);const s=null!=u?u:0;e.style.top=Math.round(s*(i>1?Math.max(0,n-e.clientHeight)/(i-1):0))+"px",e.style.setProperty("--el-left",e.style.right);const c=e.offsetWidth/(r.offsetWidth/60),l=Math.max(uF,Math.max(0,((sF[s]||0)-a)/1e3));e.style.animation=`float-lr 40s linear ${l}s`,sF[s]=a+1e3*(l+c+lF),uF=0}else{const r=t.offsetWidth;e.style.left=Math.floor(Math.random()*(r-e.clientWidth))+"px";const n=document.body.offsetHeight+e.offsetHeight*(1/cB());e.style.top=n+"px";const a=5+5*Math.random();e.style.setProperty("--el-top",n+"px"),e.style.animation=`float-up ${a}s linear ${i}s`,e.id="removeShadow"}e.addEventListener("animationend",(()=>{e.style.animation="none",mF(e)}),{once:!0})}function dF(e){const r=document.getElementById(Ze).querySelector("#lido-slide-fill");let t=r.fill;t=function(e,r=0){const t=(""+e).trim().replace("%",""),n=parseFloat(t);return isNaN(n)?r:t.startsWith("+")?r>=100?100:Math.min(100,r+n):t.startsWith("-")?r<=0?0:Math.max(0,r+n):Math.max(0,Math.min(100,n))}(e,JSON.parse(t)),r.setAttribute("fill",t)}const pF=e=>new Promise((r=>setTimeout(r,e))),hF=(e,r)=>new Promise((t=>{let n=!1;n||(n=!0,e.isConnected&&e.remove(),0===r.querySelectorAll("[type='calculate']").length&&setTimeout((()=>HF()),2e3),t())}));let vF=0;const yF=async()=>{var e;const r=document.getElementById("lido-container");if(!r)return;const t=(null===(e=r.querySelector("#lidoCalculator"))||void 0===e?void 0:e.getAttribute("value"))||"";if(!t.length)return;const n=r.querySelectorAll("[type='calculate']")[0];if(!n)return;const i="true"===r.getAttribute("is-continue-on-correct"),a=Number(n.value),o=Number(t),u=r.querySelector("#dummy111"),s=r.querySelector("#dummy112");if(i)return void await(async e=>{var r;const t=(null===(r=e.querySelector("#lidoCalculator"))||void 0===r?void 0:r.getAttribute("value"))||"",n=e.querySelectorAll("[type='calculate']")[0];if(!n)return;const i=Number(n.value),a=Number(t);if(i!==a)return;const o=n.string,u=e.querySelector("#dummy111"),s=e.querySelector("#dummy112");await pF(3e3);const c=s.innerHTML;n.innerHTML=o.replaceAll("?",""+a),s.innerHTML=n.innerHTML,await hF(n,e),c&&(u.innerHTML=c)})(r);a===o?vF++:vF>0&&vF--,console.log("SCORE:",vF);const c=n.string;await pF(3e3);const l=s.innerHTML;n.innerHTML=c.replaceAll("?",""+o),s.innerHTML=n.innerHTML,await hF(n,r),l&&(u.innerHTML=l)};function bF(e){let r=Array.from({length:100},((e,r)=>r+1));const t=new Set,n={};let i=0;const a=(e,r)=>10*e+r+1,o=e.querySelectorAll('lido-math-matrix[type="drop"]');for(const e of Array.from(o)){const o=parseInt(e.getAttribute("cols")||"1"),u=parseInt(e.getAttribute("rows")||"1"),s=[];for(let e=0;e<=10-u;e++)for(let r=0;r<=10-o;r++){const n=[];let i=!0;for(let s=0;s<u;s++){for(let u=0;u<o;u++){const o=a(e+s,r+u);if(t.has(o)){i=!1;break}n.push(o)}if(!i)break}i&&s.push(n)}if(0===s.length){console.warn("No space left for matrix "+(i+1));continue}const c=s[Math.floor(Math.random()*s.length)];c.forEach((e=>{t.add(e),r=r.filter((r=>r!==e))})),i++,n["slot-"+i]={cells:c,width:o,height:u}}return n}const gF=(e,r)=>{const t=document.getElementById(Ze),n=Er(t);e.style.transform="translate(0,0)";const i=r.getBoundingClientRect(),a=e.getBoundingClientRect(),o=(i.left+i.width/2-(a.left+a.width/2))/n,u=(i.top+i.height/2-(a.top+a.height/2))/n,s=e.getAttribute("rows")?parseInt(e.getAttribute("rows")):1,c=e.getAttribute("cols")?parseInt(e.getAttribute("cols")):1,l=parseInt(r.style.width);if(1===s||1===c)return s===c?void(e.style.transform=`translate(${o}px, ${u}px)`):void(s>c?10===s?e.style.transform=`translate(${o+(4*l+l/2)}px, ${u}px)`:5===s?e.style.transform=`translate(${o+2*l}px, ${u}px)`:2===s&&(e.style.transform=`translate(${o+l/2}px, ${u}px)`):s<c&&(10===c?e.style.transform=`translate(${o}px, ${u+4*l+.2*l+l/2}px)`:5===c&&(e.style.transform=`translate(${o}px, ${u+2*l+.0921*l}px)`)));if(s===c)return 2===s?void(e.style.transform=`translate(${o+l/2}px, ${u+l/2+4}px)`):void(e.style.transform=`translate(${o+l}px, ${u+l+4}px)`);if(3===s){if(2===c)return void(e.style.transform=`translate(${o+l}px, ${u+l/2+4}px)`);if(1===c)return void(e.style.transform=`translate(${o+l}px, ${u}px)`)}if(2===s){if(3===c)return void(e.style.transform=`translate(${o+l/2}px, ${u+l+4}px)`);if(1===c)return void(e.style.transform=`translate(${o+l/2}px, ${u}px)`)}};function xF(e){const r=Array.from({length:10},((r,t)=>e+1+10*t)),t=r[Math.floor(6*Math.random())];return Array.from({length:5},((e,r)=>t+10*r))}function wF(e=16){const r=[],t=new Set;function n(e,r){return 10*(e-1)+r}for(;r.length<e;){const e=Math.floor(9*Math.random())+1,i=Math.floor(9*Math.random())+1,a=[n(e,i),n(e,i+1),n(e+1,i),n(e+1,i+1)];a.some((e=>t.has(e)))||(a.forEach((e=>t.add(e))),r.push(a))}return r}function DF(e=16){const r=[],t=new Set;function n(e,r){return 10*(e-1)+r}for(;r.length<e;){const e=Math.floor(9*Math.random())+1,i=Math.floor(10*Math.random())+1,a=n(e,i),o=n(e+1,i);t.has(a)||t.has(o)||(r.push([a,o]),t.add(a),t.add(o))}return r}class NF{constructor(){this.startTime=0,this.elapsedTime=0,this.intervalId=null}static getI(e){return NF.instance||(NF.instance=new NF),e&&(NF.instance.onTick=e),NF.instance}start(){this.intervalId||(this.startTime=Date.now()-this.elapsedTime,this.intervalId=window.setInterval((()=>{var e;this.elapsedTime=Date.now()-this.startTime,null===(e=this.onTick)||void 0===e||e.call(this,this.elapsedTime)}),1e3))}pause(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null,this.elapsedTime=Date.now()-this.startTime)}resume(){this.intervalId||this.start()}stop(){var e;this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.startTime=0,this.elapsedTime=0,null===(e=this.onTick)||void 0===e||e.call(this,0)}getElapsed(){return this.intervalId?Date.now()-this.startTime:this.elapsedTime}}let AF=[];const MF=new ur;function CF(){const e={};return document.querySelectorAll(`[${Ve}]`).forEach((r=>{var t,n,i;const a=r.getAttribute(Ve);if(!a)return;const o=document.getElementById(a);if(!o)return;const u=null!==(t=o.getAttribute("tab-index"))&&void 0!==t?t:a;e[u]||(e[u]=[]);const s=null!==(i=null!==(n=r.getAttribute("value"))&&void 0!==n?n:r.value)&&void 0!==i?i:"";e[u].push(s)})),e}function EF(e){return Object.keys(e).sort(((e,r)=>parseInt(e)-parseInt(r))).reduce(((r,t)=>{const n=e[t];return r.push(n.length>1?`(${n.join("|")})`:n[0]),r}),[])}function SF(e,r,t){return(e||"")+(r?" "+r:"")+(t?" "+t:"")}const FF=new Set(["revealImageValue","scrollCellAfterEquationSolved","alignMatch","removeClone","speak","fill-slide","nextBtn","prevBtn","stop","sleep","avatarAnimate","cellBorderAnimate","vibrate","highlightStarsAndDisapper","boxAnimationOneByOne","questionBoxAnimate","slideAnimation","showBalanceSymbol","hideBalanceSymbol","sumTogetherAnimation","addText","disableType","updateCountBlender","updateCalculatorAnswer"]),BF=async(e,r)=>{const t=document.getElementById(Ze);if(!t)return void setTimeout((()=>BF(e,r)),500);const n=e.getAttribute("onEntry"),i="false"!==t.getAttribute("canplay");if(await qF(n,e,void 0,{visualOnly:!i}),"true"===e.getAttribute("move")&&function(e){var r;const t=e;null===(r=t.__lidoMoveCleanup)||void 0===r||r.call(t);const n=(e=>{var r;return null!==(r=e.closest("lido-container"))&&void 0!==r?r:document.getElementById(Ze)})(e);if(!n)return;let i=!1,a=!1,o=0,u=0,s=0,c=0;const l=r=>{if("false"!==n.getAttribute("canplay"))return;const t=r instanceof MouseEvent?r:r.touches[0];if(!t)return;const l=window.getComputedStyle(e);"static"===l.position&&(e.style.position="absolute"),i=!0,a=!1,o=t.clientX,u=t.clientY,s=ut(e.style.left||l.left,e.offsetLeft),c=ut(e.style.top||l.top,e.offsetTop),e.style.cursor="grabbing",e.style.transition="none",e.style.zIndex=e.style.zIndex||e.getAttribute("z")||"1",document.addEventListener("mousemove",f),document.addEventListener("mouseup",d),document.addEventListener("touchmove",f,{passive:!1}),document.addEventListener("touchend",d)},f=r=>{if(!i)return;r.cancelable&&r.preventDefault();const t=r instanceof MouseEvent?r:r.touches[0];if(!t)return;a=!0;const l=(e=>{const r=window.getComputedStyle(e).transform;return r&&"none"!==r&&new DOMMatrixReadOnly(r).a||1})(n),f=c+(t.clientY-u)/l;e.style.left=s+(t.clientX-o)/l+"px",e.style.top=f+"px"},m=()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",d),document.removeEventListener("touchmove",f),document.removeEventListener("touchend",d)},d=()=>{i&&(i=!1,m(),e.style.cursor="move",a&&(e.setAttribute("x",e.style.left),e.setAttribute("y",e.style.top)))},p=e=>{a&&(e.preventDefault(),e.stopPropagation(),a=!1)},h=()=>{i=!1,m(),e.removeEventListener("mousedown",l),e.removeEventListener("touchstart",l),e.removeEventListener("click",p,!0),e.removeEventListener(Ye,h),t.__lidoMoveCleanup===h&&delete t.__lidoMoveCleanup};t.__lidoMoveCleanup=h,e.style.cursor="move",e.style.touchAction="none",e.addEventListener("mousedown",l),e.addEventListener("touchstart",l),e.addEventListener("click",p,!0),e.addEventListener(Ye,h)}(e),i||"click"!==r||$t(e),!i)return;const a=`${r||""}:${i}`;if(e.__lidoInitializationKey!==a){switch(e.__lidoInitializationKey=a,r){case"drag":!function(e){var r;const t=e;null===(r=t.__lidoDragCleanup)||void 0===r||r.call(t);let n=!1,i=!1,a=0,o=0,u=0,s=0,c=null,l=null,f=!1,m=null,d=0,p=0,h=!1,v=!1,y=1,b=1,g=0,x=0,w=0,D=0,N=null,A=!1;const M=document.getElementById(Ze);if(!M)return void console.error('Container with ID "container" not found.');if("false"===M.getAttribute("canplay"))return;let C;rB(e,"drag");const E=()=>{const e=window.getComputedStyle(M).transform,r=e.match(/matrix3d\(([^)]+)\)/),t=e.match(/matrix\(([^)]+)\)/);if(r){const e=r[1].split(",").map((e=>parseFloat(e.trim())));return{scaleX:Math.sqrt(e[0]**2+e[1]**2)||1,scaleY:Math.sqrt(e[4]**2+e[5]**2)||1}}if(t){const e=t[1].split(",").map((e=>parseFloat(e.trim())));return{scaleX:Math.sqrt(e[0]**2+e[1]**2)||1,scaleY:Math.sqrt(e[2]**2+e[3]**2)||1}}return{scaleX:1,scaleY:1}},S=()=>{if(A){const{scaleX:e,scaleY:r}=E();y=e,b=r}},F=r=>{var t,m;if(M&&"true"===M.getAttribute("game-completed"))return;if(C=e.style.transform,Sr)return void(n=!1);if(Wr.getI().stop(),$r(e),n=!0,i=!0,r instanceof MouseEvent)a=r.clientX,o=r.clientY,N=null;else{a=r.touches[0].clientX,o=r.touches[0].clientY,A=!0,N=e.getBoundingClientRect(),g=a-N.left,x=o-N.top,w=N.left,D=N.top;const{scaleX:t,scaleY:n}=E();y=t,b=n,e.style.willChange="transform",window.addEventListener("resize",S)}if(e.style.opacity="1",e.style.cursor="grabbing",(null===(t=e.getAttribute("dropAttr"))||void 0===t?void 0:t.toLowerCase())===ar.Diagonal){const r=window.getComputedStyle(e),t=N||e.getBoundingClientRect();c||(c=e.cloneNode(!0),c.style.left=t.left+"px",c.style.top=t.top+"px",c.style.width=t.width+"px",c.style.height=t.height+"px",c.style.transform=r.transform,c.style.zIndex="0",c.setAttribute("visible","true"),c.classList.add("cloned-element"),document.body.appendChild(c))}if((null===(m=e.getAttribute("dropAttr"))||void 0===m?void 0:m.toLowerCase())===ar.InfiniteDrop){const r=e.querySelector("img"),t=null==r?void 0:r.getAttribute("src"),n=window.getComputedStyle(e),i=N||e.getBoundingClientRect();if(l||(l=e.cloneNode(!1),l.setAttribute("src",t),l.setAttribute("value",e.getAttribute("value")),l.setAttribute("visible","true"),l.style.left=i.left+"px",l.style.top=i.top+"px",l.style.width=i.width+"px",l.style.height=i.height+"px",l.style.transform=n.transform,l.style.position="absolute",l.style.zIndex="0",l.style.pointerEvents="",e.style.zIndex="100",document.body.appendChild(l)),e.getAttribute("droppedelement")){const r=e.getAttribute("droppedelement");document.querySelectorAll(`body > [droppedelement="${r}"]`).forEach((e=>e.remove()))}}const d=window.getComputedStyle(e).transform;if("none"!==d){const e=d.match(/matrix\(([^)]+)\)/);if(e){const r=e[1].split(", ");u=parseFloat(r[4]),s=parseFloat(r[5])}}else u=0,s=0;f&&(M.getBoundingClientRect(),e.getBoundingClientRect()),document.addEventListener("mousemove",k),document.addEventListener("mouseup",z),document.addEventListener("touchmove",k),document.addEventListener("touchend",z)},B=new MutationObserver((r=>{for(const t of r)"attributes"===t.type&&"style"===t.attributeName&&(M.getBoundingClientRect(),e.getBoundingClientRect()),"childList"===t.type&&t.removedNodes.length>0&&t.addedNodes.length>0&&(f=!0)}));B.observe(M,{childList:!0,attributes:!0,attributeFilter:["style"]});const q=(e,r)=>{e.style.opacity!==r&&(e.style.opacity=r)},T=()=>{if(m=null,!n||!h)return;h=!1;const r=v;if(Sr)return n=!1,void(v=!1);if(e.style.transition="none",!v){const r=cB();e.style.transform=`translate(${u+(d-a)/r}px, ${s+(p-o)/r}px)`}if(v=!1,r)return;let t=Br(e,"drop");const i=document.querySelectorAll("[type='drop']"),c=CF(),l=Object.keys(c).map(Number);i.forEach((r=>{var n;l.includes(JSON.parse(r.getAttribute("tab-index")))?((null===(n=e.getAttribute("dropAttr"))||void 0===n?void 0:n.toLowerCase())===ar.Diagonal||Mr(M)||r&&q(r,"0.3"),r!==t&&q(r,"1")):r&&q(r,"1")})),t&&("lido-text"===t.tagName.toLowerCase()?q(t,"0.3"):document.getElementById("unitsDrop")&&document.getElementById("tensDrop")&&document.getElementById("hundredsDrop")||q(t,"0.3"))},k=r=>{if(n)if(Sr)n=!1;else{if(r instanceof MouseEvent)v=!1,d=r.clientX,p=r.clientY;else{const e=r.touches[0];if(!e)return;d=e.clientX,p=e.clientY}r instanceof MouseEvent||(e.style.transition="none",e.style.transform=`translate3d(${u+(d-g-w)/y}px, ${s+(p-x-D)/b}px, 0)`,v=!0),i=!1,r instanceof MouseEvent&&(h=!0,null===m&&(m=requestAnimationFrame(T)))}};let O=null;const I=()=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",z),document.removeEventListener("touchmove",k),document.removeEventListener("touchend",z)},z=()=>{var r,t;if(null!==m&&(cancelAnimationFrame(m),T()),n=!1,A=!1,e.style.willChange="",window.removeEventListener("resize",S),I(),i)return c&&(c.remove(),c=null),void(e.style.opacity="1");e.style.opacity="",e.style.cursor="move";const a=document.querySelectorAll("[type='drop']"),o=CF(),u=Object.keys(o).map(Number);a.forEach((r=>{var t;u.includes(JSON.parse(r.getAttribute("tab-index")))?(null===(t=e.getAttribute("dropAttr"))||void 0===t?void 0:t.toLowerCase())!==ar.Diagonal&&q(r,"1"):r&&q(r,"1")}));let s=Br(e,"drop");if(s)e.style.pointerEvents="none",s.style.pointerEvents="none",s.id===e.getAttribute("drop-to")?e.style.transform=C:kr(e,s),Mr(M)&&e&&s&&(document.querySelectorAll("*").forEach((e=>{$r(e)})),s.classList.add("highlight-element")),qF("this.updateCountBlender='true'",M),setTimeout((()=>{e.style.pointerEvents="",s.style.pointerEvents=""}),1e3),(null===(r=e.getAttribute("dropAttr"))||void 0===r?void 0:r.toLowerCase())===ar.Diagonal&&(s?e&&(e.classList.add("diagonal-drop"),s.classList.add("diagonal-target"),O=s):(O&&(O.classList.remove("diagonal-target"),O=null),null==e||e.classList.remove("diagonal-drop"),e.style.transform="translate(0, 0)",c&&(c.remove(),c=null))),(null===(t=e.getAttribute("dropAttr"))||void 0===t?void 0:t.toLowerCase())===ar.InfiniteDrop&&(s&&(s.style.opacity="0"),e.getAttribute("value")&&e.setAttribute("droppedElement",e.getAttribute("value")+"-dropped"));else{M.getAttribute(Ie);const r=JSON.stringify(CF()),t=CF();JSON.stringify(t);const n=Cr();Tr(e,0,n,null,r)}},j=()=>{if(i){if(M&&"true"===M.getAttribute("game-completed"))return;Ir(e,"drag")}},R=()=>{n=!1,A=!1,e.style.willChange="",window.removeEventListener("resize",S),null!==m&&(cancelAnimationFrame(m),m=null),h=!1,v=!1,B.disconnect(),I(),e.removeEventListener("mousedown",F),e.removeEventListener("touchstart",F),e.removeEventListener("click",j),e.removeEventListener(Ye,R),null==c||c.remove(),c=null,t.__lidoDragCleanup===R&&delete t.__lidoDragCleanup};t.__lidoDragCleanup=R,e.style.cursor="move",e.style.transform="translate(0, 0)",e.classList.add("drag-element"),e.addEventListener("mousedown",F),e.addEventListener("touchstart",F),e.addEventListener("click",j),e.addEventListener(Ye,R)}(e);break;case"click":!function(e){rB(e,"click");const r=document.getElementById(Ze);"false"!==r.getAttribute("canplay")&&("bubbleType"===(null==r?void 0:r.getAttribute("template-id"))&&null!==e.closest("lido-keyboard")||(e.style.cursor="pointer",e?(e.addEventListener("click",(async()=>{var t;if(e===r)return;if("true"===r.getAttribute("game-completed"))return;const n=e.getAttribute("id");if("lido-arrow-left"===n||"lido-arrow-right"===n)return;const i=e.getAttribute("audio"),a=i&&i.trim().length>0;a&&Wr.getI().stop();const o=r.objective.split(","),u=document.querySelector("#lido-checkButton"),s="true"===r.getAttribute("show-check");if("lido-checkButton"==e.getAttribute("id"))return u.classList.add("lido-disable-check-button"),void await JF();if(0===r.objective.length)return;const c=e.classList.contains("lido-element-selected");let l=JSON.parse(null!==(t=r.getAttribute(Ie))&&void 0!==t?t:"[]");if(1===o.length){r.setAttribute(Ie,JSON.stringify([e.value]));const t=o.includes(e.value);if(gr(e,t),t||"false"===r.getAttribute("is-continue-on-correct")){const r=e.getAttribute("onCorrect");await qF(r,e)}else{const r=e.getAttribute("onInCorrect");await qF(r,e)}return _r(),void _F()}if(s&&u.classList.remove("lido-disable-check-button"),c){e.classList.remove("lido-element-selected"),qF(e.getAttribute("onEntry"),e),l=l.filter((r=>r!=e.value)),r.setAttribute(Ie,JSON.stringify([e.value]));let t=CF();const n=e.value,i=Object.keys(t).find((e=>t[e].includes(n)));if(i){t[i]=t[i].filter((e=>e!==n)),0===t[i].length&&delete t[i];const e=Object.keys(t).sort(((e,r)=>parseInt(e)-parseInt(r))).reduce(((e,r)=>e.concat(t[r])),[]);r.setAttribute(Ie,JSON.stringify(e))}s&&0===l.length&&u.classList.add("lido-disable-check-button")}else{{e.classList.add("lido-element-selected");const t=e.value,n=Object.keys(o).find((e=>o[e]===t));let i=CF();n?i[n]=[t]:i[o.length+l.length]=[t];const u=Object.keys(i).sort(((e,r)=>parseInt(e)-parseInt(r))).reduce(((e,r)=>e.concat(i[r])),[]);r.setAttribute(Ie,JSON.stringify(u));const s=o.includes(e.value);if(gr(e,s),a&&Wr.getI().stop(),s){const r=e.getAttribute("onCorrect");await qF(r,e)}else{const r=e.getAttribute("onInCorrect");await qF(r,e)}jF(s)}null!==e.closest("#lidoCalculator")||s||IF(o)!==IF(l)||JF()}})),e.addEventListener("pointerdown",(()=>{"clickable"===e.getAttribute("animation")&&(e.classList.add("removeShadow"),e.style.top="40px",e.style.position="relative")})),e.addEventListener("pointerup",(()=>{"clickable"===e.getAttribute("animation")&&setTimeout((()=>{e.classList.remove("removeShadow"),e.style.top="0px",e.style.position="relative"}),50)})),$t(e)):console.error("No element provided.")))}(e);break;case"drop":!function(e){e.classList.add("drop-element"),CF(),e.getAttribute("tab-index"),e.onclick=()=>{Ir(e,"drop")},rB(e,"drop"),Or(e)}(e);break;case"slide":!function(e){var r;const t=e;null===(r=t.__lidoSlideCleanup)||void 0===r||r.call(t);let n,i,a,o=!1,u=!1,s=0,c=0,l=0,f=0;e.classList.add("drag-element");const m=e.parentElement;if(!m)return void console.error("Parent element not found.");const d=document.getElementById(Ze);if("false"===d.getAttribute("canplay"))return;(e=>{const r=Array.from(e.querySelectorAll("[type='slide']")),t=nt(e,r);e.setAttribute(Ie,JSON.stringify(t))})(d);const p=r=>{const t=d.getAttribute("template-id");if(("arrangeLetters"===t||"reorder"===t)&&"true"===d.getAttribute("game-completed"))return;$r(e),u=!0,n=e.getBoundingClientRect(),i=n.left,a=n.top,r instanceof MouseEvent?(s=r.clientX,c=r.clientY):(s=r.touches[0].clientX,c=r.touches[0].clientY),e.style.opacity="0.8",e.style.cursor="grabbing";const o=window.getComputedStyle(e).transform;if("none"!==o){const e=o.match(/matrix\(([^)]+)\)/);if(e){const r=e[1].split(", ");l=parseFloat(r[4]),f=parseFloat(r[5])}}else l=0,f=0;m.getBoundingClientRect(),e.getBoundingClientRect(),document.addEventListener("mousemove",v),document.addEventListener("mouseup",b),document.addEventListener("touchmove",v),document.addEventListener("touchend",b)},h=new MutationObserver((r=>{for(const t of r)"attributes"===t.type&&"style"===t.attributeName&&(m.getBoundingClientRect(),e.getBoundingClientRect())}));h.observe(m,{attributes:!0,attributeFilter:["style"]});const v=r=>{if(!u)return;const t=Er(m);let n=0,d=0;r instanceof MouseEvent?(n=(r.clientX-s)/t,d=(r.clientY-c)/t):(n=(r.touches[0].clientX-s)/t,d=(r.touches[0].clientY-c)/t);const p=1/cB(),h=l+n*p,v=f+d*p,y=m.getBoundingClientRect(),b=e.getBoundingClientRect(),g=e.style.transform.match(/-?\d+(\.\d+)?/g).map(Number),x=b.left/t-g[0],w=b.top-g[1],D=y.top-w,N=y.bottom-(b.bottom-g[1]);e.style.transform=`translate(${h+x<=y.left?y.left-x:Math.min(h,y.right-(b.right/t-g[0]))}px, ${v+w<=y.top?D:Math.min(v,N)}px)`;let A=Br(e,"slide");if(A&&A!=e){u=!1;const t=e.parentElement,n=A.parentElement,m=A.getBoundingClientRect(),d=document.getElementById(Ze),p=Er(d),h=(i+b.width/2-(m.left+m.width/2))/p,v=(a+b.height/2-(m.top+m.height/2))/p;if(A.style.transition="transform 0.3s ease",e.style.transition="transform 0.3s ease",t&&n){const i=document.createComment("element-placeholder"),a=document.createComment("overlapped-placeholder");A.style.transform=`translate(${h}px, ${v}px)`,e.style.transform=`translate(${-h}px, ${-v}px)`,setTimeout((()=>{t.replaceChild(i,e),n.replaceChild(a,A),t.replaceChild(A,i),n.replaceChild(e,a),A.style.transform="translate(0, 0)",A.style.transition="",e.style.transform="translate(0, 0)",e.style.transition=""}),300),s=r instanceof MouseEvent?r.clientX:r.touches[0].clientX,c=r instanceof MouseEvent?r.clientY:r.touches[0].clientY,l=0,f=0,o=!0}}},y=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",b),document.removeEventListener("touchmove",v),document.removeEventListener("touchend",b)},b=()=>{u=!1,y(),e.style.opacity="",e.style.cursor="move",e.style.transform="translate(0, 0)",setTimeout((()=>{o&&(at(e),o=!1)}),300)},g=()=>{u=!1,h.disconnect(),y(),e.removeEventListener("mousedown",p),e.removeEventListener("touchstart",p),e.removeEventListener(Ye,g),t.__lidoSlideCleanup===g&&delete t.__lidoSlideCleanup};t.__lidoSlideCleanup=g,e.style.cursor="move",e.style.transform="translate(0, 0)",e.addEventListener("mousedown",p),e.addEventListener("touchstart",p),e.addEventListener(Ye,g)}(e);break;case"word":case"option":!function(e){let r=!1,t=!1,n=0,i=0,a=0,o=0;const u=document.getElementById(Ze);if(!u||"false"===u.getAttribute("canplay"))return;Array.from(e.children).forEach((e=>{e.style.pointerEvents="none"}));const s=document.querySelector('[type="blank"]'),c=e.parentElement!==s?e.parentElement:null,l=e.getAttribute("type"),f=u.querySelector('[type="optionArea"]');if(f&&(f.style.overflowY="auto"),!u)return void console.error('Container with ID "lido-container" not found.');const m=c=>{const f=Gr(c);if(!r&&(Math.abs(f.clientX-a)>5||Math.abs(f.clientY-o)>5)){if(r=!0,e.parentElement!==s&&"word"===l){const r=Vr(e);e.parentElement.insertBefore(r,e.nextElementSibling)}if("category"!==e.parentElement.getAttribute("type")&&"option"===l){const r=Vr(e);r.setAttribute("value",""+e.getAttribute("value")),r.style.visibility="hidden",e.parentElement.insertBefore(r,e.nextElementSibling)}const t=u.getBoundingClientRect(),a=function(e){const r=window.getComputedStyle(e).transform;if(r&&"none"!==r){const e=r.match(/matrix\(([^)]+)\)/);if(e)return e[1].split(",").map((e=>parseFloat(e.trim())))[0]}return 1}(u),o=(f.clientY-t.top-i)/a;e.style.left=(f.clientX-t.left-n)/a+"px",e.style.top=o+"px";const c=e.getBoundingClientRect();n=f.clientX-c.left,i=f.clientY-c.top,e.style.opacity="0.8",e.style.cursor="grabbing",e.style.position="absolute",e.style.zIndex="9999",e.style.touchAction="none",e.style.transition="none"}if(!r)return;t=!1,c.preventDefault();const m=u.getBoundingClientRect(),d=cB(),p=(f.clientY-m.top-i)/d;let h;if(e.style.left=(f.clientX-m.left-n)/d+"px",e.style.top=p+"px","option"===l)h=Zr(e,"option")||Zr(e,"dummy");else if(h=Zr(e,"word")||Zr(e,"dummy"),h&&h.parentElement!==document.querySelector('[type="blank"]'))return;h&&"dummy"===h.getAttribute("type")||null!==Jr&&Jr===h||(function(e,r){var t,n;if(e===r)return;if(r&&"option"===r.getAttribute("type")&&"category"!==r.parentElement.getAttribute("type"))return;if("word"===e.getAttribute("type")&&!Zr(e,"blank"))return;if("option"===e.getAttribute("type")&&!Zr(e,"category"))return;const i=document.querySelector('[type="blank"]'),a=document.querySelector('[type="dummy"]');if(a)if(r)null===(t=r.parentNode)||void 0===t||t.insertBefore(a,r);else{const r=Zr(e,"category");r?r.appendChild(a):i.appendChild(a)}else{const t=Vr(e);t.style.visibility="hidden",t.setAttribute("type","dummy");const a=`\n @keyframes widthIncrease {\n 0% { width: 0px; height: 0px; }\n 100% { width: ${e.offsetWidth}px; height: ${e.offsetHeight}px;}\n }\n `;if(r)null===(n=r.parentNode)||void 0===n||n.insertBefore(t,r);else{const r=Zr(e,"category");r?r.appendChild(t):i.appendChild(t)}const o=document.styleSheets[0];o.insertRule(a,o.cssRules.length),t.style.animation="widthIncrease 0.5s",t.addEventListener("animationend",(()=>{t.style.width=e.offsetWidth+"px",t.style.height=e.offsetHeight+"px"}))}}(e,h),Jr=h)},d=()=>{r=!1,document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",d),document.removeEventListener("touchmove",m),document.removeEventListener("touchend",d);const n=document.querySelector('[type="dummy"]');if(t)p(e);else if("option"!==l){if(Zr(e,"blank")&&n&&n.replaceWith(e),c){const r=Array.from(c.children);(function(e,r){const t=e.getBoundingClientRect(),n=r.getBoundingClientRect();return!(t.right<n.left||t.left>n.right||t.bottom<n.top||t.top>n.bottom)}(e,c)||e.parentElement===c)&&r.forEach((r=>{r!==e&&r.getAttribute("value")===e.getAttribute("value")&&r.replaceWith(e)}))}Hr(e),Jr=null,Yr(s,e)}else{const r=Zr(e,"category"),t=Array.from(u.querySelectorAll(`[value="${e.getAttribute("value")}"]`)).find((r=>r!==e&&"DIV"===r.tagName));if(r){if(n&&(n.replaceWith(e),r.parentElement.classList.add("highlight-element"),u.querySelectorAll('[type="category"]').forEach((e=>{e!==r&&e.parentElement.classList.remove("highlight-element")})),Kr(e,r)),t){const e=document.styleSheets[0];e.insertRule(`\n @keyframes widthDecrease {\n 0% { width: ${t.offsetWidth}px; height: ${t.offsetHeight}px; }\n 100% { width: 0px; height: 0px;}\n }\n `,e.cssRules.length),t.style.animation="widthDecrease 0.5s",t.addEventListener("animationend",(()=>{t.remove()}))}Hr(e)}else if("category"!==e.parentElement.type)qr(e,t,u),setTimeout((()=>{t.replaceWith(e),Hr(e)}),500);else{const r=e.parentElement,t=CF(),i=r.getAttribute("tab-index"),a=e.value;if(t[i]){t[i]=t[i].filter((e=>e!==a));const e=EF(t);u.setAttribute(Ie,JSON.stringify(e))}f.scrollTo({top:f.scrollHeight,behavior:"smooth"}),f.appendChild(e),e.classList.remove("dropped"),e.classList.remove("category-dropped-onCorrect"),e.classList.remove("category-dropped-onInCorrect"),e.removeAttribute("drop-to"),n&&n.remove(),Hr(e)}}},p=e=>{const r=document.getElementById(Ze);if("false"!==r.getAttribute("canplay")){if("option"===l){const t=r.querySelectorAll('[type="category"]');let n=Array.from(t).find((e=>e.parentElement.className.includes("highlight-element")));if(n||(n=t[0]),"category"===e.parentElement.getAttribute("type")){const r=CF(),t=n.getAttribute("tab-index"),i=e.value;r[t]&&(r[t]=r[t].filter((e=>e!==i)));const a=Vr(e);return f.appendChild(a),f.scrollTo({top:f.scrollHeight,behavior:"smooth"}),e.style.position="absolute",qF("this.alignMatch='true'",a,e),void setTimeout((()=>{Hr(e),a.replaceWith(e),e.classList.remove("dropped"),e.classList.remove("category-dropped-onCorrect"),e.classList.remove("category-dropped-onInCorrect"),e.removeAttribute("drop-to")}),100)}{const r=Vr(e);return n.appendChild(r),e.style.position="absolute",qF("this.alignMatch=true",r,e),void setTimeout((()=>{r.replaceWith(e),Hr(e),Kr(e,n),e.style.transform="translate(0,0)",e.style.marginBottom="10px"}),100)}}if("word"===l&&e.parentElement===c){const r=Vr(e);return r.style.visibility="hidden",s.appendChild(r),qF("this.alignMatch=true",r,e),void setTimeout((()=>{const t=Vr(e);e.parentElement.insertBefore(t,e.nextElementSibling),r.replaceWith(e),e.style.transform="translate(0,0)",Yr(s,e)}),500)}{const r=Array.from(c.children).find((r=>r.getAttribute("value")===e.getAttribute("value")));qF("this.alignMatch=true",r,e),setTimeout((()=>{r.replaceWith(e),e.style.transform="translate(0,0)"}),500)}}};e.style.cursor="move",e.classList.add("drag-element"),e.addEventListener("pointerdown",(e=>{if(e.target.closest(".lido-speak-icon"))return;t=!0,r=!1;const n=Gr(e);a=n.clientX,o=n.clientY,document.addEventListener("mousemove",m),document.addEventListener("mouseup",d),document.addEventListener("touchmove",m,{passive:!1}),document.addEventListener("touchend",d)}))}(e);break;case"optionArea":!function(e){Array.from(e.children).forEach((e=>{e.classList.add("drag-element")}))}(e);break;case"checkerBlock":!function(e){const r=document.querySelector(Ze);if(!r)return;const t=e;((e,r)=>{const t=r.querySelector(".slot").style.width,n=e.querySelectorAll('lido-math-matrix[type="drop"]');e.querySelectorAll('lido-math-matrix[type="drag"]').forEach((e=>{Array.from(e.querySelectorAll(".slot")).forEach((e=>{const r=e;r.parentElement.style.width=t,r.style.width=t,r.style.height=t}))})),n.forEach((e=>{Array.from(e.querySelectorAll(".slot")).forEach((e=>{const r=e;r.parentElement.style.width=t,r.style.width=t,r.style.height=t}))}))})(r,t),((e,r)=>{const t=r.querySelectorAll(".slot"),n=e.querySelectorAll('lido-math-matrix[type="drop"]'),i=e.querySelectorAll('lido-math-matrix[type="drag"]');let a=1;for(let r=0;r<n.length;r++){const o=n[r],u=o.getAttribute("rows")?parseInt(o.getAttribute("rows")):1,s=o.getAttribute("cols")?parseInt(o.getAttribute("cols")):1;if(1===u||1===s){if(u===s){const e=Array.from({length:100},((e,r)=>r+1)).sort((()=>Math.random()-.5)).slice(0,10);n.forEach(((r,n)=>{const a=t[e[n]];a&&(gF(r,a),i[n].setAttribute("text",""+(e[n]+1)))}))}if(2===u&&1===s){const e=DF(10);n.forEach(((r,n)=>{gF(r,t[e[n][0]-1])})),i.forEach(((r,t)=>{r.setAttribute("text",""+e[t])}));break}if(5===u){const e=xF(r),n=t[e[0]-1];i[r].setAttribute("text",""+e),gF(o,n)}if(10===u){const e=t[a];i[r].setAttribute("text",""+Array.from({length:10},((e,r)=>a+1+10*r))),gF(o,e),a+=2}else if(10===s){const e=t[a-1+10];i[r].setAttribute("text",""+Array.from({length:10},((e,r)=>r+10+a))),gF(o,e),a+=20}}else{if(3===u||3===s){const r=bF(e),a=Object.keys(r).map((e=>r[e].cells));i.forEach(((e,r)=>{e&&e.setAttribute("text",""+a[r])})),n.forEach(((e,n)=>{gF(e,t[r["slot-"+(n+1)].cells[0]-1])}));break}if((2===u||2===s)&&u===s){const e=wF(10);n.forEach(((r,n)=>{gF(r,t[e[n][0]-1])})),i.forEach(((r,t)=>{r.setAttribute("text",""+e[t])}));break}}}})(r,t)}(e)}!function(e){if(!e)return;const r=e.getAttribute("onTouch");let t=null,n=!1;e.addEventListener("pointerdown",(r=>{r.stopPropagation(),n=!1,t=setTimeout((()=>{(async()=>{const r=document.getElementById(Ze);if(e===r)return;const t=e.hasAttribute("disable-speak")||e.hasAttribute("disableSpeak");if(n=!0,Fr(!0),!t)return await Wr.getI().play(e),void Fr(!1);"true"===e.getAttribute("disable-speak")||e.hasAttribute("disable-speak")&&"false"!==e.getAttribute("disable-speak")||(await Wr.getI().play(e),Fr(!1))})()}),1e3)})),e.addEventListener("pointerup",(async()=>{clearTimeout(t),!n&&r?await qF(r,e):r||["category","option"].includes(e.getAttribute("type")||"")&&e.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0})),Fr(!1)})),e.addEventListener("pointerleave",(()=>{clearTimeout(t)}))}(e)}},qF=async(e,r,t,n={})=>{var i,a,o,u,s,c,l,f;const m=kF(e);for(let e=0;e<m.length;e++){const d=m[e];if(n.visualOnly&&FF.has(d.action))continue;const p=document.querySelector(d.actor),h="this"===d.actor?r:"element"===d.actor?t:p||document.getElementById(d.actor);if(h)switch(d.action){case"transform":{const e=window.getComputedStyle(h).transform;h.style.transform="none"!==e?`${e} ${d.value}`:d.value;break}case"revealImageValue":h&&pB(h);break;case"scrollCellAfterEquationSolved":h&&yF();break;case"alignMatch":{const e=h,r=t,n=document.getElementById(Ze),a=Er(n);r.style.transform="translate(0,0)";const o=e.getBoundingClientRect(),u=r.getBoundingClientRect(),s=(o.left+o.width/2-(u.left+u.width/2))/a,c=(o.top+o.height/2-(u.top+u.height/2))/a;if(r.style.transform=(null===(i=t.getAttribute("dropAttr"))||void 0===i?void 0:i.toLowerCase())===ar.Diagonal?`translate(${s-70}px, ${c-70}px)`:`translate(${s}px, ${c}px)`,"true"===r.getAttribute("hasDummy"))return;TF(r,e);break}case"removeClone":document.querySelectorAll(d.value).forEach((e=>e.remove()));break;case"addClass":h.classList.add(d.value);break;case"removeClass":h.classList.remove(d.value);break;case"speak":{const e=(""+(d.value||"")).trim().toLowerCase();if("true"===e||"1"===e||"yes"===e)try{await Wr.getI().play(h)}catch(e){console.error("Error playing audio for speak action:",e)}break}case"fill-slide":dF(d.value);break;case"nextBtn":{const e=document.getElementById(Ze);if("false"===e.getAttribute("canplay"))return;document.querySelector("lido-balance")&&(WF=Nr(e,e.objective),WF?await qF("this.showBalanceSymbol='true'",h):await qF("this.hideBalanceSymbol='true'",h)),"true"!==e.getAttribute("is-continue-on-correct")&&(h.style.pointerEvents="none",Wr.getI().stop()),e.getAttribute("game-completed")&&"false"!==e.getAttribute("game-completed")||await JF(),h.style.pointerEvents="auto";break}case"prevBtn":ZF();break;case"stop":await Wr.getI().stop();break;case"sleep":!isNaN(Number(d.value))&&await new Promise((e=>setTimeout(e,Number(d.value))));break;case"avatarAnimate":{const e=xr.getInstance().getRiveInstance();if(e&&d.value){const r=null===(a=e.stateMachineInputs("State Machine 1"))||void 0===a?void 0:a.find((e=>e.name===d.value));r?r.fire():console.warn(`Avatar reaction input "${d.value}" was not found in State Machine 1.`)}break}case"cellBorderAnimate":{const e=d.value;e&&h&&uB(h,e);break}case"vibrate":{const e=d.value;e&&h&&await sB(h,e);break}case"highlightStarsAndDisapper":{const e=d.value;e&&h&&await vB(h,e);break}case"boxAnimationOneByOne":{const e=d.value;e&&h&&await yB(h,e);break}case"questionBoxAnimate":{const e=d.value;e&&h&&await bB(h,e);break}case"slideAnimation":it();break;case"showBalanceSymbol":{const e=document.querySelector("lido-balance");if(!e)break;const r=Number(null!==(o=e.leftVal)&&void 0!==o?o:Number(null!==(s=null===(u=e.dataset)||void 0===u?void 0:u.leftVal)&&void 0!==s?s:0)),t=Number(null!==(c=e.rightVal)&&void 0!==c?c:Number(null!==(f=null===(l=e.dataset)||void 0===l?void 0:l.rightVal)&&void 0!==f?f:0)),n=r>t?">":r<t?"<":"=";e.balanceSymbol=n,e.dataset.balanceSymbol=n,e.revealSymbol?await e.revealSymbol():e.showSymbol=!0;break}case"hideBalanceSymbol":{const e=document.querySelector("lido-balance");if(!e)break;e.hideSymbol?await e.hideSymbol():e.showSymbol=!1;break}case"sumTogetherAnimation":{const e=d.value;e&&gB(h,e);break}case"addText":{const e=d.value;e&&(h.textContent+=e);break}case"disableType":{const e=document.querySelector('[type="drag"]');e.removeAttribute("type"),e.style.pointerEvents="none";break}case"updateCountBlender":{const e=document.querySelectorAll('[type="drag"]');let r=0,t=0,n=0;e.forEach((e=>{const i=e.getAttribute("drop-to");"unitsDrop"===i&&r++,"tensDrop"===i&&t++,"hundredsDrop"===i&&n++}));const i=r,a=t,o=n,u=document.getElementById("units"),s=document.getElementById("tens"),c=document.getElementById("hundreds");u&&u.setAttribute("string",""+i),s&&s.setAttribute("string",""+a),c&&c.setAttribute("string",""+o);break}case"updateCalculatorAnswer":h&&xB(h);break;default:h.style[d.action]=d.value}}},TF=(e,r)=>{const t=document.getElementById(Ze),n=Er(t),i=e,a=t.getAttribute("drop-action")===or.Move,o=t.getAttribute("drop-action")===or.InfiniteDrop;(a||o)&&setTimeout((()=>{var t,a;e.style.transform="translate(0,0)",e.style.transition="";let u=document.createElement("div");o&&(u=function(e){const r=e.tagName.toLowerCase();if("lido-text"===r){let r=document.createElement("div");return r.innerHTML=e.outerHTML,r=r.firstChild,r.setAttribute("height",e.style.height),r.setAttribute("width",e.style.width),r.setAttribute("visible","true"),r}const t=e.cloneNode(!1);return t.style.width=e.style.width,t.style.height=e.style.height,t.style.margin=e.style.margin,t.style.opacity=e.style.opacity,t.style.transform=e.style.transform,t.style.borderRadius=e.style.borderRadius,t.setAttribute("visible","true"),t.setAttribute("data-dummy","true"),"lido-math-matrix"===r&&t.setAttribute("clickable","false"),t}(e),u.classList.remove("dropped"),u.removeAttribute("drop-to"),u.removeAttribute("drop-time"),u.style.opacity="1",e.style.width=r.style.width,e.style.height=r.style.height,e.setAttribute("hasDummy","true"),setTimeout((()=>{u.style.pointerEvents=""}),100)),u.setAttribute("id",e.getAttribute("id")),e.replaceWith(u);const s=`\n @keyframes widthDecrease {\n 0% { width: ${e.style.width}; height: ${e.style.height}; margin: ${e.style.margin}; }\n 100% { width: 0px; height: 0px; margin: 0px;}\n }\n `;if(!o){u.style.width=i.style.width,u.style.height=i.style.height,u.style.margin=i.style.margin;const e=document.styleSheets[0];e.insertRule(s,e.cssRules.length),u.style.animation="widthDecrease 0.5s",u.addEventListener("animationend",(()=>{u.style.width="0px",u.style.height="0px",u.style.margin="0px"}))}const c=window.innerHeight>window.innerWidth?"portrait":"landscape",l=r.getAttribute("dropAttr"),f=eB(l,c);if("stackcascade"===(null===(t=f)||void 0===t?void 0:t.toLowerCase())||"verticalstack"===(null===(a=f)||void 0===a?void 0:a.toLowerCase()))return r.append(e),void function(e,r,t,n){const i=e.getBoundingClientRect(),a=r.getBoundingClientRect(),o=cB();e.dataset.dropCount||(e.dataset.dropCount="0");let u=parseInt(e.childElementCount)-1;const s=i.width,c=i.height;let l,f;if("landscape"===t&&"stackcascade"===n.toLowerCase()){let r,t;"unitsDrop"===e.id?(r=i.left+.15*s,t=i.top+-.1*c):"tensDrop"===e.id?(r=i.left+.4*s,t=i.top+-.1*c):(r=i.left+.1*s,t=i.top+-.1*c),l=r+u*(.02*s),f=t+u*(.02*c)}else{let r;r="unitsDrop"===e.id?i.left+.4*s:"tensDrop"===e.id?i.left+.25*s:i.left+.16*s,l=r,f=i.top-.25*c+u*(.05*c)}r.style.width="auto",r.style.height="auto";const m=(l-a.left)/o,d=(f-a.top)/o;r.style.transition="transform .2s ease-out",r.style.transform=`translate(${m}px, ${d}px)`;const p=r.getBoundingClientRect(),h=(i.left+s/2-(p.left+p.width/2))/o,v=(i.top+c/2-(p.top+p.height/2))/o;r.style.transition="none",r.style.transform=`translate(${h}px, ${v}px)`,r.getBoundingClientRect(),requestAnimationFrame((()=>{r.style.transition="transform .2s ease-out",r.style.transform=`translate(${m}px, ${d}px)`})),e.dataset.dropCount=u+1+""}(r,e,c,f);r.parentElement.append(i),e.style.position="absolute",e.style.zIndex="1";const m=r.getBoundingClientRect(),d=e.getBoundingClientRect();e.style.transform=`translate(${(m.left+m.width/2-(d.left+d.width/2))/n}px, ${(m.top+m.height/2-(d.top+d.height/2))/n}px)`}),700)},kF=e=>{var r;const t=[];return e?((null===(r=e.split(";"))||void 0===r?void 0:r.map((e=>e.trim()))).forEach((e=>{if(e){const[r,n]=e.split("=").map((e=>e.trim())),i=r.lastIndexOf(".");if(-1!==i){const e=r.substring(0,i).trim(),a=r.substring(i+1).trim();t.push({actor:e,action:a,value:n.replace(/['"]/g,"")})}}})),t):t},OF=(e,r)=>{var t;const n=e.split(",").map((e=>e.trim()));let i=0,a=new Set;if(0==n.length)return!0;if(n.length>0&&0===r.length)return!1;for(const e of n)if(e.startsWith("(")&&e.endsWith(")")){const n=e.slice(1,-1).split("|").map((e=>e.trim())),a=null!==(t=r[i])&&void 0!==t?t:"";let o=[];if(a.startsWith("(")&&a.endsWith(")"))o=a.slice(1,-1).split("|").map((e=>e.trim()));else if(a.includes("|"))o=a.split("|").map((e=>e.trim()));else{if(""===a)return!1;o=[a.trim()]}const u=e=>e.map((e=>e.trim())).sort().join("|");if(u(n)!==u(o))return!1;i++}else if(e.includes("|")){const r=e.split("|").map((e=>e.trim()));for(const e of r)a.add(e)}else{if(i>=r.length||r[i]!==e)return!1;i++}for(;i<r.length;){if(!a.has(r[i]))return!1;a.delete(r[i]),i++}return i===r.length},IF=e=>{const r=e.split(",").map((e=>e.trim()));let t=0;for(const e of r)e.startsWith("(")&&e.endsWith(")")?e.includes("|")?t+=e.split("|").length:t+=1:t+=e.split("|").length;return t};let zF=0;const jF=(e,r)=>{null!==document.querySelector("lido-calculator")&&r!==Ke||(e?(MF.rightMoves+=1,zF=0,_r()):(MF.wrongMoves+=1,zF+=1),console.log("Right Moves : ",MF.rightMoves),console.log("Wrong Moves : ",MF.wrongMoves))},RF=()=>{const e=document.getElementById(Ze);if(null!==document.querySelector("lido-calculator")&&e&&"true"!==e.getAttribute("game-completed"))return;const r=MF.rightMoves,t=MF.wrongMoves;MF.totalRightMovesCount+=r,MF.totalWrongMovesCount+=t;let n=Math.floor(r/(r+t)*100);console.log("[Activity Score]",{rightMoves:r,wrongMoves:t,activityScore:n}),PF(n),MF.rightMoves=0,MF.wrongMoves=0};async function UF(e,r){var t,n,i;const a=document.getElementById(Ze);if(!a)return;const o="blender"===a.getAttribute("template-id"),u=!!a.querySelector("lido-balance");if(u&&a.getAttribute("drop-action")!==or.Move&&a.getAttribute("drop-action")!==or.InfiniteDrop||await qF("this.alignMatch='true'",r,e),e&&r){let i=r.value.toLowerCase().includes(e.value.toLowerCase());if(o){const e=Number(null!==(t=r.getAttribute("required-drops"))&&void 0!==t?t:0),n=document.querySelectorAll(`[drop-to="${r.id}"]`).length;i=n>0&&n<=e}if(i){"category"===r.getAttribute("type")&&(e.classList.remove("category-dropped-onInCorrect"),e.classList.add("category-dropped-onCorrect"),MF.rightMoves+=1,console.log("Right Moves : ",MF.rightMoves),console.log("Wrong Moves : ",MF.wrongMoves));const t=(null===(n=a.getAttribute("dropAttr"))||void 0===n?void 0:n.toLowerCase())===ar.EnableAnimation.toLowerCase()?"":r.getAttribute("onCorrect");!t||o||u||await qF(t,r,e),"multiplyBeeds"===a.getAttribute("template-id")&&Ur(r)}else{if("category"===r.getAttribute("type")){e.classList.remove("category-dropped-onCorrect"),e.classList.add("category-dropped-onInCorrect"),MF.wrongMoves+=1,console.log("Right Moves : ",MF.rightMoves),console.log("Wrong Moves : ",MF.wrongMoves);const r=a.querySelector('[type="optionArea"]');Array.from(a.querySelectorAll(`[value="${e.getAttribute("value")}"]`)).find((r=>r!==e&&"DIV"===r.tagName)),setTimeout((()=>{const t=document.createElement("div");t.style.width=e.offsetWidth+"px",t.style.height=e.offsetHeight+"px",r.appendChild(t);const n=e.offsetLeft,i=e.offsetTop;e.style.position="absolute",e.style.transition="",e.style.transform=`translate(${n}px, ${i}px)`,qr(e,t,a),setTimeout((()=>{t.replaceWith(e),Hr(e),e.classList.remove("category-dropped-onInCorrect"),e.classList.remove("dropped"),e.removeAttribute("drop-to")}),1e3)}),2e3)}const t=r.getAttribute("onInCorrect");!t||o||u||await qF(t,r,e)}}let s=CF();const c=EF(s);a.setAttribute(Ie,JSON.stringify(c));let l=JSON.parse(null!==(i=localStorage.getItem("lidoDragMap"))&&void 0!==i?i:"{}");const f=r.getAttribute("tab-index");l[f]||(l[f]=[]),l[f].push(e.id),document.querySelectorAll("[type='drop']").forEach((e=>{var r,t;if(Object.keys(s).map(Number).includes(JSON.parse(e.getAttribute("tab-index")))){if((null===(r=e.getAttribute("dropAttr"))||void 0===r?void 0:r.toLowerCase())!==ar.Diagonal&&(null===(t=a.getAttribute("drop-action"))||void 0===t?void 0:t.toLowerCase())!==ar.InfiniteDrop&&e){const r=a.getAttribute("appendToDropOnCompletion");e.style.opacity="true"===r?"1":"0"}}else"lido-text"===e.tagName.toLowerCase()&&(e.style.opacity="1")})),_F()}const $F=()=>{const e=new URLSearchParams(window.location.search),r=r=>{var t,n;return null!==(n=null!==(t=e.get(r.toLowerCase()))&&void 0!==t?t:e.get(r))&&void 0!==n?n:""};return{studentId:r("studentId"),studentName:r("studentName"),classId:r("classId"),schoolId:r("schoolId"),courseId:r("courseId"),courseName:r("courseName"),chapterId:r("chapterId"),chapterName:r("chapterName"),lessonId:r("lessonId"),lessonName:r("lessonName"),lang:r("lang"),end:r("end")}},PF=e=>{var r,t,n;const i=document.querySelector("lido-home");if(!i)return;const a=Number(null!==(r=i.getAttribute("index"))&&void 0!==r?r:0),o=Number(null!==(t=i.getAttribute("totalIndex"))&&void 0!==t?t:0),u=JSON.parse(null!==(n=localStorage.getItem(je))&&void 0!==n?n:"{}");u[""+a]=e;const s=Number((NF.getI().getElapsed()/1e3).toFixed(1));AF.push(s),console.log(`[Utils][Activity Time] Activity ${a+1}/${o} - Time spent: ${s}s`);const c=$F();if(function(e,r,t,n,i,a,o,u){hr(Re,Object.assign(Object.assign({currentIndex:r,totalIndex:e,score:t,rightMoves:n,wrongMoves:i,timeSpentForActivity:a},o),{gameCompleted:u})),hr(er,Object.assign(Object.assign({currentIndex:r,totalIndex:e,score:t,rightMoves:n,wrongMoves:i,timeSpentForActivity:a},o),{gameCompleted:u})),console.log(`[Activity End]Activity ${r+1}/${e} - Time Spent: ${a}`)}(o,a,e,MF.rightMoves,MF.wrongMoves,s,c,!0),localStorage.setItem(je,JSON.stringify(u)),o-1==a){const e=Object.values(u),r=e.reduce(((e,r)=>e+r),0)/e.length;MF.finalScore=Math.floor(r),console.log("Total Score : ",MF.finalScore);const t=Number(AF.reduce(((e,r)=>e+r),0).toFixed(1));console.log(`[Utils][Lesson Time] Total lesson time spent: ${t}s`),function(e,r,t,n,i,a){hr(rr,Object.assign({totalIndex:e,rightMoves:r,wrongMoves:t,finalScore:n,score:n,timeSpendForLesson:i},a)),"blank"!==$F().end&&"complete"!==$F().end&&"completed"!==$F().end&&(hr(Ue,Object.assign({totalIndex:e,rightMoves:r,wrongMoves:t,finalScore:n,score:n,timeSpendForLesson:i},a)),console.log(`[Lesson End] Lesson: ${null==a?void 0:a.lessonName} (${null==a?void 0:a.lessonId}) - Total Time Spent: ${i}`))}(o,MF.totalRightMovesCount,MF.totalWrongMovesCount,r,t,c),MF.totalRightMovesCount=0,MF.totalWrongMovesCount=0,hr(tr,{}),"blank"!==$F().end&&"complete"!==$F().end&&"completed"!==$F().end&&hr(_e,{}),localStorage.removeItem(je),AF.length=0}},LF=new WeakSet,_F=async()=>{var e,r,t;const n=document.getElementById(Ze),i=n.objective,a=null!==(e=n.getAttribute(Ie))&&void 0!==e?e:"",o=document.querySelector("#lido-checkButton");if(!a||IF(a)<IF(i))qF("this.addClass='lido-disable-check-button'",o);else if("true"==n.getAttribute("show-check"))null===(r=null==o?void 0:o.classList)||void 0===r||r.remove("lido-disable-check-button");else if(!n.getAttribute("game-completed")&&!n.querySelector("[type='slide']")&&(null===(t=n.getAttribute("dropAttr"))||void 0===t?void 0:t.toLowerCase())!==ar.EnableAnimation.toLowerCase()){if(n.querySelector("[type='category']")){if(LF.has(n))return;LF.add(n);try{await(e=>{const r=Qr.get(e);if(r)return r;const t=(async e=>{const r=e.querySelectorAll('[type="category"]'),t=Wr.getI();for(const e of Array.from(r)){const r=e.parentElement.children[0];await t.play(r);for(const r of Array.from(e.children))r.scrollIntoView({behavior:"smooth",block:"end"}),await t.play(r)}})(e).finally((()=>{Qr.delete(e)}));return Qr.set(e,t),t})(n),await JF()}finally{LF.delete(n)}return}JF()}};let WF;const JF=async()=>{var e,r;const t=document.getElementById(Ze);if(!t)return;const n=t.objective,i=t.getAttribute("equationCheck");t.getAttribute("isAllowOnlyCorrect");let a=!1;if((null==n||0===n.length)&&(i&&(a=!0),!a)){const e=t.getAttribute("onCorrect");return t.setAttribute("game-completed","true"),e&&await qF(e,t),jF(!0),PF(100),MF.totalRightMovesCount++,MF.rightMoves=0,MF.wrongMoves=0,void HF()}const o=null!==(r=JSON.parse(null!==(e=t.getAttribute(Ie))&&void 0!==e?e:"[]"))&&void 0!==r?r:[];if(i){const e=document.querySelector("lido-balance");WF=e?Nr(t,n):tB(i)}else WF=OF(n,o);if(t.querySelector("lido-balance")&&!WF){const e=Array.from(t.querySelectorAll('[type="drop"]'));if(e.filter((e=>!!t.querySelector(`[drop-to="${e.id}"]`))).length<e.length)return}if(WF){t.setAttribute("game-completed","true");const e=t.getAttribute("appendToDropOnCompletion"),r=t.getAttribute("onCorrect");if(r){if("true"===e&&(()=>{const e=document.querySelectorAll("[type='drag']"),r=document.querySelectorAll("[type='drop']");if(!e||!r)return;const t="true"===document.getElementById(Ze).getAttribute("is-allow-only-correct"),n=new Set;r.forEach((r=>{for(let i=0;i<e.length;i++){const a=e[i];if(n.has(a.id))continue;const o=a,u=r;if(!0===t){if(u.value===o.value){o.style.transform="translate(0,0)",o.style.width="stretch",o.style.padding="0",u.appendChild(o),n.add(o.id),o.style.pointerEvents="none";break}}else u.value.includes(o.value)&&(o.style.transform="translate(0,0)",o.style.width="stretch",o.style.padding="0",u.appendChild(o),n.add(o.id),o.style.pointerEvents="none")}}))})(),(t.querySelectorAll("[type='click']").length>0||"blender"===t.getAttribute("template-id"))&&jF(!0),"multiplyBeeds"===t.getAttribute("template-id")){const e=t.querySelector("#beedsText");if(!e)return;await VF(e)}await qF(r,t)}RF(),"EnableAnimation"===t.getAttribute("dropAttr")?setTimeout((()=>{HF()}),2e3):HF()}else{const e="true"===t.getAttribute("is-continue-on-correct"),r=t.getAttribute("onCorrect");if((t.querySelectorAll("[type='click']").length>0||"blender"===t.getAttribute("template-id"))&&jF(!1),e){const e=t.getAttribute("onInCorrect");await qF(e,t)}else t.setAttribute("game-completed","true"),await qF(r,t),RF(),HF()}},VF=e=>{var r;const t=(e=>{const r=e.trim();if(!r)return null;const[t,n]=r.split("="),i=(null!=t?t:"").trim();if(!i)return null;const a=i.split("+").map((e=>e.trim())).filter(Boolean);if(0===a.length)return null;const o=Number(a[0]);if(Number.isNaN(o))return null;if(!a.every((e=>Number(e)===o)))return null;const u=(null!=n?n:"").trim();let s=""===u?NaN:Number(u);return Number.isNaN(s)&&(s=a.map((e=>Number(e))).reduce(((e,r)=>Number.isNaN(r)?NaN:e+r),0)),Number.isNaN(s)?null:{value:o,count:a.length,total:s}})(null!==(r=e.textContent)&&void 0!==r?r:"");if(!t)return;const n=e.getAttribute("data-multiply-timers");n&&n.split(",").map((e=>Number(e))).filter((e=>Number.isFinite(e))).forEach((e=>clearTimeout(e))),e.removeAttribute("data-multiply-timers");const i=[];[t.value+"","X",t.count+"","=",t.total+""].forEach(((r,t)=>{const n=window.setTimeout((()=>{var n;0===t&&(e.textContent="");const i=(null!==(n=e.textContent)&&void 0!==n?n:"").trim();e.textContent=i?`${i} ${r}`:r}),1e3*(t+1));i.push(n)})),e.setAttribute("data-multiply-timers",i.join(","))},HF=()=>{Wr.getI().stop();const e=document.querySelector(".lido-home");e&&("blank"===$F().end||"complete"===$F().end||"completed"===$F().end)&&Number(e.getAttribute("index"))>=Number(e.getAttribute("totalIndex"))-1||hr($e,{})},ZF=()=>{Wr.getI().stop(),hr(Pe,{})};let GF;function XF(e){GF=e}function YF(){GF=void 0}function QF(e){const r=document.getElementById(Ze),t=null==r?void 0:r.getAttribute("baseUrl"),n=GF;if((null==e?void 0:e.startsWith("http"))||(null==e?void 0:e.startsWith("blob"))||(null==e?void 0:e.startsWith("data")))return e;if(e.startsWith("/Lido-CommonAudios/"))return e;if(n){const r=e.replace(/^\.\/?/,""),t=n[e]||n[r];if(t)return t;const i=Object.keys(n).find((e=>e===r||e.endsWith("/"+r)));if(i)return n[i]}if(!n&&t){const r=e.startsWith("/")?e.slice(1):e;return r.startsWith(t.replace(/^\/+|\/+$/g,""))?r:t.endsWith("/")?t+r:`${t}/${r}`}return D(e)}function KF(e,r,t,n){if(void 0===n)return;const i=Array.from(e.children);let a=n;r&&n<r&&(a=r),t&&n>t&&(a=t),i.forEach(((e,r)=>{r>a-1&&(e.style.display="none")}))}const eB=(e,r)=>e&&e.includes(",")?e.split(",").reduce(((e,r)=>{const[t,n]=r.split(".");return e[t.trim()]=n.trim(),e}),{})[r]||"":e,rB=(e,r)=>{const t=document.querySelectorAll("[type='drag']"),n=document.querySelectorAll("[type='drop']"),i=document.querySelectorAll("[type='click']");let a=0;if("click"===r)return i.forEach((e=>{const r=e;let t=null;if(r.getAttribute("flexible-width"))t=r;else{const e=r.children;for(let r=0;r<e.length;r++){const n=e[r];if(n.getAttribute("flexible-width")){t=n;break}}}if(t){const e=t.style.width,r=t.style.padding;t.style.width="auto",t.style.padding="0 20px";const n=t.offsetWidth;t.style.width=e,t.style.padding=r,n>a&&(a=n)}})),void i.forEach((e=>{const r=e;if(r.getAttribute("flexible-width")){if("true"===r.getAttribute("flexible-width"))return;r.style.width=a+"px"}else{const e=r.children;for(let r=0;r<e.length;r++){const t=e[r];if(t.getAttribute("flexible-width")){if("true"===t.getAttribute("flexible-width"))return;t.style.width=a+"px";break}}}}));t.forEach((r=>{var t;const n=r,i=n.style.width,o=n.style.padding;n.style.width="auto",n.style.padding="0 20px";const u=n.offsetWidth;n.style.width=i,n.style.padding=o,(null===(t=e.getAttribute("dropAttr"))||void 0===t?void 0:t.toLowerCase())!==ar.Stretch&&u>a&&(a=u)})),t.forEach((e=>{const t=e,n=t.getAttribute("flexible-width");"false"===n?t.style.width=a+"px":"true"===n&&"drag"===r&&(t.style.width="auto",t.style.padding="0 20px")})),n.forEach((e=>{const t=e,n=t.getAttribute("flexible-width");if("false"===n){const e=parseFloat(getComputedStyle(t).borderWidth);if("number"==typeof e){const r=a-2*e;return t.style.height=parseFloat(t.style.height)-2*e+"px",void(t.style.width=r+"px")}}else"true"===n&&"drag"===r&&(t.style.width="auto",t.style.padding="0 20px")}))},tB=e=>{if(!e)return;const r=e.split(",").map((e=>{var r;if(e.startsWith("$")){const t=e.substring(1),n=nB(t);return sn(n)?null==n?void 0:n.map((e=>e.getAttribute("value"))):n.getAttribute("value")||(null===(r=document.getElementById(t))||void 0===r?void 0:r.value)}return e})).join("");return GS(r)},nB=e=>{if(e.startsWith("#")){const r=e.substring(1),t=document.getElementById(r);if("drop"===t.getAttribute("type")){const e=document.querySelectorAll(`[${Ve}="${r}"]`);return e.length>0?e[0]:[]}return t}const r=document.querySelectorAll(`[${Ve}="${e}"]`);return Array.from(r).sort(((e,r)=>parseInt(e.getAttribute(He))-parseInt(r.getAttribute(He))))},iB=e=>{if(e.className.includes("lido-speak-icon"))return null;const r=document.createElement("div");r.style.width="0",r.style.height="0";const t=document.createElement("div");return r.append(t),t.classList.add("lido-speak-icon"),t.addEventListener("click",(async r=>{r.stopPropagation(),fB(!0),await Wr.getI().stop();try{await Wr.getI().play(e)}catch(e){console.error("Error playing audio or TTS:",e)}fB(!1)})),e.style.position="relative",t},aB=async e=>{let r=iB(e);if("option"===e.type){e.style.position="unset";const t=document.createElement("div");t.className=e.className,t.style.position="relative",t.style.backgroundColor="transparent",t.style.padding="0",t.style.width="100%",t.style.height="100%",Array.from(e.children).forEach((e=>{t.appendChild(e)})),t.appendChild(r),r.style.position="absolute",r=t}e.appendChild(r)},oB=async(e,r)=>{if(document.getElementById(Ze)&&r){const t=parseInt(r,10);e.style.visibility="hidden",isNaN(t)||await new Promise((r=>{setTimeout((()=>{e.style.visibility="visible",r()}),t)}))}},uB=(e,r)=>{if(!e)return;r||(r="green");const t=`${"0 0 0 6px "+r}, 0 ${.08*e.offsetHeight}px 10px rgba(0, 0, 0, 0.25)`;e.style.boxShadow=t,e.style.setProperty("box-shadow",t,"important")},sB=async(e,r)=>{if(!e)return;r||(r="horizontal-shake");const t="lido-"+r;e.classList.add(t),await new Promise((e=>setTimeout(e,600))),e.classList.remove(t)};function cB(){var e;const r=[window.innerWidth],t=[window.innerHeight];(null===(e=window.screen)||void 0===e?void 0:e.width)&&(r.push(window.screen.width),t.push(window.screen.height));const n=Math.min(...r),i=Math.min(...t),a=i>n;return Math.min(a?n/900:n/1600,a?i/1600:i/900)}let lB=!1;function fB(e){lB=e}function mB(){return lB}function dB(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const r=16*Math.random()|0;return("x"===e?r:3&r|8).toString(16)}))}const pB=e=>{if(!e)return;const r=e.getAttribute("value");if(!r)return;let t=e.querySelector(".lido-display-hiddenvalue");t||(t=document.createElement("div"),t.classList.add("lido-display-hiddenvalue"),e.style.position="relative",e.appendChild(t)),t.innerText=r},hB=(e,r)=>{if(!e)return;e.classList.add("lido-image-colorize");const t=e.querySelector("img");t&&e.style.setProperty("--mask-url",`url(${t.src})`),"red"===r?e.style.setProperty("--tint-color","#ff0000"):"green"===r?e.style.setProperty("--tint-color","#00c853"):(e.style.removeProperty("--tint-color"),e.style.removeProperty("--mask-url"))},vB=async(e,r)=>{if(!e)return;if(!r)return;const t=Array.from(e.children);for(const e of t)e.classList.add("lido-glow"),await Wr.getI().play(e),e.style.opacity="0",e.style.visibility="hidden",await new Promise((e=>setTimeout(e,300))),e.classList.remove("lido-glow")},yB=async(e,r)=>{if(!e)return;if(!r)return;const t=Array.from(e.children);if(!t)return;t.forEach((e=>{e.style.visibility="hidden"}));for(const e of t)e.style.visibility="visible",e.style.opacity="1",e.classList.add("lido-box-highlight"),await new Promise((e=>setTimeout(e,600))),e.classList.remove("lido-box-highlight");const n=document.getElementById(Ze);if(!n)return;const i=n.children[2];i&&await Wr.getI().play(i);for(const e of t){const r=e.querySelector("lido-text");r&&await Wr.getI().play(r)}},bB=async(e,r)=>{e&&r&&Array.from(e.querySelectorAll("[type='drag']")).forEach((e=>{const r=e.getAttribute("drop-to");if(r&&""!==r){e.style.transition="opacity 0.5s ease",e.style.opacity="0";const t=document.getElementById(r),n=e.getAttribute("value");n&&"?"===t.innerText.trim()&&(t.innerText=n)}}))},gB=async(e,r)=>{if(!e)return;if(!r)return;const t=Array.from(e.children)[3],n=Array.from(e.children)[4],i=Array.from(e.children)[5];if(!t||!n||!i)return;const a=Array.from(t.children),o=Array.from(n.children),u=o[0],s=o[1],c=o[2],l=o[3],f=o[4],m=e=>{e&&(e.style.visibility="visible",e.style.display="",e.style.opacity="1")},d=e=>{if(!e)return 0;const r=e.getAttribute&&(e.getAttribute("value")||e.getAttribute("string"))||e.textContent||"";return parseInt((r+"").trim(),10)||0},p=async e=>{e?(u&&(await new Promise((e=>setTimeout(e,200))),m(u)),s&&(await new Promise((e=>setTimeout(e,200))),m(s))):(c&&(await new Promise((e=>setTimeout(e,200))),m(c)),l&&(await new Promise((e=>setTimeout(e,300))),m(l)),i&&(await new Promise((e=>setTimeout(e,300))),m(i)),f&&(await new Promise((e=>setTimeout(e,200))),m(f)))},h=d(u),v=d(c);if("-"==("+"===(""+(s&&(s.getAttribute("string")||s.textContent||""))).trim()?"+":"-")){for(let e=0;e<Math.min(h,a.length);e++)await new Promise((e=>setTimeout(e,75))),m(a[e]);p(!0),await new Promise((e=>setTimeout(e,500)));for(let e=0;e<Math.min(v,a.length);e++)hB(a[Math.min(h,a.length)-1-e],"red"),await new Promise((e=>setTimeout(e,200)));p(!1)}else{for(let e=0;e<Math.min(h,a.length);e++)await new Promise((e=>setTimeout(e,120))),m(a[e]);p(!0),await new Promise((e=>setTimeout(e,500)));for(let e=0;e<Math.min(v,Math.max(0,a.length-h));e++){const r=h+e;a[r]&&(m(a[r]),hB(a[r],"green")),await new Promise((e=>setTimeout(e,80)))}p(!1)}},xB=e=>{if(!document.getElementById(Ze))return;const r=document.querySelector("#lidoCalculator");if(!r)return;const t=r.getAttribute("value");e.setAttribute("string",t)};export{ZF as $,Wr as A,ir as B,Ke as C,or as D,iB as E,mr as F,Gn as G,l as H,Xn as I,dB as J,je as K,Ye as L,br as M,ur as N,yr as O,fr as P,lr as Q,xr as R,Ie as S,Qe as T,cr as U,sr as V,$e as W,Pe as X,Ge as Y,mB as Z,OF as _,eB as a,XF as a0,YF as a1,fB as a2,Xe as a3,ft as a4,R as b,QF as c,P as d,tB as e,qF as f,SF as format,RF as g,D as getAssetPath,z as h,BF as i,HF as j,oB as k,KF as l,aB as m,cB as n,_r as o,Fe as p,NF as q,fF as r,ke as render,jF as s,N as setAssetPath,Be as setNonce,qe as setPlatformOptions,Oe as t,mF as u,oF as v,Ze as w,Lr as x,JF as y,rM as z}
|
|
1
|
+
const e="@font-face{font-family:'Baloo Bhai 2';font-style:normal;font-weight:400 800;font-display:swap;src:url('../assets/offline-assets/fonts/Baloo-Bhai-2/Baloo-Bhai-2-Variable.woff2') format('woff2')}body{overflow:hidden;background-position:center;background-size:cover;background-repeat:no-repeat;height:100vh}*{user-select:none}.lido-disable-check-button{pointer-events:none;background-color:#9393935c !important;color:white}.lido-element-selected{border:2px solid;background-color:#ffdf7d !important}.diagonal-target,.diagonal-drop *{transform:scale(0.8) !important;opacity:1 !important}.cloned-element{display:flex !important;position:absolute !important;filter:grayscale(100%);pointer-events:none}.removeShadow{box-shadow:0px 0px 0px 0px #ff8900 !important}.highlight-element{border:2px solid white;box-shadow:rgb(243, 77, 8) 0px 0px 40px !important}.drop-element.empty{border:4px dashed #f34d08 !important}.drop-element.filled{border:'none' !important}.drag-element{box-shadow:0px 15px 11px rgba(43, 0, 0, 0.3) !important}.drag-element.dropped{box-shadow:none !important}.click-element{background-color:var(--btn-bg-color, rgba(255, 172, 76, 1)) !important;box-shadow:var(--btn-shadow-px) var(--btn-shadow-color, rgba(225, 121, 76, 1)) !important;cursor:pointer;transition:box-shadow 0.1s ease-out, transform 0.2s ease-out;}.click-element:active{box-shadow:0px 0px 0px var(--btn-shadow-color, rgba(225, 121, 76, 1)) !important;transform:translateY(var(--btn-active));}.click-element:focus{outline:2px solid dodgerblue;outline-offset:3px}.after-drop-popup-container{width:200%;height:200%;background-color:rgba(0, 0, 0, 0.8);position:absolute;display:flex;flex-direction:row-reverse;align-items:center;justify-content:center !important;gap:80px}.after-drop-popup-drag-element{scale:1.5;border-radius:8px;transform:none !important;position:unset !important}.after-drop-popup-drop-element{scale:1.5;border:unset;border-radius:8px;transform:none !important;position:unset !important}@keyframes zoomFadeIn{0%{transform:scale(0.6);opacity:0}100%{transform:scale(1);opacity:1}}.zoom-fade-in{animation:zoomFadeIn 0.8s ease-out forwards}@keyframes zoomFadeOut{0%{transform:scale(1);opacity:1}100%{transform:scale(0.6);opacity:0}}.zoom-fade-out{animation:zoomFadeOut 0.8s ease-in forwards}.slide-numbers{width:70px;height:70px;border:1px solid #f57139;background-color:white;font-weight:500;color:#f57139;font-size:44px;border-radius:40px;display:flex;align-items:center;justify-content:center;font-family:'Baloo Bhai 2', serif}.slide-numbers-bottom{position:absolute;display:flex;justify-content:space-around;align-items:center;bottom:-25px;width:100%;height:50px}.slide-numbers-left{position:absolute;display:flex;flex-direction:column;justify-content:space-around;height:100%;width:50px;left:-25px;bottom:0px}.lido-speak-icon{width:56px;height:56px;position:absolute;top:-25px;right:-25px;z-index:10;background-color:white;border:4px solid #F34D08;border-radius:16px;box-shadow:0px 4px 0px 0px #F34D08;background-size:contain;background-repeat:no-repeat;cursor:pointer}.lido-speak-icon:active{transform:translateY(8px);box-shadow:0px 0px 0px 0px !important}.lido-strong-shake{animation:strongShake 0.3s ease}.lido-scaled-shake{animation:scaledShake 0.6s ease-in-out}.lido-horizontal-shake{animation:horizontalShake 0.6s ease-in-out;border-radius:20px}.lido-vertical-shake{animation:verticalShake 0.6s ease-in-out;border-radius:20px}.lido-diagonal-shake{animation:diagonalShake 0.5s ease-in-out;border-radius:20px;will-change:transform}.lido-glow{animation:glowPulse 1s infinite alternate;transition:opacity 0.5s ease-in-out}.lido-box-highlight{animation:topToPlace 0.3s linear}.lido-display-hiddenvalue{position:absolute;top:0;left:0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:80px;font-weight:1000;color:brown;-webkit-text-stroke:2px white;font-family:'Baloo Bhai 2', sans-serif;pointer-events:none}.lido-image-colorize{position:relative;display:inline-block}.lido-image-colorize::after{content:'';position:absolute;inset:0;background:var(--tint-color);mix-blend-mode:multiply;opacity:0.8;pointer-events:none;mask-image:var(--mask-url);mask-size:cover;mask-repeat:no-repeat;mask-position:center}.lido-tts-highlight-overlay{position:fixed;left:0;top:0;pointer-events:none;z-index:9999;background:linear-gradient(\n 180deg,\n rgba(255, 235, 59, 0.95),\n rgba(255, 214, 0, 0.95)\n );border-radius:6px;box-shadow:0 2px 6px rgba(0, 0, 0, 0.18),\n inset 0 -1px 0 rgba(255, 255, 255, 0.25);transition:width 25ms ease-out,\n height 25ms ease-out,\n opacity 80ms ease-out;opacity:0.95;will-change:transform, width, height;contain:layout paint style}.category-dropped-onCorrect{box-shadow:rgba(129, 193, 39, 1) 0px 8px 8px 0px !important}.category-dropped-onInCorrect{box-shadow:rgba(255, 4, 16, 1) 0px 8px 8px 0px !important}";function r(e,r,t){const n="undefined"!=typeof HTMLElement?HTMLElement.prototype:null;for(;e&&e!==n;){const n=Object.getOwnPropertyDescriptor(e,r);if(n&&(!t||n.get))return n;e=Object.getPrototypeOf(e)}}var t,n=(e,t)=>{var n;Object.entries(null!=(n=t.D.o)?n:{}).map((([n,[i]])=>{if(31&i||32&i){const i=e[n],a=r(Object.getPrototypeOf(e),n,!0)||Object.getOwnPropertyDescriptor(e,n);a&&Object.defineProperty(e,n,{get(){return a.get.call(this)},set(e){a.set.call(this,e)},configurable:!0,enumerable:!0}),t.O.has(n)?e[n]=t.O.get(n):void 0!==i&&(e[n]=i)}}))},i=e=>{if(e.__stencil__getHostRef)return e.__stencil__getHostRef()},a=(e,r)=>r in e,o=(e,r)=>(0,console.error)(e,r),u=new Map,s="http://www.w3.org/1999/xlink",c="undefined"!=typeof window?window:{},l=c.HTMLElement||class{},f={ee:0,te:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,r,t,n)=>e.addEventListener(r,t,n),rel:(e,r,t,n)=>e.removeEventListener(r,t,n),ce:(e,r)=>new CustomEvent(e,r)},m=(()=>{try{return!!c.document.adoptedStyleSheets&&(new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync)}catch(e){}return!1})(),d=!!m&&(()=>!!c.document&&Object.getOwnPropertyDescriptor(c.document.adoptedStyleSheets,"length").writable)(),p=!1,h=[],v=[],y=(e,r)=>t=>{e.push(t),p||(p=!0,r&&4&f.ee?x(g):f.raf(g))},b=e=>{for(let r=0;r<e.length;r++)try{e[r](performance.now())}catch(e){o(e)}e.length=0},g=()=>{b(h),b(v),(p=h.length>0)&&f.raf(g)},x=e=>Promise.resolve(void 0).then(e),w=y(v,!0),D=e=>{const r=new URL(e,f.te);return r.origin!==c.location.origin?r.href:r.pathname},N=e=>f.te=e;function A(){var r;const n=this.attachShadow({mode:"open"});if(void 0===t&&(t=null!=(r=function(e){if(!m)return;const r=new CSSStyleSheet;return r.replaceSync(e),r}(e))?r:null),t)d?n.adoptedStyleSheets.push(t):n.adoptedStyleSheets=[...n.adoptedStyleSheets,t];else if(!m){const r=document.createElement("style");r.innerHTML=e,n.prepend(r)}}var M=e=>{const r=B(e,"childNodes");e.tagName&&e.tagName.includes("-")&&e["s-cr"]&&"SLOT-FB"!==e.tagName&&C(r,e.tagName).forEach((e=>{1===e.nodeType&&"SLOT-FB"===e.tagName&&(e.hidden=!!E(e,F(e),!1).length)}));let t=0;for(t=0;t<r.length;t++){const e=r[t];1===e.nodeType&&B(e,"childNodes").length&&M(e)}};function C(e,r,t){let n,i=0,a=[];for(;i<e.length;i++){if(n=e[i],n["s-sr"]&&(!r||n["s-hn"]===r)&&(void 0===t||F(n)===t)&&(a.push(n),void 0!==t))return a;a=[...a,...C(n.childNodes,r,t)]}return a}var E=(e,r,t=!0)=>{const n=[];(t&&e["s-sr"]||!e["s-sr"])&&n.push(e);let i=e;for(;i=i.nextSibling;)F(i)!==r||!t&&i["s-sr"]||n.push(i);return n},S=(e,r)=>1===e.nodeType?null===e.getAttribute("slot")&&""===r||e.getAttribute("slot")===r:e["s-sn"]===r||""===r,F=e=>"string"==typeof e["s-sn"]?e["s-sn"]:1===e.nodeType&&e.getAttribute("slot")||void 0;function B(e,r){if("__"+r in e){const t=e["__"+r];return"function"!=typeof t?t:t.bind(e)}return"function"!=typeof e[r]?e[r]:e[r].bind(e)}var q,T,k=new WeakMap,O=e=>"sc-"+e.ne,I=e=>"object"==(e=typeof e)||"function"===e,z=(e,r,...t)=>{let n=null,i=null,a=null,o=!1,u=!1;const s=[],c=r=>{for(let t=0;t<r.length;t++)n=r[t],Array.isArray(n)?c(n):null!=n&&"boolean"!=typeof n&&((o="function"!=typeof e&&!I(n))&&(n+=""),o&&u?s[s.length-1].ie+=n:s.push(o?j(null,n):n),u=o)};if(c(t),r){r.key&&(i=r.key),r.name&&(a=r.name);{const e=r.className||r.class;e&&(r.class="object"!=typeof e?e:Object.keys(e).filter((r=>e[r])).join(" "))}}const l=j(e,null);return l.ae=r,s.length>0&&(l.oe=s),l.ue=i,l.se=a,l},j=(e,r)=>({ee:0,le:e,ie:null!=r?r:null,fe:null,oe:null,ae:null,ue:null,se:null}),R={},U=e=>{if(!e)return;const r=Object.keys(e);if(0===r.length)return;let t=!1;for(const n of r){if(t)break;for(const r of e[n])if("string"==typeof r){t=!0;break}}if(!t)return e;const n={};for(const t of r)n[t]=e[t].map((e=>"string"==typeof e?{[e]:0}:e));return n},$=(e,r)=>null==e||I(e)?e:4&r?"false"!==e&&(""===e||!!e):2&r?"string"==typeof e?parseFloat(e):"number"==typeof e?e:NaN:1&r?e+"":e,P=(e,r)=>{const t=e;return{emit:e=>L(t,r,{bubbles:!0,composed:!0,cancelable:!0,detail:e})}},L=(e,r,t)=>{const n=f.ce(r,t);return e.dispatchEvent(n),n},_=(e,r,t,n,o,u)=>{if(t===n)return;let l=a(e,r),m=r.toLowerCase();if("class"===r){const r=e.classList,i=J(t);let a=J(n);r.remove(...i.filter((e=>e&&!a.includes(e)))),r.add(...a.filter((e=>e&&!i.includes(e))))}else if("style"===r){for(const r in t)n&&null!=n[r]||(r.includes("-")?e.style.removeProperty(r):e.style[r]="");for(const r in n)t&&n[r]===t[r]||(r.includes("-")?e.style.setProperty(r,n[r]):e.style[r]=n[r])}else if("key"===r);else if("ref"===r)n&&de(n,e);else if(e.__lookupSetter__(r)||"o"!==r[0]||"n"!==r[1]){if("a"===r[0]&&r.startsWith("attr:")){const t=r.slice(5);let a;{const r=i(e);if(r&&r.D&&r.D.o){const e=r.D.o[t];e&&e[1]&&(a=e[1])}}return a||(a=t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()),void(null==n||!1===n?!1===n&&""!==e.getAttribute(a)||e.removeAttribute(a):e.setAttribute(a,!0===n?"":n))}if("p"===r[0]&&r.startsWith("prop:")){const t=r.slice(5);try{e[t]=n}catch(e){}return}{const i=I(n);if((l||i&&null!==n)&&!o)try{if(e.tagName.includes("-"))e[r]!==n&&(e[r]=n);else{const i=null==n?"":n;"list"===r?l=!1:null!=t&&e[r]===i||("function"==typeof e.__lookupSetter__(r)?e[r]=i:e.setAttribute(r,i))}}catch(e){}let a=!1;m!==(m=m.replace(/^xlink\:?/,""))&&(r=m,a=!0),null==n||!1===n?!1===n&&""!==e.getAttribute(r)||(a?e.removeAttributeNS(s,r):e.removeAttribute(r)):(!l||4&u||o)&&!i&&1===e.nodeType&&(n=!0===n?"":n,a?e.setAttributeNS(s,r,n):e.setAttribute(r,n))}}else if(r="-"===r[2]?r.slice(3):a(c,m)?m.slice(2):m[2]+r.slice(3),t||n){const i=r.endsWith(V);r=r.replace(H,""),t&&f.rel(e,r,t,i),n&&f.ael(e,r,n,i)}},W=/\s/,J=e=>("object"==typeof e&&e&&"baseVal"in e&&(e=e.baseVal),e&&"string"==typeof e?e.split(W):[]),V="Capture",H=RegExp(V+"$"),Z=(e,r,t)=>{const n=11===r.fe.nodeType&&r.fe.host?r.fe.host:r.fe,i=e&&e.ae||{},a=r.ae||{};for(const e of G(Object.keys(i)))e in a||_(n,e,i[e],void 0,t,r.ee);for(const e of G(Object.keys(a)))_(n,e,i[e],a[e],t,r.ee)};function G(e){return e.includes("ref")?[...e.filter((e=>"ref"!==e)),"ref"]:e}var X=!1,Y=!1,Q=!1,K=!1,ee=[],re=[],te=(e,r,t)=>{var n;const i=r.oe[t];let a,o,u,s=0;if(X||(Q=!0,"slot"===i.le&&(i.ee|=i.oe?2:1)),null!=i.ie)a=i.fe=c.document.createTextNode(i.ie);else if(1&i.ee)a=i.fe=c.document.createTextNode(""),Z(null,i,K);else{if(!c.document)throw Error("You are trying to render a Stencil component in an environment that doesn't support the DOM.");if(a=i.fe=c.document.createElement(!X&&2&i.ee?"slot-fb":i.le),Z(null,i,K),i.oe){const r="template"===i.le?a.content:a;for(s=0;s<i.oe.length;++s)o=te(e,i,s),o&&r.appendChild(o)}}return a["s-hn"]=T,3&i.ee&&(a["s-sr"]=!0,a["s-cr"]=q,a["s-sn"]=i.se||"",a["s-rf"]=null==(n=i.ae)?void 0:n.ref,function(e){if(e.assignedElements||e.assignedNodes||!e["s-sr"])return;const r=r=>function(e){const t=[],n=this["s-sn"];(null==e?void 0:e.flatten)&&console.error("\n Flattening is not supported for Stencil non-shadow slots.\n You can use `.childNodes` to nested slot fallback content.\n If you have a particular use case, please open an issue on the Stencil repo.\n ");const i=this["s-cr"].parentElement;return(i.__childNodes?i.childNodes:(e=>{const r=[];for(let t=0;t<e.length;t++){const n=e[t]["s-nr"]||void 0;n&&n.isConnected&&r.push(n)}return r})(i.childNodes)).forEach((e=>{n===F(e)&&t.push(e)})),r?t.filter((e=>1===e.nodeType)):t}.bind(e);e.assignedElements=r(!0),e.assignedNodes=r(!1)}(a),u=e&&e.oe&&e.oe[t],u&&u.le===i.le&&e.fe&&ne(e.fe)),a},ne=e=>{f.ee|=1;const r=e.closest(T.toLowerCase());if(null!=r){const t=Array.from(r.__childNodes||r.childNodes).find((e=>e["s-cr"])),n=Array.from(e.__childNodes||e.childNodes);for(const e of t?n.reverse():n)null!=e["s-sh"]&&(pe(r,e,null!=t?t:null),e["s-sh"]=void 0,Q=!0)}f.ee&=-2},ie=(e,r)=>{f.ee|=1;const t=Array.from(e.__childNodes||e.childNodes);if(e["s-sr"]){let r=e;for(;r=r.nextSibling;)r&&r["s-sn"]===e["s-sn"]&&r["s-sh"]===T&&t.push(r)}for(let e=t.length-1;e>=0;e--){const n=t[e];n["s-hn"]!==T&&n["s-ol"]&&(pe(se(n).parentNode,n,se(n)),n["s-ol"].remove(),n["s-ol"]=void 0,n["s-sh"]=void 0,Q=!0),r&&ie(n,r)}f.ee&=-2},ae=(e,r,t,n,i,a)=>{let o,u=e["s-cr"]&&e["s-cr"].parentNode||e;for(u.shadowRoot&&u.tagName===T&&(u=u.shadowRoot),"template"===t.le&&(u=u.content);i<=a;++i)n[i]&&(o=te(null,t,i),o&&(n[i].fe=o,pe(u,o,se(r))))},oe=(e,r,t)=>{for(let n=r;n<=t;++n){const r=e[n];if(r){const e=r.fe;me(r),e&&(Y=!0,e["s-ol"]?e["s-ol"].remove():ie(e,!0),e.remove())}}},ue=(e,r,t=!1)=>e.le===r.le&&("slot"===e.le?e.se===r.se:t?(t&&!e.ue&&r.ue&&(e.ue=r.ue),!0):e.ue===r.ue),se=e=>e&&e["s-ol"]||e,ce=(e,r,t=!1)=>{const n=r.fe=e.fe,i=e.oe,a=r.oe,o=r.ie;let u;null==o?("slot"!==r.le||X||e.se!==r.se&&(r.fe["s-sn"]=r.se||"",ne(r.fe.parentElement)),Z(e,r,K),null!==i&&null!==a?((e,r,t,n,i=!1)=>{let a,o,u=0,s=0,c=0,l=0,f=r.length-1,m=r[0],d=r[f],p=n.length-1,h=n[0],v=n[p];const y="template"===t.le?e.content:e;for(;u<=f&&s<=p;)if(null==m)m=r[++u];else if(null==d)d=r[--f];else if(null==h)h=n[++s];else if(null==v)v=n[--p];else if(ue(m,h,i))ce(m,h,i),m=r[++u],h=n[++s];else if(ue(d,v,i))ce(d,v,i),d=r[--f],v=n[--p];else if(ue(m,v,i))"slot"!==m.le&&"slot"!==v.le||ie(m.fe.parentNode,!1),ce(m,v,i),pe(y,m.fe,d.fe.nextSibling),m=r[++u],v=n[--p];else if(ue(d,h,i))"slot"!==m.le&&"slot"!==v.le||ie(d.fe.parentNode,!1),ce(d,h,i),pe(y,d.fe,m.fe),d=r[--f],h=n[++s];else{for(c=-1,l=u;l<=f;++l)if(r[l]&&null!==r[l].ue&&r[l].ue===h.ue){c=l;break}c>=0?(o=r[c],o.le!==h.le?a=te(r&&r[s],t,c):(ce(o,h,i),r[c]=void 0,a=o.fe),h=n[++s]):(a=te(r&&r[s],t,s),h=n[++s]),a&&pe(se(m.fe).parentNode,a,se(m.fe))}u>f?ae(e,null==n[p+1]?null:n[p+1].fe,t,n,s,p):s>p&&oe(r,u,f)})(n,i,r,a,t):null!==a?(null!==e.ie&&(n.textContent=""),ae(n,null,r,a,0,a.length-1)):!t&&null!==i&&oe(i,0,i.length-1)):(u=n["s-cr"])?u.parentNode.textContent=o:e.ie!==o&&(n.data=o)},le=[],fe=e=>{let r,t,n;const i=e.__childNodes||e.childNodes;for(const e of i){if(e["s-sr"]&&(r=e["s-cr"])&&r.parentNode){t=r.parentNode.__childNodes||r.parentNode.childNodes;const i=e["s-sn"];for(n=t.length-1;n>=0;n--)if(r=t[n],!(r["s-cn"]||r["s-nr"]||r["s-hn"]===e["s-hn"]||r["s-sh"]&&r["s-sh"]===e["s-hn"]))if(S(r,i)){let t=le.find((e=>e.me===r));Y=!0,r["s-sn"]=r["s-sn"]||i,t?(t.me["s-sh"]=e["s-hn"],t.de=e):(r["s-sh"]=e["s-hn"],le.push({de:e,me:r})),r["s-sr"]&&le.map((e=>{S(e.me,r["s-sn"])&&(t=le.find((e=>e.me===r)),t&&!e.de&&(e.de=t.de))}))}else le.some((e=>e.me===r))||le.push({me:r})}1===e.nodeType&&fe(e)}},me=e=>{e.ae&&e.ae.ref&&ee.push((()=>e.ae.ref(null))),e.oe&&e.oe.map(me)},de=(e,r)=>{re.push((()=>e(r)))},pe=(e,r,t,n)=>{if("string"==typeof r["s-sn"]){e.insertBefore(r,t);const{slotNode:i}=function(e,r){var t;if(!(r=r||(null==(t=e["s-ol"])?void 0:t.parentElement)))return{slotNode:null,slotName:""};const n=e["s-sn"]=F(e)||"";return{slotNode:C(B(r,"childNodes"),r.tagName,n)[0],slotName:n}}(r);return i&&!n&&function(e){e.dispatchEvent(new CustomEvent("slotchange",{bubbles:!1,cancelable:!1,composed:!1}))}(i),r}return e.__insertBefore?e.__insertBefore(r,t):null==e?void 0:e.insertBefore(r,t)},he=(e,r,t=!1)=>{var n,i,a,o,u;const s=e.$hostElement$,l=e.D,m=e.pe||j(null,null),d=(e=>e&&e.le===R)(r)?r:z(null,null,r);if(T=s.tagName,l.he&&(d.ae=d.ae||{},l.he.forEach((([e,r])=>{d.ae[r]=s[e]}))),t&&d.ae)for(const e of Object.keys(d.ae))s.hasAttribute(e)&&!["key","ref","style","class"].includes(e)&&(d.ae[e]=s[e]);if(d.le=null,d.ee|=4,e.pe=d,d.fe=m.fe=s.shadowRoot||s,X=!(!(1&l.ee)||128&l.ee),q=s["s-cr"],Y=!1,ce(m,d,t),f.ee|=1,Q){fe(d.fe);for(const e of le){const r=e.me;if(!r["s-ol"]&&c.document){const e=c.document.createTextNode("");e["s-nr"]=r,pe(r.parentNode,r["s-ol"]=e,r,t)}}for(const e of le){const r=e.me,u=e.de;if(1===r.nodeType&&t&&(r["s-ih"]=null!=(n=r.hidden)&&n),u){const e=u.parentNode;let n=u.nextSibling;if(n&&1===n.nodeType){let t=null==(i=r["s-ol"])?void 0:i.previousSibling;for(;t;){let i=null!=(a=t["s-nr"])?a:null;if(i&&i["s-sn"]===r["s-sn"]&&e===(i.__parentNode||i.parentNode)){for(i=i.nextSibling;i===r||(null==i?void 0:i["s-sr"]);)i=null==i?void 0:i.nextSibling;if(!i||!i["s-nr"]){n=i;break}}t=t.previousSibling}}if((!n&&e!==(r.__parentNode||r.parentNode)||(r.__nextSibling||r.nextSibling)!==n)&&r!==n){if(pe(e,r,n,t),8===r.nodeType&&r.nodeValue.startsWith("s-nt-")){const e=c.document.createTextNode(r.nodeValue.replace(/^s-nt-/,""));e["s-hn"]=r["s-hn"],e["s-sn"]=r["s-sn"],e["s-sh"]=r["s-sh"],e["s-sr"]=r["s-sr"],e["s-ol"]=r["s-ol"],e["s-ol"]["s-nr"]=e,pe(r.parentNode,e,r,t),r.parentNode.removeChild(r)}1===r.nodeType&&"SLOT-FB"!==r.tagName&&(r.hidden=null!=(o=r["s-ih"])&&o)}r&&"function"==typeof u["s-rf"]&&u["s-rf"](u)}else 1===r.nodeType&&(r.hidden=!0)}}if(Y&&M(d.fe),f.ee&=-2,le.length=0,!X&&!(1&l.ee)&&s["s-cr"]){const e=d.fe.__childNodes||d.fe.childNodes;for(const r of e)if(r["s-hn"]!==T&&!r["s-sh"])if(t&&null==r["s-ih"]&&(r["s-ih"]=null!=(u=r.hidden)&&u),1===r.nodeType)r.hidden=!0;else if(3===r.nodeType&&r.nodeValue.trim()){const e=c.document.createComment("s-nt-"+r.nodeValue);e["s-sn"]=r["s-sn"],pe(r.parentNode,e,r,t),r.parentNode.removeChild(r)}}q=void 0,ee.forEach((e=>e())),ee.length=0,re.forEach((e=>e())),re.length=0},ve=(e,r)=>{if(r&&!e.ve&&r["s-p"]){const t=r["s-p"].push(new Promise((n=>e.ve=()=>{r["s-p"].splice(t-1,1),n()})))}},ye=(e,r)=>{if(e.ee|=16,4&e.ee)return void(e.ee|=512);ve(e,e.ye);const t=()=>be(e,r);if(!r)return w(t);queueMicrotask((()=>{t()}))},be=(e,r)=>{const t=e.$hostElement$,n=t;if(!n)throw Error(`Can't render component <${t.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`);let i;return i=Me(n,r?"componentWillLoad":"componentWillUpdate",void 0,t),i=ge(i,(()=>Me(n,"componentWillRender",void 0,t))),ge(i,(()=>we(e,n,r)))},ge=(e,r)=>xe(e)?e.then(r).catch((e=>{console.error(e),r()})):r(),xe=e=>e instanceof Promise||e&&e.then&&"function"==typeof e.then,we=async(e,r,t)=>{var n;const i=e.$hostElement$,a=i["s-rc"];t&&(e=>{const r=e.D,t=e.$hostElement$,n=r.ee,i=((e,r)=>{var t,n,i;const a=O(r),o=u.get(a);if(!c.document)return a;if(e=11===e.nodeType?e:c.document,o)if("string"==typeof o){let i,u=k.get(e=e.head||e);if(u||k.set(e,u=new Set),!u.has(a)){i=c.document.createElement("style"),i.textContent=o;const s=null!=(t=f.be)?t:function(){var e,r,t;return null!=(t=null==(r=null==(e=c.document.head)?void 0:e.querySelector('meta[name="csp-nonce"]'))?void 0:r.getAttribute("content"))?t:void 0}();if(null!=s&&i.setAttribute("nonce",s),!(1&r.ee))if("HEAD"===e.nodeName){const r=e.querySelectorAll("link[rel=preconnect]"),t=r.length>0?r[r.length-1].nextSibling:e.querySelector("style");e.insertBefore(i,(null==t?void 0:t.parentNode)===e?t:null)}else if("host"in e)if(m){const r=new(null!=(n=e.defaultView)?n:e.ownerDocument.defaultView).CSSStyleSheet;r.replaceSync(o),d?e.adoptedStyleSheets.unshift(r):e.adoptedStyleSheets=[r,...e.adoptedStyleSheets]}else{const r=e.querySelector("style");r?r.textContent=o+r.textContent:e.prepend(i)}else e.append(i);1&r.ee&&e.insertBefore(i,null),4&r.ee&&(i.textContent+="slot-fb{display:contents}slot-fb[hidden]{display:none}"),u&&u.add(a)}}else{let r=k.get(e);if(r||k.set(e,r=new Set),!r.has(a)){const t=null!=(i=e.defaultView)?i:e.ownerDocument.defaultView;let n;if(o.constructor===t.CSSStyleSheet)n=o;else{n=new t.CSSStyleSheet;for(let e=0;e<o.cssRules.length;e++)n.insertRule(o.cssRules[e].cssText,e)}d?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n],r.add(a)}}return a})(t.shadowRoot?t.shadowRoot:t.getRootNode(),r);10&n&&(t["s-sc"]=i,t.classList.add(i+"-h"))})(e);De(e,r,i,t),a&&(a.map((e=>e())),i["s-rc"]=void 0);{const r=null!=(n=i["s-p"])?n:[],t=()=>Ne(e);0===r.length?t():(Promise.all(r).then(t).catch(t),e.ee|=4,r.length=0)}},De=(e,r,t,n)=>{try{r=r.render(),e.ee&=-17,e.ee|=2,he(e,r,n)}catch(r){o(r,e.$hostElement$)}return null},Ne=e=>{const r=e.$hostElement$,t=r,n=e.ye;Me(t,"componentDidRender",void 0,r),64&e.ee?Me(t,"componentDidUpdate",void 0,r):(e.ee|=64,Ce(r),Me(t,"componentDidLoad",void 0,r),e.ge(r),n||Ae()),e.ve&&(e.ve(),e.ve=void 0),512&e.ee&&x((()=>ye(e,!1))),e.ee&=-517},Ae=()=>{x((()=>L(c,"appload",{detail:{namespace:"lido-player"}})))},Me=(e,r,t,n)=>{if(e&&e[r])try{return e[r](t)}catch(e){o(e,n)}},Ce=e=>e.classList.add("hydrated"),Ee=(e,r,t,n)=>{const a=i(e);if(!a)return;const u=e,s=a.O.get(r),c=a.ee,l=u;if(!((t=$(t,n.o[r][0]))===s||Number.isNaN(s)&&Number.isNaN(t))){if(a.O.set(r,t),n.xe){const e=n.xe[r];e&&e.map((e=>{try{const[[n,i]]=Object.entries(e);(128&c||1&i)&&(l?l[n](t,s,r):a.we.push((()=>{a.De[n](t,s,r)})))}catch(e){o(e,u)}}))}if(2&c){if(l.componentShouldUpdate&&!1===l.componentShouldUpdate(t,s,r)&&!(16&c))return;16&c||ye(a,!1)}}},Se=(e,t)=>{var n,a;const o=e.prototype;{e.watchers&&!t.xe&&(t.xe=U(e.watchers)),e.deserializers&&!t.Ne&&(t.Ne=e.deserializers),e.serializers&&!t.Ae&&(t.Ae=e.serializers);const u=Object.entries(null!=(n=t.o)?n:{});u.map((([e,[n]])=>{if(31&n||32&n){const{get:a,set:u}=r(o,e)||{};a&&(t.o[e][0]|=2048),u&&(t.o[e][0]|=4096),Object.defineProperty(o,e,{get(){return a?a.apply(this):((e,r)=>i(this).O.get(r))(0,e)},configurable:!0,enumerable:!0}),Object.defineProperty(o,e,{set(r){const a=i(this);if(a){if(u)return void 0===(32&n?this[e]:a.$hostElement$[e])&&a.O.get(e)&&(r=a.O.get(e)),u.call(this,$(r,n)),void Ee(this,e,r=32&n?this[e]:a.$hostElement$[e],t);Ee(this,e,r,t)}}})}}));{const r=new Map;o.attributeChangedCallback=function(e,n,a){f.jmp((()=>{var s;const c=r.get(e),l=i(this);if(this.hasOwnProperty(c),o.hasOwnProperty(c)&&"number"==typeof this[c]&&this[c]==a)return;if(null==c){const r=null==l?void 0:l.ee;if(l&&r&&!(8&r)&&a!==n){const i=this,o=null==(s=t.xe)?void 0:s[e];null==o||o.forEach((t=>{const[[o,u]]=Object.entries(t);null!=i[o]&&(128&r||1&u)&&i[o].call(i,a,n,e)}))}return}const f=u.find((([e])=>e===c)),m=f&&4&f[1][0],d=m&&null===a&&void 0===this[c];m&&(a=null!==a&&"false"!==a);const p=Object.getOwnPropertyDescriptor(o,c);d||a==this[c]||p.get&&!p.set||(this[c]=a)}))},e.observedAttributes=Array.from(new Set([...Object.keys(null!=(a=t.xe)?a:{}),...u.filter((([e,r])=>31&r[0])).map((([e,n])=>{var i;const a=n[1]||e;return r.set(a,e),512&n[0]&&(null==(i=t.he)||i.push([e,a])),a}))]))}}return e},Fe=(e,r)=>{const t={ee:r[0],ne:r[1]};try{t.o=r[2],t.xe=U(e.xe),t.Ne=e.Ne,t.Ae=e.Ae,t.he=[];const a=e.prototype.connectedCallback,s=e.prototype.disconnectedCallback;return Object.assign(e.prototype,{__hasHostListenerAttached:!1,__registerHost(){((e,r)=>{const t={ee:0,$hostElement$:e,D:r,O:new Map,Me:new Map};t.Ce=new Promise((e=>t.ge=e)),e["s-p"]=[],e["s-rc"]=[];const i=t;e.__stencil__getHostRef=()=>i,512&r.ee&&n(e,t)})(this,t)},connectedCallback(){if(!this.__hasHostListenerAttached){if(!i(this))return;this.__hasHostListenerAttached=!0}(e=>{if(!(1&f.ee)){const r=i(e);if(!r)return;const t=r.D,n=()=>{};if(1&r.ee)(null==r?void 0:r.De)||(null==r?void 0:r.Ce)&&r.Ce.then((()=>{}));else{r.ee|=1,12&t.ee&&(e=>{if(!c.document)return;const r=e["s-cr"]=c.document.createComment("");r["s-cn"]=!0,pe(e,r,e.firstChild)})(e);{let t=e;for(;t=t.parentNode||t.host;)if(t["s-p"]){ve(r,r.ye=t);break}}t.o&&Object.entries(t.o).map((([r,[t]])=>{if(31&t&&Object.prototype.hasOwnProperty.call(e,r)){const t=e[r];delete e[r],e[r]=t}})),(async(e,r,t)=>{let n;try{if(!(32&r.ee)&&(r.ee|=32,n=e.constructor,customElements.whenDefined(e.localName).then((()=>r.ee|=128)),n&&n.style)){let e;"string"==typeof n.style&&(e=n.style);const r=O(t);if(!u.has(r)){const n=()=>{};((e,r,t)=>{let n=u.get(e);m&&t?(n=n||new CSSStyleSheet,"string"==typeof n?n=r:n.replaceSync(r)):n=r,u.set(e,n)})(r,e,!!(1&t.ee)),n()}}const i=r.ye,a=()=>ye(r,!0);i&&i["s-rc"]?i["s-rc"].push(a):a()}catch(t){o(t,e),r.ve&&(r.ve(),r.ve=void 0),r.ge&&r.ge(e)}})(e,r,t)}n()}})(this),a&&a.call(this)},disconnectedCallback(){(async e=>{k.has(e)&&k.delete(e),e.shadowRoot&&k.has(e.shadowRoot)&&k.delete(e.shadowRoot)})(this),s&&s.call(this)},__attachShadow(){if(this.shadowRoot){if("open"!==this.shadowRoot.mode)throw Error(`Unable to re-use existing shadow root for ${t.ne}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`)}else A.call(this,t)}}),Object.defineProperty(e,"is",{value:t.ne,configurable:!0}),Se(e,t)}catch(r){return o(r),e}},Be=e=>f.be=e,qe=e=>Object.assign(f,e),Te=new WeakMap;function ke(e,r){let t=Te.get(r);t||(t={ee:0,D:{ee:0,ne:r.tagName},$hostElement$:r},Te.set(r,t)),he(t,e)}function Oe(e){return e}const Ie="lidoSelectedValues",ze="data-animation-vanished-values",je="lidoActivityScore",Re="lidoActivityEnd",Ue="lidoLessonEnd",$e="lidoNextContainer",Pe="lidoPrevContainer",Le="lidoActivityChange",_e="lidoGameCompleted",We="lidoGameExit",Je="dropLength",Ve="drop-to",He="drop-time",Ze="lido-container",Ge="__LIDO_COMMON_AUDIO_PATH__",Xe="lidoCommonAudioPathReady",Ye="lido:interaction-cleanup",Qe="template-id",Ke="calculator-ok",er="problemEnd",rr="lessonEnd",tr="gameEnd",nr="gameExit";var ir,ar,or;!function(e){e.NoFlow="noFlow",e.ShowFlow="showFlow",e.FreeTrace="freeTrace",e.BlindTracing="blindTracing",e.BlindFreeTrace="blindFreeTrace"}(ir||(ir={}));class ur{constructor(){this.totalRightMovesCount=0,this.totalWrongMovesCount=0,this.rightMoves=0,this.wrongMoves=0,this.finalScore=0}}!function(e){e.Diagonal="diagonal",e.Stretch="stretch",e.InfiniteDrop="infinite-drop",e.EnableAnimation="enableanimation"}(ar||(ar={})),function(e){e.InfiniteDrop="infinite-drop",e.Move="move",e.Hide="hide"}(or||(or={}));const sr="https://aeakbcdznktpsbrfsgys.supabase.co/storage/v1/object/public/template-assets/Navbar-buttons/Close.png",cr="https://aeakbcdznktpsbrfsgys.supabase.co/storage/v1/object/public/template-assets/Navbar-buttons/Previous.png",lr="https://aeakbcdznktpsbrfsgys.supabase.co/storage/v1/object/public/template-assets/Navbar-buttons/Next.png",fr="https://aeakbcdznktpsbrfsgys.supabase.co/storage/v1/object/public/template-assets/Navbar-buttons/NavAudio.png",mr="https://aeakbcdznktpsbrfsgys.supabase.co/storage/v1/object/public/template-assets/trace/Tracing-hand.png",dr={en:new Set(["a","an","the","on","in","at","to","of","for","into","up","or","is","are","were"]),hi:new Set(["का","की","के","में","पर","से","तो","को","है","था","थे"]),kn:new Set(["ಅದು","ಇದು","ನಲ್ಲಿ","ಮೇಲೆ","ಮತ್ತು","ಇದೆ","ಆಗಿತ್ತು"])},pr={en:{expectedWPM:135,minWordMs:80,syllableWeight:1.28,punctuationPauseWeight:.45,preemptiveOffsetMs:55,smoothingMs:25,fastWordMultiplier:.65,fastClusterMultiplier:.65},hi:{expectedWPM:155,minWordMs:40,syllableWeight:1.3,punctuationPauseWeight:.3,preemptiveOffsetMs:20,smoothingMs:45,fastWordMultiplier:.9,fastClusterMultiplier:.9},kn:{expectedWPM:85,minWordMs:35,syllableWeight:1.75,punctuationPauseWeight:.5,preemptiveOffsetMs:15,smoothingMs:50,fastWordMultiplier:1,fastClusterMultiplier:1}};function hr(e,r){var t;const n=new CustomEvent(e,{detail:r});window.dispatchEvent(n),e!==Re&&e!==Ue&&e!==_e&&e!==We&&e!==tr&&e!==nr&&e!==rr&&e!==er||null===(t=window.parent)||void 0===t||t.postMessage({eventName:e,detail:vr(r)},"*")}function vr(e){return e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter((([,e])=>null===e||["string","number","boolean","undefined"].includes(typeof e)||Array.isArray(e)||"object"==typeof e&&e.constructor===Object))):e}function yr(){hr(nr,{}),"blank"!==$F().end&&"complete"!==$F().end&&"completed"!==$F().end&&hr(We,{})}function br(e){hr(Le,{index:e})}function gr(e,r){hr("lidoElementClick",{element:e,isCorrect:r,createdAt:(new Date).toISOString()})}class xr{constructor(){}static getInstance(){return xr.instance||(xr.instance=new xr),xr.instance}setRiveInstance(e){this.riveInstance=e}getRiveInstance(){return this.riveInstance}}function wr(){var e,r;const t=document.querySelector("lido-balance");if(!t)return;const n=Array.from(document.querySelectorAll('[drop-to^="lefthandle"]')),i=Array.from(document.querySelectorAll('[drop-to^="righthandle"]'));t.leftVal=Dr(n,t.operation),t.rightVal=Dr(i,t.operation);const a=document.getElementById("lido-container"),o=null!==(r=null!==(e=null==a?void 0:a.objective)&&void 0!==e?e:null==a?void 0:a.getAttribute("objective"))&&void 0!==r?r:"",u=!!a&&Nr(a,o),s=a?Array.from(a.querySelectorAll('[type="drop"]')):[],c=s.filter((e=>!!(null==a?void 0:a.querySelector(`[drop-to="${e.id}"]`)))).length,l=s.length>0&&c===s.length;if(t.setFeedbackColor&&t.setFeedbackColor(l&&u?"#81C127":l?"#FF0410":""),t.updateTilt){if(!u)return void t.updateTilt(0,0);t.updateTilt(t.leftVal,t.rightVal)}}function Dr(e,r){if(0===e.length)return null;if("count"===r)return e.length;const t=e.map((e=>e.getAttribute("value")||"0")).join(["add","+"].includes(r)?" + ":["subtract","-"].includes(r)?" - ":["multiply","*"].includes(r)?" * ":["divide","/"].includes(r)?" / ":" + ");try{const e=tB(t);return"number"==typeof e?e:"boolean"==typeof e?e?1:0:parseFloat(t)||0}catch(e){return console.warn("invalid exp",t),0}}function Nr(e,r){if(!e.getAttribute("equationCheck"))return!1;const t=document.querySelector("lido-balance");if(!t)return!1;const n=t.leftVal,i=t.rightVal;return null!=n&&null!=i&&r===(n>i?">":n<i?"<":"=")}function Ar(e,r,t){e.style.pointerEvents="none",setTimeout((async()=>{var n,i;const a=document.createElement("div");e.append(a),a.classList.add("after-drop-popup-container"),r.style.scale="1",t.style.scale="1";const o=e.querySelectorAll('[type="drag"]'),u=Array.from(o).map((e=>e.parentElement)).every((e=>e===r.parentElement)),s=(e=>{var r;try{const t=JSON.parse(null!==(r=e.getAttribute(ze))&&void 0!==r?r:"[]");return Array.isArray(t)?t:[]}catch(e){return[]}})(e),c=null!==(n=r.getAttribute("value"))&&void 0!==n?n:null===(i=r.textContent)||void 0===i?void 0:i.trim();c&&(s.push(c),e.setAttribute(ze,JSON.stringify(s))),u?(r.remove(),t.remove()):(r.parentElement.parentElement.remove(),t.parentElement.parentElement.remove()),r.classList.add("zoom-fade-in","after-drop-popup-drag-element"),t.classList.add("zoom-fade-in","after-drop-popup-drop-element"),a.appendChild(r),a.appendChild(t),t.classList.remove("empty");const l=e.getAttribute("objective"),f=s.map((e=>e.trim())).sort().join(","),m=null==l?void 0:l.split(",").map((e=>e.trim())).sort().join(","),d=!!l&&f===m;if("drop"===t.getAttribute("type")){const e=t.getAttribute("onCorrect")||"";await qF(e,t,r)}if(d){const r=(null==e?void 0:e.getAttribute("onCorrect"))||"";await qF(r,e)}r.classList.remove("zoom-fade-in"),t.classList.remove("zoom-fade-in"),r.classList.add("zoom-fade-out"),t.classList.add("zoom-fade-out");const p=()=>{a.remove(),e.style.pointerEvents="auto",d&&(RF(),HF(),e.removeAttribute(ze))},h=(e.getAttribute("template-id")||"").toLowerCase();"letterpairing"===h||"numberpair"===h?p():setTimeout(p,800)}),250)}const Mr=e=>"blender"===(null==e?void 0:e.getAttribute("template-id"));function Cr(){const e={};return document.querySelectorAll("[type='drop']").forEach((r=>{const t=r.getAttribute("tab-index")||r.id,n=!!document.querySelector(`[${Ve}="${r.id}"]`);r.setAttribute("is-full",n+""),e[t]={drop:r.id,isFull:n}})),e}const Er=e=>{e.style.animation="unset";const r=window.getComputedStyle(e).transform;if("none"===r)return 1;{const e=r.match(/matrix\(([^)]+)\)/);if(e){const r=e[1].split(", ");return parseFloat(r[0])}}return 1};let Sr=!1;const Fr=e=>{Sr=e};const Br=(e,r)=>{const t=e.getBoundingClientRect(),n=document.querySelectorAll(`[type="${r}"]`);let i=null,a=0;return n.forEach((n=>{if(n===e)return;const o=n.getBoundingClientRect(),u=Math.max(0,Math.min(t.right,o.right)-Math.max(t.left,o.left))*Math.max(0,Math.min(t.bottom,o.bottom)-Math.max(t.top,o.top));0!==u&&("slide"===r?u>=.1*Math.min(t.width*t.height,o.width*o.height)&&u>a&&(a=u,i=n):u>a&&(a=u,i=n))})),i};function qr(e,r,t){if(!r||!e||!t)return;const n=r.getBoundingClientRect(),i=e.getBoundingClientRect(),a=window.getComputedStyle(e),o=new DOMMatrixReadOnly(a.transform),u=o.m42||0,s=n.top-i.top,c=(o.m41||0)+(n.left-i.left)*(1/cB()),l=u+s*(1/cB());e.style.transition="transform 1s ease",e.style.transform=`translate(${c}px, ${l}px)`}async function Tr(e,r,t,n,i){var a;e.classList.remove("dropped");const o=document.getElementById(Ze),u=o.querySelectorAll("#"+e.id),s=e.__lidoBalanceHome,c=(null==s?void 0:s.isConnected)?s:Array.from(u).find((r=>e!==r&&!r.classList.contains("dropped")));e.style.transition="transform 0.5s ease",c?(qr(e,c,o),setTimeout((()=>{o.getAttribute("drop-action")===or.InfiniteDrop?(e.removeAttribute("hasDummy"),e.style.width=c.style.width,e.style.height=c.style.height):(c.style.width=e.style.width,c.style.height=e.style.height),e.style.transform="translate(0,0)",e.style.position="unset",c.replaceWith(e),delete e.__lidoBalanceHome}),500)):e.style.transform="translate(0,0)";let l=zr.get(e);if(l){if(zr.delete(e),Or(l),(null===(a=null==l?void 0:l.getAttribute("drop-attr"))||void 0===a?void 0:a.toLowerCase())===ar.Stretch){const e=l.getAttribute("data-original-width");e?(l.style.width=e,l.removeAttribute("data-original-width")):(l.style.width="",l.removeAttribute("data-original-width"))}let r=Object.values(t).find((e=>document.getElementById(e.drop)===l));if(r){r.isFull=!1,_r();const e=document.getElementById(r.drop);e&&e.removeAttribute("is-full")}zr.delete(e)}if(n){const e=EF(CF());o.setAttribute(Ie,JSON.stringify(e))}if(i){let r=JSON.parse(i);const t=o.querySelector("#"+e.getAttribute(Ve));t&&delete r[t.getAttribute("tab-index")],e.removeAttribute(Ve),Or(l);const n=EF(CF());n&&n.length>0?o.setAttribute(Ie,JSON.stringify(n)):o.removeAttribute(Ie),wr()}document.querySelectorAll("[type='drop']").forEach((e=>{var r;const t=CF();Object.keys(t).map(Number).includes(JSON.parse(e.getAttribute("tab-index")))?(null===(r=e.getAttribute("dropAttr"))||void 0===r?void 0:r.toLowerCase())!==ar.Diagonal&&"lido-text"===e.tagName.toLowerCase()&&(e.style.opacity="1"):e&&(e.style.opacity="1")})),await qF("this.updateCountBlender='true'",o),_F(),_r()}async function kr(e,r){var t,n,i,a,o,u,s,c,l;const f=document.getElementById(Ze),m=null!==(t=f.getAttribute(Ie))&&void 0!==t?t:"[]",d=JSON.stringify(CF()),p=CF();JSON.stringify(p);let h,v=Cr();if(r||Tr(e,0,v,m,d),r){h=r.getAttribute("tab-index");const t="false"===r.getAttribute("is-allow-only-one-drop");if((null===(n=v[h])||void 0===n?void 0:n.isFull)&&!t)return void Tr(e,0,v,m,d)}if("true"===f.getAttribute("is-allow-only-correct")){if(!r)return e.style.transition="transform 0.5s ease",e.style.transform="translate(0, 0)",void Tr(e,0,v,m,d);let t;const n=(null===(i=e.getAttribute("value"))||void 0===i?void 0:i.trim())||"",o=(null===(a=r.getAttribute("value"))||void 0===a?void 0:a.trim())||"";if(Number(n)){const e=Number(n);t=o.includes(",")?o.split(",").some((r=>Number(r)===e)):Number(o)===e}else t=o.includes(",")?o.toLowerCase().includes(n.toLowerCase()):o.toLowerCase()===n.toLowerCase();if(!t){e.style.transition="transform 0.5s ease",qr(e,r,f);const t=r.getAttribute("onInCorrect");return await qF(t,r,e),jF(!1),setTimeout((()=>{e.style.transform="translate(0, 0)",Tr(e,0,v,m,d)}),500),void("option"===e.type&&Array.from(f.querySelectorAll(`[value="${e.value}"]`)).forEach((r=>{r!==e&&r.getAttribute("value")===e.getAttribute("value")&&r.replaceWith(e)})))}{const t=f.getAttribute("dropAttr");t&&t.toLowerCase()===ar.EnableAnimation.toLowerCase()&&Ar(f,e,r)}}else{const t=f.getAttribute("dropAttr");t&&t.toLowerCase()===ar.EnableAnimation.toLowerCase()&&Ar(f,e,r)}if(r){let t=JSON.parse(null!==(o=f.getAttribute(Ie))&&void 0!==o?o:"[]");const n=e.getAttribute("value");if(n&&!t.includes(n)&&t.push(n),f.setAttribute(Ie,JSON.stringify(t)),"stretch"===r.getAttribute("drop-attr")){if(!r.hasAttribute("data-original-width")){const e=window.getComputedStyle(r);r.setAttribute("data-original-width",e.width)}r.style.width=e.offsetWidth+"px"}if((null===(u=r.getAttribute("dropAttr"))||void 0===u?void 0:u.toLowerCase())!==ar.Diagonal&&("1"===r.getAttribute("minDrops")||!r.getAttribute("minDrops"))){const t=Object.values(v).find((e=>document.getElementById(e.drop)===r));if("true"===r.getAttribute("is-allow-only-one-drop")&&t?(t.isFull=!0,r.setAttribute("is-full","true"),_r()):console.warn("No matching drop item found for",r),d){let r=JSON.parse(d);for(const t in r)if(r[t].includes(e.value)&&e.classList.contains("dropped")){const t=e.getAttribute("drop-to"),n=f.querySelector("#"+t).getAttribute("tab-index");n&&delete r[n]}}if(e.classList.add("dropped"),e&&(r?e.setAttribute(Ve,null==r?void 0:r.id):e.removeAttribute(Ve),e.setAttribute(He,""+(new Date).getTime())),r&&!(null===(s=v[h])||void 0===s?void 0:s.isFull)){let t=Br(e,"drag");if("true"===r.getAttribute("is-allow-only-one-drop")&&t)return e.style.transform="translate(0,0)",e.style.transition="transform 0.5s ease",void document.querySelectorAll("[type='drop']").forEach((e=>{var r;const t=CF();Object.keys(t).map(Number).includes(JSON.parse(e.getAttribute("tab-index")))?(null===(r=e.getAttribute("dropAttr"))||void 0===r?void 0:r.toLowerCase())!==ar.Diagonal&&e&&(e.style.opacity="0"):e&&(e.style.opacity="1")}))}}}if(!r)return void Tr(e,0,v,m,d);if(wr(),d){let r=zr.get(e);if(r){let e=Object.values(v).find((e=>document.getElementById(e.drop)===r));e&&(e.isFull=!1,Rr())}}let y=parseInt(null!==(c=f.getAttribute(Je))&&void 0!==c?c:"0");if(y+=1,f.setAttribute(Je,y+""),y===IF(r.value)){const e=Object.values(v).find((e=>document.getElementById(e.drop)===r));e?e.isFull=!0:console.warn("No matching drop item found for",r),y=0,f.setAttribute(Je,y+"")}zr.set(e,r);const b=r.value.toLowerCase().includes(e.value.toLowerCase());if(function(e,r,t){hr("lidoElementDrop",{dragElement:e,dropElement:r,isCorrect:t,createdAt:(new Date).toISOString()})}(e,r,b),Mr(f)||jF(b),e.style.opacity="1",document.querySelectorAll(".drop-element").forEach((e=>Or(e))),Mr(f)){const t=Number(null!==(l=r.getAttribute("required-drops"))&&void 0!==l?l:0),n=document.querySelectorAll(`[${Ve}="${r.id}"]`).length,i=r.getAttribute(n>0&&n<=t?"onCorrect":"onInCorrect");i&&await qF(i,r,e)}_r(),await UF(e,r);const g=f.getAttribute("drop-action");f.querySelector("lido-balance")&&g!==or.Move&&g!==or.InfiniteDrop&&function(e,r){var t;const n=document.querySelector("lido-balance"),i=null==r?void 0:r.parentElement;if(!n||!i)return;const a=e;if(!(null===(t=a.__lidoBalanceHome)||void 0===t?void 0:t.isConnected)){const e=document.createElement("div");e.className="lido-balance-source-placeholder",e.setAttribute("aria-hidden","true"),a.replaceWith(e),a.__lidoBalanceHome=e}i.append(a),a.style.position="absolute",a.style.zIndex="1",a.style.transition="none",a.style.transform="translate(0, 0)";const o=r.getBoundingClientRect(),u=a.getBoundingClientRect(),s=cB()||1;a.style.transform=`translate(${(o.left+o.width/2-(u.left+u.width/2))/s}px, ${(o.top+o.height/2-(u.top+u.height/2))/s}px)`,requestAnimationFrame((()=>{a.style.transition=""}))}(e,r)}function Or(e){var r;if(!e||!e.classList.contains("drop-element"))return;const t=document.getElementById(Ze);if(!t)return;if("true"!==t.getAttribute("show-drop-border")&&!Mr(t))return;const n=document.querySelectorAll(`[${Ve}="${e.id}"]`);if(Mr(t)){const t=Number(null!==(r=e.getAttribute("required-drops"))&&void 0!==r?r:0),i=n.length,a=i>0&&i<=t;return e.classList.toggle("empty",!a),e.classList.remove("filled"),void e.style.setProperty("border",a?"5px dashed green":"5px dashed #f34d08","important")}n.length>0&&!Mr(t)?(e.classList.add("filled"),e.classList.remove("empty"),e.classList.remove("highlight-element")):(e.classList.contains("math-matrix")||e.classList.add("empty"),e.classList.remove("filled"))}async function Ir(e,r){const t=document.getElementById(Ze);if("false"===t.getAttribute("canplay")||"true"===t.getAttribute("game-completed"))return;if(document.querySelectorAll(`[type='${r}']`).forEach((e=>{e.style.pointerEvents="",$r(e)})),!document.querySelector("#dynamic-highlight-style")){const e=document.createElement("style");e.id="dynamic-highlight-style",e.innerHTML="\n .highlight {\n // border: 4px solid #e74c3c; /* Thicker red border for more visibility */\n // border-radius: 12px; /* Larger rounded corners */\n // background-color: rgba(231, 76, 60, 0.3); /* Stronger, more noticeable background */\n // box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2), 0 12px 40px rgba(0, 0, 0, 0.2); /* Stronger shadow */\n // outline: 4px solid rgba(231, 76, 60, 0.6); /* Glow effect */\n }\n ",document.head.appendChild(e)}null==e||e.classList.add("highlight-element"),e.style.pointerEvents="none",e.ariaPressed="true";const n="drop"===r?e:document.querySelector("[type='drop'].highlight-element"),i="drag"===r?e:document.querySelector("[type='drag'].highlight-element");if(setTimeout((()=>{e.style.pointerEvents=""}),1e3),n&&!e.classList.contains("dropped")){if(!e.classList.contains("drop-element")&&n&&i){if(n.style.pointerEvents="none",i.style.pointerEvents="none",i.getAttribute("drop-to"))return;i.style.transition="transform 0.5s ease",i.style.transform="";const e=document.getElementById(Ze),r=Er(e),t=n.getBoundingClientRect(),a=i.getBoundingClientRect();i.style.transform=`translate(${(t.left-a.left)/r}px, ${(t.top-a.top)/r}px)`,Mr(e)||document.querySelectorAll("*").forEach((e=>{$r(e)})),await kr(i,n),e.getAttribute("drop-action")!==or.InfiniteDrop&&e.getAttribute("drop-action")!==or.Move&&(i.style.pointerEvents=""),n.style.pointerEvents="",await qF("this.updateCountBlender='true'",e)}}else!async function(e){const r=e.getAttribute("audio");r&&r.trim().length>0&&Wr.getI().stop();const t=Cr(),n=e;if(!n)return void console.error("Element not found");const i=getComputedStyle(n).transform;if($r(e),i&&"none"!==i&&"matrix(1, 0, 0, 1, 0, 0)"!==i)return void kr(n,null);let a=Object.values(t).find((e=>!e.isFull));if(a){const e=document.querySelector("#"+a.drop);n.style.transition="transform 0.5s ease",await kr(n,e);const r=document.getElementById(Ze);await qF("this.updateCountBlender='true'",r)}}(e)}const zr=new Map,jr=document.getElementById(Ze),Rr=()=>{const e=document.querySelectorAll("[type='drop']");let r=CF();e&&jr&&r&&e&&e.forEach((e=>{var t;const n=e,i=n.getAttribute("tab-index");if((null===(t=null==n?void 0:n.getAttribute("drop-attr"))||void 0===t?void 0:t.toLowerCase())===ar.Stretch&&!1===r[i].isFull){const r=n.getAttribute("data-original-width");e.removeAttribute("is-full"),r&&(n.style.width=r,n.removeAttribute("data-original-width"))}}))},Ur=e=>{var r,t;const n=document.getElementById("lido-container").querySelector("#beedsText");if(!n)return;const i=null!==(r=e.getAttribute("cols"))&&void 0!==r?r:"";if(""===i.trim())return;const a=(null!==(t=n.textContent)&&void 0!==t?t:"").trim();if(""===a)return void(n.textContent=i);const o=a.split("=")[0].trim(),u=o?`${o}+${i}`:i,s=u.split("+").map((e=>Number(e.trim()))).reduce(((e,r)=>Number.isNaN(r)?NaN:e+r),0);n.textContent=Number.isNaN(s)?u:`${u}=${s}`};function $r(e){e.classList.remove("highlight-element"),e.ariaPressed="false"}function Pr(e){if(!e)return;e.classList.add("speaking-highlight");const r="speaking-highlight-style";if(!document.getElementById(r)){const t=document.createElement("style");t.id=r,t.innerHTML=`\n .speaking-highlight {\n --base-transform: ${e.style.transform};\n box-shadow: 0 0 20px 10px rgba(255, 165, 0, 0.9) !important; /* Stronger orange glow effect */\n // border: 3px solid green !important;\n // transition: box-shadow 0.5s ease-in-out, transform 0.5s ease-in-out;\n // transform: scale(1.05); /* Subtle scale effect to pop the element */\n // animation: pulseEffect 1.5s infinite; /* Pulsing animation */\n \n }\n\n @keyframes pulseEffect {\n 0% {\n box-shadow: 0 0 20px 10px rgba(255, 165, 0, 0.9);\n // transform: var(--base-transform) scale(1.05);\n // background-color: #FFFF0B;\n }\n 50% {\n box-shadow: 0 0 30px 15px rgba(255, 165, 0, 1);\n // transform: var(--base-transform) scale(1.1);\n // background-color: #FFFF0B;\n }\n 100% {\n box-shadow: 0 0 20px 10px rgba(255, 165, 0, 0.9);\n // transform: var(--base-transform) scale(1.05);\n // background-color: #FFFF0B;\n }\n }\n `,document.head.appendChild(t)}}function Lr(e){e&&e.classList.remove("speaking-highlight")}function _r(){const e=document.querySelector(Ze);if(!e)return;if("blender"===e.getAttribute("template-id"))return;const r=Cr();e.querySelectorAll('[type="drop"]').forEach((e=>{e.classList.remove("highlight-element")}));let t=Object.values(r).find((e=>!e.isFull));if(t){const r=e.querySelector("#"+t.drop);r&&r.classList.add("highlight-element");const n=e.querySelectorAll('[type="drag"]');zF>2&&"true"===e.getAttribute("is-continue-on-correct")?n.forEach((e=>{e.classList.remove("highlight-element"),e.getAttribute("value")===r.getAttribute("value")&&(e.classList.add("highlight-element"),e.classList.remove("drag-element"))})):n.forEach((e=>{e.classList.remove("highlight-element"),e.classList.add("drag-element")}))}else{if(zF<=2||"false"===e.getAttribute("is-continue-on-correct"))return;e.querySelectorAll("[type='click']").forEach((r=>{r.getAttribute("value")===e.getAttribute("objective")&&(r.classList.contains("highlight-element")||r.classList.add("highlight-element"))}))}}class Wr{resolvePlaybackWait(){if(!this.endPromiseResolve)return;const e=this.endPromiseResolve;this.endPromiseResolve=null,e()}constructor(){this.currentTargetElement=null,this.pendingReplayElement=null,this.playbackHasStarted=!1,this.playbackSequence=0,this.highlightOverlay=null,this.wordRects=[],this.activeWordIndex=-1,this.highlightRAF=null,this.endPromiseResolve=null,this.visibilityWaitResolvers=[],this.isVisibilityChangeRegistered=!1,this.stopEvents=[$e,Pe,Ue,Le,Re,_e,We],this.handleGlobalStopEvent=()=>this.stop(),this.handleUserClick=e=>{const r=document.getElementById(Ze);r&&(null==e?void 0:e.target)===r||"true"!==(null==r?void 0:r.getAttribute("game-completed"))&&this.stop()},this.handleVisibilityChange=async()=>{this.isWindowVisible()?this.resolveVisibilityWaiters():this.currentTargetElement&&(this.pendingReplayElement=this.currentTargetElement,await this.stop(!0))},this.audioElement=document.createElement("audio"),this.registerGlobalStopEvents(),this.registerVisibilityEvents()}static getI(){return Wr.instance||(Wr.instance=new Wr),Wr.instance}static destroyI(){Wr.instance&&Wr.instance.destroy()}stop(e=!1){const r=document.getElementById(Ze);r&&"true"===r.getAttribute("highlight-word-by-word")&&this.stopOverlayHighlightLoop(),(null===window||void 0===window?void 0:window.speechSynthesis)&&window.speechSynthesis.cancel(),this.resolvePlaybackWait(),e||(this.pendingReplayElement=null),this.currentTargetElement=null,this.playbackHasStarted=!1,this.audioElement.pause(),this.audioElement.currentTime=0,this.audioElement.src="",r&&"true"!==r.getAttribute("highlight-word-by-word")&&document.querySelectorAll(".speaking-highlight").forEach((e=>Lr(e)));const t=document.querySelector("#play"),n=document.querySelector("#pause");t&&n&&(t.style.visibility="visible",n.style.visibility="hidden")}isWindowVisible(){return"visible"===document.visibilityState&&!document.hidden}waitUntilWindowIsVisible(){return this.isWindowVisible()?Promise.resolve():(this.registerVisibilityEvents(),new Promise((e=>{this.visibilityWaitResolvers.push(e)})))}resolveVisibilityWaiters(){this.visibilityWaitResolvers.splice(0).forEach((e=>e()))}getLidoTextElement(e){return"lido-text"===e.tagName.toLowerCase()?e:e.closest("lido-text")}async play(e,r=!1,t){if(this.registerVisibilityEvents(),this.playbackHasStarted=!1,!this.isWindowVisible()){if(this.pendingReplayElement=e,await this.stop(!0),await this.waitUntilWindowIsVisible(),this.pendingReplayElement!==e)return;this.pendingReplayElement=null}const n=++this.playbackSequence;try{await Wr.getI().stop()}catch(e){console.error("Error stopping audio before speak action:",e)}const i=document.getElementById(Ze);if(!i)return void console.warn("[AudioPlayer] No lido-container found");if("true"===i.getAttribute("highlight-word-by-word")){const r=this.getLidoTextElement(e);if(!r)return void console.warn("[AudioPlayer] No lido-text found");this.stopOverlayHighlightLoop(),e=r}this.currentTargetElement=e,window.dispatchEvent(new CustomEvent("lidoAudioStarted",{detail:{target:e,playbackId:n,playbackContext:t}}));let a=e.getAttribute("audio")||"";if(!a){const r=e.children;for(let e=0;e<r.length;e++){const t=r[e].getAttribute("audio");if(t){a=t;break}}}if(a){a=QF(a),this.audioElement.src=a,this.audioElement.onplaying=()=>{this.playbackHasStarted=!0,window.dispatchEvent(new CustomEvent("lidoAudioPlaying",{detail:{target:e,playbackId:n,playbackContext:t}}))},this.audioElement.onpause=()=>{this.playbackHasStarted&&!this.audioElement.ended&&this.resolvePlaybackWait()},this.audioElement.onstalled=null,this.audioElement.onerror=()=>{this.playbackHasStarted&&this.resolvePlaybackWait()};try{const t=i.getAttribute("Lang")||"en",n=pr[t]||pr[t.split("-")[0]]||pr.en;let a=[];const o="true"===i.getAttribute("highlight-word-by-word");this.audioElement.onloadedmetadata=null,this.audioElement.onended=null,o?(await this.waitForAudioMetadata(),a=this.buildWordTimeline(e.textContent||"",1e3*this.audioElement.duration,n,t),this.wordRects=this.computeWordRects(e)):r||Pr(e),await this.audioElement.play(),o&&this.startOverlayHighlightLoop(a,n),await new Promise((e=>{this.endPromiseResolve=e,this.audioElement.onended=()=>{this.resolvePlaybackWait()}}))}catch(e){}finally{this.audioElement.onended=null,this.audioElement.onloadedmetadata=null,this.stopOverlayHighlightLoop(),window.removeEventListener("click",this.handleUserClick,!0),this.audioElement.onended=null,Fr(!1),"true"!==i.getAttribute("highlight-word-by-word")&&(r||Lr(e))}}else if(e.textContent)try{r||Pr(e),await async function(e,r){return new Promise(((t,n)=>{if(!("speechSynthesis"in window))return void n(Error("Speech synthesis is not supported in this browser."));const i=window.speechSynthesis;setTimeout((()=>{const n=new SpeechSynthesisUtterance(e);n.onend=()=>{t(!0)},i.speak(n),i.speaking||Lr(r)}),50)}))}(e.textContent,e)}catch(e){}finally{Fr(!1)}if(this.pendingReplayElement===e&&(await this.waitUntilWindowIsVisible(),this.pendingReplayElement===e))return this.pendingReplayElement=null,this.play(e,r,t);this.currentTargetElement===e&&(this.currentTargetElement=null),window.dispatchEvent(new CustomEvent("lidoAudioEnded",{detail:{target:e,playbackId:n,playbackContext:t}}))}registerGlobalStopEvents(){this.stopEvents.forEach((e=>{window.addEventListener(e,this.handleGlobalStopEvent)}))}unregisterGlobalStopEvents(){this.stopEvents.forEach((e=>{window.removeEventListener(e,this.handleGlobalStopEvent)}))}registerVisibilityEvents(){this.isVisibilityChangeRegistered||(document.addEventListener("visibilitychange",this.handleVisibilityChange),this.isVisibilityChangeRegistered=!0)}unregisterVisibilityEvents(){this.isVisibilityChangeRegistered&&(document.removeEventListener("visibilitychange",this.handleVisibilityChange),this.isVisibilityChangeRegistered=!1,this.resolveVisibilityWaiters())}destroy(){this.stop(),this.unregisterGlobalStopEvents(),this.unregisterVisibilityEvents(),this.audioElement.parentNode&&this.audioElement.parentNode.removeChild(this.audioElement),Wr.instance=void 0}countSyllables(e,r){if("en"!==r)return Math.max(2,Math.ceil(e.length/3));const t=e.toLowerCase().replace(/[^a-z]/g,"");if(t.length<=3)return 1;const n=t.match(/[aeiouy]{1,2}/g);return n?n.length:1}tokenize(e){return e.split(/(\s+)/).filter(Boolean)}isFastCluster(e,r,t){if(!e||!r||!t)return!1;const n=dr[t];return(null==n?void 0:n.has(e))&&(null==n?void 0:n.has(r))}buildWordTimeline(e,r,t,n){const i=this.tokenize(e).filter((e=>e.trim())),a=i.map(((e,r)=>{var a,o;const u=null===(a=i[r-1])||void 0===a?void 0:a.toLowerCase(),s=e.toLowerCase();let c=this.countSyllables(e,n)*t.syllableWeight;return/[.,!?]$/.test(e)&&(c+=t.punctuationPauseWeight),(null===(o=dr[n])||void 0===o?void 0:o.has(s))&&(c*=t.fastWordMultiplier),this.isFastCluster(u,s,n)&&(c*=t.fastClusterMultiplier),c})),o=a.reduce(((e,r)=>e+r),0);let u=0;const s=i.map(((e,n)=>{let i=a[n]/o*r;i=Math.max(t.minWordMs,i);const s={word:e,index:n,startMs:u,endMs:u+i};return u+=i,s})),c=s[s.length-1];if(c&&c.endMs!==r){const e=r/c.endMs;s.forEach((r=>{r.startMs*=e,r.endMs*=e}))}return s}waitForAudioMetadata(){return Number.isFinite(this.audioElement.duration)&&this.audioElement.duration>0?Promise.resolve():new Promise(((e,r)=>{const t=()=>{this.audioElement.removeEventListener("loadedmetadata",n),this.audioElement.removeEventListener("error",i)},n=()=>{t(),e()},i=()=>{t(),r(Error("Audio metadata failed to load"))};this.audioElement.addEventListener("loadedmetadata",n,{once:!0}),this.audioElement.addEventListener("error",i,{once:!0})}))}ensureOverlay(){if(this.highlightOverlay)return;const e=document.createElement("div");e.className="lido-tts-highlight-overlay",document.body.appendChild(e),this.highlightOverlay=e}clearOverlay(){this.highlightOverlay&&(this.highlightOverlay.remove(),this.highlightOverlay=null)}computeWordRects(e){const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),t=[];let n,i=0;for(;n=r.nextNode();){const e=n.textContent||"",r=e.split(/\s+/).filter(Boolean);let a=0;r.forEach((r=>{const o=e.indexOf(r,a),u=o+r.length;if(o>=0){const e=document.createRange();e.setStart(n,o),e.setEnd(n,u);const r=e.getBoundingClientRect();r.width>0&&r.height>0&&(t[i++]=r)}a=u}))}return t}moveOverlay(e){this.highlightOverlay&&(this.highlightOverlay.style.transform=`translate3d(${e.left}px, ${e.top}px, 0)`,this.highlightOverlay.style.width=e.width+"px",this.highlightOverlay.style.height=e.height+"px")}getHighlightLeadMs(e,r){if(!e.length)return r.preemptiveOffsetMs;const t=(e[e.length-1].endMs-e[0].startMs)/e.length;return Math.max(r.preemptiveOffsetMs,t<190?120:t<260?90:60)}getTimelineIndex(e,r){if(!e.length)return-1;if(r<=e[0].startMs)return 0;for(let t=0;t<e.length;t++){if(r>=e[t].startMs&&r<e[t].endMs)return t;if(e[t+1]&&r<e[t+1].startMs)return t}return e.length-1}startOverlayHighlightLoop(e,r){this.ensureOverlay(),this.activeWordIndex=-1;const t=this.getHighlightLeadMs(e,r),n=()=>{if(this.audioElement.paused||this.audioElement.ended)return void this.stopOverlayHighlightLoop();const r=this.getTimelineIndex(e,1e3*this.audioElement.currentTime+t);if(r>=0&&this.activeWordIndex>=0&&r-this.activeWordIndex>=2){const e=this.activeWordIndex+1;this.wordRects[e]&&(this.moveOverlay(this.wordRects[e]),this.activeWordIndex=e)}r!==this.activeWordIndex&&this.wordRects[r]&&(this.moveOverlay(this.wordRects[r]),this.activeWordIndex=r),this.highlightRAF=requestAnimationFrame(n)};this.highlightRAF=requestAnimationFrame(n)}stopOverlayHighlightLoop(){null!==this.highlightRAF&&(cancelAnimationFrame(this.highlightRAF),this.highlightRAF=null),this.clearOverlay(),this.activeWordIndex=-1}}let Jr;const Vr=e=>{const r=document.createElement("div");if("option"===e.getAttribute("type"))return r.style.width=e.style.width,r.style.height=e.style.height,r;const t=e.style.width,n=e.style.padding;return e.style.width="auto",e.style.padding="0 20px",r.style.width=e.offsetWidth+20+"px",r.style.height=e.offsetHeight+20+"px",r.style.border="1px solid",r.style.backgroundColor="#00000021",r.style.borderRadius="10px",e.style.width=t,e.style.padding=n,r.setAttribute("value",""+e.getAttribute("value")),r};const Hr=e=>{e.style.opacity="",e.style.cursor="move",e.style.zIndex="",e.style.transform="",e.style.position="",e.style.left="",e.style.top=""};function Zr(e,r){const t=Array.from(document.querySelectorAll(`[type="${r}"]`));let n=0,i=null;const a=e.getBoundingClientRect();for(const r of t){if(r===e)continue;const t=Xr(a,r.getBoundingClientRect());t>n&&(n=t,i=r)}return i}function Gr(e){return e instanceof MouseEvent?{clientX:e.clientX,clientY:e.clientY}:{clientX:e.touches[0].clientX,clientY:e.touches[0].clientY}}function Xr(e,r){return Math.max(0,Math.min(e.right,r.right)-Math.max(e.left,r.left))*Math.max(0,Math.min(e.bottom,r.bottom)-Math.max(e.top,r.top))}const Yr=(e,r)=>{var t;const n=document.getElementById(Ze),i=n.getAttribute("objective").split(",");let a=JSON.parse(null!==(t=n.getAttribute(Ie))&&void 0!==t?t:"[]");a=Array.from(e.children).map((e=>e.getAttribute("value"))),n.setAttribute(Ie,JSON.stringify(a));const o=a.indexOf(r.value);if(o>=0){const e=OF(r.value,[i[o].trim()]);!e&&n.getAttribute("is-allow-only-correct")&&Array.from(n.querySelectorAll(`[value="${r.value}"]`)).find((e=>e!==r)).replaceWith(r),jF(e),_F()}},Qr=new WeakMap;async function Kr(e,r){let t=CF(),n=t[r.getAttribute("tab-index")];if(!Array.isArray(n)||!n.includes(e.value)){for(const r in t){const n=t[r].indexOf(e.value);-1!==n&&t[r].splice(n,1)}(null==r?void 0:r.id)&&e.setAttribute(Ve,r.id),await UF(e,r)}}const et=e=>new Promise((r=>setTimeout(r,e))),rt=e=>"arrangeLetters"===e.getAttribute("template-id"),tt=e=>"reorder"===e.getAttribute("template-id"),nt=(e,r)=>tt(e)?r.map((e=>e.id)):r.map((e=>e.value)),it=async()=>{const e=document.getElementById(Ze);if(!e)return;e.style.pointerEvents="none";const r=Array.from(e.querySelectorAll('[type="slide"]')),t=Er(e),n=r.length,i=n%2==0?n:n-1;for(let e=0;e<i;e+=2){const n=r[e],i=r[e+1],a=n.getBoundingClientRect(),o=i.getBoundingClientRect(),u=(o.left+o.width/2-(a.left+a.width/2))/t,s=(o.top+o.height/2-(a.top+a.height/2))/t;n.style.transition=i.style.transition="transform 0.5s ease",n.style.transform=`translate(${u}px, ${s}px)`,i.style.transform=`translate(${-u}px, ${-s}px)`}await et(800);for(let e=0;e<i;e++)r[e].style.transform="translate(0, 0)";await et(500);for(let e=0;e<i;e++)r[e].style.transition="";e.style.pointerEvents=""};const at=async e=>{var r;const t=document.getElementById(Ze),n=JSON.parse(null!==(r=t.getAttribute(Ie))&&void 0!==r?r:"[]"),i=Array.from(document.querySelectorAll("[type='slide']")),a=nt(t,i);a.forEach(((e,r)=>{n[r]=e})),t.setAttribute(Ie,JSON.stringify(n));const o=document.getElementById(Ze).objective.split(","),u=i.indexOf(e),s=u>=0&&u<o.length&&OF(a[u],[o[u].trim()]);(rt(t)||tt(t))&&((e,r,t)=>{Array.from(e.querySelectorAll('[type="slide"]')).forEach(((e,n)=>{n<t.length&&r[n]===t[n].trim()?uB(e,"#65BC46"):e.style.removeProperty("box-shadow")}))})(t,a,o),"true"===t.getAttribute("is-continue-on-correct")?jF(!0):jF(s),(rt(t)||tt(t))&&await ot(a)},ot=async e=>{const r=document.getElementById(Ze);if(!r||!rt(r)&&!tt(r)||"true"===r.getAttribute("game-completed"))return;const t=document.getElementById(Ze).objective,n=rt(r)?((e,r)=>{if(!r)return!1;const t=r.split(",").map((e=>e.trim()));return e.length===t.length&&e.every(((e,r)=>e===t[r]))})(e,t):((e,r)=>{if(!r)return!1;const t=r.split(",").map((e=>e.trim()));return e.length===t.length&&e.every(((e,r)=>e===t[r]))})(e,t);n&&await JF()},ut=(e,r)=>{const t=parseFloat(e);return Number.isFinite(t)?t:r};function st(e){return st="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},st(e)}var ct=/^\s+/,lt=/\s+$/;function ft(e,r){if(r=r||{},(e=e||"")instanceof ft)return e;if(!(this instanceof ft))return new ft(e,r);var t=function(e){var r={r:0,g:0,b:0},t=1,n=null,i=null,a=null,o=!1,u=!1;return"string"==typeof e&&(e=function(e){e=e.replace(ct,"").replace(lt,"").toLowerCase();var r,t=!1;if(St[e])e=St[e],t=!0;else if("transparent"==e)return{r:0,g:0,b:0,a:0,format:"name"};return(r=Rt.rgb.exec(e))?{r:r[1],g:r[2],b:r[3]}:(r=Rt.rgba.exec(e))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=Rt.hsl.exec(e))?{h:r[1],s:r[2],l:r[3]}:(r=Rt.hsla.exec(e))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=Rt.hsv.exec(e))?{h:r[1],s:r[2],v:r[3]}:(r=Rt.hsva.exec(e))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=Rt.hex8.exec(e))?{r:kt(r[1]),g:kt(r[2]),b:kt(r[3]),a:jt(r[4]),format:t?"name":"hex8"}:(r=Rt.hex6.exec(e))?{r:kt(r[1]),g:kt(r[2]),b:kt(r[3]),format:t?"name":"hex"}:(r=Rt.hex4.exec(e))?{r:kt(r[1]+""+r[1]),g:kt(r[2]+""+r[2]),b:kt(r[3]+""+r[3]),a:jt(r[4]+""+r[4]),format:t?"name":"hex8"}:!!(r=Rt.hex3.exec(e))&&{r:kt(r[1]+""+r[1]),g:kt(r[2]+""+r[2]),b:kt(r[3]+""+r[3]),format:t?"name":"hex"}}(e)),"object"==st(e)&&(Ut(e.r)&&Ut(e.g)&&Ut(e.b)?(r=function(e,r,t){return{r:255*qt(e,255),g:255*qt(r,255),b:255*qt(t,255)}}(e.r,e.g,e.b),o=!0,u="%"===(e.r+"").substr(-1)?"prgb":"rgb"):Ut(e.h)&&Ut(e.s)&&Ut(e.v)?(n=It(e.s),i=It(e.v),r=function(e,r,t){e=6*qt(e,360),r=qt(r,100),t=qt(t,100);var n=Math.floor(e),i=e-n,a=t*(1-r),o=t*(1-i*r),u=t*(1-(1-i)*r),s=n%6;return{r:255*[t,o,a,a,u,t][s],g:255*[u,t,t,o,a,a][s],b:255*[a,a,u,t,t,o][s]}}(e.h,n,i),o=!0,u="hsv"):Ut(e.h)&&Ut(e.s)&&Ut(e.l)&&(n=It(e.s),a=It(e.l),r=function(e,r,t){var n,i,a;function o(e,r,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?e+6*(r-e)*t:t<.5?r:t<2/3?e+(r-e)*(2/3-t)*6:e}if(e=qt(e,360),r=qt(r,100),t=qt(t,100),0===r)n=i=a=t;else{var u=t<.5?t*(1+r):t+r-t*r,s=2*t-u;n=o(s,u,e+1/3),i=o(s,u,e),a=o(s,u,e-1/3)}return{r:255*n,g:255*i,b:255*a}}(e.h,n,a),o=!0,u="hsl"),e.hasOwnProperty("a")&&(t=e.a)),t=Bt(t),{ok:o,format:e.format||u,r:Math.min(255,Math.max(r.r,0)),g:Math.min(255,Math.max(r.g,0)),b:Math.min(255,Math.max(r.b,0)),a:t}}(e);this._originalInput=e,this._r=t.r,this._g=t.g,this._b=t.b,this._a=t.a,this._roundA=Math.round(100*this._a)/100,this._format=r.format||t.format,this._gradientType=r.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=t.ok}function mt(e,r,t){e=qt(e,255),r=qt(r,255),t=qt(t,255);var n,i,a=Math.max(e,r,t),o=Math.min(e,r,t),u=(a+o)/2;if(a==o)n=i=0;else{var s=a-o;switch(i=u>.5?s/(2-a-o):s/(a+o),a){case e:n=(r-t)/s+(r<t?6:0);break;case r:n=(t-e)/s+2;break;case t:n=(e-r)/s+4}n/=6}return{h:n,s:i,l:u}}function dt(e,r,t){e=qt(e,255),r=qt(r,255),t=qt(t,255);var n,i,a=Math.max(e,r,t),o=Math.min(e,r,t),u=a,s=a-o;if(i=0===a?0:s/a,a==o)n=0;else{switch(a){case e:n=(r-t)/s+(r<t?6:0);break;case r:n=(t-e)/s+2;break;case t:n=(e-r)/s+4}n/=6}return{h:n,s:i,v:u}}function pt(e,r,t,n){var i=[Ot(Math.round(e).toString(16)),Ot(Math.round(r).toString(16)),Ot(Math.round(t).toString(16))];return n&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function ht(e,r,t,n){return""+Ot(zt(n))+Ot(Math.round(e).toString(16))+Ot(Math.round(r).toString(16))+Ot(Math.round(t).toString(16))}function vt(e,r){r=0===r?0:r||10;var t=ft(e).toHsl();return t.s-=r/100,t.s=Tt(t.s),ft(t)}function yt(e,r){r=0===r?0:r||10;var t=ft(e).toHsl();return t.s+=r/100,t.s=Tt(t.s),ft(t)}function bt(e){return ft(e).desaturate(100)}function gt(e,r){r=0===r?0:r||10;var t=ft(e).toHsl();return t.l+=r/100,t.l=Tt(t.l),ft(t)}function xt(e,r){r=0===r?0:r||10;var t=ft(e).toRgb();return t.r=Math.max(0,Math.min(255,t.r-Math.round(-r/100*255))),t.g=Math.max(0,Math.min(255,t.g-Math.round(-r/100*255))),t.b=Math.max(0,Math.min(255,t.b-Math.round(-r/100*255))),ft(t)}function wt(e,r){r=0===r?0:r||10;var t=ft(e).toHsl();return t.l-=r/100,t.l=Tt(t.l),ft(t)}function Dt(e,r){var t=ft(e).toHsl(),n=(t.h+r)%360;return t.h=n<0?360+n:n,ft(t)}function Nt(e){var r=ft(e).toHsl();return r.h=(r.h+180)%360,ft(r)}function At(e,r){if(isNaN(r)||r<=0)throw Error("Argument to polyad must be a positive number");for(var t=ft(e).toHsl(),n=[ft(e)],i=360/r,a=1;a<r;a++)n.push(ft({h:(t.h+a*i)%360,s:t.s,l:t.l}));return n}function Mt(e){var r=ft(e).toHsl(),t=r.h;return[ft(e),ft({h:(t+72)%360,s:r.s,l:r.l}),ft({h:(t+216)%360,s:r.s,l:r.l})]}function Ct(e,r,t){r=r||6,t=t||30;var n=ft(e).toHsl(),i=360/t,a=[ft(e)];for(n.h=(n.h-(i*r>>1)+720)%360;--r;)n.h=(n.h+i)%360,a.push(ft(n));return a}function Et(e,r){r=r||6;for(var t=ft(e).toHsv(),n=t.h,i=t.s,a=t.v,o=[],u=1/r;r--;)o.push(ft({h:n,s:i,v:a})),a=(a+u)%1;return o}ft.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(299*e.r+587*e.g+114*e.b)/1e3},getLuminance:function(){var e,r,t,n=this.toRgb();return r=n.g/255,t=n.b/255,.2126*((e=n.r/255)<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.0722*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))},setAlpha:function(e){return this._a=Bt(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=dt(this._r,this._g,this._b);return{h:360*e.h,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=dt(this._r,this._g,this._b),r=Math.round(360*e.h),t=Math.round(100*e.s),n=Math.round(100*e.v);return 1==this._a?"hsv("+r+", "+t+"%, "+n+"%)":"hsva("+r+", "+t+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var e=mt(this._r,this._g,this._b);return{h:360*e.h,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=mt(this._r,this._g,this._b),r=Math.round(360*e.h),t=Math.round(100*e.s),n=Math.round(100*e.l);return 1==this._a?"hsl("+r+", "+t+"%, "+n+"%)":"hsla("+r+", "+t+"%, "+n+"%, "+this._roundA+")"},toHex:function(e){return pt(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return function(e,r,t,n,i){var a=[Ot(Math.round(e).toString(16)),Ot(Math.round(r).toString(16)),Ot(Math.round(t).toString(16)),Ot(zt(n))];return i&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)&&a[3].charAt(0)==a[3].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0)+a[3].charAt(0):a.join("")}(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(100*qt(this._r,255))+"%",g:Math.round(100*qt(this._g,255))+"%",b:Math.round(100*qt(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*qt(this._r,255))+"%, "+Math.round(100*qt(this._g,255))+"%, "+Math.round(100*qt(this._b,255))+"%)":"rgba("+Math.round(100*qt(this._r,255))+"%, "+Math.round(100*qt(this._g,255))+"%, "+Math.round(100*qt(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(Ft[pt(this._r,this._g,this._b,!0)]||!1)},toFilter:function(e){var r="#"+ht(this._r,this._g,this._b,this._a),t=r,n=this._gradientType?"GradientType = 1, ":"";if(e){var i=ft(e);t="#"+ht(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+r+",endColorstr="+t+")"},toString:function(e){var r=!!e;e=e||this._format;var t=!1;return r||!(this._a<1&&this._a>=0)||"hex"!==e&&"hex6"!==e&&"hex3"!==e&&"hex4"!==e&&"hex8"!==e&&"name"!==e?("rgb"===e&&(t=this.toRgbString()),"prgb"===e&&(t=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(t=this.toHexString()),"hex3"===e&&(t=this.toHexString(!0)),"hex4"===e&&(t=this.toHex8String(!0)),"hex8"===e&&(t=this.toHex8String()),"name"===e&&(t=this.toName()),"hsl"===e&&(t=this.toHslString()),"hsv"===e&&(t=this.toHsvString()),t||this.toHexString()):"name"===e&&0===this._a?this.toName():this.toRgbString()},clone:function(){return ft(""+this)},_applyModification:function(e,r){var t=e.apply(null,[this].concat([].slice.call(r)));return this._r=t._r,this._g=t._g,this._b=t._b,this.setAlpha(t._a),this},lighten:function(){return this._applyModification(gt,arguments)},brighten:function(){return this._applyModification(xt,arguments)},darken:function(){return this._applyModification(wt,arguments)},desaturate:function(){return this._applyModification(vt,arguments)},saturate:function(){return this._applyModification(yt,arguments)},greyscale:function(){return this._applyModification(bt,arguments)},spin:function(){return this._applyModification(Dt,arguments)},_applyCombination:function(e,r){return e.apply(null,[this].concat([].slice.call(r)))},analogous:function(){return this._applyCombination(Ct,arguments)},complement:function(){return this._applyCombination(Nt,arguments)},monochromatic:function(){return this._applyCombination(Et,arguments)},splitcomplement:function(){return this._applyCombination(Mt,arguments)},triad:function(){return this._applyCombination(At,[3])},tetrad:function(){return this._applyCombination(At,[4])}},ft.fromRatio=function(e,r){if("object"==st(e)){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]="a"===n?e[n]:It(e[n]));e=t}return ft(e,r)},ft.equals=function(e,r){return!(!e||!r)&&ft(e).toRgbString()==ft(r).toRgbString()},ft.random=function(){return ft.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},ft.mix=function(e,r,t){t=0===t?0:t||50;var n=ft(e).toRgb(),i=ft(r).toRgb(),a=t/100;return ft({r:(i.r-n.r)*a+n.r,g:(i.g-n.g)*a+n.g,b:(i.b-n.b)*a+n.b,a:(i.a-n.a)*a+n.a})},ft.readability=function(e,r){var t=ft(e),n=ft(r);return(Math.max(t.getLuminance(),n.getLuminance())+.05)/(Math.min(t.getLuminance(),n.getLuminance())+.05)},ft.isReadable=function(e,r,t){var n,i,a=ft.readability(e,r);switch(i=!1,n=function(e){var r,t;return"AA"!==(r=((e=e||{level:"AA",size:"small"}).level||"AA").toUpperCase())&&"AAA"!==r&&(r="AA"),"small"!==(t=(e.size||"small").toLowerCase())&&"large"!==t&&(t="small"),{level:r,size:t}}(t),n.level+n.size){case"AAsmall":case"AAAlarge":i=a>=4.5;break;case"AAlarge":i=a>=3;break;case"AAAsmall":i=a>=7}return i},ft.mostReadable=function(e,r,t){var n,i,a,o,u=null,s=0;i=(t=t||{}).includeFallbackColors,a=t.level,o=t.size;for(var c=0;c<r.length;c++)(n=ft.readability(e,r[c]))>s&&(s=n,u=ft(r[c]));return ft.isReadable(e,u,{level:a,size:o})||!i?u:(t.includeFallbackColors=!1,ft.mostReadable(e,["#fff","#000"],t))};var St=ft.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},Ft=ft.hexNames=function(e){var r={};for(var t in e)e.hasOwnProperty(t)&&(r[e[t]]=t);return r}(St);function Bt(e){return(isNaN(e=parseFloat(e))||e<0||e>1)&&(e=1),e}function qt(e,r){(function(e){return"string"==typeof e&&-1!=e.indexOf(".")&&1===parseFloat(e)})(e)&&(e="100%");var t=function(e){return"string"==typeof e&&-1!=e.indexOf("%")}(e);return e=Math.min(r,Math.max(0,parseFloat(e))),t&&(e=parseInt(e*r,10)/100),Math.abs(e-r)<1e-6?1:e%r/parseFloat(r)}function Tt(e){return Math.min(1,Math.max(0,e))}function kt(e){return parseInt(e,16)}function Ot(e){return 1==e.length?"0"+e:""+e}function It(e){return e<=1&&(e=100*e+"%"),e}function zt(e){return Math.round(255*parseFloat(e)).toString(16)}function jt(e){return kt(e)/255}var Rt=function(){var e="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",r="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?",t="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?";return{CSS_UNIT:RegExp(e),rgb:RegExp("rgb"+r),rgba:RegExp("rgba"+t),hsl:RegExp("hsl"+r),hsla:RegExp("hsla"+t),hsv:RegExp("hsv"+r),hsva:RegExp("hsva"+t),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function Ut(e){return!!Rt.CSS_UNIT.exec(e)}const $t=e=>{var r;const t=.08*(Number.isFinite(e.offsetHeight)?e.offsetHeight:0),n=(null===(r=e.style)||void 0===r?void 0:r.backgroundColor)||"#FFB742";e.style.setProperty("--btn-bg-color",n),e.style.setProperty("--btn-shadow-px",`0px ${t}px 0px`),e.style.setProperty("--btn-active",t+"px"),e.style.setProperty("--btn-shadow-color",""+ft(n).darken(17)),e.classList.add("click-element")};function Pt(){return Pt=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},Pt.apply(null,arguments)}var Lt={relTol:1e-12,absTol:1e-15,matrix:"Matrix",number:"number",numberFallback:"number",precision:64,predictable:!1,randomSeed:null};function _t(e,r){if(Jt(e,r))return e[r];if("function"==typeof e[r]&&Vt(e,r))throw Error('Cannot access method "'+r+'" as a property');throw Error('No access to property "'+r+'"')}function Wt(e,r,t){if(Jt(e,r))return e[r]=t,t;throw Error('No access to property "'+r+'"')}function Jt(e,r){return!(!function(e){return"object"==typeof e&&e&&e.constructor===Object}(e)&&!Array.isArray(e)||!Hn(Ht,r)&&(r in Object.prototype||r in Function.prototype))}function Vt(e,r){return!(null==e||"function"!=typeof e[r]||Hn(e,r)&&Object.getPrototypeOf&&r in Object.getPrototypeOf(e)||!Hn(Zt,r)&&(r in Object.prototype||r in Function.prototype))}var Ht={length:!0,name:!0},Zt={toString:!0,valueOf:!0,toLocaleString:!0};class Gt{constructor(e){this.wrappedObject=e,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).filter((e=>this.has(e))).values()}get(e){return _t(this.wrappedObject,e)}set(e,r){return Wt(this.wrappedObject,e,r),this}has(e){return Jt(this.wrappedObject,e)&&e in this.wrappedObject}entries(){return Yt(this.keys(),(e=>[e,this.get(e)]))}forEach(e){for(var r of this.keys())e(this.get(r),r,this)}delete(e){Jt(this.wrappedObject,e)&&delete this.wrappedObject[e]}clear(){for(var e of this.keys())this.delete(e)}get size(){return Object.keys(this.wrappedObject).length}}class Xt{constructor(e,r,t){this.a=e,this.b=r,this.bKeys=t,this[Symbol.iterator]=this.entries}get(e){return this.bKeys.has(e)?this.b.get(e):this.a.get(e)}set(e,r){return this.bKeys.has(e)?this.b.set(e,r):this.a.set(e,r),this}has(e){return this.b.has(e)||this.a.has(e)}keys(){return new Set([...this.a.keys(),...this.b.keys()])[Symbol.iterator]()}entries(){return Yt(this.keys(),(e=>[e,this.get(e)]))}forEach(e){for(var r of this.keys())e(this.get(r),r,this)}delete(e){return this.bKeys.has(e)?this.b.delete(e):this.a.delete(e)}clear(){this.a.clear(),this.b.clear()}get size(){return[...this.keys()].length}}function Yt(e,r){return{next:()=>{var t=e.next();return t.done?t:{value:r(t.value),done:!1}}}}function Qt(){return new Map}function Kt(e){if(!e)return Qt();if(Dn(e))return e;if(wn(e))return new Gt(e);throw Error("createMap can create maps from objects or Maps")}function en(e){return"number"==typeof e}function rn(e){return!(!e||"object"!=typeof e||"function"!=typeof e.constructor)&&(!0===e.isBigNumber&&"object"==typeof e.constructor.prototype&&!0===e.constructor.prototype.isBigNumber||"function"==typeof e.constructor.isDecimal&&!0===e.constructor.isDecimal(e))}function tn(e){return"bigint"==typeof e}function nn(e){return e&&"object"==typeof e&&!0===Object.getPrototypeOf(e).isComplex||!1}function an(e){return e&&"object"==typeof e&&!0===Object.getPrototypeOf(e).isFraction||!1}function on(e){return e&&!0===e.constructor.prototype.isUnit||!1}function un(e){return"string"==typeof e}var sn=Array.isArray;function cn(e){return e&&!0===e.constructor.prototype.isMatrix||!1}function ln(e){return Array.isArray(e)||cn(e)}function fn(e){return e&&e.isDenseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function mn(e){return e&&e.isSparseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function dn(e){return e&&!0===e.constructor.prototype.isRange||!1}function pn(e){return e&&!0===e.constructor.prototype.isIndex||!1}function hn(e){return"boolean"==typeof e}function vn(e){return e&&!0===e.constructor.prototype.isResultSet||!1}function yn(e){return e&&!0===e.constructor.prototype.isHelp||!1}function bn(e){return"function"==typeof e}function gn(e){return e instanceof Date}function xn(e){return e instanceof RegExp}function wn(e){return!(!e||"object"!=typeof e||e.constructor!==Object||nn(e)||an(e))}function Dn(e){return!!e&&(e instanceof Map||e instanceof Gt||"function"==typeof e.set&&"function"==typeof e.get&&"function"==typeof e.keys&&"function"==typeof e.has)}function Nn(e){return null===e}function An(e){return void 0===e}function Mn(e){return e&&!0===e.isAccessorNode&&!0===e.constructor.prototype.isNode||!1}function Cn(e){return e&&!0===e.isArrayNode&&!0===e.constructor.prototype.isNode||!1}function En(e){return e&&!0===e.isAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function Sn(e){return e&&!0===e.isBlockNode&&!0===e.constructor.prototype.isNode||!1}function Fn(e){return e&&!0===e.isConditionalNode&&!0===e.constructor.prototype.isNode||!1}function Bn(e){return e&&!0===e.isConstantNode&&!0===e.constructor.prototype.isNode||!1}function qn(e){return Bn(e)||jn(e)&&1===e.args.length&&Bn(e.args[0])&&"-+~".includes(e.op)}function Tn(e){return e&&!0===e.isFunctionAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function kn(e){return e&&!0===e.isFunctionNode&&!0===e.constructor.prototype.isNode||!1}function On(e){return e&&!0===e.isIndexNode&&!0===e.constructor.prototype.isNode||!1}function In(e){return e&&!0===e.isNode&&!0===e.constructor.prototype.isNode||!1}function zn(e){return e&&!0===e.isObjectNode&&!0===e.constructor.prototype.isNode||!1}function jn(e){return e&&!0===e.isOperatorNode&&!0===e.constructor.prototype.isNode||!1}function Rn(e){return e&&!0===e.isParenthesisNode&&!0===e.constructor.prototype.isNode||!1}function Un(e){return e&&!0===e.isRangeNode&&!0===e.constructor.prototype.isNode||!1}function $n(e){return e&&!0===e.isRelationalNode&&!0===e.constructor.prototype.isNode||!1}function Pn(e){return e&&!0===e.isSymbolNode&&!0===e.constructor.prototype.isNode||!1}function Ln(e){return e&&!0===e.constructor.prototype.isChain||!1}function _n(e){var r=typeof e;return"object"===r?null===e?"null":rn(e)?"BigNumber":e.constructor&&e.constructor.name?e.constructor.name:"Object":r}function Wn(e){var r=typeof e;if("number"===r||"bigint"===r||"string"===r||"boolean"===r||null==e)return e;if("function"==typeof e.clone)return e.clone();if(Array.isArray(e))return e.map((function(e){return Wn(e)}));if(e instanceof Date)return new Date(e.valueOf());if(rn(e))return e;if(wn(e))return function(e,r){var t={};for(var n in e)Hn(e,n)&&(t[n]=r(e[n]));return t}(e,Wn);if("function"===r)return e;throw new TypeError("Cannot clone: unknown type of value (value: ".concat(e,")"))}function Jn(e,r){for(var t in r)Hn(r,t)&&(e[t]=r[t]);return e}function Vn(e,r){var t,n,i;if(Array.isArray(e)){if(!Array.isArray(r))return!1;if(e.length!==r.length)return!1;for(n=0,i=e.length;n<i;n++)if(!Vn(e[n],r[n]))return!1;return!0}if("function"==typeof e)return e===r;if(e instanceof Object){if(Array.isArray(r)||!(r instanceof Object))return!1;for(t in e)if(!(t in r)||!Vn(e[t],r[t]))return!1;for(t in r)if(!(t in e))return!1;return!0}return e===r}function Hn(e,r){return e&&Object.hasOwnProperty.call(e,r)}var Zn=function(e){if(e)throw Error("The global config is readonly. \nPlease create a mathjs instance if you want to change the default configuration. \nExample:\n\n import { create, all } from 'mathjs';\n const mathjs = create(all);\n mathjs.config({ number: 'BigNumber' });\n");return Object.freeze(Lt)};Pt(Zn,Lt,{MATRIX_OPTIONS:["Matrix","Array"],NUMBER_OPTIONS:["number","BigNumber","bigint","Fraction"]});var Gn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Xn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Yn(e){if(e.__esModule)return e;var r=e.default;if("function"==typeof r){var t=function e(){return this instanceof e?Reflect.construct(r,arguments,this.constructor):r.apply(this,arguments)};t.prototype=r.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(e).forEach((function(r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})})),t}var Qn,Kn={exports:{}},ei=(Qn||(Qn=1,Kn.exports=function(){function e(){return!0}function r(){return!1}function t(){}const n="Argument is not a typed-function.";var i=function i(){function a(e){return"object"==typeof e&&null!==e&&e.constructor===Object}const o=[{name:"number",test:function(e){return"number"==typeof e}},{name:"string",test:function(e){return"string"==typeof e}},{name:"boolean",test:function(e){return"boolean"==typeof e}},{name:"Function",test:function(e){return"function"==typeof e}},{name:"Array",test:Array.isArray},{name:"Date",test:function(e){return e instanceof Date}},{name:"RegExp",test:function(e){return e instanceof RegExp}},{name:"Object",test:a},{name:"null",test:function(e){return null===e}},{name:"undefined",test:function(e){return void 0===e}}],u={name:"any",test:e,isAny:!0};let s,c,l=0,f={createCount:0};function m(e){const r=s.get(e);if(r)return r;let t='Unknown type "'+e+'"';const n=e.toLowerCase();let i;for(i of c)if(i.toLowerCase()===n){t+='. Did you mean "'+i+'" ?';break}throw new TypeError(t)}function d(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"any";const t=r?m(r).index:c.length,n=[];for(let r=0;r<e.length;++r){if(!e[r]||"string"!=typeof e[r].name||"function"!=typeof e[r].test)throw new TypeError("Object with properties {name: string, test: function} expected");const i=e[r].name;if(s.has(i))throw new TypeError('Duplicate type name "'+i+'"');n.push(i),s.set(i,{name:i,test:e[r].test,isAny:e[r].isAny,index:t+r,conversionsTo:[]})}const i=c.slice(t);c=c.slice(0,t).concat(n).concat(i);for(let e=t+n.length;e<c.length;++e)s.get(c[e]).index=e}function p(){s=new Map,c=[],l=0,d([u],!1)}function h(e){const r=c.filter((r=>{const t=s.get(r);return!t.isAny&&t.test(e)}));return r.length?r:["any"]}function v(e){return e&&"function"==typeof e&&"_typedFunctionData"in e}function y(e,r,t){if(!v(e))throw new TypeError(n);const i=t&&t.exact,a=D(Array.isArray(r)?r.join(","):r),o=b(a);if(!i||o in e.signatures){const r=e._typedFunctionData.signatureMap.get(o);if(r)return r}const u=a.length;let s,c;if(i){let r;for(r in s=[],e.signatures)s.push(e._typedFunctionData.signatureMap.get(r))}else s=e._typedFunctionData.signatures;for(let e=0;e<u;++e){const r=a[e],t=[];let n;for(n of s){const i=C(n.params,e);if(i&&(!r.restParam||i.restParam)){if(!i.hasAny){const e=w(i);if(r.types.some((r=>!e.has(r.name))))continue}t.push(n)}}if(s=t,0===s.length)break}for(c of s)if(c.params.length<=u)return c;throw new TypeError("Signature not found (signature: "+(e.name||"unnamed")+"("+b(a,", ")+"))")}function b(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:",";return e.map((e=>e.name)).join(r)}function g(e){const r=0===e.indexOf("..."),t=(r?e.length>3?e.slice(3):"any":e).split("|").map((e=>m(e.trim())));let n=!1,i=r?"...":"";return{types:t.map((function(e){return n=e.isAny||n,i+=e.name+"|",{name:e.name,typeIndex:e.index,test:e.test,isAny:e.isAny,conversion:null,conversionIndex:-1}})),name:i.slice(0,-1),hasAny:n,hasConversion:!1,restParam:r}}function x(e){const r=function(e){if(0===e.length)return[];const r=e.map(m);if(1===e.length)return r[0].conversionsTo;const t=new Set(e),n=new Set;for(let e=0;e<r.length;++e)for(const i of r[e].conversionsTo)t.has(i.from)||n.add(i.from);const i=[];for(const e of n){let t=l+1,n=null;for(let i=0;i<r.length;++i)for(const a of r[i].conversionsTo)a.from===e&&a.index<t&&(t=a.index,n=a);i.push(n)}return i}(e.types.map((e=>e.name)));let t=e.hasAny,n=e.name;const i=r.map((function(e){const r=m(e.from);return t=r.isAny||t,n+="|"+e.from,{name:e.from,typeIndex:r.index,test:r.test,isAny:r.isAny,conversion:e,conversionIndex:e.index}}));return{types:e.types.concat(i),name:n,hasAny:t,hasConversion:i.length>0,restParam:e.restParam}}function w(e){return e.typeSet||(e.typeSet=new Set,e.types.forEach((r=>e.typeSet.add(r.name)))),e.typeSet}function D(e){const r=[];if("string"!=typeof e)throw new TypeError("Signatures must be strings");const t=e.trim();if(""===t)return r;const n=t.split(",");for(let e=0;e<n.length;++e){const t=g(n[e].trim());if(t.restParam&&e!==n.length-1)throw new SyntaxError('Unexpected rest parameter "'+n[e]+'": only allowed for the last parameter');if(0===t.types.length)return null;r.push(t)}return r}function N(e){const r=W(e);return!!r&&r.restParam}function A(r){if(r&&0!==r.types.length){if(1===r.types.length)return m(r.types[0].name).test;if(2===r.types.length){const e=m(r.types[0].name).test,t=m(r.types[1].name).test;return function(r){return e(r)||t(r)}}{const e=r.types.map((function(e){return m(e.name).test}));return function(r){for(let t=0;t<e.length;t++)if(e[t](r))return!0;return!1}}}return e}function M(e){let r,t,n;if(N(e)){r=_(e).map(A);const t=r.length,n=A(W(e)),i=function(e){for(let r=t;r<e.length;r++)if(!n(e[r]))return!1;return!0};return function(e){for(let t=0;t<r.length;t++)if(!r[t](e[t]))return!1;return i(e)&&e.length>=t+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(t=A(e[0]),function(e){return t(e[0])&&1===e.length}):2===e.length?(t=A(e[0]),n=A(e[1]),function(e){return t(e[0])&&n(e[1])&&2===e.length}):(r=e.map(A),function(e){for(let t=0;t<r.length;t++)if(!r[t](e[t]))return!1;return e.length===r.length})}function C(e,r){return r<e.length?e[r]:N(e)?W(e):null}function E(e,r){const t=C(e,r);return t?w(t):new Set}function S(e){return null==e.conversion}function F(e,r){const t=new Set;return e.forEach((e=>{const n=E(e.params,r);let i;for(i of n)t.add(i)})),t.has("any")?["any"]:Array.from(t)}function B(e,r,t){let n,i;const a=e||"unnamed";let o,u=t;for(o=0;o<r.length;o++){const e=[];if(u.forEach((t=>{const n=A(C(t.params,o));(o<t.params.length||N(t.params))&&n(r[o])&&e.push(t)})),0===e.length){if(i=F(u,o),i.length>0){const e=h(r[o]);return n=new TypeError("Unexpected type of argument in function "+a+" (expected: "+i.join(" or ")+", actual: "+e.join(" | ")+", index: "+o+")"),n.data={category:"wrongType",fn:a,index:o,actual:e,expected:i},n}}else u=e}const s=u.map((function(e){return N(e.params)?1/0:e.params.length}));if(r.length<Math.min.apply(null,s))return i=F(u,o),n=new TypeError("Too few arguments in function "+a+" (expected: "+i.join(" or ")+", index: "+r.length+")"),n.data={category:"tooFewArgs",fn:a,index:r.length,expected:i},n;const c=Math.max.apply(null,s);if(r.length>c)return n=new TypeError("Too many arguments in function "+a+" (expected: "+c+", actual: "+r.length+")"),n.data={category:"tooManyArgs",fn:a,index:r.length,expectedLength:c},n;const l=[];for(let e=0;e<r.length;++e)l.push(h(r[e]).join("|"));return n=new TypeError('Arguments of type "'+l.join(", ")+'" do not match any of the defined signatures of function '+a+"."),n.data={category:"mismatch",actual:l},n}function q(e){let r=c.length+1;for(let t=0;t<e.types.length;t++)r=Math.min(r,e.types[t].typeIndex);return r}function T(e){let r=l+1;for(let t=0;t<e.types.length;t++)S(e.types[t])||(r=Math.min(r,e.types[t].conversionIndex));return r}function k(e,r){if(e.hasAny){if(!r.hasAny)return.1}else if(r.hasAny)return-.1;if(e.restParam){if(!r.restParam)return.01}else if(r.restParam)return-.01;const t=q(e)-q(r);if(t<0)return-.001;if(t>0)return.001;const n=T(e),i=T(r);if(e.hasConversion){if(!r.hasConversion)return 1e-6*(1+n)}else if(r.hasConversion)return 1e-6*-(1+i);const a=n-i;return a<0?-1e-7:a>0?1e-7:0}function O(e,r){const t=e.params,n=r.params,i=W(t),a=W(n),o=N(t),u=N(n);if(o&&i.hasAny){if(!u||!a.hasAny)return 1e7}else if(u&&a.hasAny)return-1e7;let s,c=0,l=0;for(s of t)s.hasAny&&++c,s.hasConversion&&++l;let f=0,m=0;for(s of n)s.hasAny&&++f,s.hasConversion&&++m;if(c!==f)return 1e6*(c-f);if(o&&i.hasConversion){if(!u||!a.hasConversion)return 1e5}else if(u&&a.hasConversion)return-1e5;if(l!==m)return 1e4*(l-m);if(o){if(!u)return 1e3}else if(u)return-1e3;const d=(t.length-n.length)*(o?-100:100);if(0!==d)return d;const p=[];let h,v=0;for(let e=0;e<t.length;++e){const r=k(t[e],n[e]);p.push(r),v+=r}if(0!==v)return(v<0?-10:10)+v;let y=9;const b=y/(p.length+1);for(h of p){if(0!==h)return(h<0?-y:y)+h;y-=b}return 0}function I(e,r){let t=r,n="";if(e.some((e=>e.hasConversion))){const i=N(e),a=e.map(z);n=a.map((e=>e.name)).join(";"),t=function(){const e=[],t=i?arguments.length-1:arguments.length;for(let r=0;r<t;r++)e[r]=a[r](arguments[r]);return i&&(e[t]=arguments[t].map(a[t])),r.apply(this,e)}}let i=t;if(N(e)){const r=e.length-1;i=function(){return t.apply(this,J(arguments,0,r).concat([J(arguments,r)]))}}return n&&Object.defineProperty(i,"name",{value:n}),i}function z(e){let r,t,n,i;const a=[],o=[];let u="";e.types.forEach((function(e){e.conversion&&(u+=e.conversion.from+"~>"+e.conversion.to+",",a.push(m(e.conversion.from).test),o.push(e.conversion.convert))})),u=u?u.slice(0,-1):"pass";let s=e=>e;switch(o.length){case 0:break;case 1:r=a[0],n=o[0],s=function(e){return r(e)?n(e):e};break;case 2:r=a[0],t=a[1],n=o[0],i=o[1],s=function(e){return r(e)?n(e):t(e)?i(e):e};break;default:s=function(e){for(let r=0;r<o.length;r++)if(a[r](e))return o[r](e);return e}}return Object.defineProperty(s,"name",{value:u}),s}function j(e){return function e(r,t,n){if(t<r.length){const i=r[t];let a=[];if(i.restParam){const e=i.types.filter(S);e.length<i.types.length&&a.push({types:e,name:"..."+e.map((e=>e.name)).join("|"),hasAny:e.some((e=>e.isAny)),hasConversion:!1,restParam:!0}),a.push(i)}else a=i.types.map((function(e){return{types:[e],name:e.name,hasAny:e.isAny,hasConversion:e.conversion,restParam:!1}}));return function(e,r){return Array.prototype.concat.apply([],e.map(r))}(a,(function(i){return e(r,t+1,n.concat([i]))}))}return[n]}(e,0,[])}function R(e,r){const t=Math.max(e.length,r.length);for(let n=0;n<t;n++){const t=E(e,n),i=E(r,n);let a,o=!1;for(a of i)if(t.has(a)){o=!0;break}if(!o)return!1}const n=e.length,i=r.length,a=N(e),o=N(r);return a?o?n===i:i>=n:o?n>=i:n===i}function U(e,r,t){const n=[];let i;for(i of e){let e=t[i];if("number"!=typeof e)throw new TypeError('No definition for referenced signature "'+i+'"');if(e=r[e],"function"!=typeof e)return!1;n.push(e)}return n}function $(e,r,t){const n=function(e){return e.map((e=>G(e)?H(e.referToSelf.callback):Z(e)?V(e.referTo.references,e.referTo.callback):e))}(e),i=Array(n.length).fill(!1);let a=!0;for(;a;){a=!1;let e=!0;for(let o=0;o<n.length;++o){if(i[o])continue;const u=n[o];if(G(u))n[o]=u.referToSelf.callback(t),n[o].referToSelf=u.referToSelf,i[o]=!0,e=!1;else if(Z(u)){const t=U(u.referTo.references,n,r);t?(n[o]=u.referTo.callback.apply(this,t),n[o].referTo=u.referTo,i[o]=!0,e=!1):a=!0}}if(e&&a)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return n}function P(e,n){if(f.createCount++,0===Object.keys(n).length)throw new SyntaxError("No signatures provided");f.warnAgainstDeprecatedThis&&function(e){const r=/\bthis(\(|\.signatures\b)/;Object.keys(e).forEach((t=>{if(r.test(""+e[t]))throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")}))}(n);const i=[],a=[],o={},u=[];let s;for(s in n){if(!Object.prototype.hasOwnProperty.call(n,s))continue;const e=D(s);if(!e)continue;i.forEach((function(r){if(R(r,e))throw new TypeError('Conflicting signatures "'+b(r)+'" and "'+b(e)+'".')})),i.push(e);const r=a.length;a.push(n[s]);const t=e.map(x);let c;for(c of j(t)){const e=b(c);u.push({params:c,name:e,fn:r}),c.every((e=>!e.hasConversion))&&(o[e]=r)}}u.sort(O);const c=$(a,o,ue);let l;for(l in o)Object.prototype.hasOwnProperty.call(o,l)&&(o[l]=c[o[l]]);const m=[],d=new Map;for(l of u)d.has(l.name)||(l.fn=c[l.fn],m.push(l),d.set(l.name,l));const p=m[0]&&m[0].params.length<=2&&!N(m[0].params),h=m[1]&&m[1].params.length<=2&&!N(m[1].params),v=m[2]&&m[2].params.length<=2&&!N(m[2].params),y=m[3]&&m[3].params.length<=2&&!N(m[3].params),g=m[4]&&m[4].params.length<=2&&!N(m[4].params),w=m[5]&&m[5].params.length<=2&&!N(m[5].params),C=p&&h&&v&&y&&g&&w;for(let e=0;e<m.length;++e)m[e].test=M(m[e].params);const E=p?A(m[0].params[0]):r,S=h?A(m[1].params[0]):r,F=v?A(m[2].params[0]):r,B=y?A(m[3].params[0]):r,q=g?A(m[4].params[0]):r,T=w?A(m[5].params[0]):r,k=p?A(m[0].params[1]):r,z=h?A(m[1].params[1]):r,U=v?A(m[2].params[1]):r,P=y?A(m[3].params[1]):r,L=g?A(m[4].params[1]):r,_=w?A(m[5].params[1]):r;for(let e=0;e<m.length;++e)m[e].implementation=I(m[e].params,m[e].fn);const W=p?m[0].implementation:t,J=h?m[1].implementation:t,V=v?m[2].implementation:t,H=y?m[3].implementation:t,Z=g?m[4].implementation:t,G=w?m[5].implementation:t,X=p?m[0].params.length:-1,Y=h?m[1].params.length:-1,Q=v?m[2].params.length:-1,K=y?m[3].params.length:-1,ee=g?m[4].params.length:-1,re=w?m[5].params.length:-1,te=C?6:0,ne=m.length,ie=m.map((e=>e.test)),ae=m.map((e=>e.implementation)),oe=function(){for(let e=te;e<ne;e++)if(ie[e](arguments))return ae[e].apply(this,arguments);return f.onMismatch(e,arguments,m)};function ue(e,r){return arguments.length===X&&E(e)&&k(r)?W.apply(this,arguments):arguments.length===Y&&S(e)&&z(r)?J.apply(this,arguments):arguments.length===Q&&F(e)&&U(r)?V.apply(this,arguments):arguments.length===K&&B(e)&&P(r)?H.apply(this,arguments):arguments.length===ee&&q(e)&&L(r)?Z.apply(this,arguments):arguments.length===re&&T(e)&&_(r)?G.apply(this,arguments):oe.apply(this,arguments)}try{Object.defineProperty(ue,"name",{value:e})}catch(e){}return ue.signatures=o,ue._typedFunctionData={signatures:m,signatureMap:d},ue}function L(e,r,t){throw B(e,r,t)}function _(e){return J(e,0,e.length-1)}function W(e){return e[e.length-1]}function J(e,r,t){return Array.prototype.slice.call(e,r,t)}function V(e,r){return{referTo:{references:e,callback:r}}}function H(e){if("function"!=typeof e)throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:e}}}function Z(e){return e&&"object"==typeof e.referTo&&Array.isArray(e.referTo.references)&&"function"==typeof e.referTo.callback}function G(e){return e&&"object"==typeof e.referToSelf&&"function"==typeof e.referToSelf.callback}function X(e,r){if(!e)return r;if(r&&r!==e){const t=Error("Function names do not match (expected: "+e+", actual: "+r+")");throw t.data={actual:r,expected:e},t}return e}function Y(e){let r;for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(v(e[t])||"string"==typeof e[t].signature)&&(r=X(r,e[t].name));return r}function Q(e,r){let t;for(t in r)if(Object.prototype.hasOwnProperty.call(r,t)){if(t in e&&r[t]!==e[t]){const n=Error('Signature "'+t+'" is defined twice');throw n.data={signature:t,sourceFunction:r[t],destFunction:e[t]},n}e[t]=r[t]}}p(),d(o);const K=f;function ee(e){if(!e||"string"!=typeof e.from||"string"!=typeof e.to||"function"!=typeof e.convert)throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(e.to===e.from)throw new SyntaxError('Illegal to define conversion from "'+e.from+'" to itself.')}return f=function(e){const r="string"==typeof e;let t=r?e:"";const n={};for(let e=r?1:0;e<arguments.length;++e){const i=arguments[e];let o,u={};if("function"==typeof i?(o=i.name,"string"==typeof i.signature?u[i.signature]=i:v(i)&&(u=i.signatures)):a(i)&&(u=i,r||(o=Y(i))),0===Object.keys(u).length){const r=new TypeError("Argument to 'typed' at index "+e+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw r.data={index:e,argument:i},r}r||(t=X(t,o)),Q(n,u)}return P(t||"",n)},f.create=i,f.createCount=K.createCount,f.onMismatch=L,f.throwMismatchError=L,f.createError=B,f.clear=p,f.clearConversions=function(){let e;for(e of c)s.get(e).conversionsTo=[];l=0},f.addTypes=d,f._findType=m,f.referTo=function(){const e=_(arguments).map((e=>b(D(e)))),r=W(arguments);if("function"!=typeof r)throw new TypeError("Callback function expected as last argument");return V(e,r)},f.referToSelf=H,f.convert=function(e,r){const t=m(r);if(t.test(e))return e;const n=t.conversionsTo;if(0===n.length)throw Error("There are no conversions to "+r+" defined.");for(let r=0;r<n.length;r++)if(m(n[r].from).test(e))return n[r].convert(e);throw Error("Cannot convert "+e+" to "+r)},f.findSignature=y,f.find=function(e,r,t){return y(e,r,t).implementation},f.isTypedFunction=v,f.warnAgainstDeprecatedThis=!0,f.addType=function(e,r){let t="any";!1!==r&&s.has("Object")&&(t="Object"),f.addTypes([e],t)},f.addConversion=function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{override:!1};ee(e);const t=m(e.to),n=t.conversionsTo.find((r=>r.from===e.from));if(n){if(!r||!r.override)throw Error('There is already a conversion from "'+e.from+'" to "'+t.name+'"');f.removeConversion({from:n.from,to:e.to,convert:n.convert})}t.conversionsTo.push({from:e.from,to:t.name,convert:e.convert,index:l++})},f.addConversions=function(e,r){e.forEach((e=>f.addConversion(e,r)))},f.removeConversion=function(e){ee(e);const r=m(e.to),t=function(e,r){for(let t=0;t<e.length;t++)if(r(e[t]))return e[t]}(r.conversionsTo,(r=>r.from===e.from));if(!t)throw Error("Attempt to remove nonexistent conversion from "+e.from+" to "+e.to);if(t.convert!==e.convert)throw Error("Conversion to remove does not match existing conversion");const n=r.conversionsTo.indexOf(t);r.conversionsTo.splice(n,1)},f.resolve=function(e,r){if(!v(e))throw new TypeError(n);const t=e._typedFunctionData.signatures;for(let e=0;e<t.length;++e)if(t[e].test(r))return t[e];return null},f}();return i}()),Kn.exports),ri=Xn(ei);function ti(e,r,t,n){function i(n){var i=function(e,r){for(var t={},n=0;n<r.length;n++){var i=r[n],a=e[i];void 0!==a&&(t[i]=a)}return t}(n,r.map(ni));return function(e,r,t){if(!r.filter((e=>!function(e){return e&&"?"===e[0]}(e))).every((e=>void 0!==t[e]))){var n=r.filter((e=>void 0===t[e]));throw Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(n.map((e=>'"'.concat(e,'"'))).join(", "),"."))}}(e,r,n),t(i)}return i.isFactory=!0,i.fn=e,i.dependencies=r.slice().sort(),n&&(i.meta=n),i}function ni(e){return e&&"?"===e[0]?e.slice(1):e}function ii(e){return"boolean"==typeof e||!!isFinite(e)&&e===Math.round(e)}function ai(e,r){if("bigint"===r.number)try{BigInt(e)}catch(e){return r.numberFallback}return r.number}var oi=Math.sign||function(e){return e>0?1:e<0?-1:0},ui=Math.log2||function(e){return Math.log(e)/Math.LN2},si=Math.log10||function(e){return Math.log(e)/Math.LN10},ci=Math.log1p||function(e){return Math.log(e+1)},li=Math.cbrt||function(e){if(0===e)return e;var r,t=e<0;return t&&(e=-e),r=isFinite(e)?(e/((r=Math.exp(Math.log(e)/3))*r)+2*r)/3:e,t?-r:r},fi=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function mi(e,r,t){var n={2:"0b",8:"0o",16:"0x"}[r],i="";if(t){if(t<1)throw Error("size must be in greater than 0");if(!ii(t))throw Error("size must be an integer");if(e>2**(t-1)-1||e<-(2**(t-1)))throw Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!ii(e))throw Error("Value must be an integer");e<0&&(e+=2**t),i="i".concat(t)}var a="";return e<0&&(e=-e,a="-"),"".concat(a).concat(n).concat(e.toString(r)).concat(i)}function di(e,r){if("function"==typeof r)return r(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var{notation:t,precision:n,wordSize:i}=pi(r);switch(t){case"fixed":return vi(e,n);case"exponential":return yi(e,n);case"engineering":return function(e,r){if(isNaN(e)||!isFinite(e))return e+"";var t=bi(hi(e),r),n=t.exponent,i=t.coefficients,a=n%3==0?n:n<0?n-3-n%3:n-n%3;if(en(r))for(;r>i.length||n-a+1>i.length;)i.push(0);else for(var o=Math.abs(n-a)-(i.length-1),u=0;u<o;u++)i.push(0);for(var s=Math.abs(n-a),c=1;s>0;)c++,s--;var l=i.slice(c).join(""),f=en(r)&&l.length||l.match(/[1-9]/)?"."+l:"",m=i.slice(0,c).join("")+f+"e"+(n>=0?"+":"")+a;return t.sign+m}(e,n);case"bin":return mi(e,2,i);case"oct":return mi(e,8,i);case"hex":return mi(e,16,i);case"auto":return function(e,r,t){if(isNaN(e)||!isFinite(e))return e+"";var n=Si(null==t?void 0:t.lowerExp,-3),i=Si(null==t?void 0:t.upperExp,5),a=hi(e),o=r?bi(a,r):a;if(o.exponent<n||o.exponent>=i)return yi(e,r);var u=o.coefficients,s=o.exponent;u.length<r&&(u=u.concat(gi(r-u.length))),u=u.concat(gi(s-u.length+1+(u.length<r?r-u.length:0)));var c=s>0?s:0;return c<(u=gi(-s).concat(u)).length-1&&u.splice(c+1,0,"."),o.sign+u.join("")}(e,n,r).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],r=arguments[4];return"."!==e?e+r:r}));default:throw Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function pi(e){var r,t,n="auto";if(void 0!==e)if(en(e))r=e;else if(rn(e))r=e.toNumber();else{if(!wn(e))throw Error("Unsupported type of options, number, BigNumber, or object expected");void 0!==e.precision&&(r=Ei(e.precision,(()=>{throw Error('Option "precision" must be a number or BigNumber')}))),void 0!==e.wordSize&&(t=Ei(e.wordSize,(()=>{throw Error('Option "wordSize" must be a number or BigNumber')}))),e.notation&&(n=e.notation)}return{notation:n,precision:r,wordSize:t}}function hi(e){var r=(e+"").toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!r)throw new SyntaxError("Invalid number "+e);var t=r[1],n=r[2],i=parseFloat(r[4]||"0"),a=n.indexOf(".");i+=-1!==a?a-1:n.length-1;var o=n.replace(".","").replace(/^0*/,(function(e){return i-=e.length,""})).replace(/0*$/,"").split("").map((function(e){return parseInt(e)}));return 0===o.length&&(o.push(0),i++),{sign:t,coefficients:o,exponent:i}}function vi(e,r){if(isNaN(e)||!isFinite(e))return e+"";var t=hi(e),n="number"==typeof r?bi(t,t.exponent+1+r):t,i=n.coefficients,a=n.exponent+1,o=a+(r||0);return i.length<o&&(i=i.concat(gi(o-i.length))),a<0&&(i=gi(1-a).concat(i),a=1),a<i.length&&i.splice(a,0,0===a?"0.":"."),n.sign+i.join("")}function yi(e,r){if(isNaN(e)||!isFinite(e))return e+"";var t=hi(e),n=r?bi(t,r):t,i=n.coefficients,a=n.exponent;i.length<r&&(i=i.concat(gi(r-i.length)));var o=i.shift();return n.sign+o+(i.length>0?"."+i.join(""):"")+"e"+(a>=0?"+":"")+a}function bi(e,r){for(var t={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},n=t.coefficients;r<=0;)n.unshift(0),t.exponent++,r++;if(n.length>r&&n.splice(r,n.length-r)[0]>=5){var i=r-1;for(n[i]++;10===n[i];)n.pop(),0===i&&(n.unshift(0),t.exponent++,i++),n[--i]++}return t}function gi(e){for(var r=[],t=0;t<e;t++)r.push(0);return r}function xi(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e-8,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(t<=0)throw Error("Relative tolerance must be greater than 0");if(n<0)throw Error("Absolute tolerance must be at least 0");return!isNaN(e)&&!isNaN(r)&&(isFinite(e)&&isFinite(r)?e===r||Math.abs(e-r)<=Math.max(t*Math.max(Math.abs(e),Math.abs(r)),n):e===r)}var wi=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)},Di=Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},Ni=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2},Ai=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2},Mi=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2},Ci=Math.tanh||function(e){var r=Math.exp(2*e);return(r-1)/(r+1)};function Ei(e,r){return en(e)?e:rn(e)?e.toNumber():void r()}function Si(e,r){return en(e)?e:rn(e)?e.toNumber():r}var Fi=function(){return Fi=ri.create,ri},Bi=ti("typed",["?BigNumber","?Complex","?DenseMatrix","?Fraction"],(function(e){var{BigNumber:r,Complex:t,DenseMatrix:n,Fraction:i}=e,a=Fi();return a.clear(),a.addTypes([{name:"number",test:en},{name:"Complex",test:nn},{name:"BigNumber",test:rn},{name:"bigint",test:tn},{name:"Fraction",test:an},{name:"Unit",test:on},{name:"identifier",test:e=>un&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC4\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC4\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])*$/.test(e)},{name:"string",test:un},{name:"Chain",test:Ln},{name:"Array",test:sn},{name:"Matrix",test:cn},{name:"DenseMatrix",test:fn},{name:"SparseMatrix",test:mn},{name:"Range",test:dn},{name:"Index",test:pn},{name:"boolean",test:hn},{name:"ResultSet",test:vn},{name:"Help",test:yn},{name:"function",test:bn},{name:"Date",test:gn},{name:"RegExp",test:xn},{name:"null",test:Nn},{name:"undefined",test:An},{name:"AccessorNode",test:Mn},{name:"ArrayNode",test:Cn},{name:"AssignmentNode",test:En},{name:"BlockNode",test:Sn},{name:"ConditionalNode",test:Fn},{name:"ConstantNode",test:Bn},{name:"FunctionNode",test:kn},{name:"FunctionAssignmentNode",test:Tn},{name:"IndexNode",test:On},{name:"Node",test:In},{name:"ObjectNode",test:zn},{name:"OperatorNode",test:jn},{name:"ParenthesisNode",test:Rn},{name:"RangeNode",test:Un},{name:"RelationalNode",test:$n},{name:"SymbolNode",test:Pn},{name:"Map",test:Dn},{name:"Object",test:wn}]),a.addConversions([{from:"number",to:"BigNumber",convert:function(e){if(r||qi(e),function(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}(e)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new r(e)}},{from:"number",to:"Complex",convert:function(e){return t||Ti(e),new t(e,0)}},{from:"BigNumber",to:"Complex",convert:function(e){return t||Ti(e),new t(e.toNumber(),0)}},{from:"bigint",to:"number",convert:function(e){if(e>Number.MAX_SAFE_INTEGER)throw new TypeError("Cannot implicitly convert bigint to number: value exceeds the max safe integer value (value: "+e+")");return Number(e)}},{from:"bigint",to:"BigNumber",convert:function(e){return r||qi(e),new r(""+e)}},{from:"bigint",to:"Fraction",convert:function(e){return i||ki(e),new i(e)}},{from:"Fraction",to:"BigNumber",convert:function(){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(e){return t||Ti(e),new t(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){i||ki(e);var r=new i(e);if(r.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return r}},{from:"string",to:"number",convert:function(e){var r=Number(e);if(isNaN(r))throw Error('Cannot convert "'+e+'" to a number');return r}},{from:"string",to:"BigNumber",convert:function(e){r||qi(e);try{return new r(e)}catch(r){throw Error('Cannot convert "'+e+'" to BigNumber')}}},{from:"string",to:"bigint",convert:function(e){try{return BigInt(e)}catch(r){throw Error('Cannot convert "'+e+'" to BigInt')}}},{from:"string",to:"Fraction",convert:function(e){i||ki(e);try{return new i(e)}catch(r){throw Error('Cannot convert "'+e+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(e){t||Ti(e);try{return new t(e)}catch(r){throw Error('Cannot convert "'+e+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return r||qi(e),new r(+e)}},{from:"boolean",to:"bigint",convert:function(e){return BigInt(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return i||ki(e),new i(+e)}},{from:"boolean",to:"string",convert:function(e){return e+""}},{from:"Array",to:"Matrix",convert:function(e){return n||function(){throw Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}(),new n(e)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}]),a.onMismatch=(e,r,t)=>{var n=a.createError(e,r,t);if(["wrongType","mismatch"].includes(n.data.category)&&1===r.length&&ln(r[0])&&t.some((e=>!e.params.includes(",")))){var i=new TypeError("Function '".concat(e,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(e,")'."));throw i.data=n.data,i}throw n},a.onMismatch=(e,r,t)=>{var n=a.createError(e,r,t);if(["wrongType","mismatch"].includes(n.data.category)&&1===r.length&&ln(r[0])&&t.some((e=>!e.params.includes(",")))){var i=new TypeError("Function '".concat(e,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(e,")'."));throw i.data=n.data,i}throw n},a}));function qi(e){throw Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function Ti(e){throw Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function ki(e){throw Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var Oi,Ii,zi=ti("ResultSet",[],(()=>{function e(r){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=r||[]}return e.prototype.type="ResultSet",e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return"["+this.entries.map(String).join(", ")+"]"},e.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},e.fromJSON=function(r){return new e(r.entries)},e}),{isClass:!0}),ji=9e15,Ri=1e9,Ui="0123456789abcdef",$i="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Pi="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Li={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ji,maxE:ji,crypto:!1},_i=!0,Wi="[DecimalError] ",Ji=Wi+"Invalid argument: ",Vi=Wi+"Precision limit exceeded",Hi=Wi+"crypto unavailable",Zi="[object Decimal]",Gi=Math.floor,Xi=Math.pow,Yi=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Qi=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ki=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,ea=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,ra=1e7,ta=$i.length-1,na=Pi.length-1,ia={toStringTag:Zi};function aa(e){var r,t,n,i=e.length-1,a="",o=e[0];if(i>0){for(a+=o,r=1;r<i;r++)(t=7-(n=e[r]+"").length)&&(a+=va(t)),a+=n;(t=7-(n=(o=e[r])+"").length)&&(a+=va(t))}else if(0===o)return"0";for(;o%10==0;)o/=10;return a+o}function oa(e,r,t){if(e!==~~e||e<r||e>t)throw Error(Ji+e)}function ua(e,r,t,n){var i,a,o,u;for(a=e[0];a>=10;a/=10)--r;return--r<0?(r+=7,i=0):(i=Math.ceil((r+1)/7),r%=7),a=Xi(10,7-r),u=e[i]%a|0,null==n?r<3?(0==r?u=u/100|0:1==r&&(u=u/10|0),o=t<4&&99999==u||t>3&&49999==u||5e4==u||0==u):o=(t<4&&u+1==a||t>3&&u+1==a/2)&&(e[i+1]/a/100|0)==Xi(10,r-2)-1||(u==a/2||0==u)&&!(e[i+1]/a/100|0):r<4?(0==r?u=u/1e3|0:1==r?u=u/100|0:2==r&&(u=u/10|0),o=(n||t<4)&&9999==u||!n&&t>3&&4999==u):o=((n||t<4)&&u+1==a||!n&&t>3&&u+1==a/2)&&(e[i+1]/a/1e3|0)==Xi(10,r-3)-1,o}function sa(e,r,t){for(var n,i,a=[0],o=0,u=e.length;o<u;){for(i=a.length;i--;)a[i]*=r;for(a[0]+=Ui.indexOf(e.charAt(o++)),n=0;n<a.length;n++)a[n]>t-1&&(void 0===a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/t|0,a[n]%=t)}return a.reverse()}ia.absoluteValue=ia.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),la(e)},ia.ceil=function(){return la(new this.constructor(this),this.e+1,2)},ia.clampedTo=ia.clamp=function(e,r){var t=this,n=t.constructor;if(e=new n(e),r=new n(r),!e.s||!r.s)return new n(NaN);if(e.gt(r))throw Error(Ji+r);return t.cmp(e)<0?e:t.cmp(r)>0?r:new n(t)},ia.comparedTo=ia.cmp=function(e){var r,t,n,i,a=this,o=a.d,u=(e=new a.constructor(e)).d,s=a.s,c=e.s;if(!o||!u)return s&&c?s!==c?s:o===u?0:!o^s<0?1:-1:NaN;if(!o[0]||!u[0])return o[0]?s:u[0]?-c:0;if(s!==c)return s;if(a.e!==e.e)return a.e>e.e^s<0?1:-1;for(r=0,t=(n=o.length)<(i=u.length)?n:i;r<t;++r)if(o[r]!==u[r])return o[r]>u[r]^s<0?1:-1;return n===i?0:n>i^s<0?1:-1},ia.cosine=ia.cos=function(){var e,r,t=this,n=t.constructor;return t.d?t.d[0]?(r=n.rounding,n.precision=(e=n.precision)+Math.max(t.e,t.sd())+7,n.rounding=1,t=function(e,r){var t,n,i;if(r.isZero())return r;(n=r.d.length)<32?i=""+1/Ca(4,t=Math.ceil(n/3)):(t=16,i="2.3283064365386962890625e-10"),e.precision+=t,r=Ma(e,1,r.times(i),new e(1));for(var a=t;a--;){var o=r.times(r);r=o.times(o).minus(o).times(8).plus(1)}return e.precision-=t,r}(n,Ea(n,t)),n.precision=e,n.rounding=r,la(2==Ii||3==Ii?t.neg():t,e,r,!0)):new n(1):new n(NaN)},ia.cubeRoot=ia.cbrt=function(){var e,r,t,n,i,a,o,u,s,c,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(_i=!1,(a=l.s*Xi(l.s*l,1/3))&&Math.abs(a)!=1/0?n=new f(""+a):(t=aa(l.d),(a=((e=l.e)-t.length+1)%3)&&(t+=1==a||-2==a?"0":"00"),a=Xi(t,1/3),e=Gi((e+1)/3)-(e%3==(e<0?-1:2)),(n=new f(t=a==1/0?"5e"+e:(t=a.toExponential()).slice(0,t.indexOf("e")+1)+e)).s=l.s),o=(e=f.precision)+3;;)if(c=(s=(u=n).times(u).times(u)).plus(l),n=ca(c.plus(l).times(u),c.plus(s),o+2,1),aa(u.d).slice(0,o)===(t=aa(n.d)).slice(0,o)){if("9999"!=(t=t.slice(o-3,o+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(la(n,e+1,1),r=!n.times(n).times(n).eq(l));break}if(!i&&(la(u,e+1,0),u.times(u).times(u).eq(l))){n=u;break}o+=4,i=1}return _i=!0,la(n,e,f.rounding,r)},ia.decimalPlaces=ia.dp=function(){var e,r=this.d,t=NaN;if(r){if(t=7*((e=r.length-1)-Gi(this.e/7)),e=r[e])for(;e%10==0;e/=10)t--;t<0&&(t=0)}return t},ia.dividedBy=ia.div=function(e){return ca(this,new this.constructor(e))},ia.dividedToIntegerBy=ia.divToInt=function(e){var r=this.constructor;return la(ca(this,new r(e),0,1,1),r.precision,r.rounding)},ia.equals=ia.eq=function(e){return 0===this.cmp(e)},ia.floor=function(){return la(new this.constructor(this),this.e+1,3)},ia.greaterThan=ia.gt=function(e){return this.cmp(e)>0},ia.greaterThanOrEqualTo=ia.gte=function(e){var r=this.cmp(e);return 1==r||0===r},ia.hyperbolicCosine=ia.cosh=function(){var e,r,t,n,i,a=this,o=a.constructor,u=new o(1);if(!a.isFinite())return new o(a.s?1/0:NaN);if(a.isZero())return u;n=o.rounding,o.precision=(t=o.precision)+Math.max(a.e,a.sd())+4,o.rounding=1,(i=a.d.length)<32?r=""+1/Ca(4,e=Math.ceil(i/3)):(e=16,r="2.3283064365386962890625e-10"),a=Ma(o,1,a.times(r),new o(1),!0);for(var s,c=e,l=new o(8);c--;)s=a.times(a),a=u.minus(s.times(l.minus(s.times(l))));return la(a,o.precision=t,o.rounding=n,!0)},ia.hyperbolicSine=ia.sinh=function(){var e,r,t,n,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.rounding,a.precision=(r=a.precision)+Math.max(i.e,i.sd())+4,a.rounding=1,(n=i.d.length)<3)i=Ma(a,2,i,i,!0);else{i=Ma(a,2,i=i.times(1/Ca(5,e=(e=1.4*Math.sqrt(n))>16?16:0|e)),i,!0);for(var o,u=new a(5),s=new a(16),c=new a(20);e--;)o=i.times(i),i=i.times(u.plus(o.times(s.times(o).plus(c))))}return a.precision=r,a.rounding=t,la(i,r,t,!0)},ia.hyperbolicTangent=ia.tanh=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.rounding,n.precision=(e=n.precision)+7,n.rounding=1,ca(t.sinh(),t.cosh(),n.precision=e,n.rounding=r)):new n(t.s)},ia.inverseCosine=ia.acos=function(){var e=this,r=e.constructor,t=e.abs().cmp(1),n=r.precision,i=r.rounding;return-1!==t?0===t?e.isNeg()?pa(r,n,i):new r(0):new r(NaN):e.isZero()?pa(r,n+4,i).times(.5):(r.precision=n+6,r.rounding=1,e=new r(1).minus(e).div(e.plus(1)).sqrt().atan(),r.precision=n,r.rounding=i,e.times(2))},ia.inverseHyperbolicCosine=ia.acosh=function(){var e,r,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(r=n.rounding,n.precision=(e=n.precision)+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,_i=!1,t=t.times(t).minus(1).sqrt().plus(t),_i=!0,n.precision=e,n.rounding=r,t.ln()):new n(t)},ia.inverseHyperbolicSine=ia.asinh=function(){var e,r,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(r=n.rounding,n.precision=(e=n.precision)+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,_i=!1,t=t.times(t).plus(1).sqrt().plus(t),_i=!0,n.precision=e,n.rounding=r,t.ln())},ia.inverseHyperbolicTangent=ia.atanh=function(){var e,r,t,n,i=this,a=i.constructor;return i.isFinite()?i.e>=0?new a(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=a.precision,r=a.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?la(new a(i),e,r,!0):(a.precision=t=n-i.e,i=ca(i.plus(1),new a(1).minus(i),t+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=r,i.times(.5))):new a(NaN)},ia.inverseSine=ia.asin=function(){var e,r,t,n,i=this,a=i.constructor;return i.isZero()?new a(i):(r=i.abs().cmp(1),t=a.precision,n=a.rounding,-1!==r?0===r?((e=pa(a,t+4,n).times(.5)).s=i.s,e):new a(NaN):(a.precision=t+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=t,a.rounding=n,i.times(2)))},ia.inverseTangent=ia.atan=function(){var e,r,t,n,i,a,o,u,s,c=this,l=c.constructor,f=l.precision,m=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&f+4<=na)return(o=pa(l,f+4,m).times(.25)).s=c.s,o}else{if(!c.s)return new l(NaN);if(f+4<=na)return(o=pa(l,f+4,m).times(.5)).s=c.s,o}for(l.precision=u=f+10,l.rounding=1,e=t=Math.min(28,u/7+2|0);e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(_i=!1,r=Math.ceil(u/7),n=1,s=c.times(c),o=new l(c),i=c;-1!==e;)if(i=i.times(s),a=o.minus(i.div(n+=2)),i=i.times(s),void 0!==(o=a.plus(i.div(n+=2))).d[r])for(e=r;o.d[e]===a.d[e]&&e--;);return t&&(o=o.times(2<<t-1)),_i=!0,la(o,l.precision=f,l.rounding=m,!0)},ia.isFinite=function(){return!!this.d},ia.isInteger=ia.isInt=function(){return!!this.d&&Gi(this.e/7)>this.d.length-2},ia.isNaN=function(){return!this.s},ia.isNegative=ia.isNeg=function(){return this.s<0},ia.isPositive=ia.isPos=function(){return this.s>0},ia.isZero=function(){return!!this.d&&0===this.d[0]},ia.lessThan=ia.lt=function(e){return this.cmp(e)<0},ia.lessThanOrEqualTo=ia.lte=function(e){return this.cmp(e)<1},ia.logarithm=ia.log=function(e){var r,t,n,i,a,o,u,s,c=this,l=c.constructor,f=l.precision,m=l.rounding;if(null==e)e=new l(10),r=!0;else{if(t=(e=new l(e)).d,e.s<0||!t||!t[0]||e.eq(1))return new l(NaN);r=e.eq(10)}if(t=c.d,c.s<0||!t||!t[0]||c.eq(1))return new l(t&&!t[0]?-1/0:1!=c.s?NaN:t?0:1/0);if(r)if(t.length>1)a=!0;else{for(i=t[0];i%10==0;)i/=10;a=1!==i}if(_i=!1,o=wa(c,u=f+5),n=r?da(l,u+10):wa(e,u),ua((s=ca(o,n,u,1)).d,i=f,m))do{if(o=wa(c,u+=10),n=r?da(l,u+10):wa(e,u),s=ca(o,n,u,1),!a){+aa(s.d).slice(i+1,i+15)+1==1e14&&(s=la(s,f+1,0));break}}while(ua(s.d,i+=10,m));return _i=!0,la(s,f,m)},ia.minus=ia.sub=function(e){var r,t,n,i,a,o,u,s,c,l,f,m,d=this,p=d.constructor;if(e=new p(e),!d.d||!e.d)return d.s&&e.s?d.d?e.s=-e.s:e=new p(e.d||d.s!==e.s?d:NaN):e=new p(NaN),e;if(d.s!=e.s)return e.s=-e.s,d.plus(e);if(m=e.d,u=p.precision,s=p.rounding,!(c=d.d)[0]||!m[0]){if(m[0])e.s=-e.s;else{if(!c[0])return new p(3===s?-0:0);e=new p(d)}return _i?la(e,u,s):e}if(t=Gi(e.e/7),l=Gi(d.e/7),c=c.slice(),a=l-t){for((f=a<0)?(r=c,a=-a,o=m.length):(r=m,t=l,o=c.length),a>(n=Math.max(Math.ceil(u/7),o)+2)&&(a=n,r.length=1),r.reverse(),n=a;n--;)r.push(0);r.reverse()}else{for((f=(n=c.length)<(o=m.length))&&(o=n),n=0;n<o;n++)if(c[n]!=m[n]){f=c[n]<m[n];break}a=0}for(f&&(r=c,c=m,m=r,e.s=-e.s),n=m.length-(o=c.length);n>0;--n)c[o++]=0;for(n=m.length;n>a;){if(c[--n]<m[n]){for(i=n;i&&0===c[--i];)c[i]=ra-1;--c[i],c[n]+=ra}c[n]-=m[n]}for(;0===c[--o];)c.pop();for(;0===c[0];c.shift())--t;return c[0]?(e.d=c,e.e=ma(c,t),_i?la(e,u,s):e):new p(3===s?-0:0)},ia.modulo=ia.mod=function(e){var r,t=this,n=t.constructor;return e=new n(e),!t.d||!e.s||e.d&&!e.d[0]?new n(NaN):!e.d||t.d&&!t.d[0]?la(new n(t),n.precision,n.rounding):(_i=!1,9==n.modulo?(r=ca(t,e.abs(),0,3,1)).s*=e.s:r=ca(t,e,0,n.modulo,1),r=r.times(e),_i=!0,t.minus(r))},ia.naturalExponential=ia.exp=function(){return xa(this)},ia.naturalLogarithm=ia.ln=function(){return wa(this)},ia.negated=ia.neg=function(){var e=new this.constructor(this);return e.s=-e.s,la(e)},ia.plus=ia.add=function(e){var r,t,n,i,a,o,u,s,c,l,f=this,m=f.constructor;if(e=new m(e),!f.d||!e.d)return f.s&&e.s?f.d||(e=new m(e.d||f.s===e.s?f:NaN)):e=new m(NaN),e;if(f.s!=e.s)return e.s=-e.s,f.minus(e);if(l=e.d,u=m.precision,s=m.rounding,!(c=f.d)[0]||!l[0])return l[0]||(e=new m(f)),_i?la(e,u,s):e;if(a=Gi(f.e/7),n=Gi(e.e/7),c=c.slice(),i=a-n){for(i<0?(t=c,i=-i,o=l.length):(t=l,n=a,o=c.length),i>(o=(a=Math.ceil(u/7))>o?a+1:o+1)&&(i=o,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for((o=c.length)-(i=l.length)<0&&(i=o,t=l,l=c,c=t),r=0;i;)r=(c[--i]=c[i]+l[i]+r)/ra|0,c[i]%=ra;for(r&&(c.unshift(r),++n),o=c.length;0==c[--o];)c.pop();return e.d=c,e.e=ma(c,n),_i?la(e,u,s):e},ia.precision=ia.sd=function(e){var r,t=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(Ji+e);return t.d?(r=ha(t.d),e&&t.e+1>r&&(r=t.e+1)):r=NaN,r},ia.round=function(){var e=this,r=e.constructor;return la(new r(e),e.e+1,r.rounding)},ia.sine=ia.sin=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.rounding,n.precision=(e=n.precision)+Math.max(t.e,t.sd())+7,n.rounding=1,t=function(e,r){var t,n=r.d.length;if(n<3)return r.isZero()?r:Ma(e,2,r,r);r=Ma(e,2,r=r.times(1/Ca(5,t=(t=1.4*Math.sqrt(n))>16?16:0|t)),r);for(var i,a=new e(5),o=new e(16),u=new e(20);t--;)i=r.times(r),r=r.times(a.plus(i.times(o.times(i).minus(u))));return r}(n,Ea(n,t)),n.precision=e,n.rounding=r,la(Ii>2?t.neg():t,e,r,!0)):new n(NaN)},ia.squareRoot=ia.sqrt=function(){var e,r,t,n,i,a,o=this,u=o.d,s=o.e,c=o.s,l=o.constructor;if(1!==c||!u||!u[0])return new l(!c||c<0&&(!u||u[0])?NaN:u?o:1/0);for(_i=!1,0==(c=Math.sqrt(+o))||c==1/0?(((r=aa(u)).length+s)%2==0&&(r+="0"),c=Math.sqrt(r),s=Gi((s+1)/2)-(s<0||s%2),n=new l(r=c==1/0?"5e"+s:(r=c.toExponential()).slice(0,r.indexOf("e")+1)+s)):n=new l(""+c),t=(s=l.precision)+3;;)if(n=(a=n).plus(ca(o,a,t+2,1)).times(.5),aa(a.d).slice(0,t)===(r=aa(n.d)).slice(0,t)){if("9999"!=(r=r.slice(t-3,t+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(la(n,s+1,1),e=!n.times(n).eq(o));break}if(!i&&(la(a,s+1,0),a.times(a).eq(o))){n=a;break}t+=4,i=1}return _i=!0,la(n,s,l.rounding,e)},ia.tangent=ia.tan=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.rounding,n.precision=(e=n.precision)+10,n.rounding=1,(t=t.sin()).s=1,t=ca(t,new n(1).minus(t.times(t)).sqrt(),e+10,0),n.precision=e,n.rounding=r,la(2==Ii||4==Ii?t.neg():t,e,r,!0)):new n(NaN)},ia.times=ia.mul=function(e){var r,t,n,i,a,o,u,s,c,l=this,f=l.constructor,m=l.d,d=(e=new f(e)).d;if(e.s*=l.s,!(m&&m[0]&&d&&d[0]))return new f(!e.s||m&&!m[0]&&!d||d&&!d[0]&&!m?NaN:m&&d?0*e.s:e.s/0);for(t=Gi(l.e/7)+Gi(e.e/7),(s=m.length)<(c=d.length)&&(a=m,m=d,d=a,o=s,s=c,c=o),a=[],n=o=s+c;n--;)a.push(0);for(n=c;--n>=0;){for(r=0,i=s+n;i>n;)u=a[i]+d[n]*m[i-n-1]+r,a[i--]=u%ra|0,r=u/ra|0;a[i]=(a[i]+r)%ra|0}for(;!a[--o];)a.pop();return r?++t:a.shift(),e.d=a,e.e=ma(a,t),_i?la(e,f.precision,f.rounding):e},ia.toBinary=function(e,r){return Sa(this,2,e,r)},ia.toDecimalPlaces=ia.toDP=function(e,r){var t=this,n=t.constructor;return t=new n(t),void 0===e?t:(oa(e,0,Ri),void 0===r?r=n.rounding:oa(r,0,8),la(t,e+t.e+1,r))},ia.toExponential=function(e,r){var t,n=this,i=n.constructor;return void 0===e?t=fa(n,!0):(oa(e,0,Ri),void 0===r?r=i.rounding:oa(r,0,8),t=fa(n=la(new i(n),e+1,r),!0,e+1)),n.isNeg()&&!n.isZero()?"-"+t:t},ia.toFixed=function(e,r){var t,n,i=this,a=i.constructor;return void 0===e?t=fa(i):(oa(e,0,Ri),void 0===r?r=a.rounding:oa(r,0,8),t=fa(n=la(new a(i),e+i.e+1,r),!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t},ia.toFraction=function(e){var r,t,n,i,a,o,u,s,c,l,f,m,d=this,p=d.d,h=d.constructor;if(!p)return new h(d);if(c=t=new h(1),n=s=new h(0),a=(r=new h(n)).e=ha(p)-d.e-1,r.d[0]=Xi(10,(o=a%7)<0?7+o:o),null==e)e=a>0?r:c;else{if(!(u=new h(e)).isInt()||u.lt(c))throw Error(Ji+u);e=u.gt(r)?a>0?r:c:u}for(_i=!1,u=new h(aa(p)),l=h.precision,h.precision=a=7*p.length*2;f=ca(u,r,0,1,1),1!=(i=t.plus(f.times(n))).cmp(e);)t=n,n=i,c=s.plus(f.times(i=c)),s=i,r=u.minus(f.times(i=r)),u=i;return i=ca(e.minus(t),n,0,1,1),s=s.plus(i.times(c)),t=t.plus(i.times(n)),s.s=c.s=d.s,m=ca(c,n,a,1).minus(d).abs().cmp(ca(s,t,a,1).minus(d).abs())<1?[c,n]:[s,t],h.precision=l,_i=!0,m},ia.toHexadecimal=ia.toHex=function(e,r){return Sa(this,16,e,r)},ia.toNearest=function(e,r){var t=this,n=t.constructor;if(t=new n(t),null==e){if(!t.d)return t;e=new n(1),r=n.rounding}else{if(e=new n(e),void 0===r?r=n.rounding:oa(r,0,8),!t.d)return e.s?t:e;if(!e.d)return e.s&&(e.s=t.s),e}return e.d[0]?(_i=!1,t=ca(t,e,0,r,1).times(e),_i=!0,la(t)):(e.s=t.s,t=e),t},ia.toNumber=function(){return+this},ia.toOctal=function(e,r){return Sa(this,8,e,r)},ia.toPower=ia.pow=function(e){var r,t,n,i,a,o,u=this,s=u.constructor,c=+(e=new s(e));if(!(u.d&&e.d&&u.d[0]&&e.d[0]))return new s(Xi(+u,c));if((u=new s(u)).eq(1))return u;if(n=s.precision,a=s.rounding,e.eq(1))return la(u,n,a);if((r=Gi(e.e/7))>=e.d.length-1&&(t=c<0?-c:c)<=9007199254740991)return i=ya(s,u,t,n),e.s<0?new s(1).div(i):la(i,n,a);if((o=u.s)<0){if(r<e.d.length-1)return new s(NaN);if(1&e.d[r]||(o=1),0==u.e&&1==u.d[0]&&1==u.d.length)return u.s=o,u}return(r=0!=(t=Xi(+u,c))&&isFinite(t)?new s(t+"").e:Gi(c*(Math.log("0."+aa(u.d))/Math.LN10+u.e+1)))>s.maxE+1||r<s.minE-1?new s(r>0?o/0:0):(_i=!1,s.rounding=u.s=1,(i=xa(e.times(wa(u,n+(t=Math.min(12,(r+"").length)))),n)).d&&ua((i=la(i,n+5,1)).d,n,a)&&+aa((i=la(xa(e.times(wa(u,(r=n+10)+t)),r),r+5,1)).d).slice(n+1,n+15)+1==1e14&&(i=la(i,n+1,0)),i.s=o,_i=!0,s.rounding=a,la(i,n,a))},ia.toPrecision=function(e,r){var t,n=this,i=n.constructor;return void 0===e?t=fa(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(oa(e,1,Ri),void 0===r?r=i.rounding:oa(r,0,8),t=fa(n=la(new i(n),e,r),e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+t:t},ia.toSignificantDigits=ia.toSD=function(e,r){var t=this.constructor;return void 0===e?(e=t.precision,r=t.rounding):(oa(e,1,Ri),void 0===r?r=t.rounding:oa(r,0,8)),la(new t(this),e,r)},ia.toString=function(){var e=this,r=e.constructor,t=fa(e,e.e<=r.toExpNeg||e.e>=r.toExpPos);return e.isNeg()&&!e.isZero()?"-"+t:t},ia.truncated=ia.trunc=function(){return la(new this.constructor(this),this.e+1,1)},ia.valueOf=ia.toJSON=function(){var e=this,r=e.constructor,t=fa(e,e.e<=r.toExpNeg||e.e>=r.toExpPos);return e.isNeg()?"-"+t:t};var ca=function(){function e(e,r,t){var n,i=0,a=e.length;for(e=e.slice();a--;)e[a]=(n=e[a]*r+i)%t|0,i=n/t|0;return i&&e.unshift(i),e}function r(e,r,t,n){var i,a;if(t!=n)a=t>n?1:-1;else for(i=a=0;i<t;i++)if(e[i]!=r[i]){a=e[i]>r[i]?1:-1;break}return a}function t(e,r,t,n){for(var i=0;t--;)e[t]-=i,e[t]=(i=e[t]<r[t]?1:0)*n+e[t]-r[t];for(;!e[0]&&e.length>1;)e.shift()}return function(n,i,a,o,u,s){var c,l,f,m,d,p,h,v,y,b,g,x,w,D,N,A,M,C,E,S,F=n.constructor,B=n.s==i.s?1:-1,q=n.d,T=i.d;if(!(q&&q[0]&&T&&T[0]))return new F(n.s&&i.s&&(q?!T||q[0]!=T[0]:T)?q&&0==q[0]||!T?0*B:B/0:NaN);for(s?(d=1,l=n.e-i.e):(s=ra,l=Gi(n.e/(d=7))-Gi(i.e/d)),E=T.length,M=q.length,b=(y=new F(B)).d=[],f=0;T[f]==(q[f]||0);f++);if(T[f]>(q[f]||0)&&l--,null==a?(D=a=F.precision,o=F.rounding):D=u?a+(n.e-i.e)+1:a,D<0)b.push(1),p=!0;else{if(D=D/d+2|0,f=0,1==E){for(m=0,T=T[0],D++;(f<M||m)&&D--;f++)b[f]=(N=m*s+(q[f]||0))/T|0,m=N%T|0;p=m||f<M}else{for((m=s/(T[0]+1)|0)>1&&(T=e(T,m,s),q=e(q,m,s),E=T.length,M=q.length),A=E,x=(g=q.slice(0,E)).length;x<E;)g[x++]=0;(S=T.slice()).unshift(0),C=T[0],T[1]>=s/2&&++C;do{m=0,(c=r(T,g,E,x))<0?(w=g[0],E!=x&&(w=w*s+(g[1]||0)),(m=w/C|0)>1?(m>=s&&(m=s-1),1==(c=r(h=e(T,m,s),g,v=h.length,x=g.length))&&(m--,t(h,E<v?S:T,v,s))):(0==m&&(c=m=1),h=T.slice()),(v=h.length)<x&&h.unshift(0),t(g,h,x,s),-1==c&&(c=r(T,g,E,x=g.length))<1&&(m++,t(g,E<x?S:T,x,s)),x=g.length):0===c&&(m++,g=[0]),b[f++]=m,c&&g[0]?g[x++]=q[A]||0:(g=[q[A]],x=1)}while((A++<M||void 0!==g[0])&&D--);p=void 0!==g[0]}b[0]||b.shift()}if(1==d)y.e=l,Oi=p;else{for(f=1,m=b[0];m>=10;m/=10)f++;y.e=f+l*d-1,la(y,u?a+y.e+1:a,o,p)}return y}}();function la(e,r,t,n){var i,a,o,u,s,c,l,f,m,d=e.constructor;e:if(null!=r){if(!(f=e.d))return e;for(i=1,u=f[0];u>=10;u/=10)i++;if((a=r-i)<0)a+=7,s=(l=f[m=0])/Xi(10,i-(o=r)-1)%10|0;else if((m=Math.ceil((a+1)/7))>=(u=f.length)){if(!n)break e;for(;u++<=m;)f.push(0);l=s=0,i=1,o=(a%=7)-7+1}else{for(l=u=f[m],i=1;u>=10;u/=10)i++;s=(o=(a%=7)-7+i)<0?0:l/Xi(10,i-o-1)%10|0}if(n=n||r<0||void 0!==f[m+1]||(o<0?l:l%Xi(10,i-o-1)),c=t<4?(s||n)&&(0==t||t==(e.s<0?3:2)):s>5||5==s&&(4==t||n||6==t&&(a>0?o>0?l/Xi(10,i-o):0:f[m-1])%10&1||t==(e.s<0?8:7)),r<1||!f[0])return f.length=0,c?(f[0]=Xi(10,(7-(r-=e.e+1)%7)%7),e.e=-r||0):f[0]=e.e=0,e;if(0==a?(f.length=m,u=1,m--):(f.length=m+1,u=Xi(10,7-a),f[m]=o>0?(l/Xi(10,i-o)%Xi(10,o)|0)*u:0),c)for(;;){if(0==m){for(a=1,o=f[0];o>=10;o/=10)a++;for(o=f[0]+=u,u=1;o>=10;o/=10)u++;a!=u&&(e.e++,f[0]==ra&&(f[0]=1));break}if(f[m]+=u,f[m]!=ra)break;f[m--]=0,u=1}for(a=f.length;0===f[--a];)f.pop()}return _i&&(e.e>d.maxE?(e.d=null,e.e=NaN):e.e<d.minE&&(e.e=0,e.d=[0])),e}function fa(e,r,t){if(!e.isFinite())return Da(e);var n,i=e.e,a=aa(e.d),o=a.length;return r?(t&&(n=t-o)>0?a=a.charAt(0)+"."+a.slice(1)+va(n):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(e.e<0?"e":"e+")+e.e):i<0?(a="0."+va(-i-1)+a,t&&(n=t-o)>0&&(a+=va(n))):i>=o?(a+=va(i+1-o),t&&(n=t-i-1)>0&&(a=a+"."+va(n))):((n=i+1)<o&&(a=a.slice(0,n)+"."+a.slice(n)),t&&(n=t-o)>0&&(i+1===o&&(a+="."),a+=va(n))),a}function ma(e,r){var t=e[0];for(r*=7;t>=10;t/=10)r++;return r}function da(e,r,t){if(r>ta)throw _i=!0,t&&(e.precision=t),Error(Vi);return la(new e($i),r,1,!0)}function pa(e,r,t){if(r>na)throw Error(Vi);return la(new e(Pi),r,t,!0)}function ha(e){var r=e.length-1,t=7*r+1;if(r=e[r]){for(;r%10==0;r/=10)t--;for(r=e[0];r>=10;r/=10)t++}return t}function va(e){for(var r="";e--;)r+="0";return r}function ya(e,r,t,n){var i,a=new e(1),o=Math.ceil(n/7+4);for(_i=!1;;){if(t%2&&Fa((a=a.times(r)).d,o)&&(i=!0),0===(t=Gi(t/2))){t=a.d.length-1,i&&0===a.d[t]&&++a.d[t];break}Fa((r=r.times(r)).d,o)}return _i=!0,a}function ba(e){return 1&e.d[e.d.length-1]}function ga(e,r,t){for(var n,i,a=new e(r[0]),o=0;++o<r.length;){if(!(i=new e(r[o])).s){a=i;break}((n=a.cmp(i))===t||0===n&&a.s===t)&&(a=i)}return a}function xa(e,r){var t,n,i,a,o,u,s,c=0,l=0,f=0,m=e.constructor,d=m.rounding,p=m.precision;if(!e.d||!e.d[0]||e.e>17)return new m(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==r?(_i=!1,s=p):s=r,u=new m(.03125);e.e>-2;)e=e.times(u),f+=5;for(s+=n=Math.log(Xi(2,f))/Math.LN10*2+5|0,t=a=o=new m(1),m.precision=s;;){if(a=la(a.times(e),s,1),t=t.times(++l),aa((u=o.plus(ca(a,t,s,1))).d).slice(0,s)===aa(o.d).slice(0,s)){for(i=f;i--;)o=la(o.times(o),s,1);if(null!=r)return m.precision=p,o;if(!(c<3&&ua(o.d,s-n,d,c)))return la(o,m.precision=p,d,_i=!0);m.precision=s+=10,t=a=u=new m(1),l=0,c++}o=u}}function wa(e,r){var t,n,i,a,o,u,s,c,l,f,m,d=1,p=e,h=p.d,v=p.constructor,y=v.rounding,b=v.precision;if(p.s<0||!h||!h[0]||!p.e&&1==h[0]&&1==h.length)return new v(h&&!h[0]?-1/0:1!=p.s?NaN:h?0:p);if(null==r?(_i=!1,l=b):l=r,v.precision=l+=10,n=(t=aa(h)).charAt(0),!(Math.abs(a=p.e)<15e14))return c=da(v,l+2,b).times(a+""),p=wa(new v(n+"."+t.slice(1)),l-10).plus(c),v.precision=b,null==r?la(p,b,y,_i=!0):p;for(;n<7&&1!=n||1==n&&t.charAt(1)>3;)n=(t=aa((p=p.times(e)).d)).charAt(0),d++;for(a=p.e,n>1?(p=new v("0."+t),a++):p=new v(n+"."+t.slice(1)),f=p,s=o=p=ca(p.minus(1),p.plus(1),l,1),m=la(p.times(p),l,1),i=3;;){if(o=la(o.times(m),l,1),aa((c=s.plus(ca(o,new v(i),l,1))).d).slice(0,l)===aa(s.d).slice(0,l)){if(s=s.times(2),0!==a&&(s=s.plus(da(v,l+2,b).times(a+""))),s=ca(s,new v(d),l,1),null!=r)return v.precision=b,s;if(!ua(s.d,l-10,y,u))return la(s,v.precision=b,y,_i=!0);v.precision=l+=10,c=o=p=ca(f.minus(1),f.plus(1),l,1),m=la(p.times(p),l,1),i=u=1}s=c,i+=2}}function Da(e){return e.s*e.s/0+""}function Na(e,r){var t,n,i;for((t=r.indexOf("."))>-1&&(r=r.replace(".","")),(n=r.search(/e/i))>0?(t<0&&(t=n),t+=+r.slice(n+1),r=r.substring(0,n)):t<0&&(t=r.length),n=0;48===r.charCodeAt(n);n++);for(i=r.length;48===r.charCodeAt(i-1);--i);if(r=r.slice(n,i)){if(i-=n,e.e=t=t-n-1,e.d=[],n=(t+1)%7,t<0&&(n+=7),n<i){for(n&&e.d.push(+r.slice(0,n)),i-=7;n<i;)e.d.push(+r.slice(n,n+=7));n=7-(r=r.slice(n)).length}else n-=i;for(;n--;)r+="0";e.d.push(+r),_i&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function Aa(e,r){var t,n,i,a,o,u,s,c,l;if(r.indexOf("_")>-1){if(r=r.replace(/(\d)_(?=\d)/g,"$1"),ea.test(r))return Na(e,r)}else if("Infinity"===r||"NaN"===r)return+r||(e.s=NaN),e.e=NaN,e.d=null,e;if(Qi.test(r))t=16,r=r.toLowerCase();else if(Yi.test(r))t=2;else{if(!Ki.test(r))throw Error(Ji+r);t=8}for((a=r.search(/p/i))>0?(s=+r.slice(a+1),r=r.substring(2,a)):r=r.slice(2),a=r.indexOf("."),n=e.constructor,(o=a>=0)&&(a=(u=(r=r.replace(".","")).length)-a,i=ya(n,new n(t),a,2*a)),a=l=(c=sa(r,t,ra)).length-1;0===c[a];--a)c.pop();return a<0?new n(0*e.s):(e.e=ma(c,l),e.d=c,_i=!1,o&&(e=ca(e,i,4*u)),s&&(e=e.times(Math.abs(s)<54?Xi(2,s):yo.pow(2,s))),_i=!0,e)}function Ma(e,r,t,n,i){var a,o,u,s,c=e.precision,l=Math.ceil(c/7);for(_i=!1,s=t.times(t),u=new e(n);;){if(o=ca(u.times(s),new e(r++*r++),c,1),u=i?n.plus(o):n.minus(o),n=ca(o.times(s),new e(r++*r++),c,1),void 0!==(o=u.plus(n)).d[l]){for(a=l;o.d[a]===u.d[a]&&a--;);if(-1==a)break}a=u,u=n,n=o,o=a}return _i=!0,o.d.length=l+1,o}function Ca(e,r){for(var t=e;--r;)t*=e;return t}function Ea(e,r){var t,n=r.s<0,i=pa(e,e.precision,1),a=i.times(.5);if((r=r.abs()).lte(a))return Ii=n?4:1,r;if((t=r.divToInt(i)).isZero())Ii=n?3:2;else{if((r=r.minus(t.times(i))).lte(a))return Ii=ba(t)?n?2:3:n?4:1,r;Ii=ba(t)?n?1:4:n?3:2}return r.minus(i).abs()}function Sa(e,r,t,n){var i,a,o,u,s,c,l,f,m,d=e.constructor,p=void 0!==t;if(p?(oa(t,1,Ri),void 0===n?n=d.rounding:oa(n,0,8)):(t=d.precision,n=d.rounding),e.isFinite()){for(p?(i=2,16==r?t=4*t-3:8==r&&(t=3*t-2)):i=r,(o=(l=fa(e)).indexOf("."))>=0&&(l=l.replace(".",""),(m=new d(1)).e=l.length-o,m.d=sa(fa(m),10,i),m.e=m.d.length),a=s=(f=sa(l,10,i)).length;0==f[--s];)f.pop();if(f[0]){if(o<0?a--:((e=new d(e)).d=f,e.e=a,f=(e=ca(e,m,t,n,0,i)).d,a=e.e,c=Oi),o=f[t],u=i/2,c=c||void 0!==f[t+1],c=n<4?(void 0!==o||c)&&(0===n||n===(e.s<0?3:2)):o>u||o===u&&(4===n||c||6===n&&1&f[t-1]||n===(e.s<0?8:7)),f.length=t,c)for(;++f[--t]>i-1;)f[t]=0,t||(++a,f.unshift(1));for(s=f.length;!f[s-1];--s);for(o=0,l="";o<s;o++)l+=Ui.charAt(f[o]);if(p){if(s>1)if(16==r||8==r){for(o=16==r?4:3,--s;s%o;s++)l+="0";for(s=(f=sa(l,i,r)).length;!f[s-1];--s);for(o=1,l="1.";o<s;o++)l+=Ui.charAt(f[o])}else l=l.charAt(0)+"."+l.slice(1);l=l+(a<0?"p":"p+")+a}else if(a<0){for(;++a;)l="0"+l;l="0."+l}else if(++a>s)for(a-=s;a--;)l+="0";else a<s&&(l=l.slice(0,a)+"."+l.slice(a))}else l=p?"0p+0":"0";l=(16==r?"0x":2==r?"0b":8==r?"0o":"")+l}else l=Da(e);return e.s<0?"-"+l:l}function Fa(e,r){if(e.length>r)return e.length=r,!0}function Ba(e){return new this(e).abs()}function qa(e){return new this(e).acos()}function Ta(e){return new this(e).acosh()}function ka(e,r){return new this(e).plus(r)}function Oa(e){return new this(e).asin()}function Ia(e){return new this(e).asinh()}function za(e){return new this(e).atan()}function ja(e){return new this(e).atanh()}function Ra(e,r){e=new this(e),r=new this(r);var t,n=this.precision,i=this.rounding,a=n+4;return e.s&&r.s?e.d||r.d?!r.d||e.isZero()?(t=r.s<0?pa(this,n,i):new this(0)).s=e.s:!e.d||r.isZero()?(t=pa(this,a,1).times(.5)).s=e.s:r.s<0?(this.precision=a,this.rounding=1,t=this.atan(ca(e,r,a,1)),r=pa(this,a,1),this.precision=n,this.rounding=i,t=e.s<0?t.minus(r):t.plus(r)):t=this.atan(ca(e,r,a,1)):(t=pa(this,a,1).times(r.s>0?.25:.75)).s=e.s:t=new this(NaN),t}function Ua(e){return new this(e).cbrt()}function $a(e){return la(e=new this(e),e.e+1,2)}function Pa(e,r,t){return new this(e).clamp(r,t)}function La(e){if(!e||"object"!=typeof e)throw Error(Wi+"Object expected");var r,t,n,i=!0===e.defaults,a=["precision",1,Ri,"rounding",0,8,"toExpNeg",-ji,0,"toExpPos",0,ji,"maxE",0,ji,"minE",-ji,0,"modulo",0,9];for(r=0;r<a.length;r+=3)if(t=a[r],i&&(this[t]=Li[t]),void 0!==(n=e[t])){if(!(Gi(n)===n&&n>=a[r+1]&&n<=a[r+2]))throw Error(Ji+t+": "+n);this[t]=n}if(t="crypto",i&&(this[t]=Li[t]),void 0!==(n=e[t])){if(!0!==n&&!1!==n&&0!==n&&1!==n)throw Error(Ji+t+": "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(Hi);this[t]=!0}else this[t]=!1}return this}function _a(e){return new this(e).cos()}function Wa(e){return new this(e).cosh()}function Ja(e,r){return new this(e).div(r)}function Va(e){return new this(e).exp()}function Ha(e){return la(e=new this(e),e.e+1,3)}function Za(){var e,r,t=new this(0);for(_i=!1,e=0;e<arguments.length;)if((r=new this(arguments[e++])).d)t.d&&(t=t.plus(r.times(r)));else{if(r.s)return _i=!0,new this(1/0);t=r}return _i=!0,t.sqrt()}function Ga(e){return e instanceof yo||e&&e.toStringTag===Zi||!1}function Xa(e){return new this(e).ln()}function Ya(e,r){return new this(e).log(r)}function Qa(e){return new this(e).log(2)}function Ka(e){return new this(e).log(10)}function eo(){return ga(this,arguments,-1)}function ro(){return ga(this,arguments,1)}function to(e,r){return new this(e).mod(r)}function no(e,r){return new this(e).mul(r)}function io(e,r){return new this(e).pow(r)}function ao(e){var r,t,n,i,a=0,o=new this(1),u=[];if(void 0===e?e=this.precision:oa(e,1,Ri),n=Math.ceil(e/7),this.crypto)if(crypto.getRandomValues)for(r=crypto.getRandomValues(new Uint32Array(n));a<n;)(i=r[a])>=429e7?r[a]=crypto.getRandomValues(new Uint32Array(1))[0]:u[a++]=i%1e7;else{if(!crypto.randomBytes)throw Error(Hi);for(r=crypto.randomBytes(n*=4);a<n;)(i=r[a]+(r[a+1]<<8)+(r[a+2]<<16)+((127&r[a+3])<<24))>=214e7?crypto.randomBytes(4).copy(r,a):(u.push(i%1e7),a+=4);a=n/4}else for(;a<n;)u[a++]=1e7*Math.random()|0;for(e%=7,(n=u[--a])&&e&&(i=Xi(10,7-e),u[a]=(n/i|0)*i);0===u[a];a--)u.pop();if(a<0)t=0,u=[0];else{for(t=-1;0===u[0];t-=7)u.shift();for(n=1,i=u[0];i>=10;i/=10)n++;n<7&&(t-=7-n)}return o.e=t,o.d=u,o}function oo(e){return la(e=new this(e),e.e+1,this.rounding)}function uo(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function so(e){return new this(e).sin()}function co(e){return new this(e).sinh()}function lo(e){return new this(e).sqrt()}function fo(e,r){return new this(e).sub(r)}function mo(){var e=0,r=arguments,t=new this(r[e]);for(_i=!1;t.s&&++e<r.length;)t=t.plus(r[e]);return _i=!0,la(t,this.precision,this.rounding)}function po(e){return new this(e).tan()}function ho(e){return new this(e).tanh()}function vo(e){return la(e=new this(e),e.e+1,1)}ia[Symbol.for("nodejs.util.inspect.custom")]=ia.toString,ia[Symbol.toStringTag]="Decimal";var yo=ia.constructor=function e(r){var t,n,i;function a(e){var r,t,n,i=this;if(!(i instanceof a))return new a(e);if(i.constructor=a,Ga(e))return i.s=e.s,void(_i?!e.d||e.e>a.maxE?(i.e=NaN,i.d=null):e.e<a.minE?(i.e=0,i.d=[0]):(i.e=e.e,i.d=e.d.slice()):(i.e=e.e,i.d=e.d?e.d.slice():e.d));if("number"==(n=typeof e)){if(0===e)return i.s=1/e<0?-1:1,i.e=0,void(i.d=[0]);if(e<0?(e=-e,i.s=-1):i.s=1,e===~~e&&e<1e7){for(r=0,t=e;t>=10;t/=10)r++;return void(_i?r>a.maxE?(i.e=NaN,i.d=null):r<a.minE?(i.e=0,i.d=[0]):(i.e=r,i.d=[e]):(i.e=r,i.d=[e]))}return 0*e!=0?(e||(i.s=NaN),i.e=NaN,void(i.d=null)):Na(i,""+e)}if("string"===n)return 45===(t=e.charCodeAt(0))?(e=e.slice(1),i.s=-1):(43===t&&(e=e.slice(1)),i.s=1),ea.test(e)?Na(i,e):Aa(i,e);if("bigint"===n)return e<0?(e=-e,i.s=-1):i.s=1,Na(i,""+e);throw Error(Ji+e)}if(a.prototype=ia,a.ROUND_UP=0,a.ROUND_DOWN=1,a.ROUND_CEIL=2,a.ROUND_FLOOR=3,a.ROUND_HALF_UP=4,a.ROUND_HALF_DOWN=5,a.ROUND_HALF_EVEN=6,a.ROUND_HALF_CEIL=7,a.ROUND_HALF_FLOOR=8,a.EUCLID=9,a.config=a.set=La,a.clone=e,a.isDecimal=Ga,a.abs=Ba,a.acos=qa,a.acosh=Ta,a.add=ka,a.asin=Oa,a.asinh=Ia,a.atan=za,a.atanh=ja,a.atan2=Ra,a.cbrt=Ua,a.ceil=$a,a.clamp=Pa,a.cos=_a,a.cosh=Wa,a.div=Ja,a.exp=Va,a.floor=Ha,a.hypot=Za,a.ln=Xa,a.log=Ya,a.log10=Ka,a.log2=Qa,a.max=eo,a.min=ro,a.mod=to,a.mul=no,a.pow=io,a.random=ao,a.round=oo,a.sign=uo,a.sin=so,a.sinh=co,a.sqrt=lo,a.sub=fo,a.sum=mo,a.tan=po,a.tanh=ho,a.trunc=vo,void 0===r&&(r={}),r&&!0!==r.defaults)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<i.length;)r.hasOwnProperty(n=i[t++])||(r[n]=this[n]);return a.config(r),a}(Li);$i=new yo($i),Pi=new yo(Pi);var bo,go=ti("BigNumber",["?on","config"],(e=>{var{on:r,config:t}=e,n=yo.clone({precision:t.precision,modulo:yo.EUCLID});return n.prototype=Object.create(n.prototype),n.prototype.type="BigNumber",n.prototype.isBigNumber=!0,n.prototype.toJSON=function(){return{mathjs:"BigNumber",value:""+this}},n.fromJSON=function(e){return new n(e.value)},r&&r("config",(function(e,r){e.precision!==r.precision&&n.config({precision:e.precision})})),n}),{isClass:!0}),xo={exports:{}},wo=(bo||(bo=1,function(e){const r=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:.5*(Math.exp(e)+Math.exp(-e))},t=Math.sinh||function(e){return Math.abs(e)<1e-9?e:.5*(Math.exp(e)-Math.exp(-e))},n=function(e,r){return(e=Math.abs(e))<(r=Math.abs(r))&&([e,r]=[r,e]),e<1e8?Math.sqrt(e*e+r*r):e*Math.sqrt(1+(r/=e)*r)},i=function(){throw SyntaxError("Invalid Param")};function a(e,r){const t=Math.abs(e),n=Math.abs(r);return 0===e?Math.log(n):0===r?Math.log(t):t<3e3&&n<3e3?.5*Math.log(e*e+r*r):.5*Math.log((e*=.5)*e+(r*=.5)*r)+Math.LN2}const o={re:0,im:0},u=function(e,r){const t=o;if(null==e)t.re=t.im=0;else if(void 0!==r)t.re=e,t.im=r;else switch(typeof e){case"object":if("im"in e&&"re"in e)t.re=e.re,t.im=e.im;else if("abs"in e&&"arg"in e){if(!isFinite(e.abs)&&isFinite(e.arg))return s.INFINITY;t.re=e.abs*Math.cos(e.arg),t.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!isFinite(e.r)&&isFinite(e.phi))return s.INFINITY;t.re=e.r*Math.cos(e.phi),t.im=e.r*Math.sin(e.phi)}else 2===e.length?(t.re=e[0],t.im=e[1]):i();break;case"string":t.im=t.re=0;const r=e.replace(/_/g,"").match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g);let n=1,a=0;null===r&&i();for(let e=0;e<r.length;e++){const o=r[e];" "===o||"\t"===o||"\n"===o||("+"===o?n++:"-"===o?a++:"i"===o||"I"===o?(n+a===0&&i()," "===r[e+1]||isNaN(r[e+1])?t.im+=parseFloat((a%2?"-":"")+"1"):(t.im+=parseFloat((a%2?"-":"")+r[e+1]),e++),n=a=0):((n+a===0||isNaN(o))&&i(),"i"===r[e+1]||"I"===r[e+1]?(t.im+=parseFloat((a%2?"-":"")+o),e++):t.re+=parseFloat((a%2?"-":"")+o),n=a=0))}n+a>0&&i();break;case"number":t.im=0,t.re=e;break;default:i()}return t};function s(e,r){if(!(this instanceof s))return new s(e,r);const t=u(e,r);this.re=t.re,this.im=t.im}s.prototype={re:0,im:0,sign:function(){const e=n(this.re,this.im);return new s(this.re/e,this.im/e)},add:function(e,r){const t=u(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n||i?n&&i?s.NAN:s.INFINITY:new s(this.re+t.re,this.im+t.im)},sub:function(e,r){const t=u(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n||i?n&&i?s.NAN:s.INFINITY:new s(this.re-t.re,this.im-t.im)},mul:function(e,r){const t=u(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n&&0===t.re&&0===t.im||i&&0===this.re&&0===this.im?s.NAN:n||i?s.INFINITY:0===t.im&&0===this.im?new s(this.re*t.re,0):new s(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)},div:function(e,r){const t=u(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im)),a=0===this.re&&0===this.im,o=0===t.re&&0===t.im;if(a&&o||n&&i)return s.NAN;if(o||n)return s.INFINITY;if(a||i)return s.ZERO;if(0===t.im)return new s(this.re/t.re,this.im/t.re);if(Math.abs(t.re)<Math.abs(t.im)){const e=t.re/t.im,r=t.re*e+t.im;return new s((this.re*e+this.im)/r,(this.im*e-this.re)/r)}{const e=t.im/t.re,r=t.im*e+t.re;return new s((this.re+this.im*e)/r,(this.im-this.re*e)/r)}},pow:function(e,r){const t=u(e,r),n=0===this.re&&0===this.im;if(0===t.re&&0===t.im)return s.ONE;if(0===t.im){if(0===this.im&&this.re>0)return new s(Math.pow(this.re,t.re),0);if(0===this.re)switch((t.re%4+4)%4){case 0:return new s(Math.pow(this.im,t.re),0);case 1:return new s(0,Math.pow(this.im,t.re));case 2:return new s(-Math.pow(this.im,t.re),0);case 3:return new s(0,-Math.pow(this.im,t.re))}}if(n&&t.re>0)return s.ZERO;const i=Math.atan2(this.im,this.re),o=a(this.re,this.im);let c=Math.exp(t.re*o-t.im*i),l=t.im*o+t.re*i;return new s(c*Math.cos(l),c*Math.sin(l))},sqrt:function(){const e=this.re,r=this.im;if(0===r)return e>=0?new s(Math.sqrt(e),0):new s(0,Math.sqrt(-e));const t=n(e,r);let i=Math.sqrt(.5*(t+Math.abs(e))),a=Math.abs(r)/(2*i);return e>=0?new s(i,r<0?-a:a):new s(a,r<0?-i:i)},exp:function(){const e=Math.exp(this.re);return 0===this.im?new s(e,0):new s(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){const e=this.re,r=this.im;return new s(Math.expm1(e)*Math.cos(r)+(e=>{const r=Math.sin(.5*e);return-2*r*r})(r),Math.exp(e)*Math.sin(r))},log:function(){const e=this.re,r=this.im;return 0===r&&e>0?new s(Math.log(e),0):new s(a(e,r),Math.atan2(r,e))},abs:function(){return n(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){const e=this.re,n=this.im;return new s(Math.sin(e)*r(n),Math.cos(e)*t(n))},cos:function(){const e=this.re,n=this.im;return new s(Math.cos(e)*r(n),-Math.sin(e)*t(n))},tan:function(){const e=2*this.re,n=2*this.im,i=Math.cos(e)+r(n);return new s(Math.sin(e)/i,t(n)/i)},cot:function(){const e=2*this.re,n=2*this.im,i=Math.cos(e)-r(n);return new s(-Math.sin(e)/i,t(n)/i)},sec:function(){const e=this.re,n=this.im,i=.5*r(2*n)+.5*Math.cos(2*e);return new s(Math.cos(e)*r(n)/i,Math.sin(e)*t(n)/i)},csc:function(){const e=this.re,n=this.im,i=.5*r(2*n)-.5*Math.cos(2*e);return new s(Math.sin(e)*r(n)/i,-Math.cos(e)*t(n)/i)},asin:function(){const e=this.re,r=this.im,t=new s(r*r-e*e+1,-2*e*r).sqrt(),n=new s(t.re-r,t.im+e).log();return new s(n.im,-n.re)},acos:function(){const e=this.re,r=this.im,t=new s(r*r-e*e+1,-2*e*r).sqrt(),n=new s(t.re-r,t.im+e).log();return new s(Math.PI/2-n.im,n.re)},atan:function(){const e=this.re,r=this.im;if(0===e){if(1===r)return new s(0,1/0);if(-1===r)return new s(0,-1/0)}const t=e*e+(1-r)*(1-r),n=new s((1-r*r-e*e)/t,-2*e/t).log();return new s(-.5*n.im,.5*n.re)},acot:function(){const e=this.re,r=this.im;if(0===r)return new s(Math.atan2(1,e),0);const t=e*e+r*r;return 0!==t?new s(e/t,-r/t).atan():new s(0!==e?e/0:0,0!==r?-r/0:0).atan()},asec:function(){const e=this.re,r=this.im;if(0===e&&0===r)return new s(0,1/0);const t=e*e+r*r;return 0!==t?new s(e/t,-r/t).acos():new s(0!==e?e/0:0,0!==r?-r/0:0).acos()},acsc:function(){const e=this.re,r=this.im;if(0===e&&0===r)return new s(Math.PI/2,1/0);const t=e*e+r*r;return 0!==t?new s(e/t,-r/t).asin():new s(0!==e?e/0:0,0!==r?-r/0:0).asin()},sinh:function(){const e=this.re,n=this.im;return new s(t(e)*Math.cos(n),r(e)*Math.sin(n))},cosh:function(){const e=this.re,n=this.im;return new s(r(e)*Math.cos(n),t(e)*Math.sin(n))},tanh:function(){const e=2*this.re,n=2*this.im,i=r(e)+Math.cos(n);return new s(t(e)/i,Math.sin(n)/i)},coth:function(){const e=2*this.re,n=2*this.im,i=r(e)-Math.cos(n);return new s(t(e)/i,-Math.sin(n)/i)},csch:function(){const e=this.re,n=this.im,i=Math.cos(2*n)-r(2*e);return new s(-2*t(e)*Math.cos(n)/i,2*r(e)*Math.sin(n)/i)},sech:function(){const e=this.re,n=this.im,i=Math.cos(2*n)+r(2*e);return new s(2*r(e)*Math.cos(n)/i,-2*t(e)*Math.sin(n)/i)},asinh:function(){const e=this.re,r=this.im;if(0===r){if(0===e)return new s(0,0);const r=Math.abs(e),t=Math.log(r+Math.sqrt(r*r+1));return new s(e<0?-t:t,0)}const t=new s(e*e-r*r+1,2*e*r).sqrt();return new s(e+t.re,r+t.im).log()},acosh:function(){const e=this.re,r=this.im;if(0===r)return e>1?new s(Math.log(e+Math.sqrt(e-1)*Math.sqrt(e+1)),0):e<-1?new s(Math.log(-e+Math.sqrt(e*e-1)),Math.PI):new s(0,Math.acos(e));const t=new s(e-1,r).sqrt(),n=new s(e+1,r).sqrt();return new s(e+t.re*n.re-t.im*n.im,r+t.re*n.im+t.im*n.re).log()},atanh:function(){const e=this.re,r=this.im;if(0===r)return 0===e?new s(0,0):1===e?new s(1/0,0):-1===e?new s(-1/0,0):-1<e&&e<1?new s(.5*Math.log((1+e)/(1-e)),0):e>1?new s(.5*Math.log((e+1)/(e-1)),-Math.PI/2):new s(.5*Math.log(-(1+e)/(1-e)),Math.PI/2);const t=1-e,n=1+e,i=t*t+r*r;if(0===i)return new s(-1!==e?e/0:0,0!==r?r/0:0);const o=(n*t-r*r)/i,u=(r*t+n*r)/i;return new s(a(o,u)/2,Math.atan2(u,o)/2)},acoth:function(){const e=this.re,r=this.im;if(0===e&&0===r)return new s(0,Math.PI/2);const t=e*e+r*r;return 0!==t?new s(e/t,-r/t).atanh():new s(0!==e?e/0:0,0!==r?-r/0:0).atanh()},acsch:function(){const e=this.re,r=this.im;if(0===r){if(0===e)return new s(1/0,0);const r=1/e;return new s(Math.log(r+Math.sqrt(r*r+1)),0)}const t=e*e+r*r;return 0!==t?new s(e/t,-r/t).asinh():new s(0!==e?e/0:0,0!==r?-r/0:0).asinh()},asech:function(){const e=this.re,r=this.im;if(this.isZero())return s.INFINITY;const t=e*e+r*r;return 0!==t?new s(e/t,-r/t).acosh():new s(0!==e?e/0:0,0!==r?-r/0:0).acosh()},inverse:function(){if(this.isZero())return s.INFINITY;if(this.isInfinite())return s.ZERO;const e=this.re,r=this.im,t=e*e+r*r;return new s(e/t,-r/t)},conjugate:function(){return new s(this.re,-this.im)},neg:function(){return new s(-this.re,-this.im)},ceil:function(e){return new s(Math.ceil(this.re*(e=Math.pow(10,e||0)))/e,Math.ceil(this.im*e)/e)},floor:function(e){return new s(Math.floor(this.re*(e=Math.pow(10,e||0)))/e,Math.floor(this.im*e)/e)},round:function(e){return new s(Math.round(this.re*(e=Math.pow(10,e||0)))/e,Math.round(this.im*e)/e)},equals:function(e,r){const t=u(e,r);return Math.abs(t.re-this.re)<=s.EPSILON&&Math.abs(t.im-this.im)<=s.EPSILON},clone:function(){return new s(this.re,this.im)},toString:function(){let e=this.re,r=this.im,t="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<s.EPSILON&&(e=0),Math.abs(r)<s.EPSILON&&(r=0),0===r?t+e:(0!==e?(t+=e,t+=" ",r<0?(r=-r,t+="-"):t+="+",t+=" "):r<0&&(r=-r,t+="-"),1!==r&&(t+=r),t+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return 0===this.im?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return 0===this.im&&0===this.re},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!this.isFinite()}},s.ZERO=new s(0,0),s.ONE=new s(1,0),s.I=new s(0,1),s.PI=new s(Math.PI,0),s.E=new s(Math.E,0),s.INFINITY=new s(1/0,1/0),s.NAN=new s(NaN,NaN),s.EPSILON=1e-15,Object.defineProperty(s,"__esModule",{value:!0}),s.default=s,s.Complex=s,e.exports=s}(xo)),xo.exports),Do=Xn(wo),No=ti("Complex",[],(()=>(Object.defineProperty(Do,"name",{value:"Complex"}),Do.prototype.constructor=Do,Do.prototype.type="Complex",Do.prototype.isComplex=!0,Do.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Do.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Do.prototype.format=function(e){var r=this.im,t=this.re,n=di(this.re,e),i=di(this.im,e),a=en(e)?e:e?e.precision:null;if(null!==a){var o=Math.pow(10,-a);Math.abs(t/r)<o&&(t=0),Math.abs(r/t)<o&&(r=0)}return 0===r?n:0===t?1===r?"i":-1===r?"-i":i+"i":r<0?-1===r?n+" - i":n+" - "+i.substring(1)+"i":1===r?n+" + i":n+" + "+i+"i"},Do.fromPolar=function(e){switch(arguments.length){case 1:var r=arguments[0];if("object"==typeof r)return Do(r);throw new TypeError("Input has to be an object with r and phi keys.");case 2:var t=arguments[0],n=arguments[1];if(en(t)){if(on(n)&&n.hasBase("ANGLE")&&(n=n.toNumber("rad")),en(n))return new Do({r:t,phi:n});throw new TypeError("Phi is not a number nor an angle unit.")}throw new TypeError("Radius r is not a number.");default:throw new SyntaxError("Wrong number of arguments in function fromPolar")}},Do.prototype.valueOf=Do.prototype.toString,Do.fromJSON=function(e){return new Do(e)},Do.compare=function(e,r){return e.re>r.re?1:e.re<r.re?-1:e.im>r.im?1:e.im<r.im?-1:0},Do)),{isClass:!0});"undefined"==typeof BigInt&&(BigInt=function(e){if(isNaN(e))throw Error("");return e});const Ao=BigInt(0),Mo=BigInt(1),Co=BigInt(2),Eo=BigInt(3),So=BigInt(5),Fo=BigInt(10);BigInt(Number.MAX_SAFE_INTEGER);const Bo={s:Mo,n:Ao,d:Mo};function qo(e,r){try{e=BigInt(e)}catch(e){throw $o()}return e*r}function To(e){return"bigint"==typeof e?e:Math.floor(e)}function ko(e,r){if(r===Ao)throw Uo();const t=Object.create(Ro.prototype);t.s=e<Ao?-Mo:Mo;const n=jo(e=e<Ao?-e:e,r);return t.n=e/n,t.d=r/n,t}const Oo=[Co*Co,Co,Co*Co,Co,Co*Co,Co*Eo,Co,Co*Eo];function Io(e){const r=Object.create(null);if(e<=Mo)return r[e]=Mo,r;const t=e=>{r[e]=(r[e]||Ao)+Mo};for(;e%Co===Ao;)t(Co),e/=Co;for(;e%Eo===Ao;)t(Eo),e/=Eo;for(;e%So===Ao;)t(So),e/=So;for(let r=0,n=Co+So;n*n<=e;){for(;e%n===Ao;)t(n),e/=n;n+=Oo[r],r=r+1&7}return e>Mo&&t(e),r}const zo=function(e,r){let t=Ao,n=Mo,i=Mo;if(null==e);else if(void 0!==r){if("bigint"==typeof e)t=e;else{if(isNaN(e))throw $o();if(e%1!=0)throw Po();t=BigInt(e)}if("bigint"==typeof r)n=r;else{if(isNaN(r))throw $o();if(r%1!=0)throw Po();n=BigInt(r)}i=t*n}else if("object"==typeof e){if("d"in e&&"n"in e)t=BigInt(e.n),n=BigInt(e.d),"s"in e&&(t*=BigInt(e.s));else if(0 in e)t=BigInt(e[0]),1 in e&&(n=BigInt(e[1]));else{if("bigint"!=typeof e)throw $o();t=e}i=t*n}else if("number"==typeof e){if(isNaN(e))throw $o();if(e<0&&(i=-Mo,e=-e),e%1==0)t=BigInt(e);else{let r=1,i=0,a=1,o=1,u=1,s=1e7;for(e>=1&&(r=10**Math.floor(1+Math.log10(e)),e/=r);a<=s&&u<=s;){let r=(i+o)/(a+u);if(e===r){a+u<=s?(t=i+o,n=a+u):u>a?(t=o,n=u):(t=i,n=a);break}e>r?(i+=o,a+=u):(o+=i,u+=a),a>s?(t=o,n=u):(t=i,n=a)}t=BigInt(t)*BigInt(r),n=BigInt(n)}}else if("string"==typeof e){let r=0,a=Ao,o=Ao,u=Ao,s=Mo,c=Mo,l=e.replace(/_/g,"").match(/\d+|./g);if(null===l)throw $o();if("-"===l[r]?(i=-Mo,r++):"+"===l[r]&&r++,l.length===r+1?o=qo(l[r++],i):"."===l[r+1]||"."===l[r]?("."!==l[r]&&(a=qo(l[r++],i)),r++,(r+1===l.length||"("===l[r+1]&&")"===l[r+3]||"'"===l[r+1]&&"'"===l[r+3])&&(o=qo(l[r],i),s=Fo**BigInt(l[r].length),r++),("("===l[r]&&")"===l[r+2]||"'"===l[r]&&"'"===l[r+2])&&(u=qo(l[r+1],i),c=Fo**BigInt(l[r+1].length)-Mo,r+=3)):"/"===l[r+1]||":"===l[r+1]?(o=qo(l[r],i),s=qo(l[r+2],Mo),r+=3):"/"===l[r+3]&&" "===l[r+1]&&(a=qo(l[r],i),o=qo(l[r+2],i),s=qo(l[r+4],Mo),r+=5),!(l.length<=r))throw $o();n=s*c,i=t=u+n*a+c*o}else{if("bigint"!=typeof e)throw $o();t=e,i=e,n=Mo}if(n===Ao)throw Uo();Bo.s=i<Ao?-Mo:Mo,Bo.n=t<Ao?-t:t,Bo.d=n<Ao?-n:n};function jo(e,r){if(!e)return r;if(!r)return e;for(;;){if(!(e%=r))return r;if(!(r%=e))return e}}function Ro(e,r){if(zo(e,r),!(this instanceof Ro))return ko(Bo.s*Bo.n,Bo.d);e=jo(Bo.d,Bo.n),this.s=Bo.s,this.n=Bo.n/e,this.d=Bo.d/e}const Uo=function(){return Error("Division by Zero")},$o=function(){return Error("Invalid argument")},Po=function(){return Error("Parameters must be integer")};Ro.prototype={s:Mo,n:Ao,d:Mo,abs:function(){return ko(this.n,this.d)},neg:function(){return ko(-this.s*this.n,this.d)},add:function(e,r){return zo(e,r),ko(this.s*this.n*Bo.d+Bo.s*this.d*Bo.n,this.d*Bo.d)},sub:function(e,r){return zo(e,r),ko(this.s*this.n*Bo.d-Bo.s*this.d*Bo.n,this.d*Bo.d)},mul:function(e,r){return zo(e,r),ko(this.s*Bo.s*this.n*Bo.n,this.d*Bo.d)},div:function(e,r){return zo(e,r),ko(this.s*Bo.s*this.n*Bo.d,this.d*Bo.n)},clone:function(){return ko(this.s*this.n,this.d)},mod:function(e,r){if(void 0===e)return ko(this.s*this.n%this.d,Mo);if(zo(e,r),Ao===Bo.n*this.d)throw Uo();return ko(this.s*(Bo.d*this.n)%(Bo.n*this.d),Bo.d*this.d)},gcd:function(e,r){return zo(e,r),ko(jo(Bo.n,this.n)*jo(Bo.d,this.d),Bo.d*this.d)},lcm:function(e,r){return zo(e,r),Bo.n===Ao&&this.n===Ao?ko(Ao,Mo):ko(Bo.n*this.n,jo(Bo.n,this.n)*jo(Bo.d,this.d))},inverse:function(){return ko(this.s*this.d,this.n)},pow:function(e,r){if(zo(e,r),Bo.d===Mo)return Bo.s<Ao?ko((this.s*this.d)**Bo.n,this.n**Bo.n):ko((this.s*this.n)**Bo.n,this.d**Bo.n);if(this.s<Ao)return null;let t=Io(this.n),n=Io(this.d),i=Mo,a=Mo;for(let e in t)if("1"!==e){if("0"===e){i=Ao;break}if(t[e]*=Bo.n,t[e]%Bo.d!==Ao)return null;t[e]/=Bo.d,i*=BigInt(e)**t[e]}for(let e in n)if("1"!==e){if(n[e]*=Bo.n,n[e]%Bo.d!==Ao)return null;n[e]/=Bo.d,a*=BigInt(e)**n[e]}return Bo.s<Ao?ko(a,i):ko(i,a)},log:function(e,r){if(zo(e,r),this.s<=Ao||Bo.s<=Ao)return null;const t=Object.create(null),n=Io(Bo.n),i=Io(Bo.d),a=Io(this.n),o=Io(this.d);for(const e in i)n[e]=(n[e]||Ao)-i[e];for(const e in o)a[e]=(a[e]||Ao)-o[e];for(const e in n)"1"!==e&&(t[e]=!0);for(const e in a)"1"!==e&&(t[e]=!0);let u=null,s=null;for(const e in t){const r=n[e]||Ao,t=a[e]||Ao;if(r===Ao){if(t!==Ao)return null;continue}let i=t,o=r;const c=jo(i,o);if(i/=c,o/=c,null===u&&null===s)u=i,s=o;else if(i*s!=u*o)return null}return null!==u&&null!==s?ko(u,s):null},equals:function(e,r){return zo(e,r),this.s*this.n*Bo.d==Bo.s*Bo.n*this.d},lt:function(e,r){return zo(e,r),this.s*this.n*Bo.d<Bo.s*Bo.n*this.d},lte:function(e,r){return zo(e,r),this.s*this.n*Bo.d<=Bo.s*Bo.n*this.d},gt:function(e,r){return zo(e,r),this.s*this.n*Bo.d>Bo.s*Bo.n*this.d},gte:function(e,r){return zo(e,r),this.s*this.n*Bo.d>=Bo.s*Bo.n*this.d},compare:function(e,r){zo(e,r);let t=this.s*this.n*Bo.d-Bo.s*Bo.n*this.d;return(Ao<t)-(t<Ao)},ceil:function(e){return e=Fo**BigInt(e||0),ko(To(this.s*e*this.n/this.d)+(e*this.n%this.d>Ao&&this.s>=Ao?Mo:Ao),e)},floor:function(e){return e=Fo**BigInt(e||0),ko(To(this.s*e*this.n/this.d)-(e*this.n%this.d>Ao&&this.s<Ao?Mo:Ao),e)},round:function(e){return e=Fo**BigInt(e||0),ko(To(this.s*e*this.n/this.d)+this.s*((this.s>=Ao?Mo:Ao)+Co*(e*this.n%this.d)>this.d?Mo:Ao),e)},roundTo:function(e,r){zo(e,r);const t=this.n*Bo.d,n=this.d*Bo.n,i=t%n;let a=To(t/n);return i+i>=n&&a++,ko(this.s*a*Bo.n,Bo.d)},divisible:function(e,r){return zo(e,r),Bo.n!==Ao&&this.n*Bo.d%(Bo.n*this.d)===Ao},valueOf:function(){return Number(this.s*this.n)/Number(this.d)},toString:function(e=15){let r=this.n,t=this.d,n=function(e,r){for(;r%Co===Ao;r/=Co);for(;r%So===Ao;r/=So);if(r===Mo)return Ao;let t=Fo%r,n=1;for(;t!==Mo;n++)if(t=t*Fo%r,n>2e3)return Ao;return BigInt(n)}(0,t),i=function(e,r,t){let n=Mo,i=function(e,r,t){let n=Mo;for(;r>Ao;e=e*e%t,r>>=Mo)r&Mo&&(n=n*e%t);return n}(Fo,t,r);for(let e=0;e<300;e++){if(n===i)return BigInt(e);n=n*Fo%r,i=i*Fo%r}return 0}(0,t,n),a=this.s<Ao?"-":"";if(a+=To(r/t),r%=t,r*=Fo,r&&(a+="."),n){for(let e=i;e--;)a+=To(r/t),r%=t,r*=Fo;a+="(";for(let e=n;e--;)a+=To(r/t),r%=t,r*=Fo;a+=")"}else for(let n=e;r&&n--;)a+=To(r/t),r%=t,r*=Fo;return a},toFraction:function(e=!1){let r=this.n,t=this.d,n=this.s<Ao?"-":"";if(t===Mo)n+=r;else{const i=To(r/t);e&&i>Ao&&(n+=i,n+=" ",r%=t),n+=r,n+="/",n+=t}return n},toLatex:function(e=!1){let r=this.n,t=this.d,n=this.s<Ao?"-":"";if(t===Mo)n+=r;else{const i=To(r/t);e&&i>Ao&&(n+=i,r%=t),n+="\\frac{",n+=r,n+="}{",n+=t,n+="}"}return n},toContinued:function(){let e=this.n,r=this.d;const t=[];for(;r;){t.push(To(e/r));const n=e%r;e=r,r=n}return t},simplify:function(e=.001){const r=BigInt(Math.ceil(1/e)),t=this.abs(),n=t.toContinued();for(let e=1;e<n.length;e++){let i=ko(n[e-1],Mo);for(let r=e-2;r>=0;r--)i=i.inverse().add(n[r]);let a=i.sub(t);if(a.n*r<a.d)return i.mul(this.s)}return this}};var Lo=ti("Fraction",[],(()=>(Object.defineProperty(Ro,"name",{value:"Fraction"}),Ro.prototype.constructor=Ro,Ro.prototype.type="Fraction",Ro.prototype.isFraction=!0,Ro.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n+"",d:this.d+""}},Ro.fromJSON=function(e){return new Ro(e)},Ro)),{isClass:!0}),_o=ti("Range",[],(()=>{function e(r,t,n){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var i=null!=r,a=null!=t,o=null!=n;if(i)if(rn(r))r=r.toNumber();else if("number"!=typeof r&&!tn(r))throw new TypeError("Parameter start must be a number or bigint");if(a)if(rn(t))t=t.toNumber();else if("number"!=typeof t&&!tn(t))throw new TypeError("Parameter end must be a number or bigint");if(o)if(rn(n))n=n.toNumber();else if("number"!=typeof n&&!tn(n))throw new TypeError("Parameter step must be a number or bigint");if(this.start=i?parseFloat(r):0,this.end=a?parseFloat(t):0,this.step=o?parseFloat(n):1,o&&xi(this.step,0))throw Error("Step must not be zero")}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(r){if("string"!=typeof r)return null;var t=r.split(":").map((function(e){return parseFloat(e)}));if(t.some((function(e){return isNaN(e)})))return null;switch(t.length){case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[2],t[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var e=0,r=this.step,t=this.end-this.start;return oi(r)===oi(t)?e=Math.ceil(t/r):0===t&&(e=0),isNaN(e)&&(e=0),[e]},e.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},e.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},e.prototype.forEach=function(e){var r=this.start,t=this.step,n=this.end,i=0;if(t>0)for(;r<n;)e(r,[i],this),r+=t,i++;else if(t<0)for(;r>n;)e(r,[i],this),r+=t,i++},e.prototype.map=function(e){var r=[];return this.forEach((function(t,n,i){r[n[0]]=e(t,n,i)})),r},e.prototype.toArray=function(){var e=[];return this.forEach((function(r,t){e[t[0]]=r})),e},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(e){var r=di(this.start,e);return 1!==this.step&&(r+=":"+di(this.step,e)),r+":"+di(this.end,e)},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},e.fromJSON=function(r){return new e(r.start,r.end,r.step)},e}),{isClass:!0}),Wo=ti("Matrix",[],(()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(){throw Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(){throw Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(){throw Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(){throw Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(){throw Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(){throw Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(){throw Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(){throw Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(){throw Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw Error("Cannot invoke toString on a Matrix interface")},e}),{isClass:!0});function Jo(e,r,t){var n=new(0,e.constructor)(2),i="";if(t){if(t<1)throw Error("size must be in greater than 0");if(!ii(t))throw Error("size must be an integer");if(e.greaterThan(n.pow(t-1).sub(1))||e.lessThan(n.pow(t-1).mul(-1)))throw Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!e.isInteger())throw Error("Value must be an integer");e.lessThan(0)&&(e=e.add(n.pow(t))),i="i".concat(t)}switch(r){case 2:return"".concat(e.toBinary()).concat(i);case 8:return"".concat(e.toOctal()).concat(i);case 16:return"".concat(e.toHexadecimal()).concat(i);default:throw Error("Base ".concat(r," not supported "))}}function Vo(e,r){return void 0!==r?e.toExponential(r-1):e.toExponential()}function Ho(e,r){return en(e)?e:rn(e)?e.toNumber():r}function Zo(e,r){return e.substring(e.length-r.length,e.length)===r}function Go(e,r){var t=function(e,r){return"number"==typeof e?di(e,r):rn(e)?function(e,r){if("function"==typeof r)return r(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var{notation:t,precision:n,wordSize:i}=pi(r);switch(t){case"fixed":return function(e,r){return e.toFixed(r)}(e,n);case"exponential":return Vo(e,n);case"engineering":return function(e,r){var t=e.e,n=t%3==0?t:t<0?t-3-t%3:t-t%3,i=e.mul(Math.pow(10,-n)).toPrecision(r);return i.includes("e")&&(i=new(0,e.constructor)(i).toFixed()),i+"e"+(t>=0?"+":"")+n}(e,n);case"bin":return Jo(e,2,i);case"oct":return Jo(e,8,i);case"hex":return Jo(e,16,i);case"auto":var a=Ho(null==r?void 0:r.lowerExp,-3),o=Ho(null==r?void 0:r.upperExp,5);if(e.isZero())return"0";var u=e.toSignificantDigits(n),s=u.e;return(s>=a&&s<o?u.toFixed():Vo(e,n)).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],r=arguments[4];return"."!==e?e+r:r}));default:throw Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}(e,r):function(e){return e&&"object"==typeof e&&"bigint"==typeof e.s&&"bigint"==typeof e.n&&"bigint"==typeof e.d||!1}(e)?r&&"decimal"===r.fraction?""+e:"".concat(e.s*e.n,"/").concat(e.d):Array.isArray(e)?Ko(e,r):un(e)?Xo(e):"function"==typeof e?e.syntax?e.syntax+"":"function":e&&"object"==typeof e?"function"==typeof e.format?e.format(r):e&&e.toString(r)!==""+{}?e.toString(r):"{"+Object.keys(e).map((t=>Xo(t)+": "+Go(e[t],r))).join(", ")+"}":e+""}(e,r);return r&&"object"==typeof r&&"truncate"in r&&t.length>r.truncate?t.substring(0,r.truncate-3)+"...":t}function Xo(e){for(var r=e+"",t="",n=0;n<r.length;){var i=r.charAt(n);t+=i in Yo?Yo[i]:i,n++}return'"'+t+'"'}var Yo={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"};function Qo(e){var r=e+"";return r.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function Ko(e,r){if(Array.isArray(e)){for(var t="[",n=e.length,i=0;i<n;i++)0!==i&&(t+=", "),t+=Ko(e[i],r);return t+"]"}return Go(e,r)}function eu(e,r){if(!un(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+_n(e)+", index: 0)");if(!un(r))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+_n(r)+", index: 1)");return e===r?0:e>r?1:-1}function ru(e,r,t){if(!(this instanceof ru))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=r,this.relation=t,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(r)?"["+r.join(", ")+"]":r)+")",this.stack=Error().stack}function tu(e,r,t){if(!(this instanceof tu))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=r):(this.min=r,this.max=t),this.message=void 0!==this.min&&this.index<this.min?"Index out of range ("+this.index+" < "+this.min+")":void 0!==this.max&&this.index>=this.max?"Index out of range ("+this.index+" > "+(this.max-1)+")":"Index out of range ("+this.index+")",this.stack=Error().stack}function nu(e){for(var r=[];Array.isArray(e);)r.push(e.length),e=e[0];return r}function iu(e,r,t){var n,i=e.length;if(i!==r[t])throw new ru(i,r[t]);if(t<r.length-1){var a=t+1;for(n=0;n<i;n++){if(!Array.isArray(e[n]))throw new ru(r.length-1,r.length,"<");iu(e[n],r,a)}}else for(n=0;n<i;n++)if(Array.isArray(e[n]))throw new ru(r.length+1,r.length,">")}function au(e,r){if(0===r.length){if(Array.isArray(e))throw new ru(e.length,0)}else iu(e,r,0)}function ou(e,r){var t=e.isMatrix?e._size:nu(e);r._sourceSize.forEach(((e,r)=>{if(null!==e&&e!==t[r])throw new ru(e,t[r])}))}function uu(e,r){if(void 0!==e){if(!en(e)||!ii(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof r&&e>=r)throw new tu(e,r)}}function su(e){for(var r=0;r<e._dimensions.length;++r){var t=e._dimensions[r];if(t._data&&sn(t._data)){if(0===t._size[0])return!0}else if(t.isRange){if(t.start===t.end)return!0}else if(un(t)&&0===t.length)return!0}return!1}function cu(e,r,t){if(!Array.isArray(r))throw new TypeError("Array expected");if(0===r.length)throw Error("Resizing to scalar is not supported");return r.forEach((function(e){if(!en(e)||!ii(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Go(r)+")")})),(en(e)||rn(e))&&(e=[e]),lu(e,r,0,void 0!==t?t:0),e}function lu(e,r,t,n){var i,a,o=r[t],u=Math.min(e.length,o);if(e.length=o,t<r.length-1){var s=t+1;for(i=0;i<u;i++)Array.isArray(a=e[i])||(e[i]=a=[a]),lu(a,r,s,n);for(i=u;i<o;i++)e[i]=a=[],lu(a,r,s,n)}else{for(i=0;i<u;i++)for(;Array.isArray(e[i]);)e[i]=e[i][0];for(i=u;i<o;i++)e[i]=n}}function fu(e,r){var t=bu(e,!0),n=t.length;if(!Array.isArray(e)||!Array.isArray(r))throw new TypeError("Array expected");if(0===r.length)throw new ru(0,n,"!=");var i=du(r=mu(r,n));if(n!==i)throw new ru(i,n,"!=");try{return function(e,r){for(var t,n=e,i=r.length-1;i>0;i--){var a=r[i];t=[];for(var o=n.length/a,u=0;u<o;u++)t.push(n.slice(u*a,(u+1)*a));n=t}return n}(t,r)}catch(e){if(e instanceof ru)throw new ru(i,n,"!=");throw e}}function mu(e,r){var t=du(e),n=e.slice(),i=e.indexOf(-1);if(e.indexOf(-1,i+1)>=0)throw Error("More than one wildcard in sizes");if(i>=0){if(r%t!=0)throw Error("Could not replace wildcard, since "+r+" is no multiple of "+-t);n[i]=-r/t}return n}function du(e){return e.reduce(((e,r)=>e*r),1)}function pu(e){for(var r=nu(e);Array.isArray(e)&&1===e.length;)e=e[0],r.shift();for(var t=r.length;1===r[t-1];)t--;return t<r.length&&(e=hu(e,t,0),r.length=t),e}function hu(e,r,t){var n,i;if(t<r){var a=t+1;for(n=0,i=e.length;n<i;n++)e[n]=hu(e[n],r,a)}else for(;Array.isArray(e);)e=e[0];return e}function vu(e,r,t,n){var i=n||nu(e);if(t)for(var a=0;a<t;a++)e=[e],i.unshift(1);for(e=yu(e,r,0);i.length<r;)i.push(1);return e}function yu(e,r,t){var n,i;if(Array.isArray(e)){var a=t+1;for(n=0,i=e.length;n<i;n++)e[n]=yu(e[n],r,a)}else for(var o=t;o<r;o++)e=[e];return e}function bu(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!Array.isArray(e))return e;if("boolean"!=typeof r)throw new TypeError("Boolean expected for second argument of flatten");var t=[];return r?function e(r){if(Array.isArray(r[0]))for(var n=0;n<r.length;n++)e(r[n]);else for(var i=0;i<r.length;i++)t.push(r[i])}(e):function e(r){for(var n=0;n<r.length;n++){var i=r[n];Array.isArray(i)?e(i):t.push(i)}}(e),t}function gu(e,r){return Array.prototype.map.call(e,r)}function xu(e,r){Array.prototype.forEach.call(e,r)}function wu(e,r){if(1!==nu(e).length)throw Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,(e=>r.test(e)))}function Du(e,r){return Array.prototype.join.call(e,r)}function Nu(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;var r=[],t=0;r[0]={value:e[0],identifier:0};for(var n=1;n<e.length;n++)e[n]===e[n-1]?t++:t=0,r.push({value:e[n],identifier:t});return r}function Au(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;for(var r=[],t=0;t<e.length;t++)r.push(e[t].value);return r}function Mu(e,r){for(var t,n=0,i=0;i<e.length;i++){var a=e[i],o=Array.isArray(a);if(0===i&&o&&(n=a.length),o&&a.length!==n)return;var u=o?Mu(a,r):r(a);if(void 0===t)t=u;else if(t!==u)return"mixed"}return t}function Cu(e,r,t,n){if(n<t){if(e.length!==r.length)throw new ru(e.length,r.length);for(var i=[],a=0;a<e.length;a++)i[a]=Cu(e[a],r[a],t,n+1);return i}return e.concat(r)}function Eu(){var e=Array.prototype.slice.call(arguments,0,-1),r=Array.prototype.slice.call(arguments,-1);if(1===e.length)return e[0];if(e.length>1)return e.slice(1).reduce((function(e,t){return Cu(e,t,r,0)}),e[0]);throw Error("Wrong number of arguments in function concat")}function Su(){for(var e=arguments.length,r=Array(e),t=0;t<e;t++)r[t]=arguments[t];for(var n=r.map((e=>e.length)),i=Math.max(...n),a=Array(i).fill(null),o=0;o<r.length;o++)for(var u=r[o],s=n[o],c=0;c<s;c++){var l=i-s+c;u[c]>a[l]&&(a[l]=u[c])}for(var f=0;f<r.length;f++)Fu(r[f],a);return a}function Fu(e,r){for(var t=r.length,n=e.length,i=0;i<n;i++){var a=t-n+i;if(e[i]<r[a]&&e[i]>1||e[i]>r[a])throw Error("shape mismatch: mismatch is found in arg with shape (".concat(e,") not possible to broadcast dimension ").concat(n," with size ").concat(e[i]," to size ").concat(r[a]))}}function Bu(e,r){var t=nu(e);if(Vn(t,r))return e;Fu(t,r);var n=Su(t,r),i=n.length,a=[...Array(i-t.length).fill(1),...t],o=function(e){return Pt([],e)}(e);t.length<i&&(t=nu(o=fu(o,a)));for(var u=0;u<i;u++)t[u]<n[u]&&(t=nu(o=qu(o,n[u],u)));return o}function qu(e,r,t){return Eu(...Array(r).fill(e),t)}function Tu(e,r){if(!Array.isArray(e))throw Error("Array expected");var t=nu(e);if(r.length!==t.length)throw new ru(r.length,t.length);for(var n=0;n<r.length;n++)uu(r[n],t[n]);return r.reduce(((e,r)=>e[r]),e)}function ku(e,r){if(0===e.length)return[];if(arguments.length>2&&void 0!==arguments[2]&&arguments[2])return function e(t){if(Array.isArray(t)){for(var n=t.length,i=Array(n),a=0;a<n;a++)i[a]=e(t[a]);return i}return r(t)}(e);var t=[];return function n(i,a){if(Array.isArray(i)){for(var o=i.length,u=Array(o),s=0;s<o;s++)t[a]=s,u[s]=n(i[s],a+1);return u}return r(i,t.slice(0,a),e)}(e,0)}function Ou(e,r){if(0!==e.length)if(arguments.length>2&&void 0!==arguments[2]&&arguments[2])!function e(t){if(Array.isArray(t))for(var n=t.length,i=0;i<n;i++)e(t[i]);else r(t)}(e);else{var t=[];!function n(i,a){if(Array.isArray(i))for(var o=i.length,u=0;u<o;u++)t[a]=u,n(i[u],a+1);else r(i,t.slice(0,a),e)}(e,0)}}function Iu(e,r,t,n){if(ri.isTypedFunction(e)){var i,a;if(n)i=1;else{var o=(r.isMatrix?r.size():nu(r)).map((()=>0)),u=r.isMatrix?r.get(o):Tu(r,o);i=function(e,r,t,n){for(var i=[r,t,n],a=3;a>0;a--){var o=i.slice(0,a);if(null!==ri.resolve(e,o))return a}}(e,u,o,r)}if(r.isMatrix&&"mixed"!==r.dataType&&void 0!==r.dataType){var s=function(e,r){var t=[];if(Object.entries(e.signatures).forEach((e=>{var[n,i]=e;n.split(",").length===r&&t.push(i)})),1===t.length)return t[0]}(e,i);a=void 0!==s?s:e}else a=e;return i>=1&&i<=3?{isUnary:1===i,fn:function(){for(var r=arguments.length,n=Array(r),o=0;o<r;o++)n[o]=arguments[o];return ju(a,n.slice(0,i),t,e.name)}}:{isUnary:!1,fn:function(){for(var r=arguments.length,n=Array(r),i=0;i<r;i++)n[i]=arguments[i];return ju(a,n,t,e.name)}}}return void 0===n?{isUnary:zu(e),fn:e}:{isUnary:n,fn:e}}function zu(e){if(1!==e.length)return!1;var r=""+e;if(/arguments/.test(r))return!1;var t=r.match(/\(.*?\)/);return!/\.\.\./.test(t)}function ju(e,r,t,n){try{return e(...r)}catch(e){!function(e,r,t,n){var i;if(e instanceof TypeError&&"wrongType"===(null===(i=e.data)||void 0===i?void 0:i.category)){var a=[];throw a.push("value: ".concat(_n(r[0]))),r.length>=2&&a.push("index: ".concat(_n(r[1]))),r.length>=3&&a.push("array: ".concat(_n(r[2]))),new TypeError("Function ".concat(t," cannot apply callback arguments ")+"".concat(n,"(").concat(a.join(", "),") at index ").concat(JSON.stringify(r[1])))}throw new TypeError("Function ".concat(t," cannot apply callback arguments ")+"to function ".concat(n,": ").concat(e.message))}(e,r,t,n)}}(ru.prototype=new RangeError).constructor=RangeError,ru.prototype.name="DimensionError",ru.prototype.isDimensionError=!0,(tu.prototype=new RangeError).constructor=RangeError,tu.prototype.name="IndexError",tu.prototype.isIndexError=!0;var Ru=ti("DenseMatrix",["Matrix"],(e=>{var{Matrix:r}=e;function t(e,r){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(r&&!un(r))throw Error("Invalid datatype: "+r);if(cn(e))"DenseMatrix"===e.type?(this._data=Wn(e._data),this._size=Wn(e._size),this._datatype=r||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=r||e._datatype);else if(e&&sn(e.data)&&sn(e.size))this._data=e.data,this._size=e.size,au(this._data,this._size),this._datatype=r||e.datatype;else if(sn(e))this._data=a(e),this._size=nu(this._data),au(this._data,this._size),this._datatype=r;else{if(e)throw new TypeError("Unsupported type of data ("+_n(e)+")");this._data=[],this._size=[0],this._datatype=r}}function n(e,r,t){if(0===r.length){for(var n=e._data;sn(n);)n=n[0];return n}return e._size=r.slice(0),e._data=cu(e._data,e._size,t),e}function i(e,r,t){for(var i=e._size.slice(0),a=!1;i.length<r.length;)i.push(0),a=!0;for(var o=0,u=r.length;o<u;o++)r[o]>i[o]&&(i[o]=r[o],a=!0);a&&n(e,i,t)}function a(e){return cn(e)?a(e.valueOf()):sn(e)?e.map(a):e}return(t.prototype=new r).createDenseMatrix=function(e,r){return new t(e,r)},Object.defineProperty(t,"name",{value:"DenseMatrix"}),t.prototype.constructor=t,t.prototype.type="DenseMatrix",t.prototype.isDenseMatrix=!0,t.prototype.getDataType=function(){return Mu(this._data,_n)},t.prototype.storage=function(){return"dense"},t.prototype.datatype=function(){return this._datatype},t.prototype.create=function(e,r){return new t(e,r)},t.prototype.subset=function(e,r,n){switch(arguments.length){case 1:return function(e,r){if(!pn(r))throw new TypeError("Invalid index");if(r.isScalar())return e.get(r.min());var n=r.size();if(n.length!==e._size.length)throw new ru(n.length,e._size.length);for(var i=r.min(),a=r.max(),o=0,u=e._size.length;o<u;o++)uu(i[o],e._size[o]),uu(a[o],e._size[o]);var s=new t([]),c=function(e,r){var t=r.size().length-1,n=Array(t);return{data:function e(i){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=r.dimension(a);return n[a]=o.size()[0],a<t?o.map((r=>(uu(r,i.length),e(i[r],a+1)))).valueOf():o.map((e=>(uu(e,i.length),i[e]))).valueOf()}(e),size:n}}(e._data,r);return s._size=c.size,s._datatype=e._datatype,s._data=c.data,s}(this,e);case 2:case 3:return function(e,r,t,n){if(!r||!0!==r.isIndex)throw new TypeError("Invalid index");var a,o=r.size(),u=r.isScalar();if(cn(t)?(a=t.size(),t=t.valueOf()):a=nu(t),u){if(0!==a.length)throw new TypeError("Scalar expected");e.set(r.min(),t,n)}else{if(!Vn(a,o))try{a=nu(t=Bu(0===a.length?[t]:t,o))}catch(e){}if(o.length<e._size.length)throw new ru(o.length,e._size.length,"<");if(a.length<o.length){for(var s=0,c=0;1===o[s]&&1===a[s];)s++;for(;1===o[s];)c++,s++;t=vu(t,o.length,c,a)}if(!Vn(o,a))throw new ru(o,a,">");var l=r.max().map((function(e){return e+1}));i(e,l,n),function(e,r,t){var n=r.size().length-1;!function e(t,i){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;r.dimension(a).forEach(a<n?(r,n)=>{uu(r,t.length),e(t[r],i[n[0]],a+1)}:(e,r)=>{uu(e,t.length),t[e]=i[r[0]]})}(e,t)}(e._data,r,t)}return e}(this,e,r,n);default:throw new SyntaxError("Wrong number of arguments")}},t.prototype.get=function(e){return Tu(this._data,e)},t.prototype.set=function(e,r,t){if(!sn(e))throw new TypeError("Array expected");if(e.length<this._size.length)throw new ru(e.length,this._size.length,"<");var n,a,o,u=e.map((function(e){return e+1}));i(this,u,t);var s=this._data;for(n=0,a=e.length-1;n<a;n++)uu(o=e[n],s.length),s=s[o];return uu(o=e[e.length-1],s.length),s[o]=r,this},t.prototype.resize=function(e,r,t){if(!ln(e))throw new TypeError("Array or Matrix expected");var i=e.valueOf().map((e=>Array.isArray(e)&&1===e.length?e[0]:e));return n(t?this.clone():this,i,r)},t.prototype.reshape=function(e,r){var t=r?this.clone():this;t._data=fu(t._data,e);var n=t._size.reduce(((e,r)=>e*r));return t._size=mu(e,n),t},t.prototype.clone=function(){return new t({data:Wn(this._data),size:Wn(this._size),datatype:this._datatype})},t.prototype.size=function(){return this._size.slice(0)},t.prototype.map=function(e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],t=this,n=t._size.length-1;if(n<0)return t.clone();var i=Iu(e,t,"map",r),a=i.fn,o=t.create(void 0,t._datatype);if(o._size=t._size,r||i.isUnary)return o._data=function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=Array(r.length);if(t<n)for(var o=0;o<r.length;o++)i[o]=e(r[o],t+1);else for(var u=0;u<r.length;u++)i[u]=a(r[u]);return i}(t._data),o;if(0===n){for(var u=t.valueOf(),s=Array(u.length),c=0;c<u.length;c++)s[c]=a(u[c],[c],t);return o._data=s,o}var l=[];return o._data=function e(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=Array(r.length);if(i<n)for(var u=0;u<r.length;u++)l[i]=u,o[u]=e(r[u],i+1);else for(var s=0;s<r.length;s++)l[i]=s,o[s]=a(r[s],l.slice(),t);return o}(t._data),o},t.prototype.forEach=function(e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],t=this,n=t._size.length-1;if(!(n<0)){var i=Iu(e,t,"map",r),a=i.fn;if(r||i.isUnary)!function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(t<n)for(var i=0;i<r.length;i++)e(r[i],t+1);else for(var o=0;o<r.length;o++)a(r[o])}(t._data);else if(0!==n){var o=[];!function e(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(i<n)for(var u=0;u<r.length;u++)o[i]=u,e(r[u],i+1);else for(var s=0;s<r.length;s++)o[i]=s,a(r[s],o.slice(),t)}(t._data)}else for(var u=0;u<t._data.length;u++)a(t._data[u],[u],t)}},t.prototype[Symbol.iterator]=function*(){var e=this._size.length-1;if(!(e<0))if(0!==e)for(var r=Array(e+1).fill(0),t=this._size.reduce(((e,r)=>e*r),1),n=0;n<t;n++){for(var i=this._data,a=0;a<e;a++)i=i[r[a]];yield{value:i[r[e]],index:r.slice()};for(var o=e;o>=0&&(r[o]++,!(r[o]<this._size[o]));o--)r[o]=0}else for(var u=0;u<this._data.length;u++)yield{value:this._data[u],index:[u]}},t.prototype.rows=function(){var e=[];if(2!==this.size().length)throw new TypeError("Rows can only be returned for a 2D matrix.");var r=this._data;for(var n of r)e.push(new t([n],this._datatype));return e},t.prototype.columns=function(){var e=this,r=[],n=this.size();if(2!==n.length)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var i=this._data,a=function(n){var a=i.map((e=>[e[n]]));r.push(new t(a,e._datatype))},o=0;o<n[1];o++)a(o);return r},t.prototype.toArray=function(){return Wn(this._data)},t.prototype.valueOf=function(){return this._data},t.prototype.format=function(e){return Go(this._data,e)},t.prototype.toString=function(){return Go(this._data)},t.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},t.prototype.diagonal=function(e){if(e){if(rn(e)&&(e=e.toNumber()),!en(e)||!ii(e))throw new TypeError("The parameter k must be an integer number")}else e=0;for(var r=e>0?e:0,n=e<0?-e:0,i=Math.min(this._size[0]-n,this._size[1]-r),a=[],o=0;o<i;o++)a[o]=this._data[o+n][o+r];return new t({data:a,size:[i],datatype:this._datatype})},t.diagonal=function(e,r,n,i){if(!sn(e))throw new TypeError("Array expected, size parameter");if(2!==e.length)throw Error("Only two dimensions matrix are supported");if(e=e.map((function(e){if(rn(e)&&(e=e.toNumber()),!en(e)||!ii(e)||e<1)throw Error("Size values must be positive integers");return e})),n){if(rn(n)&&(n=n.toNumber()),!en(n)||!ii(n))throw new TypeError("The parameter k must be an integer number")}else n=0;var a,o=n>0?n:0,u=n<0?-n:0,s=e[0],c=e[1],l=Math.min(s-u,c-o);if(sn(r)){if(r.length!==l)throw Error("Invalid value array length");a=function(e){return r[e]}}else if(cn(r)){var f=r.size();if(1!==f.length||f[0]!==l)throw Error("Invalid matrix length");a=function(e){return r.get([e])}}else a=function(){return r};i||(i=rn(a(0))?a(0).mul(0):0);var m=[];if(e.length>0){m=cu(m,e,i);for(var d=0;d<l;d++)m[d+u][d+o]=a(d)}return new t({data:m,size:[s,c]})},t.fromJSON=function(e){return new t(e)},t.prototype.swapRows=function(e,r){if(!(en(e)&&ii(e)&&en(r)&&ii(r)))throw Error("Row index must be positive integers");if(2!==this._size.length)throw Error("Only two dimensional matrix is supported");return uu(e,this._size[0]),uu(r,this._size[0]),t._swapRows(e,r,this._data),this},t._swapRows=function(e,r,t){var n=t[e];t[e]=t[r],t[r]=n},t}),{isClass:!0}),Uu="clone",$u=ti(Uu,["typed"],(e=>{var{typed:r}=e;return r(Uu,{any:Wn})}));function Pu(e){var r,t,n=e.length,i=e[0].length,a=[];for(t=0;t<i;t++){var o=[];for(r=0;r<n;r++)o.push(e[r][t]);a.push(o)}return a}function Lu(e){for(var r=0;r<e.length;r++)if(ln(e[r]))return!0;return!1}function _u(e,r){cn(e)?e.forEach((e=>r(e)),!1,!0):Ou(e,r,!0)}function Wu(e,r,t){if(!t)return cn(e)?e.map((e=>r(e)),!1,!0):ku(e,r,!0);var n=e=>0===e?e:r(e);return cn(e)?e.map((e=>n(e)),!1,!0):ku(e,n,!0)}function Ju(e,r,t){var n=Array.isArray(e)?nu(e):e.size();if(r<0||r>=n.length)throw new tu(r,n.length);return cn(e)?e.create(Vu(e.valueOf(),r,t),e.datatype()):Vu(e,r,t)}function Vu(e,r,t){var n,i,a,o;if(r<=0){if(Array.isArray(e[0])){for(o=Pu(e),i=[],n=0;n<o.length;n++)i[n]=Vu(o[n],r-1,t);return i}for(a=e[0],n=1;n<e.length;n++)a=t(a,e[n]);return a}for(i=[],n=0;n<e.length;n++)i[n]=Vu(e[n],r-1,t);return i}function Hu(e,r,t,n,i,a,o,u){var s,c,l,f=e._values,m=e._index,d=e._ptr;if(n)for(c=d[r+1],s=d[r];s<c;s++)t[l=m[s]]!==a?(t[l]=a,o.push(l),n[l]=f[s]):(n[l]=u(n[l],f[s]),i[l]=a);else for(c=d[r+1],s=d[r];s<c;s++)t[l=m[s]]!==a?(t[l]=a,o.push(l)):i[l]=a}var Zu="isInteger",Gu=ti(Zu,["typed"],(e=>{var{typed:r}=e;return r(Zu,{number:ii,BigNumber:function(e){return e.isInt()},bigint:function(){return!0},Fraction:function(e){return 1n===e.d},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Xu="number",Yu="number, number";function Qu(e){return Math.abs(e)}function Ku(e,r){return e+r}function es(e,r){return e-r}function rs(e,r){return e*r}function ts(e){return-e}function ns(e){return e}function is(e){return li(e)}function as(e){return e*e*e}function os(e){return Math.exp(e)}function us(e){return fi(e)}function ss(e,r){if(!ii(e)||!ii(r))throw Error("Parameters in function lcm must be integer numbers");if(0===e||0===r)return 0;for(var t,n=e*r;0!==r;)r=e%(t=r),e=t;return Math.abs(n/e)}function cs(e,r){return r?Math.log(e)/Math.log(r):Math.log(e)}function ls(e){return si(e)}function fs(e){return ui(e)}function ms(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,t=r<0;if(t&&(r=-r),0===r)throw Error("Root must be non-zero");if(e<0&&Math.abs(r)%2!=1)throw Error("Root must be odd when a is negative.");if(0===e)return t?1/0:0;if(!isFinite(e))return t?0:e;var n=Math.pow(Math.abs(e),1/r);return n=e<0?-n:n,t?1/n:n}function ds(e){return oi(e)}function ps(e){return e*e}function hs(e,r){var t,n,i,a=0,o=1,u=1,s=0;if(!ii(e)||!ii(r))throw Error("Parameters in function xgcd must be integer numbers");for(;r;)i=e-(n=Math.floor(e/r))*r,t=a,a=o-n*a,o=t,t=u,u=s-n*u,s=t,e=r,r=i;return e<0?[-e,-o,-s]:[e,e?o:0,s]}function vs(e,r){return e*e<1&&r===1/0||e*e>1&&r===-1/0?0:Math.pow(e,r)}function ys(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!ii(r)||r<0||r>15)throw Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(vi(e,r))}Qu.signature=Xu,Ku.signature=Yu,es.signature=Yu,rs.signature=Yu,ts.signature=Xu,ns.signature=Xu,is.signature=Xu,as.signature=Xu,os.signature=Xu,us.signature=Xu,ss.signature=Yu,ls.signature=Xu,fs.signature=Xu,ds.signature=Xu,ps.signature=Xu,hs.signature=Yu,vs.signature=Yu;var bs="number, number";function gs(e,r){if(!ii(e)||!ii(r))throw Error("Integers expected in function bitAnd");return e&r}function xs(e){if(!ii(e))throw Error("Integer expected in function bitNot");return~e}function ws(e,r){if(!ii(e)||!ii(r))throw Error("Integers expected in function bitOr");return e|r}function Ds(e,r){if(!ii(e)||!ii(r))throw Error("Integers expected in function bitXor");return e^r}function Ns(e,r){if(!ii(e)||!ii(r))throw Error("Integers expected in function leftShift");return e<<r}function As(e,r){if(!ii(e)||!ii(r))throw Error("Integers expected in function rightArithShift");return e>>r}function Ms(e,r){if(!ii(e)||!ii(r))throw Error("Integers expected in function rightLogShift");return e>>>r}function Cs(e,r){if(r<e)return 1;if(r===e)return r;var t=r+e>>1;return Cs(e,t)*Cs(t+1,r)}function Es(e,r){if(!ii(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!ii(r)||r<0)throw new TypeError("Positive integer value expected in function combinations");if(r>e)throw new TypeError("k must be less than or equal to n");for(var t=e-r,n=1,i=2,a=r<t?r:t,o=r<t?t+1:r+1;o<=e;++o)for(n*=o;i<=a&&n%i==0;)n/=i,++i;return i<=a&&(n/=Cs(i,a)),n}gs.signature=bs,xs.signature="number",ws.signature=bs,Ds.signature=bs,Ns.signature=bs,As.signature=bs,Ms.signature=bs,Es.signature="number, number";var Ss=Math.PI,Fs=2*Math.PI,Bs=Math.E,qs="number, number";function Ts(e){return!e}function ks(e,r){return!(!e&&!r)}function Os(e,r){return!!e!=!!r}function Is(e,r){return!(!e||!r)}function zs(e){var r;if(ii(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:Cs(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*zs(1-e));if(e>=171.35)return 1/0;if(e>85){var t=e*e,n=t*e,i=n*e,a=i*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*t)-139/(51840*n)-571/(2488320*i)+163879/(209018880*a)+5246819/(75246796800*a*e))}--e,r=Rs[0];for(var o=1;o<Rs.length;++o)r+=Rs[o]/(e+o);var u=e+js+.5;return 2.5066282746310002*Math.pow(u,e+.5)*Math.exp(-u)*r}Ts.signature="number",ks.signature=qs,Os.signature=qs,Is.signature=qs,zs.signature="number";var js=4.7421875,Rs=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],Us=.9189385332046728,$s=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function Ps(e){if(e<0)return NaN;if(0===e)return 1/0;if(!isFinite(e))return e;if(e<.5)return Math.log(Math.PI/Math.sin(Math.PI*e))-Ps(1-e);for(var r=5+(e-=1)+.5,t=$s[0],n=6;n>=1;n--)t+=$s[n]/(e+n);return Us+(e+.5)*Math.log(r)-r+Math.log(t)}Ps.signature="number";var Ls="number";function _s(e){return wi(e)}function Ws(e){return Math.atan(1/e)}function Js(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}function Vs(e){return Math.asin(1/e)}function Hs(e){var r=1/e;return Math.log(r+Math.sqrt(r*r+1))}function Zs(e){return Math.acos(1/e)}function Gs(e){var r=1/e;return Math.log(Math.sqrt(r*r-1)+r)}function Xs(e){return Di(e)}function Ys(e){return Ni(e)}function Qs(e){return 1/Math.tan(e)}function Ks(e){var r=Math.exp(2*e);return(r+1)/(r-1)}function ec(e){return 1/Math.sin(e)}function rc(e){return 0===e?1/0:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*oi(e)}function tc(e){return 1/Math.cos(e)}function nc(e){return 2/(Math.exp(e)+Math.exp(-e))}function ic(e){return Mi(e)}_s.signature=Ls,Ws.signature=Ls,Js.signature=Ls,Vs.signature=Ls,Hs.signature=Ls,Zs.signature=Ls,Gs.signature=Ls,Xs.signature=Ls,Ys.signature=Ls,Qs.signature=Ls,Ks.signature=Ls,ec.signature=Ls,rc.signature=Ls,tc.signature=Ls,nc.signature=Ls,ic.signature=Ls;var ac="number";function oc(e){return e<0}function uc(e){return e>0}function sc(e){return Number.isNaN(e)}function cc(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e-9,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(t<=0)throw Error("Relative tolerance must be greater than 0");if(n<0)throw Error("Absolute tolerance must be at least 0");return!e.isNaN()&&!r.isNaN()&&(e.isFinite()&&r.isFinite()?!!e.eq(r)||e.minus(r).abs().lte(e.constructor.max(e.constructor.max(e.abs(),r.abs()).mul(t),n)):e.eq(r))}oc.signature=ac,uc.signature=ac,sc.signature=ac;var lc="isNegative",fc=ti(lc,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(lc,{number:e=>!xi(e,0,t.relTol,t.absTol)&&oc(e),BigNumber:e=>!cc(e,new e.constructor(0),t.relTol,t.absTol)&&e.isNeg()&&!e.isZero()&&!e.isNaN(),bigint:e=>e<0n,Fraction:e=>e.s<0n,Unit:r.referToSelf((e=>t=>r.find(e,t.valueType())(t.value))),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),mc="isNumeric",dc=ti(mc,["typed"],(e=>{var{typed:r}=e;return r(mc,{"number | BigNumber | bigint | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),pc="hasNumericValue",hc=ti(pc,["typed","isNumeric"],(e=>{var{typed:r,isNumeric:t}=e;return r(pc,{boolean:()=>!0,string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return t(e)}})})),vc="isPositive",yc=ti(vc,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(vc,{number:e=>!xi(e,0,t.relTol,t.absTol)&&uc(e),BigNumber:e=>!(cc(e,new e.constructor(0),t.relTol,t.absTol)||e.isNeg()||e.isZero()||e.isNaN()),bigint:e=>e>0n,Fraction:e=>e.s>0n&&e.n>0n,Unit:r.referToSelf((e=>t=>r.find(e,t.valueType())(t.value))),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),bc="isZero",gc=ti(bc,["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return r(bc,{"number | BigNumber | Complex | Fraction":e=>t(e,0),bigint:e=>0n===e,Unit:r.referToSelf((e=>t=>r.find(e,t.valueType())(t.value))),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),xc="isNaN",wc=ti(xc,["typed"],(e=>{var{typed:r}=e;return r(xc,{number:sc,BigNumber:function(e){return e.isNaN()},bigint:function(){return!1},Fraction:function(){return!1},Complex:function(e){return e.isNaN()},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Dc="typeOf",Nc=ti(Dc,["typed"],(e=>{var{typed:r}=e;return r(Dc,{any:_n})})),Ac=ti("compareUnits",["typed"],(e=>{var{typed:r}=e;return{"Unit, Unit":r.referToSelf((e=>(t,n)=>{if(!t.equalBase(n))throw Error("Cannot compare units with different base");return r.find(e,[t.valueType(),n.valueType()])(t.value,n.value)}))}})),Mc="equalScalar",Cc=ti(Mc,["typed","config"],(e=>{var{typed:r,config:t}=e,n=Ac({typed:r});return r(Mc,{"boolean, boolean":function(e,r){return e===r},"number, number":function(e,r){return xi(e,r,t.relTol,t.absTol)},"BigNumber, BigNumber":function(e,r){return e.eq(r)||cc(e,r,t.relTol,t.absTol)},"bigint, bigint":function(e,r){return e===r},"Fraction, Fraction":function(e,r){return e.equals(r)},"Complex, Complex":function(e,r){return function(e,r,t,n){return xi(e.re,r.re,t,n)&&xi(e.im,r.im,t,n)}(e,r,t.relTol,t.absTol)}},n)}));ti(Mc,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(Mc,{"number, number":function(e,r){return xi(e,r,t.relTol,t.absTol)}})}));var Ec=ti("SparseMatrix",["typed","equalScalar","Matrix"],(e=>{var{typed:r,equalScalar:t,Matrix:n}=e;function i(e,r){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(r&&!un(r))throw Error("Invalid datatype: "+r);if(cn(e))!function(e,r,t){"SparseMatrix"===r.type?(e._values=r._values?Wn(r._values):void 0,e._index=Wn(r._index),e._ptr=Wn(r._ptr),e._size=Wn(r._size),e._datatype=t||r._datatype):a(e,r.valueOf(),t||r._datatype)}(this,e,r);else if(e&&sn(e.index)&&sn(e.ptr)&&sn(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=r||e.datatype;else if(sn(e))a(this,e,r);else{if(e)throw new TypeError("Unsupported type of data ("+_n(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=r}}function a(e,n,i){e._values=[],e._index=[],e._ptr=[],e._datatype=i;var a=n.length,o=0,u=t,s=0;if(un(i)&&(u=r.find(t,[i,i])||t,s=r.convert(0,i)),a>0){var c=0;do{e._ptr.push(e._index.length);for(var l=0;l<a;l++){var f=n[l];if(sn(f)){if(0===c&&o<f.length&&(o=f.length),c<f.length){var m=f[c];u(m,s)||(e._values.push(m),e._index.push(l))}}else 0===c&&o<1&&(o=1),u(f,s)||(e._values.push(f),e._index.push(l))}c++}while(c<o)}e._ptr.push(e._index.length),e._size=[a,o]}function o(e,r,t,n){if(t-r==0)return t;for(var i=r;i<t;i++)if(n[i]===e)return i;return r}function u(e,r,t,n,i,a,o){i.splice(e,0,n),a.splice(e,0,r);for(var u=t+1;u<o.length;u++)o[u]++}function s(e,n,i,a){var o=a||0,u=t,s=0;un(e._datatype)&&(u=r.find(t,[e._datatype,e._datatype])||t,s=r.convert(0,e._datatype),o=r.convert(o,e._datatype));var c,l,f,m=!u(o,s),d=e._size[0],p=e._size[1];if(i>p){for(l=p;l<i;l++)if(e._ptr[l]=e._values.length,m)for(c=0;c<d;c++)e._values.push(o),e._index.push(c);e._ptr[i]=e._values.length}else i<p&&(e._ptr.splice(i+1,p-i),e._values.splice(e._ptr[i],e._values.length),e._index.splice(e._ptr[i],e._index.length));if(p=i,n>d){if(m){var h=0;for(l=0;l<p;l++){e._ptr[l]=e._ptr[l]+h,f=e._ptr[l+1]+h;var v=0;for(c=d;c<n;c++,v++)e._values.splice(f+v,0,o),e._index.splice(f+v,0,c),h++}e._ptr[p]=e._values.length}}else if(n<d){var y=0;for(l=0;l<p;l++){e._ptr[l]=e._ptr[l]-y;var b=e._ptr[l+1]-y;for(f=e._ptr[l];f<b;f++)(c=e._index[f])>n-1&&(e._values.splice(f,1),e._index.splice(f,1),y++)}e._ptr[l]=e._values.length}return e._size[0]=n,e._size[1]=i,e}function c(e,r,t,n,i){var a,o,u=n[0],s=n[1],c=[];for(a=0;a<u;a++)for(c[a]=[],o=0;o<s;o++)c[a][o]=0;for(o=0;o<s;o++)for(var l=t[o+1],f=t[o];f<l;f++)c[a=r[f]][o]=e?i?Wn(e[f]):e[f]:1;return c}return(i.prototype=new n).createSparseMatrix=function(e,r){return new i(e,r)},Object.defineProperty(i,"name",{value:"SparseMatrix"}),i.prototype.constructor=i,i.prototype.type="SparseMatrix",i.prototype.isSparseMatrix=!0,i.prototype.getDataType=function(){return Mu(this._values,_n)},i.prototype.storage=function(){return"sparse"},i.prototype.datatype=function(){return this._datatype},i.prototype.create=function(e,r){return new i(e,r)},i.prototype.density=function(){var e=this._size[0],r=this._size[1];return 0!==e&&0!==r?this._index.length/(e*r):0},i.prototype.subset=function(e,r,t){if(!this._values)throw Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return function(e,r){if(!pn(r))throw new TypeError("Invalid index");if(r.isScalar())return e.get(r.min());var t,n,a,o,u=r.size();if(u.length!==e._size.length)throw new ru(u.length,e._size.length);var s=r.min(),c=r.max();for(t=0,n=e._size.length;t<n;t++)uu(s[t],e._size[t]),uu(c[t],e._size[t]);var l=e._values,f=e._index,m=e._ptr,d=r.dimension(0),p=r.dimension(1),h=[],v=[];d.forEach((function(e,r){v[e]=r[0],h[e]=!0}));var y=l?[]:void 0,b=[],g=[];return p.forEach((function(e){for(g.push(b.length),a=m[e],o=m[e+1];a<o;a++)!0===h[t=f[a]]&&(b.push(v[t]),y&&y.push(l[a]))})),g.push(b.length),new i({values:y,index:b,ptr:g,size:u,datatype:e._datatype})}(this,e);case 2:case 3:return function(e,r,t,n){if(!r||!0!==r.isIndex)throw new TypeError("Invalid index");var i,a=r.size(),o=r.isScalar();if(cn(t)?(i=t.size(),t=t.toArray()):i=nu(t),o){if(0!==i.length)throw new TypeError("Scalar expected");e.set(r.min(),t,n)}else{if(1!==a.length&&2!==a.length)throw new ru(a.length,e._size.length,"<");if(i.length<a.length){for(var u=0,s=0;1===a[u]&&1===i[u];)u++;for(;1===a[u];)s++,u++;t=vu(t,a.length,s,i)}if(!Vn(a,i))throw new ru(a,i,">");if(1===a.length)r.dimension(0).forEach((function(r,i){uu(r),e.set([r,0],t[i[0]],n)}));else{var c=r.dimension(0),l=r.dimension(1);c.forEach((function(r,i){uu(r),l.forEach((function(a,o){uu(a),e.set([r,a],t[i[0]][o[0]],n)}))}))}}return e}(this,e,r,t);default:throw new SyntaxError("Wrong number of arguments")}},i.prototype.get=function(e){if(!sn(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new ru(e.length,this._size.length);if(!this._values)throw Error("Cannot invoke get on a Pattern only matrix");var r=e[0],t=e[1];uu(r,this._size[0]),uu(t,this._size[1]);var n=o(r,this._ptr[t],this._ptr[t+1],this._index);return n<this._ptr[t+1]&&this._index[n]===r?this._values[n]:0},i.prototype.set=function(e,n,i){if(!sn(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new ru(e.length,this._size.length);if(!this._values)throw Error("Cannot invoke set on a Pattern only matrix");var a=e[0],c=e[1],l=this._size[0],f=this._size[1],m=t,d=0;un(this._datatype)&&(m=r.find(t,[this._datatype,this._datatype])||t,d=r.convert(0,this._datatype)),(a>l-1||c>f-1)&&(s(this,Math.max(a+1,l),Math.max(c+1,f),i),l=this._size[0],f=this._size[1]),uu(a,l),uu(c,f);var p=o(a,this._ptr[c],this._ptr[c+1],this._index);return p<this._ptr[c+1]&&this._index[p]===a?m(n,d)?function(e,r,t,n,i){t.splice(e,1),n.splice(e,1);for(var a=r+1;a<i.length;a++)i[a]--}(p,c,this._values,this._index,this._ptr):this._values[p]=n:m(n,d)||u(p,a,c,n,this._values,this._index,this._ptr),this},i.prototype.resize=function(e,r,t){if(!ln(e))throw new TypeError("Array or Matrix expected");var n=e.valueOf().map((e=>Array.isArray(e)&&1===e.length?e[0]:e));if(2!==n.length)throw Error("Only two dimensions matrix are supported");return n.forEach((function(e){if(!en(e)||!ii(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Go(n)+")")})),s(t?this.clone():this,n[0],n[1],r)},i.prototype.reshape=function(e,r){if(!sn(e))throw new TypeError("Array expected");if(2!==e.length)throw Error("Sparse matrices can only be reshaped in two dimensions");e.forEach((function(r){if(!en(r)||!ii(r)||r<=-2||0===r)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Go(e)+")")}));var t=this._size[0]*this._size[1];if(t!==(e=mu(e,t))[0]*e[1])throw Error("Reshaping sparse matrix will result in the wrong number of elements");var n=r?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return n;for(var i=[],a=0;a<n._ptr.length;a++)for(var s=0;s<n._ptr[a+1]-n._ptr[a];s++)i.push(a);for(var c=n._values.slice(),l=n._index.slice(),f=0;f<n._index.length;f++){var m=l[f]*n._size[1]+i[f];i[f]=m%e[1],l[f]=Math.floor(m/e[1])}n._values.length=0,n._index.length=0,n._ptr.length=e[1]+1,n._size=e.slice();for(var d=0;d<n._ptr.length;d++)n._ptr[d]=0;for(var p=0;p<c.length;p++){var h=l[p],v=i[p],y=c[p];u(o(h,n._ptr[v],n._ptr[v+1],n._index),h,v,y,n._values,n._index,n._ptr)}return n},i.prototype.clone=function(){return new i({values:this._values?Wn(this._values):void 0,index:Wn(this._index),ptr:Wn(this._ptr),size:Wn(this._size),datatype:this._datatype})},i.prototype.size=function(){return this._size.slice(0)},i.prototype.map=function(e,n){if(!this._values)throw Error("Cannot invoke map on a Pattern only matrix");var a=this,o=this._size[0],u=this._size[1],s=Iu(e,a,"map");return function(e,n,o,u,c,l,f){var m=[],d=[],p=[],h=t,v=0;un(e._datatype)&&(h=r.find(t,[e._datatype,e._datatype])||t,v=r.convert(0,e._datatype));for(var y=function(e,r,t){var n=function(e,r,t){return s.fn(e,[r,t],a)}(e,r,t);h(n,v)||(m.push(n),d.push(r))},b=0;b<=c;b++){p.push(m.length);var g=e._ptr[b],x=e._ptr[b+1];if(f)for(var w=g;w<x;w++){var D=e._index[w];D>=0&&D<=o&&y(e._values[w],D-0,b-0)}else{for(var N={},A=g;A<x;A++)N[e._index[A]]=e._values[A];for(var M=0;M<=o;M++)y(M in N?N[M]:0,M-0,b-0)}}return p.push(m.length),new i({values:m,index:d,ptr:p,size:[o-0+1,c-0+1]})}(this,0,o-1,0,u-1,0,n)},i.prototype.forEach=function(e,r){if(!this._values)throw Error("Cannot invoke forEach on a Pattern only matrix");for(var t=this,n=this._size[0],i=this._size[1],a=Iu(e,t,"forEach"),o=0;o<i;o++){var u=this._ptr[o],s=this._ptr[o+1];if(r)for(var c=u;c<s;c++)a.fn(this._values[c],[this._index[c],o],t);else{for(var l={},f=u;f<s;f++)l[this._index[f]]=this._values[f];for(var m=0;m<n;m++)a.fn(m in l?l[m]:0,[m,o],t)}}},i.prototype[Symbol.iterator]=function*(){if(!this._values)throw Error("Cannot iterate a Pattern only matrix");for(var e=this._size[1],r=0;r<e;r++)for(var t=this._ptr[r+1],n=this._ptr[r];n<t;n++){var i=this._index[n];yield{value:this._values[n],index:[i,r]}}},i.prototype.toArray=function(){return c(this._values,this._index,this._ptr,this._size,!0)},i.prototype.valueOf=function(){return c(this._values,this._index,this._ptr,this._size,!1)},i.prototype.format=function(e){for(var r=this._size[0],t=this._size[1],n=this.density(),i="Sparse Matrix ["+Go(r,e)+" x "+Go(t,e)+"] density: "+Go(n,e)+"\n",a=0;a<t;a++)for(var o=this._ptr[a+1],u=this._ptr[a];u<o;u++)i+="\n ("+Go(this._index[u],e)+", "+Go(a,e)+") ==> "+(this._values?Go(this._values[u],e):"X");return i},i.prototype.toString=function(){return Go(this.toArray())},i.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},i.prototype.diagonal=function(e){if(e){if(rn(e)&&(e=e.toNumber()),!en(e)||!ii(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var r=e>0?e:0,t=e<0?-e:0,n=this._size[1],a=Math.min(this._size[0]-t,n-r),o=[],u=[],s=[];s[0]=0;for(var c=r;c<n&&o.length<a;c++)for(var l=this._ptr[c+1],f=this._ptr[c];f<l;f++){var m=this._index[f];if(m===c-r+t){o.push(this._values[f]),u[o.length-1]=m-t;break}}return s.push(o.length),new i({values:o,index:u,ptr:s,size:[a,1]})},i.fromJSON=function(e){return new i(e)},i.diagonal=function(e,n,a,o,u){if(!sn(e))throw new TypeError("Array expected, size parameter");if(2!==e.length)throw Error("Only two dimensions matrix are supported");if(e=e.map((function(e){if(rn(e)&&(e=e.toNumber()),!en(e)||!ii(e)||e<1)throw Error("Size values must be positive integers");return e})),a){if(rn(a)&&(a=a.toNumber()),!en(a)||!ii(a))throw new TypeError("The parameter k must be an integer number")}else a=0;var s=t,c=0;un(u)&&(s=r.find(t,[u,u])||t,c=r.convert(0,u));var l,f=a>0?a:0,m=a<0?-a:0,d=e[0],p=e[1],h=Math.min(d-m,p-f);if(sn(n)){if(n.length!==h)throw Error("Invalid value array length");l=function(e){return n[e]}}else if(cn(n)){var v=n.size();if(1!==v.length||v[0]!==h)throw Error("Invalid matrix length");l=function(e){return n.get([e])}}else l=function(){return n};for(var y=[],b=[],g=[],x=0;x<p;x++){g.push(y.length);var w=x-f;if(w>=0&&w<h){var D=l(w);s(D,c)||(b.push(w+m),y.push(D))}}return g.push(y.length),new i({values:y,index:b,ptr:g,size:[d,p]})},i.prototype.swapRows=function(e,r){if(!(en(e)&&ii(e)&&en(r)&&ii(r)))throw Error("Row index must be positive integers");if(2!==this._size.length)throw Error("Only two dimensional matrix is supported");return uu(e,this._size[0]),uu(r,this._size[0]),i._swapRows(e,r,this._size[1],this._values,this._index,this._ptr),this},i._forEachRow=function(e,r,t,n,i){for(var a=n[e+1],o=n[e];o<a;o++)i(t[o],r[o])},i._swapRows=function(e,r,t,n,i,a){for(var u=0;u<t;u++){var s=a[u],c=a[u+1],l=o(e,s,c,i),f=o(r,s,c,i);if(l<c&&f<c&&i[l]===e&&i[f]===r){if(n){var m=n[l];n[l]=n[f],n[f]=m}}else if(l<c&&i[l]===e&&(f>=c||i[f]!==r)){var d=n?n[l]:void 0;i.splice(f,0,r),n&&n.splice(f,0,d),i.splice(f<=l?l+1:l,1),n&&n.splice(f<=l?l+1:l,1)}else if(f<c&&i[f]===r&&(l>=c||i[l]!==e)){var p=n?n[f]:void 0;i.splice(l,0,e),n&&n.splice(l,0,p),i.splice(l<=f?f+1:f,1),n&&n.splice(l<=f?f+1:f,1)}}},i}),{isClass:!0}),Sc=ti("number",["typed"],(e=>{var{typed:r}=e,t=r("number",{"":function(){return 0},number:function(e){return e},string:function(e){if("NaN"===e)return NaN;var r=function(e){var r=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);return r?{input:e,radix:{"0b":2,"0o":8,"0x":16}[r[1]],integerPart:r[2],fractionalPart:r[3]}:null}(e);if(r)return function(e){for(var r=parseInt(e.integerPart,e.radix),t=0,n=0;n<e.fractionalPart.length;n++)t+=parseInt(e.fractionalPart[n],e.radix)/Math.pow(e.radix,n+1);var i=r+t;if(isNaN(i))throw new SyntaxError('String "'+e.input+'" is not a valid number');return i}(r);var t=0,n=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);n&&(t=Number(n[2]),e=n[1]);var i=Number(e);if(isNaN(i))throw new SyntaxError('String "'+e+'" is not a valid number');if(n){if(i>2**t-1)throw new SyntaxError('String "'.concat(e,'" is out of range'));i>=2**(t-1)&&(i-=2**t)}return i},BigNumber:function(e){return e.toNumber()},bigint:function(e){return Number(e)},Fraction:function(e){return e.valueOf()},Unit:r.referToSelf((e=>r=>{var t=r.clone();return t.value=e(r.value),t})),null:function(){return 0},"Unit, string | Unit":function(e,r){return e.toNumber(r)},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))});return t.fromJSON=function(e){return parseFloat(e.value)},t})),Fc=ti("bigint",["typed"],(e=>{var{typed:r}=e,t=r("bigint",{"":function(){return 0n},bigint:function(e){return e},number:function(e){return BigInt(e.toFixed())},BigNumber:function(e){return BigInt(""+e.round())},Fraction:function(e){return BigInt(e.valueOf().toFixed())},"string | boolean":function(e){return BigInt(e)},null:function(){return 0n},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))});return t.fromJSON=function(e){return BigInt(e.value)},t})),Bc="string",qc=ti(Bc,["typed"],(e=>{var{typed:r}=e;return r(Bc,{"":function(){return""},number:di,null:function(){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e))),any:function(e){return e+""}})})),Tc="boolean",kc=ti(Tc,["typed"],(e=>{var{typed:r}=e;return r(Tc,{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var r=e.toLowerCase();if("true"===r)return!0;if("false"===r)return!1;var t=Number(e);if(""!==e&&!isNaN(t))return!!t;throw Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Oc=ti("bignumber",["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r("bignumber",{"":function(){return new t(0)},number:function(e){return new t(e+"")},string:function(e){var r=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(r){var n=r[2],i=t(r[1]),a=new t(2).pow(Number(n));if(i.gt(a.sub(1)))throw new SyntaxError('String "'.concat(e,'" is out of range'));var o=new t(2).pow(Number(n)-1);return i.gte(o)?i.sub(a):i}return new t(e)},BigNumber:function(e){return e},bigint:function(e){return new t(""+e)},Unit:r.referToSelf((e=>r=>{var t=r.clone();return t.value=e(r.value),t})),Fraction:function(e){return new t(e.n+"").div(e.d+"").times(e.s+"")},null:function(){return new t(0)},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Ic=ti("complex",["typed","Complex"],(e=>{var{typed:r,Complex:t}=e;return r("complex",{"":function(){return t.ZERO},number:function(e){return new t(e,0)},"number, number":function(e,r){return new t(e,r)},"BigNumber, BigNumber":function(e,r){return new t(e.toNumber(),r.toNumber())},Fraction:function(e){return new t(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return t(e)},null:function(){return t(0)},Object:function(e){if("re"in e&&"im"in e)return new t(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new t(e);throw Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),zc=ti("fraction",["typed","Fraction"],(e=>{var{typed:r,Fraction:t}=e;return r("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw Error(e+" cannot be represented as a fraction");return new t(e)},string:function(e){return new t(e)},"number, number":function(e,r){return new t(e,r)},"bigint, bigint":function(e,r){return new t(e,r)},null:function(){return new t(0)},BigNumber:function(e){return new t(""+e)},bigint:function(e){return new t(""+e)},Fraction:function(e){return e},Unit:r.referToSelf((e=>r=>{var t=r.clone();return t.value=e(r.value),t})),Object:function(e){return new t(e)},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),jc="matrix",Rc=ti(jc,["typed","Matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:r,DenseMatrix:t,SparseMatrix:n}=e;return r(jc,{"":function(){return i([])},string:function(e){return i([],e)},"string, string":function(e,r){return i([],e,r)},Array:function(e){return i(e)},Matrix:function(e){return i(e,e.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(e,r,i){if("dense"===r||"default"===r||void 0===r)return new t(e,i);if("sparse"===r)return new n(e,i);throw new TypeError("Unknown matrix type "+JSON.stringify(r)+".")}})),Uc="matrixFromFunction",$c=ti(Uc,["typed","matrix","isZero"],(e=>{var{typed:r,matrix:t,isZero:n}=e;return r(Uc,{"Array | Matrix, function, string, string":function(e,r,t,n){return i(e,r,t,n)},"Array | Matrix, function, string":function(e,r,t){return i(e,r,t)},"Matrix, function":function(e,r){return i(e,r,"dense")},"Array, function":function(e,r){return i(e,r,"dense").toArray()},"Array | Matrix, string, function":function(e,r,t){return i(e,t,r)},"Array | Matrix, string, string, function":function(e,r,t,n){return i(e,n,r,t)}});function i(e,r,i,a){var o;return(o=void 0!==a?t(i,a):t(i)).resize(e),o.forEach((function(e,t){var i=r(t);n(i)||o.set(t,i)})),o}})),Pc="matrixFromRows",Lc=ti(Pc,["typed","matrix","flatten","size"],(e=>{var{typed:r,matrix:t,flatten:n,size:i}=e;return r(Pc,{"...Array":function(e){return a(e)},"...Matrix":function(e){return t(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one row is needed to construct a matrix.");var r=o(e[0]),t=[];for(var i of e){var a=o(i);if(a!==r)throw new TypeError("The vectors had different length: "+(0|r)+" ≠ "+(0|a));t.push(n(i))}return t}function o(e){var r=i(e);if(1===r.length)return r[0];if(2===r.length){if(1===r[0])return r[1];if(1===r[1])return r[0];throw new TypeError("At least one of the arguments is not a vector.")}throw new TypeError("Only one- or two-dimensional vectors are supported.")}})),_c="matrixFromColumns",Wc=ti(_c,["typed","matrix","flatten","size"],(e=>{var{typed:r,matrix:t,flatten:n,size:i}=e;return r(_c,{"...Array":function(e){return a(e)},"...Matrix":function(e){return t(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one column is needed to construct a matrix.");for(var r=o(e[0]),t=[],i=0;i<r;i++)t[i]=[];for(var a of e){var u=o(a);if(u!==r)throw new TypeError("The vectors had different length: "+(0|r)+" ≠ "+(0|u));for(var s=n(a),c=0;c<r;c++)t[c].push(s[c])}return t}function o(e){var r=i(e);if(1===r.length)return r[0];if(2===r.length){if(1===r[0])return r[1];if(1===r[1])return r[0];throw new TypeError("At least one of the arguments is not a vector.")}throw new TypeError("Only one- or two-dimensional vectors are supported.")}})),Jc="splitUnit",Vc=ti(Jc,["typed"],(e=>{var{typed:r}=e;return r(Jc,{"Unit, Array":function(e,r){return e.splitUnit(r)}})})),Hc="unaryMinus",Zc=ti(Hc,["typed"],(e=>{var{typed:r}=e;return r(Hc,{number:ts,"Complex | BigNumber | Fraction":e=>e.neg(),bigint:e=>-e,Unit:r.referToSelf((e=>t=>{var n=t.clone();return n.value=r.find(e,n.valueType())(t.value),n})),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e,!0)))})})),Gc="unaryPlus",Xc=ti(Gc,["typed","config","numeric"],(e=>{var{typed:r,config:t,numeric:n}=e;return r(Gc,{number:ns,Complex:function(e){return e},BigNumber:function(e){return e},bigint:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e,!0))),boolean:function(e){return n(e?1:0,t.number)},string:function(e){return n(e,ai(e,t))}})})),Yc=ti("abs",["typed"],(e=>{var{typed:r}=e;return r("abs",{number:Qu,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),bigint:e=>e<0n?-e:e,"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e,!0)))})})),Qc="mapSlices",Kc=ti(Qc,["typed","isInteger"],(e=>{var{typed:r,isInteger:t}=e;return r(Qc,{"Array | Matrix, number | BigNumber, function":function(e,r,n){if(!t(r))throw new TypeError("Integer number expected for dimension");var i=Array.isArray(e)?nu(e):e.size();if(r<0||r>=i.length)throw new tu(r,i.length);return cn(e)?e.create(el(e.valueOf(),r,n),e.datatype()):el(e,r,n)}})}),{formerly:"apply"});function el(e,r,t){var n,i,a;if(r<=0){if(Array.isArray(e[0])){for(a=function(e){var r,t,n=e.length,i=e[0].length,a=[];for(t=0;t<i;t++){var o=[];for(r=0;r<n;r++)o.push(e[r][t]);a.push(o)}return a}(e),i=[],n=0;n<a.length;n++)i[n]=el(a[n],r-1,t);return i}return t(e)}for(i=[],n=0;n<e.length;n++)i[n]=el(e[n],r-1,t);return i}var rl="addScalar",tl=ti(rl,["typed"],(e=>{var{typed:r}=e;return r(rl,{"number, number":Ku,"Complex, Complex":function(e,r){return e.add(r)},"BigNumber, BigNumber":function(e,r){return e.plus(r)},"bigint, bigint":function(e,r){return e+r},"Fraction, Fraction":function(e,r){return e.add(r)},"Unit, Unit":r.referToSelf((e=>(t,n)=>{if(null==t.value)throw Error("Parameter x contains a unit with undefined value");if(null==n.value)throw Error("Parameter y contains a unit with undefined value");if(!t.equalBase(n))throw Error("Units do not match");var i=t.clone();return i.value=r.find(e,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i}))})})),nl="subtractScalar",il=ti(nl,["typed"],(e=>{var{typed:r}=e;return r(nl,{"number, number":es,"Complex, Complex":function(e,r){return e.sub(r)},"BigNumber, BigNumber":function(e,r){return e.minus(r)},"bigint, bigint":function(e,r){return e-r},"Fraction, Fraction":function(e,r){return e.sub(r)},"Unit, Unit":r.referToSelf((e=>(t,n)=>{if(null==t.value)throw Error("Parameter x contains a unit with undefined value");if(null==n.value)throw Error("Parameter y contains a unit with undefined value");if(!t.equalBase(n))throw Error("Units do not match");var i=t.clone();return i.value=r.find(e,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i}))})})),al="cbrt",ol=ti(al,["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],(e=>{var{config:r,typed:t,isNegative:n,unaryMinus:i,matrix:a,Complex:o,BigNumber:u,Fraction:s}=e;return t(al,{number:is,Complex:c,"Complex, boolean":c,BigNumber:function(e){return e.cbrt()},Unit:function(e){if(e.value&&nn(e.value)){var r=e.clone();return r.value=1,(r=r.pow(1/3)).value=c(e.value),r}var t,a=n(e.value);a&&(e.value=i(e.value)),t=rn(e.value)?new u(1).div(3):an(e.value)?new s(1,3):1/3;var o=e.pow(t);return a&&(o.value=i(o.value)),o}});function c(e,t){var n=e.arg()/3,i=e.abs(),u=new o(is(i),0).mul(new o(0,n).exp());if(t){var s=[u,new o(is(i),0).mul(new o(0,n+2*Math.PI/3).exp()),new o(is(i),0).mul(new o(0,n-2*Math.PI/3).exp())];return"Array"===r.matrix?s:a(s)}return u}})),ul=ti("matAlgo11xS0s",["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return function(e,n,i,a){var o=e._values,u=e._index,s=e._ptr,c=e._size,l=e._datatype;if(!o)throw Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,m=c[0],d=c[1],p=t,h=0,v=i;"string"==typeof l&&(p=r.find(t,[f=l,f]),h=r.convert(0,f),n=r.convert(n,f),v=r.find(i,[f,f]));for(var y=[],b=[],g=[],x=0;x<d;x++){g[x]=b.length;for(var w=s[x+1],D=s[x];D<w;D++){var N=u[D],A=a?v(n,o[D]):v(o[D],n);p(A,h)||(b.push(N),y.push(A))}}return g[d]=b.length,e.createSparseMatrix({values:y,index:b,ptr:g,size:[m,d],datatype:f})}})),sl=ti("matAlgo12xSfs",["typed","DenseMatrix"],(e=>{var{typed:r,DenseMatrix:t}=e;return function(e,n,i,a){var o=e._values,u=e._index,s=e._ptr,c=e._size,l=e._datatype;if(!o)throw Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,m=c[0],d=c[1],p=i;"string"==typeof l&&(n=r.convert(n,f=l),p=r.find(i,[f,f]));for(var h=[],v=[],y=[],b=0;b<d;b++){for(var g=b+1,x=s[b+1],w=s[b];w<x;w++){var D=u[w];v[D]=o[w],y[D]=g}for(var N=0;N<m;N++)0===b&&(h[N]=[]),h[N][b]=y[N]===g?a?p(n,v[N]):p(v[N],n):a?p(n,0):p(0,n)}return new t({data:h,size:[m,d],datatype:f})}})),cl=ti("matAlgo14xDs",["typed"],(e=>{var{typed:r}=e;return function(e,n,i,a){var o,u=e._data,s=e._size,c=e._datatype,l=i;"string"==typeof c&&(n=r.convert(n,o=c),l=r.find(i,[o,o]));var f=s.length>0?t(l,0,s,s[0],u,n,a):[];return e.createDenseMatrix({data:f,size:Wn(s),datatype:o})};function t(e,r,n,i,a,o,u){var s=[];if(r===n.length-1)for(var c=0;c<i;c++)s[c]=u?e(o,a[c]):e(a[c],o);else for(var l=0;l<i;l++)s[l]=t(e,r+1,n,n[r+1],a[l],o,u);return s}})),ll="ceil",fl=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],ml=new yo(10),dl=ti(ll,["typed","config","round"],(e=>{var{typed:r,config:t,round:n}=e;function i(e){var r=Math.ceil(e),i=n(e);return r===i?r:xi(e,i,t.relTol,t.absTol)&&!xi(e,r,t.relTol,t.absTol)?i:r}return r(ll,{number:i,"number, number":function(e,r){if(!ii(r))throw new RangeError("number of decimals in function ceil must be an integer");if(r<0||r>15)throw new RangeError("number of decimals in ceil number must be in range 0-15");var t=10**r;return i(e*t)/t}})})),pl=ti(ll,fl,(e=>{var{typed:r,config:t,round:n,matrix:i,equalScalar:a,zeros:o,DenseMatrix:u}=e,s=ul({typed:r,equalScalar:a}),c=sl({typed:r,DenseMatrix:u}),l=cl({typed:r}),f=dl({typed:r,config:t,round:n});function m(e){var r=(e,r)=>cc(e,r,t.relTol,t.absTol),i=e.ceil(),a=n(e);return i.eq(a)?i:r(e,a)&&!r(e,i)?a:i}return r("ceil",{number:f.signatures.number,"number,number":f.signatures["number,number"],Complex:function(e){return e.ceil()},"Complex, number":function(e,r){return e.ceil(r)},"Complex, BigNumber":function(e,r){return e.ceil(r.toNumber())},BigNumber:m,"BigNumber, BigNumber":function(e,r){var t=ml.pow(r);return m(e.mul(t)).div(t)},bigint:e=>e,"bigint, number":e=>e,"bigint, BigNumber":e=>e,Fraction:function(e){return e.ceil()},"Fraction, number":function(e,r){return e.ceil(r)},"Fraction, BigNumber":function(e,r){return e.ceil(r.toNumber())},"Unit, number, Unit":r.referToSelf((e=>function(r,t,n){var i=r.toNumeric(n);return n.multiply(e(i,t))})),"Unit, BigNumber, Unit":r.referToSelf((e=>(r,t,n)=>e(r,t.toNumber(),n))),"Array | Matrix, number | BigNumber, Unit":r.referToSelf((e=>(r,t,n)=>Wu(r,(r=>e(r,t,n)),!0))),"Array | Matrix | Unit, Unit":r.referToSelf((e=>(r,t)=>e(r,0,t))),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e,!0))),"Array, number | BigNumber":r.referToSelf((e=>(r,t)=>Wu(r,(r=>e(r,t)),!0))),"SparseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>s(r,t,e,!1))),"DenseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>l(r,t,e,!1))),"number | Complex | Fraction | BigNumber, Array":r.referToSelf((e=>(r,t)=>l(i(t),r,e,!0).valueOf())),"number | Complex | Fraction | BigNumber, Matrix":r.referToSelf((e=>(r,t)=>a(r,0)?o(t.size(),t.storage()):"dense"===t.storage()?l(t,r,e,!0):c(t,r,e,!0)))})})),hl="cube",vl=ti(hl,["typed"],(e=>{var{typed:r}=e;return r(hl,{number:as,Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},bigint:function(e){return e*e*e},Fraction:function(e){return e.pow(3)},Unit:function(e){return e.pow(3)}})})),yl=ti("exp",["typed"],(e=>{var{typed:r}=e;return r("exp",{number:os,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()}})})),bl="expm1",gl=ti(bl,["typed","Complex"],(e=>{var{typed:r,Complex:t}=e;return r(bl,{number:us,Complex:function(e){var r=Math.exp(e.re);return new t(r*Math.cos(e.im)-1,r*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)}})})),xl="fix",wl=["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],Dl=ti(xl,["typed","ceil","floor"],(e=>{var{typed:r,ceil:t,floor:n}=e;return r(xl,{number:function(e){return e>0?n(e):t(e)},"number, number":function(e,r){return e>0?n(e,r):t(e,r)}})})),Nl=ti(xl,wl,(e=>{var{typed:r,Complex:t,matrix:n,ceil:i,floor:a,equalScalar:o,zeros:u,DenseMatrix:s}=e,c=sl({typed:r,DenseMatrix:s}),l=cl({typed:r}),f=Dl({typed:r,ceil:i,floor:a});return r("fix",{number:f.signatures.number,"number, number | BigNumber":f.signatures["number,number"],Complex:function(e){return new t(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},"Complex, number":function(e,r){return new t(e.re>0?a(e.re,r):i(e.re,r),e.im>0?a(e.im,r):i(e.im,r))},"Complex, BigNumber":function(e,r){var n=r.toNumber();return new t(e.re>0?a(e.re,n):i(e.re,n),e.im>0?a(e.im,n):i(e.im,n))},BigNumber:function(e){return e.isNegative()?i(e):a(e)},"BigNumber, number | BigNumber":function(e,r){return e.isNegative()?i(e,r):a(e,r)},bigint:e=>e,"bigint, number":e=>e,"bigint, BigNumber":e=>e,Fraction:function(e){return e.s<0n?e.ceil():e.floor()},"Fraction, number | BigNumber":function(e,r){return e.s<0n?i(e,r):a(e,r)},"Unit, number, Unit":r.referToSelf((e=>function(r,t,n){var i=r.toNumeric(n);return n.multiply(e(i,t))})),"Unit, BigNumber, Unit":r.referToSelf((e=>(r,t,n)=>e(r,t.toNumber(),n))),"Array | Matrix, number | BigNumber, Unit":r.referToSelf((e=>(r,t,n)=>Wu(r,(r=>e(r,t,n)),!0))),"Array | Matrix | Unit, Unit":r.referToSelf((e=>(r,t)=>e(r,0,t))),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e,!0))),"Array | Matrix, number | BigNumber":r.referToSelf((e=>(r,t)=>Wu(r,(r=>e(r,t)),!0))),"number | Complex | Fraction | BigNumber, Array":r.referToSelf((e=>(r,t)=>l(n(t),r,e,!0).valueOf())),"number | Complex | Fraction | BigNumber, Matrix":r.referToSelf((e=>(r,t)=>o(r,0)?u(t.size(),t.storage()):"dense"===t.storage()?l(t,r,e,!0):c(t,r,e,!0)))})})),Al="floor",Ml=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],Cl=new yo(10),El=ti(Al,["typed","config","round"],(e=>{var{typed:r,config:t,round:n}=e;function i(e){var r=Math.floor(e),i=n(e);return r===i?r:xi(e,i,t.relTol,t.absTol)&&!xi(e,r,t.relTol,t.absTol)?i:r}return r(Al,{number:i,"number, number":function(e,r){if(!ii(r))throw new RangeError("number of decimals in function floor must be an integer");if(r<0||r>15)throw new RangeError("number of decimals in floor number must be in range 0 - 15");var t=10**r;return i(e*t)/t}})})),Sl=ti(Al,Ml,(e=>{var{typed:r,config:t,round:n,matrix:i,equalScalar:a,zeros:o,DenseMatrix:u}=e,s=ul({typed:r,equalScalar:a}),c=sl({typed:r,DenseMatrix:u}),l=cl({typed:r}),f=El({typed:r,config:t,round:n});function m(e){var r=(e,r)=>cc(e,r,t.relTol,t.absTol),i=e.floor(),a=n(e);return i.eq(a)?i:r(e,a)&&!r(e,i)?a:i}return r("floor",{number:f.signatures.number,"number,number":f.signatures["number,number"],Complex:function(e){return e.floor()},"Complex, number":function(e,r){return e.floor(r)},"Complex, BigNumber":function(e,r){return e.floor(r.toNumber())},BigNumber:m,"BigNumber, BigNumber":function(e,r){var t=Cl.pow(r);return m(e.mul(t)).div(t)},bigint:e=>e,"bigint, number":e=>e,"bigint, BigNumber":e=>e,Fraction:function(e){return e.floor()},"Fraction, number":function(e,r){return e.floor(r)},"Fraction, BigNumber":function(e,r){return e.floor(r.toNumber())},"Unit, number, Unit":r.referToSelf((e=>function(r,t,n){var i=r.toNumeric(n);return n.multiply(e(i,t))})),"Unit, BigNumber, Unit":r.referToSelf((e=>(r,t,n)=>e(r,t.toNumber(),n))),"Array | Matrix, number | BigNumber, Unit":r.referToSelf((e=>(r,t,n)=>Wu(r,(r=>e(r,t,n)),!0))),"Array | Matrix | Unit, Unit":r.referToSelf((e=>(r,t)=>e(r,0,t))),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e,!0))),"Array, number | BigNumber":r.referToSelf((e=>(r,t)=>Wu(r,(r=>e(r,t)),!0))),"SparseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>s(r,t,e,!1))),"DenseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>l(r,t,e,!1))),"number | Complex | Fraction | BigNumber, Array":r.referToSelf((e=>(r,t)=>l(i(t),r,e,!0).valueOf())),"number | Complex | Fraction | BigNumber, Matrix":r.referToSelf((e=>(r,t)=>a(r,0)?o(t.size(),t.storage()):"dense"===t.storage()?l(t,r,e,!0):c(t,r,e,!0)))})})),Fl=ti("matAlgo02xDS0",["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return function(e,n,i,a){var o=e._data,u=e._size,s=e._datatype||e.getDataType(),c=n._values,l=n._index,f=n._ptr,m=n._size,d=n._datatype||void 0===n._data?n._datatype:n.getDataType();if(u.length!==m.length)throw new ru(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");if(!c)throw Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var p,h=u[0],v=u[1],y=t,b=0,g=i;"string"==typeof s&&s===d&&"mixed"!==s&&(y=r.find(t,[p=s,p]),b=r.convert(0,p),g=r.find(i,[p,p]));for(var x=[],w=[],D=[],N=0;N<v;N++){D[N]=w.length;for(var A=f[N+1],M=f[N];M<A;M++){var C=l[M],E=a?g(c[M],o[C][N]):g(o[C][N],c[M]);y(E,b)||(w.push(C),x.push(E))}}return D[v]=w.length,n.createSparseMatrix({values:x,index:w,ptr:D,size:[h,v],datatype:s===e._datatype&&d===n._datatype?p:void 0})}})),Bl=ti("matAlgo03xDSf",["typed"],(e=>{var{typed:r}=e;return function(e,t,n,i){var a=e._data,o=e._size,u=e._datatype||e.getDataType(),s=t._values,c=t._index,l=t._ptr,f=t._size,m=t._datatype||void 0===t._data?t._datatype:t.getDataType();if(o.length!==f.length)throw new ru(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!s)throw Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var d,p=o[0],h=o[1],v=0,y=n;"string"==typeof u&&u===m&&"mixed"!==u&&(v=r.convert(0,d=u),y=r.find(n,[d,d]));for(var b=[],g=0;g<p;g++)b[g]=[];for(var x=[],w=[],D=0;D<h;D++){for(var N=D+1,A=l[D+1],M=l[D];M<A;M++){var C=c[M];x[C]=i?y(s[M],a[C][D]):y(a[C][D],s[M]),w[C]=N}for(var E=0;E<p;E++)b[E][D]=w[E]===N?x[E]:i?y(v,a[E][D]):y(a[E][D],v)}return e.createDenseMatrix({data:b,size:[p,h],datatype:u===e._datatype&&m===t._datatype?d:void 0})}})),ql=ti("matAlgo05xSfSf",["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return function(e,n,i){var a=e._values,o=e._index,u=e._ptr,s=e._size,c=e._datatype||void 0===e._data?e._datatype:e.getDataType(),l=n._values,f=n._index,m=n._ptr,d=n._size,p=n._datatype||void 0===n._data?n._datatype:n.getDataType();if(s.length!==d.length)throw new ru(s.length,d.length);if(s[0]!==d[0]||s[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+d+")");var h,v=s[0],y=s[1],b=t,g=0,x=i;"string"==typeof c&&c===p&&"mixed"!==c&&(b=r.find(t,[h=c,h]),g=r.convert(0,h),x=r.find(i,[h,h]));var w,D,N,A,M=a&&l?[]:void 0,C=[],E=[],S=M?[]:void 0,F=M?[]:void 0,B=[],q=[];for(D=0;D<y;D++){E[D]=C.length;var T=D+1;for(N=u[D],A=u[D+1];N<A;N++)C.push(w=o[N]),B[w]=T,S&&(S[w]=a[N]);for(N=m[D],A=m[D+1];N<A;N++)B[w=f[N]]!==T&&C.push(w),q[w]=T,F&&(F[w]=l[N]);if(M)for(N=E[D];N<C.length;){var k=B[w=C[N]],O=q[w];if(k===T||O===T){var I=x(k===T?S[w]:g,O===T?F[w]:g);b(I,g)?C.splice(N,1):(M.push(I),N++)}}}return E[y]=C.length,e.createSparseMatrix({values:M,index:C,ptr:E,size:[v,y],datatype:c===e._datatype&&p===n._datatype?h:void 0})}})),Tl=ti("matAlgo13xDD",["typed"],(e=>{var{typed:r}=e;return function(e,n,i){var a,o=e._data,u=e._size,s=e._datatype,c=n._data,l=n._size,f=n._datatype,m=[];if(u.length!==l.length)throw new ru(u.length,l.length);for(var d=0;d<u.length;d++){if(u[d]!==l[d])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+l+")");m[d]=u[d]}var p=i;"string"==typeof s&&s===f&&(p=r.find(i,[a=s,a]));var h=m.length>0?t(p,0,m,m[0],o,c):[];return e.createDenseMatrix({data:h,size:m,datatype:a})};function t(e,r,n,i,a,o){var u=[];if(r===n.length-1)for(var s=0;s<i;s++)u[s]=e(a[s],o[s]);else for(var c=0;c<i;c++)u[c]=t(e,r+1,n,n[r+1],a[c],o[c]);return u}}));function kl(e,r){if(Vn(e.size(),r.size()))return[e,r];var t=Su(e.size(),r.size());return[e,r].map((e=>function(e,r){return Vn(e.size(),r)?e:e.create(Bu(e.valueOf(),r),e.datatype())}(e,t)))}var Ol=ti("matrixAlgorithmSuite",["typed","matrix"],(e=>{var{typed:r,matrix:t}=e,n=Tl({typed:r}),i=cl({typed:r});return function(e){var a,o=e.elop,u=e.SD||e.DS;o?(a={"DenseMatrix, DenseMatrix":(e,r)=>n(...kl(e,r),o),"Array, Array":(e,r)=>n(...kl(t(e),t(r)),o).valueOf(),"Array, DenseMatrix":(e,r)=>n(...kl(t(e),r),o),"DenseMatrix, Array":(e,r)=>n(...kl(e,t(r)),o)},e.SS&&(a["SparseMatrix, SparseMatrix"]=(r,t)=>e.SS(...kl(r,t),o,!1)),e.DS&&(a["DenseMatrix, SparseMatrix"]=(r,t)=>e.DS(...kl(r,t),o,!1),a["Array, SparseMatrix"]=(r,n)=>e.DS(...kl(t(r),n),o,!1)),u&&(a["SparseMatrix, DenseMatrix"]=(e,r)=>u(...kl(r,e),o,!0),a["SparseMatrix, Array"]=(e,r)=>u(...kl(t(r),e),o,!0))):(a={"DenseMatrix, DenseMatrix":r.referToSelf((e=>(r,t)=>n(...kl(r,t),e))),"Array, Array":r.referToSelf((e=>(r,i)=>n(...kl(t(r),t(i)),e).valueOf())),"Array, DenseMatrix":r.referToSelf((e=>(r,i)=>n(...kl(t(r),i),e))),"DenseMatrix, Array":r.referToSelf((e=>(r,i)=>n(...kl(r,t(i)),e)))},e.SS&&(a["SparseMatrix, SparseMatrix"]=r.referToSelf((r=>(t,n)=>e.SS(...kl(t,n),r,!1)))),e.DS&&(a["DenseMatrix, SparseMatrix"]=r.referToSelf((r=>(t,n)=>e.DS(...kl(t,n),r,!1))),a["Array, SparseMatrix"]=r.referToSelf((r=>(n,i)=>e.DS(...kl(t(n),i),r,!1)))),u&&(a["SparseMatrix, DenseMatrix"]=r.referToSelf((e=>(r,t)=>u(...kl(t,r),e,!0))),a["SparseMatrix, Array"]=r.referToSelf((e=>(r,n)=>u(...kl(t(n),r),e,!0)))));var s=e.scalar||"any";(e.Ds||e.Ss)&&(o?(a["DenseMatrix,"+s]=(e,r)=>i(e,r,o,!1),a[s+", DenseMatrix"]=(e,r)=>i(r,e,o,!0),a["Array,"+s]=(e,r)=>i(t(e),r,o,!1).valueOf(),a[s+", Array"]=(e,r)=>i(t(r),e,o,!0).valueOf()):(a["DenseMatrix,"+s]=r.referToSelf((e=>(r,t)=>i(r,t,e,!1))),a[s+", DenseMatrix"]=r.referToSelf((e=>(r,t)=>i(t,r,e,!0))),a["Array,"+s]=r.referToSelf((e=>(r,n)=>i(t(r),n,e,!1).valueOf())),a[s+", Array"]=r.referToSelf((e=>(r,n)=>i(t(n),r,e,!0).valueOf()))));var c=void 0!==e.sS?e.sS:e.Ss;return o?(e.Ss&&(a["SparseMatrix,"+s]=(r,t)=>e.Ss(r,t,o,!1)),c&&(a[s+", SparseMatrix"]=(e,r)=>c(r,e,o,!0))):(e.Ss&&(a["SparseMatrix,"+s]=r.referToSelf((r=>(t,n)=>e.Ss(t,n,r,!1)))),c&&(a[s+", SparseMatrix"]=r.referToSelf((e=>(r,t)=>c(t,r,e,!0))))),o&&o.signatures&&Jn(a,o.signatures),a}})),Il=ti("mod",["typed","config","round","matrix","equalScalar","zeros","DenseMatrix","concat"],(e=>{var{typed:r,config:t,round:n,matrix:i,equalScalar:a,zeros:o,DenseMatrix:u,concat:s}=e,c=Sl({typed:r,config:t,round:n,matrix:i,equalScalar:a,zeros:o,DenseMatrix:u}),l=Fl({typed:r,equalScalar:a}),f=Bl({typed:r}),m=ql({typed:r,equalScalar:a}),d=ul({typed:r,equalScalar:a}),p=sl({typed:r,DenseMatrix:u});return r("mod",{"number, number":function(e,r){return 0===r?e:e-r*c(e/r)},"BigNumber, BigNumber":function(e,r){return r.isZero()?e:e.sub(r.mul(c(e.div(r))))},"bigint, bigint":function(e,r){if(0n===r)return e;if(e<0){var t=e%r;return 0n===t?t:t+r}return e%r},"Fraction, Fraction":function(e,r){return r.equals(0)?e:e.sub(r.mul(c(e.div(r))))}},Ol({typed:r,matrix:i,concat:s})({SS:m,DS:f,SD:l,Ss:d,sS:p}))})),zl=ti("matAlgo01xDSid",["typed"],(e=>{var{typed:r}=e;return function(e,t,n,i){var a=e._data,o=e._size,u=e._datatype||e.getDataType(),s=t._values,c=t._index,l=t._ptr,f=t._size,m=t._datatype||void 0===t._data?t._datatype:t.getDataType();if(o.length!==f.length)throw new ru(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!s)throw Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var d,p,h=o[0],v=o[1],y="string"==typeof u&&"mixed"!==u&&u===m?u:void 0,b=y?r.find(n,[y,y]):n,g=[];for(d=0;d<h;d++)g[d]=[];var x=[],w=[];for(p=0;p<v;p++){for(var D=p+1,N=l[p+1],A=l[p];A<N;A++)x[d=c[A]]=i?b(s[A],a[d][p]):b(a[d][p],s[A]),w[d]=D;for(d=0;d<h;d++)g[d][p]=w[d]===D?x[d]:a[d][p]}return e.createDenseMatrix({data:g,size:[h,v],datatype:u===e._datatype&&m===t._datatype?y:void 0})}})),jl=ti("matAlgo04xSidSid",["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return function(e,n,i){var a=e._values,o=e._index,u=e._ptr,s=e._size,c=e._datatype||void 0===e._data?e._datatype:e.getDataType(),l=n._values,f=n._index,m=n._ptr,d=n._size,p=n._datatype||void 0===n._data?n._datatype:n.getDataType();if(s.length!==d.length)throw new ru(s.length,d.length);if(s[0]!==d[0]||s[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+d+")");var h,v=s[0],y=s[1],b=t,g=0,x=i;"string"==typeof c&&c===p&&"mixed"!==c&&(b=r.find(t,[h=c,h]),g=r.convert(0,h),x=r.find(i,[h,h]));var w,D,N,A,M=a&&l?[]:void 0,C=[],E=[],S=a&&l?[]:void 0,F=a&&l?[]:void 0,B=[],q=[];for(D=0;D<y;D++){E[D]=C.length;var T=D+1;for(A=u[D+1],N=u[D];N<A;N++)C.push(w=o[N]),B[w]=T,S&&(S[w]=a[N]);for(A=m[D+1],N=m[D];N<A;N++)if(B[w=f[N]]===T){if(S){var k=x(S[w],l[N]);b(k,g)?B[w]=null:S[w]=k}}else C.push(w),q[w]=T,F&&(F[w]=l[N]);if(S&&F)for(N=E[D];N<C.length;)B[w=C[N]]===T?(M[N]=S[w],N++):q[w]===T?(M[N]=F[w],N++):C.splice(N,1)}return E[y]=C.length,e.createSparseMatrix({values:M,index:C,ptr:E,size:[v,y],datatype:c===e._datatype&&p===n._datatype?h:void 0})}})),Rl=ti("matAlgo10xSids",["typed","DenseMatrix"],(e=>{var{typed:r,DenseMatrix:t}=e;return function(e,n,i,a){var o=e._values,u=e._index,s=e._ptr,c=e._size,l=e._datatype;if(!o)throw Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,m=c[0],d=c[1],p=i;"string"==typeof l&&(n=r.convert(n,f=l),p=r.find(i,[f,f]));for(var h=[],v=[],y=[],b=0;b<d;b++){for(var g=b+1,x=s[b+1],w=s[b];w<x;w++){var D=u[w];v[D]=o[w],y[D]=g}for(var N=0;N<m;N++)0===b&&(h[N]=[]),h[N][b]=y[N]===g?a?p(n,v[N]):p(v[N],n):n}return new t({data:h,size:[m,d],datatype:f})}}));function Ul(e,r,t,n){if(!(this instanceof Ul))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=r,this.min=t,this.max=n,this.message="Wrong number of arguments in function "+e+" ("+r+" provided, "+t+(null!=n?"-"+n:"")+" expected)",this.stack=Error().stack}(Ul.prototype=Error()).constructor=Error,Ul.prototype.name="ArgumentsError",Ul.prototype.isArgumentsError=!0;var $l=["typed","config","round","matrix","equalScalar","zeros","BigNumber","DenseMatrix","concat"],Pl="number | BigNumber | Fraction | Matrix | Array",Ll="".concat(Pl,", ").concat(Pl,", ...").concat(Pl);function _l(e){return!e.some((e=>Array.isArray(e)))}var Wl=ti("gcd",$l,(e=>{var{typed:r,matrix:t,config:n,round:i,equalScalar:a,zeros:o,BigNumber:u,DenseMatrix:s,concat:c}=e,l=Il({typed:r,config:n,round:i,matrix:t,equalScalar:a,zeros:o,DenseMatrix:s,concat:c}),f=zl({typed:r}),m=jl({typed:r,equalScalar:a}),d=Rl({typed:r,DenseMatrix:s});return r("gcd",{"number, number":function(e,r){if(!ii(e)||!ii(r))throw Error("Parameters in function gcd must be integer numbers");for(var t;0!==r;)t=l(e,r),e=r,r=t;return e<0?-e:e},"BigNumber, BigNumber":function(e,r){if(!e.isInt()||!r.isInt())throw Error("Parameters in function gcd must be integer numbers");for(var t=new u(0);!r.isZero();){var n=l(e,r);e=r,r=n}return e.lt(t)?e.neg():e},"Fraction, Fraction":(e,r)=>e.gcd(r)},Ol({typed:r,matrix:t,concat:c})({SS:m,DS:f,Ss:d}),{[Ll]:r.referToSelf((e=>(r,t,n)=>{for(var i=e(r,t),a=0;a<n.length;a++)i=e(i,n[a]);return i})),Array:r.referToSelf((e=>r=>{if(1===r.length&&Array.isArray(r[0])&&_l(r[0]))return e(...r[0]);if(_l(r))return e(...r);throw new Ul("gcd() supports only 1d matrices!")})),Matrix:r.referToSelf((e=>r=>e(r.toArray())))})})),Jl=ti("matAlgo06xS0S0",["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return function(e,n,i){var a=e._values,o=e._size,u=e._datatype||void 0===e._data?e._datatype:e.getDataType(),s=n._values,c=n._size,l=n._datatype||void 0===n._data?n._datatype:n.getDataType();if(o.length!==c.length)throw new ru(o.length,c.length);if(o[0]!==c[0]||o[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+c+")");var f,m=o[0],d=o[1],p=t,h=0,v=i;"string"==typeof u&&u===l&&"mixed"!==u&&(p=r.find(t,[f=u,f]),h=r.convert(0,f),v=r.find(i,[f,f]));for(var y=a&&s?[]:void 0,b=[],g=[],x=y?[]:void 0,w=[],D=[],N=0;N<d;N++){g[N]=b.length;var A=N+1;if(Hu(e,N,w,x,D,A,b,v),Hu(n,N,w,x,D,A,b,v),x)for(var M=g[N];M<b.length;){var C=b[M];if(D[C]===A){var E=x[C];p(E,h)?b.splice(M,1):(y.push(E),M++)}else b.splice(M,1)}else for(var S=g[N];S<b.length;)D[b[S]]!==A?b.splice(S,1):S++}return g[d]=b.length,e.createSparseMatrix({values:y,index:b,ptr:g,size:[m,d],datatype:u===e._datatype&&l===n._datatype?f:void 0})}})),Vl=ti("lcm",["typed","matrix","equalScalar","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,concat:i}=e,a=Fl({typed:r,equalScalar:n}),o=Jl({typed:r,equalScalar:n}),u=ul({typed:r,equalScalar:n}),s=Ol({typed:r,matrix:t,concat:i}),c="number | BigNumber | Fraction | Matrix | Array",l={};return l["".concat(c,", ").concat(c,", ...").concat(c)]=r.referToSelf((e=>(r,t,n)=>{for(var i=e(r,t),a=0;a<n.length;a++)i=e(i,n[a]);return i})),r("lcm",{"number, number":ss,"BigNumber, BigNumber":function(e,r){if(!e.isInt()||!r.isInt())throw Error("Parameters in function lcm must be integer numbers");if(e.isZero())return e;if(r.isZero())return r;for(var t=e.times(r);!r.isZero();){var n=r;r=e.mod(n),e=n}return t.div(e).abs()},"Fraction, Fraction":(e,r)=>e.lcm(r)},s({SS:o,DS:a,Ss:u}),l)}));function Hl(e,r,t,n){return function(i){if(i>0||t.predictable){if(i<=0)return NaN;var a=i.toString(16),o=a.substring(0,15);return e*(a.length-o.length)+r(Number("0x"+o))}return n(i.toNumber())}}var Zl="log10",Gl=["typed","config","Complex"],Xl=ls(16),Yl=ti(Zl,Gl,(e=>{var{typed:r,config:t,Complex:n}=e;function i(e){return e.log().div(Math.LN10)}function a(e){return i(new n(e,0))}return r(Zl,{number:function(e){return e>=0||t.predictable?ls(e):a(e)},bigint:Hl(Xl,ls,t,a),Complex:i,BigNumber:function(e){return!e.isNegative()||t.predictable?e.log():a(e.toNumber())},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Ql="log2",Kl=ti(Ql,["typed","config","Complex"],(e=>{var{typed:r,config:t,Complex:n}=e;function i(e){return a(new n(e,0))}return r(Ql,{number:function(e){return e>=0||t.predictable?fs(e):i(e)},bigint:Hl(4,fs,t,i),Complex:a,BigNumber:function(e){return!e.isNegative()||t.predictable?e.log(2):i(e.toNumber())},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))});function a(e){var r=Math.sqrt(e.re*e.re+e.im*e.im);return new n(Math.log2?Math.log2(r):Math.log(r)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}})),ef=ti("multiplyScalar",["typed"],(e=>{var{typed:r}=e;return r("multiplyScalar",{"number, number":rs,"Complex, Complex":function(e,r){return e.mul(r)},"BigNumber, BigNumber":function(e,r){return e.times(r)},"bigint, bigint":function(e,r){return e*r},"Fraction, Fraction":function(e,r){return e.mul(r)},"number | Fraction | BigNumber | Complex, Unit":(e,r)=>r.multiply(e),"Unit, number | Fraction | BigNumber | Complex | Unit":(e,r)=>e.multiply(r)})})),rf="multiply",tf=ti(rf,["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],(e=>{var{typed:r,matrix:t,addScalar:n,multiplyScalar:i,equalScalar:a,dot:o}=e,u=ul({typed:r,equalScalar:a}),s=cl({typed:r});function c(e,r){switch(e.length){case 1:switch(r.length){case 1:if(e[0]!==r[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==r[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+r[0]+")");break;default:throw Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+r.length+" dimensions)")}break;case 2:switch(r.length){case 1:if(e[1]!==r[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+r[0]+")");break;case 2:if(e[1]!==r[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+r[0]+")");break;default:throw Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+r.length+" dimensions)")}break;default:throw Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}}var l=r("_multiplyMatrixVector",{"DenseMatrix, any":function(e,t){var a,o=e._data,u=e._size,s=e._datatype||e.getDataType(),c=t._data,l=t._datatype||t.getDataType(),f=u[0],m=u[1],d=n,p=i;s&&l&&s===l&&"string"==typeof s&&"mixed"!==s&&(d=r.find(n,[a=s,a]),p=r.find(i,[a,a]));for(var h=[],v=0;v<f;v++){for(var y=o[v],b=p(y[0],c[0]),g=1;g<m;g++)b=d(b,p(y[g],c[g]));h[v]=b}return e.createDenseMatrix({data:h,size:[f],datatype:s===e._datatype&&l===t._datatype?a:void 0})},"SparseMatrix, any":function(e,t){var o=e._values,u=e._index,s=e._ptr,c=e._datatype||void 0===e._data?e._datatype:e.getDataType();if(!o)throw Error("Cannot multiply Pattern only Matrix times Dense Matrix");var l,f=t._data,m=t._datatype||t.getDataType(),d=e._size[0],p=t._size[0],h=[],v=[],y=[],b=n,g=i,x=a,w=0;c&&m&&c===m&&"string"==typeof c&&"mixed"!==c&&(b=r.find(n,[l=c,l]),g=r.find(i,[l,l]),x=r.find(a,[l,l]),w=r.convert(0,l));var D=[],N=[];y[0]=0;for(var A=0;A<p;A++){var M=f[A];if(!x(M,w))for(var C=s[A+1],E=s[A];E<C;E++){var S=u[E];N[S]?D[S]=b(D[S],g(M,o[E])):(N[S]=!0,v.push(S),D[S]=g(M,o[E]))}}for(var F=v.length,B=0;B<F;B++)h[B]=D[v[B]];return y[1]=v.length,e.createSparseMatrix({values:h,index:v,ptr:y,size:[d,1],datatype:c===e._datatype&&m===t._datatype?l:void 0})}}),f=r("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":function(e,t){var a,o=e._data,u=e._size,s=e._datatype||e.getDataType(),c=t._data,l=t._size,f=t._datatype||t.getDataType(),m=u[0],d=u[1],p=l[1],h=n,v=i;s&&f&&s===f&&"string"==typeof s&&"mixed"!==s&&"mixed"!==s&&(h=r.find(n,[a=s,a]),v=r.find(i,[a,a]));for(var y=[],b=0;b<m;b++){var g=o[b];y[b]=[];for(var x=0;x<p;x++){for(var w=v(g[0],c[0][x]),D=1;D<d;D++)w=h(w,v(g[D],c[D][x]));y[b][x]=w}}return e.createDenseMatrix({data:y,size:[m,p],datatype:s===e._datatype&&f===t._datatype?a:void 0})},"DenseMatrix, SparseMatrix":function(e,t){var o=e._data,u=e._size,s=e._datatype||e.getDataType(),c=t._values,l=t._index,f=t._ptr,m=t._size,d=t._datatype||void 0===t._data?t._datatype:t.getDataType();if(!c)throw Error("Cannot multiply Dense Matrix times Pattern only Matrix");var p,h=u[0],v=m[1],y=n,b=i,g=a,x=0;s&&d&&s===d&&"string"==typeof s&&"mixed"!==s&&(y=r.find(n,[p=s,p]),b=r.find(i,[p,p]),g=r.find(a,[p,p]),x=r.convert(0,p));for(var w=[],D=[],N=[],A=t.createSparseMatrix({values:w,index:D,ptr:N,size:[h,v],datatype:s===e._datatype&&d===t._datatype?p:void 0}),M=0;M<v;M++){N[M]=D.length;var C=f[M],E=f[M+1];if(E>C)for(var S=0,F=0;F<h;F++){for(var B=F+1,q=void 0,T=C;T<E;T++){var k=l[T];S!==B?(q=b(o[F][k],c[T]),S=B):q=y(q,b(o[F][k],c[T]))}S!==B||g(q,x)||(D.push(F),w.push(q))}}return N[v]=D.length,A},"SparseMatrix, DenseMatrix":function(e,t){var o=e._values,u=e._index,s=e._ptr,c=e._datatype||void 0===e._data?e._datatype:e.getDataType();if(!o)throw Error("Cannot multiply Pattern only Matrix times Dense Matrix");var l,f=t._data,m=t._datatype||t.getDataType(),d=e._size[0],p=t._size[0],h=t._size[1],v=n,y=i,b=a,g=0;c&&m&&c===m&&"string"==typeof c&&"mixed"!==c&&(v=r.find(n,[l=c,l]),y=r.find(i,[l,l]),b=r.find(a,[l,l]),g=r.convert(0,l));for(var x=[],w=[],D=[],N=e.createSparseMatrix({values:x,index:w,ptr:D,size:[d,h],datatype:c===e._datatype&&m===t._datatype?l:void 0}),A=[],M=[],C=0;C<h;C++){D[C]=w.length;for(var E=C+1,S=0;S<p;S++){var F=f[S][C];if(!b(F,g))for(var B=s[S+1],q=s[S];q<B;q++){var T=u[q];M[T]!==E?(M[T]=E,w.push(T),A[T]=y(F,o[q])):A[T]=v(A[T],y(F,o[q]))}}for(var k=w.length,O=D[C];O<k;O++)x[O]=A[w[O]]}return D[h]=w.length,N},"SparseMatrix, SparseMatrix":function(e,t){var a,o=e._values,u=e._index,s=e._ptr,c=e._datatype||void 0===e._data?e._datatype:e.getDataType(),l=t._values,f=t._index,m=t._ptr,d=t._datatype||void 0===t._data?t._datatype:t.getDataType(),p=e._size[0],h=t._size[1],v=o&&l,y=n,b=i;c&&d&&c===d&&"string"==typeof c&&"mixed"!==c&&(y=r.find(n,[a=c,a]),b=r.find(i,[a,a]));for(var g,x,w,D,N,A,M=v?[]:void 0,C=[],E=[],S=e.createSparseMatrix({values:M,index:C,ptr:E,size:[p,h],datatype:c===e._datatype&&d===t._datatype?a:void 0}),F=v?[]:void 0,B=[],q=0;q<h;q++){E[q]=C.length;var T=q+1;for(D=m[q+1],w=m[q];w<D;w++)if(A=f[w],v)for(x=s[A+1],g=s[A];g<x;g++)B[N=u[g]]!==T?(B[N]=T,C.push(N),F[N]=b(l[w],o[g])):F[N]=y(F[N],b(l[w],o[g]));else for(x=s[A+1],g=s[A];g<x;g++)B[N=u[g]]!==T&&(B[N]=T,C.push(N));if(v)for(var k=C.length,O=E[q];O<k;O++)M[O]=F[C[O]]}return E[h]=C.length,S}});return r(rf,i,{"Array, Array":r.referTo("Matrix, Matrix",(e=>(r,n)=>{c(nu(r),nu(n));var i=e(t(r),t(n));return cn(i)?i.valueOf():i})),"Matrix, Matrix":function(e,t){var a=e.size(),u=t.size();return c(a,u),1===a.length?1===u.length?function(e,r,t){if(0===t)throw Error("Cannot multiply two empty vectors");return o(e,r)}(e,t,a[0]):function(e,t){if("dense"!==t.storage())throw Error("Support for SparseMatrix not implemented");return function(e,t){var a,o=e._data,u=e._size,s=e._datatype||e.getDataType(),c=t._data,l=t._size,f=t._datatype||t.getDataType(),m=u[0],d=l[1],p=n,h=i;s&&f&&s===f&&"string"==typeof s&&"mixed"!==s&&(p=r.find(n,[a=s,a]),h=r.find(i,[a,a]));for(var v=[],y=0;y<d;y++){for(var b=h(o[0],c[0][y]),g=1;g<m;g++)b=p(b,h(o[g],c[g][y]));v[y]=b}return e.createDenseMatrix({data:v,size:[d],datatype:s===e._datatype&&f===t._datatype?a:void 0})}(e,t)}(e,t):1===u.length?l(e,t):f(e,t)},"Matrix, Array":r.referTo("Matrix,Matrix",(e=>(r,n)=>e(r,t(n)))),"Array, Matrix":r.referToSelf((e=>(r,n)=>e(t(r,n.storage()),n))),"SparseMatrix, any":function(e,r){return u(e,r,i,!1)},"DenseMatrix, any":function(e,r){return s(e,r,i,!1)},"any, SparseMatrix":function(e,r){return u(r,e,i,!0)},"any, DenseMatrix":function(e,r){return s(r,e,i,!0)},"Array, any":function(e,r){return s(t(e),r,i,!1).valueOf()},"any, Array":function(e,r){return s(t(r),e,i,!0).valueOf()},"any, any":i,"any, any, ...any":r.referToSelf((e=>(r,t,n)=>{for(var i=e(r,t),a=0;a<n.length;a++)i=e(i,n[a]);return i}))})})),nf="nthRoot",af=ti(nf,["typed","matrix","equalScalar","BigNumber","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,BigNumber:i,concat:a}=e,o=zl({typed:r}),u=Fl({typed:r,equalScalar:n}),s=Jl({typed:r,equalScalar:n}),c=ul({typed:r,equalScalar:n}),l=Ol({typed:r,matrix:t,concat:a});function f(){throw Error("Complex number not supported in function nthRoot. Use nthRoots instead.")}return r(nf,{number:ms,"number, number":ms,BigNumber:e=>m(e,new i(2)),"BigNumber, BigNumber":m,Complex:f,"Complex, number":f,Array:r.referTo("DenseMatrix,number",(e=>r=>e(t(r),2).valueOf())),DenseMatrix:r.referTo("DenseMatrix,number",(e=>r=>e(r,2))),SparseMatrix:r.referTo("SparseMatrix,number",(e=>r=>e(r,2))),"SparseMatrix, SparseMatrix":r.referToSelf((e=>(r,t)=>{if(1===t.density())return s(r,t,e);throw Error("Root must be non-zero")})),"DenseMatrix, SparseMatrix":r.referToSelf((e=>(r,t)=>{if(1===t.density())return o(r,t,e,!1);throw Error("Root must be non-zero")})),"Array, SparseMatrix":r.referTo("DenseMatrix,SparseMatrix",(e=>(r,n)=>e(t(r),n))),"number | BigNumber, SparseMatrix":r.referToSelf((e=>(r,t)=>{if(1===t.density())return c(t,r,e,!0);throw Error("Root must be non-zero")}))},l({scalar:"number | BigNumber",SD:u,Ss:c,sS:!1}));function m(e,r){var t=i.precision,n=i.clone({precision:t+2}),a=new i(0),o=new n(1),u=r.isNegative();if(u&&(r=r.neg()),r.isZero())throw Error("Root must be non-zero");if(e.isNegative()&&!r.abs().mod(2).equals(1))throw Error("Root must be odd when a is negative.");if(e.isZero())return u?new n(1/0):0;if(!e.isFinite())return u?a:e;var s=e.abs().pow(o.div(r));return s=e.isNeg()?s.neg():s,new i((u?o.div(s):s).toPrecision(t))}})),of="sign",uf=ti(of,["typed","BigNumber","Fraction","complex"],(e=>{var{typed:r,BigNumber:t,complex:n,Fraction:i}=e;return r(of,{number:ds,Complex:function(e){return 0===e.im?n(ds(e.re)):e.sign()},BigNumber:function(e){return new t(e.cmp(0))},bigint:function(e){return e>0n?1n:e<0n?-1n:0n},Fraction:function(e){return new i(0n===e.n?0:e.s)},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e,!0))),Unit:r.referToSelf((e=>t=>{if(!t._isDerived()&&0!==t.units[0].unit.offset)throw new TypeError("sign is ambiguous for units with offset");return r.find(e,t.valueType())(t.value)}))})})),sf=ti("sqrt",["config","typed","Complex"],(e=>{var{config:r,typed:t,Complex:n}=e;return t("sqrt",{number:i,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||r.predictable?e.sqrt():i(e.toNumber())},Unit:function(e){return e.pow(.5)}});function i(e){return isNaN(e)?NaN:e>=0||r.predictable?Math.sqrt(e):new n(e,0).sqrt()}})),cf="square",lf=ti(cf,["typed"],(e=>{var{typed:r}=e;return r(cf,{number:ps,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},bigint:function(e){return e*e},Fraction:function(e){return e.mul(e)},Unit:function(e){return e.pow(2)}})})),ff="subtract",mf=ti(ff,["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,subtractScalar:i,DenseMatrix:a,concat:o}=e,u=zl({typed:r}),s=Bl({typed:r}),c=ql({typed:r,equalScalar:n}),l=Rl({typed:r,DenseMatrix:a}),f=sl({typed:r,DenseMatrix:a}),m=Ol({typed:r,matrix:t,concat:o});return r(ff,{"any, any":i},m({elop:i,SS:c,DS:u,SD:s,Ss:f,sS:l}))})),df="xgcd",pf=ti(df,["typed","config","matrix","BigNumber"],(e=>{var{typed:r,config:t,matrix:n,BigNumber:i}=e;return r(df,{"number, number":function(e,r){var i=hs(e,r);return"Array"===t.matrix?i:n(i)},"BigNumber, BigNumber":function(e,r){var a,o,u,s,c=new i(0),l=new i(1),f=c,m=l,d=l,p=c;if(!e.isInt()||!r.isInt())throw Error("Parameters in function xgcd must be integer numbers");for(;!r.isZero();)o=e.div(r).floor(),u=e.mod(r),a=f,f=m.minus(o.times(f)),m=a,a=d,d=p.minus(o.times(d)),p=a,e=r,r=u;return s=e.lt(c)?[e.neg(),m.neg(),p.neg()]:[e,e.isZero()?0:m,p],"Array"===t.matrix?s:n(s)}})})),hf="invmod",vf=ti(hf,["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],(e=>{var{typed:r,BigNumber:t,xgcd:n,equal:i,smaller:a,mod:o,add:u,isInteger:s}=e;return r(hf,{"number, number":c,"BigNumber, BigNumber":c});function c(e,r){if(!s(e)||!s(r))throw Error("Parameters in function invmod must be integer numbers");if(e=o(e,r),i(r,0))throw Error("Divisor must be non zero");var c=n(e,r);c=c.valueOf();var[l,f]=c;return i(l,t(1))?(f=o(f,r),a(f,t(0))&&(f=u(f,r)),f):NaN}})),yf=ti("matAlgo09xS0Sf",["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return function(e,n,i){var a=e._values,o=e._index,u=e._ptr,s=e._size,c=e._datatype||void 0===e._data?e._datatype:e.getDataType(),l=n._values,f=n._index,m=n._ptr,d=n._size,p=n._datatype||void 0===n._data?n._datatype:n.getDataType();if(s.length!==d.length)throw new ru(s.length,d.length);if(s[0]!==d[0]||s[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+d+")");var h,v=s[0],y=s[1],b=t,g=0,x=i;"string"==typeof c&&c===p&&"mixed"!==c&&(b=r.find(t,[h=c,h]),g=r.convert(0,h),x=r.find(i,[h,h]));var w,D,N,A,M=a&&l?[]:void 0,C=[],E=[],S=M?[]:void 0,F=[];for(D=0;D<y;D++){E[D]=C.length;var B=D+1;if(S)for(A=m[D+1],N=m[D];N<A;N++)F[w=f[N]]=B,S[w]=l[N];for(A=u[D+1],N=u[D];N<A;N++)if(w=o[N],S){var q=x(a[N],F[w]===B?S[w]:g);b(q,g)||(C.push(w),M.push(q))}else C.push(w)}return E[y]=C.length,e.createSparseMatrix({values:M,index:C,ptr:E,size:[v,y],datatype:c===e._datatype&&p===n._datatype?h:void 0})}})),bf="dotMultiply",gf=ti(bf,["typed","matrix","equalScalar","multiplyScalar","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,multiplyScalar:i,concat:a}=e,o=Fl({typed:r,equalScalar:n}),u=yf({typed:r,equalScalar:n}),s=ul({typed:r,equalScalar:n}),c=Ol({typed:r,matrix:t,concat:a});return r(bf,c({elop:i,SS:u,DS:o,Ss:s}))}));function xf(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw Error("Integers expected in function bitAnd");var t=e.constructor;if(e.isNaN()||r.isNaN())return new t(NaN);if(e.isZero()||r.eq(-1)||e.eq(r))return e;if(r.isZero()||e.eq(-1))return r;if(!e.isFinite()||!r.isFinite()){if(!e.isFinite()&&!r.isFinite())return e.isNegative()===r.isNegative()?e:new t(0);if(!e.isFinite())return r.isNegative()?e:e.isNegative()?new t(0):r;if(!r.isFinite())return e.isNegative()?r:r.isNegative()?new t(0):e}return Nf(e,r,(function(e,r){return e&r}))}function wf(e){if(e.isFinite()&&!e.isInteger())throw Error("Integer expected in function bitNot");var r=e.constructor,t=r.precision;r.config({precision:1e9});var n=e.plus(new r(1));return n.s=-n.s||null,r.config({precision:t}),n}function Df(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw Error("Integers expected in function bitOr");var t=e.constructor;if(e.isNaN()||r.isNaN())return new t(NaN);var n=new t(-1);return e.isZero()||r.eq(n)||e.eq(r)?r:r.isZero()||e.eq(n)?e:e.isFinite()&&r.isFinite()?Nf(e,r,(function(e,r){return e|r})):!e.isFinite()&&!e.isNegative()&&r.isNegative()||e.isNegative()&&!r.isNegative()&&!r.isFinite()?n:e.isNegative()&&r.isNegative()?e.isFinite()?e:r:e.isFinite()?r:e}function Nf(e,r,t){var n,i,a,o,u,s=e.constructor,c=+(e.s<0),l=+(r.s<0);if(c){n=Af(wf(e));for(var f=0;f<n.length;++f)n[f]^=1}else n=Af(e);if(l){i=Af(wf(r));for(var m=0;m<i.length;++m)i[m]^=1}else i=Af(r);n.length<=i.length?(a=n,o=i,u=c):(a=i,o=n,u=l);var d=a.length,p=o.length,h=1^t(c,l),v=new s(1^h),y=new s(1),b=new s(2),g=s.precision;for(s.config({precision:1e9});d>0;)t(a[--d],o[--p])===h&&(v=v.plus(y)),y=y.times(b);for(;p>0;)t(u,o[--p])===h&&(v=v.plus(y)),y=y.times(b);return s.config({precision:g}),0===h&&(v.s=-v.s),v}function Af(e){for(var r=e.d,t=r[0]+"",n=1;n<r.length;++n){for(var i=r[n]+"",a=7-i.length;a--;)i="0"+i;t+=i}for(var o=t.length;"0"===t.charAt(o);)o--;var u=e.e,s=t.slice(0,o+1||1),c=s.length;if(u>0)if(++u>c)for(u-=c;u--;)s+="0";else u<c&&(s=s.slice(0,u)+"."+s.slice(u));for(var l=[0],f=0;f<s.length;){for(var m=l.length;m--;)l[m]*=10;l[0]+=parseInt(s.charAt(f++));for(var d=0;d<l.length;++d)l[d]>1&&(null==l[d+1]&&(l[d+1]=0),l[d+1]+=l[d]>>1,l[d]&=1)}return l.reverse()}function Mf(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw Error("Integers expected in function bitXor");var t=e.constructor;if(e.isNaN()||r.isNaN())return new t(NaN);if(e.isZero())return r;if(r.isZero())return e;if(e.eq(r))return new t(0);var n=new t(-1);return e.eq(n)?wf(r):r.eq(n)?wf(e):e.isFinite()&&r.isFinite()?Nf(e,r,(function(e,r){return e^r})):e.isFinite()||r.isFinite()?new t(e.isNegative()===r.isNegative()?1/0:-1/0):n}function Cf(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw Error("Integers expected in function leftShift");var t=e.constructor;return e.isNaN()||r.isNaN()||r.isNegative()&&!r.isZero()?new t(NaN):e.isZero()||r.isZero()?e:e.isFinite()||r.isFinite()?r.lt(55)?e.times(Math.pow(2,r.toNumber())+""):e.times(new t(2).pow(r)):new t(NaN)}function Ef(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw Error("Integers expected in function rightArithShift");var t=e.constructor;return e.isNaN()||r.isNaN()||r.isNegative()&&!r.isZero()?new t(NaN):e.isZero()||r.isZero()?e:r.isFinite()?r.lt(55)?e.div(Math.pow(2,r.toNumber())+"").floor():e.div(new t(2).pow(r)).floor():e.isNegative()?new t(-1):e.isFinite()?new t(0):new t(NaN)}var Sf="bitAnd",Ff=ti(Sf,["typed","matrix","equalScalar","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,concat:i}=e,a=Fl({typed:r,equalScalar:n}),o=Jl({typed:r,equalScalar:n}),u=ul({typed:r,equalScalar:n}),s=Ol({typed:r,matrix:t,concat:i});return r(Sf,{"number, number":gs,"BigNumber, BigNumber":xf,"bigint, bigint":(e,r)=>e&r},s({SS:o,DS:a,Ss:u}))})),Bf="bitNot",qf=ti(Bf,["typed"],(e=>{var{typed:r}=e;return r(Bf,{number:xs,BigNumber:wf,bigint:e=>~e,"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Tf="bitOr",kf=ti(Tf,["typed","matrix","equalScalar","DenseMatrix","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,DenseMatrix:i,concat:a}=e,o=zl({typed:r}),u=jl({typed:r,equalScalar:n}),s=Rl({typed:r,DenseMatrix:i}),c=Ol({typed:r,matrix:t,concat:a});return r(Tf,{"number, number":ws,"BigNumber, BigNumber":Df,"bigint, bigint":(e,r)=>e|r},c({SS:u,DS:o,Ss:s}))})),Of=ti("matAlgo07xSSf",["typed","SparseMatrix"],(e=>{var{typed:r,SparseMatrix:t}=e;return function(e,i,a){var o=e._size,u=e._datatype||void 0===e._data?e._datatype:e.getDataType(),s=i._size,c=i._datatype||void 0===i._data?i._datatype:i.getDataType();if(o.length!==s.length)throw new ru(o.length,s.length);if(o[0]!==s[0]||o[1]!==s[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+s+")");var l,f=o[0],m=o[1],d=0,p=a;"string"==typeof u&&u===c&&"mixed"!==u&&(d=r.convert(0,l=u),p=r.find(a,[l,l]));for(var h=[],v=[],y=Array(m+1).fill(0),b=[],g=[],x=[],w=[],D=0;D<m;D++){var N=D+1,A=0;n(e,D,x,b,N),n(i,D,w,g,N);for(var M=0;M<f;M++){var C=p(x[M]===N?b[M]:d,w[M]===N?g[M]:d);0!==C&&!1!==C&&(v.push(M),h.push(C),A++)}y[D+1]=y[D]+A}return new t({values:h,index:v,ptr:y,size:[f,m],datatype:u===e._datatype&&c===i._datatype?l:void 0})};function n(e,r,t,n,i){for(var a=e._values,o=e._index,u=e._ptr,s=u[r],c=u[r+1];s<c;s++){var l=o[s];t[l]=i,n[l]=a[s]}}})),If="bitXor",zf=ti(If,["typed","matrix","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,matrix:t,DenseMatrix:n,concat:i,SparseMatrix:a}=e,o=Bl({typed:r}),u=Of({typed:r,SparseMatrix:a}),s=sl({typed:r,DenseMatrix:n}),c=Ol({typed:r,matrix:t,concat:i});return r(If,{"number, number":Ds,"BigNumber, BigNumber":Mf,"bigint, bigint":(e,r)=>e^r},c({SS:u,DS:o,Ss:s}))})),jf=ti("arg",["typed"],(e=>{var{typed:r}=e;return r("arg",{number:function(e){return Math.atan2(0,e)},BigNumber:function(e){return e.constructor.atan2(0,e)},Complex:function(e){return e.arg()},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Rf="conj",Uf=ti(Rf,["typed"],(e=>{var{typed:r}=e;return r(Rf,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),Unit:r.referToSelf((e=>r=>new r.constructor(e(r.toNumeric()),r.formatUnits()))),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),$f=ti("im",["typed"],(e=>{var{typed:r}=e;return r("im",{number:()=>0,"BigNumber | Fraction":e=>e.mul(0),Complex:e=>e.im,"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Pf=ti("re",["typed"],(e=>{var{typed:r}=e;return r("re",{"number | BigNumber | Fraction":e=>e,Complex:e=>e.re,"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Lf=ti("not",["typed"],(e=>{var{typed:r}=e;return r("not",{"null | undefined":()=>!0,number:Ts,Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},bigint:e=>!e,Unit:r.referToSelf((e=>t=>r.find(e,t.valueType())(t.value))),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),_f="nullish",Wf=ti(_f,["typed","matrix","size","flatten","deepEqual"],(e=>{var{typed:r,matrix:t,size:n,flatten:i,deepEqual:a}=e,o=Bl({typed:r}),u=cl({typed:r}),s=Tl({typed:r});return r(_f,{"number|bigint|Complex|BigNumber|Fraction|Unit|string|boolean|SparseMatrix, any":e=>e,"null, any":(e,r)=>r,"undefined, any":(e,r)=>r,"SparseMatrix, Array | Matrix":(e,r)=>{var t=i(n(e).valueOf()),o=i(n(r).valueOf());if(a(t,o))return e;throw new ru(t,o)},"DenseMatrix, DenseMatrix":r.referToSelf((e=>(r,t)=>s(r,t,e))),"DenseMatrix, SparseMatrix":r.referToSelf((e=>(r,t)=>o(r,t,e,!1))),"DenseMatrix, Array":r.referToSelf((e=>(r,n)=>s(r,t(n),e))),"DenseMatrix, any":r.referToSelf((e=>(r,t)=>u(r,t,e,!1))),"Array, Array":r.referToSelf((e=>(r,n)=>s(t(r),t(n),e).valueOf())),"Array, DenseMatrix":r.referToSelf((e=>(r,n)=>s(t(r),n,e))),"Array, SparseMatrix":r.referToSelf((e=>(r,n)=>o(t(r),n,e,!1))),"Array, any":r.referToSelf((e=>(r,n)=>u(t(r),n,e,!1).valueOf()))})})),Jf=ti("or",["typed","matrix","equalScalar","DenseMatrix","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,DenseMatrix:i,concat:a}=e,o=Bl({typed:r}),u=ql({typed:r,equalScalar:n}),s=sl({typed:r,DenseMatrix:i}),c=Ol({typed:r,matrix:t,concat:a});return r("or",{"number, number":ks,"Complex, Complex":function(e,r){return 0!==e.re||0!==e.im||0!==r.re||0!==r.im},"BigNumber, BigNumber":function(e,r){return!e.isZero()&&!e.isNaN()||!r.isZero()&&!r.isNaN()},"bigint, bigint":ks,"Unit, Unit":r.referToSelf((e=>(r,t)=>e(r.value||0,t.value||0)))},c({SS:u,DS:o,Ss:s}))})),Vf=ti("xor",["typed","matrix","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,matrix:t,DenseMatrix:n,concat:i,SparseMatrix:a}=e,o=Bl({typed:r}),u=Of({typed:r,SparseMatrix:a}),s=sl({typed:r,DenseMatrix:n}),c=Ol({typed:r,matrix:t,concat:i});return r("xor",{"number, number":Os,"Complex, Complex":function(e,r){return(0!==e.re||0!==e.im)!=(0!==r.re||0!==r.im)},"bigint, bigint":Os,"BigNumber, BigNumber":function(e,r){return(!e.isZero()&&!e.isNaN())!=(!r.isZero()&&!r.isNaN())},"Unit, Unit":r.referToSelf((e=>(r,t)=>e(r.value||0,t.value||0)))},c({SS:u,DS:o,Ss:s}))})),Hf="concat",Zf=ti(Hf,["typed","matrix","isInteger"],(e=>{var{typed:r,matrix:t,isInteger:n}=e;return r(Hf,{"...Array | Matrix | number | BigNumber":function(e){var r,i,a=e.length,o=-1,u=!1,s=[];for(r=0;r<a;r++){var c=e[r];if(cn(c)&&(u=!0),en(c)||rn(c)){if(r!==a-1)throw Error("Dimension must be specified as last argument");if(i=o,!n(o=c.valueOf()))throw new TypeError("Integer number expected for dimension");if(o<0||r>0&&o>i)throw new tu(o,i+1)}else{var l=Wn(c).valueOf(),f=nu(l);if(s[r]=l,i=o,o=f.length-1,r>0&&o!==i)throw new ru(i+1,o+1)}}if(0===s.length)throw new SyntaxError("At least one matrix expected");for(var m=s.shift();s.length;)m=Eu(m,s.shift(),o);return u?t(m):m},"...string":function(e){return e.join("")}})})),Gf="column",Xf=ti(Gf,["typed","Index","matrix","range"],(e=>{var{typed:r,Index:t,matrix:n,range:i}=e;return r(Gf,{"Matrix, number":a,"Array, number":function(e,r){return a(n(Wn(e)),r).valueOf()}});function a(e,r){if(2!==e.size().length)throw Error("Only two dimensional matrix is supported");uu(r,e.size()[1]);var a=i(0,e.size()[0]),o=new t(a,r),u=e.subset(o);return cn(u)?u:n([[u]])}})),Yf="count",Qf=ti(Yf,["typed","size","prod"],(e=>{var{typed:r,size:t,prod:n}=e;return r(Yf,{string:function(e){return e.length},"Matrix | Array":function(e){return n(t(e))}})})),Kf="cross",em=ti(Kf,["typed","matrix","subtract","multiply"],(e=>{var{typed:r,matrix:t,subtract:n,multiply:i}=e;return r(Kf,{"Matrix, Matrix":function(e,r){return t(a(e.toArray(),r.toArray()))},"Matrix, Array":function(e,r){return t(a(e.toArray(),r))},"Array, Matrix":function(e,r){return t(a(e,r.toArray()))},"Array, Array":a});function a(e,r){var t=Math.max(nu(e).length,nu(r).length);e=pu(e),r=pu(r);var a=nu(e),o=nu(r);if(1!==a.length||1!==o.length||3!==a[0]||3!==o[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+a.join(", ")+"], B = ["+o.join(", ")+"])");var u=[n(i(e[1],r[2]),i(e[2],r[1])),n(i(e[2],r[0]),i(e[0],r[2])),n(i(e[0],r[1]),i(e[1],r[0]))];return t>1?[u]:u}})),rm="diag",tm=ti(rm,["typed","matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:r,matrix:t,DenseMatrix:n,SparseMatrix:i}=e;return r(rm,{Array:function(e){return a(e,0,nu(e),null)},"Array, number":function(e,r){return a(e,r,nu(e),null)},"Array, BigNumber":function(e,r){return a(e,r.toNumber(),nu(e),null)},"Array, string":function(e,r){return a(e,0,nu(e),r)},"Array, number, string":function(e,r,t){return a(e,r,nu(e),t)},"Array, BigNumber, string":function(e,r,t){return a(e,r.toNumber(),nu(e),t)},Matrix:function(e){return a(e,0,e.size(),e.storage())},"Matrix, number":function(e,r){return a(e,r,e.size(),e.storage())},"Matrix, BigNumber":function(e,r){return a(e,r.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,r){return a(e,0,e.size(),r)},"Matrix, number, string":function(e,r,t){return a(e,r,e.size(),t)},"Matrix, BigNumber, string":function(e,r,t){return a(e,r.toNumber(),e.size(),t)}});function a(e,r,a,o){if(!ii(r))throw new TypeError("Second parameter in function diag must be an integer");var u=r>0?r:0,s=r<0?-r:0;switch(a.length){case 1:return function(e,r,t,a,o,u){var s=[a+o,a+u];if(t&&"sparse"!==t&&"dense"!==t)throw new TypeError("Unknown matrix type ".concat(t,'"'));var c="sparse"===t?i.diagonal(s,e,r):n.diagonal(s,e,r);return null!==t?c:c.valueOf()}(e,r,o,a[0],s,u);case 2:return function(e,r,n,i,a,o){if(cn(e)){var u=e.diagonal(r);return null!==n?n!==u.storage()?t(u,n):u:u.valueOf()}for(var s=Math.min(i[0]-a,i[1]-o),c=[],l=0;l<s;l++)c[l]=e[l+a][l+o];return null!==n?t(c):c}(e,r,o,a,s,u)}throw new RangeError("Matrix for function diag must be 2 dimensional")}})),nm=ti("filter",["typed"],(e=>{var{typed:r}=e;return r("filter",{"Array, function":im,"Matrix, function":function(e,r){return e.create(im(e.valueOf(),r),e.datatype())},"Array, RegExp":wu,"Matrix, RegExp":function(e,r){return e.create(wu(e.valueOf(),r),e.datatype())}})}));function im(e,r){var t=Iu(r,e,"filter");return function(e,r){if(1!==nu(e).length)throw Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,r)}(e,t.isUnary?t.fn:function(e,r,n){return t.fn(e,[r],n)})}var am="flatten",om=ti(am,["typed"],(e=>{var{typed:r}=e;return r(am,{Array:function(e){return bu(e)},Matrix:function(e){return e.create(bu(e.valueOf(),!0),e.datatype())}})})),um="forEach",sm=ti(um,["typed"],(e=>{var{typed:r}=e;return r(um,{"Array, function":cm,"Matrix, function":function(e,r){e.forEach(r)}})}));function cm(e,r){var t=Iu(r,e,um);Ou(e,t.fn,t.isUnary)}var lm="getMatrixDataType",fm=ti(lm,["typed"],(e=>{var{typed:r}=e;return r(lm,{Array:function(e){return Mu(e,_n)},Matrix:function(e){return e.getDataType()}})})),mm="identity",dm=ti(mm,["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],(e=>{var{typed:r,config:t,matrix:n,BigNumber:i,DenseMatrix:a,SparseMatrix:o}=e;return r(mm,{"":function(){return"Matrix"===t.matrix?n([]):[]},string:function(e){return n(e)},"number | BigNumber":function(e){return s(e,e,"Matrix"===t.matrix?"dense":void 0)},"number | BigNumber, string":function(e,r){return s(e,e,r)},"number | BigNumber, number | BigNumber":function(e,r){return s(e,r,"Matrix"===t.matrix?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(e,r,t){return s(e,r,t)},Array:function(e){return u(e)},"Array, string":function(e,r){return u(e,r)},Matrix:function(e){return u(e.valueOf(),e.storage())},"Matrix, string":function(e,r){return u(e.valueOf(),r)}});function u(e,r){switch(e.length){case 0:return r?n(r):[];case 1:return s(e[0],e[0],r);case 2:return s(e[0],e[1],r);default:throw Error("Vector containing two values expected")}}function s(e,r,t){var n=rn(e)||rn(r)?i:null;if(rn(e)&&(e=e.toNumber()),rn(r)&&(r=r.toNumber()),!ii(e)||e<1)throw Error("Parameters in function identity must be positive integers");if(!ii(r)||r<1)throw Error("Parameters in function identity must be positive integers");var u=n?new i(1):1,s=n?new n(0):0,c=[e,r];if(t){if("sparse"===t)return o.diagonal(c,u,0,s);if("dense"===t)return a.diagonal(c,u,0,s);throw new TypeError('Unknown matrix type "'.concat(t,'"'))}for(var l=cu([],c,s),f=e<r?e:r,m=0;m<f;m++)l[m][m]=u;return l}})),pm="kron",hm=ti(pm,["typed","matrix","multiplyScalar"],(e=>{var{typed:r,matrix:t,multiplyScalar:n}=e;return r(pm,{"Matrix, Matrix":function(e,r){return t(i(e.toArray(),r.toArray()))},"Matrix, Array":function(e,r){return t(i(e.toArray(),r))},"Array, Matrix":function(e,r){return t(i(e,r.toArray()))},"Array, Array":i});function i(e,r){if(1===nu(e).length&&(e=[e]),1===nu(r).length&&(r=[r]),nu(e).length>2||nu(r).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(e.length)+", y = "+JSON.stringify(r.length)+")");var t=[],i=[];return e.map((function(e){return r.map((function(r){return t.push(i=[]),e.map((function(e){return r.map((function(r){return i.push(n(e,r))}))}))}))}))&&t}})),vm="map",ym=ti(vm,["typed"],(e=>{var{typed:r}=e;return r(vm,{"Array, function":n,"Matrix, function":function(e,r){return e.map(r)},"Array|Matrix, Array|Matrix, ...Array|Matrix|function":(e,i,a)=>function(e,i){if("function"!=typeof i)throw Error("Last argument must be a callback function");var a=e[0].isMatrix,o=e.map((e=>e.isMatrix?e.size():nu(e))),u=Su(...o),s=e.length,c=a?(e,r)=>e.get(r):Tu,l=e.map(((e,r)=>{var t=o[r].map((()=>0));return e.isMatrix?e.get(t):Tu(e,t)})),f=r.isTypedFunction(i)?function(e,t,n,i){return null!==r.resolve(e,[...t,n,...i])?2:null!==r.resolve(e,[...t,n])?1:(r.resolve(e,t),0)}(i,l,u.map((()=>0)),e):function(e,r){var t=""+e;if(/arguments/.test(t))return 2;var n=t.match(/\(.*?\)/);return/\.\.\./.test(n)||e.length>r+1?2:e.length===r+1?1:0}(i,s);if(f<2){var m=t(f,i,null);return function(e,r){var t=e[0],n=e.map((e=>e.isMatrix?e.valueOf():e)),i=e.map((e=>e.isMatrix?e.size():nu(e))),a=Su(...i),o=i.map((e=>a.length-e.length)),u=a.length-1,s=r.length>1?[]:null,c=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=a[n],c=Array(i);if(n<u)for(var l=function(r){s&&(s[n]=r),c[r]=e(t.map(((e,t)=>o[t]>n?e:1===e.length?e[0]:e[r])),n+1)},f=0;f<i;f++)l(f);else for(var m=function(e){s&&(s[n]=e),c[e]=r(t.map((r=>1===r.length?r[0]:r[e])),s?s.slice():void 0)},d=0;d<i;d++)m(d);return c}(n,0);if(t.isMatrix){var l=t.create();return l._data=c,l._size=a,l}return c}(e,m)}var d=e.map(a?r=>r.isMatrix?r.create(Bu(r.toArray(),u),r.datatype()):e[0].create(Bu(r.valueOf(),u)):e=>Bu(e.isMatrix?e.toArray():e,u)),p=t(f,i,d),h=(e,r)=>p([e,...d.slice(1).map((e=>c(e,r)))],r);return a?d[0].map(h):n(d[0],h)}([e,i,...a.slice(0,a.length-1)],a[a.length-1])});function t(e,r,t){switch(e){case 0:return e=>r(...e);case 1:return(e,t)=>r(...e,t);case 2:return(e,n)=>r(...e,n,...t)}}function n(e,r){var t=Iu(r,e,vm);return ku(e,t.fn,t.isUnary)}})),bm="diff",gm=ti(bm,["typed","matrix","subtract","number"],(e=>{var{typed:r,matrix:t,subtract:n,number:i}=e;return r(bm,{"Array | Matrix":function(e){return cn(e)?t(o(e.toArray())):o(e)},"Array | Matrix, number":function(e,r){if(!ii(r))throw new RangeError("Dimension must be a whole number");return cn(e)?t(a(e.toArray(),r)):a(e,r)},"Array, BigNumber":r.referTo("Array,number",(e=>(r,t)=>e(r,i(t)))),"Matrix, BigNumber":r.referTo("Matrix,number",(e=>(r,t)=>e(r,i(t))))});function a(e,r){if(cn(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError("Array/Matrix does not have that many dimensions");if(r>0){var t=[];return e.forEach((e=>{t.push(a(e,r-1))})),t}if(0===r)return o(e);throw RangeError("Cannot have negative dimension")}function o(e){for(var r=[],t=e.length,n=1;n<t;n++)r.push(u(e[n-1],e[n]));return r}function u(e,r){cn(e)&&(e=e.toArray()),cn(r)&&(r=r.toArray());var t=Array.isArray(e),i=Array.isArray(r);if(t&&i)return function(e,r){if(e.length!==r.length)throw RangeError("Not all sub-arrays have the same length");for(var t=[],n=e.length,i=0;i<n;i++)t.push(u(e[i],r[i]));return t}(e,r);if(!t&&!i)return n(r,e);throw TypeError("Cannot calculate difference between 1 array and 1 non-array")}})),xm=ti("ones",["typed","config","matrix","BigNumber"],(e=>{var{typed:r,config:t,matrix:n,BigNumber:i}=e;return r("ones",{"":function(){return"Array"===t.matrix?a([]):a([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var r=e.pop();return a(e,r)}return"Array"===t.matrix?a(e):a(e,"default")},Array:a,Matrix:function(e){var r=e.storage();return a(e.valueOf(),r)},"Array | Matrix, string":function(e,r){return a(e.valueOf(),r)}});function a(e,r){var t=function(e){var r=!1;return e.forEach((function(e,t,n){rn(e)&&(r=!0,n[t]=e.toNumber())})),r}(e),a=t?new i(1):1;if(function(e){e.forEach((function(e){if("number"!=typeof e||!ii(e)||e<0)throw Error("Parameters in function ones must be positive integers")}))}(e),r){var o=n(r);return e.length>0?o.resize(e,a):o}var u=[];return e.length>0?cu(u,e,a):u}}));function wm(){throw Error('No "bignumber" implementation available')}function Dm(){throw Error('No "fraction" implementation available')}function Nm(){throw Error('No "matrix" implementation available')}var Am="range",Mm=ti(Am,["typed","config","?matrix","?bignumber","equal","smaller","smallerEq","larger","largerEq","add","isZero","isPositive"],(e=>{var{typed:r,config:t,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:u,largerEq:s,add:c,isZero:l,isPositive:f}=e;return r(Am,{string:d,"string, boolean":d,number:function(e){throw new TypeError("Too few arguments to function range(): ".concat(e))},boolean:function(e){throw new TypeError("Unexpected type of argument 1 to function range(): ".concat(e,", number|bigint|BigNumber|Fraction"))},"number, number":function(e,r){return m(p(e,r,1,!1))},"number, number, number":function(e,r,t){return m(p(e,r,t,!1))},"number, number, boolean":function(e,r,t){return m(p(e,r,1,t))},"number, number, number, boolean":function(e,r,t,n){return m(p(e,r,t,n))},"bigint, bigint|number":function(e,r){return m(p(e,r,1n,!1))},"number, bigint":function(e,r){return m(p(BigInt(e),r,1n,!1))},"bigint, bigint|number, bigint|number":function(e,r,t){return m(p(e,r,BigInt(t),!1))},"number, bigint, bigint|number":function(e,r,t){return m(p(BigInt(e),r,BigInt(t),!1))},"bigint, bigint|number, boolean":function(e,r,t){return m(p(e,r,1n,t))},"number, bigint, boolean":function(e,r,t){return m(p(BigInt(e),r,1n,t))},"bigint, bigint|number, bigint|number, boolean":function(e,r,t,n){return m(p(e,r,BigInt(t),n))},"number, bigint, bigint|number, boolean":function(e,r,t,n){return m(p(BigInt(e),r,BigInt(t),n))},"BigNumber, BigNumber":function(e,r){return m(p(e,r,new(0,e.constructor)(1),!1))},"BigNumber, BigNumber, BigNumber":function(e,r,t){return m(p(e,r,t,!1))},"BigNumber, BigNumber, boolean":function(e,r,t){return m(p(e,r,new(0,e.constructor)(1),t))},"BigNumber, BigNumber, BigNumber, boolean":function(e,r,t,n){return m(p(e,r,t,n))},"Fraction, Fraction":function(e,r){return m(p(e,r,1,!1))},"Fraction, Fraction, Fraction":function(e,r,t){return m(p(e,r,t,!1))},"Fraction, Fraction, boolean":function(e,r,t){return m(p(e,r,1,t))},"Fraction, Fraction, Fraction, boolean":function(e,r,t,n){return m(p(e,r,t,n))},"Unit, Unit, Unit":function(e,r,t){return m(p(e,r,t,!1))},"Unit, Unit, Unit, boolean":function(e,r,t,n){return m(p(e,r,t,n))}});function m(e){return"Matrix"===t.matrix?n?n(e):Nm():e}function d(e,r){var n=function(e){var r=e.split(":").map((function(e){return Number(e)}));if(r.some((function(e){return isNaN(e)})))return null;switch(r.length){case 2:return{start:r[0],end:r[1],step:1};case 3:return{start:r[0],end:r[2],step:r[1]};default:return null}}(e);if(!n)throw new SyntaxError('String "'+e+'" is no valid range');return"BigNumber"===t.number?(void 0===i&&wm(),m(p(i(n.start),i(n.end),i(n.step)))):m(p(n.start,n.end,n.step,r))}function p(e,r,t,n){var i=[];if(l(t))throw Error("Step must be non-zero");for(var m=f(t)?n?o:a:n?s:u,d=e;m(d,r);)i.push(d),d=c(d,t);return i}})),Cm="reshape",Em=ti(Cm,["typed","isInteger","matrix"],(e=>{var{typed:r,isInteger:t}=e;return r(Cm,{"Matrix, Array":function(e,r){return e.reshape(r,!0)},"Array, Array":function(e,r){return r.forEach((function(e){if(!t(e))throw new TypeError("Invalid size for dimension: "+e)})),fu(e,r)}})})),Sm=ti("resize",["config","matrix"],(e=>{var{config:r,matrix:t}=e;return function(e,n,i){if(2!==arguments.length&&3!==arguments.length)throw new Ul("resize",arguments.length,2,3);if(cn(n)&&(n=n.valueOf()),rn(n[0])&&(n=n.map((function(e){return rn(e)?e.toNumber():e}))),cn(e))return e.resize(n,i,!0);if("string"==typeof e)return function(e,r,t){if(void 0!==t){if("string"!=typeof t||1!==t.length)throw new TypeError("Single character expected as defaultValue")}else t=" ";if(1!==r.length)throw new ru(r.length,1);var n=r[0];if("number"!=typeof n||!ii(n))throw new TypeError("Invalid size, must contain positive integers (size: "+Go(r)+")");if(e.length>n)return e.substring(0,n);if(e.length<n){for(var i=e,a=0,o=n-e.length;a<o;a++)i+=t;return i}return e}(e,n,i);var a=!Array.isArray(e)&&"Array"!==r.matrix;if(0===n.length){for(;Array.isArray(e);)e=e[0];return Wn(e)}Array.isArray(e)||(e=[e]);var o=cu(e=Wn(e),n,i);return a?t(o):o}})),Fm="rotate",Bm=ti(Fm,["typed","multiply","rotationMatrix"],(e=>{var{typed:r,multiply:t,rotationMatrix:n}=e;return r(Fm,{"Array , number | BigNumber | Complex | Unit":function(e,r){return i(e,2),t(n(r),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,r){return i(e,2),t(n(r),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,r,a){return i(e,3),t(n(r,a),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,r,a){return i(e,3),t(n(r,a),e)}});function i(e,r){var t=Array.isArray(e)?nu(e):e.size();if(t.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(r));if(2===t.length&&1!==t[1])throw new RangeError("Vector must be of dimensions 1x".concat(r));if(t[0]!==r)throw new RangeError("Vector must be of dimensions 1x".concat(r))}})),qm="rotationMatrix",Tm=ti(qm,["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],(e=>{var{typed:r,config:t,multiplyScalar:n,addScalar:i,unaryMinus:a,norm:o,BigNumber:u,matrix:s,DenseMatrix:c,SparseMatrix:l,cos:f,sin:m}=e;return r(qm,{"":function(){return"Matrix"===t.matrix?s([]):[]},string:function(e){return s(e)},"number | BigNumber | Complex | Unit":function(e){return d(e,"Matrix"===t.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(e,r){return d(e,r)},"number | BigNumber | Complex | Unit, Array":function(e,r){var t=s(r);return p(t),y(e,t,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,r){p(r);var n=r.storage()||("Matrix"===t.matrix?"dense":void 0);return y(e,r,n)},"number | BigNumber | Complex | Unit, Array, string":function(e,r,t){var n=s(r);return p(n),y(e,n,t)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,r,t){return p(r),y(e,r,t)}});function d(e,r){var t=rn(e)?new u(-1):-1,i=f(e),a=m(e);return v([[i,n(t,a)],[a,i]],r)}function p(e){var r=e.size();if(r.length<1||3!==r[0])throw new RangeError("Vector must be of dimensions 1x3")}function h(e){return e.reduce(((e,r)=>n(e,r)))}function v(e,r){if(r){if("sparse"===r)return new l(e);if("dense"===r)return new c(e);throw new TypeError('Unknown matrix type "'.concat(r,'"'))}return e}function y(e,r,t){var n=o(r);if(0===n)throw new RangeError("Rotation around zero vector");var s=rn(e)?u:null,c=s?new s(1):1,l=s?new s(-1):-1,d=s?new s(r.get([0])/n):r.get([0])/n,p=s?new s(r.get([1])/n):r.get([1])/n,y=s?new s(r.get([2])/n):r.get([2])/n,b=f(e),g=i(c,a(b)),x=m(e);return v([[i(b,h([d,d,g])),i(h([d,p,g]),h([l,y,x])),i(h([d,y,g]),h([p,x]))],[i(h([d,p,g]),h([y,x])),i(b,h([p,p,g])),i(h([p,y,g]),h([l,d,x]))],[i(h([d,y,g]),h([l,p,x])),i(h([p,y,g]),h([d,x])),i(b,h([y,y,g]))]],t)}})),km=ti("row",["typed","Index","matrix","range"],(e=>{var{typed:r,Index:t,matrix:n,range:i}=e;return r("row",{"Matrix, number":a,"Array, number":function(e,r){return a(n(Wn(e)),r).valueOf()}});function a(e,r){if(2!==e.size().length)throw Error("Only two dimensional matrix is supported");uu(r,e.size()[0]);var a=i(0,e.size()[1]),o=new t(r,a),u=e.subset(o);return cn(u)?u:n([[u]])}})),Om="size",Im=ti(Om,["typed","config","?matrix"],(e=>{var{typed:r,config:t,matrix:n}=e;return r(Om,{Matrix:function(e){return e.create(e.size(),"number")},Array:nu,string:function(e){return"Array"===t.matrix?[e.length]:n([e.length],"dense","number")},"number | Complex | BigNumber | Unit | boolean | null":function(){return"Array"===t.matrix?[]:n?n([],"dense","number"):Nm()}})})),zm="squeeze",jm=ti(zm,["typed"],(e=>{var{typed:r}=e;return r(zm,{Array:function(e){return pu(Wn(e))},Matrix:function(e){var r=pu(e.toArray());return Array.isArray(r)?e.create(r,e.datatype()):r},any:function(e){return Wn(e)}})})),Rm="subset",Um=ti(Rm,["typed","matrix","zeros","add"],(e=>{var{typed:r,matrix:t,zeros:n,add:i}=e;return r(Rm,{"Matrix, Index":function(e,r){return su(r)?t():(ou(e,r),e.subset(r))},"Array, Index":r.referTo("Matrix, Index",(function(e){return function(r,n){var i=e(t(r),n);return n.isScalar()?i:i.valueOf()}})),"Object, Index":Lm,"string, Index":$m,"Matrix, Index, any, any":function(e,r,t,a){return su(r)?e:(ou(e,r),e.clone().subset(r,function(e,r){if("string"==typeof e)throw Error("can't boradcast a string");if(r._isScalar)return e;var t=r.size();if(!t.every((e=>e>0)))return e;try{return i(e,n(t))}catch(r){return e}}(t,r),a))},"Array, Index, any, any":r.referTo("Matrix, Index, any, any",(function(e){return function(r,n,i,a){var o=e(t(r),n,i,a);return o.isMatrix?o.valueOf():o}})),"Array, Index, any":r.referTo("Matrix, Index, any, any",(function(e){return function(r,n,i){return e(t(r),n,i,void 0).valueOf()}})),"Matrix, Index, any":r.referTo("Matrix, Index, any, any",(function(e){return function(r,t,n){return e(r,t,n,void 0)}})),"string, Index, string":Pm,"string, Index, string, string":Pm,"Object, Index, any":_m})}));function $m(e,r){if(!pn(r))throw new TypeError("Index expected");if(su(r))return"";if(ou(Array.from(e),r),1!==r.size().length)throw new ru(r.size().length,1);var t=e.length;uu(r.min()[0],t),uu(r.max()[0],t);var n=r.dimension(0),i="";return n.forEach((function(r){i+=e.charAt(r)})),i}function Pm(e,r,t,n){if(!r||!0!==r.isIndex)throw new TypeError("Index expected");if(su(r))return e;if(ou(Array.from(e),r),1!==r.size().length)throw new ru(r.size().length,1);if(void 0!==n){if("string"!=typeof n||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";var i=r.dimension(0);if(i.size()[0]!==t.length)throw new ru(i.size()[0],t.length);var a=e.length;uu(r.min()[0]),uu(r.max()[0]);for(var o=[],u=0;u<a;u++)o[u]=e.charAt(u);if(i.forEach((function(e,r){o[e]=t.charAt(r[0])})),o.length>a)for(var s=a-1,c=o.length;s<c;s++)o[s]||(o[s]=n);return o.join("")}function Lm(e,r){if(!su(r)){if(1!==r.size().length)throw new ru(r.size(),1);var t=r.dimension(0);if("string"!=typeof t)throw new TypeError("String expected as index to retrieve an object property");return _t(e,t)}}function _m(e,r,t){if(su(r))return e;if(1!==r.size().length)throw new ru(r.size(),1);var n=r.dimension(0);if("string"!=typeof n)throw new TypeError("String expected as index to retrieve an object property");var i=Wn(e);return Wt(i,n,t),i}var Wm="transpose",Jm=ti(Wm,["typed","matrix"],(e=>{var{typed:r,matrix:t}=e;return r(Wm,{Array:e=>n(t(e)).valueOf(),Matrix:n,any:Wn});function n(e){var r,t=e.size();switch(t.length){case 1:r=e.clone();break;case 2:var n=t[0],i=t[1];if(0===i)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+Go(t)+")");switch(e.storage()){case"dense":r=function(e,r,t){for(var n,i=e._data,a=[],o=0;o<t;o++){n=a[o]=[];for(var u=0;u<r;u++)n[u]=Wn(i[u][o])}return e.createDenseMatrix({data:a,size:[t,r],datatype:e._datatype})}(e,n,i);break;case"sparse":r=function(e,r,t){for(var n,i,a,o=e._values,u=e._index,s=e._ptr,c=o?[]:void 0,l=[],f=[],m=[],d=0;d<r;d++)m[d]=0;for(n=0,i=u.length;n<i;n++)m[u[n]]++;for(var p=0,h=0;h<r;h++)f.push(p),p+=m[h],m[h]=f[h];for(f.push(p),a=0;a<t;a++)for(var v=s[a+1],y=s[a];y<v;y++){var b=m[u[y]]++;l[b]=a,o&&(c[b]=Wn(o[y]))}return e.createSparseMatrix({values:c,index:l,ptr:f,size:[t,r],datatype:e._datatype})}(e,n,i)}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+Go(t)+")")}return r}})),Vm="ctranspose",Hm=ti(Vm,["typed","transpose","conj"],(e=>{var{typed:r,transpose:t,conj:n}=e;return r(Vm,{any:function(e){return n(t(e))}})})),Zm="zeros",Gm=ti(Zm,["typed","config","matrix","BigNumber"],(e=>{var{typed:r,config:t,matrix:n,BigNumber:i}=e;return r(Zm,{"":function(){return"Array"===t.matrix?a([]):a([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var r=e.pop();return a(e,r)}return"Array"===t.matrix?a(e):a(e,"default")},Array:a,Matrix:function(e){var r=e.storage();return a(e.valueOf(),r)},"Array | Matrix, string":function(e,r){return a(e.valueOf(),r)}});function a(e,r){var t=function(e){var r=!1;return e.forEach((function(e,t,n){rn(e)&&(r=!0,n[t]=e.toNumber())})),r}(e),a=t?new i(0):0;if(function(e){e.forEach((function(e){if("number"!=typeof e||!ii(e)||e<0)throw Error("Parameters in function zeros must be positive integers")}))}(e),r){var o=n(r);return e.length>0?o.resize(e,a):o}var u=[];return e.length>0?cu(u,e,a):u}})),Xm=ti("fft",["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i","dotDivide","conj","pow","ceil","log2"],(e=>{var{typed:r,addScalar:t,multiplyScalar:n,divideScalar:i,exp:a,tau:o,i:u,dotDivide:s,conj:c,pow:l,ceil:f,log2:m}=e;return r("fft",{Array:d,Matrix:function(e){return e.create(d(e.valueOf()),e.datatype())}});function d(e){var r=nu(e);return 1===r.length?h(e):p(e.map((e=>d(e,r.slice(1)))),0)}function p(e,r){var t=nu(e);if(0!==r)return Array(t[0]).fill(0).map(((t,n)=>p(e[n],r-1)));if(1===t.length)return h(e);function n(e){var r=nu(e);return Array(r[1]).fill(0).map(((t,n)=>Array(r[0]).fill(0).map(((r,t)=>e[t][n]))))}return n(p(n(e),1))}function h(e){var r=e.length;if(1===r)return[e[0]];if(r%2==0){for(var p=[...h(e.filter(((e,r)=>r%2==0))),...h(e.filter(((e,r)=>r%2==1)))],v=0;v<r/2;v++){var y=p[v],b=n(p[v+r/2],a(n(n(o,u),i(-v,r))));p[v]=t(y,b),p[v+r/2]=t(y,n(-1,b))}return p}return function(e){for(var r=e.length,t=a(i(n(-1,n(u,o)),r)),p=[],v=1-r;v<r;v++)p.push(l(t,i(l(v,2),2)));for(var y=l(2,f(m(r+r-1))),b=[...Array(r).fill(0).map(((t,i)=>n(e[i],p[r-1+i]))),...Array(y-r).fill(0)],g=[...Array(r+r-1).fill(0).map(((e,r)=>i(1,p[r]))),...Array(y-(r+r-1)).fill(0)],x=h(b),w=h(g),D=Array(y).fill(0).map(((e,r)=>n(x[r],w[r]))),N=s(c(d(c(D))),y),A=[],M=r-1;M<r+r-1;M++)A.push(n(N[M],p[M]));return A}(e)}})),Ym="ifft",Qm=ti(Ym,["typed","fft","dotDivide","conj"],(e=>{var{typed:r,fft:t,dotDivide:n,conj:i}=e;return r(Ym,{"Array | Matrix":function(e){var r=cn(e)?e.size():nu(e);return n(i(t(i(e))),r.reduce(((e,r)=>e*r),1))}})}));function Km(e){return Km="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Km(e)}function ed(e,r,t){return(r=function(e){var r=function(e,r){if("object"!=Km(e)||!e)return e;var t;if("undefined"!=typeof Symbol&&void 0!==(t=e[Symbol.toPrimitive])){var n=t.call(e,r);if("object"!=Km(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return e+""}(e,"string");return"symbol"==Km(r)?r:r+""}(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function rd(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}var td=ti("solveODE",["typed","add","subtract","multiply","divide","max","map","abs","isPositive","isNegative","larger","smaller","matrix","bignumber","unaryMinus"],(e=>{var{typed:r,add:t,subtract:n,multiply:i,divide:a,max:o,map:u,abs:s,isPositive:c,isNegative:l,larger:f,smaller:m,matrix:d,bignumber:p,unaryMinus:h}=e;function v(e){return function(r,d,v,y){if(2!==d.length||!d.every(x)&&!d.every(on))throw Error('"tspan" must be an Array of two numeric values or two units [tStart, tEnd]');var b=d[0],g=d[1],w=f(g,b),D=y.firstStep;if(void 0!==D&&!c(D))throw Error('"firstStep" must be positive');var N=y.maxStep;if(void 0!==N&&!c(N))throw Error('"maxStep" must be positive');var A=y.minStep;if(A&&l(A))throw Error('"minStep" must be positive or zero');var M=[b,g,D,A,N].filter((e=>void 0!==e));if(!M.every(x)&&!M.every(on))throw Error('Inconsistent type of "t" dependant variables');for(var C=y.tol?y.tol:1e-4,E=y.minDelta?y.minDelta:.2,S=y.maxDelta?y.maxDelta:5,F=y.maxIter?y.maxIter:1e4,B=[b,g,...v,N,A].some(rn),[q,T,k,O]=B?[p(e.a),p(e.c),p(e.b),p(e.bp)]:[e.a,e.c,e.b,e.bp],I=D?w?D:h(D):a(n(g,b),1),z=[b],j=[v],R=n(k,O),U=0,$=0,P=function(e){return e?m:f}(w),L=function(e){var r=e?f:m;return function(e,i,a){var o=t(e,a);return r(o,i)?n(i,e):a}}(w);P(z[U],g);){var _=[];I=L(z[U],g,I),_.push(r(z[U],j[U]));for(var W=1;W<T.length;++W)_.push(r(t(z[U],i(T[W],I)),t(j[U],i(I,q[W],_))));var J=o(s(u(i(R,_),(e=>on(e)?e.value:e))));J<C&&C/J>1/4&&(z.push(t(z[U],I)),j.push(t(j[U],i(I,k,_))),U++);var V=.84*(C/J)**.2;if(m(V,E)?V=E:f(V,S)&&(V=S),V=B?p(V):V,I=i(I,V),N&&f(s(I),N)?I=w?N:h(N):A&&m(s(I),A)&&(I=w?A:h(A)),++$>F)throw Error("Maximum number of iterations reached, try changing options")}return{t:z,y:j}}}function y(e,r,t,n){return v({a:[[],[.5],[0,3/4],[2/9,1/3,4/9]],c:[null,.5,3/4,1],b:[2/9,1/3,4/9,0],bp:[7/24,1/4,1/3,1/8]})(e,r,t,n)}function b(e,r,t,n){return v({a:[[],[.2],[3/40,9/40],[44/45,-56/15,32/9],[19372/6561,-25360/2187,64448/6561,-212/729],[9017/3168,-355/33,46732/5247,49/176,-5103/18656],[35/384,0,500/1113,125/192,-2187/6784,11/84]],c:[null,.2,.3,.8,8/9,1,1],b:[35/384,0,500/1113,125/192,-2187/6784,11/84,0],bp:[5179/57600,0,7571/16695,393/640,-92097/339200,187/2100,1/40]})(e,r,t,n)}function g(e,r,t,n){var i=n.method?n.method:"RK45",a={RK23:y,RK45:b};if(i.toUpperCase()in a){var o=function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?rd(Object(t),!0).forEach((function(r){ed(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):rd(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}({},n);return delete o.method,a[i.toUpperCase()](e,r,t,o)}var u=Object.keys(a).map((e=>'"'.concat(e,'"'))),s="".concat(u.slice(0,-1).join(", ")," and ").concat(u.slice(-1));throw Error('Unavailable method "'.concat(i,'". Available methods are ').concat(s))}function x(e){return rn(e)||en(e)}function w(e,r,t,n){var i=g(e,r.toArray(),t.toArray(),n);return{t:d(i.t),y:d(i.y)}}return r("solveODE",{"function, Array, Array, Object":g,"function, Matrix, Matrix, Object":w,"function, Array, Array":(e,r,t)=>g(e,r,t,{}),"function, Matrix, Matrix":(e,r,t)=>w(e,r,t,{}),"function, Array, number | BigNumber | Unit":(e,r,t)=>{var n=g(e,r,[t],{});return{t:n.t,y:n.y.map((e=>e[0]))}},"function, Matrix, number | BigNumber | Unit":(e,r,t)=>{var n=g(e,r.toArray(),[t],{});return{t:d(n.t),y:d(n.y.map((e=>e[0])))}},"function, Array, number | BigNumber | Unit, Object":(e,r,t,n)=>{var i=g(e,r,[t],n);return{t:i.t,y:i.y.map((e=>e[0]))}},"function, Matrix, number | BigNumber | Unit, Object":(e,r,t,n)=>{var i=g(e,r.toArray(),[t],n);return{t:d(i.t),y:d(i.y.map((e=>e[0])))}}})})),nd=ti("erf",["typed"],(e=>{var{typed:r}=e;return r("name",{number:function(e){var r=Math.abs(e);return r>=sd?oi(e):r<=id?oi(e)*function(e){var r,t=e*e,n=od[0][4]*t,i=t;for(r=0;r<3;r+=1)n=(n+od[0][r])*t,i=(i+ud[0][r])*t;return e*(n+od[0][3])/(i+ud[0][3])}(r):r<=4?oi(e)*(1-function(e){var r,t=od[1][8]*e,n=e;for(r=0;r<7;r+=1)t=(t+od[1][r])*e,n=(n+ud[1][r])*e;var i=(t+od[1][7])/(n+ud[1][7]),a=parseInt(16*e)/16,o=(e-a)*(e+a);return Math.exp(-a*a)*Math.exp(-o)*i}(r)):oi(e)*(1-function(e){var r,t=1/(e*e),n=od[2][5]*t,i=t;for(r=0;r<4;r+=1)n=(n+od[2][r])*t,i=(i+ud[2][r])*t;var a=t*(n+od[2][4])/(i+ud[2][4]);a=(ad-a)/e;var o=(e-(t=parseInt(16*e)/16))*(e+t);return Math.exp(-t*t)*Math.exp(-o)*a}(r))},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),id=.46875,ad=.5641895835477563,od=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],ud=[[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]],sd=Math.pow(2,53),cd="zeta",ld=ti(cd,["typed","config","multiply","pow","divide","factorial","equal","smallerEq","isNegative","gamma","sin","subtract","add","?Complex","?BigNumber","pi"],(e=>{var{typed:r,config:t,multiply:n,pow:i,divide:a,factorial:o,equal:u,smallerEq:s,isNegative:c,gamma:l,sin:f,subtract:m,add:d,Complex:p,BigNumber:h,pi:v}=e;return r(cd,{number:e=>y(e,(e=>e),(()=>20)),BigNumber:e=>y(e,(e=>new h(e)),(()=>Math.abs(Math.log10(t.relTol)))),Complex:function(e){return 0===e.re&&0===e.im?new p(-.5):1===e.re?new p(NaN,NaN):e.re===1/0&&0===e.im?new p(1):e.im===1/0||e.re===-1/0?new p(NaN,NaN):b(e,(e=>e),(e=>Math.round(19.5+.9*Math.abs(e.im))),(e=>e.re))}});function y(e,r,t){return u(e,0)?r(-.5):u(e,1)?r(NaN):isFinite(e)?b(e,r,t,(e=>e)):c(e)?r(NaN):r(1)}function b(e,r,t,o){var u=t(e);if(o(e)>-(u-1)/2)return function(e,r,t){for(var o=a(1,n(g(t(0),r),m(1,i(2,m(1,e))))),u=t(0),c=t(1);s(c,r);c=d(c,1))u=d(u,a(n((-1)**(c-1),g(c,r)),i(c,e)));return n(o,u)}(e,r(u),r);var c=n(i(2,e),i(r(v),m(e,1)));return c=n(c,f(n(a(r(v),2),e))),c=n(c,l(m(1,e))),n(c,b(m(1,e),r,t,o))}function g(e,r){for(var t=e,u=e;s(u,r);u=d(u,1)){var c=a(n(o(d(r,m(u,1))),i(4,u)),n(o(m(r,u)),o(n(2,u))));t=d(t,c)}return n(r,t)}})),fd="mode",md=ti(fd,["typed","isNaN","isNumeric"],(e=>{var{typed:r,isNaN:t,isNumeric:n}=e;return r(fd,{"Array | Matrix":i,"...":function(e){return i(e)}});function i(e){if(0===(e=bu(e.valueOf())).length)throw Error("Cannot calculate mode of an empty array");for(var r={},i=[],a=0,o=0;o<e.length;o++){var u=e[o];if(n(u)&&t(u))throw Error("Cannot calculate mode of an array containing NaN values");u in r||(r[u]=0),r[u]++,r[u]===a?i.push(u):r[u]>a&&(a=r[u],i=[u])}return i}}));function dd(e,r,t){var n;return(e+"").includes("Unexpected type")?(n=arguments.length>2?" (type: "+_n(t)+", value: "+JSON.stringify(t)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+r+", unexpected type of argument"+n)):(e+"").includes("complex numbers")?(n=arguments.length>2?" (type: "+_n(t)+", value: "+JSON.stringify(t)+")":"",new TypeError("Cannot calculate "+r+", no ordering relation is defined for complex numbers"+n)):e}var pd="prod",hd=ti(pd,["typed","config","multiplyScalar","numeric"],(e=>{var{typed:r,config:t,multiplyScalar:n,numeric:i}=e;return r(pd,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(){throw Error("prod(A, dim) is not yet supported")},"...":function(e){return a(e)}});function a(e){var r;if(_u(e,(function(e){try{r=void 0===r?e:n(r,e)}catch(r){throw dd(r,"prod",e)}})),"string"==typeof r&&(r=i(r,ai(r,t))),void 0===r)throw Error("Cannot calculate prod of an empty array");return r}})),vd="format",yd=ti(vd,["typed"],(e=>{var{typed:r}=e;return r(vd,{any:Go,"any, Object | function | number | BigNumber":Go})})),bd=ti("bin",["typed","format"],(e=>{var{typed:r,format:t}=e;return r("bin",{"number | BigNumber":function(e){return t(e,{notation:"bin"})},"number | BigNumber, number | BigNumber":function(e,r){return t(e,{notation:"bin",wordSize:r})}})})),gd=ti("oct",["typed","format"],(e=>{var{typed:r,format:t}=e;return r("oct",{"number | BigNumber":function(e){return t(e,{notation:"oct"})},"number | BigNumber, number | BigNumber":function(e,r){return t(e,{notation:"oct",wordSize:r})}})})),xd=ti("hex",["typed","format"],(e=>{var{typed:r,format:t}=e;return r("hex",{"number | BigNumber":function(e){return t(e,{notation:"hex"})},"number | BigNumber, number | BigNumber":function(e,r){return t(e,{notation:"hex",wordSize:r})}})})),wd=/\$([\w.]+)/g,Dd="print",Nd=ti(Dd,["typed"],(e=>{var{typed:r}=e;return r(Dd,{"string, Object | Array":Ad,"string, Object | Array, number | Object":Ad})}));function Ad(e,r,t){return e.replace(wd,(function(e,n){var i=n.split("."),a=r[i.shift()];for(void 0!==a&&a.isMatrix&&(a=a.toArray());i.length&&void 0!==a;){var o=i.shift();a=o?a[o]:a+"."}return void 0!==a?un(a)?a:Go(a,t):e}))}var Md=ti("to",["typed","matrix","concat"],(e=>{var{typed:r,matrix:t,concat:n}=e;return r("to",{"Unit, Unit | string":(e,r)=>e.to(r)},Ol({typed:r,matrix:t,concat:n})({Ds:!0}))})),Cd="toBest",Ed=ti(Cd,["typed"],(e=>{var{typed:r}=e;return r(Cd,{Unit:e=>e.toBest(),"Unit, string":(e,r)=>e.toBest(r.split(",")),"Unit, string, Object":(e,r,t)=>e.toBest(r.split(","),t),"Unit, Array":(e,r)=>e.toBest(r),"Unit, Array, Object":(e,r,t)=>e.toBest(r,t)})})),Sd="isPrime",Fd=ti(Sd,["typed"],(e=>{var{typed:r}=e;return r(Sd,{number:function(e){if(e<=3)return e>1;if(e%2==0||e%3==0)return!1;for(var r=5;r*r<=e;r+=6)if(e%r==0||e%(r+2)==0)return!1;return!0},bigint:function(e){if(e<=3n)return e>1n;if(e%2n===0n||e%3n===0n)return!1;for(var r=5n;r*r<=e;r+=6n)if(e%r===0n||e%(r+2n)===0n)return!1;return!0},BigNumber:function(e){if(e.lte(3))return e.gt(1);if(e.mod(2).eq(0)||e.mod(3).eq(0))return!1;if(e.lt(4294967296)){for(var r=e.toNumber(),t=5;t*t<=r;t+=6)if(r%t==0||r%(t+2)==0)return!1;return!0}function n(e,r,t){for(var n=1;!r.eq(0);)r.mod(2).eq(0)?(r=r.div(2),e=e.mul(e).mod(t)):(r=r.sub(1),n=e.mul(n).mod(t));return n}for(var i=e.constructor.clone({precision:2*e.toFixed(0).length}),a=0,o=(e=new i(e)).sub(1);o.mod(2).eq(0);)o=o.div(2),a+=1;var u=null;if(e.lt("3317044064679887385961981"))u=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter((r=>r<e));else{var s=Math.min(e.toNumber()-2,Math.floor(2*Math.pow(e.toFixed(0).length*Math.log(10),2)));u=[];for(var c=2;c<=s;c+=1)u.push(s)}for(var l=0;l<u.length;l+=1){var f=u[l],m=n(e.sub(e).add(f),o,e);if(!m.eq(1))for(var d=0,p=m;!p.eq(e.sub(1));d+=1,p=p.mul(p).mod(e))if(d===a-1)return!1}return!0},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),Bd=ti("numeric",["number","?bignumber","?fraction"],(e=>{var{number:r,bignumber:t,fraction:n}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},a={number:e=>r(e),BigNumber:t?e=>t(e):wm,bigint:e=>BigInt(e),Fraction:n?e=>n(e):Dm};return function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"number";if(void 0!==(arguments.length>2?arguments[2]:void 0))throw new SyntaxError("numeric() takes one or two arguments");var t=_n(e);if(!(t in i))throw new TypeError("Cannot convert "+e+' of type "'+t+'"; valid input types are '+Object.keys(i).join(", "));if(!(r in a))throw new TypeError("Cannot convert "+e+' to type "'+r+'"; valid output types are '+Object.keys(a).join(", "));return r===t?e:a[r](e)}})),qd="divideScalar",Td=ti(qd,["typed","numeric"],(e=>{var{typed:r}=e;return r(qd,{"number, number":function(e,r){return e/r},"Complex, Complex":function(e,r){return e.div(r)},"BigNumber, BigNumber":function(e,r){return e.div(r)},"bigint, bigint":function(e,r){return e/r},"Fraction, Fraction":function(e,r){return e.div(r)},"Unit, number | Complex | Fraction | BigNumber | Unit":(e,r)=>e.divide(r),"number | Fraction | Complex | BigNumber, Unit":(e,r)=>r.divideInto(e)})})),kd=ti("pow",["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],(e=>{var{typed:r,config:t,identity:n,multiply:i,matrix:a,inv:o,number:u,fraction:s,Complex:c}=e;return r("pow",{"number, number":l,"Complex, Complex":function(e,r){return e.pow(r)},"BigNumber, BigNumber":function(e,r){return r.isInteger()||e>=0||t.predictable?e.pow(r):new c(e.toNumber(),0).pow(r.toNumber(),0)},"bigint, bigint":(e,r)=>e**r,"Fraction, Fraction":function(e,r){var n=e.pow(r);if(null!=n)return n;if(t.predictable)throw Error("Result of pow is non-rational and cannot be expressed as a fraction");return l(e.valueOf(),r.valueOf())},"Array, number":f,"Array, BigNumber":function(e,r){return f(e,r.toNumber())},"Matrix, number":m,"Matrix, BigNumber":function(e,r){return m(e,r.toNumber())},"Unit, number | BigNumber":function(e,r){return e.pow(r)}});function l(e,r){if(t.predictable&&!ii(r)&&e<0)try{var n=s(r),i=u(n);if((r===i||Math.abs((r-i)/r)<1e-14)&&n.d%2n===1n)return(n.n%2n===0n?1:-1)*Math.pow(-e,r)}catch(e){}return t.predictable&&(e<-1&&r===1/0||e>-1&&e<0&&r===-1/0)?NaN:ii(r)||e>=0||t.predictable?vs(e,r):e*e<1&&r===1/0||e*e>1&&r===-1/0?0:new c(e,0).pow(r,0)}function f(e,r){if(!ii(r))throw new TypeError("For A^b, b must be an integer (value is "+r+")");var t=nu(e);if(2!==t.length)throw Error("For A^b, A must be 2 dimensional (A has "+t.length+" dimensions)");if(t[0]!==t[1])throw Error("For A^b, A must be square (size is "+t[0]+"x"+t[1]+")");if(r<0)try{return f(o(e),-r)}catch(e){if("Cannot calculate inverse, determinant is zero"===e.message)throw new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+r+")");throw e}for(var a=n(t[0]).valueOf(),u=e;r>=1;)1&~r||(a=i(u,a)),r>>=1,u=i(u,u);return a}function m(e,r){return a(f(e.valueOf(),r))}})),Od="Number of decimals in function round must be an integer",Id="round",zd=ti(Id,["typed","config","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],(e=>{var{typed:r,config:t,matrix:n,equalScalar:i,zeros:a,BigNumber:o,DenseMatrix:u}=e,s=ul({typed:r,equalScalar:i}),c=sl({typed:r,DenseMatrix:u}),l=cl({typed:r});function f(e){return Math.abs(hi(e).exponent)}return r(Id,{number:function(e){var r=ys(e,f(t.relTol));return ys(xi(e,r,t.relTol,t.absTol)?r:e)},"number, number":function(e,r){var n=f(t.relTol);if(r>=n)return ys(e,r);var i=ys(e,n);return ys(xi(e,i,t.relTol,t.absTol)?i:e,r)},"number, BigNumber":function(e,r){if(!r.isInteger())throw new TypeError(Od);return new o(e).toDecimalPlaces(r.toNumber())},Complex:function(e){return e.round()},"Complex, number":function(e,r){if(r%1)throw new TypeError(Od);return e.round(r)},"Complex, BigNumber":function(e,r){if(!r.isInteger())throw new TypeError(Od);var t=r.toNumber();return e.round(t)},BigNumber:function(e){var r=new o(e).toDecimalPlaces(f(t.relTol));return(cc(e,r,t.relTol,t.absTol)?r:e).toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,r){if(!r.isInteger())throw new TypeError(Od);var n=f(t.relTol);if(r>=n)return e.toDecimalPlaces(r.toNumber());var i=e.toDecimalPlaces(n);return(cc(e,i,t.relTol,t.absTol)?i:e).toDecimalPlaces(r.toNumber())},bigint:e=>e,"bigint, number":e=>e,"bigint, BigNumber":e=>e,Fraction:function(e){return e.round()},"Fraction, number":function(e,r){if(r%1)throw new TypeError(Od);return e.round(r)},"Fraction, BigNumber":function(e,r){if(!r.isInteger())throw new TypeError(Od);return e.round(r.toNumber())},"Unit, number, Unit":r.referToSelf((e=>function(r,t,n){var i=r.toNumeric(n);return n.multiply(e(i,t))})),"Unit, BigNumber, Unit":r.referToSelf((e=>(r,t,n)=>e(r,t.toNumber(),n))),"Array | Matrix, number | BigNumber, Unit":r.referToSelf((e=>(r,t,n)=>Wu(r,(r=>e(r,t,n)),!0))),"Array | Matrix | Unit, Unit":r.referToSelf((e=>(r,t)=>e(r,0,t))),"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e,!0))),"SparseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>s(r,t,e,!1))),"DenseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>l(r,t,e,!1))),"Array, number | BigNumber":r.referToSelf((e=>(r,t)=>l(n(r),t,e,!1).valueOf())),"number | Complex | BigNumber | Fraction, SparseMatrix":r.referToSelf((e=>(r,t)=>i(r,0)?a(t.size(),t.storage()):c(t,r,e,!0))),"number | Complex | BigNumber | Fraction, DenseMatrix":r.referToSelf((e=>(r,t)=>i(r,0)?a(t.size(),t.storage()):l(t,r,e,!0))),"number | Complex | BigNumber | Fraction, Array":r.referToSelf((e=>(r,t)=>l(n(t),r,e,!0).valueOf()))})})),jd=["config","typed","typeOf","divideScalar","Complex"],Rd=Math.log(16),Ud=ti("log",jd,(e=>{var{typed:r,typeOf:t,config:n,divideScalar:i,Complex:a}=e;function o(e){return e.log()}function u(e){return o(new a(e,0))}return r("log",{number:function(e){return e>=0||n.predictable?cs(e):u(e)},bigint:Hl(Rd,cs,n,u),Complex:o,BigNumber:function(e){return!e.isNegative()||n.predictable?e.ln():u(e.toNumber())},"any, any":r.referToSelf((e=>(r,n)=>{if("Fraction"===t(r)&&"Fraction"===t(n)){var a=r.log(n);if(null!==a)return a}return i(e(r),e(n))}))})})),$d="log1p",Pd=ti($d,["typed","config","divideScalar","log","Complex"],(e=>{var{typed:r,config:t,divideScalar:n,log:i,Complex:a}=e;return r($d,{number:function(e){return e>=-1||t.predictable?ci(e):o(new a(e,0))},Complex:o,BigNumber:function(e){var r=e.plus(1);return!r.isNegative()||t.predictable?r.ln():o(new a(e.toNumber(),0))},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e))),"any, any":r.referToSelf((e=>(r,t)=>n(e(r),i(t))))});function o(e){var r=e.re+1;return new a(Math.log(Math.sqrt(r*r+e.im*e.im)),Math.atan2(e.im,r))}})),Ld="nthRoots",_d=ti(Ld,["config","typed","divideScalar","Complex"],(e=>{var{typed:r,Complex:t}=e,n=[function(e){return new t(e,0)},function(e){return new t(0,e)},function(e){return new t(-e,0)},function(e){return new t(0,-e)}];function i(e,r){if(r<0)throw Error("Root must be greater than zero");if(0===r)throw Error("Root must be non-zero");if(r%1!=0)throw Error("Root must be an integer");if(0===e||0===e.abs())return[new t(0,0)];var i,a="number"==typeof e;(a||0===e.re||0===e.im)&&(i=a?2*+(e<0):0===e.im?2*+(e.re<0):2*+(e.im<0)+1);for(var o=e.arg(),u=e.abs(),s=[],c=Math.pow(u,1/r),l=0;l<r;l++){var f=(i+4*l)/r;s.push(f!==Math.round(f)?new t({r:c,phi:(o+2*Math.PI*l)/r}):n[f%4](c))}return s}return r(Ld,{Complex:function(e){return i(e,2)},"Complex, number":i})})),Wd="dotPow",Jd=ti(Wd,["typed","equalScalar","matrix","pow","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,equalScalar:t,matrix:n,pow:i,DenseMatrix:a,concat:o,SparseMatrix:u}=e,s=Bl({typed:r}),c=Of({typed:r,SparseMatrix:u}),l=ul({typed:r,equalScalar:t}),f=sl({typed:r,DenseMatrix:a}),m=Ol({typed:r,matrix:n,concat:o}),d={};for(var p in i.signatures)Object.prototype.hasOwnProperty.call(i.signatures,p)&&(p.includes("Matrix")||p.includes("Array")||(d[p]=i.signatures[p]));var h=r(d);return r(Wd,m({elop:h,SS:c,DS:s,Ss:l,sS:f}))})),Vd="dotDivide",Hd=ti(Vd,["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,matrix:t,equalScalar:n,divideScalar:i,DenseMatrix:a,concat:o,SparseMatrix:u}=e,s=Fl({typed:r,equalScalar:n}),c=Bl({typed:r}),l=Of({typed:r,SparseMatrix:u}),f=ul({typed:r,equalScalar:n}),m=sl({typed:r,DenseMatrix:a}),d=Ol({typed:r,matrix:t,concat:o});return r(Vd,d({elop:i,SS:l,DS:c,SD:s,Ss:f,sS:m}))}));function Zd(e){var{DenseMatrix:r}=e;return function(e,t,n){var i=e.size();if(2!==i.length)throw new RangeError("Matrix must be two dimensional (size: "+Go(i)+")");var a=i[0];if(a!==i[1])throw new RangeError("Matrix must be square (size: "+Go(i)+")");var o=[];if(cn(t)){var u=t.size(),s=t._data;if(1===u.length){if(u[0]!==a)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var c=0;c<a;c++)o[c]=[s[c]];return new r({data:o,size:[a,1],datatype:t._datatype})}if(2===u.length){if(u[0]!==a||1!==u[1])throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");if(fn(t)){if(n){o=[];for(var l=0;l<a;l++)o[l]=[s[l][0]];return new r({data:o,size:[a,1],datatype:t._datatype})}return t}if(mn(t)){for(var f=0;f<a;f++)o[f]=[0];for(var m=t._values,d=t._index,p=t._ptr,h=p[1],v=p[0];v<h;v++)o[d[v]][0]=m[v];return new r({data:o,size:[a,1],datatype:t._datatype})}}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}if(sn(t)){var y=nu(t);if(1===y.length){if(y[0]!==a)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var b=0;b<a;b++)o[b]=[t[b]];return new r({data:o,size:[a,1]})}if(2===y.length){if(y[0]!==a||1!==y[1])throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var g=0;g<a;g++)o[g]=[t[g][0]];return new r({data:o,size:[a,1]})}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}}}var Gd,Xd,Yd="lsolve",Qd=ti(Yd,["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],(e=>{var{typed:r,matrix:t,divideScalar:n,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:u}=e,s=Zd({DenseMatrix:u});return r(Yd,{"SparseMatrix, Array | Matrix":function(e,r){return function(e,r){for(var t=(r=s(e,r,!0))._data,c=e._size[0],l=e._size[1],f=e._values,m=e._index,d=e._ptr,p=[],h=0;h<l;h++){var v=t[h][0]||0;if(o(v,0))p[h]=[0];else{for(var y=0,b=[],g=[],x=d[h+1],w=d[h];w<x;w++){var D=m[w];D===h?y=f[w]:D>h&&(b.push(f[w]),g.push(D))}if(o(y,0))throw Error("Linear system cannot be solved since matrix is singular");for(var N=n(v,y),A=0,M=g.length;A<M;A++){var C=g[A];t[C]=[a(t[C][0]||0,i(N,b[A]))]}p[h]=[N]}}return new u({data:p,size:[c,1]})}(e,r)},"DenseMatrix, Array | Matrix":function(e,r){return c(e,r)},"Array, Array | Matrix":function(e,r){return c(t(e),r).valueOf()}});function c(e,r){for(var t=(r=s(e,r,!0))._data,c=e._size[0],l=e._size[1],f=[],m=e._data,d=0;d<l;d++){var p=t[d][0]||0,h=void 0;if(o(p,0))h=0;else{var v=m[d][d];if(o(v,0))throw Error("Linear system cannot be solved since matrix is singular");h=n(p,v);for(var y=d+1;y<c;y++)t[y]=[a(t[y][0]||0,i(h,m[y][d]))]}f[d]=[h]}return new u({data:f,size:[c,1]})}})),Kd="usolve",ep=ti(Kd,["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],(e=>{var{typed:r,matrix:t,divideScalar:n,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:u}=e,s=Zd({DenseMatrix:u});return r(Kd,{"SparseMatrix, Array | Matrix":function(e,r){return function(e,r){for(var t=(r=s(e,r,!0))._data,c=e._size[0],l=e._values,f=e._index,m=e._ptr,d=[],p=e._size[1]-1;p>=0;p--){var h=t[p][0]||0;if(o(h,0))d[p]=[0];else{for(var v=0,y=[],b=[],g=m[p],x=m[p+1]-1;x>=g;x--){var w=f[x];w===p?v=l[x]:w<p&&(y.push(l[x]),b.push(w))}if(o(v,0))throw Error("Linear system cannot be solved since matrix is singular");for(var D=n(h,v),N=0,A=b.length;N<A;N++){var M=b[N];t[M]=[a(t[M][0],i(D,y[N]))]}d[p]=[D]}}return new u({data:d,size:[c,1]})}(e,r)},"DenseMatrix, Array | Matrix":function(e,r){return c(e,r)},"Array, Array | Matrix":function(e,r){return c(t(e),r).valueOf()}});function c(e,r){for(var t=(r=s(e,r,!0))._data,c=e._size[0],l=[],f=e._data,m=e._size[1]-1;m>=0;m--){var d=t[m][0]||0,p=void 0;if(o(d,0))p=0;else{var h=f[m][m];if(o(h,0))throw Error("Linear system cannot be solved since matrix is singular");p=n(d,h);for(var v=m-1;v>=0;v--)t[v]=[a(t[v][0]||0,i(p,f[v][m]))]}l[m]=[p]}return new u({data:l,size:[c,1]})}})),rp="lsolveAll",tp=ti(rp,["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],(e=>{var{typed:r,matrix:t,divideScalar:n,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:u}=e,s=Zd({DenseMatrix:u});return r(rp,{"SparseMatrix, Array | Matrix":function(e,r){return function(e,r){for(var t=[s(e,r,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._size[1],f=e._values,m=e._index,d=e._ptr,p=0;p<l;p++)for(var h=t.length,v=0;v<h;v++){for(var y=t[v],b=[],g=[],x=d[p+1],w=0,D=d[p];D<x;D++){var N=m[D];N===p?w=f[D]:N>p&&(b.push(f[D]),g.push(N))}if(o(w,0))if(o(y[p],0)){if(0===v){var A=[...y];A[p]=1;for(var M=0,C=g.length;M<C;M++){var E=g[M];A[E]=a(A[E],b[M])}t.push(A)}}else{if(0===v)return[];t.splice(v,1),v-=1,h-=1}else{y[p]=n(y[p],w);for(var S=0,F=g.length;S<F;S++){var B=g[S];y[B]=a(y[B],i(y[p],b[S]))}}}return t.map((e=>new u({data:e.map((e=>[e])),size:[c,1]})))}(e,r)},"DenseMatrix, Array | Matrix":function(e,r){return c(e,r)},"Array, Array | Matrix":function(e,r){return c(t(e),r).map((e=>e.valueOf()))}});function c(e,r){for(var t=[s(e,r,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1],m=0;m<f;m++)for(var d=t.length,p=0;p<d;p++){var h=t[p];if(o(c[m][m],0))if(o(h[m],0)){if(0===p){var v=[...h];v[m]=1;for(var y=m+1;y<f;y++)v[y]=a(v[y],c[y][m]);t.push(v)}}else{if(0===p)return[];t.splice(p,1),p-=1,d-=1}else{h[m]=n(h[m],c[m][m]);for(var b=m+1;b<f;b++)h[b]=a(h[b],i(h[m],c[b][m]))}}return t.map((e=>new u({data:e.map((e=>[e])),size:[l,1]})))}})),np="usolveAll",ip=ti(np,["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],(e=>{var{typed:r,matrix:t,divideScalar:n,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:u}=e,s=Zd({DenseMatrix:u});return r(np,{"SparseMatrix, Array | Matrix":function(e,r){return function(e,r){for(var t=[s(e,r,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._values,f=e._index,m=e._ptr,d=e._size[1]-1;d>=0;d--)for(var p=t.length,h=0;h<p;h++){for(var v=t[h],y=[],b=[],g=m[d],x=0,w=m[d+1]-1;w>=g;w--){var D=f[w];D===d?x=l[w]:D<d&&(y.push(l[w]),b.push(D))}if(o(x,0))if(o(v[d],0)){if(0===h){var N=[...v];N[d]=1;for(var A=0,M=b.length;A<M;A++){var C=b[A];N[C]=a(N[C],y[A])}t.push(N)}}else{if(0===h)return[];t.splice(h,1),h-=1,p-=1}else{v[d]=n(v[d],x);for(var E=0,S=b.length;E<S;E++){var F=b[E];v[F]=a(v[F],i(v[d],y[E]))}}}return t.map((e=>new u({data:e.map((e=>[e])),size:[c,1]})))}(e,r)},"DenseMatrix, Array | Matrix":function(e,r){return c(e,r)},"Array, Array | Matrix":function(e,r){return c(t(e),r).map((e=>e.valueOf()))}});function c(e,r){for(var t=[s(e,r,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1]-1;f>=0;f--)for(var m=t.length,d=0;d<m;d++){var p=t[d];if(o(c[f][f],0))if(o(p[f],0)){if(0===d){var h=[...p];h[f]=1;for(var v=f-1;v>=0;v--)h[v]=a(h[v],c[v][f]);t.push(h)}}else{if(0===d)return[];t.splice(d,1),d-=1,m-=1}else{p[f]=n(p[f],c[f][f]);for(var y=f-1;y>=0;y--)p[y]=a(p[y],i(p[f],c[y][f]))}}return t.map((e=>new u({data:e.map((e=>[e])),size:[l,1]})))}})),ap=ti("matAlgo08xS0Sid",["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return function(e,n,i){var a=e._values,o=e._index,u=e._ptr,s=e._size,c=e._datatype||void 0===e._data?e._datatype:e.getDataType(),l=n._values,f=n._index,m=n._ptr,d=n._size,p=n._datatype||void 0===n._data?n._datatype:n.getDataType();if(s.length!==d.length)throw new ru(s.length,d.length);if(s[0]!==d[0]||s[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+d+")");if(!a||!l)throw Error("Cannot perform operation on Pattern Sparse Matrices");var h,v=s[0],y=s[1],b=t,g=0,x=i;"string"==typeof c&&c===p&&"mixed"!==c&&(b=r.find(t,[h=c,h]),g=r.convert(0,h),x=r.find(i,[h,h]));for(var w,D,N,A=[],M=[],C=[],E=[],S=[],F=0;F<y;F++){C[F]=M.length;var B=F+1;for(D=u[F+1],w=u[F];w<D;w++)S[N=o[w]]=B,E[N]=a[w],M.push(N);for(D=m[F+1],w=m[F];w<D;w++)S[N=f[w]]===B&&(E[N]=x(E[N],l[w]));for(w=C[F];w<M.length;){var q=E[N=M[w]];b(q,g)?M.splice(w,1):(A.push(q),w++)}}return C[y]=M.length,e.createSparseMatrix({values:A,index:M,ptr:C,size:[v,y],datatype:c===e._datatype&&p===n._datatype?h:void 0})}})),op=ti("useMatrixForArrayScalar",["typed","matrix"],(e=>{var{typed:r,matrix:t}=e;return{"Array, number":r.referTo("DenseMatrix, number",(e=>(r,n)=>e(t(r),n).valueOf())),"Array, BigNumber":r.referTo("DenseMatrix, BigNumber",(e=>(r,n)=>e(t(r),n).valueOf())),"number, Array":r.referTo("number, DenseMatrix",(e=>(r,n)=>e(r,t(n)).valueOf())),"BigNumber, Array":r.referTo("BigNumber, DenseMatrix",(e=>(r,n)=>e(r,t(n)).valueOf()))}})),up="leftShift",sp=ti(up,["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,zeros:i,DenseMatrix:a,concat:o}=e,u=zl({typed:r}),s=Fl({typed:r,equalScalar:n}),c=ap({typed:r,equalScalar:n}),l=Rl({typed:r,DenseMatrix:a}),f=ul({typed:r,equalScalar:n}),m=cl({typed:r}),d=Ol({typed:r,matrix:t,concat:o}),p=op({typed:r,matrix:t});return r(up,{"number, number":Ns,"BigNumber, BigNumber":Cf,"bigint, bigint":(e,r)=>e<<r,"SparseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>n(t,0)?r.clone():f(r,t,e,!1))),"DenseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>n(t,0)?r.clone():m(r,t,e,!1))),"number | BigNumber, SparseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):l(t,r,e,!0))),"number | BigNumber, DenseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):m(t,r,e,!0)))},p,d({SS:c,DS:u,SD:s}))})),cp="rightArithShift",lp=ti(cp,["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,zeros:i,DenseMatrix:a,concat:o}=e,u=zl({typed:r}),s=Fl({typed:r,equalScalar:n}),c=ap({typed:r,equalScalar:n}),l=Rl({typed:r,DenseMatrix:a}),f=ul({typed:r,equalScalar:n}),m=cl({typed:r}),d=Ol({typed:r,matrix:t,concat:o}),p=op({typed:r,matrix:t});return r(cp,{"number, number":As,"BigNumber, BigNumber":Ef,"bigint, bigint":(e,r)=>e>>r,"SparseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>n(t,0)?r.clone():f(r,t,e,!1))),"DenseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>n(t,0)?r.clone():m(r,t,e,!1))),"number | BigNumber, SparseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):l(t,r,e,!0))),"number | BigNumber, DenseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):m(t,r,e,!0)))},p,d({SS:c,DS:u,SD:s}))})),fp="rightLogShift",mp=ti(fp,["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,zeros:i,DenseMatrix:a,concat:o}=e,u=zl({typed:r}),s=Fl({typed:r,equalScalar:n}),c=ap({typed:r,equalScalar:n}),l=Rl({typed:r,DenseMatrix:a}),f=ul({typed:r,equalScalar:n}),m=cl({typed:r}),d=Ol({typed:r,matrix:t,concat:o}),p=op({typed:r,matrix:t});return r(fp,{"number, number":Ms,"SparseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>n(t,0)?r.clone():f(r,t,e,!1))),"DenseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>n(t,0)?r.clone():m(r,t,e,!1))),"number | BigNumber, SparseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):l(t,r,e,!0))),"number | BigNumber, DenseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):m(t,r,e,!0)))},p,d({SS:c,DS:u,SD:s}))})),dp=ti("and",["typed","matrix","equalScalar","zeros","not","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,zeros:i,not:a,concat:o}=e,u=Fl({typed:r,equalScalar:n}),s=Jl({typed:r,equalScalar:n}),c=ul({typed:r,equalScalar:n}),l=cl({typed:r}),f=Ol({typed:r,matrix:t,concat:o});return r("and",{"number, number":Is,"Complex, Complex":function(e,r){return!(0===e.re&&0===e.im||0===r.re&&0===r.im)},"BigNumber, BigNumber":function(e,r){return!(e.isZero()||r.isZero()||e.isNaN()||r.isNaN())},"bigint, bigint":Is,"Unit, Unit":r.referToSelf((e=>(r,t)=>e(r.value||0,t.value||0))),"SparseMatrix, any":r.referToSelf((e=>(r,t)=>a(t)?i(r.size(),r.storage()):c(r,t,e,!1))),"DenseMatrix, any":r.referToSelf((e=>(r,t)=>a(t)?i(r.size(),r.storage()):l(r,t,e,!1))),"any, SparseMatrix":r.referToSelf((e=>(r,t)=>a(r)?i(r.size(),r.storage()):c(t,r,e,!0))),"any, DenseMatrix":r.referToSelf((e=>(r,t)=>a(r)?i(r.size(),r.storage()):l(t,r,e,!0))),"Array, any":r.referToSelf((e=>(r,n)=>e(t(r),n).valueOf())),"any, Array":r.referToSelf((e=>(r,n)=>e(r,t(n)).valueOf()))},f({SS:s,DS:u}))})),pp="compare",hp=ti(pp,["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],(e=>{var{typed:r,config:t,equalScalar:n,matrix:i,BigNumber:a,Fraction:o,DenseMatrix:u,concat:s}=e,c=Bl({typed:r}),l=ql({typed:r,equalScalar:n}),f=sl({typed:r,DenseMatrix:u}),m=Ol({typed:r,matrix:i,concat:s}),d=Ac({typed:r});return r(pp,vp({typed:r,config:t}),{"boolean, boolean":function(e,r){return e===r?0:e>r?1:-1},"BigNumber, BigNumber":function(e,r){return cc(e,r,t.relTol,t.absTol)?new a(0):new a(e.cmp(r))},"bigint, bigint":function(e,r){return e===r?0n:e>r?1n:-1n},"Fraction, Fraction":function(e,r){return new o(e.compare(r))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},d,m({SS:l,DS:c,Ss:f}))})),vp=ti(pp,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(pp,{"number, number":function(e,r){return xi(e,r,t.relTol,t.absTol)?0:e>r?1:-1}})})),yp=(Xd||(Xd=1,Gd=function e(r,t){var n,i,a=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,o=/(^[ ]*|[ ]*$)/g,u=/(^([\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,c=/^0/,l=function(r){return e.insensitive&&(""+r).toLowerCase()||""+r},f=l(r).replace(o,"")||"",m=l(t).replace(o,"")||"",d=f.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),p=m.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),h=parseInt(f.match(s),16)||1!==d.length&&f.match(u)&&Date.parse(f),v=parseInt(m.match(s),16)||h&&m.match(u)&&Date.parse(m)||null;if(v){if(h<v)return-1;if(h>v)return 1}for(var y=0,b=Math.max(d.length,p.length);y<b;y++){if(n=!(d[y]||"").match(c)&&parseFloat(d[y])||d[y]||0,i=!(p[y]||"").match(c)&&parseFloat(p[y])||p[y]||0,isNaN(n)!==isNaN(i))return isNaN(n)?1:-1;if(typeof n!=typeof i&&(n+="",i+=""),n<i)return-1;if(n>i)return 1}return 0}),Gd),bp=Xn(yp),gp="compareNatural",xp=ti(gp,["typed","compare"],(e=>{var{typed:r,compare:t}=e,n=t.signatures["boolean,boolean"];return r(gp,{"any, any":function e(r,o){var u,s=_n(r),c=_n(o);if(!("number"!==s&&"BigNumber"!==s&&"Fraction"!==s||"number"!==c&&"BigNumber"!==c&&"Fraction"!==c))return""+(u=t(r,o))!="0"?u>0?1:-1:bp(s,c);var l=["Array","DenseMatrix","SparseMatrix"];if(l.includes(s)||l.includes(c))return 0!==(u=i(e,r,o))?u:bp(s,c);if(s!==c)return bp(s,c);if("Complex"===s)return function(e,r){return e.re>r.re?1:e.re<r.re?-1:e.im>r.im?1:e.im<r.im?-1:0}(r,o);if("Unit"===s)return r.equalBase(o)?e(r.value,o.value):a(e,r.formatUnits(),o.formatUnits());if("boolean"===s)return n(r,o);if("string"===s)return bp(r,o);if("Object"===s)return function(e,r,t){var n=Object.keys(r),i=Object.keys(t);n.sort(bp),i.sort(bp);var o=a(e,n,i);if(0!==o)return o;for(var u=0;u<n.length;u++){var s=e(r[n[u]],t[i[u]]);if(0!==s)return s}return 0}(e,r,o);if("null"===s)return 0;if("undefined"===s)return 0;throw new TypeError('Unsupported type of value "'+s+'"')}});function i(e,r,t){return mn(r)&&mn(t)?a(e,r.toJSON().values,t.toJSON().values):mn(r)?i(e,r.toArray(),t):mn(t)?i(e,r,t.toArray()):fn(r)?i(e,r.toJSON().data,t):fn(t)?i(e,r,t.toJSON().data):Array.isArray(r)?Array.isArray(t)?a(e,r,t):i(e,r,[t]):i(e,[r],t)}function a(e,r,t){for(var n=0,i=Math.min(r.length,t.length);n<i;n++){var a=e(r[n],t[n]);if(0!==a)return a}return r.length>t.length?1:r.length<t.length?-1:0}})),wp="compareText",Dp=["typed","matrix","concat"];eu.signature="any, any";var Np=ti(wp,Dp,(e=>{var{typed:r,matrix:t,concat:n}=e,i=Ol({typed:r,matrix:t,concat:n});return r(wp,eu,i({elop:eu,Ds:!0}))})),Ap="equal",Mp=ti(Ap,["typed","matrix","equalScalar","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,matrix:t,equalScalar:n,DenseMatrix:i,concat:a,SparseMatrix:o}=e,u=Bl({typed:r}),s=Of({typed:r,SparseMatrix:o}),c=sl({typed:r,DenseMatrix:i}),l=Ol({typed:r,matrix:t,concat:a});return r(Ap,Cp({typed:r,equalScalar:n}),l({elop:n,SS:s,DS:u,Ss:c}))})),Cp=ti(Ap,["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return r(Ap,{"any, any":function(e,r){return null===e?null===r:null===r?null===e:void 0===e?void 0===r:void 0===r?void 0===e:t(e,r)}})})),Ep="equalText",Sp=ti(Ep,["typed","compareText","isZero"],(e=>{var{typed:r,compareText:t,isZero:n}=e;return r(Ep,{"any, any":function(e,r){return n(t(e,r))}})})),Fp="smaller",Bp=ti(Fp,["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,config:t,bignumber:n,matrix:i,DenseMatrix:a,concat:o,SparseMatrix:u}=e,s=Bl({typed:r}),c=Of({typed:r,SparseMatrix:u}),l=sl({typed:r,DenseMatrix:a}),f=Ol({typed:r,matrix:i,concat:o}),m=Ac({typed:r});function d(e,r){return e.lt(r)&&!cc(e,r,t.relTol,t.absTol)}return r(Fp,qp({typed:r,config:t}),{"boolean, boolean":(e,r)=>e<r,"BigNumber, BigNumber":d,"bigint, bigint":(e,r)=>e<r,"Fraction, Fraction":(e,r)=>-1===e.compare(r),"Fraction, BigNumber":function(e,r){return d(n(e),r)},"BigNumber, Fraction":function(e,r){return d(e,n(r))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},m,f({SS:c,DS:s,Ss:l}))})),qp=ti(Fp,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(Fp,{"number, number":function(e,r){return e<r&&!xi(e,r,t.relTol,t.absTol)}})})),Tp="smallerEq",kp=ti(Tp,["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i,concat:a,SparseMatrix:o}=e,u=Bl({typed:r}),s=Of({typed:r,SparseMatrix:o}),c=sl({typed:r,DenseMatrix:i}),l=Ol({typed:r,matrix:n,concat:a}),f=Ac({typed:r});return r(Tp,Op({typed:r,config:t}),{"boolean, boolean":(e,r)=>e<=r,"BigNumber, BigNumber":function(e,r){return e.lte(r)||cc(e,r,t.relTol,t.absTol)},"bigint, bigint":(e,r)=>e<=r,"Fraction, Fraction":(e,r)=>1!==e.compare(r),"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},f,l({SS:s,DS:u,Ss:c}))})),Op=ti(Tp,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(Tp,{"number, number":function(e,r){return e<=r||xi(e,r,t.relTol,t.absTol)}})})),Ip="larger",zp=ti(Ip,["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,config:t,bignumber:n,matrix:i,DenseMatrix:a,concat:o,SparseMatrix:u}=e,s=Bl({typed:r}),c=Of({typed:r,SparseMatrix:u}),l=sl({typed:r,DenseMatrix:a}),f=Ol({typed:r,matrix:i,concat:o}),m=Ac({typed:r});function d(e,r){return e.gt(r)&&!cc(e,r,t.relTol,t.absTol)}return r(Ip,jp({typed:r,config:t}),{"boolean, boolean":(e,r)=>e>r,"BigNumber, BigNumber":d,"bigint, bigint":(e,r)=>e>r,"Fraction, Fraction":(e,r)=>1===e.compare(r),"Fraction, BigNumber":function(e,r){return d(n(e),r)},"BigNumber, Fraction":function(e,r){return d(e,n(r))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},m,f({SS:c,DS:s,Ss:l}))})),jp=ti(Ip,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(Ip,{"number, number":function(e,r){return e>r&&!xi(e,r,t.relTol,t.absTol)}})})),Rp="largerEq",Up=ti(Rp,["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i,concat:a,SparseMatrix:o}=e,u=Bl({typed:r}),s=Of({typed:r,SparseMatrix:o}),c=sl({typed:r,DenseMatrix:i}),l=Ol({typed:r,matrix:n,concat:a}),f=Ac({typed:r});return r(Rp,$p({typed:r,config:t}),{"boolean, boolean":(e,r)=>e>=r,"BigNumber, BigNumber":function(e,r){return e.gte(r)||cc(e,r,t.relTol,t.absTol)},"bigint, bigint":function(e,r){return e>=r},"Fraction, Fraction":(e,r)=>-1!==e.compare(r),"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},f,l({SS:s,DS:u,Ss:c}))})),$p=ti(Rp,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(Rp,{"number, number":function(e,r){return e>=r||xi(e,r,t.relTol,t.absTol)}})})),Pp="deepEqual",Lp=ti(Pp,["typed","equal"],(e=>{var{typed:r,equal:t}=e;return r(Pp,{"any, any":function(e,r){return n(e.valueOf(),r.valueOf())}});function n(e,r){if(Array.isArray(e)){if(Array.isArray(r)){var i=e.length;if(i!==r.length)return!1;for(var a=0;a<i;a++)if(!n(e[a],r[a]))return!1;return!0}return!1}return!Array.isArray(r)&&t(e,r)}})),_p="unequal",Wp=ti(_p,["typed","config","equalScalar","matrix","DenseMatrix","concat","SparseMatrix"],(e=>{var{typed:r,equalScalar:t,matrix:n,DenseMatrix:i,concat:a,SparseMatrix:o}=e,u=Bl({typed:r}),s=Of({typed:r,SparseMatrix:o}),c=sl({typed:r,DenseMatrix:i}),l=Ol({typed:r,matrix:n,concat:a});return r(_p,Jp({typed:r,equalScalar:t}),l({elop:function(e,r){return!t(e,r)},SS:s,DS:u,Ss:c}))})),Jp=ti(_p,["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return r(_p,{"any, any":function(e,r){return null===e?null!==r:null===r?null!==e:void 0===e?void 0!==r:void 0===r?void 0!==e:!t(e,r)}})})),Vp="partitionSelect",Hp=ti(Vp,["typed","isNumeric","isNaN","compare"],(e=>{var{typed:r,isNumeric:t,isNaN:n,compare:i}=e,a=i,o=(e,r)=>-i(e,r);return r(Vp,{"Array | Matrix, number":function(e,r){return u(e,r,a)},"Array | Matrix, number, string":function(e,r,t){if("asc"===t)return u(e,r,a);if("desc"===t)return u(e,r,o);throw Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":u});function u(e,r,t){if(!ii(r)||r<0)throw Error("k must be a non-negative integer");if(cn(e)){if(e.size().length>1)throw Error("Only one dimensional matrices supported");return s(e.valueOf(),r,t)}if(Array.isArray(e))return s(e,r,t)}function s(e,r,i){if(r>=e.length)throw Error("k out of bounds");for(var a=0;a<e.length;a++)if(t(e[a])&&n(e[a]))return e[a];for(var o=0,u=e.length-1;o<u;){for(var s=o,c=u,l=e[Math.floor(Math.random()*(u-o+1))+o];s<c;)if(i(e[s],l)>=0){var f=e[c];e[c]=e[s],e[s]=f,--c}else++s;i(e[s],l)>0&&--s,r<=s?u=s:o=s+1}return e[r]}})),Zp="sort",Gp=ti(Zp,["typed","matrix","compare","compareNatural"],(e=>{var{typed:r,matrix:t,compare:n,compareNatural:i}=e,a=n,o=(e,r)=>-n(e,r);return r(Zp,{Array:function(e){return s(e),e.sort(a)},Matrix:function(e){return c(e),t(e.toArray().sort(a),e.storage())},"Array, function":function(e,r){return s(e),e.sort(r)},"Matrix, function":function(e,r){return c(e),t(e.toArray().sort(r),e.storage())},"Array, string":function(e,r){return s(e),e.sort(u(r))},"Matrix, string":function(e,r){return c(e),t(e.toArray().sort(u(r)),e.storage())}});function u(e){if("asc"===e)return a;if("desc"===e)return o;if("natural"===e)return i;throw Error('String "asc", "desc", or "natural" expected')}function s(e){if(1!==nu(e).length)throw Error("One dimensional array expected")}function c(e){if(1!==e.size().length)throw Error("One dimensional matrix expected")}})),Xp=ti("max",["typed","config","numeric","larger","isNaN"],(e=>{var{typed:r,config:t,numeric:n,larger:i,isNaN:a}=e;return r("max",{"Array | Matrix":u,"Array | Matrix, number | BigNumber":function(e,r){return Ju(e,r.valueOf(),o)},"...":function(e){if(Lu(e))throw new TypeError("Scalar values expected in function max");return u(e)}});function o(e,r){try{return i(e,r)?e:r}catch(e){throw dd(e,"max",r)}}function u(e){var r;if(_u(e,(function(e){try{(a(e)||void 0===r||i(e,r))&&(r=e)}catch(r){throw dd(r,"max",e)}})),void 0===r)throw Error("Cannot calculate max of an empty array");return"string"==typeof r&&(r=n(r,ai(r,t))),r}})),Yp=ti("min",["typed","config","numeric","smaller","isNaN"],(e=>{var{typed:r,config:t,numeric:n,smaller:i,isNaN:a}=e;return r("min",{"Array | Matrix":u,"Array | Matrix, number | BigNumber":function(e,r){return Ju(e,r.valueOf(),o)},"...":function(e){if(Lu(e))throw new TypeError("Scalar values expected in function min");return u(e)}});function o(e,r){try{return i(e,r)?e:r}catch(e){throw dd(e,"min",r)}}function u(e){var r;if(_u(e,(function(e){try{(a(e)||void 0===r||i(e,r))&&(r=e)}catch(r){throw dd(r,"min",e)}})),void 0===r)throw Error("Cannot calculate min of an empty array");return"string"==typeof r&&(r=n(r,ai(r,t))),r}})),Qp=ti("ImmutableDenseMatrix",["smaller","DenseMatrix"],(e=>{var{smaller:r,DenseMatrix:t}=e;function n(e,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(r&&!un(r))throw Error("Invalid datatype: "+r);if(cn(e)||sn(e)){var i=new t(e,r);this._data=i._data,this._size=i._size,this._datatype=i._datatype,this._min=null,this._max=null}else if(e&&sn(e.data)&&sn(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=void 0!==e.min?e.min:null,this._max=void 0!==e.max?e.max:null;else{if(e)throw new TypeError("Unsupported type of data ("+_n(e)+")");this._data=[],this._size=[0],this._datatype=r,this._min=null,this._max=null}}return(n.prototype=new t).type="ImmutableDenseMatrix",n.prototype.isImmutableDenseMatrix=!0,n.prototype.subset=function(e){switch(arguments.length){case 1:var r=t.prototype.subset.call(this,e);return cn(r)?new n({data:r._data,size:r._size,datatype:r._datatype}):r;case 2:case 3:throw Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.set=function(){throw Error("Cannot invoke set on an Immutable Matrix instance")},n.prototype.resize=function(){throw Error("Cannot invoke resize on an Immutable Matrix instance")},n.prototype.reshape=function(){throw Error("Cannot invoke reshape on an Immutable Matrix instance")},n.prototype.clone=function(){return new n({data:Wn(this._data),size:Wn(this._size),datatype:this._datatype})},n.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.fromJSON=function(e){return new n(e)},n.prototype.swapRows=function(){throw Error("Cannot invoke swapRows on an Immutable Matrix instance")},n.prototype.min=function(){if(null===this._min){var e=null;this.forEach((function(t){(null===e||r(t,e))&&(e=t)})),this._min=null!==e?e:void 0}return this._min},n.prototype.max=function(){if(null===this._max){var e=null;this.forEach((function(t){(null===e||r(e,t))&&(e=t)})),this._max=null!==e?e:void 0}return this._max},n}),{isClass:!0}),Kp=ti("Index",["ImmutableDenseMatrix","getMatrixDataType"],(e=>{var{ImmutableDenseMatrix:r,getMatrixDataType:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._sourceSize=[],this._isScalar=!0;for(var r=0,a=arguments.length;r<a;r++){var o=arguments[r],u=sn(o),s=cn(o),c=typeof o,l=null;if(dn(o))this._dimensions.push(o),this._isScalar=!1;else if(u||s){var f=void 0;"boolean"===t(o)?(u&&(f=i(eh(o).valueOf())),s&&(f=i(eh(o._data).valueOf())),l=o.valueOf().length):f=i(o.valueOf()),this._dimensions.push(f);var m=f.size();1===m.length&&1===m[0]&&null===l||(this._isScalar=!1)}else if("number"===c)this._dimensions.push(i([o]));else if("bigint"===c)this._dimensions.push(i([Number(o)]));else{if("string"!==c)throw new TypeError("Dimension must be an Array, Matrix, number, bigint, string, or Range");this._dimensions.push(o)}this._sourceSize.push(l)}}function i(e){for(var t=0,n=e.length;t<n;t++)if("number"!=typeof e[t]||!ii(e[t]))throw new TypeError("Index parameters must be positive integer numbers");return new r(e)}return n.prototype.type="Index",n.prototype.isIndex=!0,n.prototype.clone=function(){var e=new n;return e._dimensions=Wn(this._dimensions),e._isScalar=this._isScalar,e._sourceSize=this._sourceSize,e},n.create=function(e){var r=new n;return n.apply(r,e),r},n.prototype.size=function(){for(var e=[],r=0,t=this._dimensions.length;r<t;r++){var n=this._dimensions[r];e[r]="string"==typeof n?1:n.size()[0]}return e},n.prototype.max=function(){for(var e=[],r=0,t=this._dimensions.length;r<t;r++){var n=this._dimensions[r];e[r]="string"==typeof n?n:n.max()}return e},n.prototype.min=function(){for(var e=[],r=0,t=this._dimensions.length;r<t;r++){var n=this._dimensions[r];e[r]="string"==typeof n?n:n.min()}return e},n.prototype.forEach=function(e){for(var r=0,t=this._dimensions.length;r<t;r++)e(this._dimensions[r],r,this)},n.prototype.dimension=function(e){return"number"!=typeof e?null:this._dimensions[e]||null},n.prototype.isObjectProperty=function(){return 1===this._dimensions.length&&"string"==typeof this._dimensions[0]},n.prototype.getObjectProperty=function(){return this.isObjectProperty()?this._dimensions[0]:null},n.prototype.isScalar=function(){return this._isScalar},n.prototype.toArray=function(){for(var e=[],r=0,t=this._dimensions.length;r<t;r++){var n=this._dimensions[r];e.push("string"==typeof n?n:n.toArray())}return e},n.prototype.valueOf=n.prototype.toArray,n.prototype.toString=function(){for(var e=[],r=0,t=this._dimensions.length;r<t;r++){var n=this._dimensions[r];e.push("string"==typeof n?JSON.stringify(n):""+n)}return"["+e.join(", ")+"]"},n.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},n.fromJSON=function(e){return n.create(e.dimensions)},n}),{isClass:!0});function eh(e){var r=[];return e.forEach(((e,t)=>{e&&r.push(t)})),r}var rh=ti("FibonacciHeap",["smaller","larger"],(e=>{var{smaller:r,larger:t}=e;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}function i(e,r,t){r.left.right=r.right,r.right.left=r.left,t.degree--,t.child===r&&(t.child=r.right),0===t.degree&&(t.child=null),r.left=e,r.right=e.right,e.right=r,r.right.left=r,r.parent=null,r.mark=!1}function a(e,r){var t=r.parent;t&&(r.mark?(i(e,r,t),a(t)):r.mark=!0)}n.prototype.type="FibonacciHeap",n.prototype.isFibonacciHeap=!0,n.prototype.insert=function(e,t){var n={key:e,value:t,degree:0};if(this._minimum){var i=this._minimum;n.left=i,n.right=i.right,i.right=n,n.right.left=n,r(e,i.key)&&(this._minimum=n)}else n.left=n,n.right=n,this._minimum=n;return this._size++,n},n.prototype.size=function(){return this._size},n.prototype.clear=function(){this._minimum=null,this._size=0},n.prototype.isEmpty=function(){return 0===this._size},n.prototype.extractMinimum=function(){var e=this._minimum;if(null===e)return e;for(var n=this._minimum,i=e.degree,a=e.child;i>0;){var u=a.right;a.left.right=a.right,a.right.left=a.left,a.left=n,a.right=n.right,n.right=a,a.right.left=a,a.parent=null,a=u,i--}return e.left.right=e.right,e.right.left=e.left,n=e===e.right?null:function(e,n){var i,a=Math.floor(2.0780869212350273*Math.log(n))+1,u=Array(a),s=0,c=e;if(c)for(s++,c=c.right;c!==e;)s++,c=c.right;for(;s>0;){for(var l=c.degree,f=c.right;i=u[l];){if(t(c.key,i.key)){var m=i;i=c,c=m}o(i,c),u[l]=null,l++}u[l]=c,c=f,s--}e=null;for(var d=0;d<a;d++)(i=u[d])&&(e?(i.left.right=i.right,i.right.left=i.left,i.left=e,i.right=e.right,e.right=i,i.right.left=i,r(i.key,e.key)&&(e=i)):e=i);return e}(n=e.right,this._size),this._size--,this._minimum=n,e},n.prototype.remove=function(e){this._minimum=function(e,t){t.key=-1;var n=t.parent;return n&&r(t.key,n.key)&&(i(e,t,n),a(e,n)),r(t.key,e.key)&&(e=t),e}(this._minimum,e),this.extractMinimum()};var o=function(e,r){e.left.right=e.right,e.right.left=e.left,e.parent=r,r.child?(e.left=r.child,e.right=r.child.right,r.child.right=e,e.right.left=e):(r.child=e,e.right=e,e.left=e),r.degree++,e.mark=!1};return n}),{isClass:!0}),th=ti("Spa",["addScalar","equalScalar","FibonacciHeap"],(e=>{var{addScalar:r,equalScalar:t,FibonacciHeap:n}=e;function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new n}return i.prototype.type="Spa",i.prototype.isSpa=!0,i.prototype.set=function(e,r){if(this._values[e])this._values[e].value=r;else{var t=this._heap.insert(e,r);this._values[e]=t}},i.prototype.get=function(e){var r=this._values[e];return r?r.value:0},i.prototype.accumulate=function(e,t){var n=this._values[e];n?n.value=r(n.value,t):(n=this._heap.insert(e,t),this._values[e]=n)},i.prototype.forEach=function(e,r,n){var i=this._heap,a=this._values,o=[],u=i.extractMinimum();for(u&&o.push(u);u&&u.key<=r;)u.key>=e&&(t(u.value,0)||n(u.key,u.value,this)),(u=i.extractMinimum())&&o.push(u);for(var s=0;s<o.length;s++){var c=o[s];a[(u=i.insert(c.key,c.value)).key]=u}},i.prototype.swap=function(e,r){var t=this._values[e],n=this._values[r];if(!t&&n)t=this._heap.insert(e,n.value),this._heap.remove(n),this._values[e]=t,this._values[r]=void 0;else if(t&&!n)n=this._heap.insert(r,t.value),this._heap.remove(t),this._values[r]=n,this._values[e]=void 0;else if(t&&n){var i=t.value;t.value=n.value,n.value=i}},i}),{isClass:!0});function nh(e){var r=0,t=1,n=Object.create(null),i=Object.create(null),a=0,o=function(e){var o=i[e];if(o&&(delete n[o],delete i[e],--r,t===o)){if(!r)return a=0,void(t=1);for(;!Object.prototype.hasOwnProperty.call(n,++t););}};return e=Math.abs(e),{hit:function(u){var s=i[u],c=++a;if(n[c]=u,i[u]=c,!s){if(++r<=e)return;return o(u=n[t]),u}if(delete n[s],t===s)for(;!Object.prototype.hasOwnProperty.call(n,++t););},delete:o,clear:function(){r=a=0,t=1,n=Object.create(null),i=Object.create(null)}}}function ih(e){var{hasher:r,limit:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t=null==t?1/0:t,r=null==r?JSON.stringify:r,function n(){"object"!=typeof n.cache&&(n.cache={values:new Map,lru:nh(t||1/0)});for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];var o=r(i);if(n.cache.values.has(o))return n.cache.lru.hit(o),n.cache.values.get(o);var u=e.apply(e,i);return n.cache.values.set(o,u),n.cache.values.delete(n.cache.lru.hit(o)),u}}var ah=ih((function(e){return new e(1).exp()}),{hasher:ch}),oh=ih((function(e){return new e(1).plus(new e(5).sqrt()).div(2)}),{hasher:ch}),uh=ih((function(e){return e.acos(-1)}),{hasher:ch}),sh=ih((function(e){return uh(e).times(2)}),{hasher:ch});function ch(e){return e[0].precision}function lh(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function fh(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?lh(Object(t),!0).forEach((function(r){ed(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):lh(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var mh=ti("Unit",["?on","config","addScalar","subtractScalar","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","toBest","number","Complex","BigNumber","Fraction"],(e=>{var r,t,n,{on:i,config:a,addScalar:o,subtractScalar:u,multiplyScalar:s,divideScalar:c,pow:l,abs:f,fix:m,round:d,equal:p,isNumeric:h,format:v,number:y,Complex:b,BigNumber:g,Fraction:x}=e,w=y;function D(e,r){if(!(this instanceof D))throw Error("Constructor must be called with the new operator");if(null!=e&&!h(e)&&!nn(e))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(this.fixPrefix=!1,this.skipAutomaticSimplification=!0,void 0===r)this.units=[],this.dimensions=I.map((()=>0));else if("string"==typeof r){var t=D.parse(r);this.units=t.units,this.dimensions=t.dimensions}else{if(!on(r)||null!==r.value)throw new TypeError("Second parameter in Unit constructor must be a string or valueless Unit");this.fixPrefix=r.fixPrefix,this.skipAutomaticSimplification=r.skipAutomaticSimplification,this.dimensions=r.dimensions.slice(0),this.units=r.units.map((e=>Pt({},e)))}this.value=this._normalize(e)}function N(){for(;" "===n||"\t"===n;)M()}function A(e){return e>="0"&&e<="9"}function M(){t++,n=r.charAt(t)}function C(e){n=r.charAt(t=e)}function E(){var e="",r=t;if("+"===n?M():"-"===n&&(e+=n,M()),!function(e){return e>="0"&&e<="9"||"."===e}(n))return C(r),null;if("."===n){if(e+=n,M(),!A(n))return C(r),null}else{for(;A(n);)e+=n,M();"."===n&&(e+=n,M())}for(;A(n);)e+=n,M();if("E"===n||"e"===n){var i="",a=t;if(i+=n,M(),"+"!==n&&"-"!==n||(i+=n,M()),!A(n))return C(a),e;for(e+=i;A(n);)e+=n,M()}return e}function S(){for(var e="";A(n)||D.isValidAlpha(n);)e+=n,M();var r=e.charAt(0);return D.isValidAlpha(r)?e:null}function F(e){return n===e?(M(),e):null}Object.defineProperty(D,"name",{value:"Unit"}),D.prototype.constructor=D,D.prototype.type="Unit",D.prototype.isUnit=!0,D.parse=function(e,i){if(i=i||{},t=-1,n="","string"!=typeof(r=e))throw new TypeError("Invalid argument in Unit.parse, string expected");var o=new D;o.units=[];var u=1,s=!1;M(),N();var c=E(),l=null;if(c){if("BigNumber"===a.number)l=new g(c);else if("Fraction"===a.number)try{l=new x(c)}catch(e){l=parseFloat(c)}else l=parseFloat(c);N(),F("*")?(u=1,s=!0):F("/")&&(u=-1,s=!0)}for(var f=[],m=1;;){for(N();"("===n;)f.push(u),m*=u,u=1,M(),N();var d;if(!n)break;var p=n;if(null===(d=S()))throw new SyntaxError('Unexpected "'+p+'" in "'+r+'" at index '+t);var h=B(d);if(null===h)throw new SyntaxError('Unit "'+d+'" not found.');var v=u*m;if(N(),F("^")){N();var y=E();if(null===y)throw new SyntaxError('In "'+e+'", "^" must be followed by a floating-point number');v*=y}o.units.push({unit:h.unit,prefix:h.prefix,power:v});for(var b=0;b<I.length;b++)o.dimensions[b]+=(h.unit.dimensions[b]||0)*v;for(N();")"===n;){if(0===f.length)throw new SyntaxError('Unmatched ")" in "'+r+'" at index '+t);m/=f.pop(),M(),N()}s=!1,F("*")?(u=1,s=!0):F("/")?(u=-1,s=!0):u=1,h.unit.base&&(L.auto[h.unit.base.key]={unit:h.unit,prefix:h.prefix})}if(N(),n)throw new SyntaxError('Could not parse: "'+e+'"');if(s)throw new SyntaxError('Trailing characters: "'+e+'"');if(0!==f.length)throw new SyntaxError('Unmatched "(" in "'+r+'"');if(0===o.units.length&&!i.allowNoUnits)throw new SyntaxError('"'+e+'" contains no units');return o.value=void 0!==l?o._normalize(l):null,o},D.prototype.clone=function(){var e=new D;e.fixPrefix=this.fixPrefix,e.skipAutomaticSimplification=this.skipAutomaticSimplification,e.value=Wn(this.value),e.dimensions=this.dimensions.slice(0),e.units=[];for(var r=0;r<this.units.length;r++)for(var t in e.units[r]={},this.units[r])Hn(this.units[r],t)&&(e.units[r][t]=this.units[r][t]);return e},D.prototype.valueType=function(){return _n(this.value)},D.prototype._isDerived=function(){return 0!==this.units.length&&(this.units.length>1||Math.abs(this.units[0].power-1)>1e-15)},D.prototype._normalize=function(e){if(null==e||0===this.units.length)return e;for(var r=e,t=D._getNumberConverter(_n(e)),n=0;n<this.units.length;n++){var i=t(this.units[n].unit.value),a=t(this.units[n].prefix.value),o=t(this.units[n].power);r=s(r,l(s(i,a),o))}return r},D.prototype._denormalize=function(e){if(null==e||0===this.units.length)return e;for(var r=e,t=D._getNumberConverter(_n(e)),n=0;n<this.units.length;n++){var i=t(this.units[n].unit.value),a=t(this.units[n].prefix.value),o=t(this.units[n].power);r=c(r,l(s(i,a),o))}return r};var B=ih((e=>{if(Hn(U,e)){var r=U[e];return{unit:r,prefix:r.prefixes[""]}}for(var t in U)if(Hn(U,t)&&Zo(e,t)){var n=U[t],i=e.substring(0,e.length-t.length),a=Hn(n.prefixes,i)?n.prefixes[i]:void 0;if(void 0!==a)return{unit:n,prefix:a}}return null}),{hasher:e=>e[0],limit:100});function q(e){return e.equalBase(z.NONE)&&null!==e.value&&!a.predictable?e.value:e}function T(e){return D._getNumberConverter(_n(e))(1)}function k(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=e.skipAutomaticSimplification||null===e.value?e.clone():e.simplify();!function(e){var r=!1;for(var t in null!=e.value&&nn(e.value)&&(r=Math.abs(e.value.re)<1e-14),e.units)Hn(e.units,t)&&e.units[t].unit&&("VA"===e.units[t].unit.name&&r?e.units[t].unit=U.VAR:"VAR"!==e.units[t].unit.name||r||(e.units[t].unit=U.VA))}(t),function(e,r){1!==e.units.length||e.fixPrefix||Math.abs(e.units[0].power-Math.round(e.units[0].power))<1e-14&&(e.units[0].prefix=e._bestPrefix(r))}(t,r.offset);var n=t._denormalize(t.value),i=null!==t.value?v(n,r||{}):"",a=t.formatUnits();return{simp:t,valueStr:i,unitStr:a}}D.isValuelessUnit=function(e){return null!==B(e)},D.prototype.hasBase=function(e){if("string"==typeof e&&(e=z[e]),!e)return!1;for(var r=0;r<I.length;r++)if(Math.abs((this.dimensions[r]||0)-(e.dimensions[r]||0))>1e-12)return!1;return!0},D.prototype.equalBase=function(e){for(var r=0;r<I.length;r++)if(Math.abs((this.dimensions[r]||0)-(e.dimensions[r]||0))>1e-12)return!1;return!0},D.prototype.equals=function(e){return this.equalBase(e)&&p(this.value,e.value)},D.prototype.multiply=function(e){for(var r=this.clone(),t=on(e)?e:new D(e),n=0;n<I.length;n++)r.dimensions[n]=(this.dimensions[n]||0)+(t.dimensions[n]||0);for(var i=0;i<t.units.length;i++){var a=fh({},t.units[i]);r.units.push(a)}if(null!==this.value||null!==t.value){var o=null===this.value?this._normalize(T(t.value)):this.value,u=null===t.value?t._normalize(T(this.value)):t.value;r.value=s(o,u)}else r.value=null;return on(e)&&(r.skipAutomaticSimplification=!1),q(r)},D.prototype.divideInto=function(e){return new D(e).divide(this)},D.prototype.divide=function(e){for(var r=this.clone(),t=on(e)?e:new D(e),n=0;n<I.length;n++)r.dimensions[n]=(this.dimensions[n]||0)-(t.dimensions[n]||0);for(var i=0;i<t.units.length;i++){var a=fh(fh({},t.units[i]),{},{power:-t.units[i].power});r.units.push(a)}if(null!==this.value||null!==t.value){var o=null===this.value?this._normalize(T(t.value)):this.value,u=null===t.value?t._normalize(T(this.value)):t.value;r.value=c(o,u)}else r.value=null;return on(e)&&(r.skipAutomaticSimplification=!1),q(r)},D.prototype.pow=function(e){for(var r=this.clone(),t=0;t<I.length;t++)r.dimensions[t]=(this.dimensions[t]||0)*e;for(var n=0;n<r.units.length;n++)r.units[n].power*=e;return r.value=null!==r.value?l(r.value,e):null,r.skipAutomaticSimplification=!1,q(r)},D.prototype.abs=function(){var e=this.clone();if(null!==e.value)if(e._isDerived()||0===e.units.length||0===e.units[0].unit.offset)e.value=f(e.value);else{var r=e._numberConverter(),t=r(e.units[0].unit.value),n=r(e.units[0].unit.offset),i=s(t,n);e.value=u(f(o(e.value,i)),i)}for(var a in e.units)"VA"!==e.units[a].unit.name&&"VAR"!==e.units[a].unit.name||(e.units[a].unit=U.W);return e},D.prototype.to=function(e){var r,t=null===this.value?this._normalize(1):this.value;if("string"==typeof e)r=D.parse(e);else{if(!on(e))throw Error("String or Unit expected as parameter");r=e.clone()}if(!this.equalBase(r))throw Error("Units do not match ('".concat(""+r,"' != '").concat(""+this,"')"));if(null!==r.value)throw Error("Cannot convert to a unit with a value");if(null===this.value||this._isDerived()||0===this.units.length||0===r.units.length||this.units[0].unit.offset===r.units[0].unit.offset)r.value=Wn(t);else{var n=D._getNumberConverter(_n(t)),i=s(this.units[0].unit.value,this.units[0].unit.offset),a=s(r.units[0].unit.value,r.units[0].unit.offset);r.value=o(t,n(u(i,a)))}return r.fixPrefix=!0,r.skipAutomaticSimplification=!0,r},D.prototype.toNumber=function(e){return w(this.toNumeric(e))},D.prototype.toNumeric=function(e){var r;return(r=e?this.to(e):this.clone())._isDerived()||0===r.units.length?r._denormalize(r.value):r._denormalize(r.value,r.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.units.length>0?this.formatUnits():null,fixPrefix:this.fixPrefix}},D.fromJSON=function(e){var r,t=new D(e.value,null!==(r=e.unit)&&void 0!==r?r:void 0);return t.fixPrefix=e.fixPrefix||!1,t},D.prototype.valueOf=D.prototype.toString,D.prototype.simplify=function(){var e,r,t=this.clone(),n=[];for(var i in _)if(Hn(_,i)&&t.hasBase(z[i])){e=i;break}if("NONE"===e)t.units=[];else if(e&&Hn(_,e)&&(r=_[e]),r)t.units=[{unit:r.unit,prefix:r.prefix,power:1}];else{for(var a=!1,o=0;o<I.length;o++){var u=I[o];Math.abs(t.dimensions[o]||0)>1e-12&&(Hn(_,u)?n.push({unit:_[u].unit,prefix:_[u].prefix,power:t.dimensions[o]||0}):a=!0)}n.length<t.units.length&&!a&&(t.units=n)}return t},D.prototype.toSI=function(){for(var e=this.clone(),r=[],t=0;t<I.length;t++){var n=I[t];if(Math.abs(e.dimensions[t]||0)>1e-12){if(!Hn(L.si,n))throw Error("Cannot express custom unit "+n+" in SI units");r.push({unit:L.si[n].unit,prefix:L.si[n].prefix,power:e.dimensions[t]||0})}}return e.units=r,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,null!==this.value?(e.value=null,this.to(e)):e},D.prototype.formatUnits=function(){for(var e="",r="",t=0,n=0,i=0;i<this.units.length;i++)this.units[i].power>0?(t++,e+=" "+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power-1)>1e-15&&(e+="^"+this.units[i].power)):this.units[i].power<0&&n++;if(n>0)for(var a=0;a<this.units.length;a++)this.units[a].power<0&&(t>0?(r+=" "+this.units[a].prefix.name+this.units[a].unit.name,Math.abs(this.units[a].power+1)>1e-15&&(r+="^"+-this.units[a].power)):(r+=" "+this.units[a].prefix.name+this.units[a].unit.name,r+="^"+this.units[a].power));e=e.substr(1),r=r.substr(1),t>1&&n>0&&(e="("+e+")"),n>1&&t>0&&(r="("+r+")");var o=e;return t>0&&n>0&&(o+=" / "),o+r},D.prototype.toBest=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e&&!Array.isArray(e))throw Error("Invalid unit type. Expected string or Unit.");var t=this.units[0].unit.prefixes;if(e&&e.length>0){var n=e.map((e=>{var r=null;if("string"==typeof e){if(!(r=D.parse(e)))throw Error("Invalid unit type. Expected compatible string or Unit.")}else if(!on(e))throw Error("Invalid unit type. Expected compatible string or Unit.");null===r&&(r=e.clone());try{return this.to(r.formatUnits()),r}catch(e){throw Error("Invalid unit type. Expected compatible string or Unit.")}})),i=n.map((e=>e.units[0].prefix));this.units[0].unit.prefixes=i.reduce(((e,r)=>(e[r.name]=r,e)),{}),this.units[0].prefix=i[0]}var a=k(this,r).simp;return this.units[0].unit.prefixes=t,a.fixPrefix=!0,a},D.prototype.format=function(e){var{simp:r,valueStr:t,unitStr:n}=k(this,e),i=t;return r.value&&nn(r.value)&&(i="("+i+")"),n.length>0&&i.length>0&&(i+=" "),i+n},D.prototype._bestPrefix=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1.2;if(1!==this.units.length)throw 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 Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var r=null!==this.value?f(this.value):0,t=f(this.units[0].unit.value),n=this.units[0].prefix;if(0===r)return n;var i=this.units[0].power,a=Math.log(r/Math.pow(n.value*t,i))/Math.LN10-e;if(a>-2.200001&&a<1.800001)return n;a=Math.abs(a);var o=this.units[0].unit.prefixes;for(var u in o)if(Hn(o,u)){var s=o[u];if(s.scientific){var c=Math.abs(Math.log(r/Math.pow(s.value*t,i))/Math.LN10-e);(c<a||c===a&&s.name.length<n.name.length)&&(n=s,a=c)}}return n},D.prototype.splitUnit=function(e){for(var r=this.clone(),t=[],n=0;n<e.length&&(r=r.to(e[n]),n!==e.length-1);n++){var i=r.toNumeric(),a=d(i),s=new D(p(a,i)?a:m(r.toNumeric()),""+e[n]);t.push(s),r=u(r,s)}for(var c=0,l=0;l<t.length;l++)c=o(c,t[l].value);return p(c,this.value)&&(r.value=0),t.push(r),t};var O={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},R:{name:"R",value:1e27,scientific:!0},Q:{name:"Q",value:1e30,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},r:{name:"r",value:1e-27,scientific:!0},q:{name:"q",value:1e-30,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},ronna:{name:"ronna",value:1e27,scientific:!0},quetta:{name:"quetta",value:1e30,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},ronto:{name:"ronto",value:1e-27,scientific:!0},quecto:{name:"quecto",value:1e-30,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},R:{name:"R",value:1e54,scientific:!0},Q:{name:"Q",value:1e60,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},r:{name:"r",value:1e-54,scientific:!0},q:{name:"q",value:1e-60,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},R:{name:"R",value:1e81,scientific:!0},Q:{name:"Q",value:1e90,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},r:{name:"r",value:1e-81,scientific:!0},q:{name:"q",value:1e-90,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:1048576,scientific:!0},Gi:{name:"Gi",value:1073741824,scientific:!0},Ti:{name:"Ti",value:1099511627776,scientific:!0},Pi:{name:"Pi",value:0x4000000000000,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:1048576,scientific:!0},gibi:{name:"gibi",value:1073741824,scientific:!0},tebi:{name:"tebi",value:1099511627776,scientific:!0},pebi:{name:"pebi",value:0x4000000000000,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}}};O.SHORTLONG=Pt({},O.SHORT,O.LONG),O.BINARY_SHORT=Pt({},O.BINARY_SHORT_SI,O.BINARY_SHORT_IEC),O.BINARY_LONG=Pt({},O.BINARY_LONG_SI,O.BINARY_LONG_IEC);var I=["MASS","LENGTH","TIME","CURRENT","TEMPERATURE","LUMINOUS_INTENSITY","AMOUNT_OF_SUBSTANCE","ANGLE","BIT"],z={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 j in z)Hn(z,j)&&(z[j].key=j);var R={name:"",base:{},value:1,offset:0,dimensions:I.map((()=>0))},U={meter:{name:"meter",base:z.LENGTH,prefixes:O.LONG,value:1,offset:0},inch:{name:"inch",base:z.LENGTH,prefixes:O.NONE,value:.0254,offset:0},foot:{name:"foot",base:z.LENGTH,prefixes:O.NONE,value:.3048,offset:0},yard:{name:"yard",base:z.LENGTH,prefixes:O.NONE,value:.9144,offset:0},mile:{name:"mile",base:z.LENGTH,prefixes:O.NONE,value:1609.344,offset:0},link:{name:"link",base:z.LENGTH,prefixes:O.NONE,value:.201168,offset:0},rod:{name:"rod",base:z.LENGTH,prefixes:O.NONE,value:5.0292,offset:0},chain:{name:"chain",base:z.LENGTH,prefixes:O.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:z.LENGTH,prefixes:O.NONE,value:1e-10,offset:0},m:{name:"m",base:z.LENGTH,prefixes:O.SHORT,value:1,offset:0},in:{name:"in",base:z.LENGTH,prefixes:O.NONE,value:.0254,offset:0},ft:{name:"ft",base:z.LENGTH,prefixes:O.NONE,value:.3048,offset:0},yd:{name:"yd",base:z.LENGTH,prefixes:O.NONE,value:.9144,offset:0},mi:{name:"mi",base:z.LENGTH,prefixes:O.NONE,value:1609.344,offset:0},li:{name:"li",base:z.LENGTH,prefixes:O.NONE,value:.201168,offset:0},rd:{name:"rd",base:z.LENGTH,prefixes:O.NONE,value:5.02921,offset:0},ch:{name:"ch",base:z.LENGTH,prefixes:O.NONE,value:20.1168,offset:0},mil:{name:"mil",base:z.LENGTH,prefixes:O.NONE,value:254e-7,offset:0},m2:{name:"m2",base:z.SURFACE,prefixes:O.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:z.SURFACE,prefixes:O.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:z.SURFACE,prefixes:O.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:z.SURFACE,prefixes:O.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:z.SURFACE,prefixes:O.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:z.SURFACE,prefixes:O.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:z.SURFACE,prefixes:O.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:z.SURFACE,prefixes:O.NONE,value:6.4516e-10,offset:0},acre:{name:"acre",base:z.SURFACE,prefixes:O.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:z.SURFACE,prefixes:O.NONE,value:1e4,offset:0},m3:{name:"m3",base:z.VOLUME,prefixes:O.CUBIC,value:1,offset:0},L:{name:"L",base:z.VOLUME,prefixes:O.SHORT,value:.001,offset:0},l:{name:"l",base:z.VOLUME,prefixes:O.SHORT,value:.001,offset:0},litre:{name:"litre",base:z.VOLUME,prefixes:O.LONG,value:.001,offset:0},cuin:{name:"cuin",base:z.VOLUME,prefixes:O.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:z.VOLUME,prefixes:O.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:z.VOLUME,prefixes:O.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:z.VOLUME,prefixes:O.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:z.VOLUME,prefixes:O.NONE,value:15e-6,offset:0},drop:{name:"drop",base:z.VOLUME,prefixes:O.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:z.VOLUME,prefixes:O.NONE,value:5e-8,offset:0},minim:{name:"minim",base:z.VOLUME,prefixes:O.NONE,value:6.1611519921875e-8,offset:0},fluiddram:{name:"fluiddram",base:z.VOLUME,prefixes:O.NONE,value:36966911953125e-19,offset:0},fluidounce:{name:"fluidounce",base:z.VOLUME,prefixes:O.NONE,value:295735295625e-16,offset:0},gill:{name:"gill",base:z.VOLUME,prefixes:O.NONE,value:.00011829411825,offset:0},cc:{name:"cc",base:z.VOLUME,prefixes:O.NONE,value:1e-6,offset:0},cup:{name:"cup",base:z.VOLUME,prefixes:O.NONE,value:.0002365882365,offset:0},pint:{name:"pint",base:z.VOLUME,prefixes:O.NONE,value:.000473176473,offset:0},quart:{name:"quart",base:z.VOLUME,prefixes:O.NONE,value:.000946352946,offset:0},gallon:{name:"gallon",base:z.VOLUME,prefixes:O.NONE,value:.003785411784,offset:0},beerbarrel:{name:"beerbarrel",base:z.VOLUME,prefixes:O.NONE,value:.117347765304,offset:0},oilbarrel:{name:"oilbarrel",base:z.VOLUME,prefixes:O.NONE,value:.158987294928,offset:0},hogshead:{name:"hogshead",base:z.VOLUME,prefixes:O.NONE,value:.238480942392,offset:0},g:{name:"g",base:z.MASS,prefixes:O.SHORT,value:.001,offset:0},gram:{name:"gram",base:z.MASS,prefixes:O.LONG,value:.001,offset:0},ton:{name:"ton",base:z.MASS,prefixes:O.SHORT,value:907.18474,offset:0},t:{name:"t",base:z.MASS,prefixes:O.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:z.MASS,prefixes:O.LONG,value:1e3,offset:0},grain:{name:"grain",base:z.MASS,prefixes:O.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:z.MASS,prefixes:O.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:z.MASS,prefixes:O.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:z.MASS,prefixes:O.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:z.MASS,prefixes:O.NONE,value:45.359237,offset:0},stick:{name:"stick",base:z.MASS,prefixes:O.NONE,value:.115,offset:0},stone:{name:"stone",base:z.MASS,prefixes:O.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:z.MASS,prefixes:O.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:z.MASS,prefixes:O.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:z.MASS,prefixes:O.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:z.MASS,prefixes:O.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:z.MASS,prefixes:O.NONE,value:45.359237,offset:0},s:{name:"s",base:z.TIME,prefixes:O.SHORT,value:1,offset:0},min:{name:"min",base:z.TIME,prefixes:O.NONE,value:60,offset:0},h:{name:"h",base:z.TIME,prefixes:O.NONE,value:3600,offset:0},second:{name:"second",base:z.TIME,prefixes:O.LONG,value:1,offset:0},sec:{name:"sec",base:z.TIME,prefixes:O.LONG,value:1,offset:0},minute:{name:"minute",base:z.TIME,prefixes:O.NONE,value:60,offset:0},hour:{name:"hour",base:z.TIME,prefixes:O.NONE,value:3600,offset:0},day:{name:"day",base:z.TIME,prefixes:O.NONE,value:86400,offset:0},week:{name:"week",base:z.TIME,prefixes:O.NONE,value:604800,offset:0},month:{name:"month",base:z.TIME,prefixes:O.NONE,value:2629800,offset:0},year:{name:"year",base:z.TIME,prefixes:O.NONE,value:31557600,offset:0},decade:{name:"decade",base:z.TIME,prefixes:O.NONE,value:315576e3,offset:0},century:{name:"century",base:z.TIME,prefixes:O.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:z.TIME,prefixes:O.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:z.FREQUENCY,prefixes:O.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:z.FREQUENCY,prefixes:O.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:z.ANGLE,prefixes:O.SHORT,value:1,offset:0},radian:{name:"radian",base:z.ANGLE,prefixes:O.LONG,value:1,offset:0},deg:{name:"deg",base:z.ANGLE,prefixes:O.SHORT,value:null,offset:0},degree:{name:"degree",base:z.ANGLE,prefixes:O.LONG,value:null,offset:0},grad:{name:"grad",base:z.ANGLE,prefixes:O.SHORT,value:null,offset:0},gradian:{name:"gradian",base:z.ANGLE,prefixes:O.LONG,value:null,offset:0},cycle:{name:"cycle",base:z.ANGLE,prefixes:O.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:z.ANGLE,prefixes:O.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:z.ANGLE,prefixes:O.NONE,value:null,offset:0},A:{name:"A",base:z.CURRENT,prefixes:O.SHORT,value:1,offset:0},ampere:{name:"ampere",base:z.CURRENT,prefixes:O.LONG,value:1,offset:0},K:{name:"K",base:z.TEMPERATURE,prefixes:O.SHORT,value:1,offset:0},degC:{name:"degC",base:z.TEMPERATURE,prefixes:O.SHORT,value:1,offset:273.15},degF:{name:"degF",base:z.TEMPERATURE,prefixes:O.SHORT,value:new x(5,9),offset:459.67},degR:{name:"degR",base:z.TEMPERATURE,prefixes:O.SHORT,value:new x(5,9),offset:0},kelvin:{name:"kelvin",base:z.TEMPERATURE,prefixes:O.LONG,value:1,offset:0},celsius:{name:"celsius",base:z.TEMPERATURE,prefixes:O.LONG,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:z.TEMPERATURE,prefixes:O.LONG,value:new x(5,9),offset:459.67},rankine:{name:"rankine",base:z.TEMPERATURE,prefixes:O.LONG,value:new x(5,9),offset:0},mol:{name:"mol",base:z.AMOUNT_OF_SUBSTANCE,prefixes:O.SHORT,value:1,offset:0},mole:{name:"mole",base:z.AMOUNT_OF_SUBSTANCE,prefixes:O.LONG,value:1,offset:0},cd:{name:"cd",base:z.LUMINOUS_INTENSITY,prefixes:O.SHORT,value:1,offset:0},candela:{name:"candela",base:z.LUMINOUS_INTENSITY,prefixes:O.LONG,value:1,offset:0},N:{name:"N",base:z.FORCE,prefixes:O.SHORT,value:1,offset:0},newton:{name:"newton",base:z.FORCE,prefixes:O.LONG,value:1,offset:0},dyn:{name:"dyn",base:z.FORCE,prefixes:O.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:z.FORCE,prefixes:O.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:z.FORCE,prefixes:O.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:z.FORCE,prefixes:O.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:z.FORCE,prefixes:O.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:z.FORCE,prefixes:O.NONE,value:9.80665,offset:0},J:{name:"J",base:z.ENERGY,prefixes:O.SHORT,value:1,offset:0},joule:{name:"joule",base:z.ENERGY,prefixes:O.LONG,value:1,offset:0},erg:{name:"erg",base:z.ENERGY,prefixes:O.SHORTLONG,value:1e-7,offset:0},Wh:{name:"Wh",base:z.ENERGY,prefixes:O.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:z.ENERGY,prefixes:O.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:z.ENERGY,prefixes:O.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:z.ENERGY,prefixes:O.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:z.POWER,prefixes:O.SHORT,value:1,offset:0},watt:{name:"watt",base:z.POWER,prefixes:O.LONG,value:1,offset:0},hp:{name:"hp",base:z.POWER,prefixes:O.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:z.POWER,prefixes:O.SHORT,value:b.I,offset:0},VA:{name:"VA",base:z.POWER,prefixes:O.SHORT,value:1,offset:0},Pa:{name:"Pa",base:z.PRESSURE,prefixes:O.SHORT,value:1,offset:0},psi:{name:"psi",base:z.PRESSURE,prefixes:O.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:z.PRESSURE,prefixes:O.NONE,value:101325,offset:0},bar:{name:"bar",base:z.PRESSURE,prefixes:O.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:z.PRESSURE,prefixes:O.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:z.PRESSURE,prefixes:O.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:z.PRESSURE,prefixes:O.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:z.PRESSURE,prefixes:O.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:z.ELECTRIC_CHARGE,prefixes:O.LONG,value:1,offset:0},C:{name:"C",base:z.ELECTRIC_CHARGE,prefixes:O.SHORT,value:1,offset:0},farad:{name:"farad",base:z.ELECTRIC_CAPACITANCE,prefixes:O.LONG,value:1,offset:0},F:{name:"F",base:z.ELECTRIC_CAPACITANCE,prefixes:O.SHORT,value:1,offset:0},volt:{name:"volt",base:z.ELECTRIC_POTENTIAL,prefixes:O.LONG,value:1,offset:0},V:{name:"V",base:z.ELECTRIC_POTENTIAL,prefixes:O.SHORT,value:1,offset:0},ohm:{name:"ohm",base:z.ELECTRIC_RESISTANCE,prefixes:O.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:z.ELECTRIC_INDUCTANCE,prefixes:O.LONG,value:1,offset:0},H:{name:"H",base:z.ELECTRIC_INDUCTANCE,prefixes:O.SHORT,value:1,offset:0},siemens:{name:"siemens",base:z.ELECTRIC_CONDUCTANCE,prefixes:O.LONG,value:1,offset:0},S:{name:"S",base:z.ELECTRIC_CONDUCTANCE,prefixes:O.SHORT,value:1,offset:0},weber:{name:"weber",base:z.MAGNETIC_FLUX,prefixes:O.LONG,value:1,offset:0},Wb:{name:"Wb",base:z.MAGNETIC_FLUX,prefixes:O.SHORT,value:1,offset:0},tesla:{name:"tesla",base:z.MAGNETIC_FLUX_DENSITY,prefixes:O.LONG,value:1,offset:0},T:{name:"T",base:z.MAGNETIC_FLUX_DENSITY,prefixes:O.SHORT,value:1,offset:0},b:{name:"b",base:z.BIT,prefixes:O.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:z.BIT,prefixes:O.BINARY_LONG,value:1,offset:0},B:{name:"B",base:z.BIT,prefixes:O.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:z.BIT,prefixes:O.BINARY_LONG,value:8,offset:0}},$={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",fldr:"fluiddram",fluiddrams:"fluiddram",floz:"fluidounce",fluidounces:"fluidounce",gi:"gill",gills:"gill",cp:"cup",cups:"cup",pt:"pint",pints:"pint",qt:"quart",quarts:"quart",gal:"gallon",gallons:"gallon",bbl:"beerbarrel",beerbarrels:"beerbarrel",obl:"oilbarrel",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 P(e){if("BigNumber"===e.number){var r=uh(g);U.rad.value=new g(1),U.deg.value=r.div(180),U.grad.value=r.div(200),U.cycle.value=r.times(2),U.arcsec.value=r.div(648e3),U.arcmin.value=r.div(10800)}else U.rad.value=1,U.deg.value=Math.PI/180,U.grad.value=Math.PI/200,U.cycle.value=2*Math.PI,U.arcsec.value=Math.PI/648e3,U.arcmin.value=Math.PI/10800;U.radian.value=U.rad.value,U.degree.value=U.deg.value,U.gradian.value=U.grad.value}P(a),i&&i("config",(function(e,r){e.number!==r.number&&P(e)}));var L={si:{NONE:{unit:R,prefix:O.NONE[""]},LENGTH:{unit:U.m,prefix:O.SHORT[""]},MASS:{unit:U.g,prefix:O.SHORT.k},TIME:{unit:U.s,prefix:O.SHORT[""]},CURRENT:{unit:U.A,prefix:O.SHORT[""]},TEMPERATURE:{unit:U.K,prefix:O.SHORT[""]},LUMINOUS_INTENSITY:{unit:U.cd,prefix:O.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:U.mol,prefix:O.SHORT[""]},ANGLE:{unit:U.rad,prefix:O.SHORT[""]},BIT:{unit:U.bits,prefix:O.SHORT[""]},FORCE:{unit:U.N,prefix:O.SHORT[""]},ENERGY:{unit:U.J,prefix:O.SHORT[""]},POWER:{unit:U.W,prefix:O.SHORT[""]},PRESSURE:{unit:U.Pa,prefix:O.SHORT[""]},ELECTRIC_CHARGE:{unit:U.C,prefix:O.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:U.F,prefix:O.SHORT[""]},ELECTRIC_POTENTIAL:{unit:U.V,prefix:O.SHORT[""]},ELECTRIC_RESISTANCE:{unit:U.ohm,prefix:O.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:U.H,prefix:O.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:U.S,prefix:O.SHORT[""]},MAGNETIC_FLUX:{unit:U.Wb,prefix:O.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:U.T,prefix:O.SHORT[""]},FREQUENCY:{unit:U.Hz,prefix:O.SHORT[""]}}};L.cgs=JSON.parse(JSON.stringify(L.si)),L.cgs.LENGTH={unit:U.m,prefix:O.SHORT.c},L.cgs.MASS={unit:U.g,prefix:O.SHORT[""]},L.cgs.FORCE={unit:U.dyn,prefix:O.SHORT[""]},L.cgs.ENERGY={unit:U.erg,prefix:O.NONE[""]},L.us=JSON.parse(JSON.stringify(L.si)),L.us.LENGTH={unit:U.ft,prefix:O.NONE[""]},L.us.MASS={unit:U.lbm,prefix:O.NONE[""]},L.us.TEMPERATURE={unit:U.degF,prefix:O.NONE[""]},L.us.FORCE={unit:U.lbf,prefix:O.NONE[""]},L.us.ENERGY={unit:U.BTU,prefix:O.BTU[""]},L.us.POWER={unit:U.hp,prefix:O.NONE[""]},L.us.PRESSURE={unit:U.psi,prefix:O.NONE[""]},L.auto=JSON.parse(JSON.stringify(L.si));var _=L.auto;for(var W in D.setUnitSystem=function(e){if(!Hn(L,e))throw Error("Unit system "+e+" does not exist. Choices are: "+Object.keys(L).join(", "));_=L[e]},D.getUnitSystem=function(){for(var e in L)if(Hn(L,e)&&L[e]===_)return e},D.typeConverters={BigNumber:function(e){return null!=e&&e.isFraction?new g(e.n+"").div(e.d+"").times(e.s+""):new g(e+"")},Fraction:function(e){return new x(e)},Complex:function(e){return e},number:function(e){return null!=e&&e.isFraction?y(e):e}},D.prototype._numberConverter=function(){var e=D.typeConverters[this.valueType()];if(e)return e;throw new TypeError('Unsupported Unit value type "'+this.valueType()+'"')},D._getNumberConverter=function(e){if(!D.typeConverters[e])throw new TypeError('Unsupported type "'+e+'"');return D.typeConverters[e]},U)if(Hn(U,W)){var J=U[W];J.dimensions=J.base.dimensions}for(var V in $)if(Hn($,V)){var H=U[$[V]],Z={};for(var G in H)Hn(H,G)&&(Z[G]=H[G]);Z.name=V,U[V]=Z}return D.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)},D.createUnit=function(e,r){if("object"!=typeof e)throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(r&&r.override)for(var t in e)if(Hn(e,t)&&D.deleteUnit(t),e[t].aliases)for(var n=0;n<e[t].aliases.length;n++)D.deleteUnit(e[t].aliases[n]);var i;for(var a in e)Hn(e,a)&&(i=D.createUnitSingle(a,e[a]));return i},D.createUnitSingle=function(e,r){if(null==r&&(r={}),"string"!=typeof e)throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");if(Hn(U,e))throw Error('Cannot create unit "'+e+'": a unit with that name already exists');!function(e){for(var r=0;r<e.length;r++){if(n=e.charAt(r),0===r&&!D.isValidAlpha(n))throw Error('Invalid unit name (must begin with alpha character): "'+e+'"');if(r>0&&!D.isValidAlpha(n)&&!A(n))throw Error('Invalid unit name (only alphanumeric characters are allowed): "'+e+'"')}}(e);var t,i,a,o=null,u=[],s=0;if(r&&"Unit"===r.type)o=r.clone();else if("string"==typeof r)""!==r&&(t=r);else{if("object"!=typeof r)throw new TypeError('Cannot create unit "'+e+'" from "'+r+'": expecting "string" or "Unit" or "Object"');t=r.definition,i=r.prefixes,s=r.offset,a=r.baseName,r.aliases&&(u=r.aliases.valueOf())}if(u)for(var c=0;c<u.length;c++)if(Hn(U,u[c]))throw Error('Cannot create alias "'+u[c]+'": a unit with that name already exists');if(t&&"string"==typeof t&&!o)try{o=D.parse(t,{allowNoUnits:!0})}catch(r){throw r.message='Could not create unit "'+e+'" from "'+t+'": '+r.message,r}else t&&"Unit"===t.type&&(o=t.clone());u=u||[],s=s||0,i=i&&i.toUpperCase&&O[i.toUpperCase()]||O.NONE;var l={};if(o){l={name:e,value:o.value,dimensions:o.dimensions.slice(0),prefixes:i,offset:s};var f=!1;for(var m in z)if(Hn(z,m)){for(var d=!0,p=0;p<I.length;p++)if(Math.abs((l.dimensions[p]||0)-(z[m].dimensions[p]||0))>1e-12){d=!1;break}if(d){f=!0,l.base=z[m];break}}if(!f){a=a||e+"_STUFF";var h={dimensions:o.dimensions.slice(0)};h.key=a,z[a]=h,_[a]={unit:l,prefix:O.NONE[""]},l.base=z[a]}}else{if(I.indexOf(a=a||e+"_STUFF")>=0)throw Error('Cannot create new base unit "'+e+'": a base unit with that name already exists (and cannot be overridden)');for(var v in I.push(a),z)Hn(z,v)&&(z[v].dimensions[I.length-1]=0);for(var y={dimensions:[]},b=0;b<I.length;b++)y.dimensions[b]=0;y.dimensions[I.length-1]=1,y.key=a,z[a]=y,l={name:e,value:1,dimensions:z[a].dimensions.slice(0),prefixes:i,offset:s,base:z[a]},_[a]={unit:l,prefix:O.NONE[""]}}D.UNITS[e]=l;for(var g=0;g<u.length;g++){var x=u[g],w={};for(var N in l)Hn(l,N)&&(w[N]=l[N]);w.name=x,D.UNITS[x]=w}return delete B.cache,new D(null,e)},D.deleteUnit=function(e){delete D.UNITS[e],delete B.cache},D.PREFIXES=O,D.BASE_DIMENSIONS=I,D.BASE_UNITS=z,D.UNIT_SYSTEMS=L,D.UNITS=U,D}),{isClass:!0}),dh="unit",ph=ti(dh,["typed","Unit"],(e=>{var{typed:r,Unit:t}=e;return r(dh,{Unit:function(e){return e.clone()},string:function(e){return t.isValuelessUnit(e)?new t(null,e):t.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string | Unit":function(e,r){return new t(e,r)},"number | BigNumber | Fraction":function(e){return new t(e)},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),hh="sparse",vh=ti(hh,["typed","SparseMatrix"],(e=>{var{typed:r,SparseMatrix:t}=e;return r(hh,{"":function(){return new t([])},string:function(e){return new t([],e)},"Array | Matrix":function(e){return new t(e)},"Array | Matrix, string":function(e,r){return new t(e,r)}})})),yh="createUnit",bh=ti(yh,["typed","Unit"],(e=>{var{typed:r,Unit:t}=e;return r(yh,{"Object, Object":function(e,r){return t.createUnit(e,r)},Object:function(e){return t.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,r,n){var i={};return i[e]=r,t.createUnit(i,n)},"string, Unit | string | Object":function(e,r){var n={};return n[e]=r,t.createUnit(n,{})},string:function(e){var r={};return r[e]={},t.createUnit(r,{})}})})),gh="acos",xh=ti(gh,["typed","config","Complex"],(e=>{var{typed:r,config:t,Complex:n}=e;return r(gh,{number:function(e){return e>=-1&&e<=1||t.predictable?Math.acos(e):new n(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()}})})),wh="acosh",Dh=ti(wh,["typed","config","Complex"],(e=>{var{typed:r,config:t,Complex:n}=e;return r(wh,{number:function(e){return e>=1||t.predictable?_s(e):e<=-1?new n(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new n(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()}})})),Nh="acot",Ah=ti(Nh,["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r(Nh,{number:Ws,Complex:function(e){return e.acot()},BigNumber:function(e){return new t(1).div(e).atan()}})})),Mh="acoth",Ch=ti(Mh,["typed","config","Complex","BigNumber"],(e=>{var{typed:r,config:t,Complex:n,BigNumber:i}=e;return r(Mh,{number:function(e){return e>=1||e<=-1||t.predictable?Js(e):new n(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new i(1).div(e).atanh()}})})),Eh="acsc",Sh=ti(Eh,["typed","config","Complex","BigNumber"],(e=>{var{typed:r,config:t,Complex:n,BigNumber:i}=e;return r(Eh,{number:function(e){return e<=-1||e>=1||t.predictable?Vs(e):new n(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new i(1).div(e).asin()}})})),Fh="acsch",Bh=ti(Fh,["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r(Fh,{number:Hs,Complex:function(e){return e.acsch()},BigNumber:function(e){return new t(1).div(e).asinh()}})})),qh="asec",Th=ti(qh,["typed","config","Complex","BigNumber"],(e=>{var{typed:r,config:t,Complex:n,BigNumber:i}=e;return r(qh,{number:function(e){return e<=-1||e>=1||t.predictable?Zs(e):new n(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new i(1).div(e).acos()}})})),kh="asech",Oh=ti(kh,["typed","config","Complex","BigNumber"],(e=>{var{typed:r,config:t,Complex:n,BigNumber:i}=e;return r(kh,{number:function(e){if(e<=1&&e>=-1||t.predictable){var r=1/e;return r>0||t.predictable?Gs(e):new n(Math.log(Math.sqrt(r*r-1)-r),Math.PI)}return new n(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new i(1).div(e).acosh()}})})),Ih="asin",zh=ti(Ih,["typed","config","Complex"],(e=>{var{typed:r,config:t,Complex:n}=e;return r(Ih,{number:function(e){return e>=-1&&e<=1||t.predictable?Math.asin(e):new n(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()}})})),jh=ti("asinh",["typed"],(e=>{var{typed:r}=e;return r("asinh",{number:Xs,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()}})})),Rh=ti("atan",["typed"],(e=>{var{typed:r}=e;return r("atan",{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()}})})),Uh="atan2",$h=ti(Uh,["typed","matrix","equalScalar","BigNumber","DenseMatrix","concat"],(e=>{var{typed:r,matrix:t,equalScalar:n,BigNumber:i,DenseMatrix:a,concat:o}=e,u=Fl({typed:r,equalScalar:n}),s=Bl({typed:r}),c=yf({typed:r,equalScalar:n}),l=ul({typed:r,equalScalar:n}),f=sl({typed:r,DenseMatrix:a}),m=Ol({typed:r,matrix:t,concat:o});return r(Uh,{"number, number":Math.atan2,"BigNumber, BigNumber":(e,r)=>i.atan2(e,r)},m({scalar:"number | BigNumber",SS:c,DS:s,SD:u,Ss:l,sS:f}))})),Ph="atanh",Lh=ti(Ph,["typed","config","Complex"],(e=>{var{typed:r,config:t,Complex:n}=e;return r(Ph,{number:function(e){return e<=1&&e>=-1||t.predictable?Ys(e):new n(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()}})})),_h=ti("trigUnit",["typed"],(e=>{var{typed:r}=e;return{Unit:r.referToSelf((e=>t=>{if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return r.find(e,t.valueType())(t.value)}))}})),Wh=ti("cos",["typed"],(e=>{var{typed:r}=e,t=_h({typed:r});return r("cos",{number:Math.cos,"Complex | BigNumber":e=>e.cos()},t)})),Jh="cosh",Vh=ti(Jh,["typed"],(e=>{var{typed:r}=e;return r(Jh,{number:Ai,"Complex | BigNumber":e=>e.cosh()})})),Hh=ti("cot",["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r("cot",{number:Qs,Complex:e=>e.cot(),BigNumber:e=>new t(1).div(e.tan())},_h({typed:r}))})),Zh="coth",Gh=ti(Zh,["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r(Zh,{number:Ks,Complex:e=>e.coth(),BigNumber:e=>new t(1).div(e.tanh())})})),Xh=ti("csc",["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r("csc",{number:ec,Complex:e=>e.csc(),BigNumber:e=>new t(1).div(e.sin())},_h({typed:r}))})),Yh="csch",Qh=ti(Yh,["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r(Yh,{number:rc,Complex:e=>e.csch(),BigNumber:e=>new t(1).div(e.sinh())})})),Kh=ti("sec",["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r("sec",{number:tc,Complex:e=>e.sec(),BigNumber:e=>new t(1).div(e.cos())},_h({typed:r}))})),ev="sech",rv=ti(ev,["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r(ev,{number:nc,Complex:e=>e.sech(),BigNumber:e=>new t(1).div(e.cosh())})})),tv=ti("sin",["typed"],(e=>{var{typed:r}=e,t=_h({typed:r});return r("sin",{number:Math.sin,"Complex | BigNumber":e=>e.sin()},t)})),nv="sinh",iv=ti(nv,["typed"],(e=>{var{typed:r}=e;return r(nv,{number:ic,"Complex | BigNumber":e=>e.sinh()})})),av=ti("tan",["typed"],(e=>{var{typed:r}=e,t=_h({typed:r});return r("tan",{number:Math.tan,"Complex | BigNumber":e=>e.tan()},t)})),ov=ti("tanh",["typed"],(e=>{var{typed:r}=e;return r("tanh",{number:Ci,"Complex | BigNumber":e=>e.tanh()})})),uv="setCartesian",sv=ti(uv,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:r,size:t,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return r(uv,{"Array | Matrix, Array | Matrix":function(e,r){var u=[];if(0!==n(t(e),new a(0))&&0!==n(t(r),new a(0))){var s=bu(Array.isArray(e)?e:e.toArray()).sort(i),c=bu(Array.isArray(r)?r:r.toArray()).sort(i);u=[];for(var l=0;l<s.length;l++)for(var f=0;f<c.length;f++)u.push([s[l],c[f]])}return Array.isArray(e)&&Array.isArray(r)?u:new o(u)}})})),cv="setDifference",lv=ti(cv,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:r,size:t,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return r(cv,{"Array | Matrix, Array | Matrix":function(e,r){var u;if(0===n(t(e),new a(0)))u=[];else{if(0===n(t(r),new a(0)))return bu(e.toArray());var s,c=Nu(bu(Array.isArray(e)?e:e.toArray()).sort(i)),l=Nu(bu(Array.isArray(r)?r:r.toArray()).sort(i));u=[];for(var f=0;f<c.length;f++){s=!1;for(var m=0;m<l.length;m++)if(0===i(c[f].value,l[m].value)&&c[f].identifier===l[m].identifier){s=!0;break}s||u.push(c[f])}}return Array.isArray(e)&&Array.isArray(r)?Au(u):new o(Au(u))}})})),fv="setDistinct",mv=ti(fv,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:r,size:t,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return r(fv,{"Array | Matrix":function(e){var r;if(0===n(t(e),new a(0)))r=[];else{var u=bu(Array.isArray(e)?e:e.toArray()).sort(i);(r=[]).push(u[0]);for(var s=1;s<u.length;s++)0!==i(u[s],u[s-1])&&r.push(u[s])}return Array.isArray(e)?r:new o(r)}})})),dv="setIntersect",pv=ti(dv,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:r,size:t,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return r(dv,{"Array | Matrix, Array | Matrix":function(e,r){var u;if(0===n(t(e),new a(0))||0===n(t(r),new a(0)))u=[];else{var s=Nu(bu(Array.isArray(e)?e:e.toArray()).sort(i)),c=Nu(bu(Array.isArray(r)?r:r.toArray()).sort(i));u=[];for(var l=0;l<s.length;l++)for(var f=0;f<c.length;f++)if(0===i(s[l].value,c[f].value)&&s[l].identifier===c[f].identifier){u.push(s[l]);break}}return Array.isArray(e)&&Array.isArray(r)?Au(u):new o(Au(u))}})})),hv="setIsSubset",vv=ti(hv,["typed","size","subset","compareNatural","Index"],(e=>{var{typed:r,size:t,subset:n,compareNatural:i,Index:a}=e;return r(hv,{"Array | Matrix, Array | Matrix":function(e,r){if(0===n(t(e),new a(0)))return!0;if(0===n(t(r),new a(0)))return!1;for(var o,u=Nu(bu(Array.isArray(e)?e:e.toArray()).sort(i)),s=Nu(bu(Array.isArray(r)?r:r.toArray()).sort(i)),c=0;c<u.length;c++){o=!1;for(var l=0;l<s.length;l++)if(0===i(u[c].value,s[l].value)&&u[c].identifier===s[l].identifier){o=!0;break}if(!1===o)return!1}return!0}})})),yv="setMultiplicity",bv=ti(yv,["typed","size","subset","compareNatural","Index"],(e=>{var{typed:r,size:t,subset:n,compareNatural:i,Index:a}=e;return r(yv,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,r){if(0===n(t(r),new a(0)))return 0;for(var o=bu(Array.isArray(r)?r:r.toArray()),u=0,s=0;s<o.length;s++)0===i(o[s],e)&&u++;return u}})})),gv="setPowerset",xv=ti(gv,["typed","size","subset","compareNatural","Index"],(e=>{var{typed:r,size:t,subset:n,compareNatural:i,Index:a}=e;return r(gv,{"Array | Matrix":function(e){if(0===n(t(e),new a(0)))return[];for(var r=bu(Array.isArray(e)?e:e.toArray()).sort(i),u=[],s=0;s.toString(2).length<=r.length;)u.push(o(r,s.toString(2).split("").reverse())),s++;return function(e){for(var r=[],t=e.length-1;t>0;t--)for(var n=0;n<t;n++)e[n].length>e[n+1].length&&(r=e[n],e[n]=e[n+1],e[n+1]=r);return e}(u)}});function o(e,r){for(var t=[],n=0;n<r.length;n++)"1"===r[n]&&t.push(e[n]);return t}})),wv="setSize",Dv=ti(wv,["typed","compareNatural"],(e=>{var{typed:r,compareNatural:t}=e;return r(wv,{"Array | Matrix":function(e){return Array.isArray(e)?bu(e).length:bu(e.toArray()).length},"Array | Matrix, boolean":function(e,r){if(!1===r||0===e.length)return Array.isArray(e)?bu(e).length:bu(e.toArray()).length;for(var n=bu(Array.isArray(e)?e:e.toArray()).sort(t),i=1,a=1;a<n.length;a++)0!==t(n[a],n[a-1])&&i++;return i}})})),Nv="setSymDifference",Av=ti(Nv,["typed","size","concat","subset","setDifference","Index"],(e=>{var{typed:r,size:t,concat:n,subset:i,setDifference:a,Index:o}=e;return r(Nv,{"Array | Matrix, Array | Matrix":function(e,r){if(0===i(t(e),new o(0)))return bu(r);if(0===i(t(r),new o(0)))return bu(e);var u=bu(e),s=bu(r);return n(a(u,s),a(s,u))}})})),Mv="setUnion",Cv=ti(Mv,["typed","size","concat","subset","setIntersect","setSymDifference","Index"],(e=>{var{typed:r,size:t,concat:n,subset:i,setIntersect:a,setSymDifference:o,Index:u}=e;return r(Mv,{"Array | Matrix, Array | Matrix":function(e,r){if(0===i(t(e),new u(0)))return bu(r);if(0===i(t(r),new u(0)))return bu(e);var s=bu(e),c=bu(r);return n(o(s,c),a(s,c))}})})),Ev=ti("add",["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],(e=>{var{typed:r,matrix:t,addScalar:n,equalScalar:i,DenseMatrix:a,concat:o}=e,u=zl({typed:r}),s=jl({typed:r,equalScalar:i}),c=Rl({typed:r,DenseMatrix:a}),l=Ol({typed:r,matrix:t,concat:o});return r("add",{"any, any":n,"any, any, ...any":r.referToSelf((e=>(r,t,n)=>{for(var i=e(r,t),a=0;a<n.length;a++)i=e(i,n[a]);return i}))},l({elop:n,DS:u,SS:s,Ss:c}))})),Sv="hypot",Fv=ti(Sv,["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],(e=>{var{typed:r,abs:t,addScalar:n,divideScalar:i,multiplyScalar:a,sqrt:o,smaller:u,isPositive:s}=e;return r(Sv,{"... number | BigNumber":c,Array:c,Matrix:e=>c(bu(e.toArray(),!0))});function c(e){for(var r=0,c=0,l=0;l<e.length;l++){if(nn(e[l]))throw new TypeError("Unexpected type of argument to hypot");var f=t(e[l]);u(c,f)?(r=a(r,a(i(c,f),i(c,f))),r=n(r,1),c=f):r=n(r,s(f)?a(i(f,c),i(f,c)):f)}return a(c,o(r))}})),Bv="norm",qv=ti(Bv,["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],(e=>{var{typed:r,abs:t,add:n,pow:i,conj:a,sqrt:o,multiply:u,equalScalar:s,larger:c,smaller:l,matrix:f,ctranspose:m,eigs:d}=e;return r(Bv,{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},boolean:function(e){return Math.abs(e)},Array:function(e){return p(f(e),2)},Matrix:function(e){return p(e,2)},"Array, number | BigNumber | string":function(e,r){return p(f(e),r)},"Matrix, number | BigNumber | string":function(e,r){return p(e,r)}});function p(e,r){var f=e.size();if(1===f.length)return function(e,r){if(r===1/0||"inf"===r)return function(e){var r=0;return e.forEach((function(e){var n=t(e);c(n,r)&&(r=n)}),!0),r}(e);if(r===-1/0||"-inf"===r)return function(e){var r;return e.forEach((function(e){var n=t(e);r&&!l(n,r)||(r=n)}),!0),r||0}(e);if("fro"===r)return p(e,2);if("number"==typeof r&&!isNaN(r)){if(!s(r,0)){var a=0;return e.forEach((function(e){a=n(i(t(e),r),a)}),!0),i(a,1/r)}return 1/0}throw Error("Unsupported parameter value")}(e,r);if(2===f.length){if(f[0]&&f[1])return function(e,r){if(1===r)return function(e){var r=[],i=0;return e.forEach((function(e,a){var o=a[1],u=n(r[o]||0,t(e));c(u,i)&&(i=u),r[o]=u}),!0),i}(e);if(r===1/0||"inf"===r)return function(e){var r=[],i=0;return e.forEach((function(e,a){var o=a[0],u=n(r[o]||0,t(e));c(u,i)&&(i=u),r[o]=u}),!0),i}(e);if("fro"===r)return function(e){var r=0;return e.forEach((function(e){r=n(r,u(e,a(e)))})),t(o(r))}(e);if(2===r)return function(e){var r=e.size();if(r[0]!==r[1])throw new RangeError("Invalid matrix dimensions");var n=m(e),i=u(n,e),a=d(i).values.toArray();return t(o(a[a.length-1]))}(e);throw Error("Unsupported parameter value "+r)}(e,r);throw new RangeError("Invalid matrix dimensions")}}})),Tv=ti("dot",["typed","addScalar","multiplyScalar","conj","size"],(e=>{var{typed:r,addScalar:t,multiplyScalar:n,conj:i,size:a}=e;return r("dot",{"Array | DenseMatrix, Array | DenseMatrix":function(e,a){var s=o(e,a),c=cn(e)?e._data:e,l=cn(e)?e._datatype||e.getDataType():void 0,f=cn(a)?a._data:a,m=cn(a)?a._datatype||a.getDataType():void 0,d=2===u(e).length,p=2===u(a).length,h=t,v=n;if(l&&m&&l===m&&"string"==typeof l&&"mixed"!==l){var y=l;h=r.find(t,[y,y]),v=r.find(n,[y,y])}if(!d&&!p){for(var b=v(i(c[0]),f[0]),g=1;g<s;g++)b=h(b,v(i(c[g]),f[g]));return b}if(!d&&p){for(var x=v(i(c[0]),f[0][0]),w=1;w<s;w++)x=h(x,v(i(c[w]),f[w][0]));return x}if(d&&!p){for(var D=v(i(c[0][0]),f[0]),N=1;N<s;N++)D=h(D,v(i(c[N][0]),f[N]));return D}if(d&&p){for(var A=v(i(c[0][0]),f[0][0]),M=1;M<s;M++)A=h(A,v(i(c[M][0]),f[M][0]));return A}},"SparseMatrix, SparseMatrix":function(e,r){o(e,r);for(var i=e._index,a=e._values,u=r._index,s=r._values,c=0,l=t,f=n,m=0,d=0;m<i.length&&d<u.length;){var p=i[m],h=u[d];p<h?m++:p>h?d++:p===h&&(c=l(c,f(a[m],s[d])),m++,d++)}return c}});function o(e,r){var t,n,i=u(e),a=u(r);if(1===i.length)t=i[0];else{if(2!==i.length||1!==i[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+i.join(", ")+")");t=i[0]}if(1===a.length)n=a[0];else{if(2!==a.length||1!==a[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+a.join(", ")+")");n=a[0]}if(t!==n)throw new RangeError("Vectors must have equal length ("+t+" != "+n+")");if(0===t)throw new RangeError("Cannot calculate the dot product of empty vectors");return t}function u(e){return cn(e)?e.size():a(e)}})),kv=ti("trace",["typed","matrix","add"],(e=>{var{typed:r,matrix:t,add:n}=e;return r("trace",{Array:function(e){return i(t(e))},SparseMatrix:function(e){var r=e._values,t=e._index,i=e._ptr,a=e._size,o=a[1];if(a[0]===o){var u=0;if(r.length>0)for(var s=0;s<o;s++)for(var c=i[s+1],l=i[s];l<c;l++){var f=t[l];if(f===s){u=n(u,r[l]);break}if(f>s)break}return u}throw new RangeError("Matrix must be square (size: "+Go(a)+")")},DenseMatrix:i,any:Wn});function i(e){var r=e._size,t=e._data;switch(r.length){case 1:if(1===r[0])return Wn(t[0]);throw new RangeError("Matrix must be square (size: "+Go(r)+")");case 2:var i=r[0];if(i===r[1]){for(var a=0,o=0;o<i;o++)a=n(a,t[o][o]);return a}throw new RangeError("Matrix must be square (size: "+Go(r)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+Go(r)+")")}}})),Ov="index",Iv=ti(Ov,["typed","Index"],(e=>{var{typed:r,Index:t}=e;return r(Ov,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var r=e.map((function(e){return rn(e)?e.toNumber():sn(e)||cn(e)?e.map((function(e){return rn(e)?e.toNumber():e})):e})),n=new t;return t.apply(n,r),n}})})),zv=new Set(["end"]),jv=ti("Node",["mathWithTransform"],(e=>{var{mathWithTransform:r}=e;return class{get type(){return"Node"}get isNode(){return!0}evaluate(e){return this.compile().evaluate(e)}compile(){var e=this._compile(r,{}),t={};return{evaluate:function(r){var n=Kt(r);return function(e){for(var r of[...zv])if(e.has(r))throw Error('Scope contains an illegal symbol, "'+r+'" is a reserved keyword')}(n),e(n,t,null)}}}_compile(e,r){throw Error("Method _compile must be implemented by type "+this.type)}forEach(e){throw Error("Cannot run forEach on a Node interface")}map(e){throw Error("Cannot run map on a Node interface")}_ifNode(e){if(!In(e))throw new TypeError("Callback function must return a Node");return e}traverse(e){e(this,null,null),function e(r,t){r.forEach((function(r,n,i){t(r,n,i),e(r,t)}))}(this,e)}transform(e){return function r(t,n,i){var a=e(t,n,i);return a!==t?a:t.map(r)}(this,null,null)}filter(e){var r=[];return this.traverse((function(t,n,i){e(t,n,i)&&r.push(t)})),r}clone(){throw Error("Cannot clone a Node interface")}cloneDeep(){return this.map((function(e){return e.cloneDeep()}))}equals(e){return!!e&&this.type===e.type&&Vn(this,e)}toString(e){var r=this._getCustomString(e);return void 0!==r?r:this._toString(e)}_toString(){throw Error("_toString not implemented for "+this.type)}toJSON(){throw Error("Cannot serialize object: toJSON not implemented by "+this.type)}toHTML(e){var r=this._getCustomString(e);return void 0!==r?r:this._toHTML(e)}_toHTML(){throw Error("_toHTML not implemented for "+this.type)}toTex(e){var r=this._getCustomString(e);return void 0!==r?r:this._toTex(e)}_toTex(e){throw Error("_toTex not implemented for "+this.type)}_getCustomString(e){if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":return;case"function":return e.handler(this,e);default:throw new TypeError("Object or function expected as callback")}}getIdentifier(){return this.type}getContent(){return this}}}),{isClass:!0,isNode:!0});function Rv(e){return e&&e.isIndexError?new tu(e.index+1,e.min+1,void 0!==e.max?e.max+1:void 0):e}function Uv(e){var{subset:r}=e;return function(e,t){try{if(Array.isArray(e))return r(e,t);if(e&&"function"==typeof e.subset)return e.subset(t);if("string"==typeof e)return r(e,t);if("object"==typeof e){if(!t.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return _t(e,t.getObjectProperty())}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Rv(e)}}}var $v="AccessorNode",Pv=ti($v,["subset","Node"],(e=>{var{subset:r,Node:t}=e,n=Uv({subset:r});function i(e){return!(Mn(e)||Cn(e)||Bn(e)||kn(e)||zn(e)||Rn(e)||Pn(e))}class a extends t{constructor(e,r){if(super(),!In(e))throw new TypeError('Node expected for parameter "object"');if(!On(r))throw new TypeError('IndexNode expected for parameter "index"');this.object=e,this.index=r}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return $v}get isAccessorNode(){return!0}_compile(e,r){var t=this.object._compile(e,r),i=this.index._compile(e,r);if(this.index.isObjectProperty()){var a=this.index.getObjectProperty();return function(e,r,n){return _t(t(e,r,n),a)}}return function(e,r,a){var o=t(e,r,a),u=i(e,r,o);return n(o,u)}}forEach(e){e(this.object,"object",this),e(this.index,"index",this)}map(e){return new a(this._ifNode(e(this.object,"object",this)),this._ifNode(e(this.index,"index",this)))}clone(){return new a(this.object,this.index)}_toString(e){var r=this.object.toString(e);return i(this.object)&&(r="("+r+")"),r+this.index.toString(e)}_toHTML(e){var r=this.object.toHTML(e);return i(this.object)&&(r='<span class="math-parenthesis math-round-parenthesis">(</span>'+r+'<span class="math-parenthesis math-round-parenthesis">)</span>'),r+this.index.toHTML(e)}_toTex(e){var r=this.object.toTex(e);return i(this.object)&&(r="\\left(' + object + '\\right)"),r+this.index.toTex(e)}toJSON(){return{mathjs:$v,object:this.object,index:this.index}}static fromJSON(e){return new a(e.object,e.index)}}return ed(a,"name",$v),a}),{isClass:!0,isNode:!0}),Lv="ArrayNode",_v=ti(Lv,["Node"],(e=>{var{Node:r}=e;class t extends r{constructor(e){if(super(),this.items=e||[],!Array.isArray(this.items)||!this.items.every(In))throw new TypeError("Array containing Nodes expected")}get type(){return Lv}get isArrayNode(){return!0}_compile(e,r){var t=gu(this.items,(function(t){return t._compile(e,r)}));if("Array"!==e.config.matrix){var n=e.matrix;return function(e,r,i){return n(gu(t,(function(t){return t(e,r,i)})))}}return function(e,r,n){return gu(t,(function(t){return t(e,r,n)}))}}forEach(e){for(var r=0;r<this.items.length;r++)e(this.items[r],"items["+r+"]",this)}map(e){for(var r=[],n=0;n<this.items.length;n++)r[n]=this._ifNode(e(this.items[n],"items["+n+"]",this));return new t(r)}clone(){return new t(this.items.slice(0))}_toString(e){return"["+this.items.map((function(r){return r.toString(e)})).join(", ")+"]"}toJSON(){return{mathjs:Lv,items:this.items}}static fromJSON(e){return new t(e.items)}_toHTML(e){return'<span class="math-parenthesis math-square-parenthesis">[</span>'+this.items.map((function(r){return r.toHTML(e)})).join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(e){return function r(t,n){var i=t.some(Cn)&&!t.every(Cn),a=n||i,o=a?"&":"\\\\",u=t.map((function(t){return t.items?r(t.items,!n):t.toTex(e)})).join(o);return i||!a||a&&!n?"\\begin{bmatrix}"+u+"\\end{bmatrix}":u}(this.items,!1)}}return ed(t,"name",Lv),t}),{isClass:!0,isNode:!0}),Wv=[{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:nullish":{op:"??",associativity:"left",associativeWith:[]}},{"OperatorNode:factorial":{op:"!",associativity:"left"}},{"OperatorNode:ctranspose":{op:"'",associativity:"left"}}];function Jv(e,r){if(!r||"auto"!==r)return e;for(var t=e;Rn(t);)t=t.content;return t}function Vv(e,r,t,n){var i=e;"keep"!==r&&(i=e.getContent());for(var a=i.getIdentifier(),o=null,u=0;u<Wv.length;u++)if(a in Wv[u]){o=u;break}if("OperatorNode:multiply"===a&&i.implicit&&"show"!==t){var s=Jv(i.args[0],r);Bn(s)&&n&&"OperatorNode:divide"===n.getIdentifier()&&qn(Jv(n.args[0],r))||"OperatorNode:divide"===s.getIdentifier()&&qn(Jv(s.args[0],r))&&Bn(Jv(s.args[1]))||(o+=1)}return o}function Hv(e,r){var t=e;"keep"!==r&&(t=e.getContent());var n=t.getIdentifier(),i=Vv(t,r);if(null===i)return null;var a=Wv[i][n];if(Hn(a,"associativity")){if("left"===a.associativity)return"left";if("right"===a.associativity)return"right";throw Error("'"+n+"' has the invalid associativity '"+a.associativity+"'.")}return null}function Zv(e,r,t){var n="keep"!==t?e.getContent():e,i="keep"!==t?e.getContent():r,a=n.getIdentifier(),o=i.getIdentifier(),u=Vv(n,t);if(null===u)return null;var s=Wv[u][a];if(Hn(s,"associativeWith")&&s.associativeWith instanceof Array){for(var c=0;c<s.associativeWith.length;c++)if(s.associativeWith[c]===o)return!0;return!1}return null}var Gv,Xv,Yv="AssignmentNode",Qv=ti(Yv,["subset","?matrix","Node"],(e=>{var{subset:r,matrix:t,Node:n}=e,i=Uv({subset:r}),a=function(e){var{subset:r,matrix:t}=e;return function(e,n,i){try{if(Array.isArray(e))return t(e).subset(n,i).valueOf().forEach(((r,t)=>{e[t]=r})),e;if(e&&"function"==typeof e.subset)return e.subset(n,i);if("string"==typeof e)return r(e,n,i);if("object"==typeof e){if(!n.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return Wt(e,n.getObjectProperty(),i),e}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Rv(e)}}}({subset:r,matrix:t});function o(e,r,t){r||(r="keep");var n=Vv(e,r,t),i=Vv(e.value,r,t);return"all"===r||null!==i&&i<=n}class u extends n{constructor(e,r,t){if(super(),this.object=e,this.index=t?r:null,this.value=t||r,!Pn(e)&&!Mn(e))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(Pn(e)&&"end"===e.name)throw Error('Cannot assign to symbol "end"');if(this.index&&!On(this.index))throw new TypeError('IndexNode expected as "index"');if(!In(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 Yv}get isAssignmentNode(){return!0}_compile(e,r){var t=this.object._compile(e,r),n=this.index?this.index._compile(e,r):null,o=this.value._compile(e,r),u=this.object.name;if(this.index){if(this.index.isObjectProperty()){var s=this.index.getObjectProperty();return function(e,r,n){var i=t(e,r,n),a=o(e,r,n);return Wt(i,s,a),a}}if(Pn(this.object))return function(e,r,i){var s=t(e,r,i),c=o(e,r,i),l=n(e,r,s);return e.set(u,a(s,l,c)),c};var c=this.object.object._compile(e,r);if(this.object.index.isObjectProperty()){var l=this.object.index.getObjectProperty();return function(e,r,t){var i=c(e,r,t),u=_t(i,l),s=n(e,r,u),f=o(e,r,t);return Wt(i,l,a(u,s,f)),f}}var f=this.object.index._compile(e,r);return function(e,r,t){var u=c(e,r,t),s=f(e,r,u),l=i(u,s),m=n(e,r,l),d=o(e,r,t);return a(u,s,a(l,m,d)),d}}if(!Pn(this.object))throw new TypeError("SymbolNode expected as object");return function(e,r,t){var n=o(e,r,t);return e.set(u,n),n}}forEach(e){e(this.object,"object",this),this.index&&e(this.index,"index",this),e(this.value,"value",this)}map(e){var r=this._ifNode(e(this.object,"object",this)),t=this.index?this._ifNode(e(this.index,"index",this)):null,n=this._ifNode(e(this.value,"value",this));return new u(r,t,n)}clone(){return new u(this.object,this.index,this.value)}_toString(e){var r=this.object.toString(e),t=this.index?this.index.toString(e):"",n=this.value.toString(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(n="("+n+")"),r+t+" = "+n}toJSON(){return{mathjs:Yv,object:this.object,index:this.index,value:this.value}}static fromJSON(e){return new u(e.object,e.index,e.value)}_toHTML(e){var r=this.object.toHTML(e),t=this.index?this.index.toHTML(e):"",n=this.value.toHTML(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(n='<span class="math-paranthesis math-round-parenthesis">(</span>'+n+'<span class="math-paranthesis math-round-parenthesis">)</span>'),r+t+'<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+n}_toTex(e){var r=this.object.toTex(e),t=this.index?this.index.toTex(e):"",n=this.value.toTex(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(n="\\left(".concat(n,"\\right)")),r+t+"="+n}}return ed(u,"name",Yv),u}),{isClass:!0,isNode:!0}),Kv="BlockNode",ey=ti(Kv,["ResultSet","Node"],(e=>{var{ResultSet:r,Node:t}=e;class n extends t{constructor(e){if(super(),!Array.isArray(e))throw Error("Array expected");this.blocks=e.map((function(e){var r=e&&e.node,t=!e||void 0===e.visible||e.visible;if(!In(r))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof t)throw new TypeError('Property "visible" must be a boolean');return{node:r,visible:t}}))}get type(){return Kv}get isBlockNode(){return!0}_compile(e,t){var n=gu(this.blocks,(function(r){return{evaluate:r.node._compile(e,t),visible:r.visible}}));return function(e,t,i){var a=[];return xu(n,(function(r){var n=r.evaluate(e,t,i);r.visible&&a.push(n)})),new r(a)}}forEach(e){for(var r=0;r<this.blocks.length;r++)e(this.blocks[r].node,"blocks["+r+"].node",this)}map(e){for(var r=[],t=0;t<this.blocks.length;t++){var i=this.blocks[t],a=this._ifNode(e(i.node,"blocks["+t+"].node",this));r[t]={node:a,visible:i.visible}}return new n(r)}clone(){var e=this.blocks.map((function(e){return{node:e.node,visible:e.visible}}));return new n(e)}_toString(e){return this.blocks.map((function(r){return r.node.toString(e)+(r.visible?"":";")})).join("\n")}toJSON(){return{mathjs:Kv,blocks:this.blocks}}static fromJSON(e){return new n(e.blocks)}_toHTML(e){return this.blocks.map((function(r){return r.node.toHTML(e)+(r.visible?"":'<span class="math-separator">;</span>')})).join('<span class="math-separator"><br /></span>')}_toTex(e){return this.blocks.map((function(r){return r.node.toTex(e)+(r.visible?"":";")})).join("\\;\\;\n")}}return ed(n,"name",Kv),n}),{isClass:!0,isNode:!0}),ry="ConditionalNode",ty=ti(ry,["Node"],(e=>{var{Node:r}=e;class t extends r{constructor(e,r,t){if(super(),!In(e))throw new TypeError("Parameter condition must be a Node");if(!In(r))throw new TypeError("Parameter trueExpr must be a Node");if(!In(t))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=r,this.falseExpr=t}get type(){return ry}get isConditionalNode(){return!0}_compile(e,r){var t=this.condition._compile(e,r),n=this.trueExpr._compile(e,r),i=this.falseExpr._compile(e,r);return function(e,r,a){return function(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return!!e;if(e){if(rn(e))return!e.isZero();if(nn(e))return!(!e.re&&!e.im);if(on(e))return!!e.value}if(null==e)return!1;throw new TypeError('Unsupported type of condition "'+_n(e)+'"')}(t(e,r,a))?n(e,r,a):i(e,r,a)}}forEach(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)}map(e){return new t(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))}clone(){return new t(this.condition,this.trueExpr,this.falseExpr)}_toString(e){var r=e&&e.parenthesis?e.parenthesis:"keep",t=Vv(this,r,e&&e.implicit),n=this.condition.toString(e),i=Vv(this.condition,r,e&&e.implicit);("all"===r||"OperatorNode"===this.condition.type||null!==i&&i<=t)&&(n="("+n+")");var a=this.trueExpr.toString(e),o=Vv(this.trueExpr,r,e&&e.implicit);("all"===r||"OperatorNode"===this.trueExpr.type||null!==o&&o<=t)&&(a="("+a+")");var u=this.falseExpr.toString(e),s=Vv(this.falseExpr,r,e&&e.implicit);return("all"===r||"OperatorNode"===this.falseExpr.type||null!==s&&s<=t)&&(u="("+u+")"),n+" ? "+a+" : "+u}toJSON(){return{mathjs:ry,condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}}static fromJSON(e){return new t(e.condition,e.trueExpr,e.falseExpr)}_toHTML(e){var r=e&&e.parenthesis?e.parenthesis:"keep",t=Vv(this,r,e&&e.implicit),n=this.condition.toHTML(e),i=Vv(this.condition,r,e&&e.implicit);("all"===r||"OperatorNode"===this.condition.type||null!==i&&i<=t)&&(n='<span class="math-parenthesis math-round-parenthesis">(</span>'+n+'<span class="math-parenthesis math-round-parenthesis">)</span>');var a=this.trueExpr.toHTML(e),o=Vv(this.trueExpr,r,e&&e.implicit);("all"===r||"OperatorNode"===this.trueExpr.type||null!==o&&o<=t)&&(a='<span class="math-parenthesis math-round-parenthesis">(</span>'+a+'<span class="math-parenthesis math-round-parenthesis">)</span>');var u=this.falseExpr.toHTML(e),s=Vv(this.falseExpr,r,e&&e.implicit);return("all"===r||"OperatorNode"===this.falseExpr.type||null!==s&&s<=t)&&(u='<span class="math-parenthesis math-round-parenthesis">(</span>'+u+'<span class="math-parenthesis math-round-parenthesis">)</span>'),n+'<span class="math-operator math-conditional-operator">?</span>'+a+'<span class="math-operator math-conditional-operator">:</span>'+u}_toTex(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"}}return ed(t,"name",ry),t}),{isClass:!0,isNode:!0}),ny=function(){if(Xv)return Gv;Xv=1;var e=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},r={"{":"\\{","}":"\\}","\\":"\\textbackslash{}","#":"\\#",$:"\\$","%":"\\%","&":"\\&","^":"\\textasciicircum{}",_:"\\_","~":"\\textasciitilde{}"},t={"–":"\\--","—":"\\---"," ":"~","\t":"\\qquad{}","\r\n":"\\newline{}","\n":"\\newline{}"},n=function(r,t){return e({},r,t)};return Gv=function(i){for(var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=a.preserveFormatting,u=void 0!==o&&o,s=a.escapeMapFn,c=i+"",l="",f=(void 0===s?n:s)(e({},r),u?e({},t):{}),m=Object.keys(f),d=function(){var e=!1;m.forEach((function(r,t){e||c.length>=r.length&&c.slice(0,r.length)===r&&(l+=f[m[t]],c=c.slice(r.length,c.length),e=!0)})),e||(l+=c.slice(0,1),c=c.slice(1,c.length))};c;)d();return l},Gv}(),iy=Xn(ny),ay={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{?}"},oy={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"},uy={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(oy.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(oy.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(oy.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(oy.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(oy.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},fraction:{2:"\\frac{${args[0]}}{${args[1]}}"},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(oy.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(oy.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(oy.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(oy.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(oy.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(oy.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(oy.bitAnd,"${args[1]}\\right)")},bitNot:{1:oy.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(oy.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(oy.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(oy.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(oy.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(oy.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(oy.and,"${args[1]}\\right)")},not:{1:oy.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(oy.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(oy.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(oy.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(oy.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(oy.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(oy.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(oy.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(oy.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(oy.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(oy.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(oy.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(oy.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(oy.to,"${args[1]}\\right)")},numeric:function(e){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)"},bigint:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(ay.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)"}},sy={deg:"^\\circ"};function cy(e){return iy(e,{preserveFormatting:!0})}function ly(e,r){return(r=void 0!==r&&r)?Hn(sy,e)?sy[e]:"\\mathrm{"+cy(e)+"}":Hn(ay,e)?ay[e]:cy(e)}var fy="ConstantNode",my=ti(fy,["Node"],(e=>{var{Node:r}=e;class t extends r{constructor(e){super(),this.value=e}get type(){return fy}get isConstantNode(){return!0}_compile(e,r){var t=this.value;return function(){return t}}forEach(e){}map(e){return this.clone()}clone(){return new t(this.value)}_toString(e){return Go(this.value,e)}_toHTML(e){var r=this._toString(e);switch(_n(this.value)){case"number":case"bigint":case"BigNumber":case"Fraction":return'<span class="math-number">'+r+"</span>";case"string":return'<span class="math-string">'+r+"</span>";case"boolean":return'<span class="math-boolean">'+r+"</span>";case"null":return'<span class="math-null-symbol">'+r+"</span>";case"undefined":return'<span class="math-undefined">'+r+"</span>";default:return'<span class="math-symbol">'+r+"</span>"}}toJSON(){return{mathjs:fy,value:this.value}}static fromJSON(e){return new t(e.value)}_toTex(e){var r=this._toString(e),t=_n(this.value);switch(t){case"string":return"\\mathtt{"+cy(r)+"}";case"number":case"BigNumber":if(!("BigNumber"===t?this.value.isFinite():isFinite(this.value)))return this.value.valueOf()<0?"-\\infty":"\\infty";var n=r.toLowerCase().indexOf("e");return-1!==n?r.substring(0,n)+"\\cdot10^{"+r.substring(n+1)+"}":r;case"bigint":return""+r;case"Fraction":return this.value.toLatex();default:return r}}}return ed(t,"name",fy),t}),{isClass:!0,isNode:!0}),dy="FunctionAssignmentNode",py=ti(dy,["typed","Node"],(e=>{var{typed:r,Node:t}=e;function n(e,r,t){var n=Vv(e,r,t),i=Vv(e.expr,r,t);return"all"===r||null!==i&&i<=n}class i extends t{constructor(e,r,t){if(super(),"string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(r))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!In(t))throw new TypeError('Node expected for parameter "expr"');if(zv.has(e))throw Error('Illegal function name, "'+e+'" is a reserved keyword');var n=new Set;for(var i of r){var a="string"==typeof i?i:i.name;if(n.has(a))throw Error('Duplicate parameter name "'.concat(a,'"'));n.add(a)}this.name=e,this.params=r.map((function(e){return e&&e.name||e})),this.types=r.map((function(e){return e&&e.type||"any"})),this.expr=t}get type(){return dy}get isFunctionAssignmentNode(){return!0}_compile(e,t){var n=Object.create(t);xu(this.params,(function(e){n[e]=!0}));var i=this.expr,a=i._compile(e,n),o=this.name,u=this.params,s=Du(this.types,","),c=o+"("+Du(this.params,", ")+")";return function(e,t,n){var l={};l[s]=function(){for(var r=Object.create(t),i=0;i<u.length;i++)r[u[i]]=arguments[i];return a(e,r,n)};var f=r(o,l);return f.syntax=c,f.expr=""+i,e.set(o,f),f}}forEach(e){e(this.expr,"expr",this)}map(e){var r=this._ifNode(e(this.expr,"expr",this));return new i(this.name,this.params.slice(0),r)}clone(){return new i(this.name,this.params.slice(0),this.expr)}_toString(e){var r=e&&e.parenthesis?e.parenthesis:"keep",t=this.expr.toString(e);return n(this,r,e&&e.implicit)&&(t="("+t+")"),this.name+"("+this.params.join(", ")+") = "+t}toJSON(){var e=this.types;return{mathjs:dy,name:this.name,params:this.params.map((function(r,t){return{name:r,type:e[t]}})),expr:this.expr}}static fromJSON(e){return new i(e.name,e.params,e.expr)}_toHTML(e){for(var r=e&&e.parenthesis?e.parenthesis:"keep",t=[],i=0;i<this.params.length;i++)t.push('<span class="math-symbol math-parameter">'+Qo(this.params[i])+"</span>");var a=this.expr.toHTML(e);return n(this,r,e&&e.implicit)&&(a='<span class="math-parenthesis math-round-parenthesis">(</span>'+a+'<span class="math-parenthesis math-round-parenthesis">)</span>'),'<span class="math-function">'+Qo(this.name)+'</span><span class="math-parenthesis math-round-parenthesis">(</span>'+t.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>'+a}_toTex(e){var r=e&&e.parenthesis?e.parenthesis:"keep",t=this.expr.toTex(e);return n(this,r,e&&e.implicit)&&(t="\\left(".concat(t,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(ly).join(",")+"\\right)="+t}}return ed(i,"name",dy),i}),{isClass:!0,isNode:!0}),hy="IndexNode",vy=ti(hy,["Node","size"],(e=>{var{Node:r,size:t}=e;class n extends r{constructor(e,r){if(super(),this.dimensions=e,this.dotNotation=r||!1,!Array.isArray(e)||!e.every(In))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw Error("dotNotation only applicable for object properties")}get type(){return hy}get isIndexNode(){return!0}_compile(e,r){var n=gu(this.dimensions,(function(n,i){if(n.filter((e=>e.isSymbolNode&&"end"===e.name)).length>0){var a=Object.create(r);a.end=!0;var o=n._compile(e,a);return function(e,r,n){if(!cn(n)&&!sn(n)&&!un(n))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+_n(n));var a=t(n).valueOf(),u=Object.create(r);return u.end=a[i],o(e,u,n)}}return n._compile(e,r)})),i=_t(e,"index");return function(e,r,t){var a=gu(n,(function(n){return n(e,r,t)}));return i(...a)}}forEach(e){for(var r=0;r<this.dimensions.length;r++)e(this.dimensions[r],"dimensions["+r+"]",this)}map(e){for(var r=[],t=0;t<this.dimensions.length;t++)r[t]=this._ifNode(e(this.dimensions[t],"dimensions["+t+"]",this));return new n(r,this.dotNotation)}clone(){return new n(this.dimensions.slice(0),this.dotNotation)}isObjectProperty(){return 1===this.dimensions.length&&Bn(this.dimensions[0])&&"string"==typeof this.dimensions[0].value}getObjectProperty(){return this.isObjectProperty()?this.dimensions[0].value:null}_toString(e){return this.dotNotation?"."+this.getObjectProperty():"["+this.dimensions.join(", ")+"]"}toJSON(){return{mathjs:hy,dimensions:this.dimensions,dotNotation:this.dotNotation}}static fromJSON(e){return new n(e.dimensions,e.dotNotation)}_toHTML(e){for(var r=[],t=0;t<this.dimensions.length;t++)r[t]=this.dimensions[t].toHTML();return this.dotNotation?'<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">'+Qo(this.getObjectProperty())+"</span>":'<span class="math-parenthesis math-square-parenthesis">[</span>'+r.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(e){var r=this.dimensions.map((function(r){return r.toTex(e)}));return this.dotNotation?"."+this.getObjectProperty():"_{"+r.join(",")+"}"}}return ed(n,"name",hy),n}),{isClass:!0,isNode:!0}),yy="ObjectNode",by=ti(yy,["Node"],(e=>{var{Node:r}=e;class t extends r{constructor(e){if(super(),this.properties=e||{},e&&("object"!=typeof e||!Object.keys(e).every((function(r){return In(e[r])}))))throw new TypeError("Object containing Nodes expected")}get type(){return yy}get isObjectNode(){return!0}_compile(e,r){var t={};for(var n in this.properties)if(Hn(this.properties,n)){var i=Xo(n),a=JSON.parse(i),o=_t(this.properties,n);t[a]=o._compile(e,r)}return function(e,r,n){var i={};for(var a in t)Hn(t,a)&&(i[a]=t[a](e,r,n));return i}}forEach(e){for(var r in this.properties)Hn(this.properties,r)&&e(this.properties[r],"properties["+Xo(r)+"]",this)}map(e){var r={};for(var n in this.properties)Hn(this.properties,n)&&(r[n]=this._ifNode(e(this.properties[n],"properties["+Xo(n)+"]",this)));return new t(r)}clone(){var e={};for(var r in this.properties)Hn(this.properties,r)&&(e[r]=this.properties[r]);return new t(e)}_toString(e){var r=[];for(var t in this.properties)Hn(this.properties,t)&&r.push(Xo(t)+": "+this.properties[t].toString(e));return"{"+r.join(", ")+"}"}toJSON(){return{mathjs:yy,properties:this.properties}}static fromJSON(e){return new t(e.properties)}_toHTML(e){var r=[];for(var t in this.properties)Hn(this.properties,t)&&r.push('<span class="math-symbol math-property">'+Qo(t)+'</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>'+this.properties[t].toHTML(e));return'<span class="math-parenthesis math-curly-parenthesis">{</span>'+r.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-curly-parenthesis">}</span>'}_toTex(e){var r=[];for(var t in this.properties)Hn(this.properties,t)&&r.push("\\mathbf{"+t+":} & "+this.properties[t].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}"+r.join("\n")+"\\end{array}\\right\\}"}}return ed(t,"name",yy),t}),{isClass:!0,isNode:!0});function gy(e,r){return new Xt(e,new Gt(r),new Set(Object.keys(r)))}var xy="OperatorNode",wy=ti(xy,["Node"],(e=>{var{Node:r}=e;function t(e,r){var n=e;if("auto"===r)for(;Rn(n);)n=n.content;return!!Bn(n)||!!jn(n)&&t(n.args[0],r)}function n(e,r,n,i,a){var o,u=Vv(e,r,n),s=Hv(e,r);if("all"===r||i.length>2&&"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier())return i.map((function(e){switch(e.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}}));switch(i.length){case 0:o=[];break;case 1:var c=Vv(i[0],r,n,e);if(a&&null!==c){var l,f;if("keep"===r?(l=i[0].getIdentifier(),f=e.getIdentifier()):(l=i[0].getContent().getIdentifier(),f=e.getContent().getIdentifier()),!1===Wv[u][f].latexLeftParens){o=[!1];break}if(!1===Wv[c][l].latexParens){o=[!1];break}}if(null===c){o=[!1];break}if(c<=u){o=[!0];break}o=[!1];break;case 2:var m,d,p=Vv(i[0],r,n,e),h=Zv(e,i[0],r);m=null!==p&&(p===u&&"right"===s&&!h||p<u);var v,y,b,g=Vv(i[1],r,n,e),x=Zv(e,i[1],r);d=null!==g&&(g===u&&"left"===s&&!x||g<u),a&&("keep"===r?(v=e.getIdentifier(),y=e.args[0].getIdentifier(),b=e.args[1].getIdentifier()):(v=e.getContent().getIdentifier(),y=e.args[0].getContent().getIdentifier(),b=e.args[1].getContent().getIdentifier()),null!==p&&(!1===Wv[u][v].latexLeftParens&&(m=!1),!1===Wv[p][y].latexParens&&(m=!1)),null!==g&&(!1===Wv[u][v].latexRightParens&&(d=!1),!1===Wv[g][b].latexParens&&(d=!1))),o=[m,d];break;default:"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier()||(o=i.map((function(t){var i=Vv(t,r,n,e),a=Zv(e,t,r),o=Hv(t,r);return null!==i&&(u===i&&s===o&&!a||i<u)})))}if(i.length>=2&&"OperatorNode:multiply"===e.getIdentifier()&&e.implicit&&"all"!==r&&"hide"===n)for(var w=1;w<o.length;++w)!t(i[w],r)||o[w-1]||"keep"===r&&Rn(i[w-1])||(o[w]=!0);return o}class i extends r{constructor(e,r,t,n,i){if(super(),"string"!=typeof e)throw new TypeError('string expected for parameter "op"');if("string"!=typeof r)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(t)||!t.every(In))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=!0===n,this.isPercentage=!0===i,this.op=e,this.fn=r,this.args=t||[]}get type(){return xy}get isOperatorNode(){return!0}_compile(e,r){if("string"!=typeof this.fn||!Vt(e,this.fn))throw Error(e[this.fn]?'No access to function "'+this.fn+'"':"Function "+this.fn+' missing in provided namespace "math"');var t=_t(e,this.fn),n=gu(this.args,(function(t){return t._compile(e,r)}));if("function"==typeof t&&!0===t.rawArgs){var i=this.args;return function(r,n){return t(i,e,gy(r,n))}}if(1===n.length){var a=n[0];return function(e,r,n){return t(a(e,r,n))}}if(2===n.length){var o=n[0],u=n[1];return function(e,r,n){return t(o(e,r,n),u(e,r,n))}}return function(e,r,i){return t.apply(null,gu(n,(function(t){return t(e,r,i)})))}}forEach(e){for(var r=0;r<this.args.length;r++)e(this.args[r],"args["+r+"]",this)}map(e){for(var r=[],t=0;t<this.args.length;t++)r[t]=this._ifNode(e(this.args[t],"args["+t+"]",this));return new i(this.op,this.fn,r,this.implicit,this.isPercentage)}clone(){return new i(this.op,this.fn,this.args.slice(0),this.implicit,this.isPercentage)}isUnary(){return 1===this.args.length}isBinary(){return 2===this.args.length}_toString(e){var r=e&&e.parenthesis?e.parenthesis:"keep",t=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,r,t,i,!1);if(1===i.length){var o=Hv(this,r),u=i[0].toString(e);a[0]&&(u="("+u+")");var s=/[a-zA-Z]+/.test(this.op);return"right"===o?this.op+(s?" ":"")+u:"left"===o?u+(s?" ":"")+this.op:u+this.op}if(2===i.length){var c=i[0].toString(e),l=i[1].toString(e);return a[0]&&(c="("+c+")"),a[1]&&(l="("+l+")"),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===t?c+" "+l:c+" "+this.op+" "+l}if(i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var f=i.map((function(r,t){return r=r.toString(e),a[t]&&(r="("+r+")"),r}));return this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===t?f.join(" "):f.join(" "+this.op+" ")}return this.fn+"("+this.args.join(", ")+")"}toJSON(){return{mathjs:xy,op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}}static fromJSON(e){return new i(e.op,e.fn,e.args,e.implicit,e.isPercentage)}_toHTML(e){var r=e&&e.parenthesis?e.parenthesis:"keep",t=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,r,t,i,!1);if(1===i.length){var o=Hv(this,r),u=i[0].toHTML(e);return a[0]&&(u='<span class="math-parenthesis math-round-parenthesis">(</span>'+u+'<span class="math-parenthesis math-round-parenthesis">)</span>'),"right"===o?'<span class="math-operator math-unary-operator math-lefthand-unary-operator">'+Qo(this.op)+"</span>"+u:u+'<span class="math-operator math-unary-operator math-righthand-unary-operator">'+Qo(this.op)+"</span>"}if(2===i.length){var s=i[0].toHTML(e),c=i[1].toHTML(e);return a[0]&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),a[1]&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===t?s+'<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'+c:s+'<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Qo(this.op)+"</span>"+c}var l=i.map((function(r,t){return r=r.toHTML(e),a[t]&&(r='<span class="math-parenthesis math-round-parenthesis">(</span>'+r+'<span class="math-parenthesis math-round-parenthesis">)</span>'),r}));return i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())?this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===t?l.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'):l.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Qo(this.op)+"</span>"):'<span class="math-function">'+Qo(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+l.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}_toTex(e){var r=e&&e.parenthesis?e.parenthesis:"keep",t=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,r,t,i,!0),o=oy[this.fn];if(o=void 0===o?this.op:o,1===i.length){var u=Hv(this,r),s=i[0].toTex(e);return a[0]&&(s="\\left(".concat(s,"\\right)")),"right"===u?o+s:s+o}if(2===i.length){var c=i[0],l=c.toTex(e);a[0]&&(l="\\left(".concat(l,"\\right)"));var f,m=i[1].toTex(e);switch(a[1]&&(m="\\left(".concat(m,"\\right)")),f="keep"===r?c.getIdentifier():c.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return o+"{"+l+"}{"+m+"}";case"OperatorNode:pow":switch(l="{"+l+"}",m="{"+m+"}",f){case"ConditionalNode":case"OperatorNode:divide":l="\\left(".concat(l,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&"hide"===t)return l+"~"+m}return l+o+m}if(i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var d=i.map((function(r,t){return r=r.toTex(e),a[t]&&(r="\\left(".concat(r,"\\right)")),r}));return"OperatorNode:multiply"===this.getIdentifier()&&this.implicit&&"hide"===t?d.join("~"):d.join(o)}return"\\mathrm{"+this.fn+"}\\left("+i.map((function(r){return r.toTex(e)})).join(",")+"\\right)"}getIdentifier(){return this.type+":"+this.fn}}return ed(i,"name",xy),i}),{isClass:!0,isNode:!0}),Dy="ParenthesisNode",Ny=ti(Dy,["Node"],(e=>{var{Node:r}=e;class t extends r{constructor(e){if(super(),!In(e))throw new TypeError('Node expected for parameter "content"');this.content=e}get type(){return Dy}get isParenthesisNode(){return!0}_compile(e,r){return this.content._compile(e,r)}getContent(){return this.content.getContent()}forEach(e){e(this.content,"content",this)}map(e){var r=e(this.content,"content",this);return new t(r)}clone(){return new t(this.content)}_toString(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)}toJSON(){return{mathjs:Dy,content:this.content}}static fromJSON(e){return new t(e.content)}_toHTML(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?'<span class="math-parenthesis math-round-parenthesis">(</span>'+this.content.toHTML(e)+'<span class="math-parenthesis math-round-parenthesis">)</span>':this.content.toHTML(e)}_toTex(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)}}return ed(t,"name",Dy),t}),{isClass:!0,isNode:!0}),Ay="RangeNode",My=ti(Ay,["Node"],(e=>{var{Node:r}=e;function t(e,r,t){var n=Vv(e,r,t),i={},a=Vv(e.start,r,t);if(i.start=null!==a&&a<=n||"all"===r,e.step){var o=Vv(e.step,r,t);i.step=null!==o&&o<=n||"all"===r}var u=Vv(e.end,r,t);return i.end=null!==u&&u<=n||"all"===r,i}class n extends r{constructor(e,r,t){if(super(),!In(e))throw new TypeError("Node expected");if(!In(r))throw new TypeError("Node expected");if(t&&!In(t))throw new TypeError("Node expected");if(arguments.length>3)throw Error("Too many arguments");this.start=e,this.end=r,this.step=t||null}get type(){return Ay}get isRangeNode(){return!0}needsEnd(){return this.filter((function(e){return Pn(e)&&"end"===e.name})).length>0}_compile(e,r){var t=e.range,n=this.start._compile(e,r),i=this.end._compile(e,r);if(this.step){var a=this.step._compile(e,r);return function(e,r,o){return t(n(e,r,o),i(e,r,o),a(e,r,o))}}return function(e,r,a){return t(n(e,r,a),i(e,r,a))}}forEach(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)}map(e){return new n(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))}clone(){return new n(this.start,this.end,this.step&&this.step)}_toString(e){var r,n=t(this,e&&e.parenthesis?e.parenthesis:"keep",e&&e.implicit),i=this.start.toString(e);if(n.start&&(i="("+i+")"),r=i,this.step){var a=this.step.toString(e);n.step&&(a="("+a+")"),r+=":"+a}var o=this.end.toString(e);return n.end&&(o="("+o+")"),r+":"+o}toJSON(){return{mathjs:Ay,start:this.start,end:this.end,step:this.step}}static fromJSON(e){return new n(e.start,e.end,e.step)}_toHTML(e){var r,n=t(this,e&&e.parenthesis?e.parenthesis:"keep",e&&e.implicit),i=this.start.toHTML(e);if(n.start&&(i='<span class="math-parenthesis math-round-parenthesis">(</span>'+i+'<span class="math-parenthesis math-round-parenthesis">)</span>'),r=i,this.step){var a=this.step.toHTML(e);n.step&&(a='<span class="math-parenthesis math-round-parenthesis">(</span>'+a+'<span class="math-parenthesis math-round-parenthesis">)</span>'),r+='<span class="math-operator math-range-operator">:</span>'+a}var o=this.end.toHTML(e);return n.end&&(o='<span class="math-parenthesis math-round-parenthesis">(</span>'+o+'<span class="math-parenthesis math-round-parenthesis">)</span>'),r+'<span class="math-operator math-range-operator">:</span>'+o}_toTex(e){var r=t(this,e&&e.parenthesis?e.parenthesis:"keep",e&&e.implicit),n=this.start.toTex(e);if(r.start&&(n="\\left(".concat(n,"\\right)")),this.step){var i=this.step.toTex(e);r.step&&(i="\\left(".concat(i,"\\right)")),n+=":"+i}var a=this.end.toTex(e);return r.end&&(a="\\left(".concat(a,"\\right)")),n+":"+a}}return ed(n,"name",Ay),n}),{isClass:!0,isNode:!0}),Cy="RelationalNode",Ey=ti(Cy,["Node"],(e=>{var{Node:r}=e,t={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="};class n extends r{constructor(e,r){if(super(),!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(r))throw new TypeError("Parameter params must be an array");if(e.length!==r.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=r}get type(){return Cy}get isRelationalNode(){return!0}_compile(e,r){var t=this,n=this.params.map((t=>t._compile(e,r)));return function(r,i,a){for(var o,u=n[0](r,i,a),s=0;s<t.conditionals.length;s++)if(o=u,u=n[s+1](r,i,a),!_t(e,t.conditionals[s])(o,u))return!1;return!0}}forEach(e){this.params.forEach(((r,t)=>e(r,"params["+t+"]",this)),this)}map(e){return new n(this.conditionals.slice(),this.params.map(((r,t)=>this._ifNode(e(r,"params["+t+"]",this))),this))}clone(){return new n(this.conditionals,this.params)}_toString(e){for(var r=e&&e.parenthesis?e.parenthesis:"keep",n=Vv(this,r,e&&e.implicit),i=this.params.map((function(t){var i=Vv(t,r,e&&e.implicit);return"all"===r||null!==i&&i<=n?"("+t.toString(e)+")":t.toString(e)})),a=i[0],o=0;o<this.conditionals.length;o++)a+=" "+t[this.conditionals[o]],a+=" "+i[o+1];return a}toJSON(){return{mathjs:Cy,conditionals:this.conditionals,params:this.params}}static fromJSON(e){return new n(e.conditionals,e.params)}_toHTML(e){for(var r=e&&e.parenthesis?e.parenthesis:"keep",n=Vv(this,r,e&&e.implicit),i=this.params.map((function(t){var i=Vv(t,r,e&&e.implicit);return"all"===r||null!==i&&i<=n?'<span class="math-parenthesis math-round-parenthesis">(</span>'+t.toHTML(e)+'<span class="math-parenthesis math-round-parenthesis">)</span>':t.toHTML(e)})),a=i[0],o=0;o<this.conditionals.length;o++)a+='<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Qo(t[this.conditionals[o]])+"</span>"+i[o+1];return a}_toTex(e){for(var r=e&&e.parenthesis?e.parenthesis:"keep",t=Vv(this,r,e&&e.implicit),n=this.params.map((function(n){var i=Vv(n,r,e&&e.implicit);return"all"===r||null!==i&&i<=t?"\\left("+n.toTex(e)+"\right)":n.toTex(e)})),i=n[0],a=0;a<this.conditionals.length;a++)i+=oy[this.conditionals[a]]+n[a+1];return i}}return ed(n,"name",Cy),n}),{isClass:!0,isNode:!0}),Sy=ti("SymbolNode",["math","?Unit","Node"],(e=>{var{math:r,Unit:t,Node:n}=e;function i(e){return!!t&&t.isValuelessUnit(e)}class a extends n{constructor(e){if(super(),"string"!=typeof e)throw new TypeError('String expected for parameter "name"');this.name=e}get type(){return"SymbolNode"}get isSymbolNode(){return!0}_compile(e,r){var n=this.name;if(!0===r[n])return function(e,r){return _t(r,n)};if(n in e)return function(r){return r.has(n)?r.get(n):_t(e,n)};var o=i(n);return function(e){return e.has(n)?e.get(n):o?new t(null,n):a.onUndefinedSymbol(n)}}forEach(e){}map(e){return this.clone()}static onUndefinedSymbol(e){throw Error("Undefined symbol "+e)}clone(){return new a(this.name)}_toString(e){return this.name}_toHTML(e){var r=Qo(this.name);return"true"===r||"false"===r?'<span class="math-symbol math-boolean">'+r+"</span>":"i"===r?'<span class="math-symbol math-imaginary-symbol">'+r+"</span>":"Infinity"===r?'<span class="math-symbol math-infinity-symbol">'+r+"</span>":"NaN"===r?'<span class="math-symbol math-nan-symbol">'+r+"</span>":"null"===r?'<span class="math-symbol math-null-symbol">'+r+"</span>":"undefined"===r?'<span class="math-symbol math-undefined-symbol">'+r+"</span>":'<span class="math-symbol">'+r+"</span>"}toJSON(){return{mathjs:"SymbolNode",name:this.name}}static fromJSON(e){return new a(e.name)}_toTex(e){var t=!1;void 0===r[this.name]&&i(this.name)&&(t=!0);var n=ly(this.name,t);return"\\"===n[0]?n:" "+n}}return a}),{isClass:!0,isNode:!0}),Fy="FunctionNode",By=ti(Fy,["math","Node","SymbolNode"],(e=>{var r,{math:t,Node:n,SymbolNode:i}=e,a=e=>Go(e,{truncate:78});function o(e,r,t){for(var n,i="",a=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,o=0;null!==(n=a.exec(e));)if(i+=e.substring(o,n.index),o=n.index,"$$"===n[0])i+="$",o++;else{o+=n[0].length;var u=r[n[1]];if(!u)throw new ReferenceError("Template: Property "+n[1]+" does not exist.");if(void 0===n[2])switch(typeof u){case"string":i+=u;break;case"object":if(In(u))i+=u.toTex(t);else{if(!Array.isArray(u))throw new TypeError("Template: "+n[1]+" has to be a Node, String or array of Nodes");i+=u.map((function(e,r){if(In(e))return e.toTex(t);throw new TypeError("Template: "+n[1]+"["+r+"] is not a Node.")})).join(",")}break;default:throw new TypeError("Template: "+n[1]+" has to be a Node, String or array of Nodes")}else{if(!In(u[n[2]]&&u[n[2]]))throw new TypeError("Template: "+n[1]+"["+n[2]+"] is not a Node.");i+=u[n[2]].toTex(t)}}return i+e.slice(o)}class u extends n{constructor(e,r){if(super(),"string"==typeof e&&(e=new i(e)),!In(e))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(r)||!r.every(In))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=e,this.args=r||[]}get name(){return this.fn.name||""}get type(){return Fy}get isFunctionNode(){return!0}_compile(e,r){var t=this.args.map((t=>t._compile(e,r)));if(!Pn(this.fn)){if(Mn(this.fn)&&On(this.fn.index)&&this.fn.index.isObjectProperty()){var n=this.fn.object._compile(e,r),i=this.fn.index.getObjectProperty(),o=this.args;return function(r,a,u){var s=n(r,a,u),c=function(e,r){if(!Vt(e,r))throw Error('No access to method "'+r+'"');return e[r]}(s,i);if(null!=c&&c.rawArgs)return c(o,e,gy(r,a));var l=t.map((e=>e(r,a,u)));return c.apply(s,l)}}var s=""+this.fn,c=this.fn._compile(e,r),l=this.args;return function(r,n,i){var o=c(r,n,i);if("function"!=typeof o)throw new TypeError("Expression '".concat(s,"' did not evaluate to a function; value is:")+"\n ".concat(a(o)));if(o.rawArgs)return o(l,e,gy(r,n));var u=t.map((e=>e(r,n,i)));return o.apply(o,u)}}var f=this.fn.name;if(r[f]){var m=this.args;return function(r,n,i){var o=_t(n,f);if("function"!=typeof o)throw new TypeError("Argument '".concat(f,"' was not a function; received: ").concat(a(o)));if(o.rawArgs)return o(m,e,gy(r,n));var u=t.map((e=>e(r,n,i)));return o.apply(o,u)}}var d=f in e?_t(e,f):void 0,p=r=>{var t;if(r.has(f))t=r.get(f);else{if(!(f in e))return u.onUndefinedFunction(f);t=_t(e,f)}if("function"==typeof t)return t;throw new TypeError("'".concat(f,"' is not a function; its value is:\n ").concat(a(t)))};if("function"==typeof d&&!0===d.rawArgs){var h=this.args;return function(r,n,i){var a=p(r);return!0===a.rawArgs?a(h,e,gy(r,n)):a(...t.map((e=>e(r,n,i))))}}switch(t.length){case 0:return function(e){return p(e)()};case 1:return function(e,r,n){return p(e)((0,t[0])(e,r,n))};case 2:return function(e,r,n){var i=p(e),a=t[1];return i((0,t[0])(e,r,n),a(e,r,n))};default:return function(e,r,n){return p(e)(...t.map((t=>t(e,r,n))))}}}forEach(e){e(this.fn,"fn",this);for(var r=0;r<this.args.length;r++)e(this.args[r],"args["+r+"]",this)}map(e){for(var r=this._ifNode(e(this.fn,"fn",this)),t=[],n=0;n<this.args.length;n++)t[n]=this._ifNode(e(this.args[n],"args["+n+"]",this));return new u(r,t)}clone(){return new u(this.fn,this.args.slice(0))}toString(e){var r,t=this.fn.toString(e);return e&&"object"==typeof e.handler&&Hn(e.handler,t)&&(r=e.handler[t](this,e)),void 0!==r?r:super.toString(e)}_toString(e){var r=this.args.map((function(r){return r.toString(e)}));return(Tn(this.fn)?"("+this.fn.toString(e)+")":this.fn.toString(e))+"("+r.join(", ")+")"}toJSON(){return{mathjs:Fy,fn:this.fn,args:this.args}}_toHTML(e){var r=this.args.map((function(r){return r.toHTML(e)}));return'<span class="math-function">'+Qo(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+r.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}toTex(e){var r;return e&&"object"==typeof e.handler&&Hn(e.handler,this.name)&&(r=e.handler[this.name](this,e)),void 0!==r?r:super.toTex(e)}_toTex(e){var r,n,i=this.args.map((function(r){return r.toTex(e)}));switch(uy[this.name]&&(r=uy[this.name]),!t[this.name]||"function"!=typeof t[this.name].toTex&&"object"!=typeof t[this.name].toTex&&"string"!=typeof t[this.name].toTex||(r=t[this.name].toTex),typeof r){case"function":n=r(this,e);break;case"string":n=o(r,this,e);break;case"object":switch(typeof r[i.length]){case"function":n=r[i.length](this,e);break;case"string":n=o(r[i.length],this,e)}}return void 0!==n?n:o("\\mathrm{${name}}\\left(${args}\\right)",this,e)}getIdentifier(){return this.type+":"+this.name}}return r=u,ed(u,"name",Fy),ed(u,"onUndefinedFunction",(function(e){throw Error("Undefined function "+e)})),ed(u,"fromJSON",(function(e){return new r(e.fn,e.args)})),u}),{isClass:!0,isNode:!0}),qy="parse",Ty=ti(qy,["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],(e=>{var{typed:r,numeric:t,config:n,AccessorNode:i,ArrayNode:a,AssignmentNode:o,BlockNode:u,ConditionalNode:s,ConstantNode:c,FunctionAssignmentNode:l,FunctionNode:f,IndexNode:m,ObjectNode:d,OperatorNode:p,ParenthesisNode:h,RangeNode:v,RelationalNode:y,SymbolNode:b}=e,g=r(qy,{string:function(e){return z(e,{})},"Array | Matrix":function(e){return x(e,{})},"string, Object":function(e,r){return z(e,void 0!==r.nodes?r.nodes:{})},"Array | Matrix, Object":x});function x(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=void 0!==r.nodes?r.nodes:{};return Wu(e,(function(e){if("string"!=typeof e)throw new TypeError("String expected");return z(e,t)}))}var w={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},D={",":!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,">>>":!0},N={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},A={true:!0,false:!1,null:null,undefined:void 0},M=["NaN","Infinity"],C={'"':'"',"'":"'","\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function E(e,r){return e.expression.substr(e.index,r)}function S(e){return E(e,1)}function F(e){e.index++}function B(e){return e.expression.charAt(e.index-1)}function q(e){return e.expression.charAt(e.index+1)}function T(e){for(e.tokenType=w.NULL,e.token="",e.comment="";;){if("#"===S(e))for(;"\n"!==S(e)&&""!==S(e);)e.comment+=S(e),F(e);if(!g.isWhitespace(S(e),e.nestingLevel))break;F(e)}if(""!==S(e)){if("\n"===S(e)&&!e.nestingLevel)return e.tokenType=w.DELIMITER,e.token=S(e),void F(e);var r=S(e),t=E(e,2),n=E(e,3);if(3===n.length&&D[n])return e.tokenType=w.DELIMITER,e.token=n,F(e),F(e),void F(e);if(2===t.length&&D[t])return e.tokenType=w.DELIMITER,e.token=t,F(e),void F(e);if(D[r])return e.tokenType=w.DELIMITER,e.token=r,void F(e);if(g.isDigitDot(r)){e.tokenType=w.NUMBER;var i=E(e,2);if("0b"===i||"0o"===i||"0x"===i){for(e.token+=S(e),F(e),e.token+=S(e),F(e);g.isHexDigit(S(e));)e.token+=S(e),F(e);if("."===S(e))for(e.token+=".",F(e);g.isHexDigit(S(e));)e.token+=S(e),F(e);else if("i"===S(e))for(e.token+="i",F(e);g.isDigit(S(e));)e.token+=S(e),F(e);return}if("."===S(e)){if(e.token+=S(e),F(e),!g.isDigit(S(e)))return void(e.tokenType=w.DELIMITER)}else{for(;g.isDigit(S(e));)e.token+=S(e),F(e);g.isDecimalMark(S(e),q(e))&&(e.token+=S(e),F(e))}for(;g.isDigit(S(e));)e.token+=S(e),F(e);if("E"===S(e)||"e"===S(e))if(g.isDigit(q(e))||"-"===q(e)||"+"===q(e)){if(e.token+=S(e),F(e),"+"!==S(e)&&"-"!==S(e)||(e.token+=S(e),F(e)),!g.isDigit(S(e)))throw ne(e,'Digit expected, got "'+S(e)+'"');for(;g.isDigit(S(e));)e.token+=S(e),F(e);if(g.isDecimalMark(S(e),q(e)))throw ne(e,'Digit expected, got "'+S(e)+'"')}else if(g.isDecimalMark(q(e),e.expression.charAt(e.index+2)))throw F(e),ne(e,'Digit expected, got "'+S(e)+'"')}else{if(!g.isAlpha(S(e),B(e),q(e))){for(e.tokenType=w.UNKNOWN;""!==S(e);)e.token+=S(e),F(e);throw ne(e,'Syntax error in part "'+e.token+'"')}for(;g.isAlpha(S(e),B(e),q(e))||g.isDigit(S(e));)e.token+=S(e),F(e);e.tokenType=Hn(N,e.token)?w.DELIMITER:w.SYMBOL}}else e.tokenType=w.DELIMITER}function k(e){do{T(e)}while("\n"===e.token)}function O(e){e.nestingLevel++}function I(e){e.nestingLevel--}function z(e,r){var t={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:w.NULL,nestingLevel:0,conditionalLevel:null};Pt(t,{expression:e,extraNodes:r}),T(t);var n=function(e){var r,t=[];for(""!==e.token&&"\n"!==e.token&&";"!==e.token&&(r=j(e),e.comment&&(r.comment=e.comment));"\n"===e.token||";"===e.token;)0===t.length&&r&&t.push({node:r,visible:";"!==e.token}),T(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&(r=j(e),e.comment&&(r.comment=e.comment),t.push({node:r,visible:";"!==e.token}));return t.length>0?new u(t):(r||(r=new c(void 0),e.comment&&(r.comment=e.comment)),r)}(t);if(""!==t.token)throw t.tokenType===w.DELIMITER?ie(t,"Unexpected operator "+t.token):ne(t,'Unexpected part "'+t.token+'"');return n}function j(e){var r,t,n,i,a=function(e){for(var r=function(e){for(var r=R(e);"or"===e.token;)k(e),r=new p("or","or",[r,R(e)]);return r}(e);"?"===e.token;){var t=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,k(e);var n=r,i=j(e);if(":"!==e.token)throw ne(e,"False part of conditional expression expected");e.conditionalLevel=null,k(e);var a=j(e);r=new s(n,i,a),e.conditionalLevel=t}return r}(e);if("="===e.token){if(Pn(a))return r=a.name,k(e),n=j(e),new o(new b(r),n);if(Mn(a))return k(e),n=j(e),new o(a.object,a.index,n);if(kn(a)&&Pn(a.fn)&&(i=!0,t=[],r=a.name,a.args.forEach((function(e,r){Pn(e)?t[r]=e.name:i=!1})),i))return k(e),n=j(e),new l(r,t,n);throw ne(e,"Invalid left hand side of assignment operator =")}return a}function R(e){for(var r=U(e);"xor"===e.token;)k(e),r=new p("xor","xor",[r,U(e)]);return r}function U(e){for(var r=$(e);"and"===e.token;)k(e),r=new p("and","and",[r,$(e)]);return r}function $(e){for(var r=P(e);"|"===e.token;)k(e),r=new p("|","bitOr",[r,P(e)]);return r}function P(e){for(var r=L(e);"^|"===e.token;)k(e),r=new p("^|","bitXor",[r,L(e)]);return r}function L(e){for(var r=_(e);"&"===e.token;)k(e),r=new p("&","bitAnd",[r,_(e)]);return r}function _(e){for(var r=[W(e)],t=[],n={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};Hn(n,e.token);)t.push({name:e.token,fn:n[e.token]}),k(e),r.push(W(e));return 1===r.length?r[0]:2===r.length?new p(t[0].name,t[0].fn,r):new y(t.map((e=>e.fn)),r)}function W(e){var r,t,n,i;r=J(e);for(var a={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Hn(a,e.token);)n=a[t=e.token],k(e),i=[r,J(e)],r=new p(t,n,i);return r}function J(e){var r,t,n,i;r=V(e);for(var a={to:"to",in:"to"};Hn(a,e.token);)n=a[t=e.token],k(e),"in"===t&&"])},;".includes(e.token)?r=new p("*","multiply",[r,new b("in")],!0):(i=[r,V(e)],r=new p(t,n,i));return r}function V(e){var r,t=[];if(r=":"===e.token?new c(1):H(e),":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(t.push(r);":"===e.token&&t.length<3;)k(e),t.push(")"===e.token||"]"===e.token||","===e.token||""===e.token?new b("end"):H(e));r=3===t.length?new v(t[0],t[2],t[1]):new v(t[0],t[1])}return r}function H(e){var r,t,n,i;r=Z(e);for(var a={"+":"add","-":"subtract"};Hn(a,e.token);){n=a[t=e.token],k(e);var o=Z(e);i=o.isPercentage?[r,new p("*","multiply",[r,o])]:[r,o],r=new p(t,n,i)}return r}function Z(e){var r,t,n,i;t=r=G(e);for(var a={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"};Hn(a,e.token);)if(i=a[n=e.token],k(e),"%"===n&&e.tokenType===w.DELIMITER&&"("!==e.token)if(""!==e.token&&a[e.token]){var o=new p("/","divide",[r,new c(100)],!1,!0);i=a[n=e.token],k(e),t=G(e),r=new p(n,i,[o,t])}else r=new p("/","divide",[r,new c(100)],!1,!0);else t=G(e),r=new p(n,i,[r,t]);return r}function G(e){var r,t;for(t=r=X(e);e.tokenType===w.SYMBOL||"in"===e.token&&Bn(r)||"in"===e.token&&jn(r)&&"unaryMinus"===r.fn&&Bn(r.args[0])||!(e.tokenType!==w.NUMBER||Bn(t)||jn(t)&&"!"!==t.op)||"("===e.token;)t=X(e),r=new p("*","multiply",[r,t],!0);return r}function X(e){for(var r=Y(e),t=r,n=[];"/"===e.token&&qn(t);){if(n.push(Pt({},e)),k(e),e.tokenType!==w.NUMBER){Pt(e,n.pop());break}if(n.push(Pt({},e)),k(e),e.tokenType!==w.SYMBOL&&"("!==e.token&&"in"!==e.token){n.pop(),Pt(e,n.pop());break}Pt(e,n.pop()),n.pop(),t=Y(e),r=new p("/","divide",[r,t])}return r}function Y(e){var r,t,n,i={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Hn(i,e.token)?(n=i[e.token],r=e.token,k(e),t=[Y(e)],new p(r,n,t)):function(e){var r,t,n,i;return r=function(e){for(var r=Q(e);"??"===e.token;)k(e),r=new p("??","nullish",[r,Q(e)]);return r}(e),("^"===e.token||".^"===e.token)&&(n="^"===(t=e.token)?"pow":"dotPow",k(e),i=[r,Y(e)],r=new p(t,n,i)),r}(e)}function Q(e){var r,i,o;r=function(e){var r=[];if(e.tokenType===w.SYMBOL&&Hn(e.extraNodes,e.token)){var i=e.extraNodes[e.token];if(T(e),"("===e.token){if(r=[],O(e),T(e),")"!==e.token)for(r.push(j(e));","===e.token;)T(e),r.push(j(e));if(")"!==e.token)throw ne(e,"Parenthesis ) expected");I(e),T(e)}return new i(r)}return function(e){var r;return e.tokenType===w.SYMBOL||e.tokenType===w.DELIMITER&&e.token in N?(r=e.token,T(e),K(e,Hn(A,r)?new c(A[r]):M.includes(r)?new c(t(r,"number")):new b(r))):function(e){var r;return'"'===e.token||"'"===e.token?(r=ee(e,e.token),K(e,new c(r))):function(e){var r,i,o,u;if("["===e.token){if(O(e),T(e),"]"!==e.token){var s=re(e);if(";"===e.token){for(o=1,i=[s];";"===e.token;)T(e),"]"!==e.token&&(i[o]=re(e),o++);if("]"!==e.token)throw ne(e,"End of matrix ] expected");I(e),T(e),u=i[0].items.length;for(var l=1;l<o;l++)if(i[l].items.length!==u)throw ie(e,"Column dimensions mismatch ("+i[l].items.length+" !== "+u+")");r=new a(i)}else{if("]"!==e.token)throw ne(e,"End of matrix ] expected");I(e),T(e),r=s}}else I(e),T(e),r=new a([]);return K(e,r)}return function(e){if("{"===e.token){var r;O(e);var i={};do{if(T(e),"}"!==e.token){if('"'===e.token||"'"===e.token)r=ee(e,e.token);else{if(!(e.tokenType===w.SYMBOL||e.tokenType===w.DELIMITER&&e.token in N))throw ne(e,"Symbol or string expected as object key");r=e.token,T(e)}if(":"!==e.token)throw ne(e,"Colon : expected after object key");T(e),i[r]=j(e)}}while(","===e.token);if("}"!==e.token)throw ne(e,"Comma , or bracket } expected after object value");I(e),T(e);var a=new d(i);return K(e,a)}return function(e){var r;if(e.tokenType===w.NUMBER){r=e.token,T(e);var i=ai(r,n),a=t(r,i);return new c(a)}return function(e){var r;if("("===e.token){if(O(e),T(e),r=j(e),")"!==e.token)throw ne(e,"Parenthesis ) expected");return I(e),T(e),K(e,r=new h(r))}return function(e){throw ne(e,""===e.token?"Unexpected end of expression":"Value expected")}(e)}(e)}(e)}(e)}(e)}(e)}(e)}(e);for(var u={"!":"factorial","'":"ctranspose"};Hn(u,e.token);)o=u[i=e.token],T(e),r=K(e,r=new p(i,o,[r]));return r}function K(e,r){for(var t;"("===e.token||"["===e.token||"."===e.token;)if(t=[],"("===e.token){if(!Pn(r)&&!Mn(r))return r;if(O(e),T(e),")"!==e.token)for(t.push(j(e));","===e.token;)T(e),t.push(j(e));if(")"!==e.token)throw ne(e,"Parenthesis ) expected");I(e),T(e),r=new f(r,t)}else if("["===e.token){if(O(e),T(e),"]"!==e.token)for(t.push(j(e));","===e.token;)T(e),t.push(j(e));if("]"!==e.token)throw ne(e,"Parenthesis ] expected");I(e),T(e),r=new i(r,new m(t))}else{if(T(e),!(e.tokenType===w.SYMBOL||e.tokenType===w.DELIMITER&&e.token in N))throw ne(e,"Property name expected after dot");t.push(new c(e.token)),T(e),r=new i(r,new m(t,!0))}return r}function ee(e,r){for(var t="";""!==S(e)&&S(e)!==r;)if("\\"===S(e)){F(e);var n=S(e),i=C[n];if(void 0!==i)t+=i,e.index+=1;else{if("u"!==n)throw ne(e,"Bad escape character \\".concat(n));var a=e.expression.slice(e.index+1,e.index+5);if(!/^[0-9A-Fa-f]{4}$/.test(a))throw ne(e,"Invalid unicode character \\u".concat(a));t+=String.fromCharCode(parseInt(a,16)),e.index+=5}}else t+=S(e),F(e);if(T(e),e.token!==r)throw ne(e,"End of string ".concat(r," expected"));return T(e),t}function re(e){for(var r=[j(e)],t=1;","===e.token;)T(e),"]"!==e.token&&";"!==e.token&&(r[t]=j(e),t++);return new a(r)}function te(e){return e.index-e.token.length+1}function ne(e,r){var t=te(e),n=new SyntaxError(r+" (char "+t+")");return n.char=t,n}function ie(e,r){var t=te(e),n=new SyntaxError(r+" (char "+t+")");return n.char=t,n}return g.isAlpha=function(e,r,t){return g.isValidLatinOrGreek(e)||g.isValidMathSymbol(e,t)||g.isValidMathSymbol(r,e)},g.isValidLatinOrGreek=function(e){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(e)},g.isValidMathSymbol=function(e,r){return/^[\uD835]$/.test(e)&&/^[\uDC00-\uDFFF]$/.test(r)&&/^[^\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(r)},g.isWhitespace=function(e,r){return" "===e||"\t"===e||" "===e||"\n"===e&&r>0},g.isDecimalMark=function(e,r){return"."===e&&"/"!==r&&"*"!==r&&"^"!==r},g.isDigitDot=function(e){return e>="0"&&e<="9"||"."===e},g.isDigit=function(e){return e>="0"&&e<="9"},g.isHexDigit=function(e){return e>="0"&&e<="9"||e>="a"&&e<="f"||e>="A"&&e<="F"},r.addConversion({from:"string",to:"Node",convert:g}),g})),ky="compile",Oy=ti(ky,["typed","parse"],(e=>{var{typed:r,parse:t}=e;return r(ky,{string:function(e){return t(e).compile()},"Array | Matrix":function(e){return Wu(e,(function(e){return t(e).compile()}))}})})),Iy="evaluate",zy=ti(Iy,["typed","parse"],(e=>{var{typed:r,parse:t}=e;return r(Iy,{string:function(e){var r=Qt();return t(e).compile().evaluate(r)},"string, Map | Object":function(e,r){return t(e).compile().evaluate(r)},"Array | Matrix":function(e){var r=Qt();return Wu(e,(function(e){return t(e).compile().evaluate(r)}))},"Array | Matrix, Map | Object":function(e,r){return Wu(e,(function(e){return t(e).compile().evaluate(r)}))}})})),jy=ti("Parser",["evaluate","parse"],(e=>{var{evaluate:r,parse:t}=e;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:Qt(),writable:!1})}return n.prototype.type="Parser",n.prototype.isParser=!0,n.prototype.evaluate=function(e){return r(e,this.scope)},n.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},n.prototype.getAll=function(){return function(e){if(e instanceof Gt)return e.wrappedObject;var r={};for(var t of e.keys())Wt(r,t,e.get(t));return r}(this.scope)},n.prototype.getAllAsMap=function(){return this.scope},n.prototype.set=function(e,r){if(!function(e){if(0===e.length)return!1;for(var r=0;r<e.length;r++){var n=e.charAt(r-1),i=e.charAt(r),a=e.charAt(r+1);if(!(t.isAlpha(i,n,a)||r>0&&t.isDigit(i)))return!1}return!0}(e))throw Error("Invalid variable name: '".concat(e,"'. Variable names must follow the specified rules."));return this.scope.set(e,r),r},n.prototype.remove=function(e){this.scope.delete(e)},n.prototype.clear=function(){this.scope.clear()},n.prototype.toJSON=function(){var e={mathjs:"Parser",variables:{},functions:{}};for(var[r,t]of this.scope)if(bn(t)){if(!Ry(t))throw Error("Cannot serialize external function ".concat(r));e.functions[r]="".concat(t.syntax," = ").concat(t.expr)}else e.variables[r]=t;return e},n.fromJSON=function(e){var r=new n;return Object.entries(e.variables).forEach((e=>{var[t,n]=e;return r.set(t,n)})),Object.entries(e.functions).forEach((e=>{var[t,n]=e;return r.evaluate(n)})),r},n}),{isClass:!0});function Ry(e){return"function"==typeof e&&"string"==typeof e.syntax&&"string"==typeof e.expr}var Uy="parser",$y=ti(Uy,["typed","Parser"],(e=>{var{typed:r,Parser:t}=e;return r(Uy,{"":function(){return new t}})})),Py=ti("lup",["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtractScalar","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],(e=>{var{typed:r,matrix:t,abs:n,addScalar:i,divideScalar:a,multiplyScalar:o,subtractScalar:u,larger:s,equalScalar:c,unaryMinus:l,DenseMatrix:f,SparseMatrix:m,Spa:d}=e;return r("lup",{DenseMatrix:function(e){return p(e)},SparseMatrix:function(e){return function(e){var r,t,i,u=e._size[0],f=e._size[1],p=Math.min(u,f),h=e._values,v=e._index,y=e._ptr,b=[],g=[],x=[],w=[u,p],D=[],N=[],A=[],M=[p,f],C=[],E=[];for(r=0;r<u;r++)C[r]=r,E[r]=r;var S=function(){var e=new d;t<u&&(x.push(b.length),b.push(1),g.push(t)),A.push(D.length);var f=y[t+1];for(i=y[t];i<f;i++)e.set(C[r=v[i]],h[i]);t>0&&e.forEach(0,t-1,(function(r,t){m._forEachRow(r,b,g,x,(function(n,i){n>r&&e.accumulate(n,l(o(i,t)))}))}));var p=t,S=e.get(t),F=n(S);e.forEach(t+1,u-1,(function(e,r){var t=n(r);s(t,F)&&(p=e,F=t,S=r)})),t!==p&&(m._swapRows(t,p,w[1],b,g,x),m._swapRows(t,p,M[1],D,N,A),e.swap(t,p),function(e,r){var t=E[e],n=E[r];C[t]=r,C[n]=e,E[e]=n,E[r]=t}(t,p)),e.forEach(0,u-1,(function(e,r){e<=t?(D.push(r),N.push(e)):(r=a(r,S),c(r,0)||(b.push(r),g.push(e)))}))};for(t=0;t<f;t++)S();return A.push(D.length),x.push(b.length),{L:new m({values:b,index:g,ptr:x,size:w}),U:new m({values:D,index:N,ptr:A,size:M}),p:C,toString:function(){return"L: "+this.L+"\nU: "+this.U+"\nP: "+this.p}}}(e)},Array:function(e){var r=p(t(e));return{L:r.L.valueOf(),U:r.U.valueOf(),p:r.p}}});function p(e){var r,t,l,m=e._size[0],d=e._size[1],p=Math.min(m,d),h=Wn(e._data),v=[],y=[m,p],b=[],g=[p,d],x=[];for(r=0;r<m;r++)x[r]=r;for(t=0;t<d;t++){if(t>0)for(r=0;r<m;r++){var w=Math.min(r,t),D=0;for(l=0;l<w;l++)D=i(D,o(h[r][l],h[l][t]));h[r][t]=u(h[r][t],D)}var N=t,A=0,M=0;for(r=t;r<m;r++){var C=h[r][t],E=n(C);s(E,A)&&(N=r,A=E,M=C)}if(t!==N&&(x[t]=[x[N],x[N]=x[t]][0],f._swapRows(t,N,h)),t<m)for(r=t+1;r<m;r++)c(h[r][t],0)||(h[r][t]=a(h[r][t],M))}for(t=0;t<d;t++)for(r=0;r<m;r++)0===t&&(r<d&&(b[r]=[]),v[r]=[]),r<t?(r<d&&(b[r][t]=h[r][t]),t<m&&(v[r][t]=0)):r!==t?(r<d&&(b[r][t]=0),t<m&&(v[r][t]=h[r][t])):(r<d&&(b[r][t]=h[r][t]),t<m&&(v[r][t]=1));var S=new f({data:v,size:y}),F=new f({data:b,size:g}),B=[];for(r=0,p=x.length;r<p;r++)B[x[r]]=r;return{L:S,U:F,p:B,toString:function(){return"L: "+this.L+"\nU: "+this.U+"\nP: "+this.p}}}})),Ly=ti("qr",["typed","matrix","zeros","identity","isZero","equal","sign","sqrt","conj","unaryMinus","addScalar","divideScalar","multiplyScalar","subtractScalar","complex"],(e=>{var{typed:r,matrix:t,zeros:n,identity:i,isZero:a,equal:o,sign:u,sqrt:s,conj:c,unaryMinus:l,addScalar:f,divideScalar:m,multiplyScalar:d,subtractScalar:p,complex:h}=e;return Pt(r("qr",{DenseMatrix:function(e){return y(e)},SparseMatrix:function(){return function(){throw Error("qr not implemented for sparse matrices yet")}()},Array:function(e){var r=y(t(e));return{Q:r.Q.valueOf(),R:r.R.valueOf()}}}),{_denseQRimpl:v});function v(e){var r,t,h,v=e._size[0],y=e._size[1],b=i([v],"dense"),g=b._data,x=e.clone(),w=x._data,D=n([v],"");for(h=0;h<Math.min(y,v);++h){var N=w[h][h],A=l(o(N,0)?1:u(N)),M=c(A),C=0;for(r=h;r<v;r++)C=f(C,d(w[r][h],c(w[r][h])));var E=d(A,s(C));if(!a(E)){var S=p(N,E);for(D[h]=1,r=h+1;r<v;r++)D[r]=m(w[r][h],S);var F=l(c(m(S,E))),B=void 0;for(t=h;t<y;t++){for(B=0,r=h;r<v;r++)B=f(B,d(c(D[r]),w[r][t]));for(B=d(B,F),r=h;r<v;r++)w[r][t]=d(p(w[r][t],d(D[r],B)),M)}for(r=0;r<v;r++){for(B=0,t=h;t<v;t++)B=f(B,d(g[r][t],D[t]));for(B=d(B,F),t=h;t<v;++t)g[r][t]=m(p(g[r][t],d(B,c(D[t]))),M)}}}return{Q:b,R:x,toString:function(){return"Q: "+this.Q+"\nR: "+this.R}}}function y(e){var r=v(e),t=r.R._data;if(e._data.length>0)for(var n="Complex"===t[0][0].type?h(0):0,i=0;i<t.length;++i)for(var a=0;a<i&&a<(t[0]||[]).length;++a)t[i][a]=n;return r}}));function _y(e,r,t,n,i,a,o){var u=0;for(t[o]=e;u>=0;){var s=t[o+u],c=t[n+s];-1===c?(u--,a[r++]=s):(t[n+s]=t[i+c],t[o+ ++u]=c)}return r}function Wy(e){return-e-2}var Jy=ti("csAmd",["add","multiply","transpose"],(e=>{var{add:r,multiply:t,transpose:n}=e;return function(e,o){if(!o||e<=0||e>3)return null;var u=o._size,s=u[0],c=u[1],l=0,f=Math.max(16,10*Math.sqrt(c)),m=function(e,i,a,o,u){var s=n(i);if(1===e&&o===a)return r(i,s);if(2===e){for(var c=s._index,l=s._ptr,f=0,m=0;m<a;m++){var d=l[m];if(l[m]=f,!(l[m+1]-d>u))for(var p=l[m+1];d<p;d++)c[f++]=c[d]}return l[a]=f,i=n(s),t(s,i)}return t(s,i)}(e,o,s,c,f=Math.min(c-2,f));!function(e,r){for(var t=e._values,n=e._index,i=e._ptr,a=e._size[1],o=0,u=0;u<a;u++){var s=i[u];for(i[u]=o;s<i[u+1];s++)r(n[s],u,t?t[s]:1,null)&&(n[o]=n[s],t&&(t[o]=t[s]),o++)}i[a]=o,n.splice(o,n.length-o),t&&t.splice(o,t.length-o)}(m,a);for(var d,p,h,v,y,b,g,x,w,D,N,A,M,C,E,S,F=m._index,B=m._ptr,q=B[c],T=[],k=[],O=c+1,I=2*(c+1),z=3*(c+1),j=4*(c+1),R=5*(c+1),U=6*(c+1),$=7*(c+1),P=T,L=function(e,r,t,n,a,o,u,s,c,l,f,m){for(var d=0;d<e;d++)t[0+d]=r[d+1]-r[d];t[0+e]=0;for(var p=0;p<=e;p++)t[a+p]=-1,o[p]=-1,t[u+p]=-1,t[s+p]=-1,t[c+p]=1,t[l+p]=1,t[f+p]=0,t[m+p]=t[0+p];var h=i(0,0,t,l,e);return t[f+e]=-2,r[e]=-1,t[l+e]=0,h}(c,B,k,0,z,P,I,$,O,U,j,R),_=function(e,r,t,n,i,a,o,u,s,c,l){for(var f=0,m=0;m<e;m++){var d=t[n+m];if(0===d)t[i+m]=-2,f++,r[m]=-1,t[a+m]=0;else if(d>o)t[u+m]=0,t[i+m]=-1,f++,r[m]=Wy(e),t[u+e]++;else{var p=t[s+d];-1!==p&&(c[p]=m),t[l+m]=t[s+d],t[s+d]=m}}return f}(c,B,k,R,j,U,f,O,z,P,I),W=0;_<c;){for(h=-1;W<c&&-1===(h=k[z+W]);W++);-1!==k[I+h]&&(P[k[I+h]]=-1),k[z+W]=k[I+h];var J=k[j+h],V=k[O+h];_+=V;var H=0;k[O+h]=-V;var Z=B[h],G=0===J?Z:q,X=G;for(v=1;v<=J+1;v++){for(v>J?(b=h,g=Z,x=k[0+h]-J):(g=B[b=F[Z++]],x=k[0+b]),y=1;y<=x;y++)(w=k[O+(d=F[g++])])<=0||(H+=w,k[O+d]=-w,F[X++]=d,-1!==k[I+d]&&(P[k[I+d]]=P[d]),-1!==P[d]?k[I+P[d]]=k[I+d]:k[z+k[R+d]]=k[I+d]);b!==h&&(B[b]=Wy(h),k[U+b]=0)}for(0!==J&&(q=X),k[R+h]=H,B[h]=G,k[0+h]=X-G,k[j+h]=-2,L=i(L,l,k,U,c),D=G;D<X;D++)if(!((N=k[j+(d=F[D])])<=0)){var Y=L-(w=-k[O+d]);for(Z=B[d],A=B[d]+N-1;Z<=A;Z++)k[U+(b=F[Z])]>=L?k[U+b]-=w:0!==k[U+b]&&(k[U+b]=k[R+b]+Y)}for(D=G;D<X;D++){for(M=(A=B[d=F[D]])+k[j+d]-1,C=A,E=0,S=0,Z=A;Z<=M;Z++)if(0!==k[U+(b=F[Z])]){var Q=k[U+b]-L;Q>0?(S+=Q,F[C++]=b,E+=b):(B[b]=Wy(h),k[U+b]=0)}k[j+d]=C-A+1;var K=C,ee=A+k[0+d];for(Z=M+1;Z<ee;Z++){var re=k[O+(p=F[Z])];re<=0||(S+=re,F[C++]=p,E+=p)}0===S?(B[d]=Wy(h),H-=w=-k[O+d],V+=w,_+=w,k[O+d]=0,k[j+d]=-1):(k[R+d]=Math.min(k[R+d],S),F[C]=F[K],F[K]=F[A],F[A]=h,k[0+d]=C-A+1,k[I+d]=k[$+(E=(E<0?-E:E)%c)],k[$+E]=d,P[d]=E)}for(k[R+h]=H,L=i(L+(l=Math.max(l,H)),l,k,U,c),D=G;D<X;D++)if(!(k[O+(d=F[D])]>=0))for(d=k[$+(E=P[d])],k[$+E]=-1;-1!==d&&-1!==k[I+d];d=k[I+d],L++){for(x=k[0+d],N=k[j+d],Z=B[d]+1;Z<=B[d]+x-1;Z++)k[U+F[Z]]=L;var te=d;for(p=k[I+d];-1!==p;){var ne=k[0+p]===x&&k[j+p]===N;for(Z=B[p]+1;ne&&Z<=B[p]+x-1;Z++)k[U+F[Z]]!==L&&(ne=0);ne?(B[p]=Wy(d),k[O+d]+=k[O+p],k[O+p]=0,k[j+p]=-1,k[I+te]=p=k[I+p]):(te=p,p=k[I+p])}}for(Z=G,D=G;D<X;D++)(w=-k[O+(d=F[D])])<=0||(k[O+d]=w,-1!==k[z+(S=Math.min(S=k[R+d]+H-w,c-_-w))]&&(P[k[z+S]]=d),k[I+d]=k[z+S],P[d]=-1,k[z+S]=d,W=Math.min(W,S),k[R+d]=S,F[Z++]=d);k[O+h]=V,0==(k[0+h]=Z-G)&&(B[h]=-1,k[U+h]=0),0!==J&&(q=Z)}for(d=0;d<c;d++)B[d]=Wy(B[d]);for(p=0;p<=c;p++)k[z+p]=-1;for(p=c;p>=0;p--)k[O+p]>0||(k[I+p]=k[z+B[p]],k[z+B[p]]=p);for(b=c;b>=0;b--)k[O+b]<=0||-1!==B[b]&&(k[I+b]=k[z+B[b]],k[z+B[b]]=b);for(h=0,d=0;d<=c;d++)-1===B[d]&&(h=_y(d,h,k,z,I,T,U));return T.splice(T.length-1,1),T};function i(e,r,t,n,i){if(e<2||e+r<0){for(var a=0;a<i;a++)0!==t[n+a]&&(t[n+a]=1);e=2}return e}function a(e,r){return e!==r}}));function Vy(e,r,t,n,i,a,o){var u,s,c,l=0;if(e<=r||t[n+r]<=t[i+e])return-1;t[i+e]=t[n+r];var f=t[a+e];if(t[a+e]=r,-1===f)l=1,c=e;else{for(l=2,c=f;c!==t[o+c];c=t[o+c]);for(u=f;u!==c;u=s)s=t[o+u],t[o+u]=c}return{jleaf:l,q:c}}var Hy=ti("csCounts",["transpose"],(e=>{var{transpose:r}=e;return function(e,t,n,i){if(!e||!t||!n)return null;var a,o,u,s,c,l,f=e._size,m=f[0],d=f[1],p=4*d+(i?d+m+1:0),h=[],v=d,y=2*d,b=3*d,g=4*d,x=5*d+1;for(u=0;u<p;u++)h[u]=-1;var w=[],D=r(e),N=D._index,A=D._ptr;for(u=0;u<d;u++)for(w[o=n[u]]=-1===h[b+o]?1:0;-1!==o&&-1===h[b+o];o=t[o])h[b+o]=u;if(i){for(u=0;u<d;u++)h[n[u]]=u;for(a=0;a<m;a++){for(u=d,l=A[a+1],c=A[a];c<l;c++)u=Math.min(u,h[N[c]]);h[x+a]=h[g+u],h[g+u]=a}}for(a=0;a<d;a++)h[0+a]=a;for(u=0;u<d;u++){for(-1!==t[o=n[u]]&&w[t[o]]--,s=i?h[g+u]:o;-1!==s;s=i?h[x+s]:-1)for(c=A[s];c<A[s+1];c++){var M=Vy(a=N[c],o,h,b,v,y,0);M.jleaf>=1&&w[o]++,2===M.jleaf&&w[M.q]--}-1!==t[o]&&(h[0+o]=t[o])}for(o=0;o<d;o++)-1!==t[o]&&(w[t[o]]+=w[o]);return w}})),Zy=ti("csSqr",["add","multiply","transpose"],(e=>{var{add:r,multiply:t,transpose:n}=e,i=Jy({add:r,multiply:t,transpose:n}),a=Hy({transpose:n});return function(e,r,t){var n,o=r._ptr,u=r._size[1],s={};if(s.q=i(e,r),e&&!s.q)return null;if(t){var c=e?function(e,r,t){for(var n=e._index,i=e._ptr,a=e._size,o=e._datatype,u=a[0],s=a[1],c=[],l=[],f=0,m=0;m<s;m++){l[m]=f;for(var d=t?t[m]:m,p=i[d+1],h=i[d];h<p;h++)c[f]=n[h],f++}return l[s]=f,e.createSparseMatrix({values:null,index:c,ptr:l,size:[u,s],datatype:o})}(r,0,s.q):r;s.parent=function(e){if(!e)return null;var r,t,n=e._index,i=e._ptr,a=e._size,o=a[0],u=a[1],s=[],c=[],l=u;for(r=0;r<o;r++)c[l+r]=-1;for(var f=0;f<u;f++){s[f]=-1,c[0+f]=-1;for(var m=i[f+1],d=i[f];d<m;d++){var p=n[d];for(r=c[l+p];-1!==r&&r<f;r=t)t=c[0+r],c[0+r]=f,-1===t&&(s[r]=f);c[l+p]=f}}return s}(c);var l=function(e,r){if(!e)return null;var t,n=0,i=[],a=[],o=r,u=2*r;for(t=0;t<r;t++)a[0+t]=-1;for(t=r-1;t>=0;t--)-1!==e[t]&&(a[o+t]=a[0+e[t]],a[0+e[t]]=t);for(t=0;t<r;t++)-1===e[t]&&(n=_y(t,n,a,0,o,i,u));return i}(s.parent,u);if(s.cp=a(c,s.parent,l,1),c&&s.parent&&s.cp&&function(e,r){var t=e._ptr,n=e._index,i=e._size,a=i[0],o=i[1];r.pinv=[],r.leftmost=[];var u,s,c,l,f=r.parent,m=r.pinv,d=r.leftmost,p=[],h=a,v=a+o,y=a+2*o;for(s=0;s<o;s++)p[h+s]=-1,p[v+s]=-1,p[y+s]=0;for(u=0;u<a;u++)d[u]=-1;for(s=o-1;s>=0;s--)for(l=t[s+1],c=t[s];c<l;c++)d[n[c]]=s;for(u=a-1;u>=0;u--)m[u]=-1,-1!==(s=d[u])&&(0==p[y+s]++&&(p[v+s]=u),p[0+u]=p[h+s],p[h+s]=u);for(r.lnz=0,r.m2=a,s=0;s<o;s++)if(u=p[h+s],r.lnz++,u<0&&(u=r.m2++),m[u]=s,!(--y[s]<=0)){r.lnz+=p[y+s];var b=f[s];-1!==b&&(0===p[y+b]&&(p[v+b]=p[v+s]),p[0+p[v+s]]=p[h+b],p[h+b]=p[0+u],p[y+b]+=p[y+s])}for(u=0;u<a;u++)m[u]<0&&(m[u]=s++);return!0}(c,s))for(s.unz=0,n=0;n<u;n++)s.unz+=s.cp[n]}else s.unz=4*o[u]+u,s.lnz=s.unz;return s}}));function Gy(e,r){return e[r]<0}function Xy(e,r){e[r]=Wy(e[r])}function Yy(e){return e<0?Wy(e):e}function Qy(e,r,t,n,i){var a,o,u,s=r._index,c=r._ptr,l=r._size[1],f=0;for(n[0]=e;f>=0;){e=n[f];var m=i?i[e]:e;Gy(c,e)||(Xy(c,e),n[l+f]=m<0?0:Yy(c[m]));var d=1;for(o=n[l+f],u=m<0?0:Yy(c[m+1]);o<u;o++)if(!Gy(c,a=s[o])){n[l+f]=o,n[++f]=a,d=0;break}d&&(f--,n[--t]=e)}return t}var Ky=ti("csSpsolve",["divideScalar","multiply","subtract"],(e=>{var{divideScalar:r,multiply:t,subtract:n}=e;return function(e,i,a,o,u,s,c){var l,f,m,d,p=e._values,h=e._index,v=e._ptr,y=e._size[1],b=i._values,g=i._index,x=i._ptr,w=function(e,r,t,n,i){var a,o,u=e._ptr,s=r._index,c=r._ptr,l=e._size[1],f=l;for(o=c[t+1],a=c[t];a<o;a++){var m=s[a];Gy(u,m)||(f=Qy(m,e,f,n,i))}for(a=f;a<l;a++)Xy(u,n[a]);return f}(e,i,a,o,s);for(l=w;l<y;l++)u[o[l]]=0;for(m=x[a+1],l=f=x[a];l<m;l++)u[g[l]]=b[l];for(var D=w;D<y;D++){var N=o[D],A=s?s[N]:N;if(!(A<0))for(f=v[A],m=v[A+1],u[N]=r(u[N],p[c?f:m-1]),l=c?f+1:f,d=c?m:m-1;l<d;l++){var M=h[l];u[M]=n(u[M],t(p[l],u[N]))}}return w}})),eb=ti("csLu",["abs","divideScalar","multiply","subtract","larger","largerEq","SparseMatrix"],(e=>{var{abs:r,divideScalar:t,multiply:n,subtract:i,larger:a,largerEq:o,SparseMatrix:u}=e,s=Ky({divideScalar:t,multiply:n,subtract:i});return function(e,i,c){if(!e)return null;var l,f=e._size[1],m=100,d=100;i&&(l=i.q,m=i.lnz||m,d=i.unz||d);var p,h,v=[],y=[],b=[],g=new u({values:v,index:y,ptr:b,size:[f,f]}),x=[],w=[],D=[],N=new u({values:x,index:w,ptr:D,size:[f,f]}),A=[],M=[],C=[];for(p=0;p<f;p++)M[p]=0,A[p]=-1,b[p+1]=0;m=0,d=0;for(var E=0;E<f;E++){b[E]=m,D[E]=d;var S=l?l[E]:E,F=s(g,e,S,C,M,A,1),B=-1,q=-1;for(h=F;h<f;h++)if(A[p=C[h]]<0){var T=r(M[p]);a(T,q)&&(q=T,B=p)}else w[d]=A[p],x[d++]=M[p];if(-1===B||q<=0)return null;A[S]<0&&o(r(M[S]),n(q,c))&&(B=S);var k=M[B];for(w[d]=E,x[d++]=k,A[B]=E,y[m]=B,v[m++]=1,h=F;h<f;h++)A[p=C[h]]<0&&(y[m]=p,v[m++]=t(M[p],k)),M[p]=0}for(b[f]=m,D[f]=d,h=0;h<m;h++)y[h]=A[y[h]];return v.splice(m,v.length-m),y.splice(m,y.length-m),x.splice(d,x.length-d),w.splice(d,w.length-d),{L:g,U:N,pinv:A}}})),rb=ti("slu",["typed","abs","add","multiply","transpose","divideScalar","subtract","larger","largerEq","SparseMatrix"],(e=>{var{typed:r,abs:t,add:n,multiply:i,transpose:a,divideScalar:o,subtract:u,larger:s,largerEq:c,SparseMatrix:l}=e,f=Zy({add:n,multiply:i,transpose:a}),m=eb({abs:t,divideScalar:o,multiply:i,subtract:u,larger:s,largerEq:c,SparseMatrix:l});return r("slu",{"SparseMatrix, number, number":function(e,r,t){if(!ii(r)||r<0||r>3)throw Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(t<0||t>1)throw Error("Partial pivoting threshold must be a number from 0 to 1");var n=f(r,e,!1),i=m(e,n,t);return{L:i.L,U:i.U,p:i.pinv,q:n.q,toString:function(){return"L: "+this.L+"\nU: "+this.U+"\np: "+this.p+(this.q?"\nq: "+this.q:"")+"\n"}}}})}));function tb(e,r){var t,n=r.length,i=[];if(e)for(t=0;t<n;t++)i[e[t]]=r[t];else for(t=0;t<n;t++)i[t]=r[t];return i}var nb="lusolve",ib=ti(nb,["typed","matrix","lup","slu","usolve","lsolve","DenseMatrix"],(e=>{var{typed:r,matrix:t,lup:n,slu:i,usolve:a,lsolve:o,DenseMatrix:u}=e,s=Zd({DenseMatrix:u});return r(nb,{"Array, Array | Matrix":function(e,r){e=t(e);var i=n(e);return l(i.L,i.U,i.p,null,r).valueOf()},"DenseMatrix, Array | Matrix":function(e,r){var t=n(e);return l(t.L,t.U,t.p,null,r)},"SparseMatrix, Array | Matrix":function(e,r){var t=n(e);return l(t.L,t.U,t.p,null,r)},"SparseMatrix, Array | Matrix, number, number":function(e,r,t,n){var a=i(e,t,n);return l(a.L,a.U,a.p,a.q,r)},"Object, Array | Matrix":function(e,r){return l(e.L,e.U,e.p,e.q,r)}});function c(e){if(cn(e))return e;if(sn(e))return t(e);throw new TypeError("Invalid Matrix LU decomposition")}function l(e,r,t,n,i){e=c(e),r=c(r),t&&((i=s(e,i,!0))._data=tb(t,i._data));var u=o(e,i),l=a(r,u);return n&&(l._data=tb(n,l._data)),l}})),ab="polynomialRoot",ob=ti(ab,["typed","isZero","equalScalar","add","subtract","multiply","divide","sqrt","unaryMinus","cbrt","typeOf","im","re"],(e=>{var{typed:r,isZero:t,equalScalar:n,add:i,subtract:a,multiply:o,divide:u,sqrt:s,unaryMinus:c,cbrt:l,typeOf:f,im:m,re:d}=e;return r(ab,{"number|Complex, ...number|Complex":(e,r)=>{for(var p=[e,...r];p.length>0&&t(p[p.length-1]);)p.pop();if(p.length<2)throw new RangeError("Polynomial [".concat(e,", ").concat(r,"] must have a non-zero non-constant coefficient"));switch(p.length){case 2:return[c(u(p[0],p[1]))];case 3:var[h,v,y]=p,b=o(2,y),g=o(v,v),x=o(4,y,h);if(n(g,x))return[u(c(v),b)];var w=s(a(g,x));return[u(a(w,v),b),u(a(c(w),v),b)];case 4:var[D,N,A,M]=p,C=c(o(3,M)),E=o(A,A),S=o(3,M,N),F=i(o(2,A,A,A),o(27,M,M,D)),B=o(9,M,A,N);if(n(E,S)&&n(F,B))return[u(A,C)];var q,T=a(E,S),k=a(F,B),O=i(o(18,M,A,N,D),o(A,A,N,N)),I=i(o(4,A,A,A,D),o(4,M,N,N,N),o(27,M,M,D,D));return n(O,I)?[u(a(o(4,M,A,N),i(o(9,M,M,D),o(A,A,A))),o(M,T)),u(a(o(9,M,D),o(A,N)),o(2,T))]:(q=n(E,S)?k:u(i(k,s(a(o(k,k),o(4,T,T,T)))),2),l(q,!0).toArray().map((e=>u(i(A,e,u(T,e)),C))).map((e=>"Complex"===f(e)&&n(d(e),d(e)+m(e))?d(e):e)));default:throw new RangeError("only implemented for cubic or lower-order polynomials, not ".concat(p))}}})})),ub=ti("Help",["evaluate"],(e=>{var{evaluate:r}=e;function t(e){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw Error('Argument "doc" missing');this.doc=e}return t.prototype.type="Help",t.prototype.isHelp=!0,t.prototype.toString=function(){var e=this.doc||{},t="\n";if(e.name&&(t+="Name: "+e.name+"\n\n"),e.category&&(t+="Category: "+e.category+"\n\n"),e.description&&(t+="Description:\n "+e.description+"\n\n"),e.syntax&&(t+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){t+="Examples:\n";for(var n=!1,i=r("config()"),a={config:e=>(n=!0,r("config(newConfig)",{newConfig:e}))},o=0;o<e.examples.length;o++){var u=e.examples[o];t+=" "+u+"\n";var s=void 0;try{s=r(u,a)}catch(e){s=e}void 0===s||yn(s)||(t+=" "+Go(s,{precision:14})+"\n")}t+="\n",n&&r("config(originalConfig)",{originalConfig:i})}return e.mayThrow&&e.mayThrow.length&&(t+="Throws: "+e.mayThrow.join(", ")+"\n\n"),e.seealso&&e.seealso.length&&(t+="See also: "+e.seealso.join(", ")+"\n"),t},t.prototype.toJSON=function(){var e=Wn(this.doc);return e.mathjs="Help",e},t.fromJSON=function(e){var r={};return Object.keys(e).filter((e=>"mathjs"!==e)).forEach((t=>{r[t]=e[t]})),new t(r)},t.prototype.valueOf=t.prototype.toString,t}),{isClass:!0}),sb=ti("Chain",["?on","math","typed"],(e=>{var{on:r,math:t,typed:n}=e;function i(e){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this.value=Ln(e)?e.value:e}function a(e,r){!function(e,t){var n,i=!0;Object.defineProperty(e,t,{get:function(){return i&&(n=function(){var e=r();if("function"==typeof e)return o(e)}(),i=!1),n},set:function(e){n=e,i=!1},configurable:!0,enumerable:!0})}(i.prototype,e)}function o(e){return function(){if(0===arguments.length)return new i(e(this.value));for(var r=[this.value],t=0;t<arguments.length;t++)r[t+1]=arguments[t];if(n.isTypedFunction(e)){var a=n.resolve(e,r);if(1===a.params.length)throw Error("chain function "+e.name+" cannot match rest parameter between chain value and additional arguments.");return new i(a.implementation.apply(e,r))}return new i(e.apply(e,r))}}i.prototype.type="Chain",i.prototype.isChain=!0,i.prototype.done=function(){return this.value},i.prototype.valueOf=function(){return this.value},i.prototype.toString=function(){return Go(this.value)},i.prototype.toJSON=function(){return{mathjs:"Chain",value:this.value}},i.fromJSON=function(e){return new i(e.value)},i.createProxy=function(e,r){if("string"==typeof e)!function(e,r){"function"==typeof r&&(i.prototype[e]=o(r))}(e,r);else{var t=function(r){Hn(e,r)&&void 0===u[r]&&a(r,(()=>e[r]))};for(var n in e)t(n)}};var u={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return i.createProxy(t),r&&r("import",(function(e,r,t){t||a(e,r)})),i}),{isClass:!0}),cb={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"]},lb={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"]},fb={bignumber:{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","bigint","complex","fraction","index","matrix","string","unit"]},bigint:{name:"bigint",category:"Construction",syntax:["bigint(x)"],description:"Create a bigint, an integer with an arbitrary number of digits, from a number or string.",examples:["123123123123123123 # a large number will lose digits",'bigint("123123123123123123")','bignumber(["1", "3", "5"])'],seealso:["boolean","bignumber","number","complex","fraction","index","matrix","string","unit"]},boolean:{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"]},complex:{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"]},createUnit:{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"]},fraction:{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"]},index:{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:["A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[1:2, 1:2] = 1","B = [1, 2, 3]","B[B>1 and B<3]"],seealso:["bignumber","boolean","complex","matrix","number","range","string","unit"]},matrix:{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"]},number:{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","bigint","boolean","complex","fraction","index","matrix","string","unit"]},sparse:{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"]},splitUnit:{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"]},string:{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"]},unit:{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"]},e:cb,E:cb,false:{name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},i:{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:[]},Infinity:{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:[]},LN2:{name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},LN10:{name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},LOG2E:{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:[]},LOG10E:{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:[]},NaN:{name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},null:{name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},pi:lb,PI:lb,phi:{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:[]},SQRT1_2:{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:[]},SQRT2:{name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},tau:{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"]},true:{name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},version:{name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},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. Deprecated in favor of coulombConstant",examples:["coulombConstant"]},coulombConstant:{description:"Coulomb's constant",examples:["coulombConstant"]},elementaryCharge:{description:"Elementary charge",examples:["elementaryCharge"]},bohrMagneton:{description:"Bohr 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:"Bohr 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:{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"]},lsolve:{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"]},lsolveAll:{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"]},lup:{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"]},lusolve:{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"]},leafCount:{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"]},polynomialRoot:{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"]},resolve:{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"]},simplify:{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"]},simplifyConstant:{name:"simplifyConstant",category:"Algebra",syntax:["simplifyConstant(expr)","simplifyConstant(expr, options)"],description:"Replace constant subexpressions of node with their values.",examples:['simplifyConstant("(3-3)*x")','simplifyConstant(parse("z-cos(tau/8)"))'],seealso:["simplify","simplifyCore","evaluate"]},simplifyCore:{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"]},symbolicEqual:{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"]},rationalize:{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"]},slu:{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"]},usolve:{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"]},usolveAll:{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"]},qr:{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"]},abs:{name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},add:{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"]},cbrt:{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"]},ceil:{name:"ceil",category:"Arithmetic",syntax:["ceil(x)","ceil(x, n)","ceil(unit, valuelessUnit)","ceil(unit, n, valuelessUnit)"],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)","ceil(3.241cm, cm)","ceil(3.241cm, 2, cm)"],seealso:["floor","fix","round"]},cube:{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"]},divide:{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"]},dotDivide:{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"]},dotMultiply:{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"]},dotPow:{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"]},exp:{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"]},expm:{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"]},expm1:{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"]},fix:{name:"fix",category:"Arithmetic",syntax:["fix(x)","fix(x, n)","fix(unit, valuelessUnit)","fix(unit, n, valuelessUnit)"],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)","fix(3.241cm, cm)","fix(3.241cm, 2, cm)"],seealso:["ceil","floor","round"]},floor:{name:"floor",category:"Arithmetic",syntax:["floor(x)","floor(x, n)","floor(unit, valuelessUnit)","floor(unit, n, valuelessUnit)"],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)","floor(3.241cm, cm)","floor(3.241cm, 2, cm)"],seealso:["ceil","fix","round"]},gcd:{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"]},hypot:{name:"hypot",category:"Arithmetic",syntax:["hypot(a, b, c, ...)","hypot([a, b, c, ...])"],description:"Calculate the hypotenuse of a list with values.",examples:["hypot(3, 4)","sqrt(3^2 + 4^2)","hypot(-2)","hypot([3, 4, 5])"],seealso:["abs","norm"]},lcm:{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"]},log:{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"]},log2:{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"]},log1p:{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"]},log10:{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"]},mod:{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"]},multiply:{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"]},norm:{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")']},nthRoot:{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"]},nthRoots:{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"]},pow:{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"]},round:{name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)","round(unit, valuelessUnit)","round(unit, n, valuelessUnit)"],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)","round(3.241cm, 2, cm)","round([3.2, 3.8, -4.7])"],seealso:["ceil","floor","fix"]},sign:{name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>0, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},sqrt:{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"]},sqrtm:{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"]},square:{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"]},subtract:{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"]},unaryMinus:{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"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{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"]},invmod:{name:"invmod",category:"Arithmetic",syntax:["invmod(a, b)"],description:"Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)",examples:["invmod(8, 12)","invmod(7, 13)","invmod(15151, 15122)"],seealso:["gcd","xgcd"]},bitAnd:{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"]},bitNot:{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"]},bitOr:{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"]},bitXor:{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"]},leftShift:{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"]},rightArithShift:{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"]},rightLogShift:{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"]},bellNumbers:{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"]},catalan:{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"]},composition:{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"]},stirlingS2:{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"]},config:{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:[]},import:{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:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number": f(x)=x+x, "string": f(x)=concat(x,x) })',"double(2)",'double("hello")'],seealso:[]},arg:{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"]},conj:{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"]},re:{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"]},im:{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"]},evaluate:{name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate(expression, scope)","evaluate([expr1, expr2, expr3, ...])","evaluate([expr1, expr2, expr3, ...], scope)"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(16)")','evaluate("2 inch to cm")','evaluate("sin(x * pi)", { "x": 1/2 })','evaluate(["width=2", "height=4","width*height"])'],seealso:["parser","parse","compile"]},help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},parse:{name:"parse",category:"Expression",syntax:["parse(expr)","parse(expr, options)","parse([expr1, expr2, expr3, ...])","parse([expr1, expr2, expr3, ...], options)"],description:"Parse an expression. Returns a node tree, which can be evaluated by invoking node.evaluate() or transformed into a functional object via node.compile().",examples:['node1 = parse("sqrt(3^2 + 4^2)")',"node1.evaluate()","code1 = node1.compile()","code1.evaluate()","scope = {a: 3, b: 4}",'node2 = parse("a * b")',"node2.evaluate(scope)","code2 = node2.compile()","code2.evaluate(scope)"],seealso:["parser","evaluate","compile"]},parser:{name:"parser",category:"Expression",syntax:["parser()"],description:"Create a parser object that keeps a context of variables and their values, allowing the evaluation of expressions in that context.",examples:["myParser = parser()",'myParser.evaluate("sqrt(3^2 + 4^2)")','myParser.set("x", 3)','myParser.evaluate("y = x + 3")','myParser.evaluate(["y = x + 3", "y = y + 1"])','myParser.get("y")'],seealso:["evaluate","parse","compile"]},compile:{name:"compile",category:"Expression",syntax:["compile(expr) ","compile([expr1, expr2, expr3, ...])"],description:"Parse and compile an expression. Returns a an object with a function evaluate([scope]) to evaluate the compiled expression.",examples:['code1 = compile("sqrt(3^2 + 4^2)")',"code1.evaluate() ",'code2 = compile("a * b")',"code2.evaluate({a: 3, b: 4})"],seealso:["parser","parse","evaluate"]},distance:{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:[]},intersect:{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:[]},and:{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"]},not:{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"]},nullish:{name:"nullish",category:"Logical",syntax:["x ?? y","nullish(x, y)"],description:"Nullish coalescing operator. Returns the right-hand operand when the left-hand operand is null or undefined, and otherwise returns the left-hand operand.",examples:["null ?? 42","undefined ?? 42","0 ?? 42","false ?? 42","null ?? undefined ?? 42"],seealso:["and","or","not"]},or:{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"]},xor:{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"]},mapSlices:{name:"mapSlices",category:"Matrix",syntax:["mapSlices(A, dim, callback)"],description:"Generate a matrix one dimension less than A by applying callback to each slice of A along dimension dim.",examples:["A = [[1, 2], [3, 4]]","mapSlices(A, 1, sum)","mapSlices(A, 2, prod)"],seealso:["map","forEach"]},concat:{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"]},count:{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"]},cross:{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"]},column:{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"]},ctranspose:{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"]},det:{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"]},diag:{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"]},diff:{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 indicate 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:["A = [1, 2, 4, 7, 0]","diff(A)","diff(A, 1)","B = [[1, 2], [3, 4]]","diff(B)","diff(B, 1)","diff(B, 2)","diff(B, bignumber(2))","diff([[1, 2], matrix([3, 4])], 2)"],seealso:["subtract","partitionSelect"]},dot:{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"]},getMatrixDataType:{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"]},identity:{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"]},filter:{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"]},flatten:{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"]},forEach:{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"]},inv:{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"]},pinv:{name:"pinv",category:"Matrix",syntax:["pinv(x)"],description:"Calculate the Moore–Penrose inverse of a matrix",examples:["pinv([1, 2; 3, 4])","pinv([[1, 0], [0, 1], [0, 1]])","pinv(4)"],seealso:["inv"]},eigs:{name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and optionally eigenvectors of a square matrix",examples:["eigs([[5, 2.3], [2.3, 1]])","eigs([[1, 2, 3], [4, 5, 6], [7, 8, 9]], { precision: 1e-6, eigenvectors: false })"],seealso:["inv"]},kron:{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"]},matrixFromFunction:{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"]},matrixFromRows:{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"]},matrixFromColumns:{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"]},map:{name:"map",category:"Matrix",syntax:["map(x, callback)","map(x, y, ..., callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array or the matrices/arrays.",examples:["map([1, 2, 3], square)","map([1, 2], [3, 4], f(a,b) = a + b)"],seealso:["filter","forEach"]},ones:{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"]},partitionSelect:{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"]},range:{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")',"range(1m, 1m, 3m)","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"]},resize:{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"]},reshape:{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"]},rotate:{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"]},rotationMatrix:{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"]},row:{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"]},size:{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"]},sort:{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"]},squeeze:{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"]},subset:{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"]},trace:{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"]},transpose:{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"]},zeros:{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"]},fft:{name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional Fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},ifft:{name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse Fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},sylvester:{name:"sylvester",category:"Algebra",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]])","A = [[-1, -2], [1, 1]]; B = [[2, -1], [1, -2]]; C = [[-3, 2], [3, 0]]","sylvester(A, B, C)"],seealso:["schur","lyap"]},schur:{name:"schur",category:"Algebra",syntax:["schur(A)"],description:"Performs a real Schur decomposition of the real matrix A = UTU'",examples:["schur([[1, 0], [-4, 3]])","A = [[1, 0], [-4, 3]]","schur(A)"],seealso:["lyap","sylvester"]},lyap:{name:"lyap",category:"Algebra",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]])","A = [[-2, 0], [1, -4]]","Q = [[3, 1], [1, 3]]","lyap(A,Q)"],seealso:["schur","sylvester"]},solveODE:{name:"solveODE",category:"Numeric",syntax:["solveODE(func, tspan, y0)","solveODE(func, tspan, y0, options)"],description:"Numerical Integration of Ordinary Differential Equations.",examples:["f(t,y) = y","tspan = [0, 4]","solveODE(f, tspan, 1)","solveODE(f, tspan, [1, 2])",'solveODE(f, tspan, 1, { method:"RK23", maxStep:0.1 })'],seealso:["derivative","simplifyCore"]},combinations:{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"]},combinationsWithRep:{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"]},factorial:{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"]},gamma:{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"]},kldivergence:{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:[]},lgamma:{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"]},multinomial:{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"]},permutations:{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"]},pickRandom:{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"]},random:{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"]},randomInt:{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"]},compare:{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"]},compareNatural:{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"]},compareText:{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"]},deepEqual:{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"]},equal:{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"]},equalText:{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"]},larger:{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. Comparing a value with NaN returns false.",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"]},largerEq:{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"]},smaller:{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. Comparing a value with NaN returns false.",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"]},smallerEq:{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"]},unequal:{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"]},setCartesian:{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"]},setDifference:{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"]},setDistinct:{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"]},setIntersect:{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"]},setIsSubset:{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"]},setMultiplicity:{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"]},setPowerset:{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"]},setSize:{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"]},setSymDifference:{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"]},setUnion:{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"]},zpk2tf:{name:"zpk2tf",category:"Signal",syntax:["zpk2tf(z, p, k)"],description:"Compute the transfer function of a zero-pole-gain model.",examples:["zpk2tf([1, 2], [-1, -2], 1)","zpk2tf([1, 2], [-1, -2])","zpk2tf([1 - 3i, 2 + 2i], [-1, -2])"],seealso:[]},freqz:{name:"freqz",category:"Signal",syntax:["freqz(b, a)","freqz(b, a, w)"],description:"Calculates the frequency response of a filter given its numerator and denominator coefficients.",examples:["freqz([1, 2], [1, 2, 3])","freqz([1, 2], [1, 2, 3], [0, 1])","freqz([1, 2], [1, 2, 3], 512)"],seealso:[]},erf:{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:[]},zeta:{name:"zeta",category:"Special",syntax:["zeta(s)"],description:"Compute the Riemann Zeta Function using an infinite series and Riemann's Functional Equation for the entire complex plane",examples:["zeta(0.2)","zeta(-0.5)","zeta(4)"],seealso:[]},cumsum:{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"]},mad:{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"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dimension)"],description:"Compute the maximum value of a list of values. If any NaN values are found, the function yields the last NaN in the input.",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"]},mean:{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"]},median:{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"]},min:{name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dimension)"],description:"Compute the minimum value of a list of values. If any NaN values are found, the function yields the last NaN in the input.",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"]},mode:{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"]},prod:{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"]},quantileSeq:{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 probability are: Number, BigNumber. \n\nIn 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"]},std:{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"]},sum:{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","variance"]},variance:{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"]},corr:{name:"corr",category:"Statistics",syntax:["corr(A,B)"],description:"Compute the correlation coefficient of a two list with values, For matrices, the matrix correlation coefficient is calculated.",examples:["corr([2, 4, 6, 8],[1, 2, 3, 6])","corr(matrix([[1, 2.2, 3, 4.8, 5], [1, 2, 3, 4, 5]]), matrix([[4, 5.3, 6.6, 7, 8], [1, 2, 3, 4, 5]]))"],seealso:["max","mean","min","median","min","prod","std","sum"]},acos:{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"]},acosh:{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"]},acot:{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"]},acoth:{name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the inverse hyperbolic tangent 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"]},acsc:{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"]},acsch:{name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the inverse hyperbolic cosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},asec:{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"]},asech:{name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},asin:{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"]},asinh:{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"]},atan:{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"]},atanh:{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"]},atan2:{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"]},cos:{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"]},cosh:{name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},cot:{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"]},coth:{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"]},csc:{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"]},csch:{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"]},sec:{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"]},sech:{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"]},sin:{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"]},sinh:{name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},tan:{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"]},tanh:{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"]},to:{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:[]},toBest:{name:"toBest",category:"Units",syntax:["toBest(x)","toBest(x, unitList)","toBest(x, unitList, options)"],description:"Converts to the most appropriate display unit.",examples:['toBest(unit(5000, "m"))','toBest(unit(3500000, "W"))','toBest(unit(0.000000123, "A"))','toBest(unit(10, "m"), "cm")','toBest(unit(10, "m"), "mm,km", {offset: 1.5})'],seealso:[]},clone:{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:[]},format:{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"]},bin:{name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},oct:{name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},hex:{name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},isNaN:{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"]},isInteger:{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"]},isNegative:{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"]},isNumeric:{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"]},hasNumericValue:{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"]},isPositive:{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"]},isPrime:{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"]},isZero:{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"]},print:{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: $1, $2, $3", [6, 9, 4])'],seealso:["format"]},typeOf:{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"]},numeric:{name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, bigint, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "bigint")','numeric("4", "BigNumber")','numeric("4", "Fraction")','numeric(4, "Fraction")','numeric(fraction(2, 5), "number")'],seealso:["number","bigint","fraction","bignumber","string","format"]}},mb="help",db=ti(mb,["typed","mathWithTransform","Help"],(e=>{var{typed:r,mathWithTransform:t,Help:n}=e;return r(mb,{any:function(e){var r,i=e;if("string"!=typeof e)for(r in t)if(Hn(t,r)&&e===t[r]){i=r;break}var a=_t(fb,i);if(!a)throw Error('No documentation found on "'+("function"==typeof i?i.name:i)+'"');return new n(a)}})})),pb="chain",hb=ti(pb,["typed","Chain"],(e=>{var{typed:r,Chain:t}=e;return r(pb,{"":function(){return new t},any:function(e){return new t(e)}})})),vb=ti("det",["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],(e=>{var{typed:r,matrix:t,subtractScalar:n,multiply:i,divideScalar:a,isZero:o,unaryMinus:u}=e;return r("det",{any:function(e){return Wn(e)},"Array | Matrix":function(e){var r;switch((r=cn(e)?e.size():Array.isArray(e)?(e=t(e)).size():[]).length){case 0:return Wn(e);case 1:if(1===r[0])return Wn(e.valueOf()[0]);if(0===r[0])return 1;throw new RangeError("Matrix must be square (size: "+Go(r)+")");case 2:var s=r[0],c=r[1];if(s===c)return function(e,r){if(1===r)return Wn(e[0][0]);if(2===r)return n(i(e[0][0],e[1][1]),i(e[1][0],e[0][1]));for(var t=!1,s=Array(r).fill(0).map(((e,r)=>r)),c=0;c<r;c++){var l=s[c];if(o(e[l][c])){var f=void 0;for(f=c+1;f<r;f++)if(!o(e[s[f]][c])){l=s[f],s[f]=s[c],s[c]=l,t=!t;break}if(f===r)return e[l][c]}for(var m=e[l][c],d=0===c?1:e[s[c-1]][c-1],p=c+1;p<r;p++)for(var h=s[p],v=c+1;v<r;v++)e[h][v]=a(n(i(e[h][v],m),i(e[h][c],e[l][v])),d)}var y=e[s[r-1]][r-1];return t?u(y):y}(e.clone().valueOf(),s);if(0===c)return 1;throw new RangeError("Matrix must be square (size: "+Go(r)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+Go(r)+")")}}})})),yb=ti("inv",["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],(e=>{var{typed:r,matrix:t,divideScalar:n,addScalar:i,multiply:a,unaryMinus:o,det:u,identity:s,abs:c}=e;return r("inv",{"Array | Matrix":function(e){var r=cn(e)?e.size():nu(e);switch(r.length){case 1:if(1===r[0])return cn(e)?t([n(1,e.valueOf()[0])]):[n(1,e[0])];throw new RangeError("Matrix must be square (size: "+Go(r)+")");case 2:var i=r[0],a=r[1];if(i===a)return cn(e)?t(l(e.valueOf(),i,a),e.storage()):l(e,i,a);throw new RangeError("Matrix must be square (size: "+Go(r)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+Go(r)+")")}},any:function(e){return n(1,e)}});function l(e,r,t){var l,f,m,d,p;if(1===r){if(0===(d=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero");return[[n(1,d)]]}if(2===r){var h=u(e);if(0===h)throw Error("Cannot calculate inverse, determinant is zero");return[[n(e[1][1],h),n(o(e[0][1]),h)],[n(o(e[1][0]),h),n(e[0][0],h)]]}var v=e.concat();for(l=0;l<r;l++)v[l]=v[l].concat();for(var y=s(r).valueOf(),b=0;b<t;b++){var g=c(v[b][b]),x=b;for(l=b+1;l<r;)c(v[l][b])>g&&(g=c(v[l][b]),x=l),l++;if(0===g)throw Error("Cannot calculate inverse, determinant is zero");(l=x)!==b&&(p=v[b],v[b]=v[l],v[l]=p,p=y[b],y[b]=y[l],y[l]=p);var w=v[b],D=y[b];for(l=0;l<r;l++){var N=v[l],A=y[l];if(l!==b){if(0!==N[b]){for(m=n(o(N[b]),w[b]),f=b;f<t;f++)N[f]=i(N[f],a(m,w[f]));for(f=0;f<t;f++)A[f]=i(A[f],a(m,D[f]))}}else{for(m=w[b],f=b;f<t;f++)N[f]=n(N[f],m);for(f=0;f<t;f++)A[f]=n(A[f],m)}}}return y}})),bb="pinv",gb=ti(bb,["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],(e=>{var{typed:r,matrix:t,inv:n,deepEqual:i,equal:a,dotDivide:o,dot:u,ctranspose:s,divideScalar:c,multiply:l,add:f,Complex:m}=e;return r(bb,{"Array | Matrix":function(e){var r=cn(e)?e.size():nu(e);switch(r.length){case 1:return h(e)?s(e):1===r[0]?n(e):o(s(e),u(e,e));case 2:if(h(e))return s(e);var i=r[0],a=r[1];if(i===a)try{return n(e)}catch(e){if(!(e instanceof Error&&e.message.match(/Cannot calculate inverse, determinant is zero/)))throw e}return cn(e)?t(d(e.valueOf(),i,a),e.storage()):d(e,i,a);default:throw new RangeError("Matrix must be two dimensional (size: "+Go(r)+")")}},any:function(e){return a(e,0)?Wn(e):c(1,e)}});function d(e,r,t){var{C:i,F:a}=function(e,r,t){var n=function(e,r,t){for(var n=Wn(e),i=0,a=0;a<r;a++){if(t<=i)return n;for(var u=a;p(n[u][i]);)if(r===++u&&(u=a,t===++i))return n;[n[u],n[a]]=[n[a],n[u]];for(var s=n[a][i],c=0;c<t;c++)n[a][c]=o(n[a][c],s);for(var m=0;m<r;m++)if(m!==a){s=n[m][i];for(var d=0;d<t;d++)n[m][d]=f(n[m][d],l(-1,l(s,n[a][d])))}i++}return n}(e,r,t),i=e.map((e=>e.filter(((e,t)=>t<r&&!p(u(n[t],n[t])))))),a=n.filter(((e,r)=>!p(u(n[r],n[r]))));return{C:i,F:a}}(e,r,t),c=l(n(l(s(i),i)),s(i)),m=l(s(a),n(l(a,s(a))));return l(m,c)}function p(e){return a(f(e,m(1,1)),f(0,m(1,1)))}function h(e){return i(f(e,m(1,1)),f(l(e,0),m(1,1)))}}));var xb=ti("eigs",["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","divideScalar","inv","bignumber","multiply","add","larger","column","flatten","number","complex","sqrt","diag","size","reshape","qr","usolve","usolveAll","im","re","smaller","matrixFromColumns","dot"],(e=>{var{config:r,typed:t,matrix:n,addScalar:i,subtract:a,equal:o,abs:u,atan:s,cos:c,sin:l,multiplyScalar:f,divideScalar:m,inv:d,bignumber:p,multiply:h,add:v,larger:y,flatten:b,number:g,complex:x,sqrt:w,diag:D,size:N,reshape:A,qr:M,usolve:C,usolveAll:E,im:S,re:F,smaller:B,dot:q}=e,T=function(e){var{config:r,addScalar:t,subtract:n,abs:i,atan:a,cos:o,sin:u,multiplyScalar:s,inv:c,bignumber:l,multiply:f,add:m}=e;function d(e,t,n){return Math.abs(t-e)<=r.relTol?Math.PI/4:.5*Math.atan(2*n/(t-e))}function p(e,t,o){var u=n(t,e);return i(u)<=r.relTol?l(-1).acos().div(4):s(.5,a(f(2,o,c(u))))}function h(e,r,t,n){for(var i=e.length,a=Math.cos(r),o=Math.sin(r),u=Array(i).fill(0),s=Array(i).fill(0),c=0;c<i;c++)u[c]=a*e[c][t]-o*e[c][n],s[c]=o*e[c][t]+a*e[c][n];for(var l=0;l<i;l++)e[l][t]=u[l],e[l][n]=s[l];return e}function v(e,r,i,a){for(var c=e.length,f=o(r),m=u(r),d=Array(c).fill(l(0)),p=Array(c).fill(l(0)),h=0;h<c;h++)d[h]=n(s(f,e[h][i]),s(m,e[h][a])),p[h]=t(s(m,e[h][i]),s(f,e[h][a]));for(var v=0;v<c;v++)e[v][i]=d[v],e[v][a]=p[v];return e}function y(e,r,i,a){for(var c=e.length,d=l(o(r)),p=l(u(r)),h=s(d,d),v=s(p,p),y=Array(c).fill(l(0)),b=Array(c).fill(l(0)),g=f(l(2),d,p,e[i][a]),x=t(n(s(h,e[i][i]),g),s(v,e[a][a])),w=m(s(v,e[i][i]),g,s(h,e[a][a])),D=0;D<c;D++)y[D]=n(s(d,e[i][D]),s(p,e[a][D])),b[D]=t(s(p,e[i][D]),s(d,e[a][D]));e[i][i]=x,e[a][a]=w,e[i][a]=l(0),e[a][i]=l(0);for(var N=0;N<c;N++)N!==i&&N!==a&&(e[i][N]=y[N],e[N][i]=y[N],e[a][N]=b[N],e[N][a]=b[N]);return e}function b(e,r,t,n){for(var i=e.length,a=Math.cos(r),o=Math.sin(r),u=a*a,s=o*o,c=Array(i).fill(0),l=Array(i).fill(0),f=u*e[t][t]-2*a*o*e[t][n]+s*e[n][n],m=s*e[t][t]+2*a*o*e[t][n]+u*e[n][n],d=0;d<i;d++)c[d]=a*e[t][d]-o*e[n][d],l[d]=o*e[t][d]+a*e[n][d];e[t][t]=f,e[n][n]=m,e[t][n]=0,e[n][t]=0;for(var p=0;p<i;p++)p!==t&&p!==n&&(e[t][p]=c[p],e[p][t]=c[p],e[n][p]=l[p],e[p][n]=l[p]);return e}function g(e){for(var r=e.length,t=0,n=[0,1],i=0;i<r;i++)for(var a=i+1;a<r;a++)Math.abs(t)<Math.abs(e[i][a])&&(t=Math.abs(e[i][a]),n=[i,a]);return[n,t]}function x(e){for(var r=e.length,t=0,n=[0,1],a=0;a<r;a++)for(var o=a+1;o<r;o++)i(t)<i(e[a][o])&&(t=i(e[a][o]),n=[a,o]);return[n,t]}function w(e,r,t){var n,a=e.length,o=Array(a);if(t){n=Array(a);for(var u=0;u<a;u++)n[u]=Array(a)}for(var s=0;s<a;s++){for(var c=0,l=e[0],f=0;f<e.length;f++)i(e[f])<i(l)&&(l=e[c=f]);if(o[s]=e.splice(c,1)[0],t)for(var m=0;m<a;m++)n[s][m]=r[m][c],r[m].splice(c,1)}if(!t)return{values:o};var d=n.map(((e,r)=>({value:o[r],vector:e})));return{values:o,eigenvectors:d}}return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r.relTol,a=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0;if("number"===a)return function(e,r,t){var n,i,a=e.length,o=Math.abs(r/a);if(t){i=Array(a);for(var u=0;u<a;u++)i[u]=Array(a).fill(0),i[u][u]=1}for(var s=g(e);Math.abs(s[1])>=Math.abs(o);){var c=s[0][0],l=s[0][1];e=b(e,n=d(e[c][c],e[l][l],e[c][l]),c,l),t&&(i=h(i,n,c,l)),s=g(e)}for(var f=Array(a).fill(0),m=0;m<a;m++)f[m]=e[m][m];return w(Wn(f),i,t)}(e,n,o);if("BigNumber"===a)return function(e,r,t){var n,a,o=e.length,u=i(r/o);if(t){a=Array(o);for(var s=0;s<o;s++)a[s]=Array(o).fill(0),a[s][s]=1}for(var c=x(e);i(c[1])>=i(u);){var l=c[0][0],f=c[0][1];e=y(e,n=p(e[l][l],e[f][f],e[l][f]),l,f),t&&(a=v(a,n,l,f)),c=x(e)}for(var m=Array(o).fill(0),d=0;d<o;d++)m[d]=e[d][d];return w(Wn(m),a,t)}(e,n,o);throw TypeError("Unsupported data type: "+a)}}({config:r,addScalar:i,subtract:a,abs:u,atan:s,cos:c,sin:l,multiplyScalar:f,inv:d,bignumber:p,multiply:h,add:v}),k=function(e){var{addScalar:r,subtract:t,flatten:n,multiply:i,multiplyScalar:a,divideScalar:o,sqrt:u,abs:s,bignumber:c,diag:l,size:f,reshape:m,inv:d,qr:p,usolve:h,usolveAll:v,equal:y,complex:b,larger:g,smaller:x,dot:w}=e;function D(e,n,i,o){var s=r(e,o),c=t(a(e,o),a(n,i)),l=a(s,.5),f=a(u(t(a(s,s),a(4,c))),.5);return[r(l,f),t(l,f)]}function N(e,r,n,i,a,o,u,l){var f="BigNumber"===l,m="Complex"===l,d=f?c(0):m?b(0):0,p=f?c(1):m?b(1):1;if(x(s(n),u))return[[p,d],[d,p]];if(g(s(t(a,o)),u))return[[t(a,i),t(o,i)],[n,n]];var h=t(e,a),v=t(i,a);return x(s(r),u)&&x(s(v),u)?[[h,p],[n,d]]:[[r,d],[v,p]]}function A(e,r){for(var t=0;t<e.length;t++)e[t].push(...Array(r-e[t].length).fill(0));for(var n=e.length;n<r;n++)e.push(Array(r).fill(0)),e[n][n]=1;return e}function M(e,r,t){for(var n=0;n<e.length;n++)if(t(e[n],r))return n;return-1}function C(e,r,t,n,i){for(var a,o="BigNumber"===i?c(1e3):1e3,u=0;u<5;++u){a=E(r,t,i);try{a=h(e,a)}catch(e){continue}if(g(F(a),o))break}if(u>=5)return null;for(u=0;;){var s=h(e,a);if(x(F(S(a,[s])),n))break;if(++u>=10)return null;a=B(s)}return a}function E(e,r,t){var n="BigNumber"===t,i="Complex"===t,a=Array(e).fill(0).map((()=>2*Math.random()-1));return n&&(a=a.map((e=>c(e)))),i&&(a=a.map((e=>b(e)))),B(a=S(a,r),t)}function S(e,r){var n=f(e);for(var a of r)a=m(a,n),e=t(e,i(o(w(a,e),w(a,a)),a));return e}function F(e){return s(u(w(e,e)))}function B(e,r){var t="Complex"===r,n="BigNumber"===r?c(1):t?b(1):1;return i(o(n,F(e)),e)}return function(e,u,f,m){var h=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],w=function(e,t,n,i,u){var f,m="BigNumber"===i,d="Complex"===i,p=m?c(0):0,h=m?c(1):d?b(1):1,v=m?c(1):1,w=m?c(10):2,D=a(w,w);u&&(f=Array(t).fill(h));for(var N=!1;!N;){N=!0;for(var A=0;A<t;A++){for(var M=p,C=p,E=0;E<t;E++)A!==E&&(M=r(M,s(e[E][A])),C=r(C,s(e[A][E])));if(!y(M,0)&&!y(C,0)){for(var S=v,F=M,B=o(C,w),q=a(C,w);x(F,B);)F=a(F,D),S=a(S,w);for(;g(F,q);)F=o(F,D),S=o(S,w);if(x(o(r(F,C),S),a(r(M,C),.95))){N=!1;for(var T=o(1,S),k=0;k<t;k++)A!==k&&(e[A][k]=a(e[A][k],T),e[k][A]=a(e[k][A],S));u&&(f[A]=a(f[A],T))}}}}return u?l(f):null}(e,u,0,m,h);!function(e,n,i,u,l,f){var m="BigNumber"===u,d="Complex"===u,p=m?c(0):d?b(0):0;m&&(i=c(i));for(var h=0;h<n-2;h++){for(var v=0,y=p,g=h+1;g<n;g++){var w=e[g][h];x(s(y),s(w))&&(y=w,v=g)}if(!x(s(y),i)){if(v!==h+1){var D=e[v];e[v]=e[h+1],e[h+1]=D;for(var N=0;N<n;N++){var A=e[N][v];e[N][v]=e[N][h+1],e[N][h+1]=A}if(l){var M=f[v];f[v]=f[h+1],f[h+1]=M}}for(var C=h+2;C<n;C++){var E=o(e[C][h],y);if(0!==E){for(var S=0;S<n;S++)e[C][S]=t(e[C][S],a(E,e[h+1][S]));for(var F=0;F<n;F++)e[F][h+1]=r(e[F][h+1],a(E,e[F][C]));if(l)for(var B=0;B<n;B++)f[C][B]=t(f[C][B],a(E,f[h+1][B]))}}}}}(e,u,f,m,h,w);var{values:E,C:S}=function(e,n,a,o,u){var f="BigNumber"===o,m="Complex"===o,d=f?c(1):m?b(1):1;f&&(a=c(a));for(var h=Wn(e),v=[],y=n,g=[],w=u?l(Array(n).fill(d)):void 0,M=u?l(Array(y).fill(d)):void 0,C=0;C<=100;){C+=1;for(var E=h[y-1][y-1],S=0;S<y;S++)h[S][S]=t(h[S][S],E);var{Q:F,R:B}=p(h);h=i(B,F);for(var q=0;q<y;q++)h[q][q]=r(h[q][q],E);if(u&&(M=i(M,F)),1===y||x(s(h[y-1][y-2]),a)){C=0,v.push(h[y-1][y-1]),u&&(g.unshift([[1]]),A(M,n),w=i(w,M),y>1&&(M=l(Array(y-1).fill(d)))),y-=1,h.pop();for(var T=0;T<y;T++)h[T].pop()}else if(2===y||x(s(h[y-2][y-3]),a)){C=0;var k=D(h[y-2][y-2],h[y-2][y-1],h[y-1][y-2],h[y-1][y-1]);v.push(...k),u&&(g.unshift(N(h[y-2][y-2],h[y-2][y-1],h[y-1][y-2],h[y-1][y-1],k[0],k[1],a,o)),A(M,n),w=i(w,M),y>2&&(M=l(Array(y-2).fill(d)))),y-=2,h.pop(),h.pop();for(var O=0;O<y;O++)h[O].pop(),h[O].pop()}if(0===y)break}if(v.sort(((e,r)=>+t(s(e),s(r)))),C>100){var I=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+v.join(", "));throw I.values=v,I.vectors=[],I}var z=u?i(w,function(e,r){for(var t=[],n=0;n<r;n++)t[n]=Array(r).fill(0);var i=0;for(var a of e){for(var o=a.length,u=0;u<o;u++)for(var s=0;s<o;s++)t[i+u][i+s]=a[u][s];i+=o}return t}(g,n)):void 0;return{values:v,C:z}}(e,u,f,m,h);if(h){var F=function(e,r,a,o,u,s,f){var m=d(a),p=i(m,e,a),h="BigNumber"===f,g="Complex"===f,x=h?c(0):g?b(0):0,w=h?c(1):g?b(1):1,D=[],N=[];for(var A of u){var E=M(D,A,y);-1===E?(D.push(A),N.push(1)):N[E]+=1}for(var S=[],F=D.length,B=Array(r).fill(x),q=l(Array(r).fill(w)),T=function(){var e=D[k],u=t(p,i(e,q)),c=v(u,B);for(c.shift();c.length<N[k];){var l=C(u,r,c,s,f);if(null===l)break;c.push(l)}var m=i(d(o),a);c=c.map((e=>i(m,e))),S.push(...c.map((r=>({value:e,vector:n(r)}))))},k=0;k<F;k++)T();return S}(e,u,S,w,E,f,m);return{values:E,eigenvectors:F}}return{values:E}}}({addScalar:i,subtract:a,multiply:h,multiplyScalar:f,flatten:b,divideScalar:m,sqrt:w,abs:u,bignumber:p,diag:D,size:N,reshape:A,qr:M,inv:d,usolve:C,usolveAll:E,equal:o,complex:x,larger:y,smaller:B,dot:q});return t("eigs",{Array:function(e){return O(n(e))},"Array, number|BigNumber":function(e,r){return O(n(e),{precision:r})},"Array, Object":(e,r)=>O(n(e),r),Matrix:function(e){return O(e,{matricize:!0})},"Matrix, number|BigNumber":function(e,r){return O(e,{precision:r,matricize:!0})},"Matrix, Object":function(e,r){var t={matricize:!0};return Pt(t,r),O(e,t)}});function O(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=!("eigenvectors"in i)||i.eigenvectors,s=function(e,r,t){var n=e.toArray(),i=e.size();if(2!==i.length||i[0]!==i[1])throw new RangeError("Matrix must be square (size: ".concat(Go(i),")"));var o=i[0];if(function(e,r,t){for(var n=0;n<r;n++)for(var i=0;i<r;i++)if(y(p(u(S(e[n][i]))),t))return!1;return!0}(n,o,r)&&(function(e,r){for(var t=0;t<r;t++)for(var n=0;n<r;n++)e[t][n]=F(e[t][n])}(n,o),function(e,r,t){for(var n=0;n<r;n++)for(var i=n;i<r;i++)if(y(p(u(a(e[n][i],e[i][n]))),t))return!1;return!0}(n,o,r))){var s=I(e,n,o);return T(n,o,r,s,t)}var c=I(e,n,o);return k(n,o,r,c,t)}(e,null!==(t=i.precision)&&void 0!==t?t:r.relTol,o);return i.matricize&&(s.values=n(s.values),o&&(s.eigenvectors=s.eigenvectors.map((e=>{var{value:r,vector:t}=e;return{value:r,vector:n(t)}})))),o&&Object.defineProperty(s,"vectors",{enumerable:!1,get:()=>{throw Error("eigs(M).vectors replaced with eigs(M).eigenvectors")}}),s}function I(e,r,t){var n=e.datatype();if("number"===n||"BigNumber"===n||"Complex"===n)return n;for(var i=!1,a=!1,o=!1,u=0;u<t;u++)for(var s=0;s<t;s++){var c=r[u][s];if(en(c)||an(c))i=!0;else if(rn(c))a=!0;else{if(!nn(c))throw TypeError("Unsupported type in Matrix: "+_n(c));o=!0}}if(a&&o&&console.warn("Complex BigNumbers not supported, this operation will lose precission."),o){for(var l=0;l<t;l++)for(var f=0;f<t;f++)r[l][f]=x(r[l][f]);return"Complex"}if(a){for(var m=0;m<t;m++)for(var d=0;d<t;d++)r[m][d]=p(r[m][d]);return"BigNumber"}if(i){for(var h=0;h<t;h++)for(var v=0;v<t;v++)r[h][v]=g(r[h][v]);return"number"}throw TypeError("Matrix contains unsupported types only.")}})),wb="expm",Db=ti(wb,["typed","abs","add","identity","inv","multiply"],(e=>{var{typed:r,abs:t,add:n,identity:i,inv:a,multiply:o}=e;return r(wb,{Matrix:function(e){var r=e.size();if(2!==r.length||r[0]!==r[1])throw new RangeError("Matrix must be square (size: "+Go(r)+")");for(var s=r[0],c=function(e){for(var r=e.size()[0],n=0,i=0;i<r;i++){for(var a=0,o=0;o<r;o++)a+=t(e.get([i,o]));n=Math.max(a,n)}return n}(e),l=function(e){for(var r=0;r<30;r++)for(var t=0;t<=r;t++){var n=r-t;if(u(e,t,n)<1e-15)return{q:t,j:n}}throw Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}(c),f=l.q,m=l.j,d=o(e,Math.pow(2,-m)),p=i(s),h=i(s),v=1,y=d,b=-1,g=1;g<=f;g++)g>1&&(y=o(y,d),b=-b),p=n(p,o(v=v*(f-g+1)/((2*f-g+1)*g),y)),h=n(h,o(v*b,y));for(var x=o(a(h),p),w=0;w<m;w++)x=o(x,x);return mn(e)?e.createSparseMatrix(x):x}});function u(e,r,t){for(var n=1,i=2;i<=r;i++)n*=i;for(var a=n,o=r+1;o<=2*r;o++)a*=o;var u=a*(2*r+1);return 8*Math.pow(e/Math.pow(2,t),2*r)*n*n/(a*u)}})),Nb="sqrtm",Ab=ti(Nb,["typed","abs","add","multiply","map","sqrt","subtract","inv","size","max","identity"],(e=>{var{typed:r,abs:t,add:n,multiply:i,map:a,sqrt:o,subtract:u,inv:s,size:c,max:l,identity:f}=e,m=1e-6;function d(e){var r,a=0,o=e,d=f(c(e));do{var p=o;if(o=i(.5,n(p,s(d))),d=i(.5,n(d,s(p))),(r=l(t(u(o,p))))>m&&++a>1e3)throw Error("computing square root of matrix: iterative method could not converge")}while(r>m);return o}return r(Nb,{"Array | Matrix":function(e){var r=cn(e)?e.size():nu(e);switch(r.length){case 1:if(1===r[0])return a(e,o);throw new RangeError("Matrix must be square (size: "+Go(r)+")");case 2:if(r[0]===r[1])return d(e);throw new RangeError("Matrix must be square (size: "+Go(r)+")");default:throw new RangeError("Matrix must be at most two dimensional (size: "+Go(r)+")")}}})})),Mb="sylvester",Cb=ti(Mb,["typed","schur","matrixFromColumns","matrix","multiply","range","concat","transpose","index","subset","add","subtract","identity","lusolve","abs"],(e=>{var{typed:r,schur:t,matrixFromColumns:n,matrix:i,multiply:a,range:o,concat:u,transpose:s,index:c,subset:l,add:f,subtract:m,identity:d,lusolve:p,abs:h}=e;return r(Mb,{"Matrix, Matrix, Matrix":v,"Array, Matrix, Matrix":function(e,r,t){return v(i(e),r,t)},"Array, Array, Matrix":function(e,r,t){return v(i(e),i(r),t)},"Array, Matrix, Array":function(e,r,t){return v(i(e),r,i(t))},"Matrix, Array, Matrix":function(e,r,t){return v(e,i(r),t)},"Matrix, Array, Array":function(e,r,t){return v(e,i(r),i(t))},"Matrix, Matrix, Array":function(e,r,t){return v(e,r,i(t))},"Array, Array, Array":function(e,r,t){return v(i(e),i(r),i(t)).toArray()}});function v(e,r,v){for(var y=r.size()[0],b=e.size()[0],g=t(e),x=g.T,w=g.U,D=t(a(-1,r)),N=D.T,A=D.U,M=a(a(s(w),v),A),C=o(0,b),E=[],S=(e,r)=>u(e,r,1),F=(e,r)=>u(e,r,0),B=0;B<y;B++)if(B<y-1&&h(l(N,c(B+1,B)))>1e-5){for(var q=F(l(M,c(C,B)),l(M,c(C,B+1))),T=0;T<B;T++)q=f(q,F(a(E[T],l(N,c(T,B))),a(E[T],l(N,c(T,B+1)))));var k=a(d(b),a(-1,l(N,c(B,B)))),O=a(d(b),a(-1,l(N,c(B+1,B)))),I=a(d(b),a(-1,l(N,c(B,B+1)))),z=a(d(b),a(-1,l(N,c(B+1,B+1)))),j=F(S(f(x,k),O),S(I,f(x,z))),R=p(j,q);E[B]=R.subset(c(o(0,b),0)),E[B+1]=R.subset(c(o(b,2*b),0)),B++}else{for(var U=l(M,c(C,B)),$=0;$<B;$++)U=f(U,a(E[$],l(N,c($,B))));var P=l(N,c(B,B)),L=m(x,a(P,d(b)));E[B]=p(L,U)}var _=i(n(...E));return a(w,a(_,s(A)))}})),Eb="schur",Sb=ti(Eb,["typed","matrix","identity","multiply","qr","norm","subtract"],(e=>{var{typed:r,matrix:t,identity:n,multiply:i,qr:a,norm:o,subtract:u}=e;return r(Eb,{Array:function(e){var r=s(t(e));return{U:r.U.valueOf(),T:r.T.valueOf()}},Matrix:function(e){return s(e)}});function s(e){var r,t=e.size()[0],s=e,c=n(t),l=0;do{r=s;var f=a(s),m=f.Q;if(s=i(f.R,m),c=i(c,m),l++>100)break}while(o(u(s,r))>1e-4);return{U:c,T:s}}})),Fb="lyap",Bb=ti(Fb,["typed","matrix","sylvester","multiply","transpose"],(e=>{var{typed:r,matrix:t,sylvester:n,multiply:i,transpose:a}=e;return r(Fb,{"Matrix, Matrix":function(e,r){return n(e,a(e),i(-1,r))},"Array, Matrix":function(e,r){return n(t(e),a(t(e)),i(-1,r))},"Matrix, Array":function(e,r){return n(e,a(t(e)),t(i(-1,r)))},"Array, Array":function(e,r){return n(t(e),a(t(e)),t(i(-1,r))).toArray()}})})),qb=ti("divide",["typed","matrix","multiply","equalScalar","divideScalar","inv"],(e=>{var{typed:r,matrix:t,multiply:n,equalScalar:i,divideScalar:a,inv:o}=e,u=ul({typed:r,equalScalar:i}),s=cl({typed:r});return r("divide",Jn({"Array | Matrix, Array | Matrix":function(e,r){return n(e,o(r))},"DenseMatrix, any":function(e,r){return s(e,r,a,!1)},"SparseMatrix, any":function(e,r){return u(e,r,a,!1)},"Array, any":function(e,r){return s(t(e),r,a,!1).valueOf()},"any, Array | Matrix":function(e,r){return n(e,o(r))}},a.signatures))})),Tb="distance",kb=ti(Tb,["typed","addScalar","subtractScalar","divideScalar","multiplyScalar","deepEqual","sqrt","abs"],(e=>{var{typed:r,addScalar:t,subtractScalar:n,multiplyScalar:i,divideScalar:a,deepEqual:o,sqrt:u,abs:s}=e;return r(Tb,{"Array, Array, Array":function(e,r,t){if(2===e.length&&2===r.length&&2===t.length){if(!l(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!l(r))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!l(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(o(r,t))throw new TypeError("LinePoint1 should not be same with LinePoint2");var a=n(t[1],r[1]),u=n(r[0],t[0]),s=n(i(t[0],r[1]),i(r[0],t[1]));return h(e[0],e[1],a,u,s)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(e,r,t){if(2===Object.keys(e).length&&2===Object.keys(r).length&&2===Object.keys(t).length){if(!l(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!l(r))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!l(t))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if(o(p(r),p(t)))throw new TypeError("LinePoint1 should not be same with LinePoint2");if("pointX"in e&&"pointY"in e&&"lineOnePtX"in r&&"lineOnePtY"in r&&"lineTwoPtX"in t&&"lineTwoPtY"in t){var a=n(t.lineTwoPtY,r.lineOnePtY),u=n(r.lineOnePtX,t.lineTwoPtX),s=n(i(t.lineTwoPtX,r.lineOnePtY),i(r.lineOnePtX,t.lineTwoPtY));return h(e.pointX,e.pointY,a,u,s)}throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(e,r){if(2===e.length&&3===r.length){if(!l(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!f(r))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return h(e[0],e[1],r[0],r[1],r[2])}if(3===e.length&&6===r.length){if(!f(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!d(r))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return v(e[0],e[1],e[2],r[0],r[1],r[2],r[3],r[4],r[5])}if(e.length===r.length&&e.length>0){if(!m(e))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!m(r))throw new TypeError("All values of an array should be numbers or BigNumbers");return y(e,r)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,r){if(2===Object.keys(e).length&&3===Object.keys(r).length){if(!l(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!f(r))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"xCoeffLine"in r&&"yCoeffLine"in r&&"constant"in r)return h(e.pointX,e.pointY,r.xCoeffLine,r.yCoeffLine,r.constant);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&6===Object.keys(r).length){if(!f(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!d(r))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"x0"in r&&"y0"in r&&"z0"in r&&"a"in r&&"b"in r&&"c"in r)return v(e.pointX,e.pointY,e.pointZ,r.x0,r.y0,r.z0,r.a,r.b,r.c);throw new TypeError("Key names do not match")}if(2===Object.keys(e).length&&2===Object.keys(r).length){if(!l(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!l(r))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointTwoX"in r&&"pointTwoY"in r)return y([e.pointOneX,e.pointOneY],[r.pointTwoX,r.pointTwoY]);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&3===Object.keys(r).length){if(!f(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!f(r))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointOneZ"in e&&"pointTwoX"in r&&"pointTwoY"in r&&"pointTwoZ"in r)return y([e.pointOneX,e.pointOneY,e.pointOneZ],[r.pointTwoX,r.pointTwoY,r.pointTwoZ]);throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},Array:function(e){if(!function(e){if(2===e[0].length&&c(e[0][0])&&c(e[0][1])){if(e.some((e=>2!==e.length||!c(e[0])||!c(e[1]))))return!1}else{if(!(3===e[0].length&&c(e[0][0])&&c(e[0][1])&&c(e[0][2])))return!1;if(e.some((e=>3!==e.length||!c(e[0])||!c(e[1])||!c(e[2]))))return!1}return!0}(e))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return function(e){for(var r=[],t=[],n=[],i=0;i<e.length-1;i++)for(var a=i+1;a<e.length;a++)2===e[0].length?(t=[e[i][0],e[i][1]],n=[e[a][0],e[a][1]]):3===e[0].length&&(t=[e[i][0],e[i][1],e[i][2]],n=[e[a][0],e[a][1],e[a][2]]),r.push(y(t,n));return r}(e)}});function c(e){return"number"==typeof e||rn(e)}function l(e){return e.constructor!==Array&&(e=p(e)),c(e[0])&&c(e[1])}function f(e){return e.constructor!==Array&&(e=p(e)),c(e[0])&&c(e[1])&&c(e[2])}function m(e){return Array.isArray(e)||(e=p(e)),e.every(c)}function d(e){return e.constructor!==Array&&(e=p(e)),c(e[0])&&c(e[1])&&c(e[2])&&c(e[3])&&c(e[4])&&c(e[5])}function p(e){for(var r=Object.keys(e),t=[],n=0;n<r.length;n++)t.push(e[r[n]]);return t}function h(e,r,n,o,c){var l=s(t(t(i(n,e),i(o,r)),c)),f=u(t(i(n,n),i(o,o)));return a(l,f)}function v(e,r,o,s,c,l,f,m,d){var p=[n(i(n(c,r),d),i(n(l,o),m)),n(i(n(l,o),f),i(n(s,e),d)),n(i(n(s,e),m),i(n(c,r),f))];p=u(t(t(i(p[0],p[0]),i(p[1],p[1])),i(p[2],p[2])));var h=u(t(t(i(f,f),i(m,m)),i(d,d)));return a(p,h)}function y(e,r){for(var a=e.length,o=0,s=0,c=0;c<a;c++)s=n(e[c],r[c]),o=t(i(s,s),o);return u(o)}})),Ob=ti("intersect",["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],(e=>{var{typed:r,config:t,abs:n,add:i,addScalar:a,matrix:o,multiply:u,multiplyScalar:s,divideScalar:c,subtract:l,smaller:f,equalScalar:m,flatten:d,isZero:p,isNumeric:h}=e;return r("intersect",{"Array, Array, Array":v,"Array, Array, Array, Array":y,"Matrix, Matrix, Matrix":function(e,r,t){var n=v(e.valueOf(),r.valueOf(),t.valueOf());return null===n?null:o(n)},"Matrix, Matrix, Matrix, Matrix":function(e,r,t,n){var i=y(e.valueOf(),r.valueOf(),t.valueOf(),n.valueOf());return null===i?null:o(i)}});function v(e,r,t){if(e=b(e),r=b(r),t=b(t),!x(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!x(r))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!function(e){return 4===e.length&&h(e[0])&&h(e[1])&&h(e[2])&&h(e[3])}(t))throw new TypeError("Array with 4 numbers expected as third argument");return function(e,r,t,n,i,o,u,f,m,d){var p=s(e,u),h=s(n,u),v=s(r,f),y=s(i,f),b=s(t,m),g=s(o,m),x=l(l(l(d,p),v),b),w=l(l(l(a(a(h,y),g),p),v),b),D=c(x,w);return[a(e,s(D,l(n,e))),a(r,s(D,l(i,r))),a(t,s(D,l(o,t)))]}(e[0],e[1],e[2],r[0],r[1],r[2],t[0],t[1],t[2],t[3])}function y(e,r,o,d){if(e=b(e),r=b(r),o=b(o),d=b(d),2===e.length){if(!g(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!g(r))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!g(o))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!g(d))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return function(e,r,o,m){var d=e,h=o,v=l(d,r),y=l(h,m),b=l(s(v[0],y[1]),s(y[0],v[1]));if(p(b))return null;if(f(n(b),t.relTol))return null;var g=s(y[0],d[1]),x=s(y[1],d[0]),w=s(y[0],h[1]),D=s(y[1],h[0]),N=c(a(l(l(g,x),w),D),b);return i(u(v,N),d)}(e,r,o,d)}if(3===e.length){if(!x(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!x(r))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!x(o))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!x(d))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return function(e,r,t,n,i,o,u,f,d,h,v,y){var b=w(e,u,h,u,r,f,v,f,t,d,y,d),g=w(h,u,n,e,v,f,i,r,y,d,o,t),x=w(e,u,n,e,r,f,i,r,t,d,o,t),D=w(h,u,h,u,v,f,v,f,y,d,y,d),N=w(n,e,n,e,i,r,i,r,o,t,o,t),A=l(s(b,g),s(x,D)),M=l(s(N,D),s(g,g));if(p(M))return null;var C=c(A,M),E=c(a(b,s(C,g)),D),S=a(e,s(C,l(n,e))),F=a(r,s(C,l(i,r))),B=a(t,s(C,l(o,t))),q=a(u,s(E,l(h,u))),T=a(f,s(E,l(v,f))),k=a(d,s(E,l(y,d)));return m(S,q)&&m(F,T)&&m(B,k)?[S,F,B]:null}(e[0],e[1],e[2],r[0],r[1],r[2],o[0],o[1],o[2],d[0],d[1],d[2])}throw new TypeError("Arrays with two or thee dimensional points expected")}function b(e){return 1===e.length?e[0]:e.length>1&&Array.isArray(e[0])&&e.every((e=>Array.isArray(e)&&1===e.length))?d(e):e}function g(e){return 2===e.length&&h(e[0])&&h(e[1])}function x(e){return 3===e.length&&h(e[0])&&h(e[1])&&h(e[2])}function w(e,r,t,n,i,o,u,c,f,m,d,p){var h=s(l(e,r),l(t,n)),v=s(l(i,o),l(u,c)),y=s(l(f,m),l(d,p));return a(a(h,v),y)}})),Ib=ti("sum",["typed","config","add","numeric"],(e=>{var{typed:r,config:t,add:n,numeric:i}=e;return r("sum",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,r){try{return Ju(e,r,n)}catch(e){throw dd(e,"sum")}},"...":function(e){if(Lu(e))throw new TypeError("Scalar values expected in function sum");return a(e)}});function a(e){var r;return _u(e,(function(e){try{r=void 0===r?e:n(r,e)}catch(r){throw dd(r,"sum",e)}})),void 0===r&&(r=i(0,t.number)),"string"==typeof r&&(r=i(r,ai(r,t))),r}})),zb="cumsum",jb=ti(zb,["typed","add","unaryPlus"],(e=>{var{typed:r,add:t,unaryPlus:n}=e;return r(zb,{Array:i,Matrix:function(e){return e.create(i(e.valueOf(),e.datatype()))},"Array, number | BigNumber":o,"Matrix, number | BigNumber":function(e,r){return e.create(o(e.valueOf(),r),e.datatype())},"...":function(e){if(Lu(e))throw new TypeError("All values expected to be scalar in function cumsum");return i(e)}});function i(e){try{return a(e)}catch(e){throw dd(e,zb)}}function a(e){if(0===e.length)return[];for(var r=[n(e[0])],i=1;i<e.length;++i)r.push(t(r[i-1],e[i]));return r}function o(e,r){var t=nu(e);if(r<0||r>=t.length)throw new tu(r,t.length);try{return u(e,r)}catch(e){throw dd(e,zb)}}function u(e,r){var t,n,i;if(r<=0){if(Array.isArray(e[0][0])){for(i=Pu(e),n=[],t=0;t<i.length;t++)n[t]=u(i[t],r-1);return n}return a(e)}for(n=[],t=0;t<e.length;t++)n[t]=u(e[t],r-1);return n}})),Rb="mean",Ub=ti(Rb,["typed","add","divide"],(e=>{var{typed:r,add:t,divide:n}=e;return r(Rb,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,r){try{var i=Ju(e,r,t),a=Array.isArray(e)?nu(e):e.size();return n(i,a[r])}catch(e){throw dd(e,"mean")}},"...":function(e){if(Lu(e))throw new TypeError("Scalar values expected in function mean");return i(e)}});function i(e){var r,i=0;if(_u(e,(function(e){try{r=void 0===r?e:t(r,e),i++}catch(r){throw dd(r,"mean",e)}})),0===i)throw Error("Cannot calculate the mean of an empty array");return n(r,i)}})),$b="median",Pb=ti($b,["typed","add","divide","compare","partitionSelect"],(e=>{var{typed:r,add:t,divide:n,compare:i,partitionSelect:a}=e;function o(e){try{var r=(e=bu(e.valueOf())).length;if(0===r)throw Error("Cannot calculate median of an empty array");if(r%2==0){for(var t=r/2-1,n=a(e,t+1),o=e[t],c=0;c<t;++c)i(e[c],o)>0&&(o=e[c]);return s(o,n)}var l=a(e,(r-1)/2);return u(l)}catch(e){throw dd(e,"median")}}var u=r({"number | BigNumber | Complex | Unit":function(e){return e}}),s=r({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,r){return n(t(e,r),2)}});return r($b,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(){throw Error("median(A, dim) is not yet supported")},"...":function(e){if(Lu(e))throw new TypeError("Scalar values expected in function median");return o(e)}})})),Lb=ti("mad",["typed","abs","map","median","subtract"],(e=>{var{typed:r,abs:t,map:n,median:i,subtract:a}=e;return r("mad",{"Array | Matrix":o,"...":function(e){return o(e)}});function o(e){if(0===(e=bu(e.valueOf())).length)throw Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var r=i(e);return i(n(e,(function(e){return t(a(e,r))})))}catch(e){throw e instanceof TypeError&&e.message.includes("median")?new TypeError(e.message.replace("median","mad")):dd(e,"mad")}}})),_b="unbiased",Wb="variance",Jb=ti(Wb,["typed","add","subtract","multiply","divide","mapSlices","isNaN"],(e=>{var{typed:r,add:t,subtract:n,multiply:i,divide:a,mapSlices:o,isNaN:u}=e;return r(Wb,{"Array | Matrix":function(e){return s(e,_b)},"Array | Matrix, string":s,"Array | Matrix, number | BigNumber":function(e,r){return c(e,r,_b)},"Array | Matrix, number | BigNumber, string":c,"...":function(e){return s(e,_b)}});function s(e,r){var o,s=0;if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(_u(e,(function(e){try{o=void 0===o?e:t(o,e),s++}catch(r){throw dd(r,"variance",e)}})),0===s)throw Error("Cannot calculate variance of an empty array");var c=a(o,s);if(o=void 0,_u(e,(function(e){var r=n(e,c);o=void 0===o?i(r,r):t(o,i(r,r))})),u(o))return o;switch(r){case"uncorrected":return a(o,s);case"biased":return a(o,s+1);case"unbiased":var l=rn(o)?o.mul(0):0;return 1===s?l:a(o,s-1);default:throw Error('Unknown normalization "'+r+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function c(e,r,t){try{if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return o(e,r,(e=>s(e,t)))}catch(e){throw dd(e,"variance")}}})),Vb="quantileSeq",Hb=ti(Vb,["typed","?bignumber","add","subtract","divide","multiply","partitionSelect","compare","isInteger","smaller","smallerEq","larger","mapSlices"],(e=>{var{typed:r,bignumber:t,add:n,subtract:i,divide:a,multiply:o,partitionSelect:u,compare:s,isInteger:c,smaller:l,smallerEq:f,larger:m,mapSlices:d}=e;return r(Vb,{"Array | Matrix, number | BigNumber":(e,r)=>h(e,r,!1),"Array | Matrix, number | BigNumber, number":(e,r,t)=>p(e,r,!1,t,h),"Array | Matrix, number | BigNumber, boolean":h,"Array | Matrix, number | BigNumber, boolean, number":(e,r,t,n)=>p(e,r,t,n,h),"Array | Matrix, Array | Matrix":(e,r)=>v(e,r,!1),"Array | Matrix, Array | Matrix, number":(e,r,t)=>p(e,r,!1,t,v),"Array | Matrix, Array | Matrix, boolean":v,"Array | Matrix, Array | Matrix, boolean, number":(e,r,t,n)=>p(e,r,t,n,v)});function p(e,r,t,n,i){return d(e,n,(e=>i(e,r,t)))}function h(e,r,i){var o,u=e.valueOf();if(l(r,0))throw Error("N/prob must be non-negative");if(f(r,1))return en(r)?y(u,r,i):t(y(u,r,i));if(m(r,1)){if(!c(r))throw Error("N must be a positive integer");if(m(r,4294967295))throw Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var s=n(r,1);o=[];for(var d=0;l(d,r);d++){var p=a(d+1,s);o.push(y(u,p,i))}return en(r)?o:t(o)}}function v(e,r,t){for(var n=e.valueOf(),i=r.valueOf(),a=[],o=0;o<i.length;++o)a.push(y(n,i[o],t));return a}function y(e,r,t){var a=bu(e),l=a.length;if(0===l)throw Error("Cannot calculate quantile of an empty sequence");var f,m,d=en(r)?r*(l-1):r.times(l-1),p=en(r)?Math.floor(d):d.floor().toNumber(),h=en(r)?d%1:d.minus(p);if(c(d))return t?a[d]:u(a,en(r)?d:d.valueOf());if(t)f=a[p],m=a[p+1];else{m=u(a,p+1),f=a[p];for(var v=0;v<p;++v)s(a[v],f)>0&&(f=a[v])}return n(o(f,i(1,h)),o(m,h))}})),Zb=ti("std",["typed","map","sqrt","variance"],(e=>{var{typed:r,map:t,sqrt:n,variance:i}=e;return r("std",{"Array | Matrix":a,"Array | Matrix, string":a,"Array | Matrix, number | BigNumber":a,"Array | Matrix, number | BigNumber, string":a,"...":function(e){return a(e)}});function a(e,r){if(0===e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{var a=i.apply(null,arguments);return ln(a)?t(a,n):n(a)}catch(e){throw e instanceof TypeError&&e.message.includes(" variance")?new TypeError(e.message.replace(" variance"," std")):e}}})),Gb="corr",Xb=ti(Gb,["typed","matrix","mean","sqrt","sum","add","subtract","multiply","pow","divide"],(e=>{var{typed:r,matrix:t,sqrt:n,sum:i,add:a,subtract:o,multiply:u,pow:s,divide:c}=e;return r(Gb,{"Array, Array":function(e,r){return l(e,r)},"Matrix, Matrix":function(e,r){var n=l(e.toArray(),r.toArray());return Array.isArray(n)?t(n):n}});function l(e,r){var t=[];if(Array.isArray(e[0])&&Array.isArray(r[0])){if(e.length!==r.length)throw new SyntaxError("Dimension mismatch. Array A and B must have the same length.");for(var n=0;n<e.length;n++){if(e[n].length!==r[n].length)throw new SyntaxError("Dimension mismatch. Array A and B must have the same number of elements.");t.push(f(e[n],r[n]))}return t}if(e.length!==r.length)throw new SyntaxError("Dimension mismatch. Array A and B must have the same number of elements.");return f(e,r)}function f(e,r){var t=e.length,l=i(e),f=i(r),m=e.reduce(((e,t,n)=>a(e,u(t,r[n]))),0),d=i(e.map((e=>s(e,2)))),p=i(r.map((e=>s(e,2)))),h=o(u(t,m),u(l,f)),v=n(u(o(u(t,d),s(l,2)),o(u(t,p),s(f,2))));return c(h,v)}})),Yb="combinations",Qb=ti(Yb,["typed"],(e=>{var{typed:r}=e;return r(Yb,{"number, number":Es,"BigNumber, BigNumber":function(e,r){var t,n,i=e.constructor,a=e.minus(r),o=new i(1);if(!Kb(e)||!Kb(r))throw new TypeError("Positive integer value expected in function combinations");if(r.gt(e))throw new TypeError("k must be less than n in function combinations");if(t=o,r.lt(a))for(n=o;n.lte(a);n=n.plus(o))t=t.times(r.plus(n)).dividedBy(n);else for(n=o;n.lte(r);n=n.plus(o))t=t.times(a.plus(n)).dividedBy(n);return t}})}));function Kb(e){return e.isInteger()&&e.gte(0)}var eg="combinationsWithRep",rg=ti(eg,["typed"],(e=>{var{typed:r}=e;return r(eg,{"number, number":function(e,r){if(!ii(e)||e<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!ii(r)||r<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e<1)throw new TypeError("k must be less than or equal to n + k - 1");return r<e-1?Cs(e,e+r-1)/Cs(1,r):Cs(r+1,e+r-1)/Cs(1,e-1)},"BigNumber, BigNumber":function(e,r){var t,n,i=new(0,e.constructor)(1),a=e.minus(i);if(!tg(e)||!tg(r))throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e.lt(i))throw new TypeError("k must be less than or equal to n + k - 1 in function combinationsWithRep");if(t=i,r.lt(a))for(n=i;n.lte(a);n=n.plus(i))t=t.times(r.plus(n)).dividedBy(n);else for(n=i;n.lte(r);n=n.plus(i))t=t.times(a.plus(n)).dividedBy(n);return t}})}));function tg(e){return e.isInteger()&&e.gte(0)}var ng="gamma",ig=ti(ng,["typed","config","multiplyScalar","pow","BigNumber","Complex"],(e=>{var{typed:r,config:t,BigNumber:n,Complex:i}=e;return r(ng,{number:zs,Complex:function e(r){if(0===r.im)return zs(r.re);if(r.re<.5){var t=new i(1-r.re,-r.im),n=new i(Math.PI*r.re,Math.PI*r.im);return new i(Math.PI).div(n.sin()).div(e(t))}r=new i(r.re-1,r.im);for(var a=new i(Rs[0],0),o=1;o<Rs.length;++o){var u=new i(Rs[o],0);a=a.add(u.div(r.add(o)))}var s=new i(r.re+js+.5,r.im),c=s.pow(r.add(.5)),l=s.neg().exp();return a.mul(2.5066282746310002).mul(c).mul(l)},BigNumber:function(e){if(e.isInteger())return e.isNegative()||e.isZero()?new n(1/0):a(e.minus(1));if(!e.isFinite())return new n(e.isNegative()?NaN:1/0);throw Error("Integer BigNumber expected")}});function a(e){if(e<8)return new n([1,1,2,6,24,120,720,5040][e]);var r=t.precision+(0|Math.log(e.toNumber())),i=n.clone({precision:r});if(e%2==1)return e.times(a(new n(e-1)));for(var o=e,u=new i(e),s=e.toNumber();o>2;)u=u.times(s+=o-=2);return new n(u.toPrecision(n.precision))}})),ag="lgamma",og=ti(ag,["Complex","typed"],(e=>{var{Complex:r,typed:t}=e,n=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return t(ag,{number:Ps,Complex:function e(t){if(t.isNaN())return new r(NaN,NaN);if(0===t.im)return new r(Ps(t.re),0);if(t.re>=7||Math.abs(t.im)>=7)return i(t);if(t.re<=.1){var n=function(e,r){return!0^(r>0||!(r<0)&&1/r==1/0)?-e:e}(6.283185307179586,t.im)*Math.floor(.5*t.re+.25),o=t.mul(Math.PI).sin().log(),u=e(new r(1-t.re,-t.im));return new r(1.1447298858494002,n).sub(o).sub(u)}return t.im>=0?a(t):a(t.conjugate()).conjugate()},BigNumber:function(){throw Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function i(e){for(var t=e.sub(.5).mul(e.log()).sub(e).add(Us),i=new r(1,0).div(e),a=i.div(e),o=n[0],u=n[1],s=2*a.re,c=a.re*a.re+a.im*a.im,l=2;l<8;l++){var f=u;u=-c*o+n[l],o=s*o+f}var m=i.mul(a.mul(o).add(u));return t.add(m)}function a(e){var t=0,n=0,a=e;for(e=e.add(1);e.re<=7;){var o=(a=a.mul(e)).im<0?1:0;0!==o&&0===n&&t++,n=o,e=e.add(1)}return i(e).sub(a.log()).sub(new r(0,2*t*Math.PI*1))}})),ug="factorial",sg=ti(ug,["typed","gamma"],(e=>{var{typed:r,gamma:t}=e;return r(ug,{number:function(e){if(e<0)throw Error("Value must be non-negative");return t(e+1)},BigNumber:function(e){if(e.isNegative())throw Error("Value must be non-negative");return t(e.plus(1))},"Array | Matrix":r.referToSelf((e=>r=>Wu(r,e)))})})),cg="kldivergence",lg=ti(cg,["typed","matrix","divide","sum","multiply","map","dotDivide","log","isNumeric"],(e=>{var{typed:r,matrix:t,divide:n,sum:i,multiply:a,map:o,dotDivide:u,log:s,isNumeric:c}=e;return r(cg,{"Array, Array":function(e,r){return l(t(e),t(r))},"Matrix, Array":function(e,r){return l(e,t(r))},"Array, Matrix":function(e,r){return l(t(e),r)},"Matrix, Matrix":function(e,r){return l(e,r)}});function l(e,r){var t=r.size().length,l=e.size().length;if(t>1)throw Error("first object must be one dimensional");if(l>1)throw Error("second object must be one dimensional");if(t!==l)throw Error("Length of two vectors must be equal");if(0===i(e))throw Error("Sum of elements in first object must be non zero");if(0===i(r))throw Error("Sum of elements in second object must be non zero");var f=n(e,i(e)),m=n(r,i(r)),d=i(a(f,o(u(f,m),(e=>s(e)))));return c(d)?d:NaN}})),fg="multinomial",mg=ti(fg,["typed","add","divide","multiply","factorial","isInteger","isPositive"],(e=>{var{typed:r,add:t,divide:n,multiply:i,factorial:a,isInteger:o,isPositive:u}=e;return r(fg,{"Array | Matrix":function(e){var r=0,s=1;return _u(e,(function(e){if(!o(e)||!u(e))throw new TypeError("Positive integer value expected in function multinomial");r=t(r,e),s=i(s,a(e))})),n(a(r),s)}})})),dg="permutations",pg=ti(dg,["typed","factorial"],(e=>{var{typed:r,factorial:t}=e;return r(dg,{"number | BigNumber":t,"number, number":function(e,r){if(!ii(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!ii(r)||r<0)throw new TypeError("Positive integer value expected in function permutations");if(r>e)throw new TypeError("second argument k must be less than or equal to first argument n");return Cs(e-r+1,e)},"BigNumber, BigNumber":function(e,r){var t,n;if(!hg(e)||!hg(r))throw new TypeError("Positive integer value expected in function permutations");if(r.gt(e))throw new TypeError("second argument k must be less than or equal to first argument n");for(t=e.mul(0).add(1),n=e.minus(r).plus(1);n.lte(e);n=n.plus(1))t=t.times(n);return t}})}));function hg(e){return e.isInteger()&&e.gte(0)}var vg,yg={exports:{}};var bg,gg={exports:{}};var xg,wg={exports:{}};var Dg,Ng={exports:{}};var Ag,Mg={exports:{}};var Cg,Eg={exports:{}};var Sg,Fg,Bg,qg={exports:{}},Tg=Yn(Object.freeze({__proto__:null,default:{}})),kg=qg.exports;function Og(){return Sg||(Sg=1,function(e){!function(r,t,n){var i,a=256,o="random",u=n.pow(a,6),s=n.pow(2,52),c=2*s,l=255;function f(e,l,f){var y=[],b=h(p((l=1==l?{entropy:!0}:l||{}).entropy?[e,v(t)]:null==e?function(){try{var e;return i&&(e=i.randomBytes)?e=e(a):(e=new Uint8Array(a),(r.crypto||r.msCrypto).getRandomValues(e)),v(e)}catch(e){var n=r.navigator,o=n&&n.plugins;return[+new Date,r,o,r.screen,v(t)]}}():e,3),y),g=new m(y),x=function(){for(var e=g.g(6),r=u,t=0;e<s;)e=(e+t)*a,r*=a,t=g.g(1);for(;e>=c;)e/=2,r/=2,t>>>=1;return(e+t)/r};return x.int32=function(){return 0|g.g(4)},x.quick=function(){return g.g(4)/4294967296},x.double=x,h(v(g.S),t),(l.pass||f||function(e,r,t,i){return i&&(i.S&&d(i,g),e.state=function(){return d(g,{})}),t?(n[o]=e,r):e})(x,b,"global"in l?l.global:this==n,l.state)}function m(e){var r,t=e.length,n=this,i=0,o=n.i=n.j=0,u=n.S=[];for(t||(e=[t++]);i<a;)u[i]=i++;for(i=0;i<a;i++)u[i]=u[o=l&o+e[i%t]+(r=u[i])],u[o]=r;(n.g=function(e){for(var r,t=0,i=n.i,o=n.j,u=n.S;e--;)r=u[i=l&i+1],t=t*a+u[l&(u[i]=u[o=l&o+r])+(u[o]=r)];return n.i=i,n.j=o,t})(a)}function d(e,r){return r.i=e.i,r.j=e.j,r.S=e.S.slice(),r}function p(e,r){var t,n=[],i=typeof e;if(r&&"object"==i)for(t in e)try{n.push(p(e[t],r-1))}catch(e){}return n.length?n:"string"==i?e:e+"\0"}function h(e,r){for(var t,n=e+"",i=0;i<n.length;)r[l&i]=l&(t^=19*r[l&i])+n.charCodeAt(i++);return v(r)}function v(e){return String.fromCharCode.apply(0,e)}if(h(n.random(),t),e.exports){e.exports=f;try{i=Tg}catch(e){}}else n["seed"+o]=f}("undefined"!=typeof self?self:kg,[],Math)}(qg)),qg.exports}var Ig=function(){if(Bg)return Fg;Bg=1;var e=(vg||(vg=1,function(){function e(e){var r=this,t=function(){var e=4022871197;return function(r){r+="";for(var t=0;t<r.length;t++){var n=.02519603282416938*(e+=r.charCodeAt(t));n-=e=n>>>0,e=(n*=e)>>>0,e+=4294967296*(n-=e)}return 2.3283064365386963e-10*(e>>>0)}}();r.next=function(){var e=2091639*r.s0+2.3283064365386963e-10*r.c;return r.s0=r.s1,r.s1=r.s2,r.s2=e-(r.c=0|e)},r.c=1,r.s0=t(" "),r.s1=t(" "),r.s2=t(" "),r.s0-=t(e),r.s0<0&&(r.s0+=1),r.s1-=t(e),r.s1<0&&(r.s1+=1),r.s2-=t(e),r.s2<0&&(r.s2+=1),t=null}function r(e,r){return r.c=e.c,r.s0=e.s0,r.s1=e.s1,r.s2=e.s2,r}function t(t,n){var i=new e(t),a=n&&n.state,o=i.next;return o.int32=function(){return 4294967296*i.next()|0},o.double=function(){return o()+11102230246251565e-32*(2097152*o()|0)},o.quick=o,a&&("object"==typeof a&&r(a,i),o.state=function(){return r(i,{})}),o}yg&&yg.exports?yg.exports=t:this.alea=t}()),yg.exports),r=(bg||(bg=1,function(){function e(e){var r=this,t="";r.x=0,r.y=0,r.z=0,r.w=0,r.next=function(){var e=r.x^r.x<<11;return r.x=r.y,r.y=r.z,r.z=r.w,r.w^=r.w>>>19^e^e>>>8},e===(0|e)?r.x=e:t+=e;for(var n=0;n<t.length+64;n++)r.x^=0|t.charCodeAt(n),r.next()}function r(e,r){return r.x=e.x,r.y=e.y,r.z=e.z,r.w=e.w,r}function t(t,n){var i=new e(t),a=n&&n.state,o=function(){return(i.next()>>>0)/4294967296};return o.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=i.next,o.quick=o,a&&("object"==typeof a&&r(a,i),o.state=function(){return r(i,{})}),o}gg&&gg.exports?gg.exports=t:this.xor128=t}()),gg.exports),t=(xg||(xg=1,function(){function e(e){var r=this,t="";r.next=function(){var e=r.x^r.x>>>2;return r.x=r.y,r.y=r.z,r.z=r.w,r.w=r.v,(r.d=r.d+362437|0)+(r.v=r.v^r.v<<4^e^e<<1)|0},r.x=0,r.y=0,r.z=0,r.w=0,r.v=0,e===(0|e)?r.x=e:t+=e;for(var n=0;n<t.length+64;n++)r.x^=0|t.charCodeAt(n),n==t.length&&(r.d=r.x<<10^r.x>>>4),r.next()}function r(e,r){return r.x=e.x,r.y=e.y,r.z=e.z,r.w=e.w,r.v=e.v,r.d=e.d,r}function t(t,n){var i=new e(t),a=n&&n.state,o=function(){return(i.next()>>>0)/4294967296};return o.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=i.next,o.quick=o,a&&("object"==typeof a&&r(a,i),o.state=function(){return r(i,{})}),o}wg&&wg.exports?wg.exports=t:this.xorwow=t}()),wg.exports),n=(Dg||(Dg=1,function(){function e(e){var r=this;r.next=function(){var e,t,n=r.x,i=r.i;return e=n[i],t=(e^=e>>>7)^e<<24,t^=(e=n[i+1&7])^e>>>10,t^=(e=n[i+3&7])^e>>>3,t^=(e=n[i+4&7])^e<<7,e=n[i+7&7],n[i]=t^=(e^=e<<13)^e<<9,r.i=i+1&7,t},function(e,r){var t,n=[];if(r===(0|r))n[0]=r;else for(r=""+r,t=0;t<r.length;++t)n[7&t]=n[7&t]<<15^r.charCodeAt(t)+n[t+1&7]<<13;for(;n.length<8;)n.push(0);for(t=0;t<8&&0===n[t];++t);for(8==t&&(n[7]=-1),e.x=n,e.i=0,t=256;t>0;--t)e.next()}(r,e)}function r(e,r){return r.x=e.x.slice(),r.i=e.i,r}function t(t,n){null==t&&(t=+new Date);var i=new e(t),a=n&&n.state,o=function(){return(i.next()>>>0)/4294967296};return o.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=i.next,o.quick=o,a&&(a.x&&r(a,i),o.state=function(){return r(i,{})}),o}Ng&&Ng.exports?Ng.exports=t:this.xorshift7=t}()),Ng.exports),i=(Ag||(Ag=1,function(){function e(e){var r=this;r.next=function(){var e,t,n=r.w,i=r.X,a=r.i;return r.w=n=n+1640531527|0,t=i[a+34&127],e=i[a=a+1&127],t^=t<<13,e^=e<<17,t=i[a]=(t^=t>>>15)^(e^=e>>>12),r.i=a,t+(n^n>>>16)|0},function(e,r){var t,n,i,a,o,u=[],s=128;for(r===(0|r)?(n=r,r=null):(n=0,s=Math.max(s,(r+="\0").length)),i=0,a=-32;a<s;++a)r&&(n^=r.charCodeAt((a+32)%r.length)),0===a&&(o=n),n^=n<<10,n^=n>>>15,n^=n<<4,n^=n>>>13,a>=0&&(i=0==(t=u[127&a]^=n+(o=o+1640531527|0))?i+1:0);for(i>=128&&(u[127&(r&&r.length||0)]=-1),i=127,a=512;a>0;--a)n=u[i+34&127],t=u[i=i+1&127],n^=n<<13,t^=t<<17,u[i]=(n^=n>>>15)^(t^=t>>>12);e.w=o,e.X=u,e.i=i}(r,e)}function r(e,r){return r.i=e.i,r.w=e.w,r.X=e.X.slice(),r}function t(t,n){null==t&&(t=+new Date);var i=new e(t),a=n&&n.state,o=function(){return(i.next()>>>0)/4294967296};return o.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=i.next,o.quick=o,a&&(a.X&&r(a,i),o.state=function(){return r(i,{})}),o}Mg&&Mg.exports?Mg.exports=t:this.xor4096=t}()),Mg.exports),a=(Cg||(Cg=1,function(){function e(e){var r=this,t="";r.next=function(){var e=r.b,t=r.c,n=r.d,i=r.a;return e=e<<25^e>>>7^t,t=t-n|0,n=n<<24^n>>>8^i,i=i-e|0,r.b=e=e<<20^e>>>12^t,r.c=t=t-n|0,r.d=n<<16^t>>>16^i,r.a=i-e|0},r.a=0,r.b=0,r.c=-1640531527,r.d=1367130551,e===Math.floor(e)?(r.a=e/4294967296|0,r.b=0|e):t+=e;for(var n=0;n<t.length+20;n++)r.b^=0|t.charCodeAt(n),r.next()}function r(e,r){return r.a=e.a,r.b=e.b,r.c=e.c,r.d=e.d,r}function t(t,n){var i=new e(t),a=n&&n.state,o=function(){return(i.next()>>>0)/4294967296};return o.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=i.next,o.quick=o,a&&("object"==typeof a&&r(a,i),o.state=function(){return r(i,{})}),o}Eg&&Eg.exports?Eg.exports=t:this.tychei=t}()),Eg.exports),o=Og();return o.alea=e,o.xor128=r,o.xorwow=t,o.xorshift7=n,o.xor4096=i,o.tychei=a,Fg=o}(),zg=Xn(Ig),jg=zg(Date.now());function Rg(e){var r;return function(e){r=null===e?jg:zg(e+"")}(e),function(){return r()}}var Ug="pickRandom",$g=ti(Ug,["typed","config","?on"],(e=>{var{typed:r,config:t,on:n}=e,i=Rg(t.randomSeed);return n&&n("config",(function(e,r){e.randomSeed!==r.randomSeed&&(i=Rg(e.randomSeed))})),r(Ug,{"Array | Matrix":function(e){return a(e,{})},"Array | Matrix, Object":function(e,r){return a(e,r)},"Array | Matrix, number":function(e,r){return a(e,{number:r})},"Array | Matrix, Array | Matrix":function(e,r){return a(e,{weights:r})},"Array | Matrix, Array | Matrix, number":function(e,r,t){return a(e,{number:t,weights:r})},"Array | Matrix, number, Array | Matrix":function(e,r,t){return a(e,{number:r,weights:t})}});function a(e,r){var{number:t,weights:n,elementWise:a=!0}=r,o=void 0===t;o&&(t=1);var u=cn(e)?e.create:cn(n)?n.create:null;e=e.valueOf(),n&&(n=n.valueOf()),!0===a&&(e=bu(e),n=bu(n));var s=0;if(void 0!==n){if(n.length!==e.length)throw Error("Weights must have the same length as possibles");for(var c=0,l=n.length;c<l;c++){if(!en(n[c])||n[c]<0)throw Error("Weights must be an array of positive numbers");s+=n[c]}}for(var f,m=e.length,d=[];d.length<t;){if(void 0===n)f=e[Math.floor(i()*m)];else for(var p=i()*s,h=0,v=e.length;h<v;h++)if((p-=n[h])<0){f=e[h];break}d.push(f)}return o?d[0]:u?u(d):d}}));function Pg(e,r){var t=[];if((e=e.slice(0)).length>1)for(var n=0,i=e.shift();n<i;n++)t.push(Pg(e,r));else for(var a=0,o=e.shift();a<o;a++)t.push(r());return t}var Lg="random",_g=ti(Lg,["typed","config","?on"],(e=>{var{typed:r,config:t,on:n}=e,i=Rg(t.randomSeed);return n&&n("config",(function(e,r){e.randomSeed!==r.randomSeed&&(i=Rg(e.randomSeed))})),r(Lg,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,r)=>o(e,r),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,r)=>a(e,0,r),"Array | Matrix, number, number":(e,r,t)=>a(e,r,t)});function a(e,r,t){var n=Pg(e.valueOf(),(()=>o(r,t)));return cn(e)?e.create(n,"number"):n}function o(e,r){return e+i()*(r-e)}})),Wg="randomInt",Jg=ti(Wg,["typed","config","log2","?on"],(e=>{var{typed:r,config:t,log2:n,on:i}=e,a=Rg(t.randomSeed);return i&&i("config",(function(e,r){e.randomSeed!==r.randomSeed&&(a=Rg(e.randomSeed))})),r(Wg,{"":()=>u(0,2),number:e=>u(0,e),"number, number":(e,r)=>u(e,r),bigint:e=>s(0n,e),"bigint, bigint":s,"Array | Matrix":e=>o(e,0,1),"Array | Matrix, number":(e,r)=>o(e,0,r),"Array | Matrix, number, number":(e,r,t)=>o(e,r,t)});function o(e,r,t){var n=Pg(e.valueOf(),(()=>u(r,t)));return cn(e)?e.create(n,"number"):n}function u(e,r){return Math.floor(e+a()*(r-e))}function s(e,r){var t=r-e;if(t<=2n**30n)return e+BigInt(u(0,Number(t)));for(var i=n(t),o=t;o>=t;){o=0n;for(var s=0;s<i;++s)o=2n*o+(a()<.5?0n:1n)}return e+o}})),Vg="stirlingS2",Hg=ti(Vg,["typed","addScalar","subtractScalar","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],(e=>{var{typed:r,addScalar:t,multiplyScalar:n,isNegative:i,isInteger:a,number:o,bignumber:u,larger:s}=e,c=[],l=[];return r(Vg,{"number | BigNumber, number | BigNumber":function(e,r){if(!a(e)||i(e)||!a(r)||i(r))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(s(r,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");var f=!(en(e)&&en(r)),m=f?l:c,d=f?u:o,p=o(e),h=o(r);if(m[p]&&m[p].length>h)return m[p][h];for(var v=0;v<=p;++v)if(m[v]||(m[v]=[d(0===v?1:0)]),0!==v)for(var y=m[v],b=m[v-1],g=y.length;g<=v&&g<=h;++g)y[g]=g===v?1:t(n(d(g),b[g]),b[g-1]);return m[p][h]}})})),Zg="bellNumbers",Gg=ti(Zg,["typed","addScalar","isNegative","isInteger","stirlingS2"],(e=>{var{typed:r,addScalar:t,isNegative:n,isInteger:i,stirlingS2:a}=e;return r(Zg,{"number | BigNumber":function(e){if(!i(e)||n(e))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var r=0,o=0;o<=e;o++)r=t(r,a(e,o));return r}})})),Xg="catalan",Yg=ti(Xg,["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],(e=>{var{typed:r,addScalar:t,divideScalar:n,multiplyScalar:i,combinations:a,isNegative:o,isInteger:u}=e;return r(Xg,{"number | BigNumber":function(e){if(!u(e)||o(e))throw new TypeError("Non-negative integer value expected in function catalan");return n(a(i(e,2),e),t(e,1))}})})),Qg="composition",Kg=ti(Qg,["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],(e=>{var{typed:r,addScalar:t,combinations:n,isPositive:i,isInteger:a,larger:o}=e;return r(Qg,{"number | BigNumber, number | BigNumber":function(e,r){if(!(a(e)&&i(e)&&a(r)&&i(r)))throw new TypeError("Positive integer value expected in function composition");if(o(r,e))throw new TypeError("k must be less than or equal to n in function composition");return n(t(e,-1),t(r,-1))}})})),ex="leafCount",rx=ti(ex,["parse","typed"],(e=>{var{typed:r}=e;function t(e){var r=0;return e.forEach((e=>{r+=t(e)})),r||1}return r(ex,{Node:function(e){return t(e)}})}));function tx(e){return Bn(e)||jn(e)&&e.isUnary()&&Bn(e.args[0])}function nx(e){return!!Bn(e)||!(!kn(e)&&!jn(e)||!e.args.every(nx))||!(!Rn(e)||!nx(e.content))}function ix(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function ax(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ix(Object(t),!0).forEach((function(r){ed(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ix(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var ox=ti("simplifyUtil",["FunctionNode","OperatorNode","SymbolNode"],(e=>{var{FunctionNode:r,OperatorNode:t,SymbolNode:n}=e,i=!0,a=!1,o="defaultF",u={add:{trivial:i,total:i,commutative:i,associative:i},unaryPlus:{trivial:i,total:i,commutative:i,associative:i},subtract:{trivial:a,total:i,commutative:a,associative:a},multiply:{trivial:i,total:i,commutative:i,associative:i},divide:{trivial:a,total:i,commutative:a,associative:a},paren:{trivial:i,total:i,commutative:i,associative:a},defaultF:{trivial:a,total:i,commutative:a,associative:a}};function s(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:u,n=o;if("string"==typeof e?n=e:jn(e)?n=""+e.fn:kn(e)?n=e.name:Rn(e)&&(n="paren"),Hn(t,n)){var i=t[n];if(Hn(i,r))return i[r];if(Hn(u,n))return u[n][r]}if(Hn(t,o)){var a=t[o];return Hn(a,r)?a[r]:u[o][r]}if(Hn(u,n)){var s=u[n];if(Hn(s,r))return s[r]}return u[o][r]}function c(e){return s(e,"associative",arguments.length>1&&void 0!==arguments[1]?arguments[1]:u)}function l(e,r){var t,n=[],i=function(e){for(var r=0;r<e.args.length;r++){var a=e.args[r];jn(a)&&t===a.op?i(a):n.push(a)}};return c(e,r)?(t=e.op,i(e),n):e.args}function f(e){return jn(e)?function(r){try{return new t(e.op,e.fn,r,e.implicit)}catch(e){return console.error(e),[]}}:function(t){return new r(new n(e.name),t)}}return{createMakeNodeFunction:f,hasProperty:s,isCommutative:function(e){return s(e,"commutative",arguments.length>1&&void 0!==arguments[1]?arguments[1]:u)},isAssociative:c,mergeContext:function(e,r){var t=ax({},e);for(var n in r)t[n]=Hn(e,n)?ax(ax({},r[n]),e[n]):r[n];return t},flatten:function e(r,t){if(!r.args||0===r.args.length)return r;r.args=l(r,t);for(var n=0;n<r.args.length;n++)e(r.args[n],t)},allChildren:l,unflattenr:function e(r,t){if(r.args&&0!==r.args.length){for(var n=f(r),i=r.args.length,a=0;a<i;a++)e(r.args[a],t);if(i>2&&c(r,t)){for(var o=r.args.pop();r.args.length>0;)o=n([r.args.pop(),o]);r.args=o.args}}},unflattenl:function e(r,t){if(r.args&&0!==r.args.length){for(var n=f(r),i=r.args.length,a=0;a<i;a++)e(r.args[a],t);if(i>2&&c(r,t)){for(var o=r.args.shift();r.args.length>0;)o=n([o,r.args.shift()]);r.args=o.args}}},defaultContext:u,realContext:{divide:{total:a},log:{total:a}},positiveContext:{subtract:{total:a},abs:{trivial:i},log:{total:i}}}})),ux=ti("simplify",["typed","parse","equal","resolve","simplifyConstant","simplifyCore","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode","replacer"],(e=>{var{typed:r,parse:t,equal:n,resolve:i,simplifyConstant:a,simplifyCore:o,AccessorNode:u,ArrayNode:s,ConstantNode:c,FunctionNode:l,IndexNode:f,ObjectNode:m,OperatorNode:d,ParenthesisNode:p,SymbolNode:h,replacer:v}=e,{hasProperty:y,isCommutative:b,isAssociative:g,mergeContext:x,flatten:w,unflattenr:D,unflattenl:N,createMakeNodeFunction:A,defaultContext:M,realContext:C,positiveContext:E}=ox({FunctionNode:l,OperatorNode:d,SymbolNode:h});r.addConversion({from:"Object",to:"Map",convert:Kt});var S=r("simplify",{Node:O,"Node, Map":(e,r)=>O(e,!1,r),"Node, Map, Object":(e,r,t)=>O(e,!1,r,t),"Node, Array":O,"Node, Array, Map":O,"Node, Array, Map, Object":O});function F(e){return e.transform((function(e){return Rn(e)?F(e.content):e}))}r.removeConversion({from:"Object",to:"Map",convert:Kt}),S.defaultContext=M,S.realContext=C,S.positiveContext=E;var B={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};function q(e,r){var n={};if(e.s){var i=e.s.split("->");if(2!==i.length)throw SyntaxError("Could not parse rule: "+e.s);n.l=i[0],n.r=i[1]}else n.l=e.l,n.r=e.r;for(var a of(n.l=F(t(n.l)),n.r=F(t(n.r)),["imposeContext","repeat","assuming"]))a in e&&(n[a]=e[a]);if(e.evaluate&&(n.evaluate=t(e.evaluate)),g(n.l,r)){var o,u=!b(n.l,r);u&&(o=k());var s=A(n.l),c=k();n.expanded={},n.expanded.l=s([n.l,c]),w(n.expanded.l,r),D(n.expanded.l,r),n.expanded.r=s([n.r,c]),u&&(n.expandedNC1={},n.expandedNC1.l=s([o,n.l]),n.expandedNC1.r=s([o,n.r]),n.expandedNC2={},n.expandedNC2.l=s([o,n.expanded.l]),n.expandedNC2.r=s([o,n.expanded.r]))}return n}S.rules=[o,{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}}},a,{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}}},a,{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"},{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"}];var T=0;function k(){return new h("_p"+T++)}function O(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Qt(),n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=n.consoleDebug;r=function(e,r){for(var t=[],n=0;n<e.length;n++){var i=e[n],a=void 0,o=typeof i;switch(o){case"string":i={s:i};case"object":a=q(i,r);break;case"function":a=i;break;default:throw TypeError("Unsupported type of rule: "+o)}t.push(a)}return t}(r||S.rules,n.context);for(var o=i(e,t),u={},s=(o=F(o)).toString({parenthesis:"all"});!u[s];){u[s]=!0,T=0;var c=s;a&&console.log("Working on: ",s);for(var l=0;l<r.length;l++){var f="";if("function"==typeof r[l]?(o=r[l](o,n),a&&(f=r[l].name)):(w(o,n.context),o=z(o,r[l],n.context),a&&(f="".concat(""+r[l].l," -> ").concat(""+r[l].r))),a){var m=o.toString({parenthesis:"all"});m!==c&&(console.log("Applying",f,"produced",m),c=m)}N(o,n.context)}s=o.toString({parenthesis:"all"})}return o}function I(e,r,t){var n=e;if(e)for(var i=0;i<e.length;++i){var a=z(e[i],r,t);a!==e[i]&&(n===e&&(n=e.slice()),n[i]=a)}return n}function z(e,r,t){if(r.assuming)for(var n in r.assuming)for(var i in r.assuming[n])if(y(n,i,t)!==r.assuming[n][i])return e;var a=x(r.imposeContext,t),o=e;if(o instanceof d||o instanceof l){var c=I(o.args,r,t);c!==o.args&&((o=o.clone()).args=c)}else if(o instanceof p){if(o.content){var h=z(o.content,r,t);h!==o.content&&(o=new p(h))}}else if(o instanceof s){var v=I(o.items,r,t);v!==o.items&&(o=new s(v))}else if(o instanceof u){var b=o.object;o.object&&(b=z(o.object,r,t));var g=o.index;o.index&&(g=z(o.index,r,t)),b===o.object&&g===o.index||(o=new u(b,g))}else if(o instanceof f){var w=I(o.dimensions,r,t);w!==o.dimensions&&(o=new f(w))}else if(o instanceof m){var D=!1,N={};for(var A in o.properties)N[A]=z(o.properties[A],r,t),N[A]!==o.properties[A]&&(D=!0);D&&(o=new m(N))}var M=r.r,C=U(r.l,o,a)[0];if(!C&&r.expanded&&(M=r.expanded.r,C=U(r.expanded.l,o,a)[0]),!C&&r.expandedNC1&&(M=r.expandedNC1.r,(C=U(r.expandedNC1.l,o,a)[0])||(M=r.expandedNC2.r,C=U(r.expandedNC2.l,o,a)[0])),C){var E=o.implicit;o=M.clone(),E&&"implicit"in M&&(o.implicit=!0),o=o.transform((function(e){return e.isSymbolNode&&Hn(C.placeholders,e.name)?C.placeholders[e.name].clone():e}))}return r.repeat&&o!==e&&(o=z(o,r,t)),o}function j(e,r){var t={placeholders:{}};if(!e.placeholders&&!r.placeholders)return t;if(!e.placeholders)return r;if(!r.placeholders)return e;for(var n in e.placeholders)if(Hn(e.placeholders,n)&&(t.placeholders[n]=e.placeholders[n],Hn(r.placeholders,n)&&!$(e.placeholders[n],r.placeholders[n])))return null;for(var i in r.placeholders)Hn(r.placeholders,i)&&(t.placeholders[i]=r.placeholders[i]);return t}function R(e,r){var t,n=[];if(0===e.length||0===r.length)return n;for(var i=0;i<e.length;i++)for(var a=0;a<r.length;a++)(t=j(e[i],r[a]))&&n.push(t);return n}function U(e,r,t,i){var a=[{placeholders:{}}];if(e instanceof d&&r instanceof d||e instanceof l&&r instanceof l){if(e instanceof d){if(e.op!==r.op||e.fn!==r.fn)return[]}else if(e instanceof l&&e.name!==r.name)return[];if(!(1===r.args.length&&1===e.args.length||!g(r,t)&&r.args.length===e.args.length||i)){if(r.args.length>=2&&2===e.args.length){for(var o=function(e,r){var t,n,i=[],a=A(e);if(b(e,r))for(var o=0;o<e.args.length;o++)(n=e.args.slice(0)).splice(o,1),t=1===n.length?n[0]:a(n),i.push(a([e.args[o],t]));else for(var u=1;u<e.args.length;u++){var s=e.args[0];u>1&&(s=a(e.args.slice(0,u))),t=1===(n=e.args.slice(u)).length?n[0]:a(n),i.push(a([s,t]))}return i}(r,t),u=[],s=0;s<o.length;s++){var f=U(e,o[s],t,!0);u=u.concat(f)}return u}if(e.args.length>2)throw Error("Unexpected non-binary associative function: "+e);return[]}for(var m=[],p=0;p<e.args.length;p++){var y=U(e.args[p],r.args[p],t);if(0===y.length)break;m.push(y)}if(m.length!==e.args.length){if(!b(r,t)||1===e.args.length)return[];if(e.args.length>2)throw Error("permuting >2 commutative non-associative rule arguments not yet implemented");var x=U(e.args[0],r.args[1],t);if(0===x.length)return[];var w=U(e.args[1],r.args[0],t);if(0===w.length)return[];m=[x,w]}a=function(e){if(0===e.length)return e;for(var r=e.reduce(R),t=[],n={},i=0;i<r.length;i++){var a=JSON.stringify(r[i],v);n[a]||(n[a]=!0,t.push(r[i]))}return t}(m)}else if(e instanceof h){if(0===e.name.length)throw Error("Symbol in rule has 0 length...!?");if(B[e.name]){if(e.name!==r.name)return[]}else switch(e.name[1]>="a"&&e.name[1]<="z"?e.name.substring(0,2):e.name[0]){case"n":case"_p":a[0].placeholders[e.name]=r;break;case"c":case"cl":if(!Bn(r))return[];a[0].placeholders[e.name]=r;break;case"v":if(Bn(r))return[];a[0].placeholders[e.name]=r;break;case"vl":if(!Pn(r))return[];a[0].placeholders[e.name]=r;break;case"cd":if(!tx(r))return[];a[0].placeholders[e.name]=r;break;case"vd":if(tx(r))return[];a[0].placeholders[e.name]=r;break;case"ce":if(!nx(r))return[];a[0].placeholders[e.name]=r;break;case"ve":if(nx(r))return[];a[0].placeholders[e.name]=r;break;default:throw Error("Invalid symbol in rule: "+e.name)}}else{if(!(e instanceof c))return[];if(!n(e.value,r.value))return[]}return a}function $(e,r){if(e instanceof c&&r instanceof c){if(!n(e.value,r.value))return!1}else if(e instanceof h&&r instanceof h){if(e.name!==r.name)return!1}else{if(!(e instanceof d&&r instanceof d||e instanceof l&&r instanceof l))return!1;if(e instanceof d){if(e.op!==r.op||e.fn!==r.fn)return!1}else if(e instanceof l&&e.name!==r.name)return!1;if(e.args.length!==r.args.length)return!1;for(var t=0;t<e.args.length;t++)if(!$(e.args[t],r.args[t]))return!1}return!0}return S})),sx=ti("simplifyConstant",["typed","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],(e=>{var{typed:r,config:t,mathWithTransform:n,matrix:i,fraction:a,bignumber:o,AccessorNode:u,ArrayNode:s,ConstantNode:c,FunctionNode:l,IndexNode:f,ObjectNode:m,OperatorNode:d,SymbolNode:p}=e,{isCommutative:h,isAssociative:v,allChildren:y,createMakeNodeFunction:b}=ox({FunctionNode:l,OperatorNode:d,SymbolNode:p}),g=r("simplifyConstant",{Node:e=>N(S(e,{})),"Node, Object":function(e,r){return N(S(e,r))}});function x(e){return an(e)?e.valueOf():e instanceof Array?e.map(x):cn(e)?i(x(e.valueOf())):e}function w(e,r,t){try{return n[e].apply(null,r)}catch(i){return r=r.map(x),M(n[e].apply(null,r),t)}}var D=r({Fraction:function(e){var r=e=>"BigNumber"===t.number&&o?o(e):Number(e),n=e.s*e.n,i=n<0n?new d("-","unaryMinus",[new c(-r(n))]):new c(r(n));return 1n===e.d?i:new d("/","divide",[i,new c(r(e.d))])},number:function(e){return e<0?C(new c(-e)):new c(e)},BigNumber:function(e){return e<0?C(new c(-e)):new c(e)},bigint:function(e){return e<0n?C(new c(-e)):new c(e)},Complex:function(){throw Error("Cannot convert Complex number to Node")},string:function(e){return new c(e)},Matrix:function(e){return new s(e.valueOf().map((e=>D(e))))}});function N(e){return In(e)?e:D(e)}function A(e,r){if(r&&!1!==r.exactFractions&&isFinite(e)&&a){var t=a(e),n=r&&"number"==typeof r.fractionsLimit?r.fractionsLimit:1/0;if(t.valueOf()===e&&t.n<n&&t.d<n)return t}return e}var M=r({"string, Object":function(e,r){var n=ai(e,t);return"BigNumber"===n?(void 0===o&&wm(),o(e)):"bigint"===n?BigInt(e):"Fraction"===n?(void 0===a&&Dm(),a(e)):A(parseFloat(e),r)},"Fraction, Object":function(e){return e},"BigNumber, Object":function(e){return e},"number, Object":function(e,r){return A(e,r)},"bigint, Object":function(e){return e},"Complex, Object":function(e,r){return 0!==e.im?e:A(e.re,r)},"Matrix, Object":function(e){return i(A(e.valueOf()))},"Array, Object":function(e){return e.map(A)}});function C(e){return new d("-","unaryMinus",[e])}function E(e,r,t,n){var i=r.shift(),a=r.reduce(((r,i)=>{if(!In(i)){var a=r.pop();if(In(a))return[a,i];try{return r.push(w(e,[a,i],n)),r}catch(e){r.push(a)}}r.push(N(r.pop()));var o=1===r.length?r[0]:t(r);return[t([o,N(i)])]}),[i]);return 1===a.length?a[0]:t([a[0],D(a[1])])}function S(e,r){switch(e.type){case"SymbolNode":return e;case"ConstantNode":switch(typeof e.value){case"number":case"bigint":return M(e.value,r);case"string":return e.value;default:if(!isNaN(e.value))return M(e.value,r)}return e;case"FunctionNode":if(n[e.name]&&n[e.name].rawArgs)return e;if(!["add","multiply"].includes(e.name)){var t=e.args.map((e=>S(e,r)));if(!t.some(In))try{return w(e.name,t,r)}catch(e){}if("size"===e.name&&1===t.length&&Cn(t[0])){for(var a=[],o=t[0];Cn(o);)a.push(o.items.length),o=o.items[0];return i(a)}return new l(e.name,t.map(N))}case"OperatorNode":var d,p,x=""+e.fn,D=b(e);if(jn(e)&&e.isUnary())p=In((d=[S(e.args[0],r)])[0])?D(d):w(x,d,r);else if(v(e,r.context))if(d=(d=y(e,r.context)).map((e=>S(e,r))),h(x,r.context)){for(var A=[],C=[],F=0;F<d.length;F++)In(d[F])?C.push(d[F]):A.push(d[F]);A.length>1?(p=E(x,A,D,r),C.unshift(p),p=E(x,C,D,r)):p=E(x,d,D,r)}else p=E(x,d,D,r);else d=e.args.map((e=>S(e,r))),p=E(x,d,D,r);return p;case"ParenthesisNode":return S(e.content,r);case"AccessorNode":return function(e,r,t){if(!On(r))return new u(N(e),N(r));if(Cn(e)||cn(e)){for(var n=Array.from(r.dimensions);n.length>0;)if(Bn(n[0])&&"string"!=typeof n[0].value){var a=M(n.shift().value,t);Cn(e)?e=e.items[a-1]:(e=e.valueOf()[a-1])instanceof Array&&(e=i(e))}else{if(!(n.length>1&&Bn(n[1])&&"string"!=typeof n[1].value))break;var o=M(n[1].value,t),l=[],m=Cn(e)?e.items:e.valueOf();for(var d of m)if(Cn(d))l.push(d.items[o-1]);else{if(!cn(e))break;l.push(d[o-1])}if(l.length!==m.length)break;e=Cn(e)?new s(l):i(l),n.splice(1,1)}return n.length===r.dimensions.length?new u(N(e),r):n.length>0?(r=new f(n),new u(N(e),r)):e}if(zn(e)&&1===r.dimensions.length&&Bn(r.dimensions[0])){var p=r.dimensions[0].value;return p in e.properties?e.properties[p]:new c}return new u(N(e),r)}(S(e.object,r),S(e.index,r),r);case"ArrayNode":var B=e.items.map((e=>S(e,r)));return B.some(In)?new s(B.map(N)):i(B);case"IndexNode":return new f(e.dimensions.map((e=>g(e,r))));case"ObjectNode":var q={};for(var T in e.properties)q[T]=g(e.properties[T],r);return new m(q);default:throw Error("Unimplemented node type in simplifyConstant: ".concat(e.type))}}return g})),cx="simplifyCore",lx=ti(cx,["typed","parse","equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:r,equal:t,isZero:n,AccessorNode:i,ArrayNode:a,ConstantNode:o,FunctionNode:u,IndexNode:s,ObjectNode:c,OperatorNode:l,SymbolNode:f}=e,m=new o(0),d=new o(1),p=new o(!0),h=new o(!1);function v(e){return jn(e)&&["and","not","or"].includes(e.op)}var{hasProperty:y,isCommutative:b}=ox({FunctionNode:u,OperatorNode:l,SymbolNode:f});function g(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r?r.context:void 0;if(y(e,"trivial",o)){if(kn(e)&&1===e.args.length)return g(e.args[0],r);var f=!1,x=0;if(e.forEach((e=>{1==++x&&(f=g(e,r))})),1===x)return f}var w=e;if(kn(w)){var D=function(e){var r="OperatorNode:"+e;for(var t of Wv)if(r in t)return t[r].op;return null}(w.name);if(!D)return new u(g(w.fn),w.args.map((e=>g(e,r))));if(w.args.length>2&&y(w,"associative",o))for(;w.args.length>2;){var N=w.args.pop(),A=w.args.pop();w.args.push(new l(D,w.name,[N,A]))}w=new l(D,w.name,w.args)}if(jn(w)&&w.isUnary()){var M=g(w.args[0],r);if("~"===w.op&&jn(M)&&M.isUnary()&&"~"===M.op)return M.args[0];if("not"===w.op&&jn(M)&&M.isUnary()&&"not"===M.op&&v(M.args[0]))return M.args[0];var C=!0;if("-"===w.op&&jn(M)&&(M.isBinary()&&"subtract"===M.fn&&(w=new l("-","subtract",[M.args[1],M.args[0]]),C=!1),M.isUnary()&&"-"===M.op))return M.args[0];if(C)return new l(w.op,w.fn,[M])}if(jn(w)&&w.isBinary()){var E=g(w.args[0],r),S=g(w.args[1],r);if("+"===w.op){if(Bn(E)&&n(E.value))return S;if(Bn(S)&&n(S.value))return E;jn(S)&&S.isUnary()&&"-"===S.op&&(w=new l("-","subtract",[E,S=S.args[0]]))}if("-"===w.op)return jn(S)&&S.isUnary()&&"-"===S.op?g(new l("+","add",[E,S.args[0]]),r):Bn(E)&&n(E.value)?g(new l("-","unaryMinus",[S])):Bn(S)&&n(S.value)?E:new l(w.op,w.fn,[E,S]);if("*"===w.op){if(Bn(E)){if(n(E.value))return m;if(t(E.value,1))return S}if(Bn(S)){if(n(S.value))return m;if(t(S.value,1))return E;if(b(w,o))return new l(w.op,w.fn,[S,E],w.implicit)}return new l(w.op,w.fn,[E,S],w.implicit)}if("/"===w.op)return Bn(E)&&n(E.value)?m:Bn(S)&&t(S.value,1)?E:new l(w.op,w.fn,[E,S]);if("^"===w.op&&Bn(S)){if(n(S.value))return d;if(t(S.value,1))return E}if("and"===w.op){if(Bn(E)){if(!E.value)return h;if(v(S))return S;if(Bn(S))return S.value?p:h}if(Bn(S)){if(!S.value)return h;if(v(E))return E}}if("or"===w.op){if(Bn(E)){if(E.value)return p;if(v(S))return S}if(Bn(S)){if(S.value)return p;if(v(E))return E}}return new l(w.op,w.fn,[E,S])}if(jn(w))return new l(w.op,w.fn,w.args.map((e=>g(e,r))));if(Cn(w))return new a(w.items.map((e=>g(e,r))));if(Mn(w))return new i(g(w.object,r),g(w.index,r));if(On(w))return new s(w.dimensions.map((e=>g(e,r))));if(zn(w)){var F={};for(var B in w.properties)F[B]=g(w.properties[B],r);return new c(F)}return w}return r(cx,{Node:g,"Node,Object":g})})),fx=ti("resolve",["typed","parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],(e=>{var{typed:r,parse:t,ConstantNode:n,FunctionNode:i,OperatorNode:a,ParenthesisNode:o}=e;function u(e,r){var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set;if(!r)return e;if(Pn(e)){if(s.has(e.name)){var c=Array.from(s).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(c,"}"))}var l=r.get(e.name);if(In(l)){var f=new Set(s);return f.add(e.name),u(l,r,f)}return"number"==typeof l?t(l+""):void 0!==l?new n(l):e}if(jn(e)){var m=e.args.map((function(e){return u(e,r,s)}));return new a(e.op,e.fn,m,e.implicit)}if(Rn(e))return new o(u(e.content,r,s));if(kn(e)){var d=e.args.map((function(e){return u(e,r,s)}));return new i(e.name,d)}return e.map((e=>u(e,r,s)))}return r("resolve",{Node:u,"Node, Map | null | undefined":u,"Node, Object":(e,r)=>u(e,Kt(r)),"Array | Matrix":r.referToSelf((e=>r=>r.map((r=>e(r))))),"Array | Matrix, null | undefined":r.referToSelf((e=>r=>r.map((r=>e(r))))),"Array, Object":r.referTo("Array,Map",(e=>(r,t)=>e(r,Kt(t)))),"Matrix, Object":r.referTo("Matrix,Map",(e=>(r,t)=>e(r,Kt(t)))),"Array | Matrix, Map":r.referToSelf((e=>(r,t)=>r.map((r=>e(r,t)))))})})),mx="symbolicEqual",dx=ti(mx,["parse","simplify","typed","OperatorNode"],(e=>{var{simplify:r,typed:t,OperatorNode:n}=e;function i(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=new n("-","subtract",[e,t]),o=r(a,{},i);return Bn(o)&&!o.value}return t(mx,{"Node, Node":i,"Node, Node, Object":i})})),px="derivative",hx=ti(px,["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:r,config:t,parse:n,simplify:i,equal:a,isZero:o,numeric:u,ConstantNode:s,FunctionNode:c,OperatorNode:l,ParenthesisNode:f,SymbolNode:m}=e;function d(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{simplify:!0},n=new Map,a=r.name,o=b(e,(function e(r){var t=n.get(r);if(void 0!==t)return t;var i=y(e,r,a);return n.set(r,i),i}));return t.simplify?i(o):o}function p(e){var r=n(e);if(!r.isSymbolNode)throw new TypeError("Invalid variable. "+"Cannot parse ".concat(JSON.stringify(e)," into a variable in function derivative"));return r}var h=r(px,{"Node, SymbolNode":d,"Node, SymbolNode, Object":d,"Node, string":(e,r)=>d(e,p(r)),"Node, string, Object":(e,r,t)=>d(e,p(r),t)});h._simplify=!0,h.toTex=function(e){return v.apply(null,e.args)};var v=r("_derivTex",{"Node, SymbolNode":function(e,r){return Bn(e)&&"string"===_n(e.value)?v(""+n(e.value),""+r,1):v(e.toTex(),""+r,1)},"Node, ConstantNode":function(e,r){if("string"===_n(r.value))return v(e,n(r.value));throw Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(e,r,t){return v(""+e,r.name,t.value)},"string, string, number":function(e,r,t){return(1===t?"{d\\over d"+r+"}":"{d^{"+t+"}\\over d"+r+"^{"+t+"}}")+"\\left[".concat(e,"\\right]")}}),y=r("_isConst",{"function, ConstantNode, string":function(){return!0},"function, SymbolNode, string":function(e,r,t){return r.name!==t},"function, ParenthesisNode, string":function(e,r,t){return e(r.content,t)},"function, FunctionAssignmentNode, string":function(e,r,t){return!r.params.includes(t)||e(r.expr,t)},"function, FunctionNode | OperatorNode, string":function(e,r,t){return r.args.every((r=>e(r,t)))}}),b=r("_derivative",{"ConstantNode, function":function(){return g(0)},"SymbolNode, function":function(e,r){return r(e)?g(0):g(1)},"ParenthesisNode, function":function(e,r){return new f(b(e.content,r))},"FunctionAssignmentNode, function":function(e,r){return r(e)?g(0):b(e.expr,r)},"FunctionNode, function":function(e,r){if(r(e))return g(0);var t,n,i,a,o=e.args[0],u=!1,s=!1;switch(e.name){case"cbrt":u=!0,n=new l("*","multiply",[g(3),new l("^","pow",[o,new l("/","divide",[g(2),g(3)])])]);break;case"sqrt":case"nthRoot":if(1===e.args.length)u=!0,n=new l("*","multiply",[g(2),new c("sqrt",[o])]);else if(2===e.args.length)return t=new l("/","divide",[g(1),e.args[1]]),b(new l("^","pow",[o,t]),r);break;case"log10":t=g(10);case"log":if(t||1!==e.args.length){if(1===e.args.length&&t||2===e.args.length&&r(e.args[1]))n=new l("*","multiply",[o.clone(),new c("log",[t||e.args[1]])]),u=!0;else if(2===e.args.length)return b(new l("/","divide",[new c("log",[o]),new c("log",[e.args[1]])]),r)}else n=o.clone(),u=!0;break;case"pow":if(2===e.args.length)return b(new l("^","pow",[o,e.args[1]]),r);break;case"exp":n=new c("exp",[o.clone()]);break;case"sin":n=new c("cos",[o.clone()]);break;case"cos":n=new l("-","unaryMinus",[new c("sin",[o.clone()])]);break;case"tan":n=new l("^","pow",[new c("sec",[o.clone()]),g(2)]);break;case"sec":n=new l("*","multiply",[e,new c("tan",[o.clone()])]);break;case"csc":s=!0,n=new l("*","multiply",[e,new c("cot",[o.clone()])]);break;case"cot":s=!0,n=new l("^","pow",[new c("csc",[o.clone()]),g(2)]);break;case"asin":u=!0,n=new c("sqrt",[new l("-","subtract",[g(1),new l("^","pow",[o.clone(),g(2)])])]);break;case"acos":u=!0,s=!0,n=new c("sqrt",[new l("-","subtract",[g(1),new l("^","pow",[o.clone(),g(2)])])]);break;case"atan":u=!0,n=new l("+","add",[new l("^","pow",[o.clone(),g(2)]),g(1)]);break;case"asec":u=!0,n=new l("*","multiply",[new c("abs",[o.clone()]),new c("sqrt",[new l("-","subtract",[new l("^","pow",[o.clone(),g(2)]),g(1)])])]);break;case"acsc":u=!0,s=!0,n=new l("*","multiply",[new c("abs",[o.clone()]),new c("sqrt",[new l("-","subtract",[new l("^","pow",[o.clone(),g(2)]),g(1)])])]);break;case"acot":u=!0,s=!0,n=new l("+","add",[new l("^","pow",[o.clone(),g(2)]),g(1)]);break;case"sinh":n=new c("cosh",[o.clone()]);break;case"cosh":n=new c("sinh",[o.clone()]);break;case"tanh":n=new l("^","pow",[new c("sech",[o.clone()]),g(2)]);break;case"sech":s=!0,n=new l("*","multiply",[e,new c("tanh",[o.clone()])]);break;case"csch":s=!0,n=new l("*","multiply",[e,new c("coth",[o.clone()])]);break;case"coth":s=!0,n=new l("^","pow",[new c("csch",[o.clone()]),g(2)]);break;case"asinh":u=!0,n=new c("sqrt",[new l("+","add",[new l("^","pow",[o.clone(),g(2)]),g(1)])]);break;case"acosh":u=!0,n=new c("sqrt",[new l("-","subtract",[new l("^","pow",[o.clone(),g(2)]),g(1)])]);break;case"atanh":u=!0,n=new l("-","subtract",[g(1),new l("^","pow",[o.clone(),g(2)])]);break;case"asech":u=!0,s=!0,n=new l("*","multiply",[o.clone(),new c("sqrt",[new l("-","subtract",[g(1),new l("^","pow",[o.clone(),g(2)])])])]);break;case"acsch":u=!0,s=!0,n=new l("*","multiply",[new c("abs",[o.clone()]),new c("sqrt",[new l("+","add",[new l("^","pow",[o.clone(),g(2)]),g(1)])])]);break;case"acoth":u=!0,s=!0,n=new l("-","subtract",[g(1),new l("^","pow",[o.clone(),g(2)])]);break;case"abs":n=new l("/","divide",[new c(new m("abs"),[o.clone()]),o.clone()]);break;default:throw Error('Cannot process function "'+e.name+'" in derivative: the function is not supported, undefined, or the number of arguments passed to it are not supported')}u?(i="/",a="divide"):(i="*",a="multiply");var f=b(o,r);return s&&(f=new l("-","unaryMinus",[f])),new l(i,a,[f,n])},"OperatorNode, function":function(e,r){if(r(e))return g(0);if("+"===e.op)return new l(e.op,e.fn,e.args.map((function(e){return b(e,r)})));if("-"===e.op){if(e.isUnary())return new l(e.op,e.fn,[b(e.args[0],r)]);if(e.isBinary())return new l(e.op,e.fn,[b(e.args[0],r),b(e.args[1],r)])}if("*"===e.op){var t=e.args.filter((function(e){return r(e)}));if(t.length>0){var n=e.args.filter((function(e){return!r(e)})),i=1===n.length?n[0]:new l("*","multiply",n),u=t.concat(b(i,r));return new l("*","multiply",u)}return new l("+","add",e.args.map((function(t){return new l("*","multiply",e.args.map((function(e){return e===t?b(e,r):e.clone()})))})))}if("/"===e.op&&e.isBinary()){var s=e.args[0],f=e.args[1];return r(f)?new l("/","divide",[b(s,r),f]):r(s)?new l("*","multiply",[new l("-","unaryMinus",[s]),new l("/","divide",[b(f,r),new l("^","pow",[f.clone(),g(2)])])]):new l("/","divide",[new l("-","subtract",[new l("*","multiply",[b(s,r),f.clone()]),new l("*","multiply",[s.clone(),b(f,r)])]),new l("^","pow",[f.clone(),g(2)])])}if("^"===e.op&&e.isBinary()){var m=e.args[0],d=e.args[1];if(r(m))return Bn(m)&&(o(m.value)||a(m.value,1))?g(0):new l("*","multiply",[e,new l("*","multiply",[new c("log",[m.clone()]),b(d.clone(),r)])]);if(r(d)){if(Bn(d)){if(o(d.value))return g(0);if(a(d.value,1))return b(m,r)}var p=new l("^","pow",[m.clone(),new l("-","subtract",[d,g(1)])]);return new l("*","multiply",[d.clone(),new l("*","multiply",[b(m,r),p])])}return new l("*","multiply",[new l("^","pow",[m.clone(),d.clone()]),new l("+","add",[new l("*","multiply",[b(m,r),new l("/","divide",[d.clone(),m.clone()])]),new l("*","multiply",[b(d,r),new c("log",[m.clone()])])])])}throw Error('Cannot process operator "'+e.op+'" in derivative: the operator is not supported, undefined, or the number of arguments passed to it are not supported')}});function g(e){return new s(u(e,ai(e+"",t)))}return h})),vx="rationalize",yx=ti(vx,["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"],(e=>{var{typed:r,simplifyConstant:t,simplifyCore:n,simplify:i,ConstantNode:a,OperatorNode:o,SymbolNode:u}=e;function s(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=function(){var e=[n,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},t,{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"}],r=[{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)"}],i=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],a={};return a.firstRules=e.concat(r,i),a.distrDivRules=[{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)"}],a.sucDivRules=i,a.firstRulesAgain=e.concat(r),a.finalRules=[n,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},t,{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))"}],a}(),u=function(e,r,t,n){var a=[],o=i(e,n,r,{exactFractions:!1}),u="+-*"+((t=!!t)?"/":"");!function e(r){var t=r.type;if("FunctionNode"===t)throw Error("There is an unsolved function call");if("OperatorNode"===t)if("^"===r.op){if("ConstantNode"!==r.args[1].type||!ii(parseFloat(r.args[1].value)))throw Error("There is a non-integer exponent");e(r.args[0])}else{if(!u.includes(r.op))throw Error("Operator "+r.op+" invalid in polynomial expression");for(var n=0;n<r.args.length;n++)e(r.args[n])}else if("SymbolNode"===t){var i=r.name;-1===a.indexOf(i)&&a.push(i)}else if("ParenthesisNode"===t)e(r.content);else if("ConstantNode"!==t)throw Error("type "+t+" is not allowed in polynomial expression")}(o);var s={};return s.expression=o,s.variables=a,s}(e,r,!0,o.firstRules),s=u.variables.length,f={exactFractions:!1},m={exactFractions:!0};if(e=u.expression,s>=1){var d,p;e=c(e);var h,v=!0,y=!1;for(e=i(e,o.firstRules,{},f);p=v?o.distrDivRules:o.sucDivRules,v=!v,(h=""+(e=i(e,p,{},m)))!==d;)y=!0,d=h;y&&(e=i(e,o.firstRulesAgain,{},f)),e=i(e,o.finalRules,{},f)}var b=[],g={};return"OperatorNode"===e.type&&e.isBinary()&&"/"===e.op?(1===s&&(e.args[0]=l(e.args[0],b),e.args[1]=l(e.args[1])),a&&(g.numerator=e.args[0],g.denominator=e.args[1])):(1===s&&(e=l(e,b)),a&&(g.numerator=e,g.denominator=null)),a?(g.coefficients=b,g.variables=u.variables,g.expression=e,g):e}return r(vx,{Node:s,"Node, boolean":(e,r)=>s(e,{},r),"Node, Object":s,"Node, Object, boolean":s});function c(e,r,t){var n=e.type,i=arguments.length>1;if("OperatorNode"===n&&e.isBinary()){var u,s=!1;if("^"===e.op&&("ParenthesisNode"!==e.args[0].type&&"OperatorNode"!==e.args[0].type||"ConstantNode"!==e.args[1].type||(s=(u=parseFloat(e.args[1].value))>=2&&ii(u))),s){if(u>2){var l=e.args[0],f=new o("^","pow",[e.args[0].cloneDeep(),new a(u-1)]);e=new o("*","multiply",[l,f])}else e=new o("*","multiply",[e.args[0],e.args[0].cloneDeep()]);i&&("content"===t?r.content=e:r.args[t]=e)}}if("ParenthesisNode"===n)c(e.content,e,"content");else if("ConstantNode"!==n&&"SymbolNode"!==n)for(var m=0;m<e.args.length;m++)c(e.args[m],e,m);if(!i)return e}function l(e,r){void 0===r&&(r=[]),r[0]=0;var t=0,n="";!function e(i,a,o){var u=i.type;if("FunctionNode"===u)throw Error("There is an unsolved function call");if("OperatorNode"===u){if(!"+-*^".includes(i.op))throw Error("Operator "+i.op+" invalid");if(null!==a){if(("unaryMinus"===i.fn||"pow"===i.fn)&&"add"!==a.fn&&"subtract"!==a.fn&&"multiply"!==a.fn)throw Error("Invalid "+i.op+" placing");if(("subtract"===i.fn||"add"===i.fn||"multiply"===i.fn)&&"add"!==a.fn&&"subtract"!==a.fn)throw Error("Invalid "+i.op+" placing");if(("subtract"===i.fn||"add"===i.fn||"unaryMinus"===i.fn)&&0!==o.noFil)throw Error("Invalid "+i.op+" placing")}"^"!==i.op&&"*"!==i.op||(o.fire=i.op);for(var s=0;s<i.args.length;s++)"unaryMinus"===i.fn&&(o.oper="-"),"+"!==i.op&&"subtract"!==i.fn||(o.fire="",o.cte=1,o.oper=0===s?"+":i.op),o.noFil=s,e(i.args[s],i,o)}else if("SymbolNode"===u){if(i.name!==n&&""!==n)throw Error("There is more than one variable");if(n=i.name,null===a)return void(r[1]=1);if("^"===a.op&&0!==o.noFil)throw Error("In power the variable should be the first parameter");if("*"===a.op&&1!==o.noFil)throw Error("In multiply the variable should be the second parameter");""!==o.fire&&"*"!==o.fire||(t<1&&(r[1]=0),r[1]+=o.cte*("+"===o.oper?1:-1),t=Math.max(1,t))}else{if("ConstantNode"!==u)throw Error("Type "+u+" is not allowed");var c=parseFloat(i.value);if(null===a)return void(r[0]=c);if("^"===a.op){if(1!==o.noFil)throw Error("Constant cannot be powered");if(!ii(c)||c<=0)throw Error("Non-integer exponent is not allowed");for(var l=t+1;l<c;l++)r[l]=0;return c>t&&(r[c]=0),r[c]+=o.cte*("+"===o.oper?1:-1),void(t=Math.max(c,t))}o.cte=c,""===o.fire&&(r[0]+=o.cte*("+"===o.oper?1:-1))}}(e,null,{cte:1,oper:"+",fire:""});for(var i,s=!0,c=t=r.length-1;c>=0;c--)if(0!==r[c]){var l=new a(s?r[c]:Math.abs(r[c])),f=r[c]<0?"-":"+";if(c>0){var m=new u(n);if(c>1){var d=new a(c);m=new o("^","pow",[m,d])}l=-1===r[c]&&s?new o("-","unaryMinus",[m]):1===Math.abs(r[c])?m:new o("*","multiply",[l,m])}i=s?l:"+"===f?new o("+","add",[i,l]):new o("-","subtract",[i,l]),s=!1}return s?new a(0):i}})),bx="zpk2tf",gx=ti(bx,["typed","add","multiply","Complex","number"],(e=>{var{typed:r,add:t,multiply:n,Complex:i,number:a}=e;return r(bx,{"Array,Array,number":function(e,r,t){return o(e,r,t)},"Array,Array":function(e,r){return o(e,r,1)},"Matrix,Matrix,number":function(e,r,t){return o(e.valueOf(),r.valueOf(),t)},"Matrix,Matrix":function(e,r){return o(e.valueOf(),r.valueOf(),1)}});function o(e,r,t){e.some((e=>"BigNumber"===e.type))&&(e=e.map((e=>a(e)))),r.some((e=>"BigNumber"===e.type))&&(r=r.map((e=>a(e))));for(var o=[i(1,0)],s=[i(1,0)],c=0;c<e.length;c++){var l=e[c];"number"==typeof l&&(l=i(l,0)),o=u(o,[i(1,0),i(-l.re,-l.im)])}for(var f=0;f<r.length;f++){var m=r[f];"number"==typeof m&&(m=i(m,0)),s=u(s,[i(1,0),i(-m.re,-m.im)])}for(var d=0;d<o.length;d++)o[d]=n(o[d],t);return[o,s]}function u(e,r){for(var a=[],o=0;o<e.length+r.length-1;o++){a[o]=i(0,0);for(var u=0;u<e.length;u++)o-u>=0&&o-u<r.length&&(a[o]=t(a[o],n(e[u],r[o-u])))}return a}})),xx="freqz",wx=ti(xx,["typed","add","multiply","Complex","divide","matrix"],(e=>{var{typed:r,add:t,multiply:n,Complex:i,divide:a,matrix:o}=e;return r(xx,{"Array, Array":function(e,r){return u(e,r,s(512))},"Array, Array, Array":function(e,r,t){return u(e,r,t)},"Array, Array, number":function(e,r,t){if(t<0)throw Error("w must be a positive number");return u(e,r,s(t))},"Matrix, Matrix":function(e,r){var t=s(512),{w:n,h:i}=u(e.valueOf(),r.valueOf(),t);return{w:o(n),h:o(i)}},"Matrix, Matrix, Matrix":function(e,r,t){var{h:n}=u(e.valueOf(),r.valueOf(),t.valueOf());return{h:o(n),w:o(t)}},"Matrix, Matrix, number":function(e,r,t){if(t<0)throw Error("w must be a positive number");var n=s(t),{h:i}=u(e.valueOf(),r.valueOf(),n);return{h:o(i),w:o(n)}}});function u(e,r,o){for(var u=[],s=[],c=0;c<o.length;c++){for(var l=i(0,0),f=i(0,0),m=0;m<e.length;m++)l=t(l,n(e[m],i(Math.cos(-m*o[c]),Math.sin(-m*o[c]))));for(var d=0;d<r.length;d++)f=t(f,n(r[d],i(Math.cos(-d*o[c]),Math.sin(-d*o[c]))));u.push(l),s.push(f)}for(var p=[],h=0;h<u.length;h++)p.push(a(u[h],s[h]));return{h:p,w:o}}function s(e){for(var r=[],t=0;t<e;t++)r.push(t/e*Math.PI);return r}})),Dx=ti("reviver",["classes"],(e=>{var{classes:r}=e;return function(e,t){var n=r[t&&t.mathjs];return n&&"function"==typeof n.fromJSON?n.fromJSON(t):t}})),Nx=ti("replacer",[],(()=>function(e,r){return"number"!=typeof r||isFinite(r)&&!isNaN(r)?"bigint"==typeof r?{mathjs:"bigint",value:r+""}:r:{mathjs:"number",value:r+""}})),Ax=ti("true",[],(()=>!0)),Mx=ti("false",[],(()=>!1)),Cx=ti("null",[],(()=>null)),Ex=Px("Infinity",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(1/0):1/0})),Sx=Px("NaN",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(NaN):NaN})),Fx=Px("pi",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?uh(t):Ss})),Bx=Px("tau",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?sh(t):Fs})),qx=Px("e",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?ah(t):Bs})),Tx=Px("phi",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?oh(t):1.618033988749895})),kx=Px("LN2",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(2).ln():Math.LN2})),Ox=Px("LN10",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(10).ln():Math.LN10})),Ix=Px("LOG2E",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(1).div(new t(2).ln()):Math.LOG2E})),zx=Px("LOG10E",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(1).div(new t(10).ln()):Math.LOG10E})),jx=Px("SQRT1_2",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t("0.5").sqrt():Math.SQRT1_2})),Rx=Px("SQRT2",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(2).sqrt():Math.SQRT2})),Ux=Px("i",["Complex"],(e=>{var{Complex:r}=e;return r.I})),$x=ti("version",[],(()=>"14.9.1"));function Px(e,r,t){return ti(e,r,t,{recreateOnConfigChange:!0})}var Lx=Uw("speedOfLight","299792458","m s^-1"),_x=Uw("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),Wx=Uw("planckConstant","6.62607015e-34","J s"),Jx=Uw("reducedPlanckConstant","1.0545718176461565e-34","J s"),Vx=Uw("magneticConstant","1.25663706212e-6","N A^-2"),Hx=Uw("electricConstant","8.8541878128e-12","F m^-1"),Zx=Uw("vacuumImpedance","376.730313667","ohm"),Gx=Uw("coulomb","8.987551792261171e9","N m^2 C^-2"),Xx=Uw("coulombConstant","8.987551792261171e9","N m^2 C^-2"),Yx=Uw("elementaryCharge","1.602176634e-19","C"),Qx=Uw("bohrMagneton","9.2740100783e-24","J T^-1"),Kx=Uw("conductanceQuantum","7.748091729863649e-5","S"),ew=Uw("inverseConductanceQuantum","12906.403729652257","ohm"),rw=Uw("magneticFluxQuantum","2.0678338484619295e-15","Wb"),tw=Uw("nuclearMagneton","5.0507837461e-27","J T^-1"),nw=Uw("klitzing","25812.807459304513","ohm"),iw=Uw("bohrRadius","5.29177210903e-11","m"),aw=Uw("classicalElectronRadius","2.8179403262e-15","m"),ow=Uw("electronMass","9.1093837015e-31","kg"),uw=Uw("fermiCoupling","1.1663787e-5","GeV^-2"),sw=$w("fineStructure",.0072973525693),cw=Uw("hartreeEnergy","4.3597447222071e-18","J"),lw=Uw("protonMass","1.67262192369e-27","kg"),fw=Uw("deuteronMass","3.3435830926e-27","kg"),mw=Uw("neutronMass","1.6749271613e-27","kg"),dw=Uw("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),pw=Uw("rydberg","10973731.568160","m^-1"),hw=Uw("thomsonCrossSection","6.6524587321e-29","m^2"),vw=$w("weakMixingAngle",.2229),yw=$w("efimovFactor",22.7),bw=Uw("atomicMass","1.66053906660e-27","kg"),gw=Uw("avogadro","6.02214076e23","mol^-1"),xw=Uw("boltzmann","1.380649e-23","J K^-1"),ww=Uw("faraday","96485.33212331001","C mol^-1"),Dw=Uw("firstRadiation","3.7417718521927573e-16","W m^2"),Nw=Uw("loschmidt","2.686780111798444e25","m^-3"),Aw=Uw("gasConstant","8.31446261815324","J K^-1 mol^-1"),Mw=Uw("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),Cw=Uw("molarVolume","0.022413969545014137","m^3 mol^-1"),Ew=$w("sackurTetrode",-1.16487052358),Sw=Uw("secondRadiation","0.014387768775039337","m K"),Fw=Uw("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),Bw=Uw("wienDisplacement","2.897771955e-3","m K"),qw=Uw("molarMass","0.99999999965e-3","kg mol^-1"),Tw=Uw("molarMassC12","11.9999999958e-3","kg mol^-1"),kw=Uw("gravity","9.80665","m s^-2"),Ow=Uw("planckLength","1.616255e-35","m"),Iw=Uw("planckMass","2.176435e-8","kg"),zw=Uw("planckTime","5.391245e-44","s"),jw=Uw("planckCharge","1.87554603778e-18","C"),Rw=Uw("planckTemperature","1.416785e+32","K");function Uw(e,r,t){return ti(e,["config","Unit","BigNumber"],(e=>{var{config:n,Unit:i,BigNumber:a}=e,o=new i("BigNumber"===n.number?new a(r):parseFloat(r),t);return o.fixPrefix=!0,o}))}function $w(e,r){return ti(e,["config","BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(r):r}))}function Pw(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}var Lw=ti("mapSlices",["typed","isInteger"],(e=>{var{typed:r,isInteger:t}=e,n=Kc({typed:r,isInteger:t});return r("mapSlices",{"...any":function(e){var r=e[1];en(r)?e[1]=r-1:rn(r)&&(e[1]=r.minus(1));try{return n.apply(null,e)}catch(e){throw Rv(e)}}})}),function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?Pw(Object(t),!0).forEach((function(r){ed(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Pw(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}({isTransformFunction:!0},Kc.meta)),_w=ti("column",["typed","Index","matrix","range"],(e=>{var{typed:r,Index:t,matrix:n,range:i}=e,a=Xf({typed:r,Index:t,matrix:n,range:i});return r("column",{"...any":function(e){var r=e.length-1,t=e[r];en(t)&&(e[r]=t-1);try{return a.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0});function Ww(e,r,t){var n=e.filter((function(e){return Pn(e)&&!(e.name in r)&&!t.has(e.name)}))[0];if(!n)throw Error('No undefined variable found in inline expression "'+e+'"');var i=n.name,a=new Map,o=new Xt(t,a,new Set([i])),u=e.compile();return function(e){return a.set(i,e),u.evaluate(o)}}var Jw=ti("transformCallback",["typed"],(e=>{var{typed:r}=e;return function(e,n){return r.isTypedFunction(e)?t(e,n):Vw(e,e.length,n)};function t(e,n){var i=Object.fromEntries(Object.entries(e.signatures).map((e=>{var[i,a]=e,o=i.split(",").length;return r.isTypedFunction(a)?[i,t(a,n)]:[i,Vw(a,o,n)]})));return"string"==typeof e.name?r(e.name,i):r(i)}}));function Vw(e,r,t){return r===t?e:r===t+1?function(){for(var r=arguments.length,n=Array(r),i=0;i<r;i++)n[i]=arguments[i];var a=n.slice(0,t),o=Hw(n[t]);return e(...a,o)}:r>t+1?function(){for(var r=arguments.length,n=Array(r),i=0;i<r;i++)n[i]=arguments[i];var a=n.slice(0,t),o=Hw(n[t]),u=n.slice(t+1);return e(...a,o,...u)}:e}function Hw(e){return e.map((e=>e+1))}var Zw=ti("filter",["typed"],(e=>{var{typed:r}=e;function t(e,t,i){var a=nm({typed:r}),o=Jw({typed:r});if(0===e.length)return a();var u=e[0];if(1===e.length)return a(u);var s=e.length-1,c=e[s];return u&&(u=n(u,i)),c&&(c=Pn(c)||Tn(c)?n(c,i):Ww(c,t,i)),a(u,o(c,s))}function n(e,r){return e.compile().evaluate(r)}return t.rawArgs=!0,t}),{isTransformFunction:!0}),Gw=ti("forEach",["typed"],(e=>{var{typed:r}=e,t=sm({typed:r}),n=Jw({typed:r});function i(e,r,i){if(0===e.length)return t();var o=e[0];if(1===e.length)return t(o);var u=e.length-1,s=e[u];return o&&(o=a(o,i)),s&&(s=Pn(s)||Tn(s)?a(s,i):Ww(s,r,i)),t(o,n(s,u))}function a(e,r){return e.compile().evaluate(r)}return i.rawArgs=!0,i}),{isTransformFunction:!0}),Xw=ti("index",["Index","getMatrixDataType"],(e=>{var{Index:r,getMatrixDataType:t}=e;return function(){for(var e=[],n=0,i=arguments.length;n<i;n++){var a=arguments[n];if(dn(a))a.start--,a.end-=a.step>0?0:2;else if(a&&!0===a.isSet)a=a.map((function(e){return e-1}));else if(sn(a)||cn(a))"boolean"!==t(a)&&(a=a.map((function(e){return e-1})));else if(en(a)||tn(a))a--;else if(rn(a))a=a.toNumber()-1;else if("string"!=typeof a)throw new TypeError("Dimension must be an Array, Matrix, number, bigint, string, or Range");e[n]=a}var o=new r;return r.apply(o,e),o}}),{isTransformFunction:!0}),Yw=ti("map",["typed"],(e=>{var{typed:r}=e,t=ym({typed:r}),n=Jw({typed:r});function i(e,r,i){if(0===e.length)return t();if(1===e.length)return t(e[0]);var a=e.length-1,o=e.slice(0,a),u=e[a];return o=o.map((e=>s(e,i))),u&&(u=Pn(u)||Tn(u)?s(u,i):Ww(u,r,i)),t(...o,n(u,a));function s(e,r){return e.compile().evaluate(r)}}return i.rawArgs=!0,i}),{isTransformFunction:!0});function Qw(e){if(2===e.length&&ln(e[0])){var r=(e=e.slice())[1];(function(e){return en(e)||rn(e)})(r)&&(e[1]=function(e){return en(e)?e-1:rn(e)?e.minus(1):e}(r))}return e}var Kw=["typed","config","numeric","larger","isNaN"],eD=ti("max",Kw,(e=>{var{typed:r,config:t,numeric:n,larger:i,isNaN:a}=e,o=Xp({typed:r,config:t,numeric:n,larger:i,isNaN:a});return r("max",{"...any":function(e){e=Qw(e);try{return o.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),rD=["typed","add","divide"],tD=ti("mean",rD,(e=>{var{typed:r,add:t,divide:n}=e,i=Ub({typed:r,add:t,divide:n});return r("mean",{"...any":function(e){e=Qw(e);try{return i.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),nD=["typed","config","numeric","smaller","isNaN"],iD=ti("min",nD,(e=>{var{typed:r,config:t,numeric:n,smaller:i,isNaN:a}=e,o=Yp({typed:r,config:t,numeric:n,smaller:i,isNaN:a});return r("min",{"...any":function(e){e=Qw(e);try{return o.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),aD=["typed","config","?matrix","?bignumber","equal","smaller","smallerEq","larger","largerEq","add","isZero","isPositive"],oD=ti("range",aD,(e=>{var{typed:r,config:t,matrix:n,bignumber:i,equal:a,smaller:o,smallerEq:u,larger:s,largerEq:c,add:l,isZero:f,isPositive:m}=e,d=Mm({typed:r,config:t,matrix:n,bignumber:i,equal:a,smaller:o,smallerEq:u,larger:s,largerEq:c,add:l,isZero:f,isPositive:m});return r("range",{"...any":function(e){return"boolean"!=typeof e[e.length-1]&&e.push(!0),d.apply(null,e)}})}),{isTransformFunction:!0}),uD=["typed","Index","matrix","range"],sD=ti("row",uD,(e=>{var{typed:r,Index:t,matrix:n,range:i}=e,a=km({typed:r,Index:t,matrix:n,range:i});return r("row",{"...any":function(e){var r=e.length-1,t=e[r];en(t)&&(e[r]=t-1);try{return a.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),cD=["typed","matrix","zeros","add"],lD=ti("subset",cD,(e=>{var{typed:r,matrix:t,zeros:n,add:i}=e,a=Um({typed:r,matrix:t,zeros:n,add:i});return r("subset",{"...any":function(e){try{return a.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),fD=["typed","matrix","isInteger"],mD=ti("concat",fD,(e=>{var{typed:r,matrix:t,isInteger:n}=e,i=Zf({typed:r,matrix:t,isInteger:n});return r("concat",{"...any":function(e){var r=e.length-1,t=e[r];en(t)?e[r]=t-1:rn(t)&&(e[r]=t.minus(1));try{return i.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),dD="diff",pD=["typed","matrix","subtract","number","bignumber"],hD=ti(dD,pD,(e=>{var{typed:r,matrix:t,subtract:n,number:i,bignumber:a}=e,o=gm({typed:r,matrix:t,subtract:n,number:i,bignumber:a});return r(dD,{"...any":function(e){e=Qw(e);try{return o.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),vD=["typed","map","sqrt","variance"],yD=ti("std",vD,(e=>{var{typed:r,map:t,sqrt:n,variance:i}=e,a=Zb({typed:r,map:t,sqrt:n,variance:i});return r("std",{"...any":function(e){e=Qw(e);try{return a.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),bD=["typed","config","add","numeric"],gD=ti("sum",bD,(e=>{var{typed:r,config:t,add:n,numeric:i}=e,a=Ib({typed:r,config:t,add:n,numeric:i});return r("sum",{"...any":function(e){e=Qw(e);try{return a.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),xD=["typed","bignumber","add","subtract","divide","multiply","partitionSelect","compare","isInteger","smaller","smallerEq","larger","mapSlices"],wD=ti("quantileSeq",xD,(e=>{var{typed:r,bignumber:t,add:n,subtract:i,divide:a,multiply:o,partitionSelect:u,compare:s,isInteger:c,smaller:l,smallerEq:f,larger:m,mapSlices:d}=e,p=Hb({typed:r,bignumber:t,add:n,subtract:i,divide:a,multiply:o,partitionSelect:u,compare:s,isInteger:c,smaller:l,smallerEq:f,larger:m,mapSlices:d});return r("quantileSeq",{"Array | Matrix, number | BigNumber":p,"Array | Matrix, number | BigNumber, number":(e,r,t)=>p(e,r,h(t)),"Array | Matrix, number | BigNumber, boolean":p,"Array | Matrix, number | BigNumber, boolean, number":(e,r,t,n)=>p(e,r,t,h(n)),"Array | Matrix, Array | Matrix":p,"Array | Matrix, Array | Matrix, number":(e,r,t)=>p(e,r,h(t)),"Array | Matrix, Array | Matrix, boolean":p,"Array | Matrix, Array | Matrix, boolean, number":(e,r,t,n)=>p(e,r,t,h(n))});function h(e){return Qw([[],e])[1]}}),{isTransformFunction:!0}),DD="cumsum",ND=["typed","add","unaryPlus"],AD=ti(DD,ND,(e=>{var{typed:r,add:t,unaryPlus:n}=e,i=jb({typed:r,add:t,unaryPlus:n});return r(DD,{"...any":function(e){if(2===e.length&&ln(e[0])){var r=e[1];en(r)?e[1]=r-1:rn(r)&&(e[1]=r.minus(1))}try{return i.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),MD="variance",CD=["typed","add","subtract","multiply","divide","mapSlices","isNaN"],ED=ti(MD,CD,(e=>{var{typed:r,add:t,subtract:n,multiply:i,divide:a,mapSlices:o,isNaN:u}=e,s=Jb({typed:r,add:t,subtract:n,multiply:i,divide:a,mapSlices:o,isNaN:u});return r(MD,{"...any":function(e){e=Qw(e);try{return s.apply(null,e)}catch(e){throw Rv(e)}}})}),{isTransformFunction:!0}),SD="print",FD=["typed","matrix","zeros","add"],BD=ti(SD,FD,(e=>{var{typed:r,matrix:t,zeros:n,add:i}=e,a=Nd({typed:r,matrix:t,zeros:n,add:i});return r(SD,{"string, Object | Array":function(e,r){return a(o(e),r)},"string, Object | Array, number | Object":function(e,r,t){return a(o(e),r,t)}});function o(e){return e.replace(wd,(e=>"$"+e.slice(1).split(".").map((function(e){return!isNaN(e)&&e.length>0?parseInt(e)-1:e})).join(".")))}}),{isTransformFunction:!0}),qD=["typed","matrix","zeros","add","equalScalar","not","concat"],TD=ti("and",qD,(e=>{var{typed:r,matrix:t,equalScalar:n,zeros:i,not:a,concat:o}=e,u=dp({typed:r,matrix:t,equalScalar:n,zeros:i,not:a,concat:o});function s(e,r,t){var n=e[0].compile().evaluate(t);if(!ln(n)&&!u(n,!0))return!1;var i=e[1].compile().evaluate(t);return u(n,i)}return s.rawArgs=!0,s}),{isTransformFunction:!0}),kD=["typed","matrix","equalScalar","DenseMatrix","concat"],OD=ti("or",kD,(e=>{var{typed:r,matrix:t,equalScalar:n,DenseMatrix:i,concat:a}=e,o=Jf({typed:r,matrix:t,equalScalar:n,DenseMatrix:i,concat:a});function u(e,r,t){var n=e[0].compile().evaluate(t);if(!ln(n)&&o(n,!1))return!0;var i=e[1].compile().evaluate(t);return o(n,i)}return u.rawArgs=!0,u}),{isTransformFunction:!0}),ID=["typed","matrix","size","flatten","deepEqual"],zD=ti("nullish",ID,(e=>{var{typed:r,matrix:t,size:n,flatten:i,deepEqual:a}=e,o=Wf({typed:r,matrix:t,size:n,flatten:i,deepEqual:a});function u(e,r,t){var n=e[0].compile().evaluate(t);if(!ln(n)&&null!=n&&void 0!==n)return n;var i=e[1].compile().evaluate(t);return o(n,i)}return u.rawArgs=!0,u}),{isTransformFunction:!0}),jD=["typed","matrix","zeros","add","equalScalar","not","concat"],RD=ti("bitAnd",jD,(e=>{var{typed:r,matrix:t,equalScalar:n,zeros:i,not:a,concat:o}=e,u=Ff({typed:r,matrix:t,equalScalar:n,zeros:i,not:a,concat:o});function s(e,r,t){var n=e[0].compile().evaluate(t);if(!ln(n)){if(isNaN(n))return NaN;if(0===n||!1===n)return 0}var i=e[1].compile().evaluate(t);return u(n,i)}return s.rawArgs=!0,s}),{isTransformFunction:!0}),UD=["typed","matrix","equalScalar","DenseMatrix","concat"],$D=ti("bitOr",UD,(e=>{var{typed:r,matrix:t,equalScalar:n,DenseMatrix:i,concat:a}=e,o=kf({typed:r,matrix:t,equalScalar:n,DenseMatrix:i,concat:a});function u(e,r,t){var n=e[0].compile().evaluate(t);if(!ln(n)){if(isNaN(n))return NaN;if(-1===n)return-1;if(!0===n)return 1}var i=e[1].compile().evaluate(t);return o(n,i)}return u.rawArgs=!0,u}),{isTransformFunction:!0}),PD=go({config:Zn}),LD=No({}),_D=qx({BigNumber:PD,config:Zn}),WD=Mx({}),JD=sw({BigNumber:PD,config:Zn}),VD=Lo({}),HD=Ux({Complex:LD}),ZD=Ex({BigNumber:PD,config:Zn}),GD=Ox({BigNumber:PD,config:Zn}),XD=zx({BigNumber:PD,config:Zn}),YD=Wo({}),QD=Sx({BigNumber:PD,config:Zn}),KD=Cx({}),eN=Tx({BigNumber:PD,config:Zn}),rN=_o({}),tN=zi({}),nN=jx({BigNumber:PD,config:Zn}),iN=Ew({BigNumber:PD,config:Zn}),aN=Bx({BigNumber:PD,config:Zn}),oN=Ax({}),uN=$x({}),sN=Ru({Matrix:YD}),cN=yw({BigNumber:PD,config:Zn}),lN=kx({BigNumber:PD,config:Zn}),fN=Fx({BigNumber:PD,config:Zn}),mN=Nx({}),dN=Rx({BigNumber:PD,config:Zn}),pN=Bi({BigNumber:PD,Complex:LD,DenseMatrix:sN,Fraction:VD}),hN=vw({BigNumber:PD,config:Zn}),vN=Yc({typed:pN}),yN=xh({Complex:LD,config:Zn,typed:pN}),bN=Ah({BigNumber:PD,typed:pN}),gN=Sh({BigNumber:PD,Complex:LD,config:Zn,typed:pN}),xN=tl({typed:pN}),wN=jf({typed:pN}),DN=Oh({BigNumber:PD,Complex:LD,config:Zn,typed:pN}),NN=jh({typed:pN}),AN=Rh({typed:pN}),MN=Lh({Complex:LD,config:Zn,typed:pN}),CN=Fc({typed:pN}),EN=qf({typed:pN}),SN=kc({typed:pN}),FN=$u({typed:pN}),BN=Qb({typed:pN}),qN=Ic({Complex:LD,typed:pN}),TN=Uf({typed:pN}),kN=Wh({typed:pN}),ON=Hh({BigNumber:PD,typed:pN}),IN=Xh({BigNumber:PD,typed:pN}),zN=vl({typed:pN}),jN=Cc({config:Zn,typed:pN}),RN=nd({typed:pN}),UN=yl({typed:pN}),$N=gl({Complex:LD,typed:pN}),PN=nm({typed:pN}),LN=om({typed:pN}),_N=sm({typed:pN}),WN=yd({typed:pN}),JN=fm({typed:pN}),VN=xd({format:WN,typed:pN}),HN=$f({typed:pN}),ZN=Gu({typed:pN}),GN=fc({config:Zn,typed:pN}),XN=yc({config:Zn,typed:pN}),YN=gc({equalScalar:jN,typed:pN}),QN=Ix({BigNumber:PD,config:Zn}),KN=og({Complex:LD,typed:pN}),eA=Yl({Complex:LD,config:Zn,typed:pN}),rA=Kl({Complex:LD,config:Zn,typed:pN}),tA=ym({typed:pN}),nA=ef({typed:pN}),iA=Lf({typed:pN}),aA=Sc({typed:pN}),oA=gd({format:WN,typed:pN}),uA=$g({config:Zn,typed:pN}),sA=Nd({typed:pN}),cA=_g({config:Zn,typed:pN}),lA=Pf({typed:pN}),fA=Kh({BigNumber:PD,typed:pN}),mA=uf({BigNumber:PD,Fraction:VD,complex:qN,typed:pN}),dA=tv({typed:pN}),pA=Ec({Matrix:YD,equalScalar:jN,typed:pN}),hA=Vc({typed:pN}),vA=lf({typed:pN}),yA=qc({typed:pN}),bA=il({typed:pN}),gA=av({typed:pN}),xA=Ed({typed:pN}),wA=Nc({typed:pN}),DA=Dh({Complex:LD,config:Zn,typed:pN}),NA=Bh({BigNumber:PD,typed:pN}),AA=Th({BigNumber:PD,Complex:LD,config:Zn,typed:pN}),MA=Oc({BigNumber:PD,typed:pN}),CA=rg({typed:pN}),EA=Vh({typed:pN}),SA=Qh({BigNumber:PD,typed:pN}),FA=wc({typed:pN}),BA=Fd({typed:pN}),qA=Kc({isInteger:ZN,typed:pN}),TA=Rc({DenseMatrix:sN,Matrix:YD,SparseMatrix:pA,typed:pN}),kA=$c({isZero:YN,matrix:TA,typed:pN}),OA=xm({BigNumber:PD,config:Zn,matrix:TA,typed:pN}),IA=Jg({config:Zn,log2:rA,typed:pN}),zA=Em({isInteger:ZN,matrix:TA,typed:pN}),jA=rv({BigNumber:PD,typed:pN}),RA=iv({typed:pN}),UA=vh({SparseMatrix:pA,typed:pN}),$A=sf({Complex:LD,config:Zn,typed:pN}),PA=jm({typed:pN}),LA=ov({typed:pN}),_A=Jm({matrix:TA,typed:pN}),WA=pf({BigNumber:PD,config:Zn,matrix:TA,typed:pN}),JA=Gm({BigNumber:PD,config:Zn,matrix:TA,typed:pN}),VA=Ch({BigNumber:PD,Complex:LD,config:Zn,typed:pN}),HA=zh({Complex:LD,config:Zn,typed:pN}),ZA=bd({format:WN,typed:pN}),GA=Zf({isInteger:ZN,matrix:TA,typed:pN}),XA=Gh({BigNumber:PD,typed:pN}),YA=Hm({conj:TN,transpose:_A,typed:pN}),QA=tm({DenseMatrix:sN,SparseMatrix:pA,matrix:TA,typed:pN}),KA=gf({concat:GA,equalScalar:jN,matrix:TA,multiplyScalar:nA,typed:pN}),eM=Mp({DenseMatrix:sN,SparseMatrix:pA,concat:GA,equalScalar:jN,matrix:TA,typed:pN}),rM=zc({Fraction:VD,typed:pN}),tM=dm({BigNumber:PD,DenseMatrix:sN,SparseMatrix:pA,config:Zn,matrix:TA,typed:pN}),nM=dc({typed:pN}),iM=hm({matrix:TA,multiplyScalar:nA,typed:pN}),aM=Up({DenseMatrix:sN,SparseMatrix:pA,concat:GA,config:Zn,matrix:TA,typed:pN}),oM=sp({DenseMatrix:sN,concat:GA,equalScalar:jN,matrix:TA,typed:pN,zeros:JA}),uM=md({isNaN:FA,isNumeric:nM,typed:pN}),sM=af({BigNumber:PD,concat:GA,equalScalar:jN,matrix:TA,typed:pN}),cM=Bd({bignumber:MA,fraction:rM,number:aA}),lM=hd({config:Zn,multiplyScalar:nA,numeric:cM,typed:pN}),fM=Sm({config:Zn,matrix:TA}),mM=lp({DenseMatrix:sN,concat:GA,equalScalar:jN,matrix:TA,typed:pN,zeros:JA}),dM=zd({BigNumber:PD,DenseMatrix:sN,config:Zn,equalScalar:jN,matrix:TA,typed:pN,zeros:JA}),pM=Im({matrix:TA,config:Zn,typed:pN}),hM=Bp({DenseMatrix:sN,SparseMatrix:pA,bignumber:MA,concat:GA,config:Zn,matrix:TA,typed:pN}),vM=Md({concat:GA,matrix:TA,typed:pN}),yM=Zc({typed:pN}),bM=Wp({DenseMatrix:sN,SparseMatrix:pA,concat:GA,config:Zn,equalScalar:jN,matrix:TA,typed:pN}),gM=Vf({DenseMatrix:sN,SparseMatrix:pA,concat:GA,matrix:TA,typed:pN}),xM=Ev({DenseMatrix:sN,SparseMatrix:pA,addScalar:xN,concat:GA,equalScalar:jN,matrix:TA,typed:pN}),wM=$h({BigNumber:PD,DenseMatrix:sN,concat:GA,equalScalar:jN,matrix:TA,typed:pN}),DM=Ff({concat:GA,equalScalar:jN,matrix:TA,typed:pN}),NM=kf({DenseMatrix:sN,concat:GA,equalScalar:jN,matrix:TA,typed:pN}),AM=zf({DenseMatrix:sN,SparseMatrix:pA,concat:GA,matrix:TA,typed:pN}),MM=ol({BigNumber:PD,Complex:LD,Fraction:VD,config:Zn,isNegative:GN,matrix:TA,typed:pN,unaryMinus:yM}),CM=hp({BigNumber:PD,DenseMatrix:sN,Fraction:VD,concat:GA,config:Zn,equalScalar:jN,matrix:TA,typed:pN}),EM=Np({concat:GA,matrix:TA,typed:pN}),SM=Qf({prod:lM,size:pM,typed:pN}),FM=Lp({equal:eM,typed:pN}),BM=Td({numeric:cM,typed:pN}),qM=Hd({DenseMatrix:sN,SparseMatrix:pA,concat:GA,divideScalar:BM,equalScalar:jN,matrix:TA,typed:pN}),TM=Sp({compareText:EM,isZero:YN,typed:pN}),kM=Sl({DenseMatrix:sN,config:Zn,equalScalar:jN,matrix:TA,round:dM,typed:pN,zeros:JA}),OM=Wl({BigNumber:PD,DenseMatrix:sN,concat:GA,config:Zn,equalScalar:jN,matrix:TA,round:dM,typed:pN,zeros:JA}),IM=hc({isNumeric:nM,typed:pN}),zM=Fv({abs:vN,addScalar:xN,divideScalar:BM,isPositive:XN,multiplyScalar:nA,smaller:hM,sqrt:$A,typed:pN}),jM=Qp({DenseMatrix:sN,smaller:hM}),RM=Kp({ImmutableDenseMatrix:jM,getMatrixDataType:JN}),UM=zp({DenseMatrix:sN,SparseMatrix:pA,bignumber:MA,concat:GA,config:Zn,matrix:TA,typed:pN}),$M=Ud({Complex:LD,config:Zn,divideScalar:BM,typeOf:wA,typed:pN}),PM=Qd({DenseMatrix:sN,divideScalar:BM,equalScalar:jN,matrix:TA,multiplyScalar:nA,subtractScalar:bA,typed:pN}),LM=Wc({flatten:LN,matrix:TA,size:pM,typed:pN}),_M=Xp({config:Zn,isNaN:FA,larger:UM,numeric:cM,typed:pN}),WM=Yp({config:Zn,isNaN:FA,numeric:cM,smaller:hM,typed:pN}),JM=Il({DenseMatrix:sN,concat:GA,config:Zn,equalScalar:jN,matrix:TA,round:dM,typed:pN,zeros:JA}),VM=_d({Complex:LD,config:Zn,divideScalar:BM,typed:pN}),HM=Wf({deepEqual:FM,flatten:LN,matrix:TA,size:pM,typed:pN}),ZM=Jf({DenseMatrix:sN,concat:GA,equalScalar:jN,matrix:TA,typed:pN}),GM=Hp({compare:CM,isNaN:FA,isNumeric:nM,typed:pN}),XM=Ly({addScalar:xN,complex:qN,conj:TN,divideScalar:BM,equal:eM,identity:tM,isZero:YN,matrix:TA,multiplyScalar:nA,sign:mA,sqrt:$A,subtractScalar:bA,typed:pN,unaryMinus:yM,zeros:JA}),YM=mp({DenseMatrix:sN,concat:GA,equalScalar:jN,matrix:TA,typed:pN,zeros:JA}),QM=kp({DenseMatrix:sN,SparseMatrix:pA,concat:GA,config:Zn,matrix:TA,typed:pN}),KM=Um({add:xM,matrix:TA,typed:pN,zeros:JA}),eC=mf({DenseMatrix:sN,concat:GA,equalScalar:jN,matrix:TA,subtractScalar:bA,typed:pN,unaryMinus:yM}),rC=kv({add:xM,matrix:TA,typed:pN}),tC=ep({DenseMatrix:sN,divideScalar:BM,equalScalar:jN,matrix:TA,multiplyScalar:nA,subtractScalar:bA,typed:pN}),nC=Yg({addScalar:xN,combinations:BN,divideScalar:BM,isInteger:ZN,isNegative:GN,multiplyScalar:nA,typed:pN}),iC=xp({compare:CM,typed:pN}),aC=Kg({addScalar:xN,combinations:BN,isInteger:ZN,isNegative:GN,isPositive:XN,larger:UM,typed:pN}),oC=gm({matrix:TA,number:aA,subtract:eC,typed:pN}),uC=kb({abs:vN,addScalar:xN,deepEqual:FM,divideScalar:BM,multiplyScalar:nA,sqrt:$A,subtractScalar:bA,typed:pN}),sC=Tv({addScalar:xN,conj:TN,multiplyScalar:nA,size:pM,typed:pN}),cC=rh({larger:UM,smaller:hM}),lC=Iv({Index:RM,typed:pN}),fC=vf({BigNumber:PD,add:xM,config:Zn,equal:eM,isInteger:ZN,mod:JM,smaller:hM,typed:pN,xgcd:WA}),mC=Vl({concat:GA,equalScalar:jN,matrix:TA,typed:pN}),dC=Pd({Complex:LD,config:Zn,divideScalar:BM,log:$M,typed:pN}),pC=tp({DenseMatrix:sN,divideScalar:BM,equalScalar:jN,matrix:TA,multiplyScalar:nA,subtractScalar:bA,typed:pN}),hC=Lc({flatten:LN,matrix:TA,size:pM,typed:pN}),vC=tf({addScalar:xN,dot:sC,equalScalar:jN,matrix:TA,multiplyScalar:nA,typed:pN}),yC=Mm({bignumber:MA,matrix:TA,add:xM,config:Zn,equal:eM,isPositive:XN,isZero:YN,larger:UM,largerEq:aM,smaller:hM,smallerEq:QM,typed:pN}),bC=km({Index:RM,matrix:TA,range:yC,typed:pN}),gC=sv({DenseMatrix:sN,Index:RM,compareNatural:iC,size:pM,subset:KM,typed:pN}),xC=mv({DenseMatrix:sN,Index:RM,compareNatural:iC,size:pM,subset:KM,typed:pN}),wC=vv({Index:RM,compareNatural:iC,size:pM,subset:KM,typed:pN}),DC=xv({Index:RM,compareNatural:iC,size:pM,subset:KM,typed:pN}),NC=rb({SparseMatrix:pA,abs:vN,add:xM,divideScalar:BM,larger:UM,largerEq:aM,multiply:vC,subtract:eC,transpose:_A,typed:pN}),AC=Gp({compare:CM,compareNatural:iC,matrix:TA,typed:pN}),MC=Xc({config:Zn,numeric:cM,typed:pN}),CC=ip({DenseMatrix:sN,divideScalar:BM,equalScalar:jN,matrix:TA,multiplyScalar:nA,subtractScalar:bA,typed:pN}),EC=gx({Complex:LD,add:xM,multiply:vC,number:aA,typed:pN}),SC=dp({concat:GA,equalScalar:jN,matrix:TA,not:iA,typed:pN,zeros:JA}),FC=pl({DenseMatrix:sN,config:Zn,equalScalar:jN,matrix:TA,round:dM,typed:pN,zeros:JA}),BC=Xf({Index:RM,matrix:TA,range:yC,typed:pN}),qC=em({matrix:TA,multiply:vC,subtract:eC,typed:pN}),TC=vb({divideScalar:BM,isZero:YN,matrix:TA,multiply:vC,subtractScalar:bA,typed:pN,unaryMinus:yM}),kC=Nl({Complex:LD,DenseMatrix:sN,ceil:FC,equalScalar:jN,floor:kM,matrix:TA,typed:pN,zeros:JA}),OC=yb({abs:vN,addScalar:xN,det:TC,divideScalar:BM,identity:tM,matrix:TA,multiply:vC,typed:pN,unaryMinus:yM}),IC=gb({Complex:LD,add:xM,ctranspose:YA,deepEqual:FM,divideScalar:BM,dot:sC,dotDivide:qM,equal:eM,inv:OC,matrix:TA,multiply:vC,typed:pN}),zC=kd({Complex:LD,config:Zn,fraction:rM,identity:tM,inv:OC,matrix:TA,multiply:vC,number:aA,typed:pN}),jC=lv({DenseMatrix:sN,Index:RM,compareNatural:iC,size:pM,subset:KM,typed:pN}),RC=bv({Index:RM,compareNatural:iC,size:pM,subset:KM,typed:pN}),UC=Av({Index:RM,concat:GA,setDifference:jC,size:pM,subset:KM,typed:pN}),$C=th({FibonacciHeap:cC,addScalar:xN,equalScalar:jN}),PC=Ab({abs:vN,add:xM,identity:tM,inv:OC,map:tA,max:_M,multiply:vC,size:pM,sqrt:$A,subtract:eC,typed:pN}),LC=Ib({add:xM,config:Zn,numeric:cM,typed:pN}),_C=mh({BigNumber:PD,Complex:LD,Fraction:VD,abs:vN,addScalar:xN,config:Zn,divideScalar:BM,equal:eM,fix:kC,format:WN,isNumeric:nM,multiplyScalar:nA,number:aA,pow:zC,round:dM,subtractScalar:bA,toBest:xA}),WC=Zx({BigNumber:PD,Unit:_C,config:Zn}),JC=Bw({BigNumber:PD,Unit:_C,config:Zn}),VC=bw({BigNumber:PD,Unit:_C,config:Zn}),HC=Qx({BigNumber:PD,Unit:_C,config:Zn}),ZC=xw({BigNumber:PD,Unit:_C,config:Zn}),GC=Kx({BigNumber:PD,Unit:_C,config:Zn}),XC=Gx({BigNumber:PD,Unit:_C,config:Zn}),YC=bh({Unit:_C,typed:pN}),QC=fw({BigNumber:PD,Unit:_C,config:Zn}),KC=Jd({DenseMatrix:sN,SparseMatrix:pA,concat:GA,equalScalar:jN,matrix:TA,pow:zC,typed:pN}),eE=Hx({BigNumber:PD,Unit:_C,config:Zn}),rE=Yx({BigNumber:PD,Unit:_C,config:Zn}),tE=Db({abs:vN,add:xM,identity:tM,inv:OC,multiply:vC,typed:pN}),nE=ww({BigNumber:PD,Unit:_C,config:Zn}),iE=Xm({addScalar:xN,ceil:FC,conj:TN,divideScalar:BM,dotDivide:qM,exp:UN,i:HD,log2:rA,matrix:TA,multiplyScalar:nA,pow:zC,tau:aN,typed:pN}),aE=ig({BigNumber:PD,Complex:LD,config:Zn,multiplyScalar:nA,pow:zC,typed:pN}),oE=_x({BigNumber:PD,Unit:_C,config:Zn}),uE=cw({BigNumber:PD,Unit:_C,config:Zn}),sE=Qm({conj:TN,dotDivide:qM,fft:iE,typed:pN}),cE=ew({BigNumber:PD,Unit:_C,config:Zn}),lE=nw({BigNumber:PD,Unit:_C,config:Zn}),fE=Nw({BigNumber:PD,Unit:_C,config:Zn}),mE=Vx({BigNumber:PD,Unit:_C,config:Zn}),dE=qw({BigNumber:PD,Unit:_C,config:Zn}),pE=Mw({BigNumber:PD,Unit:_C,config:Zn}),hE=mw({BigNumber:PD,Unit:_C,config:Zn}),vE=tw({BigNumber:PD,Unit:_C,config:Zn}),yE=jw({BigNumber:PD,Unit:_C,config:Zn}),bE=Ow({BigNumber:PD,Unit:_C,config:Zn}),gE=Rw({BigNumber:PD,Unit:_C,config:Zn}),xE=lw({BigNumber:PD,Unit:_C,config:Zn}),wE=dw({BigNumber:PD,Unit:_C,config:Zn}),DE=Jx({BigNumber:PD,Unit:_C,config:Zn}),NE=pw({BigNumber:PD,Unit:_C,config:Zn}),AE=Sw({BigNumber:PD,Unit:_C,config:Zn}),ME=Dv({compareNatural:iC,typed:pN}),CE=Lx({BigNumber:PD,Unit:_C,config:Zn}),EE=Fw({BigNumber:PD,Unit:_C,config:Zn}),SE=hw({BigNumber:PD,Unit:_C,config:Zn}),FE=gw({BigNumber:PD,Unit:_C,config:Zn}),BE=iw({BigNumber:PD,Unit:_C,config:Zn}),qE=Xx({BigNumber:PD,Unit:_C,config:Zn}),TE=qb({divideScalar:BM,equalScalar:jN,inv:OC,matrix:TA,multiply:vC,typed:pN}),kE=ow({BigNumber:PD,Unit:_C,config:Zn}),OE=sg({gamma:aE,typed:pN}),IE=Dw({BigNumber:PD,Unit:_C,config:Zn}),zE=kw({BigNumber:PD,Unit:_C,config:Zn}),jE=Ob({abs:vN,add:xM,addScalar:xN,config:Zn,divideScalar:BM,equalScalar:jN,flatten:LN,isNumeric:nM,isZero:YN,matrix:TA,multiply:vC,multiplyScalar:nA,smaller:hM,subtract:eC,typed:pN}),RE=Py({DenseMatrix:sN,Spa:$C,SparseMatrix:pA,abs:vN,addScalar:xN,divideScalar:BM,equalScalar:jN,larger:UM,matrix:TA,multiplyScalar:nA,subtractScalar:bA,typed:pN,unaryMinus:yM}),UE=rw({BigNumber:PD,Unit:_C,config:Zn}),$E=Tw({BigNumber:PD,Unit:_C,config:Zn}),PE=mg({add:xM,divide:TE,factorial:OE,isInteger:ZN,isPositive:XN,multiply:vC,typed:pN}),LE=pg({factorial:OE,typed:pN}),_E=Iw({BigNumber:PD,Unit:_C,config:Zn}),WE=ob({add:xM,cbrt:MM,divide:TE,equalScalar:jN,im:HN,isZero:YN,multiply:vC,re:lA,sqrt:$A,subtract:eC,typeOf:wA,typed:pN,unaryMinus:yM}),JE=pv({DenseMatrix:sN,Index:RM,compareNatural:iC,size:pM,subset:KM,typed:pN}),VE=td({abs:vN,add:xM,bignumber:MA,divide:TE,isNegative:GN,isPositive:XN,larger:UM,map:tA,matrix:TA,max:_M,multiply:vC,smaller:hM,subtract:eC,typed:pN,unaryMinus:yM}),HE=Hg({bignumber:MA,addScalar:xN,combinations:BN,divideScalar:BM,factorial:OE,isInteger:ZN,isNegative:GN,larger:UM,multiplyScalar:nA,number:aA,pow:zC,subtractScalar:bA,typed:pN}),ZE=ph({Unit:_C,typed:pN}),GE=Gg({addScalar:xN,isInteger:ZN,isNegative:GN,stirlingS2:HE,typed:pN}),XE=jb({add:xM,typed:pN,unaryPlus:MC}),YE=xb({abs:vN,add:xM,addScalar:xN,atan:AN,bignumber:MA,column:BC,complex:qN,config:Zn,cos:kN,diag:QA,divideScalar:BM,dot:sC,equal:eM,flatten:LN,im:HN,inv:OC,larger:UM,matrix:TA,matrixFromColumns:LM,multiply:vC,multiplyScalar:nA,number:aA,qr:XM,re:lA,reshape:zA,sin:dA,size:pM,smaller:hM,sqrt:$A,subtract:eC,typed:pN,usolve:tC,usolveAll:CC}),QE=uw({BigNumber:PD,Unit:_C,config:Zn}),KE=Aw({BigNumber:PD,Unit:_C,config:Zn}),eS=lg({divide:TE,dotDivide:qM,isNumeric:nM,log:$M,map:tA,matrix:TA,multiply:vC,sum:LC,typed:pN}),rS=ib({DenseMatrix:sN,lsolve:PM,lup:RE,matrix:TA,slu:NC,typed:pN,usolve:tC}),tS=Ub({add:xM,divide:TE,typed:pN}),nS=Cw({BigNumber:PD,Unit:_C,config:Zn}),iS=Wx({BigNumber:PD,Unit:_C,config:Zn}),aS=Hb({bignumber:MA,add:xM,compare:CM,divide:TE,isInteger:ZN,larger:UM,mapSlices:qA,multiply:vC,partitionSelect:GM,smaller:hM,smallerEq:QM,subtract:eC,typed:pN}),oS=Cv({Index:RM,concat:GA,setIntersect:JE,setSymDifference:UC,size:pM,subset:KM,typed:pN}),uS=Jb({add:xM,divide:TE,isNaN:FA,mapSlices:qA,multiply:vC,subtract:eC,typed:pN}),sS=aw({BigNumber:PD,Unit:_C,config:Zn}),cS=Pb({add:xM,compare:CM,divide:TE,partitionSelect:GM,typed:pN}),lS=Xb({add:xM,divide:TE,matrix:TA,mean:tS,multiply:vC,pow:zC,sqrt:$A,subtract:eC,sum:LC,typed:pN}),fS=wx({Complex:LD,add:xM,divide:TE,matrix:TA,multiply:vC,typed:pN}),mS=Lb({abs:vN,map:tA,median:cS,subtract:eC,typed:pN}),dS=Zb({map:tA,sqrt:$A,typed:pN,variance:uS}),pS=ld({BigNumber:PD,Complex:LD,add:xM,config:Zn,divide:TE,equal:eM,factorial:OE,gamma:aE,isNegative:GN,multiply:vC,pi:fN,pow:zC,sin:dA,smallerEq:QM,subtract:eC,typed:pN}),hS=qv({abs:vN,add:xM,conj:TN,ctranspose:YA,eigs:YE,equalScalar:jN,larger:UM,matrix:TA,multiply:vC,pow:zC,smaller:hM,sqrt:$A,typed:pN}),vS=Tm({BigNumber:PD,DenseMatrix:sN,SparseMatrix:pA,addScalar:xN,config:Zn,cos:kN,matrix:TA,multiplyScalar:nA,norm:hS,sin:dA,typed:pN,unaryMinus:yM}),yS=zw({BigNumber:PD,Unit:_C,config:Zn}),bS=Sb({identity:tM,matrix:TA,multiply:vC,norm:hS,qr:XM,subtract:eC,typed:pN}),gS=Bm({multiply:vC,rotationMatrix:vS,typed:pN}),xS=Cb({abs:vN,add:xM,concat:GA,identity:tM,index:lC,lusolve:rS,matrix:TA,matrixFromColumns:LM,multiply:vC,range:yC,schur:bS,subset:KM,subtract:eC,transpose:_A,typed:pN}),wS=Bb({matrix:TA,multiply:vC,sylvester:xS,transpose:_A,typed:pN}),DS={},NS={},AS={},MS=jv({mathWithTransform:NS}),CS=by({Node:MS}),ES=wy({Node:MS}),SS=Ny({Node:MS}),FS=Ey({Node:MS}),BS=_v({Node:MS}),qS=ey({Node:MS,ResultSet:tN}),TS=ty({Node:MS}),kS=my({Node:MS}),OS=My({Node:MS}),IS=Dx({classes:AS}),zS=sb({math:DS,typed:pN}),jS=py({Node:MS,typed:pN}),RS=hb({Chain:zS,typed:pN}),US=Pv({Node:MS,subset:KM}),$S=Qv({matrix:TA,Node:MS,subset:KM}),PS=vy({Node:MS,size:pM}),LS=Sy({Unit:_C,Node:MS,math:DS}),_S=By({Node:MS,SymbolNode:LS,math:DS}),WS=Ty({AccessorNode:US,ArrayNode:BS,AssignmentNode:$S,BlockNode:qS,ConditionalNode:TS,ConstantNode:kS,FunctionAssignmentNode:jS,FunctionNode:_S,IndexNode:PS,ObjectNode:CS,OperatorNode:ES,ParenthesisNode:SS,RangeNode:OS,RelationalNode:FS,SymbolNode:LS,config:Zn,numeric:cM,typed:pN}),JS=fx({ConstantNode:kS,FunctionNode:_S,OperatorNode:ES,ParenthesisNode:SS,parse:WS,typed:pN}),VS=sx({bignumber:MA,fraction:rM,AccessorNode:US,ArrayNode:BS,ConstantNode:kS,FunctionNode:_S,IndexNode:PS,ObjectNode:CS,OperatorNode:ES,SymbolNode:LS,config:Zn,mathWithTransform:NS,matrix:TA,typed:pN}),HS=Oy({parse:WS,typed:pN}),ZS=lx({AccessorNode:US,ArrayNode:BS,ConstantNode:kS,FunctionNode:_S,IndexNode:PS,ObjectNode:CS,OperatorNode:ES,ParenthesisNode:SS,SymbolNode:LS,add:xM,divide:TE,equal:eM,isZero:YN,multiply:vC,parse:WS,pow:zC,subtract:eC,typed:pN}),GS=zy({parse:WS,typed:pN}),XS=ub({evaluate:GS}),YS=jy({evaluate:GS,parse:WS}),QS=ux({AccessorNode:US,ArrayNode:BS,ConstantNode:kS,FunctionNode:_S,IndexNode:PS,ObjectNode:CS,OperatorNode:ES,ParenthesisNode:SS,SymbolNode:LS,equal:eM,parse:WS,replacer:mN,resolve:JS,simplifyConstant:VS,simplifyCore:ZS,typed:pN}),KS=dx({OperatorNode:ES,parse:WS,simplify:QS,typed:pN}),eF=rx({parse:WS,typed:pN}),rF=$y({Parser:YS,typed:pN}),tF=yx({bignumber:MA,fraction:rM,AccessorNode:US,ArrayNode:BS,ConstantNode:kS,FunctionNode:_S,IndexNode:PS,ObjectNode:CS,OperatorNode:ES,ParenthesisNode:SS,SymbolNode:LS,add:xM,config:Zn,divide:TE,equal:eM,isZero:YN,mathWithTransform:NS,matrix:TA,multiply:vC,parse:WS,pow:zC,simplify:QS,simplifyConstant:VS,simplifyCore:ZS,subtract:eC,typed:pN}),nF=hx({ConstantNode:kS,FunctionNode:_S,OperatorNode:ES,ParenthesisNode:SS,SymbolNode:LS,config:Zn,equal:eM,isZero:YN,numeric:cM,parse:WS,simplify:QS,typed:pN}),iF=db({Help:XS,mathWithTransform:NS,typed:pN});Pt(DS,{e:_D,false:WD,fineStructure:JD,i:HD,Infinity:ZD,LN10:GD,LOG10E:XD,NaN:QD,null:KD,phi:eN,SQRT1_2:nN,sackurTetrode:iN,tau:aN,true:oN,E:_D,version:uN,efimovFactor:cN,LN2:lN,pi:fN,replacer:mN,reviver:IS,SQRT2:dN,typed:pN,PI:fN,weakMixingAngle:hN,abs:vN,acos:yN,acot:bN,acsc:gN,addScalar:xN,arg:wN,asech:DN,asinh:NN,atan:AN,atanh:MN,bigint:CN,bitNot:EN,boolean:SN,clone:FN,combinations:BN,complex:qN,conj:TN,cos:kN,cot:ON,csc:IN,cube:zN,equalScalar:jN,erf:RN,exp:UN,expm1:$N,filter:PN,flatten:LN,forEach:_N,format:WN,getMatrixDataType:JN,hex:VN,im:HN,isInteger:ZN,isNegative:GN,isPositive:XN,isZero:YN,LOG2E:QN,lgamma:KN,log10:eA,log2:rA,map:tA,multiplyScalar:nA,not:iA,number:aA,oct:oA,pickRandom:uA,print:sA,random:cA,re:lA,sec:fA,sign:mA,sin:dA,splitUnit:hA,square:vA,string:yA,subtractScalar:bA,tan:gA,toBest:xA,typeOf:wA,acosh:DA,acsch:NA,asec:AA,bignumber:MA,chain:RS,combinationsWithRep:CA,cosh:EA,csch:SA,isNaN:FA,isPrime:BA,mapSlices:qA,matrix:TA,matrixFromFunction:kA,ones:OA,randomInt:IA,reshape:zA,sech:jA,sinh:RA,sparse:UA,sqrt:$A,squeeze:PA,tanh:LA,transpose:_A,xgcd:WA,zeros:JA,acoth:VA,asin:HA,bin:ZA,concat:GA,coth:XA,ctranspose:YA,diag:QA,dotMultiply:KA,equal:eM,fraction:rM,identity:tM,isNumeric:nM,kron:iM,largerEq:aM,leftShift:oM,mode:uM,nthRoot:sM,numeric:cM,prod:lM,resize:fM,rightArithShift:mM,round:dM,size:pM,smaller:hM,to:vM,unaryMinus:yM,unequal:bM,xor:gM,add:xM,atan2:wM,bitAnd:DM,bitOr:NM,bitXor:AM,cbrt:MM,compare:CM,compareText:EM,count:SM,deepEqual:FM,divideScalar:BM,dotDivide:qM,equalText:TM,floor:kM,gcd:OM,hasNumericValue:IM,hypot:zM,larger:UM,log:$M,lsolve:PM,matrixFromColumns:LM,max:_M,min:WM,mod:JM,nthRoots:VM,nullish:HM,or:ZM,partitionSelect:GM,qr:XM,rightLogShift:YM,smallerEq:QM,subset:KM,subtract:eC,trace:rC,usolve:tC,catalan:nC,compareNatural:iC,composition:aC,diff:oC,distance:uC,dot:sC,index:lC,invmod:fC,lcm:mC,log1p:dC,lsolveAll:pC,matrixFromRows:hC,multiply:vC,range:yC,row:bC,setCartesian:gC,setDistinct:xC,setIsSubset:wC,setPowerset:DC,slu:NC,sort:AC,unaryPlus:MC,usolveAll:CC,zpk2tf:EC,and:SC,ceil:FC,column:BC,cross:qC,det:TC,fix:kC,inv:OC,pinv:IC,pow:zC,setDifference:jC,setMultiplicity:RC,setSymDifference:UC,sqrtm:PC,sum:LC,vacuumImpedance:WC,wienDisplacement:JC,atomicMass:VC,bohrMagneton:HC,boltzmann:ZC,conductanceQuantum:GC,coulomb:XC,createUnit:YC,deuteronMass:QC,dotPow:KC,electricConstant:eE,elementaryCharge:rE,expm:tE,faraday:nE,fft:iE,gamma:aE,gravitationConstant:oE,hartreeEnergy:uE,ifft:sE,inverseConductanceQuantum:cE,klitzing:lE,loschmidt:fE,magneticConstant:mE,molarMass:dE,molarPlanckConstant:pE,neutronMass:hE,nuclearMagneton:vE,planckCharge:yE,planckLength:bE,planckTemperature:gE,protonMass:xE,quantumOfCirculation:wE,reducedPlanckConstant:DE,rydberg:NE,secondRadiation:AE,setSize:ME,speedOfLight:CE,stefanBoltzmann:EE,thomsonCrossSection:SE,avogadro:FE,bohrRadius:BE,coulombConstant:qE,divide:TE,electronMass:kE,factorial:OE,firstRadiation:IE,gravity:zE,intersect:jE,lup:RE,magneticFluxQuantum:UE,molarMassC12:$E,multinomial:PE,parse:WS,permutations:LE,planckMass:_E,polynomialRoot:WE,resolve:JS,setIntersect:JE,simplifyConstant:VS,solveODE:VE,stirlingS2:HE,unit:ZE,bellNumbers:GE,compile:HS,cumsum:XE,eigs:YE,fermiCoupling:QE,gasConstant:KE,kldivergence:eS,lusolve:rS,mean:tS,molarVolume:nS,planckConstant:iS,quantileSeq:aS,setUnion:oS,simplifyCore:ZS,variance:uS,classicalElectronRadius:sS,evaluate:GS,median:cS,simplify:QS,symbolicEqual:KS,corr:lS,freqz:fS,leafCount:eF,mad:mS,parser:rF,rationalize:tF,std:dS,zeta:pS,derivative:nF,norm:hS,rotationMatrix:vS,help:iF,planckTime:yS,schur:bS,rotate:gS,sylvester:xS,lyap:wS,config:Zn}),Pt(NS,DS,{mapSlices:Lw({isInteger:ZN,typed:pN}),filter:Zw({typed:pN}),forEach:Gw({typed:pN}),map:Yw({typed:pN}),or:OD({DenseMatrix:sN,concat:GA,equalScalar:jN,matrix:TA,typed:pN}),and:TD({add:xM,concat:GA,equalScalar:jN,matrix:TA,not:iA,typed:pN,zeros:JA}),concat:mD({isInteger:ZN,matrix:TA,typed:pN}),index:Xw({Index:RM,getMatrixDataType:JN}),print:BD({add:xM,matrix:TA,typed:pN,zeros:JA}),sum:gD({add:xM,config:Zn,numeric:cM,typed:pN}),bitAnd:RD({add:xM,concat:GA,equalScalar:jN,matrix:TA,not:iA,typed:pN,zeros:JA}),min:iD({config:Zn,isNaN:FA,numeric:cM,smaller:hM,typed:pN}),nullish:zD({deepEqual:FM,flatten:LN,matrix:TA,size:pM,typed:pN}),subset:lD({add:xM,matrix:TA,typed:pN,zeros:JA}),bitOr:$D({DenseMatrix:sN,concat:GA,equalScalar:jN,matrix:TA,typed:pN}),cumsum:AD({add:xM,typed:pN,unaryPlus:MC}),diff:hD({bignumber:MA,matrix:TA,number:aA,subtract:eC,typed:pN}),max:eD({config:Zn,isNaN:FA,larger:UM,numeric:cM,typed:pN}),range:oD({bignumber:MA,matrix:TA,add:xM,config:Zn,equal:eM,isPositive:XN,isZero:YN,larger:UM,largerEq:aM,smaller:hM,smallerEq:QM,typed:pN}),row:sD({Index:RM,matrix:TA,range:yC,typed:pN}),column:_w({Index:RM,matrix:TA,range:yC,typed:pN}),mean:tD({add:xM,divide:TE,typed:pN}),quantileSeq:wD({add:xM,bignumber:MA,compare:CM,divide:TE,isInteger:ZN,larger:UM,mapSlices:qA,multiply:vC,partitionSelect:GM,smaller:hM,smallerEq:QM,subtract:eC,typed:pN}),variance:ED({add:xM,divide:TE,isNaN:FA,mapSlices:qA,multiply:vC,subtract:eC,typed:pN}),std:yD({map:tA,sqrt:$A,typed:pN,variance:uS})}),Pt(AS,{BigNumber:PD,Complex:LD,Fraction:VD,Matrix:YD,Node:MS,ObjectNode:CS,OperatorNode:ES,ParenthesisNode:SS,Range:rN,RelationalNode:FS,ResultSet:tN,ArrayNode:BS,BlockNode:qS,ConditionalNode:TS,ConstantNode:kS,DenseMatrix:sN,RangeNode:OS,Chain:zS,FunctionAssignmentNode:jS,SparseMatrix:pA,ImmutableDenseMatrix:jM,Index:RM,AccessorNode:US,AssignmentNode:$S,FibonacciHeap:cC,IndexNode:PS,Spa:$C,Unit:_C,SymbolNode:LS,FunctionNode:_S,Help:XS,Parser:YS}),zS.createProxy(DS);let aF=!1;async function oF(e){Wr.getI().play(e),Lr(e),e.style.animation="none",mF(e);const r=document.getElementById(Ze);if(!r)return void console.error("No container found with id: lido-container");const t=r.objective,n=r.querySelector(".lido-slide-fill");if(!n)return;const i=OF(e.value,[t]);if(jF(i),i){const e=r.onCorrect;await qF(e,r),100!==JSON.parse(n.fill)||aF?aF=!1:(aF=!0,r.style.pointerEvents="none",r.getAttribute("game-completed")&&"false"!==r.getAttribute("game-completed")&&null!==r.getAttribute("game-completed")&&void 0!==r.getAttribute("game-completed")&&""!==r.getAttribute("game-completed")||(r.setAttribute("game-completed","true"),RF(),HF()))}else{const e=r.onInCorrect;await qF(e,r)}}let uF=0;const sF=[],cF=12,lF=.5;function fF(){aF=!1,uF=0,sF.length=0}function mF(e){const r=document.getElementById(Ze);if(!r)return void console.error("No container found with id: lido-container");Lr(e);const t=r.querySelector(".lido-float");if(!t)return;const n=t.getAttribute("float-direction")||"bottomToTop",i=5*Math.random();if(e.style.position="absolute","leftToRight"===n){const n=t.offsetHeight;e.classList.add("bubble-element"),e.style.left="unset",e.style.right=1600-window.innerWidth+window.innerWidth+e.offsetWidth+"px";const i=Math.max(1,Math.floor(n/Math.max(1,e.clientHeight+cF)));sF.length>i&&(sF.length=i);const a=performance.now(),o=[];for(let e=0;e<i;e++)(sF[e]||0)<=a&&o.push(e);let u=0;u=o.length>0?o[Math.floor(Math.random()*o.length)]:function(e){let r=0,t=1/0;for(let n=0;n<e;n++){const e=sF[n]||0;e<t&&(t=e,r=n)}return r}(i);const s=null!=u?u:0;e.style.top=Math.round(s*(i>1?Math.max(0,n-e.clientHeight)/(i-1):0))+"px",e.style.setProperty("--el-left",e.style.right);const c=e.offsetWidth/(r.offsetWidth/60),l=Math.max(uF,Math.max(0,((sF[s]||0)-a)/1e3));e.style.animation=`float-lr 40s linear ${l}s`,sF[s]=a+1e3*(l+c+lF),uF=0}else{const r=t.offsetWidth;e.style.left=Math.floor(Math.random()*(r-e.clientWidth))+"px";const n=document.body.offsetHeight+e.offsetHeight*(1/cB());e.style.top=n+"px";const a=5+5*Math.random();e.style.setProperty("--el-top",n+"px"),e.style.animation=`float-up ${a}s linear ${i}s`,e.id="removeShadow"}e.addEventListener("animationend",(()=>{e.style.animation="none",mF(e)}),{once:!0})}function dF(e){const r=document.getElementById(Ze).querySelector("#lido-slide-fill");let t=r.fill;t=function(e,r=0){const t=(""+e).trim().replace("%",""),n=parseFloat(t);return isNaN(n)?r:t.startsWith("+")?r>=100?100:Math.min(100,r+n):t.startsWith("-")?r<=0?0:Math.max(0,r+n):Math.max(0,Math.min(100,n))}(e,JSON.parse(t)),r.setAttribute("fill",t)}const pF=e=>new Promise((r=>setTimeout(r,e))),hF=(e,r)=>new Promise((t=>{let n=!1;n||(n=!0,e.isConnected&&e.remove(),0===r.querySelectorAll("[type='calculate']").length&&setTimeout((()=>HF()),2e3),t())}));let vF=0;const yF=async()=>{var e;const r=document.getElementById("lido-container");if(!r)return;const t=(null===(e=r.querySelector("#lidoCalculator"))||void 0===e?void 0:e.getAttribute("value"))||"";if(!t.length)return;const n=r.querySelectorAll("[type='calculate']")[0];if(!n)return;const i="true"===r.getAttribute("is-continue-on-correct"),a=Number(n.value),o=Number(t),u=r.querySelector("#dummy111"),s=r.querySelector("#dummy112");if(i)return void await(async e=>{var r;const t=(null===(r=e.querySelector("#lidoCalculator"))||void 0===r?void 0:r.getAttribute("value"))||"",n=e.querySelectorAll("[type='calculate']")[0];if(!n)return;const i=Number(n.value),a=Number(t);if(i!==a)return;const o=n.string,u=e.querySelector("#dummy111"),s=e.querySelector("#dummy112");await pF(3e3);const c=s.innerHTML;n.innerHTML=o.replaceAll("?",""+a),s.innerHTML=n.innerHTML,await hF(n,e),c&&(u.innerHTML=c)})(r);a===o?vF++:vF>0&&vF--,console.log("SCORE:",vF);const c=n.string;await pF(3e3);const l=s.innerHTML;n.innerHTML=c.replaceAll("?",""+o),s.innerHTML=n.innerHTML,await hF(n,r),l&&(u.innerHTML=l)};function bF(e){let r=Array.from({length:100},((e,r)=>r+1));const t=new Set,n={};let i=0;const a=(e,r)=>10*e+r+1,o=e.querySelectorAll('lido-math-matrix[type="drop"]');for(const e of Array.from(o)){const o=parseInt(e.getAttribute("cols")||"1"),u=parseInt(e.getAttribute("rows")||"1"),s=[];for(let e=0;e<=10-u;e++)for(let r=0;r<=10-o;r++){const n=[];let i=!0;for(let s=0;s<u;s++){for(let u=0;u<o;u++){const o=a(e+s,r+u);if(t.has(o)){i=!1;break}n.push(o)}if(!i)break}i&&s.push(n)}if(0===s.length){console.warn("No space left for matrix "+(i+1));continue}const c=s[Math.floor(Math.random()*s.length)];c.forEach((e=>{t.add(e),r=r.filter((r=>r!==e))})),i++,n["slot-"+i]={cells:c,width:o,height:u}}return n}const gF=(e,r)=>{const t=document.getElementById(Ze),n=Er(t);e.style.transform="translate(0,0)";const i=r.getBoundingClientRect(),a=e.getBoundingClientRect(),o=(i.left+i.width/2-(a.left+a.width/2))/n,u=(i.top+i.height/2-(a.top+a.height/2))/n,s=e.getAttribute("rows")?parseInt(e.getAttribute("rows")):1,c=e.getAttribute("cols")?parseInt(e.getAttribute("cols")):1,l=parseInt(r.style.width);if(1===s||1===c)return s===c?void(e.style.transform=`translate(${o}px, ${u}px)`):void(s>c?10===s?e.style.transform=`translate(${o+(4*l+l/2)}px, ${u}px)`:5===s?e.style.transform=`translate(${o+2*l}px, ${u}px)`:2===s&&(e.style.transform=`translate(${o+l/2}px, ${u}px)`):s<c&&(10===c?e.style.transform=`translate(${o}px, ${u+4*l+.2*l+l/2}px)`:5===c&&(e.style.transform=`translate(${o}px, ${u+2*l+.0921*l}px)`)));if(s===c)return 2===s?void(e.style.transform=`translate(${o+l/2}px, ${u+l/2+4}px)`):void(e.style.transform=`translate(${o+l}px, ${u+l+4}px)`);if(3===s){if(2===c)return void(e.style.transform=`translate(${o+l}px, ${u+l/2+4}px)`);if(1===c)return void(e.style.transform=`translate(${o+l}px, ${u}px)`)}if(2===s){if(3===c)return void(e.style.transform=`translate(${o+l/2}px, ${u+l+4}px)`);if(1===c)return void(e.style.transform=`translate(${o+l/2}px, ${u}px)`)}};function xF(e){const r=Array.from({length:10},((r,t)=>e+1+10*t)),t=r[Math.floor(6*Math.random())];return Array.from({length:5},((e,r)=>t+10*r))}function wF(e=16){const r=[],t=new Set;function n(e,r){return 10*(e-1)+r}for(;r.length<e;){const e=Math.floor(9*Math.random())+1,i=Math.floor(9*Math.random())+1,a=[n(e,i),n(e,i+1),n(e+1,i),n(e+1,i+1)];a.some((e=>t.has(e)))||(a.forEach((e=>t.add(e))),r.push(a))}return r}function DF(e=16){const r=[],t=new Set;function n(e,r){return 10*(e-1)+r}for(;r.length<e;){const e=Math.floor(9*Math.random())+1,i=Math.floor(10*Math.random())+1,a=n(e,i),o=n(e+1,i);t.has(a)||t.has(o)||(r.push([a,o]),t.add(a),t.add(o))}return r}class NF{constructor(){this.startTime=0,this.elapsedTime=0,this.intervalId=null}static getI(e){return NF.instance||(NF.instance=new NF),e&&(NF.instance.onTick=e),NF.instance}start(){this.intervalId||(this.startTime=Date.now()-this.elapsedTime,this.intervalId=window.setInterval((()=>{var e;this.elapsedTime=Date.now()-this.startTime,null===(e=this.onTick)||void 0===e||e.call(this,this.elapsedTime)}),1e3))}pause(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null,this.elapsedTime=Date.now()-this.startTime)}resume(){this.intervalId||this.start()}stop(){var e;this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.startTime=0,this.elapsedTime=0,null===(e=this.onTick)||void 0===e||e.call(this,0)}getElapsed(){return this.intervalId?Date.now()-this.startTime:this.elapsedTime}}let AF=[];const MF=new ur;function CF(){const e={};return document.querySelectorAll(`[${Ve}]`).forEach((r=>{var t,n,i;const a=r.getAttribute(Ve);if(!a)return;const o=document.getElementById(a);if(!o)return;const u=null!==(t=o.getAttribute("tab-index"))&&void 0!==t?t:a;e[u]||(e[u]=[]);const s=null!==(i=null!==(n=r.getAttribute("value"))&&void 0!==n?n:r.value)&&void 0!==i?i:"";e[u].push(s)})),e}function EF(e){return Object.keys(e).sort(((e,r)=>parseInt(e)-parseInt(r))).reduce(((r,t)=>{const n=e[t];return r.push(n.length>1?`(${n.join("|")})`:n[0]),r}),[])}function SF(e,r,t){return(e||"")+(r?" "+r:"")+(t?" "+t:"")}const FF=new Set(["revealImageValue","scrollCellAfterEquationSolved","alignMatch","removeClone","speak","fill-slide","nextBtn","prevBtn","stop","sleep","avatarAnimate","cellBorderAnimate","vibrate","highlightStarsAndDisapper","boxAnimationOneByOne","questionBoxAnimate","slideAnimation","showBalanceSymbol","hideBalanceSymbol","sumTogetherAnimation","addText","disableType","updateCountBlender","updateCalculatorAnswer"]),BF=async(e,r)=>{const t=document.getElementById(Ze);if(!t)return void setTimeout((()=>BF(e,r)),500);const n=e.getAttribute("onEntry"),i="false"!==t.getAttribute("canplay");if(await qF(n,e,void 0,{visualOnly:!i}),"true"===e.getAttribute("move")&&function(e){var r;const t=e;null===(r=t.__lidoMoveCleanup)||void 0===r||r.call(t);const n=(e=>{var r;return null!==(r=e.closest("lido-container"))&&void 0!==r?r:document.getElementById(Ze)})(e);if(!n)return;let i=!1,a=!1,o=0,u=0,s=0,c=0;const l=r=>{if("false"!==n.getAttribute("canplay"))return;const t=r instanceof MouseEvent?r:r.touches[0];if(!t)return;const l=window.getComputedStyle(e);"static"===l.position&&(e.style.position="absolute"),i=!0,a=!1,o=t.clientX,u=t.clientY,s=ut(e.style.left||l.left,e.offsetLeft),c=ut(e.style.top||l.top,e.offsetTop),e.style.cursor="grabbing",e.style.transition="none",e.style.zIndex=e.style.zIndex||e.getAttribute("z")||"1",document.addEventListener("mousemove",f),document.addEventListener("mouseup",d),document.addEventListener("touchmove",f,{passive:!1}),document.addEventListener("touchend",d)},f=r=>{if(!i)return;r.cancelable&&r.preventDefault();const t=r instanceof MouseEvent?r:r.touches[0];if(!t)return;a=!0;const l=(e=>{const r=window.getComputedStyle(e).transform;return r&&"none"!==r&&new DOMMatrixReadOnly(r).a||1})(n),f=c+(t.clientY-u)/l;e.style.left=s+(t.clientX-o)/l+"px",e.style.top=f+"px"},m=()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",d),document.removeEventListener("touchmove",f),document.removeEventListener("touchend",d)},d=()=>{i&&(i=!1,m(),e.style.cursor="move",a&&(e.setAttribute("x",e.style.left),e.setAttribute("y",e.style.top)))},p=e=>{a&&(e.preventDefault(),e.stopPropagation(),a=!1)},h=()=>{i=!1,m(),e.removeEventListener("mousedown",l),e.removeEventListener("touchstart",l),e.removeEventListener("click",p,!0),e.removeEventListener(Ye,h),t.__lidoMoveCleanup===h&&delete t.__lidoMoveCleanup};t.__lidoMoveCleanup=h,e.style.cursor="move",e.style.touchAction="none",e.addEventListener("mousedown",l),e.addEventListener("touchstart",l),e.addEventListener("click",p,!0),e.addEventListener(Ye,h)}(e),i||"click"!==r||$t(e),!i)return;const a=`${r||""}:${i}`;if(e.__lidoInitializationKey!==a){switch(e.__lidoInitializationKey=a,r){case"drag":!function(e){var r;const t=e;null===(r=t.__lidoDragCleanup)||void 0===r||r.call(t);let n=!1,i=!1,a=0,o=0,u=0,s=0,c=null,l=null,f=!1,m=null,d=0,p=0,h=!1,v=!1,y=1,b=1,g=0,x=0,w=0,D=0,N=null,A=!1;const M=document.getElementById(Ze);if(!M)return void console.error('Container with ID "container" not found.');if("false"===M.getAttribute("canplay"))return;let C;rB(e,"drag");const E=()=>{const e=window.getComputedStyle(M).transform,r=e.match(/matrix3d\(([^)]+)\)/),t=e.match(/matrix\(([^)]+)\)/);if(r){const e=r[1].split(",").map((e=>parseFloat(e.trim())));return{scaleX:Math.sqrt(e[0]**2+e[1]**2)||1,scaleY:Math.sqrt(e[4]**2+e[5]**2)||1}}if(t){const e=t[1].split(",").map((e=>parseFloat(e.trim())));return{scaleX:Math.sqrt(e[0]**2+e[1]**2)||1,scaleY:Math.sqrt(e[2]**2+e[3]**2)||1}}return{scaleX:1,scaleY:1}},S=()=>{if(A){const{scaleX:e,scaleY:r}=E();y=e,b=r}},F=r=>{var t,m;if(M&&"true"===M.getAttribute("game-completed"))return;if(C=e.style.transform,Sr)return void(n=!1);if(Wr.getI().stop(),$r(e),n=!0,i=!0,r instanceof MouseEvent)a=r.clientX,o=r.clientY,N=null;else{a=r.touches[0].clientX,o=r.touches[0].clientY,A=!0,N=e.getBoundingClientRect(),g=a-N.left,x=o-N.top,w=N.left,D=N.top;const{scaleX:t,scaleY:n}=E();y=t,b=n,e.style.willChange="transform",window.addEventListener("resize",S)}if(e.style.opacity="1",e.style.cursor="grabbing",(null===(t=e.getAttribute("dropAttr"))||void 0===t?void 0:t.toLowerCase())===ar.Diagonal){const r=window.getComputedStyle(e),t=N||e.getBoundingClientRect();c||(c=e.cloneNode(!0),c.style.left=t.left+"px",c.style.top=t.top+"px",c.style.width=t.width+"px",c.style.height=t.height+"px",c.style.transform=r.transform,c.style.zIndex="0",c.setAttribute("visible","true"),c.classList.add("cloned-element"),document.body.appendChild(c))}if((null===(m=e.getAttribute("dropAttr"))||void 0===m?void 0:m.toLowerCase())===ar.InfiniteDrop){const r=e.querySelector("img"),t=null==r?void 0:r.getAttribute("src"),n=window.getComputedStyle(e),i=N||e.getBoundingClientRect();if(l||(l=e.cloneNode(!1),l.setAttribute("src",t),l.setAttribute("value",e.getAttribute("value")),l.setAttribute("visible","true"),l.style.left=i.left+"px",l.style.top=i.top+"px",l.style.width=i.width+"px",l.style.height=i.height+"px",l.style.transform=n.transform,l.style.position="absolute",l.style.zIndex="0",l.style.pointerEvents="",e.style.zIndex="100",document.body.appendChild(l)),e.getAttribute("droppedelement")){const r=e.getAttribute("droppedelement");document.querySelectorAll(`body > [droppedelement="${r}"]`).forEach((e=>e.remove()))}}const d=window.getComputedStyle(e).transform;if("none"!==d){const e=d.match(/matrix\(([^)]+)\)/);if(e){const r=e[1].split(", ");u=parseFloat(r[4]),s=parseFloat(r[5])}}else u=0,s=0;f&&(M.getBoundingClientRect(),e.getBoundingClientRect()),document.addEventListener("mousemove",k),document.addEventListener("mouseup",z),document.addEventListener("touchmove",k),document.addEventListener("touchend",z)},B=new MutationObserver((r=>{for(const t of r)"attributes"===t.type&&"style"===t.attributeName&&(M.getBoundingClientRect(),e.getBoundingClientRect()),"childList"===t.type&&t.removedNodes.length>0&&t.addedNodes.length>0&&(f=!0)}));B.observe(M,{childList:!0,attributes:!0,attributeFilter:["style"]});const q=(e,r)=>{e.style.opacity!==r&&(e.style.opacity=r)},T=()=>{if(m=null,!n||!h)return;h=!1;const r=v;if(Sr)return n=!1,void(v=!1);if(e.style.transition="none",!v){const r=cB();e.style.transform=`translate(${u+(d-a)/r}px, ${s+(p-o)/r}px)`}if(v=!1,r)return;let t=Br(e,"drop");const i=document.querySelectorAll("[type='drop']"),c=CF(),l=Object.keys(c).map(Number);i.forEach((r=>{var n;l.includes(JSON.parse(r.getAttribute("tab-index")))?((null===(n=e.getAttribute("dropAttr"))||void 0===n?void 0:n.toLowerCase())===ar.Diagonal||Mr(M)||r&&q(r,"0.3"),r!==t&&q(r,"1")):r&&q(r,"1")})),t&&("lido-text"===t.tagName.toLowerCase()?q(t,"0.3"):document.getElementById("unitsDrop")&&document.getElementById("tensDrop")&&document.getElementById("hundredsDrop")||q(t,"0.3"))},k=r=>{if(n)if(Sr)n=!1;else{if(r instanceof MouseEvent)v=!1,d=r.clientX,p=r.clientY;else{const e=r.touches[0];if(!e)return;d=e.clientX,p=e.clientY}r instanceof MouseEvent||(e.style.transition="none",e.style.transform=`translate3d(${u+(d-g-w)/y}px, ${s+(p-x-D)/b}px, 0)`,v=!0),i=!1,r instanceof MouseEvent&&(h=!0,null===m&&(m=requestAnimationFrame(T)))}};let O=null;const I=()=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",z),document.removeEventListener("touchmove",k),document.removeEventListener("touchend",z)},z=()=>{var r,t;if(null!==m&&(cancelAnimationFrame(m),T()),n=!1,A=!1,e.style.willChange="",window.removeEventListener("resize",S),I(),i)return c&&(c.remove(),c=null),void(e.style.opacity="1");e.style.opacity="",e.style.cursor="move";const a=document.querySelectorAll("[type='drop']"),o=CF(),u=Object.keys(o).map(Number);a.forEach((r=>{var t;u.includes(JSON.parse(r.getAttribute("tab-index")))?(null===(t=e.getAttribute("dropAttr"))||void 0===t?void 0:t.toLowerCase())!==ar.Diagonal&&q(r,"1"):r&&q(r,"1")}));let s=Br(e,"drop");if(s)e.style.pointerEvents="none",s.style.pointerEvents="none",s.id===e.getAttribute("drop-to")?e.style.transform=C:kr(e,s),Mr(M)&&e&&s&&(document.querySelectorAll("*").forEach((e=>{$r(e)})),s.classList.add("highlight-element")),qF("this.updateCountBlender='true'",M),setTimeout((()=>{e.style.pointerEvents="",s.style.pointerEvents=""}),1e3),(null===(r=e.getAttribute("dropAttr"))||void 0===r?void 0:r.toLowerCase())===ar.Diagonal&&(s?e&&(e.classList.add("diagonal-drop"),s.classList.add("diagonal-target"),O=s):(O&&(O.classList.remove("diagonal-target"),O=null),null==e||e.classList.remove("diagonal-drop"),e.style.transform="translate(0, 0)",c&&(c.remove(),c=null))),(null===(t=e.getAttribute("dropAttr"))||void 0===t?void 0:t.toLowerCase())===ar.InfiniteDrop&&(s&&(s.style.opacity="0"),e.getAttribute("value")&&e.setAttribute("droppedElement",e.getAttribute("value")+"-dropped"));else{M.getAttribute(Ie);const r=JSON.stringify(CF()),t=CF();JSON.stringify(t);const n=Cr();Tr(e,0,n,null,r)}},j=()=>{if(i){if(M&&"true"===M.getAttribute("game-completed"))return;Ir(e,"drag")}},R=()=>{n=!1,A=!1,e.style.willChange="",window.removeEventListener("resize",S),null!==m&&(cancelAnimationFrame(m),m=null),h=!1,v=!1,B.disconnect(),I(),e.removeEventListener("mousedown",F),e.removeEventListener("touchstart",F),e.removeEventListener("click",j),e.removeEventListener(Ye,R),null==c||c.remove(),c=null,t.__lidoDragCleanup===R&&delete t.__lidoDragCleanup};t.__lidoDragCleanup=R,e.style.cursor="move",e.style.transform="translate(0, 0)",e.classList.add("drag-element"),e.addEventListener("mousedown",F),e.addEventListener("touchstart",F),e.addEventListener("click",j),e.addEventListener(Ye,R)}(e);break;case"click":!function(e){rB(e,"click");const r=document.getElementById(Ze);"false"!==r.getAttribute("canplay")&&("bubbleType"===(null==r?void 0:r.getAttribute("template-id"))&&null!==e.closest("lido-keyboard")||(e.style.cursor="pointer",e?(e.addEventListener("click",(async()=>{var t;if(e===r)return;if("true"===r.getAttribute("game-completed"))return;const n=e.getAttribute("id");if("lido-arrow-left"===n||"lido-arrow-right"===n)return;const i=e.getAttribute("audio"),a=i&&i.trim().length>0;a&&Wr.getI().stop();const o=r.objective.split(","),u=document.querySelector("#lido-checkButton"),s="true"===r.getAttribute("show-check");if("lido-checkButton"==e.getAttribute("id"))return u.classList.add("lido-disable-check-button"),void await JF();if(0===r.objective.length)return;const c=e.classList.contains("lido-element-selected");let l=JSON.parse(null!==(t=r.getAttribute(Ie))&&void 0!==t?t:"[]");if(1===o.length){r.setAttribute(Ie,JSON.stringify([e.value]));const t=o.includes(e.value);if(gr(e,t),t||"false"===r.getAttribute("is-continue-on-correct")){const r=e.getAttribute("onCorrect");await qF(r,e)}else{const r=e.getAttribute("onInCorrect");await qF(r,e)}return _r(),void _F()}if(s&&u.classList.remove("lido-disable-check-button"),c){e.classList.remove("lido-element-selected"),qF(e.getAttribute("onEntry"),e),l=l.filter((r=>r!=e.value)),r.setAttribute(Ie,JSON.stringify([e.value]));let t=CF();const n=e.value,i=Object.keys(t).find((e=>t[e].includes(n)));if(i){t[i]=t[i].filter((e=>e!==n)),0===t[i].length&&delete t[i];const e=Object.keys(t).sort(((e,r)=>parseInt(e)-parseInt(r))).reduce(((e,r)=>e.concat(t[r])),[]);r.setAttribute(Ie,JSON.stringify(e))}s&&0===l.length&&u.classList.add("lido-disable-check-button")}else{{e.classList.add("lido-element-selected");const t=e.value,n=Object.keys(o).find((e=>o[e]===t));let i=CF();n?i[n]=[t]:i[o.length+l.length]=[t];const u=Object.keys(i).sort(((e,r)=>parseInt(e)-parseInt(r))).reduce(((e,r)=>e.concat(i[r])),[]);r.setAttribute(Ie,JSON.stringify(u));const s=o.includes(e.value);if(gr(e,s),a&&Wr.getI().stop(),s){const r=e.getAttribute("onCorrect");await qF(r,e)}else{const r=e.getAttribute("onInCorrect");await qF(r,e)}jF(s)}null!==e.closest("#lidoCalculator")||s||IF(o)!==IF(l)||JF()}})),e.addEventListener("pointerdown",(()=>{"clickable"===e.getAttribute("animation")&&(e.classList.add("removeShadow"),e.style.top="40px",e.style.position="relative")})),e.addEventListener("pointerup",(()=>{"clickable"===e.getAttribute("animation")&&setTimeout((()=>{e.classList.remove("removeShadow"),e.style.top="0px",e.style.position="relative"}),50)})),$t(e)):console.error("No element provided.")))}(e);break;case"drop":!function(e){e.classList.add("drop-element"),CF(),e.getAttribute("tab-index"),e.onclick=()=>{Ir(e,"drop")},rB(e,"drop"),Or(e)}(e);break;case"slide":!function(e){var r;const t=e;null===(r=t.__lidoSlideCleanup)||void 0===r||r.call(t);let n,i,a,o=!1,u=!1,s=0,c=0,l=0,f=0;e.classList.add("drag-element");const m=e.parentElement;if(!m)return void console.error("Parent element not found.");const d=document.getElementById(Ze);if("false"===d.getAttribute("canplay"))return;(e=>{const r=Array.from(e.querySelectorAll("[type='slide']")),t=nt(e,r);e.setAttribute(Ie,JSON.stringify(t))})(d);const p=r=>{const t=d.getAttribute("template-id");if(("arrangeLetters"===t||"reorder"===t)&&"true"===d.getAttribute("game-completed"))return;$r(e),u=!0,n=e.getBoundingClientRect(),i=n.left,a=n.top,r instanceof MouseEvent?(s=r.clientX,c=r.clientY):(s=r.touches[0].clientX,c=r.touches[0].clientY),e.style.opacity="0.8",e.style.cursor="grabbing";const o=window.getComputedStyle(e).transform;if("none"!==o){const e=o.match(/matrix\(([^)]+)\)/);if(e){const r=e[1].split(", ");l=parseFloat(r[4]),f=parseFloat(r[5])}}else l=0,f=0;m.getBoundingClientRect(),e.getBoundingClientRect(),document.addEventListener("mousemove",v),document.addEventListener("mouseup",b),document.addEventListener("touchmove",v),document.addEventListener("touchend",b)},h=new MutationObserver((r=>{for(const t of r)"attributes"===t.type&&"style"===t.attributeName&&(m.getBoundingClientRect(),e.getBoundingClientRect())}));h.observe(m,{attributes:!0,attributeFilter:["style"]});const v=r=>{if(!u)return;const t=Er(m);let n=0,d=0;r instanceof MouseEvent?(n=(r.clientX-s)/t,d=(r.clientY-c)/t):(n=(r.touches[0].clientX-s)/t,d=(r.touches[0].clientY-c)/t);const p=1/cB(),h=l+n*p,v=f+d*p,y=m.getBoundingClientRect(),b=e.getBoundingClientRect(),g=e.style.transform.match(/-?\d+(\.\d+)?/g).map(Number),x=b.left/t-g[0],w=b.top-g[1],D=y.top-w,N=y.bottom-(b.bottom-g[1]);e.style.transform=`translate(${h+x<=y.left?y.left-x:Math.min(h,y.right-(b.right/t-g[0]))}px, ${v+w<=y.top?D:Math.min(v,N)}px)`;let A=Br(e,"slide");if(A&&A!=e){u=!1;const t=e.parentElement,n=A.parentElement,m=A.getBoundingClientRect(),d=document.getElementById(Ze),p=Er(d),h=(i+b.width/2-(m.left+m.width/2))/p,v=(a+b.height/2-(m.top+m.height/2))/p;if(A.style.transition="transform 0.3s ease",e.style.transition="transform 0.3s ease",t&&n){const i=document.createComment("element-placeholder"),a=document.createComment("overlapped-placeholder");A.style.transform=`translate(${h}px, ${v}px)`,e.style.transform=`translate(${-h}px, ${-v}px)`,setTimeout((()=>{t.replaceChild(i,e),n.replaceChild(a,A),t.replaceChild(A,i),n.replaceChild(e,a),A.style.transform="translate(0, 0)",A.style.transition="",e.style.transform="translate(0, 0)",e.style.transition=""}),300),s=r instanceof MouseEvent?r.clientX:r.touches[0].clientX,c=r instanceof MouseEvent?r.clientY:r.touches[0].clientY,l=0,f=0,o=!0}}},y=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",b),document.removeEventListener("touchmove",v),document.removeEventListener("touchend",b)},b=()=>{u=!1,y(),e.style.opacity="",e.style.cursor="move",e.style.transform="translate(0, 0)",setTimeout((()=>{o&&(at(e),o=!1)}),300)},g=()=>{u=!1,h.disconnect(),y(),e.removeEventListener("mousedown",p),e.removeEventListener("touchstart",p),e.removeEventListener(Ye,g),t.__lidoSlideCleanup===g&&delete t.__lidoSlideCleanup};t.__lidoSlideCleanup=g,e.style.cursor="move",e.style.transform="translate(0, 0)",e.addEventListener("mousedown",p),e.addEventListener("touchstart",p),e.addEventListener(Ye,g)}(e);break;case"word":case"option":!function(e){let r=!1,t=!1,n=0,i=0,a=0,o=0;const u=document.getElementById(Ze);if(!u||"false"===u.getAttribute("canplay"))return;Array.from(e.children).forEach((e=>{e.style.pointerEvents="none"}));const s=document.querySelector('[type="blank"]'),c=e.parentElement!==s?e.parentElement:null,l=e.getAttribute("type"),f=u.querySelector('[type="optionArea"]');if(f&&(f.style.overflowY="auto"),!u)return void console.error('Container with ID "lido-container" not found.');const m=c=>{const f=Gr(c);if(!r&&(Math.abs(f.clientX-a)>5||Math.abs(f.clientY-o)>5)){if(r=!0,e.parentElement!==s&&"word"===l){const r=Vr(e);e.parentElement.insertBefore(r,e.nextElementSibling)}if("category"!==e.parentElement.getAttribute("type")&&"option"===l){const r=Vr(e);r.setAttribute("value",""+e.getAttribute("value")),r.style.visibility="hidden",e.parentElement.insertBefore(r,e.nextElementSibling)}const t=u.getBoundingClientRect(),a=function(e){const r=window.getComputedStyle(e).transform;if(r&&"none"!==r){const e=r.match(/matrix\(([^)]+)\)/);if(e)return e[1].split(",").map((e=>parseFloat(e.trim())))[0]}return 1}(u),o=(f.clientY-t.top-i)/a;e.style.left=(f.clientX-t.left-n)/a+"px",e.style.top=o+"px";const c=e.getBoundingClientRect();n=f.clientX-c.left,i=f.clientY-c.top,e.style.opacity="0.8",e.style.cursor="grabbing",e.style.position="absolute",e.style.zIndex="9999",e.style.touchAction="none",e.style.transition="none"}if(!r)return;t=!1,c.preventDefault();const m=u.getBoundingClientRect(),d=cB(),p=(f.clientY-m.top-i)/d;let h;if(e.style.left=(f.clientX-m.left-n)/d+"px",e.style.top=p+"px","option"===l)h=Zr(e,"option")||Zr(e,"dummy");else if(h=Zr(e,"word")||Zr(e,"dummy"),h&&h.parentElement!==document.querySelector('[type="blank"]'))return;h&&"dummy"===h.getAttribute("type")||null!==Jr&&Jr===h||(function(e,r){var t,n;if(e===r)return;if(r&&"option"===r.getAttribute("type")&&"category"!==r.parentElement.getAttribute("type"))return;if("word"===e.getAttribute("type")&&!Zr(e,"blank"))return;if("option"===e.getAttribute("type")&&!Zr(e,"category"))return;const i=document.querySelector('[type="blank"]'),a=document.querySelector('[type="dummy"]');if(a)if(r)null===(t=r.parentNode)||void 0===t||t.insertBefore(a,r);else{const r=Zr(e,"category");r?r.appendChild(a):i.appendChild(a)}else{const t=Vr(e);t.style.visibility="hidden",t.setAttribute("type","dummy");const a=`\n @keyframes widthIncrease {\n 0% { width: 0px; height: 0px; }\n 100% { width: ${e.offsetWidth}px; height: ${e.offsetHeight}px;}\n }\n `;if(r)null===(n=r.parentNode)||void 0===n||n.insertBefore(t,r);else{const r=Zr(e,"category");r?r.appendChild(t):i.appendChild(t)}const o=document.styleSheets[0];o.insertRule(a,o.cssRules.length),t.style.animation="widthIncrease 0.5s",t.addEventListener("animationend",(()=>{t.style.width=e.offsetWidth+"px",t.style.height=e.offsetHeight+"px"}))}}(e,h),Jr=h)},d=()=>{r=!1,document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",d),document.removeEventListener("touchmove",m),document.removeEventListener("touchend",d);const n=document.querySelector('[type="dummy"]');if(t)p(e);else if("option"!==l){if(Zr(e,"blank")&&n&&n.replaceWith(e),c){const r=Array.from(c.children);(function(e,r){const t=e.getBoundingClientRect(),n=r.getBoundingClientRect();return!(t.right<n.left||t.left>n.right||t.bottom<n.top||t.top>n.bottom)}(e,c)||e.parentElement===c)&&r.forEach((r=>{r!==e&&r.getAttribute("value")===e.getAttribute("value")&&r.replaceWith(e)}))}Hr(e),Jr=null,Yr(s,e)}else{const r=Zr(e,"category"),t=Array.from(u.querySelectorAll(`[value="${e.getAttribute("value")}"]`)).find((r=>r!==e&&"DIV"===r.tagName));if(r){if(n&&(n.replaceWith(e),r.parentElement.classList.add("highlight-element"),u.querySelectorAll('[type="category"]').forEach((e=>{e!==r&&e.parentElement.classList.remove("highlight-element")})),Kr(e,r)),t){const e=document.styleSheets[0];e.insertRule(`\n @keyframes widthDecrease {\n 0% { width: ${t.offsetWidth}px; height: ${t.offsetHeight}px; }\n 100% { width: 0px; height: 0px;}\n }\n `,e.cssRules.length),t.style.animation="widthDecrease 0.5s",t.addEventListener("animationend",(()=>{t.remove()}))}Hr(e)}else if("category"!==e.parentElement.type)qr(e,t,u),setTimeout((()=>{t.replaceWith(e),Hr(e)}),500);else{const r=e.parentElement,t=CF(),i=r.getAttribute("tab-index"),a=e.value;if(t[i]){t[i]=t[i].filter((e=>e!==a));const e=EF(t);u.setAttribute(Ie,JSON.stringify(e))}f.scrollTo({top:f.scrollHeight,behavior:"smooth"}),f.appendChild(e),e.classList.remove("dropped"),e.classList.remove("category-dropped-onCorrect"),e.classList.remove("category-dropped-onInCorrect"),e.removeAttribute("drop-to"),n&&n.remove(),Hr(e)}}},p=e=>{const r=document.getElementById(Ze);if("false"!==r.getAttribute("canplay")){if("option"===l){const t=r.querySelectorAll('[type="category"]');let n=Array.from(t).find((e=>e.parentElement.className.includes("highlight-element")));if(n||(n=t[0]),"category"===e.parentElement.getAttribute("type")){const r=CF(),t=n.getAttribute("tab-index"),i=e.value;r[t]&&(r[t]=r[t].filter((e=>e!==i)));const a=Vr(e);return f.appendChild(a),f.scrollTo({top:f.scrollHeight,behavior:"smooth"}),e.style.position="absolute",qF("this.alignMatch='true'",a,e),void setTimeout((()=>{Hr(e),a.replaceWith(e),e.classList.remove("dropped"),e.classList.remove("category-dropped-onCorrect"),e.classList.remove("category-dropped-onInCorrect"),e.removeAttribute("drop-to")}),100)}{const r=Vr(e);return n.appendChild(r),e.style.position="absolute",qF("this.alignMatch=true",r,e),void setTimeout((()=>{r.replaceWith(e),Hr(e),Kr(e,n),e.style.transform="translate(0,0)",e.style.marginBottom="10px"}),100)}}if("word"===l&&e.parentElement===c){const r=Vr(e);return r.style.visibility="hidden",s.appendChild(r),qF("this.alignMatch=true",r,e),void setTimeout((()=>{const t=Vr(e);e.parentElement.insertBefore(t,e.nextElementSibling),r.replaceWith(e),e.style.transform="translate(0,0)",Yr(s,e)}),500)}{const r=Array.from(c.children).find((r=>r.getAttribute("value")===e.getAttribute("value")));qF("this.alignMatch=true",r,e),setTimeout((()=>{r.replaceWith(e),e.style.transform="translate(0,0)"}),500)}}};e.style.cursor="move",e.classList.add("drag-element"),e.addEventListener("pointerdown",(e=>{if(e.target.closest(".lido-speak-icon"))return;t=!0,r=!1;const n=Gr(e);a=n.clientX,o=n.clientY,document.addEventListener("mousemove",m),document.addEventListener("mouseup",d),document.addEventListener("touchmove",m,{passive:!1}),document.addEventListener("touchend",d)}))}(e);break;case"optionArea":!function(e){Array.from(e.children).forEach((e=>{e.classList.add("drag-element")}))}(e);break;case"checkerBlock":!function(e){const r=document.querySelector(Ze);if(!r)return;const t=e;((e,r)=>{const t=r.querySelector(".slot").style.width,n=e.querySelectorAll('lido-math-matrix[type="drop"]');e.querySelectorAll('lido-math-matrix[type="drag"]').forEach((e=>{Array.from(e.querySelectorAll(".slot")).forEach((e=>{const r=e;r.parentElement.style.width=t,r.style.width=t,r.style.height=t}))})),n.forEach((e=>{Array.from(e.querySelectorAll(".slot")).forEach((e=>{const r=e;r.parentElement.style.width=t,r.style.width=t,r.style.height=t}))}))})(r,t),((e,r)=>{const t=r.querySelectorAll(".slot"),n=e.querySelectorAll('lido-math-matrix[type="drop"]'),i=e.querySelectorAll('lido-math-matrix[type="drag"]');let a=1;for(let r=0;r<n.length;r++){const o=n[r],u=o.getAttribute("rows")?parseInt(o.getAttribute("rows")):1,s=o.getAttribute("cols")?parseInt(o.getAttribute("cols")):1;if(1===u||1===s){if(u===s){const e=Array.from({length:100},((e,r)=>r+1)).sort((()=>Math.random()-.5)).slice(0,10);n.forEach(((r,n)=>{const a=t[e[n]];a&&(gF(r,a),i[n].setAttribute("text",""+(e[n]+1)))}))}if(2===u&&1===s){const e=DF(10);n.forEach(((r,n)=>{gF(r,t[e[n][0]-1])})),i.forEach(((r,t)=>{r.setAttribute("text",""+e[t])}));break}if(5===u){const e=xF(r),n=t[e[0]-1];i[r].setAttribute("text",""+e),gF(o,n)}if(10===u){const e=t[a];i[r].setAttribute("text",""+Array.from({length:10},((e,r)=>a+1+10*r))),gF(o,e),a+=2}else if(10===s){const e=t[a-1+10];i[r].setAttribute("text",""+Array.from({length:10},((e,r)=>r+10+a))),gF(o,e),a+=20}}else{if(3===u||3===s){const r=bF(e),a=Object.keys(r).map((e=>r[e].cells));i.forEach(((e,r)=>{e&&e.setAttribute("text",""+a[r])})),n.forEach(((e,n)=>{gF(e,t[r["slot-"+(n+1)].cells[0]-1])}));break}if((2===u||2===s)&&u===s){const e=wF(10);n.forEach(((r,n)=>{gF(r,t[e[n][0]-1])})),i.forEach(((r,t)=>{r.setAttribute("text",""+e[t])}));break}}}})(r,t)}(e)}!function(e){if(!e)return;const r=e.getAttribute("onTouch");let t=null,n=!1;e.addEventListener("pointerdown",(r=>{r.stopPropagation(),n=!1,t=setTimeout((()=>{(async()=>{const r=document.getElementById(Ze);if(e===r)return;const t=e.hasAttribute("disable-speak")||e.hasAttribute("disableSpeak");if(n=!0,Fr(!0),!t)return await Wr.getI().play(e),void Fr(!1);"true"===e.getAttribute("disable-speak")||e.hasAttribute("disable-speak")&&"false"!==e.getAttribute("disable-speak")||(await Wr.getI().play(e),Fr(!1))})()}),1e3)})),e.addEventListener("pointerup",(async()=>{clearTimeout(t),!n&&r?await qF(r,e):r||["category","option"].includes(e.getAttribute("type")||"")&&e.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0})),Fr(!1)})),e.addEventListener("pointerleave",(()=>{clearTimeout(t)}))}(e)}},qF=async(e,r,t,n={})=>{var i,a,o,u,s,c,l,f;const m=kF(e);for(let e=0;e<m.length;e++){const d=m[e];if(n.visualOnly&&FF.has(d.action))continue;const p=document.querySelector(d.actor),h="this"===d.actor?r:"element"===d.actor?t:p||document.getElementById(d.actor);if(h)switch(d.action){case"transform":{const e=window.getComputedStyle(h).transform;h.style.transform="none"!==e?`${e} ${d.value}`:d.value;break}case"revealImageValue":h&&pB(h);break;case"scrollCellAfterEquationSolved":h&&yF();break;case"alignMatch":{const e=h,r=t,n=document.getElementById(Ze),a=Er(n);r.style.transform="translate(0,0)";const o=e.getBoundingClientRect(),u=r.getBoundingClientRect(),s=(o.left+o.width/2-(u.left+u.width/2))/a,c=(o.top+o.height/2-(u.top+u.height/2))/a;if(r.style.transform=(null===(i=t.getAttribute("dropAttr"))||void 0===i?void 0:i.toLowerCase())===ar.Diagonal?`translate(${s-70}px, ${c-70}px)`:`translate(${s}px, ${c}px)`,"true"===r.getAttribute("hasDummy"))return;TF(r,e);break}case"removeClone":document.querySelectorAll(d.value).forEach((e=>e.remove()));break;case"addClass":h.classList.add(d.value);break;case"removeClass":h.classList.remove(d.value);break;case"speak":{const e=(""+(d.value||"")).trim().toLowerCase();if("true"===e||"1"===e||"yes"===e)try{await Wr.getI().play(h)}catch(e){console.error("Error playing audio for speak action:",e)}break}case"fill-slide":dF(d.value);break;case"nextBtn":{const e=document.getElementById(Ze);if("false"===e.getAttribute("canplay"))return;document.querySelector("lido-balance")&&(WF=Nr(e,e.objective),WF?await qF("this.showBalanceSymbol='true'",h):await qF("this.hideBalanceSymbol='true'",h)),"true"!==e.getAttribute("is-continue-on-correct")&&(h.style.pointerEvents="none",Wr.getI().stop()),e.getAttribute("game-completed")&&"false"!==e.getAttribute("game-completed")||await JF(),h.style.pointerEvents="auto";break}case"prevBtn":ZF();break;case"stop":await Wr.getI().stop();break;case"sleep":!isNaN(Number(d.value))&&await new Promise((e=>setTimeout(e,Number(d.value))));break;case"avatarAnimate":{const e=xr.getInstance().getRiveInstance();if(e&&d.value){const r=null===(a=e.stateMachineInputs("State Machine 1"))||void 0===a?void 0:a.find((e=>e.name===d.value));r?r.fire():console.warn(`Avatar reaction input "${d.value}" was not found in State Machine 1.`)}break}case"cellBorderAnimate":{const e=d.value;e&&h&&uB(h,e);break}case"vibrate":{const e=d.value;e&&h&&await sB(h,e);break}case"highlightStarsAndDisapper":{const e=d.value;e&&h&&await vB(h,e);break}case"boxAnimationOneByOne":{const e=d.value;e&&h&&await yB(h,e);break}case"questionBoxAnimate":{const e=d.value;e&&h&&await bB(h,e);break}case"slideAnimation":it();break;case"showBalanceSymbol":{const e=document.querySelector("lido-balance");if(!e)break;const r=Number(null!==(o=e.leftVal)&&void 0!==o?o:Number(null!==(s=null===(u=e.dataset)||void 0===u?void 0:u.leftVal)&&void 0!==s?s:0)),t=Number(null!==(c=e.rightVal)&&void 0!==c?c:Number(null!==(f=null===(l=e.dataset)||void 0===l?void 0:l.rightVal)&&void 0!==f?f:0)),n=r>t?">":r<t?"<":"=";e.balanceSymbol=n,e.dataset.balanceSymbol=n,e.revealSymbol?await e.revealSymbol():e.showSymbol=!0;break}case"hideBalanceSymbol":{const e=document.querySelector("lido-balance");if(!e)break;e.hideSymbol?await e.hideSymbol():e.showSymbol=!1;break}case"sumTogetherAnimation":{const e=d.value;e&&gB(h,e);break}case"addText":{const e=d.value;e&&(h.textContent+=e);break}case"disableType":{const e=document.querySelector('[type="drag"]');e.removeAttribute("type"),e.style.pointerEvents="none";break}case"updateCountBlender":{const e=document.querySelectorAll('[type="drag"]');let r=0,t=0,n=0;e.forEach((e=>{const i=e.getAttribute("drop-to");"unitsDrop"===i&&r++,"tensDrop"===i&&t++,"hundredsDrop"===i&&n++}));const i=r,a=t,o=n,u=document.getElementById("units"),s=document.getElementById("tens"),c=document.getElementById("hundreds");u&&u.setAttribute("string",""+i),s&&s.setAttribute("string",""+a),c&&c.setAttribute("string",""+o);break}case"updateCalculatorAnswer":h&&xB(h);break;default:h.style[d.action]=d.value}}},TF=(e,r)=>{const t=document.getElementById(Ze),n=Er(t),i=e,a=t.getAttribute("drop-action")===or.Move,o=t.getAttribute("drop-action")===or.InfiniteDrop;(a||o)&&setTimeout((()=>{var t,a;e.style.transform="translate(0,0)",e.style.transition="";let u=document.createElement("div");o&&(u=function(e){const r=e.tagName.toLowerCase();if("lido-text"===r){let r=document.createElement("div");return r.innerHTML=e.outerHTML,r=r.firstChild,r.setAttribute("height",e.style.height),r.setAttribute("width",e.style.width),r.setAttribute("visible","true"),r}const t=e.cloneNode(!1);return t.style.width=e.style.width,t.style.height=e.style.height,t.style.margin=e.style.margin,t.style.opacity=e.style.opacity,t.style.transform=e.style.transform,t.style.borderRadius=e.style.borderRadius,t.setAttribute("visible","true"),t.setAttribute("data-dummy","true"),"lido-math-matrix"===r&&t.setAttribute("clickable","false"),t}(e),u.classList.remove("dropped"),u.removeAttribute("drop-to"),u.removeAttribute("drop-time"),u.style.opacity="1",e.style.width=r.style.width,e.style.height=r.style.height,e.setAttribute("hasDummy","true"),setTimeout((()=>{u.style.pointerEvents=""}),100)),u.setAttribute("id",e.getAttribute("id")),e.replaceWith(u);const s=`\n @keyframes widthDecrease {\n 0% { width: ${e.style.width}; height: ${e.style.height}; margin: ${e.style.margin}; }\n 100% { width: 0px; height: 0px; margin: 0px;}\n }\n `;if(!o){u.style.width=i.style.width,u.style.height=i.style.height,u.style.margin=i.style.margin;const e=document.styleSheets[0];e.insertRule(s,e.cssRules.length),u.style.animation="widthDecrease 0.5s",u.addEventListener("animationend",(()=>{u.style.width="0px",u.style.height="0px",u.style.margin="0px"}))}const c=window.innerHeight>window.innerWidth?"portrait":"landscape",l=r.getAttribute("dropAttr"),f=eB(l,c);if("stackcascade"===(null===(t=f)||void 0===t?void 0:t.toLowerCase())||"verticalstack"===(null===(a=f)||void 0===a?void 0:a.toLowerCase()))return r.append(e),void function(e,r,t,n){const i=e.getBoundingClientRect(),a=r.getBoundingClientRect(),o=cB();e.dataset.dropCount||(e.dataset.dropCount="0");let u=parseInt(e.childElementCount)-1;const s=i.width,c=i.height;let l,f;if("landscape"===t&&"stackcascade"===n.toLowerCase()){let r,t;"unitsDrop"===e.id?(r=i.left+.15*s,t=i.top+-.1*c):"tensDrop"===e.id?(r=i.left+.4*s,t=i.top+-.1*c):(r=i.left+.1*s,t=i.top+-.1*c),l=r+u*(.02*s),f=t+u*(.02*c)}else{let r;r="unitsDrop"===e.id?i.left+.4*s:"tensDrop"===e.id?i.left+.25*s:i.left+.16*s,l=r,f=i.top-.25*c+u*(.05*c)}r.style.width="auto",r.style.height="auto";const m=(l-a.left)/o,d=(f-a.top)/o;r.style.transition="transform .2s ease-out",r.style.transform=`translate(${m}px, ${d}px)`;const p=r.getBoundingClientRect(),h=(i.left+s/2-(p.left+p.width/2))/o,v=(i.top+c/2-(p.top+p.height/2))/o;r.style.transition="none",r.style.transform=`translate(${h}px, ${v}px)`,r.getBoundingClientRect(),requestAnimationFrame((()=>{r.style.transition="transform .2s ease-out",r.style.transform=`translate(${m}px, ${d}px)`})),e.dataset.dropCount=u+1+""}(r,e,c,f);r.parentElement.append(i),e.style.position="absolute",e.style.zIndex="1";const m=r.getBoundingClientRect(),d=e.getBoundingClientRect();e.style.transform=`translate(${(m.left+m.width/2-(d.left+d.width/2))/n}px, ${(m.top+m.height/2-(d.top+d.height/2))/n}px)`}),700)},kF=e=>{var r;const t=[];return e?((null===(r=e.split(";"))||void 0===r?void 0:r.map((e=>e.trim()))).forEach((e=>{if(e){const[r,n]=e.split("=").map((e=>e.trim())),i=r.lastIndexOf(".");if(-1!==i){const e=r.substring(0,i).trim(),a=r.substring(i+1).trim();t.push({actor:e,action:a,value:n.replace(/['"]/g,"")})}}})),t):t},OF=(e,r)=>{var t;const n=e.split(",").map((e=>e.trim()));let i=0,a=new Set;if(0==n.length)return!0;if(n.length>0&&0===r.length)return!1;for(const e of n)if(e.startsWith("(")&&e.endsWith(")")){const n=e.slice(1,-1).split("|").map((e=>e.trim())),a=null!==(t=r[i])&&void 0!==t?t:"";let o=[];if(a.startsWith("(")&&a.endsWith(")"))o=a.slice(1,-1).split("|").map((e=>e.trim()));else if(a.includes("|"))o=a.split("|").map((e=>e.trim()));else{if(""===a)return!1;o=[a.trim()]}const u=e=>e.map((e=>e.trim())).sort().join("|");if(u(n)!==u(o))return!1;i++}else if(e.includes("|")){const r=e.split("|").map((e=>e.trim()));for(const e of r)a.add(e)}else{if(i>=r.length||r[i]!==e)return!1;i++}for(;i<r.length;){if(!a.has(r[i]))return!1;a.delete(r[i]),i++}return i===r.length},IF=e=>{const r=e.split(",").map((e=>e.trim()));let t=0;for(const e of r)e.startsWith("(")&&e.endsWith(")")?e.includes("|")?t+=e.split("|").length:t+=1:t+=e.split("|").length;return t};let zF=0;const jF=(e,r)=>{null!==document.querySelector("lido-calculator")&&r!==Ke||(e?(MF.rightMoves+=1,zF=0,_r()):(MF.wrongMoves+=1,zF+=1),console.log("Right Moves : ",MF.rightMoves),console.log("Wrong Moves : ",MF.wrongMoves))},RF=()=>{const e=document.getElementById(Ze);if(null!==document.querySelector("lido-calculator")&&e&&"true"!==e.getAttribute("game-completed"))return;const r=MF.rightMoves,t=MF.wrongMoves;MF.totalRightMovesCount+=r,MF.totalWrongMovesCount+=t;let n=Math.floor(r/(r+t)*100);console.log("[Activity Score]",{rightMoves:r,wrongMoves:t,activityScore:n}),PF(n),MF.rightMoves=0,MF.wrongMoves=0};async function UF(e,r){var t,n,i;const a=document.getElementById(Ze);if(!a)return;const o="blender"===a.getAttribute("template-id"),u=!!a.querySelector("lido-balance");if(u&&a.getAttribute("drop-action")!==or.Move&&a.getAttribute("drop-action")!==or.InfiniteDrop||await qF("this.alignMatch='true'",r,e),e&&r){let i=r.value.toLowerCase().includes(e.value.toLowerCase());if(o){const e=Number(null!==(t=r.getAttribute("required-drops"))&&void 0!==t?t:0),n=document.querySelectorAll(`[drop-to="${r.id}"]`).length;i=n>0&&n<=e}if(i){"category"===r.getAttribute("type")&&(e.classList.remove("category-dropped-onInCorrect"),e.classList.add("category-dropped-onCorrect"),MF.rightMoves+=1,console.log("Right Moves : ",MF.rightMoves),console.log("Wrong Moves : ",MF.wrongMoves));const t=(null===(n=a.getAttribute("dropAttr"))||void 0===n?void 0:n.toLowerCase())===ar.EnableAnimation.toLowerCase()?"":r.getAttribute("onCorrect");!t||o||u||await qF(t,r,e),"multiplyBeeds"===a.getAttribute("template-id")&&Ur(r)}else{if("category"===r.getAttribute("type")){e.classList.remove("category-dropped-onCorrect"),e.classList.add("category-dropped-onInCorrect"),MF.wrongMoves+=1,console.log("Right Moves : ",MF.rightMoves),console.log("Wrong Moves : ",MF.wrongMoves);const r=a.querySelector('[type="optionArea"]');Array.from(a.querySelectorAll(`[value="${e.getAttribute("value")}"]`)).find((r=>r!==e&&"DIV"===r.tagName)),setTimeout((()=>{const t=document.createElement("div");t.style.width=e.offsetWidth+"px",t.style.height=e.offsetHeight+"px",r.appendChild(t);const n=e.offsetLeft,i=e.offsetTop;e.style.position="absolute",e.style.transition="",e.style.transform=`translate(${n}px, ${i}px)`,qr(e,t,a),setTimeout((()=>{t.replaceWith(e),Hr(e),e.classList.remove("category-dropped-onInCorrect"),e.classList.remove("dropped"),e.removeAttribute("drop-to")}),1e3)}),2e3)}const t=r.getAttribute("onInCorrect");!t||o||u||await qF(t,r,e)}}let s=CF();const c=EF(s);a.setAttribute(Ie,JSON.stringify(c));let l=JSON.parse(null!==(i=localStorage.getItem("lidoDragMap"))&&void 0!==i?i:"{}");const f=r.getAttribute("tab-index");l[f]||(l[f]=[]),l[f].push(e.id),document.querySelectorAll("[type='drop']").forEach((e=>{var r,t;if(Object.keys(s).map(Number).includes(JSON.parse(e.getAttribute("tab-index")))){if((null===(r=e.getAttribute("dropAttr"))||void 0===r?void 0:r.toLowerCase())!==ar.Diagonal&&(null===(t=a.getAttribute("drop-action"))||void 0===t?void 0:t.toLowerCase())!==ar.InfiniteDrop&&e){const r=a.getAttribute("appendToDropOnCompletion");e.style.opacity="true"===r?"1":"0"}}else"lido-text"===e.tagName.toLowerCase()&&(e.style.opacity="1")})),_F()}const $F=()=>{const e=new URLSearchParams(window.location.search),r=r=>{var t,n;return null!==(n=null!==(t=e.get(r.toLowerCase()))&&void 0!==t?t:e.get(r))&&void 0!==n?n:""};return{studentId:r("studentId"),studentName:r("studentName"),classId:r("classId"),schoolId:r("schoolId"),courseId:r("courseId"),courseName:r("courseName"),chapterId:r("chapterId"),chapterName:r("chapterName"),lessonId:r("lessonId"),lessonName:r("lessonName"),lang:r("lang"),end:r("end")}},PF=e=>{var r,t,n;const i=document.querySelector("lido-home");if(!i)return;const a=Number(null!==(r=i.getAttribute("index"))&&void 0!==r?r:0),o=Number(null!==(t=i.getAttribute("totalIndex"))&&void 0!==t?t:0),u=JSON.parse(null!==(n=localStorage.getItem(je))&&void 0!==n?n:"{}");u[""+a]=e;const s=Number((NF.getI().getElapsed()/1e3).toFixed(1));AF.push(s),console.log(`[Utils][Activity Time] Activity ${a+1}/${o} - Time spent: ${s}s`);const c=$F();if(function(e,r,t,n,i,a,o,u){hr(Re,Object.assign(Object.assign({currentIndex:r,totalIndex:e,score:t,rightMoves:n,wrongMoves:i,timeSpentForActivity:a},o),{gameCompleted:u})),hr(er,Object.assign(Object.assign({currentIndex:r,totalIndex:e,score:t,rightMoves:n,wrongMoves:i,timeSpentForActivity:a},o),{gameCompleted:u})),console.log(`[Activity End]Activity ${r+1}/${e} - Time Spent: ${a}`)}(o,a,e,MF.rightMoves,MF.wrongMoves,s,c,!0),localStorage.setItem(je,JSON.stringify(u)),o-1==a){const e=Object.values(u),r=e.reduce(((e,r)=>e+r),0)/e.length;MF.finalScore=Math.floor(r),console.log("Total Score : ",MF.finalScore);const t=Number(AF.reduce(((e,r)=>e+r),0).toFixed(1));console.log(`[Utils][Lesson Time] Total lesson time spent: ${t}s`),function(e,r,t,n,i,a){hr(rr,Object.assign({totalIndex:e,rightMoves:r,wrongMoves:t,finalScore:n,score:n,timeSpendForLesson:i},a)),"blank"!==$F().end&&"complete"!==$F().end&&"completed"!==$F().end&&(hr(Ue,Object.assign({totalIndex:e,rightMoves:r,wrongMoves:t,finalScore:n,score:n,timeSpendForLesson:i},a)),console.log(`[Lesson End] Lesson: ${null==a?void 0:a.lessonName} (${null==a?void 0:a.lessonId}) - Total Time Spent: ${i}`))}(o,MF.totalRightMovesCount,MF.totalWrongMovesCount,r,t,c),MF.totalRightMovesCount=0,MF.totalWrongMovesCount=0,hr(tr,{}),"blank"!==$F().end&&"complete"!==$F().end&&"completed"!==$F().end&&hr(_e,{}),localStorage.removeItem(je),AF.length=0}},LF=new WeakSet,_F=async()=>{var e,r,t;const n=document.getElementById(Ze),i=n.objective,a=null!==(e=n.getAttribute(Ie))&&void 0!==e?e:"",o=document.querySelector("#lido-checkButton");if(!a||IF(a)<IF(i))qF("this.addClass='lido-disable-check-button'",o);else if("true"==n.getAttribute("show-check"))null===(r=null==o?void 0:o.classList)||void 0===r||r.remove("lido-disable-check-button");else if(!n.getAttribute("game-completed")&&!n.querySelector("[type='slide']")&&(null===(t=n.getAttribute("dropAttr"))||void 0===t?void 0:t.toLowerCase())!==ar.EnableAnimation.toLowerCase()){if(n.querySelector("[type='category']")){if(LF.has(n))return;LF.add(n);try{await(e=>{const r=Qr.get(e);if(r)return r;const t=(async e=>{const r=e.querySelectorAll('[type="category"]'),t=Wr.getI();for(const e of Array.from(r)){const r=e.parentElement.children[0];await t.play(r);for(const r of Array.from(e.children))r.scrollIntoView({behavior:"smooth",block:"end"}),await t.play(r)}})(e).finally((()=>{Qr.delete(e)}));return Qr.set(e,t),t})(n),await JF()}finally{LF.delete(n)}return}JF()}};let WF;const JF=async()=>{var e,r;const t=document.getElementById(Ze);if(!t)return;const n=t.objective,i=t.getAttribute("equationCheck");t.getAttribute("isAllowOnlyCorrect");let a=!1;if((null==n||0===n.length)&&(i&&(a=!0),!a)){const e=t.getAttribute("onCorrect");return t.setAttribute("game-completed","true"),e&&await qF(e,t),jF(!0),PF(100),MF.totalRightMovesCount++,MF.rightMoves=0,MF.wrongMoves=0,void HF()}const o=null!==(r=JSON.parse(null!==(e=t.getAttribute(Ie))&&void 0!==e?e:"[]"))&&void 0!==r?r:[];if(i){const e=document.querySelector("lido-balance");WF=e?Nr(t,n):tB(i)}else WF=OF(n,o);if(t.querySelector("lido-balance")&&!WF){const e=Array.from(t.querySelectorAll('[type="drop"]'));if(e.filter((e=>!!t.querySelector(`[drop-to="${e.id}"]`))).length<e.length)return}if(WF){t.setAttribute("game-completed","true");const e=t.getAttribute("appendToDropOnCompletion"),r=t.getAttribute("onCorrect");if(r){if("true"===e&&(()=>{const e=document.querySelectorAll("[type='drag']"),r=document.querySelectorAll("[type='drop']");if(!e||!r)return;const t="true"===document.getElementById(Ze).getAttribute("is-allow-only-correct"),n=new Set;r.forEach((r=>{for(let i=0;i<e.length;i++){const a=e[i];if(n.has(a.id))continue;const o=a,u=r;if(!0===t){if(u.value===o.value){o.style.transform="translate(0,0)",o.style.width="stretch",o.style.padding="0",u.appendChild(o),n.add(o.id),o.style.pointerEvents="none";break}}else u.value.includes(o.value)&&(o.style.transform="translate(0,0)",o.style.width="stretch",o.style.padding="0",u.appendChild(o),n.add(o.id),o.style.pointerEvents="none")}}))})(),(t.querySelectorAll("[type='click']").length>0||"blender"===t.getAttribute("template-id"))&&jF(!0),"multiplyBeeds"===t.getAttribute("template-id")){const e=t.querySelector("#beedsText");if(!e)return;await VF(e)}await qF(r,t)}RF(),"EnableAnimation"===t.getAttribute("dropAttr")?setTimeout((()=>{HF()}),2e3):HF()}else{const e="true"===t.getAttribute("is-continue-on-correct"),r=t.getAttribute("onCorrect");if((t.querySelectorAll("[type='click']").length>0||"blender"===t.getAttribute("template-id"))&&jF(!1),e){const e=t.getAttribute("onInCorrect");await qF(e,t)}else t.setAttribute("game-completed","true"),await qF(r,t),RF(),HF()}},VF=e=>{var r;const t=(e=>{const r=e.trim();if(!r)return null;const[t,n]=r.split("="),i=(null!=t?t:"").trim();if(!i)return null;const a=i.split("+").map((e=>e.trim())).filter(Boolean);if(0===a.length)return null;const o=Number(a[0]);if(Number.isNaN(o))return null;if(!a.every((e=>Number(e)===o)))return null;const u=(null!=n?n:"").trim();let s=""===u?NaN:Number(u);return Number.isNaN(s)&&(s=a.map((e=>Number(e))).reduce(((e,r)=>Number.isNaN(r)?NaN:e+r),0)),Number.isNaN(s)?null:{value:o,count:a.length,total:s}})(null!==(r=e.textContent)&&void 0!==r?r:"");if(!t)return;const n=e.getAttribute("data-multiply-timers");n&&n.split(",").map((e=>Number(e))).filter((e=>Number.isFinite(e))).forEach((e=>clearTimeout(e))),e.removeAttribute("data-multiply-timers");const i=[];[t.value+"","X",t.count+"","=",t.total+""].forEach(((r,t)=>{const n=window.setTimeout((()=>{var n;0===t&&(e.textContent="");const i=(null!==(n=e.textContent)&&void 0!==n?n:"").trim();e.textContent=i?`${i} ${r}`:r}),1e3*(t+1));i.push(n)})),e.setAttribute("data-multiply-timers",i.join(","))},HF=()=>{Wr.getI().stop();const e=document.querySelector(".lido-home");e&&("blank"===$F().end||"complete"===$F().end||"completed"===$F().end)&&Number(e.getAttribute("index"))>=Number(e.getAttribute("totalIndex"))-1||hr($e,{})},ZF=()=>{Wr.getI().stop(),hr(Pe,{})};let GF;function XF(e){GF=e}function YF(){GF=void 0}function QF(e){const r=document.getElementById(Ze),t=null==r?void 0:r.getAttribute("baseUrl"),n=GF;if((null==e?void 0:e.startsWith("http"))||(null==e?void 0:e.startsWith("blob"))||(null==e?void 0:e.startsWith("data")))return e;if(e.startsWith("/Lido-CommonAudios/"))return e;if(n){const r=e.replace(/^\.\/?/,""),t=n[e]||n[r];if(t)return t;const i=Object.keys(n).find((e=>e===r||e.endsWith("/"+r)));if(i)return n[i]}if(!n&&t){const r=e.startsWith("/")?e.slice(1):e;return r.startsWith(t.replace(/^\/+|\/+$/g,""))?r:t.endsWith("/")?t+r:`${t}/${r}`}return D(e)}function KF(e,r,t,n){if(void 0===n)return;const i=Array.from(e.children);let a=n;r&&n<r&&(a=r),t&&n>t&&(a=t),i.forEach(((e,r)=>{r>a-1&&(e.style.display="none")}))}const eB=(e,r)=>e&&e.includes(",")?e.split(",").reduce(((e,r)=>{const[t,n]=r.split(".");return e[t.trim()]=n.trim(),e}),{})[r]||"":e,rB=(e,r)=>{const t=document.querySelectorAll("[type='drag']"),n=document.querySelectorAll("[type='drop']"),i=document.querySelectorAll("[type='click']");let a=0;if("click"===r)return i.forEach((e=>{const r=e;let t=null;if(r.getAttribute("flexible-width"))t=r;else{const e=r.children;for(let r=0;r<e.length;r++){const n=e[r];if(n.getAttribute("flexible-width")){t=n;break}}}if(t){const e=t.style.width,r=t.style.padding;t.style.width="auto",t.style.padding="0 20px";const n=t.offsetWidth;t.style.width=e,t.style.padding=r,n>a&&(a=n)}})),void i.forEach((e=>{const r=e;if(r.getAttribute("flexible-width")){if("true"===r.getAttribute("flexible-width"))return;r.style.width=a+"px"}else{const e=r.children;for(let r=0;r<e.length;r++){const t=e[r];if(t.getAttribute("flexible-width")){if("true"===t.getAttribute("flexible-width"))return;t.style.width=a+"px";break}}}}));t.forEach((r=>{var t;const n=r,i=n.style.width,o=n.style.padding;n.style.width="auto",n.style.padding="0 20px";const u=n.offsetWidth;n.style.width=i,n.style.padding=o,(null===(t=e.getAttribute("dropAttr"))||void 0===t?void 0:t.toLowerCase())!==ar.Stretch&&u>a&&(a=u)})),t.forEach((e=>{const t=e,n=t.getAttribute("flexible-width");"false"===n?t.style.width=a+"px":"true"===n&&"drag"===r&&(t.style.width="auto",t.style.padding="0 20px")})),n.forEach((e=>{const t=e,n=t.getAttribute("flexible-width");if("false"===n){const e=parseFloat(getComputedStyle(t).borderWidth);if("number"==typeof e){const r=a-2*e;return t.style.height=parseFloat(t.style.height)-2*e+"px",void(t.style.width=r+"px")}}else"true"===n&&"drag"===r&&(t.style.width="auto",t.style.padding="0 20px")}))},tB=e=>{if(!e)return;const r=e.split(",").map((e=>{var r;if(e.startsWith("$")){const t=e.substring(1),n=nB(t);return sn(n)?null==n?void 0:n.map((e=>e.getAttribute("value"))):n.getAttribute("value")||(null===(r=document.getElementById(t))||void 0===r?void 0:r.value)}return e})).join("");return GS(r)},nB=e=>{if(e.startsWith("#")){const r=e.substring(1),t=document.getElementById(r);if("drop"===t.getAttribute("type")){const e=document.querySelectorAll(`[${Ve}="${r}"]`);return e.length>0?e[0]:[]}return t}const r=document.querySelectorAll(`[${Ve}="${e}"]`);return Array.from(r).sort(((e,r)=>parseInt(e.getAttribute(He))-parseInt(r.getAttribute(He))))},iB=e=>{if(e.className.includes("lido-speak-icon"))return null;const r=document.createElement("div");r.style.width="0",r.style.height="0";const t=document.createElement("div");return r.append(t),t.classList.add("lido-speak-icon"),t.addEventListener("click",(async r=>{r.stopPropagation(),fB(!0),await Wr.getI().stop();try{await Wr.getI().play(e)}catch(e){console.error("Error playing audio or TTS:",e)}fB(!1)})),e.style.position="relative",t},aB=async e=>{let r=iB(e);if("option"===e.type){e.style.position="unset";const t=document.createElement("div");t.className=e.className,t.style.position="relative",t.style.backgroundColor="transparent",t.style.padding="0",t.style.width="100%",t.style.height="100%",Array.from(e.children).forEach((e=>{t.appendChild(e)})),t.appendChild(r),r.style.position="absolute",r=t}e.appendChild(r)},oB=async(e,r)=>{if(document.getElementById(Ze)&&r){const t=parseInt(r,10);e.style.visibility="hidden",isNaN(t)||await new Promise((r=>{setTimeout((()=>{e.style.visibility="visible",r()}),t)}))}},uB=(e,r)=>{if(!e)return;r||(r="green");const t=`${"0 0 0 6px "+r}, 0 ${.08*e.offsetHeight}px 10px rgba(0, 0, 0, 0.25)`;e.style.boxShadow=t,e.style.setProperty("box-shadow",t,"important")},sB=async(e,r)=>{if(!e)return;r||(r="horizontal-shake");const t="lido-"+r;e.classList.add(t),await new Promise((e=>setTimeout(e,600))),e.classList.remove(t)};function cB(){var e;const r=[window.innerWidth],t=[window.innerHeight];(null===(e=window.screen)||void 0===e?void 0:e.width)&&(r.push(window.screen.width),t.push(window.screen.height));const n=Math.min(...r),i=Math.min(...t),a=i>n;return Math.min(a?n/900:n/1600,a?i/1600:i/900)}let lB=!1;function fB(e){lB=e}function mB(){return lB}function dB(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const r=16*Math.random()|0;return("x"===e?r:3&r|8).toString(16)}))}const pB=e=>{if(!e)return;const r=e.getAttribute("value");if(!r)return;let t=e.querySelector(".lido-display-hiddenvalue");t||(t=document.createElement("div"),t.classList.add("lido-display-hiddenvalue"),e.style.position="relative",e.appendChild(t)),t.innerText=r},hB=(e,r)=>{if(!e)return;e.classList.add("lido-image-colorize");const t=e.querySelector("img");t&&e.style.setProperty("--mask-url",`url(${t.src})`),"red"===r?e.style.setProperty("--tint-color","#ff0000"):"green"===r?e.style.setProperty("--tint-color","#00c853"):(e.style.removeProperty("--tint-color"),e.style.removeProperty("--mask-url"))},vB=async(e,r)=>{if(!e)return;if(!r)return;const t=Array.from(e.children);for(const e of t)e.classList.add("lido-glow"),await Wr.getI().play(e),e.style.opacity="0",e.style.visibility="hidden",await new Promise((e=>setTimeout(e,300))),e.classList.remove("lido-glow")},yB=async(e,r)=>{if(!e)return;if(!r)return;const t=Array.from(e.children);if(!t)return;t.forEach((e=>{e.style.visibility="hidden"}));for(const e of t)e.style.visibility="visible",e.style.opacity="1",e.classList.add("lido-box-highlight"),await new Promise((e=>setTimeout(e,600))),e.classList.remove("lido-box-highlight");const n=document.getElementById(Ze);if(!n)return;const i=n.children[2];i&&await Wr.getI().play(i);for(const e of t){const r=e.querySelector("lido-text");r&&await Wr.getI().play(r)}},bB=async(e,r)=>{e&&r&&Array.from(e.querySelectorAll("[type='drag']")).forEach((e=>{const r=e.getAttribute("drop-to");if(r&&""!==r){e.style.transition="opacity 0.5s ease",e.style.opacity="0";const t=document.getElementById(r),n=e.getAttribute("value");n&&"?"===t.innerText.trim()&&(t.innerText=n)}}))},gB=async(e,r)=>{if(!e)return;if(!r)return;const t=Array.from(e.children)[3],n=Array.from(e.children)[4],i=Array.from(e.children)[5];if(!t||!n||!i)return;const a=Array.from(t.children),o=Array.from(n.children),u=o[0],s=o[1],c=o[2],l=o[3],f=o[4],m=e=>{e&&(e.style.visibility="visible",e.style.display="",e.style.opacity="1")},d=e=>{if(!e)return 0;const r=e.getAttribute&&(e.getAttribute("value")||e.getAttribute("string"))||e.textContent||"";return parseInt((r+"").trim(),10)||0},p=async e=>{e?(u&&(await new Promise((e=>setTimeout(e,200))),m(u)),s&&(await new Promise((e=>setTimeout(e,200))),m(s))):(c&&(await new Promise((e=>setTimeout(e,200))),m(c)),l&&(await new Promise((e=>setTimeout(e,300))),m(l)),i&&(await new Promise((e=>setTimeout(e,300))),m(i)),f&&(await new Promise((e=>setTimeout(e,200))),m(f)))},h=d(u),v=d(c);if("-"==("+"===(""+(s&&(s.getAttribute("string")||s.textContent||""))).trim()?"+":"-")){for(let e=0;e<Math.min(h,a.length);e++)await new Promise((e=>setTimeout(e,75))),m(a[e]);p(!0),await new Promise((e=>setTimeout(e,500)));for(let e=0;e<Math.min(v,a.length);e++)hB(a[Math.min(h,a.length)-1-e],"red"),await new Promise((e=>setTimeout(e,200)));p(!1)}else{for(let e=0;e<Math.min(h,a.length);e++)await new Promise((e=>setTimeout(e,120))),m(a[e]);p(!0),await new Promise((e=>setTimeout(e,500)));for(let e=0;e<Math.min(v,Math.max(0,a.length-h));e++){const r=h+e;a[r]&&(m(a[r]),hB(a[r],"green")),await new Promise((e=>setTimeout(e,80)))}p(!1)}},xB=e=>{if(!document.getElementById(Ze))return;const r=document.querySelector("#lidoCalculator");if(!r)return;const t=r.getAttribute("value");e.setAttribute("string",t)};export{ZF as $,Wr as A,ir as B,Ke as C,or as D,iB as E,mr as F,Gn as G,l as H,Xn as I,dB as J,je as K,Ye as L,br as M,ur as N,yr as O,fr as P,lr as Q,xr as R,Ie as S,Qe as T,cr as U,sr as V,$e as W,Pe as X,Ge as Y,mB as Z,OF as _,eB as a,XF as a0,YF as a1,fB as a2,Xe as a3,ft as a4,R as b,QF as c,P as d,tB as e,qF as f,SF as format,RF as g,D as getAssetPath,z as h,BF as i,HF as j,oB as k,KF as l,aB as m,cB as n,_r as o,Fe as p,NF as q,fF as r,ke as render,jF as s,N as setAssetPath,Be as setNonce,qe as setPlatformOptions,Oe as t,mF as u,oF as v,Ze as w,Lr as x,JF as y,rM as z}
|