modified-dicom-pacs
Version:
A modified version of DICOM PACS implementation
2 lines • 611 kB
JavaScript
/*! For license information please see 109.bundle.992920b74d042cab5e19.js.LICENSE.txt */
(globalThis.webpackChunk=globalThis.webpackChunk||[]).push([[109],{36434:function(e,r){var t;!function(n){"use strict";var i=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:.5*(Math.exp(e)+Math.exp(-e))},a=Math.sinh||function(e){return Math.abs(e)<1e-9?e:.5*(Math.exp(e)-Math.exp(-e))},o=function(){throw SyntaxError("Invalid Param")};function s(e,r){var 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):(e/=2,r/=2,.5*Math.log(e*e+r*r)+Math.LN2)}function u(e,r){if(!(this instanceof u))return new u(e,r);var t=function(e,r){var t={re:0,im:0};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(!Number.isFinite(e.abs)&&Number.isFinite(e.arg))return u.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(!Number.isFinite(e.r)&&Number.isFinite(e.phi))return u.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]):o();break;case"string":t.im=t.re=0;var n=e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),i=1,a=0;null===n&&o();for(var s=0;s<n.length;s++){var c=n[s];" "===c||"\t"===c||"\n"===c||("+"===c?i++:"-"===c?a++:"i"===c||"I"===c?(i+a===0&&o()," "===n[s+1]||isNaN(n[s+1])?t.im+=parseFloat((a%2?"-":"")+"1"):(t.im+=parseFloat((a%2?"-":"")+n[s+1]),s++),i=a=0):((i+a===0||isNaN(c))&&o(),"i"===n[s+1]||"I"===n[s+1]?(t.im+=parseFloat((a%2?"-":"")+c),s++):t.re+=parseFloat((a%2?"-":"")+c),i=a=0))}i+a>0&&o();break;case"number":t.im=0,t.re=e;break;default:o()}return isNaN(t.re)||isNaN(t.im),t}(e,r);this.re=t.re,this.im=t.im}u.prototype={re:0,im:0,sign:function(){var e=this.abs();return new u(this.re/e,this.im/e)},add:function(e,r){var t=new u(e,r);return this.isInfinite()&&t.isInfinite()?u.NAN:this.isInfinite()||t.isInfinite()?u.INFINITY:new u(this.re+t.re,this.im+t.im)},sub:function(e,r){var t=new u(e,r);return this.isInfinite()&&t.isInfinite()?u.NAN:this.isInfinite()||t.isInfinite()?u.INFINITY:new u(this.re-t.re,this.im-t.im)},mul:function(e,r){var t=new u(e,r);return this.isInfinite()&&t.isZero()||this.isZero()&&t.isInfinite()?u.NAN:this.isInfinite()||t.isInfinite()?u.INFINITY:0===t.im&&0===this.im?new u(this.re*t.re,0):new u(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)},div:function(e,r){var t=new u(e,r);if(this.isZero()&&t.isZero()||this.isInfinite()&&t.isInfinite())return u.NAN;if(this.isInfinite()||t.isZero())return u.INFINITY;if(this.isZero()||t.isInfinite())return u.ZERO;e=this.re,r=this.im;var n,i,a=t.re,o=t.im;return 0===o?new u(e/a,r/a):Math.abs(a)<Math.abs(o)?new u((e*(i=a/o)+r)/(n=a*i+o),(r*i-e)/n):new u((e+r*(i=o/a))/(n=o*i+a),(r-e*i)/n)},pow:function(e,r){var t=new u(e,r);if(e=this.re,r=this.im,t.isZero())return u.ONE;if(0===t.im){if(0===r&&e>0)return new u(Math.pow(e,t.re),0);if(0===e)switch((t.re%4+4)%4){case 0:return new u(Math.pow(r,t.re),0);case 1:return new u(0,Math.pow(r,t.re));case 2:return new u(-Math.pow(r,t.re),0);case 3:return new u(0,-Math.pow(r,t.re))}}if(0===e&&0===r&&t.re>0&&t.im>=0)return u.ZERO;var n=Math.atan2(r,e),i=s(e,r);return e=Math.exp(t.re*i-t.im*n),r=t.im*i+t.re*n,new u(e*Math.cos(r),e*Math.sin(r))},sqrt:function(){var e,r,t=this.re,n=this.im,i=this.abs();if(t>=0){if(0===n)return new u(Math.sqrt(t),0);e=.5*Math.sqrt(2*(i+t))}else e=Math.abs(n)/Math.sqrt(2*(i-t));return r=t<=0?.5*Math.sqrt(2*(i-t)):Math.abs(n)/Math.sqrt(2*(i+t)),new u(e,n<0?-r:r)},exp:function(){var e=Math.exp(this.re);return this.im,new u(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){var e=this.re,r=this.im;return new u(Math.expm1(e)*Math.cos(r)+function(e){var r=Math.PI/4;if(-r>e||e>r)return Math.cos(e)-1;var t=e*e;return t*(t*(t*(t*(t*(t*(t*(t/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-.5)}(r),Math.exp(e)*Math.sin(r))},log:function(){var e=this.re,r=this.im;return new u(s(e,r),Math.atan2(r,e))},abs:function(){return e=this.re,r=this.im,t=Math.abs(e),n=Math.abs(r),t<3e3&&n<3e3?Math.sqrt(t*t+n*n):(t<n?(t=n,n=e/r):n=r/e,t*Math.sqrt(1+n*n));var e,r,t,n},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var e=this.re,r=this.im;return new u(Math.sin(e)*i(r),Math.cos(e)*a(r))},cos:function(){var e=this.re,r=this.im;return new u(Math.cos(e)*i(r),-Math.sin(e)*a(r))},tan:function(){var e=2*this.re,r=2*this.im,t=Math.cos(e)+i(r);return new u(Math.sin(e)/t,a(r)/t)},cot:function(){var e=2*this.re,r=2*this.im,t=Math.cos(e)-i(r);return new u(-Math.sin(e)/t,a(r)/t)},sec:function(){var e=this.re,r=this.im,t=.5*i(2*r)+.5*Math.cos(2*e);return new u(Math.cos(e)*i(r)/t,Math.sin(e)*a(r)/t)},csc:function(){var e=this.re,r=this.im,t=.5*i(2*r)-.5*Math.cos(2*e);return new u(Math.sin(e)*i(r)/t,-Math.cos(e)*a(r)/t)},asin:function(){var e=this.re,r=this.im,t=new u(r*r-e*e+1,-2*e*r).sqrt(),n=new u(t.re-r,t.im+e).log();return new u(n.im,-n.re)},acos:function(){var e=this.re,r=this.im,t=new u(r*r-e*e+1,-2*e*r).sqrt(),n=new u(t.re-r,t.im+e).log();return new u(Math.PI/2-n.im,n.re)},atan:function(){var e=this.re,r=this.im;if(0===e){if(1===r)return new u(0,1/0);if(-1===r)return new u(0,-1/0)}var t=e*e+(1-r)*(1-r),n=new u((1-r*r-e*e)/t,-2*e/t).log();return new u(-.5*n.im,.5*n.re)},acot:function(){var e=this.re,r=this.im;if(0===r)return new u(Math.atan2(1,e),0);var t=e*e+r*r;return 0!==t?new u(e/t,-r/t).atan():new u(0!==e?e/0:0,0!==r?-r/0:0).atan()},asec:function(){var e=this.re,r=this.im;if(0===e&&0===r)return new u(0,1/0);var t=e*e+r*r;return 0!==t?new u(e/t,-r/t).acos():new u(0!==e?e/0:0,0!==r?-r/0:0).acos()},acsc:function(){var e=this.re,r=this.im;if(0===e&&0===r)return new u(Math.PI/2,1/0);var t=e*e+r*r;return 0!==t?new u(e/t,-r/t).asin():new u(0!==e?e/0:0,0!==r?-r/0:0).asin()},sinh:function(){var e=this.re,r=this.im;return new u(a(e)*Math.cos(r),i(e)*Math.sin(r))},cosh:function(){var e=this.re,r=this.im;return new u(i(e)*Math.cos(r),a(e)*Math.sin(r))},tanh:function(){var e=2*this.re,r=2*this.im,t=i(e)+Math.cos(r);return new u(a(e)/t,Math.sin(r)/t)},coth:function(){var e=2*this.re,r=2*this.im,t=i(e)-Math.cos(r);return new u(a(e)/t,-Math.sin(r)/t)},csch:function(){var e=this.re,r=this.im,t=Math.cos(2*r)-i(2*e);return new u(-2*a(e)*Math.cos(r)/t,2*i(e)*Math.sin(r)/t)},sech:function(){var e=this.re,r=this.im,t=Math.cos(2*r)+i(2*e);return new u(2*i(e)*Math.cos(r)/t,-2*a(e)*Math.sin(r)/t)},asinh:function(){var e=this.im;this.im=-this.re,this.re=e;var r=this.asin();return this.re=-this.im,this.im=e,e=r.re,r.re=-r.im,r.im=e,r},acosh:function(){var e=this.acos();if(e.im<=0){var r=e.re;e.re=-e.im,e.im=r}else{r=e.im;e.im=-e.re,e.re=r}return e},atanh:function(){var e=this.re,r=this.im,t=e>1&&0===r,n=1-e,i=1+e,a=n*n+r*r,o=0!==a?new u((i*n-r*r)/a,(r*n+i*r)/a):new u(-1!==e?e/0:0,0!==r?r/0:0),c=o.re;return o.re=s(o.re,o.im)/2,o.im=Math.atan2(o.im,c)/2,t&&(o.im=-o.im),o},acoth:function(){var e=this.re,r=this.im;if(0===e&&0===r)return new u(0,Math.PI/2);var t=e*e+r*r;return 0!==t?new u(e/t,-r/t).atanh():new u(0!==e?e/0:0,0!==r?-r/0:0).atanh()},acsch:function(){var e=this.re,r=this.im;if(0===r)return new u(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var t=e*e+r*r;return 0!==t?new u(e/t,-r/t).asinh():new u(0!==e?e/0:0,0!==r?-r/0:0).asinh()},asech:function(){var e=this.re,r=this.im;if(this.isZero())return u.INFINITY;var t=e*e+r*r;return 0!==t?new u(e/t,-r/t).acosh():new u(0!==e?e/0:0,0!==r?-r/0:0).acosh()},inverse:function(){if(this.isZero())return u.INFINITY;if(this.isInfinite())return u.ZERO;var e=this.re,r=this.im,t=e*e+r*r;return new u(e/t,-r/t)},conjugate:function(){return new u(this.re,-this.im)},neg:function(){return new u(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new u(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new u(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new u(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,r){var t=new u(e,r);return Math.abs(t.re-this.re)<=u.EPSILON&&Math.abs(t.im-this.im)<=u.EPSILON},clone:function(){return new u(this.re,this.im)},toString:function(){var e=this.re,r=this.im,t="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<u.EPSILON&&(e=0),Math.abs(r)<u.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.isNaN()||this.isFinite())}},u.ZERO=new u(0,0),u.ONE=new u(1,0),u.I=new u(0,1),u.PI=new u(Math.PI,0),u.E=new u(Math.E,0),u.INFINITY=new u(1/0,1/0),u.NAN=new u(NaN,NaN),u.EPSILON=1e-15,void 0===(t=function(){return u}.apply(r,[]))||(e.exports=t)}()},96298:e=>{"use strict";var r=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},t={"{":"\\{","}":"\\}","\\":"\\textbackslash{}","#":"\\#",$:"\\$","%":"\\%","&":"\\&","^":"\\textasciicircum{}",_:"\\_","~":"\\textasciitilde{}"},n={"–":"\\--","—":"\\---"," ":"~","\t":"\\qquad{}","\r\n":"\\newline{}","\n":"\\newline{}"},i=function(e,t){return r({},e,t)};e.exports=function(e){for(var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=a.preserveFormatting,s=void 0!==o&&o,u=a.escapeMapFn,c=void 0===u?i:u,l=String(e),f="",p=c(r({},t),s?r({},n):{}),m=Object.keys(p),d=function(){var e=!1;m.forEach((function(r,t){e||l.length>=r.length&&l.slice(0,r.length)===r&&(f+=p[m[t]],l=l.slice(r.length,l.length),e=!0)})),e||(f+=l.slice(0,1),l=l.slice(1,l.length))};l;)d();return f}},79978:e=>{e.exports=function e(r,t){"use strict";var n,i,a=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,o=/(^[ ]*|[ ]*$)/g,s=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,u=/^0x[0-9a-f]+$/i,c=/^0/,l=function(r){return e.insensitive&&(""+r).toLowerCase()||""+r},f=l(r).replace(o,"")||"",p=l(t).replace(o,"")||"",m=f.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),d=p.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),h=parseInt(f.match(u),16)||1!==m.length&&f.match(s)&&Date.parse(f),g=parseInt(p.match(u),16)||h&&p.match(s)&&Date.parse(p)||null;if(g){if(h<g)return-1;if(h>g)return 1}for(var y=0,v=Math.max(m.length,d.length);y<v;y++){if(n=!(m[y]||"").match(c)&&parseFloat(m[y])||m[y]||0,i=!(d[y]||"").match(c)&&parseFloat(d[y])||d[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}},77822:e=>{function r(){}r.prototype={on:function(e,r,t){var n=this.e||(this.e={});return(n[e]||(n[e]=[])).push({fn:r,ctx:t}),this},once:function(e,r,t){var n=this;function i(){n.off(e,i),r.apply(t,arguments)}return i._=r,this.on(e,i,t)},emit:function(e){for(var r=[].slice.call(arguments,1),t=((this.e||(this.e={}))[e]||[]).slice(),n=0,i=t.length;n<i;n++)t[n].fn.apply(t[n].ctx,r);return this},off:function(e,r){var t=this.e||(this.e={}),n=t[e],i=[];if(n&&r)for(var a=0,o=n.length;a<o;a++)n[a].fn!==r&&n[a].fn._!==r&&i.push(n[a]);return i.length?t[e]=i:delete t[e],this}},e.exports=r,e.exports.TinyEmitter=r},23109:(e,r,t)=>{"use strict";t.d(r,{WCD:()=>$w,lwT:()=>iw});var n=t(69276),i={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function a(e){return"number"==typeof e}function o(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 s(e){return e&&"object"==typeof e&&!0===Object.getPrototypeOf(e).isComplex||!1}function u(e){return e&&"object"==typeof e&&!0===Object.getPrototypeOf(e).isFraction||!1}function c(e){return e&&!0===e.constructor.prototype.isUnit||!1}function l(e){return"string"==typeof e}var f=Array.isArray;function p(e){return e&&!0===e.constructor.prototype.isMatrix||!1}function m(e){return Array.isArray(e)||p(e)}function d(e){return e&&e.isDenseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function h(e){return e&&e.isSparseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function g(e){return e&&!0===e.constructor.prototype.isRange||!1}function y(e){return e&&!0===e.constructor.prototype.isIndex||!1}function v(e){return"boolean"==typeof e}function x(e){return e&&!0===e.constructor.prototype.isResultSet||!1}function b(e){return e&&!0===e.constructor.prototype.isHelp||!1}function w(e){return"function"==typeof e}function N(e){return e instanceof Date}function D(e){return e instanceof RegExp}function E(e){return!(!e||"object"!=typeof e||e.constructor!==Object||s(e)||u(e))}function A(e){return null===e}function S(e){return void 0===e}function C(e){return e&&!0===e.isAccessorNode&&!0===e.constructor.prototype.isNode||!1}function M(e){return e&&!0===e.isArrayNode&&!0===e.constructor.prototype.isNode||!1}function F(e){return e&&!0===e.isAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function B(e){return e&&!0===e.isBlockNode&&!0===e.constructor.prototype.isNode||!1}function T(e){return e&&!0===e.isConditionalNode&&!0===e.constructor.prototype.isNode||!1}function O(e){return e&&!0===e.isConstantNode&&!0===e.constructor.prototype.isNode||!1}function _(e){return O(e)||P(e)&&1===e.args.length&&O(e.args[0])&&"-+~".includes(e.op)}function z(e){return e&&!0===e.isFunctionAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function q(e){return e&&!0===e.isFunctionNode&&!0===e.constructor.prototype.isNode||!1}function I(e){return e&&!0===e.isIndexNode&&!0===e.constructor.prototype.isNode||!1}function k(e){return e&&!0===e.isNode&&!0===e.constructor.prototype.isNode||!1}function R(e){return e&&!0===e.isObjectNode&&!0===e.constructor.prototype.isNode||!1}function P(e){return e&&!0===e.isOperatorNode&&!0===e.constructor.prototype.isNode||!1}function U(e){return e&&!0===e.isParenthesisNode&&!0===e.constructor.prototype.isNode||!1}function j(e){return e&&!0===e.isRangeNode&&!0===e.constructor.prototype.isNode||!1}function L(e){return e&&!0===e.isRelationalNode&&!0===e.constructor.prototype.isNode||!1}function H(e){return e&&!0===e.isSymbolNode&&!0===e.constructor.prototype.isNode||!1}function $(e){return e&&!0===e.constructor.prototype.isChain||!1}function G(e){var r=typeof e;return"object"===r?null===e?"null":o(e)?"BigNumber":e.constructor&&e.constructor.name?e.constructor.name:"Object":r}function Z(e){var r=typeof e;if("number"===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 Z(e)}));if(e instanceof Date)return new Date(e.valueOf());if(o(e))return e;if(E(e))return function(e,r){var t={};for(var n in e)Y(e,n)&&(t[n]=r(e[n]));return t}(e,Z);throw new TypeError("Cannot clone: unknown type of value (value: ".concat(e,")"))}function V(e,r){for(var t in r)Y(r,t)&&(e[t]=r[t]);return e}function W(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(!W(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)||!W(e[t],r[t]))return!1;for(t in r)if(!(t in e))return!1;return!0}return e===r}function Y(e,r){return e&&Object.hasOwnProperty.call(e,r)}var J=["Matrix","Array"],X=["number","BigNumber","Fraction"];var Q=function(e){if(e)throw new 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(i)};function K(){return!0}function ee(){return!1}function re(){}(0,n.A)(Q,i,{MATRIX_OPTIONS:J,NUMBER_OPTIONS:X});const te="Argument is not a typed-function.";const ne=function e(){function r(e){return"object"==typeof e&&null!==e&&e.constructor===Object}const t=[{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:r},{name:"null",test:function(e){return null===e}},{name:"undefined",test:function(e){return void 0===e}}],n={name:"any",test:K,isAny:!0};let i,a,o=0,s={createCount:0};function u(e){const r=i.get(e);if(r)return r;let t='Unknown type "'+e+'"';const n=e.toLowerCase();let o;for(o of a)if(o.toLowerCase()===n){t+='. Did you mean "'+o+'" ?';break}throw new TypeError(t)}function c(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"any";const t=r?u(r).index:a.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 a=e[r].name;if(i.has(a))throw new TypeError('Duplicate type name "'+a+'"');n.push(a),i.set(a,{name:a,test:e[r].test,isAny:e[r].isAny,index:t+r,conversionsTo:[]})}const o=a.slice(t);a=a.slice(0,t).concat(n).concat(o);for(let e=t+n.length;e<a.length;++e)i.get(a[e]).index=e}function l(){i=new Map,a=[],o=0,c([n],!1)}function f(e){const r=a.filter((r=>{const t=i.get(r);return!t.isAny&&t.test(e)}));return r.length?r:["any"]}function p(e){return e&&"function"==typeof e&&"_typedFunctionData"in e}function m(e,r,t){if(!p(e))throw new TypeError(te);const n=t&&t.exact,i=v(Array.isArray(r)?r.join(","):r),a=d(i);if(!n||a in e.signatures){const r=e._typedFunctionData.signatureMap.get(a);if(r)return r}const o=i.length;let s,u;if(n){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<o;++e){const r=i[e],t=[];let n;for(n of s){const i=N(n.params,e);if(i&&(!r.restParam||i.restParam)){if(!i.hasAny){const e=y(i);if(r.types.some((r=>!e.has(r.name))))continue}t.push(n)}}if(s=t,0===s.length)break}for(u of s)if(u.params.length<=o)return u;throw new TypeError("Signature not found (signature: "+(e.name||"unnamed")+"("+d(i,", ")+"))")}function d(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:",";return e.map((e=>e.name)).join(r)}function h(e){const r=0===e.indexOf("..."),t=(r?e.length>3?e.slice(3):"any":e).split("|").map((e=>u(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 g(e){const r=function(e){if(0===e.length)return[];const r=e.map(u);e.length>1&&r.sort(((e,r)=>e.index-r.index));let t=r[0].conversionsTo;if(1===e.length)return t;t=t.concat([]);const n=new Set(e);for(let e=1;e<r.length;++e){let i;for(i of r[e].conversionsTo)n.has(i.from)||(t.push(i),n.add(i.from))}return t}(e.types.map((e=>e.name)));let t=e.hasAny,n=e.name;const i=r.map((function(e){const r=u(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 y(e){return e.typeSet||(e.typeSet=new Set,e.types.forEach((r=>e.typeSet.add(r.name)))),e.typeSet}function v(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=h(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 x(e){const r=U(e);return!!r&&r.restParam}function b(e){if(e&&0!==e.types.length){if(1===e.types.length)return u(e.types[0].name).test;if(2===e.types.length){const r=u(e.types[0].name).test,t=u(e.types[1].name).test;return function(e){return r(e)||t(e)}}{const r=e.types.map((function(e){return u(e.name).test}));return function(e){for(let t=0;t<r.length;t++)if(r[t](e))return!0;return!1}}}return K}function w(e){let r,t,n;if(x(e)){r=P(e).map(b);const t=r.length,n=b(U(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=b(e[0]),function(e){return t(e[0])&&1===e.length}):2===e.length?(t=b(e[0]),n=b(e[1]),function(e){return t(e[0])&&n(e[1])&&2===e.length}):(r=e.map(b),function(e){for(let t=0;t<r.length;t++)if(!r[t](e[t]))return!1;return e.length===r.length})}function N(e,r){return r<e.length?e[r]:x(e)?U(e):null}function D(e,r){const t=N(e,r);return t?y(t):new Set}function E(e){return null===e.conversion||void 0===e.conversion}function A(e,r){const t=new Set;return e.forEach((e=>{const n=D(e.params,r);let i;for(i of n)t.add(i)})),t.has("any")?["any"]:Array.from(t)}function S(e,r,t){let n,i;const a=e||"unnamed";let o,s=t;for(o=0;o<r.length;o++){const e=[];if(s.forEach((t=>{const n=b(N(t.params,o));(o<t.params.length||x(t.params))&&n(r[o])&&e.push(t)})),0===e.length){if(i=A(s,o),i.length>0){const e=f(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 s=e}const u=s.map((function(e){return x(e.params)?1/0:e.params.length}));if(r.length<Math.min.apply(null,u))return i=A(s,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,u);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(f(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 C(e){let r=a.length+1;for(let t=0;t<e.types.length;t++)E(e.types[t])&&(r=Math.min(r,e.types[t].typeIndex));return r}function M(e){let r=o+1;for(let t=0;t<e.types.length;t++)E(e.types[t])||(r=Math.min(r,e.types[t].conversionIndex));return r}function F(e,r){if(e.hasAny){if(!r.hasAny)return 1}else if(r.hasAny)return-1;if(e.restParam){if(!r.restParam)return 1}else if(r.restParam)return-1;if(e.hasConversion){if(!r.hasConversion)return 1}else if(r.hasConversion)return-1;const t=C(e)-C(r);if(t<0)return-1;if(t>0)return 1;const n=M(e)-M(r);return n<0?-1:n>0?1:0}function B(e,r){const t=e.params,n=r.params,i=U(t),a=U(n),o=x(t),s=x(n);if(o&&i.hasAny){if(!s||!a.hasAny)return 1}else if(s&&a.hasAny)return-1;let u,c=0,l=0;for(u of t)u.hasAny&&++c,u.hasConversion&&++l;let f=0,p=0;for(u of n)u.hasAny&&++f,u.hasConversion&&++p;if(c!==f)return c-f;if(o&&i.hasConversion){if(!s||!a.hasConversion)return 1}else if(s&&a.hasConversion)return-1;if(l!==p)return l-p;if(o){if(!s)return 1}else if(s)return-1;const m=(t.length-n.length)*(o?-1:1);if(0!==m)return m;const d=[];let h,g=0;for(let e=0;e<t.length;++e){const r=F(t[e],n[e]);d.push(r),g+=r}if(0!==g)return g;for(h of d)if(0!==h)return h;return 0}function T(e,r){let t=r;if(e.some((e=>e.hasConversion))){const n=x(e),i=e.map(O);t=function(){const e=[],t=n?arguments.length-1:arguments.length;for(let r=0;r<t;r++)e[r]=i[r](arguments[r]);return n&&(e[t]=arguments[t].map(i[t])),r.apply(this,e)}}let n=t;if(x(e)){const r=e.length-1;n=function(){return t.apply(this,j(arguments,0,r).concat([j(arguments,r)]))}}return n}function O(e){let r,t,n,i;const a=[],o=[];switch(e.types.forEach((function(e){e.conversion&&(a.push(u(e.conversion.from).test),o.push(e.conversion.convert))})),o.length){case 0:return function(e){return e};case 1:return r=a[0],n=o[0],function(e){return r(e)?n(e):e};case 2:return r=a[0],t=a[1],n=o[0],i=o[1],function(e){return r(e)?n(e):t(e)?i(e):e};default:return function(e){for(let r=0;r<o.length;r++)if(a[r](e))return o[r](e);return e}}}function _(e){return function e(r,t,n){if(t<r.length){const o=r[t];let s=[];if(o.restParam){const e=o.types.filter(E);e.length<o.types.length&&s.push({types:e,name:"..."+e.map((e=>e.name)).join("|"),hasAny:e.some((e=>e.isAny)),hasConversion:!1,restParam:!0}),s.push(o)}else s=o.types.map((function(e){return{types:[e],name:e.name,hasAny:e.isAny,hasConversion:e.conversion,restParam:!1}}));return i=s,a=function(i){return e(r,t+1,n.concat([i]))},Array.prototype.concat.apply([],i.map(a))}return[n];var i,a}(e,0,[])}function z(e,r){const t=Math.max(e.length,r.length);for(let n=0;n<t;n++){const t=D(e,n),i=D(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=x(e),o=x(r);return a?o?n===i:i>=n:o?n>=i:n===i}function q(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 I(e,r,t){const n=function(e){return e.map((e=>G(e)?H(e.referToSelf.callback):$(e)?L(e.referTo.references,e.referTo.callback):e))}(e),i=new 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 s=n[o];if(G(s))n[o]=s.referToSelf.callback(t),n[o].referToSelf=s.referToSelf,i[o]=!0,e=!1;else if($(s)){const t=q(s.referTo.references,n,r);t?(n[o]=s.referTo.callback.apply(this,t),n[o].referTo=s.referTo,i[o]=!0,e=!1):a=!0}}if(e&&a)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return n}function k(e,r){if(s.createCount++,0===Object.keys(r).length)throw new SyntaxError("No signatures provided");s.warnAgainstDeprecatedThis&&function(e){const r=/\bthis(\(|\.signatures\b)/;Object.keys(e).forEach((t=>{const n=e[t];if(r.test(n.toString()))throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")}))}(r);const t=[],n=[],i={},a=[];let o;for(o in r){if(!Object.prototype.hasOwnProperty.call(r,o))continue;const e=v(o);if(!e)continue;t.forEach((function(r){if(z(r,e))throw new TypeError('Conflicting signatures "'+d(r)+'" and "'+d(e)+'".')})),t.push(e);const s=n.length;n.push(r[o]);const u=e.map(g);let c;for(c of _(u)){const e=d(c);a.push({params:c,name:e,fn:s}),c.every((e=>!e.hasConversion))&&(i[e]=s)}}a.sort(B);const u=I(n,i,se);let c;for(c in i)Object.prototype.hasOwnProperty.call(i,c)&&(i[c]=u[i[c]]);const l=[],f=new Map;for(c of a)f.has(c.name)||(c.fn=u[c.fn],l.push(c),f.set(c.name,c));const p=l[0]&&l[0].params.length<=2&&!x(l[0].params),m=l[1]&&l[1].params.length<=2&&!x(l[1].params),h=l[2]&&l[2].params.length<=2&&!x(l[2].params),y=l[3]&&l[3].params.length<=2&&!x(l[3].params),N=l[4]&&l[4].params.length<=2&&!x(l[4].params),D=l[5]&&l[5].params.length<=2&&!x(l[5].params),E=p&&m&&h&&y&&N&&D;for(let e=0;e<l.length;++e)l[e].test=w(l[e].params);const A=p?b(l[0].params[0]):ee,S=m?b(l[1].params[0]):ee,C=h?b(l[2].params[0]):ee,M=y?b(l[3].params[0]):ee,F=N?b(l[4].params[0]):ee,O=D?b(l[5].params[0]):ee,q=p?b(l[0].params[1]):ee,k=m?b(l[1].params[1]):ee,R=h?b(l[2].params[1]):ee,P=y?b(l[3].params[1]):ee,U=N?b(l[4].params[1]):ee,j=D?b(l[5].params[1]):ee;for(let e=0;e<l.length;++e)l[e].implementation=T(l[e].params,l[e].fn);const L=p?l[0].implementation:re,H=m?l[1].implementation:re,$=h?l[2].implementation:re,G=y?l[3].implementation:re,Z=N?l[4].implementation:re,V=D?l[5].implementation:re,W=p?l[0].params.length:-1,Y=m?l[1].params.length:-1,J=h?l[2].params.length:-1,X=y?l[3].params.length:-1,Q=N?l[4].params.length:-1,K=D?l[5].params.length:-1,te=E?6:0,ne=l.length,ie=l.map((e=>e.test)),ae=l.map((e=>e.implementation)),oe=function(){for(let e=te;e<ne;e++)if(ie[e](arguments))return ae[e].apply(this,arguments);return s.onMismatch(e,arguments,l)};function se(e,r){return arguments.length===W&&A(e)&&q(r)?L.apply(this,arguments):arguments.length===Y&&S(e)&&k(r)?H.apply(this,arguments):arguments.length===J&&C(e)&&R(r)?$.apply(this,arguments):arguments.length===X&&M(e)&&P(r)?G.apply(this,arguments):arguments.length===Q&&F(e)&&U(r)?Z.apply(this,arguments):arguments.length===K&&O(e)&&j(r)?V.apply(this,arguments):oe.apply(this,arguments)}try{Object.defineProperty(se,"name",{value:e})}catch(e){}return se.signatures=i,se._typedFunctionData={signatures:l,signatureMap:f},se}function R(e,r,t){throw S(e,r,t)}function P(e){return j(e,0,e.length-1)}function U(e){return e[e.length-1]}function j(e,r,t){return Array.prototype.slice.call(e,r,t)}function L(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 $(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 Z(e,r){if(!e)return r;if(r&&r!==e){const t=new Error("Function names do not match (expected: "+e+", actual: "+r+")");throw t.data={actual:r,expected:e},t}return e}function V(e){let r;for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(p(e[t])||"string"==typeof e[t].signature)&&(r=Z(r,e[t].name));return r}function W(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=new Error('Signature "'+t+'" is defined twice');throw n.data={signature:t,sourceFunction:r[t],destFunction:e[t]},n}e[t]=r[t]}}l(),c(t);const Y=s;function J(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 s=function(e){const t="string"==typeof e;let n=t?e:"";const i={};for(let e=t?1:0;e<arguments.length;++e){const a=arguments[e];let o,s={};if("function"==typeof a?(o=a.name,"string"==typeof a.signature?s[a.signature]=a:p(a)&&(s=a.signatures)):r(a)&&(s=a,t||(o=V(a))),0===Object.keys(s).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:a},r}t||(n=Z(n,o)),W(i,s)}return k(n||"",i)},s.create=e,s.createCount=Y.createCount,s.onMismatch=R,s.throwMismatchError=R,s.createError=S,s.clear=l,s.clearConversions=function(){let e;for(e of a)i.get(e).conversionsTo=[];o=0},s.addTypes=c,s._findType=u,s.referTo=function(){const e=P(arguments).map((e=>d(v(e)))),r=U(arguments);if("function"!=typeof r)throw new TypeError("Callback function expected as last argument");return L(e,r)},s.referToSelf=H,s.convert=function(e,r){const t=u(r);if(t.test(e))return e;const n=t.conversionsTo;if(0===n.length)throw new Error("There are no conversions to "+r+" defined.");for(let r=0;r<n.length;r++){if(u(n[r].from).test(e))return n[r].convert(e)}throw new Error("Cannot convert "+e+" to "+r)},s.findSignature=m,s.find=function(e,r,t){return m(e,r,t).implementation},s.isTypedFunction=p,s.warnAgainstDeprecatedThis=!0,s.addType=function(e,r){let t="any";!1!==r&&i.has("Object")&&(t="Object"),s.addTypes([e],t)},s.addConversion=function(e){J(e);const r=u(e.to);if(!r.conversionsTo.every((function(r){return r.from!==e.from})))throw new Error('There is already a conversion from "'+e.from+'" to "'+r.name+'"');r.conversionsTo.push({from:e.from,convert:e.convert,index:o++})},s.addConversions=function(e){e.forEach(s.addConversion)},s.removeConversion=function(e){J(e);const r=u(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 new Error("Attempt to remove nonexistent conversion from "+e.from+" to "+e.to);if(t.convert!==e.convert)throw new Error("Conversion to remove does not match existing conversion");const n=r.conversionsTo.indexOf(t);r.conversionsTo.splice(n,1)},s.resolve=function(e,r){if(!p(e))throw new TypeError(te);const t=e._typedFunctionData.signatures;for(let e=0;e<t.length;++e)if(t[e].test(r))return t[e];return null},s}();function ie(e){return"boolean"==typeof e||!!isFinite(e)&&e===Math.round(e)}var ae=Math.sign||function(e){return e>0?1:e<0?-1:0},oe=Math.log2||function(e){return Math.log(e)/Math.LN2},se=Math.log10||function(e){return Math.log(e)/Math.LN10},ue=Math.log1p||function(e){return Math.log(e+1)},ce=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},le=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function fe(e,r,t){var n={2:"0b",8:"0o",16:"0x"}[r],i="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!ie(t))throw new Error("size must be an integer");if(e>2**(t-1)-1||e<-(2**(t-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!ie(e))throw new 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 pe(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 t,n,i="auto";if(r&&(r.notation&&(i=r.notation),a(r)?t=r:a(r.precision)&&(t=r.precision),r.wordSize&&"number"!=typeof(n=r.wordSize)))throw new Error('Option "wordSize" must be a number');switch(i){case"fixed":return de(e,t);case"exponential":return he(e,t);case"engineering":return function(e,r){if(isNaN(e)||!isFinite(e))return String(e);var t=me(e),n=ge(t,r),i=n.exponent,o=n.coefficients,s=i%3==0?i:i<0?i-3-i%3:i-i%3;if(a(r))for(;r>o.length||i-s+1>o.length;)o.push(0);else for(var u=Math.abs(i-s)-(o.length-1),c=0;c<u;c++)o.push(0);var l=Math.abs(i-s),f=1;for(;l>0;)f++,l--;var p=o.slice(f).join(""),m=a(r)&&p.length||p.match(/[1-9]/)?"."+p:"",d=o.slice(0,f).join("")+m+"e"+(i>=0?"+":"")+s.toString();return n.sign+d}(e,t);case"bin":return fe(e,2,n);case"oct":return fe(e,8,n);case"hex":return fe(e,16,n);case"auto":return function(e,r,t){if(isNaN(e)||!isFinite(e))return String(e);var n=t&&void 0!==t.lowerExp?t.lowerExp:-3,i=t&&void 0!==t.upperExp?t.upperExp:5,a=me(e),o=r?ge(a,r):a;if(o.exponent<n||o.exponent>=i)return he(e,r);var s=o.coefficients,u=o.exponent;s.length<r&&(s=s.concat(ye(r-s.length))),s=s.concat(ye(u-s.length+1+(s.length<r?r-s.length:0)));var c=u>0?u:0;return c<(s=ye(-u).concat(s)).length-1&&s.splice(c+1,0,"."),o.sign+s.join("")}(e,t,r&&r).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],r=arguments[4];return"."!==e?e+r:r}));default:throw new Error('Unknown notation "'+i+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function me(e){var r=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!r)throw new SyntaxError("Invalid number "+e);var t=r[1],n=r[2],i=parseFloat(r[4]||"0"),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 de(e,r){if(isNaN(e)||!isFinite(e))return String(e);var t=me(e),n="number"==typeof r?ge(t,t.exponent+1+r):t,i=n.coefficients,a=n.exponent+1,o=a+(r||0);return i.length<o&&(i=i.concat(ye(o-i.length))),a<0&&(i=ye(1-a).concat(i),a=1),a<i.length&&i.splice(a,0,0===a?"0.":"."),n.sign+i.join("")}function he(e,r){if(isNaN(e)||!isFinite(e))return String(e);var t=me(e),n=r?ge(t,r):t,i=n.coefficients,a=n.exponent;i.length<r&&(i=i.concat(ye(r-i.length)));var o=i.shift();return n.sign+o+(i.length>0?"."+i.join(""):"")+"e"+(a>=0?"+":"")+a}function ge(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 ye(e){for(var r=[],t=0;t<e;t++)r.push(0);return r}var ve=Number.EPSILON||2220446049250313e-31;function xe(e,r,t){if(null==t)return e===r;if(e===r)return!0;if(isNaN(e)||isNaN(r))return!1;if(isFinite(e)&&isFinite(r)){var n=Math.abs(e-r);return n<ve||n<=Math.max(Math.abs(e),Math.abs(r))*t}return!1}var be=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)},we=Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},Ne=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2},De=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2},Ee=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2},Ae=Math.tanh||function(e){var r=Math.exp(2*e);return(r-1)/(r+1)};function Se(e,r,t){var n=new(0,e.constructor)(2),i="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!ie(t))throw new Error("size must be an integer");if(e.greaterThan(n.pow(t-1).sub(1))||e.lessThan(n.pow(t-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!e.isInteger())throw new 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 new Error("Base ".concat(r," not supported "))}}function Ce(e,r){if("function"==typeof r)return r(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var t,n,i="auto";if(void 0!==r&&(r.notation&&(i=r.notation),"number"==typeof r?t=r:void 0!==r.precision&&(t=r.precision),r.wordSize&&"number"!=typeof(n=r.wordSize)))throw new Error('Option "wordSize" must be a number');switch(i){case"fixed":return function(e,r){return e.toFixed(r)}(e,t);case"exponential":return Me(e,t);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)),a=i.toPrecision(r);if(-1!==a.indexOf("e")){a=new(0,e.constructor)(a).toFixed()}return a+"e"+(t>=0?"+":"")+n.toString()}(e,t);case"bin":return Se(e,2,n);case"oct":return Se(e,8,n);case"hex":return Se(e,16,n);case"auto":var a=r&&void 0!==r.lowerExp?r.lowerExp:-3,o=r&&void 0!==r.upperExp?r.upperExp:5;if(e.isZero())return"0";var s=e.toSignificantDigits(t),u=s.e;return(u>=a&&u<o?s.toFixed():Me(e,t)).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],r=arguments[4];return"."!==e?e+r:r}));default:throw new Error('Unknown notation "'+i+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function Me(e,r){return void 0!==r?e.toExponential(r-1):e.toExponential()}function Fe(e,r){var t=e.length-r.length,n=e.length;return e.substring(t,n)===r}function Be(e,r){var t=function(e,r){if("number"==typeof e)return pe(e,r);if(o(e))return Ce(e,r);if(function(e){return e&&"object"==typeof e&&"number"==typeof e.s&&"number"==typeof e.n&&"number"==typeof e.d||!1}(e))return r&&"decimal"===r.fraction?e.toString():e.s*e.n+"/"+e.d;if(Array.isArray(e))return ze(e,r);if(l(e))return Te(e);if("function"==typeof e)return e.syntax?String(e.syntax):"function";if(e&&"object"==typeof e){return"function"==typeof e.format?e.format(r):e&&e.toString(r)!=={}.toString()?e.toString(r):"{"+Object.keys(e).map((t=>Te(t)+": "+Be(e[t],r))).join(", ")+"}"}return String(e)}(e,r);return r&&"object"==typeof r&&"truncate"in r&&t.length>r.truncate?t.substring(0,r.truncate-3)+"...":t}function Te(e){for(var r=String(e),t="",n=0;n<r.length;){var i=r.charAt(n);t+=i in Oe?Oe[i]:i,n++}return'"'+t+'"'}var Oe={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"};function _e(e){var r=String(e);return r=r.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function ze(e,r){if(Array.isArray(e)){for(var t="[",n=e.length,i=0;i<n;i++)0!==i&&(t+=", "),t+=ze(e[i],r);return t+="]"}return Be(e,r)}function qe(e,r){if(!l(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+G(e)+", index: 0)");if(!l(r))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+G(r)+", index: 1)");return e===r?0:e>r?1:-1}function Ie(e,r,t){if(!(this instanceof Ie))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=r,this.relation=t,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(r)?"["+r.join(", ")+"]":r)+")",this.stack=(new Error).stack}function ke(e,r,t){if(!(this instanceof ke))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),void 0!==this.min&&this.index<this.min?this.message="Index out of range ("+this.index+" < "+this.min+")":void 0!==this.max&&this.index>=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}function Re(e){for(var r=[];Array.isArray(e);)r.push(e.length),e=e[0];return r}function Pe(e,r,t){var n,i=e.length;if(i!==r[t])throw new Ie(i,r[t]);if(t<r.length-1){var a=t+1;for(n=0;n<i;n++){var o=e[n];if(!Array.isArray(o))throw new Ie(r.length-1,r.length,"<");Pe(e[n],r,a)}}else for(n=0;n<i;n++)if(Array.isArray(e[n]))throw new Ie(r.length+1,r.length,">")}function Ue(e,r){if(0===r.length){if(Array.isArray(e))throw new Ie(e.length,0)}else Pe(e,r,0)}function je(e,r){var t=e.isMatrix?e._size:Re(e);r._sourceSize.forEach(((e,r)=>{if(null!==e&&e!==t[r])throw new Ie(e,t[r])}))}function Le(e,r){if(void 0!==e){if(!a(e)||!ie(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof r&&e>=r)throw new ke(e,r)}}function He(e){for(var r=0;r<e._dimensions.length;++r){var t=e._dimensions[r];if(t._data&&f(t._data)){if(0===t._size[0])return!0}else if(t.isRange){if(t.start===t.end)return!0}else if(l(t)&&0===t.length)return!0}return!1}function $e(e,r,t){if(!Array.isArray(r))throw new TypeError("Array expected");if(0===r.length)throw new Error("Resizing to scalar is not supported");return r.forEach((function(e){if(!a(e)||!ie(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Be(r)+")")})),(a(e)||o(e))&&(e=[e]),Ge(e,r,0,void 0!==t?t:0),e}function Ge(e,r,t,n){var i,a,o=e.length,s=r[t],u=Math.min(o,s);if(e.length=s,t<r.length-1){var c=t+1;for(i=0;i<u;i++)a=e[i],Array.isArray(a)||(a=[a],e[i]=a),Ge(a,r,c,n);for(i=u;i<s;i++)a=[],e[i]=a,Ge(a,r,c,n)}else{for(i=0;i<u;i++)for(;Array.isArray(e[i]);)e[i]=e[i][0];for(i=u;i<s;i++)e[i]=n}}function Ze(e,r){var t=Ke(e),n=t.length;if(!Array.isArray(e)||!Array.isArray(r))throw new TypeError("Array expected");if(0===r.length)throw new Ie(0,n,"!=");var i=We(r=Ve(r,n));if(n!==i)throw new Ie(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,s=0;s<o;s++)t.push(n.slice(s*a,(s+1)*a));n=t}return n}(t,r)}catch(e){if(e instanceof Ie)throw new Ie(i,n,"!=");throw e}}function Ve(e,r){var t=We(e),n=e.slice(),i=e.indexOf(-1);if(e.indexOf(-1,i+1)>=0)throw new Error("More than one wildcard in sizes");if(i>=0){if(!(r%t==0))throw new Error("Could not replace wildcard, since "+r+" is no multiple of "+-t);n[i]=-r/t}return n}function We(e){return e.reduce(((e,r)=>e*r),1)}function Ye(e,r){for(var t=r||Re(e);Array.isArray(e)&&1===e.length;)e=e[0],t.shift();for(var n=t.length;1===t[n-1];)n--;return n<t.length&&(e=Je(e,n,0),t.length=n),e}function Je(e,r,t){var n,i;if(t<r){var a=t+1;for(n=0,i=e.length;n<i;n++)e[n]=Je(e[n],r,a)}else for(;Array.isArray(e);)e=e[0];return e}function Xe(e,r,t,n){var i=n||Re(e);if(t)for(var a=0;a<t;a++)e=[e],i.unshift(1);for(e=Qe(e,r,0);i.length<r;)i.push(1);return e}function Qe(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]=Qe(e[n],r,a)}else for(var o=t;o<r;o++)e=[e];return e}function Ke(e){if(!Array.isArray(e))return e;var r=[];return e.forEach((function e(t){Array.isArray(t)?t.forEach(e):r.push(t)})),r}function er(e,r){return Array.prototype.map.call(e,r)}function rr(e,r){Array.prototype.forEach.call(e,r)}function tr(e,r){if(1!==Re(e).length)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,r)}function nr(e,r){if(1!==Re(e).length)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,(e=>r.test(e)))}function ir(e,r){return Array.prototype.join.call(e,r)}function ar(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 or(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 sr(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 s=o?sr(a,r):r(a);if(void 0===t)t=s;else if(t!==s)return"mixed"}return t}function ur(e,r,t,n){if(n<t){if(e.length!==r.length)throw new Ie(e.length,r.length);for(var i=[],a=0;a<e.length;a++)i[a]=ur(e[a],r[a],t,n+1);return i}return e.concat(r)}function cr(){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 ur(e,t,r,0)}),e[0]);throw new Error("Wrong number of arguments in function concat")}function lr(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];for(var n=r.map((e=>e.length)),i=Math.max(...n),a=new Array(i).fill(null),o=0;o<r.length;o++)for(var s=r[o],u=n[o],c=0;c<u;c++){var l=i-u+c;s[c]>a[l]&&(a[l]=s[c])}for(var f=0;f<r.length;f++)fr(r[f],a);return a}function fr(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 new Error("shape missmatch: missmatch 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 pr(e,r){var t=Re(e);if(W(t,r))return e;fr(t,r);var i,a,o,s=lr(t,r),u=s.length,c=[...Array(u-t.length).fill(1),...t],l=function(e){return(0,n.A)([],e)}(e);t.length<u&&(t=Re(l=Ze(l,c)));for(var f=0;f<u;f++)t[f]<s[f]&&(i=l,a=s[f],o=f,t=Re(l=cr(...Array(a).fill(i),o)));return l}function mr(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(dr));return function(e,r,t){var n=r.filter((e=>!function(e){return e&&"?"===e[0]}(e))).every((e=>void 0!==t[e]));if(!n){var i=r.filter((e=>void 0===t[e]));throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(i.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 dr(e){return e&&"?"===e[0]?e.slice(1):e}function hr(e,r){if(xr(e)&&yr(e,r))return e[r];if("function"==typeof e[r]&&vr(e,r))throw new Error('Cannot access method "'+r+'" as a property');throw new Error('No access to property "'+r+'"')}function gr(e,r,t){if(xr(e)&&yr(e,r))return e[r]=t,t;throw new Error('No access to property "'+r+'"')}function yr(e,r){return!(!e||"object"!=typeof e)&&(!!Y(br,r)||!(r in Object.prototype)&&!(r in Function.prototype))}function vr(e,r){return null!=e&&"function"==typeof e[r]&&(!(Y(e,r)&&Object.getPrototypeOf&&r in Object.getPrototypeOf(e))&&(!!Y(wr,r)||!(r in Object.prototype)&&!(r in Function.prototype)))}function xr(e){return"object"==typeof e&&e&&e.constructor===Object}Ie.prototype=new RangeError,Ie.prototype.constructor=RangeError,Ie.prototype.name="DimensionError",Ie.prototype.isDimensionError=!0,ke.prototype=new RangeError,ke.prototype.constructor=RangeError,ke.prototype.name="IndexError",ke.prototype.isIndexError=!0;var br={length:!0,name:!0},wr={toString:!0,valueOf:!0,toLocaleString:!0};class Nr{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return hr(this.wrappedObject,e)}set(e,r){return gr(this.wrappedObject,e,r),this}has(e){return r=this.wrappedObject,e in r;var r}}function Dr(){return new Map}function Er(e){if(!e)return Dr();if(Ar(e))return e;if(E(e))return new Nr(e);throw new Error("createMap can create maps from objects or Maps")}function Ar(e){return!!e&&(e instanceof Map||e instanceof Nr||"function"==typeof e.set&&"function"==typeof e.get&&"function"==typeof e.keys&&"function"==typeof e.has)}function Sr(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];for(var i of t)if(i)if(Ar(i))for(var a of i.keys())e.set(a,i.get(a));else if(E(i))for(var o of Object.keys(i))e.set(o,i[o]);return e}var Cr=function(){return Cr=ne.create,ne},Mr=mr("typed",["?BigNumber","?Complex","?DenseMatrix","?Fraction"],(function(e){var{BigNumber:r,Complex:t,DenseMatrix:n,Fraction:i}=e,_=Cr();return _.clear(),_.addTypes([{name:"number",test:a},{name:"Complex",test:s},{name:"BigNumber",test:o},{name:"Fraction",test:u},{name:"Unit",test:c},{name:"identifier",test:e=>l&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u0