js-gei 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/js-gei.es.js +1371 -1364
- package/dist/js-gei.umd.js +17 -17
- package/package.json +1 -1
- package/src/main.ts +21 -2
package/dist/js-gei.umd.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
`+n)}if(this.Records!=null){let i=this.Records.Validate(),o=null,l=null;if(i!=null&&(o=i.errorMessage,l=i.validateDetailsErrors),o==null||(t=o.toString(),l==null))return null;l.length>0&&e.push(i.validateDetailsErrors)}let a="Missing data on level "+this.Tablename+": "+t;return{combineErrors:a==""?null:a,validateErrors:e,validateDeatailErrors:this.validateDetailsErrors.length>0?this.validateDetailsErrors:[]}}}const Ho=class Ho{constructor(e,t){this.Expression="",this.FunName=null,t==null||t==""?this.Expression=e:(this.Expression=e.substring(t.length,e.length-1),this.FunName=t)}static getIsoDateWithTime(e,t){return e==null?null:typeof e=="string"?e:e.getFullYear()+"-"+this.formatToTwoNumber(e.getMonth()+1)+"-"+this.formatToTwoNumber(e.getDate())+t}static getIsoDateTime(e){return e==null?null:typeof e=="string"?e:e.getFullYear()+"-"+this.formatToTwoNumber(e.getMonth()+1)+"-"+this.formatToTwoNumber(e.getDate())+"T"+this.formatToTwoNumber(e.getHours())+":"+this.formatToTwoNumber(e.getMinutes())+":"+this.formatToTwoNumber(e.getSeconds())}static parseDateTime(e){return new Date(e)}static parseDate(e){return new Date(e)}static formatToTwoNumber(e){return e<10?"0"+e:e.toString()}static getIsoDate(e){return e==null?null:typeof e=="string"?e:e.getFullYear()+"-"+this.formatToTwoNumber(e.getMonth()+1)+"-"+this.formatToTwoNumber(e.getDate())+"T00:00:00"}static roundUp(e,t){let n=!1;e<0?n=!0:n=!1,n?e=e-10**-13:e=e+10**-13,e=Math.abs(e);let a=Math.round(e*Math.pow(10,t))/Math.pow(10,t);return n?-1*a:a}};Ho.operators=["<=",">=","!=","<>","==","<",">","="],Ho.logicaloperators=["&&","||"];let We=Ho;class Ei extends We{constructor(e){super(e,null)}Evaluate(e,t,n,a){return this.Expression}}class Hn extends We{constructor(e){super(e,null)}Evaluate(e,t,n,a){if(this.Expression=="null")return null;if(this.Expression.startsWith("N.")&&typeof this.Expression=="string")try{return parseFloat(this.Expression)}catch{throw"Value "+this.Expression+" can't be transformed to numeric!"}return this.Expression}}class wn extends We{constructor(e,t){super(e,null),this.Numeric=!1,this.Numeric=t}Evaluate(e,t,n,a){var i=He.ValueExpresion(a,this.Expression,e,t);if(i==null)return null;if(this.Numeric){if(typeof i=="string")return parseFloat(i);if(typeof i=="number")return i;throw"Value is "+typeof i+" isn't number type!"}return i}}const Ha=class Ha extends We{constructor(e){super(e,null),this.subParse=[];for(var t=[],n="";e.length>0;){var a=!1;for(let f=0;f<We.operators.length;f++){let m=We.operators[f];if(e.startsWith(m)){t.push(new Ei(e.substring(0,m.length))),e=e.substring(m.length),a=!0;break}}if(a)continue;if(["%","(",")"].indexOf(e.substring(0,1))==-1&&!He.StartsWithFunction(e)){n+=e.substring(0,1),e=e.substring(1);continue}if(n!=""&&(t.push(new Hn(n)),n=""),e.startsWith("N.%")){var i=e.substring(3).indexOf("%")+1;t.push(new wn(e.substring(2,i-1),!0)),e=e.substring(i+1);continue}if(e.startsWith("%")){var i=e.substring(1).indexOf("%")+1;t.push(new wn(e.substring(0,i+1),!1)),e=e.substring(i+1);continue}var o=!1;const c=Object.keys(He._suportedFunctions);for(let f=0;f<c.length;f++){let m=c[f];if(e.startsWith(m)){n!=""&&(t.push(new Ha(n)),n="");var l=He.FindEnd(e);if(l==-1)throw"Unbalanced brackets!!!! Expression:"+e;let v=Reflect.construct(He._suportedFunctions[m],[e.substring(0,l+1),m]);t.push(v),l<e.length?e=e.substring(l+1):e="",o=!0;break}}if(!o){var u=!1;for(let f=0;f<Ha._literalValues.length;f++){var s=Ha._literalValues[f];if(e.substring(0,1)==s){t.push(new Hn(s)),e=e.substring(1),u=!0;break}}}}n!=""&&t.push(new Hn(n)),this.subParse=t}Evaluate(e,t,n,a){return this.subParse.length==1?this.subParse[0].Evaluate(e,t,n,a):He.ConcatValues(this.subParse,e,t,n,a)}};Ha._literalValues=["(",")"];let vt=Ha;class At extends We{constructor(e,t){super(e,t)}Evaluate(e,t,n,a){return this.Expression}}class Yo extends We{constructor(e){super(e,null)}Evaluate(e,t,n,a){return this.Expression}}class Ih extends We{constructor(e,t){super(e,t),this.value=[],this.numOfZeros=[];var n=He.GetExpressions(this.Expression,this);if(n==null)return;var a=n.filter(o=>o instanceof At);if(a.length==0)throw"No comma in AddLeadZeros function";let i=[];n.forEach(o=>{o instanceof At?(this.value=i,i=[]):i.push(o)}),this.numOfZeros=i}Evaluate(e,t,n,a){var i=He.ConcatValues(this.value,e,t,n,a),o=He.ConcatValues(this.numOfZeros,e,t,n,a);if(i==null||o==null)return null;let l=-1;if(typeof o=="number"?l=o:typeof o=="string"&&(l=parseInt(o)),l==-1)throw"AddLeadZeros function can't be evaluated! expression: "+this.Expression;for(var u=i.ToString();u.Length<l;)u="0"+u;return u}}class Ph extends We{constructor(e,t){super(e,t),this.FieldName="";var n=this.Expression.split(".");this.Table=n[0],n.length>1&&(this.FieldName=n[1])}Evaluate(e,t,n,a){var i=e.FindTableLevel(this.Table);if(i==null)return!1;let o=[];if(i.Record!=null)o.push(i.Record);else if(i.Records!=null){var l=i.Records;if(l.Records.length==0)return!1;l.Records.forEach(s=>{o.push(s)})}if(o.length==0)return!1;if(this.FieldName=="")return!0;for(var u=0;u<o.length;u++)if(o[u].Record[this.FieldName]!=null)return!0;return!1}}class $h extends We{constructor(e,t){super(e,t),this.conditionParse=[],this.conditionTrueParse=[],this.conditionFalseParse=[];var n=He.GetExpressions(this.Expression,this);if(n!=null){var a=[];for(let i=0;i<n.length;i++)a=this.logic(a,n[i]);if(this.logic(a,null),this.conditionParse.length==0||this.conditionTrueParse.length==0||this.conditionFalseParse.length==0)throw"Can't parse if stategment "+e+"!"}}Evaluate(e,t,n,a){var i=this.conditionParse.filter(c=>c instanceof Yo),o=!1;if(i.length==0)o=this.validateExpression(e,t,n,a,this.conditionParse);else{let c=[],f=[];for(let m=0;m<this.conditionParse.length;m++){let v=this.conditionParse[m];if(v instanceof Yo){var l=this.validateExpression(e,t,n,a,f);f=[],c.push(l),c.push(v.Expression);continue}f.push(v)}if(f.length>0){var l=this.validateExpression(e,t,n,a,f);c.push(l)}o=c[0];for(var u=1;u<c.length;u+=2){var s=c[u];switch(s){case"&&":{o=o&&c[u+1];break}case"||":{o=o||c[u+1];break}}}}return o==!0?He.ConcatValues(this.conditionTrueParse,e,t,n,a):He.ConcatValues(this.conditionFalseParse,e,t,n,a)}logic(e,t){return t==null||t instanceof At?(this.conditionParse.length==0?this.conditionParse=e:this.conditionTrueParse.length==0?this.conditionTrueParse=e:this.conditionFalseParse.length==0&&(this.conditionFalseParse=e),[]):(e.push(t),e)}validateExpression(e,t,n,a,i){let o=null;var l=i.filter(x=>x instanceof Ei);if(l.length==0){if(i.length==1){var u=i[0].Evaluate(e,t,n,a);if(typeof u=="boolean"&&(o=u),u==null&&a.TypeNET=="bool"&&(o=!1),typeof u=="string"){var s=u;s.trim().toLowerCase()=="false"&&(o=!1),s.trim().toLowerCase()=="true"&&(o=!0)}}}else{let x=[],D=[];var c=x;for(let h=0;h<i.length;h++){if(i[h]instanceof Ei){c=D;continue}c.push(i[h])}var f=He.ConcatValues(x,e,t,n,a),m=He.ConcatValues(D,e,t,n,a);if(f==null||m==null)switch(l[0].Expression){case"=":case"==":return o=f==m,this.evaluateCondition(o);case"!=":case"<>":return o=f!=m,this.evaluateCondition(o)}if(typeof f=="number"&&typeof m=="number"){var v=f,p=m;switch(l[0].Expression){case">=":return o=v>=p,this.evaluateCondition(o);case"<=":return o=v<=p,this.evaluateCondition(o);case"!=":case"<>":return o=v!=p,this.evaluateCondition(o);case"<":return o=v<p,this.evaluateCondition(o);case">":return o=v>p,this.evaluateCondition(o);case"==":case"=":return o=v==p,this.evaluateCondition(o);default:throw"Operator "+l[0].Expression+" not supported on condition decimal and decimal"}}if(typeof f=="string"&&typeof m=="string"){if((f.toLowerCase()=="false"||f.toLowerCase()=="true")&&(m.toLowerCase()=="false"||m.toLowerCase()=="true")){let h=!!f,w=!!m;switch(l[0].Expression){case"!=":case"<>":return o=h!=w,this.evaluateCondition(o);case"==":case"=":return o=h==w,this.evaluateCondition(o);default:throw"Operator "+l[0].Expression+" not supported on condition bool and bool"}}return o=this.StringCompare(f,m,l[0].Expression),this.evaluateCondition(o)}if(f instanceof Date&&typeof m=="string"){var d=We.getIsoDateTime(f);return o=this.StringCompare(d,m,l[0].Expression),this.evaluateCondition(o)}if(typeof f=="string"&&m instanceof Date){var y=We.getIsoDateTime(m);return o=this.StringCompare(f,y,l[0].Expression),this.evaluateCondition(o)}if(f instanceof Date&&m instanceof Date)switch(l[0].Expression){case">=":return o=f>=m,this.evaluateCondition(o);case"<=":return o=f<=m,this.evaluateCondition(o);case"!=":case"<>":return o=f!=m,this.evaluateCondition(o);case"<":return o=f<m,this.evaluateCondition(o);case">":return o=f>m,this.evaluateCondition(o);case"==":case"=":return o=f==m,this.evaluateCondition(o);default:throw"Operator "+l[0].Expression+" not supported on condition string"}}return this.evaluateCondition(o)}evaluateCondition(e){if(e==null){debugger;throw"Can't eval "+this.Expression+"!"}return e}StringCompare(e,t,n){switch(n){case"!=":case"<>":return e!=t;case"==":case"=":return e==t;default:throw"Operator "+n+" not supported on condition string"}}}class qh extends We{constructor(e,t){super(e,t)}Evaluate(e,t,n,a){return e.SumByKey(this.Expression)}}class zh extends We{constructor(e,t){super(e,t),this.value="",this.offset="";var n=this.Expression.split(",");n.length==2&&(this.value=n[0],this.offset=n[1])}Evaluate(e,t,n,a){if(this.value==""||this.offset=="")return null;var i=new vt(this.value),o=i.Evaluate(e,t,n,a),l=new vt(this.offset),u=l.Evaluate(e,t,n,a),s=null,c=null;if(o.constructor.name=="Date"?s=o:typeof o=="string"&&(s=new Date(o)),typeof u=="number"?c=u:typeof u=="string"&&(c=parseInt(u)),c!=null&&s!=null){if(s.setDate(s.getDate()+c),a.TypeDDD=="Date")return We.getIsoDate(s);if(a.TypeDDD=="DateTime")return We.getIsoDateTime(s)}else debugger;return this.Expression}}class Mu extends We{constructor(e,t){super(e,t),this.lower=!0,t.toLowerCase()=="upper("&&(this.lower=!1)}Evaluate(e,t,n,a){var i=He.GetExpressions(this.Expression,this);if(i==null)return null;var o=He.ConcatValues(i,e,t,n,a);return o==null?null:typeof o=="string"?this.lower?o.toLowerCase():o.toUpperCase():o}}class _u extends We{constructor(e,t){if(super(e,t),this.Negate=!1,this.FieldSet="",this.aviableValues=[],this.Expression!=null&&this.Expression.startsWith("(")){var n=He.FindEnd(this.Expression),a=this.Expression.substring(1,n);this.FieldSet=this.Expression.substring(n+2),this.aviableValues=a.split(","),(t==null?void 0:t.toLowerCase())=="notinlist("&&(this.Negate=!0)}}Evaluate(e,t,n,a){var i=new wn(this.FieldSet,!1),o=i.Evaluate(e,t,n,a);if(o==null||this.aviableValues.length==0)return!1;var l=this.aviableValues.indexOf(o.toString());return this.Negate?l==-1:l!=-1}}class Tu extends We{constructor(e,t){if(super(e,t),this.Negate=!1,this.TableAndField="",this.Table="",this.Field="",this.aviableValues=[],this.Expression!=null&&this.Expression.startsWith("(")){var n=He.FindEnd(this.Expression),a=this.Expression.substring(1,n);if(this.TableAndField=this.Expression.substring(n+2),this.TableAndField==null||this.TableAndField=="")throw"Invalid expresion InDetail - table.field is empty!";if(a==null||a=="")throw"Invalid expresion InDetail - set of values is empty!";var i=this.TableAndField.split(".");if(i.length==2)this.Table=i[0],this.Field=i[1];else throw"Invalid expresion InDetail - table.field not in correction format!";this.aviableValues=a.split(","),(t==null?void 0:t.toLowerCase())=="notindetail("&&(this.Negate=!0)}}Evaluate(e,t,n,a){var i=e.FindTableLevel(this.Table);if(i==null)return!1;if(i.Records!=null){var o=i.Records.Records;if(this.Negate){for(var l=0;l<o.length;l++){let s=o[l];if(s.Record[this.Field]==null)continue;if(this.aviableValues.filter(f=>f!=s.Record[this.Field].toString()).length>0)return!0}return!1}else{for(var l=0;l<o.length;l++){let u=o[l];if(u.Record[this.Field]==null)continue;if(this.aviableValues.filter(c=>c==u.Record[this.Field].toString()).length>0)return!0}return!1}}}}class Uh extends We{constructor(e,t){super(e,t),this.starts=null,this.value=null;var n=this.Expression.split(",");n.length==2&&(this.starts=new vt(n[0]),this.value=new vt(n[1]))}Evaluate(e,t,n,a){var c,f;var i=(c=this.starts)==null?void 0:c.Evaluate(e,t,n,a),o=(f=this.value)==null?void 0:f.Evaluate(e,t,n,a);if(i==null||o==null)return!1;var l=i.ToString(),u=o.ToString(),s=u.startsWith(l);return s}}class Lh extends We{constructor(e,t){super(e,t),this.starts=[],this.value=[],this.length=[];var n=He.GetExpressions(this.Expression,this),a=[];if(n!=null){for(let i=0;i<n.length;i++)a=this.logic(a,n[i]);if(this.logic(a,null),this.value.length==0||this.starts.length==0||this.length.length==0)throw"Can't parse if stategment "+e+"!"}}Evaluate(e,t,n,a){var i=He.ConcatValues(this.value,e,t,n,a);if(i==null)return null;var o=i.ToString();let l=-1;var u=He.ConcatValues(this.starts,e,t,n,a);if(typeof u=="number"?l=u:typeof u=="string"&&(l=parseInt(u)),l==-1)throw"Substr start index can't be parsed! Value: "+u+"!";l--;let s=-1;var c=He.ConcatValues(this.length,e,t,n,a);if(typeof c=="number"?s=c:c=="string"&&(s=parseInt(c)),s==-1)throw"Substr length index can't be parsed! Value: "+c+"!";if(o.Length<=l)return null;var f=o.substring(l);return f.Length<=s?f:f.substring(0,s)}logic(e,t){return t==null||t instanceof At?(this.value.length==0?this.value=e:this.starts.length==0?this.starts=e:this.length.length==0&&(this.length=e),[]):(e.push(t),e)}}class kh extends We{constructor(e,t){super(e,t),this.Table=";",this.Table=this.Expression}Evaluate(e,t,n,a){var o;if(this.Table=="")throw"Function count don't have defined table!";var i=e.FindTableLevel(this.Table);return i==null?-1:(o=i.Records)==null?void 0:o.Records.length}}class Fu extends We{constructor(e,t){var a;super(e,t),this.Table="",this.FieldName="",this.Negate=!1,t.toLowerCase()=="notexists("&&(this.Negate=!0);var n=this.Expression.split(".");n.length!=2,this.Table=n[0],this.FieldName=n[1],(a=this.Table)!=null&&a.startsWith("!")&&(this.Table=this.Table.substring(1),this.Negate=!0)}Evaluate(e,t,n,a){var c;if(this.Table==null)throw"No table";var i=e.FindTableLevel(this.Table);if(i==null)throw"Table level "+this.Table+" don't exist in object!";let o=!1;if(i==e.rootLevel){var l=i.Record;o=(l==null?void 0:l.Record.Record[this.FieldName])!=null}else{var u=i.Records;if(u==null)throw"Table level "+this.Table+" don't have active records!";var s=u.Records.indexOf(t);if(s==-1)throw"Table level "+this.Table+" not the same as record!"+((c=t==null?void 0:t.Parent)==null?void 0:c.Tablename);o=u.Records[s].Record[this.FieldName]!=null}return this.Negate&&(o=!o),o}}class Ou extends We{constructor(e,t){super(e,t),this.valueExp=null,this.Negate=!1,t.toLowerCase()=="nonempty("&&(this.Negate=!0);var n=He.GetExpressions(this.Expression,this);if(n!=null)if(n.length==1&&n[0]instanceof vt)this.valueExp=n[0];else throw"Expression '"+this.Expression+"' isn't ValueFromObjParse"}Evaluate(e,t,n,a){var s;var i=(s=this.valueExp)==null?void 0:s.Evaluate(e,t,n,a);let o=!1;if(i==null)o=!0;else if(typeof i=="string"){var l=i;o=l==""||l.trim()==""}else if(typeof i=="number"){var u=i;o=u==0}return this.Negate?!o:o}}class Vh extends We{constructor(e,t){super(e,t),this.sections=[],this.sections=He.GetExpressions(this.Expression,this)??[]}Evaluate(e,t,n,a){for(var i="",o=0;o<this.sections.length;o++){let u=this.sections[o];if(!(u instanceof At)){var l=u.Evaluate(e,t,n,a);l!=null&&(i+=l)}}return i}}class Gh extends We{constructor(e,t){super(e,t),this.Detail="",this.Exp="",this.Parameter="";var n=this.Expression.split(",");if(n.length==2){var n=this.Expression.split(",");if(n.length!=3)throw"Check have more or less parameters that 3";this.Detail=n[0],this.Exp=n[1],this.Parameter=n[2]}}Evaluate(e,t,n,a){var m,v,p;var i=[];if(!Mh.isMultiple(this.Detail)){var o=e.FindTableLevel(this.Detail);if(o==null)throw"Can't find level {Detail}";if(o.Record!=null)throw"Table level isn't detail!";if(o.Records==null)throw"Table level doesn't have records!";for(var l=o.Records.Records,u=0;u<l.length;u++)i.push(l[u])}for(var s=0,u=0;u<i.length;u++){var c=i[u],f=He.ParseExpressionAndReturnValue("IF("+this.Exp+",true,false)",e,a,c,0);if(f=="true"&&(s++,((m=this.Parameter)==null?void 0:m.toLocaleLowerCase())=="one"))return!0}if(((v=this.Parameter)==null?void 0:v.toLocaleLowerCase())=="one")return!1;if(((p=this.Parameter)==null?void 0:p.toLocaleLowerCase())=="all")return s==i.length;throw"Check prameter isn't valid!Valid:One,All.Provided:"+this.Parameter}}class Hh extends We{constructor(e,t){super(e,t)}Evaluate(e,t,n,a){var i=He.GetExpressions(this.Expression,this);if(i==null)return null;if(i.length==1){var o=i[0].Evaluate(e,t,n,a);return typeof o=="string"?o.trim():o}return i.length}}class Wh extends We{constructor(e,t){super(e,null),this.Table="",this.FieldName="",this.Position="";var n=this.Expression.split(","),a="first";n.length==2&&(a=n[1]);var i=n[0].split(".");this.Table=i[0],this.FieldName=i[1],this.Position=a}Evaluate(e,t,n,a){var i=e.FindTableLevel(this.Table);if(i==null)return null;let o=null;if(i.Record!=null)o=i.Record;else if(i.Records!=null){var l=i.Records;if(l.Records.length==0)return null;this.Position.toLowerCase()=="first"?o=l.Records[0].Record:this.Position.toLowerCase()=="first"&&(o=l.Records[l.Records.length-1].Record)}if(o==null)throw"Can't find valid record for "+this.Table+"!";if(o[this.FieldName]==null)throw"Value not defined for fieldname "+this.FieldName+"!";var u=o[this.FieldName];return u==null?null:typeof u=="number"?u:u.ToString()}}class Yh extends We{constructor(e,t){super(e,t),this.useFirstExpressions=[];var n=[],a=He.GetExpressions(this.Expression,this);a==null||a.forEach(i=>{if(i instanceof At&&n.length>0){this.useFirstExpressions.push(n),n=[];return}n.push(i)}),n.length>0&&this.useFirstExpressions.push(n)}Evaluate(e,t,n,a){for(var i=0;i<this.useFirstExpressions.length;i++){var o=this.useFirstExpressions[i],l=He.ConcatValues(o,e,t,n,a);if(l!=null&&l!=null)return l}return null}}class Zh extends We{constructor(e,t){super(e,t),this.Table="",this.FieldName="",this.Negate=!1}Evaluate(e,t,n,a){if(a.ValidValuesRegistry==null)throw"SchemaStruct "+a.Alias+" don't have valid values registry defined.";var i=this.Expression;(i==null||i=="")&&(i="%"+a.TableName+"."+a.FieldName+"%");var o=He.GetExpressions(i,this),l=He.ConcatValues(o,e,t,n,a);if(l==null)return null;var u=a.ValidValuesRegistry.filter(s=>s.Code.toLowerCase().includes(l.toLowerCase()));return u!=null&&u.length>0?u[0].Name:(u=u=a.ValidValuesRegistry.filter(s=>s.Name.toLowerCase().includes(l.toLowerCase())),u!=null&&u.length>0?u[0].Code:null)}}class Jh extends We{constructor(e,t){super(e,t)}Evaluate(e,t,n,a){var i=new wn(this.Expression,!1),o=i.Evaluate(e,t,n,a),l=null;if(o instanceof Date?l=o:typeof o=="string"&&(l=new Date(o.toString())),l==null)throw new Error("Can't convert "+o+" isn't datetime!");return l.getFullYear()}}class jh extends We{constructor(e,t){super(e,t)}Evaluate(e,t,n,a){var i=new wn(this.Expression,!1),o=i.Evaluate(e,t,n,a),l=null;if(o instanceof Date?l=o:typeof o=="string"&&(l=new Date(o.toString())),l==null)throw new Error("Can't convert "+o+" isn't datetime!");return this.GetMonth(l.getMonth()+1)}GetMonth(e){return e>=10?e.toString():"0"+e.toString()}}class Xh extends We{constructor(e,t){super(e,t),this.valueParse=null,this.regexParse=null;let n=He.GetExpressions(this.Expression,this);if(n==null)throw new Error(`Error parsing Sum function: ${this.Expression}`);var a=[];for(let i=0;i<n.length;i++){let o=n[i];if(o instanceof At){if(this.valueParse==null)this.valueParse=a,a=[];else if(this.regexParse==null)throw new Error(`Clean function has too many parameters: ${this.Expression}`);continue}a.push(o)}if(a.length>0&&(this.valueParse==null?this.valueParse=a:this.regexParse=a,a=[]),this.regexParse==null||this.valueParse==null)throw new Error(`Clean function has few parameters: ${this.Expression}`)}Evaluate(e,t,n,a){var l;if(this.valueParse==null)return;let i=null;if(this.valueParse.length==1?i=this.valueParse[0].Evaluate(e,t,n,a):i=He.ConcatValues(this.valueParse,e,t,n,a),this.regexParse==null)return i;var o=(l=He.ConcatValues(this.regexParse,e,t,n,a))==null?void 0:l.ToString();return o==null?i:(o=o+"/g",i.replace("/"+o+"/g",""))}}class Qh extends We{constructor(e,t){super(e,t),this.valueParse=null,this.regexParse=null;let n=He.GetExpressions(this.Expression,this);if(n==null)throw new Error(`Error parsing Sum function: ${this.Expression}`);var a=[];for(let i=0;i<n.length;i++){let o=n[i];if(o instanceof At){if(this.valueParse==null)this.valueParse=a,a=[];else if(this.regexParse==null)throw new Error(`Clean function has too many parameters: ${this.Expression}`);continue}a.push(o)}if(a.length>0&&(this.valueParse==null?this.valueParse=a:this.regexParse=a,a=[]),this.regexParse==null||this.valueParse==null)throw new Error(`Clean function has few parameters: ${this.Expression}`)}Evaluate(e,t,n,a){var u;if(this.valueParse==null)return;let i=null;if(this.valueParse.length==1?i=this.valueParse[0].Evaluate(e,t,n,a):i=He.ConcatValues(this.valueParse,e,t,n,a),this.regexParse==null)return i;var o=(u=He.ConcatValues(this.regexParse,e,t,n,a))==null?void 0:u.ToString();if(o==null)return i;o=o+"/g";var l=i.match("/"+o+"/g","");return l!=null&&l.length>0?l[0]:null}}const Bu=6048e5,Kh=864e5,Ru=Symbol.for("constructDateFrom");function Dn(r,e){return typeof r=="function"?r(e):r&&typeof r=="object"&&Ru in r?r[Ru](e):r instanceof Date?new r.constructor(e):new Date(e)}function Gt(r,e){return Dn(e||r,r)}let eg={};function Ai(){return eg}function Za(r,e){var l,u,s,c;const t=Ai(),n=(e==null?void 0:e.weekStartsOn)??((u=(l=e==null?void 0:e.locale)==null?void 0:l.options)==null?void 0:u.weekStartsOn)??t.weekStartsOn??((c=(s=t.locale)==null?void 0:s.options)==null?void 0:c.weekStartsOn)??0,a=Gt(r,e==null?void 0:e.in),i=a.getDay(),o=(i<n?7:0)+i-n;return a.setDate(a.getDate()-o),a.setHours(0,0,0,0),a}function Si(r,e){return Za(r,{...e,weekStartsOn:1})}function Iu(r,e){const t=Gt(r,e==null?void 0:e.in),n=t.getFullYear(),a=Dn(t,0);a.setFullYear(n+1,0,4),a.setHours(0,0,0,0);const i=Si(a),o=Dn(t,0);o.setFullYear(n,0,4),o.setHours(0,0,0,0);const l=Si(o);return t.getTime()>=i.getTime()?n+1:t.getTime()>=l.getTime()?n:n-1}function Pu(r){const e=Gt(r),t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+r-+t}function rg(r,...e){const t=Dn.bind(null,e.find(n=>typeof n=="object"));return e.map(t)}function $u(r,e){const t=Gt(r,e==null?void 0:e.in);return t.setHours(0,0,0,0),t}function tg(r,e,t){const[n,a]=rg(t==null?void 0:t.in,r,e),i=$u(n),o=$u(a),l=+i-Pu(i),u=+o-Pu(o);return Math.round((l-u)/Kh)}function ng(r,e){const t=Iu(r,e),n=Dn(r,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),Si(n)}function ag(r){return r instanceof Date||typeof r=="object"&&Object.prototype.toString.call(r)==="[object Date]"}function ig(r){return!(!ag(r)&&typeof r!="number"||isNaN(+Gt(r)))}function og(r,e){const t=Gt(r,e==null?void 0:e.in);return t.setFullYear(t.getFullYear(),0,1),t.setHours(0,0,0,0),t}const sg={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},ug=(r,e,t)=>{let n;const a=sg[r];return typeof a=="string"?n=a:e===1?n=a.one:n=a.other.replace("{{count}}",e.toString()),t!=null&&t.addSuffix?t.comparison&&t.comparison>0?"in "+n:n+" ago":n};function Zo(r){return(e={})=>{const t=e.width?String(e.width):r.defaultWidth;return r.formats[t]||r.formats[r.defaultWidth]}}const lg={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},cg={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},fg={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},mg={date:Zo({formats:lg,defaultWidth:"full"}),time:Zo({formats:cg,defaultWidth:"full"}),dateTime:Zo({formats:fg,defaultWidth:"full"})},vg={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},pg=(r,e,t,n)=>vg[r];function Ja(r){return(e,t)=>{const n=t!=null&&t.context?String(t.context):"standalone";let a;if(n==="formatting"&&r.formattingValues){const o=r.defaultFormattingWidth||r.defaultWidth,l=t!=null&&t.width?String(t.width):o;a=r.formattingValues[l]||r.formattingValues[o]}else{const o=r.defaultWidth,l=t!=null&&t.width?String(t.width):r.defaultWidth;a=r.values[l]||r.values[o]}const i=r.argumentCallback?r.argumentCallback(e):e;return a[i]}}const dg={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},hg={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},gg={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},yg={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},bg={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},xg={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},wg={ordinalNumber:(r,e)=>{const t=Number(r),n=t%100;if(n>20||n<10)switch(n%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},era:Ja({values:dg,defaultWidth:"wide"}),quarter:Ja({values:hg,defaultWidth:"wide",argumentCallback:r=>r-1}),month:Ja({values:gg,defaultWidth:"wide"}),day:Ja({values:yg,defaultWidth:"wide"}),dayPeriod:Ja({values:bg,defaultWidth:"wide",formattingValues:xg,defaultFormattingWidth:"wide"})};function ja(r){return(e,t={})=>{const n=t.width,a=n&&r.matchPatterns[n]||r.matchPatterns[r.defaultMatchWidth],i=e.match(a);if(!i)return null;const o=i[0],l=n&&r.parsePatterns[n]||r.parsePatterns[r.defaultParseWidth],u=Array.isArray(l)?Ng(l,f=>f.test(o)):Dg(l,f=>f.test(o));let s;s=r.valueCallback?r.valueCallback(u):u,s=t.valueCallback?t.valueCallback(s):s;const c=e.slice(o.length);return{value:s,rest:c}}}function Dg(r,e){for(const t in r)if(Object.prototype.hasOwnProperty.call(r,t)&&e(r[t]))return t}function Ng(r,e){for(let t=0;t<r.length;t++)if(e(r[t]))return t}function Eg(r){return(e,t={})=>{const n=e.match(r.matchPattern);if(!n)return null;const a=n[0],i=e.match(r.parsePattern);if(!i)return null;let o=r.valueCallback?r.valueCallback(i[0]):i[0];o=t.valueCallback?t.valueCallback(o):o;const l=e.slice(a.length);return{value:o,rest:l}}}const Ag=/^(\d+)(th|st|nd|rd)?/i,Sg=/\d+/i,Cg={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Mg={any:[/^b/i,/^(a|c)/i]},_g={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Tg={any:[/1/i,/2/i,/3/i,/4/i]},Fg={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Og={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Bg={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Rg={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Ig={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Pg={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},$g={ordinalNumber:Eg({matchPattern:Ag,parsePattern:Sg,valueCallback:r=>parseInt(r,10)}),era:ja({matchPatterns:Cg,defaultMatchWidth:"wide",parsePatterns:Mg,defaultParseWidth:"any"}),quarter:ja({matchPatterns:_g,defaultMatchWidth:"wide",parsePatterns:Tg,defaultParseWidth:"any",valueCallback:r=>r+1}),month:ja({matchPatterns:Fg,defaultMatchWidth:"wide",parsePatterns:Og,defaultParseWidth:"any"}),day:ja({matchPatterns:Bg,defaultMatchWidth:"wide",parsePatterns:Rg,defaultParseWidth:"any"}),dayPeriod:ja({matchPatterns:Ig,defaultMatchWidth:"any",parsePatterns:Pg,defaultParseWidth:"any"})},qg={code:"en-US",formatDistance:ug,formatLong:mg,formatRelative:pg,localize:wg,match:$g,options:{weekStartsOn:0,firstWeekContainsDate:1}};function zg(r,e){const t=Gt(r,e==null?void 0:e.in);return tg(t,og(t))+1}function Ug(r,e){const t=Gt(r,e==null?void 0:e.in),n=+Si(t)-+ng(t);return Math.round(n/Bu)+1}function qu(r,e){var c,f,m,v;const t=Gt(r,e==null?void 0:e.in),n=t.getFullYear(),a=Ai(),i=(e==null?void 0:e.firstWeekContainsDate)??((f=(c=e==null?void 0:e.locale)==null?void 0:c.options)==null?void 0:f.firstWeekContainsDate)??a.firstWeekContainsDate??((v=(m=a.locale)==null?void 0:m.options)==null?void 0:v.firstWeekContainsDate)??1,o=Dn((e==null?void 0:e.in)||r,0);o.setFullYear(n+1,0,i),o.setHours(0,0,0,0);const l=Za(o,e),u=Dn((e==null?void 0:e.in)||r,0);u.setFullYear(n,0,i),u.setHours(0,0,0,0);const s=Za(u,e);return+t>=+l?n+1:+t>=+s?n:n-1}function Lg(r,e){var l,u,s,c;const t=Ai(),n=(e==null?void 0:e.firstWeekContainsDate)??((u=(l=e==null?void 0:e.locale)==null?void 0:l.options)==null?void 0:u.firstWeekContainsDate)??t.firstWeekContainsDate??((c=(s=t.locale)==null?void 0:s.options)==null?void 0:c.firstWeekContainsDate)??1,a=qu(r,e),i=Dn((e==null?void 0:e.in)||r,0);return i.setFullYear(a,0,n),i.setHours(0,0,0,0),Za(i,e)}function kg(r,e){const t=Gt(r,e==null?void 0:e.in),n=+Za(t,e)-+Lg(t,e);return Math.round(n/Bu)+1}function Er(r,e){const t=r<0?"-":"",n=Math.abs(r).toString().padStart(e,"0");return t+n}const Nn={y(r,e){const t=r.getFullYear(),n=t>0?t:1-t;return Er(e==="yy"?n%100:n,e.length)},M(r,e){const t=r.getMonth();return e==="M"?String(t+1):Er(t+1,2)},d(r,e){return Er(r.getDate(),e.length)},a(r,e){const t=r.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return t.toUpperCase();case"aaa":return t;case"aaaaa":return t[0];case"aaaa":default:return t==="am"?"a.m.":"p.m."}},h(r,e){return Er(r.getHours()%12||12,e.length)},H(r,e){return Er(r.getHours(),e.length)},m(r,e){return Er(r.getMinutes(),e.length)},s(r,e){return Er(r.getSeconds(),e.length)},S(r,e){const t=e.length,n=r.getMilliseconds(),a=Math.trunc(n*Math.pow(10,t-3));return Er(a,e.length)}},fa={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},zu={G:function(r,e,t){const n=r.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return t.era(n,{width:"abbreviated"});case"GGGGG":return t.era(n,{width:"narrow"});case"GGGG":default:return t.era(n,{width:"wide"})}},y:function(r,e,t){if(e==="yo"){const n=r.getFullYear(),a=n>0?n:1-n;return t.ordinalNumber(a,{unit:"year"})}return Nn.y(r,e)},Y:function(r,e,t,n){const a=qu(r,n),i=a>0?a:1-a;if(e==="YY"){const o=i%100;return Er(o,2)}return e==="Yo"?t.ordinalNumber(i,{unit:"year"}):Er(i,e.length)},R:function(r,e){const t=Iu(r);return Er(t,e.length)},u:function(r,e){const t=r.getFullYear();return Er(t,e.length)},Q:function(r,e,t){const n=Math.ceil((r.getMonth()+1)/3);switch(e){case"Q":return String(n);case"QQ":return Er(n,2);case"Qo":return t.ordinalNumber(n,{unit:"quarter"});case"QQQ":return t.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return t.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return t.quarter(n,{width:"wide",context:"formatting"})}},q:function(r,e,t){const n=Math.ceil((r.getMonth()+1)/3);switch(e){case"q":return String(n);case"qq":return Er(n,2);case"qo":return t.ordinalNumber(n,{unit:"quarter"});case"qqq":return t.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return t.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return t.quarter(n,{width:"wide",context:"standalone"})}},M:function(r,e,t){const n=r.getMonth();switch(e){case"M":case"MM":return Nn.M(r,e);case"Mo":return t.ordinalNumber(n+1,{unit:"month"});case"MMM":return t.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return t.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return t.month(n,{width:"wide",context:"formatting"})}},L:function(r,e,t){const n=r.getMonth();switch(e){case"L":return String(n+1);case"LL":return Er(n+1,2);case"Lo":return t.ordinalNumber(n+1,{unit:"month"});case"LLL":return t.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return t.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return t.month(n,{width:"wide",context:"standalone"})}},w:function(r,e,t,n){const a=kg(r,n);return e==="wo"?t.ordinalNumber(a,{unit:"week"}):Er(a,e.length)},I:function(r,e,t){const n=Ug(r);return e==="Io"?t.ordinalNumber(n,{unit:"week"}):Er(n,e.length)},d:function(r,e,t){return e==="do"?t.ordinalNumber(r.getDate(),{unit:"date"}):Nn.d(r,e)},D:function(r,e,t){const n=zg(r);return e==="Do"?t.ordinalNumber(n,{unit:"dayOfYear"}):Er(n,e.length)},E:function(r,e,t){const n=r.getDay();switch(e){case"E":case"EE":case"EEE":return t.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return t.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(n,{width:"short",context:"formatting"});case"EEEE":default:return t.day(n,{width:"wide",context:"formatting"})}},e:function(r,e,t,n){const a=r.getDay(),i=(a-n.weekStartsOn+8)%7||7;switch(e){case"e":return String(i);case"ee":return Er(i,2);case"eo":return t.ordinalNumber(i,{unit:"day"});case"eee":return t.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return t.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return t.day(a,{width:"short",context:"formatting"});case"eeee":default:return t.day(a,{width:"wide",context:"formatting"})}},c:function(r,e,t,n){const a=r.getDay(),i=(a-n.weekStartsOn+8)%7||7;switch(e){case"c":return String(i);case"cc":return Er(i,e.length);case"co":return t.ordinalNumber(i,{unit:"day"});case"ccc":return t.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return t.day(a,{width:"narrow",context:"standalone"});case"cccccc":return t.day(a,{width:"short",context:"standalone"});case"cccc":default:return t.day(a,{width:"wide",context:"standalone"})}},i:function(r,e,t){const n=r.getDay(),a=n===0?7:n;switch(e){case"i":return String(a);case"ii":return Er(a,e.length);case"io":return t.ordinalNumber(a,{unit:"day"});case"iii":return t.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return t.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return t.day(n,{width:"short",context:"formatting"});case"iiii":default:return t.day(n,{width:"wide",context:"formatting"})}},a:function(r,e,t){const a=r.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return t.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return t.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return t.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return t.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(r,e,t){const n=r.getHours();let a;switch(n===12?a=fa.noon:n===0?a=fa.midnight:a=n/12>=1?"pm":"am",e){case"b":case"bb":return t.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return t.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return t.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return t.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(r,e,t){const n=r.getHours();let a;switch(n>=17?a=fa.evening:n>=12?a=fa.afternoon:n>=4?a=fa.morning:a=fa.night,e){case"B":case"BB":case"BBB":return t.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return t.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return t.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(r,e,t){if(e==="ho"){let n=r.getHours()%12;return n===0&&(n=12),t.ordinalNumber(n,{unit:"hour"})}return Nn.h(r,e)},H:function(r,e,t){return e==="Ho"?t.ordinalNumber(r.getHours(),{unit:"hour"}):Nn.H(r,e)},K:function(r,e,t){const n=r.getHours()%12;return e==="Ko"?t.ordinalNumber(n,{unit:"hour"}):Er(n,e.length)},k:function(r,e,t){let n=r.getHours();return n===0&&(n=24),e==="ko"?t.ordinalNumber(n,{unit:"hour"}):Er(n,e.length)},m:function(r,e,t){return e==="mo"?t.ordinalNumber(r.getMinutes(),{unit:"minute"}):Nn.m(r,e)},s:function(r,e,t){return e==="so"?t.ordinalNumber(r.getSeconds(),{unit:"second"}):Nn.s(r,e)},S:function(r,e){return Nn.S(r,e)},X:function(r,e,t){const n=r.getTimezoneOffset();if(n===0)return"Z";switch(e){case"X":return Lu(n);case"XXXX":case"XX":return Wn(n);case"XXXXX":case"XXX":default:return Wn(n,":")}},x:function(r,e,t){const n=r.getTimezoneOffset();switch(e){case"x":return Lu(n);case"xxxx":case"xx":return Wn(n);case"xxxxx":case"xxx":default:return Wn(n,":")}},O:function(r,e,t){const n=r.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+Uu(n,":");case"OOOO":default:return"GMT"+Wn(n,":")}},z:function(r,e,t){const n=r.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+Uu(n,":");case"zzzz":default:return"GMT"+Wn(n,":")}},t:function(r,e,t){const n=Math.trunc(+r/1e3);return Er(n,e.length)},T:function(r,e,t){return Er(+r,e.length)}};function Uu(r,e=""){const t=r>0?"-":"+",n=Math.abs(r),a=Math.trunc(n/60),i=n%60;return i===0?t+String(a):t+String(a)+e+Er(i,2)}function Lu(r,e){return r%60===0?(r>0?"-":"+")+Er(Math.abs(r)/60,2):Wn(r,e)}function Wn(r,e=""){const t=r>0?"-":"+",n=Math.abs(r),a=Er(Math.trunc(n/60),2),i=Er(n%60,2);return t+a+e+i}const ku=(r,e)=>{switch(r){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},Vu=(r,e)=>{switch(r){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},Vg={p:Vu,P:(r,e)=>{const t=r.match(/(P+)(p+)?/)||[],n=t[1],a=t[2];if(!a)return ku(r,e);let i;switch(n){case"P":i=e.dateTime({width:"short"});break;case"PP":i=e.dateTime({width:"medium"});break;case"PPP":i=e.dateTime({width:"long"});break;case"PPPP":default:i=e.dateTime({width:"full"});break}return i.replace("{{date}}",ku(n,e)).replace("{{time}}",Vu(a,e))}},Gg=/^D+$/,Hg=/^Y+$/,Wg=["D","DD","YY","YYYY"];function Yg(r){return Gg.test(r)}function Zg(r){return Hg.test(r)}function Jg(r,e,t){const n=jg(r,e,t);if(console.warn(n),Wg.includes(r))throw new RangeError(n)}function jg(r,e,t){const n=r[0]==="Y"?"years":"days of the month";return`Use \`${r.toLowerCase()}\` instead of \`${r}\` (in \`${e}\`) for formatting ${n} to the input \`${t}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Xg=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Qg=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Kg=/^'([^]*?)'?$/,e0=/''/g,r0=/[a-zA-Z]/;function t0(r,e,t){var c,f,m,v;const n=Ai(),a=n.locale??qg,i=n.firstWeekContainsDate??((f=(c=n.locale)==null?void 0:c.options)==null?void 0:f.firstWeekContainsDate)??1,o=n.weekStartsOn??((v=(m=n.locale)==null?void 0:m.options)==null?void 0:v.weekStartsOn)??0,l=Gt(r,t==null?void 0:t.in);if(!ig(l))throw new RangeError("Invalid time value");let u=e.match(Qg).map(p=>{const d=p[0];if(d==="p"||d==="P"){const y=Vg[d];return y(p,a.formatLong)}return p}).join("").match(Xg).map(p=>{if(p==="''")return{isToken:!1,value:"'"};const d=p[0];if(d==="'")return{isToken:!1,value:n0(p)};if(zu[d])return{isToken:!0,value:p};if(d.match(r0))throw new RangeError("Format string contains an unescaped latin alphabet character `"+d+"`");return{isToken:!1,value:p}});a.localize.preprocessor&&(u=a.localize.preprocessor(l,u));const s={firstWeekContainsDate:i,weekStartsOn:o,locale:a};return u.map(p=>{if(!p.isToken)return p.value;const d=p.value;(Zg(d)||Yg(d))&&Jg(d,e,String(r));const y=zu[d[0]];return y(l,d,a.localize,s)}).join("")}function n0(r){const e=r.match(Kg);return e?e[1].replace(e0,"'"):r}class a0 extends We{constructor(e,t){super(e,t),this.fieldDateTime=null,this.formatDateTime=null;let n=He.GetExpressions(this.Expression,this);if(n==null)throw new Error(`Error parsing DateTimeFormat function: ${this.Expression}`);var a=[];for(let o=0;o<n.length;o++){var i=n[o];if(i instanceof At){if(this.fieldDateTime==null)this.fieldDateTime=a,a=[];else if(this.formatDateTime==null)this.formatDateTime=a,a=[];else throw new Error(`DateTimeFormat function has too many parameters: ${this.Expression}`);continue}}if(a.length>0)if(this.fieldDateTime==null)this.fieldDateTime=a;else if(this.formatDateTime==null)this.formatDateTime=a;else throw new Error(`DateTimeFormat function has too many parameters: ${this.Expression}`)}Evaluate(e,t,n,a){if(this.fieldDateTime==null&&this.formatDateTime==null)throw new Error("Invalid expression "+this.Expression+" for TotalMinutesParse function!");let i="yyyy-MM-ddTHH:mm:ss";var o=He.ConcatValues(this.fieldDateTime,e,t,n,a);const l=new Date(o.ToString());if(this.formatDateTime!=null){let u=He.ConcatValues(this.formatDateTime,e,t,n,a);if(u==null)throw new Error("Invalid format for DateTimeFormatParse function in "+this.Expression+"!");i=u.ToString()}return t0(l,i)}}class i0 extends We{constructor(e,t){super(e,t)}Evaluate(e,t,n,a){var v,p,d;let i=null,o=null;if(this.Expression==null||this.Expression=="")i=a.TableName,o=a.FieldName;else{var l=this.Expression.split(".");if(l.length!=2)return!1;i=l[0],o=l[1]}if(i==(((v=t.Parent)==null?void 0:v.Tablename)??""))return(d=(p=t.Parent)==null?void 0:p.Record)==null||d.SetValueToKeyString(o,null,t.Record),!0;var u=e.FindTableLevel(i??"");if(u==null)return!1;if(u.Record!=null){var s=u.Record;return s.SetValueToKeyString(o,null,m),!0}else if(u.Records!=null){for(var c=u.Records,f=0;f<c.Records.length;f++){var s=c.Records[f],m=s.Record;s.SetValueToKeyString(o,null,m)}return!0}return!0}}class o0 extends We{constructor(e,t){super(e,t)}Evaluate(e,t,n,a){return this.Expression}}class s0 extends We{constructor(e,t){super(e,t),this.sourceDateTimeParse=null,this.compareDateTimeParse=null;var n=He.GetExpressions(this.Expression,this),a=[];for(let o=0;o<((n==null?void 0:n.length)??0);o++){var i=n[o];if(i instanceof At){if(this.sourceDateTimeParse==null)this.sourceDateTimeParse=a;else if(this.compareDateTimeParse==null)this.compareDateTimeParse=a;else throw Error("Too many expressions in "+this.Expression+" for TotalMinutesParse function!");a=[];continue}}if(this.sourceDateTimeParse==null)this.sourceDateTimeParse=a;else if(this.compareDateTimeParse==null)this.compareDateTimeParse=a;else throw Error("Too many expressions in "+this.Expression+" for TotalMinutesParse function!")}Evaluate(e,t,n,a){if(this.sourceDateTimeParse==null&&this.compareDateTimeParse==null)throw Error("Invalid expression "+this.Expression+" for TotalMinutesParse function!");let i=new Date(0),o=new Date;var l=He.ConcatValues(this.sourceDateTimeParse,e,t,n,a);if(i=this.GetDateTime(l),this.compareDateTimeParse!=null){var u=He.ConcatValues(this.compareDateTimeParse,e,t,n,a);o=this.GetDateTime(u)}else o=new Date;var s=o.getTime()-i.getTime();const c=Math.abs(s);return Math.floor(c/(1e3*60))}GetDateTime(e){try{if(e instanceof Date)return e;if(typeof e=="string")return new Date(e);throw Error("Value "+e+" isn't DateTime or string! "+typeof e)}catch(t){throw Error("Error parsing DateTime from value '"+e+"' Type:"+typeof e+": "+t)}}}class u0 extends We{constructor(e,t){super(e,t),this.valueParse=null,this.formatParse=null;var n=He.GetExpressions(this.Expression,this),a=[];for(let i=0;i<((n==null?void 0:n.length)??0);i++){const o=n[i];if(o instanceof At)if(this.valueParse==null){this.valueParse=a,a=[];continue}else throw new Error("Time parse - Too many parameters!");a.push(o)}a.length>0&&(this.valueParse==null?this.valueParse=a:this.formatParse=a),this.formatParse==null&&(this.formatParse=[new Hn("HH:mm:ss")])}Evaluate(e,t,n,a){var u;var i=null;((u=this.valueParse)==null?void 0:u.length)==1?i=this.valueParse[0].Evaluate(e,t,n,a):i=He.ConcatValues(this.valueParse,e,t,n,a);var o=He.ConcatValues(this.formatParse,e,t,n,a).ToString();let l=null;if(i instanceof Date)l=i;else if(typeof i!="string")throw l=new Date(i),new Error("Time parse -Can't convert "+i+" to datetime!");if(l==null)throw new Error("Time parse - "+i+" hasn't valid type!");return o(l,"yyyy-MM-dd HH:mm")}}class l0 extends We{constructor(e,t){super(e,t)}Evaluate(e,t,n,a){var i=He.GetExpressions(this.Expression,this);if((i==null?void 0:i.length)==1){var o=i[0].Evaluate(e,t,n,a);if(typeof o=="string")return o.length;throw Error("LEN function accepts only string parameters.")}else{var o=He.ConcatValues(i,e,t,n,a);if(typeof o=="string")return o.length;throw Error("LEN function accepts only string parameters.")}}}class c0 extends We{constructor(e,t){super(e,t),this.codeListTableParse=null,this.codeListFieldParse=null,this.objectValueExpresionParse=null,this.codeListDestFieldParse=null;var n=He.GetExpressions(this.Expression,this),a=[];for(let i=0;i<((n==null?void 0:n.length)??0);i++){const o=n[i];if(o instanceof At)if(this.codeListTableParse==null){this.codeListTableParse=a,a=[];continue}else if(this.codeListFieldParse==null){this.codeListFieldParse=a,a=[];continue}else if(this.objectValueExpresionParse==null){this.objectValueExpresionParse=a,a=[];continue}else throw Error("FromCodeList parse - Too many parameters!");a.push(o)}if(a.length>0)if(this.objectValueExpresionParse!=null&&this.codeListDestFieldParse==null)this.codeListDestFieldParse=a;else throw new Error("FromCodeList parse - Too few parameters!")}Evaluate(e,t,n,a){var f;var i=He.ConcatValues(this.codeListTableParse,e,t,n,a);if((i==null?void 0:i.toString())==null)throw Error("FromCodeList parse - CodeList table is null or empty!");var o=He.ConcatValues(this.codeListFieldParse,e,t,n,a);if((o==null?void 0:o.toString())==null)throw new Error("FromCodeList parse - codeList field is null or empty!");var l=He.ConcatValues(this.objectValueExpresionParse,e,t,n,a);(l==null?void 0:l.toString())==null;var u=He.ConcatValues(this.codeListDestFieldParse,e,t,n,a);if((u==null?void 0:u.toString())==null)throw new Error("FromCodeList parse - codeListDestField is null or empty!");try{if(e.CodeListCache==null||e.CodeListCache[i.toString()]==null)throw new Error("FromCodeList parse - CodeList "+i.toString()+" not found in cache!");var s=e.CodeListCache[i.toString()],c=s.filter(m=>{var v;return((v=m[o.toString()])==null?void 0:v.toString())==(l==null?void 0:l.toString())});if(c.length==0)throw Error("FromCodeList parse - No records found in CodeList "+i.toString()+" for field "+o.toString()+" and value "+(l==null?void 0:l.toString()));if(c.length>1)throw Error("FromCodeList parse - Multiple records found in CodeList "+i.toString()+" for field "+o.toString()+" and value "+(l==null?void 0:l.toString()));return((f=c[0][u.toString()])==null?void 0:f.toString())??null}catch(m){throw new Error("FromCodeList parse - Error obtaining record from CodeList! Reason: "+m)}}}class f0 extends We{constructor(e,t){super(e,t),this.Table="",this.Field="",this.ValueExpress="";var n=this.Expression.split(",");this.Table=n[0],this.Field=n[1],this.ValueExpress=n[2]}Evaluate(e,t,n,a){var i=new wn(this.ValueExpress,!1),o=i.Evaluate(e,t,n,a);if(o==null)return null;try{if(e.CodeListCache==null||e.CodeListCache[this.Table]==null)throw new Error("CodeListCheck parse - CodeList "+this.Table+" not found in cache!");var l=e.CodeListCache[this.Table],u=l.filter(s=>{var c;return((c=s[this.Field])==null?void 0:c.toString())==(o==null?void 0:o.toString())});if(u.length>0)return!0}catch(s){throw new Error("CodeListCheck parse - Error obtaining record from CodeList! Reason: "+s)}return!1}}function zr(){return zr=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},zr.apply(null,arguments)}var Gu={relTol:1e-12,absTol:1e-15,matrix:"Matrix",number:"number",numberFallback:"number",precision:64,predictable:!1,randomSeed:null,legacySubset:!1};function pt(r,e){if(Ci(r,e)||Hu(r,e))return r[e];throw Jo(r,e)?new Error('Cannot access method "'.concat(e,'" as a property')):r==null?new TypeError('Cannot access property "'.concat(e,'": object is ').concat(r)):new Error('No access to property "'+e+'"')}function ma(r,e,t){if(Ci(r,e)||Hu(r,e))return r[e]=t,t;throw new Error('No access to property "'.concat(e,'"'))}function Ci(r,e){return p0(r)?!(e in Object.prototype):!1}function Hu(r,e){return Array.isArray(r)?typeof e=="number"||typeof e=="string"&&m0(e)||e==="length":!1}function m0(r){return/^\d+$/.test(r)}function v0(r,e){if(!Jo(r,e))throw new Error('No access to method "'+e+'"');return r[e]}function Jo(r,e){return r==null||typeof r[e]!="function"||$e(r,e)&&Object.getPrototypeOf&&e in Object.getPrototypeOf(r)?!1:d0.has(e)?!0:!(e in Object.prototype||e in Function.prototype)}function p0(r){return typeof r=="object"&&r&&r.constructor===Object}var d0=new Set(["toString","valueOf","toLocaleString"]);class Mi{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 pt(this.wrappedObject,e)}set(e,t){return ma(this.wrappedObject,e,t),this}has(e){return Ci(this.wrappedObject,e)&&e in this.wrappedObject}entries(){return Yu(this.keys(),e=>[e,this.get(e)])}forEach(e){for(var t of this.keys())e(this.get(t),t,this)}delete(e){Ci(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 Wu{constructor(e,t,n){this.a=e,this.b=t,this.bKeys=n,this[Symbol.iterator]=this.entries}get(e){return this.bKeys.has(e)?this.b.get(e):this.a.get(e)}set(e,t){return this.bKeys.has(e)?this.b.set(e,t):this.a.set(e,t),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 Yu(this.keys(),e=>[e,this.get(e)])}forEach(e){for(var t of this.keys())e(this.get(t),t,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 Yu(r,e){return{next:()=>{var t=r.next();return t.done?t:{value:e(t.value),done:!1}}}}function Xa(){return new Map}function va(r){if(!r)return Xa();if(ju(r))return r;if(Fi(r))return new Mi(r);throw new Error("createMap can create maps from objects or Maps")}function h0(r){if(r instanceof Mi)return r.wrappedObject;var e={};for(var t of r.keys()){var n=r.get(t);ma(e,t,n)}return e}function Ye(r){return typeof r=="number"}function or(r){return!r||typeof r!="object"||typeof r.constructor!="function"?!1:r.isBigNumber===!0&&typeof r.constructor.prototype=="object"&&r.constructor.prototype.isBigNumber===!0||typeof r.constructor.isDecimal=="function"&&r.constructor.isDecimal(r)===!0}function Qa(r){return typeof r=="bigint"}function ln(r){return r&&typeof r=="object"&&Object.getPrototypeOf(r).isComplex===!0||!1}function Ka(r){return r&&typeof r=="object"&&Object.getPrototypeOf(r).isFraction===!0||!1}function St(r){return r&&r.constructor.prototype.isUnit===!0||!1}function $r(r){return typeof r=="string"}var Ar=Array.isArray;function Je(r){return r&&r.constructor.prototype.isMatrix===!0||!1}function Ct(r){return Array.isArray(r)||Je(r)}function _i(r){return r&&r.isDenseMatrix&&r.constructor.prototype.isMatrix===!0||!1}function Yn(r){return r&&r.isSparseMatrix&&r.constructor.prototype.isMatrix===!0||!1}function jo(r){return r&&r.constructor.prototype.isRange===!0||!1}function Ti(r){return r&&r.constructor.prototype.isIndex===!0||!1}function g0(r){return typeof r=="boolean"}function y0(r){return r&&r.constructor.prototype.isResultSet===!0||!1}function Zu(r){return r&&r.constructor.prototype.isHelp===!0||!1}function Ju(r){return typeof r=="function"}function b0(r){return r instanceof Date}function x0(r){return r instanceof RegExp}function Fi(r){return!!(r&&typeof r=="object"&&r.constructor===Object&&!ln(r)&&!Ka(r))}function ju(r){return r?r instanceof Map||r instanceof Mi||typeof r.set=="function"&&typeof r.get=="function"&&typeof r.keys=="function"&&typeof r.has=="function":!1}function w0(r){return r===null}function D0(r){return r===void 0}function cn(r){return r&&r.isAccessorNode===!0&&r.constructor.prototype.isNode===!0||!1}function Rt(r){return r&&r.isArrayNode===!0&&r.constructor.prototype.isNode===!0||!1}function N0(r){return r&&r.isAssignmentNode===!0&&r.constructor.prototype.isNode===!0||!1}function E0(r){return r&&r.isBlockNode===!0&&r.constructor.prototype.isNode===!0||!1}function A0(r){return r&&r.isConditionalNode===!0&&r.constructor.prototype.isNode===!0||!1}function gr(r){return r&&r.isConstantNode===!0&&r.constructor.prototype.isNode===!0||!1}function Xo(r){return gr(r)||Ur(r)&&r.args.length===1&&gr(r.args[0])&&"-+~".includes(r.op)}function ei(r){return r&&r.isFunctionAssignmentNode===!0&&r.constructor.prototype.isNode===!0||!1}function En(r){return r&&r.isFunctionNode===!0&&r.constructor.prototype.isNode===!0||!1}function pa(r){return r&&r.isIndexNode===!0&&r.constructor.prototype.isNode===!0||!1}function Nr(r){return r&&r.isNode===!0&&r.constructor.prototype.isNode===!0||!1}function Oi(r){return r&&r.isObjectNode===!0&&r.constructor.prototype.isNode===!0||!1}function Ur(r){return r&&r.isOperatorNode===!0&&r.constructor.prototype.isNode===!0||!1}function fn(r){return r&&r.isParenthesisNode===!0&&r.constructor.prototype.isNode===!0||!1}function S0(r){return r&&r.isRangeNode===!0&&r.constructor.prototype.isNode===!0||!1}function C0(r){return r&&r.isRelationalNode===!0&&r.constructor.prototype.isNode===!0||!1}function Jr(r){return r&&r.isSymbolNode===!0&&r.constructor.prototype.isNode===!0||!1}function Xu(r){return r&&r.constructor.prototype.isChain===!0||!1}function Sr(r){var e=typeof r;return e==="object"?r===null?"null":or(r)?"BigNumber":r.constructor&&r.constructor.name?r.constructor.name:"Object":e}function er(r){var e=typeof r;if(e==="number"||e==="bigint"||e==="string"||e==="boolean"||r===null||r===void 0)return r;if(typeof r.clone=="function")return r.clone();if(Array.isArray(r))return r.map(function(t){return er(t)});if(r instanceof Date)return new Date(r.valueOf());if(or(r))return r;if(Fi(r))return M0(r,er);if(e==="function")return r;throw new TypeError("Cannot clone: unknown type of value (value: ".concat(r,")"))}function M0(r,e){var t={};for(var n in r)$e(r,n)&&(t[n]=e(r[n]));return t}function Qu(r,e){for(var t in e)$e(e,t)&&(r[t]=e[t]);return r}function mn(r,e){var t,n,a;if(Array.isArray(r)){if(!Array.isArray(e)||r.length!==e.length)return!1;for(n=0,a=r.length;n<a;n++)if(!mn(r[n],e[n]))return!1;return!0}else{if(typeof r=="function")return r===e;if(r instanceof Object){if(Array.isArray(e)||!(e instanceof Object))return!1;for(t in r)if(!(t in e)||!mn(r[t],e[t]))return!1;for(t in e)if(!(t in r))return!1;return!0}else return r===e}}function _0(r,e,t){var n=!0,a;Object.defineProperty(r,e,{get:function(){return n&&(a=t(),n=!1),a},set:function(o){a=o,n=!1},configurable:!0,enumerable:!0})}function $e(r,e){return r&&Object.hasOwnProperty.call(r,e)}function T0(r,e){for(var t={},n=0;n<e.length;n++){var a=e[n],i=r[a];i!==void 0&&(t[a]=i)}return t}var F0=["Matrix","Array"],O0=["number","BigNumber","bigint","Fraction"],ye=function(e){if(e)throw new Error(`The global config is readonly.
|
|
1
|
+
(function(At,xn){typeof exports=="object"&&typeof module<"u"?xn(exports):typeof define=="function"&&define.amd?define(["exports"],xn):(At=typeof globalThis<"u"?globalThis:At||self,xn(At.JsGei={}))})(this,function(At){"use strict";class xn{constructor(e,t,n,a){this.Root=null,this.Record=null,this.Records=null,this.validateDetailsErrors={},this.Tablename=e,this.Root=a,this.ObjectInfo=n[e],t.detail===!0?this.Records=new Du([{}],this.DefaultRecord,n):this.Record=new Ga(t,n,this)}Evaluate(e){this.Records!=null?this.Records.EvaluateInner(e):this.Record!=null&&this.Record.EvaluateInner(e)}MapToId(e){this.Records!=null?this.Records.MapToId(e):this.Record!=null&&this.Record.MapToId(e)}GetObject(){let e=JSON.parse("{}");return this.Record!=null?e[this.Tablename]=this.Record.GetObject():this.Records!=null&&(e[this.Tablename]=this.Records.GetObject()),e}TranslateObj(e){var t,n;this.Record!=null?(t=this.Record)==null||t.TranslateObj(e):this.Records!=null&&((n=this.Records)==null||n.TranslateObj(e))}getSaveObject(e){if(e[this.Tablename]==null)return null;let t=null;if(this.Record!=null){let n=this.Record.getSaveObject(e);if(n==null)return null;t=n}if(this.Records!=null){let n=this.Records.getSaveObject(e);if(n==null)return null;t=n}return t}getFullObject(e){if(e[this.Tablename]==null)return null;let t=null;if(this.Record!=null){let n=this.Record.getFullObject(e);if(n==null)return null;t=n}if(this.Records!=null){let n=this.Records.getFullObject(e);if(n==null)return null;t=n}return t}GetTableForAlias(e){if(e[this.Tablename]==null)return null;let t=null;if(this.Record!=null){let n=this.Record.GetTableForAlias(e);if(n==null)return null;t=n}if(this.Records!=null){let n=this.Records.GetTableForAlias(e);if(n==null)return null;t=n}return t}Validate(){this.validateDetailsErrors=[];let e=[],t="",n="";if(this.Record!=null){let i=this.Record.Validate();if(i==null)return null;i.missingKeys!=null&&(t="Missing mandatory keys:"+i.missingKeys,e.push(i.missingKeys)),i.validateDetailsErrors!=null&&this.validateDetailsErrors.push(...i.validateDetailsErrors),i.details!=null&&i.details.length>0&&(n=i.details),n!=""&&(t==null?t=n:t+=`
|
|
2
|
+
`+n)}if(this.Records!=null){let i=this.Records.Validate(),o=null,l=null;if(i!=null&&(o=i.errorMessage,l=i.validateDetailsErrors),o==null||(t=o.toString(),l==null))return null;l.length>0&&e.push(i.validateDetailsErrors)}let a="Missing data on level "+this.Tablename+": "+t;return{combineErrors:a==""?null:a,validateErrors:e,validateDeatailErrors:this.validateDetailsErrors.length>0?this.validateDetailsErrors:[]}}}const Ho=class Ho{constructor(e,t){this.Expression="",this.FunName=null,t==null||t==""?this.Expression=e:(this.Expression=e.substring(t.length,e.length-1),this.FunName=t)}static getIsoDateWithTime(e,t){return e==null?null:typeof e=="string"?e:e.getFullYear()+"-"+this.formatToTwoNumber(e.getMonth()+1)+"-"+this.formatToTwoNumber(e.getDate())+t}static getIsoDateTime(e){return e==null?null:typeof e=="string"?e:e.getFullYear()+"-"+this.formatToTwoNumber(e.getMonth()+1)+"-"+this.formatToTwoNumber(e.getDate())+"T"+this.formatToTwoNumber(e.getHours())+":"+this.formatToTwoNumber(e.getMinutes())+":"+this.formatToTwoNumber(e.getSeconds())}static parseDateTime(e){return new Date(e)}static parseDate(e){return new Date(e)}static formatToTwoNumber(e){return e<10?"0"+e:e.toString()}static getIsoDate(e){return e==null?null:typeof e=="string"?e:e.getFullYear()+"-"+this.formatToTwoNumber(e.getMonth()+1)+"-"+this.formatToTwoNumber(e.getDate())+"T00:00:00"}static roundUp(e,t){let n=!1;e<0?n=!0:n=!1,n?e=e-10**-13:e=e+10**-13,e=Math.abs(e);let a=Math.round(e*Math.pow(10,t))/Math.pow(10,t);return n?-1*a:a}};Ho.operators=["<=",">=","!=","<>","==","<",">","="],Ho.logicaloperators=["&&","||"];let We=Ho;class Ei extends We{constructor(e){super(e,null)}Evaluate(e,t,n,a){return this.Expression}}class Hn extends We{constructor(e){super(e,null)}Evaluate(e,t,n,a){if(this.Expression=="null")return null;if(this.Expression.startsWith("N.")&&typeof this.Expression=="string")try{return parseFloat(this.Expression)}catch{throw"Value "+this.Expression+" can't be transformed to numeric!"}return this.Expression}}class wn extends We{constructor(e,t){super(e,null),this.Numeric=!1,this.Numeric=t}Evaluate(e,t,n,a){var i=He.ValueExpresion(a,this.Expression,e,t);if(i==null)return null;if(this.Numeric){if(typeof i=="string")return parseFloat(i);if(typeof i=="number")return i;throw"Value is "+typeof i+" isn't number type!"}return i}}const Ha=class Ha extends We{constructor(e){super(e,null),this.subParse=[];for(var t=[],n="";e.length>0;){var a=!1;for(let f=0;f<We.operators.length;f++){let m=We.operators[f];if(e.startsWith(m)){t.push(new Ei(e.substring(0,m.length))),e=e.substring(m.length),a=!0;break}}if(a)continue;if(["%","(",")"].indexOf(e.substring(0,1))==-1&&!He.StartsWithFunction(e)){n+=e.substring(0,1),e=e.substring(1);continue}if(n!=""&&(t.push(new Hn(n)),n=""),e.startsWith("N.%")){var i=e.substring(3).indexOf("%")+1;t.push(new wn(e.substring(2,i-1),!0)),e=e.substring(i+1);continue}if(e.startsWith("%")){var i=e.substring(1).indexOf("%")+1;t.push(new wn(e.substring(0,i+1),!1)),e=e.substring(i+1);continue}var o=!1;const c=Object.keys(He._suportedFunctions);for(let f=0;f<c.length;f++){let m=c[f];if(e.startsWith(m)){n!=""&&(t.push(new Ha(n)),n="");var l=He.FindEnd(e);if(l==-1)throw"Unbalanced brackets!!!! Expression:"+e;let v=Reflect.construct(He._suportedFunctions[m],[e.substring(0,l+1),m]);t.push(v),l<e.length?e=e.substring(l+1):e="",o=!0;break}}if(!o){var u=!1;for(let f=0;f<Ha._literalValues.length;f++){var s=Ha._literalValues[f];if(e.substring(0,1)==s){t.push(new Hn(s)),e=e.substring(1),u=!0;break}}}}n!=""&&t.push(new Hn(n)),this.subParse=t}Evaluate(e,t,n,a){return this.subParse.length==1?this.subParse[0].Evaluate(e,t,n,a):He.ConcatValues(this.subParse,e,t,n,a)}};Ha._literalValues=["(",")"];let vt=Ha;class St extends We{constructor(e,t){super(e,t)}Evaluate(e,t,n,a){return this.Expression}}class Yo extends We{constructor(e){super(e,null)}Evaluate(e,t,n,a){return this.Expression}}class Ih extends We{constructor(e,t){super(e,t),this.value=[],this.numOfZeros=[];var n=He.GetExpressions(this.Expression,this);if(n==null)return;var a=n.filter(o=>o instanceof St);if(a.length==0)throw"No comma in AddLeadZeros function";let i=[];n.forEach(o=>{o instanceof St?(this.value=i,i=[]):i.push(o)}),this.numOfZeros=i}Evaluate(e,t,n,a){var i=He.ConcatValues(this.value,e,t,n,a),o=He.ConcatValues(this.numOfZeros,e,t,n,a);if(i==null||o==null)return null;let l=-1;if(typeof o=="number"?l=o:typeof o=="string"&&(l=parseInt(o)),l==-1)throw"AddLeadZeros function can't be evaluated! expression: "+this.Expression;for(var u=i.ToString();u.Length<l;)u="0"+u;return u}}class Ph extends We{constructor(e,t){super(e,t),this.FieldName="";var n=this.Expression.split(".");this.Table=n[0],n.length>1&&(this.FieldName=n[1])}Evaluate(e,t,n,a){var i=e.FindTableLevel(this.Table);if(i==null)return!1;let o=[];if(i.Record!=null)o.push(i.Record);else if(i.Records!=null){var l=i.Records;if(l.Records.length==0)return!1;l.Records.forEach(s=>{o.push(s)})}if(o.length==0)return!1;if(this.FieldName=="")return!0;for(var u=0;u<o.length;u++)if(o[u].Record[this.FieldName]!=null)return!0;return!1}}class $h extends We{constructor(e,t){super(e,t),this.conditionParse=[],this.conditionTrueParse=[],this.conditionFalseParse=[];var n=He.GetExpressions(this.Expression,this);if(n!=null){var a=[];for(let i=0;i<n.length;i++)a=this.logic(a,n[i]);if(this.logic(a,null),this.conditionParse.length==0||this.conditionTrueParse.length==0||this.conditionFalseParse.length==0)throw"Can't parse if stategment "+e+"!"}}Evaluate(e,t,n,a){var i=this.conditionParse.filter(c=>c instanceof Yo),o=!1;if(i.length==0)o=this.validateExpression(e,t,n,a,this.conditionParse);else{let c=[],f=[];for(let m=0;m<this.conditionParse.length;m++){let v=this.conditionParse[m];if(v instanceof Yo){var l=this.validateExpression(e,t,n,a,f);f=[],c.push(l),c.push(v.Expression);continue}f.push(v)}if(f.length>0){var l=this.validateExpression(e,t,n,a,f);c.push(l)}o=c[0];for(var u=1;u<c.length;u+=2){var s=c[u];switch(s){case"&&":{o=o&&c[u+1];break}case"||":{o=o||c[u+1];break}}}}return o==!0?He.ConcatValues(this.conditionTrueParse,e,t,n,a):He.ConcatValues(this.conditionFalseParse,e,t,n,a)}logic(e,t){return t==null||t instanceof St?(this.conditionParse.length==0?this.conditionParse=e:this.conditionTrueParse.length==0?this.conditionTrueParse=e:this.conditionFalseParse.length==0&&(this.conditionFalseParse=e),[]):(e.push(t),e)}validateExpression(e,t,n,a,i){let o=null;var l=i.filter(x=>x instanceof Ei);if(l.length==0){if(i.length==1){var u=i[0].Evaluate(e,t,n,a);if(typeof u=="boolean"&&(o=u),u==null&&a.TypeNET=="bool"&&(o=!1),typeof u=="string"){var s=u;s.trim().toLowerCase()=="false"&&(o=!1),s.trim().toLowerCase()=="true"&&(o=!0)}}}else{let x=[],D=[];var c=x;for(let h=0;h<i.length;h++){if(i[h]instanceof Ei){c=D;continue}c.push(i[h])}var f=He.ConcatValues(x,e,t,n,a),m=He.ConcatValues(D,e,t,n,a);if(f==null||m==null)switch(l[0].Expression){case"=":case"==":return o=f==m,this.evaluateCondition(o);case"!=":case"<>":return o=f!=m,this.evaluateCondition(o)}if(typeof f=="number"&&typeof m=="number"){var v=f,p=m;switch(l[0].Expression){case">=":return o=v>=p,this.evaluateCondition(o);case"<=":return o=v<=p,this.evaluateCondition(o);case"!=":case"<>":return o=v!=p,this.evaluateCondition(o);case"<":return o=v<p,this.evaluateCondition(o);case">":return o=v>p,this.evaluateCondition(o);case"==":case"=":return o=v==p,this.evaluateCondition(o);default:throw"Operator "+l[0].Expression+" not supported on condition decimal and decimal"}}if(typeof f=="string"&&typeof m=="string"){if((f.toLowerCase()=="false"||f.toLowerCase()=="true")&&(m.toLowerCase()=="false"||m.toLowerCase()=="true")){let h=!!f,w=!!m;switch(l[0].Expression){case"!=":case"<>":return o=h!=w,this.evaluateCondition(o);case"==":case"=":return o=h==w,this.evaluateCondition(o);default:throw"Operator "+l[0].Expression+" not supported on condition bool and bool"}}return o=this.StringCompare(f,m,l[0].Expression),this.evaluateCondition(o)}if(f instanceof Date&&typeof m=="string"){var d=We.getIsoDateTime(f);return o=this.StringCompare(d,m,l[0].Expression),this.evaluateCondition(o)}if(typeof f=="string"&&m instanceof Date){var y=We.getIsoDateTime(m);return o=this.StringCompare(f,y,l[0].Expression),this.evaluateCondition(o)}if(f instanceof Date&&m instanceof Date)switch(l[0].Expression){case">=":return o=f>=m,this.evaluateCondition(o);case"<=":return o=f<=m,this.evaluateCondition(o);case"!=":case"<>":return o=f!=m,this.evaluateCondition(o);case"<":return o=f<m,this.evaluateCondition(o);case">":return o=f>m,this.evaluateCondition(o);case"==":case"=":return o=f==m,this.evaluateCondition(o);default:throw"Operator "+l[0].Expression+" not supported on condition string"}}return this.evaluateCondition(o)}evaluateCondition(e){if(e==null){debugger;throw"Can't eval "+this.Expression+"!"}return e}StringCompare(e,t,n){switch(n){case"!=":case"<>":return e!=t;case"==":case"=":return e==t;default:throw"Operator "+n+" not supported on condition string"}}}class qh extends We{constructor(e,t){super(e,t)}Evaluate(e,t,n,a){return e.SumByKey(this.Expression)}}class zh extends We{constructor(e,t){super(e,t),this.value="",this.offset="";var n=this.Expression.split(",");n.length==2&&(this.value=n[0],this.offset=n[1])}Evaluate(e,t,n,a){if(this.value==""||this.offset=="")return null;var i=new vt(this.value),o=i.Evaluate(e,t,n,a),l=new vt(this.offset),u=l.Evaluate(e,t,n,a),s=null,c=null;if(o.constructor.name=="Date"?s=o:typeof o=="string"&&(s=new Date(o)),typeof u=="number"?c=u:typeof u=="string"&&(c=parseInt(u)),c!=null&&s!=null){if(s.setDate(s.getDate()+c),a.TypeDDD=="Date")return We.getIsoDate(s);if(a.TypeDDD=="DateTime")return We.getIsoDateTime(s)}else debugger;return this.Expression}}class _u extends We{constructor(e,t){super(e,t),this.lower=!0,t.toLowerCase()=="upper("&&(this.lower=!1)}Evaluate(e,t,n,a){var i=He.GetExpressions(this.Expression,this);if(i==null)return null;var o=He.ConcatValues(i,e,t,n,a);return o==null?null:typeof o=="string"?this.lower?o.toLowerCase():o.toUpperCase():o}}class Tu extends We{constructor(e,t){if(super(e,t),this.Negate=!1,this.FieldSet="",this.aviableValues=[],this.Expression!=null&&this.Expression.startsWith("(")){var n=He.FindEnd(this.Expression),a=this.Expression.substring(1,n);this.FieldSet=this.Expression.substring(n+2),this.aviableValues=a.split(","),(t==null?void 0:t.toLowerCase())=="notinlist("&&(this.Negate=!0)}}Evaluate(e,t,n,a){var i=new wn(this.FieldSet,!1),o=i.Evaluate(e,t,n,a);if(o==null||this.aviableValues.length==0)return!1;var l=this.aviableValues.indexOf(o.toString());return this.Negate?l==-1:l!=-1}}class Fu extends We{constructor(e,t){if(super(e,t),this.Negate=!1,this.TableAndField="",this.Table="",this.Field="",this.aviableValues=[],this.Expression!=null&&this.Expression.startsWith("(")){var n=He.FindEnd(this.Expression),a=this.Expression.substring(1,n);if(this.TableAndField=this.Expression.substring(n+2),this.TableAndField==null||this.TableAndField=="")throw"Invalid expresion InDetail - table.field is empty!";if(a==null||a=="")throw"Invalid expresion InDetail - set of values is empty!";var i=this.TableAndField.split(".");if(i.length==2)this.Table=i[0],this.Field=i[1];else throw"Invalid expresion InDetail - table.field not in correction format!";this.aviableValues=a.split(","),(t==null?void 0:t.toLowerCase())=="notindetail("&&(this.Negate=!0)}}Evaluate(e,t,n,a){var i=e.FindTableLevel(this.Table);if(i==null)return!1;if(i.Records!=null){var o=i.Records.Records;if(this.Negate){for(var l=0;l<o.length;l++){let s=o[l];if(s.Record[this.Field]==null)continue;if(this.aviableValues.filter(f=>f!=s.Record[this.Field].toString()).length>0)return!0}return!1}else{for(var l=0;l<o.length;l++){let u=o[l];if(u.Record[this.Field]==null)continue;if(this.aviableValues.filter(c=>c==u.Record[this.Field].toString()).length>0)return!0}return!1}}}}class Uh extends We{constructor(e,t){super(e,t),this.starts=null,this.value=null;var n=this.Expression.split(",");n.length==2&&(this.starts=new vt(n[0]),this.value=new vt(n[1]))}Evaluate(e,t,n,a){var c,f;var i=(c=this.starts)==null?void 0:c.Evaluate(e,t,n,a),o=(f=this.value)==null?void 0:f.Evaluate(e,t,n,a);if(i==null||o==null)return!1;var l=i.ToString(),u=o.ToString(),s=u.startsWith(l);return s}}class Lh extends We{constructor(e,t){super(e,t),this.starts=[],this.value=[],this.length=[];var n=He.GetExpressions(this.Expression,this),a=[];if(n!=null){for(let i=0;i<n.length;i++)a=this.logic(a,n[i]);if(this.logic(a,null),this.value.length==0||this.starts.length==0||this.length.length==0)throw"Can't parse if stategment "+e+"!"}}Evaluate(e,t,n,a){var i=He.ConcatValues(this.value,e,t,n,a);if(i==null)return null;var o=i.ToString();let l=-1;var u=He.ConcatValues(this.starts,e,t,n,a);if(typeof u=="number"?l=u:typeof u=="string"&&(l=parseInt(u)),l==-1)throw"Substr start index can't be parsed! Value: "+u+"!";l--;let s=-1;var c=He.ConcatValues(this.length,e,t,n,a);if(typeof c=="number"?s=c:c=="string"&&(s=parseInt(c)),s==-1)throw"Substr length index can't be parsed! Value: "+c+"!";if(o.Length<=l)return null;var f=o.substring(l);return f.Length<=s?f:f.substring(0,s)}logic(e,t){return t==null||t instanceof St?(this.value.length==0?this.value=e:this.starts.length==0?this.starts=e:this.length.length==0&&(this.length=e),[]):(e.push(t),e)}}class kh extends We{constructor(e,t){super(e,t),this.Table=";",this.Table=this.Expression}Evaluate(e,t,n,a){var o;if(this.Table=="")throw"Function count don't have defined table!";var i=e.FindTableLevel(this.Table);return i==null?-1:(o=i.Records)==null?void 0:o.Records.length}}class Ou extends We{constructor(e,t){var a;super(e,t),this.Table="",this.FieldName="",this.Negate=!1,t.toLowerCase()=="notexists("&&(this.Negate=!0);var n=this.Expression.split(".");n.length!=2,this.Table=n[0],this.FieldName=n[1],(a=this.Table)!=null&&a.startsWith("!")&&(this.Table=this.Table.substring(1),this.Negate=!0)}Evaluate(e,t,n,a){var c;if(this.Table==null)throw"No table";var i=e.FindTableLevel(this.Table);if(i==null)throw"Table level "+this.Table+" don't exist in object!";let o=!1;if(i==e.rootLevel){var l=i.Record;o=(l==null?void 0:l.Record.Record[this.FieldName])!=null}else{var u=i.Records;if(u==null)throw"Table level "+this.Table+" don't have active records!";var s=u.Records.indexOf(t);if(s==-1)throw"Table level "+this.Table+" not the same as record!"+((c=t==null?void 0:t.Parent)==null?void 0:c.Tablename);o=u.Records[s].Record[this.FieldName]!=null}return this.Negate&&(o=!o),o}}class Bu extends We{constructor(e,t){super(e,t),this.valueExp=null,this.Negate=!1,t.toLowerCase()=="nonempty("&&(this.Negate=!0);var n=He.GetExpressions(this.Expression,this);if(n!=null)if(n.length==1&&n[0]instanceof vt)this.valueExp=n[0];else throw"Expression '"+this.Expression+"' isn't ValueFromObjParse"}Evaluate(e,t,n,a){var s;var i=(s=this.valueExp)==null?void 0:s.Evaluate(e,t,n,a);let o=!1;if(i==null)o=!0;else if(typeof i=="string"){var l=i;o=l==""||l.trim()==""}else if(typeof i=="number"){var u=i;o=u==0}return this.Negate?!o:o}}class Vh extends We{constructor(e,t){super(e,t),this.sections=[],this.sections=He.GetExpressions(this.Expression,this)??[]}Evaluate(e,t,n,a){for(var i="",o=0;o<this.sections.length;o++){let u=this.sections[o];if(!(u instanceof St)){var l=u.Evaluate(e,t,n,a);l!=null&&(i+=l)}}return i}}class Gh extends We{constructor(e,t){super(e,t),this.Detail="",this.Exp="",this.Parameter="";var n=this.Expression.split(",");if(n.length==2){var n=this.Expression.split(",");if(n.length!=3)throw"Check have more or less parameters that 3";this.Detail=n[0],this.Exp=n[1],this.Parameter=n[2]}}Evaluate(e,t,n,a){var m,v,p;var i=[];if(!_h.isMultiple(this.Detail)){var o=e.FindTableLevel(this.Detail);if(o==null)throw"Can't find level {Detail}";if(o.Record!=null)throw"Table level isn't detail!";if(o.Records==null)throw"Table level doesn't have records!";for(var l=o.Records.Records,u=0;u<l.length;u++)i.push(l[u])}for(var s=0,u=0;u<i.length;u++){var c=i[u],f=He.ParseExpressionAndReturnValue("IF("+this.Exp+",true,false)",e,a,c,0);if(f=="true"&&(s++,((m=this.Parameter)==null?void 0:m.toLocaleLowerCase())=="one"))return!0}if(((v=this.Parameter)==null?void 0:v.toLocaleLowerCase())=="one")return!1;if(((p=this.Parameter)==null?void 0:p.toLocaleLowerCase())=="all")return s==i.length;throw"Check prameter isn't valid!Valid:One,All.Provided:"+this.Parameter}}class Hh extends We{constructor(e,t){super(e,t)}Evaluate(e,t,n,a){var i=He.GetExpressions(this.Expression,this);if(i==null)return null;if(i.length==1){var o=i[0].Evaluate(e,t,n,a);return typeof o=="string"?o.trim():o}return i.length}}class Wh extends We{constructor(e,t){super(e,null),this.Table="",this.FieldName="",this.Position="";var n=this.Expression.split(","),a="first";n.length==2&&(a=n[1]);var i=n[0].split(".");this.Table=i[0],this.FieldName=i[1],this.Position=a}Evaluate(e,t,n,a){var i=e.FindTableLevel(this.Table);if(i==null)return null;let o=null;if(i.Record!=null)o=i.Record;else if(i.Records!=null){var l=i.Records;if(l.Records.length==0)return null;this.Position.toLowerCase()=="first"?o=l.Records[0].Record:this.Position.toLowerCase()=="first"&&(o=l.Records[l.Records.length-1].Record)}if(o==null)throw"Can't find valid record for "+this.Table+"!";if(o[this.FieldName]==null)throw"Value not defined for fieldname "+this.FieldName+"!";var u=o[this.FieldName];return u==null?null:typeof u=="number"?u:u.ToString()}}class Yh extends We{constructor(e,t){super(e,t),this.useFirstExpressions=[];var n=[],a=He.GetExpressions(this.Expression,this);a==null||a.forEach(i=>{if(i instanceof St&&n.length>0){this.useFirstExpressions.push(n),n=[];return}n.push(i)}),n.length>0&&this.useFirstExpressions.push(n)}Evaluate(e,t,n,a){for(var i=0;i<this.useFirstExpressions.length;i++){var o=this.useFirstExpressions[i],l=He.ConcatValues(o,e,t,n,a);if(l!=null&&l!=null)return l}return null}}class Zh extends We{constructor(e,t){super(e,t),this.Table="",this.FieldName="",this.Negate=!1}Evaluate(e,t,n,a){if(a.ValidValuesRegistry==null)throw"SchemaStruct "+a.Alias+" don't have valid values registry defined.";var i=this.Expression;(i==null||i=="")&&(i="%"+a.TableName+"."+a.FieldName+"%");var o=He.GetExpressions(i,this),l=He.ConcatValues(o,e,t,n,a);if(l==null)return null;var u=a.ValidValuesRegistry.filter(s=>s.Code.toLowerCase().includes(l.toLowerCase()));return u!=null&&u.length>0?u[0].Name:(u=u=a.ValidValuesRegistry.filter(s=>s.Name.toLowerCase().includes(l.toLowerCase())),u!=null&&u.length>0?u[0].Code:null)}}class Jh extends We{constructor(e,t){super(e,t)}Evaluate(e,t,n,a){var i=new wn(this.Expression,!1),o=i.Evaluate(e,t,n,a),l=null;if(o instanceof Date?l=o:typeof o=="string"&&(l=new Date(o.toString())),l==null)throw new Error("Can't convert "+o+" isn't datetime!");return l.getFullYear()}}class jh extends We{constructor(e,t){super(e,t)}Evaluate(e,t,n,a){var i=new wn(this.Expression,!1),o=i.Evaluate(e,t,n,a),l=null;if(o instanceof Date?l=o:typeof o=="string"&&(l=new Date(o.toString())),l==null)throw new Error("Can't convert "+o+" isn't datetime!");return this.GetMonth(l.getMonth()+1)}GetMonth(e){return e>=10?e.toString():"0"+e.toString()}}class Xh extends We{constructor(e,t){super(e,t),this.valueParse=null,this.regexParse=null;let n=He.GetExpressions(this.Expression,this);if(n==null)throw new Error(`Error parsing Sum function: ${this.Expression}`);var a=[];for(let i=0;i<n.length;i++){let o=n[i];if(o instanceof St){if(this.valueParse==null)this.valueParse=a,a=[];else if(this.regexParse==null)throw new Error(`Clean function has too many parameters: ${this.Expression}`);continue}a.push(o)}if(a.length>0&&(this.valueParse==null?this.valueParse=a:this.regexParse=a,a=[]),this.regexParse==null||this.valueParse==null)throw new Error(`Clean function has few parameters: ${this.Expression}`)}Evaluate(e,t,n,a){var l;if(this.valueParse==null)return;let i=null;if(this.valueParse.length==1?i=this.valueParse[0].Evaluate(e,t,n,a):i=He.ConcatValues(this.valueParse,e,t,n,a),this.regexParse==null)return i;var o=(l=He.ConcatValues(this.regexParse,e,t,n,a))==null?void 0:l.ToString();return o==null?i:(o=o+"/g",i.replace("/"+o+"/g",""))}}class Qh extends We{constructor(e,t){super(e,t),this.valueParse=null,this.regexParse=null;let n=He.GetExpressions(this.Expression,this);if(n==null)throw new Error(`Error parsing Sum function: ${this.Expression}`);var a=[];for(let i=0;i<n.length;i++){let o=n[i];if(o instanceof St){if(this.valueParse==null)this.valueParse=a,a=[];else if(this.regexParse==null)throw new Error(`Clean function has too many parameters: ${this.Expression}`);continue}a.push(o)}if(a.length>0&&(this.valueParse==null?this.valueParse=a:this.regexParse=a,a=[]),this.regexParse==null||this.valueParse==null)throw new Error(`Clean function has few parameters: ${this.Expression}`)}Evaluate(e,t,n,a){var u;if(this.valueParse==null)return;let i=null;if(this.valueParse.length==1?i=this.valueParse[0].Evaluate(e,t,n,a):i=He.ConcatValues(this.valueParse,e,t,n,a),this.regexParse==null)return i;var o=(u=He.ConcatValues(this.regexParse,e,t,n,a))==null?void 0:u.ToString();if(o==null)return i;o=o+"/g";var l=i.match("/"+o+"/g","");return l!=null&&l.length>0?l[0]:null}}const Ru=6048e5,Kh=864e5,Iu=Symbol.for("constructDateFrom");function Dn(r,e){return typeof r=="function"?r(e):r&&typeof r=="object"&&Iu in r?r[Iu](e):r instanceof Date?new r.constructor(e):new Date(e)}function Gt(r,e){return Dn(e||r,r)}let eg={};function Ai(){return eg}function Za(r,e){var l,u,s,c;const t=Ai(),n=(e==null?void 0:e.weekStartsOn)??((u=(l=e==null?void 0:e.locale)==null?void 0:l.options)==null?void 0:u.weekStartsOn)??t.weekStartsOn??((c=(s=t.locale)==null?void 0:s.options)==null?void 0:c.weekStartsOn)??0,a=Gt(r,e==null?void 0:e.in),i=a.getDay(),o=(i<n?7:0)+i-n;return a.setDate(a.getDate()-o),a.setHours(0,0,0,0),a}function Si(r,e){return Za(r,{...e,weekStartsOn:1})}function Pu(r,e){const t=Gt(r,e==null?void 0:e.in),n=t.getFullYear(),a=Dn(t,0);a.setFullYear(n+1,0,4),a.setHours(0,0,0,0);const i=Si(a),o=Dn(t,0);o.setFullYear(n,0,4),o.setHours(0,0,0,0);const l=Si(o);return t.getTime()>=i.getTime()?n+1:t.getTime()>=l.getTime()?n:n-1}function $u(r){const e=Gt(r),t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+r-+t}function rg(r,...e){const t=Dn.bind(null,e.find(n=>typeof n=="object"));return e.map(t)}function qu(r,e){const t=Gt(r,e==null?void 0:e.in);return t.setHours(0,0,0,0),t}function tg(r,e,t){const[n,a]=rg(t==null?void 0:t.in,r,e),i=qu(n),o=qu(a),l=+i-$u(i),u=+o-$u(o);return Math.round((l-u)/Kh)}function ng(r,e){const t=Pu(r,e),n=Dn(r,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),Si(n)}function ag(r){return r instanceof Date||typeof r=="object"&&Object.prototype.toString.call(r)==="[object Date]"}function ig(r){return!(!ag(r)&&typeof r!="number"||isNaN(+Gt(r)))}function og(r,e){const t=Gt(r,e==null?void 0:e.in);return t.setFullYear(t.getFullYear(),0,1),t.setHours(0,0,0,0),t}const sg={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},ug=(r,e,t)=>{let n;const a=sg[r];return typeof a=="string"?n=a:e===1?n=a.one:n=a.other.replace("{{count}}",e.toString()),t!=null&&t.addSuffix?t.comparison&&t.comparison>0?"in "+n:n+" ago":n};function Zo(r){return(e={})=>{const t=e.width?String(e.width):r.defaultWidth;return r.formats[t]||r.formats[r.defaultWidth]}}const lg={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},cg={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},fg={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},mg={date:Zo({formats:lg,defaultWidth:"full"}),time:Zo({formats:cg,defaultWidth:"full"}),dateTime:Zo({formats:fg,defaultWidth:"full"})},vg={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},pg=(r,e,t,n)=>vg[r];function Ja(r){return(e,t)=>{const n=t!=null&&t.context?String(t.context):"standalone";let a;if(n==="formatting"&&r.formattingValues){const o=r.defaultFormattingWidth||r.defaultWidth,l=t!=null&&t.width?String(t.width):o;a=r.formattingValues[l]||r.formattingValues[o]}else{const o=r.defaultWidth,l=t!=null&&t.width?String(t.width):r.defaultWidth;a=r.values[l]||r.values[o]}const i=r.argumentCallback?r.argumentCallback(e):e;return a[i]}}const dg={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},hg={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},gg={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},yg={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},bg={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},xg={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},wg={ordinalNumber:(r,e)=>{const t=Number(r),n=t%100;if(n>20||n<10)switch(n%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},era:Ja({values:dg,defaultWidth:"wide"}),quarter:Ja({values:hg,defaultWidth:"wide",argumentCallback:r=>r-1}),month:Ja({values:gg,defaultWidth:"wide"}),day:Ja({values:yg,defaultWidth:"wide"}),dayPeriod:Ja({values:bg,defaultWidth:"wide",formattingValues:xg,defaultFormattingWidth:"wide"})};function ja(r){return(e,t={})=>{const n=t.width,a=n&&r.matchPatterns[n]||r.matchPatterns[r.defaultMatchWidth],i=e.match(a);if(!i)return null;const o=i[0],l=n&&r.parsePatterns[n]||r.parsePatterns[r.defaultParseWidth],u=Array.isArray(l)?Ng(l,f=>f.test(o)):Dg(l,f=>f.test(o));let s;s=r.valueCallback?r.valueCallback(u):u,s=t.valueCallback?t.valueCallback(s):s;const c=e.slice(o.length);return{value:s,rest:c}}}function Dg(r,e){for(const t in r)if(Object.prototype.hasOwnProperty.call(r,t)&&e(r[t]))return t}function Ng(r,e){for(let t=0;t<r.length;t++)if(e(r[t]))return t}function Eg(r){return(e,t={})=>{const n=e.match(r.matchPattern);if(!n)return null;const a=n[0],i=e.match(r.parsePattern);if(!i)return null;let o=r.valueCallback?r.valueCallback(i[0]):i[0];o=t.valueCallback?t.valueCallback(o):o;const l=e.slice(a.length);return{value:o,rest:l}}}const Ag=/^(\d+)(th|st|nd|rd)?/i,Sg=/\d+/i,Cg={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Mg={any:[/^b/i,/^(a|c)/i]},_g={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Tg={any:[/1/i,/2/i,/3/i,/4/i]},Fg={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Og={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Bg={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Rg={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Ig={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Pg={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},$g={ordinalNumber:Eg({matchPattern:Ag,parsePattern:Sg,valueCallback:r=>parseInt(r,10)}),era:ja({matchPatterns:Cg,defaultMatchWidth:"wide",parsePatterns:Mg,defaultParseWidth:"any"}),quarter:ja({matchPatterns:_g,defaultMatchWidth:"wide",parsePatterns:Tg,defaultParseWidth:"any",valueCallback:r=>r+1}),month:ja({matchPatterns:Fg,defaultMatchWidth:"wide",parsePatterns:Og,defaultParseWidth:"any"}),day:ja({matchPatterns:Bg,defaultMatchWidth:"wide",parsePatterns:Rg,defaultParseWidth:"any"}),dayPeriod:ja({matchPatterns:Ig,defaultMatchWidth:"any",parsePatterns:Pg,defaultParseWidth:"any"})},qg={code:"en-US",formatDistance:ug,formatLong:mg,formatRelative:pg,localize:wg,match:$g,options:{weekStartsOn:0,firstWeekContainsDate:1}};function zg(r,e){const t=Gt(r,e==null?void 0:e.in);return tg(t,og(t))+1}function Ug(r,e){const t=Gt(r,e==null?void 0:e.in),n=+Si(t)-+ng(t);return Math.round(n/Ru)+1}function zu(r,e){var c,f,m,v;const t=Gt(r,e==null?void 0:e.in),n=t.getFullYear(),a=Ai(),i=(e==null?void 0:e.firstWeekContainsDate)??((f=(c=e==null?void 0:e.locale)==null?void 0:c.options)==null?void 0:f.firstWeekContainsDate)??a.firstWeekContainsDate??((v=(m=a.locale)==null?void 0:m.options)==null?void 0:v.firstWeekContainsDate)??1,o=Dn((e==null?void 0:e.in)||r,0);o.setFullYear(n+1,0,i),o.setHours(0,0,0,0);const l=Za(o,e),u=Dn((e==null?void 0:e.in)||r,0);u.setFullYear(n,0,i),u.setHours(0,0,0,0);const s=Za(u,e);return+t>=+l?n+1:+t>=+s?n:n-1}function Lg(r,e){var l,u,s,c;const t=Ai(),n=(e==null?void 0:e.firstWeekContainsDate)??((u=(l=e==null?void 0:e.locale)==null?void 0:l.options)==null?void 0:u.firstWeekContainsDate)??t.firstWeekContainsDate??((c=(s=t.locale)==null?void 0:s.options)==null?void 0:c.firstWeekContainsDate)??1,a=zu(r,e),i=Dn((e==null?void 0:e.in)||r,0);return i.setFullYear(a,0,n),i.setHours(0,0,0,0),Za(i,e)}function kg(r,e){const t=Gt(r,e==null?void 0:e.in),n=+Za(t,e)-+Lg(t,e);return Math.round(n/Ru)+1}function Er(r,e){const t=r<0?"-":"",n=Math.abs(r).toString().padStart(e,"0");return t+n}const Nn={y(r,e){const t=r.getFullYear(),n=t>0?t:1-t;return Er(e==="yy"?n%100:n,e.length)},M(r,e){const t=r.getMonth();return e==="M"?String(t+1):Er(t+1,2)},d(r,e){return Er(r.getDate(),e.length)},a(r,e){const t=r.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return t.toUpperCase();case"aaa":return t;case"aaaaa":return t[0];case"aaaa":default:return t==="am"?"a.m.":"p.m."}},h(r,e){return Er(r.getHours()%12||12,e.length)},H(r,e){return Er(r.getHours(),e.length)},m(r,e){return Er(r.getMinutes(),e.length)},s(r,e){return Er(r.getSeconds(),e.length)},S(r,e){const t=e.length,n=r.getMilliseconds(),a=Math.trunc(n*Math.pow(10,t-3));return Er(a,e.length)}},fa={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Uu={G:function(r,e,t){const n=r.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return t.era(n,{width:"abbreviated"});case"GGGGG":return t.era(n,{width:"narrow"});case"GGGG":default:return t.era(n,{width:"wide"})}},y:function(r,e,t){if(e==="yo"){const n=r.getFullYear(),a=n>0?n:1-n;return t.ordinalNumber(a,{unit:"year"})}return Nn.y(r,e)},Y:function(r,e,t,n){const a=zu(r,n),i=a>0?a:1-a;if(e==="YY"){const o=i%100;return Er(o,2)}return e==="Yo"?t.ordinalNumber(i,{unit:"year"}):Er(i,e.length)},R:function(r,e){const t=Pu(r);return Er(t,e.length)},u:function(r,e){const t=r.getFullYear();return Er(t,e.length)},Q:function(r,e,t){const n=Math.ceil((r.getMonth()+1)/3);switch(e){case"Q":return String(n);case"QQ":return Er(n,2);case"Qo":return t.ordinalNumber(n,{unit:"quarter"});case"QQQ":return t.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return t.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return t.quarter(n,{width:"wide",context:"formatting"})}},q:function(r,e,t){const n=Math.ceil((r.getMonth()+1)/3);switch(e){case"q":return String(n);case"qq":return Er(n,2);case"qo":return t.ordinalNumber(n,{unit:"quarter"});case"qqq":return t.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return t.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return t.quarter(n,{width:"wide",context:"standalone"})}},M:function(r,e,t){const n=r.getMonth();switch(e){case"M":case"MM":return Nn.M(r,e);case"Mo":return t.ordinalNumber(n+1,{unit:"month"});case"MMM":return t.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return t.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return t.month(n,{width:"wide",context:"formatting"})}},L:function(r,e,t){const n=r.getMonth();switch(e){case"L":return String(n+1);case"LL":return Er(n+1,2);case"Lo":return t.ordinalNumber(n+1,{unit:"month"});case"LLL":return t.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return t.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return t.month(n,{width:"wide",context:"standalone"})}},w:function(r,e,t,n){const a=kg(r,n);return e==="wo"?t.ordinalNumber(a,{unit:"week"}):Er(a,e.length)},I:function(r,e,t){const n=Ug(r);return e==="Io"?t.ordinalNumber(n,{unit:"week"}):Er(n,e.length)},d:function(r,e,t){return e==="do"?t.ordinalNumber(r.getDate(),{unit:"date"}):Nn.d(r,e)},D:function(r,e,t){const n=zg(r);return e==="Do"?t.ordinalNumber(n,{unit:"dayOfYear"}):Er(n,e.length)},E:function(r,e,t){const n=r.getDay();switch(e){case"E":case"EE":case"EEE":return t.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return t.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(n,{width:"short",context:"formatting"});case"EEEE":default:return t.day(n,{width:"wide",context:"formatting"})}},e:function(r,e,t,n){const a=r.getDay(),i=(a-n.weekStartsOn+8)%7||7;switch(e){case"e":return String(i);case"ee":return Er(i,2);case"eo":return t.ordinalNumber(i,{unit:"day"});case"eee":return t.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return t.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return t.day(a,{width:"short",context:"formatting"});case"eeee":default:return t.day(a,{width:"wide",context:"formatting"})}},c:function(r,e,t,n){const a=r.getDay(),i=(a-n.weekStartsOn+8)%7||7;switch(e){case"c":return String(i);case"cc":return Er(i,e.length);case"co":return t.ordinalNumber(i,{unit:"day"});case"ccc":return t.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return t.day(a,{width:"narrow",context:"standalone"});case"cccccc":return t.day(a,{width:"short",context:"standalone"});case"cccc":default:return t.day(a,{width:"wide",context:"standalone"})}},i:function(r,e,t){const n=r.getDay(),a=n===0?7:n;switch(e){case"i":return String(a);case"ii":return Er(a,e.length);case"io":return t.ordinalNumber(a,{unit:"day"});case"iii":return t.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return t.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return t.day(n,{width:"short",context:"formatting"});case"iiii":default:return t.day(n,{width:"wide",context:"formatting"})}},a:function(r,e,t){const a=r.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return t.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return t.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return t.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return t.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(r,e,t){const n=r.getHours();let a;switch(n===12?a=fa.noon:n===0?a=fa.midnight:a=n/12>=1?"pm":"am",e){case"b":case"bb":return t.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return t.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return t.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return t.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(r,e,t){const n=r.getHours();let a;switch(n>=17?a=fa.evening:n>=12?a=fa.afternoon:n>=4?a=fa.morning:a=fa.night,e){case"B":case"BB":case"BBB":return t.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return t.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return t.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(r,e,t){if(e==="ho"){let n=r.getHours()%12;return n===0&&(n=12),t.ordinalNumber(n,{unit:"hour"})}return Nn.h(r,e)},H:function(r,e,t){return e==="Ho"?t.ordinalNumber(r.getHours(),{unit:"hour"}):Nn.H(r,e)},K:function(r,e,t){const n=r.getHours()%12;return e==="Ko"?t.ordinalNumber(n,{unit:"hour"}):Er(n,e.length)},k:function(r,e,t){let n=r.getHours();return n===0&&(n=24),e==="ko"?t.ordinalNumber(n,{unit:"hour"}):Er(n,e.length)},m:function(r,e,t){return e==="mo"?t.ordinalNumber(r.getMinutes(),{unit:"minute"}):Nn.m(r,e)},s:function(r,e,t){return e==="so"?t.ordinalNumber(r.getSeconds(),{unit:"second"}):Nn.s(r,e)},S:function(r,e){return Nn.S(r,e)},X:function(r,e,t){const n=r.getTimezoneOffset();if(n===0)return"Z";switch(e){case"X":return ku(n);case"XXXX":case"XX":return Wn(n);case"XXXXX":case"XXX":default:return Wn(n,":")}},x:function(r,e,t){const n=r.getTimezoneOffset();switch(e){case"x":return ku(n);case"xxxx":case"xx":return Wn(n);case"xxxxx":case"xxx":default:return Wn(n,":")}},O:function(r,e,t){const n=r.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+Lu(n,":");case"OOOO":default:return"GMT"+Wn(n,":")}},z:function(r,e,t){const n=r.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+Lu(n,":");case"zzzz":default:return"GMT"+Wn(n,":")}},t:function(r,e,t){const n=Math.trunc(+r/1e3);return Er(n,e.length)},T:function(r,e,t){return Er(+r,e.length)}};function Lu(r,e=""){const t=r>0?"-":"+",n=Math.abs(r),a=Math.trunc(n/60),i=n%60;return i===0?t+String(a):t+String(a)+e+Er(i,2)}function ku(r,e){return r%60===0?(r>0?"-":"+")+Er(Math.abs(r)/60,2):Wn(r,e)}function Wn(r,e=""){const t=r>0?"-":"+",n=Math.abs(r),a=Er(Math.trunc(n/60),2),i=Er(n%60,2);return t+a+e+i}const Vu=(r,e)=>{switch(r){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},Gu=(r,e)=>{switch(r){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},Vg={p:Gu,P:(r,e)=>{const t=r.match(/(P+)(p+)?/)||[],n=t[1],a=t[2];if(!a)return Vu(r,e);let i;switch(n){case"P":i=e.dateTime({width:"short"});break;case"PP":i=e.dateTime({width:"medium"});break;case"PPP":i=e.dateTime({width:"long"});break;case"PPPP":default:i=e.dateTime({width:"full"});break}return i.replace("{{date}}",Vu(n,e)).replace("{{time}}",Gu(a,e))}},Gg=/^D+$/,Hg=/^Y+$/,Wg=["D","DD","YY","YYYY"];function Yg(r){return Gg.test(r)}function Zg(r){return Hg.test(r)}function Jg(r,e,t){const n=jg(r,e,t);if(console.warn(n),Wg.includes(r))throw new RangeError(n)}function jg(r,e,t){const n=r[0]==="Y"?"years":"days of the month";return`Use \`${r.toLowerCase()}\` instead of \`${r}\` (in \`${e}\`) for formatting ${n} to the input \`${t}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Xg=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Qg=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Kg=/^'([^]*?)'?$/,e0=/''/g,r0=/[a-zA-Z]/;function t0(r,e,t){var c,f,m,v;const n=Ai(),a=n.locale??qg,i=n.firstWeekContainsDate??((f=(c=n.locale)==null?void 0:c.options)==null?void 0:f.firstWeekContainsDate)??1,o=n.weekStartsOn??((v=(m=n.locale)==null?void 0:m.options)==null?void 0:v.weekStartsOn)??0,l=Gt(r,t==null?void 0:t.in);if(!ig(l))throw new RangeError("Invalid time value");let u=e.match(Qg).map(p=>{const d=p[0];if(d==="p"||d==="P"){const y=Vg[d];return y(p,a.formatLong)}return p}).join("").match(Xg).map(p=>{if(p==="''")return{isToken:!1,value:"'"};const d=p[0];if(d==="'")return{isToken:!1,value:n0(p)};if(Uu[d])return{isToken:!0,value:p};if(d.match(r0))throw new RangeError("Format string contains an unescaped latin alphabet character `"+d+"`");return{isToken:!1,value:p}});a.localize.preprocessor&&(u=a.localize.preprocessor(l,u));const s={firstWeekContainsDate:i,weekStartsOn:o,locale:a};return u.map(p=>{if(!p.isToken)return p.value;const d=p.value;(Zg(d)||Yg(d))&&Jg(d,e,String(r));const y=Uu[d[0]];return y(l,d,a.localize,s)}).join("")}function n0(r){const e=r.match(Kg);return e?e[1].replace(e0,"'"):r}class a0 extends We{constructor(e,t){super(e,t),this.fieldDateTime=null,this.formatDateTime=null;let n=He.GetExpressions(this.Expression,this);if(n==null)throw new Error(`Error parsing DateTimeFormat function: ${this.Expression}`);var a=[];for(let o=0;o<n.length;o++){var i=n[o];if(i instanceof St){if(this.fieldDateTime==null)this.fieldDateTime=a,a=[];else if(this.formatDateTime==null)this.formatDateTime=a,a=[];else throw new Error(`DateTimeFormat function has too many parameters: ${this.Expression}`);continue}}if(a.length>0)if(this.fieldDateTime==null)this.fieldDateTime=a;else if(this.formatDateTime==null)this.formatDateTime=a;else throw new Error(`DateTimeFormat function has too many parameters: ${this.Expression}`)}Evaluate(e,t,n,a){if(this.fieldDateTime==null&&this.formatDateTime==null)throw new Error("Invalid expression "+this.Expression+" for TotalMinutesParse function!");let i="yyyy-MM-ddTHH:mm:ss";var o=He.ConcatValues(this.fieldDateTime,e,t,n,a);const l=new Date(o.ToString());if(this.formatDateTime!=null){let u=He.ConcatValues(this.formatDateTime,e,t,n,a);if(u==null)throw new Error("Invalid format for DateTimeFormatParse function in "+this.Expression+"!");i=u.ToString()}return t0(l,i)}}class i0 extends We{constructor(e,t){super(e,t)}Evaluate(e,t,n,a){var v,p,d;let i=null,o=null;if(this.Expression==null||this.Expression=="")i=a.TableName,o=a.FieldName;else{var l=this.Expression.split(".");if(l.length!=2)return!1;i=l[0],o=l[1]}if(i==(((v=t.Parent)==null?void 0:v.Tablename)??""))return(d=(p=t.Parent)==null?void 0:p.Record)==null||d.SetValueToKeyString(o,null,t.Record),!0;var u=e.FindTableLevel(i??"");if(u==null)return!1;if(u.Record!=null){var s=u.Record;return s.SetValueToKeyString(o,null,m),!0}else if(u.Records!=null){for(var c=u.Records,f=0;f<c.Records.length;f++){var s=c.Records[f],m=s.Record;s.SetValueToKeyString(o,null,m)}return!0}return!0}}class o0 extends We{constructor(e,t){super(e,t)}Evaluate(e,t,n,a){return this.Expression}}class s0 extends We{constructor(e,t){super(e,t),this.sourceDateTimeParse=null,this.compareDateTimeParse=null;var n=He.GetExpressions(this.Expression,this),a=[];for(let o=0;o<((n==null?void 0:n.length)??0);o++){var i=n[o];if(i instanceof St){if(this.sourceDateTimeParse==null)this.sourceDateTimeParse=a;else if(this.compareDateTimeParse==null)this.compareDateTimeParse=a;else throw Error("Too many expressions in "+this.Expression+" for TotalMinutesParse function!");a=[];continue}}if(this.sourceDateTimeParse==null)this.sourceDateTimeParse=a;else if(this.compareDateTimeParse==null)this.compareDateTimeParse=a;else throw Error("Too many expressions in "+this.Expression+" for TotalMinutesParse function!")}Evaluate(e,t,n,a){if(this.sourceDateTimeParse==null&&this.compareDateTimeParse==null)throw Error("Invalid expression "+this.Expression+" for TotalMinutesParse function!");let i=new Date(0),o=new Date;var l=He.ConcatValues(this.sourceDateTimeParse,e,t,n,a);if(i=this.GetDateTime(l),this.compareDateTimeParse!=null){var u=He.ConcatValues(this.compareDateTimeParse,e,t,n,a);o=this.GetDateTime(u)}else o=new Date;var s=o.getTime()-i.getTime();const c=Math.abs(s);return Math.floor(c/(1e3*60))}GetDateTime(e){try{if(e instanceof Date)return e;if(typeof e=="string")return new Date(e);throw Error("Value "+e+" isn't DateTime or string! "+typeof e)}catch(t){throw Error("Error parsing DateTime from value '"+e+"' Type:"+typeof e+": "+t)}}}class u0 extends We{constructor(e,t){super(e,t),this.valueParse=null,this.formatParse=null;var n=He.GetExpressions(this.Expression,this),a=[];for(let i=0;i<((n==null?void 0:n.length)??0);i++){const o=n[i];if(o instanceof St)if(this.valueParse==null){this.valueParse=a,a=[];continue}else throw new Error("Time parse - Too many parameters!");a.push(o)}a.length>0&&(this.valueParse==null?this.valueParse=a:this.formatParse=a),this.formatParse==null&&(this.formatParse=[new Hn("HH:mm:ss")])}Evaluate(e,t,n,a){var u;var i=null;((u=this.valueParse)==null?void 0:u.length)==1?i=this.valueParse[0].Evaluate(e,t,n,a):i=He.ConcatValues(this.valueParse,e,t,n,a);var o=He.ConcatValues(this.formatParse,e,t,n,a).ToString();let l=null;if(i instanceof Date)l=i;else if(typeof i!="string")throw l=new Date(i),new Error("Time parse -Can't convert "+i+" to datetime!");if(l==null)throw new Error("Time parse - "+i+" hasn't valid type!");return o(l,"yyyy-MM-dd HH:mm")}}class l0 extends We{constructor(e,t){super(e,t)}Evaluate(e,t,n,a){var i=He.GetExpressions(this.Expression,this);if((i==null?void 0:i.length)==1){var o=i[0].Evaluate(e,t,n,a);if(typeof o=="string")return o.length;throw Error("LEN function accepts only string parameters.")}else{var o=He.ConcatValues(i,e,t,n,a);if(typeof o=="string")return o.length;throw Error("LEN function accepts only string parameters.")}}}class c0 extends We{constructor(e,t){super(e,t),this.codeListTableParse=null,this.codeListFieldParse=null,this.objectValueExpresionParse=null,this.codeListDestFieldParse=null;var n=He.GetExpressions(this.Expression,this),a=[];for(let i=0;i<((n==null?void 0:n.length)??0);i++){const o=n[i];if(o instanceof St)if(this.codeListTableParse==null){this.codeListTableParse=a,a=[];continue}else if(this.codeListFieldParse==null){this.codeListFieldParse=a,a=[];continue}else if(this.objectValueExpresionParse==null){this.objectValueExpresionParse=a,a=[];continue}else throw Error("FromCodeList parse - Too many parameters!");a.push(o)}if(a.length>0)if(this.objectValueExpresionParse!=null&&this.codeListDestFieldParse==null)this.codeListDestFieldParse=a;else throw new Error("FromCodeList parse - Too few parameters!")}Evaluate(e,t,n,a){var f;var i=He.ConcatValues(this.codeListTableParse,e,t,n,a);if((i==null?void 0:i.toString())==null)throw Error("FromCodeList parse - CodeList table is null or empty!");var o=He.ConcatValues(this.codeListFieldParse,e,t,n,a);if((o==null?void 0:o.toString())==null)throw new Error("FromCodeList parse - codeList field is null or empty!");var l=He.ConcatValues(this.objectValueExpresionParse,e,t,n,a);(l==null?void 0:l.toString())==null;var u=He.ConcatValues(this.codeListDestFieldParse,e,t,n,a);if((u==null?void 0:u.toString())==null)throw new Error("FromCodeList parse - codeListDestField is null or empty!");try{if(e.CodeListCache==null||e.CodeListCache[i.toString()]==null)throw new Error("FromCodeList parse - CodeList "+i.toString()+" not found in cache!");var s=e.CodeListCache[i.toString()],c=s.filter(m=>{var v;return((v=m[o.toString()])==null?void 0:v.toString())==(l==null?void 0:l.toString())});if(c.length==0)throw Error("FromCodeList parse - No records found in CodeList "+i.toString()+" for field "+o.toString()+" and value "+(l==null?void 0:l.toString()));if(c.length>1)throw Error("FromCodeList parse - Multiple records found in CodeList "+i.toString()+" for field "+o.toString()+" and value "+(l==null?void 0:l.toString()));return((f=c[0][u.toString()])==null?void 0:f.toString())??null}catch(m){throw new Error("FromCodeList parse - Error obtaining record from CodeList! Reason: "+m)}}}class f0 extends We{constructor(e,t){super(e,t),this.Table="",this.Field="",this.ValueExpress="";var n=this.Expression.split(",");this.Table=n[0],this.Field=n[1],this.ValueExpress=n[2]}Evaluate(e,t,n,a){var i=new wn(this.ValueExpress,!1),o=i.Evaluate(e,t,n,a);if(o==null)return null;try{if(e.CodeListCache==null||e.CodeListCache[this.Table]==null)throw new Error("CodeListCheck parse - CodeList "+this.Table+" not found in cache!");var l=e.CodeListCache[this.Table],u=l.filter(s=>{var c;return((c=s[this.Field])==null?void 0:c.toString())==(o==null?void 0:o.toString())});if(u.length>0)return!0}catch(s){throw new Error("CodeListCheck parse - Error obtaining record from CodeList! Reason: "+s)}return!1}}function zr(){return zr=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},zr.apply(null,arguments)}var Hu={relTol:1e-12,absTol:1e-15,matrix:"Matrix",number:"number",numberFallback:"number",precision:64,predictable:!1,randomSeed:null,legacySubset:!1};function pt(r,e){if(Ci(r,e)||Wu(r,e))return r[e];throw Jo(r,e)?new Error('Cannot access method "'.concat(e,'" as a property')):r==null?new TypeError('Cannot access property "'.concat(e,'": object is ').concat(r)):new Error('No access to property "'+e+'"')}function ma(r,e,t){if(Ci(r,e)||Wu(r,e))return r[e]=t,t;throw new Error('No access to property "'.concat(e,'"'))}function Ci(r,e){return p0(r)?!(e in Object.prototype):!1}function Wu(r,e){return Array.isArray(r)?typeof e=="number"||typeof e=="string"&&m0(e)||e==="length":!1}function m0(r){return/^\d+$/.test(r)}function v0(r,e){if(!Jo(r,e))throw new Error('No access to method "'+e+'"');return r[e]}function Jo(r,e){return r==null||typeof r[e]!="function"||$e(r,e)&&Object.getPrototypeOf&&e in Object.getPrototypeOf(r)?!1:d0.has(e)?!0:!(e in Object.prototype||e in Function.prototype)}function p0(r){return typeof r=="object"&&r&&r.constructor===Object}var d0=new Set(["toString","valueOf","toLocaleString"]);class Mi{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 pt(this.wrappedObject,e)}set(e,t){return ma(this.wrappedObject,e,t),this}has(e){return Ci(this.wrappedObject,e)&&e in this.wrappedObject}entries(){return Zu(this.keys(),e=>[e,this.get(e)])}forEach(e){for(var t of this.keys())e(this.get(t),t,this)}delete(e){Ci(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 Yu{constructor(e,t,n){this.a=e,this.b=t,this.bKeys=n,this[Symbol.iterator]=this.entries}get(e){return this.bKeys.has(e)?this.b.get(e):this.a.get(e)}set(e,t){return this.bKeys.has(e)?this.b.set(e,t):this.a.set(e,t),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 Zu(this.keys(),e=>[e,this.get(e)])}forEach(e){for(var t of this.keys())e(this.get(t),t,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 Zu(r,e){return{next:()=>{var t=r.next();return t.done?t:{value:e(t.value),done:!1}}}}function Xa(){return new Map}function va(r){if(!r)return Xa();if(Xu(r))return r;if(Fi(r))return new Mi(r);throw new Error("createMap can create maps from objects or Maps")}function h0(r){if(r instanceof Mi)return r.wrappedObject;var e={};for(var t of r.keys()){var n=r.get(t);ma(e,t,n)}return e}function Ye(r){return typeof r=="number"}function or(r){return!r||typeof r!="object"||typeof r.constructor!="function"?!1:r.isBigNumber===!0&&typeof r.constructor.prototype=="object"&&r.constructor.prototype.isBigNumber===!0||typeof r.constructor.isDecimal=="function"&&r.constructor.isDecimal(r)===!0}function Qa(r){return typeof r=="bigint"}function ln(r){return r&&typeof r=="object"&&Object.getPrototypeOf(r).isComplex===!0||!1}function Ka(r){return r&&typeof r=="object"&&Object.getPrototypeOf(r).isFraction===!0||!1}function Ct(r){return r&&r.constructor.prototype.isUnit===!0||!1}function $r(r){return typeof r=="string"}var Ar=Array.isArray;function Je(r){return r&&r.constructor.prototype.isMatrix===!0||!1}function Mt(r){return Array.isArray(r)||Je(r)}function _i(r){return r&&r.isDenseMatrix&&r.constructor.prototype.isMatrix===!0||!1}function Yn(r){return r&&r.isSparseMatrix&&r.constructor.prototype.isMatrix===!0||!1}function jo(r){return r&&r.constructor.prototype.isRange===!0||!1}function Ti(r){return r&&r.constructor.prototype.isIndex===!0||!1}function g0(r){return typeof r=="boolean"}function y0(r){return r&&r.constructor.prototype.isResultSet===!0||!1}function Ju(r){return r&&r.constructor.prototype.isHelp===!0||!1}function ju(r){return typeof r=="function"}function b0(r){return r instanceof Date}function x0(r){return r instanceof RegExp}function Fi(r){return!!(r&&typeof r=="object"&&r.constructor===Object&&!ln(r)&&!Ka(r))}function Xu(r){return r?r instanceof Map||r instanceof Mi||typeof r.set=="function"&&typeof r.get=="function"&&typeof r.keys=="function"&&typeof r.has=="function":!1}function w0(r){return r===null}function D0(r){return r===void 0}function cn(r){return r&&r.isAccessorNode===!0&&r.constructor.prototype.isNode===!0||!1}function Rt(r){return r&&r.isArrayNode===!0&&r.constructor.prototype.isNode===!0||!1}function N0(r){return r&&r.isAssignmentNode===!0&&r.constructor.prototype.isNode===!0||!1}function E0(r){return r&&r.isBlockNode===!0&&r.constructor.prototype.isNode===!0||!1}function A0(r){return r&&r.isConditionalNode===!0&&r.constructor.prototype.isNode===!0||!1}function gr(r){return r&&r.isConstantNode===!0&&r.constructor.prototype.isNode===!0||!1}function Xo(r){return gr(r)||Ur(r)&&r.args.length===1&&gr(r.args[0])&&"-+~".includes(r.op)}function ei(r){return r&&r.isFunctionAssignmentNode===!0&&r.constructor.prototype.isNode===!0||!1}function En(r){return r&&r.isFunctionNode===!0&&r.constructor.prototype.isNode===!0||!1}function pa(r){return r&&r.isIndexNode===!0&&r.constructor.prototype.isNode===!0||!1}function Nr(r){return r&&r.isNode===!0&&r.constructor.prototype.isNode===!0||!1}function Oi(r){return r&&r.isObjectNode===!0&&r.constructor.prototype.isNode===!0||!1}function Ur(r){return r&&r.isOperatorNode===!0&&r.constructor.prototype.isNode===!0||!1}function fn(r){return r&&r.isParenthesisNode===!0&&r.constructor.prototype.isNode===!0||!1}function S0(r){return r&&r.isRangeNode===!0&&r.constructor.prototype.isNode===!0||!1}function C0(r){return r&&r.isRelationalNode===!0&&r.constructor.prototype.isNode===!0||!1}function jr(r){return r&&r.isSymbolNode===!0&&r.constructor.prototype.isNode===!0||!1}function Qu(r){return r&&r.constructor.prototype.isChain===!0||!1}function Sr(r){var e=typeof r;return e==="object"?r===null?"null":or(r)?"BigNumber":r.constructor&&r.constructor.name?r.constructor.name:"Object":e}function er(r){var e=typeof r;if(e==="number"||e==="bigint"||e==="string"||e==="boolean"||r===null||r===void 0)return r;if(typeof r.clone=="function")return r.clone();if(Array.isArray(r))return r.map(function(t){return er(t)});if(r instanceof Date)return new Date(r.valueOf());if(or(r))return r;if(Fi(r))return M0(r,er);if(e==="function")return r;throw new TypeError("Cannot clone: unknown type of value (value: ".concat(r,")"))}function M0(r,e){var t={};for(var n in r)$e(r,n)&&(t[n]=e(r[n]));return t}function Ku(r,e){for(var t in e)$e(e,t)&&(r[t]=e[t]);return r}function mn(r,e){var t,n,a;if(Array.isArray(r)){if(!Array.isArray(e)||r.length!==e.length)return!1;for(n=0,a=r.length;n<a;n++)if(!mn(r[n],e[n]))return!1;return!0}else{if(typeof r=="function")return r===e;if(r instanceof Object){if(Array.isArray(e)||!(e instanceof Object))return!1;for(t in r)if(!(t in e)||!mn(r[t],e[t]))return!1;for(t in e)if(!(t in r))return!1;return!0}else return r===e}}function _0(r,e,t){var n=!0,a;Object.defineProperty(r,e,{get:function(){return n&&(a=t(),n=!1),a},set:function(o){a=o,n=!1},configurable:!0,enumerable:!0})}function $e(r,e){return r&&Object.hasOwnProperty.call(r,e)}function T0(r,e){for(var t={},n=0;n<e.length;n++){var a=e[n],i=r[a];i!==void 0&&(t[a]=i)}return t}var F0=["Matrix","Array"],O0=["number","BigNumber","bigint","Fraction"],ye=function(e){if(e)throw new Error(`The global config is readonly.
|
|
3
3
|
Please create a mathjs instance if you want to change the default configuration.
|
|
4
4
|
Example:
|
|
5
5
|
|
|
6
6
|
import { create, all } from 'mathjs';
|
|
7
7
|
const mathjs = create(all);
|
|
8
8
|
mathjs.config({ number: 'BigNumber' });
|
|
9
|
-
`);return Object.freeze(Gu)};zr(ye,Gu,{MATRIX_OPTIONS:F0,NUMBER_OPTIONS:O0});function Ku(){return!0}function It(){return!1}function da(){}const el="Argument is not a typed-function.";function rl(){function r(R){return typeof R=="object"&&R!==null&&R.constructor===Object}const e=[{name:"number",test:function(R){return typeof R=="number"}},{name:"string",test:function(R){return typeof R=="string"}},{name:"boolean",test:function(R){return typeof R=="boolean"}},{name:"Function",test:function(R){return typeof R=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(R){return R instanceof Date}},{name:"RegExp",test:function(R){return R instanceof RegExp}},{name:"Object",test:r},{name:"null",test:function(R){return R===null}},{name:"undefined",test:function(R){return R===void 0}}],t={name:"any",test:Ku,isAny:!0};let n,a,i=0,o={createCount:0};function l(R){const H=n.get(R);if(H)return H;let Q='Unknown type "'+R+'"';const ie=R.toLowerCase();let ue;for(ue of a)if(ue.toLowerCase()===ie){Q+='. Did you mean "'+ue+'" ?';break}throw new TypeError(Q)}function u(R){let H=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const Q=H?l(H).index:a.length,ie=[];for(let oe=0;oe<R.length;++oe){if(!R[oe]||typeof R[oe].name!="string"||typeof R[oe].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const we=R[oe].name;if(n.has(we))throw new TypeError('Duplicate type name "'+we+'"');ie.push(we),n.set(we,{name:we,test:R[oe].test,isAny:R[oe].isAny,index:Q+oe,conversionsTo:[]})}const ue=a.slice(Q);a=a.slice(0,Q).concat(ie).concat(ue);for(let oe=Q+ie.length;oe<a.length;++oe)n.get(a[oe]).index=oe}function s(){n=new Map,a=[],i=0,u([t],!1)}s(),u(e);function c(){let R;for(R of a)n.get(R).conversionsTo=[];i=0}function f(R){const H=a.filter(Q=>{const ie=n.get(Q);return!ie.isAny&&ie.test(R)});return H.length?H:["any"]}function m(R){return R&&typeof R=="function"&&"_typedFunctionData"in R}function v(R,H,Q){if(!m(R))throw new TypeError(el);const ie=Q&&Q.exact,ue=Array.isArray(H)?H.join(","):H,oe=w(ue),we=y(oe);if(!ie||we in R.signatures){const ke=R._typedFunctionData.signatureMap.get(we);if(ke)return ke}const xe=oe.length;let Te;if(ie){Te=[];let ke;for(ke in R.signatures)Te.push(R._typedFunctionData.signatureMap.get(ke))}else Te=R._typedFunctionData.signatures;for(let ke=0;ke<xe;++ke){const fr=oe[ke],hr=[];let ir;for(ir of Te){const Fr=N(ir.params,ke);if(!(!Fr||fr.restParam&&!Fr.restParam)){if(!Fr.hasAny){const T=h(Fr);if(fr.types.some(K=>!T.has(K.name)))continue}hr.push(ir)}}if(Te=hr,Te.length===0)break}let be;for(be of Te)if(be.params.length<=xe)return be;throw new TypeError("Signature not found (signature: "+(R.name||"unnamed")+"("+y(oe,", ")+"))")}function p(R,H,Q){return v(R,H,Q).implementation}function d(R,H){const Q=l(H);if(Q.test(R))return R;const ie=Q.conversionsTo;if(ie.length===0)throw new Error("There are no conversions to "+H+" defined.");for(let ue=0;ue<ie.length;ue++)if(l(ie[ue].from).test(R))return ie[ue].convert(R);throw new Error("Cannot convert "+R+" to "+H)}function y(R){let H=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return R.map(Q=>Q.name).join(H)}function x(R){const H=R.indexOf("...")===0,ie=(H?R.length>3?R.slice(3):"any":R).split("|").map(xe=>l(xe.trim()));let ue=!1,oe=H?"...":"";return{types:ie.map(function(xe){return ue=xe.isAny||ue,oe+=xe.name+"|",{name:xe.name,typeIndex:xe.index,test:xe.test,isAny:xe.isAny,conversion:null,conversionIndex:-1}}),name:oe.slice(0,-1),hasAny:ue,hasConversion:!1,restParam:H}}function D(R){const H=R.types.map(we=>we.name),Q=P(H);let ie=R.hasAny,ue=R.name;const oe=Q.map(function(we){const xe=l(we.from);return ie=xe.isAny||ie,ue+="|"+we.from,{name:we.from,typeIndex:xe.index,test:xe.test,isAny:xe.isAny,conversion:we,conversionIndex:we.index}});return{types:R.types.concat(oe),name:ue,hasAny:ie,hasConversion:oe.length>0,restParam:R.restParam}}function h(R){return R.typeSet||(R.typeSet=new Set,R.types.forEach(H=>R.typeSet.add(H.name))),R.typeSet}function w(R){const H=[];if(typeof R!="string")throw new TypeError("Signatures must be strings");const Q=R.trim();if(Q==="")return H;const ie=Q.split(",");for(let ue=0;ue<ie.length;++ue){const oe=x(ie[ue].trim());if(oe.restParam&&ue!==ie.length-1)throw new SyntaxError('Unexpected rest parameter "'+ie[ue]+'": only allowed for the last parameter');if(oe.types.length===0)return null;H.push(oe)}return H}function g(R){const H=z(R);return H?H.restParam:!1}function b(R){if(!R||R.types.length===0)return Ku;if(R.types.length===1)return l(R.types[0].name).test;if(R.types.length===2){const H=l(R.types[0].name).test,Q=l(R.types[1].name).test;return function(ue){return H(ue)||Q(ue)}}else{const H=R.types.map(function(Q){return l(Q.name).test});return function(ie){for(let ue=0;ue<H.length;ue++)if(H[ue](ie))return!0;return!1}}}function A(R){let H,Q,ie;if(g(R)){H=Y(R).map(b);const ue=H.length,oe=b(z(R)),we=function(xe){for(let Te=ue;Te<xe.length;Te++)if(!oe(xe[Te]))return!1;return!0};return function(Te){for(let be=0;be<H.length;be++)if(!H[be](Te[be]))return!1;return we(Te)&&Te.length>=ue+1}}else return R.length===0?function(oe){return oe.length===0}:R.length===1?(Q=b(R[0]),function(oe){return Q(oe[0])&&oe.length===1}):R.length===2?(Q=b(R[0]),ie=b(R[1]),function(oe){return Q(oe[0])&&ie(oe[1])&&oe.length===2}):(H=R.map(b),function(oe){for(let we=0;we<H.length;we++)if(!H[we](oe[we]))return!1;return oe.length===H.length})}function N(R,H){return H<R.length?R[H]:g(R)?z(R):null}function E(R,H){const Q=N(R,H);return Q?h(Q):new Set}function S(R){return R.conversion===null||R.conversion===void 0}function C(R,H){const Q=new Set;return R.forEach(ie=>{const ue=E(ie.params,H);let oe;for(oe of ue)Q.add(oe)}),Q.has("any")?["any"]:Array.from(Q)}function M(R,H,Q){let ie,ue;const oe=R||"unnamed";let we=Q,xe;for(xe=0;xe<H.length;xe++){const fr=[];if(we.forEach(hr=>{const ir=N(hr.params,xe),Fr=b(ir);(xe<hr.params.length||g(hr.params))&&Fr(H[xe])&&fr.push(hr)}),fr.length===0){if(ue=C(we,xe),ue.length>0){const hr=f(H[xe]);return ie=new TypeError("Unexpected type of argument in function "+oe+" (expected: "+ue.join(" or ")+", actual: "+hr.join(" | ")+", index: "+xe+")"),ie.data={category:"wrongType",fn:oe,index:xe,actual:hr,expected:ue},ie}}else we=fr}const Te=we.map(function(fr){return g(fr.params)?1/0:fr.params.length});if(H.length<Math.min.apply(null,Te))return ue=C(we,xe),ie=new TypeError("Too few arguments in function "+oe+" (expected: "+ue.join(" or ")+", index: "+H.length+")"),ie.data={category:"tooFewArgs",fn:oe,index:H.length,expected:ue},ie;const be=Math.max.apply(null,Te);if(H.length>be)return ie=new TypeError("Too many arguments in function "+oe+" (expected: "+be+", actual: "+H.length+")"),ie.data={category:"tooManyArgs",fn:oe,index:H.length,expectedLength:be},ie;const ke=[];for(let fr=0;fr<H.length;++fr)ke.push(f(H[fr]).join("|"));return ie=new TypeError('Arguments of type "'+ke.join(", ")+'" do not match any of the defined signatures of function '+oe+"."),ie.data={category:"mismatch",actual:ke},ie}function O(R){let H=a.length+1;for(let Q=0;Q<R.types.length;Q++)H=Math.min(H,R.types[Q].typeIndex);return H}function I(R){let H=i+1;for(let Q=0;Q<R.types.length;Q++)S(R.types[Q])||(H=Math.min(H,R.types[Q].conversionIndex));return H}function k(R,H){if(R.hasAny){if(!H.hasAny)return .1}else if(H.hasAny)return-.1;if(R.restParam){if(!H.restParam)return .01}else if(H.restParam)return-.01;const Q=O(R)-O(H);if(Q<0)return-.001;if(Q>0)return .001;const ie=I(R),ue=I(H);if(R.hasConversion){if(!H.hasConversion)return(1+ie)*1e-6}else if(H.hasConversion)return-(1+ue)*1e-6;const oe=ie-ue;return oe<0?-1e-7:oe>0?1e-7:0}function _(R,H){const Q=R.params,ie=H.params,ue=z(Q),oe=z(ie),we=g(Q),xe=g(ie);if(we&&ue.hasAny){if(!xe||!oe.hasAny)return 1e7}else if(xe&&oe.hasAny)return-1e7;let Te=0,be=0,ke;for(ke of Q)ke.hasAny&&++Te,ke.hasConversion&&++be;let fr=0,hr=0;for(ke of ie)ke.hasAny&&++fr,ke.hasConversion&&++hr;if(Te!==fr)return(Te-fr)*1e6;if(we&&ue.hasConversion){if(!xe||!oe.hasConversion)return 1e5}else if(xe&&oe.hasConversion)return-1e5;if(be!==hr)return(be-hr)*1e4;if(we){if(!xe)return 1e3}else if(xe)return-1e3;const ir=(Q.length-ie.length)*(we?-100:100);if(ir!==0)return ir;const Fr=[];let T=0;for(let ze=0;ze<Q.length;++ze){const Ke=k(Q[ze],ie[ze]);Fr.push(Ke),T+=Ke}if(T!==0)return(T<0?-10:10)+T;let K,de=9;const Se=de/(Fr.length+1);for(K of Fr){if(K!==0)return(K<0?-de:de)+K;de-=Se}return 0}function P(R){if(R.length===0)return[];const H=R.map(l);if(R.length===1)return H[0].conversionsTo;const Q=new Set(R),ie=new Set;for(let oe=0;oe<H.length;++oe)for(const we of H[oe].conversionsTo)Q.has(we.from)||ie.add(we.from);const ue=[];for(const oe of ie){let we=i+1,xe=null;for(let Te=0;Te<H.length;++Te)for(const be of H[Te].conversionsTo)be.from===oe&&be.index<we&&(we=be.index,xe=be);ue.push(xe)}return ue}function V(R,H){let Q=H,ie="";if(R.some(oe=>oe.hasConversion)){const oe=g(R),we=R.map(q);ie=we.map(xe=>xe.name).join(";"),Q=function(){const Te=[],be=oe?arguments.length-1:arguments.length;for(let ke=0;ke<be;ke++)Te[ke]=we[ke](arguments[ke]);return oe&&(Te[be]=arguments[be].map(we[be])),H.apply(this,Te)}}let ue=Q;if(g(R)){const oe=R.length-1;ue=function(){return Q.apply(this,X(arguments,0,oe).concat([X(arguments,oe)]))}}return ie&&Object.defineProperty(ue,"name",{value:ie}),ue}function q(R){let H,Q,ie,ue;const oe=[],we=[];let xe="";R.types.forEach(function(be){be.conversion&&(xe+=be.conversion.from+"~>"+be.conversion.to+",",oe.push(l(be.conversion.from).test),we.push(be.conversion.convert))}),xe?xe=xe.slice(0,-1):xe="pass";let Te=be=>be;switch(we.length){case 0:break;case 1:H=oe[0],ie=we[0],Te=function(ke){return H(ke)?ie(ke):ke};break;case 2:H=oe[0],Q=oe[1],ie=we[0],ue=we[1],Te=function(ke){return H(ke)?ie(ke):Q(ke)?ue(ke):ke};break;default:Te=function(ke){for(let fr=0;fr<we.length;fr++)if(oe[fr](ke))return we[fr](ke);return ke}}return Object.defineProperty(Te,"name",{value:xe}),Te}function J(R){function H(Q,ie,ue){if(ie<Q.length){const oe=Q[ie];let we=[];if(oe.restParam){const xe=oe.types.filter(S);xe.length<oe.types.length&&we.push({types:xe,name:"..."+xe.map(Te=>Te.name).join("|"),hasAny:xe.some(Te=>Te.isAny),hasConversion:!1,restParam:!0}),we.push(oe)}else we=oe.types.map(function(xe){return{types:[xe],name:xe.name,hasAny:xe.isAny,hasConversion:xe.conversion,restParam:!1}});return re(we,function(xe){return H(Q,ie+1,ue.concat([xe]))})}else return[ue]}return H(R,0,[])}function ne(R,H){const Q=Math.max(R.length,H.length);for(let xe=0;xe<Q;xe++){const Te=E(R,xe),be=E(H,xe);let ke=!1,fr;for(fr of be)if(Te.has(fr)){ke=!0;break}if(!ke)return!1}const ie=R.length,ue=H.length,oe=g(R),we=g(H);return oe?we?ie===ue:ue>=ie:we?ie>=ue:ie===ue}function j(R){return R.map(H=>Ie(H)?De(H.referToSelf.callback):Oe(H)?ve(H.referTo.references,H.referTo.callback):H)}function F(R,H,Q){const ie=[];let ue;for(ue of R){let oe=Q[ue];if(typeof oe!="number")throw new TypeError('No definition for referenced signature "'+ue+'"');if(oe=H[oe],typeof oe!="function")return!1;ie.push(oe)}return ie}function U(R,H,Q){const ie=j(R),ue=new Array(ie.length).fill(!1);let oe=!0;for(;oe;){oe=!1;let we=!0;for(let xe=0;xe<ie.length;++xe){if(ue[xe])continue;const Te=ie[xe];if(Ie(Te))ie[xe]=Te.referToSelf.callback(Q),ie[xe].referToSelf=Te.referToSelf,ue[xe]=!0,we=!1;else if(Oe(Te)){const be=F(Te.referTo.references,ie,H);be?(ie[xe]=Te.referTo.callback.apply(this,be),ie[xe].referTo=Te.referTo,ue[xe]=!0,we=!1):oe=!0}}if(we&&oe)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return ie}function $(R){const H=/\bthis(\(|\.signatures\b)/;Object.keys(R).forEach(Q=>{const ie=R[Q];if(H.test(ie.toString()))throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function le(R,H){if(o.createCount++,Object.keys(H).length===0)throw new SyntaxError("No signatures provided");o.warnAgainstDeprecatedThis&&$(H);const Q=[],ie=[],ue={},oe=[];let we;for(we in H){if(!Object.prototype.hasOwnProperty.call(H,we))continue;const Pe=w(we);if(!Pe)continue;Q.forEach(function(Br){if(ne(Br,Pe))throw new TypeError('Conflicting signatures "'+y(Br)+'" and "'+y(Pe)+'".')}),Q.push(Pe);const mr=ie.length;ie.push(H[we]);const wr=Pe.map(D);let Pr;for(Pr of J(wr)){const Br=y(Pr);oe.push({params:Pr,name:Br,fn:mr}),Pr.every(en=>!en.hasConversion)&&(ue[Br]=mr)}}oe.sort(_);const xe=U(ie,ue,je);let Te;for(Te in ue)Object.prototype.hasOwnProperty.call(ue,Te)&&(ue[Te]=xe[ue[Te]]);const be=[],ke=new Map;for(Te of oe)ke.has(Te.name)||(Te.fn=xe[Te.fn],be.push(Te),ke.set(Te.name,Te));const fr=be[0]&&be[0].params.length<=2&&!g(be[0].params),hr=be[1]&&be[1].params.length<=2&&!g(be[1].params),ir=be[2]&&be[2].params.length<=2&&!g(be[2].params),Fr=be[3]&&be[3].params.length<=2&&!g(be[3].params),T=be[4]&&be[4].params.length<=2&&!g(be[4].params),K=be[5]&&be[5].params.length<=2&&!g(be[5].params),de=fr&&hr&&ir&&Fr&&T&&K;for(let Pe=0;Pe<be.length;++Pe)be[Pe].test=A(be[Pe].params);const Se=fr?b(be[0].params[0]):It,ze=hr?b(be[1].params[0]):It,Ke=ir?b(be[2].params[0]):It,et=Fr?b(be[3].params[0]):It,Ot=T?b(be[4].params[0]):It,xi=K?b(be[5].params[0]):It,wi=fr?b(be[0].params[1]):It,Wo=hr?b(be[1].params[1]):It,Di=ir?b(be[2].params[1]):It,un=Fr?b(be[3].params[1]):It,Wa=T?b(be[4].params[1]):It,Ya=K?b(be[5].params[1]):It;for(let Pe=0;Pe<be.length;++Pe)be[Pe].implementation=V(be[Pe].params,be[Pe].fn);const Su=fr?be[0].implementation:da,Ni=hr?be[1].implementation:da,Cu=ir?be[2].implementation:da,kr=Fr?be[3].implementation:da,B=T?be[4].implementation:da,Z=K?be[5].implementation:da,te=fr?be[0].params.length:-1,ae=hr?be[1].params.length:-1,ce=ir?be[2].params.length:-1,fe=Fr?be[3].params.length:-1,ge=T?be[4].params.length:-1,Ae=K?be[5].params.length:-1,Ee=de?6:0,Fe=be.length,Re=be.map(Pe=>Pe.test),pr=be.map(Pe=>Pe.implementation),Ve=function(){for(let mr=Ee;mr<Fe;mr++)if(Re[mr](arguments))return pr[mr].apply(this,arguments);return o.onMismatch(R,arguments,be)};function je(Pe,mr){return arguments.length===te&&Se(Pe)&&wi(mr)?Su.apply(this,arguments):arguments.length===ae&&ze(Pe)&&Wo(mr)?Ni.apply(this,arguments):arguments.length===ce&&Ke(Pe)&&Di(mr)?Cu.apply(this,arguments):arguments.length===fe&&et(Pe)&&un(mr)?kr.apply(this,arguments):arguments.length===ge&&Ot(Pe)&&Wa(mr)?B.apply(this,arguments):arguments.length===Ae&&xi(Pe)&&Ya(mr)?Z.apply(this,arguments):Ve.apply(this,arguments)}try{Object.defineProperty(je,"name",{value:R})}catch{}return je.signatures=ue,je._typedFunctionData={signatures:be,signatureMap:ke},je}function me(R,H,Q){throw M(R,H,Q)}function Y(R){return X(R,0,R.length-1)}function z(R){return R[R.length-1]}function X(R,H,Q){return Array.prototype.slice.call(R,H,Q)}function se(R,H){for(let Q=0;Q<R.length;Q++)if(H(R[Q]))return R[Q]}function re(R,H){return Array.prototype.concat.apply([],R.map(H))}function pe(){const R=Y(arguments).map(Q=>y(w(Q))),H=z(arguments);if(typeof H!="function")throw new TypeError("Callback function expected as last argument");return ve(R,H)}function ve(R,H){return{referTo:{references:R,callback:H}}}function De(R){if(typeof R!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:R}}}function Oe(R){return R&&typeof R.referTo=="object"&&Array.isArray(R.referTo.references)&&typeof R.referTo.callback=="function"}function Ie(R){return R&&typeof R.referToSelf=="object"&&typeof R.referToSelf.callback=="function"}function _e(R,H){if(!R)return H;if(H&&H!==R){const Q=new Error("Function names do not match (expected: "+R+", actual: "+H+")");throw Q.data={actual:H,expected:R},Q}return R}function Le(R){let H;for(const Q in R)Object.prototype.hasOwnProperty.call(R,Q)&&(m(R[Q])||typeof R[Q].signature=="string")&&(H=_e(H,R[Q].name));return H}function qe(R,H){let Q;for(Q in H)if(Object.prototype.hasOwnProperty.call(H,Q)){if(Q in R&&H[Q]!==R[Q]){const ie=new Error('Signature "'+Q+'" is defined twice');throw ie.data={signature:Q,sourceFunction:H[Q],destFunction:R[Q]},ie}R[Q]=H[Q]}}const G=o;o=function(R){const H=typeof R=="string",Q=H?1:0;let ie=H?R:"";const ue={};for(let oe=Q;oe<arguments.length;++oe){const we=arguments[oe];let xe={},Te;if(typeof we=="function"?(Te=we.name,typeof we.signature=="string"?xe[we.signature]=we:m(we)&&(xe=we.signatures)):r(we)&&(xe=we,H||(Te=Le(we))),Object.keys(xe).length===0){const be=new TypeError("Argument to 'typed' at index "+oe+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw be.data={index:oe,argument:we},be}H||(ie=_e(ie,Te)),qe(ue,xe)}return le(ie||"",ue)},o.create=rl,o.createCount=G.createCount,o.onMismatch=me,o.throwMismatchError=me,o.createError=M,o.clear=s,o.clearConversions=c,o.addTypes=u,o._findType=l,o.referTo=pe,o.referToSelf=De,o.convert=d,o.findSignature=v,o.find=p,o.isTypedFunction=m,o.warnAgainstDeprecatedThis=!0,o.addType=function(R,H){let Q="any";H!==!1&&n.has("Object")&&(Q="Object"),o.addTypes([R],Q)};function ee(R){if(!R||typeof R.from!="string"||typeof R.to!="string"||typeof R.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(R.to===R.from)throw new SyntaxError('Illegal to define conversion from "'+R.from+'" to itself.')}return o.addConversion=function(R){let H=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{override:!1};ee(R);const Q=l(R.to),ie=Q.conversionsTo.find(ue=>ue.from===R.from);if(ie)if(H&&H.override)o.removeConversion({from:ie.from,to:R.to,convert:ie.convert});else throw new Error('There is already a conversion from "'+R.from+'" to "'+Q.name+'"');Q.conversionsTo.push({from:R.from,to:Q.name,convert:R.convert,index:i++})},o.addConversions=function(R,H){R.forEach(Q=>o.addConversion(Q,H))},o.removeConversion=function(R){ee(R);const H=l(R.to),Q=se(H.conversionsTo,ue=>ue.from===R.from);if(!Q)throw new Error("Attempt to remove nonexistent conversion from "+R.from+" to "+R.to);if(Q.convert!==R.convert)throw new Error("Conversion to remove does not match existing conversion");const ie=H.conversionsTo.indexOf(Q);H.conversionsTo.splice(ie,1)},o.resolve=function(R,H){if(!m(R))throw new TypeError(el);const Q=R._typedFunctionData.signatures;for(let ie=0;ie<Q.length;++ie)if(Q[ie].test(H))return Q[ie];return null},o}const Bi=rl();function L(r,e,t,n){function a(i){var o=T0(i,e.map(I0));return B0(r,e,i),t(o)}return a.isFactory=!0,a.fn=r,a.dependencies=e.slice().sort(),n&&(a.meta=n),a}function B0(r,e,t){var n=e.filter(i=>!R0(i)).every(i=>t[i]!==void 0);if(!n){var a=e.filter(i=>t[i]===void 0);throw new Error('Cannot create function "'.concat(r,'", ')+"some dependencies are missing: ".concat(a.map(i=>'"'.concat(i,'"')).join(", "),"."))}}function R0(r){return r&&r[0]==="?"}function I0(r){return r&&r[0]==="?"?r.slice(1):r}function Ue(r){return typeof r=="boolean"?!0:Number.isFinite(r)?r===Math.round(r):!1}function An(r,e){if(e.number==="bigint")try{BigInt(r)}catch{return e.numberFallback}return e.number}var Sn=Math.sign||function(r){return r>0?1:r<0?-1:0},P0=Math.log2||function(e){return Math.log(e)/Math.LN2},$0=Math.log10||function(e){return Math.log(e)/Math.LN10},q0=Math.log1p||function(r){return Math.log(r+1)},z0=Math.cbrt||function(e){if(e===0)return e;var t=e<0,n;return t&&(e=-e),Number.isFinite(e)?(n=Math.exp(Math.log(e)/3),n=(e/(n*n)+2*n)/3):n=e,t?-n:n},U0=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function Qo(r,e,t){var n={2:"0b",8:"0o",16:"0x"},a=n[e],i="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!Ue(t))throw new Error("size must be an integer");if(r>2**(t-1)-1||r<-(2**(t-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!Ue(r))throw new Error("Value must be an integer");r<0&&(r=r+2**t),i="i".concat(t)}var o="";return r<0&&(r=-r,o="-"),"".concat(o).concat(a).concat(r.toString(e)).concat(i)}function Zn(r,e){if(typeof e=="function")return e(r);if(r===1/0)return"Infinity";if(r===-1/0)return"-Infinity";if(isNaN(r))return"NaN";var{notation:t,precision:n,wordSize:a}=tl(e);switch(t){case"fixed":return nl(r,n);case"exponential":return al(r,n);case"engineering":return L0(r,n);case"bin":return Qo(r,2,a);case"oct":return Qo(r,8,a);case"hex":return Qo(r,16,a);case"auto":return k0(r,n,e).replace(/((\.\d*?)(0+))($|e)/,function(){var i=arguments[2],o=arguments[4];return i!=="."?i+o:o});default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function tl(r){var e="auto",t,n;if(r!==void 0)if(Ye(r))t=r;else if(or(r))t=r.toNumber();else if(Fi(r))r.precision!==void 0&&(t=il(r.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),r.wordSize!==void 0&&(n=il(r.wordSize,()=>{throw new Error('Option "wordSize" must be a number or BigNumber')})),r.notation&&(e=r.notation);else throw new Error("Unsupported type of options, number, BigNumber, or object expected");return{notation:e,precision:t,wordSize:n}}function ri(r){var e=String(r).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!e)throw new SyntaxError("Invalid number "+r);var t=e[1],n=e[2],a=parseFloat(e[4]||"0"),i=n.indexOf(".");a+=i!==-1?i-1:n.length-1;var o=n.replace(".","").replace(/^0*/,function(l){return a-=l.length,""}).replace(/0*$/,"").split("").map(function(l){return parseInt(l)});return o.length===0&&(o.push(0),a++),{sign:t,coefficients:o,exponent:a}}function L0(r,e){if(isNaN(r)||!Number.isFinite(r))return String(r);var t=ri(r),n=Ri(t,e),a=n.exponent,i=n.coefficients,o=a%3===0?a:a<0?a-3-a%3:a-a%3;if(Ye(e))for(;e>i.length||a-o+1>i.length;)i.push(0);else for(var l=Math.abs(a-o)-(i.length-1),u=0;u<l;u++)i.push(0);for(var s=Math.abs(a-o),c=1;s>0;)c++,s--;var f=i.slice(c).join(""),m=Ye(e)&&f.length||f.match(/[1-9]/)?"."+f:"",v=i.slice(0,c).join("")+m+"e"+(a>=0?"+":"")+o.toString();return n.sign+v}function nl(r,e){if(isNaN(r)||!Number.isFinite(r))return String(r);var t=ri(r),n=typeof e=="number"?Ri(t,t.exponent+1+e):t,a=n.coefficients,i=n.exponent+1,o=i+(e||0);return a.length<o&&(a=a.concat(ha(o-a.length))),i<0&&(a=ha(-i+1).concat(a),i=1),i<a.length&&a.splice(i,0,i===0?"0.":"."),n.sign+a.join("")}function al(r,e){if(isNaN(r)||!Number.isFinite(Number(r)))return String(r);var t=ri(r),n=e?Ri(t,e):t,a=n.coefficients,i=n.exponent;a.length<e&&(a=a.concat(ha(e-a.length)));var o=a.shift();return n.sign+o+(a.length>0?"."+a.join(""):"")+"e"+(i>=0?"+":"")+i}function k0(r,e,t){if(isNaN(r)||!Number.isFinite(r))return String(r);var n=ol(t==null?void 0:t.lowerExp,-3),a=ol(t==null?void 0:t.upperExp,5),i=ri(r),o=e?Ri(i,e):i;if(o.exponent<n||o.exponent>=a)return al(r,e);var l=o.coefficients,u=o.exponent;l.length<e&&(l=l.concat(ha(e-l.length))),l=l.concat(ha(u-l.length+1+(l.length<e?e-l.length:0))),l=ha(-u).concat(l);var s=u>0?u:0;return s<l.length-1&&l.splice(s+1,0,"."),o.sign+l.join("")}function Ri(r,e){for(var t={sign:r.sign,coefficients:r.coefficients,exponent:r.exponent},n=t.coefficients;e<=0;)n.unshift(0),t.exponent++,e++;if(n.length>e){var a=n.splice(e,n.length-e);if(a[0]>=5){var i=e-1;for(n[i]++;n[i]===10;)n.pop(),i===0&&(n.unshift(0),t.exponent++,i++),i--,n[i]++}}return t}function ha(r){for(var e=[],t=0;t<r;t++)e.push(0);return e}function V0(r){return r.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}function jr(r,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e-8,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(t<=0)throw new Error("Relative tolerance must be greater than 0");if(n<0)throw new Error("Absolute tolerance must be at least 0");return isNaN(r)||isNaN(e)?!1:!Number.isFinite(r)||!Number.isFinite(e)?r===e:r===e?!0:Math.abs(r-e)<=Math.max(t*Math.max(Math.abs(r),Math.abs(e)),n)}var G0=Math.acosh||function(r){return Math.log(Math.sqrt(r*r-1)+r)},H0=Math.asinh||function(r){return Math.log(Math.sqrt(r*r+1)+r)},W0=Math.atanh||function(r){return Math.log((1+r)/(1-r))/2},Y0=Math.cosh||function(r){return(Math.exp(r)+Math.exp(-r))/2},Z0=Math.sinh||function(r){return(Math.exp(r)-Math.exp(-r))/2},J0=Math.tanh||function(r){var e=Math.exp(2*r);return(e-1)/(e+1)};function j0(r,e){var t=!0,n=e>0?!0:e<0?!1:1/e===1/0;return t^n?-r:r}function il(r,e){if(Ye(r))return r;if(or(r))return r.toNumber();e()}function ol(r,e){return Ye(r)?r:or(r)?r.toNumber():e}var sl=function(){return sl=Bi.create,Bi},X0=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],Q0=L("typed",X0,function(e){var{BigNumber:t,Complex:n,DenseMatrix:a,Fraction:i}=e,o=sl();return o.clear(),o.addTypes([{name:"number",test:Ye},{name:"Complex",test:ln},{name:"BigNumber",test:or},{name:"bigint",test:Qa},{name:"Fraction",test:Ka},{name:"Unit",test:St},{name:"identifier",test:l=>$r&&/^(?:[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-\u088F\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\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\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-\uA7DC\uA7F1-\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\uDD40-\uDD59\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-\uDEC7\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\uDDB0-\uDDDB\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\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\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2\uDFF3]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\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\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\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]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])(?:[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-\u088F\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\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\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-\uA7DC\uA7F1-\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\uDD40-\uDD59\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-\uDEC7\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\uDDB0-\uDDDB\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\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\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2\uDFF3]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\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\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\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]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])*$/.test(l)},{name:"string",test:$r},{name:"Chain",test:Xu},{name:"Array",test:Ar},{name:"Matrix",test:Je},{name:"DenseMatrix",test:_i},{name:"SparseMatrix",test:Yn},{name:"Range",test:jo},{name:"Index",test:Ti},{name:"boolean",test:g0},{name:"ResultSet",test:y0},{name:"Help",test:Zu},{name:"function",test:Ju},{name:"Date",test:b0},{name:"RegExp",test:x0},{name:"null",test:w0},{name:"undefined",test:D0},{name:"AccessorNode",test:cn},{name:"ArrayNode",test:Rt},{name:"AssignmentNode",test:N0},{name:"BlockNode",test:E0},{name:"ConditionalNode",test:A0},{name:"ConstantNode",test:gr},{name:"FunctionNode",test:En},{name:"FunctionAssignmentNode",test:ei},{name:"IndexNode",test:pa},{name:"Node",test:Nr},{name:"ObjectNode",test:Oi},{name:"OperatorNode",test:Ur},{name:"ParenthesisNode",test:fn},{name:"RangeNode",test:S0},{name:"RelationalNode",test:C0},{name:"SymbolNode",test:Jr},{name:"Map",test:ju},{name:"Object",test:Fi}]),o.addConversions([{from:"number",to:"BigNumber",convert:function(u){if(t||Ii(u),V0(u)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+u+"). Use function bignumber(x) to convert to BigNumber.");return new t(u)}},{from:"number",to:"Complex",convert:function(u){return n||Pi(u),new n(u,0)}},{from:"BigNumber",to:"Complex",convert:function(u){return n||Pi(u),new n(u.toNumber(),0)}},{from:"bigint",to:"number",convert:function(u){if(u>Number.MAX_SAFE_INTEGER)throw new TypeError("Cannot implicitly convert bigint to number: value exceeds the max safe integer value (value: "+u+")");return Number(u)}},{from:"bigint",to:"BigNumber",convert:function(u){return t||Ii(u),new t(u.toString())}},{from:"bigint",to:"Fraction",convert:function(u){return i||$i(u),new i(u)}},{from:"Fraction",to:"BigNumber",convert:function(u){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(u){return n||Pi(u),new n(u.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(u){i||$i(u);var s=new i(u);if(s.valueOf()!==u)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+u+"). Use function fraction(x) to convert to Fraction.");return s}},{from:"string",to:"number",convert:function(u){var s=Number(u);if(isNaN(s))throw new Error('Cannot convert "'+u+'" to a number');return s}},{from:"string",to:"BigNumber",convert:function(u){t||Ii(u);try{return new t(u)}catch{throw new Error('Cannot convert "'+u+'" to BigNumber')}}},{from:"string",to:"bigint",convert:function(u){try{return BigInt(u)}catch{throw new Error('Cannot convert "'+u+'" to BigInt')}}},{from:"string",to:"Fraction",convert:function(u){i||$i(u);try{return new i(u)}catch{throw new Error('Cannot convert "'+u+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(u){n||Pi(u);try{return new n(u)}catch{throw new Error('Cannot convert "'+u+'" to Complex')}}},{from:"boolean",to:"number",convert:function(u){return+u}},{from:"boolean",to:"BigNumber",convert:function(u){return t||Ii(u),new t(+u)}},{from:"boolean",to:"bigint",convert:function(u){return BigInt(+u)}},{from:"boolean",to:"Fraction",convert:function(u){return i||$i(u),new i(+u)}},{from:"boolean",to:"string",convert:function(u){return String(u)}},{from:"Array",to:"Matrix",convert:function(u){return a||K0(),new a(u)}},{from:"Matrix",to:"Array",convert:function(u){return u.valueOf()}}]),o.onMismatch=(l,u,s)=>{var c=o.createError(l,u,s);if(["wrongType","mismatch"].includes(c.data.category)&&u.length===1&&Ct(u[0])&&s.some(m=>!m.params.includes(","))){var f=new TypeError("Function '".concat(l,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(l,")'."));throw f.data=c.data,f}throw c},o.onMismatch=(l,u,s)=>{var c=o.createError(l,u,s);if(["wrongType","mismatch"].includes(c.data.category)&&u.length===1&&Ct(u[0])&&s.some(m=>!m.params.includes(","))){var f=new TypeError("Function '".concat(l,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(l,")'."));throw f.data=c.data,f}throw c},o});function Ii(r){throw new Error("Cannot convert value ".concat(r," into a BigNumber: no class 'BigNumber' provided"))}function Pi(r){throw new Error("Cannot convert value ".concat(r," into a Complex number: no class 'Complex' provided"))}function K0(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function $i(r){throw new Error("Cannot convert value ".concat(r," into a Fraction, no class 'Fraction' provided."))}var ey="ResultSet",ry=[],ty=L(ey,ry,()=>{function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this.entries=e||[]}return r.prototype.type="ResultSet",r.prototype.isResultSet=!0,r.prototype.valueOf=function(){return this.entries},r.prototype.toString=function(){return"["+this.entries.map(String).join(", ")+"]"},r.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},r.fromJSON=function(e){return new r(e.entries)},r},{isClass:!0});/*!
|
|
9
|
+
`);return Object.freeze(Hu)};zr(ye,Hu,{MATRIX_OPTIONS:F0,NUMBER_OPTIONS:O0});function el(){return!0}function It(){return!1}function da(){}const rl="Argument is not a typed-function.";function tl(){function r(R){return typeof R=="object"&&R!==null&&R.constructor===Object}const e=[{name:"number",test:function(R){return typeof R=="number"}},{name:"string",test:function(R){return typeof R=="string"}},{name:"boolean",test:function(R){return typeof R=="boolean"}},{name:"Function",test:function(R){return typeof R=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(R){return R instanceof Date}},{name:"RegExp",test:function(R){return R instanceof RegExp}},{name:"Object",test:r},{name:"null",test:function(R){return R===null}},{name:"undefined",test:function(R){return R===void 0}}],t={name:"any",test:el,isAny:!0};let n,a,i=0,o={createCount:0};function l(R){const H=n.get(R);if(H)return H;let Q='Unknown type "'+R+'"';const ie=R.toLowerCase();let ue;for(ue of a)if(ue.toLowerCase()===ie){Q+='. Did you mean "'+ue+'" ?';break}throw new TypeError(Q)}function u(R){let H=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const Q=H?l(H).index:a.length,ie=[];for(let oe=0;oe<R.length;++oe){if(!R[oe]||typeof R[oe].name!="string"||typeof R[oe].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const we=R[oe].name;if(n.has(we))throw new TypeError('Duplicate type name "'+we+'"');ie.push(we),n.set(we,{name:we,test:R[oe].test,isAny:R[oe].isAny,index:Q+oe,conversionsTo:[]})}const ue=a.slice(Q);a=a.slice(0,Q).concat(ie).concat(ue);for(let oe=Q+ie.length;oe<a.length;++oe)n.get(a[oe]).index=oe}function s(){n=new Map,a=[],i=0,u([t],!1)}s(),u(e);function c(){let R;for(R of a)n.get(R).conversionsTo=[];i=0}function f(R){const H=a.filter(Q=>{const ie=n.get(Q);return!ie.isAny&&ie.test(R)});return H.length?H:["any"]}function m(R){return R&&typeof R=="function"&&"_typedFunctionData"in R}function v(R,H,Q){if(!m(R))throw new TypeError(rl);const ie=Q&&Q.exact,ue=Array.isArray(H)?H.join(","):H,oe=w(ue),we=y(oe);if(!ie||we in R.signatures){const ke=R._typedFunctionData.signatureMap.get(we);if(ke)return ke}const xe=oe.length;let Te;if(ie){Te=[];let ke;for(ke in R.signatures)Te.push(R._typedFunctionData.signatureMap.get(ke))}else Te=R._typedFunctionData.signatures;for(let ke=0;ke<xe;++ke){const fr=oe[ke],hr=[];let ir;for(ir of Te){const Fr=N(ir.params,ke);if(!(!Fr||fr.restParam&&!Fr.restParam)){if(!Fr.hasAny){const T=h(Fr);if(fr.types.some(K=>!T.has(K.name)))continue}hr.push(ir)}}if(Te=hr,Te.length===0)break}let be;for(be of Te)if(be.params.length<=xe)return be;throw new TypeError("Signature not found (signature: "+(R.name||"unnamed")+"("+y(oe,", ")+"))")}function p(R,H,Q){return v(R,H,Q).implementation}function d(R,H){const Q=l(H);if(Q.test(R))return R;const ie=Q.conversionsTo;if(ie.length===0)throw new Error("There are no conversions to "+H+" defined.");for(let ue=0;ue<ie.length;ue++)if(l(ie[ue].from).test(R))return ie[ue].convert(R);throw new Error("Cannot convert "+R+" to "+H)}function y(R){let H=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return R.map(Q=>Q.name).join(H)}function x(R){const H=R.indexOf("...")===0,ie=(H?R.length>3?R.slice(3):"any":R).split("|").map(xe=>l(xe.trim()));let ue=!1,oe=H?"...":"";return{types:ie.map(function(xe){return ue=xe.isAny||ue,oe+=xe.name+"|",{name:xe.name,typeIndex:xe.index,test:xe.test,isAny:xe.isAny,conversion:null,conversionIndex:-1}}),name:oe.slice(0,-1),hasAny:ue,hasConversion:!1,restParam:H}}function D(R){const H=R.types.map(we=>we.name),Q=P(H);let ie=R.hasAny,ue=R.name;const oe=Q.map(function(we){const xe=l(we.from);return ie=xe.isAny||ie,ue+="|"+we.from,{name:we.from,typeIndex:xe.index,test:xe.test,isAny:xe.isAny,conversion:we,conversionIndex:we.index}});return{types:R.types.concat(oe),name:ue,hasAny:ie,hasConversion:oe.length>0,restParam:R.restParam}}function h(R){return R.typeSet||(R.typeSet=new Set,R.types.forEach(H=>R.typeSet.add(H.name))),R.typeSet}function w(R){const H=[];if(typeof R!="string")throw new TypeError("Signatures must be strings");const Q=R.trim();if(Q==="")return H;const ie=Q.split(",");for(let ue=0;ue<ie.length;++ue){const oe=x(ie[ue].trim());if(oe.restParam&&ue!==ie.length-1)throw new SyntaxError('Unexpected rest parameter "'+ie[ue]+'": only allowed for the last parameter');if(oe.types.length===0)return null;H.push(oe)}return H}function g(R){const H=z(R);return H?H.restParam:!1}function b(R){if(!R||R.types.length===0)return el;if(R.types.length===1)return l(R.types[0].name).test;if(R.types.length===2){const H=l(R.types[0].name).test,Q=l(R.types[1].name).test;return function(ue){return H(ue)||Q(ue)}}else{const H=R.types.map(function(Q){return l(Q.name).test});return function(ie){for(let ue=0;ue<H.length;ue++)if(H[ue](ie))return!0;return!1}}}function A(R){let H,Q,ie;if(g(R)){H=Y(R).map(b);const ue=H.length,oe=b(z(R)),we=function(xe){for(let Te=ue;Te<xe.length;Te++)if(!oe(xe[Te]))return!1;return!0};return function(Te){for(let be=0;be<H.length;be++)if(!H[be](Te[be]))return!1;return we(Te)&&Te.length>=ue+1}}else return R.length===0?function(oe){return oe.length===0}:R.length===1?(Q=b(R[0]),function(oe){return Q(oe[0])&&oe.length===1}):R.length===2?(Q=b(R[0]),ie=b(R[1]),function(oe){return Q(oe[0])&&ie(oe[1])&&oe.length===2}):(H=R.map(b),function(oe){for(let we=0;we<H.length;we++)if(!H[we](oe[we]))return!1;return oe.length===H.length})}function N(R,H){return H<R.length?R[H]:g(R)?z(R):null}function E(R,H){const Q=N(R,H);return Q?h(Q):new Set}function S(R){return R.conversion===null||R.conversion===void 0}function C(R,H){const Q=new Set;return R.forEach(ie=>{const ue=E(ie.params,H);let oe;for(oe of ue)Q.add(oe)}),Q.has("any")?["any"]:Array.from(Q)}function M(R,H,Q){let ie,ue;const oe=R||"unnamed";let we=Q,xe;for(xe=0;xe<H.length;xe++){const fr=[];if(we.forEach(hr=>{const ir=N(hr.params,xe),Fr=b(ir);(xe<hr.params.length||g(hr.params))&&Fr(H[xe])&&fr.push(hr)}),fr.length===0){if(ue=C(we,xe),ue.length>0){const hr=f(H[xe]);return ie=new TypeError("Unexpected type of argument in function "+oe+" (expected: "+ue.join(" or ")+", actual: "+hr.join(" | ")+", index: "+xe+")"),ie.data={category:"wrongType",fn:oe,index:xe,actual:hr,expected:ue},ie}}else we=fr}const Te=we.map(function(fr){return g(fr.params)?1/0:fr.params.length});if(H.length<Math.min.apply(null,Te))return ue=C(we,xe),ie=new TypeError("Too few arguments in function "+oe+" (expected: "+ue.join(" or ")+", index: "+H.length+")"),ie.data={category:"tooFewArgs",fn:oe,index:H.length,expected:ue},ie;const be=Math.max.apply(null,Te);if(H.length>be)return ie=new TypeError("Too many arguments in function "+oe+" (expected: "+be+", actual: "+H.length+")"),ie.data={category:"tooManyArgs",fn:oe,index:H.length,expectedLength:be},ie;const ke=[];for(let fr=0;fr<H.length;++fr)ke.push(f(H[fr]).join("|"));return ie=new TypeError('Arguments of type "'+ke.join(", ")+'" do not match any of the defined signatures of function '+oe+"."),ie.data={category:"mismatch",actual:ke},ie}function O(R){let H=a.length+1;for(let Q=0;Q<R.types.length;Q++)H=Math.min(H,R.types[Q].typeIndex);return H}function I(R){let H=i+1;for(let Q=0;Q<R.types.length;Q++)S(R.types[Q])||(H=Math.min(H,R.types[Q].conversionIndex));return H}function k(R,H){if(R.hasAny){if(!H.hasAny)return .1}else if(H.hasAny)return-.1;if(R.restParam){if(!H.restParam)return .01}else if(H.restParam)return-.01;const Q=O(R)-O(H);if(Q<0)return-.001;if(Q>0)return .001;const ie=I(R),ue=I(H);if(R.hasConversion){if(!H.hasConversion)return(1+ie)*1e-6}else if(H.hasConversion)return-(1+ue)*1e-6;const oe=ie-ue;return oe<0?-1e-7:oe>0?1e-7:0}function _(R,H){const Q=R.params,ie=H.params,ue=z(Q),oe=z(ie),we=g(Q),xe=g(ie);if(we&&ue.hasAny){if(!xe||!oe.hasAny)return 1e7}else if(xe&&oe.hasAny)return-1e7;let Te=0,be=0,ke;for(ke of Q)ke.hasAny&&++Te,ke.hasConversion&&++be;let fr=0,hr=0;for(ke of ie)ke.hasAny&&++fr,ke.hasConversion&&++hr;if(Te!==fr)return(Te-fr)*1e6;if(we&&ue.hasConversion){if(!xe||!oe.hasConversion)return 1e5}else if(xe&&oe.hasConversion)return-1e5;if(be!==hr)return(be-hr)*1e4;if(we){if(!xe)return 1e3}else if(xe)return-1e3;const ir=(Q.length-ie.length)*(we?-100:100);if(ir!==0)return ir;const Fr=[];let T=0;for(let ze=0;ze<Q.length;++ze){const Ke=k(Q[ze],ie[ze]);Fr.push(Ke),T+=Ke}if(T!==0)return(T<0?-10:10)+T;let K,de=9;const Se=de/(Fr.length+1);for(K of Fr){if(K!==0)return(K<0?-de:de)+K;de-=Se}return 0}function P(R){if(R.length===0)return[];const H=R.map(l);if(R.length===1)return H[0].conversionsTo;const Q=new Set(R),ie=new Set;for(let oe=0;oe<H.length;++oe)for(const we of H[oe].conversionsTo)Q.has(we.from)||ie.add(we.from);const ue=[];for(const oe of ie){let we=i+1,xe=null;for(let Te=0;Te<H.length;++Te)for(const be of H[Te].conversionsTo)be.from===oe&&be.index<we&&(we=be.index,xe=be);ue.push(xe)}return ue}function V(R,H){let Q=H,ie="";if(R.some(oe=>oe.hasConversion)){const oe=g(R),we=R.map(q);ie=we.map(xe=>xe.name).join(";"),Q=function(){const Te=[],be=oe?arguments.length-1:arguments.length;for(let ke=0;ke<be;ke++)Te[ke]=we[ke](arguments[ke]);return oe&&(Te[be]=arguments[be].map(we[be])),H.apply(this,Te)}}let ue=Q;if(g(R)){const oe=R.length-1;ue=function(){return Q.apply(this,X(arguments,0,oe).concat([X(arguments,oe)]))}}return ie&&Object.defineProperty(ue,"name",{value:ie}),ue}function q(R){let H,Q,ie,ue;const oe=[],we=[];let xe="";R.types.forEach(function(be){be.conversion&&(xe+=be.conversion.from+"~>"+be.conversion.to+",",oe.push(l(be.conversion.from).test),we.push(be.conversion.convert))}),xe?xe=xe.slice(0,-1):xe="pass";let Te=be=>be;switch(we.length){case 0:break;case 1:H=oe[0],ie=we[0],Te=function(ke){return H(ke)?ie(ke):ke};break;case 2:H=oe[0],Q=oe[1],ie=we[0],ue=we[1],Te=function(ke){return H(ke)?ie(ke):Q(ke)?ue(ke):ke};break;default:Te=function(ke){for(let fr=0;fr<we.length;fr++)if(oe[fr](ke))return we[fr](ke);return ke}}return Object.defineProperty(Te,"name",{value:xe}),Te}function J(R){function H(Q,ie,ue){if(ie<Q.length){const oe=Q[ie];let we=[];if(oe.restParam){const xe=oe.types.filter(S);xe.length<oe.types.length&&we.push({types:xe,name:"..."+xe.map(Te=>Te.name).join("|"),hasAny:xe.some(Te=>Te.isAny),hasConversion:!1,restParam:!0}),we.push(oe)}else we=oe.types.map(function(xe){return{types:[xe],name:xe.name,hasAny:xe.isAny,hasConversion:xe.conversion,restParam:!1}});return re(we,function(xe){return H(Q,ie+1,ue.concat([xe]))})}else return[ue]}return H(R,0,[])}function ne(R,H){const Q=Math.max(R.length,H.length);for(let xe=0;xe<Q;xe++){const Te=E(R,xe),be=E(H,xe);let ke=!1,fr;for(fr of be)if(Te.has(fr)){ke=!0;break}if(!ke)return!1}const ie=R.length,ue=H.length,oe=g(R),we=g(H);return oe?we?ie===ue:ue>=ie:we?ie>=ue:ie===ue}function j(R){return R.map(H=>Ie(H)?De(H.referToSelf.callback):Oe(H)?ve(H.referTo.references,H.referTo.callback):H)}function F(R,H,Q){const ie=[];let ue;for(ue of R){let oe=Q[ue];if(typeof oe!="number")throw new TypeError('No definition for referenced signature "'+ue+'"');if(oe=H[oe],typeof oe!="function")return!1;ie.push(oe)}return ie}function U(R,H,Q){const ie=j(R),ue=new Array(ie.length).fill(!1);let oe=!0;for(;oe;){oe=!1;let we=!0;for(let xe=0;xe<ie.length;++xe){if(ue[xe])continue;const Te=ie[xe];if(Ie(Te))ie[xe]=Te.referToSelf.callback(Q),ie[xe].referToSelf=Te.referToSelf,ue[xe]=!0,we=!1;else if(Oe(Te)){const be=F(Te.referTo.references,ie,H);be?(ie[xe]=Te.referTo.callback.apply(this,be),ie[xe].referTo=Te.referTo,ue[xe]=!0,we=!1):oe=!0}}if(we&&oe)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return ie}function $(R){const H=/\bthis(\(|\.signatures\b)/;Object.keys(R).forEach(Q=>{const ie=R[Q];if(H.test(ie.toString()))throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function le(R,H){if(o.createCount++,Object.keys(H).length===0)throw new SyntaxError("No signatures provided");o.warnAgainstDeprecatedThis&&$(H);const Q=[],ie=[],ue={},oe=[];let we;for(we in H){if(!Object.prototype.hasOwnProperty.call(H,we))continue;const Pe=w(we);if(!Pe)continue;Q.forEach(function(Br){if(ne(Br,Pe))throw new TypeError('Conflicting signatures "'+y(Br)+'" and "'+y(Pe)+'".')}),Q.push(Pe);const mr=ie.length;ie.push(H[we]);const wr=Pe.map(D);let Pr;for(Pr of J(wr)){const Br=y(Pr);oe.push({params:Pr,name:Br,fn:mr}),Pr.every(en=>!en.hasConversion)&&(ue[Br]=mr)}}oe.sort(_);const xe=U(ie,ue,je);let Te;for(Te in ue)Object.prototype.hasOwnProperty.call(ue,Te)&&(ue[Te]=xe[ue[Te]]);const be=[],ke=new Map;for(Te of oe)ke.has(Te.name)||(Te.fn=xe[Te.fn],be.push(Te),ke.set(Te.name,Te));const fr=be[0]&&be[0].params.length<=2&&!g(be[0].params),hr=be[1]&&be[1].params.length<=2&&!g(be[1].params),ir=be[2]&&be[2].params.length<=2&&!g(be[2].params),Fr=be[3]&&be[3].params.length<=2&&!g(be[3].params),T=be[4]&&be[4].params.length<=2&&!g(be[4].params),K=be[5]&&be[5].params.length<=2&&!g(be[5].params),de=fr&&hr&&ir&&Fr&&T&&K;for(let Pe=0;Pe<be.length;++Pe)be[Pe].test=A(be[Pe].params);const Se=fr?b(be[0].params[0]):It,ze=hr?b(be[1].params[0]):It,Ke=ir?b(be[2].params[0]):It,rt=Fr?b(be[3].params[0]):It,Bt=T?b(be[4].params[0]):It,xi=K?b(be[5].params[0]):It,wi=fr?b(be[0].params[1]):It,Wo=hr?b(be[1].params[1]):It,Di=ir?b(be[2].params[1]):It,un=Fr?b(be[3].params[1]):It,Wa=T?b(be[4].params[1]):It,Ya=K?b(be[5].params[1]):It;for(let Pe=0;Pe<be.length;++Pe)be[Pe].implementation=V(be[Pe].params,be[Pe].fn);const Cu=fr?be[0].implementation:da,Ni=hr?be[1].implementation:da,Mu=ir?be[2].implementation:da,kr=Fr?be[3].implementation:da,B=T?be[4].implementation:da,Z=K?be[5].implementation:da,te=fr?be[0].params.length:-1,ae=hr?be[1].params.length:-1,ce=ir?be[2].params.length:-1,fe=Fr?be[3].params.length:-1,ge=T?be[4].params.length:-1,Ae=K?be[5].params.length:-1,Ee=de?6:0,Fe=be.length,Re=be.map(Pe=>Pe.test),pr=be.map(Pe=>Pe.implementation),Ve=function(){for(let mr=Ee;mr<Fe;mr++)if(Re[mr](arguments))return pr[mr].apply(this,arguments);return o.onMismatch(R,arguments,be)};function je(Pe,mr){return arguments.length===te&&Se(Pe)&&wi(mr)?Cu.apply(this,arguments):arguments.length===ae&&ze(Pe)&&Wo(mr)?Ni.apply(this,arguments):arguments.length===ce&&Ke(Pe)&&Di(mr)?Mu.apply(this,arguments):arguments.length===fe&&rt(Pe)&&un(mr)?kr.apply(this,arguments):arguments.length===ge&&Bt(Pe)&&Wa(mr)?B.apply(this,arguments):arguments.length===Ae&&xi(Pe)&&Ya(mr)?Z.apply(this,arguments):Ve.apply(this,arguments)}try{Object.defineProperty(je,"name",{value:R})}catch{}return je.signatures=ue,je._typedFunctionData={signatures:be,signatureMap:ke},je}function me(R,H,Q){throw M(R,H,Q)}function Y(R){return X(R,0,R.length-1)}function z(R){return R[R.length-1]}function X(R,H,Q){return Array.prototype.slice.call(R,H,Q)}function se(R,H){for(let Q=0;Q<R.length;Q++)if(H(R[Q]))return R[Q]}function re(R,H){return Array.prototype.concat.apply([],R.map(H))}function pe(){const R=Y(arguments).map(Q=>y(w(Q))),H=z(arguments);if(typeof H!="function")throw new TypeError("Callback function expected as last argument");return ve(R,H)}function ve(R,H){return{referTo:{references:R,callback:H}}}function De(R){if(typeof R!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:R}}}function Oe(R){return R&&typeof R.referTo=="object"&&Array.isArray(R.referTo.references)&&typeof R.referTo.callback=="function"}function Ie(R){return R&&typeof R.referToSelf=="object"&&typeof R.referToSelf.callback=="function"}function _e(R,H){if(!R)return H;if(H&&H!==R){const Q=new Error("Function names do not match (expected: "+R+", actual: "+H+")");throw Q.data={actual:H,expected:R},Q}return R}function Le(R){let H;for(const Q in R)Object.prototype.hasOwnProperty.call(R,Q)&&(m(R[Q])||typeof R[Q].signature=="string")&&(H=_e(H,R[Q].name));return H}function qe(R,H){let Q;for(Q in H)if(Object.prototype.hasOwnProperty.call(H,Q)){if(Q in R&&H[Q]!==R[Q]){const ie=new Error('Signature "'+Q+'" is defined twice');throw ie.data={signature:Q,sourceFunction:H[Q],destFunction:R[Q]},ie}R[Q]=H[Q]}}const G=o;o=function(R){const H=typeof R=="string",Q=H?1:0;let ie=H?R:"";const ue={};for(let oe=Q;oe<arguments.length;++oe){const we=arguments[oe];let xe={},Te;if(typeof we=="function"?(Te=we.name,typeof we.signature=="string"?xe[we.signature]=we:m(we)&&(xe=we.signatures)):r(we)&&(xe=we,H||(Te=Le(we))),Object.keys(xe).length===0){const be=new TypeError("Argument to 'typed' at index "+oe+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw be.data={index:oe,argument:we},be}H||(ie=_e(ie,Te)),qe(ue,xe)}return le(ie||"",ue)},o.create=tl,o.createCount=G.createCount,o.onMismatch=me,o.throwMismatchError=me,o.createError=M,o.clear=s,o.clearConversions=c,o.addTypes=u,o._findType=l,o.referTo=pe,o.referToSelf=De,o.convert=d,o.findSignature=v,o.find=p,o.isTypedFunction=m,o.warnAgainstDeprecatedThis=!0,o.addType=function(R,H){let Q="any";H!==!1&&n.has("Object")&&(Q="Object"),o.addTypes([R],Q)};function ee(R){if(!R||typeof R.from!="string"||typeof R.to!="string"||typeof R.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(R.to===R.from)throw new SyntaxError('Illegal to define conversion from "'+R.from+'" to itself.')}return o.addConversion=function(R){let H=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{override:!1};ee(R);const Q=l(R.to),ie=Q.conversionsTo.find(ue=>ue.from===R.from);if(ie)if(H&&H.override)o.removeConversion({from:ie.from,to:R.to,convert:ie.convert});else throw new Error('There is already a conversion from "'+R.from+'" to "'+Q.name+'"');Q.conversionsTo.push({from:R.from,to:Q.name,convert:R.convert,index:i++})},o.addConversions=function(R,H){R.forEach(Q=>o.addConversion(Q,H))},o.removeConversion=function(R){ee(R);const H=l(R.to),Q=se(H.conversionsTo,ue=>ue.from===R.from);if(!Q)throw new Error("Attempt to remove nonexistent conversion from "+R.from+" to "+R.to);if(Q.convert!==R.convert)throw new Error("Conversion to remove does not match existing conversion");const ie=H.conversionsTo.indexOf(Q);H.conversionsTo.splice(ie,1)},o.resolve=function(R,H){if(!m(R))throw new TypeError(rl);const Q=R._typedFunctionData.signatures;for(let ie=0;ie<Q.length;++ie)if(Q[ie].test(H))return Q[ie];return null},o}const Bi=tl();function L(r,e,t,n){function a(i){var o=T0(i,e.map(I0));return B0(r,e,i),t(o)}return a.isFactory=!0,a.fn=r,a.dependencies=e.slice().sort(),n&&(a.meta=n),a}function B0(r,e,t){var n=e.filter(i=>!R0(i)).every(i=>t[i]!==void 0);if(!n){var a=e.filter(i=>t[i]===void 0);throw new Error('Cannot create function "'.concat(r,'", ')+"some dependencies are missing: ".concat(a.map(i=>'"'.concat(i,'"')).join(", "),"."))}}function R0(r){return r&&r[0]==="?"}function I0(r){return r&&r[0]==="?"?r.slice(1):r}function Ue(r){return typeof r=="boolean"?!0:Number.isFinite(r)?r===Math.round(r):!1}function An(r,e){if(e.number==="bigint")try{BigInt(r)}catch{return e.numberFallback}return e.number}var Sn=Math.sign||function(r){return r>0?1:r<0?-1:0},P0=Math.log2||function(e){return Math.log(e)/Math.LN2},$0=Math.log10||function(e){return Math.log(e)/Math.LN10},q0=Math.log1p||function(r){return Math.log(r+1)},z0=Math.cbrt||function(e){if(e===0)return e;var t=e<0,n;return t&&(e=-e),Number.isFinite(e)?(n=Math.exp(Math.log(e)/3),n=(e/(n*n)+2*n)/3):n=e,t?-n:n},U0=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function Qo(r,e,t){var n={2:"0b",8:"0o",16:"0x"},a=n[e],i="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!Ue(t))throw new Error("size must be an integer");if(r>2**(t-1)-1||r<-(2**(t-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!Ue(r))throw new Error("Value must be an integer");r<0&&(r=r+2**t),i="i".concat(t)}var o="";return r<0&&(r=-r,o="-"),"".concat(o).concat(a).concat(r.toString(e)).concat(i)}function Zn(r,e){if(typeof e=="function")return e(r);if(r===1/0)return"Infinity";if(r===-1/0)return"-Infinity";if(isNaN(r))return"NaN";var{notation:t,precision:n,wordSize:a}=nl(e);switch(t){case"fixed":return al(r,n);case"exponential":return il(r,n);case"engineering":return L0(r,n);case"bin":return Qo(r,2,a);case"oct":return Qo(r,8,a);case"hex":return Qo(r,16,a);case"auto":return k0(r,n,e).replace(/((\.\d*?)(0+))($|e)/,function(){var i=arguments[2],o=arguments[4];return i!=="."?i+o:o});default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function nl(r){var e="auto",t,n;if(r!==void 0)if(Ye(r))t=r;else if(or(r))t=r.toNumber();else if(Fi(r))r.precision!==void 0&&(t=ol(r.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),r.wordSize!==void 0&&(n=ol(r.wordSize,()=>{throw new Error('Option "wordSize" must be a number or BigNumber')})),r.notation&&(e=r.notation);else throw new Error("Unsupported type of options, number, BigNumber, or object expected");return{notation:e,precision:t,wordSize:n}}function ri(r){var e=String(r).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!e)throw new SyntaxError("Invalid number "+r);var t=e[1],n=e[2],a=parseFloat(e[4]||"0"),i=n.indexOf(".");a+=i!==-1?i-1:n.length-1;var o=n.replace(".","").replace(/^0*/,function(l){return a-=l.length,""}).replace(/0*$/,"").split("").map(function(l){return parseInt(l)});return o.length===0&&(o.push(0),a++),{sign:t,coefficients:o,exponent:a}}function L0(r,e){if(isNaN(r)||!Number.isFinite(r))return String(r);var t=ri(r),n=Ri(t,e),a=n.exponent,i=n.coefficients,o=a%3===0?a:a<0?a-3-a%3:a-a%3;if(Ye(e))for(;e>i.length||a-o+1>i.length;)i.push(0);else for(var l=Math.abs(a-o)-(i.length-1),u=0;u<l;u++)i.push(0);for(var s=Math.abs(a-o),c=1;s>0;)c++,s--;var f=i.slice(c).join(""),m=Ye(e)&&f.length||f.match(/[1-9]/)?"."+f:"",v=i.slice(0,c).join("")+m+"e"+(a>=0?"+":"")+o.toString();return n.sign+v}function al(r,e){if(isNaN(r)||!Number.isFinite(r))return String(r);var t=ri(r),n=typeof e=="number"?Ri(t,t.exponent+1+e):t,a=n.coefficients,i=n.exponent+1,o=i+(e||0);return a.length<o&&(a=a.concat(ha(o-a.length))),i<0&&(a=ha(-i+1).concat(a),i=1),i<a.length&&a.splice(i,0,i===0?"0.":"."),n.sign+a.join("")}function il(r,e){if(isNaN(r)||!Number.isFinite(Number(r)))return String(r);var t=ri(r),n=e?Ri(t,e):t,a=n.coefficients,i=n.exponent;a.length<e&&(a=a.concat(ha(e-a.length)));var o=a.shift();return n.sign+o+(a.length>0?"."+a.join(""):"")+"e"+(i>=0?"+":"")+i}function k0(r,e,t){if(isNaN(r)||!Number.isFinite(r))return String(r);var n=sl(t==null?void 0:t.lowerExp,-3),a=sl(t==null?void 0:t.upperExp,5),i=ri(r),o=e?Ri(i,e):i;if(o.exponent<n||o.exponent>=a)return il(r,e);var l=o.coefficients,u=o.exponent;l.length<e&&(l=l.concat(ha(e-l.length))),l=l.concat(ha(u-l.length+1+(l.length<e?e-l.length:0))),l=ha(-u).concat(l);var s=u>0?u:0;return s<l.length-1&&l.splice(s+1,0,"."),o.sign+l.join("")}function Ri(r,e){for(var t={sign:r.sign,coefficients:r.coefficients,exponent:r.exponent},n=t.coefficients;e<=0;)n.unshift(0),t.exponent++,e++;if(n.length>e){var a=n.splice(e,n.length-e);if(a[0]>=5){var i=e-1;for(n[i]++;n[i]===10;)n.pop(),i===0&&(n.unshift(0),t.exponent++,i++),i--,n[i]++}}return t}function ha(r){for(var e=[],t=0;t<r;t++)e.push(0);return e}function V0(r){return r.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}function Xr(r,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e-8,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(t<=0)throw new Error("Relative tolerance must be greater than 0");if(n<0)throw new Error("Absolute tolerance must be at least 0");return isNaN(r)||isNaN(e)?!1:!Number.isFinite(r)||!Number.isFinite(e)?r===e:r===e?!0:Math.abs(r-e)<=Math.max(t*Math.max(Math.abs(r),Math.abs(e)),n)}var G0=Math.acosh||function(r){return Math.log(Math.sqrt(r*r-1)+r)},H0=Math.asinh||function(r){return Math.log(Math.sqrt(r*r+1)+r)},W0=Math.atanh||function(r){return Math.log((1+r)/(1-r))/2},Y0=Math.cosh||function(r){return(Math.exp(r)+Math.exp(-r))/2},Z0=Math.sinh||function(r){return(Math.exp(r)-Math.exp(-r))/2},J0=Math.tanh||function(r){var e=Math.exp(2*r);return(e-1)/(e+1)};function j0(r,e){var t=!0,n=e>0?!0:e<0?!1:1/e===1/0;return t^n?-r:r}function ol(r,e){if(Ye(r))return r;if(or(r))return r.toNumber();e()}function sl(r,e){return Ye(r)?r:or(r)?r.toNumber():e}var ul=function(){return ul=Bi.create,Bi},X0=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],Q0=L("typed",X0,function(e){var{BigNumber:t,Complex:n,DenseMatrix:a,Fraction:i}=e,o=ul();return o.clear(),o.addTypes([{name:"number",test:Ye},{name:"Complex",test:ln},{name:"BigNumber",test:or},{name:"bigint",test:Qa},{name:"Fraction",test:Ka},{name:"Unit",test:Ct},{name:"identifier",test:l=>$r&&/^(?:[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-\u088F\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\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\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-\uA7DC\uA7F1-\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\uDD40-\uDD59\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-\uDEC7\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\uDDB0-\uDDDB\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\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\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2\uDFF3]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\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\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\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]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])(?:[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-\u088F\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\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\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-\uA7DC\uA7F1-\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\uDD40-\uDD59\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-\uDEC7\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\uDDB0-\uDDDB\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\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\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2\uDFF3]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\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\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\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]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])*$/.test(l)},{name:"string",test:$r},{name:"Chain",test:Qu},{name:"Array",test:Ar},{name:"Matrix",test:Je},{name:"DenseMatrix",test:_i},{name:"SparseMatrix",test:Yn},{name:"Range",test:jo},{name:"Index",test:Ti},{name:"boolean",test:g0},{name:"ResultSet",test:y0},{name:"Help",test:Ju},{name:"function",test:ju},{name:"Date",test:b0},{name:"RegExp",test:x0},{name:"null",test:w0},{name:"undefined",test:D0},{name:"AccessorNode",test:cn},{name:"ArrayNode",test:Rt},{name:"AssignmentNode",test:N0},{name:"BlockNode",test:E0},{name:"ConditionalNode",test:A0},{name:"ConstantNode",test:gr},{name:"FunctionNode",test:En},{name:"FunctionAssignmentNode",test:ei},{name:"IndexNode",test:pa},{name:"Node",test:Nr},{name:"ObjectNode",test:Oi},{name:"OperatorNode",test:Ur},{name:"ParenthesisNode",test:fn},{name:"RangeNode",test:S0},{name:"RelationalNode",test:C0},{name:"SymbolNode",test:jr},{name:"Map",test:Xu},{name:"Object",test:Fi}]),o.addConversions([{from:"number",to:"BigNumber",convert:function(u){if(t||Ii(u),V0(u)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+u+"). Use function bignumber(x) to convert to BigNumber.");return new t(u)}},{from:"number",to:"Complex",convert:function(u){return n||Pi(u),new n(u,0)}},{from:"BigNumber",to:"Complex",convert:function(u){return n||Pi(u),new n(u.toNumber(),0)}},{from:"bigint",to:"number",convert:function(u){if(u>Number.MAX_SAFE_INTEGER)throw new TypeError("Cannot implicitly convert bigint to number: value exceeds the max safe integer value (value: "+u+")");return Number(u)}},{from:"bigint",to:"BigNumber",convert:function(u){return t||Ii(u),new t(u.toString())}},{from:"bigint",to:"Fraction",convert:function(u){return i||$i(u),new i(u)}},{from:"Fraction",to:"BigNumber",convert:function(u){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(u){return n||Pi(u),new n(u.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(u){i||$i(u);var s=new i(u);if(s.valueOf()!==u)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+u+"). Use function fraction(x) to convert to Fraction.");return s}},{from:"string",to:"number",convert:function(u){var s=Number(u);if(isNaN(s))throw new Error('Cannot convert "'+u+'" to a number');return s}},{from:"string",to:"BigNumber",convert:function(u){t||Ii(u);try{return new t(u)}catch{throw new Error('Cannot convert "'+u+'" to BigNumber')}}},{from:"string",to:"bigint",convert:function(u){try{return BigInt(u)}catch{throw new Error('Cannot convert "'+u+'" to BigInt')}}},{from:"string",to:"Fraction",convert:function(u){i||$i(u);try{return new i(u)}catch{throw new Error('Cannot convert "'+u+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(u){n||Pi(u);try{return new n(u)}catch{throw new Error('Cannot convert "'+u+'" to Complex')}}},{from:"boolean",to:"number",convert:function(u){return+u}},{from:"boolean",to:"BigNumber",convert:function(u){return t||Ii(u),new t(+u)}},{from:"boolean",to:"bigint",convert:function(u){return BigInt(+u)}},{from:"boolean",to:"Fraction",convert:function(u){return i||$i(u),new i(+u)}},{from:"boolean",to:"string",convert:function(u){return String(u)}},{from:"Array",to:"Matrix",convert:function(u){return a||K0(),new a(u)}},{from:"Matrix",to:"Array",convert:function(u){return u.valueOf()}}]),o.onMismatch=(l,u,s)=>{var c=o.createError(l,u,s);if(["wrongType","mismatch"].includes(c.data.category)&&u.length===1&&Mt(u[0])&&s.some(m=>!m.params.includes(","))){var f=new TypeError("Function '".concat(l,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(l,")'."));throw f.data=c.data,f}throw c},o.onMismatch=(l,u,s)=>{var c=o.createError(l,u,s);if(["wrongType","mismatch"].includes(c.data.category)&&u.length===1&&Mt(u[0])&&s.some(m=>!m.params.includes(","))){var f=new TypeError("Function '".concat(l,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(l,")'."));throw f.data=c.data,f}throw c},o});function Ii(r){throw new Error("Cannot convert value ".concat(r," into a BigNumber: no class 'BigNumber' provided"))}function Pi(r){throw new Error("Cannot convert value ".concat(r," into a Complex number: no class 'Complex' provided"))}function K0(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function $i(r){throw new Error("Cannot convert value ".concat(r," into a Fraction, no class 'Fraction' provided."))}var ey="ResultSet",ry=[],ty=L(ey,ry,()=>{function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this.entries=e||[]}return r.prototype.type="ResultSet",r.prototype.isResultSet=!0,r.prototype.valueOf=function(){return this.entries},r.prototype.toString=function(){return"["+this.entries.map(String).join(", ")+"]"},r.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},r.fromJSON=function(e){return new r(e.entries)},r},{isClass:!0});/*!
|
|
10
10
|
* decimal.js v10.6.0
|
|
11
11
|
* An arbitrary-precision Decimal type for JavaScript.
|
|
12
12
|
* https://github.com/MikeMcl/decimal.js
|
|
13
13
|
* Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
14
14
|
* MIT Licence
|
|
15
|
-
*/var ga=9e15,Cn=1e9,Ko="0123456789abcdef",qi="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",zi="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",es={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ga,maxE:ga,crypto:!1},ul,vn,ar=!0,Ui="[DecimalError] ",Mn=Ui+"Invalid argument: ",ll=Ui+"Precision limit exceeded",cl=Ui+"crypto unavailable",fl="[object Decimal]",ot=Math.floor,Gr=Math.pow,ny=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,ay=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,iy=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,ml=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ht=1e7,Xe=7,oy=9007199254740991,sy=qi.length-1,rs=zi.length-1,Ne={toStringTag:fl};Ne.absoluteValue=Ne.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),Ze(r)},Ne.ceil=function(){return Ze(new this.constructor(this),this.e+1,2)},Ne.clampedTo=Ne.clamp=function(r,e){var t,n=this,a=n.constructor;if(r=new a(r),e=new a(e),!r.s||!e.s)return new a(NaN);if(r.gt(e))throw Error(Mn+e);return t=n.cmp(r),t<0?r:n.cmp(e)>0?e:new a(n)},Ne.comparedTo=Ne.cmp=function(r){var e,t,n,a,i=this,o=i.d,l=(r=new i.constructor(r)).d,u=i.s,s=r.s;if(!o||!l)return!u||!s?NaN:u!==s?u:o===l?0:!o^u<0?1:-1;if(!o[0]||!l[0])return o[0]?u:l[0]?-s:0;if(u!==s)return u;if(i.e!==r.e)return i.e>r.e^u<0?1:-1;for(n=o.length,a=l.length,e=0,t=n<a?n:a;e<t;++e)if(o[e]!==l[e])return o[e]>l[e]^u<0?1:-1;return n===a?0:n>a^u<0?1:-1},Ne.cosine=Ne.cos=function(){var r,e,t=this,n=t.constructor;return t.d?t.d[0]?(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+Xe,n.rounding=1,t=uy(n,yl(n,t)),n.precision=r,n.rounding=e,Ze(vn==2||vn==3?t.neg():t,r,e,!0)):new n(1):new n(NaN)},Ne.cubeRoot=Ne.cbrt=function(){var r,e,t,n,a,i,o,l,u,s,c=this,f=c.constructor;if(!c.isFinite()||c.isZero())return new f(c);for(ar=!1,i=c.s*Gr(c.s*c,1/3),!i||Math.abs(i)==1/0?(t=rt(c.d),r=c.e,(i=(r-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=Gr(t,1/3),r=ot((r+1)/3)-(r%3==(r<0?-1:2)),i==1/0?t="5e"+r:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),n=new f(t),n.s=c.s):n=new f(i.toString()),o=(r=f.precision)+3;;)if(l=n,u=l.times(l).times(l),s=u.plus(c),n=Or(s.plus(c).times(l),s.plus(u),o+2,1),rt(l.d).slice(0,o)===(t=rt(n.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!a&&t=="4999"){if(!a&&(Ze(l,r+1,0),l.times(l).times(l).eq(c))){n=l;break}o+=4,a=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Ze(n,r+1,1),e=!n.times(n).times(n).eq(c));break}return ar=!0,Ze(n,r,f.rounding,e)},Ne.decimalPlaces=Ne.dp=function(){var r,e=this.d,t=NaN;if(e){if(r=e.length-1,t=(r-ot(this.e/Xe))*Xe,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t},Ne.dividedBy=Ne.div=function(r){return Or(this,new this.constructor(r))},Ne.dividedToIntegerBy=Ne.divToInt=function(r){var e=this,t=e.constructor;return Ze(Or(e,new t(r),0,1,1),t.precision,t.rounding)},Ne.equals=Ne.eq=function(r){return this.cmp(r)===0},Ne.floor=function(){return Ze(new this.constructor(this),this.e+1,3)},Ne.greaterThan=Ne.gt=function(r){return this.cmp(r)>0},Ne.greaterThanOrEqualTo=Ne.gte=function(r){var e=this.cmp(r);return e==1||e===0},Ne.hyperbolicCosine=Ne.cosh=function(){var r,e,t,n,a,i=this,o=i.constructor,l=new o(1);if(!i.isFinite())return new o(i.s?1/0:NaN);if(i.isZero())return l;t=o.precision,n=o.rounding,o.precision=t+Math.max(i.e,i.sd())+4,o.rounding=1,a=i.d.length,a<32?(r=Math.ceil(a/3),e=(1/Hi(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),i=ya(o,1,i.times(e),new o(1),!0);for(var u,s=r,c=new o(8);s--;)u=i.times(i),i=l.minus(u.times(c.minus(u.times(c))));return Ze(i,o.precision=t,o.rounding=n,!0)},Ne.hyperbolicSine=Ne.sinh=function(){var r,e,t,n,a=this,i=a.constructor;if(!a.isFinite()||a.isZero())return new i(a);if(e=i.precision,t=i.rounding,i.precision=e+Math.max(a.e,a.sd())+4,i.rounding=1,n=a.d.length,n<3)a=ya(i,2,a,a,!0);else{r=1.4*Math.sqrt(n),r=r>16?16:r|0,a=a.times(1/Hi(5,r)),a=ya(i,2,a,a,!0);for(var o,l=new i(5),u=new i(16),s=new i(20);r--;)o=a.times(a),a=a.times(l.plus(o.times(u.times(o).plus(s))))}return i.precision=e,i.rounding=t,Ze(a,e,t,!0)},Ne.hyperbolicTangent=Ne.tanh=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+7,n.rounding=1,Or(t.sinh(),t.cosh(),n.precision=r,n.rounding=e)):new n(t.s)},Ne.inverseCosine=Ne.acos=function(){var r=this,e=r.constructor,t=r.abs().cmp(1),n=e.precision,a=e.rounding;return t!==-1?t===0?r.isNeg()?tn(e,n,a):new e(0):new e(NaN):r.isZero()?tn(e,n+4,a).times(.5):(e.precision=n+6,e.rounding=1,r=new e(1).minus(r).div(r.plus(1)).sqrt().atan(),e.precision=n,e.rounding=a,r.times(2))},Ne.inverseHyperbolicCosine=Ne.acosh=function(){var r,e,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(r=n.precision,e=n.rounding,n.precision=r+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,ar=!1,t=t.times(t).minus(1).sqrt().plus(t),ar=!0,n.precision=r,n.rounding=e,t.ln()):new n(t)},Ne.inverseHyperbolicSine=Ne.asinh=function(){var r,e,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,ar=!1,t=t.times(t).plus(1).sqrt().plus(t),ar=!0,n.precision=r,n.rounding=e,t.ln())},Ne.inverseHyperbolicTangent=Ne.atanh=function(){var r,e,t,n,a=this,i=a.constructor;return a.isFinite()?a.e>=0?new i(a.abs().eq(1)?a.s/0:a.isZero()?a:NaN):(r=i.precision,e=i.rounding,n=a.sd(),Math.max(n,r)<2*-a.e-1?Ze(new i(a),r,e,!0):(i.precision=t=n-a.e,a=Or(a.plus(1),new i(1).minus(a),t+r,1),i.precision=r+4,i.rounding=1,a=a.ln(),i.precision=r,i.rounding=e,a.times(.5))):new i(NaN)},Ne.inverseSine=Ne.asin=function(){var r,e,t,n,a=this,i=a.constructor;return a.isZero()?new i(a):(e=a.abs().cmp(1),t=i.precision,n=i.rounding,e!==-1?e===0?(r=tn(i,t+4,n).times(.5),r.s=a.s,r):new i(NaN):(i.precision=t+6,i.rounding=1,a=a.div(new i(1).minus(a.times(a)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=n,a.times(2)))},Ne.inverseTangent=Ne.atan=function(){var r,e,t,n,a,i,o,l,u,s=this,c=s.constructor,f=c.precision,m=c.rounding;if(s.isFinite()){if(s.isZero())return new c(s);if(s.abs().eq(1)&&f+4<=rs)return o=tn(c,f+4,m).times(.25),o.s=s.s,o}else{if(!s.s)return new c(NaN);if(f+4<=rs)return o=tn(c,f+4,m).times(.5),o.s=s.s,o}for(c.precision=l=f+10,c.rounding=1,t=Math.min(28,l/Xe+2|0),r=t;r;--r)s=s.div(s.times(s).plus(1).sqrt().plus(1));for(ar=!1,e=Math.ceil(l/Xe),n=1,u=s.times(s),o=new c(s),a=s;r!==-1;)if(a=a.times(u),i=o.minus(a.div(n+=2)),a=a.times(u),o=i.plus(a.div(n+=2)),o.d[e]!==void 0)for(r=e;o.d[r]===i.d[r]&&r--;);return t&&(o=o.times(2<<t-1)),ar=!0,Ze(o,c.precision=f,c.rounding=m,!0)},Ne.isFinite=function(){return!!this.d},Ne.isInteger=Ne.isInt=function(){return!!this.d&&ot(this.e/Xe)>this.d.length-2},Ne.isNaN=function(){return!this.s},Ne.isNegative=Ne.isNeg=function(){return this.s<0},Ne.isPositive=Ne.isPos=function(){return this.s>0},Ne.isZero=function(){return!!this.d&&this.d[0]===0},Ne.lessThan=Ne.lt=function(r){return this.cmp(r)<0},Ne.lessThanOrEqualTo=Ne.lte=function(r){return this.cmp(r)<1},Ne.logarithm=Ne.log=function(r){var e,t,n,a,i,o,l,u,s=this,c=s.constructor,f=c.precision,m=c.rounding,v=5;if(r==null)r=new c(10),e=!0;else{if(r=new c(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new c(NaN);e=r.eq(10)}if(t=s.d,s.s<0||!t||!t[0]||s.eq(1))return new c(t&&!t[0]?-1/0:s.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)i=!0;else{for(a=t[0];a%10===0;)a/=10;i=a!==1}if(ar=!1,l=f+v,o=Tn(s,l),n=e?Vi(c,l+10):Tn(r,l),u=Or(o,n,l,1),ti(u.d,a=f,m))do if(l+=10,o=Tn(s,l),n=e?Vi(c,l+10):Tn(r,l),u=Or(o,n,l,1),!i){+rt(u.d).slice(a+1,a+15)+1==1e14&&(u=Ze(u,f+1,0));break}while(ti(u.d,a+=10,m));return ar=!0,Ze(u,f,m)},Ne.minus=Ne.sub=function(r){var e,t,n,a,i,o,l,u,s,c,f,m,v=this,p=v.constructor;if(r=new p(r),!v.d||!r.d)return!v.s||!r.s?r=new p(NaN):v.d?r.s=-r.s:r=new p(r.d||v.s!==r.s?v:NaN),r;if(v.s!=r.s)return r.s=-r.s,v.plus(r);if(s=v.d,m=r.d,l=p.precision,u=p.rounding,!s[0]||!m[0]){if(m[0])r.s=-r.s;else if(s[0])r=new p(v);else return new p(u===3?-0:0);return ar?Ze(r,l,u):r}if(t=ot(r.e/Xe),c=ot(v.e/Xe),s=s.slice(),i=c-t,i){for(f=i<0,f?(e=s,i=-i,o=m.length):(e=m,t=c,o=s.length),n=Math.max(Math.ceil(l/Xe),o)+2,i>n&&(i=n,e.length=1),e.reverse(),n=i;n--;)e.push(0);e.reverse()}else{for(n=s.length,o=m.length,f=n<o,f&&(o=n),n=0;n<o;n++)if(s[n]!=m[n]){f=s[n]<m[n];break}i=0}for(f&&(e=s,s=m,m=e,r.s=-r.s),o=s.length,n=m.length-o;n>0;--n)s[o++]=0;for(n=m.length;n>i;){if(s[--n]<m[n]){for(a=n;a&&s[--a]===0;)s[a]=Ht-1;--s[a],s[n]+=Ht}s[n]-=m[n]}for(;s[--o]===0;)s.pop();for(;s[0]===0;s.shift())--t;return s[0]?(r.d=s,r.e=ki(s,t),ar?Ze(r,l,u):r):new p(u===3?-0:0)},Ne.modulo=Ne.mod=function(r){var e,t=this,n=t.constructor;return r=new n(r),!t.d||!r.s||r.d&&!r.d[0]?new n(NaN):!r.d||t.d&&!t.d[0]?Ze(new n(t),n.precision,n.rounding):(ar=!1,n.modulo==9?(e=Or(t,r.abs(),0,3,1),e.s*=r.s):e=Or(t,r,0,n.modulo,1),e=e.times(r),ar=!0,t.minus(e))},Ne.naturalExponential=Ne.exp=function(){return ts(this)},Ne.naturalLogarithm=Ne.ln=function(){return Tn(this)},Ne.negated=Ne.neg=function(){var r=new this.constructor(this);return r.s=-r.s,Ze(r)},Ne.plus=Ne.add=function(r){var e,t,n,a,i,o,l,u,s,c,f=this,m=f.constructor;if(r=new m(r),!f.d||!r.d)return!f.s||!r.s?r=new m(NaN):f.d||(r=new m(r.d||f.s===r.s?f:NaN)),r;if(f.s!=r.s)return r.s=-r.s,f.minus(r);if(s=f.d,c=r.d,l=m.precision,u=m.rounding,!s[0]||!c[0])return c[0]||(r=new m(f)),ar?Ze(r,l,u):r;if(i=ot(f.e/Xe),n=ot(r.e/Xe),s=s.slice(),a=i-n,a){for(a<0?(t=s,a=-a,o=c.length):(t=c,n=i,o=s.length),i=Math.ceil(l/Xe),o=i>o?i+1:o+1,a>o&&(a=o,t.length=1),t.reverse();a--;)t.push(0);t.reverse()}for(o=s.length,a=c.length,o-a<0&&(a=o,t=c,c=s,s=t),e=0;a;)e=(s[--a]=s[a]+c[a]+e)/Ht|0,s[a]%=Ht;for(e&&(s.unshift(e),++n),o=s.length;s[--o]==0;)s.pop();return r.d=s,r.e=ki(s,n),ar?Ze(r,l,u):r},Ne.precision=Ne.sd=function(r){var e,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(Mn+r);return t.d?(e=vl(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e},Ne.round=function(){var r=this,e=r.constructor;return Ze(new e(r),r.e+1,e.rounding)},Ne.sine=Ne.sin=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+Xe,n.rounding=1,t=cy(n,yl(n,t)),n.precision=r,n.rounding=e,Ze(vn>2?t.neg():t,r,e,!0)):new n(NaN)},Ne.squareRoot=Ne.sqrt=function(){var r,e,t,n,a,i,o=this,l=o.d,u=o.e,s=o.s,c=o.constructor;if(s!==1||!l||!l[0])return new c(!s||s<0&&(!l||l[0])?NaN:l?o:1/0);for(ar=!1,s=Math.sqrt(+o),s==0||s==1/0?(e=rt(l),(e.length+u)%2==0&&(e+="0"),s=Math.sqrt(e),u=ot((u+1)/2)-(u<0||u%2),s==1/0?e="5e"+u:(e=s.toExponential(),e=e.slice(0,e.indexOf("e")+1)+u),n=new c(e)):n=new c(s.toString()),t=(u=c.precision)+3;;)if(i=n,n=i.plus(Or(o,i,t+2,1)).times(.5),rt(i.d).slice(0,t)===(e=rt(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!a&&e=="4999"){if(!a&&(Ze(i,u+1,0),i.times(i).eq(o))){n=i;break}t+=4,a=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(Ze(n,u+1,1),r=!n.times(n).eq(o));break}return ar=!0,Ze(n,u,c.rounding,r)},Ne.tangent=Ne.tan=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+10,n.rounding=1,t=t.sin(),t.s=1,t=Or(t,new n(1).minus(t.times(t)).sqrt(),r+10,0),n.precision=r,n.rounding=e,Ze(vn==2||vn==4?t.neg():t,r,e,!0)):new n(NaN)},Ne.times=Ne.mul=function(r){var e,t,n,a,i,o,l,u,s,c=this,f=c.constructor,m=c.d,v=(r=new f(r)).d;if(r.s*=c.s,!m||!m[0]||!v||!v[0])return new f(!r.s||m&&!m[0]&&!v||v&&!v[0]&&!m?NaN:!m||!v?r.s/0:r.s*0);for(t=ot(c.e/Xe)+ot(r.e/Xe),u=m.length,s=v.length,u<s&&(i=m,m=v,v=i,o=u,u=s,s=o),i=[],o=u+s,n=o;n--;)i.push(0);for(n=s;--n>=0;){for(e=0,a=u+n;a>n;)l=i[a]+v[n]*m[a-n-1]+e,i[a--]=l%Ht|0,e=l/Ht|0;i[a]=(i[a]+e)%Ht|0}for(;!i[--o];)i.pop();return e?++t:i.shift(),r.d=i,r.e=ki(i,t),ar?Ze(r,f.precision,f.rounding):r},Ne.toBinary=function(r,e){return ns(this,2,r,e)},Ne.toDecimalPlaces=Ne.toDP=function(r,e){var t=this,n=t.constructor;return t=new n(t),r===void 0?t:(Dt(r,0,Cn),e===void 0?e=n.rounding:Dt(e,0,8),Ze(t,r+t.e+1,e))},Ne.toExponential=function(r,e){var t,n=this,a=n.constructor;return r===void 0?t=rn(n,!0):(Dt(r,0,Cn),e===void 0?e=a.rounding:Dt(e,0,8),n=Ze(new a(n),r+1,e),t=rn(n,!0,r+1)),n.isNeg()&&!n.isZero()?"-"+t:t},Ne.toFixed=function(r,e){var t,n,a=this,i=a.constructor;return r===void 0?t=rn(a):(Dt(r,0,Cn),e===void 0?e=i.rounding:Dt(e,0,8),n=Ze(new i(a),r+a.e+1,e),t=rn(n,!1,r+n.e+1)),a.isNeg()&&!a.isZero()?"-"+t:t},Ne.toFraction=function(r){var e,t,n,a,i,o,l,u,s,c,f,m,v=this,p=v.d,d=v.constructor;if(!p)return new d(v);if(s=t=new d(1),n=u=new d(0),e=new d(n),i=e.e=vl(p)-v.e-1,o=i%Xe,e.d[0]=Gr(10,o<0?Xe+o:o),r==null)r=i>0?e:s;else{if(l=new d(r),!l.isInt()||l.lt(s))throw Error(Mn+l);r=l.gt(e)?i>0?e:s:l}for(ar=!1,l=new d(rt(p)),c=d.precision,d.precision=i=p.length*Xe*2;f=Or(l,e,0,1,1),a=t.plus(f.times(n)),a.cmp(r)!=1;)t=n,n=a,a=s,s=u.plus(f.times(a)),u=a,a=e,e=l.minus(f.times(a)),l=a;return a=Or(r.minus(t),n,0,1,1),u=u.plus(a.times(s)),t=t.plus(a.times(n)),u.s=s.s=v.s,m=Or(s,n,i,1).minus(v).abs().cmp(Or(u,t,i,1).minus(v).abs())<1?[s,n]:[u,t],d.precision=c,ar=!0,m},Ne.toHexadecimal=Ne.toHex=function(r,e){return ns(this,16,r,e)},Ne.toNearest=function(r,e){var t=this,n=t.constructor;if(t=new n(t),r==null){if(!t.d)return t;r=new n(1),e=n.rounding}else{if(r=new n(r),e===void 0?e=n.rounding:Dt(e,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(ar=!1,t=Or(t,r,0,e,1).times(r),ar=!0,Ze(t)):(r.s=t.s,t=r),t},Ne.toNumber=function(){return+this},Ne.toOctal=function(r,e){return ns(this,8,r,e)},Ne.toPower=Ne.pow=function(r){var e,t,n,a,i,o,l=this,u=l.constructor,s=+(r=new u(r));if(!l.d||!r.d||!l.d[0]||!r.d[0])return new u(Gr(+l,s));if(l=new u(l),l.eq(1))return l;if(n=u.precision,i=u.rounding,r.eq(1))return Ze(l,n,i);if(e=ot(r.e/Xe),e>=r.d.length-1&&(t=s<0?-s:s)<=oy)return a=pl(u,l,t,n),r.s<0?new u(1).div(a):Ze(a,n,i);if(o=l.s,o<0){if(e<r.d.length-1)return new u(NaN);if(r.d[e]&1||(o=1),l.e==0&&l.d[0]==1&&l.d.length==1)return l.s=o,l}return t=Gr(+l,s),e=t==0||!isFinite(t)?ot(s*(Math.log("0."+rt(l.d))/Math.LN10+l.e+1)):new u(t+"").e,e>u.maxE+1||e<u.minE-1?new u(e>0?o/0:0):(ar=!1,u.rounding=l.s=1,t=Math.min(12,(e+"").length),a=ts(r.times(Tn(l,n+t)),n),a.d&&(a=Ze(a,n+5,1),ti(a.d,n,i)&&(e=n+10,a=Ze(ts(r.times(Tn(l,e+t)),e),e+5,1),+rt(a.d).slice(n+1,n+15)+1==1e14&&(a=Ze(a,n+1,0)))),a.s=o,ar=!0,u.rounding=i,Ze(a,n,i))},Ne.toPrecision=function(r,e){var t,n=this,a=n.constructor;return r===void 0?t=rn(n,n.e<=a.toExpNeg||n.e>=a.toExpPos):(Dt(r,1,Cn),e===void 0?e=a.rounding:Dt(e,0,8),n=Ze(new a(n),r,e),t=rn(n,r<=n.e||n.e<=a.toExpNeg,r)),n.isNeg()&&!n.isZero()?"-"+t:t},Ne.toSignificantDigits=Ne.toSD=function(r,e){var t=this,n=t.constructor;return r===void 0?(r=n.precision,e=n.rounding):(Dt(r,1,Cn),e===void 0?e=n.rounding:Dt(e,0,8)),Ze(new n(t),r,e)},Ne.toString=function(){var r=this,e=r.constructor,t=rn(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t},Ne.truncated=Ne.trunc=function(){return Ze(new this.constructor(this),this.e+1,1)},Ne.valueOf=Ne.toJSON=function(){var r=this,e=r.constructor,t=rn(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function rt(r){var e,t,n,a=r.length-1,i="",o=r[0];if(a>0){for(i+=o,e=1;e<a;e++)n=r[e]+"",t=Xe-n.length,t&&(i+=_n(t)),i+=n;o=r[e],n=o+"",t=Xe-n.length,t&&(i+=_n(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return i+o}function Dt(r,e,t){if(r!==~~r||r<e||r>t)throw Error(Mn+r)}function ti(r,e,t,n){var a,i,o,l;for(i=r[0];i>=10;i/=10)--e;return--e<0?(e+=Xe,a=0):(a=Math.ceil((e+1)/Xe),e%=Xe),i=Gr(10,Xe-e),l=r[a]%i|0,n==null?e<3?(e==0?l=l/100|0:e==1&&(l=l/10|0),o=t<4&&l==99999||t>3&&l==49999||l==5e4||l==0):o=(t<4&&l+1==i||t>3&&l+1==i/2)&&(r[a+1]/i/100|0)==Gr(10,e-2)-1||(l==i/2||l==0)&&(r[a+1]/i/100|0)==0:e<4?(e==0?l=l/1e3|0:e==1?l=l/100|0:e==2&&(l=l/10|0),o=(n||t<4)&&l==9999||!n&&t>3&&l==4999):o=((n||t<4)&&l+1==i||!n&&t>3&&l+1==i/2)&&(r[a+1]/i/1e3|0)==Gr(10,e-3)-1,o}function Li(r,e,t){for(var n,a=[0],i,o=0,l=r.length;o<l;){for(i=a.length;i--;)a[i]*=e;for(a[0]+=Ko.indexOf(r.charAt(o++)),n=0;n<a.length;n++)a[n]>t-1&&(a[n+1]===void 0&&(a[n+1]=0),a[n+1]+=a[n]/t|0,a[n]%=t)}return a.reverse()}function uy(r,e){var t,n,a;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),a=(1/Hi(4,t)).toString()):(t=16,a="2.3283064365386962890625e-10"),r.precision+=t,e=ya(r,1,e.times(a),new r(1));for(var i=t;i--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return r.precision-=t,e}var Or=function(){function r(n,a,i){var o,l=0,u=n.length;for(n=n.slice();u--;)o=n[u]*a+l,n[u]=o%i|0,l=o/i|0;return l&&n.unshift(l),n}function e(n,a,i,o){var l,u;if(i!=o)u=i>o?1:-1;else for(l=u=0;l<i;l++)if(n[l]!=a[l]){u=n[l]>a[l]?1:-1;break}return u}function t(n,a,i,o){for(var l=0;i--;)n[i]-=l,l=n[i]<a[i]?1:0,n[i]=l*o+n[i]-a[i];for(;!n[0]&&n.length>1;)n.shift()}return function(n,a,i,o,l,u){var s,c,f,m,v,p,d,y,x,D,h,w,g,b,A,N,E,S,C,M,O=n.constructor,I=n.s==a.s?1:-1,k=n.d,_=a.d;if(!k||!k[0]||!_||!_[0])return new O(!n.s||!a.s||(k?_&&k[0]==_[0]:!_)?NaN:k&&k[0]==0||!_?I*0:I/0);for(u?(v=1,c=n.e-a.e):(u=Ht,v=Xe,c=ot(n.e/v)-ot(a.e/v)),C=_.length,E=k.length,x=new O(I),D=x.d=[],f=0;_[f]==(k[f]||0);f++);if(_[f]>(k[f]||0)&&c--,i==null?(b=i=O.precision,o=O.rounding):l?b=i+(n.e-a.e)+1:b=i,b<0)D.push(1),p=!0;else{if(b=b/v+2|0,f=0,C==1){for(m=0,_=_[0],b++;(f<E||m)&&b--;f++)A=m*u+(k[f]||0),D[f]=A/_|0,m=A%_|0;p=m||f<E}else{for(m=u/(_[0]+1)|0,m>1&&(_=r(_,m,u),k=r(k,m,u),C=_.length,E=k.length),N=C,h=k.slice(0,C),w=h.length;w<C;)h[w++]=0;M=_.slice(),M.unshift(0),S=_[0],_[1]>=u/2&&++S;do m=0,s=e(_,h,C,w),s<0?(g=h[0],C!=w&&(g=g*u+(h[1]||0)),m=g/S|0,m>1?(m>=u&&(m=u-1),d=r(_,m,u),y=d.length,w=h.length,s=e(d,h,y,w),s==1&&(m--,t(d,C<y?M:_,y,u))):(m==0&&(s=m=1),d=_.slice()),y=d.length,y<w&&d.unshift(0),t(h,d,w,u),s==-1&&(w=h.length,s=e(_,h,C,w),s<1&&(m++,t(h,C<w?M:_,w,u))),w=h.length):s===0&&(m++,h=[0]),D[f++]=m,s&&h[0]?h[w++]=k[N]||0:(h=[k[N]],w=1);while((N++<E||h[0]!==void 0)&&b--);p=h[0]!==void 0}D[0]||D.shift()}if(v==1)x.e=c,ul=p;else{for(f=1,m=D[0];m>=10;m/=10)f++;x.e=f+c*v-1,Ze(x,l?i+x.e+1:i,o,p)}return x}}();function Ze(r,e,t,n){var a,i,o,l,u,s,c,f,m,v=r.constructor;e:if(e!=null){if(f=r.d,!f)return r;for(a=1,l=f[0];l>=10;l/=10)a++;if(i=e-a,i<0)i+=Xe,o=e,c=f[m=0],u=c/Gr(10,a-o-1)%10|0;else if(m=Math.ceil((i+1)/Xe),l=f.length,m>=l)if(n){for(;l++<=m;)f.push(0);c=u=0,a=1,i%=Xe,o=i-Xe+1}else break e;else{for(c=l=f[m],a=1;l>=10;l/=10)a++;i%=Xe,o=i-Xe+a,u=o<0?0:c/Gr(10,a-o-1)%10|0}if(n=n||e<0||f[m+1]!==void 0||(o<0?c:c%Gr(10,a-o-1)),s=t<4?(u||n)&&(t==0||t==(r.s<0?3:2)):u>5||u==5&&(t==4||n||t==6&&(i>0?o>0?c/Gr(10,a-o):0:f[m-1])%10&1||t==(r.s<0?8:7)),e<1||!f[0])return f.length=0,s?(e-=r.e+1,f[0]=Gr(10,(Xe-e%Xe)%Xe),r.e=-e||0):f[0]=r.e=0,r;if(i==0?(f.length=m,l=1,m--):(f.length=m+1,l=Gr(10,Xe-i),f[m]=o>0?(c/Gr(10,a-o)%Gr(10,o)|0)*l:0),s)for(;;)if(m==0){for(i=1,o=f[0];o>=10;o/=10)i++;for(o=f[0]+=l,l=1;o>=10;o/=10)l++;i!=l&&(r.e++,f[0]==Ht&&(f[0]=1));break}else{if(f[m]+=l,f[m]!=Ht)break;f[m--]=0,l=1}for(i=f.length;f[--i]===0;)f.pop()}return ar&&(r.e>v.maxE?(r.d=null,r.e=NaN):r.e<v.minE&&(r.e=0,r.d=[0])),r}function rn(r,e,t){if(!r.isFinite())return gl(r);var n,a=r.e,i=rt(r.d),o=i.length;return e?(t&&(n=t-o)>0?i=i.charAt(0)+"."+i.slice(1)+_n(n):o>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(r.e<0?"e":"e+")+r.e):a<0?(i="0."+_n(-a-1)+i,t&&(n=t-o)>0&&(i+=_n(n))):a>=o?(i+=_n(a+1-o),t&&(n=t-a-1)>0&&(i=i+"."+_n(n))):((n=a+1)<o&&(i=i.slice(0,n)+"."+i.slice(n)),t&&(n=t-o)>0&&(a+1===o&&(i+="."),i+=_n(n))),i}function ki(r,e){var t=r[0];for(e*=Xe;t>=10;t/=10)e++;return e}function Vi(r,e,t){if(e>sy)throw ar=!0,t&&(r.precision=t),Error(ll);return Ze(new r(qi),e,1,!0)}function tn(r,e,t){if(e>rs)throw Error(ll);return Ze(new r(zi),e,t,!0)}function vl(r){var e=r.length-1,t=e*Xe+1;if(e=r[e],e){for(;e%10==0;e/=10)t--;for(e=r[0];e>=10;e/=10)t++}return t}function _n(r){for(var e="";r--;)e+="0";return e}function pl(r,e,t,n){var a,i=new r(1),o=Math.ceil(n/Xe+4);for(ar=!1;;){if(t%2&&(i=i.times(e),bl(i.d,o)&&(a=!0)),t=ot(t/2),t===0){t=i.d.length-1,a&&i.d[t]===0&&++i.d[t];break}e=e.times(e),bl(e.d,o)}return ar=!0,i}function dl(r){return r.d[r.d.length-1]&1}function hl(r,e,t){for(var n,a,i=new r(e[0]),o=0;++o<e.length;){if(a=new r(e[o]),!a.s){i=a;break}n=i.cmp(a),(n===t||n===0&&i.s===t)&&(i=a)}return i}function ts(r,e){var t,n,a,i,o,l,u,s=0,c=0,f=0,m=r.constructor,v=m.rounding,p=m.precision;if(!r.d||!r.d[0]||r.e>17)return new m(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:NaN);for(e==null?(ar=!1,u=p):u=e,l=new m(.03125);r.e>-2;)r=r.times(l),f+=5;for(n=Math.log(Gr(2,f))/Math.LN10*2+5|0,u+=n,t=i=o=new m(1),m.precision=u;;){if(i=Ze(i.times(r),u,1),t=t.times(++c),l=o.plus(Or(i,t,u,1)),rt(l.d).slice(0,u)===rt(o.d).slice(0,u)){for(a=f;a--;)o=Ze(o.times(o),u,1);if(e==null)if(s<3&&ti(o.d,u-n,v,s))m.precision=u+=10,t=i=l=new m(1),c=0,s++;else return Ze(o,m.precision=p,v,ar=!0);else return m.precision=p,o}o=l}}function Tn(r,e){var t,n,a,i,o,l,u,s,c,f,m,v=1,p=10,d=r,y=d.d,x=d.constructor,D=x.rounding,h=x.precision;if(d.s<0||!y||!y[0]||!d.e&&y[0]==1&&y.length==1)return new x(y&&!y[0]?-1/0:d.s!=1?NaN:y?0:d);if(e==null?(ar=!1,c=h):c=e,x.precision=c+=p,t=rt(y),n=t.charAt(0),Math.abs(i=d.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)d=d.times(r),t=rt(d.d),n=t.charAt(0),v++;i=d.e,n>1?(d=new x("0."+t),i++):d=new x(n+"."+t.slice(1))}else return s=Vi(x,c+2,h).times(i+""),d=Tn(new x(n+"."+t.slice(1)),c-p).plus(s),x.precision=h,e==null?Ze(d,h,D,ar=!0):d;for(f=d,u=o=d=Or(d.minus(1),d.plus(1),c,1),m=Ze(d.times(d),c,1),a=3;;){if(o=Ze(o.times(m),c,1),s=u.plus(Or(o,new x(a),c,1)),rt(s.d).slice(0,c)===rt(u.d).slice(0,c))if(u=u.times(2),i!==0&&(u=u.plus(Vi(x,c+2,h).times(i+""))),u=Or(u,new x(v),c,1),e==null)if(ti(u.d,c-p,D,l))x.precision=c+=p,s=o=d=Or(f.minus(1),f.plus(1),c,1),m=Ze(d.times(d),c,1),a=l=1;else return Ze(u,x.precision=h,D,ar=!0);else return x.precision=h,u;u=s,a+=2}}function gl(r){return String(r.s*r.s/0)}function Gi(r,e){var t,n,a;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(t<0&&(t=n),t+=+e.slice(n+1),e=e.substring(0,n)):t<0&&(t=e.length),n=0;e.charCodeAt(n)===48;n++);for(a=e.length;e.charCodeAt(a-1)===48;--a);if(e=e.slice(n,a),e){if(a-=n,r.e=t=t-n-1,r.d=[],n=(t+1)%Xe,t<0&&(n+=Xe),n<a){for(n&&r.d.push(+e.slice(0,n)),a-=Xe;n<a;)r.d.push(+e.slice(n,n+=Xe));e=e.slice(n),n=Xe-e.length}else n-=a;for(;n--;)e+="0";r.d.push(+e),ar&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}function ly(r,e){var t,n,a,i,o,l,u,s,c;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),ml.test(e))return Gi(r,e)}else if(e==="Infinity"||e==="NaN")return+e||(r.s=NaN),r.e=NaN,r.d=null,r;if(ay.test(e))t=16,e=e.toLowerCase();else if(ny.test(e))t=2;else if(iy.test(e))t=8;else throw Error(Mn+e);for(i=e.search(/p/i),i>0?(u=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),o=i>=0,n=r.constructor,o&&(e=e.replace(".",""),l=e.length,i=l-i,a=pl(n,new n(t),i,i*2)),s=Li(e,t,Ht),c=s.length-1,i=c;s[i]===0;--i)s.pop();return i<0?new n(r.s*0):(r.e=ki(s,c),r.d=s,ar=!1,o&&(r=Or(r,a,l*4)),u&&(r=r.times(Math.abs(u)<54?Gr(2,u):Fn.pow(2,u))),ar=!0,r)}function cy(r,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:ya(r,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/Hi(5,t)),e=ya(r,2,e,e);for(var a,i=new r(5),o=new r(16),l=new r(20);t--;)a=e.times(e),e=e.times(i.plus(a.times(o.times(a).minus(l))));return e}function ya(r,e,t,n,a){var i,o,l,u,s=r.precision,c=Math.ceil(s/Xe);for(ar=!1,u=t.times(t),l=new r(n);;){if(o=Or(l.times(u),new r(e++*e++),s,1),l=a?n.plus(o):n.minus(o),n=Or(o.times(u),new r(e++*e++),s,1),o=l.plus(n),o.d[c]!==void 0){for(i=c;o.d[i]===l.d[i]&&i--;);if(i==-1)break}i=l,l=n,n=o,o=i}return ar=!0,o.d.length=c+1,o}function Hi(r,e){for(var t=r;--e;)t*=r;return t}function yl(r,e){var t,n=e.s<0,a=tn(r,r.precision,1),i=a.times(.5);if(e=e.abs(),e.lte(i))return vn=n?4:1,e;if(t=e.divToInt(a),t.isZero())vn=n?3:2;else{if(e=e.minus(t.times(a)),e.lte(i))return vn=dl(t)?n?2:3:n?4:1,e;vn=dl(t)?n?1:4:n?3:2}return e.minus(a).abs()}function ns(r,e,t,n){var a,i,o,l,u,s,c,f,m,v=r.constructor,p=t!==void 0;if(p?(Dt(t,1,Cn),n===void 0?n=v.rounding:Dt(n,0,8)):(t=v.precision,n=v.rounding),!r.isFinite())c=gl(r);else{for(c=rn(r),o=c.indexOf("."),p?(a=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):a=e,o>=0&&(c=c.replace(".",""),m=new v(1),m.e=c.length-o,m.d=Li(rn(m),10,a),m.e=m.d.length),f=Li(c,10,a),i=u=f.length;f[--u]==0;)f.pop();if(!f[0])c=p?"0p+0":"0";else{if(o<0?i--:(r=new v(r),r.d=f,r.e=i,r=Or(r,m,t,n,0,a),f=r.d,i=r.e,s=ul),o=f[t],l=a/2,s=s||f[t+1]!==void 0,s=n<4?(o!==void 0||s)&&(n===0||n===(r.s<0?3:2)):o>l||o===l&&(n===4||s||n===6&&f[t-1]&1||n===(r.s<0?8:7)),f.length=t,s)for(;++f[--t]>a-1;)f[t]=0,t||(++i,f.unshift(1));for(u=f.length;!f[u-1];--u);for(o=0,c="";o<u;o++)c+=Ko.charAt(f[o]);if(p){if(u>1)if(e==16||e==8){for(o=e==16?4:3,--u;u%o;u++)c+="0";for(f=Li(c,a,e),u=f.length;!f[u-1];--u);for(o=1,c="1.";o<u;o++)c+=Ko.charAt(f[o])}else c=c.charAt(0)+"."+c.slice(1);c=c+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)c="0"+c;c="0."+c}else if(++i>u)for(i-=u;i--;)c+="0";else i<u&&(c=c.slice(0,i)+"."+c.slice(i))}c=(e==16?"0x":e==2?"0b":e==8?"0o":"")+c}return r.s<0?"-"+c:c}function bl(r,e){if(r.length>e)return r.length=e,!0}function fy(r){return new this(r).abs()}function my(r){return new this(r).acos()}function vy(r){return new this(r).acosh()}function py(r,e){return new this(r).plus(e)}function dy(r){return new this(r).asin()}function hy(r){return new this(r).asinh()}function gy(r){return new this(r).atan()}function yy(r){return new this(r).atanh()}function by(r,e){r=new this(r),e=new this(e);var t,n=this.precision,a=this.rounding,i=n+4;return!r.s||!e.s?t=new this(NaN):!r.d&&!e.d?(t=tn(this,i,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?tn(this,n,a):new this(0),t.s=r.s):!r.d||e.isZero()?(t=tn(this,i,1).times(.5),t.s=r.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(Or(r,e,i,1)),e=tn(this,i,1),this.precision=n,this.rounding=a,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(Or(r,e,i,1)),t}function xy(r){return new this(r).cbrt()}function wy(r){return Ze(r=new this(r),r.e+1,2)}function Dy(r,e,t){return new this(r).clamp(e,t)}function Ny(r){if(!r||typeof r!="object")throw Error(Ui+"Object expected");var e,t,n,a=r.defaults===!0,i=["precision",1,Cn,"rounding",0,8,"toExpNeg",-ga,0,"toExpPos",0,ga,"maxE",0,ga,"minE",-ga,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],a&&(this[t]=es[t]),(n=r[t])!==void 0)if(ot(n)===n&&n>=i[e+1]&&n<=i[e+2])this[t]=n;else throw Error(Mn+t+": "+n);if(t="crypto",a&&(this[t]=es[t]),(n=r[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(cl);else this[t]=!1;else throw Error(Mn+t+": "+n);return this}function Ey(r){return new this(r).cos()}function Ay(r){return new this(r).cosh()}function xl(r){var e,t,n;function a(i){var o,l,u,s=this;if(!(s instanceof a))return new a(i);if(s.constructor=a,wl(i)){s.s=i.s,ar?!i.d||i.e>a.maxE?(s.e=NaN,s.d=null):i.e<a.minE?(s.e=0,s.d=[0]):(s.e=i.e,s.d=i.d.slice()):(s.e=i.e,s.d=i.d?i.d.slice():i.d);return}if(u=typeof i,u==="number"){if(i===0){s.s=1/i<0?-1:1,s.e=0,s.d=[0];return}if(i<0?(i=-i,s.s=-1):s.s=1,i===~~i&&i<1e7){for(o=0,l=i;l>=10;l/=10)o++;ar?o>a.maxE?(s.e=NaN,s.d=null):o<a.minE?(s.e=0,s.d=[0]):(s.e=o,s.d=[i]):(s.e=o,s.d=[i]);return}if(i*0!==0){i||(s.s=NaN),s.e=NaN,s.d=null;return}return Gi(s,i.toString())}if(u==="string")return(l=i.charCodeAt(0))===45?(i=i.slice(1),s.s=-1):(l===43&&(i=i.slice(1)),s.s=1),ml.test(i)?Gi(s,i):ly(s,i);if(u==="bigint")return i<0?(i=-i,s.s=-1):s.s=1,Gi(s,i.toString());throw Error(Mn+i)}if(a.prototype=Ne,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=Ny,a.clone=xl,a.isDecimal=wl,a.abs=fy,a.acos=my,a.acosh=vy,a.add=py,a.asin=dy,a.asinh=hy,a.atan=gy,a.atanh=yy,a.atan2=by,a.cbrt=xy,a.ceil=wy,a.clamp=Dy,a.cos=Ey,a.cosh=Ay,a.div=Sy,a.exp=Cy,a.floor=My,a.hypot=_y,a.ln=Ty,a.log=Fy,a.log10=By,a.log2=Oy,a.max=Ry,a.min=Iy,a.mod=Py,a.mul=$y,a.pow=qy,a.random=zy,a.round=Uy,a.sign=Ly,a.sin=ky,a.sinh=Vy,a.sqrt=Gy,a.sub=Hy,a.sum=Wy,a.tan=Yy,a.tanh=Zy,a.trunc=Jy,r===void 0&&(r={}),r&&r.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)r.hasOwnProperty(t=n[e++])||(r[t]=this[t]);return a.config(r),a}function Sy(r,e){return new this(r).div(e)}function Cy(r){return new this(r).exp()}function My(r){return Ze(r=new this(r),r.e+1,3)}function _y(){var r,e,t=new this(0);for(ar=!1,r=0;r<arguments.length;)if(e=new this(arguments[r++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return ar=!0,new this(1/0);t=e}return ar=!0,t.sqrt()}function wl(r){return r instanceof Fn||r&&r.toStringTag===fl||!1}function Ty(r){return new this(r).ln()}function Fy(r,e){return new this(r).log(e)}function Oy(r){return new this(r).log(2)}function By(r){return new this(r).log(10)}function Ry(){return hl(this,arguments,-1)}function Iy(){return hl(this,arguments,1)}function Py(r,e){return new this(r).mod(e)}function $y(r,e){return new this(r).mul(e)}function qy(r,e){return new this(r).pow(e)}function zy(r){var e,t,n,a,i=0,o=new this(1),l=[];if(r===void 0?r=this.precision:Dt(r,1,Cn),n=Math.ceil(r/Xe),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));i<n;)a=e[i],a>=429e7?e[i]=crypto.getRandomValues(new Uint32Array(1))[0]:l[i++]=a%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);i<n;)a=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+((e[i+3]&127)<<24),a>=214e7?crypto.randomBytes(4).copy(e,i):(l.push(a%1e7),i+=4);i=n/4}else throw Error(cl);else for(;i<n;)l[i++]=Math.random()*1e7|0;for(n=l[--i],r%=Xe,n&&r&&(a=Gr(10,Xe-r),l[i]=(n/a|0)*a);l[i]===0;i--)l.pop();if(i<0)t=0,l=[0];else{for(t=-1;l[0]===0;t-=Xe)l.shift();for(n=1,a=l[0];a>=10;a/=10)n++;n<Xe&&(t-=Xe-n)}return o.e=t,o.d=l,o}function Uy(r){return Ze(r=new this(r),r.e+1,this.rounding)}function Ly(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function ky(r){return new this(r).sin()}function Vy(r){return new this(r).sinh()}function Gy(r){return new this(r).sqrt()}function Hy(r,e){return new this(r).sub(e)}function Wy(){var r=0,e=arguments,t=new this(e[r]);for(ar=!1;t.s&&++r<e.length;)t=t.plus(e[r]);return ar=!0,Ze(t,this.precision,this.rounding)}function Yy(r){return new this(r).tan()}function Zy(r){return new this(r).tanh()}function Jy(r){return Ze(r=new this(r),r.e+1,1)}Ne[Symbol.for("nodejs.util.inspect.custom")]=Ne.toString,Ne[Symbol.toStringTag]="Decimal";var Fn=Ne.constructor=xl(es);qi=new Fn(qi),zi=new Fn(zi);var jy="BigNumber",Xy=["?on","config"],Qy=L(jy,Xy,r=>{var{on:e,config:t}=r,n=Fn.clone({precision:t.precision,modulo:Fn.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.toString()}},n.fromJSON=function(a){return new n(a.value)},e&&e("config",function(a,i){a.precision!==i.precision&&n.config({precision:a.precision})}),n},{isClass:!0});const st=Math.cosh||function(r){return Math.abs(r)<1e-9?1-r:(Math.exp(r)+Math.exp(-r))*.5},Pt=Math.sinh||function(r){return Math.abs(r)<1e-9?r:(Math.exp(r)-Math.exp(-r))*.5},Ky=r=>{const e=Math.sin(.5*r);return-2*e*e},as=function(r,e){return r=Math.abs(r),e=Math.abs(e),r<e&&([r,e]=[e,r]),r<1e8?Math.sqrt(r*r+e*e):(e/=r,r*Math.sqrt(1+e*e))},ba=function(){throw SyntaxError("Invalid Param")};function is(r,e){const t=Math.abs(r),n=Math.abs(e);return r===0?Math.log(n):e===0?Math.log(t):t<3e3&&n<3e3?Math.log(r*r+e*e)*.5:(r=r*.5,e=e*.5,.5*Math.log(r*r+e*e)+Math.LN2)}const e1={re:0,im:0},Jn=function(r,e){const t=e1;if(r==null)t.re=t.im=0;else if(e!==void 0)t.re=r,t.im=e;else switch(typeof r){case"object":if("im"in r&&"re"in r)t.re=r.re,t.im=r.im;else if("abs"in r&&"arg"in r){if(!isFinite(r.abs)&&isFinite(r.arg))return he.INFINITY;t.re=r.abs*Math.cos(r.arg),t.im=r.abs*Math.sin(r.arg)}else if("r"in r&&"phi"in r){if(!isFinite(r.r)&&isFinite(r.phi))return he.INFINITY;t.re=r.r*Math.cos(r.phi),t.im=r.r*Math.sin(r.phi)}else r.length===2?(t.re=r[0],t.im=r[1]):ba();break;case"string":t.im=t.re=0;const n=r.replace(/_/g,"").match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g);let a=1,i=0;n===null&&ba();for(let o=0;o<n.length;o++){const l=n[o];l===" "||l===" "||l===`
|
|
16
|
-
`||(l==="+"?a++:l==="-"?i++:l==="i"||l==="I"?(a+i===0&&ba(),n[o+1]!==" "&&!isNaN(n[o+1])?(t.im+=parseFloat((i%2?"-":"")+n[o+1]),o++):t.im+=parseFloat((i%2?"-":"")+"1"),a=i=0):((a+i===0||isNaN(l))&&ba(),n[o+1]==="i"||n[o+1]==="I"?(t.im+=parseFloat((i%2?"-":"")+l),o++):t.re+=parseFloat((i%2?"-":"")+l),a=i=0))}a+i>0&&ba();break;case"number":t.im=0,t.re=r;break;default:ba()}return isNaN(t.re)||isNaN(t.im),t};function he(r,e){if(!(this instanceof he))return new he(r,e);const t=Jn(r,e);this.re=t.re,this.im=t.im}he.prototype={re:0,im:0,sign:function(){const r=as(this.re,this.im);return new he(this.re/r,this.im/r)},add:function(r,e){const t=Jn(r,e),n=this.isInfinite(),a=!(isFinite(t.re)&&isFinite(t.im));return n||a?n&&a?he.NAN:he.INFINITY:new he(this.re+t.re,this.im+t.im)},sub:function(r,e){const t=Jn(r,e),n=this.isInfinite(),a=!(isFinite(t.re)&&isFinite(t.im));return n||a?n&&a?he.NAN:he.INFINITY:new he(this.re-t.re,this.im-t.im)},mul:function(r,e){const t=Jn(r,e),n=this.isInfinite(),a=!(isFinite(t.re)&&isFinite(t.im)),i=this.re===0&&this.im===0,o=t.re===0&&t.im===0;return n&&o||a&&i?he.NAN:n||a?he.INFINITY:t.im===0&&this.im===0?new he(this.re*t.re,0):new he(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)},div:function(r,e){const t=Jn(r,e),n=this.isInfinite(),a=!(isFinite(t.re)&&isFinite(t.im)),i=this.re===0&&this.im===0,o=t.re===0&&t.im===0;if(i&&o||n&&a)return he.NAN;if(o||n)return he.INFINITY;if(i||a)return he.ZERO;if(t.im===0)return new he(this.re/t.re,this.im/t.re);if(Math.abs(t.re)<Math.abs(t.im)){const l=t.re/t.im,u=t.re*l+t.im;return new he((this.re*l+this.im)/u,(this.im*l-this.re)/u)}else{const l=t.im/t.re,u=t.im*l+t.re;return new he((this.re+this.im*l)/u,(this.im-this.re*l)/u)}},pow:function(r,e){const t=Jn(r,e),n=this.re===0&&this.im===0;if(t.re===0&&t.im===0)return he.ONE;if(t.im===0){if(this.im===0&&this.re>0)return new he(Math.pow(this.re,t.re),0);if(this.re===0)switch((t.re%4+4)%4){case 0:return new he(Math.pow(this.im,t.re),0);case 1:return new he(0,Math.pow(this.im,t.re));case 2:return new he(-Math.pow(this.im,t.re),0);case 3:return new he(0,-Math.pow(this.im,t.re))}}if(n&&t.re>0)return he.ZERO;const i=Math.atan2(this.im,this.re),o=is(this.re,this.im);let l=Math.exp(t.re*o-t.im*i),u=t.im*o+t.re*i;return new he(l*Math.cos(u),l*Math.sin(u))},sqrt:function(){const r=this.re,e=this.im;if(e===0)return r>=0?new he(Math.sqrt(r),0):new he(0,Math.sqrt(-r));const t=as(r,e);let n=Math.sqrt(.5*(t+Math.abs(r))),a=Math.abs(e)/(2*n);return r>=0?new he(n,e<0?-a:a):new he(a,e<0?-n:n)},exp:function(){const r=Math.exp(this.re);return this.im===0?new he(r,0):new he(r*Math.cos(this.im),r*Math.sin(this.im))},expm1:function(){const r=this.re,e=this.im;return new he(Math.expm1(r)*Math.cos(e)+Ky(e),Math.exp(r)*Math.sin(e))},log:function(){const r=this.re,e=this.im;return e===0&&r>0?new he(Math.log(r),0):new he(is(r,e),Math.atan2(e,r))},abs:function(){return as(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){const r=this.re,e=this.im;return new he(Math.sin(r)*st(e),Math.cos(r)*Pt(e))},cos:function(){const r=this.re,e=this.im;return new he(Math.cos(r)*st(e),-Math.sin(r)*Pt(e))},tan:function(){const r=2*this.re,e=2*this.im,t=Math.cos(r)+st(e);return new he(Math.sin(r)/t,Pt(e)/t)},cot:function(){const r=2*this.re,e=2*this.im,t=Math.cos(r)-st(e);return new he(-Math.sin(r)/t,Pt(e)/t)},sec:function(){const r=this.re,e=this.im,t=.5*st(2*e)+.5*Math.cos(2*r);return new he(Math.cos(r)*st(e)/t,Math.sin(r)*Pt(e)/t)},csc:function(){const r=this.re,e=this.im,t=.5*st(2*e)-.5*Math.cos(2*r);return new he(Math.sin(r)*st(e)/t,-Math.cos(r)*Pt(e)/t)},asin:function(){const r=this.re,e=this.im,t=new he(e*e-r*r+1,-2*r*e).sqrt(),n=new he(t.re-e,t.im+r).log();return new he(n.im,-n.re)},acos:function(){const r=this.re,e=this.im,t=new he(e*e-r*r+1,-2*r*e).sqrt(),n=new he(t.re-e,t.im+r).log();return new he(Math.PI/2-n.im,n.re)},atan:function(){const r=this.re,e=this.im;if(r===0){if(e===1)return new he(0,1/0);if(e===-1)return new he(0,-1/0)}const t=r*r+(1-e)*(1-e),n=new he((1-e*e-r*r)/t,-2*r/t).log();return new he(-.5*n.im,.5*n.re)},acot:function(){const r=this.re,e=this.im;if(e===0)return new he(Math.atan2(1,r),0);const t=r*r+e*e;return t!==0?new he(r/t,-e/t).atan():new he(r!==0?r/0:0,e!==0?-e/0:0).atan()},asec:function(){const r=this.re,e=this.im;if(r===0&&e===0)return new he(0,1/0);const t=r*r+e*e;return t!==0?new he(r/t,-e/t).acos():new he(r!==0?r/0:0,e!==0?-e/0:0).acos()},acsc:function(){const r=this.re,e=this.im;if(r===0&&e===0)return new he(Math.PI/2,1/0);const t=r*r+e*e;return t!==0?new he(r/t,-e/t).asin():new he(r!==0?r/0:0,e!==0?-e/0:0).asin()},sinh:function(){const r=this.re,e=this.im;return new he(Pt(r)*Math.cos(e),st(r)*Math.sin(e))},cosh:function(){const r=this.re,e=this.im;return new he(st(r)*Math.cos(e),Pt(r)*Math.sin(e))},tanh:function(){const r=2*this.re,e=2*this.im,t=st(r)+Math.cos(e);return new he(Pt(r)/t,Math.sin(e)/t)},coth:function(){const r=2*this.re,e=2*this.im,t=st(r)-Math.cos(e);return new he(Pt(r)/t,-Math.sin(e)/t)},csch:function(){const r=this.re,e=this.im,t=Math.cos(2*e)-st(2*r);return new he(-2*Pt(r)*Math.cos(e)/t,2*st(r)*Math.sin(e)/t)},sech:function(){const r=this.re,e=this.im,t=Math.cos(2*e)+st(2*r);return new he(2*st(r)*Math.cos(e)/t,-2*Pt(r)*Math.sin(e)/t)},asinh:function(){const r=this.re,e=this.im;if(e===0){if(r===0)return new he(0,0);const i=Math.abs(r),o=Math.log(i+Math.sqrt(i*i+1));return new he(r<0?-o:o,0)}const t=r*r-e*e+1,n=2*r*e,a=new he(t,n).sqrt();return new he(r+a.re,e+a.im).log()},acosh:function(){const r=this.re,e=this.im;if(e===0){if(r>1)return new he(Math.log(r+Math.sqrt(r-1)*Math.sqrt(r+1)),0);if(r<-1){const a=Math.sqrt(r*r-1);return new he(Math.log(-r+a),Math.PI)}return new he(0,Math.acos(r))}const t=new he(r-1,e).sqrt(),n=new he(r+1,e).sqrt();return new he(r+t.re*n.re-t.im*n.im,e+t.re*n.im+t.im*n.re).log()},atanh:function(){const r=this.re,e=this.im;if(e===0){if(r===0)return new he(0,0);if(r===1)return new he(1/0,0);if(r===-1)return new he(-1/0,0);if(-1<r&&r<1)return new he(.5*Math.log((1+r)/(1-r)),0);if(r>1){const u=(r+1)/(r-1);return new he(.5*Math.log(u),-Math.PI/2)}const l=(1+r)/(1-r);return new he(.5*Math.log(-l),Math.PI/2)}const t=1-r,n=1+r,a=t*t+e*e;if(a===0)return new he(r!==-1?r/0:0,e!==0?e/0:0);const i=(n*t-e*e)/a,o=(e*t+n*e)/a;return new he(is(i,o)/2,Math.atan2(o,i)/2)},acoth:function(){const r=this.re,e=this.im;if(r===0&&e===0)return new he(0,Math.PI/2);const t=r*r+e*e;return t!==0?new he(r/t,-e/t).atanh():new he(r!==0?r/0:0,e!==0?-e/0:0).atanh()},acsch:function(){const r=this.re,e=this.im;if(e===0){if(r===0)return new he(1/0,0);const n=1/r;return new he(Math.log(n+Math.sqrt(n*n+1)),0)}const t=r*r+e*e;return t!==0?new he(r/t,-e/t).asinh():new he(r!==0?r/0:0,e!==0?-e/0:0).asinh()},asech:function(){const r=this.re,e=this.im;if(this.isZero())return he.INFINITY;const t=r*r+e*e;return t!==0?new he(r/t,-e/t).acosh():new he(r!==0?r/0:0,e!==0?-e/0:0).acosh()},inverse:function(){if(this.isZero())return he.INFINITY;if(this.isInfinite())return he.ZERO;const r=this.re,e=this.im,t=r*r+e*e;return new he(r/t,-e/t)},conjugate:function(){return new he(this.re,-this.im)},neg:function(){return new he(-this.re,-this.im)},ceil:function(r){return r=Math.pow(10,r||0),new he(Math.ceil(this.re*r)/r,Math.ceil(this.im*r)/r)},floor:function(r){return r=Math.pow(10,r||0),new he(Math.floor(this.re*r)/r,Math.floor(this.im*r)/r)},round:function(r){return r=Math.pow(10,r||0),new he(Math.round(this.re*r)/r,Math.round(this.im*r)/r)},equals:function(r,e){const t=Jn(r,e);return Math.abs(t.re-this.re)<=he.EPSILON&&Math.abs(t.im-this.im)<=he.EPSILON},clone:function(){return new he(this.re,this.im)},toString:function(){let r=this.re,e=this.im,t="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(r)<he.EPSILON&&(r=0),Math.abs(e)<he.EPSILON&&(e=0),e===0?t+r:(r!==0?(t+=r,t+=" ",e<0?(e=-e,t+="-"):t+="+",t+=" "):e<0&&(e=-e,t+="-"),e!==1&&(t+=e),t+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return this.im===0?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return this.im===0&&this.re===0},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!this.isFinite()}},he.ZERO=new he(0,0),he.ONE=new he(1,0),he.I=new he(0,1),he.PI=new he(Math.PI,0),he.E=new he(Math.E,0),he.INFINITY=new he(1/0,1/0),he.NAN=new he(NaN,NaN),he.EPSILON=1e-15;var r1="Complex",t1=[],n1=L(r1,t1,()=>(Object.defineProperty(he,"name",{value:"Complex"}),he.prototype.constructor=he,he.prototype.type="Complex",he.prototype.isComplex=!0,he.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},he.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},he.prototype.format=function(r){var e="",t=this.im,n=this.re,a=Zn(this.re,r),i=Zn(this.im,r),o=Ye(r)?r:r?r.precision:null;if(o!==null){var l=Math.pow(10,-o);Math.abs(n/t)<l&&(n=0),Math.abs(t/n)<l&&(t=0)}return t===0?e=a:n===0?t===1?e="i":t===-1?e="-i":e=i+"i":t<0?t===-1?e=a+" - i":e=a+" - "+i.substring(1)+"i":t===1?e=a+" + i":e=a+" + "+i+"i",e},he.fromPolar=function(r){switch(arguments.length){case 1:{var e=arguments[0];if(typeof e=="object")return he(e);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var t=arguments[0],n=arguments[1];if(Ye(t)){if(St(n)&&n.hasBase("ANGLE")&&(n=n.toNumber("rad")),Ye(n))return new he({r:t,phi:n});throw new TypeError("Phi is not a number nor an angle unit.")}else throw new TypeError("Radius r is not a number.")}default:throw new SyntaxError("Wrong number of arguments in function fromPolar")}},he.prototype.valueOf=he.prototype.toString,he.fromJSON=function(r){return new he(r)},he.compare=function(r,e){return r.re>e.re?1:r.re<e.re?-1:r.im>e.im?1:r.im<e.im?-1:0},he),{isClass:!0});typeof BigInt>"u"&&(BigInt=function(r){if(isNaN(r))throw new Error("");return r});const Ge=BigInt(0),vr=BigInt(1),Xr=BigInt(2),ni=BigInt(3),xa=BigInt(5),Nt=BigInt(10);BigInt(Number.MAX_SAFE_INTEGER);const a1=2e3,Be={s:vr,n:Ge,d:vr};function pn(r,e){try{r=BigInt(r)}catch{throw On()}return r*e}function Wt(r){return typeof r=="bigint"?r:Math.floor(r)}function Rr(r,e){if(e===Ge)throw os();const t=Object.create($t.prototype);t.s=r<Ge?-vr:vr,r=r<Ge?-r:r;const n=jn(r,e);return t.n=r/n,t.d=e/n,t}const i1=[Xr*Xr,Xr,Xr*Xr,Xr,Xr*Xr,Xr*ni,Xr,Xr*ni];function wa(r){const e=Object.create(null);if(r<=vr)return e[r]=vr,e;const t=n=>{e[n]=(e[n]||Ge)+vr};for(;r%Xr===Ge;)t(Xr),r/=Xr;for(;r%ni===Ge;)t(ni),r/=ni;for(;r%xa===Ge;)t(xa),r/=xa;for(let n=0,a=Xr+xa;a*a<=r;){for(;r%a===Ge;)t(a),r/=a;a+=i1[n],n=n+1&7}return r>vr&&t(r),e}const Qr=function(r,e){let t=Ge,n=vr,a=vr;if(r!=null)if(e!==void 0){if(typeof r=="bigint")t=r;else{if(isNaN(r))throw On();if(r%1!==0)throw Dl();t=BigInt(r)}if(typeof e=="bigint")n=e;else{if(isNaN(e))throw On();if(e%1!==0)throw Dl();n=BigInt(e)}a=t*n}else if(typeof r=="object"){if("d"in r&&"n"in r)t=BigInt(r.n),n=BigInt(r.d),"s"in r&&(t*=BigInt(r.s));else if(0 in r)t=BigInt(r[0]),1 in r&&(n=BigInt(r[1]));else if(typeof r=="bigint")t=r;else throw On();a=t*n}else if(typeof r=="number"){if(isNaN(r))throw On();if(r<0&&(a=-vr,r=-r),r%1===0)t=BigInt(r);else{let i=1,o=0,l=1,u=1,s=1,c=1e7;for(r>=1&&(i=10**Math.floor(1+Math.log10(r)),r/=i);l<=c&&s<=c;){let f=(o+u)/(l+s);if(r===f){l+s<=c?(t=o+u,n=l+s):s>l?(t=u,n=s):(t=o,n=l);break}else r>f?(o+=u,l+=s):(u+=o,s+=l),l>c?(t=u,n=s):(t=o,n=l)}t=BigInt(t)*BigInt(i),n=BigInt(n)}}else if(typeof r=="string"){let i=0,o=Ge,l=Ge,u=Ge,s=vr,c=vr,f=r.replace(/_/g,"").match(/\d+|./g);if(f===null)throw On();if(f[i]==="-"?(a=-vr,i++):f[i]==="+"&&i++,f.length===i+1?l=pn(f[i++],a):f[i+1]==="."||f[i]==="."?(f[i]!=="."&&(o=pn(f[i++],a)),i++,(i+1===f.length||f[i+1]==="("&&f[i+3]===")"||f[i+1]==="'"&&f[i+3]==="'")&&(l=pn(f[i],a),s=Nt**BigInt(f[i].length),i++),(f[i]==="("&&f[i+2]===")"||f[i]==="'"&&f[i+2]==="'")&&(u=pn(f[i+1],a),c=Nt**BigInt(f[i+1].length)-vr,i+=3)):f[i+1]==="/"||f[i+1]===":"?(l=pn(f[i],a),s=pn(f[i+2],vr),i+=3):f[i+3]==="/"&&f[i+1]===" "&&(o=pn(f[i],a),l=pn(f[i+2],a),s=pn(f[i+4],vr),i+=5),f.length<=i)n=s*c,a=t=u+n*o+c*l;else throw On()}else if(typeof r=="bigint")t=r,a=r,n=vr;else throw On();if(n===Ge)throw os();Be.s=a<Ge?-vr:vr,Be.n=t<Ge?-t:t,Be.d=n<Ge?-n:n};function o1(r,e,t){let n=vr;for(;e>Ge;r=r*r%t,e>>=vr)e&vr&&(n=n*r%t);return n}function s1(r,e){for(;e%Xr===Ge;e/=Xr);for(;e%xa===Ge;e/=xa);if(e===vr)return Ge;let t=Nt%e,n=1;for(;t!==vr;n++)if(t=t*Nt%e,n>a1)return Ge;return BigInt(n)}function u1(r,e,t){let n=vr,a=o1(Nt,t,e);for(let i=0;i<300;i++){if(n===a)return BigInt(i);n=n*Nt%e,a=a*Nt%e}return 0}function jn(r,e){if(!r)return e;if(!e)return r;for(;;){if(r%=e,!r)return e;if(e%=r,!e)return r}}function $t(r,e){if(Qr(r,e),this instanceof $t)r=jn(Be.d,Be.n),this.s=Be.s,this.n=Be.n/r,this.d=Be.d/r;else return Rr(Be.s*Be.n,Be.d)}const os=function(){return new Error("Division by Zero")},On=function(){return new Error("Invalid argument")},Dl=function(){return new Error("Parameters must be integer")};$t.prototype={s:vr,n:Ge,d:vr,abs:function(){return Rr(this.n,this.d)},neg:function(){return Rr(-this.s*this.n,this.d)},add:function(r,e){return Qr(r,e),Rr(this.s*this.n*Be.d+Be.s*this.d*Be.n,this.d*Be.d)},sub:function(r,e){return Qr(r,e),Rr(this.s*this.n*Be.d-Be.s*this.d*Be.n,this.d*Be.d)},mul:function(r,e){return Qr(r,e),Rr(this.s*Be.s*this.n*Be.n,this.d*Be.d)},div:function(r,e){return Qr(r,e),Rr(this.s*Be.s*this.n*Be.d,this.d*Be.n)},clone:function(){return Rr(this.s*this.n,this.d)},mod:function(r,e){if(r===void 0)return Rr(this.s*this.n%this.d,vr);if(Qr(r,e),Ge===Be.n*this.d)throw os();return Rr(this.s*(Be.d*this.n)%(Be.n*this.d),Be.d*this.d)},gcd:function(r,e){return Qr(r,e),Rr(jn(Be.n,this.n)*jn(Be.d,this.d),Be.d*this.d)},lcm:function(r,e){return Qr(r,e),Be.n===Ge&&this.n===Ge?Rr(Ge,vr):Rr(Be.n*this.n,jn(Be.n,this.n)*jn(Be.d,this.d))},inverse:function(){return Rr(this.s*this.d,this.n)},pow:function(r,e){if(Qr(r,e),Be.d===vr)return Be.s<Ge?Rr((this.s*this.d)**Be.n,this.n**Be.n):Rr((this.s*this.n)**Be.n,this.d**Be.n);if(this.s<Ge)return null;let t=wa(this.n),n=wa(this.d),a=vr,i=vr;for(let o in t)if(o!=="1"){if(o==="0"){a=Ge;break}if(t[o]*=Be.n,t[o]%Be.d===Ge)t[o]/=Be.d;else return null;a*=BigInt(o)**t[o]}for(let o in n)if(o!=="1"){if(n[o]*=Be.n,n[o]%Be.d===Ge)n[o]/=Be.d;else return null;i*=BigInt(o)**n[o]}return Be.s<Ge?Rr(i,a):Rr(a,i)},log:function(r,e){if(Qr(r,e),this.s<=Ge||Be.s<=Ge)return null;const t=Object.create(null),n=wa(Be.n),a=wa(Be.d),i=wa(this.n),o=wa(this.d);for(const s in a)n[s]=(n[s]||Ge)-a[s];for(const s in o)i[s]=(i[s]||Ge)-o[s];for(const s in n)s!=="1"&&(t[s]=!0);for(const s in i)s!=="1"&&(t[s]=!0);let l=null,u=null;for(const s in t){const c=n[s]||Ge,f=i[s]||Ge;if(c===Ge){if(f!==Ge)return null;continue}let m=f,v=c;const p=jn(m,v);if(m/=p,v/=p,l===null&&u===null)l=m,u=v;else if(m*u!==l*v)return null}return l!==null&&u!==null?Rr(l,u):null},equals:function(r,e){return Qr(r,e),this.s*this.n*Be.d===Be.s*Be.n*this.d},lt:function(r,e){return Qr(r,e),this.s*this.n*Be.d<Be.s*Be.n*this.d},lte:function(r,e){return Qr(r,e),this.s*this.n*Be.d<=Be.s*Be.n*this.d},gt:function(r,e){return Qr(r,e),this.s*this.n*Be.d>Be.s*Be.n*this.d},gte:function(r,e){return Qr(r,e),this.s*this.n*Be.d>=Be.s*Be.n*this.d},compare:function(r,e){Qr(r,e);let t=this.s*this.n*Be.d-Be.s*Be.n*this.d;return(Ge<t)-(t<Ge)},ceil:function(r){return r=Nt**BigInt(r||0),Rr(Wt(this.s*r*this.n/this.d)+(r*this.n%this.d>Ge&&this.s>=Ge?vr:Ge),r)},floor:function(r){return r=Nt**BigInt(r||0),Rr(Wt(this.s*r*this.n/this.d)-(r*this.n%this.d>Ge&&this.s<Ge?vr:Ge),r)},round:function(r){return r=Nt**BigInt(r||0),Rr(Wt(this.s*r*this.n/this.d)+this.s*((this.s>=Ge?vr:Ge)+Xr*(r*this.n%this.d)>this.d?vr:Ge),r)},roundTo:function(r,e){Qr(r,e);const t=this.n*Be.d,n=this.d*Be.n,a=t%n;let i=Wt(t/n);return a+a>=n&&i++,Rr(this.s*i*Be.n,Be.d)},divisible:function(r,e){return Qr(r,e),Be.n===Ge?!1:this.n*Be.d%(Be.n*this.d)===Ge},valueOf:function(){return Number(this.s*this.n)/Number(this.d)},toString:function(r=15){let e=this.n,t=this.d,n=s1(e,t),a=u1(e,t,n),i=this.s<Ge?"-":"";if(i+=Wt(e/t),e%=t,e*=Nt,e&&(i+="."),n){for(let o=a;o--;)i+=Wt(e/t),e%=t,e*=Nt;i+="(";for(let o=n;o--;)i+=Wt(e/t),e%=t,e*=Nt;i+=")"}else for(let o=r;e&&o--;)i+=Wt(e/t),e%=t,e*=Nt;return i},toFraction:function(r=!1){let e=this.n,t=this.d,n=this.s<Ge?"-":"";if(t===vr)n+=e;else{const a=Wt(e/t);r&&a>Ge&&(n+=a,n+=" ",e%=t),n+=e,n+="/",n+=t}return n},toLatex:function(r=!1){let e=this.n,t=this.d,n=this.s<Ge?"-":"";if(t===vr)n+=e;else{const a=Wt(e/t);r&&a>Ge&&(n+=a,e%=t),n+="\\frac{",n+=e,n+="}{",n+=t,n+="}"}return n},toContinued:function(){let r=this.n,e=this.d;const t=[];for(;e;){t.push(Wt(r/e));const n=r%e;r=e,e=n}return t},simplify:function(r=.001){const e=BigInt(Math.ceil(1/r)),t=this.abs(),n=t.toContinued();for(let a=1;a<n.length;a++){let i=Rr(n[a-1],vr);for(let l=a-2;l>=0;l--)i=i.inverse().add(n[l]);let o=i.sub(t);if(o.n*e<o.d)return i.mul(this.s)}return this}};var l1="Fraction",c1=[],f1=L(l1,c1,()=>(Object.defineProperty($t,"name",{value:"Fraction"}),$t.prototype.constructor=$t,$t.prototype.type="Fraction",$t.prototype.isFraction=!0,$t.prototype.toJSON=function(){return{mathjs:"Fraction",n:String(this.s*this.n),d:String(this.d)}},$t.fromJSON=function(r){return new $t(r)},$t),{isClass:!0}),m1="Range",v1=[],p1=L(m1,v1,()=>{function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");var a=e!=null,i=t!=null,o=n!=null;if(a){if(or(e))e=e.toNumber();else if(typeof e!="number"&&!Qa(e))throw new TypeError("Parameter start must be a number or bigint")}if(i){if(or(t))t=t.toNumber();else if(typeof t!="number"&&!Qa(t))throw new TypeError("Parameter end must be a number or bigint")}if(o){if(or(n))n=n.toNumber();else if(typeof n!="number"&&!Qa(n))throw new TypeError("Parameter step must be a number or bigint")}if(this.start=a?parseFloat(e):0,this.end=i?parseFloat(t):0,this.step=o?parseFloat(n):1,o&&jr(this.step,0))throw new Error("Step must not be zero")}return r.prototype.type="Range",r.prototype.isRange=!0,r.parse=function(e){if(typeof e!="string")return null;var t=e.split(":"),n=t.map(function(i){return parseFloat(i)}),a=n.some(function(i){return isNaN(i)});if(a)return null;switch(n.length){case 2:return new r(n[0],n[1]);case 3:return new r(n[0],n[2],n[1]);default:return null}},r.prototype.clone=function(){return new r(this.start,this.end,this.step)},r.prototype.size=function(){var e=0,t=this.start,n=this.step,a=this.end,i=a-t;return Sn(n)===Sn(i)?e=Math.ceil(i/n):i===0&&(e=0),isNaN(e)&&(e=0),[e]},r.prototype.min=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start:this.start+(e-1)*this.step},r.prototype.max=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start+(e-1)*this.step:this.start},r.prototype.forEach=function(e){var t=this.start,n=this.step,a=this.end,i=0;if(n>0)for(;t<a;)e(t,[i],this),t+=n,i++;else if(n<0)for(;t>a;)e(t,[i],this),t+=n,i++},r.prototype.map=function(e){var t=[];return this.forEach(function(n,a,i){t[a[0]]=e(n,a,i)}),t},r.prototype.toArray=function(){var e=[];return this.forEach(function(t,n){e[n[0]]=t}),e},r.prototype.valueOf=function(){return this.toArray()},r.prototype.format=function(e){var t=Zn(this.start,e);return this.step!==1&&(t+=":"+Zn(this.step,e)),t+=":"+Zn(this.end,e),t},r.prototype.toString=function(){return this.format()},r.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},r.fromJSON=function(e){return new r(e.start,e.end,e.step)},r},{isClass:!0}),d1="Matrix",h1=[],g1=L(d1,h1,()=>{function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator")}return r.prototype.type="Matrix",r.prototype.isMatrix=!0,r.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},r.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},r.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},r.prototype.subset=function(e,t,n){throw new Error("Cannot invoke subset on a Matrix interface")},r.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},r.prototype.set=function(e,t,n){throw new Error("Cannot invoke set on a Matrix interface")},r.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},r.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},r.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},r.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},r.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},r.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},r.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},r.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},r.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},r.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},r.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},r},{isClass:!0});function ss(r,e,t){var n=r.constructor,a=new n(2),i="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!Ue(t))throw new Error("size must be an integer");if(r.greaterThan(a.pow(t-1).sub(1))||r.lessThan(a.pow(t-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!r.isInteger())throw new Error("Value must be an integer");r.lessThan(0)&&(r=r.add(a.pow(t))),i="i".concat(t)}switch(e){case 2:return"".concat(r.toBinary()).concat(i);case 8:return"".concat(r.toOctal()).concat(i);case 16:return"".concat(r.toHexadecimal()).concat(i);default:throw new Error("Base ".concat(e," not supported "))}}function y1(r,e){if(typeof e=="function")return e(r);if(!r.isFinite())return r.isNaN()?"NaN":r.gt(0)?"Infinity":"-Infinity";var{notation:t,precision:n,wordSize:a}=tl(e);switch(t){case"fixed":return x1(r,n);case"exponential":return Nl(r,n);case"engineering":return b1(r,n);case"bin":return ss(r,2,a);case"oct":return ss(r,8,a);case"hex":return ss(r,16,a);case"auto":{var i=El(e==null?void 0:e.lowerExp,-3),o=El(e==null?void 0:e.upperExp,5);if(r.isZero())return"0";var l,u=r.toSignificantDigits(n),s=u.e;return s>=i&&s<o?l=u.toFixed():l=Nl(r,n),l.replace(/((\.\d*?)(0+))($|e)/,function(){var c=arguments[2],f=arguments[4];return c!=="."?c+f:f})}default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function b1(r,e){var t=r.e,n=t%3===0?t:t<0?t-3-t%3:t-t%3,a=r.mul(Math.pow(10,-n)),i=a.toPrecision(e);if(i.includes("e")){var o=r.constructor;i=new o(i).toFixed()}return i+"e"+(t>=0?"+":"")+n.toString()}function Nl(r,e){return e!==void 0?r.toExponential(e-1):r.toExponential()}function x1(r,e){return r.toFixed(e)}function El(r,e){return Ye(r)?r:or(r)?r.toNumber():e}function w1(r,e){var t=r.length-e.length,n=r.length;return r.substring(t,n)===e}function lr(r,e){var t=D1(r,e);return e&&typeof e=="object"&&"truncate"in e&&t.length>e.truncate?t.substring(0,e.truncate-3)+"...":t}function D1(r,e){if(typeof r=="number")return Zn(r,e);if(or(r))return y1(r,e);if(N1(r))return!e||e.fraction!=="decimal"?"".concat(r.s*r.n,"/").concat(r.d):r.toString();if(Array.isArray(r))return Sl(r,e);if($r(r))return Da(r);if(typeof r=="function")return r.syntax?String(r.syntax):"function";if(r&&typeof r=="object"){if(typeof r.format=="function")return r.format(e);if(r&&r.toString(e)!=={}.toString())return r.toString(e);var t=Object.keys(r).map(n=>Da(n)+": "+lr(r[n],e));return"{"+t.join(", ")+"}"}return String(r)}function Da(r){for(var e=String(r),t="",n=0;n<e.length;){var a=e.charAt(n);t+=a in Al?Al[a]:a,n++}return'"'+t+'"'}var Al={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function qt(r){var e=String(r);return e=e.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"),e}function Sl(r,e){if(Array.isArray(r)){for(var t="[",n=r.length,a=0;a<n;a++)a!==0&&(t+=", "),t+=Sl(r[a],e);return t+="]",t}else return lr(r,e)}function N1(r){return r&&typeof r=="object"&&typeof r.s=="bigint"&&typeof r.n=="bigint"&&typeof r.d=="bigint"||!1}function us(r,e){if(!$r(r))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Sr(r)+", index: 0)");if(!$r(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Sr(e)+", index: 1)");return r===e?0:r>e?1:-1}function ur(r,e,t){if(!(this instanceof ur))throw new SyntaxError("Constructor must be called with the new operator");this.actual=r,this.expected=e,this.relation=t,this.message="Dimension mismatch ("+(Array.isArray(r)?"["+r.join(", ")+"]":r)+" "+(this.relation||"!=")+" "+(Array.isArray(e)?"["+e.join(", ")+"]":e)+")",this.stack=new Error().stack}ur.prototype=new RangeError,ur.prototype.constructor=RangeError,ur.prototype.name="DimensionError",ur.prototype.isDimensionError=!0;function Yt(r,e,t){if(!(this instanceof Yt))throw new SyntaxError("Constructor must be called with the new operator");this.index=r,arguments.length<3?(this.min=0,this.max=e):(this.min=e,this.max=t),this.min!==void 0&&this.index<this.min?this.message="Index out of range ("+this.index+" < "+this.min+")":this.max!==void 0&&this.index>=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=new Error().stack}Yt.prototype=new RangeError,Yt.prototype.constructor=RangeError,Yt.prototype.name="IndexError",Yt.prototype.isIndexError=!0;function rr(r){for(var e=[];Array.isArray(r);)e.push(r.length),r=r[0];return e}function Cl(r,e,t){var n,a=r.length;if(a!==e[t])throw new ur(a,e[t]);if(t<e.length-1){var i=t+1;for(n=0;n<a;n++){var o=r[n];if(!Array.isArray(o))throw new ur(e.length-1,e.length,"<");Cl(r[n],e,i)}}else for(n=0;n<a;n++)if(Array.isArray(r[n]))throw new ur(e.length+1,e.length,">")}function Ml(r,e){var t=e.length===0;if(t){if(Array.isArray(r))throw new ur(r.length,0)}else Cl(r,e,0)}function Wi(r,e){var t=r.isMatrix?r._size:rr(r),n=e._sourceSize;n.forEach((a,i)=>{if(a!==null&&a!==t[i])throw new ur(a,t[i])})}function _r(r,e){if(r!==void 0){if(!Ye(r)||!Ue(r))throw new TypeError("Index must be an integer (value: "+r+")");if(r<0||typeof e=="number"&&r>=e)throw new Yt(r,e)}}function Na(r){for(var e=0;e<r._dimensions.length;++e){var t=r._dimensions[e];if(t._data&&Ar(t._data)){if(t._size[0]===0)return!0}else if(t.isRange){if(t.start===t.end)return!0}else if($r(t)&&t.length===0)return!0}return!1}function Ea(r,e,t){if(!Array.isArray(e))throw new TypeError("Array expected");if(e.length===0)throw new Error("Resizing to scalar is not supported");e.forEach(function(a){if(!Ye(a)||!Ue(a)||a<0)throw new TypeError("Invalid size, must contain positive integers (size: "+lr(e)+")")}),(Ye(r)||or(r))&&(r=[r]);var n=t!==void 0?t:0;return ls(r,e,0,n),r}function ls(r,e,t,n){var a,i,o=r.length,l=e[t],u=Math.min(o,l);if(r.length=l,t<e.length-1){var s=t+1;for(a=0;a<u;a++)i=r[a],Array.isArray(i)||(i=[i],r[a]=i),ls(i,e,s,n);for(a=u;a<l;a++)i=[],r[a]=i,ls(i,e,s,n)}else{for(a=0;a<u;a++)for(;Array.isArray(r[a]);)r[a]=r[a][0];for(a=u;a<l;a++)r[a]=n}}function cs(r,e){var t=yr(r,!0),n=t.length;if(!Array.isArray(r)||!Array.isArray(e))throw new TypeError("Array expected");if(e.length===0)throw new ur(0,n,"!=");e=fs(e,n);var a=_l(e);if(n!==a)throw new ur(a,n,"!=");try{return E1(t,e)}catch(i){throw i instanceof ur?new ur(a,n,"!="):i}}function fs(r,e){var t=_l(r),n=r.slice(),a=-1,i=r.indexOf(a),o=r.indexOf(a,i+1)>=0;if(o)throw new Error("More than one wildcard in sizes");var l=i>=0,u=e%t===0;if(l)if(u)n[i]=-e/t;else throw new Error("Could not replace wildcard, since "+e+" is no multiple of "+-t);return n}function _l(r){return r.reduce((e,t)=>e*t,1)}function E1(r,e){for(var t=r,n,a=e.length-1;a>0;a--){var i=e[a];n=[];for(var o=t.length/i,l=0;l<o;l++)n.push(t.slice(l*i,(l+1)*i));t=n}return t}function Yi(r,e){for(var t=rr(r);Array.isArray(r)&&r.length===1;)r=r[0],t.shift();for(var n=t.length;t[n-1]===1;)n--;return n<t.length&&(r=Tl(r,n,0),t.length=n),r}function Tl(r,e,t){var n,a;if(t<e){var i=t+1;for(n=0,a=r.length;n<a;n++)r[n]=Tl(r[n],e,i)}else for(;Array.isArray(r);)r=r[0];return r}function Fl(r,e,t,n){var a=n||rr(r);if(t)for(var i=0;i<t;i++)r=[r],a.unshift(1);for(r=Ol(r,e,0);a.length<e;)a.push(1);return r}function Ol(r,e,t){var n,a;if(Array.isArray(r)){var i=t+1;for(n=0,a=r.length;n<a;n++)r[n]=Ol(r[n],e,i)}else for(var o=t;o<e;o++)r=[r];return r}function yr(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!Array.isArray(r))return r;if(typeof e!="boolean")throw new TypeError("Boolean expected for second argument of flatten");var t=[];return e?a(r):n(r),t;function n(i){for(var o=0;o<i.length;o++){var l=i[o];Array.isArray(l)?n(l):t.push(l)}}function a(i){if(Array.isArray(i[0]))for(var o=0;o<i.length;o++)a(i[o]);else for(var l=0;l<i.length;l++)t.push(i[l])}}function Bn(r,e){return Array.prototype.map.call(r,e)}function Bl(r,e){Array.prototype.forEach.call(r,e)}function Rl(r,e){if(rr(r).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(r,e)}function Il(r,e){if(rr(r).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(r,t=>e.test(t))}function Pl(r,e){return Array.prototype.join.call(r,e)}function Aa(r){if(!Array.isArray(r))throw new TypeError("Array input expected");if(r.length===0)return r;var e=[],t=0;e[0]={value:r[0],identifier:0};for(var n=1;n<r.length;n++)r[n]===r[n-1]?t++:t=0,e.push({value:r[n],identifier:t});return e}function Zi(r){if(!Array.isArray(r))throw new TypeError("Array input expected");if(r.length===0)return r;for(var e=[],t=0;t<r.length;t++)e.push(r[t].value);return e}function Ji(r,e){for(var t,n=0,a=0;a<r.length;a++){var i=r[a],o=Array.isArray(i);if(a===0&&o&&(n=i.length),o&&i.length!==n)return;var l=o?Ji(i,e):e(i);if(t===void 0)t=l;else if(t!==l)return"mixed"}return t}function $l(r,e,t,n){if(n<t){if(r.length!==e.length)throw new ur(r.length,e.length);for(var a=[],i=0;i<r.length;i++)a[i]=$l(r[i],e[i],t,n+1);return a}else return r.concat(e)}function ql(){var r=Array.prototype.slice.call(arguments,0,-1),e=Array.prototype.slice.call(arguments,-1);if(r.length===1)return r[0];if(r.length>1)return r.slice(1).reduce(function(t,n){return $l(t,n,e,0)},r[0]);throw new Error("Wrong number of arguments in function concat")}function ji(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];for(var n=e.map(m=>m.length),a=Math.max(...n),i=new Array(a).fill(null),o=0;o<e.length;o++)for(var l=e[o],u=n[o],s=0;s<u;s++){var c=a-u+s;l[s]>i[c]&&(i[c]=l[s])}for(var f=0;f<e.length;f++)zl(e[f],i);return i}function zl(r,e){for(var t=e.length,n=r.length,a=0;a<n;a++){var i=t-n+a;if(r[a]<e[i]&&r[a]>1||r[a]>e[i])throw new Error("shape mismatch: mismatch is found in arg with shape (".concat(r,") not possible to broadcast dimension ").concat(n," with size ").concat(r[a]," to size ").concat(e[i]))}}function Xn(r,e){var t=rr(r);if(mn(t,e))return r;zl(t,e);var n=ji(t,e),a=n.length,i=[...Array(a-t.length).fill(1),...t],o=S1(r);t.length<a&&(o=cs(o,i),t=rr(o));for(var l=0;l<a;l++)t[l]<n[l]&&(o=A1(o,n[l],l),t=rr(o));return o}function A1(r,e,t){return ql(...Array(e).fill(r),t)}function Xi(r,e){if(!Array.isArray(r))throw new Error("Array expected");if(!Array.isArray(e))throw new Error("Array expected for index");var t=rr(r);if(e.length!==t.length)throw new ur(e.length,t.length);for(var n=0;n<e.length;n++)_r(e[n],t[n]);return e.reduce((a,i)=>a[i],r)}function ms(r,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(r.length===0)return[];if(t)return i(r);var n=[];return a(r,0);function a(o,l){if(Array.isArray(o)){for(var u=o.length,s=Array(u),c=0;c<u;c++)n[l]=c,s[c]=a(o[c],l+1);return s}else return e(o,n.slice(0,l),r)}function i(o){if(Array.isArray(o)){for(var l=o.length,u=Array(l),s=0;s<l;s++)u[s]=i(o[s]);return u}else return e(o)}}function Ul(r,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(r.length===0)return;if(t){i(r);return}var n=[];a(r,0);function a(o,l){if(Array.isArray(o))for(var u=o.length,s=0;s<u;s++)n[l]=s,a(o[s],l+1);else e(o,n.slice(0,l),r)}function i(o){if(Array.isArray(o))for(var l=o.length,u=0;u<l;u++)i(o[u]);else e(o)}}function S1(r){return zr([],r)}function Qn(r,e,t,n){if(Bi.isTypedFunction(r)){var a;if(n)a=1;else{var i=e.isMatrix?e.size():rr(e),o=i.length?i[i.length-1]===0:!0;if(o)return{isUnary:n,fn:r};var l=i.map(()=>0),u=e.isMatrix?e.get(l):Xi(e,l);a=_1(r,u,l,e)}var s;if(e.isMatrix&&e.dataType!=="mixed"&&e.dataType!==void 0){var c=C1(r,a);s=c!==void 0?c:r}else s=r;return a>=1&&a<=3?{isUnary:a===1,fn:function(){for(var m=arguments.length,v=new Array(m),p=0;p<m;p++)v[p]=arguments[p];return Ll(s,v.slice(0,a),t,r.name)}}:{isUnary:!1,fn:function(){for(var m=arguments.length,v=new Array(m),p=0;p<m;p++)v[p]=arguments[p];return Ll(s,v,t,r.name)}}}return n===void 0?{isUnary:M1(r),fn:r}:{isUnary:n,fn:r}}function C1(r,e){var t=[];if(Object.entries(r.signatures).forEach(n=>{var[a,i]=n;a.split(",").length===e&&t.push(i)}),t.length===1)return t[0]}function M1(r){if(r.length!==1)return!1;var e=r.toString();if(/arguments/.test(e))return!1;var t=e.match(/\(.*?\)/);return!/\.\.\./.test(t)}function _1(r,e,t,n){for(var a=[e,t,n],i=3;i>0;i--){var o=a.slice(0,i);if(Bi.resolve(r,o)!==null)return i}}function Ll(r,e,t,n){try{return r(...e)}catch(a){T1(a,e,t,n)}}function T1(r,e,t,n){var a;if(r instanceof TypeError&&((a=r.data)===null||a===void 0?void 0:a.category)==="wrongType"){var i=[];throw i.push("value: ".concat(Sr(e[0]))),e.length>=2&&i.push("index: ".concat(Sr(e[1]))),e.length>=3&&i.push("array: ".concat(Sr(e[2]))),new TypeError("Function ".concat(t," cannot apply callback arguments ")+"".concat(n,"(").concat(i.join(", "),") at index ").concat(JSON.stringify(e[1])))}else throw new TypeError("Function ".concat(t," cannot apply callback arguments ")+"to function ".concat(n,": ").concat(r.message))}var F1="DenseMatrix",O1=["Matrix","config"],B1=L(F1,O1,r=>{var{Matrix:e,config:t}=r;function n(f,m){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(m&&!$r(m))throw new Error("Invalid datatype: "+m);if(Je(f))f.type==="DenseMatrix"?(this._data=er(f._data),this._size=er(f._size),this._datatype=m||f._datatype):(this._data=f.toArray(),this._size=f.size(),this._datatype=m||f._datatype);else if(f&&Ar(f.data)&&Ar(f.size))this._data=f.data,this._size=f.size,Ml(this._data,this._size),this._datatype=m||f.datatype;else if(Ar(f))this._data=c(f),this._size=rr(this._data),Ml(this._data,this._size),this._datatype=m;else{if(f)throw new TypeError("Unsupported type of data ("+Sr(f)+")");this._data=[],this._size=[0],this._datatype=m}}n.prototype=new e,n.prototype.createDenseMatrix=function(f,m){return new n(f,m)},Object.defineProperty(n,"name",{value:"DenseMatrix"}),n.prototype.constructor=n,n.prototype.type="DenseMatrix",n.prototype.isDenseMatrix=!0,n.prototype.getDataType=function(){return Ji(this._data,Sr)},n.prototype.storage=function(){return"dense"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(f,m){return new n(f,m)},n.prototype.subset=function(f,m,v){switch(arguments.length){case 1:return a(this,f);case 2:case 3:return o(this,f,m,v);default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.get=function(f){return Xi(this._data,f)},n.prototype.set=function(f,m,v){if(!Ar(f))throw new TypeError("Array expected");if(f.length<this._size.length)throw new ur(f.length,this._size.length,"<");var p,d,y,x=f.map(function(h){return h+1});s(this,x,v);var D=this._data;for(p=0,d=f.length-1;p<d;p++)y=f[p],_r(y,D.length),D=D[y];return y=f[f.length-1],_r(y,D.length),D[y]=m,this};function a(f,m){if(!Ti(m))throw new TypeError("Invalid index");var v=t.legacySubset?m.size().every(g=>g===1):m.isScalar();if(v)return f.get(m.min());var p=m.size();if(p.length!==f._size.length)throw new ur(p.length,f._size.length);for(var d=m.min(),y=m.max(),x=0,D=f._size.length;x<D;x++)_r(d[x],f._size[x]),_r(y[x],f._size[x]);var h=new n,w=i(f._data,m);return h._size=w.size,h._datatype=f._datatype,h._data=w.data,t.legacySubset?h.reshape(m.size()):h}function i(f,m){var v=m.size().length-1,p=Array(v);return{data:d(f),size:p.filter(y=>y!==null)};function d(y){var x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,D=m.dimension(x);function h(w,g){return Ye(w)?g(w):w.map(g).valueOf()}return Ye(D)?p[x]=null:p[x]=D.size()[0],x<v?h(D,w=>(_r(w,y.length),d(y[w],x+1))):h(D,w=>(_r(w,y.length),y[w]))}}function o(f,m,v,p){if(!m||m.isIndex!==!0)throw new TypeError("Invalid index");var d=m.size(),y=m.isScalar(),x;if(Je(v)?(x=v.size(),v=v.valueOf()):x=rr(v),y){if(x.length!==0)throw new TypeError("Scalar expected");f.set(m.min(),v,p)}else{if(!mn(x,d)){if(x.length===0)v=Xn([v],d);else try{v=Xn(v,d)}catch{}x=rr(v)}if(d.length<f._size.length)throw new ur(d.length,f._size.length,"<");if(x.length<d.length){for(var D=0,h=0;d[D]===1&&x[D]===1;)D++;for(;d[D]===1;)h++,D++;v=Fl(v,d.length,h,x)}if(!mn(d,x))throw new ur(d,x,">");var w=m.max().map(function(g){return g+1});s(f,w,p),l(f._data,m,v)}return f}function l(f,m,v){var p=m.size().length-1;d(f,v);function d(y,x){var D=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,h=m.dimension(D),w=(b,A)=>{_r(b,y.length),d(y[b],x[A[0]],D+1)},g=(b,A)=>{_r(b,y.length),y[b]=x[A[0]]};D<p?Ye(h)?w(h,[0]):h.forEach(w):Ye(h)?g(h,[0]):h.forEach(g)}}n.prototype.resize=function(f,m,v){if(!Ct(f))throw new TypeError("Array or Matrix expected");var p=f.valueOf().map(y=>Array.isArray(y)&&y.length===1?y[0]:y),d=v?this.clone():this;return u(d,p,m)};function u(f,m,v){if(m.length===0){for(var p=f._data;Ar(p);)p=p[0];return p}return f._size=m.slice(0),f._data=Ea(f._data,f._size,v),f}n.prototype.reshape=function(f,m){var v=m?this.clone():this;v._data=cs(v._data,f);var p=v._size.reduce((d,y)=>d*y);return v._size=fs(f,p),v};function s(f,m,v){for(var p=f._size.slice(0),d=!1;p.length<m.length;)p.push(0),d=!0;for(var y=0,x=m.length;y<x;y++)m[y]>p[y]&&(p[y]=m[y],d=!0);d&&u(f,p,v)}n.prototype.clone=function(){var f=new n({data:er(this._data),size:er(this._size),datatype:this._datatype});return f},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(f){var m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,v=this,p=v._size.length-1;if(p<0)return v.clone();var d=Qn(f,v,"map",m),y=d.fn,x=v.create(void 0,v._datatype);if(x._size=v._size,m||d.isUnary)return x._data=A(v._data),x;if(p===0){for(var D=v.valueOf(),h=Array(D.length),w=0;w<D.length;w++)h[w]=y(D[w],[w],v);return x._data=h,x}var g=[];return x._data=b(v._data),x;function b(N){var E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,S=Array(N.length);if(E<p)for(var C=0;C<N.length;C++)g[E]=C,S[C]=b(N[C],E+1);else for(var M=0;M<N.length;M++)g[E]=M,S[M]=y(N[M],g.slice(),v);return S}function A(N){var E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,S=Array(N.length);if(E<p)for(var C=0;C<N.length;C++)S[C]=A(N[C],E+1);else for(var M=0;M<N.length;M++)S[M]=y(N[M]);return S}},n.prototype.forEach=function(f){var m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,v=this,p=v._size.length-1;if(p<0)return;var d=Qn(f,v,"map",m),y=d.fn;if(m||d.isUnary){w(v._data);return}if(p===0){for(var x=0;x<v._data.length;x++)y(v._data[x],[x],v);return}var D=[];h(v._data);function h(g){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(b<p)for(var A=0;A<g.length;A++)D[b]=A,h(g[A],b+1);else for(var N=0;N<g.length;N++)D[b]=N,y(g[N],D.slice(),v)}function w(g){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(b<p)for(var A=0;A<g.length;A++)w(g[A],b+1);else for(var N=0;N<g.length;N++)y(g[N])}},n.prototype[Symbol.iterator]=function*(){var f=this._size.length-1;if(!(f<0)){if(f===0){for(var m=0;m<this._data.length;m++)yield{value:this._data[m],index:[m]};return}for(var v=Array(f+1).fill(0),p=this._size.reduce((h,w)=>h*w,1),d=0;d<p;d++){for(var y=this._data,x=0;x<f;x++)y=y[v[x]];yield{value:y[v[f]],index:v.slice()};for(var D=f;D>=0&&(v[D]++,!(v[D]<this._size[D]));D--)v[D]=0}}},n.prototype.rows=function(){var f=[],m=this.size();if(m.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var v=this._data;for(var p of v)f.push(new n([p],this._datatype));return f},n.prototype.columns=function(){var f=this,m=[],v=this.size();if(v.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var p=this._data,d=function(D){var h=p.map(w=>[w[D]]);m.push(new n(h,f._datatype))},y=0;y<v[1];y++)d(y);return m},n.prototype.toArray=function(){return er(this._data)},n.prototype.valueOf=function(){return this._data},n.prototype.format=function(f){return lr(this._data,f)},n.prototype.toString=function(){return lr(this._data)},n.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(f){if(f){if(or(f)&&(f=f.toNumber()),!Ye(f)||!Ue(f))throw new TypeError("The parameter k must be an integer number")}else f=0;for(var m=f>0?f:0,v=f<0?-f:0,p=this._size[0],d=this._size[1],y=Math.min(p-v,d-m),x=[],D=0;D<y;D++)x[D]=this._data[D+v][D+m];return new n({data:x,size:[y],datatype:this._datatype})},n.diagonal=function(f,m,v,p){if(!Ar(f))throw new TypeError("Array expected, size parameter");if(f.length!==2)throw new Error("Only two dimensions matrix are supported");if(f=f.map(function(N){if(or(N)&&(N=N.toNumber()),!Ye(N)||!Ue(N)||N<1)throw new Error("Size values must be positive integers");return N}),v){if(or(v)&&(v=v.toNumber()),!Ye(v)||!Ue(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var d=v>0?v:0,y=v<0?-v:0,x=f[0],D=f[1],h=Math.min(x-y,D-d),w;if(Ar(m)){if(m.length!==h)throw new Error("Invalid value array length");w=function(E){return m[E]}}else if(Je(m)){var g=m.size();if(g.length!==1||g[0]!==h)throw new Error("Invalid matrix length");w=function(E){return m.get([E])}}else w=function(){return m};p||(p=or(w(0))?w(0).mul(0):0);var b=[];if(f.length>0){b=Ea(b,f,p);for(var A=0;A<h;A++)b[A+y][A+d]=w(A)}return new n({data:b,size:[x,D]})},n.fromJSON=function(f){return new n(f)},n.prototype.swapRows=function(f,m){if(!Ye(f)||!Ue(f)||!Ye(m)||!Ue(m))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return _r(f,this._size[0]),_r(m,this._size[0]),n._swapRows(f,m,this._data),this},n._swapRows=function(f,m,v){var p=v[f];v[f]=v[m],v[m]=p};function c(f){return Je(f)?c(f.valueOf()):Ar(f)?f.map(c):f}return n},{isClass:!0}),kl="clone",R1=["typed"],I1=L(kl,R1,r=>{var{typed:e}=r;return e(kl,{any:er})});function Vl(r){var e=r.length,t=r[0].length,n,a,i=[];for(a=0;a<t;a++){var o=[];for(n=0;n<e;n++)o.push(r[n][a]);i.push(o)}return i}function Sa(r){for(var e=0;e<r.length;e++)if(Ct(r[e]))return!0;return!1}function Rn(r,e){Je(r)?r.forEach(t=>e(t),!1,!0):Ul(r,e,!0)}function tr(r,e,t){if(!t)return Je(r)?r.map(a=>e(a),!1,!0):ms(r,e,!0);var n=a=>a===0?a:e(a);return Je(r)?r.map(a=>n(a),!1,!0):ms(r,n,!0)}function Qi(r,e,t){var n=Array.isArray(r)?rr(r):r.size();if(e<0||e>=n.length)throw new Yt(e,n.length);return Je(r)?r.create(Ki(r.valueOf(),e,t),r.datatype()):Ki(r,e,t)}function Ki(r,e,t){var n,a,i,o;if(e<=0)if(Array.isArray(r[0])){for(o=Vl(r),a=[],n=0;n<o.length;n++)a[n]=Ki(o[n],e-1,t);return a}else{for(i=r[0],n=1;n<r.length;n++)i=t(i,r[n]);return i}else{for(a=[],n=0;n<r.length;n++)a[n]=Ki(r[n],e-1,t);return a}}function Gl(r,e,t,n,a,i,o,l,u,s,c){var f=r._values,m=r._index,v=r._ptr,p,d,y,x;if(n)for(d=v[e],y=v[e+1],p=d;p<y;p++)x=m[p],t[x]!==i?(t[x]=i,o.push(x),n[x]=f[p]):(n[x]=l(n[x],f[p]),a[x]=i);else for(d=v[e],y=v[e+1],p=d;p<y;p++)x=m[p],t[x]!==i?(t[x]=i,o.push(x)):a[x]=i}var Hl="isInteger",P1=["typed","equal"],$1=L(Hl,P1,r=>{var{typed:e,equal:t}=r;return e(Hl,{number:n=>Number.isFinite(n)?t(n,Math.round(n)):!1,BigNumber:n=>n.isFinite()?t(n.round(),n):!1,bigint:n=>!0,Fraction:n=>n.d===1n,"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),Zt="number",Ca="number, number";function Wl(r){return Math.abs(r)}Wl.signature=Zt;function Yl(r,e){return r+e}Yl.signature=Ca;function Zl(r,e){return r-e}Zl.signature=Ca;function Jl(r,e){return r*e}Jl.signature=Ca;function jl(r){return-r}jl.signature=Zt;function Xl(r){return r}Xl.signature=Zt;function ai(r){return z0(r)}ai.signature=Zt;function Ql(r){return r*r*r}Ql.signature=Zt;function Kl(r){return Math.exp(r)}Kl.signature=Zt;function ec(r){return U0(r)}ec.signature=Zt;function rc(r,e){if(!Ue(r)||!Ue(e))throw new Error("Parameters in function lcm must be integer numbers");if(r===0||e===0)return 0;for(var t,n=r*e;e!==0;)t=e,e=r%t,r=t;return Math.abs(n/r)}rc.signature=Ca;function tc(r,e){return e?Math.log(r)/Math.log(e):Math.log(r)}function eo(r){return $0(r)}eo.signature=Zt;function vs(r){return P0(r)}vs.signature=Zt;function nc(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,t=e<0;if(t&&(e=-e),e===0)throw new Error("Root must be non-zero");if(r<0&&Math.abs(e)%2!==1)throw new Error("Root must be odd when a is negative.");if(r===0)return t?1/0:0;if(!isFinite(r))return t?0:r;var n=Math.pow(Math.abs(r),1/e);return n=r<0?-n:n,t?1/n:n}function ps(r){return Sn(r)}ps.signature=Zt;function ac(r){return r*r}ac.signature=Zt;function ic(r,e){var t,n,a,i=0,o=1,l=1,u=0;if(!Ue(r)||!Ue(e))throw new Error("Parameters in function xgcd must be integer numbers");for(;e;)n=Math.floor(r/e),a=r-n*e,t=i,i=o-n*i,o=t,t=l,l=u-n*l,u=t,r=e,e=a;var s;return r<0?s=[-r,-o,-u]:s=[r,r?o:0,u],s}ic.signature=Ca;function oc(r,e){return r*r<1&&e===1/0||r*r>1&&e===-1/0?0:Math.pow(r,e)}oc.signature=Ca;function ii(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!Ue(e)||e<0||e>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(nl(r,e))}var q1="number",Ma="number, number";function sc(r,e){if(!Ue(r)||!Ue(e))throw new Error("Integers expected in function bitAnd");return r&e}sc.signature=Ma;function uc(r){if(!Ue(r))throw new Error("Integer expected in function bitNot");return~r}uc.signature=q1;function lc(r,e){if(!Ue(r)||!Ue(e))throw new Error("Integers expected in function bitOr");return r|e}lc.signature=Ma;function cc(r,e){if(!Ue(r)||!Ue(e))throw new Error("Integers expected in function bitXor");return r^e}cc.signature=Ma;function fc(r,e){if(!Ue(r)||!Ue(e))throw new Error("Integers expected in function leftShift");return r<<e}fc.signature=Ma;function mc(r,e){if(!Ue(r)||!Ue(e))throw new Error("Integers expected in function rightArithShift");return r>>e}mc.signature=Ma;function vc(r,e){if(!Ue(r)||!Ue(e))throw new Error("Integers expected in function rightLogShift");return r>>>e}vc.signature=Ma;function dn(r,e){if(e<r)return 1;if(e===r)return e;var t=e+r>>1;return dn(r,t)*dn(t+1,e)}function pc(r,e){if(!Ue(r)||r<0)throw new TypeError("Positive integer value expected in function combinations");if(!Ue(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(e>r)throw new TypeError("k must be less than or equal to n");for(var t=r-e,n=1,a=e<t?t+1:e+1,i=2,o=e<t?e:t,l=a;l<=r;++l)for(n*=l;i<=o&&n%i===0;)n/=i,++i;return i<=o&&(n/=dn(i,o)),n}pc.signature="number, number";var z1=Math.PI,U1=2*Math.PI,L1=Math.E,k1=1.618033988749895,V1="number",ds="number, number";function dc(r){return!r}dc.signature=V1;function hs(r,e){return!!(r||e)}hs.signature=ds;function gs(r,e){return!!r!=!!e}gs.signature=ds;function ys(r,e){return!!(r&&e)}ys.signature=ds;function ro(r){var e;if(Ue(r))return r<=0?Number.isFinite(r)?1/0:NaN:r>171?1/0:dn(1,r-1);if(r<.5)return Math.PI/(Math.sin(Math.PI*r)*ro(1-r));if(r>=171.35)return 1/0;if(r>85){var t=r*r,n=t*r,a=n*r,i=a*r;return Math.sqrt(2*Math.PI/r)*Math.pow(r/Math.E,r)*(1+1/(12*r)+1/(288*t)-139/(51840*n)-571/(2488320*a)+163879/(209018880*i)+5246819/(75246796800*i*r))}--r,e=_a[0];for(var o=1;o<_a.length;++o)e+=_a[o]/(r+o);var l=r+hc+.5;return Math.sqrt(2*Math.PI)*Math.pow(l,r+.5)*Math.exp(-l)*e}ro.signature="number";var hc=4.7421875,_a=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],gc=.9189385332046728,G1=5,H1=7,yc=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function to(r){if(r<0)return NaN;if(r===0)return 1/0;if(!Number.isFinite(r))return r;if(r<.5)return Math.log(Math.PI/Math.sin(Math.PI*r))-to(1-r);r=r-1;for(var e=r+G1+.5,t=yc[0],n=H1-1;n>=1;n--)t+=yc[n]/(r+n);return gc+(r+.5)*Math.log(e)-e+Math.log(t)}to.signature="number";var ut="number";function bc(r){return G0(r)}bc.signature=ut;function xc(r){return Math.atan(1/r)}xc.signature=ut;function wc(r){return Number.isFinite(r)?(Math.log((r+1)/r)+Math.log(r/(r-1)))/2:0}wc.signature=ut;function Dc(r){return Math.asin(1/r)}Dc.signature=ut;function Nc(r){var e=1/r;return Math.log(e+Math.sqrt(e*e+1))}Nc.signature=ut;function Ec(r){return Math.acos(1/r)}Ec.signature=ut;function Ac(r){var e=1/r,t=Math.sqrt(e*e-1);return Math.log(t+e)}Ac.signature=ut;function Sc(r){return H0(r)}Sc.signature=ut;function Cc(r){return W0(r)}Cc.signature=ut;function Mc(r){return 1/Math.tan(r)}Mc.signature=ut;function _c(r){var e=Math.exp(2*r);return(e+1)/(e-1)}_c.signature=ut;function Tc(r){return 1/Math.sin(r)}Tc.signature=ut;function Fc(r){return r===0?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(r)-Math.exp(-r)))*Sn(r)}Fc.signature=ut;function Oc(r){return 1/Math.cos(r)}Oc.signature=ut;function Bc(r){return 2/(Math.exp(r)+Math.exp(-r))}Bc.signature=ut;function Rc(r){return Z0(r)}Rc.signature=ut;var bs="number";function Ic(r){return r<0}Ic.signature=bs;function Pc(r){return r>0}Pc.signature=bs;function $c(r){return Number.isNaN(r)}$c.signature=bs;function zt(r,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e-9,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(t<=0)throw new Error("Relative tolerance must be greater than 0");if(n<0)throw new Error("Absolute tolerance must be at least 0");return r.isNaN()||e.isNaN()?!1:!r.isFinite()||!e.isFinite()?r.eq(e):r.eq(e)?!0:r.minus(e).abs().lte(r.constructor.max(r.constructor.max(r.abs(),e.abs()).mul(t),n))}var qc="isNegative",W1=["typed","config"],Y1=L(qc,W1,r=>{var{typed:e,config:t}=r;return e(qc,{number:n=>jr(n,0,t.relTol,t.absTol)?!1:Ic(n),BigNumber:n=>zt(n,new n.constructor(0),t.relTol,t.absTol)?!1:n.isNeg()&&!n.isZero()&&!n.isNaN(),bigint:n=>n<0n,Fraction:n=>n.s<0n,Unit:e.referToSelf(n=>a=>e.find(n,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),zc="isNumeric",Z1=["typed"],J1=L(zc,Z1,r=>{var{typed:e}=r;return e(zc,{"number | BigNumber | bigint | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),Uc="hasNumericValue",j1=["typed","isNumeric"],X1=L(Uc,j1,r=>{var{typed:e,isNumeric:t}=r;return e(Uc,{boolean:()=>!0,string:function(a){return a.trim().length>0&&!isNaN(Number(a))},any:function(a){return t(a)}})}),Lc="isPositive",Q1=["typed","config"],K1=L(Lc,Q1,r=>{var{typed:e,config:t}=r;return e(Lc,{number:n=>jr(n,0,t.relTol,t.absTol)?!1:Pc(n),BigNumber:n=>zt(n,new n.constructor(0),t.relTol,t.absTol)?!1:!n.isNeg()&&!n.isZero()&&!n.isNaN(),bigint:n=>n>0n,Fraction:n=>n.s>0n&&n.n>0n,Unit:e.referToSelf(n=>a=>e.find(n,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),kc="isZero",eb=["typed","equalScalar"],rb=L(kc,eb,r=>{var{typed:e,equalScalar:t}=r;return e(kc,{"number | BigNumber | Complex | Fraction":n=>t(n,0),bigint:n=>n===0n,Unit:e.referToSelf(n=>a=>e.find(n,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),Vc="isNaN",tb=["typed"],nb=L(Vc,tb,r=>{var{typed:e}=r;return e(Vc,{number:$c,BigNumber:function(n){return n.isNaN()},bigint:function(n){return!1},Fraction:function(n){return!1},Complex:function(n){return n.isNaN()},Unit:function(n){return Number.isNaN(n.value)},"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),Gc="isBounded",ab=["typed"],ib=L(Gc,ab,r=>{var{typed:e}=r;return e(Gc,{number:t=>Number.isFinite(t),"BigNumber | Complex":t=>t.isFinite(),"bigint | Fraction":()=>!0,"null | undefined":()=>!1,Unit:e.referToSelf(t=>n=>t(n.value)),"Array | Matrix":e.referToSelf(t=>n=>(Array.isArray(n)||(n=n.valueOf()),n.every(a=>t(a))))})}),Hc="isFinite",ob=["typed","isBounded","map"],sb=L(Hc,ob,r=>{var{typed:e,isBounded:t,map:n}=r;return e(Hc,{"Array | Matrix":a=>n(a,t),any:a=>t(a)})}),Wc="typeOf",ub=["typed"],lb=L(Wc,ub,r=>{var{typed:e}=r;return e(Wc,{any:Sr})});function cb(r,e,t,n){return jr(r.re,e.re,t,n)&&jr(r.im,e.im,t,n)}var Ta=L("compareUnits",["typed"],r=>{var{typed:e}=r;return{"Unit, Unit":e.referToSelf(t=>(n,a)=>{if(!n.equalBase(a))throw new Error("Cannot compare units with different base");return e.find(t,[n.valueType(),a.valueType()])(n.value,a.value)})}}),no="equalScalar",fb=["typed","config"],mb=L(no,fb,r=>{var{typed:e,config:t}=r,n=Ta({typed:e});return e(no,{"boolean, boolean":function(i,o){return i===o},"number, number":function(i,o){return jr(i,o,t.relTol,t.absTol)},"BigNumber, BigNumber":function(i,o){return i.eq(o)||zt(i,o,t.relTol,t.absTol)},"bigint, bigint":function(i,o){return i===o},"Fraction, Fraction":function(i,o){return i.equals(o)},"Complex, Complex":function(i,o){return cb(i,o,t.relTol,t.absTol)}},n)});L(no,["typed","config"],r=>{var{typed:e,config:t}=r;return e(no,{"number, number":function(a,i){return jr(a,i,t.relTol,t.absTol)}})});var vb="SparseMatrix",pb=["typed","equalScalar","Matrix"],db=L(vb,pb,r=>{var{typed:e,equalScalar:t,Matrix:n}=r;function a(d,y){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(y&&!$r(y))throw new Error("Invalid datatype: "+y);if(Je(d))i(this,d,y);else if(d&&Ar(d.index)&&Ar(d.ptr)&&Ar(d.size))this._values=d.values,this._index=d.index,this._ptr=d.ptr,this._size=d.size,this._datatype=y||d.datatype;else if(Ar(d))o(this,d,y);else{if(d)throw new TypeError("Unsupported type of data ("+Sr(d)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=y}}function i(d,y,x){y.type==="SparseMatrix"?(d._values=y._values?er(y._values):void 0,d._index=er(y._index),d._ptr=er(y._ptr),d._size=er(y._size),d._datatype=x||y._datatype):o(d,y.valueOf(),x||y._datatype)}function o(d,y,x){d._values=[],d._index=[],d._ptr=[],d._datatype=x;var D=y.length,h=0,w=t,g=0;if($r(x)&&(w=e.find(t,[x,x])||t,g=e.convert(0,x)),D>0){var b=0;do{d._ptr.push(d._index.length);for(var A=0;A<D;A++){var N=y[A];if(Ar(N)){if(b===0&&h<N.length&&(h=N.length),b<N.length){var E=N[b];w(E,g)||(d._values.push(E),d._index.push(A))}}else b===0&&h<1&&(h=1),w(N,g)||(d._values.push(N),d._index.push(A))}b++}while(b<h)}for(;d._ptr.length<=h;)d._ptr.push(d._index.length);d._size=[D,h]}a.prototype=new n,a.prototype.createSparseMatrix=function(d,y){return new a(d,y)},Object.defineProperty(a,"name",{value:"SparseMatrix"}),a.prototype.constructor=a,a.prototype.type="SparseMatrix",a.prototype.isSparseMatrix=!0,a.prototype.getDataType=function(){return Ji(this._values,Sr)},a.prototype.storage=function(){return"sparse"},a.prototype.datatype=function(){return this._datatype},a.prototype.create=function(d,y){return new a(d,y)},a.prototype.density=function(){var d=this._size[0],y=this._size[1];return d!==0&&y!==0?this._index.length/(d*y):0},a.prototype.subset=function(d,y,x){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return l(this,d);case 2:case 3:return u(this,d,y,x);default:throw new SyntaxError("Wrong number of arguments")}};function l(d,y){if(!Ti(y))throw new TypeError("Invalid index");var x=y.isScalar();if(x)return d.get(y.min());var D=y.size();if(D.length!==d._size.length)throw new ur(D.length,d._size.length);var h,w,g,b,A=y.min(),N=y.max();for(h=0,w=d._size.length;h<w;h++)_r(A[h],d._size[h]),_r(N[h],d._size[h]);var E=d._values,S=d._index,C=d._ptr,M=y.dimension(0),O=y.dimension(1),I=[],k=[];function _(ne,j){k[ne]=j[0],I[ne]=!0}Number.isInteger(M)?_(M,[0]):M.forEach(_);var P=E?[]:void 0,V=[],q=[];function J(ne){for(q.push(V.length),g=C[ne],b=C[ne+1];g<b;g++)h=S[g],I[h]===!0&&(V.push(k[h]),P&&P.push(E[g]))}return Number.isInteger(O)?J(O):O.forEach(J),q.push(V.length),new a({values:P,index:V,ptr:q,size:D,datatype:d._datatype})}function u(d,y,x,D){if(!y||y.isIndex!==!0)throw new TypeError("Invalid index");var h=y.size(),w=y.isScalar(),g;if(Je(x)?(g=x.size(),x=x.toArray()):g=rr(x),w){if(g.length!==0)throw new TypeError("Scalar expected");d.set(y.min(),x,D)}else{if(h.length!==1&&h.length!==2)throw new ur(h.length,d._size.length,"<");if(g.length<h.length){for(var b=0,A=0;h[b]===1&&g[b]===1;)b++;for(;h[b]===1;)A++,b++;x=Fl(x,h.length,A,g)}if(!mn(h,g))throw new ur(h,g,">");if(h.length===1){var N=y.dimension(0);C(N,(M,O)=>{_r(M),d.set([M,0],x[O[0]],D)})}else{var E=y.dimension(0),S=y.dimension(1);C(E,(M,O)=>{_r(M),C(S,(I,k)=>{_r(I),d.set([M,I],x[O[0]][k[0]],D)})})}}return d;function C(M,O){Ye(M)?O(M,[0]):M.forEach(O)}}a.prototype.get=function(d){if(!Ar(d))throw new TypeError("Array expected");if(d.length!==this._size.length)throw new ur(d.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var y=d[0],x=d[1];_r(y,this._size[0]),_r(x,this._size[1]);var D=s(y,this._ptr[x],this._ptr[x+1],this._index);return D<this._ptr[x+1]&&this._index[D]===y?this._values[D]:0},a.prototype.set=function(d,y,x){if(!Ar(d))throw new TypeError("Array expected");if(d.length!==this._size.length)throw new ur(d.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var D=d[0],h=d[1],w=this._size[0],g=this._size[1],b=t,A=0;$r(this._datatype)&&(b=e.find(t,[this._datatype,this._datatype])||t,A=e.convert(0,this._datatype)),(D>w-1||h>g-1)&&(m(this,Math.max(D+1,w),Math.max(h+1,g),x),w=this._size[0],g=this._size[1]),_r(D,w),_r(h,g);var N=s(D,this._ptr[h],this._ptr[h+1],this._index);return N<this._ptr[h+1]&&this._index[N]===D?b(y,A)?c(N,h,this._values,this._index,this._ptr):this._values[N]=y:b(y,A)||f(N,D,h,y,this._values,this._index,this._ptr),this};function s(d,y,x,D){if(x-y===0)return x;for(var h=y;h<x;h++)if(D[h]===d)return h;return y}function c(d,y,x,D,h){x.splice(d,1),D.splice(d,1);for(var w=y+1;w<h.length;w++)h[w]--}function f(d,y,x,D,h,w,g){h.splice(d,0,D),w.splice(d,0,y);for(var b=x+1;b<g.length;b++)g[b]++}a.prototype.resize=function(d,y,x){if(!Ct(d))throw new TypeError("Array or Matrix expected");var D=d.valueOf().map(w=>Array.isArray(w)&&w.length===1?w[0]:w);if(D.length!==2)throw new Error("Only two dimensions matrix are supported");D.forEach(function(w){if(!Ye(w)||!Ue(w)||w<0)throw new TypeError("Invalid size, must contain positive integers (size: "+lr(D)+")")});var h=x?this.clone():this;return m(h,D[0],D[1],y)};function m(d,y,x,D){var h=D||0,w=t,g=0;$r(d._datatype)&&(w=e.find(t,[d._datatype,d._datatype])||t,g=e.convert(0,d._datatype),h=e.convert(h,d._datatype));var b=!w(h,g),A=d._size[0],N=d._size[1],E,S,C;if(x>N){for(S=N;S<x;S++)if(d._ptr[S]=d._values.length,b)for(E=0;E<A;E++)d._values.push(h),d._index.push(E);d._ptr[x]=d._values.length}else x<N&&(d._ptr.splice(x+1,N-x),d._values.splice(d._ptr[x],d._values.length),d._index.splice(d._ptr[x],d._index.length));if(N=x,y>A){if(b){var M=0;for(S=0;S<N;S++){d._ptr[S]=d._ptr[S]+M,C=d._ptr[S+1]+M;var O=0;for(E=A;E<y;E++,O++)d._values.splice(C+O,0,h),d._index.splice(C+O,0,E),M++}d._ptr[N]=d._values.length}}else if(y<A){var I=0;for(S=0;S<N;S++){d._ptr[S]=d._ptr[S]-I;var k=d._ptr[S],_=d._ptr[S+1]-I;for(C=k;C<_;C++)E=d._index[C],E>y-1&&(d._values.splice(C,1),d._index.splice(C,1),I++)}d._ptr[S]=d._values.length}return d._size[0]=y,d._size[1]=x,d}a.prototype.reshape=function(d,y){if(!Ar(d))throw new TypeError("Array expected");if(d.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");d.forEach(function(q){if(!Ye(q)||!Ue(q)||q<=-2||q===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+lr(d)+")")});var x=this._size[0]*this._size[1];d=fs(d,x);var D=d[0]*d[1];if(x!==D)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var h=y?this.clone():this;if(this._size[0]===d[0]&&this._size[1]===d[1])return h;for(var w=[],g=0;g<h._ptr.length;g++)for(var b=0;b<h._ptr[g+1]-h._ptr[g];b++)w.push(g);for(var A=h._values.slice(),N=h._index.slice(),E=0;E<h._index.length;E++){var S=N[E],C=w[E],M=S*h._size[1]+C;w[E]=M%d[1],N[E]=Math.floor(M/d[1])}h._values.length=0,h._index.length=0,h._ptr.length=d[1]+1,h._size=d.slice();for(var O=0;O<h._ptr.length;O++)h._ptr[O]=0;for(var I=0;I<A.length;I++){var k=N[I],_=w[I],P=A[I],V=s(k,h._ptr[_],h._ptr[_+1],h._index);f(V,k,_,P,h._values,h._index,h._ptr)}return h},a.prototype.clone=function(){var d=new a({values:this._values?er(this._values):void 0,index:er(this._index),ptr:er(this._ptr),size:er(this._size),datatype:this._datatype});return d},a.prototype.size=function(){return this._size.slice(0)},a.prototype.map=function(d,y){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var x=this,D=this._size[0],h=this._size[1],w=Qn(d,x,"map"),g=function(A,N,E){return w.fn(A,[N,E],x)};return v(this,0,D-1,0,h-1,g,y)};function v(d,y,x,D,h,w,g){var b=[],A=[],N=[],E=t,S=0;$r(d._datatype)&&(E=e.find(t,[d._datatype,d._datatype])||t,S=e.convert(0,d._datatype));for(var C=function(F,U,$){var le=w(F,U,$);E(le,S)||(b.push(le),A.push(U))},M=D;M<=h;M++){N.push(b.length);var O=d._ptr[M],I=d._ptr[M+1];if(g)for(var k=O;k<I;k++){var _=d._index[k];_>=y&&_<=x&&C(d._values[k],_-y,M-D)}else{for(var P={},V=O;V<I;V++){var q=d._index[V];P[q]=d._values[V]}for(var J=y;J<=x;J++){var ne=J in P?P[J]:0;C(ne,J-y,M-D)}}}return N.push(b.length),new a({values:b,index:A,ptr:N,size:[x-y+1,h-D+1]})}a.prototype.forEach=function(d,y){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var x=this,D=this._size[0],h=this._size[1],w=Qn(d,x,"forEach"),g=0;g<h;g++){var b=this._ptr[g],A=this._ptr[g+1];if(y)for(var N=b;N<A;N++){var E=this._index[N];w.fn(this._values[N],[E,g],x)}else{for(var S={},C=b;C<A;C++){var M=this._index[C];S[M]=this._values[C]}for(var O=0;O<D;O++){var I=O in S?S[O]:0;w.fn(I,[O,g],x)}}}},a.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var d=this._size[1],y=0;y<d;y++)for(var x=this._ptr[y],D=this._ptr[y+1],h=x;h<D;h++){var w=this._index[h];yield{value:this._values[h],index:[w,y]}}},a.prototype.toArray=function(){return p(this._values,this._index,this._ptr,this._size,!0)},a.prototype.valueOf=function(){return p(this._values,this._index,this._ptr,this._size,!1)};function p(d,y,x,D,h){var w=D[0],g=D[1],b=[],A,N;for(A=0;A<w;A++)for(b[A]=[],N=0;N<g;N++)b[A][N]=0;for(N=0;N<g;N++)for(var E=x[N],S=x[N+1],C=E;C<S;C++)A=y[C],b[A][N]=d?h?er(d[C]):d[C]:1;return b}return a.prototype.format=function(d){for(var y=this._size[0],x=this._size[1],D=this.density(),h="Sparse Matrix ["+lr(y,d)+" x "+lr(x,d)+"] density: "+lr(D,d)+`
|
|
15
|
+
*/var ga=9e15,Cn=1e9,Ko="0123456789abcdef",qi="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",zi="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",es={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ga,maxE:ga,crypto:!1},ll,vn,ar=!0,Ui="[DecimalError] ",Mn=Ui+"Invalid argument: ",cl=Ui+"Precision limit exceeded",fl=Ui+"crypto unavailable",ml="[object Decimal]",st=Math.floor,Hr=Math.pow,ny=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,ay=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,iy=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,vl=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ht=1e7,Xe=7,oy=9007199254740991,sy=qi.length-1,rs=zi.length-1,Ne={toStringTag:ml};Ne.absoluteValue=Ne.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),Ze(r)},Ne.ceil=function(){return Ze(new this.constructor(this),this.e+1,2)},Ne.clampedTo=Ne.clamp=function(r,e){var t,n=this,a=n.constructor;if(r=new a(r),e=new a(e),!r.s||!e.s)return new a(NaN);if(r.gt(e))throw Error(Mn+e);return t=n.cmp(r),t<0?r:n.cmp(e)>0?e:new a(n)},Ne.comparedTo=Ne.cmp=function(r){var e,t,n,a,i=this,o=i.d,l=(r=new i.constructor(r)).d,u=i.s,s=r.s;if(!o||!l)return!u||!s?NaN:u!==s?u:o===l?0:!o^u<0?1:-1;if(!o[0]||!l[0])return o[0]?u:l[0]?-s:0;if(u!==s)return u;if(i.e!==r.e)return i.e>r.e^u<0?1:-1;for(n=o.length,a=l.length,e=0,t=n<a?n:a;e<t;++e)if(o[e]!==l[e])return o[e]>l[e]^u<0?1:-1;return n===a?0:n>a^u<0?1:-1},Ne.cosine=Ne.cos=function(){var r,e,t=this,n=t.constructor;return t.d?t.d[0]?(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+Xe,n.rounding=1,t=uy(n,bl(n,t)),n.precision=r,n.rounding=e,Ze(vn==2||vn==3?t.neg():t,r,e,!0)):new n(1):new n(NaN)},Ne.cubeRoot=Ne.cbrt=function(){var r,e,t,n,a,i,o,l,u,s,c=this,f=c.constructor;if(!c.isFinite()||c.isZero())return new f(c);for(ar=!1,i=c.s*Hr(c.s*c,1/3),!i||Math.abs(i)==1/0?(t=tt(c.d),r=c.e,(i=(r-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=Hr(t,1/3),r=st((r+1)/3)-(r%3==(r<0?-1:2)),i==1/0?t="5e"+r:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),n=new f(t),n.s=c.s):n=new f(i.toString()),o=(r=f.precision)+3;;)if(l=n,u=l.times(l).times(l),s=u.plus(c),n=Or(s.plus(c).times(l),s.plus(u),o+2,1),tt(l.d).slice(0,o)===(t=tt(n.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!a&&t=="4999"){if(!a&&(Ze(l,r+1,0),l.times(l).times(l).eq(c))){n=l;break}o+=4,a=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Ze(n,r+1,1),e=!n.times(n).times(n).eq(c));break}return ar=!0,Ze(n,r,f.rounding,e)},Ne.decimalPlaces=Ne.dp=function(){var r,e=this.d,t=NaN;if(e){if(r=e.length-1,t=(r-st(this.e/Xe))*Xe,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t},Ne.dividedBy=Ne.div=function(r){return Or(this,new this.constructor(r))},Ne.dividedToIntegerBy=Ne.divToInt=function(r){var e=this,t=e.constructor;return Ze(Or(e,new t(r),0,1,1),t.precision,t.rounding)},Ne.equals=Ne.eq=function(r){return this.cmp(r)===0},Ne.floor=function(){return Ze(new this.constructor(this),this.e+1,3)},Ne.greaterThan=Ne.gt=function(r){return this.cmp(r)>0},Ne.greaterThanOrEqualTo=Ne.gte=function(r){var e=this.cmp(r);return e==1||e===0},Ne.hyperbolicCosine=Ne.cosh=function(){var r,e,t,n,a,i=this,o=i.constructor,l=new o(1);if(!i.isFinite())return new o(i.s?1/0:NaN);if(i.isZero())return l;t=o.precision,n=o.rounding,o.precision=t+Math.max(i.e,i.sd())+4,o.rounding=1,a=i.d.length,a<32?(r=Math.ceil(a/3),e=(1/Hi(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),i=ya(o,1,i.times(e),new o(1),!0);for(var u,s=r,c=new o(8);s--;)u=i.times(i),i=l.minus(u.times(c.minus(u.times(c))));return Ze(i,o.precision=t,o.rounding=n,!0)},Ne.hyperbolicSine=Ne.sinh=function(){var r,e,t,n,a=this,i=a.constructor;if(!a.isFinite()||a.isZero())return new i(a);if(e=i.precision,t=i.rounding,i.precision=e+Math.max(a.e,a.sd())+4,i.rounding=1,n=a.d.length,n<3)a=ya(i,2,a,a,!0);else{r=1.4*Math.sqrt(n),r=r>16?16:r|0,a=a.times(1/Hi(5,r)),a=ya(i,2,a,a,!0);for(var o,l=new i(5),u=new i(16),s=new i(20);r--;)o=a.times(a),a=a.times(l.plus(o.times(u.times(o).plus(s))))}return i.precision=e,i.rounding=t,Ze(a,e,t,!0)},Ne.hyperbolicTangent=Ne.tanh=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+7,n.rounding=1,Or(t.sinh(),t.cosh(),n.precision=r,n.rounding=e)):new n(t.s)},Ne.inverseCosine=Ne.acos=function(){var r=this,e=r.constructor,t=r.abs().cmp(1),n=e.precision,a=e.rounding;return t!==-1?t===0?r.isNeg()?tn(e,n,a):new e(0):new e(NaN):r.isZero()?tn(e,n+4,a).times(.5):(e.precision=n+6,e.rounding=1,r=new e(1).minus(r).div(r.plus(1)).sqrt().atan(),e.precision=n,e.rounding=a,r.times(2))},Ne.inverseHyperbolicCosine=Ne.acosh=function(){var r,e,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(r=n.precision,e=n.rounding,n.precision=r+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,ar=!1,t=t.times(t).minus(1).sqrt().plus(t),ar=!0,n.precision=r,n.rounding=e,t.ln()):new n(t)},Ne.inverseHyperbolicSine=Ne.asinh=function(){var r,e,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,ar=!1,t=t.times(t).plus(1).sqrt().plus(t),ar=!0,n.precision=r,n.rounding=e,t.ln())},Ne.inverseHyperbolicTangent=Ne.atanh=function(){var r,e,t,n,a=this,i=a.constructor;return a.isFinite()?a.e>=0?new i(a.abs().eq(1)?a.s/0:a.isZero()?a:NaN):(r=i.precision,e=i.rounding,n=a.sd(),Math.max(n,r)<2*-a.e-1?Ze(new i(a),r,e,!0):(i.precision=t=n-a.e,a=Or(a.plus(1),new i(1).minus(a),t+r,1),i.precision=r+4,i.rounding=1,a=a.ln(),i.precision=r,i.rounding=e,a.times(.5))):new i(NaN)},Ne.inverseSine=Ne.asin=function(){var r,e,t,n,a=this,i=a.constructor;return a.isZero()?new i(a):(e=a.abs().cmp(1),t=i.precision,n=i.rounding,e!==-1?e===0?(r=tn(i,t+4,n).times(.5),r.s=a.s,r):new i(NaN):(i.precision=t+6,i.rounding=1,a=a.div(new i(1).minus(a.times(a)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=n,a.times(2)))},Ne.inverseTangent=Ne.atan=function(){var r,e,t,n,a,i,o,l,u,s=this,c=s.constructor,f=c.precision,m=c.rounding;if(s.isFinite()){if(s.isZero())return new c(s);if(s.abs().eq(1)&&f+4<=rs)return o=tn(c,f+4,m).times(.25),o.s=s.s,o}else{if(!s.s)return new c(NaN);if(f+4<=rs)return o=tn(c,f+4,m).times(.5),o.s=s.s,o}for(c.precision=l=f+10,c.rounding=1,t=Math.min(28,l/Xe+2|0),r=t;r;--r)s=s.div(s.times(s).plus(1).sqrt().plus(1));for(ar=!1,e=Math.ceil(l/Xe),n=1,u=s.times(s),o=new c(s),a=s;r!==-1;)if(a=a.times(u),i=o.minus(a.div(n+=2)),a=a.times(u),o=i.plus(a.div(n+=2)),o.d[e]!==void 0)for(r=e;o.d[r]===i.d[r]&&r--;);return t&&(o=o.times(2<<t-1)),ar=!0,Ze(o,c.precision=f,c.rounding=m,!0)},Ne.isFinite=function(){return!!this.d},Ne.isInteger=Ne.isInt=function(){return!!this.d&&st(this.e/Xe)>this.d.length-2},Ne.isNaN=function(){return!this.s},Ne.isNegative=Ne.isNeg=function(){return this.s<0},Ne.isPositive=Ne.isPos=function(){return this.s>0},Ne.isZero=function(){return!!this.d&&this.d[0]===0},Ne.lessThan=Ne.lt=function(r){return this.cmp(r)<0},Ne.lessThanOrEqualTo=Ne.lte=function(r){return this.cmp(r)<1},Ne.logarithm=Ne.log=function(r){var e,t,n,a,i,o,l,u,s=this,c=s.constructor,f=c.precision,m=c.rounding,v=5;if(r==null)r=new c(10),e=!0;else{if(r=new c(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new c(NaN);e=r.eq(10)}if(t=s.d,s.s<0||!t||!t[0]||s.eq(1))return new c(t&&!t[0]?-1/0:s.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)i=!0;else{for(a=t[0];a%10===0;)a/=10;i=a!==1}if(ar=!1,l=f+v,o=Tn(s,l),n=e?Vi(c,l+10):Tn(r,l),u=Or(o,n,l,1),ti(u.d,a=f,m))do if(l+=10,o=Tn(s,l),n=e?Vi(c,l+10):Tn(r,l),u=Or(o,n,l,1),!i){+tt(u.d).slice(a+1,a+15)+1==1e14&&(u=Ze(u,f+1,0));break}while(ti(u.d,a+=10,m));return ar=!0,Ze(u,f,m)},Ne.minus=Ne.sub=function(r){var e,t,n,a,i,o,l,u,s,c,f,m,v=this,p=v.constructor;if(r=new p(r),!v.d||!r.d)return!v.s||!r.s?r=new p(NaN):v.d?r.s=-r.s:r=new p(r.d||v.s!==r.s?v:NaN),r;if(v.s!=r.s)return r.s=-r.s,v.plus(r);if(s=v.d,m=r.d,l=p.precision,u=p.rounding,!s[0]||!m[0]){if(m[0])r.s=-r.s;else if(s[0])r=new p(v);else return new p(u===3?-0:0);return ar?Ze(r,l,u):r}if(t=st(r.e/Xe),c=st(v.e/Xe),s=s.slice(),i=c-t,i){for(f=i<0,f?(e=s,i=-i,o=m.length):(e=m,t=c,o=s.length),n=Math.max(Math.ceil(l/Xe),o)+2,i>n&&(i=n,e.length=1),e.reverse(),n=i;n--;)e.push(0);e.reverse()}else{for(n=s.length,o=m.length,f=n<o,f&&(o=n),n=0;n<o;n++)if(s[n]!=m[n]){f=s[n]<m[n];break}i=0}for(f&&(e=s,s=m,m=e,r.s=-r.s),o=s.length,n=m.length-o;n>0;--n)s[o++]=0;for(n=m.length;n>i;){if(s[--n]<m[n]){for(a=n;a&&s[--a]===0;)s[a]=Ht-1;--s[a],s[n]+=Ht}s[n]-=m[n]}for(;s[--o]===0;)s.pop();for(;s[0]===0;s.shift())--t;return s[0]?(r.d=s,r.e=ki(s,t),ar?Ze(r,l,u):r):new p(u===3?-0:0)},Ne.modulo=Ne.mod=function(r){var e,t=this,n=t.constructor;return r=new n(r),!t.d||!r.s||r.d&&!r.d[0]?new n(NaN):!r.d||t.d&&!t.d[0]?Ze(new n(t),n.precision,n.rounding):(ar=!1,n.modulo==9?(e=Or(t,r.abs(),0,3,1),e.s*=r.s):e=Or(t,r,0,n.modulo,1),e=e.times(r),ar=!0,t.minus(e))},Ne.naturalExponential=Ne.exp=function(){return ts(this)},Ne.naturalLogarithm=Ne.ln=function(){return Tn(this)},Ne.negated=Ne.neg=function(){var r=new this.constructor(this);return r.s=-r.s,Ze(r)},Ne.plus=Ne.add=function(r){var e,t,n,a,i,o,l,u,s,c,f=this,m=f.constructor;if(r=new m(r),!f.d||!r.d)return!f.s||!r.s?r=new m(NaN):f.d||(r=new m(r.d||f.s===r.s?f:NaN)),r;if(f.s!=r.s)return r.s=-r.s,f.minus(r);if(s=f.d,c=r.d,l=m.precision,u=m.rounding,!s[0]||!c[0])return c[0]||(r=new m(f)),ar?Ze(r,l,u):r;if(i=st(f.e/Xe),n=st(r.e/Xe),s=s.slice(),a=i-n,a){for(a<0?(t=s,a=-a,o=c.length):(t=c,n=i,o=s.length),i=Math.ceil(l/Xe),o=i>o?i+1:o+1,a>o&&(a=o,t.length=1),t.reverse();a--;)t.push(0);t.reverse()}for(o=s.length,a=c.length,o-a<0&&(a=o,t=c,c=s,s=t),e=0;a;)e=(s[--a]=s[a]+c[a]+e)/Ht|0,s[a]%=Ht;for(e&&(s.unshift(e),++n),o=s.length;s[--o]==0;)s.pop();return r.d=s,r.e=ki(s,n),ar?Ze(r,l,u):r},Ne.precision=Ne.sd=function(r){var e,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(Mn+r);return t.d?(e=pl(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e},Ne.round=function(){var r=this,e=r.constructor;return Ze(new e(r),r.e+1,e.rounding)},Ne.sine=Ne.sin=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+Xe,n.rounding=1,t=cy(n,bl(n,t)),n.precision=r,n.rounding=e,Ze(vn>2?t.neg():t,r,e,!0)):new n(NaN)},Ne.squareRoot=Ne.sqrt=function(){var r,e,t,n,a,i,o=this,l=o.d,u=o.e,s=o.s,c=o.constructor;if(s!==1||!l||!l[0])return new c(!s||s<0&&(!l||l[0])?NaN:l?o:1/0);for(ar=!1,s=Math.sqrt(+o),s==0||s==1/0?(e=tt(l),(e.length+u)%2==0&&(e+="0"),s=Math.sqrt(e),u=st((u+1)/2)-(u<0||u%2),s==1/0?e="5e"+u:(e=s.toExponential(),e=e.slice(0,e.indexOf("e")+1)+u),n=new c(e)):n=new c(s.toString()),t=(u=c.precision)+3;;)if(i=n,n=i.plus(Or(o,i,t+2,1)).times(.5),tt(i.d).slice(0,t)===(e=tt(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!a&&e=="4999"){if(!a&&(Ze(i,u+1,0),i.times(i).eq(o))){n=i;break}t+=4,a=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(Ze(n,u+1,1),r=!n.times(n).eq(o));break}return ar=!0,Ze(n,u,c.rounding,r)},Ne.tangent=Ne.tan=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+10,n.rounding=1,t=t.sin(),t.s=1,t=Or(t,new n(1).minus(t.times(t)).sqrt(),r+10,0),n.precision=r,n.rounding=e,Ze(vn==2||vn==4?t.neg():t,r,e,!0)):new n(NaN)},Ne.times=Ne.mul=function(r){var e,t,n,a,i,o,l,u,s,c=this,f=c.constructor,m=c.d,v=(r=new f(r)).d;if(r.s*=c.s,!m||!m[0]||!v||!v[0])return new f(!r.s||m&&!m[0]&&!v||v&&!v[0]&&!m?NaN:!m||!v?r.s/0:r.s*0);for(t=st(c.e/Xe)+st(r.e/Xe),u=m.length,s=v.length,u<s&&(i=m,m=v,v=i,o=u,u=s,s=o),i=[],o=u+s,n=o;n--;)i.push(0);for(n=s;--n>=0;){for(e=0,a=u+n;a>n;)l=i[a]+v[n]*m[a-n-1]+e,i[a--]=l%Ht|0,e=l/Ht|0;i[a]=(i[a]+e)%Ht|0}for(;!i[--o];)i.pop();return e?++t:i.shift(),r.d=i,r.e=ki(i,t),ar?Ze(r,f.precision,f.rounding):r},Ne.toBinary=function(r,e){return ns(this,2,r,e)},Ne.toDecimalPlaces=Ne.toDP=function(r,e){var t=this,n=t.constructor;return t=new n(t),r===void 0?t:(Dt(r,0,Cn),e===void 0?e=n.rounding:Dt(e,0,8),Ze(t,r+t.e+1,e))},Ne.toExponential=function(r,e){var t,n=this,a=n.constructor;return r===void 0?t=rn(n,!0):(Dt(r,0,Cn),e===void 0?e=a.rounding:Dt(e,0,8),n=Ze(new a(n),r+1,e),t=rn(n,!0,r+1)),n.isNeg()&&!n.isZero()?"-"+t:t},Ne.toFixed=function(r,e){var t,n,a=this,i=a.constructor;return r===void 0?t=rn(a):(Dt(r,0,Cn),e===void 0?e=i.rounding:Dt(e,0,8),n=Ze(new i(a),r+a.e+1,e),t=rn(n,!1,r+n.e+1)),a.isNeg()&&!a.isZero()?"-"+t:t},Ne.toFraction=function(r){var e,t,n,a,i,o,l,u,s,c,f,m,v=this,p=v.d,d=v.constructor;if(!p)return new d(v);if(s=t=new d(1),n=u=new d(0),e=new d(n),i=e.e=pl(p)-v.e-1,o=i%Xe,e.d[0]=Hr(10,o<0?Xe+o:o),r==null)r=i>0?e:s;else{if(l=new d(r),!l.isInt()||l.lt(s))throw Error(Mn+l);r=l.gt(e)?i>0?e:s:l}for(ar=!1,l=new d(tt(p)),c=d.precision,d.precision=i=p.length*Xe*2;f=Or(l,e,0,1,1),a=t.plus(f.times(n)),a.cmp(r)!=1;)t=n,n=a,a=s,s=u.plus(f.times(a)),u=a,a=e,e=l.minus(f.times(a)),l=a;return a=Or(r.minus(t),n,0,1,1),u=u.plus(a.times(s)),t=t.plus(a.times(n)),u.s=s.s=v.s,m=Or(s,n,i,1).minus(v).abs().cmp(Or(u,t,i,1).minus(v).abs())<1?[s,n]:[u,t],d.precision=c,ar=!0,m},Ne.toHexadecimal=Ne.toHex=function(r,e){return ns(this,16,r,e)},Ne.toNearest=function(r,e){var t=this,n=t.constructor;if(t=new n(t),r==null){if(!t.d)return t;r=new n(1),e=n.rounding}else{if(r=new n(r),e===void 0?e=n.rounding:Dt(e,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(ar=!1,t=Or(t,r,0,e,1).times(r),ar=!0,Ze(t)):(r.s=t.s,t=r),t},Ne.toNumber=function(){return+this},Ne.toOctal=function(r,e){return ns(this,8,r,e)},Ne.toPower=Ne.pow=function(r){var e,t,n,a,i,o,l=this,u=l.constructor,s=+(r=new u(r));if(!l.d||!r.d||!l.d[0]||!r.d[0])return new u(Hr(+l,s));if(l=new u(l),l.eq(1))return l;if(n=u.precision,i=u.rounding,r.eq(1))return Ze(l,n,i);if(e=st(r.e/Xe),e>=r.d.length-1&&(t=s<0?-s:s)<=oy)return a=dl(u,l,t,n),r.s<0?new u(1).div(a):Ze(a,n,i);if(o=l.s,o<0){if(e<r.d.length-1)return new u(NaN);if(r.d[e]&1||(o=1),l.e==0&&l.d[0]==1&&l.d.length==1)return l.s=o,l}return t=Hr(+l,s),e=t==0||!isFinite(t)?st(s*(Math.log("0."+tt(l.d))/Math.LN10+l.e+1)):new u(t+"").e,e>u.maxE+1||e<u.minE-1?new u(e>0?o/0:0):(ar=!1,u.rounding=l.s=1,t=Math.min(12,(e+"").length),a=ts(r.times(Tn(l,n+t)),n),a.d&&(a=Ze(a,n+5,1),ti(a.d,n,i)&&(e=n+10,a=Ze(ts(r.times(Tn(l,e+t)),e),e+5,1),+tt(a.d).slice(n+1,n+15)+1==1e14&&(a=Ze(a,n+1,0)))),a.s=o,ar=!0,u.rounding=i,Ze(a,n,i))},Ne.toPrecision=function(r,e){var t,n=this,a=n.constructor;return r===void 0?t=rn(n,n.e<=a.toExpNeg||n.e>=a.toExpPos):(Dt(r,1,Cn),e===void 0?e=a.rounding:Dt(e,0,8),n=Ze(new a(n),r,e),t=rn(n,r<=n.e||n.e<=a.toExpNeg,r)),n.isNeg()&&!n.isZero()?"-"+t:t},Ne.toSignificantDigits=Ne.toSD=function(r,e){var t=this,n=t.constructor;return r===void 0?(r=n.precision,e=n.rounding):(Dt(r,1,Cn),e===void 0?e=n.rounding:Dt(e,0,8)),Ze(new n(t),r,e)},Ne.toString=function(){var r=this,e=r.constructor,t=rn(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t},Ne.truncated=Ne.trunc=function(){return Ze(new this.constructor(this),this.e+1,1)},Ne.valueOf=Ne.toJSON=function(){var r=this,e=r.constructor,t=rn(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function tt(r){var e,t,n,a=r.length-1,i="",o=r[0];if(a>0){for(i+=o,e=1;e<a;e++)n=r[e]+"",t=Xe-n.length,t&&(i+=_n(t)),i+=n;o=r[e],n=o+"",t=Xe-n.length,t&&(i+=_n(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return i+o}function Dt(r,e,t){if(r!==~~r||r<e||r>t)throw Error(Mn+r)}function ti(r,e,t,n){var a,i,o,l;for(i=r[0];i>=10;i/=10)--e;return--e<0?(e+=Xe,a=0):(a=Math.ceil((e+1)/Xe),e%=Xe),i=Hr(10,Xe-e),l=r[a]%i|0,n==null?e<3?(e==0?l=l/100|0:e==1&&(l=l/10|0),o=t<4&&l==99999||t>3&&l==49999||l==5e4||l==0):o=(t<4&&l+1==i||t>3&&l+1==i/2)&&(r[a+1]/i/100|0)==Hr(10,e-2)-1||(l==i/2||l==0)&&(r[a+1]/i/100|0)==0:e<4?(e==0?l=l/1e3|0:e==1?l=l/100|0:e==2&&(l=l/10|0),o=(n||t<4)&&l==9999||!n&&t>3&&l==4999):o=((n||t<4)&&l+1==i||!n&&t>3&&l+1==i/2)&&(r[a+1]/i/1e3|0)==Hr(10,e-3)-1,o}function Li(r,e,t){for(var n,a=[0],i,o=0,l=r.length;o<l;){for(i=a.length;i--;)a[i]*=e;for(a[0]+=Ko.indexOf(r.charAt(o++)),n=0;n<a.length;n++)a[n]>t-1&&(a[n+1]===void 0&&(a[n+1]=0),a[n+1]+=a[n]/t|0,a[n]%=t)}return a.reverse()}function uy(r,e){var t,n,a;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),a=(1/Hi(4,t)).toString()):(t=16,a="2.3283064365386962890625e-10"),r.precision+=t,e=ya(r,1,e.times(a),new r(1));for(var i=t;i--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return r.precision-=t,e}var Or=function(){function r(n,a,i){var o,l=0,u=n.length;for(n=n.slice();u--;)o=n[u]*a+l,n[u]=o%i|0,l=o/i|0;return l&&n.unshift(l),n}function e(n,a,i,o){var l,u;if(i!=o)u=i>o?1:-1;else for(l=u=0;l<i;l++)if(n[l]!=a[l]){u=n[l]>a[l]?1:-1;break}return u}function t(n,a,i,o){for(var l=0;i--;)n[i]-=l,l=n[i]<a[i]?1:0,n[i]=l*o+n[i]-a[i];for(;!n[0]&&n.length>1;)n.shift()}return function(n,a,i,o,l,u){var s,c,f,m,v,p,d,y,x,D,h,w,g,b,A,N,E,S,C,M,O=n.constructor,I=n.s==a.s?1:-1,k=n.d,_=a.d;if(!k||!k[0]||!_||!_[0])return new O(!n.s||!a.s||(k?_&&k[0]==_[0]:!_)?NaN:k&&k[0]==0||!_?I*0:I/0);for(u?(v=1,c=n.e-a.e):(u=Ht,v=Xe,c=st(n.e/v)-st(a.e/v)),C=_.length,E=k.length,x=new O(I),D=x.d=[],f=0;_[f]==(k[f]||0);f++);if(_[f]>(k[f]||0)&&c--,i==null?(b=i=O.precision,o=O.rounding):l?b=i+(n.e-a.e)+1:b=i,b<0)D.push(1),p=!0;else{if(b=b/v+2|0,f=0,C==1){for(m=0,_=_[0],b++;(f<E||m)&&b--;f++)A=m*u+(k[f]||0),D[f]=A/_|0,m=A%_|0;p=m||f<E}else{for(m=u/(_[0]+1)|0,m>1&&(_=r(_,m,u),k=r(k,m,u),C=_.length,E=k.length),N=C,h=k.slice(0,C),w=h.length;w<C;)h[w++]=0;M=_.slice(),M.unshift(0),S=_[0],_[1]>=u/2&&++S;do m=0,s=e(_,h,C,w),s<0?(g=h[0],C!=w&&(g=g*u+(h[1]||0)),m=g/S|0,m>1?(m>=u&&(m=u-1),d=r(_,m,u),y=d.length,w=h.length,s=e(d,h,y,w),s==1&&(m--,t(d,C<y?M:_,y,u))):(m==0&&(s=m=1),d=_.slice()),y=d.length,y<w&&d.unshift(0),t(h,d,w,u),s==-1&&(w=h.length,s=e(_,h,C,w),s<1&&(m++,t(h,C<w?M:_,w,u))),w=h.length):s===0&&(m++,h=[0]),D[f++]=m,s&&h[0]?h[w++]=k[N]||0:(h=[k[N]],w=1);while((N++<E||h[0]!==void 0)&&b--);p=h[0]!==void 0}D[0]||D.shift()}if(v==1)x.e=c,ll=p;else{for(f=1,m=D[0];m>=10;m/=10)f++;x.e=f+c*v-1,Ze(x,l?i+x.e+1:i,o,p)}return x}}();function Ze(r,e,t,n){var a,i,o,l,u,s,c,f,m,v=r.constructor;e:if(e!=null){if(f=r.d,!f)return r;for(a=1,l=f[0];l>=10;l/=10)a++;if(i=e-a,i<0)i+=Xe,o=e,c=f[m=0],u=c/Hr(10,a-o-1)%10|0;else if(m=Math.ceil((i+1)/Xe),l=f.length,m>=l)if(n){for(;l++<=m;)f.push(0);c=u=0,a=1,i%=Xe,o=i-Xe+1}else break e;else{for(c=l=f[m],a=1;l>=10;l/=10)a++;i%=Xe,o=i-Xe+a,u=o<0?0:c/Hr(10,a-o-1)%10|0}if(n=n||e<0||f[m+1]!==void 0||(o<0?c:c%Hr(10,a-o-1)),s=t<4?(u||n)&&(t==0||t==(r.s<0?3:2)):u>5||u==5&&(t==4||n||t==6&&(i>0?o>0?c/Hr(10,a-o):0:f[m-1])%10&1||t==(r.s<0?8:7)),e<1||!f[0])return f.length=0,s?(e-=r.e+1,f[0]=Hr(10,(Xe-e%Xe)%Xe),r.e=-e||0):f[0]=r.e=0,r;if(i==0?(f.length=m,l=1,m--):(f.length=m+1,l=Hr(10,Xe-i),f[m]=o>0?(c/Hr(10,a-o)%Hr(10,o)|0)*l:0),s)for(;;)if(m==0){for(i=1,o=f[0];o>=10;o/=10)i++;for(o=f[0]+=l,l=1;o>=10;o/=10)l++;i!=l&&(r.e++,f[0]==Ht&&(f[0]=1));break}else{if(f[m]+=l,f[m]!=Ht)break;f[m--]=0,l=1}for(i=f.length;f[--i]===0;)f.pop()}return ar&&(r.e>v.maxE?(r.d=null,r.e=NaN):r.e<v.minE&&(r.e=0,r.d=[0])),r}function rn(r,e,t){if(!r.isFinite())return yl(r);var n,a=r.e,i=tt(r.d),o=i.length;return e?(t&&(n=t-o)>0?i=i.charAt(0)+"."+i.slice(1)+_n(n):o>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(r.e<0?"e":"e+")+r.e):a<0?(i="0."+_n(-a-1)+i,t&&(n=t-o)>0&&(i+=_n(n))):a>=o?(i+=_n(a+1-o),t&&(n=t-a-1)>0&&(i=i+"."+_n(n))):((n=a+1)<o&&(i=i.slice(0,n)+"."+i.slice(n)),t&&(n=t-o)>0&&(a+1===o&&(i+="."),i+=_n(n))),i}function ki(r,e){var t=r[0];for(e*=Xe;t>=10;t/=10)e++;return e}function Vi(r,e,t){if(e>sy)throw ar=!0,t&&(r.precision=t),Error(cl);return Ze(new r(qi),e,1,!0)}function tn(r,e,t){if(e>rs)throw Error(cl);return Ze(new r(zi),e,t,!0)}function pl(r){var e=r.length-1,t=e*Xe+1;if(e=r[e],e){for(;e%10==0;e/=10)t--;for(e=r[0];e>=10;e/=10)t++}return t}function _n(r){for(var e="";r--;)e+="0";return e}function dl(r,e,t,n){var a,i=new r(1),o=Math.ceil(n/Xe+4);for(ar=!1;;){if(t%2&&(i=i.times(e),xl(i.d,o)&&(a=!0)),t=st(t/2),t===0){t=i.d.length-1,a&&i.d[t]===0&&++i.d[t];break}e=e.times(e),xl(e.d,o)}return ar=!0,i}function hl(r){return r.d[r.d.length-1]&1}function gl(r,e,t){for(var n,a,i=new r(e[0]),o=0;++o<e.length;){if(a=new r(e[o]),!a.s){i=a;break}n=i.cmp(a),(n===t||n===0&&i.s===t)&&(i=a)}return i}function ts(r,e){var t,n,a,i,o,l,u,s=0,c=0,f=0,m=r.constructor,v=m.rounding,p=m.precision;if(!r.d||!r.d[0]||r.e>17)return new m(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:NaN);for(e==null?(ar=!1,u=p):u=e,l=new m(.03125);r.e>-2;)r=r.times(l),f+=5;for(n=Math.log(Hr(2,f))/Math.LN10*2+5|0,u+=n,t=i=o=new m(1),m.precision=u;;){if(i=Ze(i.times(r),u,1),t=t.times(++c),l=o.plus(Or(i,t,u,1)),tt(l.d).slice(0,u)===tt(o.d).slice(0,u)){for(a=f;a--;)o=Ze(o.times(o),u,1);if(e==null)if(s<3&&ti(o.d,u-n,v,s))m.precision=u+=10,t=i=l=new m(1),c=0,s++;else return Ze(o,m.precision=p,v,ar=!0);else return m.precision=p,o}o=l}}function Tn(r,e){var t,n,a,i,o,l,u,s,c,f,m,v=1,p=10,d=r,y=d.d,x=d.constructor,D=x.rounding,h=x.precision;if(d.s<0||!y||!y[0]||!d.e&&y[0]==1&&y.length==1)return new x(y&&!y[0]?-1/0:d.s!=1?NaN:y?0:d);if(e==null?(ar=!1,c=h):c=e,x.precision=c+=p,t=tt(y),n=t.charAt(0),Math.abs(i=d.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)d=d.times(r),t=tt(d.d),n=t.charAt(0),v++;i=d.e,n>1?(d=new x("0."+t),i++):d=new x(n+"."+t.slice(1))}else return s=Vi(x,c+2,h).times(i+""),d=Tn(new x(n+"."+t.slice(1)),c-p).plus(s),x.precision=h,e==null?Ze(d,h,D,ar=!0):d;for(f=d,u=o=d=Or(d.minus(1),d.plus(1),c,1),m=Ze(d.times(d),c,1),a=3;;){if(o=Ze(o.times(m),c,1),s=u.plus(Or(o,new x(a),c,1)),tt(s.d).slice(0,c)===tt(u.d).slice(0,c))if(u=u.times(2),i!==0&&(u=u.plus(Vi(x,c+2,h).times(i+""))),u=Or(u,new x(v),c,1),e==null)if(ti(u.d,c-p,D,l))x.precision=c+=p,s=o=d=Or(f.minus(1),f.plus(1),c,1),m=Ze(d.times(d),c,1),a=l=1;else return Ze(u,x.precision=h,D,ar=!0);else return x.precision=h,u;u=s,a+=2}}function yl(r){return String(r.s*r.s/0)}function Gi(r,e){var t,n,a;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(t<0&&(t=n),t+=+e.slice(n+1),e=e.substring(0,n)):t<0&&(t=e.length),n=0;e.charCodeAt(n)===48;n++);for(a=e.length;e.charCodeAt(a-1)===48;--a);if(e=e.slice(n,a),e){if(a-=n,r.e=t=t-n-1,r.d=[],n=(t+1)%Xe,t<0&&(n+=Xe),n<a){for(n&&r.d.push(+e.slice(0,n)),a-=Xe;n<a;)r.d.push(+e.slice(n,n+=Xe));e=e.slice(n),n=Xe-e.length}else n-=a;for(;n--;)e+="0";r.d.push(+e),ar&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}function ly(r,e){var t,n,a,i,o,l,u,s,c;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),vl.test(e))return Gi(r,e)}else if(e==="Infinity"||e==="NaN")return+e||(r.s=NaN),r.e=NaN,r.d=null,r;if(ay.test(e))t=16,e=e.toLowerCase();else if(ny.test(e))t=2;else if(iy.test(e))t=8;else throw Error(Mn+e);for(i=e.search(/p/i),i>0?(u=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),o=i>=0,n=r.constructor,o&&(e=e.replace(".",""),l=e.length,i=l-i,a=dl(n,new n(t),i,i*2)),s=Li(e,t,Ht),c=s.length-1,i=c;s[i]===0;--i)s.pop();return i<0?new n(r.s*0):(r.e=ki(s,c),r.d=s,ar=!1,o&&(r=Or(r,a,l*4)),u&&(r=r.times(Math.abs(u)<54?Hr(2,u):Fn.pow(2,u))),ar=!0,r)}function cy(r,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:ya(r,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/Hi(5,t)),e=ya(r,2,e,e);for(var a,i=new r(5),o=new r(16),l=new r(20);t--;)a=e.times(e),e=e.times(i.plus(a.times(o.times(a).minus(l))));return e}function ya(r,e,t,n,a){var i,o,l,u,s=r.precision,c=Math.ceil(s/Xe);for(ar=!1,u=t.times(t),l=new r(n);;){if(o=Or(l.times(u),new r(e++*e++),s,1),l=a?n.plus(o):n.minus(o),n=Or(o.times(u),new r(e++*e++),s,1),o=l.plus(n),o.d[c]!==void 0){for(i=c;o.d[i]===l.d[i]&&i--;);if(i==-1)break}i=l,l=n,n=o,o=i}return ar=!0,o.d.length=c+1,o}function Hi(r,e){for(var t=r;--e;)t*=r;return t}function bl(r,e){var t,n=e.s<0,a=tn(r,r.precision,1),i=a.times(.5);if(e=e.abs(),e.lte(i))return vn=n?4:1,e;if(t=e.divToInt(a),t.isZero())vn=n?3:2;else{if(e=e.minus(t.times(a)),e.lte(i))return vn=hl(t)?n?2:3:n?4:1,e;vn=hl(t)?n?1:4:n?3:2}return e.minus(a).abs()}function ns(r,e,t,n){var a,i,o,l,u,s,c,f,m,v=r.constructor,p=t!==void 0;if(p?(Dt(t,1,Cn),n===void 0?n=v.rounding:Dt(n,0,8)):(t=v.precision,n=v.rounding),!r.isFinite())c=yl(r);else{for(c=rn(r),o=c.indexOf("."),p?(a=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):a=e,o>=0&&(c=c.replace(".",""),m=new v(1),m.e=c.length-o,m.d=Li(rn(m),10,a),m.e=m.d.length),f=Li(c,10,a),i=u=f.length;f[--u]==0;)f.pop();if(!f[0])c=p?"0p+0":"0";else{if(o<0?i--:(r=new v(r),r.d=f,r.e=i,r=Or(r,m,t,n,0,a),f=r.d,i=r.e,s=ll),o=f[t],l=a/2,s=s||f[t+1]!==void 0,s=n<4?(o!==void 0||s)&&(n===0||n===(r.s<0?3:2)):o>l||o===l&&(n===4||s||n===6&&f[t-1]&1||n===(r.s<0?8:7)),f.length=t,s)for(;++f[--t]>a-1;)f[t]=0,t||(++i,f.unshift(1));for(u=f.length;!f[u-1];--u);for(o=0,c="";o<u;o++)c+=Ko.charAt(f[o]);if(p){if(u>1)if(e==16||e==8){for(o=e==16?4:3,--u;u%o;u++)c+="0";for(f=Li(c,a,e),u=f.length;!f[u-1];--u);for(o=1,c="1.";o<u;o++)c+=Ko.charAt(f[o])}else c=c.charAt(0)+"."+c.slice(1);c=c+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)c="0"+c;c="0."+c}else if(++i>u)for(i-=u;i--;)c+="0";else i<u&&(c=c.slice(0,i)+"."+c.slice(i))}c=(e==16?"0x":e==2?"0b":e==8?"0o":"")+c}return r.s<0?"-"+c:c}function xl(r,e){if(r.length>e)return r.length=e,!0}function fy(r){return new this(r).abs()}function my(r){return new this(r).acos()}function vy(r){return new this(r).acosh()}function py(r,e){return new this(r).plus(e)}function dy(r){return new this(r).asin()}function hy(r){return new this(r).asinh()}function gy(r){return new this(r).atan()}function yy(r){return new this(r).atanh()}function by(r,e){r=new this(r),e=new this(e);var t,n=this.precision,a=this.rounding,i=n+4;return!r.s||!e.s?t=new this(NaN):!r.d&&!e.d?(t=tn(this,i,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?tn(this,n,a):new this(0),t.s=r.s):!r.d||e.isZero()?(t=tn(this,i,1).times(.5),t.s=r.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(Or(r,e,i,1)),e=tn(this,i,1),this.precision=n,this.rounding=a,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(Or(r,e,i,1)),t}function xy(r){return new this(r).cbrt()}function wy(r){return Ze(r=new this(r),r.e+1,2)}function Dy(r,e,t){return new this(r).clamp(e,t)}function Ny(r){if(!r||typeof r!="object")throw Error(Ui+"Object expected");var e,t,n,a=r.defaults===!0,i=["precision",1,Cn,"rounding",0,8,"toExpNeg",-ga,0,"toExpPos",0,ga,"maxE",0,ga,"minE",-ga,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],a&&(this[t]=es[t]),(n=r[t])!==void 0)if(st(n)===n&&n>=i[e+1]&&n<=i[e+2])this[t]=n;else throw Error(Mn+t+": "+n);if(t="crypto",a&&(this[t]=es[t]),(n=r[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(fl);else this[t]=!1;else throw Error(Mn+t+": "+n);return this}function Ey(r){return new this(r).cos()}function Ay(r){return new this(r).cosh()}function wl(r){var e,t,n;function a(i){var o,l,u,s=this;if(!(s instanceof a))return new a(i);if(s.constructor=a,Dl(i)){s.s=i.s,ar?!i.d||i.e>a.maxE?(s.e=NaN,s.d=null):i.e<a.minE?(s.e=0,s.d=[0]):(s.e=i.e,s.d=i.d.slice()):(s.e=i.e,s.d=i.d?i.d.slice():i.d);return}if(u=typeof i,u==="number"){if(i===0){s.s=1/i<0?-1:1,s.e=0,s.d=[0];return}if(i<0?(i=-i,s.s=-1):s.s=1,i===~~i&&i<1e7){for(o=0,l=i;l>=10;l/=10)o++;ar?o>a.maxE?(s.e=NaN,s.d=null):o<a.minE?(s.e=0,s.d=[0]):(s.e=o,s.d=[i]):(s.e=o,s.d=[i]);return}if(i*0!==0){i||(s.s=NaN),s.e=NaN,s.d=null;return}return Gi(s,i.toString())}if(u==="string")return(l=i.charCodeAt(0))===45?(i=i.slice(1),s.s=-1):(l===43&&(i=i.slice(1)),s.s=1),vl.test(i)?Gi(s,i):ly(s,i);if(u==="bigint")return i<0?(i=-i,s.s=-1):s.s=1,Gi(s,i.toString());throw Error(Mn+i)}if(a.prototype=Ne,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=Ny,a.clone=wl,a.isDecimal=Dl,a.abs=fy,a.acos=my,a.acosh=vy,a.add=py,a.asin=dy,a.asinh=hy,a.atan=gy,a.atanh=yy,a.atan2=by,a.cbrt=xy,a.ceil=wy,a.clamp=Dy,a.cos=Ey,a.cosh=Ay,a.div=Sy,a.exp=Cy,a.floor=My,a.hypot=_y,a.ln=Ty,a.log=Fy,a.log10=By,a.log2=Oy,a.max=Ry,a.min=Iy,a.mod=Py,a.mul=$y,a.pow=qy,a.random=zy,a.round=Uy,a.sign=Ly,a.sin=ky,a.sinh=Vy,a.sqrt=Gy,a.sub=Hy,a.sum=Wy,a.tan=Yy,a.tanh=Zy,a.trunc=Jy,r===void 0&&(r={}),r&&r.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)r.hasOwnProperty(t=n[e++])||(r[t]=this[t]);return a.config(r),a}function Sy(r,e){return new this(r).div(e)}function Cy(r){return new this(r).exp()}function My(r){return Ze(r=new this(r),r.e+1,3)}function _y(){var r,e,t=new this(0);for(ar=!1,r=0;r<arguments.length;)if(e=new this(arguments[r++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return ar=!0,new this(1/0);t=e}return ar=!0,t.sqrt()}function Dl(r){return r instanceof Fn||r&&r.toStringTag===ml||!1}function Ty(r){return new this(r).ln()}function Fy(r,e){return new this(r).log(e)}function Oy(r){return new this(r).log(2)}function By(r){return new this(r).log(10)}function Ry(){return gl(this,arguments,-1)}function Iy(){return gl(this,arguments,1)}function Py(r,e){return new this(r).mod(e)}function $y(r,e){return new this(r).mul(e)}function qy(r,e){return new this(r).pow(e)}function zy(r){var e,t,n,a,i=0,o=new this(1),l=[];if(r===void 0?r=this.precision:Dt(r,1,Cn),n=Math.ceil(r/Xe),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));i<n;)a=e[i],a>=429e7?e[i]=crypto.getRandomValues(new Uint32Array(1))[0]:l[i++]=a%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);i<n;)a=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+((e[i+3]&127)<<24),a>=214e7?crypto.randomBytes(4).copy(e,i):(l.push(a%1e7),i+=4);i=n/4}else throw Error(fl);else for(;i<n;)l[i++]=Math.random()*1e7|0;for(n=l[--i],r%=Xe,n&&r&&(a=Hr(10,Xe-r),l[i]=(n/a|0)*a);l[i]===0;i--)l.pop();if(i<0)t=0,l=[0];else{for(t=-1;l[0]===0;t-=Xe)l.shift();for(n=1,a=l[0];a>=10;a/=10)n++;n<Xe&&(t-=Xe-n)}return o.e=t,o.d=l,o}function Uy(r){return Ze(r=new this(r),r.e+1,this.rounding)}function Ly(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function ky(r){return new this(r).sin()}function Vy(r){return new this(r).sinh()}function Gy(r){return new this(r).sqrt()}function Hy(r,e){return new this(r).sub(e)}function Wy(){var r=0,e=arguments,t=new this(e[r]);for(ar=!1;t.s&&++r<e.length;)t=t.plus(e[r]);return ar=!0,Ze(t,this.precision,this.rounding)}function Yy(r){return new this(r).tan()}function Zy(r){return new this(r).tanh()}function Jy(r){return Ze(r=new this(r),r.e+1,1)}Ne[Symbol.for("nodejs.util.inspect.custom")]=Ne.toString,Ne[Symbol.toStringTag]="Decimal";var Fn=Ne.constructor=wl(es);qi=new Fn(qi),zi=new Fn(zi);var jy="BigNumber",Xy=["?on","config"],Qy=L(jy,Xy,r=>{var{on:e,config:t}=r,n=Fn.clone({precision:t.precision,modulo:Fn.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.toString()}},n.fromJSON=function(a){return new n(a.value)},e&&e("config",function(a,i){a.precision!==i.precision&&n.config({precision:a.precision})}),n},{isClass:!0});const ut=Math.cosh||function(r){return Math.abs(r)<1e-9?1-r:(Math.exp(r)+Math.exp(-r))*.5},Pt=Math.sinh||function(r){return Math.abs(r)<1e-9?r:(Math.exp(r)-Math.exp(-r))*.5},Ky=r=>{const e=Math.sin(.5*r);return-2*e*e},as=function(r,e){return r=Math.abs(r),e=Math.abs(e),r<e&&([r,e]=[e,r]),r<1e8?Math.sqrt(r*r+e*e):(e/=r,r*Math.sqrt(1+e*e))},ba=function(){throw SyntaxError("Invalid Param")};function is(r,e){const t=Math.abs(r),n=Math.abs(e);return r===0?Math.log(n):e===0?Math.log(t):t<3e3&&n<3e3?Math.log(r*r+e*e)*.5:(r=r*.5,e=e*.5,.5*Math.log(r*r+e*e)+Math.LN2)}const e1={re:0,im:0},Jn=function(r,e){const t=e1;if(r==null)t.re=t.im=0;else if(e!==void 0)t.re=r,t.im=e;else switch(typeof r){case"object":if("im"in r&&"re"in r)t.re=r.re,t.im=r.im;else if("abs"in r&&"arg"in r){if(!isFinite(r.abs)&&isFinite(r.arg))return he.INFINITY;t.re=r.abs*Math.cos(r.arg),t.im=r.abs*Math.sin(r.arg)}else if("r"in r&&"phi"in r){if(!isFinite(r.r)&&isFinite(r.phi))return he.INFINITY;t.re=r.r*Math.cos(r.phi),t.im=r.r*Math.sin(r.phi)}else r.length===2?(t.re=r[0],t.im=r[1]):ba();break;case"string":t.im=t.re=0;const n=r.replace(/_/g,"").match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g);let a=1,i=0;n===null&&ba();for(let o=0;o<n.length;o++){const l=n[o];l===" "||l===" "||l===`
|
|
16
|
+
`||(l==="+"?a++:l==="-"?i++:l==="i"||l==="I"?(a+i===0&&ba(),n[o+1]!==" "&&!isNaN(n[o+1])?(t.im+=parseFloat((i%2?"-":"")+n[o+1]),o++):t.im+=parseFloat((i%2?"-":"")+"1"),a=i=0):((a+i===0||isNaN(l))&&ba(),n[o+1]==="i"||n[o+1]==="I"?(t.im+=parseFloat((i%2?"-":"")+l),o++):t.re+=parseFloat((i%2?"-":"")+l),a=i=0))}a+i>0&&ba();break;case"number":t.im=0,t.re=r;break;default:ba()}return isNaN(t.re)||isNaN(t.im),t};function he(r,e){if(!(this instanceof he))return new he(r,e);const t=Jn(r,e);this.re=t.re,this.im=t.im}he.prototype={re:0,im:0,sign:function(){const r=as(this.re,this.im);return new he(this.re/r,this.im/r)},add:function(r,e){const t=Jn(r,e),n=this.isInfinite(),a=!(isFinite(t.re)&&isFinite(t.im));return n||a?n&&a?he.NAN:he.INFINITY:new he(this.re+t.re,this.im+t.im)},sub:function(r,e){const t=Jn(r,e),n=this.isInfinite(),a=!(isFinite(t.re)&&isFinite(t.im));return n||a?n&&a?he.NAN:he.INFINITY:new he(this.re-t.re,this.im-t.im)},mul:function(r,e){const t=Jn(r,e),n=this.isInfinite(),a=!(isFinite(t.re)&&isFinite(t.im)),i=this.re===0&&this.im===0,o=t.re===0&&t.im===0;return n&&o||a&&i?he.NAN:n||a?he.INFINITY:t.im===0&&this.im===0?new he(this.re*t.re,0):new he(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)},div:function(r,e){const t=Jn(r,e),n=this.isInfinite(),a=!(isFinite(t.re)&&isFinite(t.im)),i=this.re===0&&this.im===0,o=t.re===0&&t.im===0;if(i&&o||n&&a)return he.NAN;if(o||n)return he.INFINITY;if(i||a)return he.ZERO;if(t.im===0)return new he(this.re/t.re,this.im/t.re);if(Math.abs(t.re)<Math.abs(t.im)){const l=t.re/t.im,u=t.re*l+t.im;return new he((this.re*l+this.im)/u,(this.im*l-this.re)/u)}else{const l=t.im/t.re,u=t.im*l+t.re;return new he((this.re+this.im*l)/u,(this.im-this.re*l)/u)}},pow:function(r,e){const t=Jn(r,e),n=this.re===0&&this.im===0;if(t.re===0&&t.im===0)return he.ONE;if(t.im===0){if(this.im===0&&this.re>0)return new he(Math.pow(this.re,t.re),0);if(this.re===0)switch((t.re%4+4)%4){case 0:return new he(Math.pow(this.im,t.re),0);case 1:return new he(0,Math.pow(this.im,t.re));case 2:return new he(-Math.pow(this.im,t.re),0);case 3:return new he(0,-Math.pow(this.im,t.re))}}if(n&&t.re>0)return he.ZERO;const i=Math.atan2(this.im,this.re),o=is(this.re,this.im);let l=Math.exp(t.re*o-t.im*i),u=t.im*o+t.re*i;return new he(l*Math.cos(u),l*Math.sin(u))},sqrt:function(){const r=this.re,e=this.im;if(e===0)return r>=0?new he(Math.sqrt(r),0):new he(0,Math.sqrt(-r));const t=as(r,e);let n=Math.sqrt(.5*(t+Math.abs(r))),a=Math.abs(e)/(2*n);return r>=0?new he(n,e<0?-a:a):new he(a,e<0?-n:n)},exp:function(){const r=Math.exp(this.re);return this.im===0?new he(r,0):new he(r*Math.cos(this.im),r*Math.sin(this.im))},expm1:function(){const r=this.re,e=this.im;return new he(Math.expm1(r)*Math.cos(e)+Ky(e),Math.exp(r)*Math.sin(e))},log:function(){const r=this.re,e=this.im;return e===0&&r>0?new he(Math.log(r),0):new he(is(r,e),Math.atan2(e,r))},abs:function(){return as(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){const r=this.re,e=this.im;return new he(Math.sin(r)*ut(e),Math.cos(r)*Pt(e))},cos:function(){const r=this.re,e=this.im;return new he(Math.cos(r)*ut(e),-Math.sin(r)*Pt(e))},tan:function(){const r=2*this.re,e=2*this.im,t=Math.cos(r)+ut(e);return new he(Math.sin(r)/t,Pt(e)/t)},cot:function(){const r=2*this.re,e=2*this.im,t=Math.cos(r)-ut(e);return new he(-Math.sin(r)/t,Pt(e)/t)},sec:function(){const r=this.re,e=this.im,t=.5*ut(2*e)+.5*Math.cos(2*r);return new he(Math.cos(r)*ut(e)/t,Math.sin(r)*Pt(e)/t)},csc:function(){const r=this.re,e=this.im,t=.5*ut(2*e)-.5*Math.cos(2*r);return new he(Math.sin(r)*ut(e)/t,-Math.cos(r)*Pt(e)/t)},asin:function(){const r=this.re,e=this.im,t=new he(e*e-r*r+1,-2*r*e).sqrt(),n=new he(t.re-e,t.im+r).log();return new he(n.im,-n.re)},acos:function(){const r=this.re,e=this.im,t=new he(e*e-r*r+1,-2*r*e).sqrt(),n=new he(t.re-e,t.im+r).log();return new he(Math.PI/2-n.im,n.re)},atan:function(){const r=this.re,e=this.im;if(r===0){if(e===1)return new he(0,1/0);if(e===-1)return new he(0,-1/0)}const t=r*r+(1-e)*(1-e),n=new he((1-e*e-r*r)/t,-2*r/t).log();return new he(-.5*n.im,.5*n.re)},acot:function(){const r=this.re,e=this.im;if(e===0)return new he(Math.atan2(1,r),0);const t=r*r+e*e;return t!==0?new he(r/t,-e/t).atan():new he(r!==0?r/0:0,e!==0?-e/0:0).atan()},asec:function(){const r=this.re,e=this.im;if(r===0&&e===0)return new he(0,1/0);const t=r*r+e*e;return t!==0?new he(r/t,-e/t).acos():new he(r!==0?r/0:0,e!==0?-e/0:0).acos()},acsc:function(){const r=this.re,e=this.im;if(r===0&&e===0)return new he(Math.PI/2,1/0);const t=r*r+e*e;return t!==0?new he(r/t,-e/t).asin():new he(r!==0?r/0:0,e!==0?-e/0:0).asin()},sinh:function(){const r=this.re,e=this.im;return new he(Pt(r)*Math.cos(e),ut(r)*Math.sin(e))},cosh:function(){const r=this.re,e=this.im;return new he(ut(r)*Math.cos(e),Pt(r)*Math.sin(e))},tanh:function(){const r=2*this.re,e=2*this.im,t=ut(r)+Math.cos(e);return new he(Pt(r)/t,Math.sin(e)/t)},coth:function(){const r=2*this.re,e=2*this.im,t=ut(r)-Math.cos(e);return new he(Pt(r)/t,-Math.sin(e)/t)},csch:function(){const r=this.re,e=this.im,t=Math.cos(2*e)-ut(2*r);return new he(-2*Pt(r)*Math.cos(e)/t,2*ut(r)*Math.sin(e)/t)},sech:function(){const r=this.re,e=this.im,t=Math.cos(2*e)+ut(2*r);return new he(2*ut(r)*Math.cos(e)/t,-2*Pt(r)*Math.sin(e)/t)},asinh:function(){const r=this.re,e=this.im;if(e===0){if(r===0)return new he(0,0);const i=Math.abs(r),o=Math.log(i+Math.sqrt(i*i+1));return new he(r<0?-o:o,0)}const t=r*r-e*e+1,n=2*r*e,a=new he(t,n).sqrt();return new he(r+a.re,e+a.im).log()},acosh:function(){const r=this.re,e=this.im;if(e===0){if(r>1)return new he(Math.log(r+Math.sqrt(r-1)*Math.sqrt(r+1)),0);if(r<-1){const a=Math.sqrt(r*r-1);return new he(Math.log(-r+a),Math.PI)}return new he(0,Math.acos(r))}const t=new he(r-1,e).sqrt(),n=new he(r+1,e).sqrt();return new he(r+t.re*n.re-t.im*n.im,e+t.re*n.im+t.im*n.re).log()},atanh:function(){const r=this.re,e=this.im;if(e===0){if(r===0)return new he(0,0);if(r===1)return new he(1/0,0);if(r===-1)return new he(-1/0,0);if(-1<r&&r<1)return new he(.5*Math.log((1+r)/(1-r)),0);if(r>1){const u=(r+1)/(r-1);return new he(.5*Math.log(u),-Math.PI/2)}const l=(1+r)/(1-r);return new he(.5*Math.log(-l),Math.PI/2)}const t=1-r,n=1+r,a=t*t+e*e;if(a===0)return new he(r!==-1?r/0:0,e!==0?e/0:0);const i=(n*t-e*e)/a,o=(e*t+n*e)/a;return new he(is(i,o)/2,Math.atan2(o,i)/2)},acoth:function(){const r=this.re,e=this.im;if(r===0&&e===0)return new he(0,Math.PI/2);const t=r*r+e*e;return t!==0?new he(r/t,-e/t).atanh():new he(r!==0?r/0:0,e!==0?-e/0:0).atanh()},acsch:function(){const r=this.re,e=this.im;if(e===0){if(r===0)return new he(1/0,0);const n=1/r;return new he(Math.log(n+Math.sqrt(n*n+1)),0)}const t=r*r+e*e;return t!==0?new he(r/t,-e/t).asinh():new he(r!==0?r/0:0,e!==0?-e/0:0).asinh()},asech:function(){const r=this.re,e=this.im;if(this.isZero())return he.INFINITY;const t=r*r+e*e;return t!==0?new he(r/t,-e/t).acosh():new he(r!==0?r/0:0,e!==0?-e/0:0).acosh()},inverse:function(){if(this.isZero())return he.INFINITY;if(this.isInfinite())return he.ZERO;const r=this.re,e=this.im,t=r*r+e*e;return new he(r/t,-e/t)},conjugate:function(){return new he(this.re,-this.im)},neg:function(){return new he(-this.re,-this.im)},ceil:function(r){return r=Math.pow(10,r||0),new he(Math.ceil(this.re*r)/r,Math.ceil(this.im*r)/r)},floor:function(r){return r=Math.pow(10,r||0),new he(Math.floor(this.re*r)/r,Math.floor(this.im*r)/r)},round:function(r){return r=Math.pow(10,r||0),new he(Math.round(this.re*r)/r,Math.round(this.im*r)/r)},equals:function(r,e){const t=Jn(r,e);return Math.abs(t.re-this.re)<=he.EPSILON&&Math.abs(t.im-this.im)<=he.EPSILON},clone:function(){return new he(this.re,this.im)},toString:function(){let r=this.re,e=this.im,t="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(r)<he.EPSILON&&(r=0),Math.abs(e)<he.EPSILON&&(e=0),e===0?t+r:(r!==0?(t+=r,t+=" ",e<0?(e=-e,t+="-"):t+="+",t+=" "):e<0&&(e=-e,t+="-"),e!==1&&(t+=e),t+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return this.im===0?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return this.im===0&&this.re===0},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!this.isFinite()}},he.ZERO=new he(0,0),he.ONE=new he(1,0),he.I=new he(0,1),he.PI=new he(Math.PI,0),he.E=new he(Math.E,0),he.INFINITY=new he(1/0,1/0),he.NAN=new he(NaN,NaN),he.EPSILON=1e-15;var r1="Complex",t1=[],n1=L(r1,t1,()=>(Object.defineProperty(he,"name",{value:"Complex"}),he.prototype.constructor=he,he.prototype.type="Complex",he.prototype.isComplex=!0,he.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},he.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},he.prototype.format=function(r){var e="",t=this.im,n=this.re,a=Zn(this.re,r),i=Zn(this.im,r),o=Ye(r)?r:r?r.precision:null;if(o!==null){var l=Math.pow(10,-o);Math.abs(n/t)<l&&(n=0),Math.abs(t/n)<l&&(t=0)}return t===0?e=a:n===0?t===1?e="i":t===-1?e="-i":e=i+"i":t<0?t===-1?e=a+" - i":e=a+" - "+i.substring(1)+"i":t===1?e=a+" + i":e=a+" + "+i+"i",e},he.fromPolar=function(r){switch(arguments.length){case 1:{var e=arguments[0];if(typeof e=="object")return he(e);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var t=arguments[0],n=arguments[1];if(Ye(t)){if(Ct(n)&&n.hasBase("ANGLE")&&(n=n.toNumber("rad")),Ye(n))return new he({r:t,phi:n});throw new TypeError("Phi is not a number nor an angle unit.")}else throw new TypeError("Radius r is not a number.")}default:throw new SyntaxError("Wrong number of arguments in function fromPolar")}},he.prototype.valueOf=he.prototype.toString,he.fromJSON=function(r){return new he(r)},he.compare=function(r,e){return r.re>e.re?1:r.re<e.re?-1:r.im>e.im?1:r.im<e.im?-1:0},he),{isClass:!0});typeof BigInt>"u"&&(BigInt=function(r){if(isNaN(r))throw new Error("");return r});const Ge=BigInt(0),vr=BigInt(1),Qr=BigInt(2),ni=BigInt(3),xa=BigInt(5),Nt=BigInt(10);BigInt(Number.MAX_SAFE_INTEGER);const a1=2e3,Be={s:vr,n:Ge,d:vr};function pn(r,e){try{r=BigInt(r)}catch{throw On()}return r*e}function Wt(r){return typeof r=="bigint"?r:Math.floor(r)}function Rr(r,e){if(e===Ge)throw os();const t=Object.create($t.prototype);t.s=r<Ge?-vr:vr,r=r<Ge?-r:r;const n=jn(r,e);return t.n=r/n,t.d=e/n,t}const i1=[Qr*Qr,Qr,Qr*Qr,Qr,Qr*Qr,Qr*ni,Qr,Qr*ni];function wa(r){const e=Object.create(null);if(r<=vr)return e[r]=vr,e;const t=n=>{e[n]=(e[n]||Ge)+vr};for(;r%Qr===Ge;)t(Qr),r/=Qr;for(;r%ni===Ge;)t(ni),r/=ni;for(;r%xa===Ge;)t(xa),r/=xa;for(let n=0,a=Qr+xa;a*a<=r;){for(;r%a===Ge;)t(a),r/=a;a+=i1[n],n=n+1&7}return r>vr&&t(r),e}const Kr=function(r,e){let t=Ge,n=vr,a=vr;if(r!=null)if(e!==void 0){if(typeof r=="bigint")t=r;else{if(isNaN(r))throw On();if(r%1!==0)throw Nl();t=BigInt(r)}if(typeof e=="bigint")n=e;else{if(isNaN(e))throw On();if(e%1!==0)throw Nl();n=BigInt(e)}a=t*n}else if(typeof r=="object"){if("d"in r&&"n"in r)t=BigInt(r.n),n=BigInt(r.d),"s"in r&&(t*=BigInt(r.s));else if(0 in r)t=BigInt(r[0]),1 in r&&(n=BigInt(r[1]));else if(typeof r=="bigint")t=r;else throw On();a=t*n}else if(typeof r=="number"){if(isNaN(r))throw On();if(r<0&&(a=-vr,r=-r),r%1===0)t=BigInt(r);else{let i=1,o=0,l=1,u=1,s=1,c=1e7;for(r>=1&&(i=10**Math.floor(1+Math.log10(r)),r/=i);l<=c&&s<=c;){let f=(o+u)/(l+s);if(r===f){l+s<=c?(t=o+u,n=l+s):s>l?(t=u,n=s):(t=o,n=l);break}else r>f?(o+=u,l+=s):(u+=o,s+=l),l>c?(t=u,n=s):(t=o,n=l)}t=BigInt(t)*BigInt(i),n=BigInt(n)}}else if(typeof r=="string"){let i=0,o=Ge,l=Ge,u=Ge,s=vr,c=vr,f=r.replace(/_/g,"").match(/\d+|./g);if(f===null)throw On();if(f[i]==="-"?(a=-vr,i++):f[i]==="+"&&i++,f.length===i+1?l=pn(f[i++],a):f[i+1]==="."||f[i]==="."?(f[i]!=="."&&(o=pn(f[i++],a)),i++,(i+1===f.length||f[i+1]==="("&&f[i+3]===")"||f[i+1]==="'"&&f[i+3]==="'")&&(l=pn(f[i],a),s=Nt**BigInt(f[i].length),i++),(f[i]==="("&&f[i+2]===")"||f[i]==="'"&&f[i+2]==="'")&&(u=pn(f[i+1],a),c=Nt**BigInt(f[i+1].length)-vr,i+=3)):f[i+1]==="/"||f[i+1]===":"?(l=pn(f[i],a),s=pn(f[i+2],vr),i+=3):f[i+3]==="/"&&f[i+1]===" "&&(o=pn(f[i],a),l=pn(f[i+2],a),s=pn(f[i+4],vr),i+=5),f.length<=i)n=s*c,a=t=u+n*o+c*l;else throw On()}else if(typeof r=="bigint")t=r,a=r,n=vr;else throw On();if(n===Ge)throw os();Be.s=a<Ge?-vr:vr,Be.n=t<Ge?-t:t,Be.d=n<Ge?-n:n};function o1(r,e,t){let n=vr;for(;e>Ge;r=r*r%t,e>>=vr)e&vr&&(n=n*r%t);return n}function s1(r,e){for(;e%Qr===Ge;e/=Qr);for(;e%xa===Ge;e/=xa);if(e===vr)return Ge;let t=Nt%e,n=1;for(;t!==vr;n++)if(t=t*Nt%e,n>a1)return Ge;return BigInt(n)}function u1(r,e,t){let n=vr,a=o1(Nt,t,e);for(let i=0;i<300;i++){if(n===a)return BigInt(i);n=n*Nt%e,a=a*Nt%e}return 0}function jn(r,e){if(!r)return e;if(!e)return r;for(;;){if(r%=e,!r)return e;if(e%=r,!e)return r}}function $t(r,e){if(Kr(r,e),this instanceof $t)r=jn(Be.d,Be.n),this.s=Be.s,this.n=Be.n/r,this.d=Be.d/r;else return Rr(Be.s*Be.n,Be.d)}const os=function(){return new Error("Division by Zero")},On=function(){return new Error("Invalid argument")},Nl=function(){return new Error("Parameters must be integer")};$t.prototype={s:vr,n:Ge,d:vr,abs:function(){return Rr(this.n,this.d)},neg:function(){return Rr(-this.s*this.n,this.d)},add:function(r,e){return Kr(r,e),Rr(this.s*this.n*Be.d+Be.s*this.d*Be.n,this.d*Be.d)},sub:function(r,e){return Kr(r,e),Rr(this.s*this.n*Be.d-Be.s*this.d*Be.n,this.d*Be.d)},mul:function(r,e){return Kr(r,e),Rr(this.s*Be.s*this.n*Be.n,this.d*Be.d)},div:function(r,e){return Kr(r,e),Rr(this.s*Be.s*this.n*Be.d,this.d*Be.n)},clone:function(){return Rr(this.s*this.n,this.d)},mod:function(r,e){if(r===void 0)return Rr(this.s*this.n%this.d,vr);if(Kr(r,e),Ge===Be.n*this.d)throw os();return Rr(this.s*(Be.d*this.n)%(Be.n*this.d),Be.d*this.d)},gcd:function(r,e){return Kr(r,e),Rr(jn(Be.n,this.n)*jn(Be.d,this.d),Be.d*this.d)},lcm:function(r,e){return Kr(r,e),Be.n===Ge&&this.n===Ge?Rr(Ge,vr):Rr(Be.n*this.n,jn(Be.n,this.n)*jn(Be.d,this.d))},inverse:function(){return Rr(this.s*this.d,this.n)},pow:function(r,e){if(Kr(r,e),Be.d===vr)return Be.s<Ge?Rr((this.s*this.d)**Be.n,this.n**Be.n):Rr((this.s*this.n)**Be.n,this.d**Be.n);if(this.s<Ge)return null;let t=wa(this.n),n=wa(this.d),a=vr,i=vr;for(let o in t)if(o!=="1"){if(o==="0"){a=Ge;break}if(t[o]*=Be.n,t[o]%Be.d===Ge)t[o]/=Be.d;else return null;a*=BigInt(o)**t[o]}for(let o in n)if(o!=="1"){if(n[o]*=Be.n,n[o]%Be.d===Ge)n[o]/=Be.d;else return null;i*=BigInt(o)**n[o]}return Be.s<Ge?Rr(i,a):Rr(a,i)},log:function(r,e){if(Kr(r,e),this.s<=Ge||Be.s<=Ge)return null;const t=Object.create(null),n=wa(Be.n),a=wa(Be.d),i=wa(this.n),o=wa(this.d);for(const s in a)n[s]=(n[s]||Ge)-a[s];for(const s in o)i[s]=(i[s]||Ge)-o[s];for(const s in n)s!=="1"&&(t[s]=!0);for(const s in i)s!=="1"&&(t[s]=!0);let l=null,u=null;for(const s in t){const c=n[s]||Ge,f=i[s]||Ge;if(c===Ge){if(f!==Ge)return null;continue}let m=f,v=c;const p=jn(m,v);if(m/=p,v/=p,l===null&&u===null)l=m,u=v;else if(m*u!==l*v)return null}return l!==null&&u!==null?Rr(l,u):null},equals:function(r,e){return Kr(r,e),this.s*this.n*Be.d===Be.s*Be.n*this.d},lt:function(r,e){return Kr(r,e),this.s*this.n*Be.d<Be.s*Be.n*this.d},lte:function(r,e){return Kr(r,e),this.s*this.n*Be.d<=Be.s*Be.n*this.d},gt:function(r,e){return Kr(r,e),this.s*this.n*Be.d>Be.s*Be.n*this.d},gte:function(r,e){return Kr(r,e),this.s*this.n*Be.d>=Be.s*Be.n*this.d},compare:function(r,e){Kr(r,e);let t=this.s*this.n*Be.d-Be.s*Be.n*this.d;return(Ge<t)-(t<Ge)},ceil:function(r){return r=Nt**BigInt(r||0),Rr(Wt(this.s*r*this.n/this.d)+(r*this.n%this.d>Ge&&this.s>=Ge?vr:Ge),r)},floor:function(r){return r=Nt**BigInt(r||0),Rr(Wt(this.s*r*this.n/this.d)-(r*this.n%this.d>Ge&&this.s<Ge?vr:Ge),r)},round:function(r){return r=Nt**BigInt(r||0),Rr(Wt(this.s*r*this.n/this.d)+this.s*((this.s>=Ge?vr:Ge)+Qr*(r*this.n%this.d)>this.d?vr:Ge),r)},roundTo:function(r,e){Kr(r,e);const t=this.n*Be.d,n=this.d*Be.n,a=t%n;let i=Wt(t/n);return a+a>=n&&i++,Rr(this.s*i*Be.n,Be.d)},divisible:function(r,e){return Kr(r,e),Be.n===Ge?!1:this.n*Be.d%(Be.n*this.d)===Ge},valueOf:function(){return Number(this.s*this.n)/Number(this.d)},toString:function(r=15){let e=this.n,t=this.d,n=s1(e,t),a=u1(e,t,n),i=this.s<Ge?"-":"";if(i+=Wt(e/t),e%=t,e*=Nt,e&&(i+="."),n){for(let o=a;o--;)i+=Wt(e/t),e%=t,e*=Nt;i+="(";for(let o=n;o--;)i+=Wt(e/t),e%=t,e*=Nt;i+=")"}else for(let o=r;e&&o--;)i+=Wt(e/t),e%=t,e*=Nt;return i},toFraction:function(r=!1){let e=this.n,t=this.d,n=this.s<Ge?"-":"";if(t===vr)n+=e;else{const a=Wt(e/t);r&&a>Ge&&(n+=a,n+=" ",e%=t),n+=e,n+="/",n+=t}return n},toLatex:function(r=!1){let e=this.n,t=this.d,n=this.s<Ge?"-":"";if(t===vr)n+=e;else{const a=Wt(e/t);r&&a>Ge&&(n+=a,e%=t),n+="\\frac{",n+=e,n+="}{",n+=t,n+="}"}return n},toContinued:function(){let r=this.n,e=this.d;const t=[];for(;e;){t.push(Wt(r/e));const n=r%e;r=e,e=n}return t},simplify:function(r=.001){const e=BigInt(Math.ceil(1/r)),t=this.abs(),n=t.toContinued();for(let a=1;a<n.length;a++){let i=Rr(n[a-1],vr);for(let l=a-2;l>=0;l--)i=i.inverse().add(n[l]);let o=i.sub(t);if(o.n*e<o.d)return i.mul(this.s)}return this}};var l1="Fraction",c1=[],f1=L(l1,c1,()=>(Object.defineProperty($t,"name",{value:"Fraction"}),$t.prototype.constructor=$t,$t.prototype.type="Fraction",$t.prototype.isFraction=!0,$t.prototype.toJSON=function(){return{mathjs:"Fraction",n:String(this.s*this.n),d:String(this.d)}},$t.fromJSON=function(r){return new $t(r)},$t),{isClass:!0}),m1="Range",v1=[],p1=L(m1,v1,()=>{function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");var a=e!=null,i=t!=null,o=n!=null;if(a){if(or(e))e=e.toNumber();else if(typeof e!="number"&&!Qa(e))throw new TypeError("Parameter start must be a number or bigint")}if(i){if(or(t))t=t.toNumber();else if(typeof t!="number"&&!Qa(t))throw new TypeError("Parameter end must be a number or bigint")}if(o){if(or(n))n=n.toNumber();else if(typeof n!="number"&&!Qa(n))throw new TypeError("Parameter step must be a number or bigint")}if(this.start=a?parseFloat(e):0,this.end=i?parseFloat(t):0,this.step=o?parseFloat(n):1,o&&Xr(this.step,0))throw new Error("Step must not be zero")}return r.prototype.type="Range",r.prototype.isRange=!0,r.parse=function(e){if(typeof e!="string")return null;var t=e.split(":"),n=t.map(function(i){return parseFloat(i)}),a=n.some(function(i){return isNaN(i)});if(a)return null;switch(n.length){case 2:return new r(n[0],n[1]);case 3:return new r(n[0],n[2],n[1]);default:return null}},r.prototype.clone=function(){return new r(this.start,this.end,this.step)},r.prototype.size=function(){var e=0,t=this.start,n=this.step,a=this.end,i=a-t;return Sn(n)===Sn(i)?e=Math.ceil(i/n):i===0&&(e=0),isNaN(e)&&(e=0),[e]},r.prototype.min=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start:this.start+(e-1)*this.step},r.prototype.max=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start+(e-1)*this.step:this.start},r.prototype.forEach=function(e){var t=this.start,n=this.step,a=this.end,i=0;if(n>0)for(;t<a;)e(t,[i],this),t+=n,i++;else if(n<0)for(;t>a;)e(t,[i],this),t+=n,i++},r.prototype.map=function(e){var t=[];return this.forEach(function(n,a,i){t[a[0]]=e(n,a,i)}),t},r.prototype.toArray=function(){var e=[];return this.forEach(function(t,n){e[n[0]]=t}),e},r.prototype.valueOf=function(){return this.toArray()},r.prototype.format=function(e){var t=Zn(this.start,e);return this.step!==1&&(t+=":"+Zn(this.step,e)),t+=":"+Zn(this.end,e),t},r.prototype.toString=function(){return this.format()},r.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},r.fromJSON=function(e){return new r(e.start,e.end,e.step)},r},{isClass:!0}),d1="Matrix",h1=[],g1=L(d1,h1,()=>{function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator")}return r.prototype.type="Matrix",r.prototype.isMatrix=!0,r.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},r.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},r.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},r.prototype.subset=function(e,t,n){throw new Error("Cannot invoke subset on a Matrix interface")},r.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},r.prototype.set=function(e,t,n){throw new Error("Cannot invoke set on a Matrix interface")},r.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},r.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},r.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},r.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},r.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},r.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},r.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},r.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},r.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},r.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},r.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},r},{isClass:!0});function ss(r,e,t){var n=r.constructor,a=new n(2),i="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!Ue(t))throw new Error("size must be an integer");if(r.greaterThan(a.pow(t-1).sub(1))||r.lessThan(a.pow(t-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!r.isInteger())throw new Error("Value must be an integer");r.lessThan(0)&&(r=r.add(a.pow(t))),i="i".concat(t)}switch(e){case 2:return"".concat(r.toBinary()).concat(i);case 8:return"".concat(r.toOctal()).concat(i);case 16:return"".concat(r.toHexadecimal()).concat(i);default:throw new Error("Base ".concat(e," not supported "))}}function y1(r,e){if(typeof e=="function")return e(r);if(!r.isFinite())return r.isNaN()?"NaN":r.gt(0)?"Infinity":"-Infinity";var{notation:t,precision:n,wordSize:a}=nl(e);switch(t){case"fixed":return x1(r,n);case"exponential":return El(r,n);case"engineering":return b1(r,n);case"bin":return ss(r,2,a);case"oct":return ss(r,8,a);case"hex":return ss(r,16,a);case"auto":{var i=Al(e==null?void 0:e.lowerExp,-3),o=Al(e==null?void 0:e.upperExp,5);if(r.isZero())return"0";var l,u=r.toSignificantDigits(n),s=u.e;return s>=i&&s<o?l=u.toFixed():l=El(r,n),l.replace(/((\.\d*?)(0+))($|e)/,function(){var c=arguments[2],f=arguments[4];return c!=="."?c+f:f})}default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function b1(r,e){var t=r.e,n=t%3===0?t:t<0?t-3-t%3:t-t%3,a=r.mul(Math.pow(10,-n)),i=a.toPrecision(e);if(i.includes("e")){var o=r.constructor;i=new o(i).toFixed()}return i+"e"+(t>=0?"+":"")+n.toString()}function El(r,e){return e!==void 0?r.toExponential(e-1):r.toExponential()}function x1(r,e){return r.toFixed(e)}function Al(r,e){return Ye(r)?r:or(r)?r.toNumber():e}function w1(r,e){var t=r.length-e.length,n=r.length;return r.substring(t,n)===e}function lr(r,e){var t=D1(r,e);return e&&typeof e=="object"&&"truncate"in e&&t.length>e.truncate?t.substring(0,e.truncate-3)+"...":t}function D1(r,e){if(typeof r=="number")return Zn(r,e);if(or(r))return y1(r,e);if(N1(r))return!e||e.fraction!=="decimal"?"".concat(r.s*r.n,"/").concat(r.d):r.toString();if(Array.isArray(r))return Cl(r,e);if($r(r))return Da(r);if(typeof r=="function")return r.syntax?String(r.syntax):"function";if(r&&typeof r=="object"){if(typeof r.format=="function")return r.format(e);if(r&&r.toString(e)!=={}.toString())return r.toString(e);var t=Object.keys(r).map(n=>Da(n)+": "+lr(r[n],e));return"{"+t.join(", ")+"}"}return String(r)}function Da(r){for(var e=String(r),t="",n=0;n<e.length;){var a=e.charAt(n);t+=a in Sl?Sl[a]:a,n++}return'"'+t+'"'}var Sl={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function qt(r){var e=String(r);return e=e.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"),e}function Cl(r,e){if(Array.isArray(r)){for(var t="[",n=r.length,a=0;a<n;a++)a!==0&&(t+=", "),t+=Cl(r[a],e);return t+="]",t}else return lr(r,e)}function N1(r){return r&&typeof r=="object"&&typeof r.s=="bigint"&&typeof r.n=="bigint"&&typeof r.d=="bigint"||!1}function us(r,e){if(!$r(r))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Sr(r)+", index: 0)");if(!$r(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Sr(e)+", index: 1)");return r===e?0:r>e?1:-1}function ur(r,e,t){if(!(this instanceof ur))throw new SyntaxError("Constructor must be called with the new operator");this.actual=r,this.expected=e,this.relation=t,this.message="Dimension mismatch ("+(Array.isArray(r)?"["+r.join(", ")+"]":r)+" "+(this.relation||"!=")+" "+(Array.isArray(e)?"["+e.join(", ")+"]":e)+")",this.stack=new Error().stack}ur.prototype=new RangeError,ur.prototype.constructor=RangeError,ur.prototype.name="DimensionError",ur.prototype.isDimensionError=!0;function Yt(r,e,t){if(!(this instanceof Yt))throw new SyntaxError("Constructor must be called with the new operator");this.index=r,arguments.length<3?(this.min=0,this.max=e):(this.min=e,this.max=t),this.min!==void 0&&this.index<this.min?this.message="Index out of range ("+this.index+" < "+this.min+")":this.max!==void 0&&this.index>=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=new Error().stack}Yt.prototype=new RangeError,Yt.prototype.constructor=RangeError,Yt.prototype.name="IndexError",Yt.prototype.isIndexError=!0;function rr(r){for(var e=[];Array.isArray(r);)e.push(r.length),r=r[0];return e}function Ml(r,e,t){var n,a=r.length;if(a!==e[t])throw new ur(a,e[t]);if(t<e.length-1){var i=t+1;for(n=0;n<a;n++){var o=r[n];if(!Array.isArray(o))throw new ur(e.length-1,e.length,"<");Ml(r[n],e,i)}}else for(n=0;n<a;n++)if(Array.isArray(r[n]))throw new ur(e.length+1,e.length,">")}function _l(r,e){var t=e.length===0;if(t){if(Array.isArray(r))throw new ur(r.length,0)}else Ml(r,e,0)}function Wi(r,e){var t=r.isMatrix?r._size:rr(r),n=e._sourceSize;n.forEach((a,i)=>{if(a!==null&&a!==t[i])throw new ur(a,t[i])})}function _r(r,e){if(r!==void 0){if(!Ye(r)||!Ue(r))throw new TypeError("Index must be an integer (value: "+r+")");if(r<0||typeof e=="number"&&r>=e)throw new Yt(r,e)}}function Na(r){for(var e=0;e<r._dimensions.length;++e){var t=r._dimensions[e];if(t._data&&Ar(t._data)){if(t._size[0]===0)return!0}else if(t.isRange){if(t.start===t.end)return!0}else if($r(t)&&t.length===0)return!0}return!1}function Ea(r,e,t){if(!Array.isArray(e))throw new TypeError("Array expected");if(e.length===0)throw new Error("Resizing to scalar is not supported");e.forEach(function(a){if(!Ye(a)||!Ue(a)||a<0)throw new TypeError("Invalid size, must contain positive integers (size: "+lr(e)+")")}),(Ye(r)||or(r))&&(r=[r]);var n=t!==void 0?t:0;return ls(r,e,0,n),r}function ls(r,e,t,n){var a,i,o=r.length,l=e[t],u=Math.min(o,l);if(r.length=l,t<e.length-1){var s=t+1;for(a=0;a<u;a++)i=r[a],Array.isArray(i)||(i=[i],r[a]=i),ls(i,e,s,n);for(a=u;a<l;a++)i=[],r[a]=i,ls(i,e,s,n)}else{for(a=0;a<u;a++)for(;Array.isArray(r[a]);)r[a]=r[a][0];for(a=u;a<l;a++)r[a]=n}}function cs(r,e){var t=yr(r,!0),n=t.length;if(!Array.isArray(r)||!Array.isArray(e))throw new TypeError("Array expected");if(e.length===0)throw new ur(0,n,"!=");e=fs(e,n);var a=Tl(e);if(n!==a)throw new ur(a,n,"!=");try{return E1(t,e)}catch(i){throw i instanceof ur?new ur(a,n,"!="):i}}function fs(r,e){var t=Tl(r),n=r.slice(),a=-1,i=r.indexOf(a),o=r.indexOf(a,i+1)>=0;if(o)throw new Error("More than one wildcard in sizes");var l=i>=0,u=e%t===0;if(l)if(u)n[i]=-e/t;else throw new Error("Could not replace wildcard, since "+e+" is no multiple of "+-t);return n}function Tl(r){return r.reduce((e,t)=>e*t,1)}function E1(r,e){for(var t=r,n,a=e.length-1;a>0;a--){var i=e[a];n=[];for(var o=t.length/i,l=0;l<o;l++)n.push(t.slice(l*i,(l+1)*i));t=n}return t}function Yi(r,e){for(var t=rr(r);Array.isArray(r)&&r.length===1;)r=r[0],t.shift();for(var n=t.length;t[n-1]===1;)n--;return n<t.length&&(r=Fl(r,n,0),t.length=n),r}function Fl(r,e,t){var n,a;if(t<e){var i=t+1;for(n=0,a=r.length;n<a;n++)r[n]=Fl(r[n],e,i)}else for(;Array.isArray(r);)r=r[0];return r}function Ol(r,e,t,n){var a=n||rr(r);if(t)for(var i=0;i<t;i++)r=[r],a.unshift(1);for(r=Bl(r,e,0);a.length<e;)a.push(1);return r}function Bl(r,e,t){var n,a;if(Array.isArray(r)){var i=t+1;for(n=0,a=r.length;n<a;n++)r[n]=Bl(r[n],e,i)}else for(var o=t;o<e;o++)r=[r];return r}function yr(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!Array.isArray(r))return r;if(typeof e!="boolean")throw new TypeError("Boolean expected for second argument of flatten");var t=[];return e?a(r):n(r),t;function n(i){for(var o=0;o<i.length;o++){var l=i[o];Array.isArray(l)?n(l):t.push(l)}}function a(i){if(Array.isArray(i[0]))for(var o=0;o<i.length;o++)a(i[o]);else for(var l=0;l<i.length;l++)t.push(i[l])}}function Bn(r,e){return Array.prototype.map.call(r,e)}function Rl(r,e){Array.prototype.forEach.call(r,e)}function Il(r,e){if(rr(r).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(r,e)}function Pl(r,e){if(rr(r).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(r,t=>e.test(t))}function $l(r,e){return Array.prototype.join.call(r,e)}function Aa(r){if(!Array.isArray(r))throw new TypeError("Array input expected");if(r.length===0)return r;var e=[],t=0;e[0]={value:r[0],identifier:0};for(var n=1;n<r.length;n++)r[n]===r[n-1]?t++:t=0,e.push({value:r[n],identifier:t});return e}function Zi(r){if(!Array.isArray(r))throw new TypeError("Array input expected");if(r.length===0)return r;for(var e=[],t=0;t<r.length;t++)e.push(r[t].value);return e}function Ji(r,e){for(var t,n=0,a=0;a<r.length;a++){var i=r[a],o=Array.isArray(i);if(a===0&&o&&(n=i.length),o&&i.length!==n)return;var l=o?Ji(i,e):e(i);if(t===void 0)t=l;else if(t!==l)return"mixed"}return t}function ql(r,e,t,n){if(n<t){if(r.length!==e.length)throw new ur(r.length,e.length);for(var a=[],i=0;i<r.length;i++)a[i]=ql(r[i],e[i],t,n+1);return a}else return r.concat(e)}function zl(){var r=Array.prototype.slice.call(arguments,0,-1),e=Array.prototype.slice.call(arguments,-1);if(r.length===1)return r[0];if(r.length>1)return r.slice(1).reduce(function(t,n){return ql(t,n,e,0)},r[0]);throw new Error("Wrong number of arguments in function concat")}function ji(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];for(var n=e.map(m=>m.length),a=Math.max(...n),i=new Array(a).fill(null),o=0;o<e.length;o++)for(var l=e[o],u=n[o],s=0;s<u;s++){var c=a-u+s;l[s]>i[c]&&(i[c]=l[s])}for(var f=0;f<e.length;f++)Ul(e[f],i);return i}function Ul(r,e){for(var t=e.length,n=r.length,a=0;a<n;a++){var i=t-n+a;if(r[a]<e[i]&&r[a]>1||r[a]>e[i])throw new Error("shape mismatch: mismatch is found in arg with shape (".concat(r,") not possible to broadcast dimension ").concat(n," with size ").concat(r[a]," to size ").concat(e[i]))}}function Xn(r,e){var t=rr(r);if(mn(t,e))return r;Ul(t,e);var n=ji(t,e),a=n.length,i=[...Array(a-t.length).fill(1),...t],o=S1(r);t.length<a&&(o=cs(o,i),t=rr(o));for(var l=0;l<a;l++)t[l]<n[l]&&(o=A1(o,n[l],l),t=rr(o));return o}function A1(r,e,t){return zl(...Array(e).fill(r),t)}function Xi(r,e){if(!Array.isArray(r))throw new Error("Array expected");if(!Array.isArray(e))throw new Error("Array expected for index");var t=rr(r);if(e.length!==t.length)throw new ur(e.length,t.length);for(var n=0;n<e.length;n++)_r(e[n],t[n]);return e.reduce((a,i)=>a[i],r)}function ms(r,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(r.length===0)return[];if(t)return i(r);var n=[];return a(r,0);function a(o,l){if(Array.isArray(o)){for(var u=o.length,s=Array(u),c=0;c<u;c++)n[l]=c,s[c]=a(o[c],l+1);return s}else return e(o,n.slice(0,l),r)}function i(o){if(Array.isArray(o)){for(var l=o.length,u=Array(l),s=0;s<l;s++)u[s]=i(o[s]);return u}else return e(o)}}function Ll(r,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(r.length===0)return;if(t){i(r);return}var n=[];a(r,0);function a(o,l){if(Array.isArray(o))for(var u=o.length,s=0;s<u;s++)n[l]=s,a(o[s],l+1);else e(o,n.slice(0,l),r)}function i(o){if(Array.isArray(o))for(var l=o.length,u=0;u<l;u++)i(o[u]);else e(o)}}function S1(r){return zr([],r)}function Qn(r,e,t,n){if(Bi.isTypedFunction(r)){var a;if(n)a=1;else{var i=e.isMatrix?e.size():rr(e),o=i.length?i[i.length-1]===0:!0;if(o)return{isUnary:n,fn:r};var l=i.map(()=>0),u=e.isMatrix?e.get(l):Xi(e,l);a=_1(r,u,l,e)}var s;if(e.isMatrix&&e.dataType!=="mixed"&&e.dataType!==void 0){var c=C1(r,a);s=c!==void 0?c:r}else s=r;return a>=1&&a<=3?{isUnary:a===1,fn:function(){for(var m=arguments.length,v=new Array(m),p=0;p<m;p++)v[p]=arguments[p];return kl(s,v.slice(0,a),t,r.name)}}:{isUnary:!1,fn:function(){for(var m=arguments.length,v=new Array(m),p=0;p<m;p++)v[p]=arguments[p];return kl(s,v,t,r.name)}}}return n===void 0?{isUnary:M1(r),fn:r}:{isUnary:n,fn:r}}function C1(r,e){var t=[];if(Object.entries(r.signatures).forEach(n=>{var[a,i]=n;a.split(",").length===e&&t.push(i)}),t.length===1)return t[0]}function M1(r){if(r.length!==1)return!1;var e=r.toString();if(/arguments/.test(e))return!1;var t=e.match(/\(.*?\)/);return!/\.\.\./.test(t)}function _1(r,e,t,n){for(var a=[e,t,n],i=3;i>0;i--){var o=a.slice(0,i);if(Bi.resolve(r,o)!==null)return i}}function kl(r,e,t,n){try{return r(...e)}catch(a){T1(a,e,t,n)}}function T1(r,e,t,n){var a;if(r instanceof TypeError&&((a=r.data)===null||a===void 0?void 0:a.category)==="wrongType"){var i=[];throw i.push("value: ".concat(Sr(e[0]))),e.length>=2&&i.push("index: ".concat(Sr(e[1]))),e.length>=3&&i.push("array: ".concat(Sr(e[2]))),new TypeError("Function ".concat(t," cannot apply callback arguments ")+"".concat(n,"(").concat(i.join(", "),") at index ").concat(JSON.stringify(e[1])))}else throw new TypeError("Function ".concat(t," cannot apply callback arguments ")+"to function ".concat(n,": ").concat(r.message))}var F1="DenseMatrix",O1=["Matrix","config"],B1=L(F1,O1,r=>{var{Matrix:e,config:t}=r;function n(f,m){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(m&&!$r(m))throw new Error("Invalid datatype: "+m);if(Je(f))f.type==="DenseMatrix"?(this._data=er(f._data),this._size=er(f._size),this._datatype=m||f._datatype):(this._data=f.toArray(),this._size=f.size(),this._datatype=m||f._datatype);else if(f&&Ar(f.data)&&Ar(f.size))this._data=f.data,this._size=f.size,_l(this._data,this._size),this._datatype=m||f.datatype;else if(Ar(f))this._data=c(f),this._size=rr(this._data),_l(this._data,this._size),this._datatype=m;else{if(f)throw new TypeError("Unsupported type of data ("+Sr(f)+")");this._data=[],this._size=[0],this._datatype=m}}n.prototype=new e,n.prototype.createDenseMatrix=function(f,m){return new n(f,m)},Object.defineProperty(n,"name",{value:"DenseMatrix"}),n.prototype.constructor=n,n.prototype.type="DenseMatrix",n.prototype.isDenseMatrix=!0,n.prototype.getDataType=function(){return Ji(this._data,Sr)},n.prototype.storage=function(){return"dense"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(f,m){return new n(f,m)},n.prototype.subset=function(f,m,v){switch(arguments.length){case 1:return a(this,f);case 2:case 3:return o(this,f,m,v);default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.get=function(f){return Xi(this._data,f)},n.prototype.set=function(f,m,v){if(!Ar(f))throw new TypeError("Array expected");if(f.length<this._size.length)throw new ur(f.length,this._size.length,"<");var p,d,y,x=f.map(function(h){return h+1});s(this,x,v);var D=this._data;for(p=0,d=f.length-1;p<d;p++)y=f[p],_r(y,D.length),D=D[y];return y=f[f.length-1],_r(y,D.length),D[y]=m,this};function a(f,m){if(!Ti(m))throw new TypeError("Invalid index");var v=t.legacySubset?m.size().every(g=>g===1):m.isScalar();if(v)return f.get(m.min());var p=m.size();if(p.length!==f._size.length)throw new ur(p.length,f._size.length);for(var d=m.min(),y=m.max(),x=0,D=f._size.length;x<D;x++)_r(d[x],f._size[x]),_r(y[x],f._size[x]);var h=new n,w=i(f._data,m);return h._size=w.size,h._datatype=f._datatype,h._data=w.data,t.legacySubset?h.reshape(m.size()):h}function i(f,m){var v=m.size().length-1,p=Array(v);return{data:d(f),size:p.filter(y=>y!==null)};function d(y){var x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,D=m.dimension(x);function h(w,g){return Ye(w)?g(w):w.map(g).valueOf()}return Ye(D)?p[x]=null:p[x]=D.size()[0],x<v?h(D,w=>(_r(w,y.length),d(y[w],x+1))):h(D,w=>(_r(w,y.length),y[w]))}}function o(f,m,v,p){if(!m||m.isIndex!==!0)throw new TypeError("Invalid index");var d=m.size(),y=m.isScalar(),x;if(Je(v)?(x=v.size(),v=v.valueOf()):x=rr(v),y){if(x.length!==0)throw new TypeError("Scalar expected");f.set(m.min(),v,p)}else{if(!mn(x,d)){if(x.length===0)v=Xn([v],d);else try{v=Xn(v,d)}catch{}x=rr(v)}if(d.length<f._size.length)throw new ur(d.length,f._size.length,"<");if(x.length<d.length){for(var D=0,h=0;d[D]===1&&x[D]===1;)D++;for(;d[D]===1;)h++,D++;v=Ol(v,d.length,h,x)}if(!mn(d,x))throw new ur(d,x,">");var w=m.max().map(function(g){return g+1});s(f,w,p),l(f._data,m,v)}return f}function l(f,m,v){var p=m.size().length-1;d(f,v);function d(y,x){var D=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,h=m.dimension(D),w=(b,A)=>{_r(b,y.length),d(y[b],x[A[0]],D+1)},g=(b,A)=>{_r(b,y.length),y[b]=x[A[0]]};D<p?Ye(h)?w(h,[0]):h.forEach(w):Ye(h)?g(h,[0]):h.forEach(g)}}n.prototype.resize=function(f,m,v){if(!Mt(f))throw new TypeError("Array or Matrix expected");var p=f.valueOf().map(y=>Array.isArray(y)&&y.length===1?y[0]:y),d=v?this.clone():this;return u(d,p,m)};function u(f,m,v){if(m.length===0){for(var p=f._data;Ar(p);)p=p[0];return p}return f._size=m.slice(0),f._data=Ea(f._data,f._size,v),f}n.prototype.reshape=function(f,m){var v=m?this.clone():this;v._data=cs(v._data,f);var p=v._size.reduce((d,y)=>d*y);return v._size=fs(f,p),v};function s(f,m,v){for(var p=f._size.slice(0),d=!1;p.length<m.length;)p.push(0),d=!0;for(var y=0,x=m.length;y<x;y++)m[y]>p[y]&&(p[y]=m[y],d=!0);d&&u(f,p,v)}n.prototype.clone=function(){var f=new n({data:er(this._data),size:er(this._size),datatype:this._datatype});return f},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(f){var m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,v=this,p=v._size.length-1;if(p<0)return v.clone();var d=Qn(f,v,"map",m),y=d.fn,x=v.create(void 0,v._datatype);if(x._size=v._size,m||d.isUnary)return x._data=A(v._data),x;if(p===0){for(var D=v.valueOf(),h=Array(D.length),w=0;w<D.length;w++)h[w]=y(D[w],[w],v);return x._data=h,x}var g=[];return x._data=b(v._data),x;function b(N){var E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,S=Array(N.length);if(E<p)for(var C=0;C<N.length;C++)g[E]=C,S[C]=b(N[C],E+1);else for(var M=0;M<N.length;M++)g[E]=M,S[M]=y(N[M],g.slice(),v);return S}function A(N){var E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,S=Array(N.length);if(E<p)for(var C=0;C<N.length;C++)S[C]=A(N[C],E+1);else for(var M=0;M<N.length;M++)S[M]=y(N[M]);return S}},n.prototype.forEach=function(f){var m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,v=this,p=v._size.length-1;if(p<0)return;var d=Qn(f,v,"map",m),y=d.fn;if(m||d.isUnary){w(v._data);return}if(p===0){for(var x=0;x<v._data.length;x++)y(v._data[x],[x],v);return}var D=[];h(v._data);function h(g){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(b<p)for(var A=0;A<g.length;A++)D[b]=A,h(g[A],b+1);else for(var N=0;N<g.length;N++)D[b]=N,y(g[N],D.slice(),v)}function w(g){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(b<p)for(var A=0;A<g.length;A++)w(g[A],b+1);else for(var N=0;N<g.length;N++)y(g[N])}},n.prototype[Symbol.iterator]=function*(){var f=this._size.length-1;if(!(f<0)){if(f===0){for(var m=0;m<this._data.length;m++)yield{value:this._data[m],index:[m]};return}for(var v=Array(f+1).fill(0),p=this._size.reduce((h,w)=>h*w,1),d=0;d<p;d++){for(var y=this._data,x=0;x<f;x++)y=y[v[x]];yield{value:y[v[f]],index:v.slice()};for(var D=f;D>=0&&(v[D]++,!(v[D]<this._size[D]));D--)v[D]=0}}},n.prototype.rows=function(){var f=[],m=this.size();if(m.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var v=this._data;for(var p of v)f.push(new n([p],this._datatype));return f},n.prototype.columns=function(){var f=this,m=[],v=this.size();if(v.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var p=this._data,d=function(D){var h=p.map(w=>[w[D]]);m.push(new n(h,f._datatype))},y=0;y<v[1];y++)d(y);return m},n.prototype.toArray=function(){return er(this._data)},n.prototype.valueOf=function(){return this._data},n.prototype.format=function(f){return lr(this._data,f)},n.prototype.toString=function(){return lr(this._data)},n.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(f){if(f){if(or(f)&&(f=f.toNumber()),!Ye(f)||!Ue(f))throw new TypeError("The parameter k must be an integer number")}else f=0;for(var m=f>0?f:0,v=f<0?-f:0,p=this._size[0],d=this._size[1],y=Math.min(p-v,d-m),x=[],D=0;D<y;D++)x[D]=this._data[D+v][D+m];return new n({data:x,size:[y],datatype:this._datatype})},n.diagonal=function(f,m,v,p){if(!Ar(f))throw new TypeError("Array expected, size parameter");if(f.length!==2)throw new Error("Only two dimensions matrix are supported");if(f=f.map(function(N){if(or(N)&&(N=N.toNumber()),!Ye(N)||!Ue(N)||N<1)throw new Error("Size values must be positive integers");return N}),v){if(or(v)&&(v=v.toNumber()),!Ye(v)||!Ue(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var d=v>0?v:0,y=v<0?-v:0,x=f[0],D=f[1],h=Math.min(x-y,D-d),w;if(Ar(m)){if(m.length!==h)throw new Error("Invalid value array length");w=function(E){return m[E]}}else if(Je(m)){var g=m.size();if(g.length!==1||g[0]!==h)throw new Error("Invalid matrix length");w=function(E){return m.get([E])}}else w=function(){return m};p||(p=or(w(0))?w(0).mul(0):0);var b=[];if(f.length>0){b=Ea(b,f,p);for(var A=0;A<h;A++)b[A+y][A+d]=w(A)}return new n({data:b,size:[x,D]})},n.fromJSON=function(f){return new n(f)},n.prototype.swapRows=function(f,m){if(!Ye(f)||!Ue(f)||!Ye(m)||!Ue(m))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return _r(f,this._size[0]),_r(m,this._size[0]),n._swapRows(f,m,this._data),this},n._swapRows=function(f,m,v){var p=v[f];v[f]=v[m],v[m]=p};function c(f){return Je(f)?c(f.valueOf()):Ar(f)?f.map(c):f}return n},{isClass:!0}),Vl="clone",R1=["typed"],I1=L(Vl,R1,r=>{var{typed:e}=r;return e(Vl,{any:er})});function Gl(r){var e=r.length,t=r[0].length,n,a,i=[];for(a=0;a<t;a++){var o=[];for(n=0;n<e;n++)o.push(r[n][a]);i.push(o)}return i}function Sa(r){for(var e=0;e<r.length;e++)if(Mt(r[e]))return!0;return!1}function Rn(r,e){Je(r)?r.forEach(t=>e(t),!1,!0):Ll(r,e,!0)}function tr(r,e,t){if(!t)return Je(r)?r.map(a=>e(a),!1,!0):ms(r,e,!0);var n=a=>a===0?a:e(a);return Je(r)?r.map(a=>n(a),!1,!0):ms(r,n,!0)}function Qi(r,e,t){var n=Array.isArray(r)?rr(r):r.size();if(e<0||e>=n.length)throw new Yt(e,n.length);return Je(r)?r.create(Ki(r.valueOf(),e,t),r.datatype()):Ki(r,e,t)}function Ki(r,e,t){var n,a,i,o;if(e<=0)if(Array.isArray(r[0])){for(o=Gl(r),a=[],n=0;n<o.length;n++)a[n]=Ki(o[n],e-1,t);return a}else{for(i=r[0],n=1;n<r.length;n++)i=t(i,r[n]);return i}else{for(a=[],n=0;n<r.length;n++)a[n]=Ki(r[n],e-1,t);return a}}function Hl(r,e,t,n,a,i,o,l,u,s,c){var f=r._values,m=r._index,v=r._ptr,p,d,y,x;if(n)for(d=v[e],y=v[e+1],p=d;p<y;p++)x=m[p],t[x]!==i?(t[x]=i,o.push(x),n[x]=f[p]):(n[x]=l(n[x],f[p]),a[x]=i);else for(d=v[e],y=v[e+1],p=d;p<y;p++)x=m[p],t[x]!==i?(t[x]=i,o.push(x)):a[x]=i}var Wl="isInteger",P1=["typed","equal"],$1=L(Wl,P1,r=>{var{typed:e,equal:t}=r;return e(Wl,{number:n=>Number.isFinite(n)?t(n,Math.round(n)):!1,BigNumber:n=>n.isFinite()?t(n.round(),n):!1,bigint:n=>!0,Fraction:n=>n.d===1n,"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),Zt="number",Ca="number, number";function Yl(r){return Math.abs(r)}Yl.signature=Zt;function Zl(r,e){return r+e}Zl.signature=Ca;function Jl(r,e){return r-e}Jl.signature=Ca;function jl(r,e){return r*e}jl.signature=Ca;function Xl(r){return-r}Xl.signature=Zt;function Ql(r){return r}Ql.signature=Zt;function ai(r){return z0(r)}ai.signature=Zt;function Kl(r){return r*r*r}Kl.signature=Zt;function ec(r){return Math.exp(r)}ec.signature=Zt;function rc(r){return U0(r)}rc.signature=Zt;function tc(r,e){if(!Ue(r)||!Ue(e))throw new Error("Parameters in function lcm must be integer numbers");if(r===0||e===0)return 0;for(var t,n=r*e;e!==0;)t=e,e=r%t,r=t;return Math.abs(n/r)}tc.signature=Ca;function nc(r,e){return e?Math.log(r)/Math.log(e):Math.log(r)}function eo(r){return $0(r)}eo.signature=Zt;function vs(r){return P0(r)}vs.signature=Zt;function ac(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,t=e<0;if(t&&(e=-e),e===0)throw new Error("Root must be non-zero");if(r<0&&Math.abs(e)%2!==1)throw new Error("Root must be odd when a is negative.");if(r===0)return t?1/0:0;if(!isFinite(r))return t?0:r;var n=Math.pow(Math.abs(r),1/e);return n=r<0?-n:n,t?1/n:n}function ps(r){return Sn(r)}ps.signature=Zt;function ic(r){return r*r}ic.signature=Zt;function oc(r,e){var t,n,a,i=0,o=1,l=1,u=0;if(!Ue(r)||!Ue(e))throw new Error("Parameters in function xgcd must be integer numbers");for(;e;)n=Math.floor(r/e),a=r-n*e,t=i,i=o-n*i,o=t,t=l,l=u-n*l,u=t,r=e,e=a;var s;return r<0?s=[-r,-o,-u]:s=[r,r?o:0,u],s}oc.signature=Ca;function sc(r,e){return r*r<1&&e===1/0||r*r>1&&e===-1/0?0:Math.pow(r,e)}sc.signature=Ca;function ii(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!Ue(e)||e<0||e>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(al(r,e))}var q1="number",Ma="number, number";function uc(r,e){if(!Ue(r)||!Ue(e))throw new Error("Integers expected in function bitAnd");return r&e}uc.signature=Ma;function lc(r){if(!Ue(r))throw new Error("Integer expected in function bitNot");return~r}lc.signature=q1;function cc(r,e){if(!Ue(r)||!Ue(e))throw new Error("Integers expected in function bitOr");return r|e}cc.signature=Ma;function fc(r,e){if(!Ue(r)||!Ue(e))throw new Error("Integers expected in function bitXor");return r^e}fc.signature=Ma;function mc(r,e){if(!Ue(r)||!Ue(e))throw new Error("Integers expected in function leftShift");return r<<e}mc.signature=Ma;function vc(r,e){if(!Ue(r)||!Ue(e))throw new Error("Integers expected in function rightArithShift");return r>>e}vc.signature=Ma;function pc(r,e){if(!Ue(r)||!Ue(e))throw new Error("Integers expected in function rightLogShift");return r>>>e}pc.signature=Ma;function dn(r,e){if(e<r)return 1;if(e===r)return e;var t=e+r>>1;return dn(r,t)*dn(t+1,e)}function dc(r,e){if(!Ue(r)||r<0)throw new TypeError("Positive integer value expected in function combinations");if(!Ue(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(e>r)throw new TypeError("k must be less than or equal to n");for(var t=r-e,n=1,a=e<t?t+1:e+1,i=2,o=e<t?e:t,l=a;l<=r;++l)for(n*=l;i<=o&&n%i===0;)n/=i,++i;return i<=o&&(n/=dn(i,o)),n}dc.signature="number, number";var z1=Math.PI,U1=2*Math.PI,L1=Math.E,k1=1.618033988749895,V1="number",ds="number, number";function hc(r){return!r}hc.signature=V1;function hs(r,e){return!!(r||e)}hs.signature=ds;function gs(r,e){return!!r!=!!e}gs.signature=ds;function ys(r,e){return!!(r&&e)}ys.signature=ds;function ro(r){var e;if(Ue(r))return r<=0?Number.isFinite(r)?1/0:NaN:r>171?1/0:dn(1,r-1);if(r<.5)return Math.PI/(Math.sin(Math.PI*r)*ro(1-r));if(r>=171.35)return 1/0;if(r>85){var t=r*r,n=t*r,a=n*r,i=a*r;return Math.sqrt(2*Math.PI/r)*Math.pow(r/Math.E,r)*(1+1/(12*r)+1/(288*t)-139/(51840*n)-571/(2488320*a)+163879/(209018880*i)+5246819/(75246796800*i*r))}--r,e=_a[0];for(var o=1;o<_a.length;++o)e+=_a[o]/(r+o);var l=r+gc+.5;return Math.sqrt(2*Math.PI)*Math.pow(l,r+.5)*Math.exp(-l)*e}ro.signature="number";var gc=4.7421875,_a=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],yc=.9189385332046728,G1=5,H1=7,bc=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function to(r){if(r<0)return NaN;if(r===0)return 1/0;if(!Number.isFinite(r))return r;if(r<.5)return Math.log(Math.PI/Math.sin(Math.PI*r))-to(1-r);r=r-1;for(var e=r+G1+.5,t=bc[0],n=H1-1;n>=1;n--)t+=bc[n]/(r+n);return yc+(r+.5)*Math.log(e)-e+Math.log(t)}to.signature="number";var lt="number";function xc(r){return G0(r)}xc.signature=lt;function wc(r){return Math.atan(1/r)}wc.signature=lt;function Dc(r){return Number.isFinite(r)?(Math.log((r+1)/r)+Math.log(r/(r-1)))/2:0}Dc.signature=lt;function Nc(r){return Math.asin(1/r)}Nc.signature=lt;function Ec(r){var e=1/r;return Math.log(e+Math.sqrt(e*e+1))}Ec.signature=lt;function Ac(r){return Math.acos(1/r)}Ac.signature=lt;function Sc(r){var e=1/r,t=Math.sqrt(e*e-1);return Math.log(t+e)}Sc.signature=lt;function Cc(r){return H0(r)}Cc.signature=lt;function Mc(r){return W0(r)}Mc.signature=lt;function _c(r){return 1/Math.tan(r)}_c.signature=lt;function Tc(r){var e=Math.exp(2*r);return(e+1)/(e-1)}Tc.signature=lt;function Fc(r){return 1/Math.sin(r)}Fc.signature=lt;function Oc(r){return r===0?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(r)-Math.exp(-r)))*Sn(r)}Oc.signature=lt;function Bc(r){return 1/Math.cos(r)}Bc.signature=lt;function Rc(r){return 2/(Math.exp(r)+Math.exp(-r))}Rc.signature=lt;function Ic(r){return Z0(r)}Ic.signature=lt;var bs="number";function Pc(r){return r<0}Pc.signature=bs;function $c(r){return r>0}$c.signature=bs;function qc(r){return Number.isNaN(r)}qc.signature=bs;function zt(r,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e-9,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(t<=0)throw new Error("Relative tolerance must be greater than 0");if(n<0)throw new Error("Absolute tolerance must be at least 0");return r.isNaN()||e.isNaN()?!1:!r.isFinite()||!e.isFinite()?r.eq(e):r.eq(e)?!0:r.minus(e).abs().lte(r.constructor.max(r.constructor.max(r.abs(),e.abs()).mul(t),n))}var zc="isNegative",W1=["typed","config"],Y1=L(zc,W1,r=>{var{typed:e,config:t}=r;return e(zc,{number:n=>Xr(n,0,t.relTol,t.absTol)?!1:Pc(n),BigNumber:n=>zt(n,new n.constructor(0),t.relTol,t.absTol)?!1:n.isNeg()&&!n.isZero()&&!n.isNaN(),bigint:n=>n<0n,Fraction:n=>n.s<0n,Unit:e.referToSelf(n=>a=>e.find(n,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),Uc="isNumeric",Z1=["typed"],J1=L(Uc,Z1,r=>{var{typed:e}=r;return e(Uc,{"number | BigNumber | bigint | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),Lc="hasNumericValue",j1=["typed","isNumeric"],X1=L(Lc,j1,r=>{var{typed:e,isNumeric:t}=r;return e(Lc,{boolean:()=>!0,string:function(a){return a.trim().length>0&&!isNaN(Number(a))},any:function(a){return t(a)}})}),kc="isPositive",Q1=["typed","config"],K1=L(kc,Q1,r=>{var{typed:e,config:t}=r;return e(kc,{number:n=>Xr(n,0,t.relTol,t.absTol)?!1:$c(n),BigNumber:n=>zt(n,new n.constructor(0),t.relTol,t.absTol)?!1:!n.isNeg()&&!n.isZero()&&!n.isNaN(),bigint:n=>n>0n,Fraction:n=>n.s>0n&&n.n>0n,Unit:e.referToSelf(n=>a=>e.find(n,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),Vc="isZero",eb=["typed","equalScalar"],rb=L(Vc,eb,r=>{var{typed:e,equalScalar:t}=r;return e(Vc,{"number | BigNumber | Complex | Fraction":n=>t(n,0),bigint:n=>n===0n,Unit:e.referToSelf(n=>a=>e.find(n,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),Gc="isNaN",tb=["typed"],nb=L(Gc,tb,r=>{var{typed:e}=r;return e(Gc,{number:qc,BigNumber:function(n){return n.isNaN()},bigint:function(n){return!1},Fraction:function(n){return!1},Complex:function(n){return n.isNaN()},Unit:function(n){return Number.isNaN(n.value)},"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),Hc="isBounded",ab=["typed"],ib=L(Hc,ab,r=>{var{typed:e}=r;return e(Hc,{number:t=>Number.isFinite(t),"BigNumber | Complex":t=>t.isFinite(),"bigint | Fraction":()=>!0,"null | undefined":()=>!1,Unit:e.referToSelf(t=>n=>t(n.value)),"Array | Matrix":e.referToSelf(t=>n=>(Array.isArray(n)||(n=n.valueOf()),n.every(a=>t(a))))})}),Wc="isFinite",ob=["typed","isBounded","map"],sb=L(Wc,ob,r=>{var{typed:e,isBounded:t,map:n}=r;return e(Wc,{"Array | Matrix":a=>n(a,t),any:a=>t(a)})}),Yc="typeOf",ub=["typed"],lb=L(Yc,ub,r=>{var{typed:e}=r;return e(Yc,{any:Sr})});function cb(r,e,t,n){return Xr(r.re,e.re,t,n)&&Xr(r.im,e.im,t,n)}var Ta=L("compareUnits",["typed"],r=>{var{typed:e}=r;return{"Unit, Unit":e.referToSelf(t=>(n,a)=>{if(!n.equalBase(a))throw new Error("Cannot compare units with different base");return e.find(t,[n.valueType(),a.valueType()])(n.value,a.value)})}}),no="equalScalar",fb=["typed","config"],mb=L(no,fb,r=>{var{typed:e,config:t}=r,n=Ta({typed:e});return e(no,{"boolean, boolean":function(i,o){return i===o},"number, number":function(i,o){return Xr(i,o,t.relTol,t.absTol)},"BigNumber, BigNumber":function(i,o){return i.eq(o)||zt(i,o,t.relTol,t.absTol)},"bigint, bigint":function(i,o){return i===o},"Fraction, Fraction":function(i,o){return i.equals(o)},"Complex, Complex":function(i,o){return cb(i,o,t.relTol,t.absTol)}},n)});L(no,["typed","config"],r=>{var{typed:e,config:t}=r;return e(no,{"number, number":function(a,i){return Xr(a,i,t.relTol,t.absTol)}})});var vb="SparseMatrix",pb=["typed","equalScalar","Matrix"],db=L(vb,pb,r=>{var{typed:e,equalScalar:t,Matrix:n}=r;function a(d,y){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(y&&!$r(y))throw new Error("Invalid datatype: "+y);if(Je(d))i(this,d,y);else if(d&&Ar(d.index)&&Ar(d.ptr)&&Ar(d.size))this._values=d.values,this._index=d.index,this._ptr=d.ptr,this._size=d.size,this._datatype=y||d.datatype;else if(Ar(d))o(this,d,y);else{if(d)throw new TypeError("Unsupported type of data ("+Sr(d)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=y}}function i(d,y,x){y.type==="SparseMatrix"?(d._values=y._values?er(y._values):void 0,d._index=er(y._index),d._ptr=er(y._ptr),d._size=er(y._size),d._datatype=x||y._datatype):o(d,y.valueOf(),x||y._datatype)}function o(d,y,x){d._values=[],d._index=[],d._ptr=[],d._datatype=x;var D=y.length,h=0,w=t,g=0;if($r(x)&&(w=e.find(t,[x,x])||t,g=e.convert(0,x)),D>0){var b=0;do{d._ptr.push(d._index.length);for(var A=0;A<D;A++){var N=y[A];if(Ar(N)){if(b===0&&h<N.length&&(h=N.length),b<N.length){var E=N[b];w(E,g)||(d._values.push(E),d._index.push(A))}}else b===0&&h<1&&(h=1),w(N,g)||(d._values.push(N),d._index.push(A))}b++}while(b<h)}for(;d._ptr.length<=h;)d._ptr.push(d._index.length);d._size=[D,h]}a.prototype=new n,a.prototype.createSparseMatrix=function(d,y){return new a(d,y)},Object.defineProperty(a,"name",{value:"SparseMatrix"}),a.prototype.constructor=a,a.prototype.type="SparseMatrix",a.prototype.isSparseMatrix=!0,a.prototype.getDataType=function(){return Ji(this._values,Sr)},a.prototype.storage=function(){return"sparse"},a.prototype.datatype=function(){return this._datatype},a.prototype.create=function(d,y){return new a(d,y)},a.prototype.density=function(){var d=this._size[0],y=this._size[1];return d!==0&&y!==0?this._index.length/(d*y):0},a.prototype.subset=function(d,y,x){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return l(this,d);case 2:case 3:return u(this,d,y,x);default:throw new SyntaxError("Wrong number of arguments")}};function l(d,y){if(!Ti(y))throw new TypeError("Invalid index");var x=y.isScalar();if(x)return d.get(y.min());var D=y.size();if(D.length!==d._size.length)throw new ur(D.length,d._size.length);var h,w,g,b,A=y.min(),N=y.max();for(h=0,w=d._size.length;h<w;h++)_r(A[h],d._size[h]),_r(N[h],d._size[h]);var E=d._values,S=d._index,C=d._ptr,M=y.dimension(0),O=y.dimension(1),I=[],k=[];function _(ne,j){k[ne]=j[0],I[ne]=!0}Number.isInteger(M)?_(M,[0]):M.forEach(_);var P=E?[]:void 0,V=[],q=[];function J(ne){for(q.push(V.length),g=C[ne],b=C[ne+1];g<b;g++)h=S[g],I[h]===!0&&(V.push(k[h]),P&&P.push(E[g]))}return Number.isInteger(O)?J(O):O.forEach(J),q.push(V.length),new a({values:P,index:V,ptr:q,size:D,datatype:d._datatype})}function u(d,y,x,D){if(!y||y.isIndex!==!0)throw new TypeError("Invalid index");var h=y.size(),w=y.isScalar(),g;if(Je(x)?(g=x.size(),x=x.toArray()):g=rr(x),w){if(g.length!==0)throw new TypeError("Scalar expected");d.set(y.min(),x,D)}else{if(h.length!==1&&h.length!==2)throw new ur(h.length,d._size.length,"<");if(g.length<h.length){for(var b=0,A=0;h[b]===1&&g[b]===1;)b++;for(;h[b]===1;)A++,b++;x=Ol(x,h.length,A,g)}if(!mn(h,g))throw new ur(h,g,">");if(h.length===1){var N=y.dimension(0);C(N,(M,O)=>{_r(M),d.set([M,0],x[O[0]],D)})}else{var E=y.dimension(0),S=y.dimension(1);C(E,(M,O)=>{_r(M),C(S,(I,k)=>{_r(I),d.set([M,I],x[O[0]][k[0]],D)})})}}return d;function C(M,O){Ye(M)?O(M,[0]):M.forEach(O)}}a.prototype.get=function(d){if(!Ar(d))throw new TypeError("Array expected");if(d.length!==this._size.length)throw new ur(d.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var y=d[0],x=d[1];_r(y,this._size[0]),_r(x,this._size[1]);var D=s(y,this._ptr[x],this._ptr[x+1],this._index);return D<this._ptr[x+1]&&this._index[D]===y?this._values[D]:0},a.prototype.set=function(d,y,x){if(!Ar(d))throw new TypeError("Array expected");if(d.length!==this._size.length)throw new ur(d.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var D=d[0],h=d[1],w=this._size[0],g=this._size[1],b=t,A=0;$r(this._datatype)&&(b=e.find(t,[this._datatype,this._datatype])||t,A=e.convert(0,this._datatype)),(D>w-1||h>g-1)&&(m(this,Math.max(D+1,w),Math.max(h+1,g),x),w=this._size[0],g=this._size[1]),_r(D,w),_r(h,g);var N=s(D,this._ptr[h],this._ptr[h+1],this._index);return N<this._ptr[h+1]&&this._index[N]===D?b(y,A)?c(N,h,this._values,this._index,this._ptr):this._values[N]=y:b(y,A)||f(N,D,h,y,this._values,this._index,this._ptr),this};function s(d,y,x,D){if(x-y===0)return x;for(var h=y;h<x;h++)if(D[h]===d)return h;return y}function c(d,y,x,D,h){x.splice(d,1),D.splice(d,1);for(var w=y+1;w<h.length;w++)h[w]--}function f(d,y,x,D,h,w,g){h.splice(d,0,D),w.splice(d,0,y);for(var b=x+1;b<g.length;b++)g[b]++}a.prototype.resize=function(d,y,x){if(!Mt(d))throw new TypeError("Array or Matrix expected");var D=d.valueOf().map(w=>Array.isArray(w)&&w.length===1?w[0]:w);if(D.length!==2)throw new Error("Only two dimensions matrix are supported");D.forEach(function(w){if(!Ye(w)||!Ue(w)||w<0)throw new TypeError("Invalid size, must contain positive integers (size: "+lr(D)+")")});var h=x?this.clone():this;return m(h,D[0],D[1],y)};function m(d,y,x,D){var h=D||0,w=t,g=0;$r(d._datatype)&&(w=e.find(t,[d._datatype,d._datatype])||t,g=e.convert(0,d._datatype),h=e.convert(h,d._datatype));var b=!w(h,g),A=d._size[0],N=d._size[1],E,S,C;if(x>N){for(S=N;S<x;S++)if(d._ptr[S]=d._values.length,b)for(E=0;E<A;E++)d._values.push(h),d._index.push(E);d._ptr[x]=d._values.length}else x<N&&(d._ptr.splice(x+1,N-x),d._values.splice(d._ptr[x],d._values.length),d._index.splice(d._ptr[x],d._index.length));if(N=x,y>A){if(b){var M=0;for(S=0;S<N;S++){d._ptr[S]=d._ptr[S]+M,C=d._ptr[S+1]+M;var O=0;for(E=A;E<y;E++,O++)d._values.splice(C+O,0,h),d._index.splice(C+O,0,E),M++}d._ptr[N]=d._values.length}}else if(y<A){var I=0;for(S=0;S<N;S++){d._ptr[S]=d._ptr[S]-I;var k=d._ptr[S],_=d._ptr[S+1]-I;for(C=k;C<_;C++)E=d._index[C],E>y-1&&(d._values.splice(C,1),d._index.splice(C,1),I++)}d._ptr[S]=d._values.length}return d._size[0]=y,d._size[1]=x,d}a.prototype.reshape=function(d,y){if(!Ar(d))throw new TypeError("Array expected");if(d.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");d.forEach(function(q){if(!Ye(q)||!Ue(q)||q<=-2||q===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+lr(d)+")")});var x=this._size[0]*this._size[1];d=fs(d,x);var D=d[0]*d[1];if(x!==D)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var h=y?this.clone():this;if(this._size[0]===d[0]&&this._size[1]===d[1])return h;for(var w=[],g=0;g<h._ptr.length;g++)for(var b=0;b<h._ptr[g+1]-h._ptr[g];b++)w.push(g);for(var A=h._values.slice(),N=h._index.slice(),E=0;E<h._index.length;E++){var S=N[E],C=w[E],M=S*h._size[1]+C;w[E]=M%d[1],N[E]=Math.floor(M/d[1])}h._values.length=0,h._index.length=0,h._ptr.length=d[1]+1,h._size=d.slice();for(var O=0;O<h._ptr.length;O++)h._ptr[O]=0;for(var I=0;I<A.length;I++){var k=N[I],_=w[I],P=A[I],V=s(k,h._ptr[_],h._ptr[_+1],h._index);f(V,k,_,P,h._values,h._index,h._ptr)}return h},a.prototype.clone=function(){var d=new a({values:this._values?er(this._values):void 0,index:er(this._index),ptr:er(this._ptr),size:er(this._size),datatype:this._datatype});return d},a.prototype.size=function(){return this._size.slice(0)},a.prototype.map=function(d,y){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var x=this,D=this._size[0],h=this._size[1],w=Qn(d,x,"map"),g=function(A,N,E){return w.fn(A,[N,E],x)};return v(this,0,D-1,0,h-1,g,y)};function v(d,y,x,D,h,w,g){var b=[],A=[],N=[],E=t,S=0;$r(d._datatype)&&(E=e.find(t,[d._datatype,d._datatype])||t,S=e.convert(0,d._datatype));for(var C=function(F,U,$){var le=w(F,U,$);E(le,S)||(b.push(le),A.push(U))},M=D;M<=h;M++){N.push(b.length);var O=d._ptr[M],I=d._ptr[M+1];if(g)for(var k=O;k<I;k++){var _=d._index[k];_>=y&&_<=x&&C(d._values[k],_-y,M-D)}else{for(var P={},V=O;V<I;V++){var q=d._index[V];P[q]=d._values[V]}for(var J=y;J<=x;J++){var ne=J in P?P[J]:0;C(ne,J-y,M-D)}}}return N.push(b.length),new a({values:b,index:A,ptr:N,size:[x-y+1,h-D+1]})}a.prototype.forEach=function(d,y){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var x=this,D=this._size[0],h=this._size[1],w=Qn(d,x,"forEach"),g=0;g<h;g++){var b=this._ptr[g],A=this._ptr[g+1];if(y)for(var N=b;N<A;N++){var E=this._index[N];w.fn(this._values[N],[E,g],x)}else{for(var S={},C=b;C<A;C++){var M=this._index[C];S[M]=this._values[C]}for(var O=0;O<D;O++){var I=O in S?S[O]:0;w.fn(I,[O,g],x)}}}},a.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var d=this._size[1],y=0;y<d;y++)for(var x=this._ptr[y],D=this._ptr[y+1],h=x;h<D;h++){var w=this._index[h];yield{value:this._values[h],index:[w,y]}}},a.prototype.toArray=function(){return p(this._values,this._index,this._ptr,this._size,!0)},a.prototype.valueOf=function(){return p(this._values,this._index,this._ptr,this._size,!1)};function p(d,y,x,D,h){var w=D[0],g=D[1],b=[],A,N;for(A=0;A<w;A++)for(b[A]=[],N=0;N<g;N++)b[A][N]=0;for(N=0;N<g;N++)for(var E=x[N],S=x[N+1],C=E;C<S;C++)A=y[C],b[A][N]=d?h?er(d[C]):d[C]:1;return b}return a.prototype.format=function(d){for(var y=this._size[0],x=this._size[1],D=this.density(),h="Sparse Matrix ["+lr(y,d)+" x "+lr(x,d)+"] density: "+lr(D,d)+`
|
|
17
17
|
`,w=0;w<x;w++)for(var g=this._ptr[w],b=this._ptr[w+1],A=g;A<b;A++){var N=this._index[A];h+=`
|
|
18
|
-
(`+lr(N,d)+", "+lr(w,d)+") ==> "+(this._values?lr(this._values[A],d):"X")}return h},a.prototype.toString=function(){return lr(this.toArray())},a.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},a.prototype.diagonal=function(d){if(d){if(or(d)&&(d=d.toNumber()),!Ye(d)||!Ue(d))throw new TypeError("The parameter k must be an integer number")}else d=0;var y=d>0?d:0,x=d<0?-d:0,D=this._size[0],h=this._size[1],w=Math.min(D-x,h-y),g=[],b=[],A=[];A[0]=0;for(var N=y;N<h&&g.length<w;N++)for(var E=this._ptr[N],S=this._ptr[N+1],C=E;C<S;C++){var M=this._index[C];if(M===N-y+x){g.push(this._values[C]),b[g.length-1]=M-x;break}}return A.push(g.length),new a({values:g,index:b,ptr:A,size:[w,1]})},a.fromJSON=function(d){return new a(d)},a.diagonal=function(d,y,x,D,h){if(!Ar(d))throw new TypeError("Array expected, size parameter");if(d.length!==2)throw new Error("Only two dimensions matrix are supported");if(d=d.map(function(q){if(or(q)&&(q=q.toNumber()),!Ye(q)||!Ue(q)||q<1)throw new Error("Size values must be positive integers");return q}),x){if(or(x)&&(x=x.toNumber()),!Ye(x)||!Ue(x))throw new TypeError("The parameter k must be an integer number")}else x=0;var w=t,g=0;$r(h)&&(w=e.find(t,[h,h])||t,g=e.convert(0,h));var b=x>0?x:0,A=x<0?-x:0,N=d[0],E=d[1],S=Math.min(N-A,E-b),C;if(Ar(y)){if(y.length!==S)throw new Error("Invalid value array length");C=function(J){return y[J]}}else if(Je(y)){var M=y.size();if(M.length!==1||M[0]!==S)throw new Error("Invalid matrix length");C=function(J){return y.get([J])}}else C=function(){return y};for(var O=[],I=[],k=[],_=0;_<E;_++){k.push(O.length);var P=_-b;if(P>=0&&P<S){var V=C(P);w(V,g)||(I.push(P+A),O.push(V))}}return k.push(O.length),new a({values:O,index:I,ptr:k,size:[N,E]})},a.prototype.swapRows=function(d,y){if(!Ye(d)||!Ue(d)||!Ye(y)||!Ue(y))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return _r(d,this._size[0]),_r(y,this._size[0]),a._swapRows(d,y,this._size[1],this._values,this._index,this._ptr),this},a._forEachRow=function(d,y,x,D,h){for(var w=D[d],g=D[d+1],b=w;b<g;b++)h(x[b],y[b])},a._swapRows=function(d,y,x,D,h,w){for(var g=0;g<x;g++){var b=w[g],A=w[g+1],N=s(d,b,A,h),E=s(y,b,A,h);if(N<A&&E<A&&h[N]===d&&h[E]===y){if(D){var S=D[N];D[N]=D[E],D[E]=S}continue}if(N<A&&h[N]===d&&(E>=A||h[E]!==y)){var C=D?D[N]:void 0;h.splice(E,0,y),D&&D.splice(E,0,C),h.splice(E<=N?N+1:N,1),D&&D.splice(E<=N?N+1:N,1);continue}if(E<A&&h[E]===y&&(N>=A||h[N]!==d)){var M=D?D[E]:void 0;h.splice(N,0,d),D&&D.splice(N,0,M),h.splice(N<=E?E+1:E,1),D&&D.splice(N<=E?E+1:E,1)}}},a},{isClass:!0}),hb="number",gb=["typed"];function yb(r){var e=r.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(e){var t={"0b":2,"0o":8,"0x":16}[e[1]],n=e[2],a=e[3];return{input:r,radix:t,integerPart:n,fractionalPart:a}}else return null}function bb(r){for(var e=parseInt(r.integerPart,r.radix),t=0,n=0;n<r.fractionalPart.length;n++){var a=parseInt(r.fractionalPart[n],r.radix);t+=a/Math.pow(r.radix,n+1)}var i=e+t;if(isNaN(i))throw new SyntaxError('String "'+r.input+'" is not a valid number');return i}var xb=L(hb,gb,r=>{var{typed:e}=r,t=e("number",{"":function(){return 0},number:function(a){return a},string:function(a){if(a==="NaN")return NaN;var i=yb(a);if(i)return bb(i);var o=0,l=a.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);l&&(o=Number(l[2]),a=l[1]);var u=Number(a);if(isNaN(u))throw new SyntaxError('String "'+a+'" is not a valid number');if(l){if(u>2**o-1)throw new SyntaxError('String "'.concat(a,'" is out of range'));u>=2**(o-1)&&(u=u-2**o)}return u},BigNumber:function(a){return a.toNumber()},bigint:function(a){return Number(a)},Fraction:function(a){return a.valueOf()},Unit:e.referToSelf(n=>a=>{var i=a.clone();return i.value=n(a.value),i}),null:function(a){return 0},"Unit, string | Unit":function(a,i){return a.toNumber(i)},"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))});return t.fromJSON=function(n){return parseFloat(n.value)},t}),wb="bigint",Db=["typed"],Nb=L(wb,Db,r=>{var{typed:e}=r,t=e("bigint",{"":function(){return 0n},bigint:function(a){return a},number:function(a){return BigInt(a.toFixed())},BigNumber:function(a){return BigInt(a.round().toString())},Fraction:function(a){return BigInt(a.valueOf().toFixed())},"string | boolean":function(a){return BigInt(a)},null:function(a){return 0n},"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))});return t.fromJSON=function(n){return BigInt(n.value)},t}),Yc="string",Eb=["typed"],Ab=L(Yc,Eb,r=>{var{typed:e}=r;return e(Yc,{"":function(){return""},number:Zn,null:function(n){return"null"},boolean:function(n){return n+""},string:function(n){return n},"Array | Matrix":e.referToSelf(t=>n=>tr(n,t)),any:function(n){return String(n)}})}),Zc="boolean",Sb=["typed"],Cb=L(Zc,Sb,r=>{var{typed:e}=r;return e(Zc,{"":function(){return!1},boolean:function(n){return n},number:function(n){return!!n},null:function(n){return!1},BigNumber:function(n){return!n.isZero()},string:function(n){var a=n.toLowerCase();if(a==="true")return!0;if(a==="false")return!1;var i=Number(n);if(n!==""&&!isNaN(i))return!!i;throw new Error('Cannot convert "'+n+'" to a boolean')},"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),Mb="bignumber",_b=["typed","BigNumber"],Tb=L(Mb,_b,r=>{var{typed:e,BigNumber:t}=r;return e("bignumber",{"":function(){return new t(0)},number:function(a){return new t(a+"")},string:function(a){var i=a.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(i){var o=i[2],l=t(i[1]),u=new t(2).pow(Number(o));if(l.gt(u.sub(1)))throw new SyntaxError('String "'.concat(a,'" is out of range'));var s=new t(2).pow(Number(o)-1);return l.gte(s)?l.sub(u):l}return new t(a)},BigNumber:function(a){return a},bigint:function(a){return new t(a.toString())},Unit:e.referToSelf(n=>a=>{var i=a.clone();return i.value=n(a.value),i}),Fraction:function(a){return new t(String(a.n)).div(String(a.d)).times(String(a.s))},null:function(a){return new t(0)},"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),Fb="complex",Ob=["typed","Complex"],Bb=L(Fb,Ob,r=>{var{typed:e,Complex:t}=r;return e("complex",{"":function(){return t.ZERO},number:function(a){return new t(a,0)},"number, number":function(a,i){return new t(a,i)},"BigNumber, BigNumber":function(a,i){return new t(a.toNumber(),i.toNumber())},Fraction:function(a){return new t(a.valueOf(),0)},Complex:function(a){return a.clone()},string:function(a){return t(a)},null:function(a){return t(0)},Object:function(a){if("re"in a&&"im"in a)return new t(a.re,a.im);if("r"in a&&"phi"in a||"abs"in a&&"arg"in a)return new t(a);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),Rb="fraction",Ib=["typed","Fraction"],Pb=L(Rb,Ib,r=>{var{typed:e,Fraction:t}=r;return e("fraction",{number:function(a){if(!Number.isFinite(a)||isNaN(a))throw new Error(a+" cannot be represented as a fraction");return new t(a)},string:function(a){return new t(a)},"number, number":function(a,i){return new t(a,i)},"bigint, bigint":function(a,i){return new t(a,i)},null:function(a){return new t(0)},BigNumber:function(a){return new t(a.toString())},bigint:function(a){return new t(a.toString())},Fraction:function(a){return a},Unit:e.referToSelf(n=>a=>{var i=a.clone();return i.value=n(a.value),i}),Object:function(a){return new t(a)},"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),Jc="matrix",$b=["typed","Matrix","DenseMatrix","SparseMatrix"],qb=L(Jc,$b,r=>{var{typed:e,Matrix:t,DenseMatrix:n,SparseMatrix:a}=r;return e(Jc,{"":function(){return i([])},string:function(l){return i([],l)},"string, string":function(l,u){return i([],l,u)},Array:function(l){return i(l)},Matrix:function(l){return i(l,l.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(o,l,u){if(l==="dense"||l==="default"||l===void 0)return new n(o,u);if(l==="sparse")return new a(o,u);throw new TypeError("Unknown matrix type "+JSON.stringify(l)+".")}}),jc="matrixFromFunction",zb=["typed","matrix","isZero"],Ub=L(jc,zb,r=>{var{typed:e,matrix:t,isZero:n}=r;return e(jc,{"Array | Matrix, function, string, string":function(o,l,u,s){return a(o,l,u,s)},"Array | Matrix, function, string":function(o,l,u){return a(o,l,u)},"Matrix, function":function(o,l){return a(o,l,"dense")},"Array, function":function(o,l){return a(o,l,"dense").toArray()},"Array | Matrix, string, function":function(o,l,u){return a(o,u,l)},"Array | Matrix, string, string, function":function(o,l,u,s){return a(o,s,l,u)}});function a(i,o,l,u){var s;return u!==void 0?s=t(l,u):s=t(l),s.resize(i),s.forEach(function(c,f){var m=o(f);n(m)||s.set(f,m)}),s}}),Xc="matrixFromRows",Lb=["typed","matrix","flatten","size"],kb=L(Xc,Lb,r=>{var{typed:e,matrix:t,flatten:n,size:a}=r;return e(Xc,{"...Array":function(u){return i(u)},"...Matrix":function(u){return t(i(u.map(s=>s.toArray())))}});function i(l){if(l.length===0)throw new TypeError("At least one row is needed to construct a matrix.");var u=o(l[0]),s=[];for(var c of l){var f=o(c);if(f!==u)throw new TypeError("The vectors had different length: "+(u|0)+" ≠ "+(f|0));s.push(n(c))}return s}function o(l){var u=a(l);if(u.length===1)return u[0];if(u.length===2){if(u[0]===1)return u[1];if(u[1]===1)return u[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),Qc="matrixFromColumns",Vb=["typed","matrix","flatten","size"],Gb=L(Qc,Vb,r=>{var{typed:e,matrix:t,flatten:n,size:a}=r;return e(Qc,{"...Array":function(u){return i(u)},"...Matrix":function(u){return t(i(u.map(s=>s.toArray())))}});function i(l){if(l.length===0)throw new TypeError("At least one column is needed to construct a matrix.");for(var u=o(l[0]),s=[],c=0;c<u;c++)s[c]=[];for(var f of l){var m=o(f);if(m!==u)throw new TypeError("The vectors had different length: "+(u|0)+" ≠ "+(m|0));for(var v=n(f),p=0;p<u;p++)s[p].push(v[p])}return s}function o(l){var u=a(l);if(u.length===1)return u[0];if(u.length===2){if(u[0]===1)return u[1];if(u[1]===1)return u[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),Kc="splitUnit",Hb=["typed"],Wb=L(Kc,Hb,r=>{var{typed:e}=r;return e(Kc,{"Unit, Array":function(n,a){return n.splitUnit(a)}})}),ef="unaryMinus",Yb=["typed"],Zb=L(ef,Yb,r=>{var{typed:e}=r;return e(ef,{number:jl,"Complex | BigNumber | Fraction":t=>t.neg(),bigint:t=>-t,Unit:e.referToSelf(t=>n=>{var a=n.clone();return a.value=e.find(t,a.valueType())(n.value),a}),"Array | Matrix":e.referToSelf(t=>n=>tr(n,t,!0))})}),rf="unaryPlus",Jb=["typed","config","numeric"],jb=L(rf,Jb,r=>{var{typed:e,config:t,numeric:n}=r;return e(rf,{number:Xl,Complex:function(i){return i},BigNumber:function(i){return i},bigint:function(i){return i},Fraction:function(i){return i},Unit:function(i){return i.clone()},"Array | Matrix":e.referToSelf(a=>i=>tr(i,a,!0)),boolean:function(i){return n(i?1:0,t.number)},string:function(i){return n(i,An(i,t))}})}),tf="abs",Xb=["typed"],Qb=L(tf,Xb,r=>{var{typed:e}=r;return e(tf,{number:Wl,"Complex | BigNumber | Fraction | Unit":t=>t.abs(),bigint:t=>t<0n?-t:t,"Array | Matrix":e.referToSelf(t=>n=>tr(n,t,!0))})}),nf="mapSlices",Kb=["typed","isInteger"],xs=L(nf,Kb,r=>{var{typed:e,isInteger:t}=r;return e(nf,{"Array | Matrix, number | BigNumber, function":function(a,i,o){if(!t(i))throw new TypeError("Integer number expected for dimension");var l=Array.isArray(a)?rr(a):a.size();if(i<0||i>=l.length)throw new Yt(i,l.length);return Je(a)?a.create(ao(a.valueOf(),i,o),a.datatype()):ao(a,i,o)}})},{formerly:"apply"});function ao(r,e,t){var n,a,i;if(e<=0)if(Array.isArray(r[0])){for(i=ex(r),a=[],n=0;n<i.length;n++)a[n]=ao(i[n],e-1,t);return a}else return t(r);else{for(a=[],n=0;n<r.length;n++)a[n]=ao(r[n],e-1,t);return a}}function ex(r){var e=r.length,t=r[0].length,n,a,i=[];for(a=0;a<t;a++){var o=[];for(n=0;n<e;n++)o.push(r[n][a]);i.push(o)}return i}var af="addScalar",rx=["typed"],tx=L(af,rx,r=>{var{typed:e}=r;return e(af,{"number, number":Yl,"Complex, Complex":function(n,a){return n.add(a)},"BigNumber, BigNumber":function(n,a){return n.plus(a)},"bigint, bigint":function(n,a){return n+a},"Fraction, Fraction":function(n,a){return n.add(a)},"Unit, Unit":e.referToSelf(t=>(n,a)=>{if(n.value===null||n.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(a.value===null||a.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!n.equalBase(a))throw new Error("Units do not match");var i=n.clone();return i.value=e.find(t,[i.valueType(),a.valueType()])(i.value,a.value),i.fixPrefix=!1,i})})}),of="subtractScalar",nx=["typed"],ax=L(of,nx,r=>{var{typed:e}=r;return e(of,{"number, number":Zl,"Complex, Complex":function(n,a){return n.sub(a)},"BigNumber, BigNumber":function(n,a){return n.minus(a)},"bigint, bigint":function(n,a){return n-a},"Fraction, Fraction":function(n,a){return n.sub(a)},"Unit, Unit":e.referToSelf(t=>(n,a)=>{if(n.value===null||n.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(a.value===null||a.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!n.equalBase(a))throw new Error("Units do not match");var i=n.clone();return i.value=e.find(t,[i.valueType(),a.valueType()])(i.value,a.value),i.fixPrefix=!1,i})})}),sf="cbrt",ix=["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],ox=L(sf,ix,r=>{var{config:e,typed:t,isNegative:n,unaryMinus:a,matrix:i,Complex:o,BigNumber:l,Fraction:u}=r;return t(sf,{number:ai,Complex:s,"Complex, boolean":s,BigNumber:function(m){return m.cbrt()},Unit:c});function s(f,m){var v=f.arg()/3,p=f.abs(),d=new o(ai(p),0).mul(new o(0,v).exp());if(m){var y=[d,new o(ai(p),0).mul(new o(0,v+Math.PI*2/3).exp()),new o(ai(p),0).mul(new o(0,v-Math.PI*2/3).exp())];return e.matrix==="Array"?y:i(y)}else return d}function c(f){if(f.value&&ln(f.value)){var m=f.clone();return m.value=1,m=m.pow(1/3),m.value=s(f.value),m}else{var v=n(f.value);v&&(f.value=a(f.value));var p;or(f.value)?p=new l(1).div(3):Ka(f.value)?p=new u(1,3):p=1/3;var d=f.pow(p);return v&&(d.value=a(d.value)),d}}}),sx="matAlgo11xS0s",ux=["typed","equalScalar"],tt=L(sx,ux,r=>{var{typed:e,equalScalar:t}=r;return function(a,i,o,l){var u=a._values,s=a._index,c=a._ptr,f=a._size,m=a._datatype;if(!u)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=f[0],p=f[1],d,y=t,x=0,D=o;typeof m=="string"&&(d=m,y=e.find(t,[d,d]),x=e.convert(0,d),i=e.convert(i,d),D=e.find(o,[d,d]));for(var h=[],w=[],g=[],b=0;b<p;b++){g[b]=w.length;for(var A=c[b],N=c[b+1],E=A;E<N;E++){var S=s[E],C=l?D(i,u[E]):D(u[E],i);y(C,x)||(w.push(S),h.push(C))}}return g[p]=w.length,a.createSparseMatrix({values:h,index:w,ptr:g,size:[v,p],datatype:d})}}),lx="matAlgo12xSfs",cx=["typed","DenseMatrix"],Hr=L(lx,cx,r=>{var{typed:e,DenseMatrix:t}=r;return function(a,i,o,l){var u=a._values,s=a._index,c=a._ptr,f=a._size,m=a._datatype;if(!u)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=f[0],p=f[1],d,y=o;typeof m=="string"&&(d=m,i=e.convert(i,d),y=e.find(o,[d,d]));for(var x=[],D=[],h=[],w=0;w<p;w++){for(var g=w+1,b=c[w],A=c[w+1],N=b;N<A;N++){var E=s[N];D[E]=u[N],h[E]=g}for(var S=0;S<v;S++)w===0&&(x[S]=[]),h[S]===g?x[S][w]=l?y(i,D[S]):y(D[S],i):x[S][w]=l?y(i,0):y(0,i)}return new t({data:x,size:[v,p],datatype:d})}}),fx="matAlgo14xDs",mx=["typed"],Ut=L(fx,mx,r=>{var{typed:e}=r;return function(a,i,o,l){var u=a._data,s=a._size,c=a._datatype,f,m=o;typeof c=="string"&&(f=c,i=e.convert(i,f),m=e.find(o,[f,f]));var v=s.length>0?t(m,0,s,s[0],u,i,l):[];return a.createDenseMatrix({data:v,size:er(s),datatype:f})};function t(n,a,i,o,l,u,s){var c=[];if(a===i.length-1)for(var f=0;f<o;f++)c[f]=s?n(u,l[f]):n(l[f],u);else for(var m=0;m<o;m++)c[m]=t(n,a+1,i,i[a+1],l[m],u,s);return c}}),ws="ceil",vx=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],px=new Fn(10),dx=L(ws,["typed","config","round"],r=>{var{typed:e,config:t,round:n}=r;function a(i){var o=Math.ceil(i),l=n(i);return o===l?o:jr(i,l,t.relTol,t.absTol)&&!jr(i,o,t.relTol,t.absTol)?l:o}return e(ws,{number:a,"number, number":function(o,l){if(!Ue(l))throw new RangeError("number of decimals in function ceil must be an integer");if(l<0||l>15)throw new RangeError("number of decimals in ceil number must be in range 0-15");var u=10**l;return a(o*u)/u}})}),hx=L(ws,vx,r=>{var{typed:e,config:t,round:n,matrix:a,equalScalar:i,zeros:o,DenseMatrix:l}=r,u=tt({typed:e,equalScalar:i}),s=Hr({typed:e,DenseMatrix:l}),c=Ut({typed:e}),f=dx({typed:e,config:t,round:n});function m(v){var p=(x,D)=>zt(x,D,t.relTol,t.absTol),d=v.ceil(),y=n(v);return d.eq(y)?d:p(v,y)&&!p(v,d)?y:d}return e("ceil",{number:f.signatures.number,"number,number":f.signatures["number,number"],Complex:function(p){return p.ceil()},"Complex, number":function(p,d){return p.ceil(d)},"Complex, BigNumber":function(p,d){return p.ceil(d.toNumber())},BigNumber:m,"BigNumber, BigNumber":function(p,d){var y=px.pow(d);return m(p.mul(y)).div(y)},bigint:v=>v,"bigint, number":(v,p)=>v,"bigint, BigNumber":(v,p)=>v,Fraction:function(p){return p.ceil()},"Fraction, number":function(p,d){return p.ceil(d)},"Fraction, BigNumber":function(p,d){return p.ceil(d.toNumber())},"Unit, number, Unit":e.referToSelf(v=>function(p,d,y){var x=p.toNumeric(y);return y.multiply(v(x,d))}),"Unit, BigNumber, Unit":e.referToSelf(v=>(p,d,y)=>v(p,d.toNumber(),y)),"Array | Matrix, number | BigNumber, Unit":e.referToSelf(v=>(p,d,y)=>tr(p,x=>v(x,d,y),!0)),"Array | Matrix | Unit, Unit":e.referToSelf(v=>(p,d)=>v(p,0,d)),"Array | Matrix":e.referToSelf(v=>p=>tr(p,v,!0)),"Array, number | BigNumber":e.referToSelf(v=>(p,d)=>tr(p,y=>v(y,d),!0)),"SparseMatrix, number | BigNumber":e.referToSelf(v=>(p,d)=>u(p,d,v,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(v=>(p,d)=>c(p,d,v,!1)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(v=>(p,d)=>c(a(d),p,v,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(v=>(p,d)=>i(p,0)?o(d.size(),d.storage()):d.storage()==="dense"?c(d,p,v,!0):s(d,p,v,!0))})}),uf="cube",gx=["typed"],yx=L(uf,gx,r=>{var{typed:e}=r;return e(uf,{number:Ql,Complex:function(n){return n.mul(n).mul(n)},BigNumber:function(n){return n.times(n).times(n)},bigint:function(n){return n*n*n},Fraction:function(n){return n.pow(3)},Unit:function(n){return n.pow(3)}})}),lf="exp",bx=["typed"],xx=L(lf,bx,r=>{var{typed:e}=r;return e(lf,{number:Kl,Complex:function(n){return n.exp()},BigNumber:function(n){return n.exp()}})}),cf="expm1",wx=["typed","Complex"],Dx=L(cf,wx,r=>{var{typed:e,Complex:t}=r;return e(cf,{number:ec,Complex:function(a){var i=Math.exp(a.re);return new t(i*Math.cos(a.im)-1,i*Math.sin(a.im))},BigNumber:function(a){return a.exp().minus(1)}})}),Ds="fix",Nx=["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],Ex=L(Ds,["typed","ceil","floor"],r=>{var{typed:e,ceil:t,floor:n}=r;return e(Ds,{number:function(i){return i>0?n(i):t(i)},"number, number":function(i,o){return i>0?n(i,o):t(i,o)}})}),Ax=L(Ds,Nx,r=>{var{typed:e,Complex:t,matrix:n,ceil:a,floor:i,equalScalar:o,zeros:l,DenseMatrix:u}=r,s=Hr({typed:e,DenseMatrix:u}),c=Ut({typed:e}),f=Ex({typed:e,ceil:a,floor:i});return e("fix",{number:f.signatures.number,"number, number | BigNumber":f.signatures["number,number"],Complex:function(v){return new t(v.re>0?Math.floor(v.re):Math.ceil(v.re),v.im>0?Math.floor(v.im):Math.ceil(v.im))},"Complex, number":function(v,p){return new t(v.re>0?i(v.re,p):a(v.re,p),v.im>0?i(v.im,p):a(v.im,p))},"Complex, BigNumber":function(v,p){var d=p.toNumber();return new t(v.re>0?i(v.re,d):a(v.re,d),v.im>0?i(v.im,d):a(v.im,d))},BigNumber:function(v){return v.isNegative()?a(v):i(v)},"BigNumber, number | BigNumber":function(v,p){return v.isNegative()?a(v,p):i(v,p)},bigint:m=>m,"bigint, number":(m,v)=>m,"bigint, BigNumber":(m,v)=>m,Fraction:function(v){return v.s<0n?v.ceil():v.floor()},"Fraction, number | BigNumber":function(v,p){return v.s<0n?a(v,p):i(v,p)},"Unit, number, Unit":e.referToSelf(m=>function(v,p,d){var y=v.toNumeric(d);return d.multiply(m(y,p))}),"Unit, BigNumber, Unit":e.referToSelf(m=>(v,p,d)=>m(v,p.toNumber(),d)),"Array | Matrix, number | BigNumber, Unit":e.referToSelf(m=>(v,p,d)=>tr(v,y=>m(y,p,d),!0)),"Array | Matrix | Unit, Unit":e.referToSelf(m=>(v,p)=>m(v,0,p)),"Array | Matrix":e.referToSelf(m=>v=>tr(v,m,!0)),"Array | Matrix, number | BigNumber":e.referToSelf(m=>(v,p)=>tr(v,d=>m(d,p),!0)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,p)=>c(n(p),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,p)=>o(v,0)?l(p.size(),p.storage()):p.storage()==="dense"?c(p,v,m,!0):s(p,v,m,!0))})}),Ns="floor",Sx=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],Cx=new Fn(10),Mx=L(Ns,["typed","config","round"],r=>{var{typed:e,config:t,round:n}=r;function a(i){var o=Math.floor(i),l=n(i);return o===l?o:jr(i,l,t.relTol,t.absTol)&&!jr(i,o,t.relTol,t.absTol)?l:o}return e(Ns,{number:a,"number, number":function(o,l){if(!Ue(l))throw new RangeError("number of decimals in function floor must be an integer");if(l<0||l>15)throw new RangeError("number of decimals in floor number must be in range 0 - 15");var u=10**l;return a(o*u)/u}})}),ff=L(Ns,Sx,r=>{var{typed:e,config:t,round:n,matrix:a,equalScalar:i,zeros:o,DenseMatrix:l}=r,u=tt({typed:e,equalScalar:i}),s=Hr({typed:e,DenseMatrix:l}),c=Ut({typed:e}),f=Mx({typed:e,config:t,round:n});function m(v){var p=(x,D)=>zt(x,D,t.relTol,t.absTol),d=v.floor(),y=n(v);return d.eq(y)?d:p(v,y)&&!p(v,d)?y:d}return e("floor",{number:f.signatures.number,"number,number":f.signatures["number,number"],Complex:function(p){return p.floor()},"Complex, number":function(p,d){return p.floor(d)},"Complex, BigNumber":function(p,d){return p.floor(d.toNumber())},BigNumber:m,"BigNumber, BigNumber":function(p,d){var y=Cx.pow(d);return m(p.mul(y)).div(y)},bigint:v=>v,"bigint, number":(v,p)=>v,"bigint, BigNumber":(v,p)=>v,Fraction:function(p){return p.floor()},"Fraction, number":function(p,d){return p.floor(d)},"Fraction, BigNumber":function(p,d){return p.floor(d.toNumber())},"Unit, number, Unit":e.referToSelf(v=>function(p,d,y){var x=p.toNumeric(y);return y.multiply(v(x,d))}),"Unit, BigNumber, Unit":e.referToSelf(v=>(p,d,y)=>v(p,d.toNumber(),y)),"Array | Matrix, number | BigNumber, Unit":e.referToSelf(v=>(p,d,y)=>tr(p,x=>v(x,d,y),!0)),"Array | Matrix | Unit, Unit":e.referToSelf(v=>(p,d)=>v(p,0,d)),"Array | Matrix":e.referToSelf(v=>p=>tr(p,v,!0)),"Array, number | BigNumber":e.referToSelf(v=>(p,d)=>tr(p,y=>v(y,d),!0)),"SparseMatrix, number | BigNumber":e.referToSelf(v=>(p,d)=>u(p,d,v,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(v=>(p,d)=>c(p,d,v,!1)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(v=>(p,d)=>c(a(d),p,v,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(v=>(p,d)=>i(p,0)?o(d.size(),d.storage()):d.storage()==="dense"?c(d,p,v,!0):s(d,p,v,!0))})}),_x="matAlgo02xDS0",Tx=["typed","equalScalar"],Jt=L(_x,Tx,r=>{var{typed:e,equalScalar:t}=r;return function(a,i,o,l){var u=a._data,s=a._size,c=a._datatype||a.getDataType(),f=i._values,m=i._index,v=i._ptr,p=i._size,d=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(s.length!==p.length)throw new ur(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var y=s[0],x=s[1],D,h=t,w=0,g=o;typeof c=="string"&&c===d&&c!=="mixed"&&(D=c,h=e.find(t,[D,D]),w=e.convert(0,D),g=e.find(o,[D,D]));for(var b=[],A=[],N=[],E=0;E<x;E++){N[E]=A.length;for(var S=v[E],C=v[E+1],M=S;M<C;M++){var O=m[M],I=l?g(f[M],u[O][E]):g(u[O][E],f[M]);h(I,w)||(A.push(O),b.push(I))}}return N[x]=A.length,i.createSparseMatrix({values:b,index:A,ptr:N,size:[y,x],datatype:c===a._datatype&&d===i._datatype?D:void 0})}}),Fx="matAlgo03xDSf",Ox=["typed"],lt=L(Fx,Ox,r=>{var{typed:e}=r;return function(n,a,i,o){var l=n._data,u=n._size,s=n._datatype||n.getDataType(),c=a._values,f=a._index,m=a._ptr,v=a._size,p=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(u.length!==v.length)throw new ur(u.length,v.length);if(u[0]!==v[0]||u[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+v+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var d=u[0],y=u[1],x,D=0,h=i;typeof s=="string"&&s===p&&s!=="mixed"&&(x=s,D=e.convert(0,x),h=e.find(i,[x,x]));for(var w=[],g=0;g<d;g++)w[g]=[];for(var b=[],A=[],N=0;N<y;N++){for(var E=N+1,S=m[N],C=m[N+1],M=S;M<C;M++){var O=f[M];b[O]=o?h(c[M],l[O][N]):h(l[O][N],c[M]),A[O]=E}for(var I=0;I<d;I++)A[I]===E?w[I][N]=b[I]:w[I][N]=o?h(D,l[I][N]):h(l[I][N],D)}return n.createDenseMatrix({data:w,size:[d,y],datatype:s===n._datatype&&p===a._datatype?x:void 0})}}),Bx="matAlgo05xSfSf",Rx=["typed","equalScalar"],io=L(Bx,Rx,r=>{var{typed:e,equalScalar:t}=r;return function(a,i,o){var l=a._values,u=a._index,s=a._ptr,c=a._size,f=a._datatype||a._data===void 0?a._datatype:a.getDataType(),m=i._values,v=i._index,p=i._ptr,d=i._size,y=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(c.length!==d.length)throw new ur(c.length,d.length);if(c[0]!==d[0]||c[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+d+")");var x=c[0],D=c[1],h,w=t,g=0,b=o;typeof f=="string"&&f===y&&f!=="mixed"&&(h=f,w=e.find(t,[h,h]),g=e.convert(0,h),b=e.find(o,[h,h]));var A=l&&m?[]:void 0,N=[],E=[],S=A?[]:void 0,C=A?[]:void 0,M=[],O=[],I,k,_,P;for(k=0;k<D;k++){E[k]=N.length;var V=k+1;for(_=s[k],P=s[k+1];_<P;_++)I=u[_],N.push(I),M[I]=V,S&&(S[I]=l[_]);for(_=p[k],P=p[k+1];_<P;_++)I=v[_],M[I]!==V&&N.push(I),O[I]=V,C&&(C[I]=m[_]);if(A)for(_=E[k];_<N.length;){I=N[_];var q=M[I],J=O[I];if(q===V||J===V){var ne=q===V?S[I]:g,j=J===V?C[I]:g,F=b(ne,j);w(F,g)?N.splice(_,1):(A.push(F),_++)}}}return E[D]=N.length,a.createSparseMatrix({values:A,index:N,ptr:E,size:[x,D],datatype:f===a._datatype&&y===i._datatype?h:void 0})}}),Ix="matAlgo13xDD",Px=["typed"],mf=L(Ix,Px,r=>{var{typed:e}=r;return function(a,i,o){var l=a._data,u=a._size,s=a._datatype,c=i._data,f=i._size,m=i._datatype,v=[];if(u.length!==f.length)throw new ur(u.length,f.length);for(var p=0;p<u.length;p++){if(u[p]!==f[p])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+f+")");v[p]=u[p]}var d,y=o;typeof s=="string"&&s===m&&(d=s,y=e.find(o,[d,d]));var x=v.length>0?t(y,0,v,v[0],l,c):[];return a.createDenseMatrix({data:x,size:v,datatype:d})};function t(n,a,i,o,l,u){var s=[];if(a===i.length-1)for(var c=0;c<o;c++)s[c]=n(l[c],u[c]);else for(var f=0;f<o;f++)s[f]=t(n,a+1,i,i[a+1],l[f],u[f]);return s}});function Kr(r,e){if(mn(r.size(),e.size()))return[r,e];var t=ji(r.size(),e.size());return[r,e].map(n=>$x(n,t))}function $x(r,e){return mn(r.size(),e)?r:r.create(Xn(r.valueOf(),e),r.datatype())}var qx="matrixAlgorithmSuite",zx=["typed","matrix"],Tr=L(qx,zx,r=>{var{typed:e,matrix:t}=r,n=mf({typed:e}),a=Ut({typed:e});return function(o){var l=o.elop,u=o.SD||o.DS,s;l?(s={"DenseMatrix, DenseMatrix":(v,p)=>n(...Kr(v,p),l),"Array, Array":(v,p)=>n(...Kr(t(v),t(p)),l).valueOf(),"Array, DenseMatrix":(v,p)=>n(...Kr(t(v),p),l),"DenseMatrix, Array":(v,p)=>n(...Kr(v,t(p)),l)},o.SS&&(s["SparseMatrix, SparseMatrix"]=(v,p)=>o.SS(...Kr(v,p),l,!1)),o.DS&&(s["DenseMatrix, SparseMatrix"]=(v,p)=>o.DS(...Kr(v,p),l,!1),s["Array, SparseMatrix"]=(v,p)=>o.DS(...Kr(t(v),p),l,!1)),u&&(s["SparseMatrix, DenseMatrix"]=(v,p)=>u(...Kr(p,v),l,!0),s["SparseMatrix, Array"]=(v,p)=>u(...Kr(t(p),v),l,!0))):(s={"DenseMatrix, DenseMatrix":e.referToSelf(v=>(p,d)=>n(...Kr(p,d),v)),"Array, Array":e.referToSelf(v=>(p,d)=>n(...Kr(t(p),t(d)),v).valueOf()),"Array, DenseMatrix":e.referToSelf(v=>(p,d)=>n(...Kr(t(p),d),v)),"DenseMatrix, Array":e.referToSelf(v=>(p,d)=>n(...Kr(p,t(d)),v))},o.SS&&(s["SparseMatrix, SparseMatrix"]=e.referToSelf(v=>(p,d)=>o.SS(...Kr(p,d),v,!1))),o.DS&&(s["DenseMatrix, SparseMatrix"]=e.referToSelf(v=>(p,d)=>o.DS(...Kr(p,d),v,!1)),s["Array, SparseMatrix"]=e.referToSelf(v=>(p,d)=>o.DS(...Kr(t(p),d),v,!1))),u&&(s["SparseMatrix, DenseMatrix"]=e.referToSelf(v=>(p,d)=>u(...Kr(d,p),v,!0)),s["SparseMatrix, Array"]=e.referToSelf(v=>(p,d)=>u(...Kr(t(d),p),v,!0))));var c=o.scalar||"any",f=o.Ds||o.Ss;f&&(l?(s["DenseMatrix,"+c]=(v,p)=>a(v,p,l,!1),s[c+", DenseMatrix"]=(v,p)=>a(p,v,l,!0),s["Array,"+c]=(v,p)=>a(t(v),p,l,!1).valueOf(),s[c+", Array"]=(v,p)=>a(t(p),v,l,!0).valueOf()):(s["DenseMatrix,"+c]=e.referToSelf(v=>(p,d)=>a(p,d,v,!1)),s[c+", DenseMatrix"]=e.referToSelf(v=>(p,d)=>a(d,p,v,!0)),s["Array,"+c]=e.referToSelf(v=>(p,d)=>a(t(p),d,v,!1).valueOf()),s[c+", Array"]=e.referToSelf(v=>(p,d)=>a(t(d),p,v,!0).valueOf())));var m=o.sS!==void 0?o.sS:o.Ss;return l?(o.Ss&&(s["SparseMatrix,"+c]=(v,p)=>o.Ss(v,p,l,!1)),m&&(s[c+", SparseMatrix"]=(v,p)=>m(p,v,l,!0))):(o.Ss&&(s["SparseMatrix,"+c]=e.referToSelf(v=>(p,d)=>o.Ss(p,d,v,!1))),m&&(s[c+", SparseMatrix"]=e.referToSelf(v=>(p,d)=>m(d,p,v,!0)))),l&&l.signatures&&Qu(s,l.signatures),s}}),vf="mod",Ux=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix","concat"],pf=L(vf,Ux,r=>{var{typed:e,config:t,round:n,matrix:a,equalScalar:i,zeros:o,DenseMatrix:l,concat:u}=r,s=ff({typed:e,config:t,round:n,matrix:a,equalScalar:i,zeros:o,DenseMatrix:l}),c=Jt({typed:e,equalScalar:i}),f=lt({typed:e}),m=io({typed:e,equalScalar:i}),v=tt({typed:e,equalScalar:i}),p=Hr({typed:e,DenseMatrix:l}),d=Tr({typed:e,matrix:a,concat:u});return e(vf,{"number, number":y,"BigNumber, BigNumber":function(D,h){return h.isZero()?D:D.sub(h.mul(s(D.div(h))))},"bigint, bigint":function(D,h){if(h===0n)return D;if(D<0){var w=D%h;return w===0n?w:w+h}return D%h},"Fraction, Fraction":function(D,h){return h.equals(0)?D:D.sub(h.mul(s(D.div(h))))}},d({SS:m,DS:f,SD:c,Ss:v,sS:p}));function y(x,D){return D===0?x:x-D*s(x/D)}}),Lx="matAlgo01xDSid",kx=["typed"],In=L(Lx,kx,r=>{var{typed:e}=r;return function(n,a,i,o){var l=n._data,u=n._size,s=n._datatype||n.getDataType(),c=a._values,f=a._index,m=a._ptr,v=a._size,p=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(u.length!==v.length)throw new ur(u.length,v.length);if(u[0]!==v[0]||u[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+v+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var d=u[0],y=u[1],x=typeof s=="string"&&s!=="mixed"&&s===p?s:void 0,D=x?e.find(i,[x,x]):i,h,w,g=[];for(h=0;h<d;h++)g[h]=[];var b=[],A=[];for(w=0;w<y;w++){for(var N=w+1,E=m[w],S=m[w+1],C=E;C<S;C++)h=f[C],b[h]=o?D(c[C],l[h][w]):D(l[h][w],c[C]),A[h]=N;for(h=0;h<d;h++)A[h]===N?g[h][w]=b[h]:g[h][w]=l[h][w]}return n.createDenseMatrix({data:g,size:[d,y],datatype:s===n._datatype&&p===a._datatype?x:void 0})}}),Vx="matAlgo04xSidSid",Gx=["typed","equalScalar"],Es=L(Vx,Gx,r=>{var{typed:e,equalScalar:t}=r;return function(a,i,o){var l=a._values,u=a._index,s=a._ptr,c=a._size,f=a._datatype||a._data===void 0?a._datatype:a.getDataType(),m=i._values,v=i._index,p=i._ptr,d=i._size,y=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(c.length!==d.length)throw new ur(c.length,d.length);if(c[0]!==d[0]||c[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+d+")");var x=c[0],D=c[1],h,w=t,g=0,b=o;typeof f=="string"&&f===y&&f!=="mixed"&&(h=f,w=e.find(t,[h,h]),g=e.convert(0,h),b=e.find(o,[h,h]));var A=l&&m?[]:void 0,N=[],E=[],S=l&&m?[]:void 0,C=l&&m?[]:void 0,M=[],O=[],I,k,_,P,V;for(k=0;k<D;k++){E[k]=N.length;var q=k+1;for(P=s[k],V=s[k+1],_=P;_<V;_++)I=u[_],N.push(I),M[I]=q,S&&(S[I]=l[_]);for(P=p[k],V=p[k+1],_=P;_<V;_++)if(I=v[_],M[I]===q){if(S){var J=b(S[I],m[_]);w(J,g)?M[I]=null:S[I]=J}}else N.push(I),O[I]=q,C&&(C[I]=m[_]);if(S&&C)for(_=E[k];_<N.length;)I=N[_],M[I]===q?(A[_]=S[I],_++):O[I]===q?(A[_]=C[I],_++):N.splice(_,1)}return E[D]=N.length,a.createSparseMatrix({values:A,index:N,ptr:E,size:[x,D],datatype:f===a._datatype&&y===i._datatype?h:void 0})}}),Hx="matAlgo10xSids",Wx=["typed","DenseMatrix"],Kn=L(Hx,Wx,r=>{var{typed:e,DenseMatrix:t}=r;return function(a,i,o,l){var u=a._values,s=a._index,c=a._ptr,f=a._size,m=a._datatype;if(!u)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=f[0],p=f[1],d,y=o;typeof m=="string"&&(d=m,i=e.convert(i,d),y=e.find(o,[d,d]));for(var x=[],D=[],h=[],w=0;w<p;w++){for(var g=w+1,b=c[w],A=c[w+1],N=b;N<A;N++){var E=s[N];D[E]=u[N],h[E]=g}for(var S=0;S<v;S++)w===0&&(x[S]=[]),h[S]===g?x[S][w]=l?y(i,D[S]):y(D[S],i):x[S][w]=i}return new t({data:x,size:[v,p],datatype:d})}});function ea(r,e,t,n){if(!(this instanceof ea))throw new SyntaxError("Constructor must be called with the new operator");this.fn=r,this.count=e,this.min=t,this.max=n,this.message="Wrong number of arguments in function "+r+" ("+e+" provided, "+t+(n!=null?"-"+n:"")+" expected)",this.stack=new Error().stack}ea.prototype=new Error,ea.prototype.constructor=Error,ea.prototype.name="ArgumentsError",ea.prototype.isArgumentsError=!0;var df="gcd",Yx=["typed","config","round","matrix","equalScalar","zeros","BigNumber","DenseMatrix","concat"],As="number | BigNumber | Fraction | Matrix | Array",Zx="".concat(As,", ").concat(As,", ...").concat(As);function hf(r){return!r.some(e=>Array.isArray(e))}var Jx=L(df,Yx,r=>{var{typed:e,matrix:t,config:n,round:a,equalScalar:i,zeros:o,BigNumber:l,DenseMatrix:u,concat:s}=r,c=pf({typed:e,config:n,round:a,matrix:t,equalScalar:i,zeros:o,DenseMatrix:u,concat:s}),f=In({typed:e}),m=Es({typed:e,equalScalar:i}),v=Kn({typed:e,DenseMatrix:u}),p=Tr({typed:e,matrix:t,concat:s});return e(df,{"number, number":d,"BigNumber, BigNumber":y,"Fraction, Fraction":(x,D)=>x.gcd(D)},p({SS:m,DS:f,Ss:v}),{[Zx]:e.referToSelf(x=>(D,h,w)=>{for(var g=x(D,h),b=0;b<w.length;b++)g=x(g,w[b]);return g}),Array:e.referToSelf(x=>D=>{if(D.length===1&&Array.isArray(D[0])&&hf(D[0]))return x(...D[0]);if(hf(D))return x(...D);throw new ea("gcd() supports only 1d matrices!")}),Matrix:e.referToSelf(x=>D=>x(D.toArray()))});function d(x,D){if(!Ue(x)||!Ue(D))throw new Error("Parameters in function gcd must be integer numbers");for(var h;D!==0;)h=c(x,D),x=D,D=h;return x<0?-x:x}function y(x,D){if(!x.isInt()||!D.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var h=new l(0);!D.isZero();){var w=c(x,D);x=D,D=w}return x.lt(h)?x.neg():x}}),jx="matAlgo06xS0S0",Xx=["typed","equalScalar"],oo=L(jx,Xx,r=>{var{typed:e,equalScalar:t}=r;return function(a,i,o){var l=a._values,u=a._size,s=a._datatype||a._data===void 0?a._datatype:a.getDataType(),c=i._values,f=i._size,m=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(u.length!==f.length)throw new ur(u.length,f.length);if(u[0]!==f[0]||u[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+f+")");var v=u[0],p=u[1],d,y=t,x=0,D=o;typeof s=="string"&&s===m&&s!=="mixed"&&(d=s,y=e.find(t,[d,d]),x=e.convert(0,d),D=e.find(o,[d,d]));for(var h=l&&c?[]:void 0,w=[],g=[],b=h?[]:void 0,A=[],N=[],E=0;E<p;E++){g[E]=w.length;var S=E+1;if(Gl(a,E,A,b,N,S,w,D),Gl(i,E,A,b,N,S,w,D),b)for(var C=g[E];C<w.length;){var M=w[C];if(N[M]===S){var O=b[M];y(O,x)?w.splice(C,1):(h.push(O),C++)}else w.splice(C,1)}else for(var I=g[E];I<w.length;){var k=w[I];N[k]!==S?w.splice(I,1):I++}}return g[p]=w.length,a.createSparseMatrix({values:h,index:w,ptr:g,size:[v,p],datatype:s===a._datatype&&m===i._datatype?d:void 0})}}),gf="lcm",Qx=["typed","matrix","equalScalar","concat"],Kx=L(gf,Qx,r=>{var{typed:e,matrix:t,equalScalar:n,concat:a}=r,i=Jt({typed:e,equalScalar:n}),o=oo({typed:e,equalScalar:n}),l=tt({typed:e,equalScalar:n}),u=Tr({typed:e,matrix:t,concat:a}),s="number | BigNumber | Fraction | Matrix | Array",c={};return c["".concat(s,", ").concat(s,", ...").concat(s)]=e.referToSelf(m=>(v,p,d)=>{for(var y=m(v,p),x=0;x<d.length;x++)y=m(y,d[x]);return y}),e(gf,{"number, number":rc,"BigNumber, BigNumber":f,"Fraction, Fraction":(m,v)=>m.lcm(v)},u({SS:o,DS:i,Ss:l}),c);function f(m,v){if(!m.isInt()||!v.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(m.isZero())return m;if(v.isZero())return v;for(var p=m.times(v);!v.isZero();){var d=v;v=m.mod(d),m=d}return p.div(m).abs()}});function Ss(r,e,t,n){return function(a){if(a>0||t.predictable){if(a<=0)return NaN;var i=a.toString(16),o=i.substring(0,15);return r*(i.length-o.length)+e(+("0x"+o))}return n(a.toNumber())}}var yf="log10",ew=["typed","config","Complex"],rw=eo(16),tw=L(yf,ew,r=>{var{typed:e,config:t,Complex:n}=r;function a(o){return o.log().div(Math.LN10)}function i(o){return a(new n(o,0))}return e(yf,{number:function(l){return l>=0||t.predictable?eo(l):i(l)},bigint:Ss(rw,eo,t,i),Complex:a,BigNumber:function(l){return!l.isNegative()||t.predictable?l.log():i(l.toNumber())},"Array | Matrix":e.referToSelf(o=>l=>tr(l,o))})}),bf="log2",nw=["typed","config","Complex"],aw=L(bf,nw,r=>{var{typed:e,config:t,Complex:n}=r;function a(o){return i(new n(o,0))}return e(bf,{number:function(l){return l>=0||t.predictable?vs(l):a(l)},bigint:Ss(4,vs,t,a),Complex:i,BigNumber:function(l){return!l.isNegative()||t.predictable?l.log(2):a(l.toNumber())},"Array | Matrix":e.referToSelf(o=>l=>tr(l,o))});function i(o){var l=Math.sqrt(o.re*o.re+o.im*o.im);return new n(Math.log2?Math.log2(l):Math.log(l)/Math.LN2,Math.atan2(o.im,o.re)/Math.LN2)}}),iw="multiplyScalar",ow=["typed"],sw=L(iw,ow,r=>{var{typed:e}=r;return e("multiplyScalar",{"number, number":Jl,"Complex, Complex":function(n,a){return n.mul(a)},"BigNumber, BigNumber":function(n,a){return n.times(a)},"bigint, bigint":function(n,a){return n*a},"Fraction, Fraction":function(n,a){return n.mul(a)},"number | Fraction | BigNumber | Complex, Unit":(t,n)=>n.multiply(t),"Unit, number | Fraction | BigNumber | Complex | Unit":(t,n)=>t.multiply(n)})}),xf="multiply",uw=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],lw=L(xf,uw,r=>{var{typed:e,matrix:t,addScalar:n,multiplyScalar:a,equalScalar:i,dot:o}=r,l=tt({typed:e,equalScalar:i}),u=Ut({typed:e});function s(g,b){switch(g.length){case 1:switch(b.length){case 1:if(g[0]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(g[0]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+g[0]+") must match Matrix rows ("+b[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+b.length+" dimensions)")}break;case 2:switch(b.length){case 1:if(g[1]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+g[1]+") must match Vector length ("+b[0]+")");break;case 2:if(g[1]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+g[1]+") must match Matrix B rows ("+b[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+b.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+g.length+" dimensions)")}}function c(g,b,A){if(A===0)throw new Error("Cannot multiply two empty vectors");return o(g,b)}function f(g,b){if(b.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return m(g,b)}function m(g,b){var A=g._data,N=g._size,E=g._datatype||g.getDataType(),S=b._data,C=b._size,M=b._datatype||b.getDataType(),O=N[0],I=C[1],k,_=n,P=a;E&&M&&E===M&&typeof E=="string"&&E!=="mixed"&&(k=E,_=e.find(n,[k,k]),P=e.find(a,[k,k]));for(var V=[],q=0;q<I;q++){for(var J=P(A[0],S[0][q]),ne=1;ne<O;ne++)J=_(J,P(A[ne],S[ne][q]));V[q]=J}return g.createDenseMatrix({data:V,size:[I],datatype:E===g._datatype&&M===b._datatype?k:void 0})}var v=e("_multiplyMatrixVector",{"DenseMatrix, any":d,"SparseMatrix, any":D}),p=e("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":y,"DenseMatrix, SparseMatrix":x,"SparseMatrix, DenseMatrix":h,"SparseMatrix, SparseMatrix":w});function d(g,b){var A=g._data,N=g._size,E=g._datatype||g.getDataType(),S=b._data,C=b._datatype||b.getDataType(),M=N[0],O=N[1],I,k=n,_=a;E&&C&&E===C&&typeof E=="string"&&E!=="mixed"&&(I=E,k=e.find(n,[I,I]),_=e.find(a,[I,I]));for(var P=[],V=0;V<M;V++){for(var q=A[V],J=_(q[0],S[0]),ne=1;ne<O;ne++)J=k(J,_(q[ne],S[ne]));P[V]=J}return g.createDenseMatrix({data:P,size:[M],datatype:E===g._datatype&&C===b._datatype?I:void 0})}function y(g,b){var A=g._data,N=g._size,E=g._datatype||g.getDataType(),S=b._data,C=b._size,M=b._datatype||b.getDataType(),O=N[0],I=N[1],k=C[1],_,P=n,V=a;E&&M&&E===M&&typeof E=="string"&&E!=="mixed"&&E!=="mixed"&&(_=E,P=e.find(n,[_,_]),V=e.find(a,[_,_]));for(var q=[],J=0;J<O;J++){var ne=A[J];q[J]=[];for(var j=0;j<k;j++){for(var F=V(ne[0],S[0][j]),U=1;U<I;U++)F=P(F,V(ne[U],S[U][j]));q[J][j]=F}}return g.createDenseMatrix({data:q,size:[O,k],datatype:E===g._datatype&&M===b._datatype?_:void 0})}function x(g,b){var A=g._data,N=g._size,E=g._datatype||g.getDataType(),S=b._values,C=b._index,M=b._ptr,O=b._size,I=b._datatype||b._data===void 0?b._datatype:b.getDataType();if(!S)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var k=N[0],_=O[1],P,V=n,q=a,J=i,ne=0;E&&I&&E===I&&typeof E=="string"&&E!=="mixed"&&(P=E,V=e.find(n,[P,P]),q=e.find(a,[P,P]),J=e.find(i,[P,P]),ne=e.convert(0,P));for(var j=[],F=[],U=[],$=b.createSparseMatrix({values:j,index:F,ptr:U,size:[k,_],datatype:E===g._datatype&&I===b._datatype?P:void 0}),le=0;le<_;le++){U[le]=F.length;var me=M[le],Y=M[le+1];if(Y>me)for(var z=0,X=0;X<k;X++){for(var se=X+1,re=void 0,pe=me;pe<Y;pe++){var ve=C[pe];z!==se?(re=q(A[X][ve],S[pe]),z=se):re=V(re,q(A[X][ve],S[pe]))}z===se&&!J(re,ne)&&(F.push(X),j.push(re))}}return U[_]=F.length,$}function D(g,b){var A=g._values,N=g._index,E=g._ptr,S=g._datatype||g._data===void 0?g._datatype:g.getDataType();if(!A)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var C=b._data,M=b._datatype||b.getDataType(),O=g._size[0],I=b._size[0],k=[],_=[],P=[],V,q=n,J=a,ne=i,j=0;S&&M&&S===M&&typeof S=="string"&&S!=="mixed"&&(V=S,q=e.find(n,[V,V]),J=e.find(a,[V,V]),ne=e.find(i,[V,V]),j=e.convert(0,V));var F=[],U=[];P[0]=0;for(var $=0;$<I;$++){var le=C[$];if(!ne(le,j))for(var me=E[$],Y=E[$+1],z=me;z<Y;z++){var X=N[z];U[X]?F[X]=q(F[X],J(le,A[z])):(U[X]=!0,_.push(X),F[X]=J(le,A[z]))}}for(var se=_.length,re=0;re<se;re++){var pe=_[re];k[re]=F[pe]}return P[1]=_.length,g.createSparseMatrix({values:k,index:_,ptr:P,size:[O,1],datatype:S===g._datatype&&M===b._datatype?V:void 0})}function h(g,b){var A=g._values,N=g._index,E=g._ptr,S=g._datatype||g._data===void 0?g._datatype:g.getDataType();if(!A)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var C=b._data,M=b._datatype||b.getDataType(),O=g._size[0],I=b._size[0],k=b._size[1],_,P=n,V=a,q=i,J=0;S&&M&&S===M&&typeof S=="string"&&S!=="mixed"&&(_=S,P=e.find(n,[_,_]),V=e.find(a,[_,_]),q=e.find(i,[_,_]),J=e.convert(0,_));for(var ne=[],j=[],F=[],U=g.createSparseMatrix({values:ne,index:j,ptr:F,size:[O,k],datatype:S===g._datatype&&M===b._datatype?_:void 0}),$=[],le=[],me=0;me<k;me++){F[me]=j.length;for(var Y=me+1,z=0;z<I;z++){var X=C[z][me];if(!q(X,J))for(var se=E[z],re=E[z+1],pe=se;pe<re;pe++){var ve=N[pe];le[ve]!==Y?(le[ve]=Y,j.push(ve),$[ve]=V(X,A[pe])):$[ve]=P($[ve],V(X,A[pe]))}}for(var De=F[me],Oe=j.length,Ie=De;Ie<Oe;Ie++){var _e=j[Ie];ne[Ie]=$[_e]}}return F[k]=j.length,U}function w(g,b){var A=g._values,N=g._index,E=g._ptr,S=g._datatype||g._data===void 0?g._datatype:g.getDataType(),C=b._values,M=b._index,O=b._ptr,I=b._datatype||b._data===void 0?b._datatype:b.getDataType(),k=g._size[0],_=b._size[1],P=A&&C,V,q=n,J=a;S&&I&&S===I&&typeof S=="string"&&S!=="mixed"&&(V=S,q=e.find(n,[V,V]),J=e.find(a,[V,V]));for(var ne=P?[]:void 0,j=[],F=[],U=g.createSparseMatrix({values:ne,index:j,ptr:F,size:[k,_],datatype:S===g._datatype&&I===b._datatype?V:void 0}),$=P?[]:void 0,le=[],me,Y,z,X,se,re,pe,ve,De=0;De<_;De++){F[De]=j.length;var Oe=De+1;for(se=O[De],re=O[De+1],X=se;X<re;X++)if(ve=M[X],P)for(Y=E[ve],z=E[ve+1],me=Y;me<z;me++)pe=N[me],le[pe]!==Oe?(le[pe]=Oe,j.push(pe),$[pe]=J(C[X],A[me])):$[pe]=q($[pe],J(C[X],A[me]));else for(Y=E[ve],z=E[ve+1],me=Y;me<z;me++)pe=N[me],le[pe]!==Oe&&(le[pe]=Oe,j.push(pe));if(P)for(var Ie=F[De],_e=j.length,Le=Ie;Le<_e;Le++){var qe=j[Le];ne[Le]=$[qe]}}return F[_]=j.length,U}return e(xf,a,{"Array, Array":e.referTo("Matrix, Matrix",g=>(b,A)=>{s(rr(b),rr(A));var N=g(t(b),t(A));return Je(N)?N.valueOf():N}),"Matrix, Matrix":function(b,A){var N=b.size(),E=A.size();return s(N,E),N.length===1?E.length===1?c(b,A,N[0]):f(b,A):E.length===1?v(b,A):p(b,A)},"Matrix, Array":e.referTo("Matrix,Matrix",g=>(b,A)=>g(b,t(A))),"Array, Matrix":e.referToSelf(g=>(b,A)=>g(t(b,A.storage()),A)),"SparseMatrix, any":function(b,A){return l(b,A,a,!1)},"DenseMatrix, any":function(b,A){return u(b,A,a,!1)},"any, SparseMatrix":function(b,A){return l(A,b,a,!0)},"any, DenseMatrix":function(b,A){return u(A,b,a,!0)},"Array, any":function(b,A){return u(t(b),A,a,!1).valueOf()},"any, Array":function(b,A){return u(t(A),b,a,!0).valueOf()},"any, any":a,"any, any, ...any":e.referToSelf(g=>(b,A,N)=>{for(var E=g(b,A),S=0;S<N.length;S++)E=g(E,N[S]);return E})})}),wf="nthRoot",cw=["typed","matrix","equalScalar","BigNumber","concat"],fw=L(wf,cw,r=>{var{typed:e,matrix:t,equalScalar:n,BigNumber:a,concat:i}=r,o=In({typed:e}),l=Jt({typed:e,equalScalar:n}),u=oo({typed:e,equalScalar:n}),s=tt({typed:e,equalScalar:n}),c=Tr({typed:e,matrix:t,concat:i});function f(){throw new Error("Complex number not supported in function nthRoot. Use nthRoots instead.")}return e(wf,{number:nc,"number, number":nc,BigNumber:v=>m(v,new a(2)),"BigNumber, BigNumber":m,Complex:f,"Complex, number":f,Array:e.referTo("DenseMatrix,number",v=>p=>v(t(p),2).valueOf()),DenseMatrix:e.referTo("DenseMatrix,number",v=>p=>v(p,2)),SparseMatrix:e.referTo("SparseMatrix,number",v=>p=>v(p,2)),"SparseMatrix, SparseMatrix":e.referToSelf(v=>(p,d)=>{if(d.density()===1)return u(p,d,v);throw new Error("Root must be non-zero")}),"DenseMatrix, SparseMatrix":e.referToSelf(v=>(p,d)=>{if(d.density()===1)return o(p,d,v,!1);throw new Error("Root must be non-zero")}),"Array, SparseMatrix":e.referTo("DenseMatrix,SparseMatrix",v=>(p,d)=>v(t(p),d)),"number | BigNumber, SparseMatrix":e.referToSelf(v=>(p,d)=>{if(d.density()===1)return s(d,p,v,!0);throw new Error("Root must be non-zero")})},c({scalar:"number | BigNumber",SD:l,Ss:s,sS:!1}));function m(v,p){var d=a.precision,y=a.clone({precision:d+2}),x=new a(0),D=new y(1),h=p.isNegative();if(h&&(p=p.neg()),p.isZero())throw new Error("Root must be non-zero");if(v.isNegative()&&!p.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(v.isZero())return h?new y(1/0):0;if(!v.isFinite())return h?x:v;var w=v.abs().pow(D.div(p));return w=v.isNeg()?w.neg():w,new a((h?D.div(w):w).toPrecision(d))}}),Df="sign",mw=["typed","BigNumber","Fraction","complex"],vw=L(Df,mw,r=>{var{typed:e,BigNumber:t,complex:n,Fraction:a}=r;return e(Df,{number:ps,Complex:function(o){return o.im===0?n(ps(o.re)):o.sign()},BigNumber:function(o){return new t(o.cmp(0))},bigint:function(o){return o>0n?1n:o<0n?-1n:0n},Fraction:function(o){return o.n===0n?new a(0):new a(o.s)},"Array | Matrix":e.referToSelf(i=>o=>tr(o,i,!0)),Unit:e.referToSelf(i=>o=>{if(!o._isDerived()&&o.units[0].unit.offset!==0)throw new TypeError("sign is ambiguous for units with offset");return e.find(i,o.valueType())(o.value)})})}),pw="sqrt",dw=["config","typed","Complex"],hw=L(pw,dw,r=>{var{config:e,typed:t,Complex:n}=r;return t("sqrt",{number:a,Complex:function(o){return o.sqrt()},BigNumber:function(o){return!o.isNegative()||e.predictable?o.sqrt():a(o.toNumber())},Unit:function(o){return o.pow(.5)}});function a(i){return isNaN(i)?NaN:i>=0||e.predictable?Math.sqrt(i):new n(i,0).sqrt()}}),Nf="square",gw=["typed"],yw=L(Nf,gw,r=>{var{typed:e}=r;return e(Nf,{number:ac,Complex:function(n){return n.mul(n)},BigNumber:function(n){return n.times(n)},bigint:function(n){return n*n},Fraction:function(n){return n.mul(n)},Unit:function(n){return n.pow(2)}})}),Ef="subtract",bw=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],xw=L(Ef,bw,r=>{var{typed:e,matrix:t,equalScalar:n,subtractScalar:a,unaryMinus:i,DenseMatrix:o,concat:l}=r,u=In({typed:e}),s=lt({typed:e}),c=io({typed:e,equalScalar:n}),f=Kn({typed:e,DenseMatrix:o}),m=Hr({typed:e,DenseMatrix:o}),v=Tr({typed:e,matrix:t,concat:l});return e(Ef,{"any, any":a},v({elop:a,SS:c,DS:u,SD:s,Ss:m,sS:f}))}),Af="xgcd",ww=["typed","config","matrix","BigNumber"],Dw=L(Af,ww,r=>{var{typed:e,config:t,matrix:n,BigNumber:a}=r;return e(Af,{"number, number":function(l,u){var s=ic(l,u);return t.matrix==="Array"?s:n(s)},"BigNumber, BigNumber":i});function i(o,l){var u,s,c,f=new a(0),m=new a(1),v=f,p=m,d=m,y=f;if(!o.isInt()||!l.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!l.isZero();)s=o.div(l).floor(),c=o.mod(l),u=v,v=p.minus(s.times(v)),p=u,u=d,d=y.minus(s.times(d)),y=u,o=l,l=c;var x;return o.lt(f)?x=[o.neg(),p.neg(),y.neg()]:x=[o,o.isZero()?0:p,y],t.matrix==="Array"?x:n(x)}}),Sf="invmod",Nw=["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],Ew=L(Sf,Nw,r=>{var{typed:e,config:t,BigNumber:n,xgcd:a,equal:i,smaller:o,mod:l,add:u,isInteger:s}=r;return e(Sf,{"number, number":c,"BigNumber, BigNumber":c});function c(f,m){if(!s(f)||!s(m))throw new Error("Parameters in function invmod must be integer numbers");if(f=l(f,m),i(m,0))throw new Error("Divisor must be non zero");var v=a(f,m);v=v.valueOf();var[p,d]=v;return i(p,n(1))?(d=l(d,m),o(d,n(0))&&(d=u(d,m)),d):NaN}}),Aw="matAlgo09xS0Sf",Sw=["typed","equalScalar"],Cf=L(Aw,Sw,r=>{var{typed:e,equalScalar:t}=r;return function(a,i,o){var l=a._values,u=a._index,s=a._ptr,c=a._size,f=a._datatype||a._data===void 0?a._datatype:a.getDataType(),m=i._values,v=i._index,p=i._ptr,d=i._size,y=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(c.length!==d.length)throw new ur(c.length,d.length);if(c[0]!==d[0]||c[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+d+")");var x=c[0],D=c[1],h,w=t,g=0,b=o;typeof f=="string"&&f===y&&f!=="mixed"&&(h=f,w=e.find(t,[h,h]),g=e.convert(0,h),b=e.find(o,[h,h]));var A=l&&m?[]:void 0,N=[],E=[],S=A?[]:void 0,C=[],M,O,I,k,_;for(O=0;O<D;O++){E[O]=N.length;var P=O+1;if(S)for(k=p[O],_=p[O+1],I=k;I<_;I++)M=v[I],C[M]=P,S[M]=m[I];for(k=s[O],_=s[O+1],I=k;I<_;I++)if(M=u[I],S){var V=C[M]===P?S[M]:g,q=b(l[I],V);w(q,g)||(N.push(M),A.push(q))}else N.push(M)}return E[D]=N.length,a.createSparseMatrix({values:A,index:N,ptr:E,size:[x,D],datatype:f===a._datatype&&y===i._datatype?h:void 0})}}),Mf="dotMultiply",Cw=["typed","matrix","equalScalar","multiplyScalar","concat"],Mw=L(Mf,Cw,r=>{var{typed:e,matrix:t,equalScalar:n,multiplyScalar:a,concat:i}=r,o=Jt({typed:e,equalScalar:n}),l=Cf({typed:e,equalScalar:n}),u=tt({typed:e,equalScalar:n}),s=Tr({typed:e,matrix:t,concat:i});return e(Mf,s({elop:a,SS:l,DS:o,Ss:u}))});function _w(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function bitAnd");var t=r.constructor;if(r.isNaN()||e.isNaN())return new t(NaN);if(r.isZero()||e.eq(-1)||r.eq(e))return r;if(e.isZero()||r.eq(-1))return e;if(!r.isFinite()||!e.isFinite()){if(!r.isFinite()&&!e.isFinite())return r.isNegative()===e.isNegative()?r:new t(0);if(!r.isFinite())return e.isNegative()?r:r.isNegative()?new t(0):e;if(!e.isFinite())return r.isNegative()?e:e.isNegative()?new t(0):r}return Cs(r,e,function(n,a){return n&a})}function oi(r){if(r.isFinite()&&!r.isInteger())throw new Error("Integer expected in function bitNot");var e=r.constructor,t=e.precision;e.config({precision:1e9});var n=r.plus(new e(1));return n.s=-n.s||null,e.config({precision:t}),n}function Tw(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function bitOr");var t=r.constructor;if(r.isNaN()||e.isNaN())return new t(NaN);var n=new t(-1);return r.isZero()||e.eq(n)||r.eq(e)?e:e.isZero()||r.eq(n)?r:!r.isFinite()||!e.isFinite()?!r.isFinite()&&!r.isNegative()&&e.isNegative()||r.isNegative()&&!e.isNegative()&&!e.isFinite()?n:r.isNegative()&&e.isNegative()?r.isFinite()?r:e:r.isFinite()?e:r:Cs(r,e,function(a,i){return a|i})}function Cs(r,e,t){var n=r.constructor,a,i,o=+(r.s<0),l=+(e.s<0);if(o){a=so(oi(r));for(var u=0;u<a.length;++u)a[u]^=1}else a=so(r);if(l){i=so(oi(e));for(var s=0;s<i.length;++s)i[s]^=1}else i=so(e);var c,f,m;a.length<=i.length?(c=a,f=i,m=o):(c=i,f=a,m=l);var v=c.length,p=f.length,d=t(o,l)^1,y=new n(d^1),x=new n(1),D=new n(2),h=n.precision;for(n.config({precision:1e9});v>0;)t(c[--v],f[--p])===d&&(y=y.plus(x)),x=x.times(D);for(;p>0;)t(m,f[--p])===d&&(y=y.plus(x)),x=x.times(D);return n.config({precision:h}),d===0&&(y.s=-y.s),y}function so(r){for(var e=r.d,t=e[0]+"",n=1;n<e.length;++n){for(var a=e[n]+"",i=7-a.length;i--;)a="0"+a;t+=a}for(var o=t.length;t.charAt(o)==="0";)o--;var l=r.e,u=t.slice(0,o+1||1),s=u.length;if(l>0)if(++l>s)for(l-=s;l--;)u+="0";else l<s&&(u=u.slice(0,l)+"."+u.slice(l));for(var c=[0],f=0;f<u.length;){for(var m=c.length;m--;)c[m]*=10;c[0]+=parseInt(u.charAt(f++));for(var v=0;v<c.length;++v)c[v]>1&&((c[v+1]===null||c[v+1]===void 0)&&(c[v+1]=0),c[v+1]+=c[v]>>1,c[v]&=1)}return c.reverse()}function Fw(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function bitXor");var t=r.constructor;if(r.isNaN()||e.isNaN())return new t(NaN);if(r.isZero())return e;if(e.isZero())return r;if(r.eq(e))return new t(0);var n=new t(-1);return r.eq(n)?oi(e):e.eq(n)?oi(r):!r.isFinite()||!e.isFinite()?!r.isFinite()&&!e.isFinite()?n:new t(r.isNegative()===e.isNegative()?1/0:-1/0):Cs(r,e,function(a,i){return a^i})}function Ow(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function leftShift");var t=r.constructor;return r.isNaN()||e.isNaN()||e.isNegative()&&!e.isZero()?new t(NaN):r.isZero()||e.isZero()?r:!r.isFinite()&&!e.isFinite()?new t(NaN):e.lt(55)?r.times(Math.pow(2,e.toNumber())+""):r.times(new t(2).pow(e))}function Bw(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function rightArithShift");var t=r.constructor;return r.isNaN()||e.isNaN()||e.isNegative()&&!e.isZero()?new t(NaN):r.isZero()||e.isZero()?r:e.isFinite()?e.lt(55)?r.div(Math.pow(2,e.toNumber())+"").floor():r.div(new t(2).pow(e)).floor():r.isNegative()?new t(-1):r.isFinite()?new t(0):new t(NaN)}var _f="bitAnd",Rw=["typed","matrix","equalScalar","concat"],Tf=L(_f,Rw,r=>{var{typed:e,matrix:t,equalScalar:n,concat:a}=r,i=Jt({typed:e,equalScalar:n}),o=oo({typed:e,equalScalar:n}),l=tt({typed:e,equalScalar:n}),u=Tr({typed:e,matrix:t,concat:a});return e(_f,{"number, number":sc,"BigNumber, BigNumber":_w,"bigint, bigint":(s,c)=>s&c},u({SS:o,DS:i,Ss:l}))}),Ff="bitNot",Iw=["typed"],Pw=L(Ff,Iw,r=>{var{typed:e}=r;return e(Ff,{number:uc,BigNumber:oi,bigint:t=>~t,"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),Of="bitOr",$w=["typed","matrix","equalScalar","DenseMatrix","concat"],Bf=L(Of,$w,r=>{var{typed:e,matrix:t,equalScalar:n,DenseMatrix:a,concat:i}=r,o=In({typed:e}),l=Es({typed:e,equalScalar:n}),u=Kn({typed:e,DenseMatrix:a}),s=Tr({typed:e,matrix:t,concat:i});return e(Of,{"number, number":lc,"BigNumber, BigNumber":Tw,"bigint, bigint":(c,f)=>c|f},s({SS:l,DS:o,Ss:u}))}),qw="matAlgo07xSSf",zw=["typed","SparseMatrix"],nn=L(qw,zw,r=>{var{typed:e,SparseMatrix:t}=r;return function(i,o,l){var u=i._size,s=i._datatype||i._data===void 0?i._datatype:i.getDataType(),c=o._size,f=o._datatype||o._data===void 0?o._datatype:o.getDataType();if(u.length!==c.length)throw new ur(u.length,c.length);if(u[0]!==c[0]||u[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+c+")");var m=u[0],v=u[1],p,d=0,y=l;typeof s=="string"&&s===f&&s!=="mixed"&&(p=s,d=e.convert(0,p),y=e.find(l,[p,p]));for(var x=[],D=[],h=new Array(v+1).fill(0),w=[],g=[],b=[],A=[],N=0;N<v;N++){var E=N+1,S=0;n(i,N,b,w,E),n(o,N,A,g,E);for(var C=0;C<m;C++){var M=b[C]===E?w[C]:d,O=A[C]===E?g[C]:d,I=y(M,O);I!==0&&I!==!1&&(D.push(C),x.push(I),S++)}h[N+1]=h[N]+S}return new t({values:x,index:D,ptr:h,size:[m,v],datatype:s===i._datatype&&f===o._datatype?p:void 0})};function n(a,i,o,l,u){for(var s=a._values,c=a._index,f=a._ptr,m=f[i],v=f[i+1];m<v;m++){var p=c[m];o[p]=u,l[p]=s[m]}}}),Rf="bitXor",Uw=["typed","matrix","DenseMatrix","concat","SparseMatrix"],Lw=L(Rf,Uw,r=>{var{typed:e,matrix:t,DenseMatrix:n,concat:a,SparseMatrix:i}=r,o=lt({typed:e}),l=nn({typed:e,SparseMatrix:i}),u=Hr({typed:e,DenseMatrix:n}),s=Tr({typed:e,matrix:t,concat:a});return e(Rf,{"number, number":cc,"BigNumber, BigNumber":Fw,"bigint, bigint":(c,f)=>c^f},s({SS:l,DS:o,Ss:u}))}),If="arg",kw=["typed"],Vw=L(If,kw,r=>{var{typed:e}=r;return e(If,{number:function(n){return Math.atan2(0,n)},BigNumber:function(n){return n.constructor.atan2(0,n)},Complex:function(n){return n.arg()},"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),Pf="conj",Gw=["typed"],Hw=L(Pf,Gw,r=>{var{typed:e}=r;return e(Pf,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.conjugate(),Unit:e.referToSelf(t=>n=>new n.constructor(t(n.toNumeric()),n.formatUnits())),"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),$f="im",Ww=["typed"],Yw=L($f,Ww,r=>{var{typed:e}=r;return e($f,{number:()=>0,"BigNumber | Fraction":t=>t.mul(0),Complex:t=>t.im,"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),qf="re",Zw=["typed"],Jw=L(qf,Zw,r=>{var{typed:e}=r;return e(qf,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.re,"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),zf="not",jw=["typed"],Xw=L(zf,jw,r=>{var{typed:e}=r;return e(zf,{"null | undefined":()=>!0,number:dc,Complex:function(n){return n.re===0&&n.im===0},BigNumber:function(n){return n.isZero()||n.isNaN()},bigint:t=>!t,Unit:e.referToSelf(t=>n=>e.find(t,n.valueType())(n.value)),"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),Uf="nullish",Qw=["typed","matrix","size","flatten","deepEqual"],Lf=L(Uf,Qw,r=>{var{typed:e,matrix:t,size:n,flatten:a,deepEqual:i}=r,o=lt({typed:e}),l=Ut({typed:e}),u=mf({typed:e});return e(Uf,{"number|bigint|Complex|BigNumber|Fraction|Unit|string|boolean|SparseMatrix, any":(s,c)=>s,"null, any":(s,c)=>c,"undefined, any":(s,c)=>c,"SparseMatrix, Array | Matrix":(s,c)=>{var f=n(s),m=n(c);if(i(f,m))return s;throw new ur(f,m)},"DenseMatrix, DenseMatrix":e.referToSelf(s=>(c,f)=>u(c,f,s)),"DenseMatrix, SparseMatrix":e.referToSelf(s=>(c,f)=>o(c,f,s,!1)),"DenseMatrix, Array":e.referToSelf(s=>(c,f)=>u(c,t(f),s)),"DenseMatrix, any":e.referToSelf(s=>(c,f)=>l(c,f,s,!1)),"Array, Array":e.referToSelf(s=>(c,f)=>u(t(c),t(f),s).valueOf()),"Array, DenseMatrix":e.referToSelf(s=>(c,f)=>u(t(c),f,s)),"Array, SparseMatrix":e.referToSelf(s=>(c,f)=>o(t(c),f,s,!1)),"Array, any":e.referToSelf(s=>(c,f)=>l(t(c),f,s,!1).valueOf())})}),kf="or",Kw=["typed","matrix","equalScalar","DenseMatrix","concat"],Vf=L(kf,Kw,r=>{var{typed:e,matrix:t,equalScalar:n,DenseMatrix:a,concat:i}=r,o=lt({typed:e}),l=io({typed:e,equalScalar:n}),u=Hr({typed:e,DenseMatrix:a}),s=Tr({typed:e,matrix:t,concat:i});return e(kf,{"number, number":hs,"Complex, Complex":function(f,m){return f.re!==0||f.im!==0||m.re!==0||m.im!==0},"BigNumber, BigNumber":function(f,m){return!f.isZero()&&!f.isNaN()||!m.isZero()&&!m.isNaN()},"bigint, bigint":hs,"Unit, Unit":e.referToSelf(c=>(f,m)=>c(f.value||0,m.value||0))},s({SS:l,DS:o,Ss:u}))}),Gf="xor",eD=["typed","matrix","DenseMatrix","concat","SparseMatrix"],rD=L(Gf,eD,r=>{var{typed:e,matrix:t,DenseMatrix:n,concat:a,SparseMatrix:i}=r,o=lt({typed:e}),l=nn({typed:e,SparseMatrix:i}),u=Hr({typed:e,DenseMatrix:n}),s=Tr({typed:e,matrix:t,concat:a});return e(Gf,{"number, number":gs,"Complex, Complex":function(f,m){return(f.re!==0||f.im!==0)!=(m.re!==0||m.im!==0)},"bigint, bigint":gs,"BigNumber, BigNumber":function(f,m){return(!f.isZero()&&!f.isNaN())!=(!m.isZero()&&!m.isNaN())},"Unit, Unit":e.referToSelf(c=>(f,m)=>c(f.value||0,m.value||0))},s({SS:l,DS:o,Ss:u}))}),Hf="concat",tD=["typed","matrix","isInteger"],Wf=L(Hf,tD,r=>{var{typed:e,matrix:t,isInteger:n}=r;return e(Hf,{"...Array | Matrix | number | BigNumber":function(i){var o,l=i.length,u=-1,s,c=!1,f=[];for(o=0;o<l;o++){var m=i[o];if(Je(m)&&(c=!0),Ye(m)||or(m)){if(o!==l-1)throw new Error("Dimension must be specified as last argument");if(s=u,u=m.valueOf(),!n(u))throw new TypeError("Integer number expected for dimension");if(u<0||o>0&&u>s)throw new Yt(u,s+1)}else{var v=er(m).valueOf(),p=rr(v);if(f[o]=v,s=u,u=p.length-1,o>0&&u!==s)throw new ur(s+1,u+1)}}if(f.length===0)throw new SyntaxError("At least one matrix expected");for(var d=f.shift();f.length;)d=ql(d,f.shift(),u);return c?t(d):d},"...string":function(i){return i.join("")}})}),Yf="column",nD=["typed","Index","matrix","range"],Zf=L(Yf,nD,r=>{var{typed:e,Index:t,matrix:n,range:a}=r;return e(Yf,{"Matrix, number":i,"Array, number":function(l,u){return i(n(er(l)),u).valueOf()}});function i(o,l){if(o.size().length!==2)throw new Error("Only two dimensional matrix is supported");_r(l,o.size()[1]);var u=a(0,o.size()[0]),s=new t(u,[l]),c=o.subset(s);return Je(c)?c:n([[c]])}}),Jf="count",aD=["typed","size","prod"],iD=L(Jf,aD,r=>{var{typed:e,size:t,prod:n}=r;return e(Jf,{string:function(i){return i.length},"Matrix | Array":function(i){return n(t(i))}})}),jf="cross",oD=["typed","matrix","subtract","multiply"],sD=L(jf,oD,r=>{var{typed:e,matrix:t,subtract:n,multiply:a}=r;return e(jf,{"Matrix, Matrix":function(l,u){return t(i(l.toArray(),u.toArray()))},"Matrix, Array":function(l,u){return t(i(l.toArray(),u))},"Array, Matrix":function(l,u){return t(i(l,u.toArray()))},"Array, Array":i});function i(o,l){var u=Math.max(rr(o).length,rr(l).length);o=Yi(o),l=Yi(l);var s=rr(o),c=rr(l);if(s.length!==1||c.length!==1||s[0]!==3||c[0]!==3)throw new RangeError("Vectors with length 3 expected (Size A = ["+s.join(", ")+"], B = ["+c.join(", ")+"])");var f=[n(a(o[1],l[2]),a(o[2],l[1])),n(a(o[2],l[0]),a(o[0],l[2])),n(a(o[0],l[1]),a(o[1],l[0]))];return u>1?[f]:f}}),Xf="diag",uD=["typed","matrix","DenseMatrix","SparseMatrix"],lD=L(Xf,uD,r=>{var{typed:e,matrix:t,DenseMatrix:n,SparseMatrix:a}=r;return e(Xf,{Array:function(s){return i(s,0,rr(s),null)},"Array, number":function(s,c){return i(s,c,rr(s),null)},"Array, BigNumber":function(s,c){return i(s,c.toNumber(),rr(s),null)},"Array, string":function(s,c){return i(s,0,rr(s),c)},"Array, number, string":function(s,c,f){return i(s,c,rr(s),f)},"Array, BigNumber, string":function(s,c,f){return i(s,c.toNumber(),rr(s),f)},Matrix:function(s){return i(s,0,s.size(),s.storage())},"Matrix, number":function(s,c){return i(s,c,s.size(),s.storage())},"Matrix, BigNumber":function(s,c){return i(s,c.toNumber(),s.size(),s.storage())},"Matrix, string":function(s,c){return i(s,0,s.size(),c)},"Matrix, number, string":function(s,c,f){return i(s,c,s.size(),f)},"Matrix, BigNumber, string":function(s,c,f){return i(s,c.toNumber(),s.size(),f)}});function i(u,s,c,f){if(!Ue(s))throw new TypeError("Second parameter in function diag must be an integer");var m=s>0?s:0,v=s<0?-s:0;switch(c.length){case 1:return o(u,s,f,c[0],v,m);case 2:return l(u,s,f,c,v,m)}throw new RangeError("Matrix for function diag must be 2 dimensional")}function o(u,s,c,f,m,v){var p=[f+m,f+v];if(c&&c!=="sparse"&&c!=="dense")throw new TypeError("Unknown matrix type ".concat(c,'"'));var d=c==="sparse"?a.diagonal(p,u,s):n.diagonal(p,u,s);return c!==null?d:d.valueOf()}function l(u,s,c,f,m,v){if(Je(u)){var p=u.diagonal(s);return c!==null?c!==p.storage()?t(p,c):p:p.valueOf()}for(var d=Math.min(f[0]-m,f[1]-v),y=[],x=0;x<d;x++)y[x]=u[x+m][x+v];return c!==null?t(y):y}}),cD="filter",fD=["typed"],Qf=L(cD,fD,r=>{var{typed:e}=r;return e("filter",{"Array, function":Kf,"Matrix, function":function(n,a){return n.create(Kf(n.valueOf(),a),n.datatype())},"Array, RegExp":Il,"Matrix, RegExp":function(n,a){return n.create(Il(n.valueOf(),a),n.datatype())}})});function Kf(r,e){var t=Qn(e,r,"filter");return t.isUnary?Rl(r,t.fn):Rl(r,function(n,a,i){return t.fn(n,[a],i)})}var em="flatten",mD=["typed"],vD=L(em,mD,r=>{var{typed:e}=r;return e(em,{Array:function(n){return yr(n)},DenseMatrix:function(n){return n.create(yr(n.valueOf(),!0),n.datatype())},SparseMatrix:function(n){throw new TypeError("SparseMatrix is not supported by function flatten because it does not support 1D vectors. Convert to a DenseMatrix or Array first. Example: flatten(x.toArray())")}})}),Ms="forEach",pD=["typed"],rm=L(Ms,pD,r=>{var{typed:e}=r;return e(Ms,{"Array, function":dD,"Matrix, function":function(n,a){n.forEach(a)}})});function dD(r,e){var t=Qn(e,r,Ms);Ul(r,t.fn,t.isUnary)}var tm="getMatrixDataType",hD=["typed"],gD=L(tm,hD,r=>{var{typed:e}=r;return e(tm,{Array:function(n){return Ji(n,Sr)},Matrix:function(n){return n.getDataType()}})}),nm="identity",yD=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],bD=L(nm,yD,r=>{var{typed:e,config:t,matrix:n,BigNumber:a,DenseMatrix:i,SparseMatrix:o}=r;return e(nm,{"":function(){return t.matrix==="Matrix"?n([]):[]},string:function(c){return n(c)},"number | BigNumber":function(c){return u(c,c,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(c,f){return u(c,c,f)},"number | BigNumber, number | BigNumber":function(c,f){return u(c,f,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(c,f,m){return u(c,f,m)},Array:function(c){return l(c)},"Array, string":function(c,f){return l(c,f)},Matrix:function(c){return l(c.valueOf(),c.storage())},"Matrix, string":function(c,f){return l(c.valueOf(),f)}});function l(s,c){switch(s.length){case 0:return c?n(c):[];case 1:return u(s[0],s[0],c);case 2:return u(s[0],s[1],c);default:throw new Error("Vector containing two values expected")}}function u(s,c,f){var m=or(s)||or(c)?a:null;if(or(s)&&(s=s.toNumber()),or(c)&&(c=c.toNumber()),!Ue(s)||s<1)throw new Error("Parameters in function identity must be positive integers");if(!Ue(c)||c<1)throw new Error("Parameters in function identity must be positive integers");var v=m?new a(1):1,p=m?new m(0):0,d=[s,c];if(f){if(f==="sparse")return o.diagonal(d,v,0,p);if(f==="dense")return i.diagonal(d,v,0,p);throw new TypeError('Unknown matrix type "'.concat(f,'"'))}for(var y=Ea([],d,p),x=s<c?s:c,D=0;D<x;D++)y[D][D]=v;return y}}),am="kron",xD=["typed","matrix","multiplyScalar"],wD=L(am,xD,r=>{var{typed:e,matrix:t,multiplyScalar:n}=r;return e(am,{"Matrix, Matrix":function(l,u){return t(i(l.toArray(),u.toArray()))},"Matrix, Array":function(l,u){return t(i(l.toArray(),u))},"Array, Matrix":function(l,u){return t(i(l,u.toArray()))},"Array, Array":i});function a(o,l){return o.flatMap(u=>l.map(s=>n(u,s)))}function i(o,l){var u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:-1;if(u<0){var s=rr(o).length,c=rr(l).length;for(u=Math.max(s,c);s++<u;)o=[o];for(;c++<u;)l=[l]}return u===1?a(o,l):o.flatMap(f=>l.map(m=>i(f,m,u-1)))}}),_s="map",DD=["typed"],im=L(_s,DD,r=>{var{typed:e}=r;return e(_s,{"Array, function":l,"Matrix, function":function(s,c){return s.map(c)},"Array|Matrix, Array|Matrix, ...Array|Matrix|function":(u,s,c)=>t([u,s,...c.slice(0,c.length-1)],c[c.length-1])});function t(u,s){if(typeof s!="function")throw new Error("Last argument must be a callback function");var c=u[0].isMatrix,f=u.map(g=>g.isMatrix?g.size():rr(g)),m=ji(...f),v=u.length,p=c?(g,b)=>g.get(b):Xi,d=u.map((g,b)=>{var A=f[b].map(()=>0);return g.isMatrix?g.get(A):Xi(g,A)}),y=e.isTypedFunction(s)?o(s,d,m.map(()=>0),u):i(s,v);if(y<2){var x=a(y,s,null);return n(u,x)}var D=c?u.map(g=>g.isMatrix?g.create(Xn(g.toArray(),m),g.datatype()):u[0].create(Xn(g.valueOf(),m))):u.map(g=>g.isMatrix?Xn(g.toArray(),m):Xn(g,m)),h=a(y,s,D),w=(g,b)=>h([g,...D.slice(1).map(A=>p(A,b))],b);return c?D[0].map(w):l(D[0],w)}function n(u,s){var c=u[0],f=u.map(g=>g.isMatrix?g.valueOf():g),m=u.map(g=>g.isMatrix?g.size():rr(g)),v=ji(...m),p=m.map(g=>v.length-g.length),d=v.length-1,y=s.length>1,x=y?[]:null,D=w(f,0);if(c.isMatrix){var h=c.create();return h._data=D,h._size=v,h}else return D;function w(g){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,A=v[b],N=Array(A);if(b<d)for(var E=function(I){x&&(x[b]=I),N[I]=w(g.map((k,_)=>p[_]>b?k:k.length===1?k[0]:k[I]),b+1)},S=0;S<A;S++)E(S);else for(var C=function(I){x&&(x[b]=I),N[I]=s(g.map(k=>k.length===1?k[0]:k[I]),x?x.slice():void 0)},M=0;M<A;M++)C(M);return N}}function a(u,s,c){switch(u){case 0:return f=>s(...f);case 1:return(f,m)=>s(...f,m);case 2:return(f,m)=>s(...f,m,...c)}}function i(u,s){var c=u.toString();if(/arguments/.test(c))return 2;var f=c.match(/\(.*?\)/);return/\.\.\./.test(f)||u.length>s+1?2:u.length===s+1?1:0}function o(u,s,c,f){return e.resolve(u,[...s,c,...f])!==null?2:e.resolve(u,[...s,c])!==null?1:(e.resolve(u,s)!==null,0)}function l(u,s){var c=Qn(s,u,_s);return ms(u,c.fn,c.isUnary)}}),om="diff",ND=["typed","matrix","subtract","number"],sm=L(om,ND,r=>{var{typed:e,matrix:t,subtract:n,number:a}=r;return e(om,{"Array | Matrix":function(c){return Je(c)?t(o(c.toArray())):o(c)},"Array | Matrix, number":function(c,f){if(!Ue(f))throw new RangeError("Dimension must be a whole number");return Je(c)?t(i(c.toArray(),f)):i(c,f)},"Array, BigNumber":e.referTo("Array,number",s=>(c,f)=>s(c,a(f))),"Matrix, BigNumber":e.referTo("Matrix,number",s=>(c,f)=>s(c,a(f)))});function i(s,c){if(Je(s)&&(s=s.toArray()),!Array.isArray(s))throw RangeError("Array/Matrix does not have that many dimensions");if(c>0){var f=[];return s.forEach(m=>{f.push(i(m,c-1))}),f}else{if(c===0)return o(s);throw RangeError("Cannot have negative dimension")}}function o(s){for(var c=[],f=s.length,m=1;m<f;m++)c.push(l(s[m-1],s[m]));return c}function l(s,c){Je(s)&&(s=s.toArray()),Je(c)&&(c=c.toArray());var f=Array.isArray(s),m=Array.isArray(c);if(f&&m)return u(s,c);if(!f&&!m)return n(c,s);throw TypeError("Cannot calculate difference between 1 array and 1 non-array")}function u(s,c){if(s.length!==c.length)throw RangeError("Not all sub-arrays have the same length");for(var f=[],m=s.length,v=0;v<m;v++)f.push(l(s[v],c[v]));return f}}),ED="ones",AD=["typed","config","matrix","BigNumber"],SD=L(ED,AD,r=>{var{typed:e,config:t,matrix:n,BigNumber:a}=r;return e("ones",{"":function(){return t.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(s){var c=s[s.length-1];if(typeof c=="string"){var f=s.pop();return i(s,f)}else return t.matrix==="Array"?i(s):i(s,"default")},Array:i,Matrix:function(s){var c=s.storage();return i(s.valueOf(),c)},"Array | Matrix, string":function(s,c){return i(s.valueOf(),c)}});function i(u,s){var c=o(u),f=c?new a(1):1;if(l(u),s){var m=n(s);return u.length>0?m.resize(u,f):m}else{var v=[];return u.length>0?Ea(v,u,f):v}}function o(u){var s=!1;return u.forEach(function(c,f,m){or(c)&&(s=!0,m[f]=c.toNumber())}),s}function l(u){u.forEach(function(s){if(typeof s!="number"||!Ue(s)||s<0)throw new Error("Parameters in function ones must be positive integers")})}});function Ts(){throw new Error('No "bignumber" implementation available')}function um(){throw new Error('No "fraction" implementation available')}function CD(){throw new Error('No "matrix" implementation available')}var lm="range",MD=["typed","config","?matrix","?bignumber","equal","smaller","smallerEq","larger","largerEq","add","isZero","isPositive"],cm=L(lm,MD,r=>{var{typed:e,config:t,matrix:n,bignumber:a,smaller:i,smallerEq:o,larger:l,largerEq:u,add:s,isZero:c,isPositive:f}=r;return e(lm,{string:v,"string, boolean":v,number:function(x){throw new TypeError("Too few arguments to function range(): ".concat(x))},boolean:function(x){throw new TypeError("Unexpected type of argument 1 to function range(): ".concat(x,", number|bigint|BigNumber|Fraction"))},"number, number":function(x,D){return m(p(x,D,1,!1))},"number, number, number":function(x,D,h){return m(p(x,D,h,!1))},"number, number, boolean":function(x,D,h){return m(p(x,D,1,h))},"number, number, number, boolean":function(x,D,h,w){return m(p(x,D,h,w))},"bigint, bigint|number":function(x,D){return m(p(x,D,1n,!1))},"number, bigint":function(x,D){return m(p(BigInt(x),D,1n,!1))},"bigint, bigint|number, bigint|number":function(x,D,h){return m(p(x,D,BigInt(h),!1))},"number, bigint, bigint|number":function(x,D,h){return m(p(BigInt(x),D,BigInt(h),!1))},"bigint, bigint|number, boolean":function(x,D,h){return m(p(x,D,1n,h))},"number, bigint, boolean":function(x,D,h){return m(p(BigInt(x),D,1n,h))},"bigint, bigint|number, bigint|number, boolean":function(x,D,h,w){return m(p(x,D,BigInt(h),w))},"number, bigint, bigint|number, boolean":function(x,D,h,w){return m(p(BigInt(x),D,BigInt(h),w))},"BigNumber, BigNumber":function(x,D){var h=x.constructor;return m(p(x,D,new h(1),!1))},"BigNumber, BigNumber, BigNumber":function(x,D,h){return m(p(x,D,h,!1))},"BigNumber, BigNumber, boolean":function(x,D,h){var w=x.constructor;return m(p(x,D,new w(1),h))},"BigNumber, BigNumber, BigNumber, boolean":function(x,D,h,w){return m(p(x,D,h,w))},"Fraction, Fraction":function(x,D){return m(p(x,D,1,!1))},"Fraction, Fraction, Fraction":function(x,D,h){return m(p(x,D,h,!1))},"Fraction, Fraction, boolean":function(x,D,h){return m(p(x,D,1,h))},"Fraction, Fraction, Fraction, boolean":function(x,D,h,w){return m(p(x,D,h,w))},"Unit, Unit, Unit":function(x,D,h){return m(p(x,D,h,!1))},"Unit, Unit, Unit, boolean":function(x,D,h,w){return m(p(x,D,h,w))}});function m(y){return t.matrix==="Matrix"?n?n(y):CD():y}function v(y,x){var D=d(y);if(!D)throw new SyntaxError('String "'+y+'" is no valid range');return t.number==="BigNumber"?(a===void 0&&Ts(),m(p(a(D.start),a(D.end),a(D.step)))):m(p(D.start,D.end,D.step,x))}function p(y,x,D,h){var w=[];if(c(D))throw new Error("Step must be non-zero");for(var g=f(D)?h?o:i:h?u:l,b=y;g(b,x);)w.push(b),b=s(b,D);return w}function d(y){var x=y.split(":"),D=x.map(function(w){return Number(w)}),h=D.some(function(w){return isNaN(w)});if(h)return null;switch(D.length){case 2:return{start:D[0],end:D[1],step:1};case 3:return{start:D[0],end:D[2],step:D[1]};default:return null}}}),fm="reshape",_D=["typed","isInteger","matrix"],TD=L(fm,_D,r=>{var{typed:e,isInteger:t}=r;return e(fm,{"Matrix, Array":function(a,i){return a.reshape(i,!0)},"Array, Array":function(a,i){return i.forEach(function(o){if(!t(o))throw new TypeError("Invalid size for dimension: "+o)}),cs(a,i)}})}),FD="resize",OD=["config","matrix"],BD=L(FD,OD,r=>{var{config:e,matrix:t}=r;return function(i,o,l){if(arguments.length!==2&&arguments.length!==3)throw new ea("resize",arguments.length,2,3);if(Je(o)&&(o=o.valueOf()),or(o[0])&&(o=o.map(function(c){return or(c)?c.toNumber():c})),Je(i))return i.resize(o,l,!0);if(typeof i=="string")return n(i,o,l);var u=Array.isArray(i)?!1:e.matrix!=="Array";if(o.length===0){for(;Array.isArray(i);)i=i[0];return er(i)}else{Array.isArray(i)||(i=[i]),i=er(i);var s=Ea(i,o,l);return u?t(s):s}};function n(a,i,o){if(o!==void 0){if(typeof o!="string"||o.length!==1)throw new TypeError("Single character expected as defaultValue")}else o=" ";if(i.length!==1)throw new ur(i.length,1);var l=i[0];if(typeof l!="number"||!Ue(l))throw new TypeError("Invalid size, must contain positive integers (size: "+lr(i)+")");if(a.length>l)return a.substring(0,l);if(a.length<l){for(var u=a,s=0,c=l-a.length;s<c;s++)u+=o;return u}else return a}}),mm="rotate",RD=["typed","multiply","rotationMatrix"],ID=L(mm,RD,r=>{var{typed:e,multiply:t,rotationMatrix:n}=r;return e(mm,{"Array , number | BigNumber | Complex | Unit":function(o,l){a(o,2);var u=t(n(l),o);return u.toArray()},"Matrix , number | BigNumber | Complex | Unit":function(o,l){return a(o,2),t(n(l),o)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(o,l,u){a(o,3);var s=t(n(l,u),o);return s},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(o,l,u){return a(o,3),t(n(l,u),o)}});function a(i,o){var l=Array.isArray(i)?rr(i):i.size();if(l.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(o));if(l.length===2&&l[1]!==1)throw new RangeError("Vector must be of dimensions 1x".concat(o));if(l[0]!==o)throw new RangeError("Vector must be of dimensions 1x".concat(o))}}),vm="rotationMatrix",PD=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],$D=L(vm,PD,r=>{var{typed:e,config:t,multiplyScalar:n,addScalar:a,unaryMinus:i,norm:o,BigNumber:l,matrix:u,DenseMatrix:s,SparseMatrix:c,cos:f,sin:m}=r;return e(vm,{"":function(){return t.matrix==="Matrix"?u([]):[]},string:function(h){return u(h)},"number | BigNumber | Complex | Unit":function(h){return v(h,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(h,w){return v(h,w)},"number | BigNumber | Complex | Unit, Array":function(h,w){var g=u(w);return p(g),x(h,g,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(h,w){p(w);var g=w.storage()||(t.matrix==="Matrix"?"dense":void 0);return x(h,w,g)},"number | BigNumber | Complex | Unit, Array, string":function(h,w,g){var b=u(w);return p(b),x(h,b,g)},"number | BigNumber | Complex | Unit, Matrix, string":function(h,w,g){return p(w),x(h,w,g)}});function v(D,h){var w=or(D),g=w?new l(-1):-1,b=f(D),A=m(D),N=[[b,n(g,A)],[A,b]];return y(N,h)}function p(D){var h=D.size();if(h.length<1||h[0]!==3)throw new RangeError("Vector must be of dimensions 1x3")}function d(D){return D.reduce((h,w)=>n(h,w))}function y(D,h){if(h){if(h==="sparse")return new c(D);if(h==="dense")return new s(D);throw new TypeError('Unknown matrix type "'.concat(h,'"'))}return D}function x(D,h,w){var g=o(h);if(g===0)throw new RangeError("Rotation around zero vector");var b=or(D)?l:null,A=b?new b(1):1,N=b?new b(-1):-1,E=b?new b(h.get([0])/g):h.get([0])/g,S=b?new b(h.get([1])/g):h.get([1])/g,C=b?new b(h.get([2])/g):h.get([2])/g,M=f(D),O=a(A,i(M)),I=m(D),k=a(M,d([E,E,O])),_=a(d([E,S,O]),d([N,C,I])),P=a(d([E,C,O]),d([S,I])),V=a(d([E,S,O]),d([C,I])),q=a(M,d([S,S,O])),J=a(d([S,C,O]),d([N,E,I])),ne=a(d([E,C,O]),d([N,S,I])),j=a(d([S,C,O]),d([E,I])),F=a(M,d([C,C,O])),U=[[k,_,P],[V,q,J],[ne,j,F]];return y(U,w)}}),pm="row",qD=["typed","Index","matrix","range"],dm=L(pm,qD,r=>{var{typed:e,Index:t,matrix:n,range:a}=r;return e(pm,{"Matrix, number":i,"Array, number":function(l,u){return i(n(er(l)),u).valueOf()}});function i(o,l){if(o.size().length!==2)throw new Error("Only two dimensional matrix is supported");_r(l,o.size()[0]);var u=a(0,o.size()[1]),s=new t([l],u),c=o.subset(s);return Je(c)?c:n([[c]])}}),hm="size",zD=["typed"],UD=L(hm,zD,r=>{var{typed:e}=r;return e(hm,{Matrix:t=>t.size(),Array:rr,string:t=>[t.length],"number | Complex | BigNumber | Unit | boolean | null":t=>[]})}),gm="squeeze",LD=["typed"],kD=L(gm,LD,r=>{var{typed:e}=r;return e(gm,{Array:function(n){return Yi(er(n))},Matrix:function(n){var a=Yi(n.toArray());return Array.isArray(a)?n.create(a,n.datatype()):a},any:function(n){return er(n)}})}),ym="subset",VD=["typed","matrix","zeros","add"],bm=L(ym,VD,r=>{var{typed:e,matrix:t,zeros:n,add:a}=r;return e(ym,{"Matrix, Index":function(l,u){return Na(u)?t():(Wi(l,u),l.subset(u))},"Array, Index":e.referTo("Matrix, Index",function(o){return function(l,u){var s=o(t(l),u);return u.isScalar()?s:s.valueOf()}}),"Object, Index":HD,"string, Index":GD,"Matrix, Index, any, any":function(l,u,s,c){return Na(u)?l:(Wi(l,u),l.clone().subset(u,i(s,u),c))},"Array, Index, any, any":e.referTo("Matrix, Index, any, any",function(o){return function(l,u,s,c){var f=o(t(l),u,s,c);return f.isMatrix?f.valueOf():f}}),"Array, Index, any":e.referTo("Matrix, Index, any, any",function(o){return function(l,u,s){return o(t(l),u,s,void 0).valueOf()}}),"Matrix, Index, any":e.referTo("Matrix, Index, any, any",function(o){return function(l,u,s){return o(l,u,s,void 0)}}),"string, Index, string":xm,"string, Index, string, string":xm,"Object, Index, any":WD});function i(o,l){if(typeof o=="string")throw new Error("can't boradcast a string");if(l.isScalar())return o;var u=l.size();if(u.every(s=>s>0))try{return a(o,n(u))}catch{return o}else return o}});function GD(r,e){if(!Ti(e))throw new TypeError("Index expected");if(Na(e))return"";if(Wi(Array.from(r),e),e.size().length!==1)throw new ur(e.size().length,1);var t=r.length;_r(e.min()[0],t),_r(e.max()[0],t);var n=e.dimension(0),a="";function i(o){a+=r.charAt(o)}return Number.isInteger(n)?i(n):n.forEach(i),a}function xm(r,e,t,n){if(!e||e.isIndex!==!0)throw new TypeError("Index expected");if(Na(e))return r;if(Wi(Array.from(r),e),e.size().length!==1)throw new ur(e.size().length,1);if(n!==void 0){if(typeof n!="string"||n.length!==1)throw new TypeError("Single character expected as defaultValue")}else n=" ";var a=e.dimension(0),i=Number.isInteger(a)?1:a.size()[0];if(i!==t.length)throw new ur(a.size()[0],t.length);var o=r.length;_r(e.min()[0]),_r(e.max()[0]);for(var l=[],u=0;u<o;u++)l[u]=r.charAt(u);function s(m,v){l[m]=t.charAt(v[0])}if(Number.isInteger(a)?s(a,[0]):a.forEach(s),l.length>o)for(var c=o-1,f=l.length;c<f;c++)l[c]||(l[c]=n);return l.join("")}function HD(r,e){if(!Na(e)){if(e.size().length!==1)throw new ur(e.size(),1);var t=e.dimension(0);if(typeof t!="string")throw new TypeError("String expected as index to retrieve an object property");return pt(r,t)}}function WD(r,e,t){if(Na(e))return r;if(e.size().length!==1)throw new ur(e.size(),1);var n=e.dimension(0);if(typeof n!="string")throw new TypeError("String expected as index to retrieve an object property");var a=er(r);return ma(a,n,t),a}var wm="transpose",YD=["typed","matrix"],ZD=L(wm,YD,r=>{var{typed:e,matrix:t}=r;return e(wm,{Array:o=>n(t(o)).valueOf(),Matrix:n,any:er});function n(o){var l=o.size(),u;switch(l.length){case 1:u=o.clone();break;case 2:{var s=l[0],c=l[1];if(c===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+lr(l)+")");switch(o.storage()){case"dense":u=a(o,s,c);break;case"sparse":u=i(o,s,c);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+lr(l)+")")}return u}function a(o,l,u){for(var s=o._data,c=[],f,m=0;m<u;m++){f=c[m]=[];for(var v=0;v<l;v++)f[v]=er(s[v][m])}return o.createDenseMatrix({data:c,size:[u,l],datatype:o._datatype})}function i(o,l,u){for(var s=o._values,c=o._index,f=o._ptr,m=s?[]:void 0,v=[],p=[],d=[],y=0;y<l;y++)d[y]=0;var x,D,h;for(x=0,D=c.length;x<D;x++)d[c[x]]++;for(var w=0,g=0;g<l;g++)p.push(w),w+=d[g],d[g]=p[g];for(p.push(w),h=0;h<u;h++)for(var b=f[h],A=f[h+1],N=b;N<A;N++){var E=d[c[N]]++;v[E]=h,s&&(m[E]=er(s[N]))}return o.createSparseMatrix({values:m,index:v,ptr:p,size:[u,l],datatype:o._datatype})}}),Dm="ctranspose",JD=["typed","transpose","conj"],jD=L(Dm,JD,r=>{var{typed:e,transpose:t,conj:n}=r;return e(Dm,{any:function(i){return n(t(i))}})}),Nm="zeros",XD=["typed","config","matrix","BigNumber"],QD=L(Nm,XD,r=>{var{typed:e,config:t,matrix:n,BigNumber:a}=r;return e(Nm,{"":function(){return t.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(s){var c=s[s.length-1];if(typeof c=="string"){var f=s.pop();return i(s,f)}else return t.matrix==="Array"?i(s):i(s,"default")},Array:i,Matrix:function(s){var c=s.storage();return i(s.valueOf(),c)},"Array | Matrix, string":function(s,c){return i(s.valueOf(),c)}});function i(u,s){var c=o(u),f=c?new a(0):0;if(l(u),s){var m=n(s);return u.length>0?m.resize(u,f):m}else{var v=[];return u.length>0?Ea(v,u,f):v}}function o(u){var s=!1;return u.forEach(function(c,f,m){or(c)&&(s=!0,m[f]=c.toNumber())}),s}function l(u){u.forEach(function(s){if(typeof s!="number"||!Ue(s)||s<0)throw new Error("Parameters in function zeros must be positive integers")})}}),Em="fft",KD=["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i","dotDivide","conj","pow","ceil","log2"],eN=L(Em,KD,r=>{var{typed:e,matrix:t,addScalar:n,multiplyScalar:a,divideScalar:i,exp:o,tau:l,i:u,dotDivide:s,conj:c,pow:f,ceil:m,log2:v}=r;return e(Em,{Array:p,Matrix:function(h){return h.create(p(h.valueOf()),h.datatype())}});function p(D){var h=rr(D);return h.length===1?x(D,h[0]):d(D.map(w=>p(w,h.slice(1))),0)}function d(D,h){var w=rr(D);if(h!==0)return new Array(w[0]).fill(0).map((b,A)=>d(D[A],h-1));if(w.length===1)return x(D);function g(b){var A=rr(b);return new Array(A[1]).fill(0).map((N,E)=>new Array(A[0]).fill(0).map((S,C)=>b[C][E]))}return g(d(g(D),1))}function y(D){for(var h=D.length,w=o(i(a(-1,a(u,l)),h)),g=[],b=1-h;b<h;b++)g.push(f(w,i(f(b,2),2)));for(var A=f(2,m(v(h+h-1))),N=[...new Array(h).fill(0).map((_,P)=>a(D[P],g[h-1+P])),...new Array(A-h).fill(0)],E=[...new Array(h+h-1).fill(0).map((_,P)=>i(1,g[P])),...new Array(A-(h+h-1)).fill(0)],S=x(N),C=x(E),M=new Array(A).fill(0).map((_,P)=>a(S[P],C[P])),O=s(c(p(c(M))),A),I=[],k=h-1;k<h+h-1;k++)I.push(a(O[k],g[k]));return I}function x(D){var h=D.length;if(h===1)return[D[0]];if(h%2===0){for(var w=[...x(D.filter((N,E)=>E%2===0)),...x(D.filter((N,E)=>E%2===1))],g=0;g<h/2;g++){var b=w[g],A=a(w[g+h/2],o(a(a(l,u),i(-g,h))));w[g]=n(b,A),w[g+h/2]=n(b,a(-1,A))}return w}else return y(D)}}),Am="ifft",rN=["typed","fft","dotDivide","conj"],tN=L(Am,rN,r=>{var{typed:e,fft:t,dotDivide:n,conj:a}=r;return e(Am,{"Array | Matrix":function(o){var l=Je(o)?o.size():rr(o);return n(a(t(a(o))),l.reduce((u,s)=>u*s,1))}})});function si(r){"@babel/helpers - typeof";return si=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},si(r)}function nN(r,e){if(si(r)!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(si(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function aN(r){var e=nN(r,"string");return si(e)=="symbol"?e:e+""}function Vr(r,e,t){return(e=aN(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Sm(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function iN(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Sm(Object(t),!0).forEach(function(n){Vr(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Sm(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}var oN="solveODE",sN=["typed","add","subtract","multiply","divide","max","map","abs","isPositive","isNegative","larger","smaller","matrix","bignumber","unaryMinus"],uN=L(oN,sN,r=>{var{typed:e,add:t,subtract:n,multiply:a,divide:i,max:o,map:l,abs:u,isPositive:s,isNegative:c,larger:f,smaller:m,matrix:v,bignumber:p,unaryMinus:d}=r;function y(N){return function(E,S,C,M){var O=!(S.length===2&&(S.every(b)||S.every(St)));if(O)throw new Error('"tspan" must be an Array of two numeric values or two units [tStart, tEnd]');var I=S[0],k=S[1],_=f(k,I),P=M.firstStep;if(P!==void 0&&!s(P))throw new Error('"firstStep" must be positive');var V=M.maxStep;if(V!==void 0&&!s(V))throw new Error('"maxStep" must be positive');var q=M.minStep;if(q&&c(q))throw new Error('"minStep" must be positive or zero');var J=[I,k,P,q,V].filter(R=>R!==void 0);if(!(J.every(b)||J.every(St)))throw new Error('Inconsistent type of "t" dependant variables');for(var ne=1,j=M.tol?M.tol:1e-4,F=M.minDelta?M.minDelta:.2,U=M.maxDelta?M.maxDelta:5,$=M.maxIter?M.maxIter:1e4,le=[I,k,...C,V,q].some(or),[me,Y,z,X]=le?[p(N.a),p(N.c),p(N.b),p(N.bp)]:[N.a,N.c,N.b,N.bp],se=P?_?P:d(P):i(n(k,I),ne),re=[I],pe=[C],ve=n(z,X),De=0,Oe=0,Ie=w(_),_e=g(_);Ie(re[De],k);){var Le=[];se=_e(re[De],k,se),Le.push(E(re[De],pe[De]));for(var qe=1;qe<Y.length;++qe)Le.push(E(t(re[De],a(Y[qe],se)),t(pe[De],a(se,me[qe],Le))));var G=o(u(l(a(ve,Le),R=>St(R)?R.value:R)));G<j&&j/G>1/4&&(re.push(t(re[De],se)),pe.push(t(pe[De],a(se,z,Le))),De++);var ee=.84*(j/G)**(1/5);if(m(ee,F)?ee=F:f(ee,U)&&(ee=U),ee=le?p(ee):ee,se=a(se,ee),V&&f(u(se),V)?se=_?V:d(V):q&&m(u(se),q)&&(se=_?q:d(q)),Oe++,Oe>$)throw new Error("Maximum number of iterations reached, try changing options")}return{t:re,y:pe}}}function x(N,E,S,C){var M=[[],[.5],[0,.75],[.2222222222222222,.3333333333333333,.4444444444444444]],O=[null,1/2,3/4,1],I=[2/9,1/3,4/9,0],k=[7/24,1/4,1/3,1/8],_={a:M,c:O,b:I,bp:k};return y(_)(N,E,S,C)}function D(N,E,S,C){var M=[[],[.2],[.075,.225],[.9777777777777777,-3.7333333333333334,3.5555555555555554],[2.9525986892242035,-11.595793324188385,9.822892851699436,-.2908093278463649],[2.8462752525252526,-10.757575757575758,8.906422717743473,.2784090909090909,-.2735313036020583],[.09114583333333333,0,.44923629829290207,.6510416666666666,-.322376179245283,.13095238095238096]],O=[null,1/5,3/10,4/5,8/9,1,1],I=[35/384,0,500/1113,125/192,-2187/6784,11/84,0],k=[5179/57600,0,7571/16695,393/640,-92097/339200,187/2100,1/40],_={a:M,c:O,b:I,bp:k};return y(_)(N,E,S,C)}function h(N,E,S,C){var M=C.method?C.method:"RK45",O={RK23:x,RK45:D};if(M.toUpperCase()in O){var I=iN({},C);return delete I.method,O[M.toUpperCase()](N,E,S,I)}else{var k=Object.keys(O).map(P=>'"'.concat(P,'"')),_="".concat(k.slice(0,-1).join(", ")," and ").concat(k.slice(-1));throw new Error('Unavailable method "'.concat(M,'". Available methods are ').concat(_))}}function w(N){return N?m:f}function g(N){var E=N?f:m;return function(S,C,M){var O=t(S,M);return E(O,C)?n(C,S):M}}function b(N){return or(N)||Ye(N)}function A(N,E,S,C){var M=h(N,E.toArray(),S.toArray(),C);return{t:v(M.t),y:v(M.y)}}return e("solveODE",{"function, Array, Array, Object":h,"function, Matrix, Matrix, Object":A,"function, Array, Array":(N,E,S)=>h(N,E,S,{}),"function, Matrix, Matrix":(N,E,S)=>A(N,E,S,{}),"function, Array, number | BigNumber | Unit":(N,E,S)=>{var C=h(N,E,[S],{});return{t:C.t,y:C.y.map(M=>M[0])}},"function, Matrix, number | BigNumber | Unit":(N,E,S)=>{var C=h(N,E.toArray(),[S],{});return{t:v(C.t),y:v(C.y.map(M=>M[0]))}},"function, Array, number | BigNumber | Unit, Object":(N,E,S,C)=>{var M=h(N,E,[S],C);return{t:M.t,y:M.y.map(O=>O[0])}},"function, Matrix, number | BigNumber | Unit, Object":(N,E,S,C)=>{var M=h(N,E.toArray(),[S],C);return{t:v(M.t),y:v(M.y.map(O=>O[0]))}}})}),lN="erf",cN=["typed"],fN=L(lN,cN,r=>{var{typed:e}=r;return e("name",{number:function(o){var l=Math.abs(o);return l>=pN?Sn(o):l<=mN?Sn(o)*t(l):l<=4?Sn(o)*(1-n(l)):Sn(o)*(1-a(l))},"Array | Matrix":e.referToSelf(i=>o=>tr(o,i))});function t(i){var o=i*i,l=hn[0][4]*o,u=o,s;for(s=0;s<3;s+=1)l=(l+hn[0][s])*o,u=(u+Fa[0][s])*o;return i*(l+hn[0][3])/(u+Fa[0][3])}function n(i){var o=hn[1][8]*i,l=i,u;for(u=0;u<7;u+=1)o=(o+hn[1][u])*i,l=(l+Fa[1][u])*i;var s=(o+hn[1][7])/(l+Fa[1][7]),c=parseInt(i*16)/16,f=(i-c)*(i+c);return Math.exp(-c*c)*Math.exp(-f)*s}function a(i){var o=1/(i*i),l=hn[2][5]*o,u=o,s;for(s=0;s<4;s+=1)l=(l+hn[2][s])*o,u=(u+Fa[2][s])*o;var c=o*(l+hn[2][4])/(u+Fa[2][4]);c=(vN-c)/i,o=parseInt(i*16)/16;var f=(i-o)*(i+o);return Math.exp(-o*o)*Math.exp(-f)*c}}),mN=.46875,vN=.5641895835477563,hn=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,21531153547440383e-24],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],Fa=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],pN=Math.pow(2,53),Cm="zeta",dN=["typed","config","multiply","pow","divide","factorial","equal","smallerEq","isBounded","isNegative","gamma","sin","subtract","add","?Complex","?BigNumber","pi"],hN=L(Cm,dN,r=>{var{typed:e,config:t,multiply:n,pow:a,divide:i,factorial:o,equal:l,smallerEq:u,isBounded:s,isNegative:c,gamma:f,sin:m,subtract:v,add:p,Complex:d,BigNumber:y,pi:x}=r;return e(Cm,{number:A=>D(A,N=>N,()=>20),BigNumber:A=>D(A,N=>new y(N),()=>Math.abs(Math.log10(t.relTol))),Complex:h});function D(A,N,E){return l(A,0)?N(-.5):l(A,1)?N(NaN):s(A)?w(A,N,E,S=>S):c(A)?N(NaN):N(1)}function h(A){return A.re===0&&A.im===0?new d(-.5):A.re===1?new d(NaN,NaN):A.re===1/0&&A.im===0?new d(1):A.im===1/0||A.re===-1/0?new d(NaN,NaN):w(A,N=>N,N=>Math.round(1.3*15+.9*Math.abs(N.im)),N=>N.re)}function w(A,N,E,S){var C=E(A);if(S(A)>-(C-1)/2)return b(A,N(C),N);var M=n(a(2,A),a(N(x),v(A,1)));return M=n(M,m(n(i(N(x),2),A))),M=n(M,f(v(1,A))),n(M,w(v(1,A),N,E,S))}function g(A,N){for(var E=A,S=A;u(S,N);S=p(S,1)){var C=i(n(o(p(N,v(S,1))),a(4,S)),n(o(v(N,S)),o(n(2,S))));E=p(E,C)}return n(N,E)}function b(A,N,E){for(var S=i(1,n(g(E(0),N),v(1,a(2,v(1,A))))),C=E(0),M=E(1);u(M,N);M=p(M,1))C=p(C,i(n((-1)**(M-1),g(M,N)),a(M,A)));return n(S,C)}}),Mm="mode",gN=["typed","isNaN","isNumeric"],yN=L(Mm,gN,r=>{var{typed:e,isNaN:t,isNumeric:n}=r;return e(Mm,{"Array | Matrix":a,"...":function(o){return a(o)}});function a(i){i=yr(i.valueOf());var o=i.length;if(o===0)throw new Error("Cannot calculate mode of an empty array");for(var l={},u=[],s=0,c=0;c<i.length;c++){var f=i[c];if(n(f)&&t(f))throw new Error("Cannot calculate mode of an array containing NaN values");f in l||(l[f]=0),l[f]++,l[f]===s?u.push(f):l[f]>s&&(s=l[f],u=[f])}return u}});function dt(r,e,t){var n;return String(r).includes("Unexpected type")?(n=arguments.length>2?" (type: "+Sr(t)+", value: "+JSON.stringify(t)+")":" (type: "+r.data.actual+")",new TypeError("Cannot calculate "+e+", unexpected type of argument"+n)):String(r).includes("complex numbers")?(n=arguments.length>2?" (type: "+Sr(t)+", value: "+JSON.stringify(t)+")":"",new TypeError("Cannot calculate "+e+", no ordering relation is defined for complex numbers"+n)):r}var _m="prod",bN=["typed","config","multiplyScalar","numeric"],xN=L(_m,bN,r=>{var{typed:e,config:t,multiplyScalar:n,numeric:a}=r;return e(_m,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(l,u){throw new Error("prod(A, dim) is not yet supported")},"...":function(l){return i(l)}});function i(o){var l;if(Rn(o,function(u){try{l=l===void 0?u:n(l,u)}catch(s){throw dt(s,"prod",u)}}),typeof l=="string"&&(l=a(l,An(l,t))),l===void 0)throw new Error("Cannot calculate prod of an empty array");return l}}),Tm="format",wN=["typed"],DN=L(Tm,wN,r=>{var{typed:e}=r;return e(Tm,{any:lr,"any, Object | function | number | BigNumber":lr})}),Fm="bin",NN=["typed","format"],EN=L(Fm,NN,r=>{var{typed:e,format:t}=r;return e(Fm,{"number | BigNumber":function(a){return t(a,{notation:"bin"})},"number | BigNumber, number | BigNumber":function(a,i){return t(a,{notation:"bin",wordSize:i})}})}),Om="oct",AN=["typed","format"],SN=L(Om,AN,r=>{var{typed:e,format:t}=r;return e(Om,{"number | BigNumber":function(a){return t(a,{notation:"oct"})},"number | BigNumber, number | BigNumber":function(a,i){return t(a,{notation:"oct",wordSize:i})}})}),Bm="hex",CN=["typed","format"],MN=L(Bm,CN,r=>{var{typed:e,format:t}=r;return e(Bm,{"number | BigNumber":function(a){return t(a,{notation:"hex"})},"number | BigNumber, number | BigNumber":function(a,i){return t(a,{notation:"hex",wordSize:i})}})}),Rm=/\$([\w.]+)/g,Im="print",_N=["typed"],Pm=L(Im,_N,r=>{var{typed:e}=r;return e(Im,{"string, Object | Array":$m,"string, Object | Array, number | Object":$m})});function $m(r,e,t){return r.replace(Rm,function(n,a){var i=a.split("."),o=e[i.shift()];for(o!==void 0&&o.isMatrix&&(o=o.toArray());i.length&&o!==void 0;){var l=i.shift();o=l?o[l]:o+"."}return o!==void 0?$r(o)?o:lr(o,t):n})}var qm="to",TN=["typed","matrix","concat"],FN=L(qm,TN,r=>{var{typed:e,matrix:t,concat:n}=r,a=Tr({typed:e,matrix:t,concat:n});return e(qm,{"Unit, Unit | string":(i,o)=>i.to(o)},a({Ds:!0}))}),zm="toBest",ON=["typed"],BN=L(zm,ON,r=>{var{typed:e}=r;return e(zm,{Unit:t=>t.toBest(),"Unit, string":(t,n)=>t.toBest(n.split(",")),"Unit, string, Object":(t,n,a)=>t.toBest(n.split(","),a),"Unit, Array":(t,n)=>t.toBest(n),"Unit, Array, Object":(t,n,a)=>t.toBest(n,a)})}),Um="isPrime",RN=["typed"],IN=L(Um,RN,r=>{var{typed:e}=r;return e(Um,{number:function(n){if(n<=3)return n>1;if(n%2===0||n%3===0)return!1;for(var a=5;a*a<=n;a+=6)if(n%a===0||n%(a+2)===0)return!1;return!0},bigint:function(n){if(n<=3n)return n>1n;if(n%2n===0n||n%3n===0n)return!1;for(var a=5n;a*a<=n;a+=6n)if(n%a===0n||n%(a+2n)===0n)return!1;return!0},BigNumber:function(n){if(n.lte(3))return n.gt(1);if(n.mod(2).eq(0)||n.mod(3).eq(0))return!1;if(n.lt(Math.pow(2,32))){for(var a=n.toNumber(),i=5;i*i<=a;i+=6)if(a%i===0||a%(i+2)===0)return!1;return!0}function o(D,h,w){for(var g=1;!h.eq(0);)h.mod(2).eq(0)?(h=h.div(2),D=D.mul(D).mod(w)):(h=h.sub(1),g=D.mul(g).mod(w));return g}var l=n.constructor.clone({precision:n.toFixed(0).length*2});n=new l(n);for(var u=0,s=n.sub(1);s.mod(2).eq(0);)s=s.div(2),u+=1;var c=null;if(n.lt("3317044064679887385961981"))c=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter(D=>D<n);else{var f=Math.min(n.toNumber()-2,Math.floor(2*Math.pow(n.toFixed(0).length*Math.log(10),2)));c=[];for(var m=2;m<=f;m+=1)c.push(f)}for(var v=0;v<c.length;v+=1){var p=c[v],d=o(n.sub(n).add(p),s,n);if(!d.eq(1)){for(var y=0,x=d;!x.eq(n.sub(1));y+=1,x=x.mul(x).mod(n))if(y===u-1)return!1}}return!0},"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),PN="numeric",$N=["number","?bignumber","?fraction"],qN=L(PN,$N,r=>{var{number:e,bignumber:t,fraction:n}=r,a={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:o=>e(o),BigNumber:t?o=>t(o):Ts,bigint:o=>BigInt(o),Fraction:n?o=>n(o):um};return function(l){var u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",s=arguments.length>2?arguments[2]:void 0;if(s!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var c=Sr(l);if(!(c in a))throw new TypeError("Cannot convert "+l+' of type "'+c+'"; valid input types are '+Object.keys(a).join(", "));if(!(u in i))throw new TypeError("Cannot convert "+l+' to type "'+u+'"; valid output types are '+Object.keys(i).join(", "));return u===c?l:i[u](l)}}),Lm="divideScalar",zN=["typed","numeric"],UN=L(Lm,zN,r=>{var{typed:e,numeric:t}=r;return e(Lm,{"number, number":function(a,i){return a/i},"Complex, Complex":function(a,i){return a.div(i)},"BigNumber, BigNumber":function(a,i){return a.div(i)},"bigint, bigint":function(a,i){return a/i},"Fraction, Fraction":function(a,i){return a.div(i)},"Unit, number | Complex | Fraction | BigNumber | Unit":(n,a)=>n.divide(a),"number | Fraction | Complex | BigNumber, Unit":(n,a)=>a.divideInto(n)})}),km="pow",LN=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],kN=L(km,LN,r=>{var{typed:e,config:t,identity:n,multiply:a,matrix:i,inv:o,number:l,fraction:u,Complex:s}=r;return e(km,{"number, number":c,"Complex, Complex":function(p,d){return p.pow(d)},"BigNumber, BigNumber":function(p,d){return d.isInteger()||p>=0||t.predictable?p.pow(d):new s(p.toNumber(),0).pow(d.toNumber(),0)},"bigint, bigint":(v,p)=>v**p,"Fraction, Fraction":function(p,d){var y=p.pow(d);if(y!=null)return y;if(t.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return c(p.valueOf(),d.valueOf())},"Array, number":f,"Array, BigNumber":function(p,d){return f(p,d.toNumber())},"Matrix, number":m,"Matrix, BigNumber":function(p,d){return m(p,d.toNumber())},"Unit, number | BigNumber":function(p,d){return p.pow(d)}});function c(v,p){if(t.predictable&&!Ue(p)&&v<0)try{var d=u(p),y=l(d);if((p===y||Math.abs((p-y)/p)<1e-14)&&d.d%2n===1n)return(d.n%2n===0n?1:-1)*Math.pow(-v,p)}catch{}return t.predictable&&(v<-1&&p===1/0||v>-1&&v<0&&p===-1/0)?NaN:Ue(p)||v>=0||t.predictable?oc(v,p):v*v<1&&p===1/0||v*v>1&&p===-1/0?0:new s(v,0).pow(p,0)}function f(v,p){if(!Ue(p))throw new TypeError("For A^b, b must be an integer (value is "+p+")");var d=rr(v);if(d.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+d.length+" dimensions)");if(d[0]!==d[1])throw new Error("For A^b, A must be square (size is "+d[0]+"x"+d[1]+")");if(p<0)try{return f(o(v),-p)}catch(D){throw D.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+p+")"):D}for(var y=n(d[0]).valueOf(),x=v;p>=1;)(p&1)===1&&(y=a(x,y)),p>>=1,x=a(x,x);return y}function m(v,p){return i(f(v.valueOf(),p))}}),Oa="Number of decimals in function round must be an integer",Vm="round",VN=["typed","config","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],GN=L(Vm,VN,r=>{var{typed:e,config:t,matrix:n,equalScalar:a,zeros:i,BigNumber:o,DenseMatrix:l}=r,u=tt({typed:e,equalScalar:a}),s=Hr({typed:e,DenseMatrix:l}),c=Ut({typed:e});function f(m){return Math.abs(ri(m).exponent)}return e(Vm,{number:function(v){var p=ii(v,f(t.relTol)),d=jr(v,p,t.relTol,t.absTol)?p:v;return ii(d)},"number, number":function(v,p){var d=f(t.relTol);if(p>=d)return ii(v,p);var y=ii(v,d),x=jr(v,y,t.relTol,t.absTol)?y:v;return ii(x,p)},"number, BigNumber":function(v,p){if(!p.isInteger())throw new TypeError(Oa);return new o(v).toDecimalPlaces(p.toNumber())},Complex:function(v){return v.round()},"Complex, number":function(v,p){if(p%1)throw new TypeError(Oa);return v.round(p)},"Complex, BigNumber":function(v,p){if(!p.isInteger())throw new TypeError(Oa);var d=p.toNumber();return v.round(d)},BigNumber:function(v){var p=new o(v).toDecimalPlaces(f(t.relTol)),d=zt(v,p,t.relTol,t.absTol)?p:v;return d.toDecimalPlaces(0)},"BigNumber, BigNumber":function(v,p){if(!p.isInteger())throw new TypeError(Oa);var d=f(t.relTol);if(p>=d)return v.toDecimalPlaces(p.toNumber());var y=v.toDecimalPlaces(d),x=zt(v,y,t.relTol,t.absTol)?y:v;return x.toDecimalPlaces(p.toNumber())},bigint:m=>m,"bigint, number":(m,v)=>m,"bigint, BigNumber":(m,v)=>m,Fraction:function(v){return v.round()},"Fraction, number":function(v,p){if(p%1)throw new TypeError(Oa);return v.round(p)},"Fraction, BigNumber":function(v,p){if(!p.isInteger())throw new TypeError(Oa);return v.round(p.toNumber())},"Unit, number, Unit":e.referToSelf(m=>function(v,p,d){var y=v.toNumeric(d);return d.multiply(m(y,p))}),"Unit, BigNumber, Unit":e.referToSelf(m=>(v,p,d)=>m(v,p.toNumber(),d)),"Array | Matrix, number | BigNumber, Unit":e.referToSelf(m=>(v,p,d)=>tr(v,y=>m(y,p,d),!0)),"Array | Matrix | Unit, Unit":e.referToSelf(m=>(v,p)=>m(v,0,p)),"Array | Matrix":e.referToSelf(m=>v=>tr(v,m,!0)),"SparseMatrix, number | BigNumber":e.referToSelf(m=>(v,p)=>u(v,p,m,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(m=>(v,p)=>c(v,p,m,!1)),"Array, number | BigNumber":e.referToSelf(m=>(v,p)=>c(n(v),p,m,!1).valueOf()),"number | Complex | BigNumber | Fraction, SparseMatrix":e.referToSelf(m=>(v,p)=>a(v,0)?i(p.size(),p.storage()):s(p,v,m,!0)),"number | Complex | BigNumber | Fraction, DenseMatrix":e.referToSelf(m=>(v,p)=>a(v,0)?i(p.size(),p.storage()):c(p,v,m,!0)),"number | Complex | BigNumber | Fraction, Array":e.referToSelf(m=>(v,p)=>c(n(p),v,m,!0).valueOf())})}),Gm="log",HN=["config","typed","typeOf","divideScalar","Complex"],WN=Math.log(16),YN=L(Gm,HN,r=>{var{typed:e,typeOf:t,config:n,divideScalar:a,Complex:i}=r;function o(u){return u.log()}function l(u){return o(new i(u,0))}return e(Gm,{number:function(s){return s>=0||n.predictable?tc(s):l(s)},bigint:Ss(WN,tc,n,l),Complex:o,BigNumber:function(s){return!s.isNegative()||n.predictable?s.ln():l(s.toNumber())},"any, any":e.referToSelf(u=>(s,c)=>{if(t(s)==="Fraction"&&t(c)==="Fraction"){var f=s.log(c);if(f!==null)return f}return a(u(s),u(c))})})}),Hm="log1p",ZN=["typed","config","divideScalar","log","Complex"],JN=L(Hm,ZN,r=>{var{typed:e,config:t,divideScalar:n,log:a,Complex:i}=r;return e(Hm,{number:function(u){return u>=-1||t.predictable?q0(u):o(new i(u,0))},Complex:o,BigNumber:function(u){var s=u.plus(1);return!s.isNegative()||t.predictable?s.ln():o(new i(u.toNumber(),0))},"Array | Matrix":e.referToSelf(l=>u=>tr(u,l)),"any, any":e.referToSelf(l=>(u,s)=>n(l(u),a(s)))});function o(l){var u=l.re+1;return new i(Math.log(Math.sqrt(u*u+l.im*l.im)),Math.atan2(l.im,u))}}),Wm="nthRoots",jN=["config","typed","divideScalar","Complex"],XN=L(Wm,jN,r=>{var{typed:e,config:t,divideScalar:n,Complex:a}=r,i=[function(u){return new a(u,0)},function(u){return new a(0,u)},function(u){return new a(-u,0)},function(u){return new a(0,-u)}];function o(l,u){if(u<0)throw new Error("Root must be greater than zero");if(u===0)throw new Error("Root must be non-zero");if(u%1!==0)throw new Error("Root must be an integer");if(l===0||l.abs()===0)return[new a(0,0)];var s=typeof l=="number",c;(s||l.re===0||l.im===0)&&(s?c=2*+(l<0):l.im===0?c=2*+(l.re<0):c=2*+(l.im<0)+1);for(var f=l.arg(),m=l.abs(),v=[],p=Math.pow(m,1/u),d=0;d<u;d++){var y=(c+4*d)/u;if(y===Math.round(y)){v.push(i[y%4](p));continue}v.push(new a({r:p,phi:(f+2*Math.PI*d)/u}))}return v}return e(Wm,{Complex:function(u){return o(u,2)},"Complex, number":o})}),Ym="dotPow",QN=["typed","equalScalar","matrix","pow","DenseMatrix","concat","SparseMatrix"],KN=L(Ym,QN,r=>{var{typed:e,equalScalar:t,matrix:n,pow:a,DenseMatrix:i,concat:o,SparseMatrix:l}=r,u=lt({typed:e}),s=nn({typed:e,SparseMatrix:l}),c=tt({typed:e,equalScalar:t}),f=Hr({typed:e,DenseMatrix:i}),m=Tr({typed:e,matrix:n,concat:o}),v={};for(var p in a.signatures)Object.prototype.hasOwnProperty.call(a.signatures,p)&&!p.includes("Matrix")&&!p.includes("Array")&&(v[p]=a.signatures[p]);var d=e(v);return e(Ym,m({elop:d,SS:s,DS:u,Ss:c,sS:f}))}),Zm="dotDivide",e2=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat","SparseMatrix"],r2=L(Zm,e2,r=>{var{typed:e,matrix:t,equalScalar:n,divideScalar:a,DenseMatrix:i,concat:o,SparseMatrix:l}=r,u=Jt({typed:e,equalScalar:n}),s=lt({typed:e}),c=nn({typed:e,SparseMatrix:l}),f=tt({typed:e,equalScalar:n}),m=Hr({typed:e,DenseMatrix:i}),v=Tr({typed:e,matrix:t,concat:o});return e(Zm,v({elop:a,SS:c,DS:s,SD:u,Ss:f,sS:m}))});function ui(r){var{DenseMatrix:e}=r;return function(n,a,i){var o=n.size();if(o.length!==2)throw new RangeError("Matrix must be two dimensional (size: "+lr(o)+")");var l=o[0],u=o[1];if(l!==u)throw new RangeError("Matrix must be square (size: "+lr(o)+")");var s=[];if(Je(a)){var c=a.size(),f=a._data;if(c.length===1){if(c[0]!==l)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var m=0;m<l;m++)s[m]=[f[m]];return new e({data:s,size:[l,1],datatype:a._datatype})}if(c.length===2){if(c[0]!==l||c[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");if(_i(a)){if(i){s=[];for(var v=0;v<l;v++)s[v]=[f[v][0]];return new e({data:s,size:[l,1],datatype:a._datatype})}return a}if(Yn(a)){for(var p=0;p<l;p++)s[p]=[0];for(var d=a._values,y=a._index,x=a._ptr,D=x[1],h=x[0];h<D;h++){var w=y[h];s[w][0]=d[h]}return new e({data:s,size:[l,1],datatype:a._datatype})}}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}if(Ar(a)){var g=rr(a);if(g.length===1){if(g[0]!==l)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var b=0;b<l;b++)s[b]=[a[b]];return new e({data:s,size:[l,1]})}if(g.length===2){if(g[0]!==l||g[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var A=0;A<l;A++)s[A]=[a[A][0]];return new e({data:s,size:[l,1]})}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}}}var Jm="lsolve",t2=["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],n2=L(Jm,t2,r=>{var{typed:e,matrix:t,divideScalar:n,multiplyScalar:a,subtractScalar:i,equalScalar:o,DenseMatrix:l}=r,u=ui({DenseMatrix:l});return e(Jm,{"SparseMatrix, Array | Matrix":function(m,v){return c(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return s(m,v)},"Array, Array | Matrix":function(m,v){var p=t(m),d=s(p,v);return d.valueOf()}});function s(f,m){m=u(f,m,!0);for(var v=m._data,p=f._size[0],d=f._size[1],y=[],x=f._data,D=0;D<d;D++){var h=v[D][0]||0,w=void 0;if(o(h,0))w=0;else{var g=x[D][D];if(o(g,0))throw new Error("Linear system cannot be solved since matrix is singular");w=n(h,g);for(var b=D+1;b<p;b++)v[b]=[i(v[b][0]||0,a(w,x[b][D]))]}y[D]=[w]}return new l({data:y,size:[p,1]})}function c(f,m){m=u(f,m,!0);for(var v=m._data,p=f._size[0],d=f._size[1],y=f._values,x=f._index,D=f._ptr,h=[],w=0;w<d;w++){var g=v[w][0]||0;if(o(g,0))h[w]=[0];else{for(var b=0,A=[],N=[],E=D[w],S=D[w+1],C=E;C<S;C++){var M=x[C];M===w?b=y[C]:M>w&&(A.push(y[C]),N.push(M))}if(o(b,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var O=n(g,b),I=0,k=N.length;I<k;I++){var _=N[I];v[_]=[i(v[_][0]||0,a(O,A[I]))]}h[w]=[O]}}return new l({data:h,size:[p,1]})}}),jm="usolve",a2=["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],i2=L(jm,a2,r=>{var{typed:e,matrix:t,divideScalar:n,multiplyScalar:a,subtractScalar:i,equalScalar:o,DenseMatrix:l}=r,u=ui({DenseMatrix:l});return e(jm,{"SparseMatrix, Array | Matrix":function(m,v){return c(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return s(m,v)},"Array, Array | Matrix":function(m,v){var p=t(m),d=s(p,v);return d.valueOf()}});function s(f,m){m=u(f,m,!0);for(var v=m._data,p=f._size[0],d=f._size[1],y=[],x=f._data,D=d-1;D>=0;D--){var h=v[D][0]||0,w=void 0;if(o(h,0))w=0;else{var g=x[D][D];if(o(g,0))throw new Error("Linear system cannot be solved since matrix is singular");w=n(h,g);for(var b=D-1;b>=0;b--)v[b]=[i(v[b][0]||0,a(w,x[b][D]))]}y[D]=[w]}return new l({data:y,size:[p,1]})}function c(f,m){m=u(f,m,!0);for(var v=m._data,p=f._size[0],d=f._size[1],y=f._values,x=f._index,D=f._ptr,h=[],w=d-1;w>=0;w--){var g=v[w][0]||0;if(o(g,0))h[w]=[0];else{for(var b=0,A=[],N=[],E=D[w],S=D[w+1],C=S-1;C>=E;C--){var M=x[C];M===w?b=y[C]:M<w&&(A.push(y[C]),N.push(M))}if(o(b,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var O=n(g,b),I=0,k=N.length;I<k;I++){var _=N[I];v[_]=[i(v[_][0],a(O,A[I]))]}h[w]=[O]}}return new l({data:h,size:[p,1]})}}),Xm="lsolveAll",o2=["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],s2=L(Xm,o2,r=>{var{typed:e,matrix:t,divideScalar:n,multiplyScalar:a,subtractScalar:i,equalScalar:o,DenseMatrix:l}=r,u=ui({DenseMatrix:l});return e(Xm,{"SparseMatrix, Array | Matrix":function(m,v){return c(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return s(m,v)},"Array, Array | Matrix":function(m,v){var p=t(m),d=s(p,v);return d.map(y=>y.valueOf())}});function s(f,m){for(var v=[u(f,m,!0)._data.map(N=>N[0])],p=f._data,d=f._size[0],y=f._size[1],x=0;x<y;x++)for(var D=v.length,h=0;h<D;h++){var w=v[h];if(o(p[x][x],0))if(o(w[x],0)){if(h===0){var b=[...w];b[x]=1;for(var A=x+1;A<y;A++)b[A]=i(b[A],p[A][x]);v.push(b)}}else{if(h===0)return[];v.splice(h,1),h-=1,D-=1}else{w[x]=n(w[x],p[x][x]);for(var g=x+1;g<y;g++)w[g]=i(w[g],a(w[x],p[g][x]))}}return v.map(N=>new l({data:N.map(E=>[E]),size:[d,1]}))}function c(f,m){for(var v=[u(f,m,!0)._data.map(ne=>ne[0])],p=f._size[0],d=f._size[1],y=f._values,x=f._index,D=f._ptr,h=0;h<d;h++)for(var w=v.length,g=0;g<w;g++){for(var b=v[g],A=[],N=[],E=D[h],S=D[h+1],C=0,M=E;M<S;M++){var O=x[M];O===h?C=y[M]:O>h&&(A.push(y[M]),N.push(O))}if(o(C,0))if(o(b[h],0)){if(g===0){var P=[...b];P[h]=1;for(var V=0,q=N.length;V<q;V++){var J=N[V];P[J]=i(P[J],A[V])}v.push(P)}}else{if(g===0)return[];v.splice(g,1),g-=1,w-=1}else{b[h]=n(b[h],C);for(var I=0,k=N.length;I<k;I++){var _=N[I];b[_]=i(b[_],a(b[h],A[I]))}}}return v.map(ne=>new l({data:ne.map(j=>[j]),size:[p,1]}))}}),Qm="usolveAll",u2=["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],l2=L(Qm,u2,r=>{var{typed:e,matrix:t,divideScalar:n,multiplyScalar:a,subtractScalar:i,equalScalar:o,DenseMatrix:l}=r,u=ui({DenseMatrix:l});return e(Qm,{"SparseMatrix, Array | Matrix":function(m,v){return c(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return s(m,v)},"Array, Array | Matrix":function(m,v){var p=t(m),d=s(p,v);return d.map(y=>y.valueOf())}});function s(f,m){for(var v=[u(f,m,!0)._data.map(N=>N[0])],p=f._data,d=f._size[0],y=f._size[1],x=y-1;x>=0;x--)for(var D=v.length,h=0;h<D;h++){var w=v[h];if(o(p[x][x],0))if(o(w[x],0)){if(h===0){var b=[...w];b[x]=1;for(var A=x-1;A>=0;A--)b[A]=i(b[A],p[A][x]);v.push(b)}}else{if(h===0)return[];v.splice(h,1),h-=1,D-=1}else{w[x]=n(w[x],p[x][x]);for(var g=x-1;g>=0;g--)w[g]=i(w[g],a(w[x],p[g][x]))}}return v.map(N=>new l({data:N.map(E=>[E]),size:[d,1]}))}function c(f,m){for(var v=[u(f,m,!0)._data.map(ne=>ne[0])],p=f._size[0],d=f._size[1],y=f._values,x=f._index,D=f._ptr,h=d-1;h>=0;h--)for(var w=v.length,g=0;g<w;g++){for(var b=v[g],A=[],N=[],E=D[h],S=D[h+1],C=0,M=S-1;M>=E;M--){var O=x[M];O===h?C=y[M]:O<h&&(A.push(y[M]),N.push(O))}if(o(C,0))if(o(b[h],0)){if(g===0){var P=[...b];P[h]=1;for(var V=0,q=N.length;V<q;V++){var J=N[V];P[J]=i(P[J],A[V])}v.push(P)}}else{if(g===0)return[];v.splice(g,1),g-=1,w-=1}else{b[h]=n(b[h],C);for(var I=0,k=N.length;I<k;I++){var _=N[I];b[_]=i(b[_],a(b[h],A[I]))}}}return v.map(ne=>new l({data:ne.map(j=>[j]),size:[p,1]}))}}),c2="matAlgo08xS0Sid",f2=["typed","equalScalar"],Fs=L(c2,f2,r=>{var{typed:e,equalScalar:t}=r;return function(a,i,o){var l=a._values,u=a._index,s=a._ptr,c=a._size,f=a._datatype||a._data===void 0?a._datatype:a.getDataType(),m=i._values,v=i._index,p=i._ptr,d=i._size,y=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(c.length!==d.length)throw new ur(c.length,d.length);if(c[0]!==d[0]||c[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+d+")");if(!l||!m)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var x=c[0],D=c[1],h,w=t,g=0,b=o;typeof f=="string"&&f===y&&f!=="mixed"&&(h=f,w=e.find(t,[h,h]),g=e.convert(0,h),b=e.find(o,[h,h]));for(var A=[],N=[],E=[],S=[],C=[],M,O,I,k,_=0;_<D;_++){E[_]=N.length;var P=_+1;for(O=s[_],I=s[_+1],M=O;M<I;M++)k=u[M],C[k]=P,S[k]=l[M],N.push(k);for(O=p[_],I=p[_+1],M=O;M<I;M++)k=v[M],C[k]===P&&(S[k]=b(S[k],m[M]));for(M=E[_];M<N.length;){k=N[M];var V=S[k];w(V,g)?N.splice(M,1):(A.push(V),M++)}}return E[D]=N.length,a.createSparseMatrix({values:A,index:N,ptr:E,size:[x,D],datatype:f===a._datatype&&y===i._datatype?h:void 0})}}),Os=L("useMatrixForArrayScalar",["typed","matrix"],r=>{var{typed:e,matrix:t}=r;return{"Array, number":e.referTo("DenseMatrix, number",n=>(a,i)=>n(t(a),i).valueOf()),"Array, BigNumber":e.referTo("DenseMatrix, BigNumber",n=>(a,i)=>n(t(a),i).valueOf()),"number, Array":e.referTo("number, DenseMatrix",n=>(a,i)=>n(a,t(i)).valueOf()),"BigNumber, Array":e.referTo("BigNumber, DenseMatrix",n=>(a,i)=>n(a,t(i)).valueOf())}}),Km="leftShift",m2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],v2=L(Km,m2,r=>{var{typed:e,matrix:t,equalScalar:n,zeros:a,DenseMatrix:i,concat:o}=r,l=In({typed:e}),u=Jt({typed:e,equalScalar:n}),s=Fs({typed:e,equalScalar:n}),c=Kn({typed:e,DenseMatrix:i}),f=tt({typed:e,equalScalar:n}),m=Ut({typed:e}),v=Tr({typed:e,matrix:t,concat:o}),p=Os({typed:e,matrix:t});return e(Km,{"number, number":fc,"BigNumber, BigNumber":Ow,"bigint, bigint":(d,y)=>d<<y,"SparseMatrix, number | BigNumber":e.referToSelf(d=>(y,x)=>n(x,0)?y.clone():f(y,x,d,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(d=>(y,x)=>n(x,0)?y.clone():m(y,x,d,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(d=>(y,x)=>n(y,0)?a(x.size(),x.storage()):c(x,y,d,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(d=>(y,x)=>n(y,0)?a(x.size(),x.storage()):m(x,y,d,!0))},p,v({SS:s,DS:l,SD:u}))}),ev="rightArithShift",p2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],d2=L(ev,p2,r=>{var{typed:e,matrix:t,equalScalar:n,zeros:a,DenseMatrix:i,concat:o}=r,l=In({typed:e}),u=Jt({typed:e,equalScalar:n}),s=Fs({typed:e,equalScalar:n}),c=Kn({typed:e,DenseMatrix:i}),f=tt({typed:e,equalScalar:n}),m=Ut({typed:e}),v=Tr({typed:e,matrix:t,concat:o}),p=Os({typed:e,matrix:t});return e(ev,{"number, number":mc,"BigNumber, BigNumber":Bw,"bigint, bigint":(d,y)=>d>>y,"SparseMatrix, number | BigNumber":e.referToSelf(d=>(y,x)=>n(x,0)?y.clone():f(y,x,d,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(d=>(y,x)=>n(x,0)?y.clone():m(y,x,d,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(d=>(y,x)=>n(y,0)?a(x.size(),x.storage()):c(x,y,d,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(d=>(y,x)=>n(y,0)?a(x.size(),x.storage()):m(x,y,d,!0))},p,v({SS:s,DS:l,SD:u}))}),rv="rightLogShift",h2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],g2=L(rv,h2,r=>{var{typed:e,matrix:t,equalScalar:n,zeros:a,DenseMatrix:i,concat:o}=r,l=In({typed:e}),u=Jt({typed:e,equalScalar:n}),s=Fs({typed:e,equalScalar:n}),c=Kn({typed:e,DenseMatrix:i}),f=tt({typed:e,equalScalar:n}),m=Ut({typed:e}),v=Tr({typed:e,matrix:t,concat:o}),p=Os({typed:e,matrix:t});return e(rv,{"number, number":vc,"SparseMatrix, number | BigNumber":e.referToSelf(d=>(y,x)=>n(x,0)?y.clone():f(y,x,d,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(d=>(y,x)=>n(x,0)?y.clone():m(y,x,d,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(d=>(y,x)=>n(y,0)?a(x.size(),x.storage()):c(x,y,d,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(d=>(y,x)=>n(y,0)?a(x.size(),x.storage()):m(x,y,d,!0))},p,v({SS:s,DS:l,SD:u}))}),tv="and",y2=["typed","matrix","equalScalar","zeros","not","concat"],nv=L(tv,y2,r=>{var{typed:e,matrix:t,equalScalar:n,zeros:a,not:i,concat:o}=r,l=Jt({typed:e,equalScalar:n}),u=oo({typed:e,equalScalar:n}),s=tt({typed:e,equalScalar:n}),c=Ut({typed:e}),f=Tr({typed:e,matrix:t,concat:o});return e(tv,{"number, number":ys,"Complex, Complex":function(v,p){return(v.re!==0||v.im!==0)&&(p.re!==0||p.im!==0)},"BigNumber, BigNumber":function(v,p){return!v.isZero()&&!p.isZero()&&!v.isNaN()&&!p.isNaN()},"bigint, bigint":ys,"Unit, Unit":e.referToSelf(m=>(v,p)=>m(v.value||0,p.value||0)),"SparseMatrix, any":e.referToSelf(m=>(v,p)=>i(p)?a(v.size(),v.storage()):s(v,p,m,!1)),"DenseMatrix, any":e.referToSelf(m=>(v,p)=>i(p)?a(v.size(),v.storage()):c(v,p,m,!1)),"any, SparseMatrix":e.referToSelf(m=>(v,p)=>i(v)?a(v.size(),v.storage()):s(p,v,m,!0)),"any, DenseMatrix":e.referToSelf(m=>(v,p)=>i(v)?a(v.size(),v.storage()):c(p,v,m,!0)),"Array, any":e.referToSelf(m=>(v,p)=>m(t(v),p).valueOf()),"any, Array":e.referToSelf(m=>(v,p)=>m(v,t(p)).valueOf())},f({SS:u,DS:l}))}),uo="compare",b2=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],x2=L(uo,b2,r=>{var{typed:e,config:t,equalScalar:n,matrix:a,BigNumber:i,Fraction:o,DenseMatrix:l,concat:u}=r,s=lt({typed:e}),c=io({typed:e,equalScalar:n}),f=Hr({typed:e,DenseMatrix:l}),m=Tr({typed:e,matrix:a,concat:u}),v=Ta({typed:e});return e(uo,w2({typed:e,config:t}),{"boolean, boolean":function(d,y){return d===y?0:d>y?1:-1},"BigNumber, BigNumber":function(d,y){return zt(d,y,t.relTol,t.absTol)?new i(0):new i(d.cmp(y))},"bigint, bigint":function(d,y){return d===y?0n:d>y?1n:-1n},"Fraction, Fraction":function(d,y){return new o(d.compare(y))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},v,m({SS:c,DS:s,Ss:f}))}),w2=L(uo,["typed","config"],r=>{var{typed:e,config:t}=r;return e(uo,{"number, number":function(a,i){return jr(a,i,t.relTol,t.absTol)?0:a>i?1:-1}})}),ra=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Bs(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function D2(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var a=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:function(){return r[n]}})}),t}var N2=function r(e,t){var n=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,a=/(^[ ]*|[ ]*$)/g,i=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,o=/^0x[0-9a-f]+$/i,l=/^0/,u=function(h){return r.insensitive&&(""+h).toLowerCase()||""+h},s=u(e).replace(a,"")||"",c=u(t).replace(a,"")||"",f=s.replace(n,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),m=c.replace(n,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),v=parseInt(s.match(o),16)||f.length!==1&&s.match(i)&&Date.parse(s),p=parseInt(c.match(o),16)||v&&c.match(i)&&Date.parse(c)||null,d,y;if(p){if(v<p)return-1;if(v>p)return 1}for(var x=0,D=Math.max(f.length,m.length);x<D;x++){if(d=!(f[x]||"").match(l)&&parseFloat(f[x])||f[x]||0,y=!(m[x]||"").match(l)&&parseFloat(m[x])||m[x]||0,isNaN(d)!==isNaN(y))return isNaN(d)?1:-1;if(typeof d!=typeof y&&(d+="",y+=""),d<y)return-1;if(d>y)return 1}return 0};const Ba=Bs(N2);var av="compareNatural",E2=["typed","compare"],A2=L(av,E2,r=>{var{typed:e,compare:t}=r,n=t.signatures["boolean,boolean"];return e(av,{"any, any":a});function a(u,s){var c=Sr(u),f=Sr(s),m;if((c==="number"||c==="BigNumber"||c==="Fraction"||c==="bigint")&&(f==="number"||f==="BigNumber"||f==="Fraction"||f==="bigint"))return m=t(u,s),m.toString()!=="0"?m>0?1:-1:Ba(c,f);var v=["Array","DenseMatrix","SparseMatrix"];if(v.includes(c)||v.includes(f))return m=i(a,u,s),m!==0?m:Ba(c,f);if(c!==f)return Ba(c,f);if(c==="Complex")return S2(u,s);if(c==="Unit")return u.equalBase(s)?a(u.value,s.value):o(a,u.formatUnits(),s.formatUnits());if(c==="boolean")return n(u,s);if(c==="string")return Ba(u,s);if(c==="Object")return l(a,u,s);if(c==="null"||c==="undefined")return 0;throw new TypeError('Unsupported type of value "'+c+'"')}function i(u,s,c){return Yn(s)&&Yn(c)?o(u,s.toJSON().values,c.toJSON().values):Yn(s)?i(u,s.toArray(),c):Yn(c)?i(u,s,c.toArray()):_i(s)?i(u,s.toJSON().data,c):_i(c)?i(u,s,c.toJSON().data):Array.isArray(s)?Array.isArray(c)?o(u,s,c):i(u,s,[c]):i(u,[s],c)}function o(u,s,c){for(var f=0,m=Math.min(s.length,c.length);f<m;f++){var v=u(s[f],c[f]);if(v!==0)return v}return s.length>c.length?1:s.length<c.length?-1:0}function l(u,s,c){var f=Object.keys(s),m=Object.keys(c);f.sort(Ba),m.sort(Ba);var v=o(u,f,m);if(v!==0)return v;for(var p=0;p<f.length;p++){var d=u(s[f[p]],c[m[p]]);if(d!==0)return d}return 0}});function S2(r,e){return r.re>e.re?1:r.re<e.re?-1:r.im>e.im?1:r.im<e.im?-1:0}var iv="compareText",C2=["typed","matrix","concat"];us.signature="any, any";var M2=L(iv,C2,r=>{var{typed:e,matrix:t,concat:n}=r,a=Tr({typed:e,matrix:t,concat:n});return e(iv,us,a({elop:us,Ds:!0}))}),lo="equal",_2=["typed","matrix","equalScalar","DenseMatrix","SparseMatrix"],T2=L(lo,_2,r=>{var{typed:e,matrix:t,equalScalar:n,DenseMatrix:a,concat:i,SparseMatrix:o}=r,l=lt({typed:e}),u=nn({typed:e,SparseMatrix:o}),s=Hr({typed:e,DenseMatrix:a}),c=Tr({typed:e,matrix:t});return e(lo,F2({typed:e,equalScalar:n}),c({elop:n,SS:u,DS:l,Ss:s}))}),F2=L(lo,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e(lo,{"any, any":function(a,i){return a===null?i===null:i===null?a===null:a===void 0?i===void 0:i===void 0?a===void 0:t(a,i)}})}),ov="equalText",O2=["typed","compareText","isZero"],B2=L(ov,O2,r=>{var{typed:e,compareText:t,isZero:n}=r;return e(ov,{"any, any":function(i,o){return n(t(i,o))}})}),co="smaller",R2=["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],I2=L(co,R2,r=>{var{typed:e,config:t,bignumber:n,matrix:a,DenseMatrix:i,concat:o,SparseMatrix:l}=r,u=lt({typed:e}),s=nn({typed:e,SparseMatrix:l}),c=Hr({typed:e,DenseMatrix:i}),f=Tr({typed:e,matrix:a,concat:o}),m=Ta({typed:e});function v(p,d){return p.lt(d)&&!zt(p,d,t.relTol,t.absTol)}return e(co,P2({typed:e,config:t}),{"boolean, boolean":(p,d)=>p<d,"BigNumber, BigNumber":v,"bigint, bigint":(p,d)=>p<d,"Fraction, Fraction":(p,d)=>p.compare(d)===-1,"Fraction, BigNumber":function(d,y){return v(n(d),y)},"BigNumber, Fraction":function(d,y){return v(d,n(y))},"Complex, Complex":function(d,y){throw new TypeError("No ordering relation is defined for complex numbers")}},m,f({SS:s,DS:u,Ss:c}))}),P2=L(co,["typed","config"],r=>{var{typed:e,config:t}=r;return e(co,{"number, number":function(a,i){return a<i&&!jr(a,i,t.relTol,t.absTol)}})}),fo="smallerEq",$2=["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],q2=L(fo,$2,r=>{var{typed:e,config:t,matrix:n,DenseMatrix:a,concat:i,SparseMatrix:o}=r,l=lt({typed:e}),u=nn({typed:e,SparseMatrix:o}),s=Hr({typed:e,DenseMatrix:a}),c=Tr({typed:e,matrix:n,concat:i}),f=Ta({typed:e});return e(fo,z2({typed:e,config:t}),{"boolean, boolean":(m,v)=>m<=v,"BigNumber, BigNumber":function(v,p){return v.lte(p)||zt(v,p,t.relTol,t.absTol)},"bigint, bigint":(m,v)=>m<=v,"Fraction, Fraction":(m,v)=>m.compare(v)!==1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},f,c({SS:u,DS:l,Ss:s}))}),z2=L(fo,["typed","config"],r=>{var{typed:e,config:t}=r;return e(fo,{"number, number":function(a,i){return a<=i||jr(a,i,t.relTol,t.absTol)}})}),mo="larger",U2=["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],L2=L(mo,U2,r=>{var{typed:e,config:t,bignumber:n,matrix:a,DenseMatrix:i,concat:o,SparseMatrix:l}=r,u=lt({typed:e}),s=nn({typed:e,SparseMatrix:l}),c=Hr({typed:e,DenseMatrix:i}),f=Tr({typed:e,matrix:a,concat:o}),m=Ta({typed:e});function v(p,d){return p.gt(d)&&!zt(p,d,t.relTol,t.absTol)}return e(mo,k2({typed:e,config:t}),{"boolean, boolean":(p,d)=>p>d,"BigNumber, BigNumber":v,"bigint, bigint":(p,d)=>p>d,"Fraction, Fraction":(p,d)=>p.compare(d)===1,"Fraction, BigNumber":function(d,y){return v(n(d),y)},"BigNumber, Fraction":function(d,y){return v(d,n(y))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},m,f({SS:s,DS:u,Ss:c}))}),k2=L(mo,["typed","config"],r=>{var{typed:e,config:t}=r;return e(mo,{"number, number":function(a,i){return a>i&&!jr(a,i,t.relTol,t.absTol)}})}),vo="largerEq",V2=["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],G2=L(vo,V2,r=>{var{typed:e,config:t,matrix:n,DenseMatrix:a,concat:i,SparseMatrix:o}=r,l=lt({typed:e}),u=nn({typed:e,SparseMatrix:o}),s=Hr({typed:e,DenseMatrix:a}),c=Tr({typed:e,matrix:n,concat:i}),f=Ta({typed:e});return e(vo,H2({typed:e,config:t}),{"boolean, boolean":(m,v)=>m>=v,"BigNumber, BigNumber":function(v,p){return v.gte(p)||zt(v,p,t.relTol,t.absTol)},"bigint, bigint":function(v,p){return v>=p},"Fraction, Fraction":(m,v)=>m.compare(v)!==-1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},f,c({SS:u,DS:l,Ss:s}))}),H2=L(vo,["typed","config"],r=>{var{typed:e,config:t}=r;return e(vo,{"number, number":function(a,i){return a>=i||jr(a,i,t.relTol,t.absTol)}})}),sv="deepEqual",W2=["typed","equal"],Y2=L(sv,W2,r=>{var{typed:e,equal:t}=r;return e(sv,{"any, any":function(i,o){return n(i.valueOf(),o.valueOf())}});function n(a,i){if(Array.isArray(a))if(Array.isArray(i)){var o=a.length;if(o!==i.length)return!1;for(var l=0;l<o;l++)if(!n(a[l],i[l]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:t(a,i)}}),po="unequal",Z2=["typed","config","equalScalar","matrix","DenseMatrix","concat","SparseMatrix"],J2=L(po,Z2,r=>{var{typed:e,config:t,equalScalar:n,matrix:a,DenseMatrix:i,concat:o,SparseMatrix:l}=r,u=lt({typed:e}),s=nn({typed:e,SparseMatrix:l}),c=Hr({typed:e,DenseMatrix:i}),f=Tr({typed:e,matrix:a,concat:o});return e(po,j2({typed:e,equalScalar:n}),f({elop:m,SS:s,DS:u,Ss:c}));function m(v,p){return!n(v,p)}}),j2=L(po,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e(po,{"any, any":function(a,i){return a===null?i!==null:i===null?a!==null:a===void 0?i!==void 0:i===void 0?a!==void 0:!t(a,i)}})}),uv="partitionSelect",X2=["typed","isNumeric","isNaN","compare"],Q2=L(uv,X2,r=>{var{typed:e,isNumeric:t,isNaN:n,compare:a}=r,i=a,o=(s,c)=>-a(s,c);return e(uv,{"Array | Matrix, number":function(c,f){return l(c,f,i)},"Array | Matrix, number, string":function(c,f,m){if(m==="asc")return l(c,f,i);if(m==="desc")return l(c,f,o);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":l});function l(s,c,f){if(!Ue(c)||c<0)throw new Error("k must be a non-negative integer");if(Je(s)){var m=s.size();if(m.length>1)throw new Error("Only one dimensional matrices supported");return u(s.valueOf(),c,f)}if(Array.isArray(s))return u(s,c,f)}function u(s,c,f){if(c>=s.length)throw new Error("k out of bounds");for(var m=0;m<s.length;m++)if(t(s[m])&&n(s[m]))return s[m];for(var v=0,p=s.length-1;v<p;){for(var d=v,y=p,x=s[Math.floor(Math.random()*(p-v+1))+v];d<y;)if(f(s[d],x)>=0){var D=s[y];s[y]=s[d],s[d]=D,--y}else++d;f(s[d],x)>0&&--d,c<=d?p=d:v=d+1}return s[c]}}),lv="sort",K2=["typed","matrix","compare","compareNatural"],eE=L(lv,K2,r=>{var{typed:e,matrix:t,compare:n,compareNatural:a}=r,i=n,o=(c,f)=>-n(c,f);return e(lv,{Array:function(f){return u(f),f.sort(i)},Matrix:function(f){return s(f),t(f.toArray().sort(i),f.storage())},"Array, function":function(f,m){return u(f),f.sort(m)},"Matrix, function":function(f,m){return s(f),t(f.toArray().sort(m),f.storage())},"Array, string":function(f,m){return u(f),f.sort(l(m))},"Matrix, string":function(f,m){return s(f),t(f.toArray().sort(l(m)),f.storage())}});function l(c){if(c==="asc")return i;if(c==="desc")return o;if(c==="natural")return a;throw new Error('String "asc", "desc", or "natural" expected')}function u(c){if(rr(c).length!==1)throw new Error("One dimensional array expected")}function s(c){if(c.size().length!==1)throw new Error("One dimensional matrix expected")}}),cv="max",rE=["typed","config","numeric","larger","isNaN"],fv=L(cv,rE,r=>{var{typed:e,config:t,numeric:n,larger:a,isNaN:i}=r;return e(cv,{"Array | Matrix":l,"Array | Matrix, number | BigNumber":function(s,c){return Qi(s,c.valueOf(),o)},"...":function(s){if(Sa(s))throw new TypeError("Scalar values expected in function max");return l(s)}});function o(u,s){try{return a(u,s)?u:s}catch(c){throw dt(c,"max",s)}}function l(u){var s;if(Rn(u,function(c){try{(i(c)||s===void 0||a(c,s))&&(s=c)}catch(f){throw dt(f,"max",c)}}),s===void 0)throw new Error("Cannot calculate max of an empty array");return typeof s=="string"&&(s=n(s,An(s,t))),s}}),mv="min",tE=["typed","config","numeric","smaller","isNaN"],vv=L(mv,tE,r=>{var{typed:e,config:t,numeric:n,smaller:a,isNaN:i}=r;return e(mv,{"Array | Matrix":l,"Array | Matrix, number | BigNumber":function(s,c){return Qi(s,c.valueOf(),o)},"...":function(s){if(Sa(s))throw new TypeError("Scalar values expected in function min");return l(s)}});function o(u,s){try{return a(u,s)?u:s}catch(c){throw dt(c,"min",s)}}function l(u){var s;if(Rn(u,function(c){try{(i(c)||s===void 0||a(c,s))&&(s=c)}catch(f){throw dt(f,"min",c)}}),s===void 0)throw new Error("Cannot calculate min of an empty array");return typeof s=="string"&&(s=n(s,An(s,t))),s}}),nE="ImmutableDenseMatrix",aE=["smaller","DenseMatrix"],iE=L(nE,aE,r=>{var{smaller:e,DenseMatrix:t}=r;function n(a,i){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(i&&!$r(i))throw new Error("Invalid datatype: "+i);if(Je(a)||Ar(a)){var o=new t(a,i);this._data=o._data,this._size=o._size,this._datatype=o._datatype,this._min=null,this._max=null}else if(a&&Ar(a.data)&&Ar(a.size))this._data=a.data,this._size=a.size,this._datatype=a.datatype,this._min=typeof a.min<"u"?a.min:null,this._max=typeof a.max<"u"?a.max:null;else{if(a)throw new TypeError("Unsupported type of data ("+Sr(a)+")");this._data=[],this._size=[0],this._datatype=i,this._min=null,this._max=null}}return n.prototype=new t,n.prototype.type="ImmutableDenseMatrix",n.prototype.isImmutableDenseMatrix=!0,n.prototype.subset=function(a){switch(arguments.length){case 1:{var i=t.prototype.subset.call(this,a);return Je(i)?new n({data:i._data,size:i._size,datatype:i._datatype}):i}case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},n.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},n.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},n.prototype.clone=function(){return new n({data:er(this._data),size:er(this._size),datatype:this._datatype})},n.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.fromJSON=function(a){return new n(a)},n.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},n.prototype.min=function(){if(this._min===null){var a=null;this.forEach(function(i){(a===null||e(i,a))&&(a=i)}),this._min=a!==null?a:void 0}return this._min},n.prototype.max=function(){if(this._max===null){var a=null;this.forEach(function(i){(a===null||e(a,i))&&(a=i)}),this._max=a!==null?a:void 0}return this._max},n},{isClass:!0}),oE="Index",sE=["ImmutableDenseMatrix","getMatrixDataType"],uE=L(oE,sE,r=>{var{ImmutableDenseMatrix:e,getMatrixDataType:t}=r;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._sourceSize=[],this._isScalar=!0;for(var i=0,o=arguments.length;i<o;i++){var l=i<0||arguments.length<=i?void 0:arguments[i],u=Ar(l),s=Je(l),c=typeof l,f=null;if(jo(l))this._dimensions.push(l),this._isScalar=!1;else if(u||s){var m=void 0;this._isScalar=!1,t(l)==="boolean"?(u&&(m=a(pv(l).valueOf())),s&&(m=a(pv(l._data).valueOf())),f=l.valueOf().length):m=a(l.valueOf()),this._dimensions.push(m)}else if(c==="number")this._dimensions.push(l);else if(c==="bigint")this._dimensions.push(Number(l));else if(c==="string")this._dimensions.push(l);else throw new TypeError("Dimension must be an Array, Matrix, number, bigint, string, or Range");this._sourceSize.push(f)}}n.prototype.type="Index",n.prototype.isIndex=!0;function a(i){for(var o=0,l=i.length;o<l;o++)if(!Ye(i[o])||!Ue(i[o]))throw new TypeError("Index parameters must be positive integer numbers");var u=new e;return u._data=i,u._size=[i.length],u}return n.prototype.clone=function(){var i=new n;return i._dimensions=er(this._dimensions),i._isScalar=this._isScalar,i._sourceSize=this._sourceSize,i},n.create=function(i){var o=new n;return n.apply(o,i),o},n.prototype.size=function(){for(var i=[],o=0,l=this._dimensions.length;o<l;o++){var u=this._dimensions[o];i[o]=$r(u)||Ye(u)?1:u.size()[0]}return i},n.prototype.max=function(){for(var i=[],o=0,l=this._dimensions.length;o<l;o++){var u=this._dimensions[o];i[o]=$r(u)||Ye(u)?u:u.max()}return i},n.prototype.min=function(){for(var i=[],o=0,l=this._dimensions.length;o<l;o++){var u=this._dimensions[o];i[o]=$r(u)||Ye(u)?u:u.min()}return i},n.prototype.forEach=function(i){for(var o=0,l=this._dimensions.length;o<l;o++)i(this._dimensions[o],o,this)},n.prototype.dimension=function(i){var o;return Ye(i)&&(o=this._dimensions[i])!==null&&o!==void 0?o:null},n.prototype.isObjectProperty=function(){return this._dimensions.length===1&&$r(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 i=[],o=0,l=this._dimensions.length;o<l;o++){var u=this._dimensions[o];i.push($r(u)||Ye(u)?u:u.toArray())}return i},n.prototype.valueOf=n.prototype.toArray,n.prototype.toString=function(){for(var i=[],o=0,l=this._dimensions.length;o<l;o++){var u=this._dimensions[o];$r(u)?i.push(JSON.stringify(u)):i.push(u.toString())}return"["+i.join(", ")+"]"},n.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},n.fromJSON=function(i){return n.create(i.dimensions)},n},{isClass:!0});function pv(r){var e=[];return r.forEach((t,n)=>{t&&e.push(n)}),e}var lE="FibonacciHeap",cE=["smaller","larger"],fE=L(lE,cE,r=>{var{smaller:e,larger:t}=r,n=1/Math.log((1+Math.sqrt(5))/2);function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}a.prototype.type="FibonacciHeap",a.prototype.isFibonacciHeap=!0,a.prototype.insert=function(c,f){var m={key:c,value:f,degree:0};if(this._minimum){var v=this._minimum;m.left=v,m.right=v.right,v.right=m,m.right.left=m,e(c,v.key)&&(this._minimum=m)}else m.left=m,m.right=m,this._minimum=m;return this._size++,m},a.prototype.size=function(){return this._size},a.prototype.clear=function(){this._minimum=null,this._size=0},a.prototype.isEmpty=function(){return this._size===0},a.prototype.extractMinimum=function(){var c=this._minimum;if(c===null)return c;for(var f=this._minimum,m=c.degree,v=c.child;m>0;){var p=v.right;v.left.right=v.right,v.right.left=v.left,v.left=f,v.right=f.right,f.right=v,v.right.left=v,v.parent=null,v=p,m--}return c.left.right=c.right,c.right.left=c.left,c===c.right?f=null:(f=c.right,f=s(f,this._size)),this._size--,this._minimum=f,c},a.prototype.remove=function(c){this._minimum=i(this._minimum,c,-1),this.extractMinimum()};function i(c,f,m){f.key=m;var v=f.parent;return v&&e(f.key,v.key)&&(o(c,f,v),l(c,v)),e(f.key,c.key)&&(c=f),c}function o(c,f,m){f.left.right=f.right,f.right.left=f.left,m.degree--,m.child===f&&(m.child=f.right),m.degree===0&&(m.child=null),f.left=c,f.right=c.right,c.right=f,f.right.left=f,f.parent=null,f.mark=!1}function l(c,f){var m=f.parent;m&&(f.mark?(o(c,f,m),l(m)):f.mark=!0)}var u=function(f,m){f.left.right=f.right,f.right.left=f.left,f.parent=m,m.child?(f.left=m.child,f.right=m.child.right,m.child.right=f,f.right.left=f):(m.child=f,f.right=f,f.left=f),m.degree++,f.mark=!1};function s(c,f){var m=Math.floor(Math.log(f)*n)+1,v=new Array(m),p=0,d=c;if(d)for(p++,d=d.right;d!==c;)p++,d=d.right;for(var y;p>0;){for(var x=d.degree,D=d.right;y=v[x],!!y;){if(t(d.key,y.key)){var h=y;y=d,d=h}u(y,d),v[x]=null,x++}v[x]=d,d=D,p--}c=null;for(var w=0;w<m;w++)y=v[w],y&&(c?(y.left.right=y.right,y.right.left=y.left,y.left=c,y.right=c.right,c.right=y,y.right.left=y,e(y.key,c.key)&&(c=y)):c=y);return c}return a},{isClass:!0}),mE="Spa",vE=["addScalar","equalScalar","FibonacciHeap"],pE=L(mE,vE,r=>{var{addScalar:e,equalScalar:t,FibonacciHeap:n}=r;function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new n}return a.prototype.type="Spa",a.prototype.isSpa=!0,a.prototype.set=function(i,o){if(this._values[i])this._values[i].value=o;else{var l=this._heap.insert(i,o);this._values[i]=l}},a.prototype.get=function(i){var o=this._values[i];return o?o.value:0},a.prototype.accumulate=function(i,o){var l=this._values[i];l?l.value=e(l.value,o):(l=this._heap.insert(i,o),this._values[i]=l)},a.prototype.forEach=function(i,o,l){var u=this._heap,s=this._values,c=[],f=u.extractMinimum();for(f&&c.push(f);f&&f.key<=o;)f.key>=i&&(t(f.value,0)||l(f.key,f.value,this)),f=u.extractMinimum(),f&&c.push(f);for(var m=0;m<c.length;m++){var v=c[m];f=u.insert(v.key,v.value),s[f.key]=f}},a.prototype.swap=function(i,o){var l=this._values[i],u=this._values[o];if(!l&&u)l=this._heap.insert(i,u.value),this._heap.remove(u),this._values[i]=l,this._values[o]=void 0;else if(l&&!u)u=this._heap.insert(o,l.value),this._heap.remove(l),this._values[o]=u,this._values[i]=void 0;else if(l&&u){var s=l.value;l.value=u.value,u.value=s}},a},{isClass:!0});function dE(r){var e=0,t=1,n=Object.create(null),a=Object.create(null),i=0,o=function(u){var s=a[u];if(s&&(delete n[s],delete a[u],--e,t===s)){if(!e){i=0,t=1;return}for(;!Object.prototype.hasOwnProperty.call(n,++t););}};return r=Math.abs(r),{hit:function(u){var s=a[u],c=++i;if(n[c]=u,a[u]=c,!s)return++e,e<=r?void 0:(u=n[t],o(u),u);if(delete n[s],t===s)for(;!Object.prototype.hasOwnProperty.call(n,++t););},delete:o,clear:function(){e=i=0,t=1,n=Object.create(null),a=Object.create(null)}}}function li(r){var{hasher:e,limit:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return t=t??Number.POSITIVE_INFINITY,e=e??JSON.stringify,function n(){typeof n.cache!="object"&&(n.cache={values:new Map,lru:dE(t||Number.POSITIVE_INFINITY)});for(var a=[],i=0;i<arguments.length;i++)a[i]=arguments[i];var o=e(a);if(n.cache.values.has(o))return n.cache.lru.hit(o),n.cache.values.get(o);var l=r.apply(r,a);return n.cache.values.set(o,l),n.cache.values.delete(n.cache.lru.hit(o)),l}}var hE=li(function(r){return new r(1).exp()},{hasher:ho}),gE=li(function(r){return new r(1).plus(new r(5).sqrt()).div(2)},{hasher:ho}),Rs=li(function(r){return r.acos(-1)},{hasher:ho}),yE=li(function(r){return Rs(r).times(2)},{hasher:ho});function ho(r){return r[0].precision}function dv(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function Is(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?dv(Object(t),!0).forEach(function(n){Vr(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):dv(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}var bE="Unit",xE=["?on","config","addScalar","subtractScalar","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","number","Complex","BigNumber","Fraction"],wE=L(bE,xE,r=>{var{on:e,config:t,addScalar:n,subtractScalar:a,multiplyScalar:i,divideScalar:o,pow:l,abs:u,fix:s,round:c,equal:f,isNumeric:m,format:v,number:p,Complex:d,BigNumber:y,Fraction:x}=r,D=p,h=!1,w=!0;function g(G,ee){if(!(this instanceof g))throw new Error("Constructor must be called with the new operator");if(!(G==null||m(G)||ln(G)))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(this.fixPrefix=h,this.skipAutomaticSimplification=w,ee===void 0)this.units=[],this.dimensions=U.map(H=>0);else if(typeof ee=="string"){var R=g.parse(ee);this.units=R.units,this.dimensions=R.dimensions}else if(St(ee)&&ee.value===null)this.fixPrefix=ee.fixPrefix,this.skipAutomaticSimplification=ee.skipAutomaticSimplification,this.dimensions=ee.dimensions.slice(0),this.units=ee.units.map(H=>zr({},H));else throw new TypeError("Second parameter in Unit constructor must be a string or valueless Unit");this.value=this._normalize(G)}Object.defineProperty(g,"name",{value:"Unit"}),g.prototype.constructor=g,g.prototype.type="Unit",g.prototype.isUnit=!0;var b,A,N;function E(){for(;N===" "||N===" ";)M()}function S(G){return G>="0"&&G<="9"||G==="."}function C(G){return G>="0"&&G<="9"}function M(){A++,N=b.charAt(A)}function O(G){A=G,N=b.charAt(A)}function I(){var G="",ee=A;if(N==="+"?M():N==="-"&&(G+=N,M()),!S(N))return O(ee),null;if(N==="."){if(G+=N,M(),!C(N))return O(ee),null}else{for(;C(N);)G+=N,M();N==="."&&(G+=N,M())}for(;C(N);)G+=N,M();if(N==="E"||N==="e"){var R="",H=A;if(R+=N,M(),(N==="+"||N==="-")&&(R+=N,M()),!C(N))return O(H),G;for(G=G+R;C(N);)G+=N,M()}return G}function k(){for(var G="";C(N)||g.isValidAlpha(N);)G+=N,M();var ee=G.charAt(0);return g.isValidAlpha(ee)?G:null}function _(G){return N===G?(M(),G):null}g.parse=function(G,ee){if(ee=ee||{},b=G,A=-1,N="",typeof b!="string")throw new TypeError("Invalid argument in Unit.parse, string expected");var R=new g;R.units=[];var H=1,Q=!1;M(),E();var ie=I(),ue=null;if(ie){if(t.number==="BigNumber")ue=new y(ie);else if(t.number==="Fraction")try{ue=new x(ie)}catch{ue=parseFloat(ie)}else ue=parseFloat(ie);E(),_("*")?(H=1,Q=!0):_("/")&&(H=-1,Q=!0)}for(var oe=[],we=1;;){for(E();N==="(";)oe.push(H),we*=H,H=1,M(),E();var xe=void 0;if(N){var Te=N;if(xe=k(),xe===null)throw new SyntaxError('Unexpected "'+Te+'" in "'+b+'" at index '+A.toString())}else break;var be=P(xe);if(be===null)throw new SyntaxError('Unit "'+xe+'" not found.');var ke=H*we;if(E(),_("^")){E();var fr=I();if(fr===null)throw new SyntaxError('In "'+G+'", "^" must be followed by a floating-point number');ke*=fr}R.units.push({unit:be.unit,prefix:be.prefix,power:ke});for(var hr=0;hr<U.length;hr++)R.dimensions[hr]+=(be.unit.dimensions[hr]||0)*ke;for(E();N===")";){if(oe.length===0)throw new SyntaxError('Unmatched ")" in "'+b+'" at index '+A.toString());we/=oe.pop(),M(),E()}if(Q=!1,_("*")?(H=1,Q=!0):_("/")?(H=-1,Q=!0):H=1,be.unit.base){var ir=be.unit.base.key;re.auto[ir]={unit:be.unit,prefix:be.prefix}}}if(E(),N)throw new SyntaxError('Could not parse: "'+G+'"');if(Q)throw new SyntaxError('Trailing characters: "'+G+'"');if(oe.length!==0)throw new SyntaxError('Unmatched "(" in "'+b+'"');if(R.units.length===0&&!ee.allowNoUnits)throw new SyntaxError('"'+G+'" contains no units');return R.value=ue!==void 0?R._normalize(ue):null,R},g.prototype.clone=function(){var G=new g;G.fixPrefix=this.fixPrefix,G.skipAutomaticSimplification=this.skipAutomaticSimplification,G.value=er(this.value),G.dimensions=this.dimensions.slice(0),G.units=[];for(var ee=0;ee<this.units.length;ee++){G.units[ee]={};for(var R in this.units[ee])$e(this.units[ee],R)&&(G.units[ee][R]=this.units[ee][R])}return G},g.prototype.valueType=function(){return Sr(this.value)},g.prototype._isDerived=function(){return this.units.length===0?!1:this.units.length>1||Math.abs(this.units[0].power-1)>1e-15},g.prototype._normalize=function(G){if(G==null||this.units.length===0)return G;for(var ee=G,R=g._getNumberConverter(Sr(G)),H=0;H<this.units.length;H++){var Q=R(this.units[H].unit.value),ie=R(this.units[H].prefix.value),ue=R(this.units[H].power);ee=i(ee,l(i(Q,ie),ue))}return ee},g.prototype._denormalize=function(G,ee){if(G==null||this.units.length===0)return G;for(var R=G,H=g._getNumberConverter(Sr(G)),Q=0;Q<this.units.length;Q++){var ie=H(this.units[Q].unit.value),ue=H(this.units[Q].prefix.value),oe=H(this.units[Q].power);R=o(R,l(i(ie,ue),oe))}return R};var P=li(G=>{if($e(z,G)){var ee=z[G],R=ee.prefixes[""];return{unit:ee,prefix:R}}for(var H in z)if($e(z,H)&&w1(G,H)){var Q=z[H],ie=G.length-H.length,ue=G.substring(0,ie),oe=$e(Q.prefixes,ue)?Q.prefixes[ue]:void 0;if(oe!==void 0)return{unit:Q,prefix:oe}}return null},{hasher:G=>G[0],limit:100});g.isValuelessUnit=function(G){return P(G)!==null},g.prototype.hasBase=function(G){if(typeof G=="string"&&(G=$[G]),!G)return!1;for(var ee=0;ee<U.length;ee++)if(Math.abs((this.dimensions[ee]||0)-(G.dimensions[ee]||0))>1e-12)return!1;return!0},g.prototype.equalBase=function(G){for(var ee=0;ee<U.length;ee++)if(Math.abs((this.dimensions[ee]||0)-(G.dimensions[ee]||0))>1e-12)return!1;return!0},g.prototype.equals=function(G){return this.equalBase(G)&&f(this.value,G.value)},g.prototype.multiply=function(G){for(var ee=this.clone(),R=St(G)?G:new g(G),H=0;H<U.length;H++)ee.dimensions[H]=(this.dimensions[H]||0)+(R.dimensions[H]||0);for(var Q=0;Q<R.units.length;Q++){var ie=Is({},R.units[Q]);ee.units.push(ie)}if(this.value!==null||R.value!==null){var ue=this.value===null?this._normalize(q(R.value)):this.value,oe=R.value===null?R._normalize(q(this.value)):R.value;ee.value=i(ue,oe)}else ee.value=null;return St(G)&&(ee.skipAutomaticSimplification=!1),V(ee)},g.prototype.divideInto=function(G){return new g(G).divide(this)},g.prototype.divide=function(G){for(var ee=this.clone(),R=St(G)?G:new g(G),H=0;H<U.length;H++)ee.dimensions[H]=(this.dimensions[H]||0)-(R.dimensions[H]||0);for(var Q=0;Q<R.units.length;Q++){var ie=Is(Is({},R.units[Q]),{},{power:-R.units[Q].power});ee.units.push(ie)}if(this.value!==null||R.value!==null){var ue=this.value===null?this._normalize(q(R.value)):this.value,oe=R.value===null?R._normalize(q(this.value)):R.value;ee.value=o(ue,oe)}else ee.value=null;return St(G)&&(ee.skipAutomaticSimplification=!1),V(ee)},g.prototype.pow=function(G){for(var ee=this.clone(),R=0;R<U.length;R++)ee.dimensions[R]=(this.dimensions[R]||0)*G;for(var H=0;H<ee.units.length;H++)ee.units[H].power*=G;return ee.value!==null?ee.value=l(ee.value,G):ee.value=null,ee.skipAutomaticSimplification=!1,V(ee)};function V(G){return G.equalBase($.NONE)&&G.value!==null&&!t.predictable?G.value:G}function q(G){var ee=g._getNumberConverter(Sr(G));return ee(1)}g.prototype.abs=function(){var G=this.clone();if(G.value!==null)if(G._isDerived()||G.units.length===0||G.units[0].unit.offset===0)G.value=u(G.value);else{var ee=G._numberConverter(),R=ee(G.units[0].unit.value),H=ee(G.units[0].unit.offset),Q=i(R,H);G.value=a(u(n(G.value,Q)),Q)}for(var ie in G.units)(G.units[ie].unit.name==="VA"||G.units[ie].unit.name==="VAR")&&(G.units[ie].unit=z.W);return G},g.prototype.to=function(G){var ee=this.value===null?this._normalize(1):this.value,R;if(typeof G=="string")R=g.parse(G);else if(St(G))R=G.clone();else throw new Error("String or Unit expected as parameter");if(!this.equalBase(R))throw new Error("Units do not match ('".concat(R.toString(),"' != '").concat(this.toString(),"')"));if(R.value!==null)throw new Error("Cannot convert to a unit with a value");if(this.value===null||this._isDerived()||this.units.length===0||R.units.length===0||this.units[0].unit.offset===R.units[0].unit.offset)R.value=er(ee);else{var H=g._getNumberConverter(Sr(ee)),Q=this.units[0].unit.value,ie=this.units[0].unit.offset,ue=i(Q,ie),oe=R.units[0].unit.value,we=R.units[0].unit.offset,xe=i(oe,we);R.value=n(ee,H(a(ue,xe)))}return R.fixPrefix=!0,R.skipAutomaticSimplification=!0,R},g.prototype.toNumber=function(G){return D(this.toNumeric(G))},g.prototype.toNumeric=function(G){var ee;return G?ee=this.to(G):ee=this.clone(),ee._isDerived()||ee.units.length===0?ee._denormalize(ee.value):ee._denormalize(ee.value,ee.units[0].prefix.value)},g.prototype.toString=function(){return this.format()},g.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.units.length>0?this.formatUnits():null,fixPrefix:this.fixPrefix,skipSimp:this.skipAutomaticSimplification}},g.fromJSON=function(G){var ee,R,H,Q=new g(G.value,(ee=G.unit)!==null&&ee!==void 0?ee:void 0);return Q.fixPrefix=(R=G.fixPrefix)!==null&&R!==void 0?R:h,Q.skipAutomaticSimplification=(H=G.skipSimp)!==null&&H!==void 0?H:w,Q},g.prototype.valueOf=g.prototype.toString,g.prototype.simplify=function(){var G=this.clone(),ee=[],R;for(var H in pe)if($e(pe,H)&&G.hasBase($[H])){R=H;break}if(R==="NONE")G.units=[];else{var Q;if(R&&$e(pe,R)&&(Q=pe[R]),Q)G.units=[{unit:Q.unit,prefix:Q.prefix,power:1}];else{for(var ie=!1,ue=0;ue<U.length;ue++){var oe=U[ue];Math.abs(G.dimensions[ue]||0)>1e-12&&($e(pe,oe)?ee.push({unit:pe[oe].unit,prefix:pe[oe].prefix,power:G.dimensions[ue]||0}):ie=!0)}ee.length<G.units.length&&!ie&&(G.units=ee)}}return G},g.prototype.toSI=function(){for(var G=this.clone(),ee=[],R=0;R<U.length;R++){var H=U[R];if(Math.abs(G.dimensions[R]||0)>1e-12)if($e(re.si,H))ee.push({unit:re.si[H].unit,prefix:re.si[H].prefix,power:G.dimensions[R]||0});else throw new Error("Cannot express custom unit "+H+" in SI units")}return G.units=ee,G.fixPrefix=!0,G.skipAutomaticSimplification=!0,this.value!==null?(G.value=null,this.to(G)):G},g.prototype.formatUnits=function(){for(var G="",ee="",R=0,H=0,Q=0;Q<this.units.length;Q++)this.units[Q].power>0?(R++,G+=" "+this.units[Q].prefix.name+this.units[Q].unit.name,Math.abs(this.units[Q].power-1)>1e-15&&(G+="^"+this.units[Q].power)):this.units[Q].power<0&&H++;if(H>0)for(var ie=0;ie<this.units.length;ie++)this.units[ie].power<0&&(R>0?(ee+=" "+this.units[ie].prefix.name+this.units[ie].unit.name,Math.abs(this.units[ie].power+1)>1e-15&&(ee+="^"+-this.units[ie].power)):(ee+=" "+this.units[ie].prefix.name+this.units[ie].unit.name,ee+="^"+this.units[ie].power));G=G.substr(1),ee=ee.substr(1),R>1&&H>0&&(G="("+G+")"),H>1&&R>0&&(ee="("+ee+")");var ue=G;return R>0&&H>0&&(ue+=" / "),ue+=ee,ue},g.prototype.toBest=function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(G&&!Array.isArray(G))throw new Error("Invalid unit type. Expected string or Unit.");var R=this.units[0].unit.prefixes;if(G&&G.length>0){var H=G.map(ue=>{var oe=null;if(typeof ue=="string"){if(oe=g.parse(ue),!oe)throw new Error("Invalid unit type. Expected compatible string or Unit.")}else if(!St(ue))throw new Error("Invalid unit type. Expected compatible string or Unit.");oe===null&&(oe=ue.clone());try{return this.to(oe.formatUnits()),oe}catch{throw new Error("Invalid unit type. Expected compatible string or Unit.")}}),Q=H.map(ue=>ue.units[0].prefix);this.units[0].unit.prefixes=Q.reduce((ue,oe)=>(ue[oe.name]=oe,ue),{}),this.units[0].prefix=Q[0]}var ie=J(this,ee).simp;return this.units[0].unit.prefixes=R,ie.fixPrefix=!0,ie},g.prototype.format=function(G){var{simp:ee,valueStr:R,unitStr:H}=J(this,G),Q=R;return ee.value&&ln(ee.value)&&(Q="("+Q+")"),H.length>0&&Q.length>0&&(Q+=" "),Q+=H,Q};function J(G){var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},R=G.skipAutomaticSimplification||G.value===null?G.clone():G.simplify();ne(R),j(R,ee.offset);var H=R._denormalize(R.value),Q=R.value!==null?v(H,ee||{}):"",ie=R.formatUnits();return{simp:R,valueStr:Q,unitStr:ie}}function ne(G){var ee=!1;typeof G.value<"u"&&G.value!==null&&ln(G.value)&&(ee=Math.abs(G.value.re)<1e-14);for(var R in G.units)$e(G.units,R)&&G.units[R].unit&&(G.units[R].unit.name==="VA"&&ee?G.units[R].unit=z.VAR:G.units[R].unit.name==="VAR"&&!ee&&(G.units[R].unit=z.VA))}function j(G,ee){G.units.length===1&&!G.fixPrefix&&Math.abs(G.units[0].power-Math.round(G.units[0].power))<1e-14&&(G.units[0].prefix=G._bestPrefix(ee))}g.prototype._bestPrefix=function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1.2;if(this.units.length!==1)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var ee=this.value!==null?u(this.value):0,R=u(this.units[0].unit.value),H=this.units[0].prefix;if(ee===0)return H;var Q=this.units[0].power,ie=Math.log(ee/Math.pow(H.value*R,Q))/Math.LN10-G;if(ie>-2.200001&&ie<1.800001)return H;ie=Math.abs(ie);var ue=this.units[0].unit.prefixes;for(var oe in ue)if($e(ue,oe)){var we=ue[oe];if(we.scientific){var xe=Math.abs(Math.log(ee/Math.pow(we.value*R,Q))/Math.LN10-G);(xe<ie||xe===ie&&we.name.length<H.name.length)&&(H=we,ie=xe)}}return H},g.prototype.splitUnit=function(G){for(var ee=this.clone(),R=[],H=0;H<G.length&&(ee=ee.to(G[H]),H!==G.length-1);H++){var Q=ee.toNumeric(),ie=c(Q),ue=void 0,oe=f(ie,Q);oe?ue=ie:ue=s(ee.toNumeric());var we=new g(ue,G[H].toString());R.push(we),ee=a(ee,we)}for(var xe=0,Te=0;Te<R.length;Te++)xe=n(xe,R[Te].value);return f(xe,this.value)&&(ee.value=0),R.push(ee),R};var F={NONE:{"":{name:"",value:1,scientific:!0}},SHORT:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:10,scientific:!1},h:{name:"h",value:100,scientific:!1},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0},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:Math.pow(1024,2),scientific:!0},Gi:{name:"Gi",value:Math.pow(1024,3),scientific:!0},Ti:{name:"Ti",value:Math.pow(1024,4),scientific:!0},Pi:{name:"Pi",value:Math.pow(1024,5),scientific:!0},Ei:{name:"Ei",value:Math.pow(1024,6),scientific:!0},Zi:{name:"Zi",value:Math.pow(1024,7),scientific:!0},Yi:{name:"Yi",value:Math.pow(1024,8),scientific:!0}},BINARY_LONG_SI:{"":{name:"",value:1,scientific:!0},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0}},BINARY_LONG_IEC:{"":{name:"",value:1,scientific:!0},kibi:{name:"kibi",value:1024,scientific:!0},mebi:{name:"mebi",value:Math.pow(1024,2),scientific:!0},gibi:{name:"gibi",value:Math.pow(1024,3),scientific:!0},tebi:{name:"tebi",value:Math.pow(1024,4),scientific:!0},pebi:{name:"pebi",value:Math.pow(1024,5),scientific:!0},exi:{name:"exi",value:Math.pow(1024,6),scientific:!0},zebi:{name:"zebi",value:Math.pow(1024,7),scientific:!0},yobi:{name:"yobi",value:Math.pow(1024,8),scientific:!0}},BTU:{"":{name:"",value:1,scientific:!0},MM:{name:"MM",value:1e6,scientific:!0}}};F.SHORTLONG=zr({},F.SHORT,F.LONG),F.BINARY_SHORT=zr({},F.BINARY_SHORT_SI,F.BINARY_SHORT_IEC),F.BINARY_LONG=zr({},F.BINARY_LONG_SI,F.BINARY_LONG_IEC);var U=["MASS","LENGTH","TIME","CURRENT","TEMPERATURE","LUMINOUS_INTENSITY","AMOUNT_OF_SUBSTANCE","ANGLE","BIT"],$={NONE:{dimensions:[0,0,0,0,0,0,0,0,0]},MASS:{dimensions:[1,0,0,0,0,0,0,0,0]},LENGTH:{dimensions:[0,1,0,0,0,0,0,0,0]},TIME:{dimensions:[0,0,1,0,0,0,0,0,0]},CURRENT:{dimensions:[0,0,0,1,0,0,0,0,0]},TEMPERATURE:{dimensions:[0,0,0,0,1,0,0,0,0]},LUMINOUS_INTENSITY:{dimensions:[0,0,0,0,0,1,0,0,0]},AMOUNT_OF_SUBSTANCE:{dimensions:[0,0,0,0,0,0,1,0,0]},FORCE:{dimensions:[1,1,-2,0,0,0,0,0,0]},SURFACE:{dimensions:[0,2,0,0,0,0,0,0,0]},VOLUME:{dimensions:[0,3,0,0,0,0,0,0,0]},ENERGY:{dimensions:[1,2,-2,0,0,0,0,0,0]},POWER:{dimensions:[1,2,-3,0,0,0,0,0,0]},PRESSURE:{dimensions:[1,-1,-2,0,0,0,0,0,0]},ELECTRIC_CHARGE:{dimensions:[0,0,1,1,0,0,0,0,0]},ELECTRIC_CAPACITANCE:{dimensions:[-1,-2,4,2,0,0,0,0,0]},ELECTRIC_POTENTIAL:{dimensions:[1,2,-3,-1,0,0,0,0,0]},ELECTRIC_RESISTANCE:{dimensions:[1,2,-3,-2,0,0,0,0,0]},ELECTRIC_INDUCTANCE:{dimensions:[1,2,-2,-2,0,0,0,0,0]},ELECTRIC_CONDUCTANCE:{dimensions:[-1,-2,3,2,0,0,0,0,0]},MAGNETIC_FLUX:{dimensions:[1,2,-2,-1,0,0,0,0,0]},MAGNETIC_FLUX_DENSITY:{dimensions:[1,0,-2,-1,0,0,0,0,0]},FREQUENCY:{dimensions:[0,0,-1,0,0,0,0,0,0]},ANGLE:{dimensions:[0,0,0,0,0,0,0,1,0]},BIT:{dimensions:[0,0,0,0,0,0,0,0,1]}};for(var le in $)$e($,le)&&($[le].key=le);var me={},Y={name:"",base:me,value:1,offset:0,dimensions:U.map(G=>0)},z={meter:{name:"meter",base:$.LENGTH,prefixes:F.LONG,value:1,offset:0},inch:{name:"inch",base:$.LENGTH,prefixes:F.NONE,value:.0254,offset:0},foot:{name:"foot",base:$.LENGTH,prefixes:F.NONE,value:.3048,offset:0},yard:{name:"yard",base:$.LENGTH,prefixes:F.NONE,value:.9144,offset:0},mile:{name:"mile",base:$.LENGTH,prefixes:F.NONE,value:1609.344,offset:0},link:{name:"link",base:$.LENGTH,prefixes:F.NONE,value:.201168,offset:0},rod:{name:"rod",base:$.LENGTH,prefixes:F.NONE,value:5.0292,offset:0},chain:{name:"chain",base:$.LENGTH,prefixes:F.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:$.LENGTH,prefixes:F.NONE,value:1e-10,offset:0},m:{name:"m",base:$.LENGTH,prefixes:F.SHORT,value:1,offset:0},in:{name:"in",base:$.LENGTH,prefixes:F.NONE,value:.0254,offset:0},ft:{name:"ft",base:$.LENGTH,prefixes:F.NONE,value:.3048,offset:0},yd:{name:"yd",base:$.LENGTH,prefixes:F.NONE,value:.9144,offset:0},mi:{name:"mi",base:$.LENGTH,prefixes:F.NONE,value:1609.344,offset:0},li:{name:"li",base:$.LENGTH,prefixes:F.NONE,value:.201168,offset:0},rd:{name:"rd",base:$.LENGTH,prefixes:F.NONE,value:5.02921,offset:0},ch:{name:"ch",base:$.LENGTH,prefixes:F.NONE,value:20.1168,offset:0},mil:{name:"mil",base:$.LENGTH,prefixes:F.NONE,value:254e-7,offset:0},m2:{name:"m2",base:$.SURFACE,prefixes:F.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:$.SURFACE,prefixes:F.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:$.SURFACE,prefixes:F.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:$.SURFACE,prefixes:F.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:$.SURFACE,prefixes:F.NONE,value:2589988110336e-6,offset:0},sqrd:{name:"sqrd",base:$.SURFACE,prefixes:F.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:$.SURFACE,prefixes:F.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:$.SURFACE,prefixes:F.NONE,value:64516e-14,offset:0},acre:{name:"acre",base:$.SURFACE,prefixes:F.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:$.SURFACE,prefixes:F.NONE,value:1e4,offset:0},m3:{name:"m3",base:$.VOLUME,prefixes:F.CUBIC,value:1,offset:0},L:{name:"L",base:$.VOLUME,prefixes:F.SHORT,value:.001,offset:0},l:{name:"l",base:$.VOLUME,prefixes:F.SHORT,value:.001,offset:0},litre:{name:"litre",base:$.VOLUME,prefixes:F.LONG,value:.001,offset:0},cuin:{name:"cuin",base:$.VOLUME,prefixes:F.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:$.VOLUME,prefixes:F.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:$.VOLUME,prefixes:F.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:$.VOLUME,prefixes:F.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:$.VOLUME,prefixes:F.NONE,value:15e-6,offset:0},drop:{name:"drop",base:$.VOLUME,prefixes:F.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:$.VOLUME,prefixes:F.NONE,value:5e-8,offset:0},minim:{name:"minim",base:$.VOLUME,prefixes:F.NONE,value:61611519921875e-21,offset:0},fluiddram:{name:"fluiddram",base:$.VOLUME,prefixes:F.NONE,value:36966911953125e-19,offset:0},fluidounce:{name:"fluidounce",base:$.VOLUME,prefixes:F.NONE,value:295735295625e-16,offset:0},gill:{name:"gill",base:$.VOLUME,prefixes:F.NONE,value:.00011829411825,offset:0},cc:{name:"cc",base:$.VOLUME,prefixes:F.NONE,value:1e-6,offset:0},cup:{name:"cup",base:$.VOLUME,prefixes:F.NONE,value:.0002365882365,offset:0},pint:{name:"pint",base:$.VOLUME,prefixes:F.NONE,value:.000473176473,offset:0},quart:{name:"quart",base:$.VOLUME,prefixes:F.NONE,value:.000946352946,offset:0},gallon:{name:"gallon",base:$.VOLUME,prefixes:F.NONE,value:.003785411784,offset:0},beerbarrel:{name:"beerbarrel",base:$.VOLUME,prefixes:F.NONE,value:.117347765304,offset:0},oilbarrel:{name:"oilbarrel",base:$.VOLUME,prefixes:F.NONE,value:.158987294928,offset:0},hogshead:{name:"hogshead",base:$.VOLUME,prefixes:F.NONE,value:.238480942392,offset:0},g:{name:"g",base:$.MASS,prefixes:F.SHORT,value:.001,offset:0},gram:{name:"gram",base:$.MASS,prefixes:F.LONG,value:.001,offset:0},ton:{name:"ton",base:$.MASS,prefixes:F.SHORT,value:907.18474,offset:0},t:{name:"t",base:$.MASS,prefixes:F.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:$.MASS,prefixes:F.LONG,value:1e3,offset:0},grain:{name:"grain",base:$.MASS,prefixes:F.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:$.MASS,prefixes:F.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:$.MASS,prefixes:F.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:$.MASS,prefixes:F.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:$.MASS,prefixes:F.NONE,value:45.359237,offset:0},stick:{name:"stick",base:$.MASS,prefixes:F.NONE,value:.115,offset:0},stone:{name:"stone",base:$.MASS,prefixes:F.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:$.MASS,prefixes:F.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:$.MASS,prefixes:F.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:$.MASS,prefixes:F.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:$.MASS,prefixes:F.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:$.MASS,prefixes:F.NONE,value:45.359237,offset:0},s:{name:"s",base:$.TIME,prefixes:F.SHORT,value:1,offset:0},min:{name:"min",base:$.TIME,prefixes:F.NONE,value:60,offset:0},h:{name:"h",base:$.TIME,prefixes:F.NONE,value:3600,offset:0},second:{name:"second",base:$.TIME,prefixes:F.LONG,value:1,offset:0},sec:{name:"sec",base:$.TIME,prefixes:F.LONG,value:1,offset:0},minute:{name:"minute",base:$.TIME,prefixes:F.NONE,value:60,offset:0},hour:{name:"hour",base:$.TIME,prefixes:F.NONE,value:3600,offset:0},day:{name:"day",base:$.TIME,prefixes:F.NONE,value:86400,offset:0},week:{name:"week",base:$.TIME,prefixes:F.NONE,value:7*86400,offset:0},month:{name:"month",base:$.TIME,prefixes:F.NONE,value:2629800,offset:0},year:{name:"year",base:$.TIME,prefixes:F.NONE,value:31557600,offset:0},decade:{name:"decade",base:$.TIME,prefixes:F.NONE,value:315576e3,offset:0},century:{name:"century",base:$.TIME,prefixes:F.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:$.TIME,prefixes:F.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:$.FREQUENCY,prefixes:F.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:$.FREQUENCY,prefixes:F.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:$.ANGLE,prefixes:F.SHORT,value:1,offset:0},radian:{name:"radian",base:$.ANGLE,prefixes:F.LONG,value:1,offset:0},deg:{name:"deg",base:$.ANGLE,prefixes:F.SHORT,value:null,offset:0},degree:{name:"degree",base:$.ANGLE,prefixes:F.LONG,value:null,offset:0},grad:{name:"grad",base:$.ANGLE,prefixes:F.SHORT,value:null,offset:0},gradian:{name:"gradian",base:$.ANGLE,prefixes:F.LONG,value:null,offset:0},cycle:{name:"cycle",base:$.ANGLE,prefixes:F.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:$.ANGLE,prefixes:F.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:$.ANGLE,prefixes:F.NONE,value:null,offset:0},A:{name:"A",base:$.CURRENT,prefixes:F.SHORT,value:1,offset:0},ampere:{name:"ampere",base:$.CURRENT,prefixes:F.LONG,value:1,offset:0},K:{name:"K",base:$.TEMPERATURE,prefixes:F.SHORT,value:1,offset:0},degC:{name:"degC",base:$.TEMPERATURE,prefixes:F.SHORT,value:1,offset:273.15},degF:{name:"degF",base:$.TEMPERATURE,prefixes:F.SHORT,value:new x(5,9),offset:459.67},degR:{name:"degR",base:$.TEMPERATURE,prefixes:F.SHORT,value:new x(5,9),offset:0},kelvin:{name:"kelvin",base:$.TEMPERATURE,prefixes:F.LONG,value:1,offset:0},celsius:{name:"celsius",base:$.TEMPERATURE,prefixes:F.LONG,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:$.TEMPERATURE,prefixes:F.LONG,value:new x(5,9),offset:459.67},rankine:{name:"rankine",base:$.TEMPERATURE,prefixes:F.LONG,value:new x(5,9),offset:0},mol:{name:"mol",base:$.AMOUNT_OF_SUBSTANCE,prefixes:F.SHORT,value:1,offset:0},mole:{name:"mole",base:$.AMOUNT_OF_SUBSTANCE,prefixes:F.LONG,value:1,offset:0},cd:{name:"cd",base:$.LUMINOUS_INTENSITY,prefixes:F.SHORT,value:1,offset:0},candela:{name:"candela",base:$.LUMINOUS_INTENSITY,prefixes:F.LONG,value:1,offset:0},N:{name:"N",base:$.FORCE,prefixes:F.SHORT,value:1,offset:0},newton:{name:"newton",base:$.FORCE,prefixes:F.LONG,value:1,offset:0},dyn:{name:"dyn",base:$.FORCE,prefixes:F.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:$.FORCE,prefixes:F.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:$.FORCE,prefixes:F.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:$.FORCE,prefixes:F.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:$.FORCE,prefixes:F.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:$.FORCE,prefixes:F.NONE,value:9.80665,offset:0},J:{name:"J",base:$.ENERGY,prefixes:F.SHORT,value:1,offset:0},joule:{name:"joule",base:$.ENERGY,prefixes:F.LONG,value:1,offset:0},erg:{name:"erg",base:$.ENERGY,prefixes:F.SHORTLONG,value:1e-7,offset:0},Wh:{name:"Wh",base:$.ENERGY,prefixes:F.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:$.ENERGY,prefixes:F.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:$.ENERGY,prefixes:F.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:$.ENERGY,prefixes:F.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:$.POWER,prefixes:F.SHORT,value:1,offset:0},watt:{name:"watt",base:$.POWER,prefixes:F.LONG,value:1,offset:0},hp:{name:"hp",base:$.POWER,prefixes:F.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:$.POWER,prefixes:F.SHORT,value:d.I,offset:0},VA:{name:"VA",base:$.POWER,prefixes:F.SHORT,value:1,offset:0},Pa:{name:"Pa",base:$.PRESSURE,prefixes:F.SHORT,value:1,offset:0},psi:{name:"psi",base:$.PRESSURE,prefixes:F.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:$.PRESSURE,prefixes:F.NONE,value:101325,offset:0},bar:{name:"bar",base:$.PRESSURE,prefixes:F.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:$.PRESSURE,prefixes:F.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:$.PRESSURE,prefixes:F.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:$.PRESSURE,prefixes:F.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:$.PRESSURE,prefixes:F.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:$.ELECTRIC_CHARGE,prefixes:F.LONG,value:1,offset:0},C:{name:"C",base:$.ELECTRIC_CHARGE,prefixes:F.SHORT,value:1,offset:0},Ah:{name:"Ah",base:$.ELECTRIC_CHARGE,prefixes:F.SHORT,value:3600,offset:0},farad:{name:"farad",base:$.ELECTRIC_CAPACITANCE,prefixes:F.LONG,value:1,offset:0},F:{name:"F",base:$.ELECTRIC_CAPACITANCE,prefixes:F.SHORT,value:1,offset:0},volt:{name:"volt",base:$.ELECTRIC_POTENTIAL,prefixes:F.LONG,value:1,offset:0},V:{name:"V",base:$.ELECTRIC_POTENTIAL,prefixes:F.SHORT,value:1,offset:0},ohm:{name:"ohm",base:$.ELECTRIC_RESISTANCE,prefixes:F.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:$.ELECTRIC_INDUCTANCE,prefixes:F.LONG,value:1,offset:0},H:{name:"H",base:$.ELECTRIC_INDUCTANCE,prefixes:F.SHORT,value:1,offset:0},siemens:{name:"siemens",base:$.ELECTRIC_CONDUCTANCE,prefixes:F.LONG,value:1,offset:0},S:{name:"S",base:$.ELECTRIC_CONDUCTANCE,prefixes:F.SHORT,value:1,offset:0},weber:{name:"weber",base:$.MAGNETIC_FLUX,prefixes:F.LONG,value:1,offset:0},Wb:{name:"Wb",base:$.MAGNETIC_FLUX,prefixes:F.SHORT,value:1,offset:0},tesla:{name:"tesla",base:$.MAGNETIC_FLUX_DENSITY,prefixes:F.LONG,value:1,offset:0},T:{name:"T",base:$.MAGNETIC_FLUX_DENSITY,prefixes:F.SHORT,value:1,offset:0},b:{name:"b",base:$.BIT,prefixes:F.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:$.BIT,prefixes:F.BINARY_LONG,value:1,offset:0},B:{name:"B",base:$.BIT,prefixes:F.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:$.BIT,prefixes:F.BINARY_LONG,value:8,offset:0}},X={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 se(G){if(G.number==="BigNumber"){var ee=Rs(y);z.rad.value=new y(1),z.deg.value=ee.div(180),z.grad.value=ee.div(200),z.cycle.value=ee.times(2),z.arcsec.value=ee.div(648e3),z.arcmin.value=ee.div(10800)}else z.rad.value=1,z.deg.value=Math.PI/180,z.grad.value=Math.PI/200,z.cycle.value=Math.PI*2,z.arcsec.value=Math.PI/648e3,z.arcmin.value=Math.PI/10800;z.radian.value=z.rad.value,z.degree.value=z.deg.value,z.gradian.value=z.grad.value}se(t),e&&e("config",function(G,ee){G.number!==ee.number&&se(G)});var re={si:{NONE:{unit:Y,prefix:F.NONE[""]},LENGTH:{unit:z.m,prefix:F.SHORT[""]},MASS:{unit:z.g,prefix:F.SHORT.k},TIME:{unit:z.s,prefix:F.SHORT[""]},CURRENT:{unit:z.A,prefix:F.SHORT[""]},TEMPERATURE:{unit:z.K,prefix:F.SHORT[""]},LUMINOUS_INTENSITY:{unit:z.cd,prefix:F.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:z.mol,prefix:F.SHORT[""]},ANGLE:{unit:z.rad,prefix:F.SHORT[""]},BIT:{unit:z.bits,prefix:F.SHORT[""]},FORCE:{unit:z.N,prefix:F.SHORT[""]},ENERGY:{unit:z.J,prefix:F.SHORT[""]},POWER:{unit:z.W,prefix:F.SHORT[""]},PRESSURE:{unit:z.Pa,prefix:F.SHORT[""]},ELECTRIC_CHARGE:{unit:z.C,prefix:F.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:z.F,prefix:F.SHORT[""]},ELECTRIC_POTENTIAL:{unit:z.V,prefix:F.SHORT[""]},ELECTRIC_RESISTANCE:{unit:z.ohm,prefix:F.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:z.H,prefix:F.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:z.S,prefix:F.SHORT[""]},MAGNETIC_FLUX:{unit:z.Wb,prefix:F.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:z.T,prefix:F.SHORT[""]},FREQUENCY:{unit:z.Hz,prefix:F.SHORT[""]}}};re.cgs=JSON.parse(JSON.stringify(re.si)),re.cgs.LENGTH={unit:z.m,prefix:F.SHORT.c},re.cgs.MASS={unit:z.g,prefix:F.SHORT[""]},re.cgs.FORCE={unit:z.dyn,prefix:F.SHORT[""]},re.cgs.ENERGY={unit:z.erg,prefix:F.NONE[""]},re.us=JSON.parse(JSON.stringify(re.si)),re.us.LENGTH={unit:z.ft,prefix:F.NONE[""]},re.us.MASS={unit:z.lbm,prefix:F.NONE[""]},re.us.TEMPERATURE={unit:z.degF,prefix:F.NONE[""]},re.us.FORCE={unit:z.lbf,prefix:F.NONE[""]},re.us.ENERGY={unit:z.BTU,prefix:F.BTU[""]},re.us.POWER={unit:z.hp,prefix:F.NONE[""]},re.us.PRESSURE={unit:z.psi,prefix:F.NONE[""]},re.auto=JSON.parse(JSON.stringify(re.si));var pe=re.auto;g.setUnitSystem=function(G){if($e(re,G))pe=re[G];else throw new Error("Unit system "+G+" does not exist. Choices are: "+Object.keys(re).join(", "))},g.getUnitSystem=function(){for(var G in re)if($e(re,G)&&re[G]===pe)return G},g.typeConverters={BigNumber:function(ee){return ee!=null&&ee.isFraction?new y(String(ee.n)).div(String(ee.d)).times(String(ee.s)):new y(ee+"")},Fraction:function(ee){return new x(ee)},Complex:function(ee){return ee},number:function(ee){return ee!=null&&ee.isFraction?p(ee):ee}},g.prototype._numberConverter=function(){var G=g.typeConverters[this.valueType()];if(G)return G;throw new TypeError('Unsupported Unit value type "'+this.valueType()+'"')},g._getNumberConverter=function(G){if(!g.typeConverters[G])throw new TypeError('Unsupported type "'+G+'"');return g.typeConverters[G]};for(var ve in z)if($e(z,ve)){var De=z[ve];De.dimensions=De.base.dimensions}for(var Oe in X)if($e(X,Oe)){var Ie=z[X[Oe]],_e={};for(var Le in Ie)$e(Ie,Le)&&(_e[Le]=Ie[Le]);_e.name=Oe,z[Oe]=_e}g.isValidAlpha=function(ee){return/^[a-zA-Z]$/.test(ee)};function qe(G){for(var ee=0;ee<G.length;ee++){if(N=G.charAt(ee),ee===0&&!g.isValidAlpha(N))throw new Error('Invalid unit name (must begin with alpha character): "'+G+'"');if(ee>0&&!(g.isValidAlpha(N)||C(N)))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+G+'"')}}return g.createUnit=function(G,ee){if(typeof G!="object")throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(ee&&ee.override){for(var R in G)if($e(G,R)&&g.deleteUnit(R),G[R].aliases)for(var H=0;H<G[R].aliases.length;H++)g.deleteUnit(G[R].aliases[H])}var Q;for(var ie in G)$e(G,ie)&&(Q=g.createUnitSingle(ie,G[ie]));return Q},g.createUnitSingle=function(G,ee){if((typeof ee>"u"||ee===null)&&(ee={}),typeof G!="string")throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");if($e(z,G))throw new Error('Cannot create unit "'+G+'": a unit with that name already exists');qe(G);var R=null,H=[],Q=0,ie,ue,oe;if(ee&&ee.type==="Unit")R=ee.clone();else if(typeof ee=="string")ee!==""&&(ie=ee);else if(typeof ee=="object")ie=ee.definition,ue=ee.prefixes,Q=ee.offset,oe=ee.baseName,ee.aliases&&(H=ee.aliases.valueOf());else throw new TypeError('Cannot create unit "'+G+'" from "'+ee.toString()+'": expecting "string" or "Unit" or "Object"');if(H){for(var we=0;we<H.length;we++)if($e(z,H[we]))throw new Error('Cannot create alias "'+H[we]+'": a unit with that name already exists')}if(ie&&typeof ie=="string"&&!R)try{R=g.parse(ie,{allowNoUnits:!0})}catch(Ke){throw Ke.message='Could not create unit "'+G+'" from "'+ie+'": '+Ke.message,Ke}else ie&&ie.type==="Unit"&&(R=ie.clone());H=H||[],Q=Q||0,ue&&ue.toUpperCase?ue=F[ue.toUpperCase()]||F.NONE:ue=F.NONE;var xe={};if(R){xe={name:G,value:R.value,dimensions:R.dimensions.slice(0),prefixes:ue,offset:Q};var fr=!1;for(var hr in $)if($e($,hr)){for(var ir=!0,Fr=0;Fr<U.length;Fr++)if(Math.abs((xe.dimensions[Fr]||0)-($[hr].dimensions[Fr]||0))>1e-12){ir=!1;break}if(ir){fr=!0,xe.base=$[hr];break}}if(!fr){oe=oe||G+"_STUFF";var T={dimensions:R.dimensions.slice(0)};T.key=oe,$[oe]=T,pe[oe]={unit:xe,prefix:F.NONE[""]},xe.base=$[oe]}}else{if(oe=oe||G+"_STUFF",U.indexOf(oe)>=0)throw new Error('Cannot create new base unit "'+G+'": a base unit with that name already exists (and cannot be overridden)');U.push(oe);for(var Te in $)$e($,Te)&&($[Te].dimensions[U.length-1]=0);for(var be={dimensions:[]},ke=0;ke<U.length;ke++)be.dimensions[ke]=0;be.dimensions[U.length-1]=1,be.key=oe,$[oe]=be,xe={name:G,value:1,dimensions:$[oe].dimensions.slice(0),prefixes:ue,offset:Q,base:$[oe]},pe[oe]={unit:xe,prefix:F.NONE[""]}}g.UNITS[G]=xe;for(var K=0;K<H.length;K++){var de=H[K],Se={};for(var ze in xe)$e(xe,ze)&&(Se[ze]=xe[ze]);Se.name=de,g.UNITS[de]=Se}return delete P.cache,new g(null,G)},g.deleteUnit=function(G){delete g.UNITS[G],delete P.cache},g.PREFIXES=F,g.BASE_DIMENSIONS=U,g.BASE_UNITS=$,g.UNIT_SYSTEMS=re,g.UNITS=z,g},{isClass:!0}),hv="unit",DE=["typed","Unit"],NE=L(hv,DE,r=>{var{typed:e,Unit:t}=r;return e(hv,{Unit:function(a){return a.clone()},string:function(a){return t.isValuelessUnit(a)?new t(null,a):t.parse(a,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string | Unit":function(a,i){return new t(a,i)},"number | BigNumber | Fraction":function(a){return new t(a)},"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),gv="sparse",EE=["typed","SparseMatrix"],AE=L(gv,EE,r=>{var{typed:e,SparseMatrix:t}=r;return e(gv,{"":function(){return new t([])},string:function(a){return new t([],a)},"Array | Matrix":function(a){return new t(a)},"Array | Matrix, string":function(a,i){return new t(a,i)}})}),yv="createUnit",SE=["typed","Unit"],CE=L(yv,SE,r=>{var{typed:e,Unit:t}=r;return e(yv,{"Object, Object":function(a,i){return t.createUnit(a,i)},Object:function(a){return t.createUnit(a,{})},"string, Unit | string | Object, Object":function(a,i,o){var l={};return l[a]=i,t.createUnit(l,o)},"string, Unit | string | Object":function(a,i){var o={};return o[a]=i,t.createUnit(o,{})},string:function(a){var i={};return i[a]={},t.createUnit(i,{})}})}),bv="acos",ME=["typed","config","Complex"],_E=L(bv,ME,r=>{var{typed:e,config:t,Complex:n}=r;return e(bv,{number:function(i){return i>=-1&&i<=1||t.predictable?Math.acos(i):new n(i,0).acos()},Complex:function(i){return i.acos()},BigNumber:function(i){return i.acos()}})}),xv="acosh",TE=["typed","config","Complex"],FE=L(xv,TE,r=>{var{typed:e,config:t,Complex:n}=r;return e(xv,{number:function(i){return i>=1||t.predictable?bc(i):i<=-1?new n(Math.log(Math.sqrt(i*i-1)-i),Math.PI):new n(i,0).acosh()},Complex:function(i){return i.acosh()},BigNumber:function(i){return i.acosh()}})}),wv="acot",OE=["typed","BigNumber"],BE=L(wv,OE,r=>{var{typed:e,BigNumber:t}=r;return e(wv,{number:xc,Complex:function(a){return a.acot()},BigNumber:function(a){return new t(1).div(a).atan()}})}),Dv="acoth",RE=["typed","config","Complex","BigNumber"],IE=L(Dv,RE,r=>{var{typed:e,config:t,Complex:n,BigNumber:a}=r;return e(Dv,{number:function(o){return o>=1||o<=-1||t.predictable?wc(o):new n(o,0).acoth()},Complex:function(o){return o.acoth()},BigNumber:function(o){return new a(1).div(o).atanh()}})}),Nv="acsc",PE=["typed","config","Complex","BigNumber"],$E=L(Nv,PE,r=>{var{typed:e,config:t,Complex:n,BigNumber:a}=r;return e(Nv,{number:function(o){return o<=-1||o>=1||t.predictable?Dc(o):new n(o,0).acsc()},Complex:function(o){return o.acsc()},BigNumber:function(o){return new a(1).div(o).asin()}})}),Ev="acsch",qE=["typed","BigNumber"],zE=L(Ev,qE,r=>{var{typed:e,BigNumber:t}=r;return e(Ev,{number:Nc,Complex:function(a){return a.acsch()},BigNumber:function(a){return new t(1).div(a).asinh()}})}),Av="asec",UE=["typed","config","Complex","BigNumber"],LE=L(Av,UE,r=>{var{typed:e,config:t,Complex:n,BigNumber:a}=r;return e(Av,{number:function(o){return o<=-1||o>=1||t.predictable?Ec(o):new n(o,0).asec()},Complex:function(o){return o.asec()},BigNumber:function(o){return new a(1).div(o).acos()}})}),Sv="asech",kE=["typed","config","Complex","BigNumber"],VE=L(Sv,kE,r=>{var{typed:e,config:t,Complex:n,BigNumber:a}=r;return e(Sv,{number:function(o){if(o<=1&&o>=-1||t.predictable){var l=1/o;if(l>0||t.predictable)return Ac(o);var u=Math.sqrt(l*l-1);return new n(Math.log(u-l),Math.PI)}return new n(o,0).asech()},Complex:function(o){return o.asech()},BigNumber:function(o){return new a(1).div(o).acosh()}})}),Cv="asin",GE=["typed","config","Complex"],HE=L(Cv,GE,r=>{var{typed:e,config:t,Complex:n}=r;return e(Cv,{number:function(i){return i>=-1&&i<=1||t.predictable?Math.asin(i):new n(i,0).asin()},Complex:function(i){return i.asin()},BigNumber:function(i){return i.asin()}})}),WE="asinh",YE=["typed"],ZE=L(WE,YE,r=>{var{typed:e}=r;return e("asinh",{number:Sc,Complex:function(n){return n.asinh()},BigNumber:function(n){return n.asinh()}})}),JE="atan",jE=["typed"],XE=L(JE,jE,r=>{var{typed:e}=r;return e("atan",{number:function(n){return Math.atan(n)},Complex:function(n){return n.atan()},BigNumber:function(n){return n.atan()}})}),Mv="atan2",QE=["typed","matrix","equalScalar","BigNumber","DenseMatrix","concat"],KE=L(Mv,QE,r=>{var{typed:e,matrix:t,equalScalar:n,BigNumber:a,DenseMatrix:i,concat:o}=r,l=Jt({typed:e,equalScalar:n}),u=lt({typed:e}),s=Cf({typed:e,equalScalar:n}),c=tt({typed:e,equalScalar:n}),f=Hr({typed:e,DenseMatrix:i}),m=Tr({typed:e,matrix:t,concat:o});return e(Mv,{"number, number":Math.atan2,"BigNumber, BigNumber":(v,p)=>a.atan2(v,p)},m({scalar:"number | BigNumber",SS:s,DS:u,SD:l,Ss:c,sS:f}))}),_v="atanh",eA=["typed","config","Complex"],rA=L(_v,eA,r=>{var{typed:e,config:t,Complex:n}=r;return e(_v,{number:function(i){return i<=1&&i>=-1||t.predictable?Cc(i):new n(i,0).atanh()},Complex:function(i){return i.atanh()},BigNumber:function(i){return i.atanh()}})}),Ra=L("trigUnit",["typed"],r=>{var{typed:e}=r;return{Unit:e.referToSelf(t=>n=>{if(!n.hasBase(n.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return e.find(t,n.valueType())(n.value)})}}),Tv="cos",tA=["typed"],nA=L(Tv,tA,r=>{var{typed:e}=r,t=Ra({typed:e});return e(Tv,{number:Math.cos,"Complex | BigNumber":n=>n.cos()},t)}),Fv="cosh",aA=["typed"],iA=L(Fv,aA,r=>{var{typed:e}=r;return e(Fv,{number:Y0,"Complex | BigNumber":t=>t.cosh()})}),Ov="cot",oA=["typed","BigNumber"],sA=L(Ov,oA,r=>{var{typed:e,BigNumber:t}=r,n=Ra({typed:e});return e(Ov,{number:Mc,Complex:a=>a.cot(),BigNumber:a=>new t(1).div(a.tan())},n)}),Bv="coth",uA=["typed","BigNumber"],lA=L(Bv,uA,r=>{var{typed:e,BigNumber:t}=r;return e(Bv,{number:_c,Complex:n=>n.coth(),BigNumber:n=>new t(1).div(n.tanh())})}),Rv="csc",cA=["typed","BigNumber"],fA=L(Rv,cA,r=>{var{typed:e,BigNumber:t}=r,n=Ra({typed:e});return e(Rv,{number:Tc,Complex:a=>a.csc(),BigNumber:a=>new t(1).div(a.sin())},n)}),Iv="csch",mA=["typed","BigNumber"],vA=L(Iv,mA,r=>{var{typed:e,BigNumber:t}=r;return e(Iv,{number:Fc,Complex:n=>n.csch(),BigNumber:n=>new t(1).div(n.sinh())})}),Pv="sec",pA=["typed","BigNumber"],dA=L(Pv,pA,r=>{var{typed:e,BigNumber:t}=r,n=Ra({typed:e});return e(Pv,{number:Oc,Complex:a=>a.sec(),BigNumber:a=>new t(1).div(a.cos())},n)}),$v="sech",hA=["typed","BigNumber"],gA=L($v,hA,r=>{var{typed:e,BigNumber:t}=r;return e($v,{number:Bc,Complex:n=>n.sech(),BigNumber:n=>new t(1).div(n.cosh())})}),qv="sin",yA=["typed"],bA=L(qv,yA,r=>{var{typed:e}=r,t=Ra({typed:e});return e(qv,{number:Math.sin,"Complex | BigNumber":n=>n.sin()},t)}),zv="sinh",xA=["typed"],wA=L(zv,xA,r=>{var{typed:e}=r;return e(zv,{number:Rc,"Complex | BigNumber":t=>t.sinh()})}),Uv="tan",DA=["typed"],NA=L(Uv,DA,r=>{var{typed:e}=r,t=Ra({typed:e});return e(Uv,{number:Math.tan,"Complex | BigNumber":n=>n.tan()},t)}),EA="tanh",AA=["typed"],SA=L(EA,AA,r=>{var{typed:e}=r;return e("tanh",{number:J0,"Complex | BigNumber":t=>t.tanh()})}),Lv="setCartesian",CA=["typed","size","subset","compareNatural","Index","DenseMatrix"],MA=L(Lv,CA,r=>{var{typed:e,size:t,subset:n,compareNatural:a,Index:i,DenseMatrix:o}=r;return e(Lv,{"Array | Matrix, Array | Matrix":function(u,s){var c=[];if(n(t(u),new i(0))!==0&&n(t(s),new i(0))!==0){var f=yr(Array.isArray(u)?u:u.toArray()).sort(a),m=yr(Array.isArray(s)?s:s.toArray()).sort(a);c=[];for(var v=0;v<f.length;v++)for(var p=0;p<m.length;p++)c.push([f[v],m[p]])}return Array.isArray(u)&&Array.isArray(s)?c:new o(c)}})}),kv="setDifference",_A=["typed","size","subset","compareNatural","Index","DenseMatrix"],TA=L(kv,_A,r=>{var{typed:e,size:t,subset:n,compareNatural:a,Index:i,DenseMatrix:o}=r;return e(kv,{"Array | Matrix, Array | Matrix":function(u,s){var c;if(n(t(u),new i(0))===0)c=[];else{if(n(t(s),new i(0))===0)return yr(u.toArray());var f=Aa(yr(Array.isArray(u)?u:u.toArray()).sort(a)),m=Aa(yr(Array.isArray(s)?s:s.toArray()).sort(a));c=[];for(var v,p=0;p<f.length;p++){v=!1;for(var d=0;d<m.length;d++)if(a(f[p].value,m[d].value)===0&&f[p].identifier===m[d].identifier){v=!0;break}v||c.push(f[p])}}return Array.isArray(u)&&Array.isArray(s)?Zi(c):new o(Zi(c))}})}),Vv="setDistinct",FA=["typed","size","subset","compareNatural","Index","DenseMatrix"],OA=L(Vv,FA,r=>{var{typed:e,size:t,subset:n,compareNatural:a,Index:i,DenseMatrix:o}=r;return e(Vv,{"Array | Matrix":function(u){var s;if(n(t(u),new i(0))===0)s=[];else{var c=yr(Array.isArray(u)?u:u.toArray()).sort(a);s=[],s.push(c[0]);for(var f=1;f<c.length;f++)a(c[f],c[f-1])!==0&&s.push(c[f])}return Array.isArray(u)?s:new o(s)}})}),Gv="setIntersect",BA=["typed","size","subset","compareNatural","Index","DenseMatrix"],RA=L(Gv,BA,r=>{var{typed:e,size:t,subset:n,compareNatural:a,Index:i,DenseMatrix:o}=r;return e(Gv,{"Array | Matrix, Array | Matrix":function(u,s){var c;if(n(t(u),new i(0))===0||n(t(s),new i(0))===0)c=[];else{var f=Aa(yr(Array.isArray(u)?u:u.toArray()).sort(a)),m=Aa(yr(Array.isArray(s)?s:s.toArray()).sort(a));c=[];for(var v=0;v<f.length;v++)for(var p=0;p<m.length;p++)if(a(f[v].value,m[p].value)===0&&f[v].identifier===m[p].identifier){c.push(f[v]);break}}return Array.isArray(u)&&Array.isArray(s)?Zi(c):new o(Zi(c))}})}),Hv="setIsSubset",IA=["typed","size","subset","compareNatural","Index"],PA=L(Hv,IA,r=>{var{typed:e,size:t,subset:n,compareNatural:a,Index:i}=r;return e(Hv,{"Array | Matrix, Array | Matrix":function(l,u){if(n(t(l),new i(0))===0)return!0;if(n(t(u),new i(0))===0)return!1;for(var s=Aa(yr(Array.isArray(l)?l:l.toArray()).sort(a)),c=Aa(yr(Array.isArray(u)?u:u.toArray()).sort(a)),f,m=0;m<s.length;m++){f=!1;for(var v=0;v<c.length;v++)if(a(s[m].value,c[v].value)===0&&s[m].identifier===c[v].identifier){f=!0;break}if(f===!1)return!1}return!0}})}),Wv="setMultiplicity",$A=["typed","size","subset","compareNatural","Index"],qA=L(Wv,$A,r=>{var{typed:e,size:t,subset:n,compareNatural:a,Index:i}=r;return e(Wv,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(l,u){if(n(t(u),new i(0))===0)return 0;for(var s=yr(Array.isArray(u)?u:u.toArray()),c=0,f=0;f<s.length;f++)a(s[f],l)===0&&c++;return c}})}),Yv="setPowerset",zA=["typed","size","subset","compareNatural","Index"],UA=L(Yv,zA,r=>{var{typed:e,size:t,subset:n,compareNatural:a,Index:i}=r;return e(Yv,{"Array | Matrix":function(s){if(n(t(s),new i(0))===0)return[];for(var c=yr(Array.isArray(s)?s:s.toArray()).sort(a),f=[],m=0;m.toString(2).length<=c.length;)f.push(o(c,m.toString(2).split("").reverse())),m++;return l(f)}});function o(u,s){for(var c=[],f=0;f<s.length;f++)s[f]==="1"&&c.push(u[f]);return c}function l(u){for(var s=[],c=u.length-1;c>0;c--)for(var f=0;f<c;f++)u[f].length>u[f+1].length&&(s=u[f],u[f]=u[f+1],u[f+1]=s);return u}}),Zv="setSize",LA=["typed","compareNatural"],kA=L(Zv,LA,r=>{var{typed:e,compareNatural:t}=r;return e(Zv,{"Array | Matrix":function(a){return Array.isArray(a)?yr(a).length:yr(a.toArray()).length},"Array | Matrix, boolean":function(a,i){if(i===!1||a.length===0)return Array.isArray(a)?yr(a).length:yr(a.toArray()).length;for(var o=yr(Array.isArray(a)?a:a.toArray()).sort(t),l=1,u=1;u<o.length;u++)t(o[u],o[u-1])!==0&&l++;return l}})}),Jv="setSymDifference",VA=["typed","size","concat","subset","setDifference","Index"],GA=L(Jv,VA,r=>{var{typed:e,size:t,concat:n,subset:a,setDifference:i,Index:o}=r;return e(Jv,{"Array | Matrix, Array | Matrix":function(u,s){if(a(t(u),new o(0))===0)return yr(s);if(a(t(s),new o(0))===0)return yr(u);var c=yr(u),f=yr(s);return n(i(c,f),i(f,c))}})}),jv="setUnion",HA=["typed","size","concat","subset","setIntersect","setSymDifference","Index"],WA=L(jv,HA,r=>{var{typed:e,size:t,concat:n,subset:a,setIntersect:i,setSymDifference:o,Index:l}=r;return e(jv,{"Array | Matrix, Array | Matrix":function(s,c){if(a(t(s),new l(0))===0)return yr(c);if(a(t(c),new l(0))===0)return yr(s);var f=yr(s),m=yr(c);return n(o(f,m),i(f,m))}})}),Xv="add",YA=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],ZA=L(Xv,YA,r=>{var{typed:e,matrix:t,addScalar:n,equalScalar:a,DenseMatrix:i,SparseMatrix:o,concat:l}=r,u=In({typed:e}),s=Es({typed:e,equalScalar:a}),c=Kn({typed:e,DenseMatrix:i}),f=Tr({typed:e,matrix:t,concat:l});return e(Xv,{"any, any":n,"any, any, ...any":e.referToSelf(m=>(v,p,d)=>{for(var y=m(v,p),x=0;x<d.length;x++)y=m(y,d[x]);return y})},f({elop:n,DS:u,SS:s,Ss:c}))}),Qv="hypot",JA=["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],jA=L(Qv,JA,r=>{var{typed:e,abs:t,addScalar:n,divideScalar:a,multiplyScalar:i,sqrt:o,smaller:l,isPositive:u}=r;return e(Qv,{"... number | BigNumber":s,Array:s,Matrix:c=>s(yr(c.toArray(),!0))});function s(c){for(var f=0,m=0,v=0;v<c.length;v++){if(ln(c[v]))throw new TypeError("Unexpected type of argument to hypot");var p=t(c[v]);l(m,p)?(f=i(f,i(a(m,p),a(m,p))),f=n(f,1),m=p):f=n(f,u(p)?i(a(p,m),a(p,m)):p)}return i(m,o(f))}}),Kv="norm",XA=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],QA=L(Kv,XA,r=>{var{typed:e,abs:t,add:n,pow:a,conj:i,sqrt:o,multiply:l,equalScalar:u,larger:s,smaller:c,matrix:f,ctranspose:m,eigs:v}=r;return e(Kv,{number:Math.abs,Complex:function(N){return N.abs()},BigNumber:function(N){return N.abs()},boolean:function(N){return Math.abs(N)},Array:function(N){return b(f(N),2)},Matrix:function(N){return b(N,2)},"Array, number | BigNumber | string":function(N,E){return b(f(N),E)},"Matrix, number | BigNumber | string":function(N,E){return b(N,E)}});function p(A){var N=0;return A.forEach(function(E){var S=t(E);s(S,N)&&(N=S)},!0),N}function d(A){var N;return A.forEach(function(E){var S=t(E);(!N||c(S,N))&&(N=S)},!0),N||0}function y(A,N){if(N===Number.POSITIVE_INFINITY||N==="inf")return p(A);if(N===Number.NEGATIVE_INFINITY||N==="-inf")return d(A);if(N==="fro")return b(A,2);if(typeof N=="number"&&!isNaN(N)){if(!u(N,0)){var E=0;return A.forEach(function(S){E=n(a(t(S),N),E)},!0),a(E,1/N)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}function x(A){var N=0;return A.forEach(function(E,S){N=n(N,l(E,i(E)))}),t(o(N))}function D(A){var N=[],E=0;return A.forEach(function(S,C){var M=C[1],O=n(N[M]||0,t(S));s(O,E)&&(E=O),N[M]=O},!0),E}function h(A){var N=A.size();if(N[0]!==N[1])throw new RangeError("Invalid matrix dimensions");var E=m(A),S=l(E,A),C=v(S).values.toArray(),M=C[C.length-1];return t(o(M))}function w(A){var N=[],E=0;return A.forEach(function(S,C){var M=C[0],O=n(N[M]||0,t(S));s(O,E)&&(E=O),N[M]=O},!0),E}function g(A,N){if(N===1)return D(A);if(N===Number.POSITIVE_INFINITY||N==="inf")return w(A);if(N==="fro")return x(A);if(N===2)return h(A);throw new Error("Unsupported parameter value "+N)}function b(A,N){var E=A.size();if(E.length===1)return y(A,N);if(E.length===2){if(E[0]&&E[1])return g(A,N);throw new RangeError("Invalid matrix dimensions")}}}),ep="dot",KA=["typed","addScalar","multiplyScalar","conj","size"],eS=L(ep,KA,r=>{var{typed:e,addScalar:t,multiplyScalar:n,conj:a,size:i}=r;return e(ep,{"Array | DenseMatrix, Array | DenseMatrix":l,"SparseMatrix, SparseMatrix":u});function o(s,c){var f=i(s),m=i(c),v,p;if(f.length===1)v=f[0];else if(f.length===2&&f[1]===1)v=f[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+f.join(", ")+")");if(m.length===1)p=m[0];else if(m.length===2&&m[1]===1)p=m[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+m.join(", ")+")");if(v!==p)throw new RangeError("Vectors must have equal length ("+v+" != "+p+")");if(v===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return v}function l(s,c){var f=o(s,c),m=Je(s)?s._data:s,v=Je(s)?s._datatype||s.getDataType():void 0,p=Je(c)?c._data:c,d=Je(c)?c._datatype||c.getDataType():void 0,y=i(s).length===2,x=i(c).length===2,D=t,h=n;if(v&&d&&v===d&&typeof v=="string"&&v!=="mixed"){var w=v;D=e.find(t,[w,w]),h=e.find(n,[w,w])}if(!y&&!x){for(var g=h(a(m[0]),p[0]),b=1;b<f;b++)g=D(g,h(a(m[b]),p[b]));return g}if(!y&&x){for(var A=h(a(m[0]),p[0][0]),N=1;N<f;N++)A=D(A,h(a(m[N]),p[N][0]));return A}if(y&&!x){for(var E=h(a(m[0][0]),p[0]),S=1;S<f;S++)E=D(E,h(a(m[S][0]),p[S]));return E}if(y&&x){for(var C=h(a(m[0][0]),p[0][0]),M=1;M<f;M++)C=D(C,h(a(m[M][0]),p[M][0]));return C}}function u(s,c){o(s,c);for(var f=s._index,m=s._values,v=c._index,p=c._values,d=0,y=t,x=n,D=0,h=0;D<f.length&&h<v.length;){var w=f[D],g=v[h];if(w<g){D++;continue}if(w>g){h++;continue}w===g&&(d=y(d,x(m[D],p[h])),D++,h++)}return d}}),rS="trace",tS=["typed","matrix","add"],nS=L(rS,tS,r=>{var{typed:e,matrix:t,add:n}=r;return e("trace",{Array:function(l){return a(t(l))},SparseMatrix:i,DenseMatrix:a,any:er});function a(o){var l=o._size,u=o._data;switch(l.length){case 1:if(l[0]===1)return er(u[0]);throw new RangeError("Matrix must be square (size: "+lr(l)+")");case 2:{var s=l[0],c=l[1];if(s===c){for(var f=0,m=0;m<s;m++)f=n(f,u[m][m]);return f}else throw new RangeError("Matrix must be square (size: "+lr(l)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+lr(l)+")")}}function i(o){var l=o._values,u=o._index,s=o._ptr,c=o._size,f=c[0],m=c[1];if(f===m){var v=0;if(l.length>0)for(var p=0;p<m;p++)for(var d=s[p],y=s[p+1],x=d;x<y;x++){var D=u[x];if(D===p){v=n(v,l[x]);break}if(D>p)break}return v}throw new RangeError("Matrix must be square (size: "+lr(c)+")")}}),rp="index",aS=["typed","Index"],iS=L(rp,aS,r=>{var{typed:e,Index:t}=r;return e(rp,{"...number | string | BigNumber | Range | Array | Matrix":function(a){var i=a.map(function(l){return or(l)?l.toNumber():Ar(l)||Je(l)?l.map(function(u){return or(u)?u.toNumber():u}):l}),o=new t;return t.apply(o,i),o}})}),tp=new Set(["end"]),oS="Node",sS=["mathWithTransform"],uS=L(oS,sS,r=>{var{mathWithTransform:e}=r;function t(a){for(var i of[...tp])if(a.has(i))throw new Error('Scope contains an illegal symbol, "'+i+'" is a reserved keyword')}class n{get type(){return"Node"}get isNode(){return!0}evaluate(i){return this.compile().evaluate(i)}compile(){var i=this._compile(e,{}),o={},l=null;function u(s){var c=va(s);return t(c),i(c,o,l)}return{evaluate:u}}_compile(i,o){throw new Error("Method _compile must be implemented by type "+this.type)}forEach(i){throw new Error("Cannot run forEach on a Node interface")}map(i){throw new Error("Cannot run map on a Node interface")}_ifNode(i){if(!Nr(i))throw new TypeError("Callback function must return a Node");return i}traverse(i){i(this,null,null);function o(l,u){l.forEach(function(s,c,f){u(s,c,f),o(s,u)})}o(this,i)}transform(i){function o(l,u,s){var c=i(l,u,s);return c!==l?c:l.map(o)}return o(this,null,null)}filter(i){var o=[];return this.traverse(function(l,u,s){i(l,u,s)&&o.push(l)}),o}clone(){throw new Error("Cannot clone a Node interface")}cloneDeep(){return this.map(function(i){return i.cloneDeep()})}equals(i){return i?this.type===i.type&&mn(this,i):!1}toString(i){var o=this._getCustomString(i);return typeof o<"u"?o:this._toString(i)}_toString(){throw new Error("_toString not implemented for "+this.type)}toJSON(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)}toHTML(i){var o=this._getCustomString(i);return typeof o<"u"?o:this._toHTML(i)}_toHTML(){throw new Error("_toHTML not implemented for "+this.type)}toTex(i){var o=this._getCustomString(i);return typeof o<"u"?o:this._toTex(i)}_toTex(i){throw new Error("_toTex not implemented for "+this.type)}_getCustomString(i){if(i&&typeof i=="object")switch(typeof i.handler){case"object":case"undefined":return;case"function":return i.handler(this,i);default:throw new TypeError("Object or function expected as callback")}}getIdentifier(){return this.type}getContent(){return this}}return n},{isClass:!0,isNode:!0});function ht(r){return r&&r.isIndexError?new Yt(r.index+1,r.min+1,r.max!==void 0?r.max+1:void 0):r}function np(r){var{subset:e}=r;return function(n,a){try{if(Array.isArray(n))return e(n,a);if(n&&typeof n.subset=="function")return n.subset(a);if(typeof n=="string")return e(n,a);if(typeof n=="object"){if(!a.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return pt(n,a.getObjectProperty())}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(i){throw ht(i)}}}var go="AccessorNode",lS=["subset","Node"],cS=L(go,lS,r=>{var{subset:e,Node:t}=r,n=np({subset:e});function a(o){return!(cn(o)||Rt(o)||gr(o)||En(o)||Oi(o)||fn(o)||Jr(o))}class i extends t{constructor(l,u){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(super(),!Nr(l))throw new TypeError('Node expected for parameter "object"');if(!pa(u))throw new TypeError('IndexNode expected for parameter "index"');this.object=l,this.index=u,this.optionalChaining=s}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return go}get isAccessorNode(){return!0}_compile(l,u){var s=this.object._compile(l,u),c=this.index._compile(l,u),f=this.optionalChaining,m=cn(this.object)&&this.object.optionalChaining;if(this.index.isObjectProperty()){var v=this.index.getObjectProperty();return function(d,y,x){var D=x||{},h=s(d,y,D);if(f&&h==null){D.optionalShortCircuit=!0;return}if(!(m&&D!==null&&D!==void 0&&D.optionalShortCircuit))return pt(h,v)}}else return function(d,y,x){var D=x||{},h=s(d,y,D);if(f&&h==null){D.optionalShortCircuit=!0;return}if(!(m&&D!==null&&D!==void 0&&D.optionalShortCircuit)){var w=c(d,y,h);return n(h,w)}}}forEach(l){l(this.object,"object",this),l(this.index,"index",this)}map(l){return new i(this._ifNode(l(this.object,"object",this)),this._ifNode(l(this.index,"index",this)),this.optionalChaining)}clone(){return new i(this.object,this.index,this.optionalChaining)}_toString(l){var u=this.object.toString(l);a(this.object)&&(u="("+u+")");var s=this.optionalChaining?this.index.dotNotation?"?":"?.":"";return u+s+this.index.toString(l)}_toHTML(l){var u=this.object.toHTML(l);return a(this.object)&&(u='<span class="math-parenthesis math-round-parenthesis">(</span>'+u+'<span class="math-parenthesis math-round-parenthesis">)</span>'),u+this.index.toHTML(l)}_toTex(l){var u=this.object.toTex(l);return a(this.object)&&(u="\\left(' + object + '\\right)"),u+this.index.toTex(l)}toJSON(){return{mathjs:go,object:this.object,index:this.index,optionalChaining:this.optionalChaining}}static fromJSON(l){return new i(l.object,l.index,l.optionalChaining)}}return Vr(i,"name",go),i},{isClass:!0,isNode:!0}),yo="ArrayNode",fS=["Node"],mS=L(yo,fS,r=>{var{Node:e}=r;class t extends e{constructor(a){if(super(),this.items=a||[],!Array.isArray(this.items)||!this.items.every(Nr))throw new TypeError("Array containing Nodes expected")}get type(){return yo}get isArrayNode(){return!0}_compile(a,i){var o=Bn(this.items,function(s){return s._compile(a,i)}),l=a.config.matrix!=="Array";if(l){var u=a.matrix;return function(c,f,m){return u(Bn(o,function(v){return v(c,f,m)}))}}else return function(c,f,m){return Bn(o,function(v){return v(c,f,m)})}}forEach(a){for(var i=0;i<this.items.length;i++){var o=this.items[i];a(o,"items["+i+"]",this)}}map(a){for(var i=[],o=0;o<this.items.length;o++)i[o]=this._ifNode(a(this.items[o],"items["+o+"]",this));return new t(i)}clone(){return new t(this.items.slice(0))}_toString(a){var i=this.items.map(function(o){return o.toString(a)});return"["+i.join(", ")+"]"}toJSON(){return{mathjs:yo,items:this.items}}static fromJSON(a){return new t(a.items)}_toHTML(a){var i=this.items.map(function(o){return o.toHTML(a)});return'<span class="math-parenthesis math-square-parenthesis">[</span>'+i.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(a){function i(o,l){var u=o.some(Rt)&&!o.every(Rt),s=l||u,c=s?"&":"\\\\",f=o.map(function(m){return m.items?i(m.items,!l):m.toTex(a)}).join(c);return u||!s||s&&!l?"\\begin{bmatrix}"+f+"\\end{bmatrix}":f}return i(this.items,!1)}}return Vr(t,"name",yo),t},{isClass:!0,isNode:!0});function vS(r){var{subset:e,matrix:t}=r;return function(a,i,o){try{if(Array.isArray(a)){var l=t(a).subset(i,o).valueOf();return l.forEach((u,s)=>{a[s]=u}),a}else{if(a&&typeof a.subset=="function")return a.subset(i,o);if(typeof a=="string")return e(a,i,o);if(typeof a=="object"){if(!i.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return ma(a,i.getObjectProperty(),o),a}else throw new TypeError("Cannot apply index: unsupported type of object")}}catch(u){throw ht(u)}}}var jt=[{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 bo(r,e){if(!e||e!=="auto")return r;for(var t=r;fn(t);)t=t.content;return t}function Cr(r,e,t,n){var a=r;e!=="keep"&&(a=r.getContent());for(var i=a.getIdentifier(),o=null,l=0;l<jt.length;l++)if(i in jt[l]){o=l;break}if(i==="OperatorNode:multiply"&&a.implicit&&t!=="show"){var u=bo(a.args[0],e);!(gr(u)&&n&&n.getIdentifier()==="OperatorNode:divide"&&Xo(bo(n.args[0],e)))&&!(u.getIdentifier()==="OperatorNode:divide"&&Xo(bo(u.args[0],e))&&gr(bo(u.args[1])))&&(o+=1)}return o}function ci(r,e){var t=r;e!=="keep"&&(t=r.getContent());var n=t.getIdentifier(),a=Cr(t,e);if(a===null)return null;var i=jt[a][n];if($e(i,"associativity")){if(i.associativity==="left")return"left";if(i.associativity==="right")return"right";throw Error("'"+n+"' has the invalid associativity '"+i.associativity+"'.")}return null}function Ps(r,e,t){var n=t!=="keep"?r.getContent():r,a=t!=="keep"?r.getContent():e,i=n.getIdentifier(),o=a.getIdentifier(),l=Cr(n,t);if(l===null)return null;var u=jt[l][i];if($e(u,"associativeWith")&&u.associativeWith instanceof Array){for(var s=0;s<u.associativeWith.length;s++)if(u.associativeWith[s]===o)return!0;return!1}return null}function pS(r){var e="OperatorNode:"+r;for(var t of jt)if(e in t)return t[e].op;return null}var xo="AssignmentNode",dS=["subset","?matrix","Node"],hS=L(xo,dS,r=>{var{subset:e,matrix:t,Node:n}=r,a=np({subset:e}),i=vS({subset:e,matrix:t});function o(u,s,c){s||(s="keep");var f=Cr(u,s,c),m=Cr(u.value,s,c);return s==="all"||m!==null&&m<=f}class l extends n{constructor(s,c,f){if(super(),this.object=s,this.index=f?c:null,this.value=f||c,!Jr(s)&&!cn(s))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(Jr(s)&&s.name==="end")throw new Error('Cannot assign to symbol "end"');if(this.index&&!pa(this.index))throw new TypeError('IndexNode expected as "index"');if(!Nr(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 xo}get isAssignmentNode(){return!0}_compile(s,c){var f=this.object._compile(s,c),m=this.index?this.index._compile(s,c):null,v=this.value._compile(s,c),p=this.object.name;if(this.index)if(this.index.isObjectProperty()){var d=this.index.getObjectProperty();return function(w,g,b){var A=f(w,g,b),N=v(w,g,b);return ma(A,d,N),N}}else{if(Jr(this.object))return function(w,g,b){var A=f(w,g,b),N=v(w,g,b),E=m(w,g,A);return w.set(p,i(A,E,N)),N};var y=this.object.object._compile(s,c);if(this.object.index.isObjectProperty()){var x=this.object.index.getObjectProperty();return function(w,g,b){var A=y(w,g,b),N=pt(A,x),E=m(w,g,N),S=v(w,g,b);return ma(A,x,i(N,E,S)),S}}else{var D=this.object.index._compile(s,c);return function(w,g,b){var A=y(w,g,b),N=D(w,g,A),E=a(A,N),S=m(w,g,E),C=v(w,g,b);return i(A,N,i(E,S,C)),C}}}else{if(!Jr(this.object))throw new TypeError("SymbolNode expected as object");return function(w,g,b){var A=v(w,g,b);return w.set(p,A),A}}}forEach(s){s(this.object,"object",this),this.index&&s(this.index,"index",this),s(this.value,"value",this)}map(s){var c=this._ifNode(s(this.object,"object",this)),f=this.index?this._ifNode(s(this.index,"index",this)):null,m=this._ifNode(s(this.value,"value",this));return new l(c,f,m)}clone(){return new l(this.object,this.index,this.value)}_toString(s){var c=this.object.toString(s),f=this.index?this.index.toString(s):"",m=this.value.toString(s);return o(this,s&&s.parenthesis,s&&s.implicit)&&(m="("+m+")"),c+f+" = "+m}toJSON(){return{mathjs:xo,object:this.object,index:this.index,value:this.value}}static fromJSON(s){return new l(s.object,s.index,s.value)}_toHTML(s){var c=this.object.toHTML(s),f=this.index?this.index.toHTML(s):"",m=this.value.toHTML(s);return o(this,s&&s.parenthesis,s&&s.implicit)&&(m='<span class="math-paranthesis math-round-parenthesis">(</span>'+m+'<span class="math-paranthesis math-round-parenthesis">)</span>'),c+f+'<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+m}_toTex(s){var c=this.object.toTex(s),f=this.index?this.index.toTex(s):"",m=this.value.toTex(s);return o(this,s&&s.parenthesis,s&&s.implicit)&&(m="\\left(".concat(m,"\\right)")),c+f+"="+m}}return Vr(l,"name",xo),l},{isClass:!0,isNode:!0}),wo="BlockNode",gS=["ResultSet","Node"],yS=L(wo,gS,r=>{var{ResultSet:e,Node:t}=r;class n extends t{constructor(i){if(super(),!Array.isArray(i))throw new Error("Array expected");this.blocks=i.map(function(o){var l=o&&o.node,u=o&&o.visible!==void 0?o.visible:!0;if(!Nr(l))throw new TypeError('Property "node" must be a Node');if(typeof u!="boolean")throw new TypeError('Property "visible" must be a boolean');return{node:l,visible:u}})}get type(){return wo}get isBlockNode(){return!0}_compile(i,o){var l=Bn(this.blocks,function(u){return{evaluate:u.node._compile(i,o),visible:u.visible}});return function(s,c,f){var m=[];return Bl(l,function(p){var d=p.evaluate(s,c,f);p.visible&&m.push(d)}),new e(m)}}forEach(i){for(var o=0;o<this.blocks.length;o++)i(this.blocks[o].node,"blocks["+o+"].node",this)}map(i){for(var o=[],l=0;l<this.blocks.length;l++){var u=this.blocks[l],s=this._ifNode(i(u.node,"blocks["+l+"].node",this));o[l]={node:s,visible:u.visible}}return new n(o)}clone(){var i=this.blocks.map(function(o){return{node:o.node,visible:o.visible}});return new n(i)}_toString(i){return this.blocks.map(function(o){return o.node.toString(i)+(o.visible?"":";")}).join(`
|
|
18
|
+
(`+lr(N,d)+", "+lr(w,d)+") ==> "+(this._values?lr(this._values[A],d):"X")}return h},a.prototype.toString=function(){return lr(this.toArray())},a.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},a.prototype.diagonal=function(d){if(d){if(or(d)&&(d=d.toNumber()),!Ye(d)||!Ue(d))throw new TypeError("The parameter k must be an integer number")}else d=0;var y=d>0?d:0,x=d<0?-d:0,D=this._size[0],h=this._size[1],w=Math.min(D-x,h-y),g=[],b=[],A=[];A[0]=0;for(var N=y;N<h&&g.length<w;N++)for(var E=this._ptr[N],S=this._ptr[N+1],C=E;C<S;C++){var M=this._index[C];if(M===N-y+x){g.push(this._values[C]),b[g.length-1]=M-x;break}}return A.push(g.length),new a({values:g,index:b,ptr:A,size:[w,1]})},a.fromJSON=function(d){return new a(d)},a.diagonal=function(d,y,x,D,h){if(!Ar(d))throw new TypeError("Array expected, size parameter");if(d.length!==2)throw new Error("Only two dimensions matrix are supported");if(d=d.map(function(q){if(or(q)&&(q=q.toNumber()),!Ye(q)||!Ue(q)||q<1)throw new Error("Size values must be positive integers");return q}),x){if(or(x)&&(x=x.toNumber()),!Ye(x)||!Ue(x))throw new TypeError("The parameter k must be an integer number")}else x=0;var w=t,g=0;$r(h)&&(w=e.find(t,[h,h])||t,g=e.convert(0,h));var b=x>0?x:0,A=x<0?-x:0,N=d[0],E=d[1],S=Math.min(N-A,E-b),C;if(Ar(y)){if(y.length!==S)throw new Error("Invalid value array length");C=function(J){return y[J]}}else if(Je(y)){var M=y.size();if(M.length!==1||M[0]!==S)throw new Error("Invalid matrix length");C=function(J){return y.get([J])}}else C=function(){return y};for(var O=[],I=[],k=[],_=0;_<E;_++){k.push(O.length);var P=_-b;if(P>=0&&P<S){var V=C(P);w(V,g)||(I.push(P+A),O.push(V))}}return k.push(O.length),new a({values:O,index:I,ptr:k,size:[N,E]})},a.prototype.swapRows=function(d,y){if(!Ye(d)||!Ue(d)||!Ye(y)||!Ue(y))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return _r(d,this._size[0]),_r(y,this._size[0]),a._swapRows(d,y,this._size[1],this._values,this._index,this._ptr),this},a._forEachRow=function(d,y,x,D,h){for(var w=D[d],g=D[d+1],b=w;b<g;b++)h(x[b],y[b])},a._swapRows=function(d,y,x,D,h,w){for(var g=0;g<x;g++){var b=w[g],A=w[g+1],N=s(d,b,A,h),E=s(y,b,A,h);if(N<A&&E<A&&h[N]===d&&h[E]===y){if(D){var S=D[N];D[N]=D[E],D[E]=S}continue}if(N<A&&h[N]===d&&(E>=A||h[E]!==y)){var C=D?D[N]:void 0;h.splice(E,0,y),D&&D.splice(E,0,C),h.splice(E<=N?N+1:N,1),D&&D.splice(E<=N?N+1:N,1);continue}if(E<A&&h[E]===y&&(N>=A||h[N]!==d)){var M=D?D[E]:void 0;h.splice(N,0,d),D&&D.splice(N,0,M),h.splice(N<=E?E+1:E,1),D&&D.splice(N<=E?E+1:E,1)}}},a},{isClass:!0}),hb="number",gb=["typed"];function yb(r){var e=r.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(e){var t={"0b":2,"0o":8,"0x":16}[e[1]],n=e[2],a=e[3];return{input:r,radix:t,integerPart:n,fractionalPart:a}}else return null}function bb(r){for(var e=parseInt(r.integerPart,r.radix),t=0,n=0;n<r.fractionalPart.length;n++){var a=parseInt(r.fractionalPart[n],r.radix);t+=a/Math.pow(r.radix,n+1)}var i=e+t;if(isNaN(i))throw new SyntaxError('String "'+r.input+'" is not a valid number');return i}var xb=L(hb,gb,r=>{var{typed:e}=r,t=e("number",{"":function(){return 0},number:function(a){return a},string:function(a){if(a==="NaN")return NaN;var i=yb(a);if(i)return bb(i);var o=0,l=a.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);l&&(o=Number(l[2]),a=l[1]);var u=Number(a);if(isNaN(u))throw new SyntaxError('String "'+a+'" is not a valid number');if(l){if(u>2**o-1)throw new SyntaxError('String "'.concat(a,'" is out of range'));u>=2**(o-1)&&(u=u-2**o)}return u},BigNumber:function(a){return a.toNumber()},bigint:function(a){return Number(a)},Fraction:function(a){return a.valueOf()},Unit:e.referToSelf(n=>a=>{var i=a.clone();return i.value=n(a.value),i}),null:function(a){return 0},"Unit, string | Unit":function(a,i){return a.toNumber(i)},"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))});return t.fromJSON=function(n){return parseFloat(n.value)},t}),wb="bigint",Db=["typed"],Nb=L(wb,Db,r=>{var{typed:e}=r,t=e("bigint",{"":function(){return 0n},bigint:function(a){return a},number:function(a){return BigInt(a.toFixed())},BigNumber:function(a){return BigInt(a.round().toString())},Fraction:function(a){return BigInt(a.valueOf().toFixed())},"string | boolean":function(a){return BigInt(a)},null:function(a){return 0n},"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))});return t.fromJSON=function(n){return BigInt(n.value)},t}),Zc="string",Eb=["typed"],Ab=L(Zc,Eb,r=>{var{typed:e}=r;return e(Zc,{"":function(){return""},number:Zn,null:function(n){return"null"},boolean:function(n){return n+""},string:function(n){return n},"Array | Matrix":e.referToSelf(t=>n=>tr(n,t)),any:function(n){return String(n)}})}),Jc="boolean",Sb=["typed"],Cb=L(Jc,Sb,r=>{var{typed:e}=r;return e(Jc,{"":function(){return!1},boolean:function(n){return n},number:function(n){return!!n},null:function(n){return!1},BigNumber:function(n){return!n.isZero()},string:function(n){var a=n.toLowerCase();if(a==="true")return!0;if(a==="false")return!1;var i=Number(n);if(n!==""&&!isNaN(i))return!!i;throw new Error('Cannot convert "'+n+'" to a boolean')},"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),Mb="bignumber",_b=["typed","BigNumber"],Tb=L(Mb,_b,r=>{var{typed:e,BigNumber:t}=r;return e("bignumber",{"":function(){return new t(0)},number:function(a){return new t(a+"")},string:function(a){var i=a.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(i){var o=i[2],l=t(i[1]),u=new t(2).pow(Number(o));if(l.gt(u.sub(1)))throw new SyntaxError('String "'.concat(a,'" is out of range'));var s=new t(2).pow(Number(o)-1);return l.gte(s)?l.sub(u):l}return new t(a)},BigNumber:function(a){return a},bigint:function(a){return new t(a.toString())},Unit:e.referToSelf(n=>a=>{var i=a.clone();return i.value=n(a.value),i}),Fraction:function(a){return new t(String(a.n)).div(String(a.d)).times(String(a.s))},null:function(a){return new t(0)},"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),Fb="complex",Ob=["typed","Complex"],Bb=L(Fb,Ob,r=>{var{typed:e,Complex:t}=r;return e("complex",{"":function(){return t.ZERO},number:function(a){return new t(a,0)},"number, number":function(a,i){return new t(a,i)},"BigNumber, BigNumber":function(a,i){return new t(a.toNumber(),i.toNumber())},Fraction:function(a){return new t(a.valueOf(),0)},Complex:function(a){return a.clone()},string:function(a){return t(a)},null:function(a){return t(0)},Object:function(a){if("re"in a&&"im"in a)return new t(a.re,a.im);if("r"in a&&"phi"in a||"abs"in a&&"arg"in a)return new t(a);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),Rb="fraction",Ib=["typed","Fraction"],Pb=L(Rb,Ib,r=>{var{typed:e,Fraction:t}=r;return e("fraction",{number:function(a){if(!Number.isFinite(a)||isNaN(a))throw new Error(a+" cannot be represented as a fraction");return new t(a)},string:function(a){return new t(a)},"number, number":function(a,i){return new t(a,i)},"bigint, bigint":function(a,i){return new t(a,i)},null:function(a){return new t(0)},BigNumber:function(a){return new t(a.toString())},bigint:function(a){return new t(a.toString())},Fraction:function(a){return a},Unit:e.referToSelf(n=>a=>{var i=a.clone();return i.value=n(a.value),i}),Object:function(a){return new t(a)},"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),jc="matrix",$b=["typed","Matrix","DenseMatrix","SparseMatrix"],qb=L(jc,$b,r=>{var{typed:e,Matrix:t,DenseMatrix:n,SparseMatrix:a}=r;return e(jc,{"":function(){return i([])},string:function(l){return i([],l)},"string, string":function(l,u){return i([],l,u)},Array:function(l){return i(l)},Matrix:function(l){return i(l,l.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(o,l,u){if(l==="dense"||l==="default"||l===void 0)return new n(o,u);if(l==="sparse")return new a(o,u);throw new TypeError("Unknown matrix type "+JSON.stringify(l)+".")}}),Xc="matrixFromFunction",zb=["typed","matrix","isZero"],Ub=L(Xc,zb,r=>{var{typed:e,matrix:t,isZero:n}=r;return e(Xc,{"Array | Matrix, function, string, string":function(o,l,u,s){return a(o,l,u,s)},"Array | Matrix, function, string":function(o,l,u){return a(o,l,u)},"Matrix, function":function(o,l){return a(o,l,"dense")},"Array, function":function(o,l){return a(o,l,"dense").toArray()},"Array | Matrix, string, function":function(o,l,u){return a(o,u,l)},"Array | Matrix, string, string, function":function(o,l,u,s){return a(o,s,l,u)}});function a(i,o,l,u){var s;return u!==void 0?s=t(l,u):s=t(l),s.resize(i),s.forEach(function(c,f){var m=o(f);n(m)||s.set(f,m)}),s}}),Qc="matrixFromRows",Lb=["typed","matrix","flatten","size"],kb=L(Qc,Lb,r=>{var{typed:e,matrix:t,flatten:n,size:a}=r;return e(Qc,{"...Array":function(u){return i(u)},"...Matrix":function(u){return t(i(u.map(s=>s.toArray())))}});function i(l){if(l.length===0)throw new TypeError("At least one row is needed to construct a matrix.");var u=o(l[0]),s=[];for(var c of l){var f=o(c);if(f!==u)throw new TypeError("The vectors had different length: "+(u|0)+" ≠ "+(f|0));s.push(n(c))}return s}function o(l){var u=a(l);if(u.length===1)return u[0];if(u.length===2){if(u[0]===1)return u[1];if(u[1]===1)return u[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),Kc="matrixFromColumns",Vb=["typed","matrix","flatten","size"],Gb=L(Kc,Vb,r=>{var{typed:e,matrix:t,flatten:n,size:a}=r;return e(Kc,{"...Array":function(u){return i(u)},"...Matrix":function(u){return t(i(u.map(s=>s.toArray())))}});function i(l){if(l.length===0)throw new TypeError("At least one column is needed to construct a matrix.");for(var u=o(l[0]),s=[],c=0;c<u;c++)s[c]=[];for(var f of l){var m=o(f);if(m!==u)throw new TypeError("The vectors had different length: "+(u|0)+" ≠ "+(m|0));for(var v=n(f),p=0;p<u;p++)s[p].push(v[p])}return s}function o(l){var u=a(l);if(u.length===1)return u[0];if(u.length===2){if(u[0]===1)return u[1];if(u[1]===1)return u[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),ef="splitUnit",Hb=["typed"],Wb=L(ef,Hb,r=>{var{typed:e}=r;return e(ef,{"Unit, Array":function(n,a){return n.splitUnit(a)}})}),rf="unaryMinus",Yb=["typed"],Zb=L(rf,Yb,r=>{var{typed:e}=r;return e(rf,{number:Xl,"Complex | BigNumber | Fraction":t=>t.neg(),bigint:t=>-t,Unit:e.referToSelf(t=>n=>{var a=n.clone();return a.value=e.find(t,a.valueType())(n.value),a}),"Array | Matrix":e.referToSelf(t=>n=>tr(n,t,!0))})}),tf="unaryPlus",Jb=["typed","config","numeric"],jb=L(tf,Jb,r=>{var{typed:e,config:t,numeric:n}=r;return e(tf,{number:Ql,Complex:function(i){return i},BigNumber:function(i){return i},bigint:function(i){return i},Fraction:function(i){return i},Unit:function(i){return i.clone()},"Array | Matrix":e.referToSelf(a=>i=>tr(i,a,!0)),boolean:function(i){return n(i?1:0,t.number)},string:function(i){return n(i,An(i,t))}})}),nf="abs",Xb=["typed"],Qb=L(nf,Xb,r=>{var{typed:e}=r;return e(nf,{number:Yl,"Complex | BigNumber | Fraction | Unit":t=>t.abs(),bigint:t=>t<0n?-t:t,"Array | Matrix":e.referToSelf(t=>n=>tr(n,t,!0))})}),af="mapSlices",Kb=["typed","isInteger"],xs=L(af,Kb,r=>{var{typed:e,isInteger:t}=r;return e(af,{"Array | Matrix, number | BigNumber, function":function(a,i,o){if(!t(i))throw new TypeError("Integer number expected for dimension");var l=Array.isArray(a)?rr(a):a.size();if(i<0||i>=l.length)throw new Yt(i,l.length);return Je(a)?a.create(ao(a.valueOf(),i,o),a.datatype()):ao(a,i,o)}})},{formerly:"apply"});function ao(r,e,t){var n,a,i;if(e<=0)if(Array.isArray(r[0])){for(i=ex(r),a=[],n=0;n<i.length;n++)a[n]=ao(i[n],e-1,t);return a}else return t(r);else{for(a=[],n=0;n<r.length;n++)a[n]=ao(r[n],e-1,t);return a}}function ex(r){var e=r.length,t=r[0].length,n,a,i=[];for(a=0;a<t;a++){var o=[];for(n=0;n<e;n++)o.push(r[n][a]);i.push(o)}return i}var of="addScalar",rx=["typed"],tx=L(of,rx,r=>{var{typed:e}=r;return e(of,{"number, number":Zl,"Complex, Complex":function(n,a){return n.add(a)},"BigNumber, BigNumber":function(n,a){return n.plus(a)},"bigint, bigint":function(n,a){return n+a},"Fraction, Fraction":function(n,a){return n.add(a)},"Unit, Unit":e.referToSelf(t=>(n,a)=>{if(n.value===null||n.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(a.value===null||a.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!n.equalBase(a))throw new Error("Units do not match");var i=n.clone();return i.value=e.find(t,[i.valueType(),a.valueType()])(i.value,a.value),i.fixPrefix=!1,i})})}),sf="subtractScalar",nx=["typed"],ax=L(sf,nx,r=>{var{typed:e}=r;return e(sf,{"number, number":Jl,"Complex, Complex":function(n,a){return n.sub(a)},"BigNumber, BigNumber":function(n,a){return n.minus(a)},"bigint, bigint":function(n,a){return n-a},"Fraction, Fraction":function(n,a){return n.sub(a)},"Unit, Unit":e.referToSelf(t=>(n,a)=>{if(n.value===null||n.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(a.value===null||a.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!n.equalBase(a))throw new Error("Units do not match");var i=n.clone();return i.value=e.find(t,[i.valueType(),a.valueType()])(i.value,a.value),i.fixPrefix=!1,i})})}),uf="cbrt",ix=["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],ox=L(uf,ix,r=>{var{config:e,typed:t,isNegative:n,unaryMinus:a,matrix:i,Complex:o,BigNumber:l,Fraction:u}=r;return t(uf,{number:ai,Complex:s,"Complex, boolean":s,BigNumber:function(m){return m.cbrt()},Unit:c});function s(f,m){var v=f.arg()/3,p=f.abs(),d=new o(ai(p),0).mul(new o(0,v).exp());if(m){var y=[d,new o(ai(p),0).mul(new o(0,v+Math.PI*2/3).exp()),new o(ai(p),0).mul(new o(0,v-Math.PI*2/3).exp())];return e.matrix==="Array"?y:i(y)}else return d}function c(f){if(f.value&&ln(f.value)){var m=f.clone();return m.value=1,m=m.pow(1/3),m.value=s(f.value),m}else{var v=n(f.value);v&&(f.value=a(f.value));var p;or(f.value)?p=new l(1).div(3):Ka(f.value)?p=new u(1,3):p=1/3;var d=f.pow(p);return v&&(d.value=a(d.value)),d}}}),sx="matAlgo11xS0s",ux=["typed","equalScalar"],nt=L(sx,ux,r=>{var{typed:e,equalScalar:t}=r;return function(a,i,o,l){var u=a._values,s=a._index,c=a._ptr,f=a._size,m=a._datatype;if(!u)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=f[0],p=f[1],d,y=t,x=0,D=o;typeof m=="string"&&(d=m,y=e.find(t,[d,d]),x=e.convert(0,d),i=e.convert(i,d),D=e.find(o,[d,d]));for(var h=[],w=[],g=[],b=0;b<p;b++){g[b]=w.length;for(var A=c[b],N=c[b+1],E=A;E<N;E++){var S=s[E],C=l?D(i,u[E]):D(u[E],i);y(C,x)||(w.push(S),h.push(C))}}return g[p]=w.length,a.createSparseMatrix({values:h,index:w,ptr:g,size:[v,p],datatype:d})}}),lx="matAlgo12xSfs",cx=["typed","DenseMatrix"],Wr=L(lx,cx,r=>{var{typed:e,DenseMatrix:t}=r;return function(a,i,o,l){var u=a._values,s=a._index,c=a._ptr,f=a._size,m=a._datatype;if(!u)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=f[0],p=f[1],d,y=o;typeof m=="string"&&(d=m,i=e.convert(i,d),y=e.find(o,[d,d]));for(var x=[],D=[],h=[],w=0;w<p;w++){for(var g=w+1,b=c[w],A=c[w+1],N=b;N<A;N++){var E=s[N];D[E]=u[N],h[E]=g}for(var S=0;S<v;S++)w===0&&(x[S]=[]),h[S]===g?x[S][w]=l?y(i,D[S]):y(D[S],i):x[S][w]=l?y(i,0):y(0,i)}return new t({data:x,size:[v,p],datatype:d})}}),fx="matAlgo14xDs",mx=["typed"],Ut=L(fx,mx,r=>{var{typed:e}=r;return function(a,i,o,l){var u=a._data,s=a._size,c=a._datatype,f,m=o;typeof c=="string"&&(f=c,i=e.convert(i,f),m=e.find(o,[f,f]));var v=s.length>0?t(m,0,s,s[0],u,i,l):[];return a.createDenseMatrix({data:v,size:er(s),datatype:f})};function t(n,a,i,o,l,u,s){var c=[];if(a===i.length-1)for(var f=0;f<o;f++)c[f]=s?n(u,l[f]):n(l[f],u);else for(var m=0;m<o;m++)c[m]=t(n,a+1,i,i[a+1],l[m],u,s);return c}}),ws="ceil",vx=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],px=new Fn(10),dx=L(ws,["typed","config","round"],r=>{var{typed:e,config:t,round:n}=r;function a(i){var o=Math.ceil(i),l=n(i);return o===l?o:Xr(i,l,t.relTol,t.absTol)&&!Xr(i,o,t.relTol,t.absTol)?l:o}return e(ws,{number:a,"number, number":function(o,l){if(!Ue(l))throw new RangeError("number of decimals in function ceil must be an integer");if(l<0||l>15)throw new RangeError("number of decimals in ceil number must be in range 0-15");var u=10**l;return a(o*u)/u}})}),hx=L(ws,vx,r=>{var{typed:e,config:t,round:n,matrix:a,equalScalar:i,zeros:o,DenseMatrix:l}=r,u=nt({typed:e,equalScalar:i}),s=Wr({typed:e,DenseMatrix:l}),c=Ut({typed:e}),f=dx({typed:e,config:t,round:n});function m(v){var p=(x,D)=>zt(x,D,t.relTol,t.absTol),d=v.ceil(),y=n(v);return d.eq(y)?d:p(v,y)&&!p(v,d)?y:d}return e("ceil",{number:f.signatures.number,"number,number":f.signatures["number,number"],Complex:function(p){return p.ceil()},"Complex, number":function(p,d){return p.ceil(d)},"Complex, BigNumber":function(p,d){return p.ceil(d.toNumber())},BigNumber:m,"BigNumber, BigNumber":function(p,d){var y=px.pow(d);return m(p.mul(y)).div(y)},bigint:v=>v,"bigint, number":(v,p)=>v,"bigint, BigNumber":(v,p)=>v,Fraction:function(p){return p.ceil()},"Fraction, number":function(p,d){return p.ceil(d)},"Fraction, BigNumber":function(p,d){return p.ceil(d.toNumber())},"Unit, number, Unit":e.referToSelf(v=>function(p,d,y){var x=p.toNumeric(y);return y.multiply(v(x,d))}),"Unit, BigNumber, Unit":e.referToSelf(v=>(p,d,y)=>v(p,d.toNumber(),y)),"Array | Matrix, number | BigNumber, Unit":e.referToSelf(v=>(p,d,y)=>tr(p,x=>v(x,d,y),!0)),"Array | Matrix | Unit, Unit":e.referToSelf(v=>(p,d)=>v(p,0,d)),"Array | Matrix":e.referToSelf(v=>p=>tr(p,v,!0)),"Array, number | BigNumber":e.referToSelf(v=>(p,d)=>tr(p,y=>v(y,d),!0)),"SparseMatrix, number | BigNumber":e.referToSelf(v=>(p,d)=>u(p,d,v,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(v=>(p,d)=>c(p,d,v,!1)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(v=>(p,d)=>c(a(d),p,v,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(v=>(p,d)=>i(p,0)?o(d.size(),d.storage()):d.storage()==="dense"?c(d,p,v,!0):s(d,p,v,!0))})}),lf="cube",gx=["typed"],yx=L(lf,gx,r=>{var{typed:e}=r;return e(lf,{number:Kl,Complex:function(n){return n.mul(n).mul(n)},BigNumber:function(n){return n.times(n).times(n)},bigint:function(n){return n*n*n},Fraction:function(n){return n.pow(3)},Unit:function(n){return n.pow(3)}})}),cf="exp",bx=["typed"],xx=L(cf,bx,r=>{var{typed:e}=r;return e(cf,{number:ec,Complex:function(n){return n.exp()},BigNumber:function(n){return n.exp()}})}),ff="expm1",wx=["typed","Complex"],Dx=L(ff,wx,r=>{var{typed:e,Complex:t}=r;return e(ff,{number:rc,Complex:function(a){var i=Math.exp(a.re);return new t(i*Math.cos(a.im)-1,i*Math.sin(a.im))},BigNumber:function(a){return a.exp().minus(1)}})}),Ds="fix",Nx=["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],Ex=L(Ds,["typed","ceil","floor"],r=>{var{typed:e,ceil:t,floor:n}=r;return e(Ds,{number:function(i){return i>0?n(i):t(i)},"number, number":function(i,o){return i>0?n(i,o):t(i,o)}})}),Ax=L(Ds,Nx,r=>{var{typed:e,Complex:t,matrix:n,ceil:a,floor:i,equalScalar:o,zeros:l,DenseMatrix:u}=r,s=Wr({typed:e,DenseMatrix:u}),c=Ut({typed:e}),f=Ex({typed:e,ceil:a,floor:i});return e("fix",{number:f.signatures.number,"number, number | BigNumber":f.signatures["number,number"],Complex:function(v){return new t(v.re>0?Math.floor(v.re):Math.ceil(v.re),v.im>0?Math.floor(v.im):Math.ceil(v.im))},"Complex, number":function(v,p){return new t(v.re>0?i(v.re,p):a(v.re,p),v.im>0?i(v.im,p):a(v.im,p))},"Complex, BigNumber":function(v,p){var d=p.toNumber();return new t(v.re>0?i(v.re,d):a(v.re,d),v.im>0?i(v.im,d):a(v.im,d))},BigNumber:function(v){return v.isNegative()?a(v):i(v)},"BigNumber, number | BigNumber":function(v,p){return v.isNegative()?a(v,p):i(v,p)},bigint:m=>m,"bigint, number":(m,v)=>m,"bigint, BigNumber":(m,v)=>m,Fraction:function(v){return v.s<0n?v.ceil():v.floor()},"Fraction, number | BigNumber":function(v,p){return v.s<0n?a(v,p):i(v,p)},"Unit, number, Unit":e.referToSelf(m=>function(v,p,d){var y=v.toNumeric(d);return d.multiply(m(y,p))}),"Unit, BigNumber, Unit":e.referToSelf(m=>(v,p,d)=>m(v,p.toNumber(),d)),"Array | Matrix, number | BigNumber, Unit":e.referToSelf(m=>(v,p,d)=>tr(v,y=>m(y,p,d),!0)),"Array | Matrix | Unit, Unit":e.referToSelf(m=>(v,p)=>m(v,0,p)),"Array | Matrix":e.referToSelf(m=>v=>tr(v,m,!0)),"Array | Matrix, number | BigNumber":e.referToSelf(m=>(v,p)=>tr(v,d=>m(d,p),!0)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,p)=>c(n(p),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,p)=>o(v,0)?l(p.size(),p.storage()):p.storage()==="dense"?c(p,v,m,!0):s(p,v,m,!0))})}),Ns="floor",Sx=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],Cx=new Fn(10),Mx=L(Ns,["typed","config","round"],r=>{var{typed:e,config:t,round:n}=r;function a(i){var o=Math.floor(i),l=n(i);return o===l?o:Xr(i,l,t.relTol,t.absTol)&&!Xr(i,o,t.relTol,t.absTol)?l:o}return e(Ns,{number:a,"number, number":function(o,l){if(!Ue(l))throw new RangeError("number of decimals in function floor must be an integer");if(l<0||l>15)throw new RangeError("number of decimals in floor number must be in range 0 - 15");var u=10**l;return a(o*u)/u}})}),mf=L(Ns,Sx,r=>{var{typed:e,config:t,round:n,matrix:a,equalScalar:i,zeros:o,DenseMatrix:l}=r,u=nt({typed:e,equalScalar:i}),s=Wr({typed:e,DenseMatrix:l}),c=Ut({typed:e}),f=Mx({typed:e,config:t,round:n});function m(v){var p=(x,D)=>zt(x,D,t.relTol,t.absTol),d=v.floor(),y=n(v);return d.eq(y)?d:p(v,y)&&!p(v,d)?y:d}return e("floor",{number:f.signatures.number,"number,number":f.signatures["number,number"],Complex:function(p){return p.floor()},"Complex, number":function(p,d){return p.floor(d)},"Complex, BigNumber":function(p,d){return p.floor(d.toNumber())},BigNumber:m,"BigNumber, BigNumber":function(p,d){var y=Cx.pow(d);return m(p.mul(y)).div(y)},bigint:v=>v,"bigint, number":(v,p)=>v,"bigint, BigNumber":(v,p)=>v,Fraction:function(p){return p.floor()},"Fraction, number":function(p,d){return p.floor(d)},"Fraction, BigNumber":function(p,d){return p.floor(d.toNumber())},"Unit, number, Unit":e.referToSelf(v=>function(p,d,y){var x=p.toNumeric(y);return y.multiply(v(x,d))}),"Unit, BigNumber, Unit":e.referToSelf(v=>(p,d,y)=>v(p,d.toNumber(),y)),"Array | Matrix, number | BigNumber, Unit":e.referToSelf(v=>(p,d,y)=>tr(p,x=>v(x,d,y),!0)),"Array | Matrix | Unit, Unit":e.referToSelf(v=>(p,d)=>v(p,0,d)),"Array | Matrix":e.referToSelf(v=>p=>tr(p,v,!0)),"Array, number | BigNumber":e.referToSelf(v=>(p,d)=>tr(p,y=>v(y,d),!0)),"SparseMatrix, number | BigNumber":e.referToSelf(v=>(p,d)=>u(p,d,v,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(v=>(p,d)=>c(p,d,v,!1)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(v=>(p,d)=>c(a(d),p,v,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(v=>(p,d)=>i(p,0)?o(d.size(),d.storage()):d.storage()==="dense"?c(d,p,v,!0):s(d,p,v,!0))})}),_x="matAlgo02xDS0",Tx=["typed","equalScalar"],Jt=L(_x,Tx,r=>{var{typed:e,equalScalar:t}=r;return function(a,i,o,l){var u=a._data,s=a._size,c=a._datatype||a.getDataType(),f=i._values,m=i._index,v=i._ptr,p=i._size,d=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(s.length!==p.length)throw new ur(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var y=s[0],x=s[1],D,h=t,w=0,g=o;typeof c=="string"&&c===d&&c!=="mixed"&&(D=c,h=e.find(t,[D,D]),w=e.convert(0,D),g=e.find(o,[D,D]));for(var b=[],A=[],N=[],E=0;E<x;E++){N[E]=A.length;for(var S=v[E],C=v[E+1],M=S;M<C;M++){var O=m[M],I=l?g(f[M],u[O][E]):g(u[O][E],f[M]);h(I,w)||(A.push(O),b.push(I))}}return N[x]=A.length,i.createSparseMatrix({values:b,index:A,ptr:N,size:[y,x],datatype:c===a._datatype&&d===i._datatype?D:void 0})}}),Fx="matAlgo03xDSf",Ox=["typed"],ct=L(Fx,Ox,r=>{var{typed:e}=r;return function(n,a,i,o){var l=n._data,u=n._size,s=n._datatype||n.getDataType(),c=a._values,f=a._index,m=a._ptr,v=a._size,p=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(u.length!==v.length)throw new ur(u.length,v.length);if(u[0]!==v[0]||u[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+v+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var d=u[0],y=u[1],x,D=0,h=i;typeof s=="string"&&s===p&&s!=="mixed"&&(x=s,D=e.convert(0,x),h=e.find(i,[x,x]));for(var w=[],g=0;g<d;g++)w[g]=[];for(var b=[],A=[],N=0;N<y;N++){for(var E=N+1,S=m[N],C=m[N+1],M=S;M<C;M++){var O=f[M];b[O]=o?h(c[M],l[O][N]):h(l[O][N],c[M]),A[O]=E}for(var I=0;I<d;I++)A[I]===E?w[I][N]=b[I]:w[I][N]=o?h(D,l[I][N]):h(l[I][N],D)}return n.createDenseMatrix({data:w,size:[d,y],datatype:s===n._datatype&&p===a._datatype?x:void 0})}}),Bx="matAlgo05xSfSf",Rx=["typed","equalScalar"],io=L(Bx,Rx,r=>{var{typed:e,equalScalar:t}=r;return function(a,i,o){var l=a._values,u=a._index,s=a._ptr,c=a._size,f=a._datatype||a._data===void 0?a._datatype:a.getDataType(),m=i._values,v=i._index,p=i._ptr,d=i._size,y=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(c.length!==d.length)throw new ur(c.length,d.length);if(c[0]!==d[0]||c[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+d+")");var x=c[0],D=c[1],h,w=t,g=0,b=o;typeof f=="string"&&f===y&&f!=="mixed"&&(h=f,w=e.find(t,[h,h]),g=e.convert(0,h),b=e.find(o,[h,h]));var A=l&&m?[]:void 0,N=[],E=[],S=A?[]:void 0,C=A?[]:void 0,M=[],O=[],I,k,_,P;for(k=0;k<D;k++){E[k]=N.length;var V=k+1;for(_=s[k],P=s[k+1];_<P;_++)I=u[_],N.push(I),M[I]=V,S&&(S[I]=l[_]);for(_=p[k],P=p[k+1];_<P;_++)I=v[_],M[I]!==V&&N.push(I),O[I]=V,C&&(C[I]=m[_]);if(A)for(_=E[k];_<N.length;){I=N[_];var q=M[I],J=O[I];if(q===V||J===V){var ne=q===V?S[I]:g,j=J===V?C[I]:g,F=b(ne,j);w(F,g)?N.splice(_,1):(A.push(F),_++)}}}return E[D]=N.length,a.createSparseMatrix({values:A,index:N,ptr:E,size:[x,D],datatype:f===a._datatype&&y===i._datatype?h:void 0})}}),Ix="matAlgo13xDD",Px=["typed"],vf=L(Ix,Px,r=>{var{typed:e}=r;return function(a,i,o){var l=a._data,u=a._size,s=a._datatype,c=i._data,f=i._size,m=i._datatype,v=[];if(u.length!==f.length)throw new ur(u.length,f.length);for(var p=0;p<u.length;p++){if(u[p]!==f[p])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+f+")");v[p]=u[p]}var d,y=o;typeof s=="string"&&s===m&&(d=s,y=e.find(o,[d,d]));var x=v.length>0?t(y,0,v,v[0],l,c):[];return a.createDenseMatrix({data:x,size:v,datatype:d})};function t(n,a,i,o,l,u){var s=[];if(a===i.length-1)for(var c=0;c<o;c++)s[c]=n(l[c],u[c]);else for(var f=0;f<o;f++)s[f]=t(n,a+1,i,i[a+1],l[f],u[f]);return s}});function et(r,e){if(mn(r.size(),e.size()))return[r,e];var t=ji(r.size(),e.size());return[r,e].map(n=>$x(n,t))}function $x(r,e){return mn(r.size(),e)?r:r.create(Xn(r.valueOf(),e),r.datatype())}var qx="matrixAlgorithmSuite",zx=["typed","matrix"],Tr=L(qx,zx,r=>{var{typed:e,matrix:t}=r,n=vf({typed:e}),a=Ut({typed:e});return function(o){var l=o.elop,u=o.SD||o.DS,s;l?(s={"DenseMatrix, DenseMatrix":(v,p)=>n(...et(v,p),l),"Array, Array":(v,p)=>n(...et(t(v),t(p)),l).valueOf(),"Array, DenseMatrix":(v,p)=>n(...et(t(v),p),l),"DenseMatrix, Array":(v,p)=>n(...et(v,t(p)),l)},o.SS&&(s["SparseMatrix, SparseMatrix"]=(v,p)=>o.SS(...et(v,p),l,!1)),o.DS&&(s["DenseMatrix, SparseMatrix"]=(v,p)=>o.DS(...et(v,p),l,!1),s["Array, SparseMatrix"]=(v,p)=>o.DS(...et(t(v),p),l,!1)),u&&(s["SparseMatrix, DenseMatrix"]=(v,p)=>u(...et(p,v),l,!0),s["SparseMatrix, Array"]=(v,p)=>u(...et(t(p),v),l,!0))):(s={"DenseMatrix, DenseMatrix":e.referToSelf(v=>(p,d)=>n(...et(p,d),v)),"Array, Array":e.referToSelf(v=>(p,d)=>n(...et(t(p),t(d)),v).valueOf()),"Array, DenseMatrix":e.referToSelf(v=>(p,d)=>n(...et(t(p),d),v)),"DenseMatrix, Array":e.referToSelf(v=>(p,d)=>n(...et(p,t(d)),v))},o.SS&&(s["SparseMatrix, SparseMatrix"]=e.referToSelf(v=>(p,d)=>o.SS(...et(p,d),v,!1))),o.DS&&(s["DenseMatrix, SparseMatrix"]=e.referToSelf(v=>(p,d)=>o.DS(...et(p,d),v,!1)),s["Array, SparseMatrix"]=e.referToSelf(v=>(p,d)=>o.DS(...et(t(p),d),v,!1))),u&&(s["SparseMatrix, DenseMatrix"]=e.referToSelf(v=>(p,d)=>u(...et(d,p),v,!0)),s["SparseMatrix, Array"]=e.referToSelf(v=>(p,d)=>u(...et(t(d),p),v,!0))));var c=o.scalar||"any",f=o.Ds||o.Ss;f&&(l?(s["DenseMatrix,"+c]=(v,p)=>a(v,p,l,!1),s[c+", DenseMatrix"]=(v,p)=>a(p,v,l,!0),s["Array,"+c]=(v,p)=>a(t(v),p,l,!1).valueOf(),s[c+", Array"]=(v,p)=>a(t(p),v,l,!0).valueOf()):(s["DenseMatrix,"+c]=e.referToSelf(v=>(p,d)=>a(p,d,v,!1)),s[c+", DenseMatrix"]=e.referToSelf(v=>(p,d)=>a(d,p,v,!0)),s["Array,"+c]=e.referToSelf(v=>(p,d)=>a(t(p),d,v,!1).valueOf()),s[c+", Array"]=e.referToSelf(v=>(p,d)=>a(t(d),p,v,!0).valueOf())));var m=o.sS!==void 0?o.sS:o.Ss;return l?(o.Ss&&(s["SparseMatrix,"+c]=(v,p)=>o.Ss(v,p,l,!1)),m&&(s[c+", SparseMatrix"]=(v,p)=>m(p,v,l,!0))):(o.Ss&&(s["SparseMatrix,"+c]=e.referToSelf(v=>(p,d)=>o.Ss(p,d,v,!1))),m&&(s[c+", SparseMatrix"]=e.referToSelf(v=>(p,d)=>m(d,p,v,!0)))),l&&l.signatures&&Ku(s,l.signatures),s}}),pf="mod",Ux=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix","concat"],df=L(pf,Ux,r=>{var{typed:e,config:t,round:n,matrix:a,equalScalar:i,zeros:o,DenseMatrix:l,concat:u}=r,s=mf({typed:e,config:t,round:n,matrix:a,equalScalar:i,zeros:o,DenseMatrix:l}),c=Jt({typed:e,equalScalar:i}),f=ct({typed:e}),m=io({typed:e,equalScalar:i}),v=nt({typed:e,equalScalar:i}),p=Wr({typed:e,DenseMatrix:l}),d=Tr({typed:e,matrix:a,concat:u});return e(pf,{"number, number":y,"BigNumber, BigNumber":function(D,h){return h.isZero()?D:D.sub(h.mul(s(D.div(h))))},"bigint, bigint":function(D,h){if(h===0n)return D;if(D<0){var w=D%h;return w===0n?w:w+h}return D%h},"Fraction, Fraction":function(D,h){return h.equals(0)?D:D.sub(h.mul(s(D.div(h))))}},d({SS:m,DS:f,SD:c,Ss:v,sS:p}));function y(x,D){return D===0?x:x-D*s(x/D)}}),Lx="matAlgo01xDSid",kx=["typed"],In=L(Lx,kx,r=>{var{typed:e}=r;return function(n,a,i,o){var l=n._data,u=n._size,s=n._datatype||n.getDataType(),c=a._values,f=a._index,m=a._ptr,v=a._size,p=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(u.length!==v.length)throw new ur(u.length,v.length);if(u[0]!==v[0]||u[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+v+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var d=u[0],y=u[1],x=typeof s=="string"&&s!=="mixed"&&s===p?s:void 0,D=x?e.find(i,[x,x]):i,h,w,g=[];for(h=0;h<d;h++)g[h]=[];var b=[],A=[];for(w=0;w<y;w++){for(var N=w+1,E=m[w],S=m[w+1],C=E;C<S;C++)h=f[C],b[h]=o?D(c[C],l[h][w]):D(l[h][w],c[C]),A[h]=N;for(h=0;h<d;h++)A[h]===N?g[h][w]=b[h]:g[h][w]=l[h][w]}return n.createDenseMatrix({data:g,size:[d,y],datatype:s===n._datatype&&p===a._datatype?x:void 0})}}),Vx="matAlgo04xSidSid",Gx=["typed","equalScalar"],Es=L(Vx,Gx,r=>{var{typed:e,equalScalar:t}=r;return function(a,i,o){var l=a._values,u=a._index,s=a._ptr,c=a._size,f=a._datatype||a._data===void 0?a._datatype:a.getDataType(),m=i._values,v=i._index,p=i._ptr,d=i._size,y=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(c.length!==d.length)throw new ur(c.length,d.length);if(c[0]!==d[0]||c[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+d+")");var x=c[0],D=c[1],h,w=t,g=0,b=o;typeof f=="string"&&f===y&&f!=="mixed"&&(h=f,w=e.find(t,[h,h]),g=e.convert(0,h),b=e.find(o,[h,h]));var A=l&&m?[]:void 0,N=[],E=[],S=l&&m?[]:void 0,C=l&&m?[]:void 0,M=[],O=[],I,k,_,P,V;for(k=0;k<D;k++){E[k]=N.length;var q=k+1;for(P=s[k],V=s[k+1],_=P;_<V;_++)I=u[_],N.push(I),M[I]=q,S&&(S[I]=l[_]);for(P=p[k],V=p[k+1],_=P;_<V;_++)if(I=v[_],M[I]===q){if(S){var J=b(S[I],m[_]);w(J,g)?M[I]=null:S[I]=J}}else N.push(I),O[I]=q,C&&(C[I]=m[_]);if(S&&C)for(_=E[k];_<N.length;)I=N[_],M[I]===q?(A[_]=S[I],_++):O[I]===q?(A[_]=C[I],_++):N.splice(_,1)}return E[D]=N.length,a.createSparseMatrix({values:A,index:N,ptr:E,size:[x,D],datatype:f===a._datatype&&y===i._datatype?h:void 0})}}),Hx="matAlgo10xSids",Wx=["typed","DenseMatrix"],Kn=L(Hx,Wx,r=>{var{typed:e,DenseMatrix:t}=r;return function(a,i,o,l){var u=a._values,s=a._index,c=a._ptr,f=a._size,m=a._datatype;if(!u)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=f[0],p=f[1],d,y=o;typeof m=="string"&&(d=m,i=e.convert(i,d),y=e.find(o,[d,d]));for(var x=[],D=[],h=[],w=0;w<p;w++){for(var g=w+1,b=c[w],A=c[w+1],N=b;N<A;N++){var E=s[N];D[E]=u[N],h[E]=g}for(var S=0;S<v;S++)w===0&&(x[S]=[]),h[S]===g?x[S][w]=l?y(i,D[S]):y(D[S],i):x[S][w]=i}return new t({data:x,size:[v,p],datatype:d})}});function ea(r,e,t,n){if(!(this instanceof ea))throw new SyntaxError("Constructor must be called with the new operator");this.fn=r,this.count=e,this.min=t,this.max=n,this.message="Wrong number of arguments in function "+r+" ("+e+" provided, "+t+(n!=null?"-"+n:"")+" expected)",this.stack=new Error().stack}ea.prototype=new Error,ea.prototype.constructor=Error,ea.prototype.name="ArgumentsError",ea.prototype.isArgumentsError=!0;var hf="gcd",Yx=["typed","config","round","matrix","equalScalar","zeros","BigNumber","DenseMatrix","concat"],As="number | BigNumber | Fraction | Matrix | Array",Zx="".concat(As,", ").concat(As,", ...").concat(As);function gf(r){return!r.some(e=>Array.isArray(e))}var Jx=L(hf,Yx,r=>{var{typed:e,matrix:t,config:n,round:a,equalScalar:i,zeros:o,BigNumber:l,DenseMatrix:u,concat:s}=r,c=df({typed:e,config:n,round:a,matrix:t,equalScalar:i,zeros:o,DenseMatrix:u,concat:s}),f=In({typed:e}),m=Es({typed:e,equalScalar:i}),v=Kn({typed:e,DenseMatrix:u}),p=Tr({typed:e,matrix:t,concat:s});return e(hf,{"number, number":d,"BigNumber, BigNumber":y,"Fraction, Fraction":(x,D)=>x.gcd(D)},p({SS:m,DS:f,Ss:v}),{[Zx]:e.referToSelf(x=>(D,h,w)=>{for(var g=x(D,h),b=0;b<w.length;b++)g=x(g,w[b]);return g}),Array:e.referToSelf(x=>D=>{if(D.length===1&&Array.isArray(D[0])&&gf(D[0]))return x(...D[0]);if(gf(D))return x(...D);throw new ea("gcd() supports only 1d matrices!")}),Matrix:e.referToSelf(x=>D=>x(D.toArray()))});function d(x,D){if(!Ue(x)||!Ue(D))throw new Error("Parameters in function gcd must be integer numbers");for(var h;D!==0;)h=c(x,D),x=D,D=h;return x<0?-x:x}function y(x,D){if(!x.isInt()||!D.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var h=new l(0);!D.isZero();){var w=c(x,D);x=D,D=w}return x.lt(h)?x.neg():x}}),jx="matAlgo06xS0S0",Xx=["typed","equalScalar"],oo=L(jx,Xx,r=>{var{typed:e,equalScalar:t}=r;return function(a,i,o){var l=a._values,u=a._size,s=a._datatype||a._data===void 0?a._datatype:a.getDataType(),c=i._values,f=i._size,m=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(u.length!==f.length)throw new ur(u.length,f.length);if(u[0]!==f[0]||u[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+f+")");var v=u[0],p=u[1],d,y=t,x=0,D=o;typeof s=="string"&&s===m&&s!=="mixed"&&(d=s,y=e.find(t,[d,d]),x=e.convert(0,d),D=e.find(o,[d,d]));for(var h=l&&c?[]:void 0,w=[],g=[],b=h?[]:void 0,A=[],N=[],E=0;E<p;E++){g[E]=w.length;var S=E+1;if(Hl(a,E,A,b,N,S,w,D),Hl(i,E,A,b,N,S,w,D),b)for(var C=g[E];C<w.length;){var M=w[C];if(N[M]===S){var O=b[M];y(O,x)?w.splice(C,1):(h.push(O),C++)}else w.splice(C,1)}else for(var I=g[E];I<w.length;){var k=w[I];N[k]!==S?w.splice(I,1):I++}}return g[p]=w.length,a.createSparseMatrix({values:h,index:w,ptr:g,size:[v,p],datatype:s===a._datatype&&m===i._datatype?d:void 0})}}),yf="lcm",Qx=["typed","matrix","equalScalar","concat"],Kx=L(yf,Qx,r=>{var{typed:e,matrix:t,equalScalar:n,concat:a}=r,i=Jt({typed:e,equalScalar:n}),o=oo({typed:e,equalScalar:n}),l=nt({typed:e,equalScalar:n}),u=Tr({typed:e,matrix:t,concat:a}),s="number | BigNumber | Fraction | Matrix | Array",c={};return c["".concat(s,", ").concat(s,", ...").concat(s)]=e.referToSelf(m=>(v,p,d)=>{for(var y=m(v,p),x=0;x<d.length;x++)y=m(y,d[x]);return y}),e(yf,{"number, number":tc,"BigNumber, BigNumber":f,"Fraction, Fraction":(m,v)=>m.lcm(v)},u({SS:o,DS:i,Ss:l}),c);function f(m,v){if(!m.isInt()||!v.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(m.isZero())return m;if(v.isZero())return v;for(var p=m.times(v);!v.isZero();){var d=v;v=m.mod(d),m=d}return p.div(m).abs()}});function Ss(r,e,t,n){return function(a){if(a>0||t.predictable){if(a<=0)return NaN;var i=a.toString(16),o=i.substring(0,15);return r*(i.length-o.length)+e(+("0x"+o))}return n(a.toNumber())}}var bf="log10",ew=["typed","config","Complex"],rw=eo(16),tw=L(bf,ew,r=>{var{typed:e,config:t,Complex:n}=r;function a(o){return o.log().div(Math.LN10)}function i(o){return a(new n(o,0))}return e(bf,{number:function(l){return l>=0||t.predictable?eo(l):i(l)},bigint:Ss(rw,eo,t,i),Complex:a,BigNumber:function(l){return!l.isNegative()||t.predictable?l.log():i(l.toNumber())},"Array | Matrix":e.referToSelf(o=>l=>tr(l,o))})}),xf="log2",nw=["typed","config","Complex"],aw=L(xf,nw,r=>{var{typed:e,config:t,Complex:n}=r;function a(o){return i(new n(o,0))}return e(xf,{number:function(l){return l>=0||t.predictable?vs(l):a(l)},bigint:Ss(4,vs,t,a),Complex:i,BigNumber:function(l){return!l.isNegative()||t.predictable?l.log(2):a(l.toNumber())},"Array | Matrix":e.referToSelf(o=>l=>tr(l,o))});function i(o){var l=Math.sqrt(o.re*o.re+o.im*o.im);return new n(Math.log2?Math.log2(l):Math.log(l)/Math.LN2,Math.atan2(o.im,o.re)/Math.LN2)}}),iw="multiplyScalar",ow=["typed"],sw=L(iw,ow,r=>{var{typed:e}=r;return e("multiplyScalar",{"number, number":jl,"Complex, Complex":function(n,a){return n.mul(a)},"BigNumber, BigNumber":function(n,a){return n.times(a)},"bigint, bigint":function(n,a){return n*a},"Fraction, Fraction":function(n,a){return n.mul(a)},"number | Fraction | BigNumber | Complex, Unit":(t,n)=>n.multiply(t),"Unit, number | Fraction | BigNumber | Complex | Unit":(t,n)=>t.multiply(n)})}),wf="multiply",uw=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],lw=L(wf,uw,r=>{var{typed:e,matrix:t,addScalar:n,multiplyScalar:a,equalScalar:i,dot:o}=r,l=nt({typed:e,equalScalar:i}),u=Ut({typed:e});function s(g,b){switch(g.length){case 1:switch(b.length){case 1:if(g[0]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(g[0]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+g[0]+") must match Matrix rows ("+b[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+b.length+" dimensions)")}break;case 2:switch(b.length){case 1:if(g[1]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+g[1]+") must match Vector length ("+b[0]+")");break;case 2:if(g[1]!==b[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+g[1]+") must match Matrix B rows ("+b[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+b.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+g.length+" dimensions)")}}function c(g,b,A){if(A===0)throw new Error("Cannot multiply two empty vectors");return o(g,b)}function f(g,b){if(b.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return m(g,b)}function m(g,b){var A=g._data,N=g._size,E=g._datatype||g.getDataType(),S=b._data,C=b._size,M=b._datatype||b.getDataType(),O=N[0],I=C[1],k,_=n,P=a;E&&M&&E===M&&typeof E=="string"&&E!=="mixed"&&(k=E,_=e.find(n,[k,k]),P=e.find(a,[k,k]));for(var V=[],q=0;q<I;q++){for(var J=P(A[0],S[0][q]),ne=1;ne<O;ne++)J=_(J,P(A[ne],S[ne][q]));V[q]=J}return g.createDenseMatrix({data:V,size:[I],datatype:E===g._datatype&&M===b._datatype?k:void 0})}var v=e("_multiplyMatrixVector",{"DenseMatrix, any":d,"SparseMatrix, any":D}),p=e("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":y,"DenseMatrix, SparseMatrix":x,"SparseMatrix, DenseMatrix":h,"SparseMatrix, SparseMatrix":w});function d(g,b){var A=g._data,N=g._size,E=g._datatype||g.getDataType(),S=b._data,C=b._datatype||b.getDataType(),M=N[0],O=N[1],I,k=n,_=a;E&&C&&E===C&&typeof E=="string"&&E!=="mixed"&&(I=E,k=e.find(n,[I,I]),_=e.find(a,[I,I]));for(var P=[],V=0;V<M;V++){for(var q=A[V],J=_(q[0],S[0]),ne=1;ne<O;ne++)J=k(J,_(q[ne],S[ne]));P[V]=J}return g.createDenseMatrix({data:P,size:[M],datatype:E===g._datatype&&C===b._datatype?I:void 0})}function y(g,b){var A=g._data,N=g._size,E=g._datatype||g.getDataType(),S=b._data,C=b._size,M=b._datatype||b.getDataType(),O=N[0],I=N[1],k=C[1],_,P=n,V=a;E&&M&&E===M&&typeof E=="string"&&E!=="mixed"&&E!=="mixed"&&(_=E,P=e.find(n,[_,_]),V=e.find(a,[_,_]));for(var q=[],J=0;J<O;J++){var ne=A[J];q[J]=[];for(var j=0;j<k;j++){for(var F=V(ne[0],S[0][j]),U=1;U<I;U++)F=P(F,V(ne[U],S[U][j]));q[J][j]=F}}return g.createDenseMatrix({data:q,size:[O,k],datatype:E===g._datatype&&M===b._datatype?_:void 0})}function x(g,b){var A=g._data,N=g._size,E=g._datatype||g.getDataType(),S=b._values,C=b._index,M=b._ptr,O=b._size,I=b._datatype||b._data===void 0?b._datatype:b.getDataType();if(!S)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var k=N[0],_=O[1],P,V=n,q=a,J=i,ne=0;E&&I&&E===I&&typeof E=="string"&&E!=="mixed"&&(P=E,V=e.find(n,[P,P]),q=e.find(a,[P,P]),J=e.find(i,[P,P]),ne=e.convert(0,P));for(var j=[],F=[],U=[],$=b.createSparseMatrix({values:j,index:F,ptr:U,size:[k,_],datatype:E===g._datatype&&I===b._datatype?P:void 0}),le=0;le<_;le++){U[le]=F.length;var me=M[le],Y=M[le+1];if(Y>me)for(var z=0,X=0;X<k;X++){for(var se=X+1,re=void 0,pe=me;pe<Y;pe++){var ve=C[pe];z!==se?(re=q(A[X][ve],S[pe]),z=se):re=V(re,q(A[X][ve],S[pe]))}z===se&&!J(re,ne)&&(F.push(X),j.push(re))}}return U[_]=F.length,$}function D(g,b){var A=g._values,N=g._index,E=g._ptr,S=g._datatype||g._data===void 0?g._datatype:g.getDataType();if(!A)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var C=b._data,M=b._datatype||b.getDataType(),O=g._size[0],I=b._size[0],k=[],_=[],P=[],V,q=n,J=a,ne=i,j=0;S&&M&&S===M&&typeof S=="string"&&S!=="mixed"&&(V=S,q=e.find(n,[V,V]),J=e.find(a,[V,V]),ne=e.find(i,[V,V]),j=e.convert(0,V));var F=[],U=[];P[0]=0;for(var $=0;$<I;$++){var le=C[$];if(!ne(le,j))for(var me=E[$],Y=E[$+1],z=me;z<Y;z++){var X=N[z];U[X]?F[X]=q(F[X],J(le,A[z])):(U[X]=!0,_.push(X),F[X]=J(le,A[z]))}}for(var se=_.length,re=0;re<se;re++){var pe=_[re];k[re]=F[pe]}return P[1]=_.length,g.createSparseMatrix({values:k,index:_,ptr:P,size:[O,1],datatype:S===g._datatype&&M===b._datatype?V:void 0})}function h(g,b){var A=g._values,N=g._index,E=g._ptr,S=g._datatype||g._data===void 0?g._datatype:g.getDataType();if(!A)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var C=b._data,M=b._datatype||b.getDataType(),O=g._size[0],I=b._size[0],k=b._size[1],_,P=n,V=a,q=i,J=0;S&&M&&S===M&&typeof S=="string"&&S!=="mixed"&&(_=S,P=e.find(n,[_,_]),V=e.find(a,[_,_]),q=e.find(i,[_,_]),J=e.convert(0,_));for(var ne=[],j=[],F=[],U=g.createSparseMatrix({values:ne,index:j,ptr:F,size:[O,k],datatype:S===g._datatype&&M===b._datatype?_:void 0}),$=[],le=[],me=0;me<k;me++){F[me]=j.length;for(var Y=me+1,z=0;z<I;z++){var X=C[z][me];if(!q(X,J))for(var se=E[z],re=E[z+1],pe=se;pe<re;pe++){var ve=N[pe];le[ve]!==Y?(le[ve]=Y,j.push(ve),$[ve]=V(X,A[pe])):$[ve]=P($[ve],V(X,A[pe]))}}for(var De=F[me],Oe=j.length,Ie=De;Ie<Oe;Ie++){var _e=j[Ie];ne[Ie]=$[_e]}}return F[k]=j.length,U}function w(g,b){var A=g._values,N=g._index,E=g._ptr,S=g._datatype||g._data===void 0?g._datatype:g.getDataType(),C=b._values,M=b._index,O=b._ptr,I=b._datatype||b._data===void 0?b._datatype:b.getDataType(),k=g._size[0],_=b._size[1],P=A&&C,V,q=n,J=a;S&&I&&S===I&&typeof S=="string"&&S!=="mixed"&&(V=S,q=e.find(n,[V,V]),J=e.find(a,[V,V]));for(var ne=P?[]:void 0,j=[],F=[],U=g.createSparseMatrix({values:ne,index:j,ptr:F,size:[k,_],datatype:S===g._datatype&&I===b._datatype?V:void 0}),$=P?[]:void 0,le=[],me,Y,z,X,se,re,pe,ve,De=0;De<_;De++){F[De]=j.length;var Oe=De+1;for(se=O[De],re=O[De+1],X=se;X<re;X++)if(ve=M[X],P)for(Y=E[ve],z=E[ve+1],me=Y;me<z;me++)pe=N[me],le[pe]!==Oe?(le[pe]=Oe,j.push(pe),$[pe]=J(C[X],A[me])):$[pe]=q($[pe],J(C[X],A[me]));else for(Y=E[ve],z=E[ve+1],me=Y;me<z;me++)pe=N[me],le[pe]!==Oe&&(le[pe]=Oe,j.push(pe));if(P)for(var Ie=F[De],_e=j.length,Le=Ie;Le<_e;Le++){var qe=j[Le];ne[Le]=$[qe]}}return F[_]=j.length,U}return e(wf,a,{"Array, Array":e.referTo("Matrix, Matrix",g=>(b,A)=>{s(rr(b),rr(A));var N=g(t(b),t(A));return Je(N)?N.valueOf():N}),"Matrix, Matrix":function(b,A){var N=b.size(),E=A.size();return s(N,E),N.length===1?E.length===1?c(b,A,N[0]):f(b,A):E.length===1?v(b,A):p(b,A)},"Matrix, Array":e.referTo("Matrix,Matrix",g=>(b,A)=>g(b,t(A))),"Array, Matrix":e.referToSelf(g=>(b,A)=>g(t(b,A.storage()),A)),"SparseMatrix, any":function(b,A){return l(b,A,a,!1)},"DenseMatrix, any":function(b,A){return u(b,A,a,!1)},"any, SparseMatrix":function(b,A){return l(A,b,a,!0)},"any, DenseMatrix":function(b,A){return u(A,b,a,!0)},"Array, any":function(b,A){return u(t(b),A,a,!1).valueOf()},"any, Array":function(b,A){return u(t(A),b,a,!0).valueOf()},"any, any":a,"any, any, ...any":e.referToSelf(g=>(b,A,N)=>{for(var E=g(b,A),S=0;S<N.length;S++)E=g(E,N[S]);return E})})}),Df="nthRoot",cw=["typed","matrix","equalScalar","BigNumber","concat"],fw=L(Df,cw,r=>{var{typed:e,matrix:t,equalScalar:n,BigNumber:a,concat:i}=r,o=In({typed:e}),l=Jt({typed:e,equalScalar:n}),u=oo({typed:e,equalScalar:n}),s=nt({typed:e,equalScalar:n}),c=Tr({typed:e,matrix:t,concat:i});function f(){throw new Error("Complex number not supported in function nthRoot. Use nthRoots instead.")}return e(Df,{number:ac,"number, number":ac,BigNumber:v=>m(v,new a(2)),"BigNumber, BigNumber":m,Complex:f,"Complex, number":f,Array:e.referTo("DenseMatrix,number",v=>p=>v(t(p),2).valueOf()),DenseMatrix:e.referTo("DenseMatrix,number",v=>p=>v(p,2)),SparseMatrix:e.referTo("SparseMatrix,number",v=>p=>v(p,2)),"SparseMatrix, SparseMatrix":e.referToSelf(v=>(p,d)=>{if(d.density()===1)return u(p,d,v);throw new Error("Root must be non-zero")}),"DenseMatrix, SparseMatrix":e.referToSelf(v=>(p,d)=>{if(d.density()===1)return o(p,d,v,!1);throw new Error("Root must be non-zero")}),"Array, SparseMatrix":e.referTo("DenseMatrix,SparseMatrix",v=>(p,d)=>v(t(p),d)),"number | BigNumber, SparseMatrix":e.referToSelf(v=>(p,d)=>{if(d.density()===1)return s(d,p,v,!0);throw new Error("Root must be non-zero")})},c({scalar:"number | BigNumber",SD:l,Ss:s,sS:!1}));function m(v,p){var d=a.precision,y=a.clone({precision:d+2}),x=new a(0),D=new y(1),h=p.isNegative();if(h&&(p=p.neg()),p.isZero())throw new Error("Root must be non-zero");if(v.isNegative()&&!p.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(v.isZero())return h?new y(1/0):0;if(!v.isFinite())return h?x:v;var w=v.abs().pow(D.div(p));return w=v.isNeg()?w.neg():w,new a((h?D.div(w):w).toPrecision(d))}}),Nf="sign",mw=["typed","BigNumber","Fraction","complex"],vw=L(Nf,mw,r=>{var{typed:e,BigNumber:t,complex:n,Fraction:a}=r;return e(Nf,{number:ps,Complex:function(o){return o.im===0?n(ps(o.re)):o.sign()},BigNumber:function(o){return new t(o.cmp(0))},bigint:function(o){return o>0n?1n:o<0n?-1n:0n},Fraction:function(o){return o.n===0n?new a(0):new a(o.s)},"Array | Matrix":e.referToSelf(i=>o=>tr(o,i,!0)),Unit:e.referToSelf(i=>o=>{if(!o._isDerived()&&o.units[0].unit.offset!==0)throw new TypeError("sign is ambiguous for units with offset");return e.find(i,o.valueType())(o.value)})})}),pw="sqrt",dw=["config","typed","Complex"],hw=L(pw,dw,r=>{var{config:e,typed:t,Complex:n}=r;return t("sqrt",{number:a,Complex:function(o){return o.sqrt()},BigNumber:function(o){return!o.isNegative()||e.predictable?o.sqrt():a(o.toNumber())},Unit:function(o){return o.pow(.5)}});function a(i){return isNaN(i)?NaN:i>=0||e.predictable?Math.sqrt(i):new n(i,0).sqrt()}}),Ef="square",gw=["typed"],yw=L(Ef,gw,r=>{var{typed:e}=r;return e(Ef,{number:ic,Complex:function(n){return n.mul(n)},BigNumber:function(n){return n.times(n)},bigint:function(n){return n*n},Fraction:function(n){return n.mul(n)},Unit:function(n){return n.pow(2)}})}),Af="subtract",bw=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],xw=L(Af,bw,r=>{var{typed:e,matrix:t,equalScalar:n,subtractScalar:a,unaryMinus:i,DenseMatrix:o,concat:l}=r,u=In({typed:e}),s=ct({typed:e}),c=io({typed:e,equalScalar:n}),f=Kn({typed:e,DenseMatrix:o}),m=Wr({typed:e,DenseMatrix:o}),v=Tr({typed:e,matrix:t,concat:l});return e(Af,{"any, any":a},v({elop:a,SS:c,DS:u,SD:s,Ss:m,sS:f}))}),Sf="xgcd",ww=["typed","config","matrix","BigNumber"],Dw=L(Sf,ww,r=>{var{typed:e,config:t,matrix:n,BigNumber:a}=r;return e(Sf,{"number, number":function(l,u){var s=oc(l,u);return t.matrix==="Array"?s:n(s)},"BigNumber, BigNumber":i});function i(o,l){var u,s,c,f=new a(0),m=new a(1),v=f,p=m,d=m,y=f;if(!o.isInt()||!l.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!l.isZero();)s=o.div(l).floor(),c=o.mod(l),u=v,v=p.minus(s.times(v)),p=u,u=d,d=y.minus(s.times(d)),y=u,o=l,l=c;var x;return o.lt(f)?x=[o.neg(),p.neg(),y.neg()]:x=[o,o.isZero()?0:p,y],t.matrix==="Array"?x:n(x)}}),Cf="invmod",Nw=["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],Ew=L(Cf,Nw,r=>{var{typed:e,config:t,BigNumber:n,xgcd:a,equal:i,smaller:o,mod:l,add:u,isInteger:s}=r;return e(Cf,{"number, number":c,"BigNumber, BigNumber":c});function c(f,m){if(!s(f)||!s(m))throw new Error("Parameters in function invmod must be integer numbers");if(f=l(f,m),i(m,0))throw new Error("Divisor must be non zero");var v=a(f,m);v=v.valueOf();var[p,d]=v;return i(p,n(1))?(d=l(d,m),o(d,n(0))&&(d=u(d,m)),d):NaN}}),Aw="matAlgo09xS0Sf",Sw=["typed","equalScalar"],Mf=L(Aw,Sw,r=>{var{typed:e,equalScalar:t}=r;return function(a,i,o){var l=a._values,u=a._index,s=a._ptr,c=a._size,f=a._datatype||a._data===void 0?a._datatype:a.getDataType(),m=i._values,v=i._index,p=i._ptr,d=i._size,y=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(c.length!==d.length)throw new ur(c.length,d.length);if(c[0]!==d[0]||c[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+d+")");var x=c[0],D=c[1],h,w=t,g=0,b=o;typeof f=="string"&&f===y&&f!=="mixed"&&(h=f,w=e.find(t,[h,h]),g=e.convert(0,h),b=e.find(o,[h,h]));var A=l&&m?[]:void 0,N=[],E=[],S=A?[]:void 0,C=[],M,O,I,k,_;for(O=0;O<D;O++){E[O]=N.length;var P=O+1;if(S)for(k=p[O],_=p[O+1],I=k;I<_;I++)M=v[I],C[M]=P,S[M]=m[I];for(k=s[O],_=s[O+1],I=k;I<_;I++)if(M=u[I],S){var V=C[M]===P?S[M]:g,q=b(l[I],V);w(q,g)||(N.push(M),A.push(q))}else N.push(M)}return E[D]=N.length,a.createSparseMatrix({values:A,index:N,ptr:E,size:[x,D],datatype:f===a._datatype&&y===i._datatype?h:void 0})}}),_f="dotMultiply",Cw=["typed","matrix","equalScalar","multiplyScalar","concat"],Mw=L(_f,Cw,r=>{var{typed:e,matrix:t,equalScalar:n,multiplyScalar:a,concat:i}=r,o=Jt({typed:e,equalScalar:n}),l=Mf({typed:e,equalScalar:n}),u=nt({typed:e,equalScalar:n}),s=Tr({typed:e,matrix:t,concat:i});return e(_f,s({elop:a,SS:l,DS:o,Ss:u}))});function _w(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function bitAnd");var t=r.constructor;if(r.isNaN()||e.isNaN())return new t(NaN);if(r.isZero()||e.eq(-1)||r.eq(e))return r;if(e.isZero()||r.eq(-1))return e;if(!r.isFinite()||!e.isFinite()){if(!r.isFinite()&&!e.isFinite())return r.isNegative()===e.isNegative()?r:new t(0);if(!r.isFinite())return e.isNegative()?r:r.isNegative()?new t(0):e;if(!e.isFinite())return r.isNegative()?e:e.isNegative()?new t(0):r}return Cs(r,e,function(n,a){return n&a})}function oi(r){if(r.isFinite()&&!r.isInteger())throw new Error("Integer expected in function bitNot");var e=r.constructor,t=e.precision;e.config({precision:1e9});var n=r.plus(new e(1));return n.s=-n.s||null,e.config({precision:t}),n}function Tw(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function bitOr");var t=r.constructor;if(r.isNaN()||e.isNaN())return new t(NaN);var n=new t(-1);return r.isZero()||e.eq(n)||r.eq(e)?e:e.isZero()||r.eq(n)?r:!r.isFinite()||!e.isFinite()?!r.isFinite()&&!r.isNegative()&&e.isNegative()||r.isNegative()&&!e.isNegative()&&!e.isFinite()?n:r.isNegative()&&e.isNegative()?r.isFinite()?r:e:r.isFinite()?e:r:Cs(r,e,function(a,i){return a|i})}function Cs(r,e,t){var n=r.constructor,a,i,o=+(r.s<0),l=+(e.s<0);if(o){a=so(oi(r));for(var u=0;u<a.length;++u)a[u]^=1}else a=so(r);if(l){i=so(oi(e));for(var s=0;s<i.length;++s)i[s]^=1}else i=so(e);var c,f,m;a.length<=i.length?(c=a,f=i,m=o):(c=i,f=a,m=l);var v=c.length,p=f.length,d=t(o,l)^1,y=new n(d^1),x=new n(1),D=new n(2),h=n.precision;for(n.config({precision:1e9});v>0;)t(c[--v],f[--p])===d&&(y=y.plus(x)),x=x.times(D);for(;p>0;)t(m,f[--p])===d&&(y=y.plus(x)),x=x.times(D);return n.config({precision:h}),d===0&&(y.s=-y.s),y}function so(r){for(var e=r.d,t=e[0]+"",n=1;n<e.length;++n){for(var a=e[n]+"",i=7-a.length;i--;)a="0"+a;t+=a}for(var o=t.length;t.charAt(o)==="0";)o--;var l=r.e,u=t.slice(0,o+1||1),s=u.length;if(l>0)if(++l>s)for(l-=s;l--;)u+="0";else l<s&&(u=u.slice(0,l)+"."+u.slice(l));for(var c=[0],f=0;f<u.length;){for(var m=c.length;m--;)c[m]*=10;c[0]+=parseInt(u.charAt(f++));for(var v=0;v<c.length;++v)c[v]>1&&((c[v+1]===null||c[v+1]===void 0)&&(c[v+1]=0),c[v+1]+=c[v]>>1,c[v]&=1)}return c.reverse()}function Fw(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function bitXor");var t=r.constructor;if(r.isNaN()||e.isNaN())return new t(NaN);if(r.isZero())return e;if(e.isZero())return r;if(r.eq(e))return new t(0);var n=new t(-1);return r.eq(n)?oi(e):e.eq(n)?oi(r):!r.isFinite()||!e.isFinite()?!r.isFinite()&&!e.isFinite()?n:new t(r.isNegative()===e.isNegative()?1/0:-1/0):Cs(r,e,function(a,i){return a^i})}function Ow(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function leftShift");var t=r.constructor;return r.isNaN()||e.isNaN()||e.isNegative()&&!e.isZero()?new t(NaN):r.isZero()||e.isZero()?r:!r.isFinite()&&!e.isFinite()?new t(NaN):e.lt(55)?r.times(Math.pow(2,e.toNumber())+""):r.times(new t(2).pow(e))}function Bw(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function rightArithShift");var t=r.constructor;return r.isNaN()||e.isNaN()||e.isNegative()&&!e.isZero()?new t(NaN):r.isZero()||e.isZero()?r:e.isFinite()?e.lt(55)?r.div(Math.pow(2,e.toNumber())+"").floor():r.div(new t(2).pow(e)).floor():r.isNegative()?new t(-1):r.isFinite()?new t(0):new t(NaN)}var Tf="bitAnd",Rw=["typed","matrix","equalScalar","concat"],Ff=L(Tf,Rw,r=>{var{typed:e,matrix:t,equalScalar:n,concat:a}=r,i=Jt({typed:e,equalScalar:n}),o=oo({typed:e,equalScalar:n}),l=nt({typed:e,equalScalar:n}),u=Tr({typed:e,matrix:t,concat:a});return e(Tf,{"number, number":uc,"BigNumber, BigNumber":_w,"bigint, bigint":(s,c)=>s&c},u({SS:o,DS:i,Ss:l}))}),Of="bitNot",Iw=["typed"],Pw=L(Of,Iw,r=>{var{typed:e}=r;return e(Of,{number:lc,BigNumber:oi,bigint:t=>~t,"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),Bf="bitOr",$w=["typed","matrix","equalScalar","DenseMatrix","concat"],Rf=L(Bf,$w,r=>{var{typed:e,matrix:t,equalScalar:n,DenseMatrix:a,concat:i}=r,o=In({typed:e}),l=Es({typed:e,equalScalar:n}),u=Kn({typed:e,DenseMatrix:a}),s=Tr({typed:e,matrix:t,concat:i});return e(Bf,{"number, number":cc,"BigNumber, BigNumber":Tw,"bigint, bigint":(c,f)=>c|f},s({SS:l,DS:o,Ss:u}))}),qw="matAlgo07xSSf",zw=["typed","SparseMatrix"],nn=L(qw,zw,r=>{var{typed:e,SparseMatrix:t}=r;return function(i,o,l){var u=i._size,s=i._datatype||i._data===void 0?i._datatype:i.getDataType(),c=o._size,f=o._datatype||o._data===void 0?o._datatype:o.getDataType();if(u.length!==c.length)throw new ur(u.length,c.length);if(u[0]!==c[0]||u[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+c+")");var m=u[0],v=u[1],p,d=0,y=l;typeof s=="string"&&s===f&&s!=="mixed"&&(p=s,d=e.convert(0,p),y=e.find(l,[p,p]));for(var x=[],D=[],h=new Array(v+1).fill(0),w=[],g=[],b=[],A=[],N=0;N<v;N++){var E=N+1,S=0;n(i,N,b,w,E),n(o,N,A,g,E);for(var C=0;C<m;C++){var M=b[C]===E?w[C]:d,O=A[C]===E?g[C]:d,I=y(M,O);I!==0&&I!==!1&&(D.push(C),x.push(I),S++)}h[N+1]=h[N]+S}return new t({values:x,index:D,ptr:h,size:[m,v],datatype:s===i._datatype&&f===o._datatype?p:void 0})};function n(a,i,o,l,u){for(var s=a._values,c=a._index,f=a._ptr,m=f[i],v=f[i+1];m<v;m++){var p=c[m];o[p]=u,l[p]=s[m]}}}),If="bitXor",Uw=["typed","matrix","DenseMatrix","concat","SparseMatrix"],Lw=L(If,Uw,r=>{var{typed:e,matrix:t,DenseMatrix:n,concat:a,SparseMatrix:i}=r,o=ct({typed:e}),l=nn({typed:e,SparseMatrix:i}),u=Wr({typed:e,DenseMatrix:n}),s=Tr({typed:e,matrix:t,concat:a});return e(If,{"number, number":fc,"BigNumber, BigNumber":Fw,"bigint, bigint":(c,f)=>c^f},s({SS:l,DS:o,Ss:u}))}),Pf="arg",kw=["typed"],Vw=L(Pf,kw,r=>{var{typed:e}=r;return e(Pf,{number:function(n){return Math.atan2(0,n)},BigNumber:function(n){return n.constructor.atan2(0,n)},Complex:function(n){return n.arg()},"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),$f="conj",Gw=["typed"],Hw=L($f,Gw,r=>{var{typed:e}=r;return e($f,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.conjugate(),Unit:e.referToSelf(t=>n=>new n.constructor(t(n.toNumeric()),n.formatUnits())),"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),qf="im",Ww=["typed"],Yw=L(qf,Ww,r=>{var{typed:e}=r;return e(qf,{number:()=>0,"BigNumber | Fraction":t=>t.mul(0),Complex:t=>t.im,"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),zf="re",Zw=["typed"],Jw=L(zf,Zw,r=>{var{typed:e}=r;return e(zf,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.re,"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),Uf="not",jw=["typed"],Xw=L(Uf,jw,r=>{var{typed:e}=r;return e(Uf,{"null | undefined":()=>!0,number:hc,Complex:function(n){return n.re===0&&n.im===0},BigNumber:function(n){return n.isZero()||n.isNaN()},bigint:t=>!t,Unit:e.referToSelf(t=>n=>e.find(t,n.valueType())(n.value)),"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),Lf="nullish",Qw=["typed","matrix","size","flatten","deepEqual"],kf=L(Lf,Qw,r=>{var{typed:e,matrix:t,size:n,flatten:a,deepEqual:i}=r,o=ct({typed:e}),l=Ut({typed:e}),u=vf({typed:e});return e(Lf,{"number|bigint|Complex|BigNumber|Fraction|Unit|string|boolean|SparseMatrix, any":(s,c)=>s,"null, any":(s,c)=>c,"undefined, any":(s,c)=>c,"SparseMatrix, Array | Matrix":(s,c)=>{var f=n(s),m=n(c);if(i(f,m))return s;throw new ur(f,m)},"DenseMatrix, DenseMatrix":e.referToSelf(s=>(c,f)=>u(c,f,s)),"DenseMatrix, SparseMatrix":e.referToSelf(s=>(c,f)=>o(c,f,s,!1)),"DenseMatrix, Array":e.referToSelf(s=>(c,f)=>u(c,t(f),s)),"DenseMatrix, any":e.referToSelf(s=>(c,f)=>l(c,f,s,!1)),"Array, Array":e.referToSelf(s=>(c,f)=>u(t(c),t(f),s).valueOf()),"Array, DenseMatrix":e.referToSelf(s=>(c,f)=>u(t(c),f,s)),"Array, SparseMatrix":e.referToSelf(s=>(c,f)=>o(t(c),f,s,!1)),"Array, any":e.referToSelf(s=>(c,f)=>l(t(c),f,s,!1).valueOf())})}),Vf="or",Kw=["typed","matrix","equalScalar","DenseMatrix","concat"],Gf=L(Vf,Kw,r=>{var{typed:e,matrix:t,equalScalar:n,DenseMatrix:a,concat:i}=r,o=ct({typed:e}),l=io({typed:e,equalScalar:n}),u=Wr({typed:e,DenseMatrix:a}),s=Tr({typed:e,matrix:t,concat:i});return e(Vf,{"number, number":hs,"Complex, Complex":function(f,m){return f.re!==0||f.im!==0||m.re!==0||m.im!==0},"BigNumber, BigNumber":function(f,m){return!f.isZero()&&!f.isNaN()||!m.isZero()&&!m.isNaN()},"bigint, bigint":hs,"Unit, Unit":e.referToSelf(c=>(f,m)=>c(f.value||0,m.value||0))},s({SS:l,DS:o,Ss:u}))}),Hf="xor",eD=["typed","matrix","DenseMatrix","concat","SparseMatrix"],rD=L(Hf,eD,r=>{var{typed:e,matrix:t,DenseMatrix:n,concat:a,SparseMatrix:i}=r,o=ct({typed:e}),l=nn({typed:e,SparseMatrix:i}),u=Wr({typed:e,DenseMatrix:n}),s=Tr({typed:e,matrix:t,concat:a});return e(Hf,{"number, number":gs,"Complex, Complex":function(f,m){return(f.re!==0||f.im!==0)!=(m.re!==0||m.im!==0)},"bigint, bigint":gs,"BigNumber, BigNumber":function(f,m){return(!f.isZero()&&!f.isNaN())!=(!m.isZero()&&!m.isNaN())},"Unit, Unit":e.referToSelf(c=>(f,m)=>c(f.value||0,m.value||0))},s({SS:l,DS:o,Ss:u}))}),Wf="concat",tD=["typed","matrix","isInteger"],Yf=L(Wf,tD,r=>{var{typed:e,matrix:t,isInteger:n}=r;return e(Wf,{"...Array | Matrix | number | BigNumber":function(i){var o,l=i.length,u=-1,s,c=!1,f=[];for(o=0;o<l;o++){var m=i[o];if(Je(m)&&(c=!0),Ye(m)||or(m)){if(o!==l-1)throw new Error("Dimension must be specified as last argument");if(s=u,u=m.valueOf(),!n(u))throw new TypeError("Integer number expected for dimension");if(u<0||o>0&&u>s)throw new Yt(u,s+1)}else{var v=er(m).valueOf(),p=rr(v);if(f[o]=v,s=u,u=p.length-1,o>0&&u!==s)throw new ur(s+1,u+1)}}if(f.length===0)throw new SyntaxError("At least one matrix expected");for(var d=f.shift();f.length;)d=zl(d,f.shift(),u);return c?t(d):d},"...string":function(i){return i.join("")}})}),Zf="column",nD=["typed","Index","matrix","range"],Jf=L(Zf,nD,r=>{var{typed:e,Index:t,matrix:n,range:a}=r;return e(Zf,{"Matrix, number":i,"Array, number":function(l,u){return i(n(er(l)),u).valueOf()}});function i(o,l){if(o.size().length!==2)throw new Error("Only two dimensional matrix is supported");_r(l,o.size()[1]);var u=a(0,o.size()[0]),s=new t(u,[l]),c=o.subset(s);return Je(c)?c:n([[c]])}}),jf="count",aD=["typed","size","prod"],iD=L(jf,aD,r=>{var{typed:e,size:t,prod:n}=r;return e(jf,{string:function(i){return i.length},"Matrix | Array":function(i){return n(t(i))}})}),Xf="cross",oD=["typed","matrix","subtract","multiply"],sD=L(Xf,oD,r=>{var{typed:e,matrix:t,subtract:n,multiply:a}=r;return e(Xf,{"Matrix, Matrix":function(l,u){return t(i(l.toArray(),u.toArray()))},"Matrix, Array":function(l,u){return t(i(l.toArray(),u))},"Array, Matrix":function(l,u){return t(i(l,u.toArray()))},"Array, Array":i});function i(o,l){var u=Math.max(rr(o).length,rr(l).length);o=Yi(o),l=Yi(l);var s=rr(o),c=rr(l);if(s.length!==1||c.length!==1||s[0]!==3||c[0]!==3)throw new RangeError("Vectors with length 3 expected (Size A = ["+s.join(", ")+"], B = ["+c.join(", ")+"])");var f=[n(a(o[1],l[2]),a(o[2],l[1])),n(a(o[2],l[0]),a(o[0],l[2])),n(a(o[0],l[1]),a(o[1],l[0]))];return u>1?[f]:f}}),Qf="diag",uD=["typed","matrix","DenseMatrix","SparseMatrix"],lD=L(Qf,uD,r=>{var{typed:e,matrix:t,DenseMatrix:n,SparseMatrix:a}=r;return e(Qf,{Array:function(s){return i(s,0,rr(s),null)},"Array, number":function(s,c){return i(s,c,rr(s),null)},"Array, BigNumber":function(s,c){return i(s,c.toNumber(),rr(s),null)},"Array, string":function(s,c){return i(s,0,rr(s),c)},"Array, number, string":function(s,c,f){return i(s,c,rr(s),f)},"Array, BigNumber, string":function(s,c,f){return i(s,c.toNumber(),rr(s),f)},Matrix:function(s){return i(s,0,s.size(),s.storage())},"Matrix, number":function(s,c){return i(s,c,s.size(),s.storage())},"Matrix, BigNumber":function(s,c){return i(s,c.toNumber(),s.size(),s.storage())},"Matrix, string":function(s,c){return i(s,0,s.size(),c)},"Matrix, number, string":function(s,c,f){return i(s,c,s.size(),f)},"Matrix, BigNumber, string":function(s,c,f){return i(s,c.toNumber(),s.size(),f)}});function i(u,s,c,f){if(!Ue(s))throw new TypeError("Second parameter in function diag must be an integer");var m=s>0?s:0,v=s<0?-s:0;switch(c.length){case 1:return o(u,s,f,c[0],v,m);case 2:return l(u,s,f,c,v,m)}throw new RangeError("Matrix for function diag must be 2 dimensional")}function o(u,s,c,f,m,v){var p=[f+m,f+v];if(c&&c!=="sparse"&&c!=="dense")throw new TypeError("Unknown matrix type ".concat(c,'"'));var d=c==="sparse"?a.diagonal(p,u,s):n.diagonal(p,u,s);return c!==null?d:d.valueOf()}function l(u,s,c,f,m,v){if(Je(u)){var p=u.diagonal(s);return c!==null?c!==p.storage()?t(p,c):p:p.valueOf()}for(var d=Math.min(f[0]-m,f[1]-v),y=[],x=0;x<d;x++)y[x]=u[x+m][x+v];return c!==null?t(y):y}}),cD="filter",fD=["typed"],Kf=L(cD,fD,r=>{var{typed:e}=r;return e("filter",{"Array, function":em,"Matrix, function":function(n,a){return n.create(em(n.valueOf(),a),n.datatype())},"Array, RegExp":Pl,"Matrix, RegExp":function(n,a){return n.create(Pl(n.valueOf(),a),n.datatype())}})});function em(r,e){var t=Qn(e,r,"filter");return t.isUnary?Il(r,t.fn):Il(r,function(n,a,i){return t.fn(n,[a],i)})}var rm="flatten",mD=["typed"],vD=L(rm,mD,r=>{var{typed:e}=r;return e(rm,{Array:function(n){return yr(n)},DenseMatrix:function(n){return n.create(yr(n.valueOf(),!0),n.datatype())},SparseMatrix:function(n){throw new TypeError("SparseMatrix is not supported by function flatten because it does not support 1D vectors. Convert to a DenseMatrix or Array first. Example: flatten(x.toArray())")}})}),Ms="forEach",pD=["typed"],tm=L(Ms,pD,r=>{var{typed:e}=r;return e(Ms,{"Array, function":dD,"Matrix, function":function(n,a){n.forEach(a)}})});function dD(r,e){var t=Qn(e,r,Ms);Ll(r,t.fn,t.isUnary)}var nm="getMatrixDataType",hD=["typed"],gD=L(nm,hD,r=>{var{typed:e}=r;return e(nm,{Array:function(n){return Ji(n,Sr)},Matrix:function(n){return n.getDataType()}})}),am="identity",yD=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],bD=L(am,yD,r=>{var{typed:e,config:t,matrix:n,BigNumber:a,DenseMatrix:i,SparseMatrix:o}=r;return e(am,{"":function(){return t.matrix==="Matrix"?n([]):[]},string:function(c){return n(c)},"number | BigNumber":function(c){return u(c,c,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(c,f){return u(c,c,f)},"number | BigNumber, number | BigNumber":function(c,f){return u(c,f,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(c,f,m){return u(c,f,m)},Array:function(c){return l(c)},"Array, string":function(c,f){return l(c,f)},Matrix:function(c){return l(c.valueOf(),c.storage())},"Matrix, string":function(c,f){return l(c.valueOf(),f)}});function l(s,c){switch(s.length){case 0:return c?n(c):[];case 1:return u(s[0],s[0],c);case 2:return u(s[0],s[1],c);default:throw new Error("Vector containing two values expected")}}function u(s,c,f){var m=or(s)||or(c)?a:null;if(or(s)&&(s=s.toNumber()),or(c)&&(c=c.toNumber()),!Ue(s)||s<1)throw new Error("Parameters in function identity must be positive integers");if(!Ue(c)||c<1)throw new Error("Parameters in function identity must be positive integers");var v=m?new a(1):1,p=m?new m(0):0,d=[s,c];if(f){if(f==="sparse")return o.diagonal(d,v,0,p);if(f==="dense")return i.diagonal(d,v,0,p);throw new TypeError('Unknown matrix type "'.concat(f,'"'))}for(var y=Ea([],d,p),x=s<c?s:c,D=0;D<x;D++)y[D][D]=v;return y}}),im="kron",xD=["typed","matrix","multiplyScalar"],wD=L(im,xD,r=>{var{typed:e,matrix:t,multiplyScalar:n}=r;return e(im,{"Matrix, Matrix":function(l,u){return t(i(l.toArray(),u.toArray()))},"Matrix, Array":function(l,u){return t(i(l.toArray(),u))},"Array, Matrix":function(l,u){return t(i(l,u.toArray()))},"Array, Array":i});function a(o,l){return o.flatMap(u=>l.map(s=>n(u,s)))}function i(o,l){var u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:-1;if(u<0){var s=rr(o).length,c=rr(l).length;for(u=Math.max(s,c);s++<u;)o=[o];for(;c++<u;)l=[l]}return u===1?a(o,l):o.flatMap(f=>l.map(m=>i(f,m,u-1)))}}),_s="map",DD=["typed"],om=L(_s,DD,r=>{var{typed:e}=r;return e(_s,{"Array, function":l,"Matrix, function":function(s,c){return s.map(c)},"Array|Matrix, Array|Matrix, ...Array|Matrix|function":(u,s,c)=>t([u,s,...c.slice(0,c.length-1)],c[c.length-1])});function t(u,s){if(typeof s!="function")throw new Error("Last argument must be a callback function");var c=u[0].isMatrix,f=u.map(g=>g.isMatrix?g.size():rr(g)),m=ji(...f),v=u.length,p=c?(g,b)=>g.get(b):Xi,d=u.map((g,b)=>{var A=f[b].map(()=>0);return g.isMatrix?g.get(A):Xi(g,A)}),y=e.isTypedFunction(s)?o(s,d,m.map(()=>0),u):i(s,v);if(y<2){var x=a(y,s,null);return n(u,x)}var D=c?u.map(g=>g.isMatrix?g.create(Xn(g.toArray(),m),g.datatype()):u[0].create(Xn(g.valueOf(),m))):u.map(g=>g.isMatrix?Xn(g.toArray(),m):Xn(g,m)),h=a(y,s,D),w=(g,b)=>h([g,...D.slice(1).map(A=>p(A,b))],b);return c?D[0].map(w):l(D[0],w)}function n(u,s){var c=u[0],f=u.map(g=>g.isMatrix?g.valueOf():g),m=u.map(g=>g.isMatrix?g.size():rr(g)),v=ji(...m),p=m.map(g=>v.length-g.length),d=v.length-1,y=s.length>1,x=y?[]:null,D=w(f,0);if(c.isMatrix){var h=c.create();return h._data=D,h._size=v,h}else return D;function w(g){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,A=v[b],N=Array(A);if(b<d)for(var E=function(I){x&&(x[b]=I),N[I]=w(g.map((k,_)=>p[_]>b?k:k.length===1?k[0]:k[I]),b+1)},S=0;S<A;S++)E(S);else for(var C=function(I){x&&(x[b]=I),N[I]=s(g.map(k=>k.length===1?k[0]:k[I]),x?x.slice():void 0)},M=0;M<A;M++)C(M);return N}}function a(u,s,c){switch(u){case 0:return f=>s(...f);case 1:return(f,m)=>s(...f,m);case 2:return(f,m)=>s(...f,m,...c)}}function i(u,s){var c=u.toString();if(/arguments/.test(c))return 2;var f=c.match(/\(.*?\)/);return/\.\.\./.test(f)||u.length>s+1?2:u.length===s+1?1:0}function o(u,s,c,f){return e.resolve(u,[...s,c,...f])!==null?2:e.resolve(u,[...s,c])!==null?1:(e.resolve(u,s)!==null,0)}function l(u,s){var c=Qn(s,u,_s);return ms(u,c.fn,c.isUnary)}}),sm="diff",ND=["typed","matrix","subtract","number"],um=L(sm,ND,r=>{var{typed:e,matrix:t,subtract:n,number:a}=r;return e(sm,{"Array | Matrix":function(c){return Je(c)?t(o(c.toArray())):o(c)},"Array | Matrix, number":function(c,f){if(!Ue(f))throw new RangeError("Dimension must be a whole number");return Je(c)?t(i(c.toArray(),f)):i(c,f)},"Array, BigNumber":e.referTo("Array,number",s=>(c,f)=>s(c,a(f))),"Matrix, BigNumber":e.referTo("Matrix,number",s=>(c,f)=>s(c,a(f)))});function i(s,c){if(Je(s)&&(s=s.toArray()),!Array.isArray(s))throw RangeError("Array/Matrix does not have that many dimensions");if(c>0){var f=[];return s.forEach(m=>{f.push(i(m,c-1))}),f}else{if(c===0)return o(s);throw RangeError("Cannot have negative dimension")}}function o(s){for(var c=[],f=s.length,m=1;m<f;m++)c.push(l(s[m-1],s[m]));return c}function l(s,c){Je(s)&&(s=s.toArray()),Je(c)&&(c=c.toArray());var f=Array.isArray(s),m=Array.isArray(c);if(f&&m)return u(s,c);if(!f&&!m)return n(c,s);throw TypeError("Cannot calculate difference between 1 array and 1 non-array")}function u(s,c){if(s.length!==c.length)throw RangeError("Not all sub-arrays have the same length");for(var f=[],m=s.length,v=0;v<m;v++)f.push(l(s[v],c[v]));return f}}),ED="ones",AD=["typed","config","matrix","BigNumber"],SD=L(ED,AD,r=>{var{typed:e,config:t,matrix:n,BigNumber:a}=r;return e("ones",{"":function(){return t.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(s){var c=s[s.length-1];if(typeof c=="string"){var f=s.pop();return i(s,f)}else return t.matrix==="Array"?i(s):i(s,"default")},Array:i,Matrix:function(s){var c=s.storage();return i(s.valueOf(),c)},"Array | Matrix, string":function(s,c){return i(s.valueOf(),c)}});function i(u,s){var c=o(u),f=c?new a(1):1;if(l(u),s){var m=n(s);return u.length>0?m.resize(u,f):m}else{var v=[];return u.length>0?Ea(v,u,f):v}}function o(u){var s=!1;return u.forEach(function(c,f,m){or(c)&&(s=!0,m[f]=c.toNumber())}),s}function l(u){u.forEach(function(s){if(typeof s!="number"||!Ue(s)||s<0)throw new Error("Parameters in function ones must be positive integers")})}});function Ts(){throw new Error('No "bignumber" implementation available')}function lm(){throw new Error('No "fraction" implementation available')}function CD(){throw new Error('No "matrix" implementation available')}var cm="range",MD=["typed","config","?matrix","?bignumber","equal","smaller","smallerEq","larger","largerEq","add","isZero","isPositive"],fm=L(cm,MD,r=>{var{typed:e,config:t,matrix:n,bignumber:a,smaller:i,smallerEq:o,larger:l,largerEq:u,add:s,isZero:c,isPositive:f}=r;return e(cm,{string:v,"string, boolean":v,number:function(x){throw new TypeError("Too few arguments to function range(): ".concat(x))},boolean:function(x){throw new TypeError("Unexpected type of argument 1 to function range(): ".concat(x,", number|bigint|BigNumber|Fraction"))},"number, number":function(x,D){return m(p(x,D,1,!1))},"number, number, number":function(x,D,h){return m(p(x,D,h,!1))},"number, number, boolean":function(x,D,h){return m(p(x,D,1,h))},"number, number, number, boolean":function(x,D,h,w){return m(p(x,D,h,w))},"bigint, bigint|number":function(x,D){return m(p(x,D,1n,!1))},"number, bigint":function(x,D){return m(p(BigInt(x),D,1n,!1))},"bigint, bigint|number, bigint|number":function(x,D,h){return m(p(x,D,BigInt(h),!1))},"number, bigint, bigint|number":function(x,D,h){return m(p(BigInt(x),D,BigInt(h),!1))},"bigint, bigint|number, boolean":function(x,D,h){return m(p(x,D,1n,h))},"number, bigint, boolean":function(x,D,h){return m(p(BigInt(x),D,1n,h))},"bigint, bigint|number, bigint|number, boolean":function(x,D,h,w){return m(p(x,D,BigInt(h),w))},"number, bigint, bigint|number, boolean":function(x,D,h,w){return m(p(BigInt(x),D,BigInt(h),w))},"BigNumber, BigNumber":function(x,D){var h=x.constructor;return m(p(x,D,new h(1),!1))},"BigNumber, BigNumber, BigNumber":function(x,D,h){return m(p(x,D,h,!1))},"BigNumber, BigNumber, boolean":function(x,D,h){var w=x.constructor;return m(p(x,D,new w(1),h))},"BigNumber, BigNumber, BigNumber, boolean":function(x,D,h,w){return m(p(x,D,h,w))},"Fraction, Fraction":function(x,D){return m(p(x,D,1,!1))},"Fraction, Fraction, Fraction":function(x,D,h){return m(p(x,D,h,!1))},"Fraction, Fraction, boolean":function(x,D,h){return m(p(x,D,1,h))},"Fraction, Fraction, Fraction, boolean":function(x,D,h,w){return m(p(x,D,h,w))},"Unit, Unit, Unit":function(x,D,h){return m(p(x,D,h,!1))},"Unit, Unit, Unit, boolean":function(x,D,h,w){return m(p(x,D,h,w))}});function m(y){return t.matrix==="Matrix"?n?n(y):CD():y}function v(y,x){var D=d(y);if(!D)throw new SyntaxError('String "'+y+'" is no valid range');return t.number==="BigNumber"?(a===void 0&&Ts(),m(p(a(D.start),a(D.end),a(D.step)))):m(p(D.start,D.end,D.step,x))}function p(y,x,D,h){var w=[];if(c(D))throw new Error("Step must be non-zero");for(var g=f(D)?h?o:i:h?u:l,b=y;g(b,x);)w.push(b),b=s(b,D);return w}function d(y){var x=y.split(":"),D=x.map(function(w){return Number(w)}),h=D.some(function(w){return isNaN(w)});if(h)return null;switch(D.length){case 2:return{start:D[0],end:D[1],step:1};case 3:return{start:D[0],end:D[2],step:D[1]};default:return null}}}),mm="reshape",_D=["typed","isInteger","matrix"],TD=L(mm,_D,r=>{var{typed:e,isInteger:t}=r;return e(mm,{"Matrix, Array":function(a,i){return a.reshape(i,!0)},"Array, Array":function(a,i){return i.forEach(function(o){if(!t(o))throw new TypeError("Invalid size for dimension: "+o)}),cs(a,i)}})}),FD="resize",OD=["config","matrix"],BD=L(FD,OD,r=>{var{config:e,matrix:t}=r;return function(i,o,l){if(arguments.length!==2&&arguments.length!==3)throw new ea("resize",arguments.length,2,3);if(Je(o)&&(o=o.valueOf()),or(o[0])&&(o=o.map(function(c){return or(c)?c.toNumber():c})),Je(i))return i.resize(o,l,!0);if(typeof i=="string")return n(i,o,l);var u=Array.isArray(i)?!1:e.matrix!=="Array";if(o.length===0){for(;Array.isArray(i);)i=i[0];return er(i)}else{Array.isArray(i)||(i=[i]),i=er(i);var s=Ea(i,o,l);return u?t(s):s}};function n(a,i,o){if(o!==void 0){if(typeof o!="string"||o.length!==1)throw new TypeError("Single character expected as defaultValue")}else o=" ";if(i.length!==1)throw new ur(i.length,1);var l=i[0];if(typeof l!="number"||!Ue(l))throw new TypeError("Invalid size, must contain positive integers (size: "+lr(i)+")");if(a.length>l)return a.substring(0,l);if(a.length<l){for(var u=a,s=0,c=l-a.length;s<c;s++)u+=o;return u}else return a}}),vm="rotate",RD=["typed","multiply","rotationMatrix"],ID=L(vm,RD,r=>{var{typed:e,multiply:t,rotationMatrix:n}=r;return e(vm,{"Array , number | BigNumber | Complex | Unit":function(o,l){a(o,2);var u=t(n(l),o);return u.toArray()},"Matrix , number | BigNumber | Complex | Unit":function(o,l){return a(o,2),t(n(l),o)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(o,l,u){a(o,3);var s=t(n(l,u),o);return s},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(o,l,u){return a(o,3),t(n(l,u),o)}});function a(i,o){var l=Array.isArray(i)?rr(i):i.size();if(l.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(o));if(l.length===2&&l[1]!==1)throw new RangeError("Vector must be of dimensions 1x".concat(o));if(l[0]!==o)throw new RangeError("Vector must be of dimensions 1x".concat(o))}}),pm="rotationMatrix",PD=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],$D=L(pm,PD,r=>{var{typed:e,config:t,multiplyScalar:n,addScalar:a,unaryMinus:i,norm:o,BigNumber:l,matrix:u,DenseMatrix:s,SparseMatrix:c,cos:f,sin:m}=r;return e(pm,{"":function(){return t.matrix==="Matrix"?u([]):[]},string:function(h){return u(h)},"number | BigNumber | Complex | Unit":function(h){return v(h,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(h,w){return v(h,w)},"number | BigNumber | Complex | Unit, Array":function(h,w){var g=u(w);return p(g),x(h,g,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(h,w){p(w);var g=w.storage()||(t.matrix==="Matrix"?"dense":void 0);return x(h,w,g)},"number | BigNumber | Complex | Unit, Array, string":function(h,w,g){var b=u(w);return p(b),x(h,b,g)},"number | BigNumber | Complex | Unit, Matrix, string":function(h,w,g){return p(w),x(h,w,g)}});function v(D,h){var w=or(D),g=w?new l(-1):-1,b=f(D),A=m(D),N=[[b,n(g,A)],[A,b]];return y(N,h)}function p(D){var h=D.size();if(h.length<1||h[0]!==3)throw new RangeError("Vector must be of dimensions 1x3")}function d(D){return D.reduce((h,w)=>n(h,w))}function y(D,h){if(h){if(h==="sparse")return new c(D);if(h==="dense")return new s(D);throw new TypeError('Unknown matrix type "'.concat(h,'"'))}return D}function x(D,h,w){var g=o(h);if(g===0)throw new RangeError("Rotation around zero vector");var b=or(D)?l:null,A=b?new b(1):1,N=b?new b(-1):-1,E=b?new b(h.get([0])/g):h.get([0])/g,S=b?new b(h.get([1])/g):h.get([1])/g,C=b?new b(h.get([2])/g):h.get([2])/g,M=f(D),O=a(A,i(M)),I=m(D),k=a(M,d([E,E,O])),_=a(d([E,S,O]),d([N,C,I])),P=a(d([E,C,O]),d([S,I])),V=a(d([E,S,O]),d([C,I])),q=a(M,d([S,S,O])),J=a(d([S,C,O]),d([N,E,I])),ne=a(d([E,C,O]),d([N,S,I])),j=a(d([S,C,O]),d([E,I])),F=a(M,d([C,C,O])),U=[[k,_,P],[V,q,J],[ne,j,F]];return y(U,w)}}),dm="row",qD=["typed","Index","matrix","range"],hm=L(dm,qD,r=>{var{typed:e,Index:t,matrix:n,range:a}=r;return e(dm,{"Matrix, number":i,"Array, number":function(l,u){return i(n(er(l)),u).valueOf()}});function i(o,l){if(o.size().length!==2)throw new Error("Only two dimensional matrix is supported");_r(l,o.size()[0]);var u=a(0,o.size()[1]),s=new t([l],u),c=o.subset(s);return Je(c)?c:n([[c]])}}),gm="size",zD=["typed"],UD=L(gm,zD,r=>{var{typed:e}=r;return e(gm,{Matrix:t=>t.size(),Array:rr,string:t=>[t.length],"number | Complex | BigNumber | Unit | boolean | null":t=>[]})}),ym="squeeze",LD=["typed"],kD=L(ym,LD,r=>{var{typed:e}=r;return e(ym,{Array:function(n){return Yi(er(n))},Matrix:function(n){var a=Yi(n.toArray());return Array.isArray(a)?n.create(a,n.datatype()):a},any:function(n){return er(n)}})}),bm="subset",VD=["typed","matrix","zeros","add"],xm=L(bm,VD,r=>{var{typed:e,matrix:t,zeros:n,add:a}=r;return e(bm,{"Matrix, Index":function(l,u){return Na(u)?t():(Wi(l,u),l.subset(u))},"Array, Index":e.referTo("Matrix, Index",function(o){return function(l,u){var s=o(t(l),u);return u.isScalar()?s:s.valueOf()}}),"Object, Index":HD,"string, Index":GD,"Matrix, Index, any, any":function(l,u,s,c){return Na(u)?l:(Wi(l,u),l.clone().subset(u,i(s,u),c))},"Array, Index, any, any":e.referTo("Matrix, Index, any, any",function(o){return function(l,u,s,c){var f=o(t(l),u,s,c);return f.isMatrix?f.valueOf():f}}),"Array, Index, any":e.referTo("Matrix, Index, any, any",function(o){return function(l,u,s){return o(t(l),u,s,void 0).valueOf()}}),"Matrix, Index, any":e.referTo("Matrix, Index, any, any",function(o){return function(l,u,s){return o(l,u,s,void 0)}}),"string, Index, string":wm,"string, Index, string, string":wm,"Object, Index, any":WD});function i(o,l){if(typeof o=="string")throw new Error("can't boradcast a string");if(l.isScalar())return o;var u=l.size();if(u.every(s=>s>0))try{return a(o,n(u))}catch{return o}else return o}});function GD(r,e){if(!Ti(e))throw new TypeError("Index expected");if(Na(e))return"";if(Wi(Array.from(r),e),e.size().length!==1)throw new ur(e.size().length,1);var t=r.length;_r(e.min()[0],t),_r(e.max()[0],t);var n=e.dimension(0),a="";function i(o){a+=r.charAt(o)}return Number.isInteger(n)?i(n):n.forEach(i),a}function wm(r,e,t,n){if(!e||e.isIndex!==!0)throw new TypeError("Index expected");if(Na(e))return r;if(Wi(Array.from(r),e),e.size().length!==1)throw new ur(e.size().length,1);if(n!==void 0){if(typeof n!="string"||n.length!==1)throw new TypeError("Single character expected as defaultValue")}else n=" ";var a=e.dimension(0),i=Number.isInteger(a)?1:a.size()[0];if(i!==t.length)throw new ur(a.size()[0],t.length);var o=r.length;_r(e.min()[0]),_r(e.max()[0]);for(var l=[],u=0;u<o;u++)l[u]=r.charAt(u);function s(m,v){l[m]=t.charAt(v[0])}if(Number.isInteger(a)?s(a,[0]):a.forEach(s),l.length>o)for(var c=o-1,f=l.length;c<f;c++)l[c]||(l[c]=n);return l.join("")}function HD(r,e){if(!Na(e)){if(e.size().length!==1)throw new ur(e.size(),1);var t=e.dimension(0);if(typeof t!="string")throw new TypeError("String expected as index to retrieve an object property");return pt(r,t)}}function WD(r,e,t){if(Na(e))return r;if(e.size().length!==1)throw new ur(e.size(),1);var n=e.dimension(0);if(typeof n!="string")throw new TypeError("String expected as index to retrieve an object property");var a=er(r);return ma(a,n,t),a}var Dm="transpose",YD=["typed","matrix"],ZD=L(Dm,YD,r=>{var{typed:e,matrix:t}=r;return e(Dm,{Array:o=>n(t(o)).valueOf(),Matrix:n,any:er});function n(o){var l=o.size(),u;switch(l.length){case 1:u=o.clone();break;case 2:{var s=l[0],c=l[1];if(c===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+lr(l)+")");switch(o.storage()){case"dense":u=a(o,s,c);break;case"sparse":u=i(o,s,c);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+lr(l)+")")}return u}function a(o,l,u){for(var s=o._data,c=[],f,m=0;m<u;m++){f=c[m]=[];for(var v=0;v<l;v++)f[v]=er(s[v][m])}return o.createDenseMatrix({data:c,size:[u,l],datatype:o._datatype})}function i(o,l,u){for(var s=o._values,c=o._index,f=o._ptr,m=s?[]:void 0,v=[],p=[],d=[],y=0;y<l;y++)d[y]=0;var x,D,h;for(x=0,D=c.length;x<D;x++)d[c[x]]++;for(var w=0,g=0;g<l;g++)p.push(w),w+=d[g],d[g]=p[g];for(p.push(w),h=0;h<u;h++)for(var b=f[h],A=f[h+1],N=b;N<A;N++){var E=d[c[N]]++;v[E]=h,s&&(m[E]=er(s[N]))}return o.createSparseMatrix({values:m,index:v,ptr:p,size:[u,l],datatype:o._datatype})}}),Nm="ctranspose",JD=["typed","transpose","conj"],jD=L(Nm,JD,r=>{var{typed:e,transpose:t,conj:n}=r;return e(Nm,{any:function(i){return n(t(i))}})}),Em="zeros",XD=["typed","config","matrix","BigNumber"],QD=L(Em,XD,r=>{var{typed:e,config:t,matrix:n,BigNumber:a}=r;return e(Em,{"":function(){return t.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(s){var c=s[s.length-1];if(typeof c=="string"){var f=s.pop();return i(s,f)}else return t.matrix==="Array"?i(s):i(s,"default")},Array:i,Matrix:function(s){var c=s.storage();return i(s.valueOf(),c)},"Array | Matrix, string":function(s,c){return i(s.valueOf(),c)}});function i(u,s){var c=o(u),f=c?new a(0):0;if(l(u),s){var m=n(s);return u.length>0?m.resize(u,f):m}else{var v=[];return u.length>0?Ea(v,u,f):v}}function o(u){var s=!1;return u.forEach(function(c,f,m){or(c)&&(s=!0,m[f]=c.toNumber())}),s}function l(u){u.forEach(function(s){if(typeof s!="number"||!Ue(s)||s<0)throw new Error("Parameters in function zeros must be positive integers")})}}),Am="fft",KD=["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i","dotDivide","conj","pow","ceil","log2"],eN=L(Am,KD,r=>{var{typed:e,matrix:t,addScalar:n,multiplyScalar:a,divideScalar:i,exp:o,tau:l,i:u,dotDivide:s,conj:c,pow:f,ceil:m,log2:v}=r;return e(Am,{Array:p,Matrix:function(h){return h.create(p(h.valueOf()),h.datatype())}});function p(D){var h=rr(D);return h.length===1?x(D,h[0]):d(D.map(w=>p(w,h.slice(1))),0)}function d(D,h){var w=rr(D);if(h!==0)return new Array(w[0]).fill(0).map((b,A)=>d(D[A],h-1));if(w.length===1)return x(D);function g(b){var A=rr(b);return new Array(A[1]).fill(0).map((N,E)=>new Array(A[0]).fill(0).map((S,C)=>b[C][E]))}return g(d(g(D),1))}function y(D){for(var h=D.length,w=o(i(a(-1,a(u,l)),h)),g=[],b=1-h;b<h;b++)g.push(f(w,i(f(b,2),2)));for(var A=f(2,m(v(h+h-1))),N=[...new Array(h).fill(0).map((_,P)=>a(D[P],g[h-1+P])),...new Array(A-h).fill(0)],E=[...new Array(h+h-1).fill(0).map((_,P)=>i(1,g[P])),...new Array(A-(h+h-1)).fill(0)],S=x(N),C=x(E),M=new Array(A).fill(0).map((_,P)=>a(S[P],C[P])),O=s(c(p(c(M))),A),I=[],k=h-1;k<h+h-1;k++)I.push(a(O[k],g[k]));return I}function x(D){var h=D.length;if(h===1)return[D[0]];if(h%2===0){for(var w=[...x(D.filter((N,E)=>E%2===0)),...x(D.filter((N,E)=>E%2===1))],g=0;g<h/2;g++){var b=w[g],A=a(w[g+h/2],o(a(a(l,u),i(-g,h))));w[g]=n(b,A),w[g+h/2]=n(b,a(-1,A))}return w}else return y(D)}}),Sm="ifft",rN=["typed","fft","dotDivide","conj"],tN=L(Sm,rN,r=>{var{typed:e,fft:t,dotDivide:n,conj:a}=r;return e(Sm,{"Array | Matrix":function(o){var l=Je(o)?o.size():rr(o);return n(a(t(a(o))),l.reduce((u,s)=>u*s,1))}})});function si(r){"@babel/helpers - typeof";return si=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},si(r)}function nN(r,e){if(si(r)!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(si(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function aN(r){var e=nN(r,"string");return si(e)=="symbol"?e:e+""}function Vr(r,e,t){return(e=aN(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Cm(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function iN(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Cm(Object(t),!0).forEach(function(n){Vr(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Cm(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}var oN="solveODE",sN=["typed","add","subtract","multiply","divide","max","map","abs","isPositive","isNegative","larger","smaller","matrix","bignumber","unaryMinus"],uN=L(oN,sN,r=>{var{typed:e,add:t,subtract:n,multiply:a,divide:i,max:o,map:l,abs:u,isPositive:s,isNegative:c,larger:f,smaller:m,matrix:v,bignumber:p,unaryMinus:d}=r;function y(N){return function(E,S,C,M){var O=!(S.length===2&&(S.every(b)||S.every(Ct)));if(O)throw new Error('"tspan" must be an Array of two numeric values or two units [tStart, tEnd]');var I=S[0],k=S[1],_=f(k,I),P=M.firstStep;if(P!==void 0&&!s(P))throw new Error('"firstStep" must be positive');var V=M.maxStep;if(V!==void 0&&!s(V))throw new Error('"maxStep" must be positive');var q=M.minStep;if(q&&c(q))throw new Error('"minStep" must be positive or zero');var J=[I,k,P,q,V].filter(R=>R!==void 0);if(!(J.every(b)||J.every(Ct)))throw new Error('Inconsistent type of "t" dependant variables');for(var ne=1,j=M.tol?M.tol:1e-4,F=M.minDelta?M.minDelta:.2,U=M.maxDelta?M.maxDelta:5,$=M.maxIter?M.maxIter:1e4,le=[I,k,...C,V,q].some(or),[me,Y,z,X]=le?[p(N.a),p(N.c),p(N.b),p(N.bp)]:[N.a,N.c,N.b,N.bp],se=P?_?P:d(P):i(n(k,I),ne),re=[I],pe=[C],ve=n(z,X),De=0,Oe=0,Ie=w(_),_e=g(_);Ie(re[De],k);){var Le=[];se=_e(re[De],k,se),Le.push(E(re[De],pe[De]));for(var qe=1;qe<Y.length;++qe)Le.push(E(t(re[De],a(Y[qe],se)),t(pe[De],a(se,me[qe],Le))));var G=o(u(l(a(ve,Le),R=>Ct(R)?R.value:R)));G<j&&j/G>1/4&&(re.push(t(re[De],se)),pe.push(t(pe[De],a(se,z,Le))),De++);var ee=.84*(j/G)**(1/5);if(m(ee,F)?ee=F:f(ee,U)&&(ee=U),ee=le?p(ee):ee,se=a(se,ee),V&&f(u(se),V)?se=_?V:d(V):q&&m(u(se),q)&&(se=_?q:d(q)),Oe++,Oe>$)throw new Error("Maximum number of iterations reached, try changing options")}return{t:re,y:pe}}}function x(N,E,S,C){var M=[[],[.5],[0,.75],[.2222222222222222,.3333333333333333,.4444444444444444]],O=[null,1/2,3/4,1],I=[2/9,1/3,4/9,0],k=[7/24,1/4,1/3,1/8],_={a:M,c:O,b:I,bp:k};return y(_)(N,E,S,C)}function D(N,E,S,C){var M=[[],[.2],[.075,.225],[.9777777777777777,-3.7333333333333334,3.5555555555555554],[2.9525986892242035,-11.595793324188385,9.822892851699436,-.2908093278463649],[2.8462752525252526,-10.757575757575758,8.906422717743473,.2784090909090909,-.2735313036020583],[.09114583333333333,0,.44923629829290207,.6510416666666666,-.322376179245283,.13095238095238096]],O=[null,1/5,3/10,4/5,8/9,1,1],I=[35/384,0,500/1113,125/192,-2187/6784,11/84,0],k=[5179/57600,0,7571/16695,393/640,-92097/339200,187/2100,1/40],_={a:M,c:O,b:I,bp:k};return y(_)(N,E,S,C)}function h(N,E,S,C){var M=C.method?C.method:"RK45",O={RK23:x,RK45:D};if(M.toUpperCase()in O){var I=iN({},C);return delete I.method,O[M.toUpperCase()](N,E,S,I)}else{var k=Object.keys(O).map(P=>'"'.concat(P,'"')),_="".concat(k.slice(0,-1).join(", ")," and ").concat(k.slice(-1));throw new Error('Unavailable method "'.concat(M,'". Available methods are ').concat(_))}}function w(N){return N?m:f}function g(N){var E=N?f:m;return function(S,C,M){var O=t(S,M);return E(O,C)?n(C,S):M}}function b(N){return or(N)||Ye(N)}function A(N,E,S,C){var M=h(N,E.toArray(),S.toArray(),C);return{t:v(M.t),y:v(M.y)}}return e("solveODE",{"function, Array, Array, Object":h,"function, Matrix, Matrix, Object":A,"function, Array, Array":(N,E,S)=>h(N,E,S,{}),"function, Matrix, Matrix":(N,E,S)=>A(N,E,S,{}),"function, Array, number | BigNumber | Unit":(N,E,S)=>{var C=h(N,E,[S],{});return{t:C.t,y:C.y.map(M=>M[0])}},"function, Matrix, number | BigNumber | Unit":(N,E,S)=>{var C=h(N,E.toArray(),[S],{});return{t:v(C.t),y:v(C.y.map(M=>M[0]))}},"function, Array, number | BigNumber | Unit, Object":(N,E,S,C)=>{var M=h(N,E,[S],C);return{t:M.t,y:M.y.map(O=>O[0])}},"function, Matrix, number | BigNumber | Unit, Object":(N,E,S,C)=>{var M=h(N,E.toArray(),[S],C);return{t:v(M.t),y:v(M.y.map(O=>O[0]))}}})}),lN="erf",cN=["typed"],fN=L(lN,cN,r=>{var{typed:e}=r;return e("name",{number:function(o){var l=Math.abs(o);return l>=pN?Sn(o):l<=mN?Sn(o)*t(l):l<=4?Sn(o)*(1-n(l)):Sn(o)*(1-a(l))},"Array | Matrix":e.referToSelf(i=>o=>tr(o,i))});function t(i){var o=i*i,l=hn[0][4]*o,u=o,s;for(s=0;s<3;s+=1)l=(l+hn[0][s])*o,u=(u+Fa[0][s])*o;return i*(l+hn[0][3])/(u+Fa[0][3])}function n(i){var o=hn[1][8]*i,l=i,u;for(u=0;u<7;u+=1)o=(o+hn[1][u])*i,l=(l+Fa[1][u])*i;var s=(o+hn[1][7])/(l+Fa[1][7]),c=parseInt(i*16)/16,f=(i-c)*(i+c);return Math.exp(-c*c)*Math.exp(-f)*s}function a(i){var o=1/(i*i),l=hn[2][5]*o,u=o,s;for(s=0;s<4;s+=1)l=(l+hn[2][s])*o,u=(u+Fa[2][s])*o;var c=o*(l+hn[2][4])/(u+Fa[2][4]);c=(vN-c)/i,o=parseInt(i*16)/16;var f=(i-o)*(i+o);return Math.exp(-o*o)*Math.exp(-f)*c}}),mN=.46875,vN=.5641895835477563,hn=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,21531153547440383e-24],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],Fa=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],pN=Math.pow(2,53),Mm="zeta",dN=["typed","config","multiply","pow","divide","factorial","equal","smallerEq","isBounded","isNegative","gamma","sin","subtract","add","?Complex","?BigNumber","pi"],hN=L(Mm,dN,r=>{var{typed:e,config:t,multiply:n,pow:a,divide:i,factorial:o,equal:l,smallerEq:u,isBounded:s,isNegative:c,gamma:f,sin:m,subtract:v,add:p,Complex:d,BigNumber:y,pi:x}=r;return e(Mm,{number:A=>D(A,N=>N,()=>20),BigNumber:A=>D(A,N=>new y(N),()=>Math.abs(Math.log10(t.relTol))),Complex:h});function D(A,N,E){return l(A,0)?N(-.5):l(A,1)?N(NaN):s(A)?w(A,N,E,S=>S):c(A)?N(NaN):N(1)}function h(A){return A.re===0&&A.im===0?new d(-.5):A.re===1?new d(NaN,NaN):A.re===1/0&&A.im===0?new d(1):A.im===1/0||A.re===-1/0?new d(NaN,NaN):w(A,N=>N,N=>Math.round(1.3*15+.9*Math.abs(N.im)),N=>N.re)}function w(A,N,E,S){var C=E(A);if(S(A)>-(C-1)/2)return b(A,N(C),N);var M=n(a(2,A),a(N(x),v(A,1)));return M=n(M,m(n(i(N(x),2),A))),M=n(M,f(v(1,A))),n(M,w(v(1,A),N,E,S))}function g(A,N){for(var E=A,S=A;u(S,N);S=p(S,1)){var C=i(n(o(p(N,v(S,1))),a(4,S)),n(o(v(N,S)),o(n(2,S))));E=p(E,C)}return n(N,E)}function b(A,N,E){for(var S=i(1,n(g(E(0),N),v(1,a(2,v(1,A))))),C=E(0),M=E(1);u(M,N);M=p(M,1))C=p(C,i(n((-1)**(M-1),g(M,N)),a(M,A)));return n(S,C)}}),_m="mode",gN=["typed","isNaN","isNumeric"],yN=L(_m,gN,r=>{var{typed:e,isNaN:t,isNumeric:n}=r;return e(_m,{"Array | Matrix":a,"...":function(o){return a(o)}});function a(i){i=yr(i.valueOf());var o=i.length;if(o===0)throw new Error("Cannot calculate mode of an empty array");for(var l={},u=[],s=0,c=0;c<i.length;c++){var f=i[c];if(n(f)&&t(f))throw new Error("Cannot calculate mode of an array containing NaN values");f in l||(l[f]=0),l[f]++,l[f]===s?u.push(f):l[f]>s&&(s=l[f],u=[f])}return u}});function dt(r,e,t){var n;return String(r).includes("Unexpected type")?(n=arguments.length>2?" (type: "+Sr(t)+", value: "+JSON.stringify(t)+")":" (type: "+r.data.actual+")",new TypeError("Cannot calculate "+e+", unexpected type of argument"+n)):String(r).includes("complex numbers")?(n=arguments.length>2?" (type: "+Sr(t)+", value: "+JSON.stringify(t)+")":"",new TypeError("Cannot calculate "+e+", no ordering relation is defined for complex numbers"+n)):r}var Tm="prod",bN=["typed","config","multiplyScalar","numeric"],xN=L(Tm,bN,r=>{var{typed:e,config:t,multiplyScalar:n,numeric:a}=r;return e(Tm,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(l,u){throw new Error("prod(A, dim) is not yet supported")},"...":function(l){return i(l)}});function i(o){var l;if(Rn(o,function(u){try{l=l===void 0?u:n(l,u)}catch(s){throw dt(s,"prod",u)}}),typeof l=="string"&&(l=a(l,An(l,t))),l===void 0)throw new Error("Cannot calculate prod of an empty array");return l}}),Fm="format",wN=["typed"],DN=L(Fm,wN,r=>{var{typed:e}=r;return e(Fm,{any:lr,"any, Object | function | number | BigNumber":lr})}),Om="bin",NN=["typed","format"],EN=L(Om,NN,r=>{var{typed:e,format:t}=r;return e(Om,{"number | BigNumber":function(a){return t(a,{notation:"bin"})},"number | BigNumber, number | BigNumber":function(a,i){return t(a,{notation:"bin",wordSize:i})}})}),Bm="oct",AN=["typed","format"],SN=L(Bm,AN,r=>{var{typed:e,format:t}=r;return e(Bm,{"number | BigNumber":function(a){return t(a,{notation:"oct"})},"number | BigNumber, number | BigNumber":function(a,i){return t(a,{notation:"oct",wordSize:i})}})}),Rm="hex",CN=["typed","format"],MN=L(Rm,CN,r=>{var{typed:e,format:t}=r;return e(Rm,{"number | BigNumber":function(a){return t(a,{notation:"hex"})},"number | BigNumber, number | BigNumber":function(a,i){return t(a,{notation:"hex",wordSize:i})}})}),Im=/\$([\w.]+)/g,Pm="print",_N=["typed"],$m=L(Pm,_N,r=>{var{typed:e}=r;return e(Pm,{"string, Object | Array":qm,"string, Object | Array, number | Object":qm})});function qm(r,e,t){return r.replace(Im,function(n,a){var i=a.split("."),o=e[i.shift()];for(o!==void 0&&o.isMatrix&&(o=o.toArray());i.length&&o!==void 0;){var l=i.shift();o=l?o[l]:o+"."}return o!==void 0?$r(o)?o:lr(o,t):n})}var zm="to",TN=["typed","matrix","concat"],FN=L(zm,TN,r=>{var{typed:e,matrix:t,concat:n}=r,a=Tr({typed:e,matrix:t,concat:n});return e(zm,{"Unit, Unit | string":(i,o)=>i.to(o)},a({Ds:!0}))}),Um="toBest",ON=["typed"],BN=L(Um,ON,r=>{var{typed:e}=r;return e(Um,{Unit:t=>t.toBest(),"Unit, string":(t,n)=>t.toBest(n.split(",")),"Unit, string, Object":(t,n,a)=>t.toBest(n.split(","),a),"Unit, Array":(t,n)=>t.toBest(n),"Unit, Array, Object":(t,n,a)=>t.toBest(n,a)})}),Lm="isPrime",RN=["typed"],IN=L(Lm,RN,r=>{var{typed:e}=r;return e(Lm,{number:function(n){if(n<=3)return n>1;if(n%2===0||n%3===0)return!1;for(var a=5;a*a<=n;a+=6)if(n%a===0||n%(a+2)===0)return!1;return!0},bigint:function(n){if(n<=3n)return n>1n;if(n%2n===0n||n%3n===0n)return!1;for(var a=5n;a*a<=n;a+=6n)if(n%a===0n||n%(a+2n)===0n)return!1;return!0},BigNumber:function(n){if(n.lte(3))return n.gt(1);if(n.mod(2).eq(0)||n.mod(3).eq(0))return!1;if(n.lt(Math.pow(2,32))){for(var a=n.toNumber(),i=5;i*i<=a;i+=6)if(a%i===0||a%(i+2)===0)return!1;return!0}function o(D,h,w){for(var g=1;!h.eq(0);)h.mod(2).eq(0)?(h=h.div(2),D=D.mul(D).mod(w)):(h=h.sub(1),g=D.mul(g).mod(w));return g}var l=n.constructor.clone({precision:n.toFixed(0).length*2});n=new l(n);for(var u=0,s=n.sub(1);s.mod(2).eq(0);)s=s.div(2),u+=1;var c=null;if(n.lt("3317044064679887385961981"))c=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter(D=>D<n);else{var f=Math.min(n.toNumber()-2,Math.floor(2*Math.pow(n.toFixed(0).length*Math.log(10),2)));c=[];for(var m=2;m<=f;m+=1)c.push(f)}for(var v=0;v<c.length;v+=1){var p=c[v],d=o(n.sub(n).add(p),s,n);if(!d.eq(1)){for(var y=0,x=d;!x.eq(n.sub(1));y+=1,x=x.mul(x).mod(n))if(y===u-1)return!1}}return!0},"Array | Matrix":e.referToSelf(t=>n=>tr(n,t))})}),PN="numeric",$N=["number","?bignumber","?fraction"],qN=L(PN,$N,r=>{var{number:e,bignumber:t,fraction:n}=r,a={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:o=>e(o),BigNumber:t?o=>t(o):Ts,bigint:o=>BigInt(o),Fraction:n?o=>n(o):lm};return function(l){var u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",s=arguments.length>2?arguments[2]:void 0;if(s!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var c=Sr(l);if(!(c in a))throw new TypeError("Cannot convert "+l+' of type "'+c+'"; valid input types are '+Object.keys(a).join(", "));if(!(u in i))throw new TypeError("Cannot convert "+l+' to type "'+u+'"; valid output types are '+Object.keys(i).join(", "));return u===c?l:i[u](l)}}),km="divideScalar",zN=["typed","numeric"],UN=L(km,zN,r=>{var{typed:e,numeric:t}=r;return e(km,{"number, number":function(a,i){return a/i},"Complex, Complex":function(a,i){return a.div(i)},"BigNumber, BigNumber":function(a,i){return a.div(i)},"bigint, bigint":function(a,i){return a/i},"Fraction, Fraction":function(a,i){return a.div(i)},"Unit, number | Complex | Fraction | BigNumber | Unit":(n,a)=>n.divide(a),"number | Fraction | Complex | BigNumber, Unit":(n,a)=>a.divideInto(n)})}),Vm="pow",LN=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],kN=L(Vm,LN,r=>{var{typed:e,config:t,identity:n,multiply:a,matrix:i,inv:o,number:l,fraction:u,Complex:s}=r;return e(Vm,{"number, number":c,"Complex, Complex":function(p,d){return p.pow(d)},"BigNumber, BigNumber":function(p,d){return d.isInteger()||p>=0||t.predictable?p.pow(d):new s(p.toNumber(),0).pow(d.toNumber(),0)},"bigint, bigint":(v,p)=>v**p,"Fraction, Fraction":function(p,d){var y=p.pow(d);if(y!=null)return y;if(t.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return c(p.valueOf(),d.valueOf())},"Array, number":f,"Array, BigNumber":function(p,d){return f(p,d.toNumber())},"Matrix, number":m,"Matrix, BigNumber":function(p,d){return m(p,d.toNumber())},"Unit, number | BigNumber":function(p,d){return p.pow(d)}});function c(v,p){if(t.predictable&&!Ue(p)&&v<0)try{var d=u(p),y=l(d);if((p===y||Math.abs((p-y)/p)<1e-14)&&d.d%2n===1n)return(d.n%2n===0n?1:-1)*Math.pow(-v,p)}catch{}return t.predictable&&(v<-1&&p===1/0||v>-1&&v<0&&p===-1/0)?NaN:Ue(p)||v>=0||t.predictable?sc(v,p):v*v<1&&p===1/0||v*v>1&&p===-1/0?0:new s(v,0).pow(p,0)}function f(v,p){if(!Ue(p))throw new TypeError("For A^b, b must be an integer (value is "+p+")");var d=rr(v);if(d.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+d.length+" dimensions)");if(d[0]!==d[1])throw new Error("For A^b, A must be square (size is "+d[0]+"x"+d[1]+")");if(p<0)try{return f(o(v),-p)}catch(D){throw D.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+p+")"):D}for(var y=n(d[0]).valueOf(),x=v;p>=1;)(p&1)===1&&(y=a(x,y)),p>>=1,x=a(x,x);return y}function m(v,p){return i(f(v.valueOf(),p))}}),Oa="Number of decimals in function round must be an integer",Gm="round",VN=["typed","config","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],GN=L(Gm,VN,r=>{var{typed:e,config:t,matrix:n,equalScalar:a,zeros:i,BigNumber:o,DenseMatrix:l}=r,u=nt({typed:e,equalScalar:a}),s=Wr({typed:e,DenseMatrix:l}),c=Ut({typed:e});function f(m){return Math.abs(ri(m).exponent)}return e(Gm,{number:function(v){var p=ii(v,f(t.relTol)),d=Xr(v,p,t.relTol,t.absTol)?p:v;return ii(d)},"number, number":function(v,p){var d=f(t.relTol);if(p>=d)return ii(v,p);var y=ii(v,d),x=Xr(v,y,t.relTol,t.absTol)?y:v;return ii(x,p)},"number, BigNumber":function(v,p){if(!p.isInteger())throw new TypeError(Oa);return new o(v).toDecimalPlaces(p.toNumber())},Complex:function(v){return v.round()},"Complex, number":function(v,p){if(p%1)throw new TypeError(Oa);return v.round(p)},"Complex, BigNumber":function(v,p){if(!p.isInteger())throw new TypeError(Oa);var d=p.toNumber();return v.round(d)},BigNumber:function(v){var p=new o(v).toDecimalPlaces(f(t.relTol)),d=zt(v,p,t.relTol,t.absTol)?p:v;return d.toDecimalPlaces(0)},"BigNumber, BigNumber":function(v,p){if(!p.isInteger())throw new TypeError(Oa);var d=f(t.relTol);if(p>=d)return v.toDecimalPlaces(p.toNumber());var y=v.toDecimalPlaces(d),x=zt(v,y,t.relTol,t.absTol)?y:v;return x.toDecimalPlaces(p.toNumber())},bigint:m=>m,"bigint, number":(m,v)=>m,"bigint, BigNumber":(m,v)=>m,Fraction:function(v){return v.round()},"Fraction, number":function(v,p){if(p%1)throw new TypeError(Oa);return v.round(p)},"Fraction, BigNumber":function(v,p){if(!p.isInteger())throw new TypeError(Oa);return v.round(p.toNumber())},"Unit, number, Unit":e.referToSelf(m=>function(v,p,d){var y=v.toNumeric(d);return d.multiply(m(y,p))}),"Unit, BigNumber, Unit":e.referToSelf(m=>(v,p,d)=>m(v,p.toNumber(),d)),"Array | Matrix, number | BigNumber, Unit":e.referToSelf(m=>(v,p,d)=>tr(v,y=>m(y,p,d),!0)),"Array | Matrix | Unit, Unit":e.referToSelf(m=>(v,p)=>m(v,0,p)),"Array | Matrix":e.referToSelf(m=>v=>tr(v,m,!0)),"SparseMatrix, number | BigNumber":e.referToSelf(m=>(v,p)=>u(v,p,m,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(m=>(v,p)=>c(v,p,m,!1)),"Array, number | BigNumber":e.referToSelf(m=>(v,p)=>c(n(v),p,m,!1).valueOf()),"number | Complex | BigNumber | Fraction, SparseMatrix":e.referToSelf(m=>(v,p)=>a(v,0)?i(p.size(),p.storage()):s(p,v,m,!0)),"number | Complex | BigNumber | Fraction, DenseMatrix":e.referToSelf(m=>(v,p)=>a(v,0)?i(p.size(),p.storage()):c(p,v,m,!0)),"number | Complex | BigNumber | Fraction, Array":e.referToSelf(m=>(v,p)=>c(n(p),v,m,!0).valueOf())})}),Hm="log",HN=["config","typed","typeOf","divideScalar","Complex"],WN=Math.log(16),YN=L(Hm,HN,r=>{var{typed:e,typeOf:t,config:n,divideScalar:a,Complex:i}=r;function o(u){return u.log()}function l(u){return o(new i(u,0))}return e(Hm,{number:function(s){return s>=0||n.predictable?nc(s):l(s)},bigint:Ss(WN,nc,n,l),Complex:o,BigNumber:function(s){return!s.isNegative()||n.predictable?s.ln():l(s.toNumber())},"any, any":e.referToSelf(u=>(s,c)=>{if(t(s)==="Fraction"&&t(c)==="Fraction"){var f=s.log(c);if(f!==null)return f}return a(u(s),u(c))})})}),Wm="log1p",ZN=["typed","config","divideScalar","log","Complex"],JN=L(Wm,ZN,r=>{var{typed:e,config:t,divideScalar:n,log:a,Complex:i}=r;return e(Wm,{number:function(u){return u>=-1||t.predictable?q0(u):o(new i(u,0))},Complex:o,BigNumber:function(u){var s=u.plus(1);return!s.isNegative()||t.predictable?s.ln():o(new i(u.toNumber(),0))},"Array | Matrix":e.referToSelf(l=>u=>tr(u,l)),"any, any":e.referToSelf(l=>(u,s)=>n(l(u),a(s)))});function o(l){var u=l.re+1;return new i(Math.log(Math.sqrt(u*u+l.im*l.im)),Math.atan2(l.im,u))}}),Ym="nthRoots",jN=["config","typed","divideScalar","Complex"],XN=L(Ym,jN,r=>{var{typed:e,config:t,divideScalar:n,Complex:a}=r,i=[function(u){return new a(u,0)},function(u){return new a(0,u)},function(u){return new a(-u,0)},function(u){return new a(0,-u)}];function o(l,u){if(u<0)throw new Error("Root must be greater than zero");if(u===0)throw new Error("Root must be non-zero");if(u%1!==0)throw new Error("Root must be an integer");if(l===0||l.abs()===0)return[new a(0,0)];var s=typeof l=="number",c;(s||l.re===0||l.im===0)&&(s?c=2*+(l<0):l.im===0?c=2*+(l.re<0):c=2*+(l.im<0)+1);for(var f=l.arg(),m=l.abs(),v=[],p=Math.pow(m,1/u),d=0;d<u;d++){var y=(c+4*d)/u;if(y===Math.round(y)){v.push(i[y%4](p));continue}v.push(new a({r:p,phi:(f+2*Math.PI*d)/u}))}return v}return e(Ym,{Complex:function(u){return o(u,2)},"Complex, number":o})}),Zm="dotPow",QN=["typed","equalScalar","matrix","pow","DenseMatrix","concat","SparseMatrix"],KN=L(Zm,QN,r=>{var{typed:e,equalScalar:t,matrix:n,pow:a,DenseMatrix:i,concat:o,SparseMatrix:l}=r,u=ct({typed:e}),s=nn({typed:e,SparseMatrix:l}),c=nt({typed:e,equalScalar:t}),f=Wr({typed:e,DenseMatrix:i}),m=Tr({typed:e,matrix:n,concat:o}),v={};for(var p in a.signatures)Object.prototype.hasOwnProperty.call(a.signatures,p)&&!p.includes("Matrix")&&!p.includes("Array")&&(v[p]=a.signatures[p]);var d=e(v);return e(Zm,m({elop:d,SS:s,DS:u,Ss:c,sS:f}))}),Jm="dotDivide",e2=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat","SparseMatrix"],r2=L(Jm,e2,r=>{var{typed:e,matrix:t,equalScalar:n,divideScalar:a,DenseMatrix:i,concat:o,SparseMatrix:l}=r,u=Jt({typed:e,equalScalar:n}),s=ct({typed:e}),c=nn({typed:e,SparseMatrix:l}),f=nt({typed:e,equalScalar:n}),m=Wr({typed:e,DenseMatrix:i}),v=Tr({typed:e,matrix:t,concat:o});return e(Jm,v({elop:a,SS:c,DS:s,SD:u,Ss:f,sS:m}))});function ui(r){var{DenseMatrix:e}=r;return function(n,a,i){var o=n.size();if(o.length!==2)throw new RangeError("Matrix must be two dimensional (size: "+lr(o)+")");var l=o[0],u=o[1];if(l!==u)throw new RangeError("Matrix must be square (size: "+lr(o)+")");var s=[];if(Je(a)){var c=a.size(),f=a._data;if(c.length===1){if(c[0]!==l)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var m=0;m<l;m++)s[m]=[f[m]];return new e({data:s,size:[l,1],datatype:a._datatype})}if(c.length===2){if(c[0]!==l||c[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");if(_i(a)){if(i){s=[];for(var v=0;v<l;v++)s[v]=[f[v][0]];return new e({data:s,size:[l,1],datatype:a._datatype})}return a}if(Yn(a)){for(var p=0;p<l;p++)s[p]=[0];for(var d=a._values,y=a._index,x=a._ptr,D=x[1],h=x[0];h<D;h++){var w=y[h];s[w][0]=d[h]}return new e({data:s,size:[l,1],datatype:a._datatype})}}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}if(Ar(a)){var g=rr(a);if(g.length===1){if(g[0]!==l)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var b=0;b<l;b++)s[b]=[a[b]];return new e({data:s,size:[l,1]})}if(g.length===2){if(g[0]!==l||g[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var A=0;A<l;A++)s[A]=[a[A][0]];return new e({data:s,size:[l,1]})}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}}}var jm="lsolve",t2=["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],n2=L(jm,t2,r=>{var{typed:e,matrix:t,divideScalar:n,multiplyScalar:a,subtractScalar:i,equalScalar:o,DenseMatrix:l}=r,u=ui({DenseMatrix:l});return e(jm,{"SparseMatrix, Array | Matrix":function(m,v){return c(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return s(m,v)},"Array, Array | Matrix":function(m,v){var p=t(m),d=s(p,v);return d.valueOf()}});function s(f,m){m=u(f,m,!0);for(var v=m._data,p=f._size[0],d=f._size[1],y=[],x=f._data,D=0;D<d;D++){var h=v[D][0]||0,w=void 0;if(o(h,0))w=0;else{var g=x[D][D];if(o(g,0))throw new Error("Linear system cannot be solved since matrix is singular");w=n(h,g);for(var b=D+1;b<p;b++)v[b]=[i(v[b][0]||0,a(w,x[b][D]))]}y[D]=[w]}return new l({data:y,size:[p,1]})}function c(f,m){m=u(f,m,!0);for(var v=m._data,p=f._size[0],d=f._size[1],y=f._values,x=f._index,D=f._ptr,h=[],w=0;w<d;w++){var g=v[w][0]||0;if(o(g,0))h[w]=[0];else{for(var b=0,A=[],N=[],E=D[w],S=D[w+1],C=E;C<S;C++){var M=x[C];M===w?b=y[C]:M>w&&(A.push(y[C]),N.push(M))}if(o(b,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var O=n(g,b),I=0,k=N.length;I<k;I++){var _=N[I];v[_]=[i(v[_][0]||0,a(O,A[I]))]}h[w]=[O]}}return new l({data:h,size:[p,1]})}}),Xm="usolve",a2=["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],i2=L(Xm,a2,r=>{var{typed:e,matrix:t,divideScalar:n,multiplyScalar:a,subtractScalar:i,equalScalar:o,DenseMatrix:l}=r,u=ui({DenseMatrix:l});return e(Xm,{"SparseMatrix, Array | Matrix":function(m,v){return c(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return s(m,v)},"Array, Array | Matrix":function(m,v){var p=t(m),d=s(p,v);return d.valueOf()}});function s(f,m){m=u(f,m,!0);for(var v=m._data,p=f._size[0],d=f._size[1],y=[],x=f._data,D=d-1;D>=0;D--){var h=v[D][0]||0,w=void 0;if(o(h,0))w=0;else{var g=x[D][D];if(o(g,0))throw new Error("Linear system cannot be solved since matrix is singular");w=n(h,g);for(var b=D-1;b>=0;b--)v[b]=[i(v[b][0]||0,a(w,x[b][D]))]}y[D]=[w]}return new l({data:y,size:[p,1]})}function c(f,m){m=u(f,m,!0);for(var v=m._data,p=f._size[0],d=f._size[1],y=f._values,x=f._index,D=f._ptr,h=[],w=d-1;w>=0;w--){var g=v[w][0]||0;if(o(g,0))h[w]=[0];else{for(var b=0,A=[],N=[],E=D[w],S=D[w+1],C=S-1;C>=E;C--){var M=x[C];M===w?b=y[C]:M<w&&(A.push(y[C]),N.push(M))}if(o(b,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var O=n(g,b),I=0,k=N.length;I<k;I++){var _=N[I];v[_]=[i(v[_][0],a(O,A[I]))]}h[w]=[O]}}return new l({data:h,size:[p,1]})}}),Qm="lsolveAll",o2=["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],s2=L(Qm,o2,r=>{var{typed:e,matrix:t,divideScalar:n,multiplyScalar:a,subtractScalar:i,equalScalar:o,DenseMatrix:l}=r,u=ui({DenseMatrix:l});return e(Qm,{"SparseMatrix, Array | Matrix":function(m,v){return c(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return s(m,v)},"Array, Array | Matrix":function(m,v){var p=t(m),d=s(p,v);return d.map(y=>y.valueOf())}});function s(f,m){for(var v=[u(f,m,!0)._data.map(N=>N[0])],p=f._data,d=f._size[0],y=f._size[1],x=0;x<y;x++)for(var D=v.length,h=0;h<D;h++){var w=v[h];if(o(p[x][x],0))if(o(w[x],0)){if(h===0){var b=[...w];b[x]=1;for(var A=x+1;A<y;A++)b[A]=i(b[A],p[A][x]);v.push(b)}}else{if(h===0)return[];v.splice(h,1),h-=1,D-=1}else{w[x]=n(w[x],p[x][x]);for(var g=x+1;g<y;g++)w[g]=i(w[g],a(w[x],p[g][x]))}}return v.map(N=>new l({data:N.map(E=>[E]),size:[d,1]}))}function c(f,m){for(var v=[u(f,m,!0)._data.map(ne=>ne[0])],p=f._size[0],d=f._size[1],y=f._values,x=f._index,D=f._ptr,h=0;h<d;h++)for(var w=v.length,g=0;g<w;g++){for(var b=v[g],A=[],N=[],E=D[h],S=D[h+1],C=0,M=E;M<S;M++){var O=x[M];O===h?C=y[M]:O>h&&(A.push(y[M]),N.push(O))}if(o(C,0))if(o(b[h],0)){if(g===0){var P=[...b];P[h]=1;for(var V=0,q=N.length;V<q;V++){var J=N[V];P[J]=i(P[J],A[V])}v.push(P)}}else{if(g===0)return[];v.splice(g,1),g-=1,w-=1}else{b[h]=n(b[h],C);for(var I=0,k=N.length;I<k;I++){var _=N[I];b[_]=i(b[_],a(b[h],A[I]))}}}return v.map(ne=>new l({data:ne.map(j=>[j]),size:[p,1]}))}}),Km="usolveAll",u2=["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],l2=L(Km,u2,r=>{var{typed:e,matrix:t,divideScalar:n,multiplyScalar:a,subtractScalar:i,equalScalar:o,DenseMatrix:l}=r,u=ui({DenseMatrix:l});return e(Km,{"SparseMatrix, Array | Matrix":function(m,v){return c(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return s(m,v)},"Array, Array | Matrix":function(m,v){var p=t(m),d=s(p,v);return d.map(y=>y.valueOf())}});function s(f,m){for(var v=[u(f,m,!0)._data.map(N=>N[0])],p=f._data,d=f._size[0],y=f._size[1],x=y-1;x>=0;x--)for(var D=v.length,h=0;h<D;h++){var w=v[h];if(o(p[x][x],0))if(o(w[x],0)){if(h===0){var b=[...w];b[x]=1;for(var A=x-1;A>=0;A--)b[A]=i(b[A],p[A][x]);v.push(b)}}else{if(h===0)return[];v.splice(h,1),h-=1,D-=1}else{w[x]=n(w[x],p[x][x]);for(var g=x-1;g>=0;g--)w[g]=i(w[g],a(w[x],p[g][x]))}}return v.map(N=>new l({data:N.map(E=>[E]),size:[d,1]}))}function c(f,m){for(var v=[u(f,m,!0)._data.map(ne=>ne[0])],p=f._size[0],d=f._size[1],y=f._values,x=f._index,D=f._ptr,h=d-1;h>=0;h--)for(var w=v.length,g=0;g<w;g++){for(var b=v[g],A=[],N=[],E=D[h],S=D[h+1],C=0,M=S-1;M>=E;M--){var O=x[M];O===h?C=y[M]:O<h&&(A.push(y[M]),N.push(O))}if(o(C,0))if(o(b[h],0)){if(g===0){var P=[...b];P[h]=1;for(var V=0,q=N.length;V<q;V++){var J=N[V];P[J]=i(P[J],A[V])}v.push(P)}}else{if(g===0)return[];v.splice(g,1),g-=1,w-=1}else{b[h]=n(b[h],C);for(var I=0,k=N.length;I<k;I++){var _=N[I];b[_]=i(b[_],a(b[h],A[I]))}}}return v.map(ne=>new l({data:ne.map(j=>[j]),size:[p,1]}))}}),c2="matAlgo08xS0Sid",f2=["typed","equalScalar"],Fs=L(c2,f2,r=>{var{typed:e,equalScalar:t}=r;return function(a,i,o){var l=a._values,u=a._index,s=a._ptr,c=a._size,f=a._datatype||a._data===void 0?a._datatype:a.getDataType(),m=i._values,v=i._index,p=i._ptr,d=i._size,y=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(c.length!==d.length)throw new ur(c.length,d.length);if(c[0]!==d[0]||c[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+d+")");if(!l||!m)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var x=c[0],D=c[1],h,w=t,g=0,b=o;typeof f=="string"&&f===y&&f!=="mixed"&&(h=f,w=e.find(t,[h,h]),g=e.convert(0,h),b=e.find(o,[h,h]));for(var A=[],N=[],E=[],S=[],C=[],M,O,I,k,_=0;_<D;_++){E[_]=N.length;var P=_+1;for(O=s[_],I=s[_+1],M=O;M<I;M++)k=u[M],C[k]=P,S[k]=l[M],N.push(k);for(O=p[_],I=p[_+1],M=O;M<I;M++)k=v[M],C[k]===P&&(S[k]=b(S[k],m[M]));for(M=E[_];M<N.length;){k=N[M];var V=S[k];w(V,g)?N.splice(M,1):(A.push(V),M++)}}return E[D]=N.length,a.createSparseMatrix({values:A,index:N,ptr:E,size:[x,D],datatype:f===a._datatype&&y===i._datatype?h:void 0})}}),Os=L("useMatrixForArrayScalar",["typed","matrix"],r=>{var{typed:e,matrix:t}=r;return{"Array, number":e.referTo("DenseMatrix, number",n=>(a,i)=>n(t(a),i).valueOf()),"Array, BigNumber":e.referTo("DenseMatrix, BigNumber",n=>(a,i)=>n(t(a),i).valueOf()),"number, Array":e.referTo("number, DenseMatrix",n=>(a,i)=>n(a,t(i)).valueOf()),"BigNumber, Array":e.referTo("BigNumber, DenseMatrix",n=>(a,i)=>n(a,t(i)).valueOf())}}),ev="leftShift",m2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],v2=L(ev,m2,r=>{var{typed:e,matrix:t,equalScalar:n,zeros:a,DenseMatrix:i,concat:o}=r,l=In({typed:e}),u=Jt({typed:e,equalScalar:n}),s=Fs({typed:e,equalScalar:n}),c=Kn({typed:e,DenseMatrix:i}),f=nt({typed:e,equalScalar:n}),m=Ut({typed:e}),v=Tr({typed:e,matrix:t,concat:o}),p=Os({typed:e,matrix:t});return e(ev,{"number, number":mc,"BigNumber, BigNumber":Ow,"bigint, bigint":(d,y)=>d<<y,"SparseMatrix, number | BigNumber":e.referToSelf(d=>(y,x)=>n(x,0)?y.clone():f(y,x,d,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(d=>(y,x)=>n(x,0)?y.clone():m(y,x,d,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(d=>(y,x)=>n(y,0)?a(x.size(),x.storage()):c(x,y,d,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(d=>(y,x)=>n(y,0)?a(x.size(),x.storage()):m(x,y,d,!0))},p,v({SS:s,DS:l,SD:u}))}),rv="rightArithShift",p2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],d2=L(rv,p2,r=>{var{typed:e,matrix:t,equalScalar:n,zeros:a,DenseMatrix:i,concat:o}=r,l=In({typed:e}),u=Jt({typed:e,equalScalar:n}),s=Fs({typed:e,equalScalar:n}),c=Kn({typed:e,DenseMatrix:i}),f=nt({typed:e,equalScalar:n}),m=Ut({typed:e}),v=Tr({typed:e,matrix:t,concat:o}),p=Os({typed:e,matrix:t});return e(rv,{"number, number":vc,"BigNumber, BigNumber":Bw,"bigint, bigint":(d,y)=>d>>y,"SparseMatrix, number | BigNumber":e.referToSelf(d=>(y,x)=>n(x,0)?y.clone():f(y,x,d,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(d=>(y,x)=>n(x,0)?y.clone():m(y,x,d,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(d=>(y,x)=>n(y,0)?a(x.size(),x.storage()):c(x,y,d,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(d=>(y,x)=>n(y,0)?a(x.size(),x.storage()):m(x,y,d,!0))},p,v({SS:s,DS:l,SD:u}))}),tv="rightLogShift",h2=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],g2=L(tv,h2,r=>{var{typed:e,matrix:t,equalScalar:n,zeros:a,DenseMatrix:i,concat:o}=r,l=In({typed:e}),u=Jt({typed:e,equalScalar:n}),s=Fs({typed:e,equalScalar:n}),c=Kn({typed:e,DenseMatrix:i}),f=nt({typed:e,equalScalar:n}),m=Ut({typed:e}),v=Tr({typed:e,matrix:t,concat:o}),p=Os({typed:e,matrix:t});return e(tv,{"number, number":pc,"SparseMatrix, number | BigNumber":e.referToSelf(d=>(y,x)=>n(x,0)?y.clone():f(y,x,d,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(d=>(y,x)=>n(x,0)?y.clone():m(y,x,d,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(d=>(y,x)=>n(y,0)?a(x.size(),x.storage()):c(x,y,d,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(d=>(y,x)=>n(y,0)?a(x.size(),x.storage()):m(x,y,d,!0))},p,v({SS:s,DS:l,SD:u}))}),nv="and",y2=["typed","matrix","equalScalar","zeros","not","concat"],av=L(nv,y2,r=>{var{typed:e,matrix:t,equalScalar:n,zeros:a,not:i,concat:o}=r,l=Jt({typed:e,equalScalar:n}),u=oo({typed:e,equalScalar:n}),s=nt({typed:e,equalScalar:n}),c=Ut({typed:e}),f=Tr({typed:e,matrix:t,concat:o});return e(nv,{"number, number":ys,"Complex, Complex":function(v,p){return(v.re!==0||v.im!==0)&&(p.re!==0||p.im!==0)},"BigNumber, BigNumber":function(v,p){return!v.isZero()&&!p.isZero()&&!v.isNaN()&&!p.isNaN()},"bigint, bigint":ys,"Unit, Unit":e.referToSelf(m=>(v,p)=>m(v.value||0,p.value||0)),"SparseMatrix, any":e.referToSelf(m=>(v,p)=>i(p)?a(v.size(),v.storage()):s(v,p,m,!1)),"DenseMatrix, any":e.referToSelf(m=>(v,p)=>i(p)?a(v.size(),v.storage()):c(v,p,m,!1)),"any, SparseMatrix":e.referToSelf(m=>(v,p)=>i(v)?a(v.size(),v.storage()):s(p,v,m,!0)),"any, DenseMatrix":e.referToSelf(m=>(v,p)=>i(v)?a(v.size(),v.storage()):c(p,v,m,!0)),"Array, any":e.referToSelf(m=>(v,p)=>m(t(v),p).valueOf()),"any, Array":e.referToSelf(m=>(v,p)=>m(v,t(p)).valueOf())},f({SS:u,DS:l}))}),uo="compare",b2=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],x2=L(uo,b2,r=>{var{typed:e,config:t,equalScalar:n,matrix:a,BigNumber:i,Fraction:o,DenseMatrix:l,concat:u}=r,s=ct({typed:e}),c=io({typed:e,equalScalar:n}),f=Wr({typed:e,DenseMatrix:l}),m=Tr({typed:e,matrix:a,concat:u}),v=Ta({typed:e});return e(uo,w2({typed:e,config:t}),{"boolean, boolean":function(d,y){return d===y?0:d>y?1:-1},"BigNumber, BigNumber":function(d,y){return zt(d,y,t.relTol,t.absTol)?new i(0):new i(d.cmp(y))},"bigint, bigint":function(d,y){return d===y?0n:d>y?1n:-1n},"Fraction, Fraction":function(d,y){return new o(d.compare(y))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},v,m({SS:c,DS:s,Ss:f}))}),w2=L(uo,["typed","config"],r=>{var{typed:e,config:t}=r;return e(uo,{"number, number":function(a,i){return Xr(a,i,t.relTol,t.absTol)?0:a>i?1:-1}})}),ra=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Bs(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function D2(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var a=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:function(){return r[n]}})}),t}var N2=function r(e,t){var n=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,a=/(^[ ]*|[ ]*$)/g,i=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,o=/^0x[0-9a-f]+$/i,l=/^0/,u=function(h){return r.insensitive&&(""+h).toLowerCase()||""+h},s=u(e).replace(a,"")||"",c=u(t).replace(a,"")||"",f=s.replace(n,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),m=c.replace(n,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),v=parseInt(s.match(o),16)||f.length!==1&&s.match(i)&&Date.parse(s),p=parseInt(c.match(o),16)||v&&c.match(i)&&Date.parse(c)||null,d,y;if(p){if(v<p)return-1;if(v>p)return 1}for(var x=0,D=Math.max(f.length,m.length);x<D;x++){if(d=!(f[x]||"").match(l)&&parseFloat(f[x])||f[x]||0,y=!(m[x]||"").match(l)&&parseFloat(m[x])||m[x]||0,isNaN(d)!==isNaN(y))return isNaN(d)?1:-1;if(typeof d!=typeof y&&(d+="",y+=""),d<y)return-1;if(d>y)return 1}return 0};const Ba=Bs(N2);var iv="compareNatural",E2=["typed","compare"],A2=L(iv,E2,r=>{var{typed:e,compare:t}=r,n=t.signatures["boolean,boolean"];return e(iv,{"any, any":a});function a(u,s){var c=Sr(u),f=Sr(s),m;if((c==="number"||c==="BigNumber"||c==="Fraction"||c==="bigint")&&(f==="number"||f==="BigNumber"||f==="Fraction"||f==="bigint"))return m=t(u,s),m.toString()!=="0"?m>0?1:-1:Ba(c,f);var v=["Array","DenseMatrix","SparseMatrix"];if(v.includes(c)||v.includes(f))return m=i(a,u,s),m!==0?m:Ba(c,f);if(c!==f)return Ba(c,f);if(c==="Complex")return S2(u,s);if(c==="Unit")return u.equalBase(s)?a(u.value,s.value):o(a,u.formatUnits(),s.formatUnits());if(c==="boolean")return n(u,s);if(c==="string")return Ba(u,s);if(c==="Object")return l(a,u,s);if(c==="null"||c==="undefined")return 0;throw new TypeError('Unsupported type of value "'+c+'"')}function i(u,s,c){return Yn(s)&&Yn(c)?o(u,s.toJSON().values,c.toJSON().values):Yn(s)?i(u,s.toArray(),c):Yn(c)?i(u,s,c.toArray()):_i(s)?i(u,s.toJSON().data,c):_i(c)?i(u,s,c.toJSON().data):Array.isArray(s)?Array.isArray(c)?o(u,s,c):i(u,s,[c]):i(u,[s],c)}function o(u,s,c){for(var f=0,m=Math.min(s.length,c.length);f<m;f++){var v=u(s[f],c[f]);if(v!==0)return v}return s.length>c.length?1:s.length<c.length?-1:0}function l(u,s,c){var f=Object.keys(s),m=Object.keys(c);f.sort(Ba),m.sort(Ba);var v=o(u,f,m);if(v!==0)return v;for(var p=0;p<f.length;p++){var d=u(s[f[p]],c[m[p]]);if(d!==0)return d}return 0}});function S2(r,e){return r.re>e.re?1:r.re<e.re?-1:r.im>e.im?1:r.im<e.im?-1:0}var ov="compareText",C2=["typed","matrix","concat"];us.signature="any, any";var M2=L(ov,C2,r=>{var{typed:e,matrix:t,concat:n}=r,a=Tr({typed:e,matrix:t,concat:n});return e(ov,us,a({elop:us,Ds:!0}))}),lo="equal",_2=["typed","matrix","equalScalar","DenseMatrix","SparseMatrix"],T2=L(lo,_2,r=>{var{typed:e,matrix:t,equalScalar:n,DenseMatrix:a,concat:i,SparseMatrix:o}=r,l=ct({typed:e}),u=nn({typed:e,SparseMatrix:o}),s=Wr({typed:e,DenseMatrix:a}),c=Tr({typed:e,matrix:t});return e(lo,F2({typed:e,equalScalar:n}),c({elop:n,SS:u,DS:l,Ss:s}))}),F2=L(lo,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e(lo,{"any, any":function(a,i){return a===null?i===null:i===null?a===null:a===void 0?i===void 0:i===void 0?a===void 0:t(a,i)}})}),sv="equalText",O2=["typed","compareText","isZero"],B2=L(sv,O2,r=>{var{typed:e,compareText:t,isZero:n}=r;return e(sv,{"any, any":function(i,o){return n(t(i,o))}})}),co="smaller",R2=["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],I2=L(co,R2,r=>{var{typed:e,config:t,bignumber:n,matrix:a,DenseMatrix:i,concat:o,SparseMatrix:l}=r,u=ct({typed:e}),s=nn({typed:e,SparseMatrix:l}),c=Wr({typed:e,DenseMatrix:i}),f=Tr({typed:e,matrix:a,concat:o}),m=Ta({typed:e});function v(p,d){return p.lt(d)&&!zt(p,d,t.relTol,t.absTol)}return e(co,P2({typed:e,config:t}),{"boolean, boolean":(p,d)=>p<d,"BigNumber, BigNumber":v,"bigint, bigint":(p,d)=>p<d,"Fraction, Fraction":(p,d)=>p.compare(d)===-1,"Fraction, BigNumber":function(d,y){return v(n(d),y)},"BigNumber, Fraction":function(d,y){return v(d,n(y))},"Complex, Complex":function(d,y){throw new TypeError("No ordering relation is defined for complex numbers")}},m,f({SS:s,DS:u,Ss:c}))}),P2=L(co,["typed","config"],r=>{var{typed:e,config:t}=r;return e(co,{"number, number":function(a,i){return a<i&&!Xr(a,i,t.relTol,t.absTol)}})}),fo="smallerEq",$2=["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],q2=L(fo,$2,r=>{var{typed:e,config:t,matrix:n,DenseMatrix:a,concat:i,SparseMatrix:o}=r,l=ct({typed:e}),u=nn({typed:e,SparseMatrix:o}),s=Wr({typed:e,DenseMatrix:a}),c=Tr({typed:e,matrix:n,concat:i}),f=Ta({typed:e});return e(fo,z2({typed:e,config:t}),{"boolean, boolean":(m,v)=>m<=v,"BigNumber, BigNumber":function(v,p){return v.lte(p)||zt(v,p,t.relTol,t.absTol)},"bigint, bigint":(m,v)=>m<=v,"Fraction, Fraction":(m,v)=>m.compare(v)!==1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},f,c({SS:u,DS:l,Ss:s}))}),z2=L(fo,["typed","config"],r=>{var{typed:e,config:t}=r;return e(fo,{"number, number":function(a,i){return a<=i||Xr(a,i,t.relTol,t.absTol)}})}),mo="larger",U2=["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],L2=L(mo,U2,r=>{var{typed:e,config:t,bignumber:n,matrix:a,DenseMatrix:i,concat:o,SparseMatrix:l}=r,u=ct({typed:e}),s=nn({typed:e,SparseMatrix:l}),c=Wr({typed:e,DenseMatrix:i}),f=Tr({typed:e,matrix:a,concat:o}),m=Ta({typed:e});function v(p,d){return p.gt(d)&&!zt(p,d,t.relTol,t.absTol)}return e(mo,k2({typed:e,config:t}),{"boolean, boolean":(p,d)=>p>d,"BigNumber, BigNumber":v,"bigint, bigint":(p,d)=>p>d,"Fraction, Fraction":(p,d)=>p.compare(d)===1,"Fraction, BigNumber":function(d,y){return v(n(d),y)},"BigNumber, Fraction":function(d,y){return v(d,n(y))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},m,f({SS:s,DS:u,Ss:c}))}),k2=L(mo,["typed","config"],r=>{var{typed:e,config:t}=r;return e(mo,{"number, number":function(a,i){return a>i&&!Xr(a,i,t.relTol,t.absTol)}})}),vo="largerEq",V2=["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],G2=L(vo,V2,r=>{var{typed:e,config:t,matrix:n,DenseMatrix:a,concat:i,SparseMatrix:o}=r,l=ct({typed:e}),u=nn({typed:e,SparseMatrix:o}),s=Wr({typed:e,DenseMatrix:a}),c=Tr({typed:e,matrix:n,concat:i}),f=Ta({typed:e});return e(vo,H2({typed:e,config:t}),{"boolean, boolean":(m,v)=>m>=v,"BigNumber, BigNumber":function(v,p){return v.gte(p)||zt(v,p,t.relTol,t.absTol)},"bigint, bigint":function(v,p){return v>=p},"Fraction, Fraction":(m,v)=>m.compare(v)!==-1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},f,c({SS:u,DS:l,Ss:s}))}),H2=L(vo,["typed","config"],r=>{var{typed:e,config:t}=r;return e(vo,{"number, number":function(a,i){return a>=i||Xr(a,i,t.relTol,t.absTol)}})}),uv="deepEqual",W2=["typed","equal"],Y2=L(uv,W2,r=>{var{typed:e,equal:t}=r;return e(uv,{"any, any":function(i,o){return n(i.valueOf(),o.valueOf())}});function n(a,i){if(Array.isArray(a))if(Array.isArray(i)){var o=a.length;if(o!==i.length)return!1;for(var l=0;l<o;l++)if(!n(a[l],i[l]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:t(a,i)}}),po="unequal",Z2=["typed","config","equalScalar","matrix","DenseMatrix","concat","SparseMatrix"],J2=L(po,Z2,r=>{var{typed:e,config:t,equalScalar:n,matrix:a,DenseMatrix:i,concat:o,SparseMatrix:l}=r,u=ct({typed:e}),s=nn({typed:e,SparseMatrix:l}),c=Wr({typed:e,DenseMatrix:i}),f=Tr({typed:e,matrix:a,concat:o});return e(po,j2({typed:e,equalScalar:n}),f({elop:m,SS:s,DS:u,Ss:c}));function m(v,p){return!n(v,p)}}),j2=L(po,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e(po,{"any, any":function(a,i){return a===null?i!==null:i===null?a!==null:a===void 0?i!==void 0:i===void 0?a!==void 0:!t(a,i)}})}),lv="partitionSelect",X2=["typed","isNumeric","isNaN","compare"],Q2=L(lv,X2,r=>{var{typed:e,isNumeric:t,isNaN:n,compare:a}=r,i=a,o=(s,c)=>-a(s,c);return e(lv,{"Array | Matrix, number":function(c,f){return l(c,f,i)},"Array | Matrix, number, string":function(c,f,m){if(m==="asc")return l(c,f,i);if(m==="desc")return l(c,f,o);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":l});function l(s,c,f){if(!Ue(c)||c<0)throw new Error("k must be a non-negative integer");if(Je(s)){var m=s.size();if(m.length>1)throw new Error("Only one dimensional matrices supported");return u(s.valueOf(),c,f)}if(Array.isArray(s))return u(s,c,f)}function u(s,c,f){if(c>=s.length)throw new Error("k out of bounds");for(var m=0;m<s.length;m++)if(t(s[m])&&n(s[m]))return s[m];for(var v=0,p=s.length-1;v<p;){for(var d=v,y=p,x=s[Math.floor(Math.random()*(p-v+1))+v];d<y;)if(f(s[d],x)>=0){var D=s[y];s[y]=s[d],s[d]=D,--y}else++d;f(s[d],x)>0&&--d,c<=d?p=d:v=d+1}return s[c]}}),cv="sort",K2=["typed","matrix","compare","compareNatural"],eE=L(cv,K2,r=>{var{typed:e,matrix:t,compare:n,compareNatural:a}=r,i=n,o=(c,f)=>-n(c,f);return e(cv,{Array:function(f){return u(f),f.sort(i)},Matrix:function(f){return s(f),t(f.toArray().sort(i),f.storage())},"Array, function":function(f,m){return u(f),f.sort(m)},"Matrix, function":function(f,m){return s(f),t(f.toArray().sort(m),f.storage())},"Array, string":function(f,m){return u(f),f.sort(l(m))},"Matrix, string":function(f,m){return s(f),t(f.toArray().sort(l(m)),f.storage())}});function l(c){if(c==="asc")return i;if(c==="desc")return o;if(c==="natural")return a;throw new Error('String "asc", "desc", or "natural" expected')}function u(c){if(rr(c).length!==1)throw new Error("One dimensional array expected")}function s(c){if(c.size().length!==1)throw new Error("One dimensional matrix expected")}}),fv="max",rE=["typed","config","numeric","larger","isNaN"],mv=L(fv,rE,r=>{var{typed:e,config:t,numeric:n,larger:a,isNaN:i}=r;return e(fv,{"Array | Matrix":l,"Array | Matrix, number | BigNumber":function(s,c){return Qi(s,c.valueOf(),o)},"...":function(s){if(Sa(s))throw new TypeError("Scalar values expected in function max");return l(s)}});function o(u,s){try{return a(u,s)?u:s}catch(c){throw dt(c,"max",s)}}function l(u){var s;if(Rn(u,function(c){try{(i(c)||s===void 0||a(c,s))&&(s=c)}catch(f){throw dt(f,"max",c)}}),s===void 0)throw new Error("Cannot calculate max of an empty array");return typeof s=="string"&&(s=n(s,An(s,t))),s}}),vv="min",tE=["typed","config","numeric","smaller","isNaN"],pv=L(vv,tE,r=>{var{typed:e,config:t,numeric:n,smaller:a,isNaN:i}=r;return e(vv,{"Array | Matrix":l,"Array | Matrix, number | BigNumber":function(s,c){return Qi(s,c.valueOf(),o)},"...":function(s){if(Sa(s))throw new TypeError("Scalar values expected in function min");return l(s)}});function o(u,s){try{return a(u,s)?u:s}catch(c){throw dt(c,"min",s)}}function l(u){var s;if(Rn(u,function(c){try{(i(c)||s===void 0||a(c,s))&&(s=c)}catch(f){throw dt(f,"min",c)}}),s===void 0)throw new Error("Cannot calculate min of an empty array");return typeof s=="string"&&(s=n(s,An(s,t))),s}}),nE="ImmutableDenseMatrix",aE=["smaller","DenseMatrix"],iE=L(nE,aE,r=>{var{smaller:e,DenseMatrix:t}=r;function n(a,i){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(i&&!$r(i))throw new Error("Invalid datatype: "+i);if(Je(a)||Ar(a)){var o=new t(a,i);this._data=o._data,this._size=o._size,this._datatype=o._datatype,this._min=null,this._max=null}else if(a&&Ar(a.data)&&Ar(a.size))this._data=a.data,this._size=a.size,this._datatype=a.datatype,this._min=typeof a.min<"u"?a.min:null,this._max=typeof a.max<"u"?a.max:null;else{if(a)throw new TypeError("Unsupported type of data ("+Sr(a)+")");this._data=[],this._size=[0],this._datatype=i,this._min=null,this._max=null}}return n.prototype=new t,n.prototype.type="ImmutableDenseMatrix",n.prototype.isImmutableDenseMatrix=!0,n.prototype.subset=function(a){switch(arguments.length){case 1:{var i=t.prototype.subset.call(this,a);return Je(i)?new n({data:i._data,size:i._size,datatype:i._datatype}):i}case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},n.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},n.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},n.prototype.clone=function(){return new n({data:er(this._data),size:er(this._size),datatype:this._datatype})},n.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.fromJSON=function(a){return new n(a)},n.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},n.prototype.min=function(){if(this._min===null){var a=null;this.forEach(function(i){(a===null||e(i,a))&&(a=i)}),this._min=a!==null?a:void 0}return this._min},n.prototype.max=function(){if(this._max===null){var a=null;this.forEach(function(i){(a===null||e(a,i))&&(a=i)}),this._max=a!==null?a:void 0}return this._max},n},{isClass:!0}),oE="Index",sE=["ImmutableDenseMatrix","getMatrixDataType"],uE=L(oE,sE,r=>{var{ImmutableDenseMatrix:e,getMatrixDataType:t}=r;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._sourceSize=[],this._isScalar=!0;for(var i=0,o=arguments.length;i<o;i++){var l=i<0||arguments.length<=i?void 0:arguments[i],u=Ar(l),s=Je(l),c=typeof l,f=null;if(jo(l))this._dimensions.push(l),this._isScalar=!1;else if(u||s){var m=void 0;this._isScalar=!1,t(l)==="boolean"?(u&&(m=a(dv(l).valueOf())),s&&(m=a(dv(l._data).valueOf())),f=l.valueOf().length):m=a(l.valueOf()),this._dimensions.push(m)}else if(c==="number")this._dimensions.push(l);else if(c==="bigint")this._dimensions.push(Number(l));else if(c==="string")this._dimensions.push(l);else throw new TypeError("Dimension must be an Array, Matrix, number, bigint, string, or Range");this._sourceSize.push(f)}}n.prototype.type="Index",n.prototype.isIndex=!0;function a(i){for(var o=0,l=i.length;o<l;o++)if(!Ye(i[o])||!Ue(i[o]))throw new TypeError("Index parameters must be positive integer numbers");var u=new e;return u._data=i,u._size=[i.length],u}return n.prototype.clone=function(){var i=new n;return i._dimensions=er(this._dimensions),i._isScalar=this._isScalar,i._sourceSize=this._sourceSize,i},n.create=function(i){var o=new n;return n.apply(o,i),o},n.prototype.size=function(){for(var i=[],o=0,l=this._dimensions.length;o<l;o++){var u=this._dimensions[o];i[o]=$r(u)||Ye(u)?1:u.size()[0]}return i},n.prototype.max=function(){for(var i=[],o=0,l=this._dimensions.length;o<l;o++){var u=this._dimensions[o];i[o]=$r(u)||Ye(u)?u:u.max()}return i},n.prototype.min=function(){for(var i=[],o=0,l=this._dimensions.length;o<l;o++){var u=this._dimensions[o];i[o]=$r(u)||Ye(u)?u:u.min()}return i},n.prototype.forEach=function(i){for(var o=0,l=this._dimensions.length;o<l;o++)i(this._dimensions[o],o,this)},n.prototype.dimension=function(i){var o;return Ye(i)&&(o=this._dimensions[i])!==null&&o!==void 0?o:null},n.prototype.isObjectProperty=function(){return this._dimensions.length===1&&$r(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 i=[],o=0,l=this._dimensions.length;o<l;o++){var u=this._dimensions[o];i.push($r(u)||Ye(u)?u:u.toArray())}return i},n.prototype.valueOf=n.prototype.toArray,n.prototype.toString=function(){for(var i=[],o=0,l=this._dimensions.length;o<l;o++){var u=this._dimensions[o];$r(u)?i.push(JSON.stringify(u)):i.push(u.toString())}return"["+i.join(", ")+"]"},n.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},n.fromJSON=function(i){return n.create(i.dimensions)},n},{isClass:!0});function dv(r){var e=[];return r.forEach((t,n)=>{t&&e.push(n)}),e}var lE="FibonacciHeap",cE=["smaller","larger"],fE=L(lE,cE,r=>{var{smaller:e,larger:t}=r,n=1/Math.log((1+Math.sqrt(5))/2);function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}a.prototype.type="FibonacciHeap",a.prototype.isFibonacciHeap=!0,a.prototype.insert=function(c,f){var m={key:c,value:f,degree:0};if(this._minimum){var v=this._minimum;m.left=v,m.right=v.right,v.right=m,m.right.left=m,e(c,v.key)&&(this._minimum=m)}else m.left=m,m.right=m,this._minimum=m;return this._size++,m},a.prototype.size=function(){return this._size},a.prototype.clear=function(){this._minimum=null,this._size=0},a.prototype.isEmpty=function(){return this._size===0},a.prototype.extractMinimum=function(){var c=this._minimum;if(c===null)return c;for(var f=this._minimum,m=c.degree,v=c.child;m>0;){var p=v.right;v.left.right=v.right,v.right.left=v.left,v.left=f,v.right=f.right,f.right=v,v.right.left=v,v.parent=null,v=p,m--}return c.left.right=c.right,c.right.left=c.left,c===c.right?f=null:(f=c.right,f=s(f,this._size)),this._size--,this._minimum=f,c},a.prototype.remove=function(c){this._minimum=i(this._minimum,c,-1),this.extractMinimum()};function i(c,f,m){f.key=m;var v=f.parent;return v&&e(f.key,v.key)&&(o(c,f,v),l(c,v)),e(f.key,c.key)&&(c=f),c}function o(c,f,m){f.left.right=f.right,f.right.left=f.left,m.degree--,m.child===f&&(m.child=f.right),m.degree===0&&(m.child=null),f.left=c,f.right=c.right,c.right=f,f.right.left=f,f.parent=null,f.mark=!1}function l(c,f){var m=f.parent;m&&(f.mark?(o(c,f,m),l(m)):f.mark=!0)}var u=function(f,m){f.left.right=f.right,f.right.left=f.left,f.parent=m,m.child?(f.left=m.child,f.right=m.child.right,m.child.right=f,f.right.left=f):(m.child=f,f.right=f,f.left=f),m.degree++,f.mark=!1};function s(c,f){var m=Math.floor(Math.log(f)*n)+1,v=new Array(m),p=0,d=c;if(d)for(p++,d=d.right;d!==c;)p++,d=d.right;for(var y;p>0;){for(var x=d.degree,D=d.right;y=v[x],!!y;){if(t(d.key,y.key)){var h=y;y=d,d=h}u(y,d),v[x]=null,x++}v[x]=d,d=D,p--}c=null;for(var w=0;w<m;w++)y=v[w],y&&(c?(y.left.right=y.right,y.right.left=y.left,y.left=c,y.right=c.right,c.right=y,y.right.left=y,e(y.key,c.key)&&(c=y)):c=y);return c}return a},{isClass:!0}),mE="Spa",vE=["addScalar","equalScalar","FibonacciHeap"],pE=L(mE,vE,r=>{var{addScalar:e,equalScalar:t,FibonacciHeap:n}=r;function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new n}return a.prototype.type="Spa",a.prototype.isSpa=!0,a.prototype.set=function(i,o){if(this._values[i])this._values[i].value=o;else{var l=this._heap.insert(i,o);this._values[i]=l}},a.prototype.get=function(i){var o=this._values[i];return o?o.value:0},a.prototype.accumulate=function(i,o){var l=this._values[i];l?l.value=e(l.value,o):(l=this._heap.insert(i,o),this._values[i]=l)},a.prototype.forEach=function(i,o,l){var u=this._heap,s=this._values,c=[],f=u.extractMinimum();for(f&&c.push(f);f&&f.key<=o;)f.key>=i&&(t(f.value,0)||l(f.key,f.value,this)),f=u.extractMinimum(),f&&c.push(f);for(var m=0;m<c.length;m++){var v=c[m];f=u.insert(v.key,v.value),s[f.key]=f}},a.prototype.swap=function(i,o){var l=this._values[i],u=this._values[o];if(!l&&u)l=this._heap.insert(i,u.value),this._heap.remove(u),this._values[i]=l,this._values[o]=void 0;else if(l&&!u)u=this._heap.insert(o,l.value),this._heap.remove(l),this._values[o]=u,this._values[i]=void 0;else if(l&&u){var s=l.value;l.value=u.value,u.value=s}},a},{isClass:!0});function dE(r){var e=0,t=1,n=Object.create(null),a=Object.create(null),i=0,o=function(u){var s=a[u];if(s&&(delete n[s],delete a[u],--e,t===s)){if(!e){i=0,t=1;return}for(;!Object.prototype.hasOwnProperty.call(n,++t););}};return r=Math.abs(r),{hit:function(u){var s=a[u],c=++i;if(n[c]=u,a[u]=c,!s)return++e,e<=r?void 0:(u=n[t],o(u),u);if(delete n[s],t===s)for(;!Object.prototype.hasOwnProperty.call(n,++t););},delete:o,clear:function(){e=i=0,t=1,n=Object.create(null),a=Object.create(null)}}}function li(r){var{hasher:e,limit:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return t=t??Number.POSITIVE_INFINITY,e=e??JSON.stringify,function n(){typeof n.cache!="object"&&(n.cache={values:new Map,lru:dE(t||Number.POSITIVE_INFINITY)});for(var a=[],i=0;i<arguments.length;i++)a[i]=arguments[i];var o=e(a);if(n.cache.values.has(o))return n.cache.lru.hit(o),n.cache.values.get(o);var l=r.apply(r,a);return n.cache.values.set(o,l),n.cache.values.delete(n.cache.lru.hit(o)),l}}var hE=li(function(r){return new r(1).exp()},{hasher:ho}),gE=li(function(r){return new r(1).plus(new r(5).sqrt()).div(2)},{hasher:ho}),Rs=li(function(r){return r.acos(-1)},{hasher:ho}),yE=li(function(r){return Rs(r).times(2)},{hasher:ho});function ho(r){return r[0].precision}function hv(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function Is(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?hv(Object(t),!0).forEach(function(n){Vr(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):hv(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}var bE="Unit",xE=["?on","config","addScalar","subtractScalar","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","number","Complex","BigNumber","Fraction"],wE=L(bE,xE,r=>{var{on:e,config:t,addScalar:n,subtractScalar:a,multiplyScalar:i,divideScalar:o,pow:l,abs:u,fix:s,round:c,equal:f,isNumeric:m,format:v,number:p,Complex:d,BigNumber:y,Fraction:x}=r,D=p,h=!1,w=!0;function g(G,ee){if(!(this instanceof g))throw new Error("Constructor must be called with the new operator");if(!(G==null||m(G)||ln(G)))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(this.fixPrefix=h,this.skipAutomaticSimplification=w,ee===void 0)this.units=[],this.dimensions=U.map(H=>0);else if(typeof ee=="string"){var R=g.parse(ee);this.units=R.units,this.dimensions=R.dimensions}else if(Ct(ee)&&ee.value===null)this.fixPrefix=ee.fixPrefix,this.skipAutomaticSimplification=ee.skipAutomaticSimplification,this.dimensions=ee.dimensions.slice(0),this.units=ee.units.map(H=>zr({},H));else throw new TypeError("Second parameter in Unit constructor must be a string or valueless Unit");this.value=this._normalize(G)}Object.defineProperty(g,"name",{value:"Unit"}),g.prototype.constructor=g,g.prototype.type="Unit",g.prototype.isUnit=!0;var b,A,N;function E(){for(;N===" "||N===" ";)M()}function S(G){return G>="0"&&G<="9"||G==="."}function C(G){return G>="0"&&G<="9"}function M(){A++,N=b.charAt(A)}function O(G){A=G,N=b.charAt(A)}function I(){var G="",ee=A;if(N==="+"?M():N==="-"&&(G+=N,M()),!S(N))return O(ee),null;if(N==="."){if(G+=N,M(),!C(N))return O(ee),null}else{for(;C(N);)G+=N,M();N==="."&&(G+=N,M())}for(;C(N);)G+=N,M();if(N==="E"||N==="e"){var R="",H=A;if(R+=N,M(),(N==="+"||N==="-")&&(R+=N,M()),!C(N))return O(H),G;for(G=G+R;C(N);)G+=N,M()}return G}function k(){for(var G="";C(N)||g.isValidAlpha(N);)G+=N,M();var ee=G.charAt(0);return g.isValidAlpha(ee)?G:null}function _(G){return N===G?(M(),G):null}g.parse=function(G,ee){if(ee=ee||{},b=G,A=-1,N="",typeof b!="string")throw new TypeError("Invalid argument in Unit.parse, string expected");var R=new g;R.units=[];var H=1,Q=!1;M(),E();var ie=I(),ue=null;if(ie){if(t.number==="BigNumber")ue=new y(ie);else if(t.number==="Fraction")try{ue=new x(ie)}catch{ue=parseFloat(ie)}else ue=parseFloat(ie);E(),_("*")?(H=1,Q=!0):_("/")&&(H=-1,Q=!0)}for(var oe=[],we=1;;){for(E();N==="(";)oe.push(H),we*=H,H=1,M(),E();var xe=void 0;if(N){var Te=N;if(xe=k(),xe===null)throw new SyntaxError('Unexpected "'+Te+'" in "'+b+'" at index '+A.toString())}else break;var be=P(xe);if(be===null)throw new SyntaxError('Unit "'+xe+'" not found.');var ke=H*we;if(E(),_("^")){E();var fr=I();if(fr===null)throw new SyntaxError('In "'+G+'", "^" must be followed by a floating-point number');ke*=fr}R.units.push({unit:be.unit,prefix:be.prefix,power:ke});for(var hr=0;hr<U.length;hr++)R.dimensions[hr]+=(be.unit.dimensions[hr]||0)*ke;for(E();N===")";){if(oe.length===0)throw new SyntaxError('Unmatched ")" in "'+b+'" at index '+A.toString());we/=oe.pop(),M(),E()}if(Q=!1,_("*")?(H=1,Q=!0):_("/")?(H=-1,Q=!0):H=1,be.unit.base){var ir=be.unit.base.key;re.auto[ir]={unit:be.unit,prefix:be.prefix}}}if(E(),N)throw new SyntaxError('Could not parse: "'+G+'"');if(Q)throw new SyntaxError('Trailing characters: "'+G+'"');if(oe.length!==0)throw new SyntaxError('Unmatched "(" in "'+b+'"');if(R.units.length===0&&!ee.allowNoUnits)throw new SyntaxError('"'+G+'" contains no units');return R.value=ue!==void 0?R._normalize(ue):null,R},g.prototype.clone=function(){var G=new g;G.fixPrefix=this.fixPrefix,G.skipAutomaticSimplification=this.skipAutomaticSimplification,G.value=er(this.value),G.dimensions=this.dimensions.slice(0),G.units=[];for(var ee=0;ee<this.units.length;ee++){G.units[ee]={};for(var R in this.units[ee])$e(this.units[ee],R)&&(G.units[ee][R]=this.units[ee][R])}return G},g.prototype.valueType=function(){return Sr(this.value)},g.prototype._isDerived=function(){return this.units.length===0?!1:this.units.length>1||Math.abs(this.units[0].power-1)>1e-15},g.prototype._normalize=function(G){if(G==null||this.units.length===0)return G;for(var ee=G,R=g._getNumberConverter(Sr(G)),H=0;H<this.units.length;H++){var Q=R(this.units[H].unit.value),ie=R(this.units[H].prefix.value),ue=R(this.units[H].power);ee=i(ee,l(i(Q,ie),ue))}return ee},g.prototype._denormalize=function(G,ee){if(G==null||this.units.length===0)return G;for(var R=G,H=g._getNumberConverter(Sr(G)),Q=0;Q<this.units.length;Q++){var ie=H(this.units[Q].unit.value),ue=H(this.units[Q].prefix.value),oe=H(this.units[Q].power);R=o(R,l(i(ie,ue),oe))}return R};var P=li(G=>{if($e(z,G)){var ee=z[G],R=ee.prefixes[""];return{unit:ee,prefix:R}}for(var H in z)if($e(z,H)&&w1(G,H)){var Q=z[H],ie=G.length-H.length,ue=G.substring(0,ie),oe=$e(Q.prefixes,ue)?Q.prefixes[ue]:void 0;if(oe!==void 0)return{unit:Q,prefix:oe}}return null},{hasher:G=>G[0],limit:100});g.isValuelessUnit=function(G){return P(G)!==null},g.prototype.hasBase=function(G){if(typeof G=="string"&&(G=$[G]),!G)return!1;for(var ee=0;ee<U.length;ee++)if(Math.abs((this.dimensions[ee]||0)-(G.dimensions[ee]||0))>1e-12)return!1;return!0},g.prototype.equalBase=function(G){for(var ee=0;ee<U.length;ee++)if(Math.abs((this.dimensions[ee]||0)-(G.dimensions[ee]||0))>1e-12)return!1;return!0},g.prototype.equals=function(G){return this.equalBase(G)&&f(this.value,G.value)},g.prototype.multiply=function(G){for(var ee=this.clone(),R=Ct(G)?G:new g(G),H=0;H<U.length;H++)ee.dimensions[H]=(this.dimensions[H]||0)+(R.dimensions[H]||0);for(var Q=0;Q<R.units.length;Q++){var ie=Is({},R.units[Q]);ee.units.push(ie)}if(this.value!==null||R.value!==null){var ue=this.value===null?this._normalize(q(R.value)):this.value,oe=R.value===null?R._normalize(q(this.value)):R.value;ee.value=i(ue,oe)}else ee.value=null;return Ct(G)&&(ee.skipAutomaticSimplification=!1),V(ee)},g.prototype.divideInto=function(G){return new g(G).divide(this)},g.prototype.divide=function(G){for(var ee=this.clone(),R=Ct(G)?G:new g(G),H=0;H<U.length;H++)ee.dimensions[H]=(this.dimensions[H]||0)-(R.dimensions[H]||0);for(var Q=0;Q<R.units.length;Q++){var ie=Is(Is({},R.units[Q]),{},{power:-R.units[Q].power});ee.units.push(ie)}if(this.value!==null||R.value!==null){var ue=this.value===null?this._normalize(q(R.value)):this.value,oe=R.value===null?R._normalize(q(this.value)):R.value;ee.value=o(ue,oe)}else ee.value=null;return Ct(G)&&(ee.skipAutomaticSimplification=!1),V(ee)},g.prototype.pow=function(G){for(var ee=this.clone(),R=0;R<U.length;R++)ee.dimensions[R]=(this.dimensions[R]||0)*G;for(var H=0;H<ee.units.length;H++)ee.units[H].power*=G;return ee.value!==null?ee.value=l(ee.value,G):ee.value=null,ee.skipAutomaticSimplification=!1,V(ee)};function V(G){return G.equalBase($.NONE)&&G.value!==null&&!t.predictable?G.value:G}function q(G){var ee=g._getNumberConverter(Sr(G));return ee(1)}g.prototype.abs=function(){var G=this.clone();if(G.value!==null)if(G._isDerived()||G.units.length===0||G.units[0].unit.offset===0)G.value=u(G.value);else{var ee=G._numberConverter(),R=ee(G.units[0].unit.value),H=ee(G.units[0].unit.offset),Q=i(R,H);G.value=a(u(n(G.value,Q)),Q)}for(var ie in G.units)(G.units[ie].unit.name==="VA"||G.units[ie].unit.name==="VAR")&&(G.units[ie].unit=z.W);return G},g.prototype.to=function(G){var ee=this.value===null?this._normalize(1):this.value,R;if(typeof G=="string")R=g.parse(G);else if(Ct(G))R=G.clone();else throw new Error("String or Unit expected as parameter");if(!this.equalBase(R))throw new Error("Units do not match ('".concat(R.toString(),"' != '").concat(this.toString(),"')"));if(R.value!==null)throw new Error("Cannot convert to a unit with a value");if(this.value===null||this._isDerived()||this.units.length===0||R.units.length===0||this.units[0].unit.offset===R.units[0].unit.offset)R.value=er(ee);else{var H=g._getNumberConverter(Sr(ee)),Q=this.units[0].unit.value,ie=this.units[0].unit.offset,ue=i(Q,ie),oe=R.units[0].unit.value,we=R.units[0].unit.offset,xe=i(oe,we);R.value=n(ee,H(a(ue,xe)))}return R.fixPrefix=!0,R.skipAutomaticSimplification=!0,R},g.prototype.toNumber=function(G){return D(this.toNumeric(G))},g.prototype.toNumeric=function(G){var ee;return G?ee=this.to(G):ee=this.clone(),ee._isDerived()||ee.units.length===0?ee._denormalize(ee.value):ee._denormalize(ee.value,ee.units[0].prefix.value)},g.prototype.toString=function(){return this.format()},g.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.units.length>0?this.formatUnits():null,fixPrefix:this.fixPrefix,skipSimp:this.skipAutomaticSimplification}},g.fromJSON=function(G){var ee,R,H,Q=new g(G.value,(ee=G.unit)!==null&&ee!==void 0?ee:void 0);return Q.fixPrefix=(R=G.fixPrefix)!==null&&R!==void 0?R:h,Q.skipAutomaticSimplification=(H=G.skipSimp)!==null&&H!==void 0?H:w,Q},g.prototype.valueOf=g.prototype.toString,g.prototype.simplify=function(){var G=this.clone(),ee=[],R;for(var H in pe)if($e(pe,H)&&G.hasBase($[H])){R=H;break}if(R==="NONE")G.units=[];else{var Q;if(R&&$e(pe,R)&&(Q=pe[R]),Q)G.units=[{unit:Q.unit,prefix:Q.prefix,power:1}];else{for(var ie=!1,ue=0;ue<U.length;ue++){var oe=U[ue];Math.abs(G.dimensions[ue]||0)>1e-12&&($e(pe,oe)?ee.push({unit:pe[oe].unit,prefix:pe[oe].prefix,power:G.dimensions[ue]||0}):ie=!0)}ee.length<G.units.length&&!ie&&(G.units=ee)}}return G},g.prototype.toSI=function(){for(var G=this.clone(),ee=[],R=0;R<U.length;R++){var H=U[R];if(Math.abs(G.dimensions[R]||0)>1e-12)if($e(re.si,H))ee.push({unit:re.si[H].unit,prefix:re.si[H].prefix,power:G.dimensions[R]||0});else throw new Error("Cannot express custom unit "+H+" in SI units")}return G.units=ee,G.fixPrefix=!0,G.skipAutomaticSimplification=!0,this.value!==null?(G.value=null,this.to(G)):G},g.prototype.formatUnits=function(){for(var G="",ee="",R=0,H=0,Q=0;Q<this.units.length;Q++)this.units[Q].power>0?(R++,G+=" "+this.units[Q].prefix.name+this.units[Q].unit.name,Math.abs(this.units[Q].power-1)>1e-15&&(G+="^"+this.units[Q].power)):this.units[Q].power<0&&H++;if(H>0)for(var ie=0;ie<this.units.length;ie++)this.units[ie].power<0&&(R>0?(ee+=" "+this.units[ie].prefix.name+this.units[ie].unit.name,Math.abs(this.units[ie].power+1)>1e-15&&(ee+="^"+-this.units[ie].power)):(ee+=" "+this.units[ie].prefix.name+this.units[ie].unit.name,ee+="^"+this.units[ie].power));G=G.substr(1),ee=ee.substr(1),R>1&&H>0&&(G="("+G+")"),H>1&&R>0&&(ee="("+ee+")");var ue=G;return R>0&&H>0&&(ue+=" / "),ue+=ee,ue},g.prototype.toBest=function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(G&&!Array.isArray(G))throw new Error("Invalid unit type. Expected string or Unit.");var R=this.units[0].unit.prefixes;if(G&&G.length>0){var H=G.map(ue=>{var oe=null;if(typeof ue=="string"){if(oe=g.parse(ue),!oe)throw new Error("Invalid unit type. Expected compatible string or Unit.")}else if(!Ct(ue))throw new Error("Invalid unit type. Expected compatible string or Unit.");oe===null&&(oe=ue.clone());try{return this.to(oe.formatUnits()),oe}catch{throw new Error("Invalid unit type. Expected compatible string or Unit.")}}),Q=H.map(ue=>ue.units[0].prefix);this.units[0].unit.prefixes=Q.reduce((ue,oe)=>(ue[oe.name]=oe,ue),{}),this.units[0].prefix=Q[0]}var ie=J(this,ee).simp;return this.units[0].unit.prefixes=R,ie.fixPrefix=!0,ie},g.prototype.format=function(G){var{simp:ee,valueStr:R,unitStr:H}=J(this,G),Q=R;return ee.value&&ln(ee.value)&&(Q="("+Q+")"),H.length>0&&Q.length>0&&(Q+=" "),Q+=H,Q};function J(G){var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},R=G.skipAutomaticSimplification||G.value===null?G.clone():G.simplify();ne(R),j(R,ee.offset);var H=R._denormalize(R.value),Q=R.value!==null?v(H,ee||{}):"",ie=R.formatUnits();return{simp:R,valueStr:Q,unitStr:ie}}function ne(G){var ee=!1;typeof G.value<"u"&&G.value!==null&&ln(G.value)&&(ee=Math.abs(G.value.re)<1e-14);for(var R in G.units)$e(G.units,R)&&G.units[R].unit&&(G.units[R].unit.name==="VA"&&ee?G.units[R].unit=z.VAR:G.units[R].unit.name==="VAR"&&!ee&&(G.units[R].unit=z.VA))}function j(G,ee){G.units.length===1&&!G.fixPrefix&&Math.abs(G.units[0].power-Math.round(G.units[0].power))<1e-14&&(G.units[0].prefix=G._bestPrefix(ee))}g.prototype._bestPrefix=function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1.2;if(this.units.length!==1)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var ee=this.value!==null?u(this.value):0,R=u(this.units[0].unit.value),H=this.units[0].prefix;if(ee===0)return H;var Q=this.units[0].power,ie=Math.log(ee/Math.pow(H.value*R,Q))/Math.LN10-G;if(ie>-2.200001&&ie<1.800001)return H;ie=Math.abs(ie);var ue=this.units[0].unit.prefixes;for(var oe in ue)if($e(ue,oe)){var we=ue[oe];if(we.scientific){var xe=Math.abs(Math.log(ee/Math.pow(we.value*R,Q))/Math.LN10-G);(xe<ie||xe===ie&&we.name.length<H.name.length)&&(H=we,ie=xe)}}return H},g.prototype.splitUnit=function(G){for(var ee=this.clone(),R=[],H=0;H<G.length&&(ee=ee.to(G[H]),H!==G.length-1);H++){var Q=ee.toNumeric(),ie=c(Q),ue=void 0,oe=f(ie,Q);oe?ue=ie:ue=s(ee.toNumeric());var we=new g(ue,G[H].toString());R.push(we),ee=a(ee,we)}for(var xe=0,Te=0;Te<R.length;Te++)xe=n(xe,R[Te].value);return f(xe,this.value)&&(ee.value=0),R.push(ee),R};var F={NONE:{"":{name:"",value:1,scientific:!0}},SHORT:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:10,scientific:!1},h:{name:"h",value:100,scientific:!1},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0},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:Math.pow(1024,2),scientific:!0},Gi:{name:"Gi",value:Math.pow(1024,3),scientific:!0},Ti:{name:"Ti",value:Math.pow(1024,4),scientific:!0},Pi:{name:"Pi",value:Math.pow(1024,5),scientific:!0},Ei:{name:"Ei",value:Math.pow(1024,6),scientific:!0},Zi:{name:"Zi",value:Math.pow(1024,7),scientific:!0},Yi:{name:"Yi",value:Math.pow(1024,8),scientific:!0}},BINARY_LONG_SI:{"":{name:"",value:1,scientific:!0},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0}},BINARY_LONG_IEC:{"":{name:"",value:1,scientific:!0},kibi:{name:"kibi",value:1024,scientific:!0},mebi:{name:"mebi",value:Math.pow(1024,2),scientific:!0},gibi:{name:"gibi",value:Math.pow(1024,3),scientific:!0},tebi:{name:"tebi",value:Math.pow(1024,4),scientific:!0},pebi:{name:"pebi",value:Math.pow(1024,5),scientific:!0},exi:{name:"exi",value:Math.pow(1024,6),scientific:!0},zebi:{name:"zebi",value:Math.pow(1024,7),scientific:!0},yobi:{name:"yobi",value:Math.pow(1024,8),scientific:!0}},BTU:{"":{name:"",value:1,scientific:!0},MM:{name:"MM",value:1e6,scientific:!0}}};F.SHORTLONG=zr({},F.SHORT,F.LONG),F.BINARY_SHORT=zr({},F.BINARY_SHORT_SI,F.BINARY_SHORT_IEC),F.BINARY_LONG=zr({},F.BINARY_LONG_SI,F.BINARY_LONG_IEC);var U=["MASS","LENGTH","TIME","CURRENT","TEMPERATURE","LUMINOUS_INTENSITY","AMOUNT_OF_SUBSTANCE","ANGLE","BIT"],$={NONE:{dimensions:[0,0,0,0,0,0,0,0,0]},MASS:{dimensions:[1,0,0,0,0,0,0,0,0]},LENGTH:{dimensions:[0,1,0,0,0,0,0,0,0]},TIME:{dimensions:[0,0,1,0,0,0,0,0,0]},CURRENT:{dimensions:[0,0,0,1,0,0,0,0,0]},TEMPERATURE:{dimensions:[0,0,0,0,1,0,0,0,0]},LUMINOUS_INTENSITY:{dimensions:[0,0,0,0,0,1,0,0,0]},AMOUNT_OF_SUBSTANCE:{dimensions:[0,0,0,0,0,0,1,0,0]},FORCE:{dimensions:[1,1,-2,0,0,0,0,0,0]},SURFACE:{dimensions:[0,2,0,0,0,0,0,0,0]},VOLUME:{dimensions:[0,3,0,0,0,0,0,0,0]},ENERGY:{dimensions:[1,2,-2,0,0,0,0,0,0]},POWER:{dimensions:[1,2,-3,0,0,0,0,0,0]},PRESSURE:{dimensions:[1,-1,-2,0,0,0,0,0,0]},ELECTRIC_CHARGE:{dimensions:[0,0,1,1,0,0,0,0,0]},ELECTRIC_CAPACITANCE:{dimensions:[-1,-2,4,2,0,0,0,0,0]},ELECTRIC_POTENTIAL:{dimensions:[1,2,-3,-1,0,0,0,0,0]},ELECTRIC_RESISTANCE:{dimensions:[1,2,-3,-2,0,0,0,0,0]},ELECTRIC_INDUCTANCE:{dimensions:[1,2,-2,-2,0,0,0,0,0]},ELECTRIC_CONDUCTANCE:{dimensions:[-1,-2,3,2,0,0,0,0,0]},MAGNETIC_FLUX:{dimensions:[1,2,-2,-1,0,0,0,0,0]},MAGNETIC_FLUX_DENSITY:{dimensions:[1,0,-2,-1,0,0,0,0,0]},FREQUENCY:{dimensions:[0,0,-1,0,0,0,0,0,0]},ANGLE:{dimensions:[0,0,0,0,0,0,0,1,0]},BIT:{dimensions:[0,0,0,0,0,0,0,0,1]}};for(var le in $)$e($,le)&&($[le].key=le);var me={},Y={name:"",base:me,value:1,offset:0,dimensions:U.map(G=>0)},z={meter:{name:"meter",base:$.LENGTH,prefixes:F.LONG,value:1,offset:0},inch:{name:"inch",base:$.LENGTH,prefixes:F.NONE,value:.0254,offset:0},foot:{name:"foot",base:$.LENGTH,prefixes:F.NONE,value:.3048,offset:0},yard:{name:"yard",base:$.LENGTH,prefixes:F.NONE,value:.9144,offset:0},mile:{name:"mile",base:$.LENGTH,prefixes:F.NONE,value:1609.344,offset:0},link:{name:"link",base:$.LENGTH,prefixes:F.NONE,value:.201168,offset:0},rod:{name:"rod",base:$.LENGTH,prefixes:F.NONE,value:5.0292,offset:0},chain:{name:"chain",base:$.LENGTH,prefixes:F.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:$.LENGTH,prefixes:F.NONE,value:1e-10,offset:0},m:{name:"m",base:$.LENGTH,prefixes:F.SHORT,value:1,offset:0},in:{name:"in",base:$.LENGTH,prefixes:F.NONE,value:.0254,offset:0},ft:{name:"ft",base:$.LENGTH,prefixes:F.NONE,value:.3048,offset:0},yd:{name:"yd",base:$.LENGTH,prefixes:F.NONE,value:.9144,offset:0},mi:{name:"mi",base:$.LENGTH,prefixes:F.NONE,value:1609.344,offset:0},li:{name:"li",base:$.LENGTH,prefixes:F.NONE,value:.201168,offset:0},rd:{name:"rd",base:$.LENGTH,prefixes:F.NONE,value:5.02921,offset:0},ch:{name:"ch",base:$.LENGTH,prefixes:F.NONE,value:20.1168,offset:0},mil:{name:"mil",base:$.LENGTH,prefixes:F.NONE,value:254e-7,offset:0},m2:{name:"m2",base:$.SURFACE,prefixes:F.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:$.SURFACE,prefixes:F.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:$.SURFACE,prefixes:F.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:$.SURFACE,prefixes:F.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:$.SURFACE,prefixes:F.NONE,value:2589988110336e-6,offset:0},sqrd:{name:"sqrd",base:$.SURFACE,prefixes:F.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:$.SURFACE,prefixes:F.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:$.SURFACE,prefixes:F.NONE,value:64516e-14,offset:0},acre:{name:"acre",base:$.SURFACE,prefixes:F.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:$.SURFACE,prefixes:F.NONE,value:1e4,offset:0},m3:{name:"m3",base:$.VOLUME,prefixes:F.CUBIC,value:1,offset:0},L:{name:"L",base:$.VOLUME,prefixes:F.SHORT,value:.001,offset:0},l:{name:"l",base:$.VOLUME,prefixes:F.SHORT,value:.001,offset:0},litre:{name:"litre",base:$.VOLUME,prefixes:F.LONG,value:.001,offset:0},cuin:{name:"cuin",base:$.VOLUME,prefixes:F.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:$.VOLUME,prefixes:F.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:$.VOLUME,prefixes:F.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:$.VOLUME,prefixes:F.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:$.VOLUME,prefixes:F.NONE,value:15e-6,offset:0},drop:{name:"drop",base:$.VOLUME,prefixes:F.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:$.VOLUME,prefixes:F.NONE,value:5e-8,offset:0},minim:{name:"minim",base:$.VOLUME,prefixes:F.NONE,value:61611519921875e-21,offset:0},fluiddram:{name:"fluiddram",base:$.VOLUME,prefixes:F.NONE,value:36966911953125e-19,offset:0},fluidounce:{name:"fluidounce",base:$.VOLUME,prefixes:F.NONE,value:295735295625e-16,offset:0},gill:{name:"gill",base:$.VOLUME,prefixes:F.NONE,value:.00011829411825,offset:0},cc:{name:"cc",base:$.VOLUME,prefixes:F.NONE,value:1e-6,offset:0},cup:{name:"cup",base:$.VOLUME,prefixes:F.NONE,value:.0002365882365,offset:0},pint:{name:"pint",base:$.VOLUME,prefixes:F.NONE,value:.000473176473,offset:0},quart:{name:"quart",base:$.VOLUME,prefixes:F.NONE,value:.000946352946,offset:0},gallon:{name:"gallon",base:$.VOLUME,prefixes:F.NONE,value:.003785411784,offset:0},beerbarrel:{name:"beerbarrel",base:$.VOLUME,prefixes:F.NONE,value:.117347765304,offset:0},oilbarrel:{name:"oilbarrel",base:$.VOLUME,prefixes:F.NONE,value:.158987294928,offset:0},hogshead:{name:"hogshead",base:$.VOLUME,prefixes:F.NONE,value:.238480942392,offset:0},g:{name:"g",base:$.MASS,prefixes:F.SHORT,value:.001,offset:0},gram:{name:"gram",base:$.MASS,prefixes:F.LONG,value:.001,offset:0},ton:{name:"ton",base:$.MASS,prefixes:F.SHORT,value:907.18474,offset:0},t:{name:"t",base:$.MASS,prefixes:F.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:$.MASS,prefixes:F.LONG,value:1e3,offset:0},grain:{name:"grain",base:$.MASS,prefixes:F.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:$.MASS,prefixes:F.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:$.MASS,prefixes:F.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:$.MASS,prefixes:F.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:$.MASS,prefixes:F.NONE,value:45.359237,offset:0},stick:{name:"stick",base:$.MASS,prefixes:F.NONE,value:.115,offset:0},stone:{name:"stone",base:$.MASS,prefixes:F.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:$.MASS,prefixes:F.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:$.MASS,prefixes:F.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:$.MASS,prefixes:F.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:$.MASS,prefixes:F.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:$.MASS,prefixes:F.NONE,value:45.359237,offset:0},s:{name:"s",base:$.TIME,prefixes:F.SHORT,value:1,offset:0},min:{name:"min",base:$.TIME,prefixes:F.NONE,value:60,offset:0},h:{name:"h",base:$.TIME,prefixes:F.NONE,value:3600,offset:0},second:{name:"second",base:$.TIME,prefixes:F.LONG,value:1,offset:0},sec:{name:"sec",base:$.TIME,prefixes:F.LONG,value:1,offset:0},minute:{name:"minute",base:$.TIME,prefixes:F.NONE,value:60,offset:0},hour:{name:"hour",base:$.TIME,prefixes:F.NONE,value:3600,offset:0},day:{name:"day",base:$.TIME,prefixes:F.NONE,value:86400,offset:0},week:{name:"week",base:$.TIME,prefixes:F.NONE,value:7*86400,offset:0},month:{name:"month",base:$.TIME,prefixes:F.NONE,value:2629800,offset:0},year:{name:"year",base:$.TIME,prefixes:F.NONE,value:31557600,offset:0},decade:{name:"decade",base:$.TIME,prefixes:F.NONE,value:315576e3,offset:0},century:{name:"century",base:$.TIME,prefixes:F.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:$.TIME,prefixes:F.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:$.FREQUENCY,prefixes:F.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:$.FREQUENCY,prefixes:F.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:$.ANGLE,prefixes:F.SHORT,value:1,offset:0},radian:{name:"radian",base:$.ANGLE,prefixes:F.LONG,value:1,offset:0},deg:{name:"deg",base:$.ANGLE,prefixes:F.SHORT,value:null,offset:0},degree:{name:"degree",base:$.ANGLE,prefixes:F.LONG,value:null,offset:0},grad:{name:"grad",base:$.ANGLE,prefixes:F.SHORT,value:null,offset:0},gradian:{name:"gradian",base:$.ANGLE,prefixes:F.LONG,value:null,offset:0},cycle:{name:"cycle",base:$.ANGLE,prefixes:F.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:$.ANGLE,prefixes:F.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:$.ANGLE,prefixes:F.NONE,value:null,offset:0},A:{name:"A",base:$.CURRENT,prefixes:F.SHORT,value:1,offset:0},ampere:{name:"ampere",base:$.CURRENT,prefixes:F.LONG,value:1,offset:0},K:{name:"K",base:$.TEMPERATURE,prefixes:F.SHORT,value:1,offset:0},degC:{name:"degC",base:$.TEMPERATURE,prefixes:F.SHORT,value:1,offset:273.15},degF:{name:"degF",base:$.TEMPERATURE,prefixes:F.SHORT,value:new x(5,9),offset:459.67},degR:{name:"degR",base:$.TEMPERATURE,prefixes:F.SHORT,value:new x(5,9),offset:0},kelvin:{name:"kelvin",base:$.TEMPERATURE,prefixes:F.LONG,value:1,offset:0},celsius:{name:"celsius",base:$.TEMPERATURE,prefixes:F.LONG,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:$.TEMPERATURE,prefixes:F.LONG,value:new x(5,9),offset:459.67},rankine:{name:"rankine",base:$.TEMPERATURE,prefixes:F.LONG,value:new x(5,9),offset:0},mol:{name:"mol",base:$.AMOUNT_OF_SUBSTANCE,prefixes:F.SHORT,value:1,offset:0},mole:{name:"mole",base:$.AMOUNT_OF_SUBSTANCE,prefixes:F.LONG,value:1,offset:0},cd:{name:"cd",base:$.LUMINOUS_INTENSITY,prefixes:F.SHORT,value:1,offset:0},candela:{name:"candela",base:$.LUMINOUS_INTENSITY,prefixes:F.LONG,value:1,offset:0},N:{name:"N",base:$.FORCE,prefixes:F.SHORT,value:1,offset:0},newton:{name:"newton",base:$.FORCE,prefixes:F.LONG,value:1,offset:0},dyn:{name:"dyn",base:$.FORCE,prefixes:F.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:$.FORCE,prefixes:F.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:$.FORCE,prefixes:F.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:$.FORCE,prefixes:F.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:$.FORCE,prefixes:F.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:$.FORCE,prefixes:F.NONE,value:9.80665,offset:0},J:{name:"J",base:$.ENERGY,prefixes:F.SHORT,value:1,offset:0},joule:{name:"joule",base:$.ENERGY,prefixes:F.LONG,value:1,offset:0},erg:{name:"erg",base:$.ENERGY,prefixes:F.SHORTLONG,value:1e-7,offset:0},Wh:{name:"Wh",base:$.ENERGY,prefixes:F.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:$.ENERGY,prefixes:F.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:$.ENERGY,prefixes:F.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:$.ENERGY,prefixes:F.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:$.POWER,prefixes:F.SHORT,value:1,offset:0},watt:{name:"watt",base:$.POWER,prefixes:F.LONG,value:1,offset:0},hp:{name:"hp",base:$.POWER,prefixes:F.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:$.POWER,prefixes:F.SHORT,value:d.I,offset:0},VA:{name:"VA",base:$.POWER,prefixes:F.SHORT,value:1,offset:0},Pa:{name:"Pa",base:$.PRESSURE,prefixes:F.SHORT,value:1,offset:0},psi:{name:"psi",base:$.PRESSURE,prefixes:F.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:$.PRESSURE,prefixes:F.NONE,value:101325,offset:0},bar:{name:"bar",base:$.PRESSURE,prefixes:F.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:$.PRESSURE,prefixes:F.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:$.PRESSURE,prefixes:F.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:$.PRESSURE,prefixes:F.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:$.PRESSURE,prefixes:F.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:$.ELECTRIC_CHARGE,prefixes:F.LONG,value:1,offset:0},C:{name:"C",base:$.ELECTRIC_CHARGE,prefixes:F.SHORT,value:1,offset:0},Ah:{name:"Ah",base:$.ELECTRIC_CHARGE,prefixes:F.SHORT,value:3600,offset:0},farad:{name:"farad",base:$.ELECTRIC_CAPACITANCE,prefixes:F.LONG,value:1,offset:0},F:{name:"F",base:$.ELECTRIC_CAPACITANCE,prefixes:F.SHORT,value:1,offset:0},volt:{name:"volt",base:$.ELECTRIC_POTENTIAL,prefixes:F.LONG,value:1,offset:0},V:{name:"V",base:$.ELECTRIC_POTENTIAL,prefixes:F.SHORT,value:1,offset:0},ohm:{name:"ohm",base:$.ELECTRIC_RESISTANCE,prefixes:F.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:$.ELECTRIC_INDUCTANCE,prefixes:F.LONG,value:1,offset:0},H:{name:"H",base:$.ELECTRIC_INDUCTANCE,prefixes:F.SHORT,value:1,offset:0},siemens:{name:"siemens",base:$.ELECTRIC_CONDUCTANCE,prefixes:F.LONG,value:1,offset:0},S:{name:"S",base:$.ELECTRIC_CONDUCTANCE,prefixes:F.SHORT,value:1,offset:0},weber:{name:"weber",base:$.MAGNETIC_FLUX,prefixes:F.LONG,value:1,offset:0},Wb:{name:"Wb",base:$.MAGNETIC_FLUX,prefixes:F.SHORT,value:1,offset:0},tesla:{name:"tesla",base:$.MAGNETIC_FLUX_DENSITY,prefixes:F.LONG,value:1,offset:0},T:{name:"T",base:$.MAGNETIC_FLUX_DENSITY,prefixes:F.SHORT,value:1,offset:0},b:{name:"b",base:$.BIT,prefixes:F.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:$.BIT,prefixes:F.BINARY_LONG,value:1,offset:0},B:{name:"B",base:$.BIT,prefixes:F.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:$.BIT,prefixes:F.BINARY_LONG,value:8,offset:0}},X={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 se(G){if(G.number==="BigNumber"){var ee=Rs(y);z.rad.value=new y(1),z.deg.value=ee.div(180),z.grad.value=ee.div(200),z.cycle.value=ee.times(2),z.arcsec.value=ee.div(648e3),z.arcmin.value=ee.div(10800)}else z.rad.value=1,z.deg.value=Math.PI/180,z.grad.value=Math.PI/200,z.cycle.value=Math.PI*2,z.arcsec.value=Math.PI/648e3,z.arcmin.value=Math.PI/10800;z.radian.value=z.rad.value,z.degree.value=z.deg.value,z.gradian.value=z.grad.value}se(t),e&&e("config",function(G,ee){G.number!==ee.number&&se(G)});var re={si:{NONE:{unit:Y,prefix:F.NONE[""]},LENGTH:{unit:z.m,prefix:F.SHORT[""]},MASS:{unit:z.g,prefix:F.SHORT.k},TIME:{unit:z.s,prefix:F.SHORT[""]},CURRENT:{unit:z.A,prefix:F.SHORT[""]},TEMPERATURE:{unit:z.K,prefix:F.SHORT[""]},LUMINOUS_INTENSITY:{unit:z.cd,prefix:F.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:z.mol,prefix:F.SHORT[""]},ANGLE:{unit:z.rad,prefix:F.SHORT[""]},BIT:{unit:z.bits,prefix:F.SHORT[""]},FORCE:{unit:z.N,prefix:F.SHORT[""]},ENERGY:{unit:z.J,prefix:F.SHORT[""]},POWER:{unit:z.W,prefix:F.SHORT[""]},PRESSURE:{unit:z.Pa,prefix:F.SHORT[""]},ELECTRIC_CHARGE:{unit:z.C,prefix:F.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:z.F,prefix:F.SHORT[""]},ELECTRIC_POTENTIAL:{unit:z.V,prefix:F.SHORT[""]},ELECTRIC_RESISTANCE:{unit:z.ohm,prefix:F.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:z.H,prefix:F.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:z.S,prefix:F.SHORT[""]},MAGNETIC_FLUX:{unit:z.Wb,prefix:F.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:z.T,prefix:F.SHORT[""]},FREQUENCY:{unit:z.Hz,prefix:F.SHORT[""]}}};re.cgs=JSON.parse(JSON.stringify(re.si)),re.cgs.LENGTH={unit:z.m,prefix:F.SHORT.c},re.cgs.MASS={unit:z.g,prefix:F.SHORT[""]},re.cgs.FORCE={unit:z.dyn,prefix:F.SHORT[""]},re.cgs.ENERGY={unit:z.erg,prefix:F.NONE[""]},re.us=JSON.parse(JSON.stringify(re.si)),re.us.LENGTH={unit:z.ft,prefix:F.NONE[""]},re.us.MASS={unit:z.lbm,prefix:F.NONE[""]},re.us.TEMPERATURE={unit:z.degF,prefix:F.NONE[""]},re.us.FORCE={unit:z.lbf,prefix:F.NONE[""]},re.us.ENERGY={unit:z.BTU,prefix:F.BTU[""]},re.us.POWER={unit:z.hp,prefix:F.NONE[""]},re.us.PRESSURE={unit:z.psi,prefix:F.NONE[""]},re.auto=JSON.parse(JSON.stringify(re.si));var pe=re.auto;g.setUnitSystem=function(G){if($e(re,G))pe=re[G];else throw new Error("Unit system "+G+" does not exist. Choices are: "+Object.keys(re).join(", "))},g.getUnitSystem=function(){for(var G in re)if($e(re,G)&&re[G]===pe)return G},g.typeConverters={BigNumber:function(ee){return ee!=null&&ee.isFraction?new y(String(ee.n)).div(String(ee.d)).times(String(ee.s)):new y(ee+"")},Fraction:function(ee){return new x(ee)},Complex:function(ee){return ee},number:function(ee){return ee!=null&&ee.isFraction?p(ee):ee}},g.prototype._numberConverter=function(){var G=g.typeConverters[this.valueType()];if(G)return G;throw new TypeError('Unsupported Unit value type "'+this.valueType()+'"')},g._getNumberConverter=function(G){if(!g.typeConverters[G])throw new TypeError('Unsupported type "'+G+'"');return g.typeConverters[G]};for(var ve in z)if($e(z,ve)){var De=z[ve];De.dimensions=De.base.dimensions}for(var Oe in X)if($e(X,Oe)){var Ie=z[X[Oe]],_e={};for(var Le in Ie)$e(Ie,Le)&&(_e[Le]=Ie[Le]);_e.name=Oe,z[Oe]=_e}g.isValidAlpha=function(ee){return/^[a-zA-Z]$/.test(ee)};function qe(G){for(var ee=0;ee<G.length;ee++){if(N=G.charAt(ee),ee===0&&!g.isValidAlpha(N))throw new Error('Invalid unit name (must begin with alpha character): "'+G+'"');if(ee>0&&!(g.isValidAlpha(N)||C(N)))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+G+'"')}}return g.createUnit=function(G,ee){if(typeof G!="object")throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(ee&&ee.override){for(var R in G)if($e(G,R)&&g.deleteUnit(R),G[R].aliases)for(var H=0;H<G[R].aliases.length;H++)g.deleteUnit(G[R].aliases[H])}var Q;for(var ie in G)$e(G,ie)&&(Q=g.createUnitSingle(ie,G[ie]));return Q},g.createUnitSingle=function(G,ee){if((typeof ee>"u"||ee===null)&&(ee={}),typeof G!="string")throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");if($e(z,G))throw new Error('Cannot create unit "'+G+'": a unit with that name already exists');qe(G);var R=null,H=[],Q=0,ie,ue,oe;if(ee&&ee.type==="Unit")R=ee.clone();else if(typeof ee=="string")ee!==""&&(ie=ee);else if(typeof ee=="object")ie=ee.definition,ue=ee.prefixes,Q=ee.offset,oe=ee.baseName,ee.aliases&&(H=ee.aliases.valueOf());else throw new TypeError('Cannot create unit "'+G+'" from "'+ee.toString()+'": expecting "string" or "Unit" or "Object"');if(H){for(var we=0;we<H.length;we++)if($e(z,H[we]))throw new Error('Cannot create alias "'+H[we]+'": a unit with that name already exists')}if(ie&&typeof ie=="string"&&!R)try{R=g.parse(ie,{allowNoUnits:!0})}catch(Ke){throw Ke.message='Could not create unit "'+G+'" from "'+ie+'": '+Ke.message,Ke}else ie&&ie.type==="Unit"&&(R=ie.clone());H=H||[],Q=Q||0,ue&&ue.toUpperCase?ue=F[ue.toUpperCase()]||F.NONE:ue=F.NONE;var xe={};if(R){xe={name:G,value:R.value,dimensions:R.dimensions.slice(0),prefixes:ue,offset:Q};var fr=!1;for(var hr in $)if($e($,hr)){for(var ir=!0,Fr=0;Fr<U.length;Fr++)if(Math.abs((xe.dimensions[Fr]||0)-($[hr].dimensions[Fr]||0))>1e-12){ir=!1;break}if(ir){fr=!0,xe.base=$[hr];break}}if(!fr){oe=oe||G+"_STUFF";var T={dimensions:R.dimensions.slice(0)};T.key=oe,$[oe]=T,pe[oe]={unit:xe,prefix:F.NONE[""]},xe.base=$[oe]}}else{if(oe=oe||G+"_STUFF",U.indexOf(oe)>=0)throw new Error('Cannot create new base unit "'+G+'": a base unit with that name already exists (and cannot be overridden)');U.push(oe);for(var Te in $)$e($,Te)&&($[Te].dimensions[U.length-1]=0);for(var be={dimensions:[]},ke=0;ke<U.length;ke++)be.dimensions[ke]=0;be.dimensions[U.length-1]=1,be.key=oe,$[oe]=be,xe={name:G,value:1,dimensions:$[oe].dimensions.slice(0),prefixes:ue,offset:Q,base:$[oe]},pe[oe]={unit:xe,prefix:F.NONE[""]}}g.UNITS[G]=xe;for(var K=0;K<H.length;K++){var de=H[K],Se={};for(var ze in xe)$e(xe,ze)&&(Se[ze]=xe[ze]);Se.name=de,g.UNITS[de]=Se}return delete P.cache,new g(null,G)},g.deleteUnit=function(G){delete g.UNITS[G],delete P.cache},g.PREFIXES=F,g.BASE_DIMENSIONS=U,g.BASE_UNITS=$,g.UNIT_SYSTEMS=re,g.UNITS=z,g},{isClass:!0}),gv="unit",DE=["typed","Unit"],NE=L(gv,DE,r=>{var{typed:e,Unit:t}=r;return e(gv,{Unit:function(a){return a.clone()},string:function(a){return t.isValuelessUnit(a)?new t(null,a):t.parse(a,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string | Unit":function(a,i){return new t(a,i)},"number | BigNumber | Fraction":function(a){return new t(a)},"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),yv="sparse",EE=["typed","SparseMatrix"],AE=L(yv,EE,r=>{var{typed:e,SparseMatrix:t}=r;return e(yv,{"":function(){return new t([])},string:function(a){return new t([],a)},"Array | Matrix":function(a){return new t(a)},"Array | Matrix, string":function(a,i){return new t(a,i)}})}),bv="createUnit",SE=["typed","Unit"],CE=L(bv,SE,r=>{var{typed:e,Unit:t}=r;return e(bv,{"Object, Object":function(a,i){return t.createUnit(a,i)},Object:function(a){return t.createUnit(a,{})},"string, Unit | string | Object, Object":function(a,i,o){var l={};return l[a]=i,t.createUnit(l,o)},"string, Unit | string | Object":function(a,i){var o={};return o[a]=i,t.createUnit(o,{})},string:function(a){var i={};return i[a]={},t.createUnit(i,{})}})}),xv="acos",ME=["typed","config","Complex"],_E=L(xv,ME,r=>{var{typed:e,config:t,Complex:n}=r;return e(xv,{number:function(i){return i>=-1&&i<=1||t.predictable?Math.acos(i):new n(i,0).acos()},Complex:function(i){return i.acos()},BigNumber:function(i){return i.acos()}})}),wv="acosh",TE=["typed","config","Complex"],FE=L(wv,TE,r=>{var{typed:e,config:t,Complex:n}=r;return e(wv,{number:function(i){return i>=1||t.predictable?xc(i):i<=-1?new n(Math.log(Math.sqrt(i*i-1)-i),Math.PI):new n(i,0).acosh()},Complex:function(i){return i.acosh()},BigNumber:function(i){return i.acosh()}})}),Dv="acot",OE=["typed","BigNumber"],BE=L(Dv,OE,r=>{var{typed:e,BigNumber:t}=r;return e(Dv,{number:wc,Complex:function(a){return a.acot()},BigNumber:function(a){return new t(1).div(a).atan()}})}),Nv="acoth",RE=["typed","config","Complex","BigNumber"],IE=L(Nv,RE,r=>{var{typed:e,config:t,Complex:n,BigNumber:a}=r;return e(Nv,{number:function(o){return o>=1||o<=-1||t.predictable?Dc(o):new n(o,0).acoth()},Complex:function(o){return o.acoth()},BigNumber:function(o){return new a(1).div(o).atanh()}})}),Ev="acsc",PE=["typed","config","Complex","BigNumber"],$E=L(Ev,PE,r=>{var{typed:e,config:t,Complex:n,BigNumber:a}=r;return e(Ev,{number:function(o){return o<=-1||o>=1||t.predictable?Nc(o):new n(o,0).acsc()},Complex:function(o){return o.acsc()},BigNumber:function(o){return new a(1).div(o).asin()}})}),Av="acsch",qE=["typed","BigNumber"],zE=L(Av,qE,r=>{var{typed:e,BigNumber:t}=r;return e(Av,{number:Ec,Complex:function(a){return a.acsch()},BigNumber:function(a){return new t(1).div(a).asinh()}})}),Sv="asec",UE=["typed","config","Complex","BigNumber"],LE=L(Sv,UE,r=>{var{typed:e,config:t,Complex:n,BigNumber:a}=r;return e(Sv,{number:function(o){return o<=-1||o>=1||t.predictable?Ac(o):new n(o,0).asec()},Complex:function(o){return o.asec()},BigNumber:function(o){return new a(1).div(o).acos()}})}),Cv="asech",kE=["typed","config","Complex","BigNumber"],VE=L(Cv,kE,r=>{var{typed:e,config:t,Complex:n,BigNumber:a}=r;return e(Cv,{number:function(o){if(o<=1&&o>=-1||t.predictable){var l=1/o;if(l>0||t.predictable)return Sc(o);var u=Math.sqrt(l*l-1);return new n(Math.log(u-l),Math.PI)}return new n(o,0).asech()},Complex:function(o){return o.asech()},BigNumber:function(o){return new a(1).div(o).acosh()}})}),Mv="asin",GE=["typed","config","Complex"],HE=L(Mv,GE,r=>{var{typed:e,config:t,Complex:n}=r;return e(Mv,{number:function(i){return i>=-1&&i<=1||t.predictable?Math.asin(i):new n(i,0).asin()},Complex:function(i){return i.asin()},BigNumber:function(i){return i.asin()}})}),WE="asinh",YE=["typed"],ZE=L(WE,YE,r=>{var{typed:e}=r;return e("asinh",{number:Cc,Complex:function(n){return n.asinh()},BigNumber:function(n){return n.asinh()}})}),JE="atan",jE=["typed"],XE=L(JE,jE,r=>{var{typed:e}=r;return e("atan",{number:function(n){return Math.atan(n)},Complex:function(n){return n.atan()},BigNumber:function(n){return n.atan()}})}),_v="atan2",QE=["typed","matrix","equalScalar","BigNumber","DenseMatrix","concat"],KE=L(_v,QE,r=>{var{typed:e,matrix:t,equalScalar:n,BigNumber:a,DenseMatrix:i,concat:o}=r,l=Jt({typed:e,equalScalar:n}),u=ct({typed:e}),s=Mf({typed:e,equalScalar:n}),c=nt({typed:e,equalScalar:n}),f=Wr({typed:e,DenseMatrix:i}),m=Tr({typed:e,matrix:t,concat:o});return e(_v,{"number, number":Math.atan2,"BigNumber, BigNumber":(v,p)=>a.atan2(v,p)},m({scalar:"number | BigNumber",SS:s,DS:u,SD:l,Ss:c,sS:f}))}),Tv="atanh",eA=["typed","config","Complex"],rA=L(Tv,eA,r=>{var{typed:e,config:t,Complex:n}=r;return e(Tv,{number:function(i){return i<=1&&i>=-1||t.predictable?Mc(i):new n(i,0).atanh()},Complex:function(i){return i.atanh()},BigNumber:function(i){return i.atanh()}})}),Ra=L("trigUnit",["typed"],r=>{var{typed:e}=r;return{Unit:e.referToSelf(t=>n=>{if(!n.hasBase(n.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return e.find(t,n.valueType())(n.value)})}}),Fv="cos",tA=["typed"],nA=L(Fv,tA,r=>{var{typed:e}=r,t=Ra({typed:e});return e(Fv,{number:Math.cos,"Complex | BigNumber":n=>n.cos()},t)}),Ov="cosh",aA=["typed"],iA=L(Ov,aA,r=>{var{typed:e}=r;return e(Ov,{number:Y0,"Complex | BigNumber":t=>t.cosh()})}),Bv="cot",oA=["typed","BigNumber"],sA=L(Bv,oA,r=>{var{typed:e,BigNumber:t}=r,n=Ra({typed:e});return e(Bv,{number:_c,Complex:a=>a.cot(),BigNumber:a=>new t(1).div(a.tan())},n)}),Rv="coth",uA=["typed","BigNumber"],lA=L(Rv,uA,r=>{var{typed:e,BigNumber:t}=r;return e(Rv,{number:Tc,Complex:n=>n.coth(),BigNumber:n=>new t(1).div(n.tanh())})}),Iv="csc",cA=["typed","BigNumber"],fA=L(Iv,cA,r=>{var{typed:e,BigNumber:t}=r,n=Ra({typed:e});return e(Iv,{number:Fc,Complex:a=>a.csc(),BigNumber:a=>new t(1).div(a.sin())},n)}),Pv="csch",mA=["typed","BigNumber"],vA=L(Pv,mA,r=>{var{typed:e,BigNumber:t}=r;return e(Pv,{number:Oc,Complex:n=>n.csch(),BigNumber:n=>new t(1).div(n.sinh())})}),$v="sec",pA=["typed","BigNumber"],dA=L($v,pA,r=>{var{typed:e,BigNumber:t}=r,n=Ra({typed:e});return e($v,{number:Bc,Complex:a=>a.sec(),BigNumber:a=>new t(1).div(a.cos())},n)}),qv="sech",hA=["typed","BigNumber"],gA=L(qv,hA,r=>{var{typed:e,BigNumber:t}=r;return e(qv,{number:Rc,Complex:n=>n.sech(),BigNumber:n=>new t(1).div(n.cosh())})}),zv="sin",yA=["typed"],bA=L(zv,yA,r=>{var{typed:e}=r,t=Ra({typed:e});return e(zv,{number:Math.sin,"Complex | BigNumber":n=>n.sin()},t)}),Uv="sinh",xA=["typed"],wA=L(Uv,xA,r=>{var{typed:e}=r;return e(Uv,{number:Ic,"Complex | BigNumber":t=>t.sinh()})}),Lv="tan",DA=["typed"],NA=L(Lv,DA,r=>{var{typed:e}=r,t=Ra({typed:e});return e(Lv,{number:Math.tan,"Complex | BigNumber":n=>n.tan()},t)}),EA="tanh",AA=["typed"],SA=L(EA,AA,r=>{var{typed:e}=r;return e("tanh",{number:J0,"Complex | BigNumber":t=>t.tanh()})}),kv="setCartesian",CA=["typed","size","subset","compareNatural","Index","DenseMatrix"],MA=L(kv,CA,r=>{var{typed:e,size:t,subset:n,compareNatural:a,Index:i,DenseMatrix:o}=r;return e(kv,{"Array | Matrix, Array | Matrix":function(u,s){var c=[];if(n(t(u),new i(0))!==0&&n(t(s),new i(0))!==0){var f=yr(Array.isArray(u)?u:u.toArray()).sort(a),m=yr(Array.isArray(s)?s:s.toArray()).sort(a);c=[];for(var v=0;v<f.length;v++)for(var p=0;p<m.length;p++)c.push([f[v],m[p]])}return Array.isArray(u)&&Array.isArray(s)?c:new o(c)}})}),Vv="setDifference",_A=["typed","size","subset","compareNatural","Index","DenseMatrix"],TA=L(Vv,_A,r=>{var{typed:e,size:t,subset:n,compareNatural:a,Index:i,DenseMatrix:o}=r;return e(Vv,{"Array | Matrix, Array | Matrix":function(u,s){var c;if(n(t(u),new i(0))===0)c=[];else{if(n(t(s),new i(0))===0)return yr(u.toArray());var f=Aa(yr(Array.isArray(u)?u:u.toArray()).sort(a)),m=Aa(yr(Array.isArray(s)?s:s.toArray()).sort(a));c=[];for(var v,p=0;p<f.length;p++){v=!1;for(var d=0;d<m.length;d++)if(a(f[p].value,m[d].value)===0&&f[p].identifier===m[d].identifier){v=!0;break}v||c.push(f[p])}}return Array.isArray(u)&&Array.isArray(s)?Zi(c):new o(Zi(c))}})}),Gv="setDistinct",FA=["typed","size","subset","compareNatural","Index","DenseMatrix"],OA=L(Gv,FA,r=>{var{typed:e,size:t,subset:n,compareNatural:a,Index:i,DenseMatrix:o}=r;return e(Gv,{"Array | Matrix":function(u){var s;if(n(t(u),new i(0))===0)s=[];else{var c=yr(Array.isArray(u)?u:u.toArray()).sort(a);s=[],s.push(c[0]);for(var f=1;f<c.length;f++)a(c[f],c[f-1])!==0&&s.push(c[f])}return Array.isArray(u)?s:new o(s)}})}),Hv="setIntersect",BA=["typed","size","subset","compareNatural","Index","DenseMatrix"],RA=L(Hv,BA,r=>{var{typed:e,size:t,subset:n,compareNatural:a,Index:i,DenseMatrix:o}=r;return e(Hv,{"Array | Matrix, Array | Matrix":function(u,s){var c;if(n(t(u),new i(0))===0||n(t(s),new i(0))===0)c=[];else{var f=Aa(yr(Array.isArray(u)?u:u.toArray()).sort(a)),m=Aa(yr(Array.isArray(s)?s:s.toArray()).sort(a));c=[];for(var v=0;v<f.length;v++)for(var p=0;p<m.length;p++)if(a(f[v].value,m[p].value)===0&&f[v].identifier===m[p].identifier){c.push(f[v]);break}}return Array.isArray(u)&&Array.isArray(s)?Zi(c):new o(Zi(c))}})}),Wv="setIsSubset",IA=["typed","size","subset","compareNatural","Index"],PA=L(Wv,IA,r=>{var{typed:e,size:t,subset:n,compareNatural:a,Index:i}=r;return e(Wv,{"Array | Matrix, Array | Matrix":function(l,u){if(n(t(l),new i(0))===0)return!0;if(n(t(u),new i(0))===0)return!1;for(var s=Aa(yr(Array.isArray(l)?l:l.toArray()).sort(a)),c=Aa(yr(Array.isArray(u)?u:u.toArray()).sort(a)),f,m=0;m<s.length;m++){f=!1;for(var v=0;v<c.length;v++)if(a(s[m].value,c[v].value)===0&&s[m].identifier===c[v].identifier){f=!0;break}if(f===!1)return!1}return!0}})}),Yv="setMultiplicity",$A=["typed","size","subset","compareNatural","Index"],qA=L(Yv,$A,r=>{var{typed:e,size:t,subset:n,compareNatural:a,Index:i}=r;return e(Yv,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(l,u){if(n(t(u),new i(0))===0)return 0;for(var s=yr(Array.isArray(u)?u:u.toArray()),c=0,f=0;f<s.length;f++)a(s[f],l)===0&&c++;return c}})}),Zv="setPowerset",zA=["typed","size","subset","compareNatural","Index"],UA=L(Zv,zA,r=>{var{typed:e,size:t,subset:n,compareNatural:a,Index:i}=r;return e(Zv,{"Array | Matrix":function(s){if(n(t(s),new i(0))===0)return[];for(var c=yr(Array.isArray(s)?s:s.toArray()).sort(a),f=[],m=0;m.toString(2).length<=c.length;)f.push(o(c,m.toString(2).split("").reverse())),m++;return l(f)}});function o(u,s){for(var c=[],f=0;f<s.length;f++)s[f]==="1"&&c.push(u[f]);return c}function l(u){for(var s=[],c=u.length-1;c>0;c--)for(var f=0;f<c;f++)u[f].length>u[f+1].length&&(s=u[f],u[f]=u[f+1],u[f+1]=s);return u}}),Jv="setSize",LA=["typed","compareNatural"],kA=L(Jv,LA,r=>{var{typed:e,compareNatural:t}=r;return e(Jv,{"Array | Matrix":function(a){return Array.isArray(a)?yr(a).length:yr(a.toArray()).length},"Array | Matrix, boolean":function(a,i){if(i===!1||a.length===0)return Array.isArray(a)?yr(a).length:yr(a.toArray()).length;for(var o=yr(Array.isArray(a)?a:a.toArray()).sort(t),l=1,u=1;u<o.length;u++)t(o[u],o[u-1])!==0&&l++;return l}})}),jv="setSymDifference",VA=["typed","size","concat","subset","setDifference","Index"],GA=L(jv,VA,r=>{var{typed:e,size:t,concat:n,subset:a,setDifference:i,Index:o}=r;return e(jv,{"Array | Matrix, Array | Matrix":function(u,s){if(a(t(u),new o(0))===0)return yr(s);if(a(t(s),new o(0))===0)return yr(u);var c=yr(u),f=yr(s);return n(i(c,f),i(f,c))}})}),Xv="setUnion",HA=["typed","size","concat","subset","setIntersect","setSymDifference","Index"],WA=L(Xv,HA,r=>{var{typed:e,size:t,concat:n,subset:a,setIntersect:i,setSymDifference:o,Index:l}=r;return e(Xv,{"Array | Matrix, Array | Matrix":function(s,c){if(a(t(s),new l(0))===0)return yr(c);if(a(t(c),new l(0))===0)return yr(s);var f=yr(s),m=yr(c);return n(o(f,m),i(f,m))}})}),Qv="add",YA=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],ZA=L(Qv,YA,r=>{var{typed:e,matrix:t,addScalar:n,equalScalar:a,DenseMatrix:i,SparseMatrix:o,concat:l}=r,u=In({typed:e}),s=Es({typed:e,equalScalar:a}),c=Kn({typed:e,DenseMatrix:i}),f=Tr({typed:e,matrix:t,concat:l});return e(Qv,{"any, any":n,"any, any, ...any":e.referToSelf(m=>(v,p,d)=>{for(var y=m(v,p),x=0;x<d.length;x++)y=m(y,d[x]);return y})},f({elop:n,DS:u,SS:s,Ss:c}))}),Kv="hypot",JA=["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],jA=L(Kv,JA,r=>{var{typed:e,abs:t,addScalar:n,divideScalar:a,multiplyScalar:i,sqrt:o,smaller:l,isPositive:u}=r;return e(Kv,{"... number | BigNumber":s,Array:s,Matrix:c=>s(yr(c.toArray(),!0))});function s(c){for(var f=0,m=0,v=0;v<c.length;v++){if(ln(c[v]))throw new TypeError("Unexpected type of argument to hypot");var p=t(c[v]);l(m,p)?(f=i(f,i(a(m,p),a(m,p))),f=n(f,1),m=p):f=n(f,u(p)?i(a(p,m),a(p,m)):p)}return i(m,o(f))}}),ep="norm",XA=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],QA=L(ep,XA,r=>{var{typed:e,abs:t,add:n,pow:a,conj:i,sqrt:o,multiply:l,equalScalar:u,larger:s,smaller:c,matrix:f,ctranspose:m,eigs:v}=r;return e(ep,{number:Math.abs,Complex:function(N){return N.abs()},BigNumber:function(N){return N.abs()},boolean:function(N){return Math.abs(N)},Array:function(N){return b(f(N),2)},Matrix:function(N){return b(N,2)},"Array, number | BigNumber | string":function(N,E){return b(f(N),E)},"Matrix, number | BigNumber | string":function(N,E){return b(N,E)}});function p(A){var N=0;return A.forEach(function(E){var S=t(E);s(S,N)&&(N=S)},!0),N}function d(A){var N;return A.forEach(function(E){var S=t(E);(!N||c(S,N))&&(N=S)},!0),N||0}function y(A,N){if(N===Number.POSITIVE_INFINITY||N==="inf")return p(A);if(N===Number.NEGATIVE_INFINITY||N==="-inf")return d(A);if(N==="fro")return b(A,2);if(typeof N=="number"&&!isNaN(N)){if(!u(N,0)){var E=0;return A.forEach(function(S){E=n(a(t(S),N),E)},!0),a(E,1/N)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}function x(A){var N=0;return A.forEach(function(E,S){N=n(N,l(E,i(E)))}),t(o(N))}function D(A){var N=[],E=0;return A.forEach(function(S,C){var M=C[1],O=n(N[M]||0,t(S));s(O,E)&&(E=O),N[M]=O},!0),E}function h(A){var N=A.size();if(N[0]!==N[1])throw new RangeError("Invalid matrix dimensions");var E=m(A),S=l(E,A),C=v(S).values.toArray(),M=C[C.length-1];return t(o(M))}function w(A){var N=[],E=0;return A.forEach(function(S,C){var M=C[0],O=n(N[M]||0,t(S));s(O,E)&&(E=O),N[M]=O},!0),E}function g(A,N){if(N===1)return D(A);if(N===Number.POSITIVE_INFINITY||N==="inf")return w(A);if(N==="fro")return x(A);if(N===2)return h(A);throw new Error("Unsupported parameter value "+N)}function b(A,N){var E=A.size();if(E.length===1)return y(A,N);if(E.length===2){if(E[0]&&E[1])return g(A,N);throw new RangeError("Invalid matrix dimensions")}}}),rp="dot",KA=["typed","addScalar","multiplyScalar","conj","size"],eS=L(rp,KA,r=>{var{typed:e,addScalar:t,multiplyScalar:n,conj:a,size:i}=r;return e(rp,{"Array | DenseMatrix, Array | DenseMatrix":l,"SparseMatrix, SparseMatrix":u});function o(s,c){var f=i(s),m=i(c),v,p;if(f.length===1)v=f[0];else if(f.length===2&&f[1]===1)v=f[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+f.join(", ")+")");if(m.length===1)p=m[0];else if(m.length===2&&m[1]===1)p=m[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+m.join(", ")+")");if(v!==p)throw new RangeError("Vectors must have equal length ("+v+" != "+p+")");if(v===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return v}function l(s,c){var f=o(s,c),m=Je(s)?s._data:s,v=Je(s)?s._datatype||s.getDataType():void 0,p=Je(c)?c._data:c,d=Je(c)?c._datatype||c.getDataType():void 0,y=i(s).length===2,x=i(c).length===2,D=t,h=n;if(v&&d&&v===d&&typeof v=="string"&&v!=="mixed"){var w=v;D=e.find(t,[w,w]),h=e.find(n,[w,w])}if(!y&&!x){for(var g=h(a(m[0]),p[0]),b=1;b<f;b++)g=D(g,h(a(m[b]),p[b]));return g}if(!y&&x){for(var A=h(a(m[0]),p[0][0]),N=1;N<f;N++)A=D(A,h(a(m[N]),p[N][0]));return A}if(y&&!x){for(var E=h(a(m[0][0]),p[0]),S=1;S<f;S++)E=D(E,h(a(m[S][0]),p[S]));return E}if(y&&x){for(var C=h(a(m[0][0]),p[0][0]),M=1;M<f;M++)C=D(C,h(a(m[M][0]),p[M][0]));return C}}function u(s,c){o(s,c);for(var f=s._index,m=s._values,v=c._index,p=c._values,d=0,y=t,x=n,D=0,h=0;D<f.length&&h<v.length;){var w=f[D],g=v[h];if(w<g){D++;continue}if(w>g){h++;continue}w===g&&(d=y(d,x(m[D],p[h])),D++,h++)}return d}}),rS="trace",tS=["typed","matrix","add"],nS=L(rS,tS,r=>{var{typed:e,matrix:t,add:n}=r;return e("trace",{Array:function(l){return a(t(l))},SparseMatrix:i,DenseMatrix:a,any:er});function a(o){var l=o._size,u=o._data;switch(l.length){case 1:if(l[0]===1)return er(u[0]);throw new RangeError("Matrix must be square (size: "+lr(l)+")");case 2:{var s=l[0],c=l[1];if(s===c){for(var f=0,m=0;m<s;m++)f=n(f,u[m][m]);return f}else throw new RangeError("Matrix must be square (size: "+lr(l)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+lr(l)+")")}}function i(o){var l=o._values,u=o._index,s=o._ptr,c=o._size,f=c[0],m=c[1];if(f===m){var v=0;if(l.length>0)for(var p=0;p<m;p++)for(var d=s[p],y=s[p+1],x=d;x<y;x++){var D=u[x];if(D===p){v=n(v,l[x]);break}if(D>p)break}return v}throw new RangeError("Matrix must be square (size: "+lr(c)+")")}}),tp="index",aS=["typed","Index"],iS=L(tp,aS,r=>{var{typed:e,Index:t}=r;return e(tp,{"...number | string | BigNumber | Range | Array | Matrix":function(a){var i=a.map(function(l){return or(l)?l.toNumber():Ar(l)||Je(l)?l.map(function(u){return or(u)?u.toNumber():u}):l}),o=new t;return t.apply(o,i),o}})}),np=new Set(["end"]),oS="Node",sS=["mathWithTransform"],uS=L(oS,sS,r=>{var{mathWithTransform:e}=r;function t(a){for(var i of[...np])if(a.has(i))throw new Error('Scope contains an illegal symbol, "'+i+'" is a reserved keyword')}class n{get type(){return"Node"}get isNode(){return!0}evaluate(i){return this.compile().evaluate(i)}compile(){var i=this._compile(e,{}),o={},l=null;function u(s){var c=va(s);return t(c),i(c,o,l)}return{evaluate:u}}_compile(i,o){throw new Error("Method _compile must be implemented by type "+this.type)}forEach(i){throw new Error("Cannot run forEach on a Node interface")}map(i){throw new Error("Cannot run map on a Node interface")}_ifNode(i){if(!Nr(i))throw new TypeError("Callback function must return a Node");return i}traverse(i){i(this,null,null);function o(l,u){l.forEach(function(s,c,f){u(s,c,f),o(s,u)})}o(this,i)}transform(i){function o(l,u,s){var c=i(l,u,s);return c!==l?c:l.map(o)}return o(this,null,null)}filter(i){var o=[];return this.traverse(function(l,u,s){i(l,u,s)&&o.push(l)}),o}clone(){throw new Error("Cannot clone a Node interface")}cloneDeep(){return this.map(function(i){return i.cloneDeep()})}equals(i){return i?this.type===i.type&&mn(this,i):!1}toString(i){var o=this._getCustomString(i);return typeof o<"u"?o:this._toString(i)}_toString(){throw new Error("_toString not implemented for "+this.type)}toJSON(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)}toHTML(i){var o=this._getCustomString(i);return typeof o<"u"?o:this._toHTML(i)}_toHTML(){throw new Error("_toHTML not implemented for "+this.type)}toTex(i){var o=this._getCustomString(i);return typeof o<"u"?o:this._toTex(i)}_toTex(i){throw new Error("_toTex not implemented for "+this.type)}_getCustomString(i){if(i&&typeof i=="object")switch(typeof i.handler){case"object":case"undefined":return;case"function":return i.handler(this,i);default:throw new TypeError("Object or function expected as callback")}}getIdentifier(){return this.type}getContent(){return this}}return n},{isClass:!0,isNode:!0});function ht(r){return r&&r.isIndexError?new Yt(r.index+1,r.min+1,r.max!==void 0?r.max+1:void 0):r}function ap(r){var{subset:e}=r;return function(n,a){try{if(Array.isArray(n))return e(n,a);if(n&&typeof n.subset=="function")return n.subset(a);if(typeof n=="string")return e(n,a);if(typeof n=="object"){if(!a.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return pt(n,a.getObjectProperty())}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(i){throw ht(i)}}}var go="AccessorNode",lS=["subset","Node"],cS=L(go,lS,r=>{var{subset:e,Node:t}=r,n=ap({subset:e});function a(o){return!(cn(o)||Rt(o)||gr(o)||En(o)||Oi(o)||fn(o)||jr(o))}class i extends t{constructor(l,u){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(super(),!Nr(l))throw new TypeError('Node expected for parameter "object"');if(!pa(u))throw new TypeError('IndexNode expected for parameter "index"');this.object=l,this.index=u,this.optionalChaining=s}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return go}get isAccessorNode(){return!0}_compile(l,u){var s=this.object._compile(l,u),c=this.index._compile(l,u),f=this.optionalChaining,m=cn(this.object)&&this.object.optionalChaining;if(this.index.isObjectProperty()){var v=this.index.getObjectProperty();return function(d,y,x){var D=x||{},h=s(d,y,D);if(f&&h==null){D.optionalShortCircuit=!0;return}if(!(m&&D!==null&&D!==void 0&&D.optionalShortCircuit))return pt(h,v)}}else return function(d,y,x){var D=x||{},h=s(d,y,D);if(f&&h==null){D.optionalShortCircuit=!0;return}if(!(m&&D!==null&&D!==void 0&&D.optionalShortCircuit)){var w=c(d,y,h);return n(h,w)}}}forEach(l){l(this.object,"object",this),l(this.index,"index",this)}map(l){return new i(this._ifNode(l(this.object,"object",this)),this._ifNode(l(this.index,"index",this)),this.optionalChaining)}clone(){return new i(this.object,this.index,this.optionalChaining)}_toString(l){var u=this.object.toString(l);a(this.object)&&(u="("+u+")");var s=this.optionalChaining?this.index.dotNotation?"?":"?.":"";return u+s+this.index.toString(l)}_toHTML(l){var u=this.object.toHTML(l);return a(this.object)&&(u='<span class="math-parenthesis math-round-parenthesis">(</span>'+u+'<span class="math-parenthesis math-round-parenthesis">)</span>'),u+this.index.toHTML(l)}_toTex(l){var u=this.object.toTex(l);return a(this.object)&&(u="\\left(' + object + '\\right)"),u+this.index.toTex(l)}toJSON(){return{mathjs:go,object:this.object,index:this.index,optionalChaining:this.optionalChaining}}static fromJSON(l){return new i(l.object,l.index,l.optionalChaining)}}return Vr(i,"name",go),i},{isClass:!0,isNode:!0}),yo="ArrayNode",fS=["Node"],mS=L(yo,fS,r=>{var{Node:e}=r;class t extends e{constructor(a){if(super(),this.items=a||[],!Array.isArray(this.items)||!this.items.every(Nr))throw new TypeError("Array containing Nodes expected")}get type(){return yo}get isArrayNode(){return!0}_compile(a,i){var o=Bn(this.items,function(s){return s._compile(a,i)}),l=a.config.matrix!=="Array";if(l){var u=a.matrix;return function(c,f,m){return u(Bn(o,function(v){return v(c,f,m)}))}}else return function(c,f,m){return Bn(o,function(v){return v(c,f,m)})}}forEach(a){for(var i=0;i<this.items.length;i++){var o=this.items[i];a(o,"items["+i+"]",this)}}map(a){for(var i=[],o=0;o<this.items.length;o++)i[o]=this._ifNode(a(this.items[o],"items["+o+"]",this));return new t(i)}clone(){return new t(this.items.slice(0))}_toString(a){var i=this.items.map(function(o){return o.toString(a)});return"["+i.join(", ")+"]"}toJSON(){return{mathjs:yo,items:this.items}}static fromJSON(a){return new t(a.items)}_toHTML(a){var i=this.items.map(function(o){return o.toHTML(a)});return'<span class="math-parenthesis math-square-parenthesis">[</span>'+i.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(a){function i(o,l){var u=o.some(Rt)&&!o.every(Rt),s=l||u,c=s?"&":"\\\\",f=o.map(function(m){return m.items?i(m.items,!l):m.toTex(a)}).join(c);return u||!s||s&&!l?"\\begin{bmatrix}"+f+"\\end{bmatrix}":f}return i(this.items,!1)}}return Vr(t,"name",yo),t},{isClass:!0,isNode:!0});function vS(r){var{subset:e,matrix:t}=r;return function(a,i,o){try{if(Array.isArray(a)){var l=t(a).subset(i,o).valueOf();return l.forEach((u,s)=>{a[s]=u}),a}else{if(a&&typeof a.subset=="function")return a.subset(i,o);if(typeof a=="string")return e(a,i,o);if(typeof a=="object"){if(!i.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return ma(a,i.getObjectProperty(),o),a}else throw new TypeError("Cannot apply index: unsupported type of object")}}catch(u){throw ht(u)}}}var jt=[{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 bo(r,e){if(!e||e!=="auto")return r;for(var t=r;fn(t);)t=t.content;return t}function Cr(r,e,t,n){var a=r;e!=="keep"&&(a=r.getContent());for(var i=a.getIdentifier(),o=null,l=0;l<jt.length;l++)if(i in jt[l]){o=l;break}if(i==="OperatorNode:multiply"&&a.implicit&&t!=="show"){var u=bo(a.args[0],e);!(gr(u)&&n&&n.getIdentifier()==="OperatorNode:divide"&&Xo(bo(n.args[0],e)))&&!(u.getIdentifier()==="OperatorNode:divide"&&Xo(bo(u.args[0],e))&&gr(bo(u.args[1])))&&(o+=1)}return o}function ci(r,e){var t=r;e!=="keep"&&(t=r.getContent());var n=t.getIdentifier(),a=Cr(t,e);if(a===null)return null;var i=jt[a][n];if($e(i,"associativity")){if(i.associativity==="left")return"left";if(i.associativity==="right")return"right";throw Error("'"+n+"' has the invalid associativity '"+i.associativity+"'.")}return null}function Ps(r,e,t){var n=t!=="keep"?r.getContent():r,a=t!=="keep"?r.getContent():e,i=n.getIdentifier(),o=a.getIdentifier(),l=Cr(n,t);if(l===null)return null;var u=jt[l][i];if($e(u,"associativeWith")&&u.associativeWith instanceof Array){for(var s=0;s<u.associativeWith.length;s++)if(u.associativeWith[s]===o)return!0;return!1}return null}function pS(r){var e="OperatorNode:"+r;for(var t of jt)if(e in t)return t[e].op;return null}var xo="AssignmentNode",dS=["subset","?matrix","Node"],hS=L(xo,dS,r=>{var{subset:e,matrix:t,Node:n}=r,a=ap({subset:e}),i=vS({subset:e,matrix:t});function o(u,s,c){s||(s="keep");var f=Cr(u,s,c),m=Cr(u.value,s,c);return s==="all"||m!==null&&m<=f}class l extends n{constructor(s,c,f){if(super(),this.object=s,this.index=f?c:null,this.value=f||c,!jr(s)&&!cn(s))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(jr(s)&&s.name==="end")throw new Error('Cannot assign to symbol "end"');if(this.index&&!pa(this.index))throw new TypeError('IndexNode expected as "index"');if(!Nr(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 xo}get isAssignmentNode(){return!0}_compile(s,c){var f=this.object._compile(s,c),m=this.index?this.index._compile(s,c):null,v=this.value._compile(s,c),p=this.object.name;if(this.index)if(this.index.isObjectProperty()){var d=this.index.getObjectProperty();return function(w,g,b){var A=f(w,g,b),N=v(w,g,b);return ma(A,d,N),N}}else{if(jr(this.object))return function(w,g,b){var A=f(w,g,b),N=v(w,g,b),E=m(w,g,A);return w.set(p,i(A,E,N)),N};var y=this.object.object._compile(s,c);if(this.object.index.isObjectProperty()){var x=this.object.index.getObjectProperty();return function(w,g,b){var A=y(w,g,b),N=pt(A,x),E=m(w,g,N),S=v(w,g,b);return ma(A,x,i(N,E,S)),S}}else{var D=this.object.index._compile(s,c);return function(w,g,b){var A=y(w,g,b),N=D(w,g,A),E=a(A,N),S=m(w,g,E),C=v(w,g,b);return i(A,N,i(E,S,C)),C}}}else{if(!jr(this.object))throw new TypeError("SymbolNode expected as object");return function(w,g,b){var A=v(w,g,b);return w.set(p,A),A}}}forEach(s){s(this.object,"object",this),this.index&&s(this.index,"index",this),s(this.value,"value",this)}map(s){var c=this._ifNode(s(this.object,"object",this)),f=this.index?this._ifNode(s(this.index,"index",this)):null,m=this._ifNode(s(this.value,"value",this));return new l(c,f,m)}clone(){return new l(this.object,this.index,this.value)}_toString(s){var c=this.object.toString(s),f=this.index?this.index.toString(s):"",m=this.value.toString(s);return o(this,s&&s.parenthesis,s&&s.implicit)&&(m="("+m+")"),c+f+" = "+m}toJSON(){return{mathjs:xo,object:this.object,index:this.index,value:this.value}}static fromJSON(s){return new l(s.object,s.index,s.value)}_toHTML(s){var c=this.object.toHTML(s),f=this.index?this.index.toHTML(s):"",m=this.value.toHTML(s);return o(this,s&&s.parenthesis,s&&s.implicit)&&(m='<span class="math-paranthesis math-round-parenthesis">(</span>'+m+'<span class="math-paranthesis math-round-parenthesis">)</span>'),c+f+'<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+m}_toTex(s){var c=this.object.toTex(s),f=this.index?this.index.toTex(s):"",m=this.value.toTex(s);return o(this,s&&s.parenthesis,s&&s.implicit)&&(m="\\left(".concat(m,"\\right)")),c+f+"="+m}}return Vr(l,"name",xo),l},{isClass:!0,isNode:!0}),wo="BlockNode",gS=["ResultSet","Node"],yS=L(wo,gS,r=>{var{ResultSet:e,Node:t}=r;class n extends t{constructor(i){if(super(),!Array.isArray(i))throw new Error("Array expected");this.blocks=i.map(function(o){var l=o&&o.node,u=o&&o.visible!==void 0?o.visible:!0;if(!Nr(l))throw new TypeError('Property "node" must be a Node');if(typeof u!="boolean")throw new TypeError('Property "visible" must be a boolean');return{node:l,visible:u}})}get type(){return wo}get isBlockNode(){return!0}_compile(i,o){var l=Bn(this.blocks,function(u){return{evaluate:u.node._compile(i,o),visible:u.visible}});return function(s,c,f){var m=[];return Rl(l,function(p){var d=p.evaluate(s,c,f);p.visible&&m.push(d)}),new e(m)}}forEach(i){for(var o=0;o<this.blocks.length;o++)i(this.blocks[o].node,"blocks["+o+"].node",this)}map(i){for(var o=[],l=0;l<this.blocks.length;l++){var u=this.blocks[l],s=this._ifNode(i(u.node,"blocks["+l+"].node",this));o[l]={node:s,visible:u.visible}}return new n(o)}clone(){var i=this.blocks.map(function(o){return{node:o.node,visible:o.visible}});return new n(i)}_toString(i){return this.blocks.map(function(o){return o.node.toString(i)+(o.visible?"":";")}).join(`
|
|
19
19
|
`)}toJSON(){return{mathjs:wo,blocks:this.blocks}}static fromJSON(i){return new n(i.blocks)}_toHTML(i){return this.blocks.map(function(o){return o.node.toHTML(i)+(o.visible?"":'<span class="math-separator">;</span>')}).join('<span class="math-separator"><br /></span>')}_toTex(i){return this.blocks.map(function(o){return o.node.toTex(i)+(o.visible?"":";")}).join(`\\;\\;
|
|
20
|
-
`)}}return Vr(n,"name",wo),n},{isClass:!0,isNode:!0}),Do="ConditionalNode",bS=["Node"],xS=L(Do,bS,r=>{var{Node:e}=r;function t(a){if(typeof a=="number"||typeof a=="boolean"||typeof a=="string")return!!a;if(a){if(or(a))return!a.isZero();if(ln(a))return!!(a.re||a.im);if(St(a))return!!a.value}if(a==null)return!1;throw new TypeError('Unsupported type of condition "'+Sr(a)+'"')}class n extends e{constructor(i,o,l){if(super(),!Nr(i))throw new TypeError("Parameter condition must be a Node");if(!Nr(o))throw new TypeError("Parameter trueExpr must be a Node");if(!Nr(l))throw new TypeError("Parameter falseExpr must be a Node");this.condition=i,this.trueExpr=o,this.falseExpr=l}get type(){return Do}get isConditionalNode(){return!0}_compile(i,o){var l=this.condition._compile(i,o),u=this.trueExpr._compile(i,o),s=this.falseExpr._compile(i,o);return function(f,m,v){return t(l(f,m,v))?u(f,m,v):s(f,m,v)}}forEach(i){i(this.condition,"condition",this),i(this.trueExpr,"trueExpr",this),i(this.falseExpr,"falseExpr",this)}map(i){return new n(this._ifNode(i(this.condition,"condition",this)),this._ifNode(i(this.trueExpr,"trueExpr",this)),this._ifNode(i(this.falseExpr,"falseExpr",this)))}clone(){return new n(this.condition,this.trueExpr,this.falseExpr)}_toString(i){var o=i&&i.parenthesis?i.parenthesis:"keep",l=Cr(this,o,i&&i.implicit),u=this.condition.toString(i),s=Cr(this.condition,o,i&&i.implicit);(o==="all"||this.condition.type==="OperatorNode"||s!==null&&s<=l)&&(u="("+u+")");var c=this.trueExpr.toString(i),f=Cr(this.trueExpr,o,i&&i.implicit);(o==="all"||this.trueExpr.type==="OperatorNode"||f!==null&&f<=l)&&(c="("+c+")");var m=this.falseExpr.toString(i),v=Cr(this.falseExpr,o,i&&i.implicit);return(o==="all"||this.falseExpr.type==="OperatorNode"||v!==null&&v<=l)&&(m="("+m+")"),u+" ? "+c+" : "+m}toJSON(){return{mathjs:Do,condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}}static fromJSON(i){return new n(i.condition,i.trueExpr,i.falseExpr)}_toHTML(i){var o=i&&i.parenthesis?i.parenthesis:"keep",l=Cr(this,o,i&&i.implicit),u=this.condition.toHTML(i),s=Cr(this.condition,o,i&&i.implicit);(o==="all"||this.condition.type==="OperatorNode"||s!==null&&s<=l)&&(u='<span class="math-parenthesis math-round-parenthesis">(</span>'+u+'<span class="math-parenthesis math-round-parenthesis">)</span>');var c=this.trueExpr.toHTML(i),f=Cr(this.trueExpr,o,i&&i.implicit);(o==="all"||this.trueExpr.type==="OperatorNode"||f!==null&&f<=l)&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>');var m=this.falseExpr.toHTML(i),v=Cr(this.falseExpr,o,i&&i.implicit);return(o==="all"||this.falseExpr.type==="OperatorNode"||v!==null&&v<=l)&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>'),u+'<span class="math-operator math-conditional-operator">?</span>'+c+'<span class="math-operator math-conditional-operator">:</span>'+m}_toTex(i){return"\\begin{cases} {"+this.trueExpr.toTex(i)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(i)+"}\\\\{"+this.falseExpr.toTex(i)+"}, &\\quad{\\text{otherwise}}\\end{cases}"}}return Vr(n,"name",Do),n},{isClass:!0,isNode:!0}),$s=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},wS={"{":"\\{","}":"\\}","\\":"\\textbackslash{}","#":"\\#",$:"\\$","%":"\\%","&":"\\&","^":"\\textasciicircum{}",_:"\\_","~":"\\textasciitilde{}"},DS={"–":"\\--","—":"\\---"," ":"~"," ":"\\qquad{}","\r\n":"\\newline{}","\n":"\\newline{}"},NS=function(e,t){return $s({},e,t)},ES=function(r){for(var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.preserveFormatting,n=t===void 0?!1:t,a=e.escapeMapFn,i=a===void 0?NS:a,o=String(r),l="",u=i($s({},wS),n?$s({},DS):{}),s=Object.keys(u),c=function(){var m=!1;s.forEach(function(v,p){m||o.length>=v.length&&o.slice(0,v.length)===v&&(l+=u[s[p]],o=o.slice(v.length,o.length),m=!0)}),m||(l+=o.slice(0,1),o=o.slice(1,o.length))};o;)c();return l};const AS=Bs(ES);var qs={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{?}"},br={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"},ap={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(br.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(br.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(br.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(br.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(br.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(br.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(br.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(br.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(br.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(br.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(br.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(br.bitAnd,"${args[1]}\\right)")},bitNot:{1:br.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(br.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(br.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(br.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(br.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(br.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(br.and,"${args[1]}\\right)")},not:{1:br.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(br.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(br.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(br.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(br.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(br.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(br.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(br.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(br.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(br.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(br.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(br.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(br.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(br.to,"${args[1]}\\right)")},numeric:function(e,t){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},bigint:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(qs.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)"}},SS="\\mathrm{${name}}\\left(${args}\\right)",ip={deg:"^\\circ"};function zs(r){return AS(r,{preserveFormatting:!0})}function op(r,e){return e=typeof e>"u"?!1:e,e?$e(ip,r)?ip[r]:"\\mathrm{"+zs(r)+"}":$e(qs,r)?qs[r]:zs(r)}var No="ConstantNode",CS=["Node","isBounded"],MS=L(No,CS,r=>{var{Node:e,isBounded:t}=r;class n extends e{constructor(i){super(),this.value=i}get type(){return No}get isConstantNode(){return!0}_compile(i,o){var l=this.value;return function(){return l}}forEach(i){}map(i){return this.clone()}clone(){return new n(this.value)}_toString(i){return lr(this.value,i)}_toHTML(i){var o=this._toString(i);switch(Sr(this.value)){case"number":case"bigint":case"BigNumber":case"Fraction":return'<span class="math-number">'+o+"</span>";case"string":return'<span class="math-string">'+o+"</span>";case"boolean":return'<span class="math-boolean">'+o+"</span>";case"null":return'<span class="math-null-symbol">'+o+"</span>";case"undefined":return'<span class="math-undefined">'+o+"</span>";default:return'<span class="math-symbol">'+o+"</span>"}}toJSON(){return{mathjs:No,value:this.value}}static fromJSON(i){return new n(i.value)}_toTex(i){var o=this._toString(i),l=Sr(this.value);switch(l){case"string":return"\\mathtt{"+zs(o)+"}";case"number":case"BigNumber":{if(!t(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var u=o.toLowerCase().indexOf("e");return u!==-1?o.substring(0,u)+"\\cdot10^{"+o.substring(u+1)+"}":o}case"bigint":return o.toString();case"Fraction":return this.value.toLatex();default:return o}}}return Vr(n,"name",No),n},{isClass:!0,isNode:!0}),Eo="FunctionAssignmentNode",_S=["typed","Node"],TS=L(Eo,_S,r=>{var{typed:e,Node:t}=r;function n(i,o,l){var u=Cr(i,o,l),s=Cr(i.expr,o,l);return o==="all"||s!==null&&s<=u}class a extends t{constructor(o,l,u){if(super(),typeof o!="string")throw new TypeError('String expected for parameter "name"');if(!Array.isArray(l))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!Nr(u))throw new TypeError('Node expected for parameter "expr"');if(tp.has(o))throw new Error('Illegal function name, "'+o+'" is a reserved keyword');var s=new Set;for(var c of l){var f=typeof c=="string"?c:c.name;if(s.has(f))throw new Error('Duplicate parameter name "'.concat(f,'"'));s.add(f)}this.name=o,this.params=l.map(function(m){return m&&m.name||m}),this.types=l.map(function(m){return m&&m.type||"any"}),this.expr=u}get type(){return Eo}get isFunctionAssignmentNode(){return!0}_compile(o,l){var u=Object.create(l);Bl(this.params,function(d){u[d]=!0});var s=this.expr,c=s._compile(o,u),f=this.name,m=this.params,v=Pl(this.types,","),p=f+"("+Pl(this.params,", ")+")";return function(y,x,D){var h={};h[v]=function(){for(var g=Object.create(x),b=0;b<m.length;b++)g[m[b]]=arguments[b];return c(y,g,D)};var w=e(f,h);return w.syntax=p,w.expr=s.toString(),y.set(f,w),w}}forEach(o){o(this.expr,"expr",this)}map(o){var l=this._ifNode(o(this.expr,"expr",this));return new a(this.name,this.params.slice(0),l)}clone(){return new a(this.name,this.params.slice(0),this.expr)}_toString(o){var l=o&&o.parenthesis?o.parenthesis:"keep",u=this.expr.toString(o);return n(this,l,o&&o.implicit)&&(u="("+u+")"),this.name+"("+this.params.join(", ")+") = "+u}toJSON(){var o=this.types;return{mathjs:Eo,name:this.name,params:this.params.map(function(l,u){return{name:l,type:o[u]}}),expr:this.expr}}static fromJSON(o){return new a(o.name,o.params,o.expr)}_toHTML(o){for(var l=o&&o.parenthesis?o.parenthesis:"keep",u=[],s=0;s<this.params.length;s++)u.push('<span class="math-symbol math-parameter">'+qt(this.params[s])+"</span>");var c=this.expr.toHTML(o);return n(this,l,o&&o.implicit)&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>'),'<span class="math-function">'+qt(this.name)+'</span><span class="math-parenthesis math-round-parenthesis">(</span>'+u.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>'+c}_toTex(o){var l=o&&o.parenthesis?o.parenthesis:"keep",u=this.expr.toTex(o);return n(this,l,o&&o.implicit)&&(u="\\left(".concat(u,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(op).join(",")+"\\right)="+u}}return Vr(a,"name",Eo),a},{isClass:!0,isNode:!0}),Ao="IndexNode",FS=["Node","size"],OS=L(Ao,FS,r=>{var{Node:e,size:t}=r;class n extends e{constructor(i,o){if(super(),this.dimensions=i,this.dotNotation=o||!1,!Array.isArray(i)||!i.every(Nr))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}get type(){return Ao}get isIndexNode(){return!0}_compile(i,o){var l=Bn(this.dimensions,function(s,c){var f=s.filter(p=>p.isSymbolNode&&p.name==="end").length>0;if(f){var m=Object.create(o);m.end=!0;var v=s._compile(i,m);return function(d,y,x){if(!Je(x)&&!Ar(x)&&!$r(x))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+Sr(x));var D=t(x),h=Object.create(y);return h.end=D[c],v(d,h,x)}}else return s._compile(i,o)}),u=pt(i,"index");return function(c,f,m){var v=Bn(l,function(p){return p(c,f,m)});return u(...v)}}forEach(i){for(var o=0;o<this.dimensions.length;o++)i(this.dimensions[o],"dimensions["+o+"]",this)}map(i){for(var o=[],l=0;l<this.dimensions.length;l++)o[l]=this._ifNode(i(this.dimensions[l],"dimensions["+l+"]",this));return new n(o,this.dotNotation)}clone(){return new n(this.dimensions.slice(0),this.dotNotation)}isObjectProperty(){return this.dimensions.length===1&&gr(this.dimensions[0])&&typeof this.dimensions[0].value=="string"}getObjectProperty(){return this.isObjectProperty()?this.dimensions[0].value:null}_toString(i){return this.dotNotation?"."+this.getObjectProperty():"["+this.dimensions.join(", ")+"]"}toJSON(){return{mathjs:Ao,dimensions:this.dimensions,dotNotation:this.dotNotation}}static fromJSON(i){return new n(i.dimensions,i.dotNotation)}_toHTML(i){for(var o=[],l=0;l<this.dimensions.length;l++)o[l]=this.dimensions[l].toHTML();return this.dotNotation?'<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">'+qt(this.getObjectProperty())+"</span>":'<span class="math-parenthesis math-square-parenthesis">[</span>'+o.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(i){var o=this.dimensions.map(function(l){return l.toTex(i)});return this.dotNotation?"."+this.getObjectProperty():"_{"+o.join(",")+"}"}}return Vr(n,"name",Ao),n},{isClass:!0,isNode:!0}),So="ObjectNode",BS=["Node"],RS=L(So,BS,r=>{var{Node:e}=r;class t extends e{constructor(a){if(super(),this.properties=a||{},a&&(typeof a!="object"||!Object.keys(a).every(function(i){return Nr(a[i])})))throw new TypeError("Object containing Nodes expected")}get type(){return So}get isObjectNode(){return!0}_compile(a,i){var o={};for(var l in this.properties)if($e(this.properties,l)){var u=Da(l),s=JSON.parse(u),c=pt(this.properties,l);o[s]=c._compile(a,i)}return function(m,v,p){var d={};for(var y in o)$e(o,y)&&(d[y]=o[y](m,v,p));return d}}forEach(a){for(var i in this.properties)$e(this.properties,i)&&a(this.properties[i],"properties["+Da(i)+"]",this)}map(a){var i={};for(var o in this.properties)$e(this.properties,o)&&(i[o]=this._ifNode(a(this.properties[o],"properties["+Da(o)+"]",this)));return new t(i)}clone(){var a={};for(var i in this.properties)$e(this.properties,i)&&(a[i]=this.properties[i]);return new t(a)}_toString(a){var i=[];for(var o in this.properties)$e(this.properties,o)&&i.push(Da(o)+": "+this.properties[o].toString(a));return"{"+i.join(", ")+"}"}toJSON(){return{mathjs:So,properties:this.properties}}static fromJSON(a){return new t(a.properties)}_toHTML(a){var i=[];for(var o in this.properties)$e(this.properties,o)&&i.push('<span class="math-symbol math-property">'+qt(o)+'</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>'+this.properties[o].toHTML(a));return'<span class="math-parenthesis math-curly-parenthesis">{</span>'+i.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-curly-parenthesis">}</span>'}_toTex(a){var i=[];for(var o in this.properties)$e(this.properties,o)&&i.push("\\mathbf{"+o+":} & "+this.properties[o].toTex(a)+"\\\\");var l="\\left\\{\\begin{array}{ll}"+i.join(`
|
|
21
|
-
`)+"\\end{array}\\right\\}";return l}}return Vr(t,"name",So),t},{isClass:!0,isNode:!0});function fi(r,e){return new Wu(r,new Mi(e),new Set(Object.keys(e)))}var Co="OperatorNode",IS=["Node"],PS=L(Co,IS,r=>{var{Node:e}=r;function t(i,o){var l=i;if(o==="auto")for(;fn(l);)l=l.content;return gr(l)?!0:Ur(l)?t(l.args[0],o):!1}function n(i,o,l,u,s){var c=Cr(i,o,l),f=ci(i,o);if(o==="all"||u.length>2&&i.getIdentifier()!=="OperatorNode:add"&&i.getIdentifier()!=="OperatorNode:multiply")return u.map(function(S){switch(S.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}});var m;switch(u.length){case 0:m=[];break;case 1:{var v=Cr(u[0],o,l,i);if(s&&v!==null){var p,d;if(o==="keep"?(p=u[0].getIdentifier(),d=i.getIdentifier()):(p=u[0].getContent().getIdentifier(),d=i.getContent().getIdentifier()),jt[c][d].latexLeftParens===!1){m=[!1];break}if(jt[v][p].latexParens===!1){m=[!1];break}}if(v===null){m=[!1];break}if(v<=c){m=[!0];break}m=[!1]}break;case 2:{var y,x=Cr(u[0],o,l,i),D=Ps(i,u[0],o);x===null?y=!1:x===c&&f==="right"&&!D||x<c?y=!0:y=!1;var h,w=Cr(u[1],o,l,i),g=Ps(i,u[1],o);if(w===null?h=!1:w===c&&f==="left"&&!g||w<c?h=!0:h=!1,s){var b,A,N;o==="keep"?(b=i.getIdentifier(),A=i.args[0].getIdentifier(),N=i.args[1].getIdentifier()):(b=i.getContent().getIdentifier(),A=i.args[0].getContent().getIdentifier(),N=i.args[1].getContent().getIdentifier()),x!==null&&(jt[c][b].latexLeftParens===!1&&(y=!1),jt[x][A].latexParens===!1&&(y=!1)),w!==null&&(jt[c][b].latexRightParens===!1&&(h=!1),jt[w][N].latexParens===!1&&(h=!1))}m=[y,h]}break;default:(i.getIdentifier()==="OperatorNode:add"||i.getIdentifier()==="OperatorNode:multiply")&&(m=u.map(function(S){var C=Cr(S,o,l,i),M=Ps(i,S,o),O=ci(S,o);return C===null?!1:c===C&&f===O&&!M?!0:C<c}));break}if(u.length>=2&&i.getIdentifier()==="OperatorNode:multiply"&&i.implicit&&o!=="all"&&l==="hide")for(var E=1;E<m.length;++E)t(u[E],o)&&!m[E-1]&&(o!=="keep"||!fn(u[E-1]))&&(m[E]=!0);return m}class a extends e{constructor(o,l,u,s,c){if(super(),typeof o!="string")throw new TypeError('string expected for parameter "op"');if(typeof l!="string")throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(u)||!u.every(Nr))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=s===!0,this.isPercentage=c===!0,this.op=o,this.fn=l,this.args=u||[]}get type(){return Co}get isOperatorNode(){return!0}_compile(o,l){if(typeof this.fn!="string"||!Jo(o,this.fn))throw o[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var u=pt(o,this.fn),s=Bn(this.args,function(p){return p._compile(o,l)});if(typeof u=="function"&&u.rawArgs===!0){var c=this.args;return function(d,y,x){return u(c,o,fi(d,y))}}else if(s.length===1){var f=s[0];return function(d,y,x){return u(f(d,y,x))}}else if(s.length===2){var m=s[0],v=s[1];return function(d,y,x){return u(m(d,y,x),v(d,y,x))}}else return function(d,y,x){return u.apply(null,Bn(s,function(D){return D(d,y,x)}))}}forEach(o){for(var l=0;l<this.args.length;l++)o(this.args[l],"args["+l+"]",this)}map(o){for(var l=[],u=0;u<this.args.length;u++)l[u]=this._ifNode(o(this.args[u],"args["+u+"]",this));return new a(this.op,this.fn,l,this.implicit,this.isPercentage)}clone(){return new a(this.op,this.fn,this.args.slice(0),this.implicit,this.isPercentage)}isUnary(){return this.args.length===1}isBinary(){return this.args.length===2}_toString(o){var l=o&&o.parenthesis?o.parenthesis:"keep",u=o&&o.implicit?o.implicit:"hide",s=this.args,c=n(this,l,u,s,!1);if(s.length===1){var f=ci(this,l),m=s[0].toString(o);c[0]&&(m="("+m+")");var v=/[a-zA-Z]+/.test(this.op);return f==="right"?this.op+(v?" ":"")+m:f==="left"?m+(v?" ":"")+this.op:m+this.op}else if(s.length===2){var p=s[0].toString(o),d=s[1].toString(o);return c[0]&&(p="("+p+")"),c[1]&&(d="("+d+")"),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&u==="hide"?p+" "+d:p+" "+this.op+" "+d}else if(s.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var y=s.map(function(x,D){return x=x.toString(o),c[D]&&(x="("+x+")"),x});return this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&u==="hide"?y.join(" "):y.join(" "+this.op+" ")}else return this.fn+"("+this.args.join(", ")+")"}toJSON(){return{mathjs:Co,op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}}static fromJSON(o){return new a(o.op,o.fn,o.args,o.implicit,o.isPercentage)}_toHTML(o){var l=o&&o.parenthesis?o.parenthesis:"keep",u=o&&o.implicit?o.implicit:"hide",s=this.args,c=n(this,l,u,s,!1);if(s.length===1){var f=ci(this,l),m=s[0].toHTML(o);return c[0]&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>'),f==="right"?'<span class="math-operator math-unary-operator math-lefthand-unary-operator">'+qt(this.op)+"</span>"+m:m+'<span class="math-operator math-unary-operator math-righthand-unary-operator">'+qt(this.op)+"</span>"}else if(s.length===2){var v=s[0].toHTML(o),p=s[1].toHTML(o);return c[0]&&(v='<span class="math-parenthesis math-round-parenthesis">(</span>'+v+'<span class="math-parenthesis math-round-parenthesis">)</span>'),c[1]&&(p='<span class="math-parenthesis math-round-parenthesis">(</span>'+p+'<span class="math-parenthesis math-round-parenthesis">)</span>'),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&u==="hide"?v+'<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'+p:v+'<span class="math-operator math-binary-operator math-explicit-binary-operator">'+qt(this.op)+"</span>"+p}else{var d=s.map(function(y,x){return y=y.toHTML(o),c[x]&&(y='<span class="math-parenthesis math-round-parenthesis">(</span>'+y+'<span class="math-parenthesis math-round-parenthesis">)</span>'),y});return s.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")?this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&u==="hide"?d.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'):d.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">'+qt(this.op)+"</span>"):'<span class="math-function">'+qt(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+d.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}}_toTex(o){var l=o&&o.parenthesis?o.parenthesis:"keep",u=o&&o.implicit?o.implicit:"hide",s=this.args,c=n(this,l,u,s,!0),f=br[this.fn];if(f=typeof f>"u"?this.op:f,s.length===1){var m=ci(this,l),v=s[0].toTex(o);return c[0]&&(v="\\left(".concat(v,"\\right)")),m==="right"?f+v:v+f}else if(s.length===2){var p=s[0],d=p.toTex(o);c[0]&&(d="\\left(".concat(d,"\\right)"));var y=s[1],x=y.toTex(o);c[1]&&(x="\\left(".concat(x,"\\right)"));var D;switch(l==="keep"?D=p.getIdentifier():D=p.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return f+"{"+d+"}{"+x+"}";case"OperatorNode:pow":switch(d="{"+d+"}",x="{"+x+"}",D){case"ConditionalNode":case"OperatorNode:divide":d="\\left(".concat(d,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&u==="hide")return d+"~"+x}return d+f+x}else if(s.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var h=s.map(function(w,g){return w=w.toTex(o),c[g]&&(w="\\left(".concat(w,"\\right)")),w});return this.getIdentifier()==="OperatorNode:multiply"&&this.implicit&&u==="hide"?h.join("~"):h.join(f)}else return"\\mathrm{"+this.fn+"}\\left("+s.map(function(w){return w.toTex(o)}).join(",")+"\\right)"}getIdentifier(){return this.type+":"+this.fn}}return Vr(a,"name",Co),a},{isClass:!0,isNode:!0}),Mo="ParenthesisNode",$S=["Node"],qS=L(Mo,$S,r=>{var{Node:e}=r;class t extends e{constructor(a){if(super(),!Nr(a))throw new TypeError('Node expected for parameter "content"');this.content=a}get type(){return Mo}get isParenthesisNode(){return!0}_compile(a,i){return this.content._compile(a,i)}getContent(){return this.content.getContent()}forEach(a){a(this.content,"content",this)}map(a){var i=a(this.content,"content",this);return new t(i)}clone(){return new t(this.content)}_toString(a){return!a||a&&!a.parenthesis||a&&a.parenthesis==="keep"?"("+this.content.toString(a)+")":this.content.toString(a)}toJSON(){return{mathjs:Mo,content:this.content}}static fromJSON(a){return new t(a.content)}_toHTML(a){return!a||a&&!a.parenthesis||a&&a.parenthesis==="keep"?'<span class="math-parenthesis math-round-parenthesis">(</span>'+this.content.toHTML(a)+'<span class="math-parenthesis math-round-parenthesis">)</span>':this.content.toHTML(a)}_toTex(a){return!a||a&&!a.parenthesis||a&&a.parenthesis==="keep"?"\\left(".concat(this.content.toTex(a),"\\right)"):this.content.toTex(a)}}return Vr(t,"name",Mo),t},{isClass:!0,isNode:!0}),_o="RangeNode",zS=["Node"],US=L(_o,zS,r=>{var{Node:e}=r;function t(a,i,o){var l=Cr(a,i,o),u={},s=Cr(a.start,i,o);if(u.start=s!==null&&s<=l||i==="all",a.step){var c=Cr(a.step,i,o);u.step=c!==null&&c<=l||i==="all"}var f=Cr(a.end,i,o);return u.end=f!==null&&f<=l||i==="all",u}class n extends e{constructor(i,o,l){if(super(),!Nr(i))throw new TypeError("Node expected");if(!Nr(o))throw new TypeError("Node expected");if(l&&!Nr(l))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=i,this.end=o,this.step=l||null}get type(){return _o}get isRangeNode(){return!0}needsEnd(){var i=this.filter(function(o){return Jr(o)&&o.name==="end"});return i.length>0}_compile(i,o){var l=i.range,u=this.start._compile(i,o),s=this.end._compile(i,o);if(this.step){var c=this.step._compile(i,o);return function(m,v,p){return l(u(m,v,p),s(m,v,p),c(m,v,p))}}else return function(m,v,p){return l(u(m,v,p),s(m,v,p))}}forEach(i){i(this.start,"start",this),i(this.end,"end",this),this.step&&i(this.step,"step",this)}map(i){return new n(this._ifNode(i(this.start,"start",this)),this._ifNode(i(this.end,"end",this)),this.step&&this._ifNode(i(this.step,"step",this)))}clone(){return new n(this.start,this.end,this.step&&this.step)}_toString(i){var o=i&&i.parenthesis?i.parenthesis:"keep",l=t(this,o,i&&i.implicit),u,s=this.start.toString(i);if(l.start&&(s="("+s+")"),u=s,this.step){var c=this.step.toString(i);l.step&&(c="("+c+")"),u+=":"+c}var f=this.end.toString(i);return l.end&&(f="("+f+")"),u+=":"+f,u}toJSON(){return{mathjs:_o,start:this.start,end:this.end,step:this.step}}static fromJSON(i){return new n(i.start,i.end,i.step)}_toHTML(i){var o=i&&i.parenthesis?i.parenthesis:"keep",l=t(this,o,i&&i.implicit),u,s=this.start.toHTML(i);if(l.start&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),u=s,this.step){var c=this.step.toHTML(i);l.step&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>'),u+='<span class="math-operator math-range-operator">:</span>'+c}var f=this.end.toHTML(i);return l.end&&(f='<span class="math-parenthesis math-round-parenthesis">(</span>'+f+'<span class="math-parenthesis math-round-parenthesis">)</span>'),u+='<span class="math-operator math-range-operator">:</span>'+f,u}_toTex(i){var o=i&&i.parenthesis?i.parenthesis:"keep",l=t(this,o,i&&i.implicit),u=this.start.toTex(i);if(l.start&&(u="\\left(".concat(u,"\\right)")),this.step){var s=this.step.toTex(i);l.step&&(s="\\left(".concat(s,"\\right)")),u+=":"+s}var c=this.end.toTex(i);return l.end&&(c="\\left(".concat(c,"\\right)")),u+=":"+c,u}}return Vr(n,"name",_o),n},{isClass:!0,isNode:!0}),To="RelationalNode",LS=["Node"],kS=L(To,LS,r=>{var{Node:e}=r,t={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="};class n extends e{constructor(i,o){if(super(),!Array.isArray(i))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(o))throw new TypeError("Parameter params must be an array");if(i.length!==o.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=i,this.params=o}get type(){return To}get isRelationalNode(){return!0}_compile(i,o){var l=this,u=this.params.map(s=>s._compile(i,o));return function(c,f,m){for(var v,p=u[0](c,f,m),d=0;d<l.conditionals.length;d++){v=p,p=u[d+1](c,f,m);var y=pt(i,l.conditionals[d]);if(!y(v,p))return!1}return!0}}forEach(i){this.params.forEach((o,l)=>i(o,"params["+l+"]",this),this)}map(i){return new n(this.conditionals.slice(),this.params.map((o,l)=>this._ifNode(i(o,"params["+l+"]",this)),this))}clone(){return new n(this.conditionals,this.params)}_toString(i){for(var o=i&&i.parenthesis?i.parenthesis:"keep",l=Cr(this,o,i&&i.implicit),u=this.params.map(function(f,m){var v=Cr(f,o,i&&i.implicit);return o==="all"||v!==null&&v<=l?"("+f.toString(i)+")":f.toString(i)}),s=u[0],c=0;c<this.conditionals.length;c++)s+=" "+t[this.conditionals[c]],s+=" "+u[c+1];return s}toJSON(){return{mathjs:To,conditionals:this.conditionals,params:this.params}}static fromJSON(i){return new n(i.conditionals,i.params)}_toHTML(i){for(var o=i&&i.parenthesis?i.parenthesis:"keep",l=Cr(this,o,i&&i.implicit),u=this.params.map(function(f,m){var v=Cr(f,o,i&&i.implicit);return o==="all"||v!==null&&v<=l?'<span class="math-parenthesis math-round-parenthesis">(</span>'+f.toHTML(i)+'<span class="math-parenthesis math-round-parenthesis">)</span>':f.toHTML(i)}),s=u[0],c=0;c<this.conditionals.length;c++)s+='<span class="math-operator math-binary-operator math-explicit-binary-operator">'+qt(t[this.conditionals[c]])+"</span>"+u[c+1];return s}_toTex(i){for(var o=i&&i.parenthesis?i.parenthesis:"keep",l=Cr(this,o,i&&i.implicit),u=this.params.map(function(f,m){var v=Cr(f,o,i&&i.implicit);return o==="all"||v!==null&&v<=l?"\\left("+f.toTex(i)+"\right)":f.toTex(i)}),s=u[0],c=0;c<this.conditionals.length;c++)s+=br[this.conditionals[c]]+u[c+1];return s}}return Vr(n,"name",To),n},{isClass:!0,isNode:!0}),VS="SymbolNode",GS=["math","?Unit","Node"],HS=L(VS,GS,r=>{var{math:e,Unit:t,Node:n}=r;function a(o){return t?t.isValuelessUnit(o):!1}class i extends n{constructor(l){if(super(),typeof l!="string")throw new TypeError('String expected for parameter "name"');this.name=l}get type(){return"SymbolNode"}get isSymbolNode(){return!0}_compile(l,u){var s=this.name;if(u[s]===!0)return function(f,m,v){return pt(m,s)};if(s in l)return function(f,m,v){return f.has(s)?f.get(s):pt(l,s)};var c=a(s);return function(f,m,v){return f.has(s)?f.get(s):c?new t(null,s):i.onUndefinedSymbol(s)}}forEach(l){}map(l){return this.clone()}static onUndefinedSymbol(l){throw new Error("Undefined symbol "+l)}clone(){return new i(this.name)}_toString(l){return this.name}_toHTML(l){var u=qt(this.name);return u==="true"||u==="false"?'<span class="math-symbol math-boolean">'+u+"</span>":u==="i"?'<span class="math-symbol math-imaginary-symbol">'+u+"</span>":u==="Infinity"?'<span class="math-symbol math-infinity-symbol">'+u+"</span>":u==="NaN"?'<span class="math-symbol math-nan-symbol">'+u+"</span>":u==="null"?'<span class="math-symbol math-null-symbol">'+u+"</span>":u==="undefined"?'<span class="math-symbol math-undefined-symbol">'+u+"</span>":'<span class="math-symbol">'+u+"</span>"}toJSON(){return{mathjs:"SymbolNode",name:this.name}}static fromJSON(l){return new i(l.name)}_toTex(l){var u=!1;typeof e[this.name]>"u"&&a(this.name)&&(u=!0);var s=op(this.name,u);return s[0]==="\\"?s:" "+s}}return i},{isClass:!0,isNode:!0}),Fo="FunctionNode",WS=["math","Node","SymbolNode"],YS=L(Fo,WS,r=>{var e,{math:t,Node:n,SymbolNode:a}=r,i=u=>lr(u,{truncate:78});function o(u,s,c){for(var f="",m=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,v=0,p;(p=m.exec(u))!==null;)if(f+=u.substring(v,p.index),v=p.index,p[0]==="$$")f+="$",v++;else{v+=p[0].length;var d=s[p[1]];if(!d)throw new ReferenceError("Template: Property "+p[1]+" does not exist.");if(p[2]===void 0)switch(typeof d){case"string":f+=d;break;case"object":if(Nr(d))f+=d.toTex(c);else if(Array.isArray(d))f+=d.map(function(y,x){if(Nr(y))return y.toTex(c);throw new TypeError("Template: "+p[1]+"["+x+"] is not a Node.")}).join(",");else throw new TypeError("Template: "+p[1]+" has to be a Node, String or array of Nodes");break;default:throw new TypeError("Template: "+p[1]+" has to be a Node, String or array of Nodes")}else if(Nr(d[p[2]]&&d[p[2]]))f+=d[p[2]].toTex(c);else throw new TypeError("Template: "+p[1]+"["+p[2]+"] is not a Node.")}return f+=u.slice(v),f}class l extends n{constructor(s,c,f){if(super(),typeof s=="string"&&(s=new a(s)),!Nr(s))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(c)||!c.every(Nr))throw new TypeError('Array containing Nodes expected for parameter "args"');var m=typeof f;if(!(m==="undefined"||m==="boolean"))throw new TypeError("optional flag, if specified, must be boolean");this.fn=s,this.args=c||[],this.optional=!!f}get name(){return this.fn.name||""}get type(){return Fo}get isFunctionNode(){return!0}_compile(s,c){var f=this.args.map(E=>E._compile(s,c)),m=this.optional||cn(this.fn)&&this.fn.optionalChaining;if(Jr(this.fn)){var v=this.fn.name;if(c[v]){var D=this.args;return function(S,C,M){var O=pt(C,v);if(!(m&&O===void 0)){if(typeof O!="function")throw new TypeError("Argument '".concat(v,"' was not a function; received: ").concat(i(O)));if(O.rawArgs)return O(D,s,fi(S,C));var I=f.map(k=>k(S,C,M));return O.apply(O,I)}}}else{var p=v in s?pt(s,v):void 0,d=typeof p=="function"&&p.rawArgs===!0,y=E=>{var S;if(E.has(v))S=E.get(v);else if(v in s)S=pt(s,v);else if(m)S=void 0;else return l.onUndefinedFunction(v);if(typeof S=="function"||m&&S===void 0)return S;throw new TypeError("'".concat(v,`' is not a function; its value is:
|
|
20
|
+
`)}}return Vr(n,"name",wo),n},{isClass:!0,isNode:!0}),Do="ConditionalNode",bS=["Node"],xS=L(Do,bS,r=>{var{Node:e}=r;function t(a){if(typeof a=="number"||typeof a=="boolean"||typeof a=="string")return!!a;if(a){if(or(a))return!a.isZero();if(ln(a))return!!(a.re||a.im);if(Ct(a))return!!a.value}if(a==null)return!1;throw new TypeError('Unsupported type of condition "'+Sr(a)+'"')}class n extends e{constructor(i,o,l){if(super(),!Nr(i))throw new TypeError("Parameter condition must be a Node");if(!Nr(o))throw new TypeError("Parameter trueExpr must be a Node");if(!Nr(l))throw new TypeError("Parameter falseExpr must be a Node");this.condition=i,this.trueExpr=o,this.falseExpr=l}get type(){return Do}get isConditionalNode(){return!0}_compile(i,o){var l=this.condition._compile(i,o),u=this.trueExpr._compile(i,o),s=this.falseExpr._compile(i,o);return function(f,m,v){return t(l(f,m,v))?u(f,m,v):s(f,m,v)}}forEach(i){i(this.condition,"condition",this),i(this.trueExpr,"trueExpr",this),i(this.falseExpr,"falseExpr",this)}map(i){return new n(this._ifNode(i(this.condition,"condition",this)),this._ifNode(i(this.trueExpr,"trueExpr",this)),this._ifNode(i(this.falseExpr,"falseExpr",this)))}clone(){return new n(this.condition,this.trueExpr,this.falseExpr)}_toString(i){var o=i&&i.parenthesis?i.parenthesis:"keep",l=Cr(this,o,i&&i.implicit),u=this.condition.toString(i),s=Cr(this.condition,o,i&&i.implicit);(o==="all"||this.condition.type==="OperatorNode"||s!==null&&s<=l)&&(u="("+u+")");var c=this.trueExpr.toString(i),f=Cr(this.trueExpr,o,i&&i.implicit);(o==="all"||this.trueExpr.type==="OperatorNode"||f!==null&&f<=l)&&(c="("+c+")");var m=this.falseExpr.toString(i),v=Cr(this.falseExpr,o,i&&i.implicit);return(o==="all"||this.falseExpr.type==="OperatorNode"||v!==null&&v<=l)&&(m="("+m+")"),u+" ? "+c+" : "+m}toJSON(){return{mathjs:Do,condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}}static fromJSON(i){return new n(i.condition,i.trueExpr,i.falseExpr)}_toHTML(i){var o=i&&i.parenthesis?i.parenthesis:"keep",l=Cr(this,o,i&&i.implicit),u=this.condition.toHTML(i),s=Cr(this.condition,o,i&&i.implicit);(o==="all"||this.condition.type==="OperatorNode"||s!==null&&s<=l)&&(u='<span class="math-parenthesis math-round-parenthesis">(</span>'+u+'<span class="math-parenthesis math-round-parenthesis">)</span>');var c=this.trueExpr.toHTML(i),f=Cr(this.trueExpr,o,i&&i.implicit);(o==="all"||this.trueExpr.type==="OperatorNode"||f!==null&&f<=l)&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>');var m=this.falseExpr.toHTML(i),v=Cr(this.falseExpr,o,i&&i.implicit);return(o==="all"||this.falseExpr.type==="OperatorNode"||v!==null&&v<=l)&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>'),u+'<span class="math-operator math-conditional-operator">?</span>'+c+'<span class="math-operator math-conditional-operator">:</span>'+m}_toTex(i){return"\\begin{cases} {"+this.trueExpr.toTex(i)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(i)+"}\\\\{"+this.falseExpr.toTex(i)+"}, &\\quad{\\text{otherwise}}\\end{cases}"}}return Vr(n,"name",Do),n},{isClass:!0,isNode:!0}),$s=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},wS={"{":"\\{","}":"\\}","\\":"\\textbackslash{}","#":"\\#",$:"\\$","%":"\\%","&":"\\&","^":"\\textasciicircum{}",_:"\\_","~":"\\textasciitilde{}"},DS={"–":"\\--","—":"\\---"," ":"~"," ":"\\qquad{}","\r\n":"\\newline{}","\n":"\\newline{}"},NS=function(e,t){return $s({},e,t)},ES=function(r){for(var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.preserveFormatting,n=t===void 0?!1:t,a=e.escapeMapFn,i=a===void 0?NS:a,o=String(r),l="",u=i($s({},wS),n?$s({},DS):{}),s=Object.keys(u),c=function(){var m=!1;s.forEach(function(v,p){m||o.length>=v.length&&o.slice(0,v.length)===v&&(l+=u[s[p]],o=o.slice(v.length,o.length),m=!0)}),m||(l+=o.slice(0,1),o=o.slice(1,o.length))};o;)c();return l};const AS=Bs(ES);var qs={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{?}"},br={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"},ip={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(br.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(br.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(br.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(br.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(br.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(br.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(br.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(br.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(br.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(br.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(br.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(br.bitAnd,"${args[1]}\\right)")},bitNot:{1:br.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(br.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(br.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(br.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(br.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(br.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(br.and,"${args[1]}\\right)")},not:{1:br.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(br.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(br.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(br.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(br.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(br.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(br.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(br.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(br.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(br.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(br.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(br.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(br.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(br.to,"${args[1]}\\right)")},numeric:function(e,t){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},bigint:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(qs.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)"}},SS="\\mathrm{${name}}\\left(${args}\\right)",op={deg:"^\\circ"};function zs(r){return AS(r,{preserveFormatting:!0})}function sp(r,e){return e=typeof e>"u"?!1:e,e?$e(op,r)?op[r]:"\\mathrm{"+zs(r)+"}":$e(qs,r)?qs[r]:zs(r)}var No="ConstantNode",CS=["Node","isBounded"],MS=L(No,CS,r=>{var{Node:e,isBounded:t}=r;class n extends e{constructor(i){super(),this.value=i}get type(){return No}get isConstantNode(){return!0}_compile(i,o){var l=this.value;return function(){return l}}forEach(i){}map(i){return this.clone()}clone(){return new n(this.value)}_toString(i){return lr(this.value,i)}_toHTML(i){var o=this._toString(i);switch(Sr(this.value)){case"number":case"bigint":case"BigNumber":case"Fraction":return'<span class="math-number">'+o+"</span>";case"string":return'<span class="math-string">'+o+"</span>";case"boolean":return'<span class="math-boolean">'+o+"</span>";case"null":return'<span class="math-null-symbol">'+o+"</span>";case"undefined":return'<span class="math-undefined">'+o+"</span>";default:return'<span class="math-symbol">'+o+"</span>"}}toJSON(){return{mathjs:No,value:this.value}}static fromJSON(i){return new n(i.value)}_toTex(i){var o=this._toString(i),l=Sr(this.value);switch(l){case"string":return"\\mathtt{"+zs(o)+"}";case"number":case"BigNumber":{if(!t(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var u=o.toLowerCase().indexOf("e");return u!==-1?o.substring(0,u)+"\\cdot10^{"+o.substring(u+1)+"}":o}case"bigint":return o.toString();case"Fraction":return this.value.toLatex();default:return o}}}return Vr(n,"name",No),n},{isClass:!0,isNode:!0}),Eo="FunctionAssignmentNode",_S=["typed","Node"],TS=L(Eo,_S,r=>{var{typed:e,Node:t}=r;function n(i,o,l){var u=Cr(i,o,l),s=Cr(i.expr,o,l);return o==="all"||s!==null&&s<=u}class a extends t{constructor(o,l,u){if(super(),typeof o!="string")throw new TypeError('String expected for parameter "name"');if(!Array.isArray(l))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!Nr(u))throw new TypeError('Node expected for parameter "expr"');if(np.has(o))throw new Error('Illegal function name, "'+o+'" is a reserved keyword');var s=new Set;for(var c of l){var f=typeof c=="string"?c:c.name;if(s.has(f))throw new Error('Duplicate parameter name "'.concat(f,'"'));s.add(f)}this.name=o,this.params=l.map(function(m){return m&&m.name||m}),this.types=l.map(function(m){return m&&m.type||"any"}),this.expr=u}get type(){return Eo}get isFunctionAssignmentNode(){return!0}_compile(o,l){var u=Object.create(l);Rl(this.params,function(d){u[d]=!0});var s=this.expr,c=s._compile(o,u),f=this.name,m=this.params,v=$l(this.types,","),p=f+"("+$l(this.params,", ")+")";return function(y,x,D){var h={};h[v]=function(){for(var g=Object.create(x),b=0;b<m.length;b++)g[m[b]]=arguments[b];return c(y,g,D)};var w=e(f,h);return w.syntax=p,w.expr=s.toString(),y.set(f,w),w}}forEach(o){o(this.expr,"expr",this)}map(o){var l=this._ifNode(o(this.expr,"expr",this));return new a(this.name,this.params.slice(0),l)}clone(){return new a(this.name,this.params.slice(0),this.expr)}_toString(o){var l=o&&o.parenthesis?o.parenthesis:"keep",u=this.expr.toString(o);return n(this,l,o&&o.implicit)&&(u="("+u+")"),this.name+"("+this.params.join(", ")+") = "+u}toJSON(){var o=this.types;return{mathjs:Eo,name:this.name,params:this.params.map(function(l,u){return{name:l,type:o[u]}}),expr:this.expr}}static fromJSON(o){return new a(o.name,o.params,o.expr)}_toHTML(o){for(var l=o&&o.parenthesis?o.parenthesis:"keep",u=[],s=0;s<this.params.length;s++)u.push('<span class="math-symbol math-parameter">'+qt(this.params[s])+"</span>");var c=this.expr.toHTML(o);return n(this,l,o&&o.implicit)&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>'),'<span class="math-function">'+qt(this.name)+'</span><span class="math-parenthesis math-round-parenthesis">(</span>'+u.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>'+c}_toTex(o){var l=o&&o.parenthesis?o.parenthesis:"keep",u=this.expr.toTex(o);return n(this,l,o&&o.implicit)&&(u="\\left(".concat(u,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(sp).join(",")+"\\right)="+u}}return Vr(a,"name",Eo),a},{isClass:!0,isNode:!0}),Ao="IndexNode",FS=["Node","size"],OS=L(Ao,FS,r=>{var{Node:e,size:t}=r;class n extends e{constructor(i,o){if(super(),this.dimensions=i,this.dotNotation=o||!1,!Array.isArray(i)||!i.every(Nr))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}get type(){return Ao}get isIndexNode(){return!0}_compile(i,o){var l=Bn(this.dimensions,function(s,c){var f=s.filter(p=>p.isSymbolNode&&p.name==="end").length>0;if(f){var m=Object.create(o);m.end=!0;var v=s._compile(i,m);return function(d,y,x){if(!Je(x)&&!Ar(x)&&!$r(x))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+Sr(x));var D=t(x),h=Object.create(y);return h.end=D[c],v(d,h,x)}}else return s._compile(i,o)}),u=pt(i,"index");return function(c,f,m){var v=Bn(l,function(p){return p(c,f,m)});return u(...v)}}forEach(i){for(var o=0;o<this.dimensions.length;o++)i(this.dimensions[o],"dimensions["+o+"]",this)}map(i){for(var o=[],l=0;l<this.dimensions.length;l++)o[l]=this._ifNode(i(this.dimensions[l],"dimensions["+l+"]",this));return new n(o,this.dotNotation)}clone(){return new n(this.dimensions.slice(0),this.dotNotation)}isObjectProperty(){return this.dimensions.length===1&&gr(this.dimensions[0])&&typeof this.dimensions[0].value=="string"}getObjectProperty(){return this.isObjectProperty()?this.dimensions[0].value:null}_toString(i){return this.dotNotation?"."+this.getObjectProperty():"["+this.dimensions.join(", ")+"]"}toJSON(){return{mathjs:Ao,dimensions:this.dimensions,dotNotation:this.dotNotation}}static fromJSON(i){return new n(i.dimensions,i.dotNotation)}_toHTML(i){for(var o=[],l=0;l<this.dimensions.length;l++)o[l]=this.dimensions[l].toHTML();return this.dotNotation?'<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">'+qt(this.getObjectProperty())+"</span>":'<span class="math-parenthesis math-square-parenthesis">[</span>'+o.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(i){var o=this.dimensions.map(function(l){return l.toTex(i)});return this.dotNotation?"."+this.getObjectProperty():"_{"+o.join(",")+"}"}}return Vr(n,"name",Ao),n},{isClass:!0,isNode:!0}),So="ObjectNode",BS=["Node"],RS=L(So,BS,r=>{var{Node:e}=r;class t extends e{constructor(a){if(super(),this.properties=a||{},a&&(typeof a!="object"||!Object.keys(a).every(function(i){return Nr(a[i])})))throw new TypeError("Object containing Nodes expected")}get type(){return So}get isObjectNode(){return!0}_compile(a,i){var o={};for(var l in this.properties)if($e(this.properties,l)){var u=Da(l),s=JSON.parse(u),c=pt(this.properties,l);o[s]=c._compile(a,i)}return function(m,v,p){var d={};for(var y in o)$e(o,y)&&(d[y]=o[y](m,v,p));return d}}forEach(a){for(var i in this.properties)$e(this.properties,i)&&a(this.properties[i],"properties["+Da(i)+"]",this)}map(a){var i={};for(var o in this.properties)$e(this.properties,o)&&(i[o]=this._ifNode(a(this.properties[o],"properties["+Da(o)+"]",this)));return new t(i)}clone(){var a={};for(var i in this.properties)$e(this.properties,i)&&(a[i]=this.properties[i]);return new t(a)}_toString(a){var i=[];for(var o in this.properties)$e(this.properties,o)&&i.push(Da(o)+": "+this.properties[o].toString(a));return"{"+i.join(", ")+"}"}toJSON(){return{mathjs:So,properties:this.properties}}static fromJSON(a){return new t(a.properties)}_toHTML(a){var i=[];for(var o in this.properties)$e(this.properties,o)&&i.push('<span class="math-symbol math-property">'+qt(o)+'</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>'+this.properties[o].toHTML(a));return'<span class="math-parenthesis math-curly-parenthesis">{</span>'+i.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-curly-parenthesis">}</span>'}_toTex(a){var i=[];for(var o in this.properties)$e(this.properties,o)&&i.push("\\mathbf{"+o+":} & "+this.properties[o].toTex(a)+"\\\\");var l="\\left\\{\\begin{array}{ll}"+i.join(`
|
|
21
|
+
`)+"\\end{array}\\right\\}";return l}}return Vr(t,"name",So),t},{isClass:!0,isNode:!0});function fi(r,e){return new Yu(r,new Mi(e),new Set(Object.keys(e)))}var Co="OperatorNode",IS=["Node"],PS=L(Co,IS,r=>{var{Node:e}=r;function t(i,o){var l=i;if(o==="auto")for(;fn(l);)l=l.content;return gr(l)?!0:Ur(l)?t(l.args[0],o):!1}function n(i,o,l,u,s){var c=Cr(i,o,l),f=ci(i,o);if(o==="all"||u.length>2&&i.getIdentifier()!=="OperatorNode:add"&&i.getIdentifier()!=="OperatorNode:multiply")return u.map(function(S){switch(S.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}});var m;switch(u.length){case 0:m=[];break;case 1:{var v=Cr(u[0],o,l,i);if(s&&v!==null){var p,d;if(o==="keep"?(p=u[0].getIdentifier(),d=i.getIdentifier()):(p=u[0].getContent().getIdentifier(),d=i.getContent().getIdentifier()),jt[c][d].latexLeftParens===!1){m=[!1];break}if(jt[v][p].latexParens===!1){m=[!1];break}}if(v===null){m=[!1];break}if(v<=c){m=[!0];break}m=[!1]}break;case 2:{var y,x=Cr(u[0],o,l,i),D=Ps(i,u[0],o);x===null?y=!1:x===c&&f==="right"&&!D||x<c?y=!0:y=!1;var h,w=Cr(u[1],o,l,i),g=Ps(i,u[1],o);if(w===null?h=!1:w===c&&f==="left"&&!g||w<c?h=!0:h=!1,s){var b,A,N;o==="keep"?(b=i.getIdentifier(),A=i.args[0].getIdentifier(),N=i.args[1].getIdentifier()):(b=i.getContent().getIdentifier(),A=i.args[0].getContent().getIdentifier(),N=i.args[1].getContent().getIdentifier()),x!==null&&(jt[c][b].latexLeftParens===!1&&(y=!1),jt[x][A].latexParens===!1&&(y=!1)),w!==null&&(jt[c][b].latexRightParens===!1&&(h=!1),jt[w][N].latexParens===!1&&(h=!1))}m=[y,h]}break;default:(i.getIdentifier()==="OperatorNode:add"||i.getIdentifier()==="OperatorNode:multiply")&&(m=u.map(function(S){var C=Cr(S,o,l,i),M=Ps(i,S,o),O=ci(S,o);return C===null?!1:c===C&&f===O&&!M?!0:C<c}));break}if(u.length>=2&&i.getIdentifier()==="OperatorNode:multiply"&&i.implicit&&o!=="all"&&l==="hide")for(var E=1;E<m.length;++E)t(u[E],o)&&!m[E-1]&&(o!=="keep"||!fn(u[E-1]))&&(m[E]=!0);return m}class a extends e{constructor(o,l,u,s,c){if(super(),typeof o!="string")throw new TypeError('string expected for parameter "op"');if(typeof l!="string")throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(u)||!u.every(Nr))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=s===!0,this.isPercentage=c===!0,this.op=o,this.fn=l,this.args=u||[]}get type(){return Co}get isOperatorNode(){return!0}_compile(o,l){if(typeof this.fn!="string"||!Jo(o,this.fn))throw o[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var u=pt(o,this.fn),s=Bn(this.args,function(p){return p._compile(o,l)});if(typeof u=="function"&&u.rawArgs===!0){var c=this.args;return function(d,y,x){return u(c,o,fi(d,y))}}else if(s.length===1){var f=s[0];return function(d,y,x){return u(f(d,y,x))}}else if(s.length===2){var m=s[0],v=s[1];return function(d,y,x){return u(m(d,y,x),v(d,y,x))}}else return function(d,y,x){return u.apply(null,Bn(s,function(D){return D(d,y,x)}))}}forEach(o){for(var l=0;l<this.args.length;l++)o(this.args[l],"args["+l+"]",this)}map(o){for(var l=[],u=0;u<this.args.length;u++)l[u]=this._ifNode(o(this.args[u],"args["+u+"]",this));return new a(this.op,this.fn,l,this.implicit,this.isPercentage)}clone(){return new a(this.op,this.fn,this.args.slice(0),this.implicit,this.isPercentage)}isUnary(){return this.args.length===1}isBinary(){return this.args.length===2}_toString(o){var l=o&&o.parenthesis?o.parenthesis:"keep",u=o&&o.implicit?o.implicit:"hide",s=this.args,c=n(this,l,u,s,!1);if(s.length===1){var f=ci(this,l),m=s[0].toString(o);c[0]&&(m="("+m+")");var v=/[a-zA-Z]+/.test(this.op);return f==="right"?this.op+(v?" ":"")+m:f==="left"?m+(v?" ":"")+this.op:m+this.op}else if(s.length===2){var p=s[0].toString(o),d=s[1].toString(o);return c[0]&&(p="("+p+")"),c[1]&&(d="("+d+")"),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&u==="hide"?p+" "+d:p+" "+this.op+" "+d}else if(s.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var y=s.map(function(x,D){return x=x.toString(o),c[D]&&(x="("+x+")"),x});return this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&u==="hide"?y.join(" "):y.join(" "+this.op+" ")}else return this.fn+"("+this.args.join(", ")+")"}toJSON(){return{mathjs:Co,op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}}static fromJSON(o){return new a(o.op,o.fn,o.args,o.implicit,o.isPercentage)}_toHTML(o){var l=o&&o.parenthesis?o.parenthesis:"keep",u=o&&o.implicit?o.implicit:"hide",s=this.args,c=n(this,l,u,s,!1);if(s.length===1){var f=ci(this,l),m=s[0].toHTML(o);return c[0]&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>'),f==="right"?'<span class="math-operator math-unary-operator math-lefthand-unary-operator">'+qt(this.op)+"</span>"+m:m+'<span class="math-operator math-unary-operator math-righthand-unary-operator">'+qt(this.op)+"</span>"}else if(s.length===2){var v=s[0].toHTML(o),p=s[1].toHTML(o);return c[0]&&(v='<span class="math-parenthesis math-round-parenthesis">(</span>'+v+'<span class="math-parenthesis math-round-parenthesis">)</span>'),c[1]&&(p='<span class="math-parenthesis math-round-parenthesis">(</span>'+p+'<span class="math-parenthesis math-round-parenthesis">)</span>'),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&u==="hide"?v+'<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'+p:v+'<span class="math-operator math-binary-operator math-explicit-binary-operator">'+qt(this.op)+"</span>"+p}else{var d=s.map(function(y,x){return y=y.toHTML(o),c[x]&&(y='<span class="math-parenthesis math-round-parenthesis">(</span>'+y+'<span class="math-parenthesis math-round-parenthesis">)</span>'),y});return s.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")?this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&u==="hide"?d.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'):d.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">'+qt(this.op)+"</span>"):'<span class="math-function">'+qt(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+d.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}}_toTex(o){var l=o&&o.parenthesis?o.parenthesis:"keep",u=o&&o.implicit?o.implicit:"hide",s=this.args,c=n(this,l,u,s,!0),f=br[this.fn];if(f=typeof f>"u"?this.op:f,s.length===1){var m=ci(this,l),v=s[0].toTex(o);return c[0]&&(v="\\left(".concat(v,"\\right)")),m==="right"?f+v:v+f}else if(s.length===2){var p=s[0],d=p.toTex(o);c[0]&&(d="\\left(".concat(d,"\\right)"));var y=s[1],x=y.toTex(o);c[1]&&(x="\\left(".concat(x,"\\right)"));var D;switch(l==="keep"?D=p.getIdentifier():D=p.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return f+"{"+d+"}{"+x+"}";case"OperatorNode:pow":switch(d="{"+d+"}",x="{"+x+"}",D){case"ConditionalNode":case"OperatorNode:divide":d="\\left(".concat(d,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&u==="hide")return d+"~"+x}return d+f+x}else if(s.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var h=s.map(function(w,g){return w=w.toTex(o),c[g]&&(w="\\left(".concat(w,"\\right)")),w});return this.getIdentifier()==="OperatorNode:multiply"&&this.implicit&&u==="hide"?h.join("~"):h.join(f)}else return"\\mathrm{"+this.fn+"}\\left("+s.map(function(w){return w.toTex(o)}).join(",")+"\\right)"}getIdentifier(){return this.type+":"+this.fn}}return Vr(a,"name",Co),a},{isClass:!0,isNode:!0}),Mo="ParenthesisNode",$S=["Node"],qS=L(Mo,$S,r=>{var{Node:e}=r;class t extends e{constructor(a){if(super(),!Nr(a))throw new TypeError('Node expected for parameter "content"');this.content=a}get type(){return Mo}get isParenthesisNode(){return!0}_compile(a,i){return this.content._compile(a,i)}getContent(){return this.content.getContent()}forEach(a){a(this.content,"content",this)}map(a){var i=a(this.content,"content",this);return new t(i)}clone(){return new t(this.content)}_toString(a){return!a||a&&!a.parenthesis||a&&a.parenthesis==="keep"?"("+this.content.toString(a)+")":this.content.toString(a)}toJSON(){return{mathjs:Mo,content:this.content}}static fromJSON(a){return new t(a.content)}_toHTML(a){return!a||a&&!a.parenthesis||a&&a.parenthesis==="keep"?'<span class="math-parenthesis math-round-parenthesis">(</span>'+this.content.toHTML(a)+'<span class="math-parenthesis math-round-parenthesis">)</span>':this.content.toHTML(a)}_toTex(a){return!a||a&&!a.parenthesis||a&&a.parenthesis==="keep"?"\\left(".concat(this.content.toTex(a),"\\right)"):this.content.toTex(a)}}return Vr(t,"name",Mo),t},{isClass:!0,isNode:!0}),_o="RangeNode",zS=["Node"],US=L(_o,zS,r=>{var{Node:e}=r;function t(a,i,o){var l=Cr(a,i,o),u={},s=Cr(a.start,i,o);if(u.start=s!==null&&s<=l||i==="all",a.step){var c=Cr(a.step,i,o);u.step=c!==null&&c<=l||i==="all"}var f=Cr(a.end,i,o);return u.end=f!==null&&f<=l||i==="all",u}class n extends e{constructor(i,o,l){if(super(),!Nr(i))throw new TypeError("Node expected");if(!Nr(o))throw new TypeError("Node expected");if(l&&!Nr(l))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=i,this.end=o,this.step=l||null}get type(){return _o}get isRangeNode(){return!0}needsEnd(){var i=this.filter(function(o){return jr(o)&&o.name==="end"});return i.length>0}_compile(i,o){var l=i.range,u=this.start._compile(i,o),s=this.end._compile(i,o);if(this.step){var c=this.step._compile(i,o);return function(m,v,p){return l(u(m,v,p),s(m,v,p),c(m,v,p))}}else return function(m,v,p){return l(u(m,v,p),s(m,v,p))}}forEach(i){i(this.start,"start",this),i(this.end,"end",this),this.step&&i(this.step,"step",this)}map(i){return new n(this._ifNode(i(this.start,"start",this)),this._ifNode(i(this.end,"end",this)),this.step&&this._ifNode(i(this.step,"step",this)))}clone(){return new n(this.start,this.end,this.step&&this.step)}_toString(i){var o=i&&i.parenthesis?i.parenthesis:"keep",l=t(this,o,i&&i.implicit),u,s=this.start.toString(i);if(l.start&&(s="("+s+")"),u=s,this.step){var c=this.step.toString(i);l.step&&(c="("+c+")"),u+=":"+c}var f=this.end.toString(i);return l.end&&(f="("+f+")"),u+=":"+f,u}toJSON(){return{mathjs:_o,start:this.start,end:this.end,step:this.step}}static fromJSON(i){return new n(i.start,i.end,i.step)}_toHTML(i){var o=i&&i.parenthesis?i.parenthesis:"keep",l=t(this,o,i&&i.implicit),u,s=this.start.toHTML(i);if(l.start&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),u=s,this.step){var c=this.step.toHTML(i);l.step&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>'),u+='<span class="math-operator math-range-operator">:</span>'+c}var f=this.end.toHTML(i);return l.end&&(f='<span class="math-parenthesis math-round-parenthesis">(</span>'+f+'<span class="math-parenthesis math-round-parenthesis">)</span>'),u+='<span class="math-operator math-range-operator">:</span>'+f,u}_toTex(i){var o=i&&i.parenthesis?i.parenthesis:"keep",l=t(this,o,i&&i.implicit),u=this.start.toTex(i);if(l.start&&(u="\\left(".concat(u,"\\right)")),this.step){var s=this.step.toTex(i);l.step&&(s="\\left(".concat(s,"\\right)")),u+=":"+s}var c=this.end.toTex(i);return l.end&&(c="\\left(".concat(c,"\\right)")),u+=":"+c,u}}return Vr(n,"name",_o),n},{isClass:!0,isNode:!0}),To="RelationalNode",LS=["Node"],kS=L(To,LS,r=>{var{Node:e}=r,t={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="};class n extends e{constructor(i,o){if(super(),!Array.isArray(i))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(o))throw new TypeError("Parameter params must be an array");if(i.length!==o.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=i,this.params=o}get type(){return To}get isRelationalNode(){return!0}_compile(i,o){var l=this,u=this.params.map(s=>s._compile(i,o));return function(c,f,m){for(var v,p=u[0](c,f,m),d=0;d<l.conditionals.length;d++){v=p,p=u[d+1](c,f,m);var y=pt(i,l.conditionals[d]);if(!y(v,p))return!1}return!0}}forEach(i){this.params.forEach((o,l)=>i(o,"params["+l+"]",this),this)}map(i){return new n(this.conditionals.slice(),this.params.map((o,l)=>this._ifNode(i(o,"params["+l+"]",this)),this))}clone(){return new n(this.conditionals,this.params)}_toString(i){for(var o=i&&i.parenthesis?i.parenthesis:"keep",l=Cr(this,o,i&&i.implicit),u=this.params.map(function(f,m){var v=Cr(f,o,i&&i.implicit);return o==="all"||v!==null&&v<=l?"("+f.toString(i)+")":f.toString(i)}),s=u[0],c=0;c<this.conditionals.length;c++)s+=" "+t[this.conditionals[c]],s+=" "+u[c+1];return s}toJSON(){return{mathjs:To,conditionals:this.conditionals,params:this.params}}static fromJSON(i){return new n(i.conditionals,i.params)}_toHTML(i){for(var o=i&&i.parenthesis?i.parenthesis:"keep",l=Cr(this,o,i&&i.implicit),u=this.params.map(function(f,m){var v=Cr(f,o,i&&i.implicit);return o==="all"||v!==null&&v<=l?'<span class="math-parenthesis math-round-parenthesis">(</span>'+f.toHTML(i)+'<span class="math-parenthesis math-round-parenthesis">)</span>':f.toHTML(i)}),s=u[0],c=0;c<this.conditionals.length;c++)s+='<span class="math-operator math-binary-operator math-explicit-binary-operator">'+qt(t[this.conditionals[c]])+"</span>"+u[c+1];return s}_toTex(i){for(var o=i&&i.parenthesis?i.parenthesis:"keep",l=Cr(this,o,i&&i.implicit),u=this.params.map(function(f,m){var v=Cr(f,o,i&&i.implicit);return o==="all"||v!==null&&v<=l?"\\left("+f.toTex(i)+"\right)":f.toTex(i)}),s=u[0],c=0;c<this.conditionals.length;c++)s+=br[this.conditionals[c]]+u[c+1];return s}}return Vr(n,"name",To),n},{isClass:!0,isNode:!0}),VS="SymbolNode",GS=["math","?Unit","Node"],HS=L(VS,GS,r=>{var{math:e,Unit:t,Node:n}=r;function a(o){return t?t.isValuelessUnit(o):!1}class i extends n{constructor(l){if(super(),typeof l!="string")throw new TypeError('String expected for parameter "name"');this.name=l}get type(){return"SymbolNode"}get isSymbolNode(){return!0}_compile(l,u){var s=this.name;if(u[s]===!0)return function(f,m,v){return pt(m,s)};if(s in l)return function(f,m,v){return f.has(s)?f.get(s):pt(l,s)};var c=a(s);return function(f,m,v){return f.has(s)?f.get(s):c?new t(null,s):i.onUndefinedSymbol(s)}}forEach(l){}map(l){return this.clone()}static onUndefinedSymbol(l){throw new Error("Undefined symbol "+l)}clone(){return new i(this.name)}_toString(l){return this.name}_toHTML(l){var u=qt(this.name);return u==="true"||u==="false"?'<span class="math-symbol math-boolean">'+u+"</span>":u==="i"?'<span class="math-symbol math-imaginary-symbol">'+u+"</span>":u==="Infinity"?'<span class="math-symbol math-infinity-symbol">'+u+"</span>":u==="NaN"?'<span class="math-symbol math-nan-symbol">'+u+"</span>":u==="null"?'<span class="math-symbol math-null-symbol">'+u+"</span>":u==="undefined"?'<span class="math-symbol math-undefined-symbol">'+u+"</span>":'<span class="math-symbol">'+u+"</span>"}toJSON(){return{mathjs:"SymbolNode",name:this.name}}static fromJSON(l){return new i(l.name)}_toTex(l){var u=!1;typeof e[this.name]>"u"&&a(this.name)&&(u=!0);var s=sp(this.name,u);return s[0]==="\\"?s:" "+s}}return i},{isClass:!0,isNode:!0}),Fo="FunctionNode",WS=["math","Node","SymbolNode"],YS=L(Fo,WS,r=>{var e,{math:t,Node:n,SymbolNode:a}=r,i=u=>lr(u,{truncate:78});function o(u,s,c){for(var f="",m=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,v=0,p;(p=m.exec(u))!==null;)if(f+=u.substring(v,p.index),v=p.index,p[0]==="$$")f+="$",v++;else{v+=p[0].length;var d=s[p[1]];if(!d)throw new ReferenceError("Template: Property "+p[1]+" does not exist.");if(p[2]===void 0)switch(typeof d){case"string":f+=d;break;case"object":if(Nr(d))f+=d.toTex(c);else if(Array.isArray(d))f+=d.map(function(y,x){if(Nr(y))return y.toTex(c);throw new TypeError("Template: "+p[1]+"["+x+"] is not a Node.")}).join(",");else throw new TypeError("Template: "+p[1]+" has to be a Node, String or array of Nodes");break;default:throw new TypeError("Template: "+p[1]+" has to be a Node, String or array of Nodes")}else if(Nr(d[p[2]]&&d[p[2]]))f+=d[p[2]].toTex(c);else throw new TypeError("Template: "+p[1]+"["+p[2]+"] is not a Node.")}return f+=u.slice(v),f}class l extends n{constructor(s,c,f){if(super(),typeof s=="string"&&(s=new a(s)),!Nr(s))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(c)||!c.every(Nr))throw new TypeError('Array containing Nodes expected for parameter "args"');var m=typeof f;if(!(m==="undefined"||m==="boolean"))throw new TypeError("optional flag, if specified, must be boolean");this.fn=s,this.args=c||[],this.optional=!!f}get name(){return this.fn.name||""}get type(){return Fo}get isFunctionNode(){return!0}_compile(s,c){var f=this.args.map(E=>E._compile(s,c)),m=this.optional||cn(this.fn)&&this.fn.optionalChaining;if(jr(this.fn)){var v=this.fn.name;if(c[v]){var D=this.args;return function(S,C,M){var O=pt(C,v);if(!(m&&O===void 0)){if(typeof O!="function")throw new TypeError("Argument '".concat(v,"' was not a function; received: ").concat(i(O)));if(O.rawArgs)return O(D,s,fi(S,C));var I=f.map(k=>k(S,C,M));return O.apply(O,I)}}}else{var p=v in s?pt(s,v):void 0,d=typeof p=="function"&&p.rawArgs===!0,y=E=>{var S;if(E.has(v))S=E.get(v);else if(v in s)S=pt(s,v);else if(m)S=void 0;else return l.onUndefinedFunction(v);if(typeof S=="function"||m&&S===void 0)return S;throw new TypeError("'".concat(v,`' is not a function; its value is:
|
|
22
22
|
`).concat(i(S)))};if(d){var x=this.args;return function(S,C,M){var O=y(S);if(O.rawArgs===!0)return O(x,s,fi(S,C));var I=f.map(k=>k(S,C,M));return O(...I)}}else switch(f.length){case 0:return function(S,C,M){var O=y(S);if(!(m&&O===void 0))return O()};case 1:return function(S,C,M){var O=y(S);if(!(m&&O===void 0)){var I=f[0];return O(I(S,C,M))}};case 2:return function(S,C,M){var O=y(S);if(!(m&&O===void 0)){var I=f[0],k=f[1];return O(I(S,C,M),k(S,C,M))}};default:return function(S,C,M){var O=y(S);if(!(m&&O===void 0)){var I=f.map(k=>k(S,C,M));return O(...I)}}}}}else if(cn(this.fn)&&pa(this.fn.index)&&this.fn.index.isObjectProperty()){var h=this.fn.object._compile(s,c),w=this.fn.index.getObjectProperty(),g=this.args;return function(S,C,M){var O=h(S,C,M);if(!(m&&(O==null||O[w]===void 0))){var I=v0(O,w);if(I!=null&&I.rawArgs)return I(g,s,fi(S,C));var k=f.map(_=>_(S,C,M));return I.apply(O,k)}}}else{var b=this.fn.toString(),A=this.fn._compile(s,c),N=this.args;return function(S,C,M){var O=A(S,C,M);if(!(m&&O===void 0)){if(typeof O!="function")throw new TypeError("Expression '".concat(b,"' did not evaluate to a function; value is:")+`
|
|
23
|
-
`.concat(i(O)));if(O.rawArgs)return O(N,s,fi(S,C));var I=f.map(k=>k(S,C,M));return O.apply(O,I)}}}}forEach(s){s(this.fn,"fn",this);for(var c=0;c<this.args.length;c++)s(this.args[c],"args["+c+"]",this)}map(s){for(var c=this._ifNode(s(this.fn,"fn",this)),f=[],m=0;m<this.args.length;m++)f[m]=this._ifNode(s(this.args[m],"args["+m+"]",this));return new l(c,f)}clone(){return new l(this.fn,this.args.slice(0))}toString(s){var c,f=this.fn.toString(s);return s&&typeof s.handler=="object"&&$e(s.handler,f)&&(c=s.handler[f](this,s)),typeof c<"u"?c:super.toString(s)}_toString(s){var c=this.args.map(function(m){return m.toString(s)}),f=ei(this.fn)?"("+this.fn.toString(s)+")":this.fn.toString(s);return f+"("+c.join(", ")+")"}toJSON(){return{mathjs:Fo,fn:this.fn,args:this.args}}_toHTML(s){var c=this.args.map(function(f){return f.toHTML(s)});return'<span class="math-function">'+qt(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+c.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}toTex(s){var c;return s&&typeof s.handler=="object"&&$e(s.handler,this.name)&&(c=s.handler[this.name](this,s)),typeof c<"u"?c:super.toTex(s)}_toTex(s){var c=this.args.map(function(v){return v.toTex(s)}),f;
|
|
23
|
+
`.concat(i(O)));if(O.rawArgs)return O(N,s,fi(S,C));var I=f.map(k=>k(S,C,M));return O.apply(O,I)}}}}forEach(s){s(this.fn,"fn",this);for(var c=0;c<this.args.length;c++)s(this.args[c],"args["+c+"]",this)}map(s){for(var c=this._ifNode(s(this.fn,"fn",this)),f=[],m=0;m<this.args.length;m++)f[m]=this._ifNode(s(this.args[m],"args["+m+"]",this));return new l(c,f)}clone(){return new l(this.fn,this.args.slice(0))}toString(s){var c,f=this.fn.toString(s);return s&&typeof s.handler=="object"&&$e(s.handler,f)&&(c=s.handler[f](this,s)),typeof c<"u"?c:super.toString(s)}_toString(s){var c=this.args.map(function(m){return m.toString(s)}),f=ei(this.fn)?"("+this.fn.toString(s)+")":this.fn.toString(s);return f+"("+c.join(", ")+")"}toJSON(){return{mathjs:Fo,fn:this.fn,args:this.args}}_toHTML(s){var c=this.args.map(function(f){return f.toHTML(s)});return'<span class="math-function">'+qt(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+c.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}toTex(s){var c;return s&&typeof s.handler=="object"&&$e(s.handler,this.name)&&(c=s.handler[this.name](this,s)),typeof c<"u"?c:super.toTex(s)}_toTex(s){var c=this.args.map(function(v){return v.toTex(s)}),f;ip[this.name]&&(f=ip[this.name]),t[this.name]&&(typeof t[this.name].toTex=="function"||typeof t[this.name].toTex=="object"||typeof t[this.name].toTex=="string")&&(f=t[this.name].toTex);var m;switch(typeof f){case"function":m=f(this,s);break;case"string":m=o(f,this,s);break;case"object":switch(typeof f[c.length]){case"function":m=f[c.length](this,s);break;case"string":m=o(f[c.length],this,s);break}}return typeof m<"u"?m:o(SS,this,s)}getIdentifier(){return this.type+":"+this.name}}return e=l,Vr(l,"name",Fo),Vr(l,"onUndefinedFunction",function(u){throw new Error("Undefined function "+u)}),Vr(l,"fromJSON",function(u){return new e(u.fn,u.args)}),l},{isClass:!0,isNode:!0}),up="parse",ZS=["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],JS=L(up,ZS,r=>{var{typed:e,numeric:t,config:n,AccessorNode:a,ArrayNode:i,AssignmentNode:o,BlockNode:l,ConditionalNode:u,ConstantNode:s,FunctionAssignmentNode:c,FunctionNode:f,IndexNode:m,ObjectNode:v,OperatorNode:p,ParenthesisNode:d,RangeNode:y,RelationalNode:x,SymbolNode:D}=r,h=e(up,{string:function(K){return ne(K,{})},"Array | Matrix":function(K){return w(K,{})},"string, Object":function(K,de){var Se=de.nodes!==void 0?de.nodes:{};return ne(K,Se)},"Array | Matrix, Object":w});function w(T){var K=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},de=K.nodes!==void 0?K.nodes:{};return tr(T,function(Se){if(typeof Se!="string")throw new TypeError("String expected");return ne(Se,de)})}var g={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},b={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"?.":!0,"??":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},A={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},N={true:!0,false:!1,null:null,undefined:void 0},E=["NaN","Infinity"],S={'"':'"',"'":"'","\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
24
24
|
`,r:"\r",t:" "};function C(){return{extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:g.NULL,nestingLevel:0,conditionalLevel:null}}function M(T,K){return T.expression.substr(T.index,K)}function O(T){return M(T,1)}function I(T){T.index++}function k(T){return T.expression.charAt(T.index-1)}function _(T){return T.expression.charAt(T.index+1)}function P(T){for(T.tokenType=g.NULL,T.token="",T.comment="";;){if(O(T)==="#")for(;O(T)!==`
|
|
25
25
|
`&&O(T)!=="";)T.comment+=O(T),I(T);if(h.isWhitespace(O(T),T.nestingLevel))I(T);else break}if(O(T)===""){T.tokenType=g.DELIMITER;return}if(O(T)===`
|
|
26
26
|
`&&!T.nestingLevel){T.tokenType=g.DELIMITER,T.token=O(T),I(T);return}var K=O(T),de=M(T,2),Se=M(T,3);if(Se.length===3&&b[Se]){T.tokenType=g.DELIMITER,T.token=Se,I(T),I(T),I(T);return}if(de.length===2&&b[de]&&(de!=="?."||!h.isDigit(T.expression.charAt(T.index+2)))){T.tokenType=g.DELIMITER,T.token=de,I(T),I(T);return}if(b[K]){T.tokenType=g.DELIMITER,T.token=K,I(T);return}if(h.isDigitDot(K)){T.tokenType=g.NUMBER;var ze=M(T,2);if(ze==="0b"||ze==="0o"||ze==="0x"){for(T.token+=O(T),I(T),T.token+=O(T),I(T);h.isAlpha(O(T),k(T),_(T))||h.isDigit(O(T));)T.token+=O(T),I(T);if(O(T)===".")for(T.token+=".",I(T);h.isAlpha(O(T),k(T),_(T))||h.isDigit(O(T));)T.token+=O(T),I(T);else if(O(T)==="i")for(T.token+="i",I(T);h.isDigit(O(T));)T.token+=O(T),I(T);return}if(O(T)==="."){if(T.token+=O(T),I(T),!h.isDigit(O(T))){T.tokenType=g.DELIMITER;return}}else{for(;h.isDigit(O(T));)T.token+=O(T),I(T);h.isDecimalMark(O(T),_(T))&&(T.token+=O(T),I(T))}for(;h.isDigit(O(T));)T.token+=O(T),I(T);if(O(T)==="E"||O(T)==="e"){if(h.isDigit(_(T))||_(T)==="-"||_(T)==="+"){if(T.token+=O(T),I(T),(O(T)==="+"||O(T)==="-")&&(T.token+=O(T),I(T)),!h.isDigit(O(T)))throw ir(T,'Digit expected, got "'+O(T)+'"');for(;h.isDigit(O(T));)T.token+=O(T),I(T);if(h.isDecimalMark(O(T),_(T)))throw ir(T,'Digit expected, got "'+O(T)+'"')}else if(h.isDecimalMark(_(T),T.expression.charAt(T.index+2)))throw I(T),ir(T,'Digit expected, got "'+O(T)+'"')}return}if(h.isAlpha(O(T),k(T),_(T))){for(;h.isAlpha(O(T),k(T),_(T))||h.isDigit(O(T));)T.token+=O(T),I(T);$e(A,T.token)?T.tokenType=g.DELIMITER:T.tokenType=g.SYMBOL;return}for(T.tokenType=g.UNKNOWN;O(T)!=="";)T.token+=O(T),I(T);throw ir(T,'Syntax error in part "'+T.token+'"')}function V(T){do P(T);while(T.token===`
|
|
@@ -28,16 +28,16 @@ Example:
|
|
|
28
28
|
`&&de>0},h.isDecimalMark=function(K,de){return K==="."&&de!=="/"&&de!=="*"&&de!=="^"},h.isDigitDot=function(K){return K>="0"&&K<="9"||K==="."},h.isDigit=function(K){return K>="0"&&K<="9"};function ne(T,K){var de=C();zr(de,{expression:T,extraNodes:K}),P(de);var Se=j(de);if(de.token!=="")throw de.tokenType===g.DELIMITER?Fr(de,"Unexpected operator "+de.token):ir(de,'Unexpected part "'+de.token+'"');return Se}function j(T){var K,de=[],Se;for(T.token!==""&&T.token!==`
|
|
29
29
|
`&&T.token!==";"&&(K=F(T),T.comment&&(K.comment=T.comment));T.token===`
|
|
30
30
|
`||T.token===";";)de.length===0&&K&&(Se=T.token!==";",de.push({node:K,visible:Se})),P(T),T.token!==`
|
|
31
|
-
`&&T.token!==";"&&T.token!==""&&(K=F(T),T.comment&&(K.comment=T.comment),Se=T.token!==";",de.push({node:K,visible:Se}));return de.length>0?new l(de):(K||(K=new s(void 0),T.comment&&(K.comment=T.comment)),K)}function F(T){var K,de,Se,ze,Ke=U(T);if(T.token==="="){if(Jr(Ke))return K=Ke.name,V(T),Se=F(T),new o(new D(K),Se);if(cn(Ke)){if(Ke.optionalChaining)throw ir(T,"Cannot assign to optional chain");return V(T),Se=F(T),new o(Ke.object,Ke.index,Se)}else if(En(Ke)&&Jr(Ke.fn)&&(ze=!0,de=[],K=Ke.name,Ke.args.forEach(function(et,Ot){Jr(et)?de[Ot]=et.name:ze=!1}),ze))return V(T),Se=F(T),new c(K,de,Se);throw ir(T,"Invalid left hand side of assignment operator =")}return Ke}function U(T){for(var K=$(T);T.token==="?";){var de=T.conditionalLevel;T.conditionalLevel=T.nestingLevel,V(T);var Se=K,ze=F(T);if(T.token!==":")throw ir(T,"False part of conditional expression expected");T.conditionalLevel=null,V(T);var Ke=F(T);K=new u(Se,ze,Ke),T.conditionalLevel=de}return K}function $(T){for(var K=le(T);T.token==="or";)V(T),K=new p("or","or",[K,le(T)]);return K}function le(T){for(var K=me(T);T.token==="xor";)V(T),K=new p("xor","xor",[K,me(T)]);return K}function me(T){for(var K=Y(T);T.token==="and";)V(T),K=new p("and","and",[K,Y(T)]);return K}function Y(T){for(var K=z(T);T.token==="|";)V(T),K=new p("|","bitOr",[K,z(T)]);return K}function z(T){for(var K=X(T);T.token==="^|";)V(T),K=new p("^|","bitXor",[K,X(T)]);return K}function X(T){for(var K=se(T);T.token==="&";)V(T),K=new p("&","bitAnd",[K,se(T)]);return K}function se(T){for(var K=[re(T)],de=[],Se={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};$e(Se,T.token);){var ze={name:T.token,fn:Se[T.token]};de.push(ze),V(T),K.push(re(T))}return K.length===1?K[0]:K.length===2?new p(de[0].name,de[0].fn,K):new x(de.map(Ke=>Ke.fn),K)}function re(T){var K,de,Se,ze;K=pe(T);for(var Ke={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};$e(Ke,T.token);)de=T.token,Se=Ke[de],V(T),ze=[K,pe(T)],K=new p(de,Se,ze);return K}function pe(T){var K,de,Se,ze;K=ve(T);for(var Ke={to:"to",in:"to"};$e(Ke,T.token);)de=T.token,Se=Ke[de],V(T),de==="in"&&"])},;".includes(T.token)?K=new p("*","multiply",[K,new D("in")],!0):(ze=[K,ve(T)],K=new p(de,Se,ze));return K}function ve(T){var K,de=[];if(T.token===":"){if(T.conditionalLevel===T.nestingLevel)throw ir(T,"The true-expression of a conditional operator may not be empty");K=new s(1)}else K=De(T);if(T.token===":"&&T.conditionalLevel!==T.nestingLevel){for(de.push(K);T.token===":"&&de.length<3;)V(T),T.token===")"||T.token==="]"||T.token===","||T.token===""?de.push(new D("end")):de.push(De(T));de.length===3?K=new y(de[0],de[2],de[1]):K=new y(de[0],de[1])}return K}function De(T){var K,de,Se,ze;K=Oe(T);for(var Ke={"+":"add","-":"subtract"};$e(Ke,T.token);){de=T.token,Se=Ke[de],V(T);var et=Oe(T);et.isPercentage?ze=[K,new p("*","multiply",[K,et])]:ze=[K,et],K=new p(de,Se,ze)}return K}function Oe(T){var K,de,Se,ze;K=Ie(T),de=K;for(var Ke={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"};$e(Ke,T.token);)Se=T.token,ze=Ke[Se],V(T),de=Ie(T),K=new p(Se,ze,[K,de]);return K}function Ie(T){var K,de;for(K=_e(T),de=K;T.tokenType===g.SYMBOL||T.token==="in"&&gr(K)||T.token==="in"&&Ur(K)&&K.fn==="unaryMinus"&&gr(K.args[0])||T.tokenType===g.NUMBER&&!gr(de)&&(!Ur(de)||de.op==="!")||T.token==="(";)de=_e(T),K=new p("*","multiply",[K,de],!0);return K}function _e(T){for(var K=Le(T),de=K,Se=[];T.token==="/"&&Xo(de);)if(Se.push(zr({},T)),V(T),T.tokenType===g.NUMBER)if(Se.push(zr({},T)),V(T),T.tokenType===g.SYMBOL||T.token==="("||T.token==="in")zr(T,Se.pop()),Se.pop(),de=Le(T),K=new p("/","divide",[K,de]);else{Se.pop(),zr(T,Se.pop());break}else{zr(T,Se.pop());break}return K}function Le(T){var K=qe(T);if(T.token==="%"){var de=zr({},T);V(T);try{qe(T),zr(T,de)}catch{K=new p("/","divide",[K,new s(100)],!1,!0)}}return K}function qe(T){var K,de,Se,ze={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return $e(ze,T.token)?(Se=ze[T.token],K=T.token,V(T),de=[qe(T)],new p(K,Se,de)):G(T)}function G(T){var K,de,Se,ze;return K=ee(T),(T.token==="^"||T.token===".^")&&(de=T.token,Se=de==="^"?"pow":"dotPow",V(T),ze=[K,qe(T)],K=new p(de,Se,ze)),K}function ee(T){for(var K=R(T);T.token==="??";)V(T),K=new p("??","nullish",[K,R(T)]);return K}function R(T){var K,de,Se,ze;K=H(T);for(var Ke={"!":"factorial","'":"ctranspose"};$e(Ke,T.token);)de=T.token,Se=Ke[de],P(T),ze=[K],K=new p(de,Se,ze),K=ie(T,K);return K}function H(T){var K=[];if(T.tokenType===g.SYMBOL&&$e(T.extraNodes,T.token)){var de=T.extraNodes[T.token];if(P(T),T.token==="("){if(K=[],q(T),P(T),T.token!==")")for(K.push(F(T));T.token===",";)P(T),K.push(F(T));if(T.token!==")")throw ir(T,"Parenthesis ) expected");J(T),P(T)}return new de(K)}return Q(T)}function Q(T){var K,de;return T.tokenType===g.SYMBOL||T.tokenType===g.DELIMITER&&T.token in A?(de=T.token,P(T),$e(N,de)?K=new s(N[de]):E.includes(de)?K=new s(t(de,"number")):K=new D(de),K=ie(T,K),K):ue(T)}function ie(T,K,de){for(var Se;;){var ze=!1;T.token==="?."&&(ze=!0,P(T));var Ke=(T.token==="("||T.token==="["||T.token===".")&&!0;if(!(ze||Ke))break;if(Se=[],T.token==="(")if(ze||Jr(K)||cn(K)){if(q(T),P(T),T.token!==")")for(Se.push(F(T));T.token===",";)P(T),Se.push(F(T));if(T.token!==")")throw ir(T,"Parenthesis ) expected");J(T),P(T),K=new f(K,Se,ze)}else return K;else if(T.token==="["){if(q(T),P(T),T.token!=="]")for(Se.push(F(T));T.token===",";)P(T),Se.push(F(T));if(T.token!=="]")throw ir(T,"Parenthesis ] expected");J(T),P(T),K=new a(K,new m(Se),ze)}else{ze||P(T);var et=T.tokenType===g.SYMBOL||T.tokenType===g.DELIMITER&&T.token in A;if(!et){var Ot="Property name expected after ";throw Ot+=ze?"optional chain":"dot",ir(T,Ot)}Se.push(new s(T.token)),P(T);var xi=!0;K=new a(K,new m(Se,xi),ze)}}return K}function ue(T){var K,de;return T.token==='"'||T.token==="'"?(de=oe(T,T.token),K=new s(de),K=ie(T,K),K):we(T)}function oe(T,K){for(var de="";O(T)!==""&&O(T)!==K;)if(O(T)==="\\"){I(T);var Se=O(T),ze=S[Se];if(ze!==void 0)de+=ze,T.index+=1;else if(Se==="u"){var Ke=T.expression.slice(T.index+1,T.index+5);if(/^[0-9A-Fa-f]{4}$/.test(Ke))de+=String.fromCharCode(parseInt(Ke,16)),T.index+=5;else throw ir(T,"Invalid unicode character \\u".concat(Ke))}else throw ir(T,"Bad escape character \\".concat(Se))}else de+=O(T),I(T);if(P(T),T.token!==K)throw ir(T,"End of string ".concat(K," expected"));return P(T),de}function we(T){var K,de,Se,ze;if(T.token==="["){if(q(T),P(T),T.token!=="]"){var Ke=xe(T);if(T.token===";"){for(Se=1,de=[Ke];T.token===";";)P(T),T.token!=="]"&&(de[Se]=xe(T),Se++);if(T.token!=="]")throw ir(T,"End of matrix ] expected");J(T),P(T),ze=de[0].items.length;for(var et=1;et<Se;et++)if(de[et].items.length!==ze)throw Fr(T,"Column dimensions mismatch ("+de[et].items.length+" !== "+ze+")");K=new i(de)}else{if(T.token!=="]")throw ir(T,"End of matrix ] expected");J(T),P(T),K=Ke}}else J(T),P(T),K=new i([]);return ie(T,K)}return Te(T)}function xe(T){for(var K=[F(T)],de=1;T.token===",";)P(T),T.token!=="]"&&T.token!==";"&&(K[de]=F(T),de++);return new i(K)}function Te(T){if(T.token==="{"){q(T);var K,de={};do if(P(T),T.token!=="}"){if(T.token==='"'||T.token==="'")K=oe(T,T.token);else if(T.tokenType===g.SYMBOL||T.tokenType===g.DELIMITER&&T.token in A)K=T.token,P(T);else throw ir(T,"Symbol or string expected as object key");if(T.token!==":")throw ir(T,"Colon : expected after object key");P(T),de[K]=F(T)}while(T.token===",");if(T.token!=="}")throw ir(T,"Comma , or bracket } expected after object value");J(T),P(T);var Se=new v(de);return Se=ie(T,Se),Se}return be(T)}function be(T){var K;if(T.tokenType===g.NUMBER){K=T.token,P(T);var de=An(K,n),Se=t(K,de);return new s(Se)}return ke(T)}function ke(T){var K;if(T.token==="("){if(q(T),P(T),K=F(T),T.token!==")")throw ir(T,"Parenthesis ) expected");return J(T),P(T),K=new d(K),K=ie(T,K),K}return fr(T)}function fr(T){throw T.token===""?ir(T,"Unexpected end of expression"):ir(T,"Value expected")}function hr(T){return T.index-T.token.length+1}function ir(T,K){var de=hr(T),Se=new SyntaxError(K+" (char "+de+")");return Se.char=de,Se}function Fr(T,K){var de=hr(T),Se=new SyntaxError(K+" (char "+de+")");return Se.char=de,Se}return e.addConversion({from:"string",to:"Node",convert:h}),h}),up="compile",jS=["typed","parse"],XS=L(up,jS,r=>{var{typed:e,parse:t}=r;return e(up,{string:function(a){return t(a).compile()},"Array | Matrix":function(a){return tr(a,function(i){return t(i).compile()})}})}),lp="evaluate",QS=["typed","parse"],KS=L(lp,QS,r=>{var{typed:e,parse:t}=r;return e(lp,{string:function(a){var i=Xa();return t(a).compile().evaluate(i)},"string, Map | Object":function(a,i){return t(a).compile().evaluate(i)},"Array | Matrix":function(a){var i=Xa();return tr(a,function(o){return t(o).compile().evaluate(i)})},"Array | Matrix, Map | Object":function(a,i){return tr(a,function(o){return t(o).compile().evaluate(i)})}})}),eC="Parser",rC=["evaluate","parse"],tC=L(eC,rC,r=>{var{evaluate:e,parse:t}=r;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:Xa(),writable:!1})}n.prototype.type="Parser",n.prototype.isParser=!0,n.prototype.evaluate=function(i){return e(i,this.scope)},n.prototype.get=function(i){if(this.scope.has(i))return this.scope.get(i)},n.prototype.getAll=function(){return h0(this.scope)},n.prototype.getAllAsMap=function(){return this.scope};function a(i){if(i.length===0)return!1;for(var o=0;o<i.length;o++){var l=i.charAt(o-1),u=i.charAt(o),s=i.charAt(o+1),c=t.isAlpha(u,l,s)||o>0&&t.isDigit(u);if(!c)return!1}return!0}return n.prototype.set=function(i,o){if(!a(i))throw new Error("Invalid variable name: '".concat(i,"'. Variable names must follow the specified rules."));return this.scope.set(i,o),o},n.prototype.remove=function(i){this.scope.delete(i)},n.prototype.clear=function(){this.scope.clear()},n.prototype.toJSON=function(){var i={mathjs:"Parser",variables:{},functions:{}};for(var[o,l]of this.scope)if(Ju(l)){if(!nC(l))throw new Error("Cannot serialize external function ".concat(o));i.functions[o]="".concat(l.syntax," = ").concat(l.expr)}else i.variables[o]=l;return i},n.fromJSON=function(i){var o=new n;return Object.entries(i.variables).forEach(l=>{var[u,s]=l;return o.set(u,s)}),Object.entries(i.functions).forEach(l=>{var[u,s]=l;return o.evaluate(s)}),o},n},{isClass:!0});function nC(r){return typeof r=="function"&&typeof r.syntax=="string"&&typeof r.expr=="string"}var cp="parser",aC=["typed","Parser"],iC=L(cp,aC,r=>{var{typed:e,Parser:t}=r;return e(cp,{"":function(){return new t}})}),fp="lup",oC=["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtractScalar","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],sC=L(fp,oC,r=>{var{typed:e,matrix:t,abs:n,addScalar:a,divideScalar:i,multiplyScalar:o,subtractScalar:l,larger:u,equalScalar:s,unaryMinus:c,DenseMatrix:f,SparseMatrix:m,Spa:v}=r;return e(fp,{DenseMatrix:function(x){return p(x)},SparseMatrix:function(x){return d(x)},Array:function(x){var D=t(x),h=p(D);return{L:h.L.valueOf(),U:h.U.valueOf(),p:h.p}}});function p(y){var x=y._size[0],D=y._size[1],h=Math.min(x,D),w=er(y._data),g=[],b=[x,h],A=[],N=[h,D],E,S,C,M=[];for(E=0;E<x;E++)M[E]=E;for(S=0;S<D;S++){if(S>0)for(E=0;E<x;E++){var O=Math.min(E,S),I=0;for(C=0;C<O;C++)I=a(I,o(w[E][C],w[C][S]));w[E][S]=l(w[E][S],I)}var k=S,_=0,P=0;for(E=S;E<x;E++){var V=w[E][S],q=n(V);u(q,_)&&(k=E,_=q,P=V)}if(S!==k&&(M[S]=[M[k],M[k]=M[S]][0],f._swapRows(S,k,w)),S<x)for(E=S+1;E<x;E++){var J=w[E][S];s(J,0)||(w[E][S]=i(w[E][S],P))}}for(S=0;S<D;S++)for(E=0;E<x;E++){if(S===0&&(E<D&&(A[E]=[]),g[E]=[]),E<S){E<D&&(A[E][S]=w[E][S]),S<x&&(g[E][S]=0);continue}if(E===S){E<D&&(A[E][S]=w[E][S]),S<x&&(g[E][S]=1);continue}E<D&&(A[E][S]=0),S<x&&(g[E][S]=w[E][S])}var ne=new f({data:g,size:b}),j=new f({data:A,size:N}),F=[];for(E=0,h=M.length;E<h;E++)F[M[E]]=E;return{L:ne,U:j,p:F,toString:function(){return"L: "+this.L.toString()+`
|
|
31
|
+
`&&T.token!==";"&&T.token!==""&&(K=F(T),T.comment&&(K.comment=T.comment),Se=T.token!==";",de.push({node:K,visible:Se}));return de.length>0?new l(de):(K||(K=new s(void 0),T.comment&&(K.comment=T.comment)),K)}function F(T){var K,de,Se,ze,Ke=U(T);if(T.token==="="){if(jr(Ke))return K=Ke.name,V(T),Se=F(T),new o(new D(K),Se);if(cn(Ke)){if(Ke.optionalChaining)throw ir(T,"Cannot assign to optional chain");return V(T),Se=F(T),new o(Ke.object,Ke.index,Se)}else if(En(Ke)&&jr(Ke.fn)&&(ze=!0,de=[],K=Ke.name,Ke.args.forEach(function(rt,Bt){jr(rt)?de[Bt]=rt.name:ze=!1}),ze))return V(T),Se=F(T),new c(K,de,Se);throw ir(T,"Invalid left hand side of assignment operator =")}return Ke}function U(T){for(var K=$(T);T.token==="?";){var de=T.conditionalLevel;T.conditionalLevel=T.nestingLevel,V(T);var Se=K,ze=F(T);if(T.token!==":")throw ir(T,"False part of conditional expression expected");T.conditionalLevel=null,V(T);var Ke=F(T);K=new u(Se,ze,Ke),T.conditionalLevel=de}return K}function $(T){for(var K=le(T);T.token==="or";)V(T),K=new p("or","or",[K,le(T)]);return K}function le(T){for(var K=me(T);T.token==="xor";)V(T),K=new p("xor","xor",[K,me(T)]);return K}function me(T){for(var K=Y(T);T.token==="and";)V(T),K=new p("and","and",[K,Y(T)]);return K}function Y(T){for(var K=z(T);T.token==="|";)V(T),K=new p("|","bitOr",[K,z(T)]);return K}function z(T){for(var K=X(T);T.token==="^|";)V(T),K=new p("^|","bitXor",[K,X(T)]);return K}function X(T){for(var K=se(T);T.token==="&";)V(T),K=new p("&","bitAnd",[K,se(T)]);return K}function se(T){for(var K=[re(T)],de=[],Se={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};$e(Se,T.token);){var ze={name:T.token,fn:Se[T.token]};de.push(ze),V(T),K.push(re(T))}return K.length===1?K[0]:K.length===2?new p(de[0].name,de[0].fn,K):new x(de.map(Ke=>Ke.fn),K)}function re(T){var K,de,Se,ze;K=pe(T);for(var Ke={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};$e(Ke,T.token);)de=T.token,Se=Ke[de],V(T),ze=[K,pe(T)],K=new p(de,Se,ze);return K}function pe(T){var K,de,Se,ze;K=ve(T);for(var Ke={to:"to",in:"to"};$e(Ke,T.token);)de=T.token,Se=Ke[de],V(T),de==="in"&&"])},;".includes(T.token)?K=new p("*","multiply",[K,new D("in")],!0):(ze=[K,ve(T)],K=new p(de,Se,ze));return K}function ve(T){var K,de=[];if(T.token===":"){if(T.conditionalLevel===T.nestingLevel)throw ir(T,"The true-expression of a conditional operator may not be empty");K=new s(1)}else K=De(T);if(T.token===":"&&T.conditionalLevel!==T.nestingLevel){for(de.push(K);T.token===":"&&de.length<3;)V(T),T.token===")"||T.token==="]"||T.token===","||T.token===""?de.push(new D("end")):de.push(De(T));de.length===3?K=new y(de[0],de[2],de[1]):K=new y(de[0],de[1])}return K}function De(T){var K,de,Se,ze;K=Oe(T);for(var Ke={"+":"add","-":"subtract"};$e(Ke,T.token);){de=T.token,Se=Ke[de],V(T);var rt=Oe(T);rt.isPercentage?ze=[K,new p("*","multiply",[K,rt])]:ze=[K,rt],K=new p(de,Se,ze)}return K}function Oe(T){var K,de,Se,ze;K=Ie(T),de=K;for(var Ke={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"};$e(Ke,T.token);)Se=T.token,ze=Ke[Se],V(T),de=Ie(T),K=new p(Se,ze,[K,de]);return K}function Ie(T){var K,de;for(K=_e(T),de=K;T.tokenType===g.SYMBOL||T.token==="in"&&gr(K)||T.token==="in"&&Ur(K)&&K.fn==="unaryMinus"&&gr(K.args[0])||T.tokenType===g.NUMBER&&!gr(de)&&(!Ur(de)||de.op==="!")||T.token==="(";)de=_e(T),K=new p("*","multiply",[K,de],!0);return K}function _e(T){for(var K=Le(T),de=K,Se=[];T.token==="/"&&Xo(de);)if(Se.push(zr({},T)),V(T),T.tokenType===g.NUMBER)if(Se.push(zr({},T)),V(T),T.tokenType===g.SYMBOL||T.token==="("||T.token==="in")zr(T,Se.pop()),Se.pop(),de=Le(T),K=new p("/","divide",[K,de]);else{Se.pop(),zr(T,Se.pop());break}else{zr(T,Se.pop());break}return K}function Le(T){var K=qe(T);if(T.token==="%"){var de=zr({},T);V(T);try{qe(T),zr(T,de)}catch{K=new p("/","divide",[K,new s(100)],!1,!0)}}return K}function qe(T){var K,de,Se,ze={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return $e(ze,T.token)?(Se=ze[T.token],K=T.token,V(T),de=[qe(T)],new p(K,Se,de)):G(T)}function G(T){var K,de,Se,ze;return K=ee(T),(T.token==="^"||T.token===".^")&&(de=T.token,Se=de==="^"?"pow":"dotPow",V(T),ze=[K,qe(T)],K=new p(de,Se,ze)),K}function ee(T){for(var K=R(T);T.token==="??";)V(T),K=new p("??","nullish",[K,R(T)]);return K}function R(T){var K,de,Se,ze;K=H(T);for(var Ke={"!":"factorial","'":"ctranspose"};$e(Ke,T.token);)de=T.token,Se=Ke[de],P(T),ze=[K],K=new p(de,Se,ze),K=ie(T,K);return K}function H(T){var K=[];if(T.tokenType===g.SYMBOL&&$e(T.extraNodes,T.token)){var de=T.extraNodes[T.token];if(P(T),T.token==="("){if(K=[],q(T),P(T),T.token!==")")for(K.push(F(T));T.token===",";)P(T),K.push(F(T));if(T.token!==")")throw ir(T,"Parenthesis ) expected");J(T),P(T)}return new de(K)}return Q(T)}function Q(T){var K,de;return T.tokenType===g.SYMBOL||T.tokenType===g.DELIMITER&&T.token in A?(de=T.token,P(T),$e(N,de)?K=new s(N[de]):E.includes(de)?K=new s(t(de,"number")):K=new D(de),K=ie(T,K),K):ue(T)}function ie(T,K,de){for(var Se;;){var ze=!1;T.token==="?."&&(ze=!0,P(T));var Ke=(T.token==="("||T.token==="["||T.token===".")&&!0;if(!(ze||Ke))break;if(Se=[],T.token==="(")if(ze||jr(K)||cn(K)){if(q(T),P(T),T.token!==")")for(Se.push(F(T));T.token===",";)P(T),Se.push(F(T));if(T.token!==")")throw ir(T,"Parenthesis ) expected");J(T),P(T),K=new f(K,Se,ze)}else return K;else if(T.token==="["){if(q(T),P(T),T.token!=="]")for(Se.push(F(T));T.token===",";)P(T),Se.push(F(T));if(T.token!=="]")throw ir(T,"Parenthesis ] expected");J(T),P(T),K=new a(K,new m(Se),ze)}else{ze||P(T);var rt=T.tokenType===g.SYMBOL||T.tokenType===g.DELIMITER&&T.token in A;if(!rt){var Bt="Property name expected after ";throw Bt+=ze?"optional chain":"dot",ir(T,Bt)}Se.push(new s(T.token)),P(T);var xi=!0;K=new a(K,new m(Se,xi),ze)}}return K}function ue(T){var K,de;return T.token==='"'||T.token==="'"?(de=oe(T,T.token),K=new s(de),K=ie(T,K),K):we(T)}function oe(T,K){for(var de="";O(T)!==""&&O(T)!==K;)if(O(T)==="\\"){I(T);var Se=O(T),ze=S[Se];if(ze!==void 0)de+=ze,T.index+=1;else if(Se==="u"){var Ke=T.expression.slice(T.index+1,T.index+5);if(/^[0-9A-Fa-f]{4}$/.test(Ke))de+=String.fromCharCode(parseInt(Ke,16)),T.index+=5;else throw ir(T,"Invalid unicode character \\u".concat(Ke))}else throw ir(T,"Bad escape character \\".concat(Se))}else de+=O(T),I(T);if(P(T),T.token!==K)throw ir(T,"End of string ".concat(K," expected"));return P(T),de}function we(T){var K,de,Se,ze;if(T.token==="["){if(q(T),P(T),T.token!=="]"){var Ke=xe(T);if(T.token===";"){for(Se=1,de=[Ke];T.token===";";)P(T),T.token!=="]"&&(de[Se]=xe(T),Se++);if(T.token!=="]")throw ir(T,"End of matrix ] expected");J(T),P(T),ze=de[0].items.length;for(var rt=1;rt<Se;rt++)if(de[rt].items.length!==ze)throw Fr(T,"Column dimensions mismatch ("+de[rt].items.length+" !== "+ze+")");K=new i(de)}else{if(T.token!=="]")throw ir(T,"End of matrix ] expected");J(T),P(T),K=Ke}}else J(T),P(T),K=new i([]);return ie(T,K)}return Te(T)}function xe(T){for(var K=[F(T)],de=1;T.token===",";)P(T),T.token!=="]"&&T.token!==";"&&(K[de]=F(T),de++);return new i(K)}function Te(T){if(T.token==="{"){q(T);var K,de={};do if(P(T),T.token!=="}"){if(T.token==='"'||T.token==="'")K=oe(T,T.token);else if(T.tokenType===g.SYMBOL||T.tokenType===g.DELIMITER&&T.token in A)K=T.token,P(T);else throw ir(T,"Symbol or string expected as object key");if(T.token!==":")throw ir(T,"Colon : expected after object key");P(T),de[K]=F(T)}while(T.token===",");if(T.token!=="}")throw ir(T,"Comma , or bracket } expected after object value");J(T),P(T);var Se=new v(de);return Se=ie(T,Se),Se}return be(T)}function be(T){var K;if(T.tokenType===g.NUMBER){K=T.token,P(T);var de=An(K,n),Se=t(K,de);return new s(Se)}return ke(T)}function ke(T){var K;if(T.token==="("){if(q(T),P(T),K=F(T),T.token!==")")throw ir(T,"Parenthesis ) expected");return J(T),P(T),K=new d(K),K=ie(T,K),K}return fr(T)}function fr(T){throw T.token===""?ir(T,"Unexpected end of expression"):ir(T,"Value expected")}function hr(T){return T.index-T.token.length+1}function ir(T,K){var de=hr(T),Se=new SyntaxError(K+" (char "+de+")");return Se.char=de,Se}function Fr(T,K){var de=hr(T),Se=new SyntaxError(K+" (char "+de+")");return Se.char=de,Se}return e.addConversion({from:"string",to:"Node",convert:h}),h}),lp="compile",jS=["typed","parse"],XS=L(lp,jS,r=>{var{typed:e,parse:t}=r;return e(lp,{string:function(a){return t(a).compile()},"Array | Matrix":function(a){return tr(a,function(i){return t(i).compile()})}})}),cp="evaluate",QS=["typed","parse"],KS=L(cp,QS,r=>{var{typed:e,parse:t}=r;return e(cp,{string:function(a){var i=Xa();return t(a).compile().evaluate(i)},"string, Map | Object":function(a,i){return t(a).compile().evaluate(i)},"Array | Matrix":function(a){var i=Xa();return tr(a,function(o){return t(o).compile().evaluate(i)})},"Array | Matrix, Map | Object":function(a,i){return tr(a,function(o){return t(o).compile().evaluate(i)})}})}),eC="Parser",rC=["evaluate","parse"],tC=L(eC,rC,r=>{var{evaluate:e,parse:t}=r;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:Xa(),writable:!1})}n.prototype.type="Parser",n.prototype.isParser=!0,n.prototype.evaluate=function(i){return e(i,this.scope)},n.prototype.get=function(i){if(this.scope.has(i))return this.scope.get(i)},n.prototype.getAll=function(){return h0(this.scope)},n.prototype.getAllAsMap=function(){return this.scope};function a(i){if(i.length===0)return!1;for(var o=0;o<i.length;o++){var l=i.charAt(o-1),u=i.charAt(o),s=i.charAt(o+1),c=t.isAlpha(u,l,s)||o>0&&t.isDigit(u);if(!c)return!1}return!0}return n.prototype.set=function(i,o){if(!a(i))throw new Error("Invalid variable name: '".concat(i,"'. Variable names must follow the specified rules."));return this.scope.set(i,o),o},n.prototype.remove=function(i){this.scope.delete(i)},n.prototype.clear=function(){this.scope.clear()},n.prototype.toJSON=function(){var i={mathjs:"Parser",variables:{},functions:{}};for(var[o,l]of this.scope)if(ju(l)){if(!nC(l))throw new Error("Cannot serialize external function ".concat(o));i.functions[o]="".concat(l.syntax," = ").concat(l.expr)}else i.variables[o]=l;return i},n.fromJSON=function(i){var o=new n;return Object.entries(i.variables).forEach(l=>{var[u,s]=l;return o.set(u,s)}),Object.entries(i.functions).forEach(l=>{var[u,s]=l;return o.evaluate(s)}),o},n},{isClass:!0});function nC(r){return typeof r=="function"&&typeof r.syntax=="string"&&typeof r.expr=="string"}var fp="parser",aC=["typed","Parser"],iC=L(fp,aC,r=>{var{typed:e,Parser:t}=r;return e(fp,{"":function(){return new t}})}),mp="lup",oC=["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtractScalar","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],sC=L(mp,oC,r=>{var{typed:e,matrix:t,abs:n,addScalar:a,divideScalar:i,multiplyScalar:o,subtractScalar:l,larger:u,equalScalar:s,unaryMinus:c,DenseMatrix:f,SparseMatrix:m,Spa:v}=r;return e(mp,{DenseMatrix:function(x){return p(x)},SparseMatrix:function(x){return d(x)},Array:function(x){var D=t(x),h=p(D);return{L:h.L.valueOf(),U:h.U.valueOf(),p:h.p}}});function p(y){var x=y._size[0],D=y._size[1],h=Math.min(x,D),w=er(y._data),g=[],b=[x,h],A=[],N=[h,D],E,S,C,M=[];for(E=0;E<x;E++)M[E]=E;for(S=0;S<D;S++){if(S>0)for(E=0;E<x;E++){var O=Math.min(E,S),I=0;for(C=0;C<O;C++)I=a(I,o(w[E][C],w[C][S]));w[E][S]=l(w[E][S],I)}var k=S,_=0,P=0;for(E=S;E<x;E++){var V=w[E][S],q=n(V);u(q,_)&&(k=E,_=q,P=V)}if(S!==k&&(M[S]=[M[k],M[k]=M[S]][0],f._swapRows(S,k,w)),S<x)for(E=S+1;E<x;E++){var J=w[E][S];s(J,0)||(w[E][S]=i(w[E][S],P))}}for(S=0;S<D;S++)for(E=0;E<x;E++){if(S===0&&(E<D&&(A[E]=[]),g[E]=[]),E<S){E<D&&(A[E][S]=w[E][S]),S<x&&(g[E][S]=0);continue}if(E===S){E<D&&(A[E][S]=w[E][S]),S<x&&(g[E][S]=1);continue}E<D&&(A[E][S]=0),S<x&&(g[E][S]=w[E][S])}var ne=new f({data:g,size:b}),j=new f({data:A,size:N}),F=[];for(E=0,h=M.length;E<h;E++)F[M[E]]=E;return{L:ne,U:j,p:F,toString:function(){return"L: "+this.L.toString()+`
|
|
32
32
|
U: `+this.U.toString()+`
|
|
33
33
|
P: `+this.p}}}function d(y){var x=y._size[0],D=y._size[1],h=Math.min(x,D),w=y._values,g=y._index,b=y._ptr,A=[],N=[],E=[],S=[x,h],C=[],M=[],O=[],I=[h,D],k,_,P,V=[],q=[];for(k=0;k<x;k++)V[k]=k,q[k]=k;var J=function(F,U){var $=q[F],le=q[U];V[$]=U,V[le]=F,q[F]=le,q[U]=$},ne=function(){var F=new v;_<x&&(E.push(A.length),A.push(1),N.push(_)),O.push(C.length);var U=b[_],$=b[_+1];for(P=U;P<$;P++)k=g[P],F.set(V[k],w[P]);_>0&&F.forEach(0,_-1,function(z,X){m._forEachRow(z,A,N,E,function(se,re){se>z&&F.accumulate(se,c(o(re,X)))})});var le=_,me=F.get(_),Y=n(me);F.forEach(_+1,x-1,function(z,X){var se=n(X);u(se,Y)&&(le=z,Y=se,me=X)}),_!==le&&(m._swapRows(_,le,S[1],A,N,E),m._swapRows(_,le,I[1],C,M,O),F.swap(_,le),J(_,le)),F.forEach(0,x-1,function(z,X){z<=_?(C.push(X),M.push(z)):(X=i(X,me),s(X,0)||(A.push(X),N.push(z)))})};for(_=0;_<D;_++)ne();return O.push(C.length),E.push(A.length),{L:new m({values:A,index:N,ptr:E,size:S}),U:new m({values:C,index:M,ptr:O,size:I}),p:V,toString:function(){return"L: "+this.L.toString()+`
|
|
34
34
|
U: `+this.U.toString()+`
|
|
35
|
-
P: `+this.p}}}}),
|
|
36
|
-
R: `+this.R.toString()}}}function x(h){var w=y(h),g=w.R._data;if(h._data.length>0)for(var b=g[0][0].type==="Complex"?d(0):0,A=0;A<g.length;++A)for(var N=0;N<A&&N<(g[0]||[]).length;++N)g[A][N]=b;return w}function D(h){throw new Error("qr not implemented for sparse matrices yet")}});function cC(r,e,t,n){r._values;for(var a=r._index,i=r._ptr,o=r._size,l=r._datatype,u=o[0],s=o[1],c=null,f=[],m=[],v=0,p=0;p<s;p++){m[p]=v;for(var d=t?t[p]:p,y=i[d],x=i[d+1],D=y;D<x;D++){var h=a[D];f[v]=h,v++}}return m[s]=v,r.createSparseMatrix({values:c,index:f,ptr:m,size:[u,s],datatype:l})}function
|
|
35
|
+
P: `+this.p}}}}),vp="qr",uC=["typed","matrix","zeros","identity","isZero","equal","sign","sqrt","conj","unaryMinus","addScalar","divideScalar","multiplyScalar","subtractScalar","complex"],lC=L(vp,uC,r=>{var{typed:e,matrix:t,zeros:n,identity:a,isZero:i,equal:o,sign:l,sqrt:u,conj:s,unaryMinus:c,addScalar:f,divideScalar:m,multiplyScalar:v,subtractScalar:p,complex:d}=r;return zr(e(vp,{DenseMatrix:function(w){return x(w)},SparseMatrix:function(w){return D()},Array:function(w){var g=t(w),b=x(g);return{Q:b.Q.valueOf(),R:b.R.valueOf()}}}),{_denseQRimpl:y});function y(h){var w=h._size[0],g=h._size[1],b=a([w],"dense"),A=b._data,N=h.clone(),E=N._data,S,C,M,O=n([w],"");for(M=0;M<Math.min(g,w);++M){var I=E[M][M],k=c(o(I,0)?1:l(I)),_=s(k),P=0;for(S=M;S<w;S++)P=f(P,v(E[S][M],s(E[S][M])));var V=v(k,u(P));if(!i(V)){var q=p(I,V);for(O[M]=1,S=M+1;S<w;S++)O[S]=m(E[S][M],q);var J=c(s(m(q,V))),ne=void 0;for(C=M;C<g;C++){for(ne=0,S=M;S<w;S++)ne=f(ne,v(s(O[S]),E[S][C]));for(ne=v(ne,J),S=M;S<w;S++)E[S][C]=v(p(E[S][C],v(O[S],ne)),_)}for(S=0;S<w;S++){for(ne=0,C=M;C<w;C++)ne=f(ne,v(A[S][C],O[C]));for(ne=v(ne,J),C=M;C<w;++C)A[S][C]=m(p(A[S][C],v(ne,s(O[C]))),_)}}}return{Q:b,R:N,toString:function(){return"Q: "+this.Q.toString()+`
|
|
36
|
+
R: `+this.R.toString()}}}function x(h){var w=y(h),g=w.R._data;if(h._data.length>0)for(var b=g[0][0].type==="Complex"?d(0):0,A=0;A<g.length;++A)for(var N=0;N<A&&N<(g[0]||[]).length;++N)g[A][N]=b;return w}function D(h){throw new Error("qr not implemented for sparse matrices yet")}});function cC(r,e,t,n){r._values;for(var a=r._index,i=r._ptr,o=r._size,l=r._datatype,u=o[0],s=o[1],c=null,f=[],m=[],v=0,p=0;p<s;p++){m[p]=v;for(var d=t?t[p]:p,y=i[d],x=i[d+1],D=y;D<x;D++){var h=a[D];f[v]=h,v++}}return m[s]=v,r.createSparseMatrix({values:c,index:f,ptr:m,size:[u,s],datatype:l})}function pp(r,e,t,n,a,i,o){var l=0;for(t[o]=r;l>=0;){var u=t[o+l],s=t[n+u];s===-1?(l--,i[e++]=u):(t[n+u]=t[a+s],++l,t[o+l]=s)}return e}function fC(r,e){if(!r)return null;var t=0,n,a=[],i=[],o=0,l=e,u=2*e;for(n=0;n<e;n++)i[o+n]=-1;for(n=e-1;n>=0;n--)r[n]!==-1&&(i[l+n]=i[o+r[n]],i[o+r[n]]=n);for(n=0;n<e;n++)r[n]===-1&&(t=pp(n,t,i,o,l,a,u));return a}function mC(r,e){if(!r)return null;var t=r._index,n=r._ptr,a=r._size,i=a[0],o=a[1],l=[],u=[],s=0,c=o,f,m;for(f=0;f<i;f++)u[c+f]=-1;for(var v=0;v<o;v++){l[v]=-1,u[s+v]=-1;for(var p=n[v],d=n[v+1],y=p;y<d;y++){var x=t[y];for(f=u[c+x];f!==-1&&f<v;f=m)m=u[s+f],u[s+f]=v,m===-1&&(l[f]=v);u[c+x]=v}}return l}function vC(r,e,t){for(var n=r._values,a=r._index,i=r._ptr,o=r._size,l=o[1],u=0,s=0;s<l;s++){var c=i[s];for(i[s]=u;c<i[s+1];c++)e(a[c],s,n?n[c]:1,t)&&(a[u]=a[c],n&&(n[u]=n[c]),u++)}return i[l]=u,a.splice(u,a.length-u),n&&n.splice(u,n.length-u),u}function Pn(r){return-r-2}var pC="csAmd",dC=["add","multiply","transpose"],hC=L(pC,dC,r=>{var{add:e,multiply:t,transpose:n}=r;return function(c,f){if(!f||c<=0||c>3)return null;var m=f._size,v=m[0],p=m[1],d=0,y=Math.max(16,10*Math.sqrt(p));y=Math.min(p-2,y);var x=a(c,f,v,p,y);vC(x,u,null);for(var D=x._index,h=x._ptr,w=h[p],g=[],b=[],A=0,N=p+1,E=2*(p+1),S=3*(p+1),C=4*(p+1),M=5*(p+1),O=6*(p+1),I=7*(p+1),k=g,_=i(p,h,b,A,S,k,E,I,N,O,C,M),P=o(p,h,b,M,C,O,y,N,S,k,E),V=0,q,J,ne,j,F,U,$,le,me,Y,z,X,se,re,pe,ve;P<p;){for(ne=-1;V<p&&(ne=b[S+V])===-1;V++);b[E+ne]!==-1&&(k[b[E+ne]]=-1),b[S+V]=b[E+ne];var De=b[C+ne],Oe=b[N+ne];P+=Oe;var Ie=0;b[N+ne]=-Oe;var _e=h[ne],Le=De===0?_e:w,qe=Le;for(j=1;j<=De+1;j++){for(j>De?(U=ne,$=_e,le=b[A+ne]-De):(U=D[_e++],$=h[U],le=b[A+U]),F=1;F<=le;F++)q=D[$++],!((me=b[N+q])<=0)&&(Ie+=me,b[N+q]=-me,D[qe++]=q,b[E+q]!==-1&&(k[b[E+q]]=k[q]),k[q]!==-1?b[E+k[q]]=b[E+q]:b[S+b[M+q]]=b[E+q]);U!==ne&&(h[U]=Pn(ne),b[O+U]=0)}for(De!==0&&(w=qe),b[M+ne]=Ie,h[ne]=Le,b[A+ne]=qe-Le,b[C+ne]=-2,_=l(_,d,b,O,p),Y=Le;Y<qe;Y++)if(q=D[Y],!((z=b[C+q])<=0)){me=-b[N+q];var G=_-me;for(_e=h[q],X=h[q]+z-1;_e<=X;_e++)U=D[_e],b[O+U]>=_?b[O+U]-=me:b[O+U]!==0&&(b[O+U]=b[M+U]+G)}for(Y=Le;Y<qe;Y++){for(q=D[Y],X=h[q],se=X+b[C+q]-1,re=X,pe=0,ve=0,_e=X;_e<=se;_e++)if(U=D[_e],b[O+U]!==0){var ee=b[O+U]-_;ee>0?(ve+=ee,D[re++]=U,pe+=U):(h[U]=Pn(ne),b[O+U]=0)}b[C+q]=re-X+1;var R=re,H=X+b[A+q];for(_e=se+1;_e<H;_e++){J=D[_e];var Q=b[N+J];Q<=0||(ve+=Q,D[re++]=J,pe+=J)}ve===0?(h[q]=Pn(ne),me=-b[N+q],Ie-=me,Oe+=me,P+=me,b[N+q]=0,b[C+q]=-1):(b[M+q]=Math.min(b[M+q],ve),D[re]=D[R],D[R]=D[X],D[X]=ne,b[A+q]=re-X+1,pe=(pe<0?-pe:pe)%p,b[E+q]=b[I+pe],b[I+pe]=q,k[q]=pe)}for(b[M+ne]=Ie,d=Math.max(d,Ie),_=l(_+d,d,b,O,p),Y=Le;Y<qe;Y++)if(q=D[Y],!(b[N+q]>=0))for(pe=k[q],q=b[I+pe],b[I+pe]=-1;q!==-1&&b[E+q]!==-1;q=b[E+q],_++){for(le=b[A+q],z=b[C+q],_e=h[q]+1;_e<=h[q]+le-1;_e++)b[O+D[_e]]=_;var ie=q;for(J=b[E+q];J!==-1;){var ue=b[A+J]===le&&b[C+J]===z;for(_e=h[J]+1;ue&&_e<=h[J]+le-1;_e++)b[O+D[_e]]!==_&&(ue=0);ue?(h[J]=Pn(q),b[N+q]+=b[N+J],b[N+J]=0,b[C+J]=-1,J=b[E+J],b[E+ie]=J):(ie=J,J=b[E+J])}}for(_e=Le,Y=Le;Y<qe;Y++)q=D[Y],!((me=-b[N+q])<=0)&&(b[N+q]=me,ve=b[M+q]+Ie-me,ve=Math.min(ve,p-P-me),b[S+ve]!==-1&&(k[b[S+ve]]=q),b[E+q]=b[S+ve],k[q]=-1,b[S+ve]=q,V=Math.min(V,ve),b[M+q]=ve,D[_e++]=q);b[N+ne]=Oe,(b[A+ne]=_e-Le)===0&&(h[ne]=-1,b[O+ne]=0),De!==0&&(w=_e)}for(q=0;q<p;q++)h[q]=Pn(h[q]);for(J=0;J<=p;J++)b[S+J]=-1;for(J=p;J>=0;J--)b[N+J]>0||(b[E+J]=b[S+h[J]],b[S+h[J]]=J);for(U=p;U>=0;U--)b[N+U]<=0||h[U]!==-1&&(b[E+U]=b[S+h[U]],b[S+h[U]]=U);for(ne=0,q=0;q<=p;q++)h[q]===-1&&(ne=pp(q,ne,b,S,E,g,O));return g.splice(g.length-1,1),g};function a(s,c,f,m,v){var p=n(c);if(s===1&&m===f)return e(c,p);if(s===2){for(var d=p._index,y=p._ptr,x=0,D=0;D<f;D++){var h=y[D];if(y[D]=x,!(y[D+1]-h>v))for(var w=y[D+1];h<w;h++)d[x++]=d[h]}return y[f]=x,c=n(p),t(p,c)}return t(p,c)}function i(s,c,f,m,v,p,d,y,x,D,h,w){for(var g=0;g<s;g++)f[m+g]=c[g+1]-c[g];f[m+s]=0;for(var b=0;b<=s;b++)f[v+b]=-1,p[b]=-1,f[d+b]=-1,f[y+b]=-1,f[x+b]=1,f[D+b]=1,f[h+b]=0,f[w+b]=f[m+b];var A=l(0,0,f,D,s);return f[h+s]=-2,c[s]=-1,f[D+s]=0,A}function o(s,c,f,m,v,p,d,y,x,D,h){for(var w=0,g=0;g<s;g++){var b=f[m+g];if(b===0)f[v+g]=-2,w++,c[g]=-1,f[p+g]=0;else if(b>d)f[y+g]=0,f[v+g]=-1,w++,c[g]=Pn(s),f[y+s]++;else{var A=f[x+b];A!==-1&&(D[A]=g),f[h+g]=f[x+b],f[x+b]=g}}return w}function l(s,c,f,m,v){if(s<2||s+c<0){for(var p=0;p<v;p++)f[m+p]!==0&&(f[m+p]=1);s=2}return s}function u(s,c){return s!==c}});function gC(r,e,t,n,a,i,o){var l,u,s=0,c;if(r<=e||t[n+e]<=t[a+r])return-1;t[a+r]=t[n+e];var f=t[i+r];if(t[i+r]=e,f===-1)s=1,c=r;else{for(s=2,c=f;c!==t[o+c];c=t[o+c]);for(l=f;l!==c;l=u)u=t[o+l],t[o+l]=c}return{jleaf:s,q:c}}var yC="csCounts",bC=["transpose"],xC=L(yC,bC,r=>{var{transpose:e}=r;return function(t,n,a,i){if(!t||!n||!a)return null;var o=t._size,l=o[0],u=o[1],s,c,f,m,v,p,d,y=4*u+(i?u+l+1:0),x=[],D=0,h=u,w=2*u,g=3*u,b=4*u,A=5*u+1;for(f=0;f<y;f++)x[f]=-1;var N=[],E=e(t),S=E._index,C=E._ptr;for(f=0;f<u;f++)for(c=a[f],N[c]=x[g+c]===-1?1:0;c!==-1&&x[g+c]===-1;c=n[c])x[g+c]=f;if(i){for(f=0;f<u;f++)x[a[f]]=f;for(s=0;s<l;s++){for(f=u,p=C[s],d=C[s+1],v=p;v<d;v++)f=Math.min(f,x[S[v]]);x[A+s]=x[b+f],x[b+f]=s}}for(s=0;s<u;s++)x[D+s]=s;for(f=0;f<u;f++){for(c=a[f],n[c]!==-1&&N[n[c]]--,m=i?x[b+f]:c;m!==-1;m=i?x[A+m]:-1)for(v=C[m];v<C[m+1];v++){s=S[v];var M=gC(s,c,x,g,h,w,D);M.jleaf>=1&&N[c]++,M.jleaf===2&&N[M.q]--}n[c]!==-1&&(x[D+c]=n[c])}for(c=0;c<u;c++)n[c]!==-1&&(N[n[c]]+=N[c]);return N}}),wC="csSqr",DC=["add","multiply","transpose"],NC=L(wC,DC,r=>{var{add:e,multiply:t,transpose:n}=r,a=hC({add:e,multiply:t,transpose:n}),i=xC({transpose:n});return function(u,s,c){var f=s._ptr,m=s._size,v=m[1],p,d={};if(d.q=a(u,s),u&&!d.q)return null;if(c){var y=u?cC(s,null,d.q):s;d.parent=mC(y);var x=fC(d.parent,v);if(d.cp=i(y,d.parent,x,1),y&&d.parent&&d.cp&&o(y,d))for(d.unz=0,p=0;p<v;p++)d.unz+=d.cp[p]}else d.unz=4*f[v]+v,d.lnz=d.unz;return d};function o(l,u){var s=l._ptr,c=l._index,f=l._size,m=f[0],v=f[1];u.pinv=[],u.leftmost=[];var p=u.parent,d=u.pinv,y=u.leftmost,x=[],D=0,h=m,w=m+v,g=m+2*v,b,A,N,E,S;for(A=0;A<v;A++)x[h+A]=-1,x[w+A]=-1,x[g+A]=0;for(b=0;b<m;b++)y[b]=-1;for(A=v-1;A>=0;A--)for(E=s[A],S=s[A+1],N=E;N<S;N++)y[c[N]]=A;for(b=m-1;b>=0;b--)d[b]=-1,A=y[b],A!==-1&&(x[g+A]++===0&&(x[w+A]=b),x[D+b]=x[h+A],x[h+A]=b);for(u.lnz=0,u.m2=m,A=0;A<v;A++)if(b=x[h+A],u.lnz++,b<0&&(b=u.m2++),d[b]=A,!(--g[A]<=0)){u.lnz+=x[g+A];var C=p[A];C!==-1&&(x[g+C]===0&&(x[w+C]=x[w+A]),x[D+x[w+A]]=x[h+C],x[h+C]=x[D+b],x[g+C]+=x[g+A])}for(b=0;b<m;b++)d[b]<0&&(d[b]=A++);return!0}});function Us(r,e){return r[e]<0}function dp(r,e){r[e]=Pn(r[e])}function hp(r){return r<0?Pn(r):r}function EC(r,e,t,n,a){var i=e._index,o=e._ptr,l=e._size,u=l[1],s,c,f,m=0;for(n[0]=r;m>=0;){r=n[m];var v=a?a[r]:r;Us(o,r)||(dp(o,r),n[u+m]=v<0?0:hp(o[v]));var p=1;for(c=n[u+m],f=v<0?0:hp(o[v+1]);c<f;c++)if(s=i[c],!Us(o,s)){n[u+m]=c,n[++m]=s,p=0;break}p&&(m--,n[--t]=r)}return t}function AC(r,e,t,n,a){var i=r._ptr,o=r._size,l=e._index,u=e._ptr,s=o[1],c,f,m,v=s;for(f=u[t],m=u[t+1],c=f;c<m;c++){var p=l[c];Us(i,p)||(v=EC(p,r,v,n,a))}for(c=v;c<s;c++)dp(i,n[c]);return v}var SC="csSpsolve",CC=["divideScalar","multiply","subtract"],MC=L(SC,CC,r=>{var{divideScalar:e,multiply:t,subtract:n}=r;return function(i,o,l,u,s,c,f){var m=i._values,v=i._index,p=i._ptr,d=i._size,y=d[1],x=o._values,D=o._index,h=o._ptr,w,g,b,A,N=AC(i,o,l,u,c);for(w=N;w<y;w++)s[u[w]]=0;for(g=h[l],b=h[l+1],w=g;w<b;w++)s[D[w]]=x[w];for(var E=N;E<y;E++){var S=u[E],C=c?c[S]:S;if(!(C<0))for(g=p[C],b=p[C+1],s[S]=e(s[S],m[f?g:b-1]),w=f?g+1:g,A=f?b:b-1;w<A;w++){var M=v[w];s[M]=n(s[M],t(m[w],s[S]))}}return N}}),_C="csLu",TC=["abs","divideScalar","multiply","subtract","larger","largerEq","SparseMatrix"],FC=L(_C,TC,r=>{var{abs:e,divideScalar:t,multiply:n,subtract:a,larger:i,largerEq:o,SparseMatrix:l}=r,u=MC({divideScalar:t,multiply:n,subtract:a});return function(c,f,m){if(!c)return null;var v=c._size,p=v[1],d,y=100,x=100;f&&(d=f.q,y=f.lnz||y,x=f.unz||x);var D=[],h=[],w=[],g=new l({values:D,index:h,ptr:w,size:[p,p]}),b=[],A=[],N=[],E=new l({values:b,index:A,ptr:N,size:[p,p]}),S=[],C,M,O=[],I=[];for(C=0;C<p;C++)O[C]=0,S[C]=-1,w[C+1]=0;y=0,x=0;for(var k=0;k<p;k++){w[k]=y,N[k]=x;var _=d?d[k]:k,P=u(g,c,_,I,O,S,1),V=-1,q=-1;for(M=P;M<p;M++)if(C=I[M],S[C]<0){var J=e(O[C]);i(J,q)&&(q=J,V=C)}else A[x]=S[C],b[x++]=O[C];if(V===-1||q<=0)return null;S[_]<0&&o(e(O[_]),n(q,m))&&(V=_);var ne=O[V];for(A[x]=k,b[x++]=ne,S[V]=k,h[y]=V,D[y++]=1,M=P;M<p;M++)C=I[M],S[C]<0&&(h[y]=C,D[y++]=t(O[C],ne)),O[C]=0}for(w[p]=y,N[p]=x,M=0;M<y;M++)h[M]=S[h[M]];return D.splice(y,D.length-y),h.splice(y,h.length-y),b.splice(x,b.length-x),A.splice(x,A.length-x),{L:g,U:E,pinv:S}}}),gp="slu",OC=["typed","abs","add","multiply","transpose","divideScalar","subtract","larger","largerEq","SparseMatrix"],BC=L(gp,OC,r=>{var{typed:e,abs:t,add:n,multiply:a,transpose:i,divideScalar:o,subtract:l,larger:u,largerEq:s,SparseMatrix:c}=r,f=NC({add:n,multiply:a,transpose:i}),m=FC({abs:t,divideScalar:o,multiply:a,subtract:l,larger:u,largerEq:s,SparseMatrix:c});return e(gp,{"SparseMatrix, number, number":function(p,d,y){if(!Ue(d)||d<0||d>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(y<0||y>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var x=f(d,p,!1),D=m(p,x,y);return{L:D.L,U:D.U,p:D.pinv,q:x.q,toString:function(){return"L: "+this.L.toString()+`
|
|
37
37
|
U: `+this.U.toString()+`
|
|
38
38
|
p: `+this.p.toString()+(this.q?`
|
|
39
39
|
q: `+this.q.toString():"")+`
|
|
40
|
-
`}}}})});function
|
|
40
|
+
`}}}})});function yp(r,e){var t,n=e.length,a=[];if(r)for(t=0;t<n;t++)a[r[t]]=e[t];else for(t=0;t<n;t++)a[t]=e[t];return a}var bp="lusolve",RC=["typed","matrix","lup","slu","usolve","lsolve","DenseMatrix"],IC=L(bp,RC,r=>{var{typed:e,matrix:t,lup:n,slu:a,usolve:i,lsolve:o,DenseMatrix:l}=r,u=ui({DenseMatrix:l});return e(bp,{"Array, Array | Matrix":function(m,v){m=t(m);var p=n(m),d=c(p.L,p.U,p.p,null,v);return d.valueOf()},"DenseMatrix, Array | Matrix":function(m,v){var p=n(m);return c(p.L,p.U,p.p,null,v)},"SparseMatrix, Array | Matrix":function(m,v){var p=n(m);return c(p.L,p.U,p.p,null,v)},"SparseMatrix, Array | Matrix, number, number":function(m,v,p,d){var y=a(m,p,d);return c(y.L,y.U,y.p,y.q,v)},"Object, Array | Matrix":function(m,v){return c(m.L,m.U,m.p,m.q,v)}});function s(f){if(Je(f))return f;if(Ar(f))return t(f);throw new TypeError("Invalid Matrix LU decomposition")}function c(f,m,v,p,d){f=s(f),m=s(m),v&&(d=u(f,d,!0),d._data=yp(v,d._data));var y=o(f,d),x=i(m,y);return p&&(x._data=yp(p,x._data)),x}}),xp="polynomialRoot",PC=["typed","isZero","equalScalar","add","subtract","multiply","divide","sqrt","unaryMinus","cbrt","typeOf","im","re"],$C=L(xp,PC,r=>{var{typed:e,isZero:t,equalScalar:n,add:a,subtract:i,multiply:o,divide:l,sqrt:u,unaryMinus:s,cbrt:c,typeOf:f,im:m,re:v}=r;return e(xp,{"number|Complex, ...number|Complex":(p,d)=>{for(var y=[p,...d];y.length>0&&t(y[y.length-1]);)y.pop();if(y.length<2)throw new RangeError("Polynomial [".concat(p,", ").concat(d,"] must have a non-zero non-constant coefficient"));switch(y.length){case 2:return[s(l(y[0],y[1]))];case 3:{var[x,D,h]=y,w=o(2,h),g=o(D,D),b=o(4,h,x);if(n(g,b))return[l(s(D),w)];var A=u(i(g,b));return[l(i(A,D),w),l(i(s(A),D),w)]}case 4:{var[N,E,S,C]=y,M=s(o(3,C)),O=o(S,S),I=o(3,C,E),k=a(o(2,S,S,S),o(27,C,C,N)),_=o(9,C,S,E);if(n(O,I)&&n(k,_))return[l(S,M)];var P=i(O,I),V=i(k,_),q=a(o(18,C,S,E,N),o(S,S,E,E)),J=a(o(4,S,S,S,N),o(4,C,E,E,E),o(27,C,C,N,N));if(n(q,J))return[l(i(o(4,C,S,E),a(o(9,C,C,N),o(S,S,S))),o(C,P)),l(i(o(9,C,N),o(S,E)),o(2,P))];var ne;n(O,I)?ne=V:ne=l(a(V,u(i(o(V,V),o(4,P,P,P)))),2);var j=!0,F=c(ne,j).toArray().map(U=>l(a(S,U,l(P,U)),M));return F.map(U=>f(U)==="Complex"&&n(v(U),v(U)+m(U))?v(U):U)}default:throw new RangeError("only implemented for cubic or lower-order polynomials, not ".concat(y))}}})}),qC="Help",zC=["evaluate"],UC=L(qC,zC,r=>{var{evaluate:e}=r;function t(n){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(!n)throw new Error('Argument "doc" missing');this.doc=n}return t.prototype.type="Help",t.prototype.isHelp=!0,t.prototype.toString=function(){var n=this.doc||{},a=`
|
|
41
41
|
`;if(n.name&&(a+="Name: "+n.name+`
|
|
42
42
|
|
|
43
43
|
`),n.category&&(a+="Category: "+n.category+`
|
|
@@ -51,14 +51,14 @@ q: `+this.q.toString():"")+`
|
|
|
51
51
|
|
|
52
52
|
`),n.examples){a+=`Examples:
|
|
53
53
|
`;for(var i=!1,o=e("config()"),l={config:f=>(i=!0,e("config(newConfig)",{newConfig:f}))},u=0;u<n.examples.length;u++){var s=n.examples[u];a+=" "+s+`
|
|
54
|
-
`;var c=void 0;try{c=e(s,l)}catch(f){c=f}c!==void 0&&!
|
|
54
|
+
`;var c=void 0;try{c=e(s,l)}catch(f){c=f}c!==void 0&&!Ju(c)&&(a+=" "+lr(c,{precision:14})+`
|
|
55
55
|
`)}a+=`
|
|
56
56
|
`,i&&e("config(originalConfig)",{originalConfig:o})}return n.mayThrow&&n.mayThrow.length&&(a+="Throws: "+n.mayThrow.join(", ")+`
|
|
57
57
|
|
|
58
58
|
`),n.seealso&&n.seealso.length&&(a+="See also: "+n.seealso.join(", ")+`
|
|
59
|
-
`),a},t.prototype.toJSON=function(){var n=er(this.doc);return n.mathjs="Help",n},t.fromJSON=function(n){var a={};return Object.keys(n).filter(i=>i!=="mathjs").forEach(i=>{a[i]=n[i]}),new t(a)},t.prototype.valueOf=t.prototype.toString,t},{isClass:!0}),LC="Chain",kC=["?on","math","typed"],VC=L(LC,kC,r=>{var{on:e,math:t,typed:n}=r;function a(s){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");Xu(s)?this.value=s.value:this.value=s}a.prototype.type="Chain",a.prototype.isChain=!0,a.prototype.done=function(){return this.value},a.prototype.valueOf=function(){return this.value},a.prototype.toString=function(){return lr(this.value)},a.prototype.toJSON=function(){return{mathjs:"Chain",value:this.value}},a.fromJSON=function(s){return new a(s.value)};function i(s,c){typeof c=="function"&&(a.prototype[s]=l(c))}function o(s,c){_0(a.prototype,s,function(){var m=c();if(typeof m=="function")return l(m)})}function l(s){return function(){if(arguments.length===0)return new a(s(this.value));for(var c=[this.value],f=0;f<arguments.length;f++)c[f+1]=arguments[f];if(n.isTypedFunction(s)){var m=n.resolve(s,c);if(m.params.length===1)throw new Error("chain function "+s.name+" cannot match rest parameter between chain value and additional arguments.");return new a(m.implementation.apply(s,c))}return new a(s.apply(s,c))}}a.createProxy=function(s,c){if(typeof s=="string")i(s,c);else{var f=function(p){$e(s,p)&&u[p]===void 0&&o(p,()=>s[p])};for(var m in s)f(m)}};var u={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return a.createProxy(t),e&&e("import",function(s,c,f){f||o(s,c)}),a},{isClass:!0}),xp={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"]},GC={name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},HC={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:[]},WC={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:[]},YC={name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},ZC={name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},JC={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:[]},jC={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:[]},XC={name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},QC={name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},KC={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:[]},wp={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"]},eM={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:[]},rM={name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},tM={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"]},nM={name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},aM={name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},iM={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"]},oM={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"]},sM={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"]},uM={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"]},lM={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"]},cM={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"]},fM={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"]},mM={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"]},vM={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"]},pM={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"]},dM={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"]},hM={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"]},gM={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"]},yM={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:[]},bM={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:[]},xM={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:[]},wM={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"]},DM={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"]},NM={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"]},EM={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"]},AM={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"]},SM={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"]},CM={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"]},MM={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"]},_M={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"]},TM={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"]},FM={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"]},OM={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"]},BM={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"]},RM={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"]},IM={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"]},PM={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"]},$M={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"]},qM={name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},zM={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"]},UM={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"]},LM={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"]},kM={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"]},VM={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"]},GM={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"]},HM={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"]},WM={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"]},YM={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"]},ZM={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"]},JM={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"]},jM={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"]},XM={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"]},QM={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"]},KM={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"]},e_={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"]},r_={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"]},t_={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"]},n_={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"]},a_={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"]},i_={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"]},o_={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"]},s_={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"]},u_={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")']},l_={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"]},c_={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"]},f_={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"]},m_={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"]},v_={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"]},p_={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"]},d_={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"]},h_={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"]},g_={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"]},y_={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"]},b_={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"]},x_={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"]},w_={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"]},D_={name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},N_={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"]},E_={name:"num",category:"Fraction",syntax:["num(x)"],description:"Get the numerator of a fraction.",examples:["num(fraction(2, 3))","num(fraction(5, 8))"],seealso:["den","fraction"]},A_={name:"den",category:"Fraction",syntax:["den(x)"],description:"Get the denominator of a fraction.",examples:["den(fraction(2, 3))","den(fraction(5, 8))"],seealso:["num","fraction"]},S_={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"]},C_={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"]},M_={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"]},__={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"]},T_={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"]},F_={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"]},O_={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"]},B_={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"]},R_={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"]},I_={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"]},P_={name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"The 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","bernoulli"]},$_={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"]},q_={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"]},z_={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"]},U_={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"]},L_={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"]},k_={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"]},V_={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"]},G_={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"]},H_={name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},W_={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:[]},Y_={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:[]},Z_={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"]},J_={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"]},j_={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"]},X_={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"]},Q_={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"]},K_={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"]},eT={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"]},rT={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"]},tT={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"]},nT={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"]},aT={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"]},iT={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"]},oT={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"]},sT={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"]},uT={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"]},lT={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"]},cT={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"]},fT={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"]},mT={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"]},vT={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"]},pT={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"]},dT={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"]},hT={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"]},gT={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"]},yT={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"]},bT={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"]},xT={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"]},wT={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"]},DT={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"]},NT={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"]},ET={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"]},AT={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"]},ST={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"]},CT={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"]},MT={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"]},_T={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"]},TT={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"]},FT={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"]},OT={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"]},BT={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"]},RT={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"]},IT={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"]},PT={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"]},$T={name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional Fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},qT={name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse Fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},zT={name:"bernoulli",category:"Probability",syntax:["bernoulli(n)"],description:"The nth Bernoulli number",examples:["bernoulli(4)","bernoulli(fraction(12))"],seealso:["combinations","gamma","stirlingS2"]},UT={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"]},LT={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"]},kT={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"]},VT={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"]},GT={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"]},HT={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:[]},WT={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"]},YT={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"]},ZT={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"]},JT={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"]},jT={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"]},XT={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"]},QT={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"]},KT={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"]},eF={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"]},rF={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"]},tF={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"]},nF={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"]},aF={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"]},iF={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"]},oF={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"]},sF={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"]},uF={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"]},lF={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"]},cF={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"]},fF={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"]},mF={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"]},vF={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"]},pF={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"]},dF={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"]},hF={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"]},gF={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"]},yF={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:[]},bF={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:[]},xF={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:[]},wF={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:[]},DF={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"]},NF={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"]},EF={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"]},AF={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"]},SF={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"]},CF={name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},MF={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"]},_F={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.
|
|
59
|
+
`),a},t.prototype.toJSON=function(){var n=er(this.doc);return n.mathjs="Help",n},t.fromJSON=function(n){var a={};return Object.keys(n).filter(i=>i!=="mathjs").forEach(i=>{a[i]=n[i]}),new t(a)},t.prototype.valueOf=t.prototype.toString,t},{isClass:!0}),LC="Chain",kC=["?on","math","typed"],VC=L(LC,kC,r=>{var{on:e,math:t,typed:n}=r;function a(s){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");Qu(s)?this.value=s.value:this.value=s}a.prototype.type="Chain",a.prototype.isChain=!0,a.prototype.done=function(){return this.value},a.prototype.valueOf=function(){return this.value},a.prototype.toString=function(){return lr(this.value)},a.prototype.toJSON=function(){return{mathjs:"Chain",value:this.value}},a.fromJSON=function(s){return new a(s.value)};function i(s,c){typeof c=="function"&&(a.prototype[s]=l(c))}function o(s,c){_0(a.prototype,s,function(){var m=c();if(typeof m=="function")return l(m)})}function l(s){return function(){if(arguments.length===0)return new a(s(this.value));for(var c=[this.value],f=0;f<arguments.length;f++)c[f+1]=arguments[f];if(n.isTypedFunction(s)){var m=n.resolve(s,c);if(m.params.length===1)throw new Error("chain function "+s.name+" cannot match rest parameter between chain value and additional arguments.");return new a(m.implementation.apply(s,c))}return new a(s.apply(s,c))}}a.createProxy=function(s,c){if(typeof s=="string")i(s,c);else{var f=function(p){$e(s,p)&&u[p]===void 0&&o(p,()=>s[p])};for(var m in s)f(m)}};var u={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return a.createProxy(t),e&&e("import",function(s,c,f){f||o(s,c)}),a},{isClass:!0}),wp={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"]},GC={name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},HC={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:[]},WC={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:[]},YC={name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},ZC={name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},JC={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:[]},jC={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:[]},XC={name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},QC={name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},KC={name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["phi"],seealso:[]},Dp={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]},eM={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:[]},rM={name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},tM={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"]},nM={name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},aM={name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},iM={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"]},oM={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"]},sM={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"]},uM={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"]},lM={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"]},cM={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"]},fM={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"]},mM={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"]},vM={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"]},pM={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"]},dM={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"]},hM={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"]},gM={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"]},yM={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:[]},bM={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:[]},xM={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:[]},wM={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"]},DM={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"]},NM={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"]},EM={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"]},AM={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"]},SM={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"]},CM={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"]},MM={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"]},_M={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"]},TM={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"]},FM={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"]},OM={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"]},BM={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"]},RM={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"]},IM={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"]},PM={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"]},$M={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"]},qM={name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},zM={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"]},UM={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"]},LM={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"]},kM={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"]},VM={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"]},GM={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"]},HM={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"]},WM={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"]},YM={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"]},ZM={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"]},JM={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"]},jM={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"]},XM={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"]},QM={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"]},KM={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"]},e_={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"]},r_={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"]},t_={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"]},n_={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"]},a_={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"]},i_={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"]},o_={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"]},s_={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"]},u_={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")']},l_={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"]},c_={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"]},f_={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"]},m_={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"]},v_={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"]},p_={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"]},d_={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"]},h_={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"]},g_={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"]},y_={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"]},b_={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"]},x_={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"]},w_={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"]},D_={name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},N_={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"]},E_={name:"num",category:"Fraction",syntax:["num(x)"],description:"Get the numerator of a fraction.",examples:["num(fraction(2, 3))","num(fraction(5, 8))"],seealso:["den","fraction"]},A_={name:"den",category:"Fraction",syntax:["den(x)"],description:"Get the denominator of a fraction.",examples:["den(fraction(2, 3))","den(fraction(5, 8))"],seealso:["num","fraction"]},S_={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"]},C_={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"]},M_={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"]},__={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"]},T_={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"]},F_={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"]},O_={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"]},B_={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"]},R_={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"]},I_={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"]},P_={name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"The 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","bernoulli"]},$_={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"]},q_={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"]},z_={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"]},U_={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"]},L_={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"]},k_={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"]},V_={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"]},G_={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"]},H_={name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},W_={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:[]},Y_={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:[]},Z_={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"]},J_={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"]},j_={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"]},X_={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"]},Q_={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"]},K_={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"]},eT={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"]},rT={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"]},tT={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"]},nT={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"]},aT={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"]},iT={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"]},oT={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"]},sT={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"]},uT={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"]},lT={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"]},cT={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"]},fT={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"]},mT={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"]},vT={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"]},pT={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"]},dT={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"]},hT={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"]},gT={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"]},yT={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"]},bT={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"]},xT={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"]},wT={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"]},DT={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"]},NT={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"]},ET={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"]},AT={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"]},ST={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"]},CT={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"]},MT={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"]},_T={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"]},TT={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"]},FT={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"]},OT={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"]},BT={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"]},RT={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"]},IT={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"]},PT={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"]},$T={name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional Fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},qT={name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse Fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},zT={name:"bernoulli",category:"Probability",syntax:["bernoulli(n)"],description:"The nth Bernoulli number",examples:["bernoulli(4)","bernoulli(fraction(12))"],seealso:["combinations","gamma","stirlingS2"]},UT={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"]},LT={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"]},kT={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"]},VT={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"]},GT={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"]},HT={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:[]},WT={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"]},YT={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"]},ZT={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"]},JT={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"]},jT={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"]},XT={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"]},QT={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"]},KT={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"]},eF={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"]},rF={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"]},tF={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"]},nF={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"]},aF={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"]},iF={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"]},oF={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"]},sF={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"]},uF={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"]},lF={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"]},cF={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"]},fF={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"]},mF={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"]},vF={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"]},pF={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"]},dF={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"]},hF={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"]},gF={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"]},yF={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:[]},bF={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:[]},xF={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:[]},wF={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:[]},DF={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"]},NF={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"]},EF={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"]},AF={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"]},SF={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"]},CF={name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},MF={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"]},_F={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.
|
|
60
60
|
|
|
61
|
-
In case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.`,examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},TF={name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, dimension)","std(A, normalization)","std(A, dimension, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},FF={name:"cumsum",category:"Statistics",syntax:["cumsum(a, b, c, ...)","cumsum(A)"],description:"Compute the cumulative sum of all values.",examples:["cumsum(2, 3, 4, 1)","cumsum([2, 3, 4, 1])","cumsum([1, 2; 3, 4])","cumsum([1, 2; 3, 4], 1)","cumsum([1, 2; 3, 4], 2)"],seealso:["max","mean","median","min","prod","std","sum","variance"]},OF={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"]},BF={name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, dimension)","variance(A, normalization)","variance(A, dimension, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},RF={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"]},IF={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"]},PF={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"]},$F={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"]},qF={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"]},zF={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"]},UF={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"]},LF={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"]},kF={name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},VF={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"]},GF={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"]},HF={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"]},WF={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"]},YF={name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},ZF={name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},JF={name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},jF={name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},XF={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"]},QF={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"]},KF={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"]},e3={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"]},r3={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"]},t3={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"]},n3={name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},a3={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"]},i3={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"]},o3={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:[]},s3={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:[]},u3={name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},l3={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:[]},c3={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"]},f3={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"]},m3={name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},v3={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"]},p3={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","isFinite","isBounded"]},d3={name:"isBounded",category:"Utils",syntax:["isBounded(x)"],description:"Test whether a value or its entries are bounded.",examples:["isBounded(Infinity)","isBounded(bigint(3))","isBounded([3, -Infinity, -3])"],seealso:["isFinite","isNumeric","isNaN","isNegative","isPositive"]},h3={name:"isFinite",category:"Utils",syntax:["isFinite(x)"],description:"Test whether a value is finite, elementwise on collections.",examples:["isFinite(Infinity)","isFinite(bigint(3))","isFinite([3, -Infinity, -3])"],seealso:["isBounded","isNumeric","isNaN","isNegative","isPositive"]},g3={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"]},y3={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","isFinite","isBounded"]},b3={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"]},x3={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"]},w3={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"]},D3={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"]},N3={name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},E3={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"]},A3={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"]},S3={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"]},C3={bignumber:iM,bigint:oM,boolean:sM,complex:uM,createUnit:lM,fraction:cM,index:fM,matrix:mM,number:vM,sparse:pM,splitUnit:dM,string:hM,unit:gM,e:xp,E:xp,false:GC,i:HC,Infinity:WC,LN2:ZC,LN10:YC,LOG2E:jC,LOG10E:JC,NaN:XC,null:QC,pi:wp,PI:wp,phi:KC,SQRT1_2:eM,SQRT2:rM,tau:tM,true:nM,version:aM,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:wM,lsolve:NM,lsolveAll:EM,lup:AM,lusolve:SM,leafCount:DM,polynomialRoot:CM,resolve:TM,simplify:FM,simplifyConstant:OM,simplifyCore:BM,symbolicEqual:IM,rationalize:_M,slu:RM,usolve:PM,usolveAll:$M,qr:MM,abs:qM,add:zM,cbrt:UM,ceil:LM,cube:kM,divide:VM,dotDivide:GM,dotMultiply:HM,dotPow:WM,exp:YM,expm:ZM,expm1:JM,fix:jM,floor:XM,gcd:QM,hypot:KM,lcm:r_,log:t_,log2:i_,log1p:a_,log10:n_,mod:o_,multiply:s_,norm:u_,nthRoot:l_,nthRoots:c_,pow:f_,round:m_,sign:v_,sqrt:p_,sqrtm:d_,square:b_,subtract:x_,unaryMinus:w_,unaryPlus:D_,xgcd:N_,invmod:e_,num:E_,den:A_,bitAnd:S_,bitNot:C_,bitOr:M_,bitXor:__,leftShift:T_,rightArithShift:F_,rightLogShift:O_,bellNumbers:B_,catalan:R_,composition:I_,stirlingS2:P_,config:yM,import:bM,typed:xM,arg:$_,conj:q_,re:U_,im:z_,evaluate:L_,help:H_,parse:V_,parser:k_,compile:G_,distance:W_,intersect:Y_,and:Z_,not:J_,nullish:j_,or:X_,xor:Q_,mapSlices:K_,concat:rT,count:tT,cross:nT,column:eT,ctranspose:aT,det:iT,diag:oT,diff:sT,dot:uT,getMatrixDataType:vT,identity:pT,filter:cT,flatten:fT,forEach:mT,inv:dT,pinv:hT,eigs:lT,kron:gT,matrixFromFunction:xT,matrixFromRows:wT,matrixFromColumns:bT,map:yT,ones:DT,partitionSelect:NT,range:ET,resize:ST,reshape:AT,rotate:CT,rotationMatrix:MT,row:_T,size:TT,sort:FT,squeeze:OT,subset:BT,trace:RT,transpose:IT,zeros:PT,fft:$T,ifft:qT,sylvester:h_,schur:g_,lyap:y_,solveODE:S3,bernoulli:zT,combinations:UT,combinationsWithRep:LT,factorial:kT,gamma:VT,kldivergence:HT,lgamma:GT,multinomial:WT,permutations:YT,pickRandom:ZT,random:JT,randomInt:jT,compare:XT,compareNatural:QT,compareText:KT,deepEqual:eF,equal:rF,equalText:tF,larger:nF,largerEq:aF,smaller:iF,smallerEq:oF,unequal:sF,setCartesian:uF,setDifference:lF,setDistinct:cF,setIntersect:fF,setIsSubset:mF,setMultiplicity:vF,setPowerset:pF,setSize:dF,setSymDifference:hF,setUnion:gF,zpk2tf:yF,freqz:bF,erf:xF,zeta:wF,cumsum:FF,mad:DF,max:NF,mean:EF,median:AF,min:SF,mode:CF,prod:MF,quantileSeq:_F,std:TF,sum:OF,variance:BF,corr:RF,acos:IF,acosh:PF,acot:$F,acoth:qF,acsc:zF,acsch:UF,asec:LF,asech:kF,asin:VF,asinh:GF,atan:HF,atanh:YF,atan2:WF,cos:ZF,cosh:JF,cot:jF,coth:XF,csc:QF,csch:KF,sec:e3,sech:r3,sin:t3,sinh:n3,tan:a3,tanh:i3,to:o3,toBest:s3,clone:l3,format:c3,bin:u3,oct:N3,hex:m3,isNaN:p3,isBounded:d3,isFinite:h3,isInteger:v3,isNegative:g3,isNumeric:y3,hasNumericValue:f3,isPositive:b3,isPrime:x3,isZero:w3,print:E3,typeOf:A3,numeric:D3},Dp="help",M3=["typed","mathWithTransform","Help"],_3=L(Dp,M3,r=>{var{typed:e,mathWithTransform:t,Help:n}=r;return e(Dp,{any:function(i){var o,l=i;if(typeof i!="string"){for(o in t)if($e(t,o)&&i===t[o]){l=o;break}}var u=pt(C3,l);if(!u){var s=typeof l=="function"?l.name:l;throw new Error('No documentation found on "'+s+'"')}return new n(u)}})}),Np="chain",T3=["typed","Chain"],F3=L(Np,T3,r=>{var{typed:e,Chain:t}=r;return e(Np,{"":function(){return new t},any:function(a){return new t(a)}})}),Ep="det",O3=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],B3=L(Ep,O3,r=>{var{typed:e,matrix:t,subtractScalar:n,multiply:a,divideScalar:i,isZero:o,unaryMinus:l}=r;return e(Ep,{any:function(c){return er(c)},"Array | Matrix":function(c){var f;switch(Je(c)?f=c.size():Array.isArray(c)?(c=t(c),f=c.size()):f=[],f.length){case 0:return er(c);case 1:if(f[0]===1)return er(c.valueOf()[0]);if(f[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+lr(f)+")");case 2:{var m=f[0],v=f[1];if(m===v)return u(c.clone().valueOf(),m);if(v===0)return 1;throw new RangeError("Matrix must be square (size: "+lr(f)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+lr(f)+")")}}});function u(s,c,f){if(c===1)return er(s[0][0]);if(c===2)return n(a(s[0][0],s[1][1]),a(s[1][0],s[0][1]));for(var m=!1,v=new Array(c).fill(0).map((A,N)=>N),p=0;p<c;p++){var d=v[p];if(o(s[d][p])){var y=void 0;for(y=p+1;y<c;y++)if(!o(s[v[y]][p])){d=v[y],v[y]=v[p],v[p]=d,m=!m;break}if(y===c)return s[d][p]}for(var x=s[d][p],D=p===0?1:s[v[p-1]][p-1],h=p+1;h<c;h++)for(var w=v[h],g=p+1;g<c;g++)s[w][g]=i(n(a(s[w][g],x),a(s[w][p],s[d][g])),D)}var b=s[v[c-1]][c-1];return m?l(b):b}}),Ap="inv",R3=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],I3=L(Ap,R3,r=>{var{typed:e,matrix:t,divideScalar:n,addScalar:a,multiply:i,unaryMinus:o,det:l,identity:u,abs:s}=r;return e(Ap,{"Array | Matrix":function(m){var v=Je(m)?m.size():rr(m);switch(v.length){case 1:if(v[0]===1)return Je(m)?t([n(1,m.valueOf()[0])]):[n(1,m[0])];throw new RangeError("Matrix must be square (size: "+lr(v)+")");case 2:{var p=v[0],d=v[1];if(p===d)return Je(m)?t(c(m.valueOf(),p,d),m.storage()):c(m,p,d);throw new RangeError("Matrix must be square (size: "+lr(v)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+lr(v)+")")}},any:function(m){return n(1,m)}});function c(f,m,v){var p,d,y,x,D;if(m===1){if(x=f[0][0],x===0)throw Error("Cannot calculate inverse, determinant is zero");return[[n(1,x)]]}else if(m===2){var h=l(f);if(h===0)throw Error("Cannot calculate inverse, determinant is zero");return[[n(f[1][1],h),n(o(f[0][1]),h)],[n(o(f[1][0]),h),n(f[0][0],h)]]}else{var w=f.concat();for(p=0;p<m;p++)w[p]=w[p].concat();for(var g=u(m).valueOf(),b=0;b<v;b++){var A=s(w[b][b]),N=b;for(p=b+1;p<m;)s(w[p][b])>A&&(A=s(w[p][b]),N=p),p++;if(A===0)throw Error("Cannot calculate inverse, determinant is zero");p=N,p!==b&&(D=w[b],w[b]=w[p],w[p]=D,D=g[b],g[b]=g[p],g[p]=D);var E=w[b],S=g[b];for(p=0;p<m;p++){var C=w[p],M=g[p];if(p!==b){if(C[b]!==0){for(y=n(o(C[b]),E[b]),d=b;d<v;d++)C[d]=a(C[d],i(y,E[d]));for(d=0;d<v;d++)M[d]=a(M[d],i(y,S[d]))}}else{for(y=E[b],d=b;d<v;d++)C[d]=n(C[d],y);for(d=0;d<v;d++)M[d]=n(M[d],y)}}}return g}}}),Sp="pinv",P3=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],$3=L(Sp,P3,r=>{var{typed:e,matrix:t,inv:n,deepEqual:a,equal:i,dotDivide:o,dot:l,ctranspose:u,divideScalar:s,multiply:c,add:f,Complex:m}=r;return e(Sp,{"Array | Matrix":function(h){var w=Je(h)?h.size():rr(h);switch(w.length){case 1:return x(h)?u(h):w[0]===1?n(h):o(u(h),l(h,h));case 2:{if(x(h))return u(h);var g=w[0],b=w[1];if(g===b)try{return n(h)}catch(A){if(!(A instanceof Error&&A.message.match(/Cannot calculate inverse, determinant is zero/)))throw A}return Je(h)?t(v(h.valueOf(),g,b),h.storage()):v(h,g,b)}default:throw new RangeError("Matrix must be two dimensional (size: "+lr(w)+")")}},any:function(h){return i(h,0)?er(h):s(1,h)}});function v(D,h,w){var{C:g,F:b}=d(D,h,w),A=c(n(c(u(g),g)),u(g)),N=c(u(b),n(c(b,u(b))));return c(N,A)}function p(D,h,w){for(var g=er(D),b=0,A=0;A<h;A++){if(w<=b)return g;for(var N=A;y(g[N][b]);)if(N++,h===N&&(N=A,b++,w===b))return g;[g[N],g[A]]=[g[A],g[N]];for(var E=g[A][b],S=0;S<w;S++)g[A][S]=o(g[A][S],E);for(var C=0;C<h;C++)if(C!==A){E=g[C][b];for(var M=0;M<w;M++)g[C][M]=f(g[C][M],c(-1,c(E,g[A][M])))}b++}return g}function d(D,h,w){var g=p(D,h,w),b=D.map((N,E)=>N.filter((S,C)=>C<h&&!y(l(g[C],g[C])))),A=g.filter((N,E)=>!y(l(g[E],g[E])));return{C:b,F:A}}function y(D){return i(f(D,m(1,1)),f(0,m(1,1)))}function x(D){return a(f(D,m(1,1)),f(c(D,0),m(1,1)))}});function q3(r){var{addScalar:e,subtract:t,flatten:n,multiply:a,multiplyScalar:i,divideScalar:o,sqrt:l,abs:u,bignumber:s,diag:c,size:f,reshape:m,inv:v,qr:p,usolve:d,usolveAll:y,equal:x,complex:D,larger:h,smaller:w,matrixFromColumns:g,dot:b}=r;function A(j,F,U,$){var le=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,me=N(j,F,U,$,le);E(j,F,U,$,le,me);var{values:Y,C:z}=S(j,F,U,$,le);if(le){var X=C(j,F,z,me,Y,U,$);return{values:Y,eigenvectors:X}}return{values:Y}}function N(j,F,U,$,le){var me=$==="BigNumber",Y=$==="Complex",z=me?s(0):0,X=me?s(1):Y?D(1):1,se=me?s(1):1,re=me?s(10):2,pe=i(re,re),ve;le&&(ve=Array(F).fill(X));for(var De=!1;!De;){De=!0;for(var Oe=0;Oe<F;Oe++){for(var Ie=z,_e=z,Le=0;Le<F;Le++)Oe!==Le&&(Ie=e(Ie,u(j[Le][Oe])),_e=e(_e,u(j[Oe][Le])));if(!x(Ie,0)&&!x(_e,0)){for(var qe=se,G=Ie,ee=o(_e,re),R=i(_e,re);w(G,ee);)G=i(G,pe),qe=i(qe,re);for(;h(G,R);)G=o(G,pe),qe=o(qe,re);var H=w(o(e(G,_e),qe),i(e(Ie,_e),.95));if(H){De=!1;for(var Q=o(1,qe),ie=0;ie<F;ie++)Oe!==ie&&(j[Oe][ie]=i(j[Oe][ie],Q),j[ie][Oe]=i(j[ie][Oe],qe));le&&(ve[Oe]=i(ve[Oe],Q))}}}}return le?c(ve):null}function E(j,F,U,$,le,me){var Y=$==="BigNumber",z=$==="Complex",X=Y?s(0):z?D(0):0;Y&&(U=s(U));for(var se=0;se<F-2;se++){for(var re=0,pe=X,ve=se+1;ve<F;ve++){var De=j[ve][se];w(u(pe),u(De))&&(pe=De,re=ve)}if(!w(u(pe),U)){if(re!==se+1){var Oe=j[re];j[re]=j[se+1],j[se+1]=Oe;for(var Ie=0;Ie<F;Ie++){var _e=j[Ie][re];j[Ie][re]=j[Ie][se+1],j[Ie][se+1]=_e}if(le){var Le=me[re];me[re]=me[se+1],me[se+1]=Le}}for(var qe=se+2;qe<F;qe++){var G=o(j[qe][se],pe);if(G!==0){for(var ee=0;ee<F;ee++)j[qe][ee]=t(j[qe][ee],i(G,j[se+1][ee]));for(var R=0;R<F;R++)j[R][se+1]=e(j[R][se+1],i(G,j[R][qe]));if(le)for(var H=0;H<F;H++)me[qe][H]=t(me[qe][H],i(G,me[se+1][H]))}}}}return me}function S(j,F,U,$,le){var me=$==="BigNumber",Y=$==="Complex",z=me?s(1):Y?D(1):1;me&&(U=s(U));for(var X=er(j),se=[],re=F,pe=[],ve=le?c(Array(F).fill(z)):void 0,De=le?c(Array(re).fill(z)):void 0,Oe=0;Oe<=100;){Oe+=1;for(var Ie=X[re-1][re-1],_e=0;_e<re;_e++)X[_e][_e]=t(X[_e][_e],Ie);var{Q:Le,R:qe}=p(X);X=a(qe,Le);for(var G=0;G<re;G++)X[G][G]=e(X[G][G],Ie);if(le&&(De=a(De,Le)),re===1||w(u(X[re-1][re-2]),U)){Oe=0,se.push(X[re-1][re-1]),le&&(pe.unshift([[1]]),I(De,F),ve=a(ve,De),re>1&&(De=c(Array(re-1).fill(z)))),re-=1,X.pop();for(var ee=0;ee<re;ee++)X[ee].pop()}else if(re===2||w(u(X[re-2][re-3]),U)){Oe=0;var R=M(X[re-2][re-2],X[re-2][re-1],X[re-1][re-2],X[re-1][re-1]);se.push(...R),le&&(pe.unshift(O(X[re-2][re-2],X[re-2][re-1],X[re-1][re-2],X[re-1][re-1],R[0],R[1],U,$)),I(De,F),ve=a(ve,De),re>2&&(De=c(Array(re-2).fill(z)))),re-=2,X.pop(),X.pop();for(var H=0;H<re;H++)X[H].pop(),X[H].pop()}if(re===0)break}if(se.sort((ue,oe)=>+t(u(ue),u(oe))),Oe>100){var Q=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+se.join(", "));throw Q.values=se,Q.vectors=[],Q}var ie=le?a(ve,k(pe,F)):void 0;return{values:se,C:ie}}function C(j,F,U,$,le,me,Y){var z=v(U),X=a(z,j,U),se=Y==="BigNumber",re=Y==="Complex",pe=se?s(0):re?D(0):0,ve=se?s(1):re?D(1):1,De=[],Oe=[];for(var Ie of le){var _e=_(De,Ie,x);_e===-1?(De.push(Ie),Oe.push(1)):Oe[_e]+=1}for(var Le=[],qe=De.length,G=Array(F).fill(pe),ee=c(Array(F).fill(ve)),R=function(){var ie=De[H],ue=t(X,a(ie,ee)),oe=y(ue,G);for(oe.shift();oe.length<Oe[H];){var we=P(ue,F,oe,me,Y);if(we===null)break;oe.push(we)}var xe=a(v($),U);oe=oe.map(Te=>a(xe,Te)),Le.push(...oe.map(Te=>({value:ie,vector:n(Te)})))},H=0;H<qe;H++)R();return Le}function M(j,F,U,$){var le=e(j,$),me=t(i(j,$),i(F,U)),Y=i(le,.5),z=i(l(t(i(le,le),i(4,me))),.5);return[e(Y,z),t(Y,z)]}function O(j,F,U,$,le,me,Y,z){var X=z==="BigNumber",se=z==="Complex",re=X?s(0):se?D(0):0,pe=X?s(1):se?D(1):1;if(w(u(U),Y))return[[pe,re],[re,pe]];if(h(u(t(le,me)),Y))return[[t(le,$),t(me,$)],[U,U]];var ve=t(j,le),De=t($,le);return w(u(F),Y)&&w(u(De),Y)?[[ve,pe],[U,re]]:[[F,re],[De,pe]]}function I(j,F){for(var U=0;U<j.length;U++)j[U].push(...Array(F-j[U].length).fill(0));for(var $=j.length;$<F;$++)j.push(Array(F).fill(0)),j[$][$]=1;return j}function k(j,F){for(var U=[],$=0;$<F;$++)U[$]=Array(F).fill(0);var le=0;for(var me of j){for(var Y=me.length,z=0;z<Y;z++)for(var X=0;X<Y;X++)U[le+z][le+X]=me[z][X];le+=Y}return U}function _(j,F,U){for(var $=0;$<j.length;$++)if(U(j[$],F))return $;return-1}function P(j,F,U,$,le){for(var me=le==="BigNumber"?s(1e3):1e3,Y,z=0;z<5;++z){Y=V(F,U,le);try{Y=d(j,Y)}catch{continue}if(h(J(Y),me))break}if(z>=5)return null;for(z=0;;){var X=d(j,Y);if(w(J(q(Y,[X])),$))break;if(++z>=10)return null;Y=ne(X)}return Y}function V(j,F,U){var $=U==="BigNumber",le=U==="Complex",me=Array(j).fill(0).map(Y=>2*Math.random()-1);return $&&(me=me.map(Y=>s(Y))),le&&(me=me.map(Y=>D(Y))),me=q(me,F),ne(me,U)}function q(j,F){var U=f(j);for(var $ of F)$=m($,U),j=t(j,a(o(b($,j),b($,$)),$));return j}function J(j){return u(l(b(j,j)))}function ne(j,F){var U=F==="BigNumber",$=F==="Complex",le=U?s(1):$?D(1):1;return a(o(le,J(j)),j)}return A}function z3(r){var{config:e,addScalar:t,subtract:n,abs:a,atan:i,cos:o,sin:l,multiplyScalar:u,inv:s,bignumber:c,multiply:f,add:m}=r;function v(E,S){var C=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.relTol,M=arguments.length>3?arguments[3]:void 0,O=arguments.length>4?arguments[4]:void 0;if(M==="number")return p(E,C,O);if(M==="BigNumber")return d(E,C,O);throw TypeError("Unsupported data type: "+M)}function p(E,S,C){var M=E.length,O=Math.abs(S/M),I,k;if(C){k=new Array(M);for(var _=0;_<M;_++)k[_]=Array(M).fill(0),k[_][_]=1}for(var P=b(E);Math.abs(P[1])>=Math.abs(O);){var V=P[0][0],q=P[0][1];I=y(E[V][V],E[q][q],E[V][q]),E=g(E,I,V,q),C&&(k=D(k,I,V,q)),P=b(E)}for(var J=Array(M).fill(0),ne=0;ne<M;ne++)J[ne]=E[ne][ne];return N(er(J),k,C)}function d(E,S,C){var M=E.length,O=a(S/M),I,k;if(C){k=new Array(M);for(var _=0;_<M;_++)k[_]=Array(M).fill(0),k[_][_]=1}for(var P=A(E);a(P[1])>=a(O);){var V=P[0][0],q=P[0][1];I=x(E[V][V],E[q][q],E[V][q]),E=w(E,I,V,q),C&&(k=h(k,I,V,q)),P=A(E)}for(var J=Array(M).fill(0),ne=0;ne<M;ne++)J[ne]=E[ne][ne];return N(er(J),k,C)}function y(E,S,C){var M=S-E;return Math.abs(M)<=e.relTol?Math.PI/4:.5*Math.atan(2*C/(S-E))}function x(E,S,C){var M=n(S,E);return a(M)<=e.relTol?c(-1).acos().div(4):u(.5,i(f(2,C,s(M))))}function D(E,S,C,M){for(var O=E.length,I=Math.cos(S),k=Math.sin(S),_=Array(O).fill(0),P=Array(O).fill(0),V=0;V<O;V++)_[V]=I*E[V][C]-k*E[V][M],P[V]=k*E[V][C]+I*E[V][M];for(var q=0;q<O;q++)E[q][C]=_[q],E[q][M]=P[q];return E}function h(E,S,C,M){for(var O=E.length,I=o(S),k=l(S),_=Array(O).fill(c(0)),P=Array(O).fill(c(0)),V=0;V<O;V++)_[V]=n(u(I,E[V][C]),u(k,E[V][M])),P[V]=t(u(k,E[V][C]),u(I,E[V][M]));for(var q=0;q<O;q++)E[q][C]=_[q],E[q][M]=P[q];return E}function w(E,S,C,M){for(var O=E.length,I=c(o(S)),k=c(l(S)),_=u(I,I),P=u(k,k),V=Array(O).fill(c(0)),q=Array(O).fill(c(0)),J=f(c(2),I,k,E[C][M]),ne=t(n(u(_,E[C][C]),J),u(P,E[M][M])),j=m(u(P,E[C][C]),J,u(_,E[M][M])),F=0;F<O;F++)V[F]=n(u(I,E[C][F]),u(k,E[M][F])),q[F]=t(u(k,E[C][F]),u(I,E[M][F]));E[C][C]=ne,E[M][M]=j,E[C][M]=c(0),E[M][C]=c(0);for(var U=0;U<O;U++)U!==C&&U!==M&&(E[C][U]=V[U],E[U][C]=V[U],E[M][U]=q[U],E[U][M]=q[U]);return E}function g(E,S,C,M){for(var O=E.length,I=Math.cos(S),k=Math.sin(S),_=I*I,P=k*k,V=Array(O).fill(0),q=Array(O).fill(0),J=_*E[C][C]-2*I*k*E[C][M]+P*E[M][M],ne=P*E[C][C]+2*I*k*E[C][M]+_*E[M][M],j=0;j<O;j++)V[j]=I*E[C][j]-k*E[M][j],q[j]=k*E[C][j]+I*E[M][j];E[C][C]=J,E[M][M]=ne,E[C][M]=0,E[M][C]=0;for(var F=0;F<O;F++)F!==C&&F!==M&&(E[C][F]=V[F],E[F][C]=V[F],E[M][F]=q[F],E[F][M]=q[F]);return E}function b(E){for(var S=E.length,C=0,M=[0,1],O=0;O<S;O++)for(var I=O+1;I<S;I++)Math.abs(C)<Math.abs(E[O][I])&&(C=Math.abs(E[O][I]),M=[O,I]);return[M,C]}function A(E){for(var S=E.length,C=0,M=[0,1],O=0;O<S;O++)for(var I=O+1;I<S;I++)a(C)<a(E[O][I])&&(C=a(E[O][I]),M=[O,I]);return[M,C]}function N(E,S,C){var M=E.length,O=Array(M),I;if(C){I=Array(M);for(var k=0;k<M;k++)I[k]=Array(M)}for(var _=0;_<M;_++){for(var P=0,V=E[0],q=0;q<E.length;q++)a(E[q])<a(V)&&(P=q,V=E[P]);if(O[_]=E.splice(P,1)[0],C)for(var J=0;J<M;J++)I[_][J]=S[J][P],S[J].splice(P,1)}if(!C)return{values:O};var ne=I.map((j,F)=>({value:O[F],vector:j}));return{values:O,eigenvectors:ne}}return v}var U3="eigs",L3=["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"],k3=L(U3,L3,r=>{var{config:e,typed:t,matrix:n,addScalar:a,subtract:i,equal:o,abs:l,atan:u,cos:s,sin:c,multiplyScalar:f,divideScalar:m,inv:v,bignumber:p,multiply:d,add:y,larger:x,column:D,flatten:h,number:w,complex:g,sqrt:b,diag:A,size:N,reshape:E,qr:S,usolve:C,usolveAll:M,im:O,re:I,smaller:k,matrixFromColumns:_,dot:P}=r,V=z3({config:e,addScalar:a,subtract:i,abs:l,atan:u,cos:s,sin:c,multiplyScalar:f,inv:v,bignumber:p,multiply:d,add:y}),q=q3({addScalar:a,subtract:i,multiply:d,multiplyScalar:f,flatten:h,divideScalar:m,sqrt:b,abs:l,bignumber:p,diag:A,size:N,reshape:E,qr:S,inv:v,usolve:C,usolveAll:M,equal:o,complex:g,larger:x,smaller:k,matrixFromColumns:_,dot:P});return t("eigs",{Array:function(me){return J(n(me))},"Array, number|BigNumber":function(me,Y){return J(n(me),{precision:Y})},"Array, Object"(le,me){return J(n(le),me)},Matrix:function(me){return J(me,{matricize:!0})},"Matrix, number|BigNumber":function(me,Y){return J(me,{precision:Y,matricize:!0})},"Matrix, Object":function(me,Y){var z={matricize:!0};return zr(z,Y),J(me,z)}});function J(le){var me,Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},z="eigenvectors"in Y?Y.eigenvectors:!0,X=(me=Y.precision)!==null&&me!==void 0?me:e.relTol,se=ne(le,X,z);return Y.matricize&&(se.values=n(se.values),z&&(se.eigenvectors=se.eigenvectors.map(re=>{var{value:pe,vector:ve}=re;return{value:pe,vector:n(ve)}}))),z&&Object.defineProperty(se,"vectors",{enumerable:!1,get:()=>{throw new Error("eigs(M).vectors replaced with eigs(M).eigenvectors")}}),se}function ne(le,me,Y){var z=le.toArray(),X=le.size();if(X.length!==2||X[0]!==X[1])throw new RangeError("Matrix must be square (size: ".concat(lr(X),")"));var se=X[0];if(F(z,se,me)&&(U(z,se),j(z,se,me))){var re=$(le,z,se);return V(z,se,me,re,Y)}var pe=$(le,z,se);return q(z,se,me,pe,Y)}function j(le,me,Y){for(var z=0;z<me;z++)for(var X=z;X<me;X++)if(x(p(l(i(le[z][X],le[X][z]))),Y))return!1;return!0}function F(le,me,Y){for(var z=0;z<me;z++)for(var X=0;X<me;X++)if(x(p(l(O(le[z][X]))),Y))return!1;return!0}function U(le,me){for(var Y=0;Y<me;Y++)for(var z=0;z<me;z++)le[Y][z]=I(le[Y][z])}function $(le,me,Y){var z=le.datatype();if(z==="number"||z==="BigNumber"||z==="Complex")return z;for(var X=!1,se=!1,re=!1,pe=0;pe<Y;pe++)for(var ve=0;ve<Y;ve++){var De=me[pe][ve];if(Ye(De)||Ka(De))X=!0;else if(or(De))se=!0;else if(ln(De))re=!0;else throw TypeError("Unsupported type in Matrix: "+Sr(De))}if(se&&re&&console.warn("Complex BigNumbers not supported, this operation will lose precission."),re){for(var Oe=0;Oe<Y;Oe++)for(var Ie=0;Ie<Y;Ie++)me[Oe][Ie]=g(me[Oe][Ie]);return"Complex"}if(se){for(var _e=0;_e<Y;_e++)for(var Le=0;Le<Y;Le++)me[_e][Le]=p(me[_e][Le]);return"BigNumber"}if(X){for(var qe=0;qe<Y;qe++)for(var G=0;G<Y;G++)me[qe][G]=w(me[qe][G]);return"number"}else throw TypeError("Matrix contains unsupported types only.")}}),Cp="expm",V3=["typed","abs","add","identity","inv","multiply"],G3=L(Cp,V3,r=>{var{typed:e,abs:t,add:n,identity:a,inv:i,multiply:o}=r;return e(Cp,{Matrix:function(f){var m=f.size();if(m.length!==2||m[0]!==m[1])throw new RangeError("Matrix must be square (size: "+lr(m)+")");for(var v=m[0],p=1e-15,d=l(f),y=u(d,p),x=y.q,D=y.j,h=o(f,Math.pow(2,-D)),w=a(v),g=a(v),b=1,A=h,N=-1,E=1;E<=x;E++)E>1&&(A=o(A,h),N=-N),b=b*(x-E+1)/((2*x-E+1)*E),w=n(w,o(b,A)),g=n(g,o(b*N,A));for(var S=o(i(g),w),C=0;C<D;C++)S=o(S,S);return Yn(f)?f.createSparseMatrix(S):S}});function l(c){for(var f=c.size()[0],m=0,v=0;v<f;v++){for(var p=0,d=0;d<f;d++)p+=t(c.get([v,d]));m=Math.max(p,m)}return m}function u(c,f){for(var m=30,v=0;v<m;v++)for(var p=0;p<=v;p++){var d=v-p;if(s(c,p,d)<f)return{q:p,j:d}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}function s(c,f,m){for(var v=1,p=2;p<=f;p++)v*=p;for(var d=v,y=f+1;y<=2*f;y++)d*=y;var x=d*(2*f+1);return 8*Math.pow(c/Math.pow(2,m),2*f)*v*v/(d*x)}}),Mp="sqrtm",H3=["typed","abs","add","multiply","map","sqrt","subtract","inv","size","max","identity"],W3=L(Mp,H3,r=>{var{typed:e,abs:t,add:n,multiply:a,map:i,sqrt:o,subtract:l,inv:u,size:s,max:c,identity:f}=r,m=1e3,v=1e-6;function p(d){var y,x=0,D=d,h=f(s(d));do{var w=D;if(D=a(.5,n(w,u(h))),h=a(.5,n(h,u(w))),y=c(t(l(D,w))),y>v&&++x>m)throw new Error("computing square root of matrix: iterative method could not converge")}while(y>v);return D}return e(Mp,{"Array | Matrix":function(y){var x=Je(y)?y.size():rr(y);switch(x.length){case 1:if(x[0]===1)return i(y,o);throw new RangeError("Matrix must be square (size: "+lr(x)+")");case 2:{var D=x[0],h=x[1];if(D===h)return p(y);throw new RangeError("Matrix must be square (size: "+lr(x)+")")}default:throw new RangeError("Matrix must be at most two dimensional (size: "+lr(x)+")")}}})}),_p="sylvester",Y3=["typed","schur","matrixFromColumns","matrix","multiply","range","concat","transpose","index","subset","add","subtract","identity","lusolve","abs"],Z3=L(_p,Y3,r=>{var{typed:e,schur:t,matrixFromColumns:n,matrix:a,multiply:i,range:o,concat:l,transpose:u,index:s,subset:c,add:f,subtract:m,identity:v,lusolve:p,abs:d,config:y}=r;return e(_p,{"Matrix, Matrix, Matrix":x,"Array, Matrix, Matrix":function(h,w,g){return x(a(h),w,g)},"Array, Array, Matrix":function(h,w,g){return x(a(h),a(w),g)},"Array, Matrix, Array":function(h,w,g){return x(a(h),w,a(g))},"Matrix, Array, Matrix":function(h,w,g){return x(h,a(w),g)},"Matrix, Array, Array":function(h,w,g){return x(h,a(w),a(g))},"Matrix, Matrix, Array":function(h,w,g){return x(h,w,a(g))},"Array, Array, Array":function(h,w,g){return x(a(h),a(w),a(g)).toArray()}});function x(D,h,w){for(var g=h.size()[0],b=D.size()[0],A=t(D),N=A.T,E=A.U,S=t(i(-1,h)),C=S.T,M=S.U,O=i(i(u(E),w),M),I=o(0,b),k=[],_=(pe,ve)=>l(pe,ve,1),P=(pe,ve)=>l(pe,ve,0),V=0;V<g;V++)if(V<g-1&&d(c(C,s(V+1,V)))>1e-5){for(var q=P(c(O,s(I,[V])),c(O,s(I,[V+1]))),J=0;J<V;J++)q=f(q,P(i(k[J],c(C,s(J,V))),i(k[J],c(C,s(J,V+1)))));var ne=i(v(b),i(-1,c(C,s(V,V)))),j=i(v(b),i(-1,c(C,s(V+1,V)))),F=i(v(b),i(-1,c(C,s(V,V+1)))),U=i(v(b),i(-1,c(C,s(V+1,V+1)))),$=P(_(f(N,ne),j),_(F,f(N,U))),le=p($,q);k[V]=le.subset(s(o(0,b),[0])),k[V+1]=le.subset(s(o(b,2*b),[0])),V++}else{for(var me=c(O,s(I,[V])),Y=0;Y<V;Y++)me=f(me,i(k[Y],c(C,s(Y,V))));var z=c(C,s(V,V)),X=m(N,i(z,v(b)));k[V]=p(X,me)}var se=a(n(...k)),re=i(E,i(se,u(M)));return re}}),Tp="schur",J3=["typed","matrix","identity","multiply","qr","norm","subtract"],j3=L(Tp,J3,r=>{var{typed:e,matrix:t,identity:n,multiply:a,qr:i,norm:o,subtract:l}=r;return e(Tp,{Array:function(c){var f=u(t(c));return{U:f.U.valueOf(),T:f.T.valueOf()}},Matrix:function(c){return u(c)}});function u(s){var c=s.size()[0],f=s,m=n(c),v=0,p;do{p=f;var d=i(f),y=d.Q,x=d.R;if(f=a(x,y),m=a(m,y),v++>100)break}while(o(l(f,p))>1e-4);return{U:m,T:f}}}),Fp="lyap",X3=["typed","matrix","sylvester","multiply","transpose"],Q3=L(Fp,X3,r=>{var{typed:e,matrix:t,sylvester:n,multiply:a,transpose:i}=r;return e(Fp,{"Matrix, Matrix":function(l,u){return n(l,i(l),a(-1,u))},"Array, Matrix":function(l,u){return n(t(l),i(t(l)),a(-1,u))},"Matrix, Array":function(l,u){return n(l,i(t(l)),t(a(-1,u)))},"Array, Array":function(l,u){return n(t(l),i(t(l)),t(a(-1,u))).toArray()}})}),K3="divide",eO=["typed","matrix","multiply","equalScalar","divideScalar","inv"],rO=L(K3,eO,r=>{var{typed:e,matrix:t,multiply:n,equalScalar:a,divideScalar:i,inv:o}=r,l=tt({typed:e,equalScalar:a}),u=Ut({typed:e});return e("divide",Qu({"Array | Matrix, Array | Matrix":function(c,f){return n(c,o(f))},"DenseMatrix, any":function(c,f){return u(c,f,i,!1)},"SparseMatrix, any":function(c,f){return l(c,f,i,!1)},"Array, any":function(c,f){return u(t(c),f,i,!1).valueOf()},"any, Array | Matrix":function(c,f){return n(c,o(f))}},i.signatures))}),Op="distance",tO=["typed","addScalar","subtractScalar","divideScalar","multiplyScalar","deepEqual","sqrt","abs"],nO=L(Op,tO,r=>{var{typed:e,addScalar:t,subtractScalar:n,multiplyScalar:a,divideScalar:i,deepEqual:o,sqrt:l,abs:u}=r;return e(Op,{"Array, Array, Array":function(g,b,A){if(g.length===2&&b.length===2&&A.length===2){if(!c(g))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!c(b))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!c(A))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(o(b,A))throw new TypeError("LinePoint1 should not be same with LinePoint2");var N=n(A[1],b[1]),E=n(b[0],A[0]),S=n(a(A[0],b[1]),a(b[0],A[1]));return y(g[0],g[1],N,E,S)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(g,b,A){if(Object.keys(g).length===2&&Object.keys(b).length===2&&Object.keys(A).length===2){if(!c(g))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!c(b))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!c(A))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if(o(p(b),p(A)))throw new TypeError("LinePoint1 should not be same with LinePoint2");if("pointX"in g&&"pointY"in g&&"lineOnePtX"in b&&"lineOnePtY"in b&&"lineTwoPtX"in A&&"lineTwoPtY"in A){var N=n(A.lineTwoPtY,b.lineOnePtY),E=n(b.lineOnePtX,A.lineTwoPtX),S=n(a(A.lineTwoPtX,b.lineOnePtY),a(b.lineOnePtX,A.lineTwoPtY));return y(g.pointX,g.pointY,N,E,S)}else throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(g,b){if(g.length===2&&b.length===3){if(!c(g))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!f(b))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return y(g[0],g[1],b[0],b[1],b[2])}else if(g.length===3&&b.length===6){if(!f(g))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!v(b))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return x(g[0],g[1],g[2],b[0],b[1],b[2],b[3],b[4],b[5])}else if(g.length===b.length&&g.length>0){if(!m(g))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!m(b))throw new TypeError("All values of an array should be numbers or BigNumbers");return D(g,b)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(g,b){if(Object.keys(g).length===2&&Object.keys(b).length===3){if(!c(g))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!f(b))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in g&&"pointY"in g&&"xCoeffLine"in b&&"yCoeffLine"in b&&"constant"in b)return y(g.pointX,g.pointY,b.xCoeffLine,b.yCoeffLine,b.constant);throw new TypeError("Key names do not match")}else if(Object.keys(g).length===3&&Object.keys(b).length===6){if(!f(g))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!v(b))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in g&&"pointY"in g&&"x0"in b&&"y0"in b&&"z0"in b&&"a"in b&&"b"in b&&"c"in b)return x(g.pointX,g.pointY,g.pointZ,b.x0,b.y0,b.z0,b.a,b.b,b.c);throw new TypeError("Key names do not match")}else if(Object.keys(g).length===2&&Object.keys(b).length===2){if(!c(g))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!c(b))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in g&&"pointOneY"in g&&"pointTwoX"in b&&"pointTwoY"in b)return D([g.pointOneX,g.pointOneY],[b.pointTwoX,b.pointTwoY]);throw new TypeError("Key names do not match")}else if(Object.keys(g).length===3&&Object.keys(b).length===3){if(!f(g))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!f(b))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in g&&"pointOneY"in g&&"pointOneZ"in g&&"pointTwoX"in b&&"pointTwoY"in b&&"pointTwoZ"in b)return D([g.pointOneX,g.pointOneY,g.pointOneZ],[b.pointTwoX,b.pointTwoY,b.pointTwoZ]);throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},Array:function(g){if(!d(g))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return h(g)}});function s(w){return typeof w=="number"||or(w)}function c(w){return w.constructor!==Array&&(w=p(w)),s(w[0])&&s(w[1])}function f(w){return w.constructor!==Array&&(w=p(w)),s(w[0])&&s(w[1])&&s(w[2])}function m(w){return Array.isArray(w)||(w=p(w)),w.every(s)}function v(w){return w.constructor!==Array&&(w=p(w)),s(w[0])&&s(w[1])&&s(w[2])&&s(w[3])&&s(w[4])&&s(w[5])}function p(w){for(var g=Object.keys(w),b=[],A=0;A<g.length;A++)b.push(w[g[A]]);return b}function d(w){if(w[0].length===2&&s(w[0][0])&&s(w[0][1])){if(w.some(g=>g.length!==2||!s(g[0])||!s(g[1])))return!1}else if(w[0].length===3&&s(w[0][0])&&s(w[0][1])&&s(w[0][2])){if(w.some(g=>g.length!==3||!s(g[0])||!s(g[1])||!s(g[2])))return!1}else return!1;return!0}function y(w,g,b,A,N){var E=u(t(t(a(b,w),a(A,g)),N)),S=l(t(a(b,b),a(A,A)));return i(E,S)}function x(w,g,b,A,N,E,S,C,M){var O=[n(a(n(N,g),M),a(n(E,b),C)),n(a(n(E,b),S),a(n(A,w),M)),n(a(n(A,w),C),a(n(N,g),S))];O=l(t(t(a(O[0],O[0]),a(O[1],O[1])),a(O[2],O[2])));var I=l(t(t(a(S,S),a(C,C)),a(M,M)));return i(O,I)}function D(w,g){for(var b=w.length,A=0,N=0,E=0;E<b;E++)N=n(w[E],g[E]),A=t(a(N,N),A);return l(A)}function h(w){for(var g=[],b=[],A=[],N=0;N<w.length-1;N++)for(var E=N+1;E<w.length;E++)w[0].length===2?(b=[w[N][0],w[N][1]],A=[w[E][0],w[E][1]]):w[0].length===3&&(b=[w[N][0],w[N][1],w[N][2]],A=[w[E][0],w[E][1],w[E][2]]),g.push(D(b,A));return g}}),aO="intersect",iO=["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],oO=L(aO,iO,r=>{var{typed:e,config:t,abs:n,add:a,addScalar:i,matrix:o,multiply:l,multiplyScalar:u,divideScalar:s,subtract:c,smaller:f,equalScalar:m,flatten:v,isZero:p,isNumeric:d}=r;return e("intersect",{"Array, Array, Array":y,"Array, Array, Array, Array":x,"Matrix, Matrix, Matrix":function(C,M,O){var I=y(C.valueOf(),M.valueOf(),O.valueOf());return I===null?null:o(I)},"Matrix, Matrix, Matrix, Matrix":function(C,M,O,I){var k=x(C.valueOf(),M.valueOf(),O.valueOf(),I.valueOf());return k===null?null:o(k)}});function y(S,C,M){if(S=D(S),C=D(C),M=D(M),!w(S))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!w(C))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!g(M))throw new TypeError("Array with 4 numbers expected as third argument");return E(S[0],S[1],S[2],C[0],C[1],C[2],M[0],M[1],M[2],M[3])}function x(S,C,M,O){if(S=D(S),C=D(C),M=D(M),O=D(O),S.length===2){if(!h(S))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!h(C))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!h(M))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!h(O))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return b(S,C,M,O)}else if(S.length===3){if(!w(S))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!w(C))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!w(M))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!w(O))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return N(S[0],S[1],S[2],C[0],C[1],C[2],M[0],M[1],M[2],O[0],O[1],O[2])}else throw new TypeError("Arrays with two or thee dimensional points expected")}function D(S){return S.length===1?S[0]:S.length>1&&Array.isArray(S[0])&&S.every(C=>Array.isArray(C)&&C.length===1)?v(S):S}function h(S){return S.length===2&&d(S[0])&&d(S[1])}function w(S){return S.length===3&&d(S[0])&&d(S[1])&&d(S[2])}function g(S){return S.length===4&&d(S[0])&&d(S[1])&&d(S[2])&&d(S[3])}function b(S,C,M,O){var I=S,k=M,_=c(I,C),P=c(k,O),V=c(u(_[0],P[1]),u(P[0],_[1]));if(p(V)||f(n(V),t.relTol))return null;var q=u(P[0],I[1]),J=u(P[1],I[0]),ne=u(P[0],k[1]),j=u(P[1],k[0]),F=s(i(c(c(q,J),ne),j),V);return a(l(_,F),I)}function A(S,C,M,O,I,k,_,P,V,q,J,ne){var j=u(c(S,C),c(M,O)),F=u(c(I,k),c(_,P)),U=u(c(V,q),c(J,ne));return i(i(j,F),U)}function N(S,C,M,O,I,k,_,P,V,q,J,ne){var j=A(S,_,q,_,C,P,J,P,M,V,ne,V),F=A(q,_,O,S,J,P,I,C,ne,V,k,M),U=A(S,_,O,S,C,P,I,C,M,V,k,M),$=A(q,_,q,_,J,P,J,P,ne,V,ne,V),le=A(O,S,O,S,I,C,I,C,k,M,k,M),me=c(u(j,F),u(U,$)),Y=c(u(le,$),u(F,F));if(p(Y))return null;var z=s(me,Y),X=s(i(j,u(z,F)),$),se=i(S,u(z,c(O,S))),re=i(C,u(z,c(I,C))),pe=i(M,u(z,c(k,M))),ve=i(_,u(X,c(q,_))),De=i(P,u(X,c(J,P))),Oe=i(V,u(X,c(ne,V)));return m(se,ve)&&m(re,De)&&m(pe,Oe)?[se,re,pe]:null}function E(S,C,M,O,I,k,_,P,V,q){var J=u(S,_),ne=u(O,_),j=u(C,P),F=u(I,P),U=u(M,V),$=u(k,V),le=c(c(c(q,J),j),U),me=c(c(c(i(i(ne,F),$),J),j),U),Y=s(le,me),z=i(S,u(Y,c(O,S))),X=i(C,u(Y,c(I,C))),se=i(M,u(Y,c(k,M)));return[z,X,se]}}),Bp="sum",sO=["typed","config","add","numeric"],Rp=L(Bp,sO,r=>{var{typed:e,config:t,add:n,numeric:a}=r;return e(Bp,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":o,"...":function(u){if(Sa(u))throw new TypeError("Scalar values expected in function sum");return i(u)}});function i(l){var u;return Rn(l,function(s){try{u=u===void 0?s:n(u,s)}catch(c){throw dt(c,"sum",s)}}),u===void 0&&(u=a(0,t.number)),typeof u=="string"&&(u=a(u,An(u,t))),u}function o(l,u){try{var s=Qi(l,u,n);return s}catch(c){throw dt(c,"sum")}}}),Oo="cumsum",uO=["typed","add","unaryPlus"],Ip=L(Oo,uO,r=>{var{typed:e,add:t,unaryPlus:n}=r;return e(Oo,{Array:a,Matrix:function(s){return s.create(a(s.valueOf(),s.datatype()))},"Array, number | BigNumber":o,"Matrix, number | BigNumber":function(s,c){return s.create(o(s.valueOf(),c),s.datatype())},"...":function(s){if(Sa(s))throw new TypeError("All values expected to be scalar in function cumsum");return a(s)}});function a(u){try{return i(u)}catch(s){throw dt(s,Oo)}}function i(u){if(u.length===0)return[];for(var s=[n(u[0])],c=1;c<u.length;++c)s.push(t(s[c-1],u[c]));return s}function o(u,s){var c=rr(u);if(s<0||s>=c.length)throw new Yt(s,c.length);try{return l(u,s)}catch(f){throw dt(f,Oo)}}function l(u,s){var c,f,m;if(s<=0){var v=u[0][0];if(Array.isArray(v)){for(m=Vl(u),f=[],c=0;c<m.length;c++)f[c]=l(m[c],s-1);return f}else return i(u)}else{for(f=[],c=0;c<u.length;c++)f[c]=l(u[c],s-1);return f}}}),Pp="mean",lO=["typed","add","divide"],$p=L(Pp,lO,r=>{var{typed:e,add:t,divide:n}=r;return e(Pp,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":a,"...":function(l){if(Sa(l))throw new TypeError("Scalar values expected in function mean");return i(l)}});function a(o,l){try{var u=Qi(o,l,t),s=Array.isArray(o)?rr(o):o.size();return n(u,s[l])}catch(c){throw dt(c,"mean")}}function i(o){var l,u=0;if(Rn(o,function(s){try{l=l===void 0?s:t(l,s),u++}catch(c){throw dt(c,"mean",s)}}),u===0)throw new Error("Cannot calculate the mean of an empty array");return n(l,u)}}),qp="median",cO=["typed","add","divide","compare","partitionSelect"],fO=L(qp,cO,r=>{var{typed:e,add:t,divide:n,compare:a,partitionSelect:i}=r;function o(s){try{s=yr(s.valueOf());var c=s.length;if(c===0)throw new Error("Cannot calculate median of an empty array");if(c%2===0){for(var f=c/2-1,m=i(s,f+1),v=s[f],p=0;p<f;++p)a(s[p],v)>0&&(v=s[p]);return u(v,m)}else{var d=i(s,(c-1)/2);return l(d)}}catch(y){throw dt(y,"median")}}var l=e({"number | BigNumber | Complex | Unit":function(c){return c}}),u=e({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(c,f){return n(t(c,f),2)}});return e(qp,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(c,f){throw new Error("median(A, dim) is not yet supported")},"...":function(c){if(Sa(c))throw new TypeError("Scalar values expected in function median");return o(c)}})}),zp="mad",mO=["typed","abs","map","median","subtract"],vO=L(zp,mO,r=>{var{typed:e,abs:t,map:n,median:a,subtract:i}=r;return e(zp,{"Array | Matrix":o,"...":function(u){return o(u)}});function o(l){if(l=yr(l.valueOf()),l.length===0)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var u=a(l);return a(n(l,function(s){return t(i(s,u))}))}catch(s){throw s instanceof TypeError&&s.message.includes("median")?new TypeError(s.message.replace("median","mad")):dt(s,"mad")}}}),Ls="unbiased",Up="variance",pO=["typed","add","subtract","multiply","divide","mapSlices","isNaN"],Lp=L(Up,pO,r=>{var{typed:e,add:t,subtract:n,multiply:a,divide:i,mapSlices:o,isNaN:l}=r;return e(Up,{"Array | Matrix":function(f){return u(f,Ls)},"Array | Matrix, string":u,"Array | Matrix, number | BigNumber":function(f,m){return s(f,m,Ls)},"Array | Matrix, number | BigNumber, string":s,"...":function(f){return u(f,Ls)}});function u(c,f){var m,v=0;if(c.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Rn(c,function(y){try{m=m===void 0?y:t(m,y),v++}catch(x){throw dt(x,"variance",y)}}),v===0)throw new Error("Cannot calculate variance of an empty array");var p=i(m,v);if(m=void 0,Rn(c,function(y){var x=n(y,p);m=m===void 0?a(x,x):t(m,a(x,x))}),l(m))return m;switch(f){case"uncorrected":return i(m,v);case"biased":return i(m,v+1);case"unbiased":{var d=or(m)?m.mul(0):0;return v===1?d:i(m,v-1)}default:throw new Error('Unknown normalization "'+f+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function s(c,f,m){try{if(c.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return o(c,f,v=>u(v,m))}catch(v){throw dt(v,"variance")}}}),kp="quantileSeq",dO=["typed","?bignumber","add","subtract","divide","multiply","partitionSelect","compare","isInteger","smaller","smallerEq","larger","mapSlices"],Vp=L(kp,dO,r=>{var{typed:e,bignumber:t,add:n,subtract:a,divide:i,multiply:o,partitionSelect:l,compare:u,isInteger:s,smaller:c,smallerEq:f,larger:m,mapSlices:v}=r;return e(kp,{"Array | Matrix, number | BigNumber":(D,h)=>d(D,h,!1),"Array | Matrix, number | BigNumber, number":(D,h,w)=>p(D,h,!1,w,d),"Array | Matrix, number | BigNumber, boolean":d,"Array | Matrix, number | BigNumber, boolean, number":(D,h,w,g)=>p(D,h,w,g,d),"Array | Matrix, Array | Matrix":(D,h)=>y(D,h,!1),"Array | Matrix, Array | Matrix, number":(D,h,w)=>p(D,h,!1,w,y),"Array | Matrix, Array | Matrix, boolean":y,"Array | Matrix, Array | Matrix, boolean, number":(D,h,w,g)=>p(D,h,w,g,y)});function p(D,h,w,g,b){return v(D,g,A=>b(A,h,w))}function d(D,h,w){var g,b=D.valueOf();if(c(h,0))throw new Error("N/prob must be non-negative");if(f(h,1))return Ye(h)?x(b,h,w):t(x(b,h,w));if(m(h,1)){if(!s(h))throw new Error("N must be a positive integer");if(m(h,4294967295))throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var A=n(h,1);g=[];for(var N=0;c(N,h);N++){var E=i(N+1,A);g.push(x(b,E,w))}return Ye(h)?g:t(g)}}function y(D,h,w){for(var g=D.valueOf(),b=h.valueOf(),A=[],N=0;N<b.length;++N)A.push(x(g,b[N],w));return A}function x(D,h,w){var g=yr(D),b=g.length;if(b===0)throw new Error("Cannot calculate quantile of an empty sequence");var A=Ye(h)?h*(b-1):h.times(b-1),N=Ye(h)?Math.floor(A):A.floor().toNumber(),E=Ye(h)?A%1:A.minus(N);if(s(A))return w?g[A]:l(g,Ye(h)?A:A.valueOf());var S,C;if(w)S=g[N],C=g[N+1];else{C=l(g,N+1),S=g[N];for(var M=0;M<N;++M)u(g[M],S)>0&&(S=g[M])}return n(o(S,a(1,E)),o(C,E))}}),Gp="std",hO=["typed","map","sqrt","variance"],Hp=L(Gp,hO,r=>{var{typed:e,map:t,sqrt:n,variance:a}=r;return e(Gp,{"Array | Matrix":i,"Array | Matrix, string":i,"Array | Matrix, number | BigNumber":i,"Array | Matrix, number | BigNumber, string":i,"...":function(l){return i(l)}});function i(o,l){if(o.length===0)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{var u=a.apply(null,arguments);return Ct(u)?t(u,n):n(u)}catch(s){throw s instanceof TypeError&&s.message.includes(" variance")?new TypeError(s.message.replace(" variance"," std")):s}}}),Wp="corr",gO=["typed","matrix","mean","sqrt","sum","add","subtract","multiply","pow","divide"],yO=L(Wp,gO,r=>{var{typed:e,matrix:t,sqrt:n,sum:a,add:i,subtract:o,multiply:l,pow:u,divide:s}=r;return e(Wp,{"Array, Array":function(v,p){return c(v,p)},"Matrix, Matrix":function(v,p){var d=c(v.toArray(),p.toArray());return Array.isArray(d)?t(d):d}});function c(m,v){var p=[];if(Array.isArray(m[0])&&Array.isArray(v[0])){if(m.length!==v.length)throw new SyntaxError("Dimension mismatch. Array A and B must have the same length.");for(var d=0;d<m.length;d++){if(m[d].length!==v[d].length)throw new SyntaxError("Dimension mismatch. Array A and B must have the same number of elements.");p.push(f(m[d],v[d]))}return p}else{if(m.length!==v.length)throw new SyntaxError("Dimension mismatch. Array A and B must have the same number of elements.");return f(m,v)}}function f(m,v){var p=m.length,d=a(m),y=a(v),x=m.reduce((b,A,N)=>i(b,l(A,v[N])),0),D=a(m.map(b=>u(b,2))),h=a(v.map(b=>u(b,2))),w=o(l(p,x),l(d,y)),g=n(l(o(l(p,D),u(d,2)),o(l(p,h),u(y,2))));return s(w,g)}}),Yp="bernoulli",bO=["typed","config","isInteger","number","?BigNumber","?Fraction"],xO=L(Yp,bO,r=>{var{typed:e,config:t,number:n,BigNumber:a,Fraction:i}=r,o=[void 0],l=[void 0],u=[void 0],s=50;return e(Yp,{number:c=>ks(c,f=>f,o,(f,m)=>f+m,(f,m)=>f*m,(f,m)=>f/m),"bigint | Fraction":c=>ks(n(c),f=>new i(f),l,(f,m)=>f.add(m),(f,m)=>f.mul(m),(f,m)=>f.div(m)),BigNumber:c=>(t.precision!==s&&(u=[void 0],s=t.precision),ks(n(c),f=>new a(f),u,(f,m)=>f.add(m),(f,m)=>f.mul(m),(f,m)=>f.div(m)))})});function ks(r,e,t,n,a,i){if(r<0||!Ue(r))throw new RangeError("Bernoulli index must be nonnegative integer");if(r===0)return e(1);if(r===1)return i(e(-1),e(2));if(r%2===1)return e(0);var o=e(1);t.length===1&&t.push([i(o,e(-3)),i(o,e(-2)),i(o,e(6))]);for(var l=r/2,u=e(0),s=e(2);t.length<=l;){for(var c=t.length,f=Math.floor((c+1)/2),m=u,v=1;v<f;++v)m=n(m,a(t[v][0],t[c-v][0]));m=a(m,s),c%2===0&&(m=n(m,a(t[f][0],t[f][0]))),m=i(m,e(-(2*c+1)));var p=i(a(t[c-1][1],e(-c*(2*c-1))),s);t.push([m,p,a(p,m)])}return t[l][2]}var Zp="combinations",wO=["typed"],DO=L(Zp,wO,r=>{var{typed:e}=r;return e(Zp,{"number, number":pc,"BigNumber, BigNumber":function(n,a){var i=n.constructor,o,l,u=n.minus(a),s=new i(1);if(!Jp(n)||!Jp(a))throw new TypeError("Positive integer value expected in function combinations");if(a.gt(n))throw new TypeError("k must be less than n in function combinations");if(o=s,a.lt(u))for(l=s;l.lte(u);l=l.plus(s))o=o.times(a.plus(l)).dividedBy(l);else for(l=s;l.lte(a);l=l.plus(s))o=o.times(u.plus(l)).dividedBy(l);return o}})});function Jp(r){return r.isInteger()&&r.gte(0)}var jp="combinationsWithRep",NO=["typed"],EO=L(jp,NO,r=>{var{typed:e}=r;return e(jp,{"number, number":function(n,a){if(!Ue(n)||n<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!Ue(a)||a<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(n<1)throw new TypeError("k must be less than or equal to n + k - 1");if(a<n-1){var i=dn(n,n+a-1);return i/dn(1,a)}var o=dn(a+1,n+a-1);return o/dn(1,n-1)},"BigNumber, BigNumber":function(n,a){var i=n.constructor,o,l,u=new i(1),s=n.minus(u);if(!Xp(n)||!Xp(a))throw new TypeError("Positive integer value expected in function combinationsWithRep");if(n.lt(u))throw new TypeError("k must be less than or equal to n + k - 1 in function combinationsWithRep");if(o=u,a.lt(s))for(l=u;l.lte(s);l=l.plus(u))o=o.times(a.plus(l)).dividedBy(l);else for(l=u;l.lte(a);l=l.plus(u))o=o.times(s.plus(l)).dividedBy(l);return o}})});function Xp(r){return r.isInteger()&&r.gte(0)}var Qp="gamma",AO=["typed","config","multiplyScalar","pow","BigNumber","Complex"],SO=L(Qp,AO,r=>{var{typed:e,config:t,multiplyScalar:n,pow:a,BigNumber:i,Complex:o}=r;function l(s){if(s.im===0)return ro(s.re);if(s.re<.5){var c=new o(1-s.re,-s.im),f=new o(Math.PI*s.re,Math.PI*s.im);return new o(Math.PI).div(f.sin()).div(l(c))}s=new o(s.re-1,s.im);for(var m=new o(_a[0],0),v=1;v<_a.length;++v){var p=new o(_a[v],0);m=m.add(p.div(s.add(v)))}var d=new o(s.re+hc+.5,s.im),y=Math.sqrt(2*Math.PI),x=d.pow(s.add(.5)),D=d.neg().exp();return m.mul(y).mul(x).mul(D)}return e(Qp,{number:ro,Complex:l,BigNumber:function(c){if(c.isInteger())return c.isNegative()||c.isZero()?new i(1/0):u(c.minus(1));if(!c.isFinite())return new i(c.isNegative()?NaN:1/0);throw new Error("Integer BigNumber expected")}});function u(s){if(s<8)return new i([1,1,2,6,24,120,720,5040][s]);var c=t.precision+(Math.log(s.toNumber())|0),f=i.clone({precision:c});if(s%2===1)return s.times(u(new i(s-1)));for(var m=s,v=new f(s),p=s.toNumber();m>2;)m-=2,p+=m,v=v.times(p);return new i(v.toPrecision(i.precision))}}),Kp="lgamma",CO=["Complex","typed"],MO=L(Kp,CO,r=>{var{Complex:e,typed:t}=r,n=7,a=7,i=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return t(Kp,{number:to,Complex:o,BigNumber:function(){throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function o(s){var c=6.283185307179586,f=1.1447298858494002,m=.1;if(s.isNaN())return new e(NaN,NaN);if(s.im===0)return new e(to(s.re),0);if(s.re>=n||Math.abs(s.im)>=a)return l(s);if(s.re<=m){var v=j0(c,s.im)*Math.floor(.5*s.re+.25),p=s.mul(Math.PI).sin().log(),d=o(new e(1-s.re,-s.im));return new e(f,v).sub(p).sub(d)}else return s.im>=0?u(s):u(s.conjugate()).conjugate()}function l(s){for(var c=s.sub(.5).mul(s.log()).sub(s).add(gc),f=new e(1,0).div(s),m=f.div(s),v=i[0],p=i[1],d=2*m.re,y=m.re*m.re+m.im*m.im,x=2;x<8;x++){var D=p;p=-y*v+i[x],v=d*v+D}var h=f.mul(m.mul(v).add(p));return c.add(h)}function u(s){var c=0,f=0,m=s;for(s=s.add(1);s.re<=n;){m=m.mul(s);var v=m.im<0?1:0;v!==0&&f===0&&c++,f=v,s=s.add(1)}return l(s).sub(m.log()).sub(new e(0,c*2*Math.PI*1))}}),ed="factorial",_O=["typed","gamma"],TO=L(ed,_O,r=>{var{typed:e,gamma:t}=r;return e(ed,{number:function(a){if(a<0)throw new Error("Value must be non-negative");return t(a+1)},BigNumber:function(a){if(a.isNegative())throw new Error("Value must be non-negative");return t(a.plus(1))},"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),rd="kldivergence",FO=["typed","matrix","divide","sum","multiply","map","dotDivide","log","isNumeric"],OO=L(rd,FO,r=>{var{typed:e,matrix:t,divide:n,sum:a,multiply:i,map:o,dotDivide:l,log:u,isNumeric:s}=r;return e(rd,{"Array, Array":function(m,v){return c(t(m),t(v))},"Matrix, Array":function(m,v){return c(m,t(v))},"Array, Matrix":function(m,v){return c(t(m),v)},"Matrix, Matrix":function(m,v){return c(m,v)}});function c(f,m){var v=m.size().length,p=f.size().length;if(v>1)throw new Error("first object must be one dimensional");if(p>1)throw new Error("second object must be one dimensional");if(v!==p)throw new Error("Length of two vectors must be equal");var d=a(f);if(d===0)throw new Error("Sum of elements in first object must be non zero");var y=a(m);if(y===0)throw new Error("Sum of elements in second object must be non zero");var x=n(f,a(f)),D=n(m,a(m)),h=a(i(x,o(l(x,D),w=>u(w))));return s(h)?h:Number.NaN}}),td="multinomial",BO=["typed","add","divide","multiply","factorial","isInteger","isPositive"],RO=L(td,BO,r=>{var{typed:e,add:t,divide:n,multiply:a,factorial:i,isInteger:o,isPositive:l}=r;return e(td,{"Array | Matrix":function(s){var c=0,f=1;return Rn(s,function(m){if(!o(m)||!l(m))throw new TypeError("Positive integer value expected in function multinomial");c=t(c,m),f=a(f,i(m))}),n(i(c),f)}})}),nd="permutations",IO=["typed","factorial"],PO=L(nd,IO,r=>{var{typed:e,factorial:t}=r;return e(nd,{"number | BigNumber":t,"number, number":function(a,i){if(!Ue(a)||a<0)throw new TypeError("Positive integer value expected in function permutations");if(!Ue(i)||i<0)throw new TypeError("Positive integer value expected in function permutations");if(i>a)throw new TypeError("second argument k must be less than or equal to first argument n");return dn(a-i+1,a)},"BigNumber, BigNumber":function(a,i){var o,l;if(!ad(a)||!ad(i))throw new TypeError("Positive integer value expected in function permutations");if(i.gt(a))throw new TypeError("second argument k must be less than or equal to first argument n");var u=a.mul(0).add(1);for(o=u,l=a.minus(i).plus(1);l.lte(a);l=l.plus(1))o=o.times(l);return o}})});function ad(r){return r.isInteger()&&r.gte(0)}var Vs={exports:{}};Vs.exports,function(r){(function(e,t,n){function a(u){var s=this,c=l();s.next=function(){var f=2091639*s.s0+s.c*23283064365386963e-26;return s.s0=s.s1,s.s1=s.s2,s.s2=f-(s.c=f|0)},s.c=1,s.s0=c(" "),s.s1=c(" "),s.s2=c(" "),s.s0-=c(u),s.s0<0&&(s.s0+=1),s.s1-=c(u),s.s1<0&&(s.s1+=1),s.s2-=c(u),s.s2<0&&(s.s2+=1),c=null}function i(u,s){return s.c=u.c,s.s0=u.s0,s.s1=u.s1,s.s2=u.s2,s}function o(u,s){var c=new a(u),f=s&&s.state,m=c.next;return m.int32=function(){return c.next()*4294967296|0},m.double=function(){return m()+(m()*2097152|0)*11102230246251565e-32},m.quick=m,f&&(typeof f=="object"&&i(f,c),m.state=function(){return i(c,{})}),m}function l(){var u=4022871197,s=function(c){c=String(c);for(var f=0;f<c.length;f++){u+=c.charCodeAt(f);var m=.02519603282416938*u;u=m>>>0,m-=u,m*=u,u=m>>>0,m-=u,u+=m*4294967296}return(u>>>0)*23283064365386963e-26};return s}t&&t.exports?t.exports=o:this.alea=o})(ra,r)}(Vs);var $O=Vs.exports,Gs={exports:{}};Gs.exports,function(r){(function(e,t,n){function a(l){var u=this,s="";u.x=0,u.y=0,u.z=0,u.w=0,u.next=function(){var f=u.x^u.x<<11;return u.x=u.y,u.y=u.z,u.z=u.w,u.w^=u.w>>>19^f^f>>>8},l===(l|0)?u.x=l:s+=l;for(var c=0;c<s.length+64;c++)u.x^=s.charCodeAt(c)|0,u.next()}function i(l,u){return u.x=l.x,u.y=l.y,u.z=l.z,u.w=l.w,u}function o(l,u){var s=new a(l),c=u&&u.state,f=function(){return(s.next()>>>0)/4294967296};return f.double=function(){do var m=s.next()>>>11,v=(s.next()>>>0)/4294967296,p=(m+v)/(1<<21);while(p===0);return p},f.int32=s.next,f.quick=f,c&&(typeof c=="object"&&i(c,s),f.state=function(){return i(s,{})}),f}t&&t.exports?t.exports=o:this.xor128=o})(ra,r)}(Gs);var qO=Gs.exports,Hs={exports:{}};Hs.exports,function(r){(function(e,t,n){function a(l){var u=this,s="";u.next=function(){var f=u.x^u.x>>>2;return u.x=u.y,u.y=u.z,u.z=u.w,u.w=u.v,(u.d=u.d+362437|0)+(u.v=u.v^u.v<<4^(f^f<<1))|0},u.x=0,u.y=0,u.z=0,u.w=0,u.v=0,l===(l|0)?u.x=l:s+=l;for(var c=0;c<s.length+64;c++)u.x^=s.charCodeAt(c)|0,c==s.length&&(u.d=u.x<<10^u.x>>>4),u.next()}function i(l,u){return u.x=l.x,u.y=l.y,u.z=l.z,u.w=l.w,u.v=l.v,u.d=l.d,u}function o(l,u){var s=new a(l),c=u&&u.state,f=function(){return(s.next()>>>0)/4294967296};return f.double=function(){do var m=s.next()>>>11,v=(s.next()>>>0)/4294967296,p=(m+v)/(1<<21);while(p===0);return p},f.int32=s.next,f.quick=f,c&&(typeof c=="object"&&i(c,s),f.state=function(){return i(s,{})}),f}t&&t.exports?t.exports=o:this.xorwow=o})(ra,r)}(Hs);var zO=Hs.exports,Ws={exports:{}};Ws.exports,function(r){(function(e,t,n){function a(l){var u=this;u.next=function(){var c=u.x,f=u.i,m,v;return m=c[f],m^=m>>>7,v=m^m<<24,m=c[f+1&7],v^=m^m>>>10,m=c[f+3&7],v^=m^m>>>3,m=c[f+4&7],v^=m^m<<7,m=c[f+7&7],m=m^m<<13,v^=m^m<<9,c[f]=v,u.i=f+1&7,v};function s(c,f){var m,v=[];if(f===(f|0))v[0]=f;else for(f=""+f,m=0;m<f.length;++m)v[m&7]=v[m&7]<<15^f.charCodeAt(m)+v[m+1&7]<<13;for(;v.length<8;)v.push(0);for(m=0;m<8&&v[m]===0;++m);for(m==8?v[7]=-1:v[m],c.x=v,c.i=0,m=256;m>0;--m)c.next()}s(u,l)}function i(l,u){return u.x=l.x.slice(),u.i=l.i,u}function o(l,u){l==null&&(l=+new Date);var s=new a(l),c=u&&u.state,f=function(){return(s.next()>>>0)/4294967296};return f.double=function(){do var m=s.next()>>>11,v=(s.next()>>>0)/4294967296,p=(m+v)/(1<<21);while(p===0);return p},f.int32=s.next,f.quick=f,c&&(c.x&&i(c,s),f.state=function(){return i(s,{})}),f}t&&t.exports?t.exports=o:this.xorshift7=o})(ra,r)}(Ws);var UO=Ws.exports,Ys={exports:{}};Ys.exports,function(r){(function(e,t,n){function a(l){var u=this;u.next=function(){var c=u.w,f=u.X,m=u.i,v,p;return u.w=c=c+1640531527|0,p=f[m+34&127],v=f[m=m+1&127],p^=p<<13,v^=v<<17,p^=p>>>15,v^=v>>>12,p=f[m]=p^v,u.i=m,p+(c^c>>>16)|0};function s(c,f){var m,v,p,d,y,x=[],D=128;for(f===(f|0)?(v=f,f=null):(f=f+"\0",v=0,D=Math.max(D,f.length)),p=0,d=-32;d<D;++d)f&&(v^=f.charCodeAt((d+32)%f.length)),d===0&&(y=v),v^=v<<10,v^=v>>>15,v^=v<<4,v^=v>>>13,d>=0&&(y=y+1640531527|0,m=x[d&127]^=v+y,p=m==0?p+1:0);for(p>=128&&(x[(f&&f.length||0)&127]=-1),p=127,d=4*128;d>0;--d)v=x[p+34&127],m=x[p=p+1&127],v^=v<<13,m^=m<<17,v^=v>>>15,m^=m>>>12,x[p]=v^m;c.w=y,c.X=x,c.i=p}s(u,l)}function i(l,u){return u.i=l.i,u.w=l.w,u.X=l.X.slice(),u}function o(l,u){l==null&&(l=+new Date);var s=new a(l),c=u&&u.state,f=function(){return(s.next()>>>0)/4294967296};return f.double=function(){do var m=s.next()>>>11,v=(s.next()>>>0)/4294967296,p=(m+v)/(1<<21);while(p===0);return p},f.int32=s.next,f.quick=f,c&&(c.X&&i(c,s),f.state=function(){return i(s,{})}),f}t&&t.exports?t.exports=o:this.xor4096=o})(ra,r)}(Ys);var LO=Ys.exports,Zs={exports:{}};Zs.exports,function(r){(function(e,t,n){function a(l){var u=this,s="";u.next=function(){var f=u.b,m=u.c,v=u.d,p=u.a;return f=f<<25^f>>>7^m,m=m-v|0,v=v<<24^v>>>8^p,p=p-f|0,u.b=f=f<<20^f>>>12^m,u.c=m=m-v|0,u.d=v<<16^m>>>16^p,u.a=p-f|0},u.a=0,u.b=0,u.c=-1640531527,u.d=1367130551,l===Math.floor(l)?(u.a=l/4294967296|0,u.b=l|0):s+=l;for(var c=0;c<s.length+20;c++)u.b^=s.charCodeAt(c)|0,u.next()}function i(l,u){return u.a=l.a,u.b=l.b,u.c=l.c,u.d=l.d,u}function o(l,u){var s=new a(l),c=u&&u.state,f=function(){return(s.next()>>>0)/4294967296};return f.double=function(){do var m=s.next()>>>11,v=(s.next()>>>0)/4294967296,p=(m+v)/(1<<21);while(p===0);return p},f.int32=s.next,f.quick=f,c&&(typeof c=="object"&&i(c,s),f.state=function(){return i(s,{})}),f}t&&t.exports?t.exports=o:this.tychei=o})(ra,r)}(Zs);var kO=Zs.exports,id={exports:{}};const VO=D2(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(r){(function(e,t,n){var a=256,i=6,o=52,l="random",u=n.pow(a,i),s=n.pow(2,o),c=s*2,f=a-1,m;function v(w,g,b){var A=[];g=g==!0?{entropy:!0}:g||{};var N=x(y(g.entropy?[w,h(t)]:w??D(),3),A),E=new p(A),S=function(){for(var C=E.g(i),M=u,O=0;C<s;)C=(C+O)*a,M*=a,O=E.g(1);for(;C>=c;)C/=2,M/=2,O>>>=1;return(C+O)/M};return S.int32=function(){return E.g(4)|0},S.quick=function(){return E.g(4)/4294967296},S.double=S,x(h(E.S),t),(g.pass||b||function(C,M,O,I){return I&&(I.S&&d(I,E),C.state=function(){return d(E,{})}),O?(n[l]=C,M):C})(S,N,"global"in g?g.global:this==n,g.state)}function p(w){var g,b=w.length,A=this,N=0,E=A.i=A.j=0,S=A.S=[];for(b||(w=[b++]);N<a;)S[N]=N++;for(N=0;N<a;N++)S[N]=S[E=f&E+w[N%b]+(g=S[N])],S[E]=g;(A.g=function(C){for(var M,O=0,I=A.i,k=A.j,_=A.S;C--;)M=_[I=f&I+1],O=O*a+_[f&(_[I]=_[k=f&k+M])+(_[k]=M)];return A.i=I,A.j=k,O})(a)}function d(w,g){return g.i=w.i,g.j=w.j,g.S=w.S.slice(),g}function y(w,g){var b=[],A=typeof w,N;if(g&&A=="object")for(N in w)try{b.push(y(w[N],g-1))}catch{}return b.length?b:A=="string"?w:w+"\0"}function x(w,g){for(var b=w+"",A,N=0;N<b.length;)g[f&N]=f&(A^=g[f&N]*19)+b.charCodeAt(N++);return h(g)}function D(){try{var w;return m&&(w=m.randomBytes)?w=w(a):(w=new Uint8Array(a),(e.crypto||e.msCrypto).getRandomValues(w)),h(w)}catch{var g=e.navigator,b=g&&g.plugins;return[+new Date,e,b,e.screen,h(t)]}}function h(w){return String.fromCharCode.apply(0,w)}if(x(n.random(),t),r.exports){r.exports=v;try{m=VO}catch{}}else n["seed"+l]=v})(typeof self<"u"?self:ra,[],Math)})(id);var GO=id.exports,HO=$O,WO=qO,YO=zO,ZO=UO,JO=LO,jO=kO,ta=GO;ta.alea=HO,ta.xor128=WO,ta.xorwow=YO,ta.xorshift7=ZO,ta.xor4096=JO,ta.tychei=jO;var XO=ta;const od=Bs(XO);var QO=od(Date.now());function Ia(r){var e;function t(a){e=a===null?QO:od(String(a))}t(r);function n(){return e()}return n}var sd="pickRandom",KO=["typed","config","?on"],eB=L(sd,KO,r=>{var{typed:e,config:t,on:n}=r,a=Ia(t.randomSeed);return n&&n("config",function(o,l){o.randomSeed!==l.randomSeed&&(a=Ia(o.randomSeed))}),e(sd,{"Array | Matrix":function(l){return i(l,{})},"Array | Matrix, Object":function(l,u){return i(l,u)},"Array | Matrix, number":function(l,u){return i(l,{number:u})},"Array | Matrix, Array | Matrix":function(l,u){return i(l,{weights:u})},"Array | Matrix, Array | Matrix, number":function(l,u,s){return i(l,{number:s,weights:u})},"Array | Matrix, number, Array | Matrix":function(l,u,s){return i(l,{number:u,weights:s})}});function i(o,l){var{number:u,weights:s,elementWise:c=!0}=l,f=typeof u>"u";f&&(u=1);var m=Je(o)?o.create:Je(s)?s.create:null;o=o.valueOf(),s&&(s=s.valueOf()),c===!0&&(o=yr(o),s=yr(s));var v=0;if(typeof s<"u"){if(s.length!==o.length)throw new Error("Weights must have the same length as possibles");for(var p=0,d=s.length;p<d;p++){if(!Ye(s[p])||s[p]<0)throw new Error("Weights must be an array of positive numbers");v+=s[p]}}for(var y=o.length,x=[],D;x.length<u;){if(typeof s>"u")D=o[Math.floor(a()*y)];else for(var h=a()*v,w=0,g=o.length;w<g;w++)if(h-=s[w],h<0){D=o[w];break}x.push(D)}return f?x[0]:m?m(x):x}});function Js(r,e){var t=[];if(r=r.slice(0),r.length>1)for(var n=0,a=r.shift();n<a;n++)t.push(Js(r,e));else for(var i=0,o=r.shift();i<o;i++)t.push(e());return t}var ud="random",rB=["typed","config","?on"],tB=L(ud,rB,r=>{var{typed:e,config:t,on:n}=r,a=Ia(t.randomSeed);return n&&n("config",function(l,u){l.randomSeed!==u.randomSeed&&(a=Ia(l.randomSeed))}),e(ud,{"":()=>o(0,1),number:l=>o(0,l),"number, number":(l,u)=>o(l,u),"Array | Matrix":l=>i(l,0,1),"Array | Matrix, number":(l,u)=>i(l,0,u),"Array | Matrix, number, number":(l,u,s)=>i(l,u,s)});function i(l,u,s){var c=Js(l.valueOf(),()=>o(u,s));return Je(l)?l.create(c,"number"):c}function o(l,u){return l+a()*(u-l)}}),ld="randomInt",nB=["typed","config","log2","?on"],aB=L(ld,nB,r=>{var{typed:e,config:t,log2:n,on:a}=r,i=Ia(t.randomSeed);return a&&a("config",function(s,c){s.randomSeed!==c.randomSeed&&(i=Ia(s.randomSeed))}),e(ld,{"":()=>l(0,2),number:s=>l(0,s),"number, number":(s,c)=>l(s,c),bigint:s=>u(0n,s),"bigint, bigint":u,"Array | Matrix":s=>o(s,0,1),"Array | Matrix, number":(s,c)=>o(s,0,c),"Array | Matrix, number, number":(s,c,f)=>o(s,c,f)});function o(s,c,f){var m=Js(s.valueOf(),()=>l(c,f));return Je(s)?s.create(m,"number"):m}function l(s,c){return Math.floor(s+i()*(c-s))}function u(s,c){var f=2n**30n,m=c-s;if(m<=f)return s+BigInt(l(0,Number(m)));for(var v=n(m),p=m;p>=m;){p=0n;for(var d=0;d<v;++d)p=2n*p+(i()<.5?0n:1n)}return s+p}}),cd="stirlingS2",iB=["typed","addScalar","subtractScalar","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],oB=L(cd,iB,r=>{var{typed:e,addScalar:t,subtractScalar:n,multiplyScalar:a,divideScalar:i,pow:o,factorial:l,combinations:u,isNegative:s,isInteger:c,number:f,bignumber:m,larger:v}=r,p=[],d=[];return e(cd,{"number | BigNumber, number | BigNumber":function(x,D){if(!c(x)||s(x)||!c(D)||s(D))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(v(D,x))throw new TypeError("k must be less than or equal to n in function stirlingS2");var h=!(Ye(x)&&Ye(D)),w=h?d:p,g=h?m:f,b=f(x),A=f(D);if(w[b]&&w[b].length>A)return w[b][A];for(var N=0;N<=b;++N)if(w[N]||(w[N]=[g(N===0?1:0)]),N!==0)for(var E=w[N],S=w[N-1],C=E.length;C<=N&&C<=A;++C)C===N?E[C]=1:E[C]=t(a(g(C),S[C]),S[C-1]);return w[b][A]}})}),fd="bellNumbers",sB=["typed","addScalar","isNegative","isInteger","stirlingS2"],uB=L(fd,sB,r=>{var{typed:e,addScalar:t,isNegative:n,isInteger:a,stirlingS2:i}=r;return e(fd,{"number | BigNumber":function(l){if(!a(l)||n(l))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var u=0,s=0;s<=l;s++)u=t(u,i(l,s));return u}})}),md="catalan",lB=["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],cB=L(md,lB,r=>{var{typed:e,addScalar:t,divideScalar:n,multiplyScalar:a,combinations:i,isNegative:o,isInteger:l}=r;return e(md,{"number | BigNumber":function(s){if(!l(s)||o(s))throw new TypeError("Non-negative integer value expected in function catalan");return n(i(a(s,2),s),t(s,1))}})}),vd="composition",fB=["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],mB=L(vd,fB,r=>{var{typed:e,addScalar:t,combinations:n,isPositive:a,isNegative:i,isInteger:o,larger:l}=r;return e(vd,{"number | BigNumber, number | BigNumber":function(s,c){if(!o(s)||!a(s)||!o(c)||!a(c))throw new TypeError("Positive integer value expected in function composition");if(l(c,s))throw new TypeError("k must be less than or equal to n in function composition");return n(t(s,-1),t(c,-1))}})}),pd="leafCount",vB=["parse","typed"],pB=L(pd,vB,r=>{var{parse:e,typed:t}=r;function n(a){var i=0;return a.forEach(o=>{i+=n(o)}),i||1}return t(pd,{Node:function(i){return n(i)}})});function dd(r){return gr(r)||Ur(r)&&r.isUnary()&&gr(r.args[0])}function Bo(r){return!!(gr(r)||(En(r)||Ur(r))&&r.args.every(Bo)||fn(r)&&Bo(r.content))}function hd(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function js(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?hd(Object(t),!0).forEach(function(n){Vr(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):hd(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}var dB="simplifyUtil",hB=["FunctionNode","OperatorNode","SymbolNode"],Xs=L(dB,hB,r=>{var{FunctionNode:e,OperatorNode:t,SymbolNode:n}=r,a=!0,i=!1,o="defaultF",l={add:{trivial:a,total:a,commutative:a,associative:a},unaryPlus:{trivial:a,total:a,commutative:a,associative:a},subtract:{trivial:i,total:a,commutative:i,associative:i},multiply:{trivial:a,total:a,commutative:a,associative:a},divide:{trivial:i,total:a,commutative:i,associative:i},paren:{trivial:a,total:a,commutative:a,associative:i},defaultF:{trivial:i,total:a,commutative:i,associative:i}},u={divide:{total:i},log:{total:i}},s={subtract:{total:i},abs:{trivial:a},log:{total:a}};function c(h,w){var g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:l,b=o;if(typeof h=="string"?b=h:Ur(h)?b=h.fn.toString():En(h)?b=h.name:fn(h)&&(b="paren"),$e(g,b)){var A=g[b];if($e(A,w))return A[w];if($e(l,b))return l[b][w]}if($e(g,o)){var N=g[o];return $e(N,w)?N[w]:l[o][w]}if($e(l,b)){var E=l[b];if($e(E,w))return E[w]}return l[o][w]}function f(h){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:l;return c(h,"commutative",w)}function m(h){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:l;return c(h,"associative",w)}function v(h,w){var g=js({},h);for(var b in w)$e(h,b)?g[b]=js(js({},w[b]),h[b]):g[b]=w[b];return g}function p(h,w){if(!h.args||h.args.length===0)return h;h.args=d(h,w);for(var g=0;g<h.args.length;g++)p(h.args[g],w)}function d(h,w){var g,b=[],A=function(E){for(var S=0;S<E.args.length;S++){var C=E.args[S];Ur(C)&&g===C.op?A(C):b.push(C)}};return m(h,w)?(g=h.op,A(h),b):h.args}function y(h,w){if(!(!h.args||h.args.length===0)){for(var g=D(h),b=h.args.length,A=0;A<b;A++)y(h.args[A],w);if(b>2&&m(h,w)){for(var N=h.args.pop();h.args.length>0;)N=g([h.args.pop(),N]);h.args=N.args}}}function x(h,w){if(!(!h.args||h.args.length===0)){for(var g=D(h),b=h.args.length,A=0;A<b;A++)x(h.args[A],w);if(b>2&&m(h,w)){for(var N=h.args.shift();h.args.length>0;)N=g([N,h.args.shift()]);h.args=N.args}}}function D(h){return Ur(h)?function(w){try{return new t(h.op,h.fn,w,h.implicit)}catch(g){return console.error(g),[]}}:function(w){return new e(new n(h.name),w)}}return{createMakeNodeFunction:D,hasProperty:c,isCommutative:f,isAssociative:m,mergeContext:v,flatten:p,allChildren:d,unflattenr:y,unflattenl:x,defaultContext:l,realContext:u,positiveContext:s}}),gB="simplify",yB=["typed","parse","equal","resolve","simplifyConstant","simplifyCore","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode","replacer"],bB=L(gB,yB,r=>{var{typed:e,parse:t,equal:n,resolve:a,simplifyConstant:i,simplifyCore:o,AccessorNode:l,ArrayNode:u,ConstantNode:s,FunctionNode:c,IndexNode:f,ObjectNode:m,OperatorNode:v,ParenthesisNode:p,SymbolNode:d,replacer:y}=r,{hasProperty:x,isCommutative:D,isAssociative:h,mergeContext:w,flatten:g,unflattenr:b,unflattenl:A,createMakeNodeFunction:N,defaultContext:E,realContext:S,positiveContext:C}=Xs({FunctionNode:c,OperatorNode:v,SymbolNode:d});e.addConversion({from:"Object",to:"Map",convert:va});var M=e("simplify",{Node:q,"Node, Map":(Y,z)=>q(Y,!1,z),"Node, Map, Object":(Y,z,X)=>q(Y,!1,z,X),"Node, Array":q,"Node, Array, Map":q,"Node, Array, Map, Object":q});e.removeConversion({from:"Object",to:"Map",convert:va}),M.defaultContext=E,M.realContext=S,M.positiveContext=C;function O(Y){return Y.transform(function(z){return fn(z)?O(z.content):z})}var I={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};M.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}}},i,{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}}},i,{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"}];function k(Y,z){var X={};if(Y.s){var se=Y.s.split("->");if(se.length===2)X.l=se[0],X.r=se[1];else throw SyntaxError("Could not parse rule: "+Y.s)}else X.l=Y.l,X.r=Y.r;X.l=O(t(X.l)),X.r=O(t(X.r));for(var re of["imposeContext","repeat","assuming"])re in Y&&(X[re]=Y[re]);if(Y.evaluate&&(X.evaluate=t(Y.evaluate)),h(X.l,z)){var pe=!D(X.l,z),ve;pe&&(ve=V());var De=N(X.l),Oe=V();X.expanded={},X.expanded.l=De([X.l,Oe]),g(X.expanded.l,z),b(X.expanded.l,z),X.expanded.r=De([X.r,Oe]),pe&&(X.expandedNC1={},X.expandedNC1.l=De([ve,X.l]),X.expandedNC1.r=De([ve,X.r]),X.expandedNC2={},X.expandedNC2.l=De([ve,X.expanded.l]),X.expandedNC2.r=De([ve,X.expanded.r]))}return X}function _(Y,z){for(var X=[],se=0;se<Y.length;se++){var re=Y[se],pe=void 0,ve=typeof re;switch(ve){case"string":re={s:re};case"object":pe=k(re,z);break;case"function":pe=re;break;default:throw TypeError("Unsupported type of rule: "+ve)}X.push(pe)}return X}var P=0;function V(){return new d("_p"+P++)}function q(Y,z){var X=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Xa(),se=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},re=se.consoleDebug;z=_(z||M.rules,se.context);var pe=a(Y,X);pe=O(pe);for(var ve={},De=pe.toString({parenthesis:"all"});!ve[De];){ve[De]=!0,P=0;var Oe=De;re&&console.log("Working on: ",De);for(var Ie=0;Ie<z.length;Ie++){var _e="";if(typeof z[Ie]=="function"?(pe=z[Ie](pe,se),re&&(_e=z[Ie].name)):(g(pe,se.context),pe=ne(pe,z[Ie],se.context),re&&(_e="".concat(z[Ie].l.toString()," -> ").concat(z[Ie].r.toString()))),re){var Le=pe.toString({parenthesis:"all"});Le!==Oe&&(console.log("Applying",_e,"produced",Le),Oe=Le)}A(pe,se.context)}De=pe.toString({parenthesis:"all"})}return pe}function J(Y,z,X){var se=Y;if(Y)for(var re=0;re<Y.length;++re){var pe=ne(Y[re],z,X);pe!==Y[re]&&(se===Y&&(se=Y.slice()),se[re]=pe)}return se}function ne(Y,z,X){if(z.assuming){for(var se in z.assuming)for(var re in z.assuming[se])if(x(se,re,X)!==z.assuming[se][re])return Y}var pe=w(z.imposeContext,X),ve=Y;if(ve instanceof v||ve instanceof c){var De=J(ve.args,z,X);De!==ve.args&&(ve=ve.clone(),ve.args=De)}else if(ve instanceof p){if(ve.content){var Oe=ne(ve.content,z,X);Oe!==ve.content&&(ve=new p(Oe))}}else if(ve instanceof u){var Ie=J(ve.items,z,X);Ie!==ve.items&&(ve=new u(Ie))}else if(ve instanceof l){var _e=ve.object;ve.object&&(_e=ne(ve.object,z,X));var Le=ve.index;ve.index&&(Le=ne(ve.index,z,X)),(_e!==ve.object||Le!==ve.index)&&(ve=new l(_e,Le))}else if(ve instanceof f){var qe=J(ve.dimensions,z,X);qe!==ve.dimensions&&(ve=new f(qe))}else if(ve instanceof m){var G=!1,ee={};for(var R in ve.properties)ee[R]=ne(ve.properties[R],z,X),ee[R]!==ve.properties[R]&&(G=!0);G&&(ve=new m(ee))}var H=z.r,Q=le(z.l,ve,pe)[0];if(!Q&&z.expanded&&(H=z.expanded.r,Q=le(z.expanded.l,ve,pe)[0]),!Q&&z.expandedNC1&&(H=z.expandedNC1.r,Q=le(z.expandedNC1.l,ve,pe)[0],Q||(H=z.expandedNC2.r,Q=le(z.expandedNC2.l,ve,pe)[0])),Q){var ie=ve.implicit;ve=H.clone(),ie&&"implicit"in H&&(ve.implicit=!0),ve=ve.transform(function(ue){return ue.isSymbolNode&&$e(Q.placeholders,ue.name)?Q.placeholders[ue.name].clone():ue})}return z.repeat&&ve!==Y&&(ve=ne(ve,z,X)),ve}function j(Y,z){var X=[],se,re,pe=N(Y);if(D(Y,z))for(var ve=0;ve<Y.args.length;ve++)re=Y.args.slice(0),re.splice(ve,1),se=re.length===1?re[0]:pe(re),X.push(pe([Y.args[ve],se]));else for(var De=1;De<Y.args.length;De++){var Oe=Y.args[0];De>1&&(Oe=pe(Y.args.slice(0,De))),re=Y.args.slice(De),se=re.length===1?re[0]:pe(re),X.push(pe([Oe,se]))}return X}function F(Y,z){var X={placeholders:{}};if(!Y.placeholders&&!z.placeholders)return X;if(Y.placeholders){if(!z.placeholders)return Y}else return z;for(var se in Y.placeholders)if($e(Y.placeholders,se)&&(X.placeholders[se]=Y.placeholders[se],$e(z.placeholders,se)&&!me(Y.placeholders[se],z.placeholders[se])))return null;for(var re in z.placeholders)$e(z.placeholders,re)&&(X.placeholders[re]=z.placeholders[re]);return X}function U(Y,z){var X=[];if(Y.length===0||z.length===0)return X;for(var se,re=0;re<Y.length;re++)for(var pe=0;pe<z.length;pe++)se=F(Y[re],z[pe]),se&&X.push(se);return X}function $(Y){if(Y.length===0)return Y;for(var z=Y.reduce(U),X=[],se={},re=0;re<z.length;re++){var pe=JSON.stringify(z[re],y);se[pe]||(se[pe]=!0,X.push(z[re]))}return X}function le(Y,z,X,se){var re=[{placeholders:{}}];if(Y instanceof v&&z instanceof v||Y instanceof c&&z instanceof c){if(Y instanceof v){if(Y.op!==z.op||Y.fn!==z.fn)return[]}else if(Y instanceof c&&Y.name!==z.name)return[];if(z.args.length===1&&Y.args.length===1||!h(z,X)&&z.args.length===Y.args.length||se){for(var pe=[],ve=0;ve<Y.args.length;ve++){var De=le(Y.args[ve],z.args[ve],X);if(De.length===0)break;pe.push(De)}if(pe.length!==Y.args.length){if(!D(z,X)||Y.args.length===1)return[];if(Y.args.length>2)throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");var Oe=le(Y.args[0],z.args[1],X);if(Oe.length===0)return[];var Ie=le(Y.args[1],z.args[0],X);if(Ie.length===0)return[];pe=[Oe,Ie]}re=$(pe)}else if(z.args.length>=2&&Y.args.length===2){for(var _e=j(z,X),Le=[],qe=0;qe<_e.length;qe++){var G=le(Y,_e[qe],X,!0);Le=Le.concat(G)}return Le}else{if(Y.args.length>2)throw Error("Unexpected non-binary associative function: "+Y.toString());return[]}}else if(Y instanceof d){if(Y.name.length===0)throw new Error("Symbol in rule has 0 length...!?");if(I[Y.name]){if(Y.name!==z.name)return[]}else switch(Y.name[1]>="a"&&Y.name[1]<="z"?Y.name.substring(0,2):Y.name[0]){case"n":case"_p":re[0].placeholders[Y.name]=z;break;case"c":case"cl":if(gr(z))re[0].placeholders[Y.name]=z;else return[];break;case"v":if(!gr(z))re[0].placeholders[Y.name]=z;else return[];break;case"vl":if(Jr(z))re[0].placeholders[Y.name]=z;else return[];break;case"cd":if(dd(z))re[0].placeholders[Y.name]=z;else return[];break;case"vd":if(!dd(z))re[0].placeholders[Y.name]=z;else return[];break;case"ce":if(Bo(z))re[0].placeholders[Y.name]=z;else return[];break;case"ve":if(!Bo(z))re[0].placeholders[Y.name]=z;else return[];break;default:throw new Error("Invalid symbol in rule: "+Y.name)}}else if(Y instanceof s){if(!n(Y.value,z.value))return[]}else return[];return re}function me(Y,z){if(Y instanceof s&&z instanceof s){if(!n(Y.value,z.value))return!1}else if(Y instanceof d&&z instanceof d){if(Y.name!==z.name)return!1}else if(Y instanceof v&&z instanceof v||Y instanceof c&&z instanceof c){if(Y instanceof v){if(Y.op!==z.op||Y.fn!==z.fn)return!1}else if(Y instanceof c&&Y.name!==z.name)return!1;if(Y.args.length!==z.args.length)return!1;for(var X=0;X<Y.args.length;X++)if(!me(Y.args[X],z.args[X]))return!1}else return!1;return!0}return M}),xB="simplifyConstant",wB=["typed","config","mathWithTransform","matrix","isBounded","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],DB=L(xB,wB,r=>{var{typed:e,config:t,mathWithTransform:n,matrix:a,isBounded:i,fraction:o,bignumber:l,AccessorNode:u,ArrayNode:s,ConstantNode:c,FunctionNode:f,IndexNode:m,ObjectNode:v,OperatorNode:p,SymbolNode:d}=r,{isCommutative:y,isAssociative:x,allChildren:D,createMakeNodeFunction:h}=Xs({FunctionNode:f,OperatorNode:p,SymbolNode:d}),w=e("simplifyConstant",{Node:_=>N(k(_,{})),"Node, Object":function(P,V){return N(k(P,V))}});function g(_){return Ka(_)?_.valueOf():_ instanceof Array?_.map(g):Je(_)?a(g(_.valueOf())):_}function b(_,P,V){try{return n[_].apply(null,P)}catch{return P=P.map(g),S(n[_].apply(null,P),V)}}var A=e({Fraction:M,number:function(P){return P<0?C(new c(-P)):new c(P)},BigNumber:function(P){return P<0?C(new c(-P)):new c(P)},bigint:function(P){return P<0n?C(new c(-P)):new c(P)},Complex:function(P){throw new Error("Cannot convert Complex number to Node")},string:function(P){return new c(P)},Matrix:function(P){return new s(P.valueOf().map(V=>A(V)))}});function N(_){return Nr(_)?_:A(_)}function E(_,P){var V=P&&P.exactFractions!==!1;if(V&&i(_)&&o){var q=o(_),J=P&&typeof P.fractionsLimit=="number"?P.fractionsLimit:1/0;if(q.valueOf()===_&&q.n<J&&q.d<J)return q}return _}var S=e({"string, Object":function(P,V){var q=An(P,t);if(q==="BigNumber")return l===void 0&&Ts(),l(P);if(q==="bigint")return BigInt(P);if(q==="Fraction")return o===void 0&&um(),o(P);var J=parseFloat(P);return E(J,V)},"Fraction, Object":function(P,V){return P},"BigNumber, Object":function(P,V){return P},"number, Object":function(P,V){return E(P,V)},"bigint, Object":function(P,V){return P},"Complex, Object":function(P,V){return P.im!==0?P:E(P.re,V)},"Matrix, Object":function(P,V){return a(E(P.valueOf()))},"Array, Object":function(P,V){return P.map(E)}});function C(_){return new p("-","unaryMinus",[_])}function M(_){var P=J=>t.number==="BigNumber"&&l?l(J):Number(J),V=_.s*_.n,q=V<0n?new p("-","unaryMinus",[new c(-P(V))]):new c(P(V));return _.d===1n?q:new p("/","divide",[q,new c(P(_.d))])}function O(_,P,V){if(!pa(P))return new u(N(_),N(P));if(Rt(_)||Je(_)){for(var q=Array.from(P.dimensions);q.length>0;)if(gr(q[0])&&typeof q[0].value!="string"){var J=S(q.shift().value,V);Rt(_)?_=_.items[J-1]:(_=_.valueOf()[J-1],_ instanceof Array&&(_=a(_)))}else if(q.length>1&&gr(q[1])&&typeof q[1].value!="string"){var ne=S(q[1].value,V),j=[],F=Rt(_)?_.items:_.valueOf();for(var U of F)if(Rt(U))j.push(U.items[ne-1]);else if(Je(_))j.push(U[ne-1]);else break;if(j.length===F.length)Rt(_)?_=new s(j):_=a(j),q.splice(1,1);else break}else break;return q.length===P.dimensions.length?new u(N(_),P):q.length>0?(P=new m(q),new u(N(_),P)):_}if(Oi(_)&&P.dimensions.length===1&&gr(P.dimensions[0])){var $=P.dimensions[0].value;return $ in _.properties?_.properties[$]:new c}return new u(N(_),P)}function I(_,P,V,q){var J=P.shift(),ne=P.reduce((j,F)=>{if(!Nr(F)){var U=j.pop();if(Nr(U))return[U,F];try{return j.push(b(_,[U,F],q)),j}catch{j.push(U)}}j.push(N(j.pop()));var $=j.length===1?j[0]:V(j);return[V([$,N(F)])]},[J]);return ne.length===1?ne[0]:V([ne[0],A(ne[1])])}function k(_,P){switch(_.type){case"SymbolNode":return _;case"ConstantNode":switch(typeof _.value){case"number":return S(_.value,P);case"bigint":return S(_.value,P);case"string":return _.value;default:if(!isNaN(_.value))return S(_.value,P)}return _;case"FunctionNode":if(n[_.name]&&n[_.name].rawArgs)return _;{var V=["add","multiply"];if(!V.includes(_.name)){var q=_.args.map(re=>k(re,P));if(!q.some(Nr))try{return b(_.name,q,P)}catch{}if(_.name==="size"&&q.length===1&&Rt(q[0])){for(var J=[],ne=q[0];Rt(ne);)J.push(ne.items.length),ne=ne.items[0];return a(J)}return new f(_.name,q.map(N))}}case"OperatorNode":{var j=_.fn.toString(),F,U,$=h(_);if(Ur(_)&&_.isUnary())F=[k(_.args[0],P)],Nr(F[0])?U=$(F):U=b(j,F,P);else if(x(_,P.context))if(F=D(_,P.context),F=F.map(re=>k(re,P)),y(j,P.context)){for(var le=[],me=[],Y=0;Y<F.length;Y++)Nr(F[Y])?me.push(F[Y]):le.push(F[Y]);le.length>1?(U=I(j,le,$,P),me.unshift(U),U=I(j,me,$,P)):U=I(j,F,$,P)}else U=I(j,F,$,P);else F=_.args.map(re=>k(re,P)),U=I(j,F,$,P);return U}case"ParenthesisNode":return k(_.content,P);case"AccessorNode":return O(k(_.object,P),k(_.index,P),P);case"ArrayNode":{var z=_.items.map(re=>k(re,P));return z.some(Nr)?new s(z.map(N)):a(z)}case"IndexNode":return new m(_.dimensions.map(re=>w(re,P)));case"ObjectNode":{var X={};for(var se in _.properties)X[se]=w(_.properties[se],P);return new v(X)}case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"RangeNode":case"ConditionalNode":default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(_.type))}}return w}),gd="simplifyCore",NB=["typed","parse","equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],EB=L(gd,NB,r=>{var{typed:e,parse:t,equal:n,isZero:a,add:i,subtract:o,multiply:l,divide:u,pow:s,AccessorNode:c,ArrayNode:f,ConstantNode:m,FunctionNode:v,IndexNode:p,ObjectNode:d,OperatorNode:y,ParenthesisNode:x,SymbolNode:D}=r,h=new m(0),w=new m(1),g=new m(!0),b=new m(!1);function A(C){return Ur(C)&&["and","not","or"].includes(C.op)}var{hasProperty:N,isCommutative:E}=Xs({FunctionNode:v,OperatorNode:y,SymbolNode:D});function S(C){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},O=M?M.context:void 0;if(N(C,"trivial",O)){if(En(C)&&C.args.length===1)return S(C.args[0],M);var I=!1,k=0;if(C.forEach(le=>{++k,k===1&&(I=S(le,M))}),k===1)return I}var _=C;if(En(_)){var P=pS(_.name);if(P){if(_.args.length>2&&N(_,"associative",O))for(;_.args.length>2;){var V=_.args.pop(),q=_.args.pop();_.args.push(new y(P,_.name,[V,q]))}_=new y(P,_.name,_.args)}else return new v(S(_.fn),_.args.map(le=>S(le,M)))}if(Ur(_)&&_.isUnary()){var J=S(_.args[0],M);if(_.op==="~"&&Ur(J)&&J.isUnary()&&J.op==="~"||_.op==="not"&&Ur(J)&&J.isUnary()&&J.op==="not"&&A(J.args[0]))return J.args[0];var ne=!0;if(_.op==="-"&&Ur(J)&&(J.isBinary()&&J.fn==="subtract"&&(_=new y("-","subtract",[J.args[1],J.args[0]]),ne=!1),J.isUnary()&&J.op==="-"))return J.args[0];if(ne)return new y(_.op,_.fn,[J])}if(Ur(_)&&_.isBinary()){var j=S(_.args[0],M),F=S(_.args[1],M);if(_.op==="+"){if(gr(j)&&a(j.value))return F;if(gr(F)&&a(F.value))return j;Ur(F)&&F.isUnary()&&F.op==="-"&&(F=F.args[0],_=new y("-","subtract",[j,F]))}if(_.op==="-")return Ur(F)&&F.isUnary()&&F.op==="-"?S(new y("+","add",[j,F.args[0]]),M):gr(j)&&a(j.value)?S(new y("-","unaryMinus",[F])):gr(F)&&a(F.value)?j:new y(_.op,_.fn,[j,F]);if(_.op==="*"){if(gr(j)){if(a(j.value))return h;if(n(j.value,1))return F}if(gr(F)){if(a(F.value))return h;if(n(F.value,1))return j;if(E(_,O))return new y(_.op,_.fn,[F,j],_.implicit)}return new y(_.op,_.fn,[j,F],_.implicit)}if(_.op==="/")return gr(j)&&a(j.value)?h:gr(F)&&n(F.value,1)?j:new y(_.op,_.fn,[j,F]);if(_.op==="^"&&gr(F)){if(a(F.value))return w;if(n(F.value,1))return j}if(_.op==="and"){if(gr(j))if(j.value){if(A(F))return F;if(gr(F))return F.value?g:b}else return b;if(gr(F))if(F.value){if(A(j))return j}else return b}if(_.op==="or"){if(gr(j)){if(j.value)return g;if(A(F))return F}if(gr(F)){if(F.value)return g;if(A(j))return j}}return new y(_.op,_.fn,[j,F])}if(Ur(_))return new y(_.op,_.fn,_.args.map(le=>S(le,M)));if(Rt(_))return new f(_.items.map(le=>S(le,M)));if(cn(_))return new c(S(_.object,M),S(_.index,M));if(pa(_))return new p(_.dimensions.map(le=>S(le,M)));if(Oi(_)){var U={};for(var $ in _.properties)U[$]=S(_.properties[$],M);return new d(U)}return _}return e(gd,{Node:S,"Node,Object":S})}),AB="resolve",SB=["typed","parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],CB=L(AB,SB,r=>{var{typed:e,parse:t,ConstantNode:n,FunctionNode:a,OperatorNode:i,ParenthesisNode:o}=r;function l(u,s){var c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;if(!s)return u;if(Jr(u)){if(c.has(u.name)){var f=Array.from(c).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(f,"}"))}var m=s.get(u.name);if(Nr(m)){var v=new Set(c);return v.add(u.name),l(m,s,v)}else return typeof m=="number"?t(String(m)):m!==void 0?new n(m):u}else if(Ur(u)){var p=u.args.map(function(y){return l(y,s,c)});return new i(u.op,u.fn,p,u.implicit)}else{if(fn(u))return new o(l(u.content,s,c));if(En(u)){var d=u.args.map(function(y){return l(y,s,c)});return new a(u.name,d)}}return u.map(y=>l(y,s,c))}return e("resolve",{Node:l,"Node, Map | null | undefined":l,"Node, Object":(u,s)=>l(u,va(s)),"Array | Matrix":e.referToSelf(u=>s=>s.map(c=>u(c))),"Array | Matrix, null | undefined":e.referToSelf(u=>s=>s.map(c=>u(c))),"Array, Object":e.referTo("Array,Map",u=>(s,c)=>u(s,va(c))),"Matrix, Object":e.referTo("Matrix,Map",u=>(s,c)=>u(s,va(c))),"Array | Matrix, Map":e.referToSelf(u=>(s,c)=>s.map(f=>u(f,c)))})}),yd="symbolicEqual",MB=["parse","simplify","typed","OperatorNode"],_B=L(yd,MB,r=>{var{parse:e,simplify:t,typed:n,OperatorNode:a}=r;function i(o,l){var u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=new a("-","subtract",[o,l]),c=t(s,{},u);return gr(c)&&!c.value}return n(yd,{"Node, Node":i,"Node, Node, Object":i})}),bd="derivative",TB=["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],FB=L(bd,TB,r=>{var{typed:e,config:t,parse:n,simplify:a,equal:i,isZero:o,numeric:l,ConstantNode:u,FunctionNode:s,OperatorNode:c,ParenthesisNode:f,SymbolNode:m}=r;function v(w,g){var b=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{simplify:!0},A=new Map,N=g.name;function E(C){var M=A.get(C);if(M!==void 0)return M;var O=x(E,C,N);return A.set(C,O),O}var S=D(w,E);return b.simplify?a(S):S}function p(w){var g=n(w);if(!g.isSymbolNode)throw new TypeError("Invalid variable. "+"Cannot parse ".concat(JSON.stringify(w)," into a variable in function derivative"));return g}var d=e(bd,{"Node, SymbolNode":v,"Node, SymbolNode, Object":v,"Node, string":(w,g)=>v(w,p(g)),"Node, string, Object":(w,g,b)=>v(w,p(g),b)});d._simplify=!0,d.toTex=function(w){return y.apply(null,w.args)};var y=e("_derivTex",{"Node, SymbolNode":function(g,b){return gr(g)&&Sr(g.value)==="string"?y(n(g.value).toString(),b.toString(),1):y(g.toTex(),b.toString(),1)},"Node, ConstantNode":function(g,b){if(Sr(b.value)==="string")return y(g,n(b.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(g,b,A){return y(g.toString(),b.name,A.value)},"string, string, number":function(g,b,A){var N;return A===1?N="{d\\over d"+b+"}":N="{d^{"+A+"}\\over d"+b+"^{"+A+"}}",N+"\\left[".concat(g,"\\right]")}}),x=e("_isConst",{"function, ConstantNode, string":function(){return!0},"function, SymbolNode, string":function(g,b,A){return b.name!==A},"function, ParenthesisNode, string":function(g,b,A){return g(b.content,A)},"function, FunctionAssignmentNode, string":function(g,b,A){return b.params.includes(A)?g(b.expr,A):!0},"function, FunctionNode | OperatorNode, string":function(g,b,A){return b.args.every(N=>g(N,A))}}),D=e("_derivative",{"ConstantNode, function":function(){return h(0)},"SymbolNode, function":function(g,b){return b(g)?h(0):h(1)},"ParenthesisNode, function":function(g,b){return new f(D(g.content,b))},"FunctionAssignmentNode, function":function(g,b){return b(g)?h(0):D(g.expr,b)},"FunctionNode, function":function(g,b){if(b(g))return h(0);var A=g.args[0],N,E=!1,S=!1,C;switch(g.name){case"cbrt":E=!0,C=new c("*","multiply",[h(3),new c("^","pow",[A,new c("/","divide",[h(2),h(3)])])]);break;case"sqrt":case"nthRoot":if(g.args.length===1)E=!0,C=new c("*","multiply",[h(2),new s("sqrt",[A])]);else if(g.args.length===2)return N=new c("/","divide",[h(1),g.args[1]]),D(new c("^","pow",[A,N]),b);break;case"log10":N=h(10);case"log":if(!N&&g.args.length===1)C=A.clone(),E=!0;else if(g.args.length===1&&N||g.args.length===2&&b(g.args[1]))C=new c("*","multiply",[A.clone(),new s("log",[N||g.args[1]])]),E=!0;else if(g.args.length===2)return D(new c("/","divide",[new s("log",[A]),new s("log",[g.args[1]])]),b);break;case"pow":if(g.args.length===2)return D(new c("^","pow",[A,g.args[1]]),b);break;case"exp":C=new s("exp",[A.clone()]);break;case"sin":C=new s("cos",[A.clone()]);break;case"cos":C=new c("-","unaryMinus",[new s("sin",[A.clone()])]);break;case"tan":C=new c("^","pow",[new s("sec",[A.clone()]),h(2)]);break;case"sec":C=new c("*","multiply",[g,new s("tan",[A.clone()])]);break;case"csc":S=!0,C=new c("*","multiply",[g,new s("cot",[A.clone()])]);break;case"cot":S=!0,C=new c("^","pow",[new s("csc",[A.clone()]),h(2)]);break;case"asin":E=!0,C=new s("sqrt",[new c("-","subtract",[h(1),new c("^","pow",[A.clone(),h(2)])])]);break;case"acos":E=!0,S=!0,C=new s("sqrt",[new c("-","subtract",[h(1),new c("^","pow",[A.clone(),h(2)])])]);break;case"atan":E=!0,C=new c("+","add",[new c("^","pow",[A.clone(),h(2)]),h(1)]);break;case"asec":E=!0,C=new c("*","multiply",[new s("abs",[A.clone()]),new s("sqrt",[new c("-","subtract",[new c("^","pow",[A.clone(),h(2)]),h(1)])])]);break;case"acsc":E=!0,S=!0,C=new c("*","multiply",[new s("abs",[A.clone()]),new s("sqrt",[new c("-","subtract",[new c("^","pow",[A.clone(),h(2)]),h(1)])])]);break;case"acot":E=!0,S=!0,C=new c("+","add",[new c("^","pow",[A.clone(),h(2)]),h(1)]);break;case"sinh":C=new s("cosh",[A.clone()]);break;case"cosh":C=new s("sinh",[A.clone()]);break;case"tanh":C=new c("^","pow",[new s("sech",[A.clone()]),h(2)]);break;case"sech":S=!0,C=new c("*","multiply",[g,new s("tanh",[A.clone()])]);break;case"csch":S=!0,C=new c("*","multiply",[g,new s("coth",[A.clone()])]);break;case"coth":S=!0,C=new c("^","pow",[new s("csch",[A.clone()]),h(2)]);break;case"asinh":E=!0,C=new s("sqrt",[new c("+","add",[new c("^","pow",[A.clone(),h(2)]),h(1)])]);break;case"acosh":E=!0,C=new s("sqrt",[new c("-","subtract",[new c("^","pow",[A.clone(),h(2)]),h(1)])]);break;case"atanh":E=!0,C=new c("-","subtract",[h(1),new c("^","pow",[A.clone(),h(2)])]);break;case"asech":E=!0,S=!0,C=new c("*","multiply",[A.clone(),new s("sqrt",[new c("-","subtract",[h(1),new c("^","pow",[A.clone(),h(2)])])])]);break;case"acsch":E=!0,S=!0,C=new c("*","multiply",[new s("abs",[A.clone()]),new s("sqrt",[new c("+","add",[new c("^","pow",[A.clone(),h(2)]),h(1)])])]);break;case"acoth":E=!0,S=!0,C=new c("-","subtract",[h(1),new c("^","pow",[A.clone(),h(2)])]);break;case"abs":C=new c("/","divide",[new s(new m("abs"),[A.clone()]),A.clone()]);break;case"gamma":default:throw new Error('Cannot process function "'+g.name+'" in derivative: the function is not supported, undefined, or the number of arguments passed to it are not supported')}var M,O;E?(M="/",O="divide"):(M="*",O="multiply");var I=D(A,b);return S&&(I=new c("-","unaryMinus",[I])),new c(M,O,[I,C])},"OperatorNode, function":function(g,b){if(b(g))return h(0);if(g.op==="+")return new c(g.op,g.fn,g.args.map(function(_){return D(_,b)}));if(g.op==="-"){if(g.isUnary())return new c(g.op,g.fn,[D(g.args[0],b)]);if(g.isBinary())return new c(g.op,g.fn,[D(g.args[0],b),D(g.args[1],b)])}if(g.op==="*"){var A=g.args.filter(function(_){return b(_)});if(A.length>0){var N=g.args.filter(function(_){return!b(_)}),E=N.length===1?N[0]:new c("*","multiply",N),S=A.concat(D(E,b));return new c("*","multiply",S)}return new c("+","add",g.args.map(function(_){return new c("*","multiply",g.args.map(function(P){return P===_?D(P,b):P.clone()}))}))}if(g.op==="/"&&g.isBinary()){var C=g.args[0],M=g.args[1];return b(M)?new c("/","divide",[D(C,b),M]):b(C)?new c("*","multiply",[new c("-","unaryMinus",[C]),new c("/","divide",[D(M,b),new c("^","pow",[M.clone(),h(2)])])]):new c("/","divide",[new c("-","subtract",[new c("*","multiply",[D(C,b),M.clone()]),new c("*","multiply",[C.clone(),D(M,b)])]),new c("^","pow",[M.clone(),h(2)])])}if(g.op==="^"&&g.isBinary()){var O=g.args[0],I=g.args[1];if(b(O))return gr(O)&&(o(O.value)||i(O.value,1))?h(0):new c("*","multiply",[g,new c("*","multiply",[new s("log",[O.clone()]),D(I.clone(),b)])]);if(b(I)){if(gr(I)){if(o(I.value))return h(0);if(i(I.value,1))return D(O,b)}var k=new c("^","pow",[O.clone(),new c("-","subtract",[I,h(1)])]);return new c("*","multiply",[I.clone(),new c("*","multiply",[D(O,b),k])])}return new c("*","multiply",[new c("^","pow",[O.clone(),I.clone()]),new c("+","add",[new c("*","multiply",[D(O,b),new c("/","divide",[I.clone(),O.clone()])]),new c("*","multiply",[D(I,b),new s("log",[O.clone()])])])])}throw new Error('Cannot process operator "'+g.op+'" in derivative: the operator is not supported, undefined, or the number of arguments passed to it are not supported')}});function h(w,g){return new u(l(w,An(String(w),t)))}return d}),xd="rationalize",OB=["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"],BB=L(xd,OB,r=>{var{config:e,typed:t,equal:n,isZero:a,add:i,subtract:o,multiply:l,divide:u,pow:s,parse:c,simplifyConstant:f,simplifyCore:m,simplify:v,fraction:p,bignumber:d,mathWithTransform:y,matrix:x,AccessorNode:D,ArrayNode:h,ConstantNode:w,FunctionNode:g,IndexNode:b,ObjectNode:A,OperatorNode:N,SymbolNode:E,ParenthesisNode:S}=r;function C(_){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},V=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,q=O(),J=M(_,P,!0,q.firstRules),ne=J.variables.length,j={exactFractions:!1},F={exactFractions:!0};if(_=J.expression,ne>=1){_=I(_);var U,$,le=!0,me=!1;_=v(_,q.firstRules,{},j);for(var Y;$=le?q.distrDivRules:q.sucDivRules,_=v(_,$,{},F),le=!le,Y=_.toString(),Y!==U;)me=!0,U=Y;me&&(_=v(_,q.firstRulesAgain,{},j)),_=v(_,q.finalRules,{},j)}var z=[],X={};return _.type==="OperatorNode"&&_.isBinary()&&_.op==="/"?(ne===1&&(_.args[0]=k(_.args[0],z),_.args[1]=k(_.args[1])),V&&(X.numerator=_.args[0],X.denominator=_.args[1])):(ne===1&&(_=k(_,z)),V&&(X.numerator=_,X.denominator=null)),V?(X.coefficients=z,X.variables=J.variables,X.expression=_,X):_}return t(xd,{Node:C,"Node, boolean":(_,P)=>C(_,{},P),"Node, Object":C,"Node, Object, boolean":C});function M(_,P,V,q){var J=[],ne=v(_,q,P,{exactFractions:!1});V=!!V;var j="+-*"+(V?"/":"");U(ne);var F={};return F.expression=ne,F.variables=J,F;function U($){var le=$.type;if(le==="FunctionNode")throw new Error("There is an unsolved function call");if(le==="OperatorNode")if($.op==="^"){if($.args[1].type!=="ConstantNode"||!Ue(parseFloat($.args[1].value)))throw new Error("There is a non-integer exponent");U($.args[0])}else{if(!j.includes($.op))throw new Error("Operator "+$.op+" invalid in polynomial expression");for(var me=0;me<$.args.length;me++)U($.args[me])}else if(le==="SymbolNode"){var Y=$.name,z=J.indexOf(Y);z===-1&&J.push(Y)}else if(le==="ParenthesisNode")U($.content);else if(le!=="ConstantNode")throw new Error("type "+le+" is not allowed in polynomial expression")}}function O(){var _=[m,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},f,{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"}],P=[{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)"}],V=[{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)"}],q=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],J={};return J.firstRules=_.concat(P,q),J.distrDivRules=V,J.sucDivRules=q,J.firstRulesAgain=_.concat(P),J.finalRules=[m,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},f,{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))"}],J}function I(_,P,V){var q=_.type,J=arguments.length>1;if(q==="OperatorNode"&&_.isBinary()){var ne=!1,j;if(_.op==="^"&&(_.args[0].type==="ParenthesisNode"||_.args[0].type==="OperatorNode")&&_.args[1].type==="ConstantNode"&&(j=parseFloat(_.args[1].value),ne=j>=2&&Ue(j)),ne){if(j>2){var F=_.args[0],U=new N("^","pow",[_.args[0].cloneDeep(),new w(j-1)]);_=new N("*","multiply",[F,U])}else _=new N("*","multiply",[_.args[0],_.args[0].cloneDeep()]);J&&(V==="content"?P.content=_:P.args[V]=_)}}if(q==="ParenthesisNode")I(_.content,_,"content");else if(q!=="ConstantNode"&&q!=="SymbolNode")for(var $=0;$<_.args.length;$++)I(_.args[$],_,$);if(!J)return _}function k(_,P){P===void 0&&(P=[]),P[0]=0;var V={};V.cte=1,V.oper="+",V.fire="";var q=0,J="";Y(_,null,V),q=P.length-1;for(var ne=!0,j,F=q;F>=0;F--)if(P[F]!==0){var U=new w(ne?P[F]:Math.abs(P[F])),$=P[F]<0?"-":"+";if(F>0){var le=new E(J);if(F>1){var me=new w(F);le=new N("^","pow",[le,me])}P[F]===-1&&ne?U=new N("-","unaryMinus",[le]):Math.abs(P[F])===1?U=le:U=new N("*","multiply",[U,le])}ne?j=U:$==="+"?j=new N("+","add",[j,U]):j=new N("-","subtract",[j,U]),ne=!1}if(ne)return new w(0);return j;function Y(z,X,se){var re=z.type;if(re==="FunctionNode")throw new Error("There is an unsolved function call");if(re==="OperatorNode"){if(!"+-*^".includes(z.op))throw new Error("Operator "+z.op+" invalid");if(X!==null){if((z.fn==="unaryMinus"||z.fn==="pow")&&X.fn!=="add"&&X.fn!=="subtract"&&X.fn!=="multiply")throw new Error("Invalid "+z.op+" placing");if((z.fn==="subtract"||z.fn==="add"||z.fn==="multiply")&&X.fn!=="add"&&X.fn!=="subtract")throw new Error("Invalid "+z.op+" placing");if((z.fn==="subtract"||z.fn==="add"||z.fn==="unaryMinus")&&se.noFil!==0)throw new Error("Invalid "+z.op+" placing")}(z.op==="^"||z.op==="*")&&(se.fire=z.op);for(var pe=0;pe<z.args.length;pe++)z.fn==="unaryMinus"&&(se.oper="-"),(z.op==="+"||z.fn==="subtract")&&(se.fire="",se.cte=1,se.oper=pe===0?"+":z.op),se.noFil=pe,Y(z.args[pe],z,se)}else if(re==="SymbolNode"){if(z.name!==J&&J!=="")throw new Error("There is more than one variable");if(J=z.name,X===null){P[1]=1;return}if(X.op==="^"&&se.noFil!==0)throw new Error("In power the variable should be the first parameter");if(X.op==="*"&&se.noFil!==1)throw new Error("In multiply the variable should be the second parameter");(se.fire===""||se.fire==="*")&&(q<1&&(P[1]=0),P[1]+=se.cte*(se.oper==="+"?1:-1),q=Math.max(1,q))}else if(re==="ConstantNode"){var ve=parseFloat(z.value);if(X===null){P[0]=ve;return}if(X.op==="^"){if(se.noFil!==1)throw new Error("Constant cannot be powered");if(!Ue(ve)||ve<=0)throw new Error("Non-integer exponent is not allowed");for(var De=q+1;De<ve;De++)P[De]=0;ve>q&&(P[ve]=0),P[ve]+=se.cte*(se.oper==="+"?1:-1),q=Math.max(ve,q);return}se.cte=ve,se.fire===""&&(P[0]+=se.cte*(se.oper==="+"?1:-1))}else throw new Error("Type "+re+" is not allowed")}}}),wd="zpk2tf",RB=["typed","add","multiply","Complex","number"],IB=L(wd,RB,r=>{var{typed:e,add:t,multiply:n,Complex:a,number:i}=r;return e(wd,{"Array,Array,number":function(s,c,f){return o(s,c,f)},"Array,Array":function(s,c){return o(s,c,1)},"Matrix,Matrix,number":function(s,c,f){return o(s.valueOf(),c.valueOf(),f)},"Matrix,Matrix":function(s,c){return o(s.valueOf(),c.valueOf(),1)}});function o(u,s,c){u.some(D=>D.type==="BigNumber")&&(u=u.map(D=>i(D))),s.some(D=>D.type==="BigNumber")&&(s=s.map(D=>i(D)));for(var f=[a(1,0)],m=[a(1,0)],v=0;v<u.length;v++){var p=u[v];typeof p=="number"&&(p=a(p,0)),f=l(f,[a(1,0),a(-p.re,-p.im)])}for(var d=0;d<s.length;d++){var y=s[d];typeof y=="number"&&(y=a(y,0)),m=l(m,[a(1,0),a(-y.re,-y.im)])}for(var x=0;x<f.length;x++)f[x]=n(f[x],c);return[f,m]}function l(u,s){for(var c=[],f=0;f<u.length+s.length-1;f++){c[f]=a(0,0);for(var m=0;m<u.length;m++)f-m>=0&&f-m<s.length&&(c[f]=t(c[f],n(u[m],s[f-m])))}return c}}),Dd="freqz",PB=["typed","add","multiply","Complex","divide","matrix"],$B=L(Dd,PB,r=>{var{typed:e,add:t,multiply:n,Complex:a,divide:i,matrix:o}=r;return e(Dd,{"Array, Array":function(c,f){var m=u(512);return l(c,f,m)},"Array, Array, Array":function(c,f,m){return l(c,f,m)},"Array, Array, number":function(c,f,m){if(m<0)throw new Error("w must be a positive number");var v=u(m);return l(c,f,v)},"Matrix, Matrix":function(c,f){var m=u(512),{w:v,h:p}=l(c.valueOf(),f.valueOf(),m);return{w:o(v),h:o(p)}},"Matrix, Matrix, Matrix":function(c,f,m){var{h:v}=l(c.valueOf(),f.valueOf(),m.valueOf());return{h:o(v),w:o(m)}},"Matrix, Matrix, number":function(c,f,m){if(m<0)throw new Error("w must be a positive number");var v=u(m),{h:p}=l(c.valueOf(),f.valueOf(),v);return{h:o(p),w:o(v)}}});function l(s,c,f){for(var m=[],v=[],p=0;p<f.length;p++){for(var d=a(0,0),y=a(0,0),x=0;x<s.length;x++)d=t(d,n(s[x],a(Math.cos(-x*f[p]),Math.sin(-x*f[p]))));for(var D=0;D<c.length;D++)y=t(y,n(c[D],a(Math.cos(-D*f[p]),Math.sin(-D*f[p]))));m.push(d),v.push(y)}for(var h=[],w=0;w<m.length;w++)h.push(i(m[w],v[w]));return{h,w:f}}function u(s){for(var c=[],f=0;f<s;f++)c.push(f/s*Math.PI);return c}}),qB="reviver",zB=["classes"],UB=L(qB,zB,r=>{var{classes:e}=r;return function(n,a){var i=e[a&&a.mathjs];return i&&typeof i.fromJSON=="function"?i.fromJSON(a):a}}),LB="replacer",kB=[],VB=L(LB,kB,()=>function(e,t){return typeof t=="number"&&(!Number.isFinite(t)||isNaN(t))?{mathjs:"number",value:String(t)}:typeof t=="bigint"?{mathjs:"bigint",value:String(t)}:t}),GB="15.2.0",HB=L("true",[],()=>!0),WB=L("false",[],()=>!1),YB=L("null",[],()=>null),ZB=Mt("Infinity",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1/0):1/0}),JB=Mt("NaN",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(NaN):NaN}),jB=Mt("pi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?Rs(t):z1}),XB=Mt("tau",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?yE(t):U1}),QB=Mt("e",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?hE(t):L1}),KB=Mt("phi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?gE(t):k1}),e4=Mt("LN2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).ln():Math.LN2}),r4=Mt("LN10",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(10).ln():Math.LN10}),t4=Mt("LOG2E",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1).div(new t(2).ln()):Math.LOG2E}),n4=Mt("LOG10E",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1).div(new t(10).ln()):Math.LOG10E}),a4=Mt("SQRT1_2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t("0.5").sqrt():Math.SQRT1_2}),i4=Mt("SQRT2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).sqrt():Math.SQRT2}),o4=Mt("i",["Complex"],r=>{var{Complex:e}=r;return e.I}),s4=L("version",[],()=>GB);function Mt(r,e,t){return L(r,e,t,{recreateOnConfigChange:!0})}var u4=nr("speedOfLight","299792458","m s^-1"),l4=nr("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),c4=nr("planckConstant","6.62607015e-34","J s"),f4=nr("reducedPlanckConstant","1.0545718176461565e-34","J s"),m4=nr("magneticConstant","1.25663706212e-6","N A^-2"),v4=nr("electricConstant","8.8541878128e-12","F m^-1"),p4=nr("vacuumImpedance","376.730313667","ohm"),d4=nr("coulomb","8.987551792261171e9","N m^2 C^-2"),h4=nr("coulombConstant","8.987551792261171e9","N m^2 C^-2"),g4=nr("elementaryCharge","1.602176634e-19","C"),y4=nr("bohrMagneton","9.2740100783e-24","J T^-1"),b4=nr("conductanceQuantum","7.748091729863649e-5","S"),x4=nr("inverseConductanceQuantum","12906.403729652257","ohm"),w4=nr("magneticFluxQuantum","2.0678338484619295e-15","Wb"),D4=nr("nuclearMagneton","5.0507837461e-27","J T^-1"),N4=nr("klitzing","25812.807459304513","ohm"),E4=nr("bohrRadius","5.29177210903e-11","m"),A4=nr("classicalElectronRadius","2.8179403262e-15","m"),S4=nr("electronMass","9.1093837015e-31","kg"),C4=nr("fermiCoupling","1.1663787e-5","GeV^-2"),M4=Ro("fineStructure",.0072973525693),_4=nr("hartreeEnergy","4.3597447222071e-18","J"),T4=nr("protonMass","1.67262192369e-27","kg"),F4=nr("deuteronMass","3.3435830926e-27","kg"),O4=nr("neutronMass","1.6749271613e-27","kg"),B4=nr("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),R4=nr("rydberg","10973731.568160","m^-1"),I4=nr("thomsonCrossSection","6.6524587321e-29","m^2"),P4=Ro("weakMixingAngle",.2229),$4=Ro("efimovFactor",22.7),q4=nr("atomicMass","1.66053906660e-27","kg"),z4=nr("avogadro","6.02214076e23","mol^-1"),U4=nr("boltzmann","1.380649e-23","J K^-1"),L4=nr("faraday","96485.33212331001","C mol^-1"),k4=nr("firstRadiation","3.7417718521927573e-16","W m^2"),V4=nr("loschmidt","2.686780111798444e25","m^-3"),G4=nr("gasConstant","8.31446261815324","J K^-1 mol^-1"),H4=nr("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),W4=nr("molarVolume","0.022413969545014137","m^3 mol^-1"),Y4=Ro("sackurTetrode",-1.16487052358),Z4=nr("secondRadiation","0.014387768775039337","m K"),J4=nr("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),j4=nr("wienDisplacement","2.897771955e-3","m K"),X4=nr("molarMass","0.99999999965e-3","kg mol^-1"),Q4=nr("molarMassC12","11.9999999958e-3","kg mol^-1"),K4=nr("gravity","9.80665","m s^-2"),eR=nr("planckLength","1.616255e-35","m"),rR=nr("planckMass","2.176435e-8","kg"),tR=nr("planckTime","5.391245e-44","s"),nR=nr("planckCharge","1.87554603778e-18","C"),aR=nr("planckTemperature","1.416785e+32","K");function nr(r,e,t){var n=["config","Unit","BigNumber"];return L(r,n,a=>{var{config:i,Unit:o,BigNumber:l}=a,u=i.number==="BigNumber"?new l(e):parseFloat(e),s=new o(u,t);return s.fixPrefix=!0,s})}function Ro(r,e){var t=["config","BigNumber"];return L(r,t,n=>{var{config:a,BigNumber:i}=n;return a.number==="BigNumber"?new i(e):e})}function Nd(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function iR(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Nd(Object(t),!0).forEach(function(n){Vr(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Nd(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}var oR="mapSlices",sR=["typed","isInteger"],uR=L(oR,sR,r=>{var{typed:e,isInteger:t}=r,n=xs({typed:e,isInteger:t});return e("mapSlices",{"...any":function(i){var o=i[1];Ye(o)?i[1]=o-1:or(o)&&(i[1]=o.minus(1));try{return n.apply(null,i)}catch(l){throw ht(l)}}})},iR({isTransformFunction:!0},xs.meta)),lR="column",cR=["typed","Index","matrix","range"],fR=L(lR,cR,r=>{var{typed:e,Index:t,matrix:n,range:a}=r,i=Zf({typed:e,Index:t,matrix:n,range:a});return e("column",{"...any":function(l){var u=l.length-1,s=l[u];Ye(s)&&(l[u]=s-1);try{return i.apply(null,l)}catch(c){throw ht(c)}}})},{isTransformFunction:!0});function Qs(r,e,t){var n=r.filter(function(u){return Jr(u)&&!(u.name in e)&&!t.has(u.name)})[0];if(!n)throw new Error('No undefined variable found in inline expression "'+r+'"');var a=n.name,i=new Map,o=new Wu(t,i,new Set([a])),l=r.compile();return function(s){return i.set(a,s),l.evaluate(o)}}var mR="transformCallback",vR=["typed"],Ks=L(mR,vR,r=>{var{typed:e}=r;return function(n,a){return e.isTypedFunction(n)?t(n,a):Ed(n,n.length,a)};function t(n,a){var i=Object.fromEntries(Object.entries(n.signatures).map(o=>{var[l,u]=o,s=l.split(",").length;return e.isTypedFunction(u)?[l,t(u,a)]:[l,Ed(u,s,a)]}));return typeof n.name=="string"?e(n.name,i):e(i)}});function Ed(r,e,t){return e===t?r:e===t+1?function(){for(var n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];var o=a.slice(0,t),l=Ad(a[t]);return r(...o,l)}:e>t+1?function(){for(var n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];var o=a.slice(0,t),l=Ad(a[t]),u=a.slice(t+1);return r(...o,l,...u)}:r}function Ad(r){return r.map(e=>e+1)}var pR="filter",dR=["typed"],hR=L(pR,dR,r=>{var{typed:e}=r;function t(a,i,o){var l=Qf({typed:e}),u=Ks({typed:e});if(a.length===0)return l();var s=a[0];if(a.length===1)return l(s);var c=a.length-1,f=a[c];return s&&(s=n(s,o)),f&&(Jr(f)||ei(f)?f=n(f,o):f=Qs(f,i,o)),l(s,u(f,c))}t.rawArgs=!0;function n(a,i){return a.compile().evaluate(i)}return t},{isTransformFunction:!0}),gR="forEach",yR=["typed"],bR=L(gR,yR,r=>{var{typed:e}=r,t=rm({typed:e}),n=Ks({typed:e});function a(o,l,u){if(o.length===0)return t();var s=o[0];if(o.length===1)return t(s);var c=o.length-1,f=o[c];return s&&(s=i(s,u)),f&&(Jr(f)||ei(f)?f=i(f,u):f=Qs(f,l,u)),t(s,n(f,c))}a.rawArgs=!0;function i(o,l){return o.compile().evaluate(l)}return a},{isTransformFunction:!0}),xR="index",wR=["Index","getMatrixDataType"],DR=L(xR,wR,r=>{var{Index:e,getMatrixDataType:t}=r;return function(){for(var a=[],i=0,o=arguments.length;i<o;i++){var l=arguments[i];if(jo(l))l.start--,l.end-=l.step>0?0:2;else if(l&&l.isSet===!0)l=l.map(function(s){return s-1});else if(Ar(l)||Je(l))t(l)!=="boolean"&&(l=l.map(function(s){return s-1}));else if(Ye(l)||Qa(l))l--;else if(or(l))l=l.toNumber()-1;else if(typeof l!="string")throw new TypeError("Dimension must be an Array, Matrix, number, bigint, string, or Range");a[i]=l}var u=new e;return e.apply(u,a),u}},{isTransformFunction:!0}),NR="map",ER=["typed"],AR=L(NR,ER,r=>{var{typed:e}=r,t=im({typed:e}),n=Ks({typed:e});function a(i,o,l){if(i.length===0)return t();if(i.length===1)return t(i[0]);var u=i.length-1,s=i.slice(0,u),c=i[u];return s=s.map(m=>f(m,l)),c&&(Jr(c)||ei(c)?c=f(c,l):c=Qs(c,o,l)),t(...s,n(c,u));function f(m,v){return m.compile().evaluate(v)}}return a.rawArgs=!0,a},{isTransformFunction:!0});function SR(r){return Ye(r)?r-1:or(r)?r.minus(1):r}function CR(r){return Ye(r)||or(r)}function $n(r){if(r.length===2&&Ct(r[0])){r=r.slice();var e=r[1];CR(e)&&(r[1]=SR(e))}return r}var MR="max",_R=["typed","config","numeric","larger","isNaN"],TR=L(MR,_R,r=>{var{typed:e,config:t,numeric:n,larger:a,isNaN:i}=r,o=fv({typed:e,config:t,numeric:n,larger:a,isNaN:i});return e("max",{"...any":function(u){u=$n(u);try{return o.apply(null,u)}catch(s){throw ht(s)}}})},{isTransformFunction:!0}),FR="mean",OR=["typed","add","divide"],BR=L(FR,OR,r=>{var{typed:e,add:t,divide:n}=r,a=$p({typed:e,add:t,divide:n});return e("mean",{"...any":function(o){o=$n(o);try{return a.apply(null,o)}catch(l){throw ht(l)}}})},{isTransformFunction:!0}),RR="min",IR=["typed","config","numeric","smaller","isNaN"],PR=L(RR,IR,r=>{var{typed:e,config:t,numeric:n,smaller:a,isNaN:i}=r,o=vv({typed:e,config:t,numeric:n,smaller:a,isNaN:i});return e("min",{"...any":function(u){u=$n(u);try{return o.apply(null,u)}catch(s){throw ht(s)}}})},{isTransformFunction:!0}),$R="range",qR=["typed","config","?matrix","?bignumber","equal","smaller","smallerEq","larger","largerEq","add","isZero","isPositive"],zR=L($R,qR,r=>{var{typed:e,config:t,matrix:n,bignumber:a,equal:i,smaller:o,smallerEq:l,larger:u,largerEq:s,add:c,isZero:f,isPositive:m}=r,v=cm({typed:e,config:t,matrix:n,bignumber:a,equal:i,smaller:o,smallerEq:l,larger:u,largerEq:s,add:c,isZero:f,isPositive:m});return e("range",{"...any":function(d){var y=d.length-1,x=d[y];return typeof x!="boolean"&&d.push(!0),v.apply(null,d)}})},{isTransformFunction:!0}),UR="row",LR=["typed","Index","matrix","range"],kR=L(UR,LR,r=>{var{typed:e,Index:t,matrix:n,range:a}=r,i=dm({typed:e,Index:t,matrix:n,range:a});return e("row",{"...any":function(l){var u=l.length-1,s=l[u];Ye(s)&&(l[u]=s-1);try{return i.apply(null,l)}catch(c){throw ht(c)}}})},{isTransformFunction:!0}),VR="subset",GR=["typed","matrix","zeros","add"],HR=L(VR,GR,r=>{var{typed:e,matrix:t,zeros:n,add:a}=r,i=bm({typed:e,matrix:t,zeros:n,add:a});return e("subset",{"...any":function(l){try{return i.apply(null,l)}catch(u){throw ht(u)}}})},{isTransformFunction:!0}),WR="concat",YR=["typed","matrix","isInteger"],ZR=L(WR,YR,r=>{var{typed:e,matrix:t,isInteger:n}=r,a=Wf({typed:e,matrix:t,isInteger:n});return e("concat",{"...any":function(o){var l=o.length-1,u=o[l];Ye(u)?o[l]=u-1:or(u)&&(o[l]=u.minus(1));try{return a.apply(null,o)}catch(s){throw ht(s)}}})},{isTransformFunction:!0}),Sd="diff",JR=["typed","matrix","subtract","number","bignumber"],jR=L(Sd,JR,r=>{var{typed:e,matrix:t,subtract:n,number:a,bignumber:i}=r,o=sm({typed:e,matrix:t,subtract:n,number:a,bignumber:i});return e(Sd,{"...any":function(u){u=$n(u);try{return o.apply(null,u)}catch(s){throw ht(s)}}})},{isTransformFunction:!0}),XR="std",QR=["typed","map","sqrt","variance"],KR=L(XR,QR,r=>{var{typed:e,map:t,sqrt:n,variance:a}=r,i=Hp({typed:e,map:t,sqrt:n,variance:a});return e("std",{"...any":function(l){l=$n(l);try{return i.apply(null,l)}catch(u){throw ht(u)}}})},{isTransformFunction:!0}),Cd="sum",e5=["typed","config","add","numeric"],r5=L(Cd,e5,r=>{var{typed:e,config:t,add:n,numeric:a}=r,i=Rp({typed:e,config:t,add:n,numeric:a});return e(Cd,{"...any":function(l){l=$n(l);try{return i.apply(null,l)}catch(u){throw ht(u)}}})},{isTransformFunction:!0}),t5="quantileSeq",n5=["typed","bignumber","add","subtract","divide","multiply","partitionSelect","compare","isInteger","smaller","smallerEq","larger","mapSlices"],a5=L(t5,n5,r=>{var{typed:e,bignumber:t,add:n,subtract:a,divide:i,multiply:o,partitionSelect:l,compare:u,isInteger:s,smaller:c,smallerEq:f,larger:m,mapSlices:v}=r,p=Vp({typed:e,bignumber:t,add:n,subtract:a,divide:i,multiply:o,partitionSelect:l,compare:u,isInteger:s,smaller:c,smallerEq:f,larger:m,mapSlices:v});return e("quantileSeq",{"Array | Matrix, number | BigNumber":p,"Array | Matrix, number | BigNumber, number":(y,x,D)=>p(y,x,d(D)),"Array | Matrix, number | BigNumber, boolean":p,"Array | Matrix, number | BigNumber, boolean, number":(y,x,D,h)=>p(y,x,D,d(h)),"Array | Matrix, Array | Matrix":p,"Array | Matrix, Array | Matrix, number":(y,x,D)=>p(y,x,d(D)),"Array | Matrix, Array | Matrix, boolean":p,"Array | Matrix, Array | Matrix, boolean, number":(y,x,D,h)=>p(y,x,D,d(h))});function d(y){return $n([[],y])[1]}},{isTransformFunction:!0}),Md="cumsum",i5=["typed","add","unaryPlus"],o5=L(Md,i5,r=>{var{typed:e,add:t,unaryPlus:n}=r,a=Ip({typed:e,add:t,unaryPlus:n});return e(Md,{"...any":function(o){if(o.length===2&&Ct(o[0])){var l=o[1];Ye(l)?o[1]=l-1:or(l)&&(o[1]=l.minus(1))}try{return a.apply(null,o)}catch(u){throw ht(u)}}})},{isTransformFunction:!0}),_d="variance",s5=["typed","add","subtract","multiply","divide","mapSlices","isNaN"],u5=L(_d,s5,r=>{var{typed:e,add:t,subtract:n,multiply:a,divide:i,mapSlices:o,isNaN:l}=r,u=Lp({typed:e,add:t,subtract:n,multiply:a,divide:i,mapSlices:o,isNaN:l});return e(_d,{"...any":function(c){c=$n(c);try{return u.apply(null,c)}catch(f){throw ht(f)}}})},{isTransformFunction:!0}),Td="print",l5=["typed","matrix","zeros","add"],c5=L(Td,l5,r=>{var{typed:e,matrix:t,zeros:n,add:a}=r,i=Pm({typed:e,matrix:t,zeros:n,add:a});return e(Td,{"string, Object | Array":function(u,s){return i(o(u),s)},"string, Object | Array, number | Object":function(u,s,c){return i(o(u),s,c)}});function o(l){return l.replace(Rm,u=>{var s=u.slice(1).split("."),c=s.map(function(f){return!isNaN(f)&&f.length>0?parseInt(f)-1:f});return"$"+c.join(".")})}},{isTransformFunction:!0}),f5="and",m5=["typed","matrix","zeros","add","equalScalar","not","concat"],v5=L(f5,m5,r=>{var{typed:e,matrix:t,equalScalar:n,zeros:a,not:i,concat:o}=r,l=nv({typed:e,matrix:t,equalScalar:n,zeros:a,not:i,concat:o});function u(s,c,f){var m=s[0].compile().evaluate(f);if(!Ct(m)&&!l(m,!0))return!1;var v=s[1].compile().evaluate(f);return l(m,v)}return u.rawArgs=!0,u},{isTransformFunction:!0}),p5="or",d5=["typed","matrix","equalScalar","DenseMatrix","concat"],h5=L(p5,d5,r=>{var{typed:e,matrix:t,equalScalar:n,DenseMatrix:a,concat:i}=r,o=Vf({typed:e,matrix:t,equalScalar:n,DenseMatrix:a,concat:i});function l(u,s,c){var f=u[0].compile().evaluate(c);if(!Ct(f)&&o(f,!1))return!0;var m=u[1].compile().evaluate(c);return o(f,m)}return l.rawArgs=!0,l},{isTransformFunction:!0}),g5="nullish",y5=["typed","matrix","size","flatten","deepEqual"],b5=L(g5,y5,r=>{var{typed:e,matrix:t,size:n,flatten:a,deepEqual:i}=r,o=Lf({typed:e,matrix:t,size:n,flatten:a,deepEqual:i});function l(u,s,c){var f=u[0].compile().evaluate(c);if(!Ct(f)&&f!=null&&f!==void 0)return f;var m=u[1].compile().evaluate(c);return o(f,m)}return l.rawArgs=!0,l},{isTransformFunction:!0}),x5="bitAnd",w5=["typed","matrix","zeros","add","equalScalar","not","concat"],D5=L(x5,w5,r=>{var{typed:e,matrix:t,equalScalar:n,zeros:a,not:i,concat:o}=r,l=Tf({typed:e,matrix:t,equalScalar:n,zeros:a,not:i,concat:o});function u(s,c,f){var m=s[0].compile().evaluate(f);if(!Ct(m)){if(isNaN(m))return NaN;if(m===0||m===!1)return 0}var v=s[1].compile().evaluate(f);return l(m,v)}return u.rawArgs=!0,u},{isTransformFunction:!0}),N5="bitOr",E5=["typed","matrix","equalScalar","DenseMatrix","concat"],A5=L(N5,E5,r=>{var{typed:e,matrix:t,equalScalar:n,DenseMatrix:a,concat:i}=r,o=Bf({typed:e,matrix:t,equalScalar:n,DenseMatrix:a,concat:i});function l(u,s,c){var f=u[0].compile().evaluate(c);if(!Ct(f)){if(isNaN(f))return NaN;if(f===-1)return-1;if(f===!0)return 1}var m=u[1].compile().evaluate(c);return o(f,m)}return l.rawArgs=!0,l},{isTransformFunction:!0}),Fd="num",S5=["typed","fraction"],C5=L(Fd,S5,r=>{var{typed:e,fraction:t}=r;return e(Fd,{Fraction:n=>n.s*n.n,BigNumber:n=>{var a=t(n);return a.s*a.n},"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),Od="den",M5=["typed","fraction"],_5=L(Od,M5,r=>{var{typed:e,fraction:t}=r;return e(Od,{Fraction:n=>n.d,BigNumber:n=>t(n).d,"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),Me=Qy({config:ye}),Mr=n1({}),Bd=QB({BigNumber:Me,config:ye}),T5=WB({}),F5=M4({BigNumber:Me,config:ye}),qn=f1({}),Rd=o4({Complex:Mr}),O5=ZB({BigNumber:Me,config:ye}),B5=r4({BigNumber:Me,config:ye}),R5=n4({BigNumber:Me,config:ye}),Io=g1({}),I5=JB({BigNumber:Me,config:ye}),P5=YB({}),$5=KB({BigNumber:Me,config:ye}),q5=p1({}),Id=ty({}),z5=a4({BigNumber:Me,config:ye}),U5=Y4({BigNumber:Me,config:ye}),Pd=XB({BigNumber:Me,config:ye}),L5=HB({}),k5=s4({}),sr=B1({Matrix:Io,config:ye}),V5=$4({BigNumber:Me,config:ye}),G5=e4({BigNumber:Me,config:ye}),eu=jB({BigNumber:Me,config:ye}),$d=VB({}),H5=i4({BigNumber:Me,config:ye}),W=Q0({BigNumber:Me,Complex:Mr,DenseMatrix:sr,Fraction:qn}),W5=P4({BigNumber:Me,config:ye}),gt=Qb({typed:W}),Y5=_E({Complex:Mr,config:ye,typed:W}),Z5=BE({BigNumber:Me,typed:W}),J5=$E({BigNumber:Me,Complex:Mr,config:ye,typed:W}),Wr=tx({typed:W}),j5=Vw({typed:W}),X5=VE({BigNumber:Me,Complex:Mr,config:ye,typed:W}),Q5=ZE({typed:W}),qd=XE({typed:W}),K5=rA({Complex:Mr,config:ye,typed:W}),eI=Nb({typed:W}),rI=Pw({typed:W}),tI=Cb({typed:W}),nI=I1({typed:W}),Po=DO({typed:W}),$o=Bb({Complex:Mr,typed:W}),na=Hw({typed:W}),ru=nA({typed:W}),aI=sA({BigNumber:Me,typed:W}),iI=fA({BigNumber:Me,typed:W}),oI=yx({typed:W}),cr=mb({config:ye,typed:W}),sI=fN({typed:W}),zd=xx({typed:W}),uI=Dx({Complex:Mr,typed:W}),lI=Qf({typed:W}),aa=vD({typed:W}),cI=rm({typed:W}),mi=DN({typed:W}),tu=gD({typed:W}),fI=MN({format:mi,typed:W}),nu=Yw({typed:W}),vi=ib({typed:W}),gn=nb({typed:W}),ia=J1({typed:W}),mI=IN({typed:W}),vI=t4({BigNumber:Me,config:ye}),pI=MO({Complex:Mr,typed:W}),dI=tw({Complex:Mr,config:ye,typed:W}),au=aw({Complex:Mr,config:ye,typed:W}),zn=im({typed:W}),hI=yN({isNaN:gn,isNumeric:ia,typed:W}),qr=sw({typed:W}),qo=Xw({typed:W}),an=xb({typed:W}),gI=SN({format:mi,typed:W}),yI=eB({config:ye,typed:W}),bI=Pm({typed:W}),xI=tB({config:ye,typed:W}),iu=Jw({typed:W}),wI=dA({BigNumber:Me,typed:W}),Ud=vw({BigNumber:Me,Fraction:qn,complex:$o,typed:W}),zo=bA({typed:W}),Yr=UD({typed:W}),Zr=db({Matrix:Io,equalScalar:cr,typed:W}),DI=Wb({typed:W}),NI=yw({typed:W}),EI=Ab({typed:W}),Lt=ax({typed:W}),AI=NA({typed:W}),SI=BN({typed:W}),ou=lb({typed:W}),CI=FE({Complex:Mr,config:ye,typed:W}),MI=zE({BigNumber:Me,typed:W}),_I=LE({BigNumber:Me,Complex:Mr,config:ye,typed:W}),Et=Tb({BigNumber:Me,typed:W}),TI=EO({typed:W}),FI=iA({typed:W}),OI=vA({BigNumber:Me,typed:W}),Uo=eS({addScalar:Wr,conj:na,multiplyScalar:qr,size:Yr,typed:W}),BI=X1({isNumeric:ia,typed:W}),RI=sb({isBounded:vi,map:zn,typed:W}),Un=Y1({config:ye,typed:W}),kt=rb({equalScalar:cr,typed:W}),Ce=qb({DenseMatrix:sr,Matrix:Io,SparseMatrix:Zr,typed:W}),II=Ub({isZero:kt,matrix:Ce,typed:W}),Dr=lw({addScalar:Wr,dot:Uo,equalScalar:cr,matrix:Ce,multiplyScalar:qr,typed:W}),PI=SD({BigNumber:Me,config:ye,matrix:Ce,typed:W}),$I=aB({config:ye,log2:au,typed:W}),qI=BD({config:ye,matrix:Ce}),zI=gA({BigNumber:Me,typed:W}),UI=wA({typed:W}),LI=AE({SparseMatrix:Zr,typed:W}),Xt=hw({Complex:Mr,config:ye,typed:W}),kI=kD({typed:W}),VI=SA({typed:W}),pi=ZD({matrix:Ce,typed:W}),Ld=Dw({BigNumber:Me,config:ye,matrix:Ce,typed:W}),nt=QD({BigNumber:Me,config:ye,matrix:Ce,typed:W}),GI=IE({BigNumber:Me,Complex:Mr,config:ye,typed:W}),HI=HE({Complex:Mr,config:ye,typed:W}),WI=EN({format:mi,typed:W}),YI=lA({BigNumber:Me,typed:W}),su=jD({conj:na,transpose:pi,typed:W}),kd=lD({DenseMatrix:sr,SparseMatrix:Zr,matrix:Ce,typed:W}),yt=T2({DenseMatrix:sr,SparseMatrix:Zr,equalScalar:cr,matrix:Ce,typed:W}),oa=Pb({Fraction:qn,typed:W}),Ln=bD({BigNumber:Me,DenseMatrix:sr,SparseMatrix:Zr,config:ye,matrix:Ce,typed:W}),bt=$1({equal:yt,typed:W}),ZI=wD({matrix:Ce,multiplyScalar:qr,typed:W}),di=xs({isInteger:bt,typed:W}),uu=Gb({flatten:aa,matrix:Ce,size:Yr,typed:W}),JI=C5({fraction:oa,typed:W}),Vd=TD({isInteger:bt,matrix:Ce,typed:W}),Pa=GN({BigNumber:Me,DenseMatrix:sr,config:ye,equalScalar:cr,matrix:Ce,typed:W,zeros:nt}),on=Zb({typed:W}),jI=xO({BigNumber:Me,Fraction:qn,config:ye,isInteger:bt,number:an,typed:W}),Gd=ox({BigNumber:Me,Complex:Mr,Fraction:qn,config:ye,isNegative:Un,matrix:Ce,typed:W,unaryMinus:on}),xr=Wf({isInteger:bt,matrix:Ce,typed:W}),hi=Y2({equal:yt,typed:W}),XI=Mw({concat:xr,equalScalar:cr,matrix:Ce,multiplyScalar:qr,typed:W}),Hd=ff({DenseMatrix:sr,config:ye,equalScalar:cr,matrix:Ce,round:Pa,typed:W,zeros:nt}),QI=Jx({BigNumber:Me,DenseMatrix:sr,concat:xr,config:ye,equalScalar:cr,matrix:Ce,round:Pa,typed:W,zeros:nt}),sa=K1({config:ye,typed:W}),xt=L2({DenseMatrix:sr,SparseMatrix:Zr,bignumber:Et,concat:xr,config:ye,matrix:Ce,typed:W}),KI=Kx({concat:xr,equalScalar:cr,matrix:Ce,typed:W}),e8=v2({DenseMatrix:sr,concat:xr,equalScalar:cr,matrix:Ce,typed:W,zeros:nt}),Wd=pf({DenseMatrix:sr,concat:xr,config:ye,equalScalar:cr,matrix:Ce,round:Pa,typed:W,zeros:nt}),r8=fw({BigNumber:Me,concat:xr,equalScalar:cr,matrix:Ce,typed:W}),t8=Lf({deepEqual:hi,flatten:aa,matrix:Ce,size:Yr,typed:W}),Vt=qN({bignumber:Et,fraction:oa,number:an}),Yd=xN({config:ye,multiplyScalar:qr,numeric:Vt,typed:W}),n8=d2({DenseMatrix:sr,concat:xr,equalScalar:cr,matrix:Ce,typed:W,zeros:nt}),wt=I2({DenseMatrix:sr,SparseMatrix:Zr,bignumber:Et,concat:xr,config:ye,matrix:Ce,typed:W}),Lr=xw({DenseMatrix:sr,concat:xr,equalScalar:cr,matrix:Ce,subtractScalar:Lt,typed:W,unaryMinus:on}),a8=FN({concat:xr,matrix:Ce,typed:W}),lu=jb({config:ye,numeric:Vt,typed:W}),i8=rD({DenseMatrix:sr,SparseMatrix:Zr,concat:xr,matrix:Ce,typed:W}),dr=ZA({DenseMatrix:sr,SparseMatrix:Zr,addScalar:Wr,concat:xr,equalScalar:cr,matrix:Ce,typed:W}),o8=KE({BigNumber:Me,DenseMatrix:sr,concat:xr,equalScalar:cr,matrix:Ce,typed:W}),s8=Tf({concat:xr,equalScalar:cr,matrix:Ce,typed:W}),u8=Bf({DenseMatrix:sr,concat:xr,equalScalar:cr,matrix:Ce,typed:W}),l8=Lw({DenseMatrix:sr,SparseMatrix:Zr,concat:xr,matrix:Ce,typed:W}),cu=hx({DenseMatrix:sr,config:ye,equalScalar:cr,matrix:Ce,round:Pa,typed:W,zeros:nt}),ua=x2({BigNumber:Me,DenseMatrix:sr,Fraction:qn,concat:xr,config:ye,equalScalar:cr,matrix:Ce,typed:W}),Zd=M2({concat:xr,matrix:Ce,typed:W}),c8=mB({addScalar:Wr,combinations:Po,isInteger:bt,isNegative:Un,isPositive:sa,larger:xt,typed:W}),f8=iD({prod:Yd,size:Yr,typed:W}),m8=sD({matrix:Ce,multiply:Dr,subtract:Lr,typed:W}),v8=sm({matrix:Ce,number:an,subtract:Lr,typed:W}),Ir=UN({numeric:Vt,typed:W}),p8=B2({compareText:Zd,isZero:kt,typed:W}),Jd=fE({larger:xt,smaller:wt}),jd=Ax({Complex:Mr,DenseMatrix:sr,ceil:cu,equalScalar:cr,floor:Hd,matrix:Ce,typed:W,zeros:nt}),d8=jA({abs:gt,addScalar:Wr,divideScalar:Ir,isPositive:sa,multiplyScalar:qr,smaller:wt,sqrt:Xt,typed:W}),Xd=iE({DenseMatrix:sr,smaller:wt}),ct=uE({ImmutableDenseMatrix:Xd,getMatrixDataType:tu}),h8=oO({abs:gt,add:dr,addScalar:Wr,config:ye,divideScalar:Ir,equalScalar:cr,flatten:aa,isNumeric:ia,isZero:kt,matrix:Ce,multiply:Dr,multiplyScalar:qr,smaller:wt,subtract:Lr,typed:W}),g8=Ew({BigNumber:Me,add:dr,config:ye,equal:yt,isInteger:bt,mod:Wd,smaller:wt,typed:W,xgcd:Ld}),Lo=G2({DenseMatrix:sr,SparseMatrix:Zr,concat:xr,config:ye,matrix:Ce,typed:W}),fu=YN({Complex:Mr,config:ye,divideScalar:Ir,typeOf:ou,typed:W}),Qd=n2({DenseMatrix:sr,divideScalar:Ir,equalScalar:cr,matrix:Ce,multiplyScalar:qr,subtractScalar:Lt,typed:W}),y8=kb({flatten:aa,matrix:Ce,size:Yr,typed:W}),b8=vv({config:ye,isNaN:gn,numeric:Vt,smaller:wt,typed:W}),x8=XN({Complex:Mr,config:ye,divideScalar:Ir,typed:W}),ko=Q2({compare:ua,isNaN:gn,isNumeric:ia,typed:W}),mu=lC({addScalar:Wr,complex:$o,conj:na,divideScalar:Ir,equal:yt,identity:Ln,isZero:kt,matrix:Ce,multiplyScalar:qr,sign:Ud,sqrt:Xt,subtractScalar:Lt,typed:W,unaryMinus:on,zeros:nt}),w8=g2({DenseMatrix:sr,concat:xr,equalScalar:cr,matrix:Ce,typed:W,zeros:nt}),Kd=BC({SparseMatrix:Zr,abs:gt,add:dr,divideScalar:Ir,larger:xt,largerEq:Lo,multiply:Dr,subtract:Lr,transpose:pi,typed:W}),eh=pE({FibonacciHeap:Jd,addScalar:Wr,equalScalar:cr}),_t=bm({add:dr,matrix:Ce,typed:W,zeros:nt}),vu=Rp({add:dr,config:ye,numeric:Vt,typed:W}),D8=nS({add:dr,matrix:Ce,typed:W}),pu=i2({DenseMatrix:sr,divideScalar:Ir,equalScalar:cr,matrix:Ce,multiplyScalar:qr,subtractScalar:Lt,typed:W}),N8=IB({Complex:Mr,add:dr,multiply:Dr,number:an,typed:W}),E8=cB({addScalar:Wr,combinations:Po,divideScalar:Ir,isInteger:bt,isNegative:Un,multiplyScalar:qr,typed:W}),sn=A2({compare:ua,typed:W}),A8=Ip({add:dr,typed:W,unaryPlus:lu}),rh=B3({divideScalar:Ir,isZero:kt,matrix:Ce,multiply:Dr,subtractScalar:Lt,typed:W,unaryMinus:on}),gi=r2({DenseMatrix:sr,SparseMatrix:Zr,concat:xr,divideScalar:Ir,equalScalar:cr,matrix:Ce,typed:W}),th=iS({Index:ct,typed:W}),la=I3({abs:gt,addScalar:Wr,det:rh,divideScalar:Ir,identity:Ln,matrix:Ce,multiply:Dr,typed:W,unaryMinus:on}),S8=JN({Complex:Mr,config:ye,divideScalar:Ir,log:fu,typed:W}),C8=s2({DenseMatrix:sr,divideScalar:Ir,equalScalar:cr,matrix:Ce,multiplyScalar:qr,subtractScalar:Lt,typed:W}),du=fv({config:ye,isNaN:gn,larger:xt,numeric:Vt,typed:W}),M8=Vf({DenseMatrix:sr,concat:xr,equalScalar:cr,matrix:Ce,typed:W}),_8=$3({Complex:Mr,add:dr,ctranspose:su,deepEqual:hi,divideScalar:Ir,dot:Uo,dotDivide:gi,equal:yt,inv:la,matrix:Ce,multiply:Dr,typed:W}),Qt=kN({Complex:Mr,config:ye,fraction:oa,identity:Ln,inv:la,matrix:Ce,multiply:Dr,number:an,typed:W}),T8=MA({DenseMatrix:sr,Index:ct,compareNatural:sn,size:Yr,subset:_t,typed:W}),F8=OA({DenseMatrix:sr,Index:ct,compareNatural:sn,size:Yr,subset:_t,typed:W}),O8=PA({Index:ct,compareNatural:sn,size:Yr,subset:_t,typed:W}),B8=UA({Index:ct,compareNatural:sn,size:Yr,subset:_t,typed:W}),$a=q2({DenseMatrix:sr,SparseMatrix:Zr,concat:xr,config:ye,matrix:Ce,typed:W}),R8=eE({compare:ua,compareNatural:sn,matrix:Ce,typed:W}),I8=W3({abs:gt,add:dr,identity:Ln,inv:la,map:zn,max:du,multiply:Dr,size:Yr,sqrt:Xt,subtract:Lr,typed:W}),P8=J2({DenseMatrix:sr,SparseMatrix:Zr,concat:xr,config:ye,equalScalar:cr,matrix:Ce,typed:W}),nh=l2({DenseMatrix:sr,divideScalar:Ir,equalScalar:cr,matrix:Ce,multiplyScalar:qr,subtractScalar:Lt,typed:W}),$8=nv({concat:xr,equalScalar:cr,matrix:Ce,not:qo,typed:W,zeros:nt}),q8=_5({fraction:oa,typed:W}),z8=nO({abs:gt,addScalar:Wr,deepEqual:hi,divideScalar:Ir,multiplyScalar:qr,sqrt:Xt,subtractScalar:Lt,typed:W}),U8=KN({DenseMatrix:sr,SparseMatrix:Zr,concat:xr,equalScalar:cr,matrix:Ce,pow:Qt,typed:W}),L8=G3({abs:gt,add:dr,identity:Ln,inv:la,multiply:Dr,typed:W}),ah=eN({addScalar:Wr,ceil:cu,conj:na,divideScalar:Ir,dotDivide:gi,exp:zd,i:Rd,log2:au,matrix:Ce,multiplyScalar:qr,pow:Qt,tau:Pd,typed:W}),hu=SO({BigNumber:Me,Complex:Mr,config:ye,multiplyScalar:qr,pow:Qt,typed:W}),k8=tN({conj:na,dotDivide:gi,fft:ah,typed:W}),ih=sC({DenseMatrix:sr,Spa:eh,SparseMatrix:Zr,abs:gt,addScalar:Wr,divideScalar:Ir,equalScalar:cr,larger:xt,matrix:Ce,multiplyScalar:qr,subtractScalar:Lt,typed:W,unaryMinus:on}),qa=cm({bignumber:Et,matrix:Ce,add:dr,config:ye,equal:yt,isPositive:sa,isZero:kt,larger:xt,largerEq:Lo,smaller:wt,smallerEq:$a,typed:W}),V8=dm({Index:ct,matrix:Ce,range:qa,typed:W}),oh=TA({DenseMatrix:sr,Index:ct,compareNatural:sn,size:Yr,subset:_t,typed:W}),G8=qA({Index:ct,compareNatural:sn,size:Yr,subset:_t,typed:W}),sh=GA({Index:ct,concat:xr,setDifference:oh,size:Yr,subset:_t,typed:W}),Qe=wE({BigNumber:Me,Complex:Mr,Fraction:qn,abs:gt,addScalar:Wr,config:ye,divideScalar:Ir,equal:yt,fix:jd,format:mi,isNumeric:ia,multiplyScalar:qr,number:an,pow:Qt,round:Pa,subtractScalar:Lt}),H8=p4({BigNumber:Me,Unit:Qe,config:ye}),W8=j4({BigNumber:Me,Unit:Qe,config:ye}),Y8=q4({BigNumber:Me,Unit:Qe,config:ye}),Z8=y4({BigNumber:Me,Unit:Qe,config:ye}),J8=U4({BigNumber:Me,Unit:Qe,config:ye}),uh=Zf({Index:ct,matrix:Ce,range:qa,typed:W}),j8=b4({BigNumber:Me,Unit:Qe,config:ye}),X8=d4({BigNumber:Me,Unit:Qe,config:ye}),Q8=CE({Unit:Qe,typed:W}),K8=F4({BigNumber:Me,Unit:Qe,config:ye}),lh=k3({abs:gt,add:dr,addScalar:Wr,atan:qd,bignumber:Et,column:uh,complex:$o,config:ye,cos:ru,diag:kd,divideScalar:Ir,dot:Uo,equal:yt,flatten:aa,im:nu,inv:la,larger:xt,matrix:Ce,matrixFromColumns:uu,multiply:Dr,multiplyScalar:qr,number:an,qr:mu,re:iu,reshape:Vd,sin:zo,size:Yr,smaller:wt,sqrt:Xt,subtract:Lr,typed:W,usolve:pu,usolveAll:nh}),eP=S4({BigNumber:Me,Unit:Qe,config:ye}),yi=TO({gamma:hu,typed:W}),rP=C4({BigNumber:Me,Unit:Qe,config:ye}),tP=G4({BigNumber:Me,Unit:Qe,config:ye}),nP=K4({BigNumber:Me,Unit:Qe,config:ye}),aP=N4({BigNumber:Me,Unit:Qe,config:ye}),iP=V4({BigNumber:Me,Unit:Qe,config:ye}),oP=m4({BigNumber:Me,Unit:Qe,config:ye}),sP=X4({BigNumber:Me,Unit:Qe,config:ye}),uP=H4({BigNumber:Me,Unit:Qe,config:ye}),lP=O4({BigNumber:Me,Unit:Qe,config:ye}),cP=D4({BigNumber:Me,Unit:Qe,config:ye}),fP=PO({factorial:yi,typed:W}),mP=c4({BigNumber:Me,Unit:Qe,config:ye}),vP=rR({BigNumber:Me,Unit:Qe,config:ye}),pP=tR({BigNumber:Me,Unit:Qe,config:ye}),dP=T4({BigNumber:Me,Unit:Qe,config:ye}),hP=B4({BigNumber:Me,Unit:Qe,config:ye}),gP=f4({BigNumber:Me,Unit:Qe,config:ye}),yP=Z4({BigNumber:Me,Unit:Qe,config:ye}),bP=kA({compareNatural:sn,typed:W}),xP=u4({BigNumber:Me,Unit:Qe,config:ye}),wP=J4({BigNumber:Me,Unit:Qe,config:ye}),DP=I4({BigNumber:Me,Unit:Qe,config:ye}),NP=z4({BigNumber:Me,Unit:Qe,config:ye}),EP=E4({BigNumber:Me,Unit:Qe,config:ye}),AP=h4({BigNumber:Me,Unit:Qe,config:ye}),at=rO({divideScalar:Ir,equalScalar:cr,inv:la,matrix:Ce,multiply:Dr,typed:W}),SP=g4({BigNumber:Me,Unit:Qe,config:ye}),CP=L4({BigNumber:Me,Unit:Qe,config:ye}),MP=$B({Complex:Mr,add:dr,divide:at,matrix:Ce,multiply:Dr,typed:W}),_P=l4({BigNumber:Me,Unit:Qe,config:ye}),TP=x4({BigNumber:Me,Unit:Qe,config:ye}),ch=IC({DenseMatrix:sr,lsolve:Qd,lup:ih,matrix:Ce,slu:Kd,typed:W,usolve:pu}),FP=w4({BigNumber:Me,Unit:Qe,config:ye}),OP=Q4({BigNumber:Me,Unit:Qe,config:ye}),BP=RO({add:dr,divide:at,factorial:yi,isInteger:bt,isPositive:sa,multiply:Dr,typed:W}),RP=nR({BigNumber:Me,Unit:Qe,config:ye}),IP=aR({BigNumber:Me,Unit:Qe,config:ye}),PP=Vp({bignumber:Et,add:dr,compare:ua,divide:at,isInteger:bt,larger:xt,mapSlices:di,multiply:Dr,partitionSelect:ko,smaller:wt,smallerEq:$a,subtract:Lr,typed:W}),$P=R4({BigNumber:Me,Unit:Qe,config:ye}),fh=RA({DenseMatrix:sr,Index:ct,compareNatural:sn,size:Yr,subset:_t,typed:W}),qP=uN({abs:gt,add:dr,bignumber:Et,divide:at,isNegative:Un,isPositive:sa,larger:xt,map:zn,matrix:Ce,max:du,multiply:Dr,smaller:wt,subtract:Lr,typed:W,unaryMinus:on}),mh=oB({bignumber:Et,addScalar:Wr,combinations:Po,divideScalar:Ir,factorial:yi,isInteger:bt,isNegative:Un,larger:xt,multiplyScalar:qr,number:an,pow:Qt,subtractScalar:Lt,typed:W}),zP=NE({Unit:Qe,typed:W}),UP=uB({addScalar:Wr,isInteger:bt,isNegative:Un,stirlingS2:mh,typed:W}),LP=v4({BigNumber:Me,Unit:Qe,config:ye}),kP=k4({BigNumber:Me,Unit:Qe,config:ye}),VP=_4({BigNumber:Me,Unit:Qe,config:ye}),GP=OO({divide:at,dotDivide:gi,isNumeric:ia,log:fu,map:zn,matrix:Ce,multiply:Dr,sum:vu,typed:W}),vh=$p({add:dr,divide:at,typed:W}),HP=W4({BigNumber:Me,Unit:Qe,config:ye}),WP=eR({BigNumber:Me,Unit:Qe,config:ye}),YP=WA({Index:ct,concat:xr,setIntersect:fh,setSymDifference:sh,size:Yr,subset:_t,typed:W}),gu=Lp({add:dr,divide:at,isNaN:gn,mapSlices:di,multiply:Dr,subtract:Lr,typed:W}),ZP=A4({BigNumber:Me,Unit:Qe,config:ye}),JP=yO({add:dr,divide:at,matrix:Ce,mean:vh,multiply:Dr,pow:Qt,sqrt:Xt,subtract:Lr,sum:vu,typed:W}),ph=fO({add:dr,compare:ua,divide:at,partitionSelect:ko,typed:W}),jP=$C({add:dr,cbrt:Gd,divide:at,equalScalar:cr,im:nu,isZero:kt,multiply:Dr,re:iu,sqrt:Xt,subtract:Lr,typeOf:ou,typed:W,unaryMinus:on}),XP=Hp({map:zn,sqrt:Xt,typed:W,variance:gu}),QP=hN({BigNumber:Me,Complex:Mr,add:dr,config:ye,divide:at,equal:yt,factorial:yi,gamma:hu,isBounded:vi,isNegative:Un,multiply:Dr,pi:eu,pow:Qt,sin:zo,smallerEq:$a,subtract:Lr,typed:W}),KP=vO({abs:gt,map:zn,median:ph,subtract:Lr,typed:W}),yu=QA({abs:gt,add:dr,conj:na,ctranspose:su,eigs:lh,equalScalar:cr,larger:xt,matrix:Ce,multiply:Dr,pow:Qt,smaller:wt,sqrt:Xt,typed:W}),dh=$D({BigNumber:Me,DenseMatrix:sr,SparseMatrix:Zr,addScalar:Wr,config:ye,cos:ru,matrix:Ce,multiplyScalar:qr,norm:yu,sin:zo,typed:W,unaryMinus:on}),e6=ID({multiply:Dr,rotationMatrix:dh,typed:W}),hh=j3({identity:Ln,matrix:Ce,multiply:Dr,norm:yu,qr:mu,subtract:Lr,typed:W}),gh=Z3({abs:gt,add:dr,concat:xr,identity:Ln,index:th,lusolve:ch,matrix:Ce,matrixFromColumns:uu,multiply:Dr,range:qa,schur:hh,subset:_t,subtract:Lr,transpose:pi,typed:W}),r6=Q3({matrix:Ce,multiply:Dr,sylvester:gh,transpose:pi,typed:W}),za={},bi={},yh={},ft=uS({mathWithTransform:bi}),Ua=RS({Node:ft}),yn=PS({Node:ft}),ca=qS({Node:ft}),bh=kS({Node:ft}),La=mS({Node:ft}),xh=yS({Node:ft,ResultSet:Id}),wh=xS({Node:ft}),Dh=US({Node:ft}),t6=UB({classes:yh}),bu=VC({math:za,typed:W}),Nh=TS({Node:ft,typed:W}),n6=F3({Chain:bu,typed:W}),kn=MS({Node:ft,isBounded:vi}),ka=OS({Node:ft,size:Yr}),Va=cS({Node:ft,subset:_t}),Eh=hS({matrix:Ce,Node:ft,subset:_t}),Vn=HS({Unit:Qe,Node:ft,math:za}),Gn=YS({Node:ft,SymbolNode:Vn,math:za}),Kt=JS({AccessorNode:Va,ArrayNode:La,AssignmentNode:Eh,BlockNode:xh,ConditionalNode:wh,ConstantNode:kn,FunctionAssignmentNode:Nh,FunctionNode:Gn,IndexNode:ka,ObjectNode:Ua,OperatorNode:yn,ParenthesisNode:ca,RangeNode:Dh,RelationalNode:bh,SymbolNode:Vn,config:ye,numeric:Vt,typed:W}),Ah=CB({ConstantNode:kn,FunctionNode:Gn,OperatorNode:yn,ParenthesisNode:ca,parse:Kt,typed:W}),xu=DB({bignumber:Et,fraction:oa,AccessorNode:Va,ArrayNode:La,ConstantNode:kn,FunctionNode:Gn,IndexNode:ka,ObjectNode:Ua,OperatorNode:yn,SymbolNode:Vn,config:ye,isBounded:vi,mathWithTransform:bi,matrix:Ce,typed:W}),a6=XS({parse:Kt,typed:W}),Vo=KS({parse:Kt,typed:W}),Sh=UC({evaluate:Vo}),Ch=tC({evaluate:Vo,parse:Kt}),wu=EB({AccessorNode:Va,ArrayNode:La,ConstantNode:kn,FunctionNode:Gn,IndexNode:ka,ObjectNode:Ua,OperatorNode:yn,ParenthesisNode:ca,SymbolNode:Vn,add:dr,divide:at,equal:yt,isZero:kt,multiply:Dr,parse:Kt,pow:Qt,subtract:Lr,typed:W}),i6=_3({Help:Sh,mathWithTransform:bi,typed:W}),Go=bB({AccessorNode:Va,ArrayNode:La,ConstantNode:kn,FunctionNode:Gn,IndexNode:ka,ObjectNode:Ua,OperatorNode:yn,ParenthesisNode:ca,SymbolNode:Vn,equal:yt,parse:Kt,replacer:$d,resolve:Ah,simplifyConstant:xu,simplifyCore:wu,typed:W}),o6=_B({OperatorNode:yn,parse:Kt,simplify:Go,typed:W}),s6=FB({ConstantNode:kn,FunctionNode:Gn,OperatorNode:yn,ParenthesisNode:ca,SymbolNode:Vn,config:ye,equal:yt,isZero:kt,numeric:Vt,parse:Kt,simplify:Go,typed:W}),u6=iC({Parser:Ch,typed:W}),l6=pB({parse:Kt,typed:W}),c6=BB({bignumber:Et,fraction:oa,AccessorNode:Va,ArrayNode:La,ConstantNode:kn,FunctionNode:Gn,IndexNode:ka,ObjectNode:Ua,OperatorNode:yn,ParenthesisNode:ca,SymbolNode:Vn,add:dr,config:ye,divide:at,equal:yt,isZero:kt,mathWithTransform:bi,matrix:Ce,multiply:Dr,parse:Kt,pow:Qt,simplify:Go,simplifyConstant:xu,simplifyCore:wu,subtract:Lr,typed:W});zr(za,{e:Bd,false:T5,fineStructure:F5,i:Rd,Infinity:O5,LN10:B5,LOG10E:R5,NaN:I5,null:P5,phi:$5,SQRT1_2:z5,sackurTetrode:U5,tau:Pd,true:L5,E:Bd,version:k5,efimovFactor:V5,LN2:G5,pi:eu,replacer:$d,reviver:t6,SQRT2:H5,typed:W,PI:eu,weakMixingAngle:W5,abs:gt,acos:Y5,acot:Z5,acsc:J5,addScalar:Wr,arg:j5,asech:X5,asinh:Q5,atan:qd,atanh:K5,bigint:eI,bitNot:rI,boolean:tI,clone:nI,combinations:Po,complex:$o,conj:na,cos:ru,cot:aI,csc:iI,cube:oI,equalScalar:cr,erf:sI,exp:zd,expm1:uI,filter:lI,flatten:aa,forEach:cI,format:mi,getMatrixDataType:tu,hex:fI,im:nu,isBounded:vi,isNaN:gn,isNumeric:ia,isPrime:mI,LOG2E:vI,lgamma:pI,log10:dI,log2:au,map:zn,mode:hI,multiplyScalar:qr,not:qo,number:an,oct:gI,pickRandom:yI,print:bI,random:xI,re:iu,sec:wI,sign:Ud,sin:zo,size:Yr,splitUnit:DI,square:NI,string:EI,subtractScalar:Lt,tan:AI,toBest:SI,typeOf:ou,acosh:CI,acsch:MI,asec:_I,bignumber:Et,chain:n6,combinationsWithRep:TI,cosh:FI,csch:OI,dot:Uo,hasNumericValue:BI,isFinite:RI,isNegative:Un,isZero:kt,matrix:Ce,matrixFromFunction:II,multiply:Dr,ones:PI,randomInt:$I,resize:qI,sech:zI,sinh:UI,sparse:LI,sqrt:Xt,squeeze:kI,tanh:VI,transpose:pi,xgcd:Ld,zeros:nt,acoth:GI,asin:HI,bin:WI,coth:YI,ctranspose:su,diag:kd,equal:yt,fraction:oa,identity:Ln,isInteger:bt,kron:ZI,mapSlices:di,matrixFromColumns:uu,num:JI,reshape:Vd,round:Pa,unaryMinus:on,bernoulli:jI,cbrt:Gd,concat:xr,deepEqual:hi,dotMultiply:XI,floor:Hd,gcd:QI,isPositive:sa,larger:xt,lcm:KI,leftShift:e8,mod:Wd,nthRoot:r8,nullish:t8,numeric:Vt,prod:Yd,rightArithShift:n8,smaller:wt,subtract:Lr,to:a8,unaryPlus:lu,xor:i8,add:dr,atan2:o8,bitAnd:s8,bitOr:u8,bitXor:l8,ceil:cu,compare:ua,compareText:Zd,composition:c8,count:f8,cross:m8,diff:v8,divideScalar:Ir,equalText:p8,fix:jd,hypot:d8,intersect:h8,invmod:g8,largerEq:Lo,log:fu,lsolve:Qd,matrixFromRows:y8,min:b8,nthRoots:x8,partitionSelect:ko,qr:mu,rightLogShift:w8,slu:Kd,subset:_t,sum:vu,trace:D8,usolve:pu,zpk2tf:N8,catalan:E8,compareNatural:sn,cumsum:A8,det:rh,dotDivide:gi,index:th,inv:la,log1p:S8,lsolveAll:C8,max:du,or:M8,pinv:_8,pow:Qt,setCartesian:T8,setDistinct:F8,setIsSubset:O8,setPowerset:B8,smallerEq:$a,sort:R8,sqrtm:I8,unequal:P8,usolveAll:nh,and:$8,den:q8,distance:z8,dotPow:U8,expm:L8,fft:ah,gamma:hu,ifft:k8,lup:ih,range:qa,row:V8,setDifference:oh,setMultiplicity:G8,setSymDifference:sh,vacuumImpedance:H8,wienDisplacement:W8,atomicMass:Y8,bohrMagneton:Z8,boltzmann:J8,column:uh,conductanceQuantum:j8,coulomb:X8,createUnit:Q8,deuteronMass:K8,eigs:lh,electronMass:eP,factorial:yi,fermiCoupling:rP,gasConstant:tP,gravity:nP,klitzing:aP,loschmidt:iP,magneticConstant:oP,molarMass:sP,molarPlanckConstant:uP,neutronMass:lP,nuclearMagneton:cP,permutations:fP,planckConstant:mP,planckMass:vP,planckTime:pP,protonMass:dP,quantumOfCirculation:hP,reducedPlanckConstant:gP,secondRadiation:yP,setSize:bP,speedOfLight:xP,stefanBoltzmann:wP,thomsonCrossSection:DP,avogadro:NP,bohrRadius:EP,coulombConstant:AP,divide:at,elementaryCharge:SP,faraday:CP,freqz:MP,gravitationConstant:_P,inverseConductanceQuantum:TP,lusolve:ch,magneticFluxQuantum:FP,molarMassC12:OP,multinomial:BP,planckCharge:RP,planckTemperature:IP,quantileSeq:PP,rydberg:$P,setIntersect:fh,solveODE:qP,stirlingS2:mh,unit:zP,bellNumbers:UP,electricConstant:LP,firstRadiation:kP,hartreeEnergy:VP,kldivergence:GP,mean:vh,molarVolume:HP,planckLength:WP,setUnion:YP,variance:gu,classicalElectronRadius:ZP,corr:JP,median:ph,parse:Kt,polynomialRoot:jP,resolve:Ah,simplifyConstant:xu,std:XP,zeta:QP,compile:a6,evaluate:Vo,mad:KP,simplifyCore:wu,help:i6,norm:yu,rotationMatrix:dh,simplify:Go,symbolicEqual:o6,derivative:s6,parser:u6,rotate:e6,leafCount:l6,rationalize:c6,schur:hh,sylvester:gh,lyap:r6,config:ye}),zr(bi,za,{map:AR({typed:W}),filter:hR({typed:W}),forEach:bR({typed:W}),mapSlices:uR({isInteger:bt,typed:W}),or:h5({DenseMatrix:sr,concat:xr,equalScalar:cr,matrix:Ce,typed:W}),and:v5({add:dr,concat:xr,equalScalar:cr,matrix:Ce,not:qo,typed:W,zeros:nt}),cumsum:o5({add:dr,typed:W,unaryPlus:lu}),max:TR({config:ye,isNaN:gn,larger:xt,numeric:Vt,typed:W}),nullish:b5({deepEqual:hi,flatten:aa,matrix:Ce,size:Yr,typed:W}),print:c5({add:dr,matrix:Ce,typed:W,zeros:nt}),bitAnd:D5({add:dr,concat:xr,equalScalar:cr,matrix:Ce,not:qo,typed:W,zeros:nt}),concat:ZR({isInteger:bt,matrix:Ce,typed:W}),diff:jR({bignumber:Et,matrix:Ce,number:an,subtract:Lr,typed:W}),min:PR({config:ye,isNaN:gn,numeric:Vt,smaller:wt,typed:W}),subset:HR({add:dr,matrix:Ce,typed:W,zeros:nt}),bitOr:A5({DenseMatrix:sr,concat:xr,equalScalar:cr,matrix:Ce,typed:W}),sum:r5({add:dr,config:ye,numeric:Vt,typed:W}),index:DR({Index:ct,getMatrixDataType:tu}),row:kR({Index:ct,matrix:Ce,range:qa,typed:W}),column:fR({Index:ct,matrix:Ce,range:qa,typed:W}),mean:BR({add:dr,divide:at,typed:W}),range:zR({bignumber:Et,matrix:Ce,add:dr,config:ye,equal:yt,isPositive:sa,isZero:kt,larger:xt,largerEq:Lo,smaller:wt,smallerEq:$a,typed:W}),variance:u5({add:dr,divide:at,isNaN:gn,mapSlices:di,multiply:Dr,subtract:Lr,typed:W}),quantileSeq:a5({add:dr,bignumber:Et,compare:ua,divide:at,isInteger:bt,larger:xt,mapSlices:di,multiply:Dr,partitionSelect:ko,smaller:wt,smallerEq:$a,subtract:Lr,typed:W}),std:KR({map:zn,sqrt:Xt,typed:W,variance:gu})}),zr(yh,{BigNumber:Me,Complex:Mr,Fraction:qn,Matrix:Io,Node:ft,ObjectNode:Ua,OperatorNode:yn,ParenthesisNode:ca,Range:q5,RelationalNode:bh,ResultSet:Id,ArrayNode:La,BlockNode:xh,ConditionalNode:wh,DenseMatrix:sr,RangeNode:Dh,Chain:bu,FunctionAssignmentNode:Nh,SparseMatrix:Zr,ConstantNode:kn,IndexNode:ka,FibonacciHeap:Jd,ImmutableDenseMatrix:Xd,Index:ct,Spa:eh,AccessorNode:Va,AssignmentNode:Eh,Unit:Qe,SymbolNode:Vn,FunctionNode:Gn,Help:Sh,Parser:Ch}),bu.createProxy(za);const it=class it{constructor(){}static GetExpressions(e,t){let n=[];for(var a=0,i="";e.length>0;){if(!this.HasFunctionInside(e)&&e.indexOf(",")==-1){n.push(new vt(e));break}if(e.substring(a,a+1)=="("){var o=this.FindEnd(e);if(o==-1)throw"Unbalanced brackets!!!! Expression:"+e;i!=""&&(n.push(new Hn(i)),i=""),n.push(new vt(e.substring(0,o+1))),o<e.length?e=e.substring(o+1):e="";continue}if(e.startsWith("N.%")){i!=""&&(n.push(new Hn(i)),i="");var l=e.substring(3).indexOf("%")+1;n.push(new wn(e.substring(2,l+3),!0)),e=e.substring(l+3);continue}if(e.substring(0,1)=="%"){i!=""&&(n.push(new Hn(i)),i="");var l=e.substring(1).indexOf("%")+1;n.push(new wn(e.substring(0,l+1),!1)),e=e.substring(l+1);continue}if(e.substring(a,a+1)==","){i!=""&&(n.push(new vt(i)),i=""),n.push(new At(e.substring(0,1),"")),1<e.length?e=e.substring(1):e="";continue}var u=!1;if(We.operators.forEach(m=>{if(e.startsWith(m)){i!=""&&(n.push(new vt(i)),i=""),n.push(new Ei(e.substring(0,m.length))),e=e.substring(m.length),u=!0;return}}),u)continue;for(let m=0;m<We.logicaloperators.length;m++){let v=We.logicaloperators[m];if(e.startsWith(v)){i!=""&&(n.push(new vt(i)),i=""),n.push(new Yo(e.substring(0,v.length))),e=e.substring(v.length),u=!0;break}}if(u)continue;var s=!1;let f=e.toLowerCase();var c=Object.keys(it._suportedFunctions);for(let m=0;m<c.length;m++){let v=c[m];if(f.startsWith(v)){i!=""&&(n.push(new vt(i)),i="");var o=this.FindEnd(e);if(o==-1)throw"Unbalanced brackets!!!! Expression:"+e;let d=Reflect.construct(it._suportedFunctions[v],[e.substring(0,o+1),v]);n.push(d),o<e.length?e=e.substring(o+1):e="",s=!0;break}}s||(i+=e.substring(0,1),e=e.substring(1))}return i!=""&&(n.push(new vt(i)),i=""),n}static HasFunctionInside(e){if(e==null||e=="")return!1;var t=!1;const n=e.toLowerCase();return Object.keys(it._suportedFunctions).forEach(a=>{if(n.indexOf(a)!=-1){t=!0;return}}),t}static StartsWithFunction(e){const t=e.toLowerCase();var n=!1;return Object.keys(it._suportedFunctions).forEach(a=>{if(t.startsWith(a)){n=!0;return}}),n}static FindEnd(e){for(var t=0,n=0,a=0;a<e.length;a++)if(e.substring(a,a+1)=="("?n++:e.substring(a,a+1)==")"&&t++,n>0&&n==t)return a;return-1}static ConcatValues(e,t,n,a,i){if(e==null)return null;if(e.length==1)return e[0].Evaluate(t,n,a,i);let o="";for(let l=0;l<e.length;l++){let u=e[l].Evaluate(t,n,a,i);typeof u=="number"?o+=u.toString():u instanceof Date?o+=u.toISOString():o+=u}return o}static CastToTypeNet(e,t){let n=null;if(t==null)return null;switch(e.TypeNET){case"decimal":{n=parseFloat(t);break}case"int":{n=parseInt(t);break}case"bool":{this.toString().toLowerCase()=="true"||this.toString().toLowerCase()=="false"||(n=t);break}default:{n=t;break}}return n}static ParseAndFillExpression(e,t,n,a,i,o,l){if(n==null)return null;var u=it.ParseExpressionAndReturnValue(e,n,t,a,0);if(console.log(t.FieldName+" "+e+" "+u),u!=null)if(t.Type=="decimal"||t.Type=="int")try{if(u=="0/0")return a.Record[t.FieldName]=0,0;if(u=="*(-1)")return null;const c=Vo(u);return console.log(t.FieldName+" "+e+" RET: "+u+" EVAL:"+c),c}catch{if(l)return console.log(t.FieldName+" "+e+" Err: 0"),0;var s=it.CastToTypeNet(t,u);return console.log(t.FieldName+" "+e+" Err: "+s),s}else{var s=it.CastToTypeNet(t,u);return console.log(t.FieldName+" "+e+" Ret: "+s),s}else return console.log(t.FieldName+" "+e+" Value: "+u),u}static ParseExpressionAndReturnValue(e,t,n,a,i){var s;if(e==null||t==null)return null;let o=null;try{o=it.GetExpressions(e,null)}catch{debugger}if(o==null)return null;o[0]instanceof vt;var l=a.Record;if(o.length==1){var u=o[0].Evaluate(t,a,l,n);if(u==null)return null;if(u instanceof Date){if(n.TypeDDD=="Date")return We.getIsoDate(u);if(n.TypeDDD=="DateTime")return We.getIsoDateTime(u)}else if(typeof u=="number")return u.toString();return u.toString()}return(s=it.ConcatValues(o,t,a,l,n))==null?void 0:s.toString()}static ValueExpresion(e,t,n,a){var g;if(t=="null")return null;if(!t.startsWith("%")&&!t.endsWith("%"))return t;let i="";try{i=t.substring(1,t.length-1)}catch(b){throw e!=null?e.FieldName+" "+e.ValueExpression+" Expression:"+t+b:t+b}var o=i.split("."),l=o[0];switch(l){case"V":return n.GetValues(o[1]);case"E":{const b=o[1],A=o[2];if(b.toLowerCase()=="eu_scr")return n.ExternalTables.EU_SCR[A];if(b.toLowerCase()=="session"){for(var u=n.ExternalTables.Session,s=2;s<o.length;s++)if(u[o[s]]!=null)u=u[o[s]];else return null;return u}else return""}case"S":{if(n.Settings==null||n.Settings[o[1]]==null)throw"Can't find setting for "+o[1];var c=n.Settings[o[1]];return c.Value}default:{if(o.length==2){var f=o[0],m=o[1];if(f==((g=a==null?void 0:a.Parent)==null?void 0:g.Tablename)){var v=it.ReturnFromObject(a.Record,m);if(v.found===!0)return v.return}var p=n.FindTableLevel(f);if(p!=null){if(p.Record!=null){var d=p.Record,v=it.ReturnFromObject(d.Record,m);if(v.found===!0)return v.return;if(v.found===!1&&m=="InvIssueDate")return null;if(v.found===!1&&m.indexOf("__")!=-1){var y=it.ReturnFromObject(d.Record,m);if(y.found===!0)return y.return}return null}else if(p.Records!=null){var x=p.Records,D=x.Records.filter(b=>b==a);if(D.length>0){var h=D[0],w=h.Record,v=it.ReturnFromObject(w,m);if(v.found===!0)return v.return;if(v.found===!1&&m.indexOf("__")!=-1){var y=it.ReturnFromObject(h.Record,m);if(y.found===!0)return y.return}if(m=="ItemRetailPriceInp"||m=="ItemVatCodeSC__VCCode_EN16931")return null;throw"Can't evaluate "+t+" key:"+e.FieldName}}}}break}}return null}static ReturnFromObject(e,t){return Object.keys(e).indexOf(t)==-1?{found:!1,return:null}:e[t]==null?{found:!0,return:null}:e[t]instanceof Date?{found:!0,return:e[t]}:{found:!0,return:e[t].toString()}}};it._suportedFunctions={"tonull(":i0,"sum(":qh,"if(":$h,"calcdate(":zh,"addleadzeros(":Ih,"starts(":Uh,"substr(":Lh,"count(":kh,"check(":Gh,"concat(":Vh,"empty(":Ou,"nonempty(":Ou,"exists(":Fu,"notexists(":Fu,"noeval(":o0,"appear(":Ph,"value(":Wh,"year(":Jh,"month(":jh,"screxists(":f0,"inlist(":_u,"notinlist(":_u,"indetail(":Tu,"notindetail(":Tu,"upper(":Mu,"lower(":Mu,"trim(":Hh,"totalminutes(":s0,"datetimeformat(":a0,"time(":u0,"clean(":Xh,"fromcodelist(":c0,"len(":l0,"registrycheck(":Zh,"extract(":Qh,"usefirst(":Yh};let He=it;class Tt{static GetRecords(e,t){return t.GetReferenceRecords("__VatRate")}static SumByFieldNameAndVarCode(e,t,n){var a=this.GetRecords(t,n);if(a==null)return 0;for(var i=0,o=0;o<a.length;o++)i+=a[o].Record[e]??0;return i}static GetFirstRecordItem(e,t){var n=this.GetRecords(e,t);return n==null?null:n[0]}}class f6{static Execute(e,t,n,a){if(t==null)return"Invoice object is null";switch(e.FieldName){case"VatInvAllowAmount":{n.SetValueToKey(e,Tt.SumByFieldNameAndVarCode("LineInvAllowAmount",t,n),a);break}case"VatTaxableAmount":{n.SetValueToKey(e,Tt.SumByFieldNameAndVarCode("LineTotalNetAmount",t,n),a);break}case"VatTaxAmount":{n.SetValueToKey(e,Tt.SumByFieldNameAndVarCode("LineTotalVatAmount",t,n),a);break}case"VatInvChargeAmount":{n.SetValueToKey(e,Tt.SumByFieldNameAndVarCode("LineTotalVatAmount",t,n),a);break}case"VatInvAllowBaseAmount":{n.SetValueToKey(e,Tt.SumByFieldNameAndVarCode("LineBaseAmountInclAllow",t,n),a);break}case"VatInvChargeBaseAmount":{n.SetValueToKey(e,Tt.SumByFieldNameAndVarCode("LineTotalVatAmount",t,n),a);break}case"VatCatCode":{var i=Tt.GetFirstRecordItem(t,n);i!=null&&n.SetValueToKey(e,i.RecordAnalitic.ItemVatCodeSC__VCCode_EN16931,a);break}case"VatCode":{var i=Tt.GetFirstRecordItem(t,n);i!=null&&n.SetValueToKey(e,i.RecordAnalitic.ItemVatCodeSC__VatCode,a);break}case"VatRate":{var i=Tt.GetFirstRecordItem(t,n);i!=null&&n.SetValueToKey(e,i.RecordAnalitic.ItemVatCodeSC__Rate,a);break}case"VatCodeUI":{var i=Tt.GetFirstRecordItem(t,n);i!=null&&n.SetValueToKey(e,i.RecordAnalitic.ItemVatCodeSC__GroupUIVatCode,a);break}case"VatExemptReasonDesc":{var o=Tt.GetRecords(t,n);if(o!=null&&o.length>0){for(var l=new Set,u=0;u<o.length;u++){var s=o[u];if(s.Record.ItemVatCodeSC__VatCode=="E_999"){l.add(s.Record.VatExemReasonDescE_999??"");continue}l.add(s.RecordAnalitic.ItemVatCodeSC__VERDesc??"")}const c=new Set([...l].filter(f=>f!=""));c.size>0?n.SetValueToKey(e,[...c].join(", "),a):n.SetValueToKey(e,null,a)}break}case"VatExemptReasonCode":{var i=Tt.GetFirstRecordItem(t,n);i!=null&&n.SetValueToKey(e,null,a);break}case"NumOfItems":{var o=Tt.GetRecords(t,n);o!=null&&n.SetValueToKey(e,o.length,a);break}}}}class m6{static Execute(e,t,n,a){if(t==null)return"Invoice object is null";switch(e.FieldName){case"LineIdent":{var i=this.GetRecords(t),o=i.indexOf(n)+1;n.SetValueToKey(e,o,a);break}}}static GetRecords(e){var t=e.FindTableLevel("EU_Invoices_Items");if(t==null)throw Error("Can't find level EU_Invoices_Items");var n=t.Records;return(n==null?void 0:n.Records)??[]}}const bn=class bn{static IsDetailTable(e){return this._objectTablesDetail.indexOf(e)!=-1}static isMultiple(e){return e=="EU_Invoices_Items_Classes"||e=="EU_Invoices_Items_AllowsCharges"||e=="EU_Invoices_CN_IICRefs_Items"||e=="EU_Invoices_AdvanceUsage"||e=="EU_Invoices_AdvanceUsageVatCode"||e=="EU_Invoices_Items_Attributes"}static GetMultipleParent(e){return this.__multipleParent[e]?this.__multipleParent[e]:null}static GetTableForAlias(e){return this._dicAliasMap[e]??e}static GetTableFromAlias(e){for(var t=Object.keys(this._dicAliasMap),n=0;n<t.length;n++)if(this._dicAliasMap[t[n]]==e)return t[n];return e}};bn.masterEntity="EU_Invoices",bn.itemsEntity="EU_Invoices_Items",bn.vatEntity="EU_Invoices_Vats",bn.paymentInstrsEntity="EU_Invoices_PaymentInstrs",bn._objectTablesDetail=["EU_Invoices_Items","EU_Invoices_Items_Classes","EU_Invoices_Items_Attributes","EU_Invoices_Items_AllowsCharges","EU_Invoices_Errors","EU_Invoices_PaymentInstrs","EU_Invoices_Vats","EU_Invoices_VatsFisc","EU_Invoices_VatsCatCode","EU_Invoices_VatsUI","EU_Invoices_PrecedInvs","EU_Invoices_AllowsCharges","EU_Invoices_AddRefDocs","EU_Invoices_AdvanceUsage"],bn._dicAliasMap={EU_Invoices:"Invoice",EU_Invoices_CN_IICRefs:"CreditNoteRefs",EU_Invoices_Items:"Items",EU_Invoices_PaymentInstrs:"Payments",EU_Invoices_AddRefDocs:"Attachments",EU_Invoices_Items_Classes:"ItemsClasses",EU_Invoices_Items_Attributes:"ItemsAttributes",EU_Invoices_Items_Incomes:"ItemsIncomes",EU_Invoices_Items_Expenses:"ItemsExpenses",EU_Invoices_Items_AllowsCharges:"ItemsAllowsCharges"},bn.__multipleParent={EU_Invoices_Items_Classes:"EU_Invoices_Items",EU_Invoices_Items_AllowsCharges:"EU_Invoices_Items",EU_Invoices_CN_IICRefs_Items:"EU_Invoices_Items",EU_Invoices_Items_Attributes:"EU_Invoices_Items",EU_Invoices_Items_Incomes:"EU_Invoices_Items",EU_Invoices_Items_Expenses:"EU_Invoices_Items"};let Ft=bn;class Ga{constructor(e,t,n){if(this.Details=null,this.IsDefaultRecord=!1,this._LeftInstance=null,this._referenceRecords=null,this.RecordAnalitic={},this.Parent=n,e._details!=null){var a={},i=Object.keys(e._details);i.forEach(o=>{var l;a[o]=new xn(o,e._details[o],t,((l=this.Parent)==null?void 0:l.Root)??null)}),this.Details=a,delete e._details}this.Record={}}SetReferenceRecords(e,t){this._referenceRecords==null&&(this._referenceRecords=new Map),this._referenceRecords.set(e,t)}GetReferenceRecords(e){return this._referenceRecords==null?null:this._referenceRecords.get(e)??null}SetLeftInstanceReference(e){this._LeftInstance=e}GetLeftInstanceReference(){return this._LeftInstance}AddDetail(e,t){this.Details==null&&(this.Details={}),this.Details[e]=t}GetDetail(e){return this.Details==null?null:this.Details[e]}HasDetails(e){return this.Details==null?!1:this.Details[e]!=null}SetValueToKey(e,t,n){if(n!=null&&n==this.Record&&(this.RecordAnalitic[e.FieldName]=t),t==null){this.Record[e.FieldName]=null;return}if(e.FieldName!=null){if(typeof t=="string")switch(e.Type){case"int":{t=parseInt(t);break}case"decimal":{t=parseFloat(t);break}case"bool":case"boolean":{t=i=>i.trim().toLowerCase()==="true";break}}if(e.RoundTo!=null){var a=e.RoundTo;typeof t=="number"&&(t=this.roundUp(t,a))}}this.Record[e.FieldName]=t}SetValueToKeyString(e,t,n){if(n!=null&&(this.RecordAnalitic[e]=t),t==null){this.Record[e]=null;return}this.Record[e]=t}roundUp(e,t){let n=!1;e<0?n=!0:n=!1,n?e=e-10**-13:e=e+10**-13,e=Math.abs(e);let a=Math.round(e*Math.pow(10,t))/Math.pow(10,t);return n?-1*a:a}GetObject(){var e=JSON.parse(JSON.stringify(this.Record));if(this.Details!=null){let t=JSON.parse("{}");for(let n=0;n<this.Details.length;n++){let a=this.Details[n].GetObject();a!=null&&(t[this.Details[n].Tablename]=a)}e._details=t}return e}TranslateObj(e){if(this.Details!=null)for(let i=0;i<this.Details.length;i++)this.Details[i].TranslateObj(e);var t=Object.keys(this.Record),n=Object.keys(e),a=t.filter(i=>n.indexOf(i)!=-1);a.length>0&&a.forEach(i=>{var o=e[i].data[this.Record[e[i].key]];o!=null&&(this.Record[i]=e[i].data[this.Record[e[i].key]])})}MapToId(e){e.length!=0&&e.forEach(t=>{this.MapToIdItem(t)})}MapToIdItem(e){var d,y,x,D;if(e==null)return null;var t={},n=e.FieldName,a=Object.keys(this.Record),i=Object.keys((((y=(d=this.Parent)==null?void 0:d.Root)==null?void 0:y.ObjectInfo)??{})[e.TableName??""]).filter(h=>h.startsWith(n+"__")),o=a.filter(h=>h.startsWith(n+"__"));e.FieldName=="ItemVatCodeSC";for(let h=0;h<o.length;h++){var l=o[h].substring((n+"__").length);this.Record[o[h]]!=null&&(t[l]=this.Record[o[h]])}if(Object.keys(t).length==0||e.ConnTable==null)return null;var u=(D=(x=this.Parent)==null?void 0:x.Root)==null?void 0:D.CodeListCache[e.ConnTable],s=Object.keys(t);let c=u;for(let h=0;h<s.length;h++){var f=s[h];if(c=c.filter(w=>w[f]==t[f]),c.length==0)return null}if(c.length>1)throw"More than 1 record found for "+e.FieldName+" with value "+JSON.stringify(t);var m=c[0];this.Record[e.FieldName]=m[e.ByKey??"Id"];for(let h=0;h<i.length;h++){var f=i[h],v=f.substring((n+"__").length);this.Record[f]=m[v]}var p=Object.keys(m);for(let h=0;h<p.length;h++){var f=p[h];this.RecordAnalitic[e.FieldName+"__"+f]=m[f]}}EvaluateInner(e){e.length!=0&&e.forEach(t=>{var a,i,o,l,u;if(((i=(a=this.Parent)==null?void 0:a.Root)==null?void 0:i.EvalType)=="Init"){if(this.Record[t.FieldName]==null&&t.ValueExpressionInit!=null){var n=He.ParseAndFillExpression(t.ValueExpressionInit,t,((o=this==null?void 0:this.Parent)==null?void 0:o.Root)??null,this,this.Record,!0,!1);this.Record[t.FieldName]=n}}else((u=(l=this.Parent)==null?void 0:l.Root)==null?void 0:u.EvalType)=="Eval"&&this.Evaluate(t)})}Evaluate(e){var a,i,o,l;if(!(e.EvalOnlyIfEmpty===!0&&this.Record[e.FieldName]!=null)){if(e.EvaluateOnlyIF!=null){var t=He.ParseExpressionAndReturnValue(e.EvaluateOnlyIF,((a=this==null?void 0:this.Parent)==null?void 0:a.Root)??null,e,this,0);if(t==null||t.toUpperCase()!="TRUE")return}if(e.ValueExpression!=null){var n=He.ParseAndFillExpression(e.ValueExpression,e,((i=this==null?void 0:this.Parent)==null?void 0:i.Root)??null,this,this.Record,!0,!1);this.SetValueToKey(e,n,this.Record)}else this.Record[e.FieldName]==null&&this.SetValueToKey(e,null,this.Record);switch(e.GetValueFrom){case"Code":{switch(e.TableName){case"EU_Invoices_VatsUI":{f6.Execute(e,((o=this.Parent)==null?void 0:o.Root)??null,this,this.Record);break}case"EU_Invoices_Items":{m6.Execute(e,((l=this.Parent)==null?void 0:l.Root)??null,this,this.Record);break}}break}}}}ParseExpressionAndReturnValue(e,t){return this.ParseExpressionAndReturnValueNew(e,t)}ParseExpressionAndReturnValueNew(e,t){var a;if(((a=this.Parent)==null?void 0:a.Root)==null)return null;var n=He.ParseAndFillExpression(e,t,this.Parent.Root,this,this.Record,!1,!1);return n}valueToType(e){return e==null||e=="null"?null:typeof e!="string"?e:e.toLocaleLowerCase()=="true"?!0:e.toLocaleLowerCase()=="false"?!1:isNaN(parseFloat(e))?e:parseFloat(e)}ValueExpresion(e){var i,o,l;if(e==null)return null;if(!e.startsWith("%")||!e.endsWith("%"))return this.valueToType(e);let n=e.substring(1,e.length-1).split(".");var a=n[0];switch(a){case"V":return console.warn("V not supported!"),null;case"E":{const u=n[1];if(u!="EU_AOrg"){if(u!="EU_SCR"){if(u!="Session")return console.warn("Other E not supported!"),null}}break}case"S":return console.warn("S not supported!"),null;default:{if(n.length==2){const u=n[0];if(u==((i=this.Parent)==null?void 0:i.Tablename))return this.Record[n[1]];{let s=(l=(o=this.Parent)==null?void 0:o.Root)==null?void 0:l.FindTableLevel(u);if(s!=null&&s.Record!=null&&(s==null?void 0:s.Record)!=null)return this.valueToType(s==null?void 0:s.Record.Record[n[1]])}}break}}return null}getSaveObject(e){var i,o,l;const t={};if(this.Details!=null){const u={};for(let s=0;s<this.Details.length;s++){const c=this.Details[s].getSaveObject(e);c!=null&&(u[this.Details[s].Tablename]=c)}Object.keys(u).length>0&&(t._details=u)}if(((i=this.Parent)==null?void 0:i.Tablename)==null)return null;const n=e[(o=this.Parent)==null?void 0:o.Tablename],a=Object.keys(n);for(let u=0;u<a.length;u++){const s=a[u];switch(n[s].TypeDDD){case"Date":{t[s]=We.getIsoDate(this.Record[s]);break}case"DateTime":{t[s]=We.getIsoDateTime(this.Record[s]);break}default:{t[s]=this.Record[s];break}}}return this.Record.Id!=null&&(t.Id=this.Record.Id),((l=this.Parent)==null?void 0:l.Tablename)=="EU_Invoices",Object.keys(t).length>0?t:null}getFullObject(e){var o,l,u;const t={};if(this.Details!=null){const s={};var n=Object.keys(this.Details);for(let c=0;c<n.length;c++){const f=this.Details[n[c]].getFullObject(e);f!=null&&(s[this.Details[n[c]].Tablename]=f)}Object.keys(s).length>0&&(t._details=s)}if(((o=this.Parent)==null?void 0:o.Tablename)==null)return null;const a=e[(l=this.Parent)==null?void 0:l.Tablename],i=Object.keys(a);for(let s=0;s<i.length;s++){const c=i[s];switch(a[c].Type){case"Date":{t[c]=We.getIsoDate(this.Record[c]);break}case"DateTime":{t[c]=We.getIsoDateTime(this.Record[c]);break}default:{t[c]=this.Record[c];break}}}return this.Record.Id!=null&&(t.Id=this.Record.Id),((u=this.Parent)==null?void 0:u.Tablename)=="EU_Invoices"&&(t.InvTotalVatAmountCCInp=this.Record.InvTotalVatAmountCC,t.InvAmountInclVatInp=this.Record.InvAmountInclVat),Object.keys(t).length>0?t:null}GetTableForAlias(e){var o,l,u;const t={};if(this.Details!=null){const s={};var n=Object.keys(this.Details);for(let c=0;c<n.length;c++){const f=this.Details[n[c]].GetTableForAlias(e);f!=null&&(s[Ft.GetTableForAlias(this.Details[n[c]].Tablename)]=f)}Object.keys(s).length>0&&(t._details=s)}if(((o=this.Parent)==null?void 0:o.Tablename)==null)return null;const a=e[(l=this.Parent)==null?void 0:l.Tablename],i=Object.keys(a);for(let s=0;s<i.length;s++){const c=i[s],f=a[c].Type,m=a[c].Alias??c;switch(f){case"Date":{t[m]=We.getIsoDate(this.Record[c]);break}case"DateTime":{t[m]=We.getIsoDateTime(this.Record[c]);break}default:{t[m]=this.Record[c];break}}}return this.Record.Id!=null&&(t.Id=this.Record.Id),((u=this.Parent)==null?void 0:u.Tablename)=="EU_Invoices"&&(t.InvTotalVatAmountCCInp=this.Record.InvTotalVatAmountCC,t.InvAmountInclVatInp=this.Record.InvAmountInclVat),Object.keys(t).length>0?t:null}Validate(){}}class Du{constructor(e,t,n){this.Records=[],this.Parent=n,this.ObjectInfo=t,this.Records.push(new Ga(e,t,n))}MapToId(e){if(this.Records!=null)for(let t=0;t<this.Records.length;t++)this.Records[t].MapToId(e)}EvaluateInner(e){if(this.Records!=null)for(let n=0;n<this.Records.length;n++){var t=this.Records[n];try{t.EvaluateInner(e)}catch{debugger}}}TranslateObj(e){if(this.Records.length!=0)for(let t=0;t<this.Records.length;t++)this.Records[t].TranslateObj(e)}GetObject(){if(this.Records.length==0)return null;var e=[];for(let t=0;t<this.Records.length;t++)e.push(this.Records[t].GetObject());return e}getSaveObject(e){var a;if(this.Records==null)return null;var t=[];if(((a=this.Parent)==null?void 0:a.Tablename)=="EU_Invoices_Items_Classes"&&this.Records.length==1){var n=this.Records[0];if(n.Record.ItemClassCodeSchID==null&&n.Record.ItemClassCode==null)return t}for(let i=0;i<this.Records.length;i++)t.push(this.Records[i].getSaveObject(e));return t}getFullObject(e){if(this.Records==null)return null;var t=[];for(let n=0;n<this.Records.length;n++)t.push(this.Records[n].getFullObject(e));return t}GetTableForAlias(e){if(this.Records==null)return null;var t=[];for(let n=0;n<this.Records.length;n++)t.push(this.Records[n].GetTableForAlias(e));return t}Validate(){if(this.Records==null)return null;const e={};for(let i=0;i<this.Records.length;i++){let o=this.Records[i].Validate();o!=null&&(e[i.toString()]=o)}if(Object.keys(e).length==0)return null;const t=Object.keys(e);let n="",a={};for(let i=0;i<t.length;i++){let o="";const l=t[i];let u=e[l];u.missingKeys!=null&&(o="Missing mandatory keys:"+u.missingKeys),o!=null&&(n+="Errors on index "+l+": "+o,a.push([l,u.missingKeys]))}return{errorMessage:n==""?null:n,validateDetailsErrors:a}}}class Mh{constructor(e,t,n){this.rootLevel=null,this.LeftObject=null,this.ExternalTables={},this.Settings=null,this._dicValues={},this.EvalType="Init",this.Mappings=null,this.CodeListCache={},this.InvoiceStructure={},this.Legislation=e,this.LeftObject=t,this.ObjectInfo=(n==null?void 0:n.OI)??{},this.CodeListCache=(n==null?void 0:n.CodeList)??{},this.InvoiceStructure=(n==null?void 0:n.InvoiceStructure)??{},this.ExternalTables=(n==null?void 0:n.External)??{},this.Settings=(n==null?void 0:n.Settings)??{},this.prepareValues()}prepareValues(){const e=new Date;this._dicValues={NOW:this.formatDateTime(e),DATE:this.formatDate(e),LEGISLATION:this.Legislation}}static isMultiple(e){return e=="EU_Invoices_Items_Classes"||e=="EU_Invoices_Items_AllowsCharges"||e=="EU_Invoices_CN_IICRefs_Items"||e=="EU_Invoices_AdvanceUsage"||e=="EU_Invoices_AdvanceUsageVatCode"}InitAfterConst(){}formatDate(e){return e.getFullYear()+"-"+this.formatToTwoNumber(e.getMonth()+1)+"-"+this.formatToTwoNumber(e.getDate())}formatDateTime(e){return e.getFullYear()+"-"+this.formatToTwoNumber(e.getMonth()+1)+"-"+this.formatToTwoNumber(e.getDate())+"T"+this.formatToTwoNumber(e.getHours())+":"+this.formatToTwoNumber(e.getMinutes())+":"+this.formatToTwoNumber(e.getSeconds())}formatToTwoNumber(e){return e<10?"0"+e:e.toString()}GetValues(e){var t=e.toUpperCase();return this._dicValues[t]!=null?this._dicValues[t]:null}FindTableLevel(e){var t=this.RecursiveFindLevel(this.rootLevel,e);return t??(console.error("Can't find level "+e),null)}RecursiveFindLevel(e,t){if(e==null&&(e=this.rootLevel),e==null)return null;if((e==null?void 0:e.Tablename)==t)return e;if(e.Record!=null&&e.Record.Details!=null){var n=Object.keys(e.Record.Details);for(let a=0;a<n.length;a++){const i=this.RecursiveFindLevel(e.Record.Details[n[a]],t);if(i!=null)return i}}return null}GetObject(){var e;return(e=this.rootLevel)==null?void 0:e.GetObject()}SumByKey(e){var t=e.split(","),n=t[0].split(".");if(n.length!=2)throw"Key isn't well formmed! "+e;var a=this.RecursiveFindLevel(this.rootLevel,n[0]);if(a==null)throw"Can't find table level "+n[0];let i=null;if(t.length==2){var o=t[1].split(".");i=o[1]}let l=0;if(a.Records!=null)for(var u=a.Records,s=0;s<u.Records.length;s++){const c=u.Records[s];if(c.Record[n[1]]!=null){if(i!=null&&!c.Record[i])continue;l+=c.Record[n[1]]}}return l}getSaveObject(){return{}}getFullObject(){var t,n;const e={};return e[((t=this.rootLevel)==null?void 0:t.Tablename)??"EU_Invoices"]=(n=this.rootLevel)==null?void 0:n.getFullObject(this.ObjectInfo),e}getAliasObject(){var t;const e={};return e[Ft.GetTableForAlias("EU_Invoices")]=(t=this.rootLevel)==null?void 0:t.GetTableForAlias(this.ObjectInfo),e}ValidateBeforeSave(){}TranslateObj(e){var t;(t=this.rootLevel)==null||t.TranslateObj(e)}prepareSchemaStruct(){var e=[],t=Object.keys(this.ObjectInfo);return t.forEach(n=>{var a=Object.keys(this.ObjectInfo[n]);a.forEach(i=>{e.push(this.ObjectInfo[n][i])})}),e}Evaluate(){this.rootLevel=new xn("EU_Invoices",this.InvoiceStructure.EU_Invoices,this.ObjectInfo,this);var e=this.prepareSchemaStruct(),t=e.filter(n=>n.ValueExpressionInit!=null);return this.InicializeEval("Init",t),this.FillInvoiceDataIntoObjStuct(this.LeftObject,e,this.ObjectInfo,!1),console.log(this.getFullObject()),t=e.filter(n=>n.EvalStep=="PRE"&&(n.ValueExpression!=null||n.GetValueFrom=="Mappings"||n.GetValueFrom=="Code")),this.InicializeEval("Eval",t),t=e.filter(n=>n.ConnField),this.MapToId(t),t=e.filter(n=>n.EvalStep=="EVAL"),this.InicializeEval("Eval",t),t=e.filter(n=>n.EvalStep=="POST"&&n.Group=="Vats"),this.vatsPrepare(t),t=e.filter(n=>n.EvalStep=="POST"&&n.Group!="Vats"),this.InicializeEval("Eval",t),!0}InicializeEval(e,t){if(this.EvalType=e,t.length==0)return!0;try{var n=t.sort((o,l)=>(o.CalcPhase??0)-(l.CalcPhase??0)),a=[],i=null;for(let o=0;o<n.length;o++){const l=n[o];if(i==null){i=l.TableName,a.push(l);continue}i!=l.TableName&&(this.InicializeEvalInner(i??"",a),a=[],i=l.TableName),a.push(l)}a.length>0&&this.InicializeEvalInner(i??"",a)}catch(o){return console.error(o),!1}return!0}FillInvoiceDataIntoObjStuct(e,t,n,a){var le,me,Y,z,X,se,re;var i=(le=this.rootLevel)==null?void 0:le.Record;if(t.length>0){const pe=a?Ft.masterEntity:"Invoice";var o=e[pe],l=o._details,u=new Map,s=this.RecursiveFindLevel(null,Ft.masterEntity),i=s==null?void 0:s.Record,c=this.groupBy(t,"TableName"),f=Object.keys(c);if(o!=null||l!=null)for(var m=0;m<f.length;m++){var v=f[m],p=c[v];if(v==Ft.masterEntity){if(o==null||i==null)continue;for(var d=0;d<p.length;d++){var y=p[d];this.setValueForObject(o,i,y,a,null)}}else if(Ft.IsDetailTable(v)){if(l==null)continue;if(Ft.isMultiple(v)){u.set(v,p);continue}var x=a?v:Ft.GetTableForAlias(v);if(l[x]==null||l[x].length==0)continue;var D=this.RecursiveFindLevel(this.rootLevel,v);if(D==null||D==null)continue;var h=[],w=l[x],g={};if((D==null?void 0:D.Records)!=null&&((me=D.Records)==null?void 0:me.Records.length)>0){var b=D.Records.Records[0];b.IsDefaultRecord=!1;for(var A=Object.keys(b.Record),N=0;N<A.length;N++){var E=A[N];g[E]=b.Record[E]}}for(var d=0;d<w.length;d++){for(var S=JSON.parse(JSON.stringify(g)),C=w[d],M=new Ga(S,n,D),O=0;O<p.length;O++){var y=p[O];this.setValueForObject(C,M,y,a,null)}M.SetLeftInstanceReference(C),h.push(M)}D.Records!=null&&(D.Records.Records=h)}}else for(var I=t.filter(Oe=>Oe.FromInputKey!=null),c=this.groupBy(I,"TableName"),m=0;m<f.length;m++){var v=f[m],p=c[v];if(v==Ft.masterEntity&&i!=null)for(var d=0;d<p.length;d++){var y=p[d];this.setValueForObject(o,i,y,a,null)}else{var x=Ft.GetTableForAlias(v),D=this.RecursiveFindLevel(null,v);if(D==null)continue;var h=[],k="",w=this.FindJArray(e,((z=(Y=p[0])==null?void 0:Y.FromInputKey)==null?void 0:z.split("."))??[],k),g={};if(((X=D.Records)==null?void 0:X.Records)==null||D.Records.Records.length===0||D.Records.Records[0].Record==null)continue;for(var _=D.Records.Records[0].Record,P=Object.keys(_),N=0;N<P.length;N++){var E=P[N];g[E]=_.Record[E]}for(var m=0;m<w.length;m++){for(var S=JSON.parse(JSON.stringify(g)),C=w[m],M=new Ga(S,n,D),O=0;O<p.length;O++){var y=p[O];this.setValueForObject(C,M,y,a,null)}M.SetLeftInstanceReference(C),h.push(M)}D.Records=new Du(h,n,D)}}if(u.size>0)return;for(const[De,Oe]of u){var V=Ft.GetMultipleParent(De);if(V==null)throw"Can't find parent for multiple table "+De;var q=this.RecursiveFindLevel(this.rootLevel,V);if(q!=null)for(var J=((se=q.Records)==null?void 0:se.Records)??[],m=0;m<(J==null?void 0:J.length);m++){var ne=J[m].GetLeftInstanceReference();if(ne==null)continue;var j=ne._details;if(j==null)continue;var F=j[De];if(F==null||F.length==0)continue;let _e=null;if(J[m].HasDetails(De)){if(_e=J[m].GetDetail(De),_e==null)continue}else _e=new xn(De,[],this.ObjectInfo,this),J[m].AddDetail(De,_e);for(var U=(re=_e.Records)==null?void 0:re.Records,$=[],m=0;m<F.Count;m++){let qe=null;U&&U.length>m?qe=U[m]:(qe=new Ga({},this.ObjectInfo,_e),$.push(qe));for(var O=0;O<Oe.length;O++){var y=Oe[O];this.setValueForObject(C,qe,y,a,null)}}}}}}FindJArray(e,t,n){if(t.length==0)return null;if(n!=""&&(n+="."),n+=t[0],e[t[0]]!=null&&Array.isArray(e[t[0]])){var a=e[t[0]],i=JSON.parse(JSON.stringify(t));return i.splice(0,1),a.length==1&&t.length>2?this.FindJArray(a[0],i,n):a}var o=JSON.parse(JSON.stringify(t));return o.splice(0,1),this.FindJArray(e[t[0]],o,n)}setValueForObject(e,t,n,a,i){if(e!=null){if(n==null){debugger;return}var o=a?n.FieldName:n.AliasExport??n.FieldName;if(e[o]!=null){var l=t.Record;t.SetValueToKey(n,e[o],l)}else if(n.FromInputKey!=null)for(var u=n.FromInputKey.split("??"),s=0;s<u.length;s++){var c=u[s];if(i!=null&&(c=c.replace(i+".","")),e.Get(c)!=null){var l=t.Record;t.SetValueToKey(n,e.Get(c),l)}}}}InicializeEvalInner(e,t){var n=this.RecursiveFindLevel(null,e);return n==null?!1:(n.Evaluate(t),!0)}MapToId(e){if(e.length==0)return!0;try{var t=e.sort((i,o)=>(i.CalcPhase??0)-(o.CalcPhase??0)),n=[],a=null;for(let i=0;i<t.length;i++){const o=t[i];if(a==null){a=o.TableName,n.push(o);continue}a!=o.TableName&&(this.MapToIdInner(a??"",n),n=[],a=o.TableName),n.push(o)}n.length>0&&this.MapToIdInner(a??"",n)}catch{return!1}return!0}MapToIdInner(e,t){var n=this.RecursiveFindLevel(null,e);return n==null?!1:(n.MapToId(t),!0)}vatsPrepare(e){var l;if(e.length!=0){var t=this.RecursiveFindLevel(null,"EU_Invoices_Items"),n=this.groupBy(e,"TableName");for(const u in n){var a=this.RecursiveFindLevel(null,u);a==null&&(a=new xn(u,[],this.ObjectInfo,this)),a.Records==null&&(a.Records=new Du([],this.ObjectInfo[u],a));var i={};(l=t==null?void 0:t.Records)==null||l.Records.forEach(c=>{var f=c.Record.VatsUIGroupKey;i[f]==null&&(i[f]=[]),i[f].push(c)});var o=[];Object.keys(i).forEach(c=>{var f={};f.__VatRate=c;var m=new Ga({},this.ObjectInfo,a);m.Record=f,m.SetReferenceRecords("__VatRate",i[c]),o.push(m)}),a.Records.Records=o;const s=n[u];a.Evaluate(s)}}}groupBy(e,t){return e.reduce((n,a)=>{const i=String(a[t]);return(n[i]||(n[i]=[])).push(a),n},{})}}class _h{static hasKey(e){return this.getFromSessionStorage(e)!=null}static getFromSessionStorage(e){return localStorage.getItem(e)}static setToSessionStorage(e,t){typeof t=="object"&&(t=JSON.stringify(t)),localStorage.setItem(e,t)}}(function(r,e){typeof Bt=="object"&&typeof module<"u"?module.exports=e():typeof define=="function"&&define.amd?define(e):(r=typeof globalThis<"u"?globalThis:r||self).axios=e()})(void 0,function(){function r(B){return r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(Z){return typeof Z}:function(Z){return Z&&typeof Symbol=="function"&&Z.constructor===Symbol&&Z!==Symbol.prototype?"symbol":typeof Z},r(B)}function e(B,Z){if(!(B instanceof Z))throw new TypeError("Cannot call a class as a function")}function t(B,Z){for(var te=0;te<Z.length;te++){var ae=Z[te];ae.enumerable=ae.enumerable||!1,ae.configurable=!0,"value"in ae&&(ae.writable=!0),Object.defineProperty(B,ae.key,ae)}}function n(B,Z,te){return Z&&t(B.prototype,Z),te&&t(B,te),Object.defineProperty(B,"prototype",{writable:!1}),B}function a(B,Z){return function(te){if(Array.isArray(te))return te}(B)||function(te,ae){var ce=te==null?null:typeof Symbol<"u"&&te[Symbol.iterator]||te["@@iterator"];if(ce!=null){var fe,ge,Ae=[],Ee=!0,Fe=!1;try{for(ce=ce.call(te);!(Ee=(fe=ce.next()).done)&&(Ae.push(fe.value),!ae||Ae.length!==ae);Ee=!0);}catch(Re){Fe=!0,ge=Re}finally{try{Ee||ce.return==null||ce.return()}finally{if(Fe)throw ge}}return Ae}}(B,Z)||function(te,ae){if(te){if(typeof te=="string")return i(te,ae);var ce=Object.prototype.toString.call(te).slice(8,-1);if(ce==="Object"&&te.constructor&&(ce=te.constructor.name),ce==="Map"||ce==="Set")return Array.from(te);if(ce==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(ce))return i(te,ae)}}(B,Z)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
61
|
+
In case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.`,examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},TF={name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, dimension)","std(A, normalization)","std(A, dimension, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},FF={name:"cumsum",category:"Statistics",syntax:["cumsum(a, b, c, ...)","cumsum(A)"],description:"Compute the cumulative sum of all values.",examples:["cumsum(2, 3, 4, 1)","cumsum([2, 3, 4, 1])","cumsum([1, 2; 3, 4])","cumsum([1, 2; 3, 4], 1)","cumsum([1, 2; 3, 4], 2)"],seealso:["max","mean","median","min","prod","std","sum","variance"]},OF={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"]},BF={name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, dimension)","variance(A, normalization)","variance(A, dimension, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},RF={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"]},IF={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"]},PF={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"]},$F={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"]},qF={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"]},zF={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"]},UF={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"]},LF={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"]},kF={name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},VF={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"]},GF={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"]},HF={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"]},WF={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"]},YF={name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},ZF={name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},JF={name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},jF={name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},XF={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"]},QF={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"]},KF={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"]},e3={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"]},r3={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"]},t3={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"]},n3={name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},a3={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"]},i3={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"]},o3={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:[]},s3={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:[]},u3={name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},l3={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:[]},c3={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"]},f3={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"]},m3={name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},v3={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"]},p3={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","isFinite","isBounded"]},d3={name:"isBounded",category:"Utils",syntax:["isBounded(x)"],description:"Test whether a value or its entries are bounded.",examples:["isBounded(Infinity)","isBounded(bigint(3))","isBounded([3, -Infinity, -3])"],seealso:["isFinite","isNumeric","isNaN","isNegative","isPositive"]},h3={name:"isFinite",category:"Utils",syntax:["isFinite(x)"],description:"Test whether a value is finite, elementwise on collections.",examples:["isFinite(Infinity)","isFinite(bigint(3))","isFinite([3, -Infinity, -3])"],seealso:["isBounded","isNumeric","isNaN","isNegative","isPositive"]},g3={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"]},y3={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","isFinite","isBounded"]},b3={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"]},x3={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"]},w3={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"]},D3={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"]},N3={name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},E3={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"]},A3={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"]},S3={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"]},C3={bignumber:iM,bigint:oM,boolean:sM,complex:uM,createUnit:lM,fraction:cM,index:fM,matrix:mM,number:vM,sparse:pM,splitUnit:dM,string:hM,unit:gM,e:wp,E:wp,false:GC,i:HC,Infinity:WC,LN2:ZC,LN10:YC,LOG2E:jC,LOG10E:JC,NaN:XC,null:QC,pi:Dp,PI:Dp,phi:KC,SQRT1_2:eM,SQRT2:rM,tau:tM,true:nM,version:aM,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:wM,lsolve:NM,lsolveAll:EM,lup:AM,lusolve:SM,leafCount:DM,polynomialRoot:CM,resolve:TM,simplify:FM,simplifyConstant:OM,simplifyCore:BM,symbolicEqual:IM,rationalize:_M,slu:RM,usolve:PM,usolveAll:$M,qr:MM,abs:qM,add:zM,cbrt:UM,ceil:LM,cube:kM,divide:VM,dotDivide:GM,dotMultiply:HM,dotPow:WM,exp:YM,expm:ZM,expm1:JM,fix:jM,floor:XM,gcd:QM,hypot:KM,lcm:r_,log:t_,log2:i_,log1p:a_,log10:n_,mod:o_,multiply:s_,norm:u_,nthRoot:l_,nthRoots:c_,pow:f_,round:m_,sign:v_,sqrt:p_,sqrtm:d_,square:b_,subtract:x_,unaryMinus:w_,unaryPlus:D_,xgcd:N_,invmod:e_,num:E_,den:A_,bitAnd:S_,bitNot:C_,bitOr:M_,bitXor:__,leftShift:T_,rightArithShift:F_,rightLogShift:O_,bellNumbers:B_,catalan:R_,composition:I_,stirlingS2:P_,config:yM,import:bM,typed:xM,arg:$_,conj:q_,re:U_,im:z_,evaluate:L_,help:H_,parse:V_,parser:k_,compile:G_,distance:W_,intersect:Y_,and:Z_,not:J_,nullish:j_,or:X_,xor:Q_,mapSlices:K_,concat:rT,count:tT,cross:nT,column:eT,ctranspose:aT,det:iT,diag:oT,diff:sT,dot:uT,getMatrixDataType:vT,identity:pT,filter:cT,flatten:fT,forEach:mT,inv:dT,pinv:hT,eigs:lT,kron:gT,matrixFromFunction:xT,matrixFromRows:wT,matrixFromColumns:bT,map:yT,ones:DT,partitionSelect:NT,range:ET,resize:ST,reshape:AT,rotate:CT,rotationMatrix:MT,row:_T,size:TT,sort:FT,squeeze:OT,subset:BT,trace:RT,transpose:IT,zeros:PT,fft:$T,ifft:qT,sylvester:h_,schur:g_,lyap:y_,solveODE:S3,bernoulli:zT,combinations:UT,combinationsWithRep:LT,factorial:kT,gamma:VT,kldivergence:HT,lgamma:GT,multinomial:WT,permutations:YT,pickRandom:ZT,random:JT,randomInt:jT,compare:XT,compareNatural:QT,compareText:KT,deepEqual:eF,equal:rF,equalText:tF,larger:nF,largerEq:aF,smaller:iF,smallerEq:oF,unequal:sF,setCartesian:uF,setDifference:lF,setDistinct:cF,setIntersect:fF,setIsSubset:mF,setMultiplicity:vF,setPowerset:pF,setSize:dF,setSymDifference:hF,setUnion:gF,zpk2tf:yF,freqz:bF,erf:xF,zeta:wF,cumsum:FF,mad:DF,max:NF,mean:EF,median:AF,min:SF,mode:CF,prod:MF,quantileSeq:_F,std:TF,sum:OF,variance:BF,corr:RF,acos:IF,acosh:PF,acot:$F,acoth:qF,acsc:zF,acsch:UF,asec:LF,asech:kF,asin:VF,asinh:GF,atan:HF,atanh:YF,atan2:WF,cos:ZF,cosh:JF,cot:jF,coth:XF,csc:QF,csch:KF,sec:e3,sech:r3,sin:t3,sinh:n3,tan:a3,tanh:i3,to:o3,toBest:s3,clone:l3,format:c3,bin:u3,oct:N3,hex:m3,isNaN:p3,isBounded:d3,isFinite:h3,isInteger:v3,isNegative:g3,isNumeric:y3,hasNumericValue:f3,isPositive:b3,isPrime:x3,isZero:w3,print:E3,typeOf:A3,numeric:D3},Np="help",M3=["typed","mathWithTransform","Help"],_3=L(Np,M3,r=>{var{typed:e,mathWithTransform:t,Help:n}=r;return e(Np,{any:function(i){var o,l=i;if(typeof i!="string"){for(o in t)if($e(t,o)&&i===t[o]){l=o;break}}var u=pt(C3,l);if(!u){var s=typeof l=="function"?l.name:l;throw new Error('No documentation found on "'+s+'"')}return new n(u)}})}),Ep="chain",T3=["typed","Chain"],F3=L(Ep,T3,r=>{var{typed:e,Chain:t}=r;return e(Ep,{"":function(){return new t},any:function(a){return new t(a)}})}),Ap="det",O3=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],B3=L(Ap,O3,r=>{var{typed:e,matrix:t,subtractScalar:n,multiply:a,divideScalar:i,isZero:o,unaryMinus:l}=r;return e(Ap,{any:function(c){return er(c)},"Array | Matrix":function(c){var f;switch(Je(c)?f=c.size():Array.isArray(c)?(c=t(c),f=c.size()):f=[],f.length){case 0:return er(c);case 1:if(f[0]===1)return er(c.valueOf()[0]);if(f[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+lr(f)+")");case 2:{var m=f[0],v=f[1];if(m===v)return u(c.clone().valueOf(),m);if(v===0)return 1;throw new RangeError("Matrix must be square (size: "+lr(f)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+lr(f)+")")}}});function u(s,c,f){if(c===1)return er(s[0][0]);if(c===2)return n(a(s[0][0],s[1][1]),a(s[1][0],s[0][1]));for(var m=!1,v=new Array(c).fill(0).map((A,N)=>N),p=0;p<c;p++){var d=v[p];if(o(s[d][p])){var y=void 0;for(y=p+1;y<c;y++)if(!o(s[v[y]][p])){d=v[y],v[y]=v[p],v[p]=d,m=!m;break}if(y===c)return s[d][p]}for(var x=s[d][p],D=p===0?1:s[v[p-1]][p-1],h=p+1;h<c;h++)for(var w=v[h],g=p+1;g<c;g++)s[w][g]=i(n(a(s[w][g],x),a(s[w][p],s[d][g])),D)}var b=s[v[c-1]][c-1];return m?l(b):b}}),Sp="inv",R3=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],I3=L(Sp,R3,r=>{var{typed:e,matrix:t,divideScalar:n,addScalar:a,multiply:i,unaryMinus:o,det:l,identity:u,abs:s}=r;return e(Sp,{"Array | Matrix":function(m){var v=Je(m)?m.size():rr(m);switch(v.length){case 1:if(v[0]===1)return Je(m)?t([n(1,m.valueOf()[0])]):[n(1,m[0])];throw new RangeError("Matrix must be square (size: "+lr(v)+")");case 2:{var p=v[0],d=v[1];if(p===d)return Je(m)?t(c(m.valueOf(),p,d),m.storage()):c(m,p,d);throw new RangeError("Matrix must be square (size: "+lr(v)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+lr(v)+")")}},any:function(m){return n(1,m)}});function c(f,m,v){var p,d,y,x,D;if(m===1){if(x=f[0][0],x===0)throw Error("Cannot calculate inverse, determinant is zero");return[[n(1,x)]]}else if(m===2){var h=l(f);if(h===0)throw Error("Cannot calculate inverse, determinant is zero");return[[n(f[1][1],h),n(o(f[0][1]),h)],[n(o(f[1][0]),h),n(f[0][0],h)]]}else{var w=f.concat();for(p=0;p<m;p++)w[p]=w[p].concat();for(var g=u(m).valueOf(),b=0;b<v;b++){var A=s(w[b][b]),N=b;for(p=b+1;p<m;)s(w[p][b])>A&&(A=s(w[p][b]),N=p),p++;if(A===0)throw Error("Cannot calculate inverse, determinant is zero");p=N,p!==b&&(D=w[b],w[b]=w[p],w[p]=D,D=g[b],g[b]=g[p],g[p]=D);var E=w[b],S=g[b];for(p=0;p<m;p++){var C=w[p],M=g[p];if(p!==b){if(C[b]!==0){for(y=n(o(C[b]),E[b]),d=b;d<v;d++)C[d]=a(C[d],i(y,E[d]));for(d=0;d<v;d++)M[d]=a(M[d],i(y,S[d]))}}else{for(y=E[b],d=b;d<v;d++)C[d]=n(C[d],y);for(d=0;d<v;d++)M[d]=n(M[d],y)}}}return g}}}),Cp="pinv",P3=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],$3=L(Cp,P3,r=>{var{typed:e,matrix:t,inv:n,deepEqual:a,equal:i,dotDivide:o,dot:l,ctranspose:u,divideScalar:s,multiply:c,add:f,Complex:m}=r;return e(Cp,{"Array | Matrix":function(h){var w=Je(h)?h.size():rr(h);switch(w.length){case 1:return x(h)?u(h):w[0]===1?n(h):o(u(h),l(h,h));case 2:{if(x(h))return u(h);var g=w[0],b=w[1];if(g===b)try{return n(h)}catch(A){if(!(A instanceof Error&&A.message.match(/Cannot calculate inverse, determinant is zero/)))throw A}return Je(h)?t(v(h.valueOf(),g,b),h.storage()):v(h,g,b)}default:throw new RangeError("Matrix must be two dimensional (size: "+lr(w)+")")}},any:function(h){return i(h,0)?er(h):s(1,h)}});function v(D,h,w){var{C:g,F:b}=d(D,h,w),A=c(n(c(u(g),g)),u(g)),N=c(u(b),n(c(b,u(b))));return c(N,A)}function p(D,h,w){for(var g=er(D),b=0,A=0;A<h;A++){if(w<=b)return g;for(var N=A;y(g[N][b]);)if(N++,h===N&&(N=A,b++,w===b))return g;[g[N],g[A]]=[g[A],g[N]];for(var E=g[A][b],S=0;S<w;S++)g[A][S]=o(g[A][S],E);for(var C=0;C<h;C++)if(C!==A){E=g[C][b];for(var M=0;M<w;M++)g[C][M]=f(g[C][M],c(-1,c(E,g[A][M])))}b++}return g}function d(D,h,w){var g=p(D,h,w),b=D.map((N,E)=>N.filter((S,C)=>C<h&&!y(l(g[C],g[C])))),A=g.filter((N,E)=>!y(l(g[E],g[E])));return{C:b,F:A}}function y(D){return i(f(D,m(1,1)),f(0,m(1,1)))}function x(D){return a(f(D,m(1,1)),f(c(D,0),m(1,1)))}});function q3(r){var{addScalar:e,subtract:t,flatten:n,multiply:a,multiplyScalar:i,divideScalar:o,sqrt:l,abs:u,bignumber:s,diag:c,size:f,reshape:m,inv:v,qr:p,usolve:d,usolveAll:y,equal:x,complex:D,larger:h,smaller:w,matrixFromColumns:g,dot:b}=r;function A(j,F,U,$){var le=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,me=N(j,F,U,$,le);E(j,F,U,$,le,me);var{values:Y,C:z}=S(j,F,U,$,le);if(le){var X=C(j,F,z,me,Y,U,$);return{values:Y,eigenvectors:X}}return{values:Y}}function N(j,F,U,$,le){var me=$==="BigNumber",Y=$==="Complex",z=me?s(0):0,X=me?s(1):Y?D(1):1,se=me?s(1):1,re=me?s(10):2,pe=i(re,re),ve;le&&(ve=Array(F).fill(X));for(var De=!1;!De;){De=!0;for(var Oe=0;Oe<F;Oe++){for(var Ie=z,_e=z,Le=0;Le<F;Le++)Oe!==Le&&(Ie=e(Ie,u(j[Le][Oe])),_e=e(_e,u(j[Oe][Le])));if(!x(Ie,0)&&!x(_e,0)){for(var qe=se,G=Ie,ee=o(_e,re),R=i(_e,re);w(G,ee);)G=i(G,pe),qe=i(qe,re);for(;h(G,R);)G=o(G,pe),qe=o(qe,re);var H=w(o(e(G,_e),qe),i(e(Ie,_e),.95));if(H){De=!1;for(var Q=o(1,qe),ie=0;ie<F;ie++)Oe!==ie&&(j[Oe][ie]=i(j[Oe][ie],Q),j[ie][Oe]=i(j[ie][Oe],qe));le&&(ve[Oe]=i(ve[Oe],Q))}}}}return le?c(ve):null}function E(j,F,U,$,le,me){var Y=$==="BigNumber",z=$==="Complex",X=Y?s(0):z?D(0):0;Y&&(U=s(U));for(var se=0;se<F-2;se++){for(var re=0,pe=X,ve=se+1;ve<F;ve++){var De=j[ve][se];w(u(pe),u(De))&&(pe=De,re=ve)}if(!w(u(pe),U)){if(re!==se+1){var Oe=j[re];j[re]=j[se+1],j[se+1]=Oe;for(var Ie=0;Ie<F;Ie++){var _e=j[Ie][re];j[Ie][re]=j[Ie][se+1],j[Ie][se+1]=_e}if(le){var Le=me[re];me[re]=me[se+1],me[se+1]=Le}}for(var qe=se+2;qe<F;qe++){var G=o(j[qe][se],pe);if(G!==0){for(var ee=0;ee<F;ee++)j[qe][ee]=t(j[qe][ee],i(G,j[se+1][ee]));for(var R=0;R<F;R++)j[R][se+1]=e(j[R][se+1],i(G,j[R][qe]));if(le)for(var H=0;H<F;H++)me[qe][H]=t(me[qe][H],i(G,me[se+1][H]))}}}}return me}function S(j,F,U,$,le){var me=$==="BigNumber",Y=$==="Complex",z=me?s(1):Y?D(1):1;me&&(U=s(U));for(var X=er(j),se=[],re=F,pe=[],ve=le?c(Array(F).fill(z)):void 0,De=le?c(Array(re).fill(z)):void 0,Oe=0;Oe<=100;){Oe+=1;for(var Ie=X[re-1][re-1],_e=0;_e<re;_e++)X[_e][_e]=t(X[_e][_e],Ie);var{Q:Le,R:qe}=p(X);X=a(qe,Le);for(var G=0;G<re;G++)X[G][G]=e(X[G][G],Ie);if(le&&(De=a(De,Le)),re===1||w(u(X[re-1][re-2]),U)){Oe=0,se.push(X[re-1][re-1]),le&&(pe.unshift([[1]]),I(De,F),ve=a(ve,De),re>1&&(De=c(Array(re-1).fill(z)))),re-=1,X.pop();for(var ee=0;ee<re;ee++)X[ee].pop()}else if(re===2||w(u(X[re-2][re-3]),U)){Oe=0;var R=M(X[re-2][re-2],X[re-2][re-1],X[re-1][re-2],X[re-1][re-1]);se.push(...R),le&&(pe.unshift(O(X[re-2][re-2],X[re-2][re-1],X[re-1][re-2],X[re-1][re-1],R[0],R[1],U,$)),I(De,F),ve=a(ve,De),re>2&&(De=c(Array(re-2).fill(z)))),re-=2,X.pop(),X.pop();for(var H=0;H<re;H++)X[H].pop(),X[H].pop()}if(re===0)break}if(se.sort((ue,oe)=>+t(u(ue),u(oe))),Oe>100){var Q=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+se.join(", "));throw Q.values=se,Q.vectors=[],Q}var ie=le?a(ve,k(pe,F)):void 0;return{values:se,C:ie}}function C(j,F,U,$,le,me,Y){var z=v(U),X=a(z,j,U),se=Y==="BigNumber",re=Y==="Complex",pe=se?s(0):re?D(0):0,ve=se?s(1):re?D(1):1,De=[],Oe=[];for(var Ie of le){var _e=_(De,Ie,x);_e===-1?(De.push(Ie),Oe.push(1)):Oe[_e]+=1}for(var Le=[],qe=De.length,G=Array(F).fill(pe),ee=c(Array(F).fill(ve)),R=function(){var ie=De[H],ue=t(X,a(ie,ee)),oe=y(ue,G);for(oe.shift();oe.length<Oe[H];){var we=P(ue,F,oe,me,Y);if(we===null)break;oe.push(we)}var xe=a(v($),U);oe=oe.map(Te=>a(xe,Te)),Le.push(...oe.map(Te=>({value:ie,vector:n(Te)})))},H=0;H<qe;H++)R();return Le}function M(j,F,U,$){var le=e(j,$),me=t(i(j,$),i(F,U)),Y=i(le,.5),z=i(l(t(i(le,le),i(4,me))),.5);return[e(Y,z),t(Y,z)]}function O(j,F,U,$,le,me,Y,z){var X=z==="BigNumber",se=z==="Complex",re=X?s(0):se?D(0):0,pe=X?s(1):se?D(1):1;if(w(u(U),Y))return[[pe,re],[re,pe]];if(h(u(t(le,me)),Y))return[[t(le,$),t(me,$)],[U,U]];var ve=t(j,le),De=t($,le);return w(u(F),Y)&&w(u(De),Y)?[[ve,pe],[U,re]]:[[F,re],[De,pe]]}function I(j,F){for(var U=0;U<j.length;U++)j[U].push(...Array(F-j[U].length).fill(0));for(var $=j.length;$<F;$++)j.push(Array(F).fill(0)),j[$][$]=1;return j}function k(j,F){for(var U=[],$=0;$<F;$++)U[$]=Array(F).fill(0);var le=0;for(var me of j){for(var Y=me.length,z=0;z<Y;z++)for(var X=0;X<Y;X++)U[le+z][le+X]=me[z][X];le+=Y}return U}function _(j,F,U){for(var $=0;$<j.length;$++)if(U(j[$],F))return $;return-1}function P(j,F,U,$,le){for(var me=le==="BigNumber"?s(1e3):1e3,Y,z=0;z<5;++z){Y=V(F,U,le);try{Y=d(j,Y)}catch{continue}if(h(J(Y),me))break}if(z>=5)return null;for(z=0;;){var X=d(j,Y);if(w(J(q(Y,[X])),$))break;if(++z>=10)return null;Y=ne(X)}return Y}function V(j,F,U){var $=U==="BigNumber",le=U==="Complex",me=Array(j).fill(0).map(Y=>2*Math.random()-1);return $&&(me=me.map(Y=>s(Y))),le&&(me=me.map(Y=>D(Y))),me=q(me,F),ne(me,U)}function q(j,F){var U=f(j);for(var $ of F)$=m($,U),j=t(j,a(o(b($,j),b($,$)),$));return j}function J(j){return u(l(b(j,j)))}function ne(j,F){var U=F==="BigNumber",$=F==="Complex",le=U?s(1):$?D(1):1;return a(o(le,J(j)),j)}return A}function z3(r){var{config:e,addScalar:t,subtract:n,abs:a,atan:i,cos:o,sin:l,multiplyScalar:u,inv:s,bignumber:c,multiply:f,add:m}=r;function v(E,S){var C=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.relTol,M=arguments.length>3?arguments[3]:void 0,O=arguments.length>4?arguments[4]:void 0;if(M==="number")return p(E,C,O);if(M==="BigNumber")return d(E,C,O);throw TypeError("Unsupported data type: "+M)}function p(E,S,C){var M=E.length,O=Math.abs(S/M),I,k;if(C){k=new Array(M);for(var _=0;_<M;_++)k[_]=Array(M).fill(0),k[_][_]=1}for(var P=b(E);Math.abs(P[1])>=Math.abs(O);){var V=P[0][0],q=P[0][1];I=y(E[V][V],E[q][q],E[V][q]),E=g(E,I,V,q),C&&(k=D(k,I,V,q)),P=b(E)}for(var J=Array(M).fill(0),ne=0;ne<M;ne++)J[ne]=E[ne][ne];return N(er(J),k,C)}function d(E,S,C){var M=E.length,O=a(S/M),I,k;if(C){k=new Array(M);for(var _=0;_<M;_++)k[_]=Array(M).fill(0),k[_][_]=1}for(var P=A(E);a(P[1])>=a(O);){var V=P[0][0],q=P[0][1];I=x(E[V][V],E[q][q],E[V][q]),E=w(E,I,V,q),C&&(k=h(k,I,V,q)),P=A(E)}for(var J=Array(M).fill(0),ne=0;ne<M;ne++)J[ne]=E[ne][ne];return N(er(J),k,C)}function y(E,S,C){var M=S-E;return Math.abs(M)<=e.relTol?Math.PI/4:.5*Math.atan(2*C/(S-E))}function x(E,S,C){var M=n(S,E);return a(M)<=e.relTol?c(-1).acos().div(4):u(.5,i(f(2,C,s(M))))}function D(E,S,C,M){for(var O=E.length,I=Math.cos(S),k=Math.sin(S),_=Array(O).fill(0),P=Array(O).fill(0),V=0;V<O;V++)_[V]=I*E[V][C]-k*E[V][M],P[V]=k*E[V][C]+I*E[V][M];for(var q=0;q<O;q++)E[q][C]=_[q],E[q][M]=P[q];return E}function h(E,S,C,M){for(var O=E.length,I=o(S),k=l(S),_=Array(O).fill(c(0)),P=Array(O).fill(c(0)),V=0;V<O;V++)_[V]=n(u(I,E[V][C]),u(k,E[V][M])),P[V]=t(u(k,E[V][C]),u(I,E[V][M]));for(var q=0;q<O;q++)E[q][C]=_[q],E[q][M]=P[q];return E}function w(E,S,C,M){for(var O=E.length,I=c(o(S)),k=c(l(S)),_=u(I,I),P=u(k,k),V=Array(O).fill(c(0)),q=Array(O).fill(c(0)),J=f(c(2),I,k,E[C][M]),ne=t(n(u(_,E[C][C]),J),u(P,E[M][M])),j=m(u(P,E[C][C]),J,u(_,E[M][M])),F=0;F<O;F++)V[F]=n(u(I,E[C][F]),u(k,E[M][F])),q[F]=t(u(k,E[C][F]),u(I,E[M][F]));E[C][C]=ne,E[M][M]=j,E[C][M]=c(0),E[M][C]=c(0);for(var U=0;U<O;U++)U!==C&&U!==M&&(E[C][U]=V[U],E[U][C]=V[U],E[M][U]=q[U],E[U][M]=q[U]);return E}function g(E,S,C,M){for(var O=E.length,I=Math.cos(S),k=Math.sin(S),_=I*I,P=k*k,V=Array(O).fill(0),q=Array(O).fill(0),J=_*E[C][C]-2*I*k*E[C][M]+P*E[M][M],ne=P*E[C][C]+2*I*k*E[C][M]+_*E[M][M],j=0;j<O;j++)V[j]=I*E[C][j]-k*E[M][j],q[j]=k*E[C][j]+I*E[M][j];E[C][C]=J,E[M][M]=ne,E[C][M]=0,E[M][C]=0;for(var F=0;F<O;F++)F!==C&&F!==M&&(E[C][F]=V[F],E[F][C]=V[F],E[M][F]=q[F],E[F][M]=q[F]);return E}function b(E){for(var S=E.length,C=0,M=[0,1],O=0;O<S;O++)for(var I=O+1;I<S;I++)Math.abs(C)<Math.abs(E[O][I])&&(C=Math.abs(E[O][I]),M=[O,I]);return[M,C]}function A(E){for(var S=E.length,C=0,M=[0,1],O=0;O<S;O++)for(var I=O+1;I<S;I++)a(C)<a(E[O][I])&&(C=a(E[O][I]),M=[O,I]);return[M,C]}function N(E,S,C){var M=E.length,O=Array(M),I;if(C){I=Array(M);for(var k=0;k<M;k++)I[k]=Array(M)}for(var _=0;_<M;_++){for(var P=0,V=E[0],q=0;q<E.length;q++)a(E[q])<a(V)&&(P=q,V=E[P]);if(O[_]=E.splice(P,1)[0],C)for(var J=0;J<M;J++)I[_][J]=S[J][P],S[J].splice(P,1)}if(!C)return{values:O};var ne=I.map((j,F)=>({value:O[F],vector:j}));return{values:O,eigenvectors:ne}}return v}var U3="eigs",L3=["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"],k3=L(U3,L3,r=>{var{config:e,typed:t,matrix:n,addScalar:a,subtract:i,equal:o,abs:l,atan:u,cos:s,sin:c,multiplyScalar:f,divideScalar:m,inv:v,bignumber:p,multiply:d,add:y,larger:x,column:D,flatten:h,number:w,complex:g,sqrt:b,diag:A,size:N,reshape:E,qr:S,usolve:C,usolveAll:M,im:O,re:I,smaller:k,matrixFromColumns:_,dot:P}=r,V=z3({config:e,addScalar:a,subtract:i,abs:l,atan:u,cos:s,sin:c,multiplyScalar:f,inv:v,bignumber:p,multiply:d,add:y}),q=q3({addScalar:a,subtract:i,multiply:d,multiplyScalar:f,flatten:h,divideScalar:m,sqrt:b,abs:l,bignumber:p,diag:A,size:N,reshape:E,qr:S,inv:v,usolve:C,usolveAll:M,equal:o,complex:g,larger:x,smaller:k,matrixFromColumns:_,dot:P});return t("eigs",{Array:function(me){return J(n(me))},"Array, number|BigNumber":function(me,Y){return J(n(me),{precision:Y})},"Array, Object"(le,me){return J(n(le),me)},Matrix:function(me){return J(me,{matricize:!0})},"Matrix, number|BigNumber":function(me,Y){return J(me,{precision:Y,matricize:!0})},"Matrix, Object":function(me,Y){var z={matricize:!0};return zr(z,Y),J(me,z)}});function J(le){var me,Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},z="eigenvectors"in Y?Y.eigenvectors:!0,X=(me=Y.precision)!==null&&me!==void 0?me:e.relTol,se=ne(le,X,z);return Y.matricize&&(se.values=n(se.values),z&&(se.eigenvectors=se.eigenvectors.map(re=>{var{value:pe,vector:ve}=re;return{value:pe,vector:n(ve)}}))),z&&Object.defineProperty(se,"vectors",{enumerable:!1,get:()=>{throw new Error("eigs(M).vectors replaced with eigs(M).eigenvectors")}}),se}function ne(le,me,Y){var z=le.toArray(),X=le.size();if(X.length!==2||X[0]!==X[1])throw new RangeError("Matrix must be square (size: ".concat(lr(X),")"));var se=X[0];if(F(z,se,me)&&(U(z,se),j(z,se,me))){var re=$(le,z,se);return V(z,se,me,re,Y)}var pe=$(le,z,se);return q(z,se,me,pe,Y)}function j(le,me,Y){for(var z=0;z<me;z++)for(var X=z;X<me;X++)if(x(p(l(i(le[z][X],le[X][z]))),Y))return!1;return!0}function F(le,me,Y){for(var z=0;z<me;z++)for(var X=0;X<me;X++)if(x(p(l(O(le[z][X]))),Y))return!1;return!0}function U(le,me){for(var Y=0;Y<me;Y++)for(var z=0;z<me;z++)le[Y][z]=I(le[Y][z])}function $(le,me,Y){var z=le.datatype();if(z==="number"||z==="BigNumber"||z==="Complex")return z;for(var X=!1,se=!1,re=!1,pe=0;pe<Y;pe++)for(var ve=0;ve<Y;ve++){var De=me[pe][ve];if(Ye(De)||Ka(De))X=!0;else if(or(De))se=!0;else if(ln(De))re=!0;else throw TypeError("Unsupported type in Matrix: "+Sr(De))}if(se&&re&&console.warn("Complex BigNumbers not supported, this operation will lose precission."),re){for(var Oe=0;Oe<Y;Oe++)for(var Ie=0;Ie<Y;Ie++)me[Oe][Ie]=g(me[Oe][Ie]);return"Complex"}if(se){for(var _e=0;_e<Y;_e++)for(var Le=0;Le<Y;Le++)me[_e][Le]=p(me[_e][Le]);return"BigNumber"}if(X){for(var qe=0;qe<Y;qe++)for(var G=0;G<Y;G++)me[qe][G]=w(me[qe][G]);return"number"}else throw TypeError("Matrix contains unsupported types only.")}}),Mp="expm",V3=["typed","abs","add","identity","inv","multiply"],G3=L(Mp,V3,r=>{var{typed:e,abs:t,add:n,identity:a,inv:i,multiply:o}=r;return e(Mp,{Matrix:function(f){var m=f.size();if(m.length!==2||m[0]!==m[1])throw new RangeError("Matrix must be square (size: "+lr(m)+")");for(var v=m[0],p=1e-15,d=l(f),y=u(d,p),x=y.q,D=y.j,h=o(f,Math.pow(2,-D)),w=a(v),g=a(v),b=1,A=h,N=-1,E=1;E<=x;E++)E>1&&(A=o(A,h),N=-N),b=b*(x-E+1)/((2*x-E+1)*E),w=n(w,o(b,A)),g=n(g,o(b*N,A));for(var S=o(i(g),w),C=0;C<D;C++)S=o(S,S);return Yn(f)?f.createSparseMatrix(S):S}});function l(c){for(var f=c.size()[0],m=0,v=0;v<f;v++){for(var p=0,d=0;d<f;d++)p+=t(c.get([v,d]));m=Math.max(p,m)}return m}function u(c,f){for(var m=30,v=0;v<m;v++)for(var p=0;p<=v;p++){var d=v-p;if(s(c,p,d)<f)return{q:p,j:d}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}function s(c,f,m){for(var v=1,p=2;p<=f;p++)v*=p;for(var d=v,y=f+1;y<=2*f;y++)d*=y;var x=d*(2*f+1);return 8*Math.pow(c/Math.pow(2,m),2*f)*v*v/(d*x)}}),_p="sqrtm",H3=["typed","abs","add","multiply","map","sqrt","subtract","inv","size","max","identity"],W3=L(_p,H3,r=>{var{typed:e,abs:t,add:n,multiply:a,map:i,sqrt:o,subtract:l,inv:u,size:s,max:c,identity:f}=r,m=1e3,v=1e-6;function p(d){var y,x=0,D=d,h=f(s(d));do{var w=D;if(D=a(.5,n(w,u(h))),h=a(.5,n(h,u(w))),y=c(t(l(D,w))),y>v&&++x>m)throw new Error("computing square root of matrix: iterative method could not converge")}while(y>v);return D}return e(_p,{"Array | Matrix":function(y){var x=Je(y)?y.size():rr(y);switch(x.length){case 1:if(x[0]===1)return i(y,o);throw new RangeError("Matrix must be square (size: "+lr(x)+")");case 2:{var D=x[0],h=x[1];if(D===h)return p(y);throw new RangeError("Matrix must be square (size: "+lr(x)+")")}default:throw new RangeError("Matrix must be at most two dimensional (size: "+lr(x)+")")}}})}),Tp="sylvester",Y3=["typed","schur","matrixFromColumns","matrix","multiply","range","concat","transpose","index","subset","add","subtract","identity","lusolve","abs"],Z3=L(Tp,Y3,r=>{var{typed:e,schur:t,matrixFromColumns:n,matrix:a,multiply:i,range:o,concat:l,transpose:u,index:s,subset:c,add:f,subtract:m,identity:v,lusolve:p,abs:d,config:y}=r;return e(Tp,{"Matrix, Matrix, Matrix":x,"Array, Matrix, Matrix":function(h,w,g){return x(a(h),w,g)},"Array, Array, Matrix":function(h,w,g){return x(a(h),a(w),g)},"Array, Matrix, Array":function(h,w,g){return x(a(h),w,a(g))},"Matrix, Array, Matrix":function(h,w,g){return x(h,a(w),g)},"Matrix, Array, Array":function(h,w,g){return x(h,a(w),a(g))},"Matrix, Matrix, Array":function(h,w,g){return x(h,w,a(g))},"Array, Array, Array":function(h,w,g){return x(a(h),a(w),a(g)).toArray()}});function x(D,h,w){for(var g=h.size()[0],b=D.size()[0],A=t(D),N=A.T,E=A.U,S=t(i(-1,h)),C=S.T,M=S.U,O=i(i(u(E),w),M),I=o(0,b),k=[],_=(pe,ve)=>l(pe,ve,1),P=(pe,ve)=>l(pe,ve,0),V=0;V<g;V++)if(V<g-1&&d(c(C,s(V+1,V)))>1e-5){for(var q=P(c(O,s(I,[V])),c(O,s(I,[V+1]))),J=0;J<V;J++)q=f(q,P(i(k[J],c(C,s(J,V))),i(k[J],c(C,s(J,V+1)))));var ne=i(v(b),i(-1,c(C,s(V,V)))),j=i(v(b),i(-1,c(C,s(V+1,V)))),F=i(v(b),i(-1,c(C,s(V,V+1)))),U=i(v(b),i(-1,c(C,s(V+1,V+1)))),$=P(_(f(N,ne),j),_(F,f(N,U))),le=p($,q);k[V]=le.subset(s(o(0,b),[0])),k[V+1]=le.subset(s(o(b,2*b),[0])),V++}else{for(var me=c(O,s(I,[V])),Y=0;Y<V;Y++)me=f(me,i(k[Y],c(C,s(Y,V))));var z=c(C,s(V,V)),X=m(N,i(z,v(b)));k[V]=p(X,me)}var se=a(n(...k)),re=i(E,i(se,u(M)));return re}}),Fp="schur",J3=["typed","matrix","identity","multiply","qr","norm","subtract"],j3=L(Fp,J3,r=>{var{typed:e,matrix:t,identity:n,multiply:a,qr:i,norm:o,subtract:l}=r;return e(Fp,{Array:function(c){var f=u(t(c));return{U:f.U.valueOf(),T:f.T.valueOf()}},Matrix:function(c){return u(c)}});function u(s){var c=s.size()[0],f=s,m=n(c),v=0,p;do{p=f;var d=i(f),y=d.Q,x=d.R;if(f=a(x,y),m=a(m,y),v++>100)break}while(o(l(f,p))>1e-4);return{U:m,T:f}}}),Op="lyap",X3=["typed","matrix","sylvester","multiply","transpose"],Q3=L(Op,X3,r=>{var{typed:e,matrix:t,sylvester:n,multiply:a,transpose:i}=r;return e(Op,{"Matrix, Matrix":function(l,u){return n(l,i(l),a(-1,u))},"Array, Matrix":function(l,u){return n(t(l),i(t(l)),a(-1,u))},"Matrix, Array":function(l,u){return n(l,i(t(l)),t(a(-1,u)))},"Array, Array":function(l,u){return n(t(l),i(t(l)),t(a(-1,u))).toArray()}})}),K3="divide",eO=["typed","matrix","multiply","equalScalar","divideScalar","inv"],rO=L(K3,eO,r=>{var{typed:e,matrix:t,multiply:n,equalScalar:a,divideScalar:i,inv:o}=r,l=nt({typed:e,equalScalar:a}),u=Ut({typed:e});return e("divide",Ku({"Array | Matrix, Array | Matrix":function(c,f){return n(c,o(f))},"DenseMatrix, any":function(c,f){return u(c,f,i,!1)},"SparseMatrix, any":function(c,f){return l(c,f,i,!1)},"Array, any":function(c,f){return u(t(c),f,i,!1).valueOf()},"any, Array | Matrix":function(c,f){return n(c,o(f))}},i.signatures))}),Bp="distance",tO=["typed","addScalar","subtractScalar","divideScalar","multiplyScalar","deepEqual","sqrt","abs"],nO=L(Bp,tO,r=>{var{typed:e,addScalar:t,subtractScalar:n,multiplyScalar:a,divideScalar:i,deepEqual:o,sqrt:l,abs:u}=r;return e(Bp,{"Array, Array, Array":function(g,b,A){if(g.length===2&&b.length===2&&A.length===2){if(!c(g))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!c(b))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!c(A))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(o(b,A))throw new TypeError("LinePoint1 should not be same with LinePoint2");var N=n(A[1],b[1]),E=n(b[0],A[0]),S=n(a(A[0],b[1]),a(b[0],A[1]));return y(g[0],g[1],N,E,S)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(g,b,A){if(Object.keys(g).length===2&&Object.keys(b).length===2&&Object.keys(A).length===2){if(!c(g))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!c(b))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!c(A))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if(o(p(b),p(A)))throw new TypeError("LinePoint1 should not be same with LinePoint2");if("pointX"in g&&"pointY"in g&&"lineOnePtX"in b&&"lineOnePtY"in b&&"lineTwoPtX"in A&&"lineTwoPtY"in A){var N=n(A.lineTwoPtY,b.lineOnePtY),E=n(b.lineOnePtX,A.lineTwoPtX),S=n(a(A.lineTwoPtX,b.lineOnePtY),a(b.lineOnePtX,A.lineTwoPtY));return y(g.pointX,g.pointY,N,E,S)}else throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(g,b){if(g.length===2&&b.length===3){if(!c(g))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!f(b))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return y(g[0],g[1],b[0],b[1],b[2])}else if(g.length===3&&b.length===6){if(!f(g))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!v(b))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return x(g[0],g[1],g[2],b[0],b[1],b[2],b[3],b[4],b[5])}else if(g.length===b.length&&g.length>0){if(!m(g))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!m(b))throw new TypeError("All values of an array should be numbers or BigNumbers");return D(g,b)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(g,b){if(Object.keys(g).length===2&&Object.keys(b).length===3){if(!c(g))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!f(b))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in g&&"pointY"in g&&"xCoeffLine"in b&&"yCoeffLine"in b&&"constant"in b)return y(g.pointX,g.pointY,b.xCoeffLine,b.yCoeffLine,b.constant);throw new TypeError("Key names do not match")}else if(Object.keys(g).length===3&&Object.keys(b).length===6){if(!f(g))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!v(b))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in g&&"pointY"in g&&"x0"in b&&"y0"in b&&"z0"in b&&"a"in b&&"b"in b&&"c"in b)return x(g.pointX,g.pointY,g.pointZ,b.x0,b.y0,b.z0,b.a,b.b,b.c);throw new TypeError("Key names do not match")}else if(Object.keys(g).length===2&&Object.keys(b).length===2){if(!c(g))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!c(b))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in g&&"pointOneY"in g&&"pointTwoX"in b&&"pointTwoY"in b)return D([g.pointOneX,g.pointOneY],[b.pointTwoX,b.pointTwoY]);throw new TypeError("Key names do not match")}else if(Object.keys(g).length===3&&Object.keys(b).length===3){if(!f(g))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!f(b))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in g&&"pointOneY"in g&&"pointOneZ"in g&&"pointTwoX"in b&&"pointTwoY"in b&&"pointTwoZ"in b)return D([g.pointOneX,g.pointOneY,g.pointOneZ],[b.pointTwoX,b.pointTwoY,b.pointTwoZ]);throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},Array:function(g){if(!d(g))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return h(g)}});function s(w){return typeof w=="number"||or(w)}function c(w){return w.constructor!==Array&&(w=p(w)),s(w[0])&&s(w[1])}function f(w){return w.constructor!==Array&&(w=p(w)),s(w[0])&&s(w[1])&&s(w[2])}function m(w){return Array.isArray(w)||(w=p(w)),w.every(s)}function v(w){return w.constructor!==Array&&(w=p(w)),s(w[0])&&s(w[1])&&s(w[2])&&s(w[3])&&s(w[4])&&s(w[5])}function p(w){for(var g=Object.keys(w),b=[],A=0;A<g.length;A++)b.push(w[g[A]]);return b}function d(w){if(w[0].length===2&&s(w[0][0])&&s(w[0][1])){if(w.some(g=>g.length!==2||!s(g[0])||!s(g[1])))return!1}else if(w[0].length===3&&s(w[0][0])&&s(w[0][1])&&s(w[0][2])){if(w.some(g=>g.length!==3||!s(g[0])||!s(g[1])||!s(g[2])))return!1}else return!1;return!0}function y(w,g,b,A,N){var E=u(t(t(a(b,w),a(A,g)),N)),S=l(t(a(b,b),a(A,A)));return i(E,S)}function x(w,g,b,A,N,E,S,C,M){var O=[n(a(n(N,g),M),a(n(E,b),C)),n(a(n(E,b),S),a(n(A,w),M)),n(a(n(A,w),C),a(n(N,g),S))];O=l(t(t(a(O[0],O[0]),a(O[1],O[1])),a(O[2],O[2])));var I=l(t(t(a(S,S),a(C,C)),a(M,M)));return i(O,I)}function D(w,g){for(var b=w.length,A=0,N=0,E=0;E<b;E++)N=n(w[E],g[E]),A=t(a(N,N),A);return l(A)}function h(w){for(var g=[],b=[],A=[],N=0;N<w.length-1;N++)for(var E=N+1;E<w.length;E++)w[0].length===2?(b=[w[N][0],w[N][1]],A=[w[E][0],w[E][1]]):w[0].length===3&&(b=[w[N][0],w[N][1],w[N][2]],A=[w[E][0],w[E][1],w[E][2]]),g.push(D(b,A));return g}}),aO="intersect",iO=["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],oO=L(aO,iO,r=>{var{typed:e,config:t,abs:n,add:a,addScalar:i,matrix:o,multiply:l,multiplyScalar:u,divideScalar:s,subtract:c,smaller:f,equalScalar:m,flatten:v,isZero:p,isNumeric:d}=r;return e("intersect",{"Array, Array, Array":y,"Array, Array, Array, Array":x,"Matrix, Matrix, Matrix":function(C,M,O){var I=y(C.valueOf(),M.valueOf(),O.valueOf());return I===null?null:o(I)},"Matrix, Matrix, Matrix, Matrix":function(C,M,O,I){var k=x(C.valueOf(),M.valueOf(),O.valueOf(),I.valueOf());return k===null?null:o(k)}});function y(S,C,M){if(S=D(S),C=D(C),M=D(M),!w(S))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!w(C))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!g(M))throw new TypeError("Array with 4 numbers expected as third argument");return E(S[0],S[1],S[2],C[0],C[1],C[2],M[0],M[1],M[2],M[3])}function x(S,C,M,O){if(S=D(S),C=D(C),M=D(M),O=D(O),S.length===2){if(!h(S))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!h(C))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!h(M))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!h(O))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return b(S,C,M,O)}else if(S.length===3){if(!w(S))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!w(C))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!w(M))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!w(O))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return N(S[0],S[1],S[2],C[0],C[1],C[2],M[0],M[1],M[2],O[0],O[1],O[2])}else throw new TypeError("Arrays with two or thee dimensional points expected")}function D(S){return S.length===1?S[0]:S.length>1&&Array.isArray(S[0])&&S.every(C=>Array.isArray(C)&&C.length===1)?v(S):S}function h(S){return S.length===2&&d(S[0])&&d(S[1])}function w(S){return S.length===3&&d(S[0])&&d(S[1])&&d(S[2])}function g(S){return S.length===4&&d(S[0])&&d(S[1])&&d(S[2])&&d(S[3])}function b(S,C,M,O){var I=S,k=M,_=c(I,C),P=c(k,O),V=c(u(_[0],P[1]),u(P[0],_[1]));if(p(V)||f(n(V),t.relTol))return null;var q=u(P[0],I[1]),J=u(P[1],I[0]),ne=u(P[0],k[1]),j=u(P[1],k[0]),F=s(i(c(c(q,J),ne),j),V);return a(l(_,F),I)}function A(S,C,M,O,I,k,_,P,V,q,J,ne){var j=u(c(S,C),c(M,O)),F=u(c(I,k),c(_,P)),U=u(c(V,q),c(J,ne));return i(i(j,F),U)}function N(S,C,M,O,I,k,_,P,V,q,J,ne){var j=A(S,_,q,_,C,P,J,P,M,V,ne,V),F=A(q,_,O,S,J,P,I,C,ne,V,k,M),U=A(S,_,O,S,C,P,I,C,M,V,k,M),$=A(q,_,q,_,J,P,J,P,ne,V,ne,V),le=A(O,S,O,S,I,C,I,C,k,M,k,M),me=c(u(j,F),u(U,$)),Y=c(u(le,$),u(F,F));if(p(Y))return null;var z=s(me,Y),X=s(i(j,u(z,F)),$),se=i(S,u(z,c(O,S))),re=i(C,u(z,c(I,C))),pe=i(M,u(z,c(k,M))),ve=i(_,u(X,c(q,_))),De=i(P,u(X,c(J,P))),Oe=i(V,u(X,c(ne,V)));return m(se,ve)&&m(re,De)&&m(pe,Oe)?[se,re,pe]:null}function E(S,C,M,O,I,k,_,P,V,q){var J=u(S,_),ne=u(O,_),j=u(C,P),F=u(I,P),U=u(M,V),$=u(k,V),le=c(c(c(q,J),j),U),me=c(c(c(i(i(ne,F),$),J),j),U),Y=s(le,me),z=i(S,u(Y,c(O,S))),X=i(C,u(Y,c(I,C))),se=i(M,u(Y,c(k,M)));return[z,X,se]}}),Rp="sum",sO=["typed","config","add","numeric"],Ip=L(Rp,sO,r=>{var{typed:e,config:t,add:n,numeric:a}=r;return e(Rp,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":o,"...":function(u){if(Sa(u))throw new TypeError("Scalar values expected in function sum");return i(u)}});function i(l){var u;return Rn(l,function(s){try{u=u===void 0?s:n(u,s)}catch(c){throw dt(c,"sum",s)}}),u===void 0&&(u=a(0,t.number)),typeof u=="string"&&(u=a(u,An(u,t))),u}function o(l,u){try{var s=Qi(l,u,n);return s}catch(c){throw dt(c,"sum")}}}),Oo="cumsum",uO=["typed","add","unaryPlus"],Pp=L(Oo,uO,r=>{var{typed:e,add:t,unaryPlus:n}=r;return e(Oo,{Array:a,Matrix:function(s){return s.create(a(s.valueOf(),s.datatype()))},"Array, number | BigNumber":o,"Matrix, number | BigNumber":function(s,c){return s.create(o(s.valueOf(),c),s.datatype())},"...":function(s){if(Sa(s))throw new TypeError("All values expected to be scalar in function cumsum");return a(s)}});function a(u){try{return i(u)}catch(s){throw dt(s,Oo)}}function i(u){if(u.length===0)return[];for(var s=[n(u[0])],c=1;c<u.length;++c)s.push(t(s[c-1],u[c]));return s}function o(u,s){var c=rr(u);if(s<0||s>=c.length)throw new Yt(s,c.length);try{return l(u,s)}catch(f){throw dt(f,Oo)}}function l(u,s){var c,f,m;if(s<=0){var v=u[0][0];if(Array.isArray(v)){for(m=Gl(u),f=[],c=0;c<m.length;c++)f[c]=l(m[c],s-1);return f}else return i(u)}else{for(f=[],c=0;c<u.length;c++)f[c]=l(u[c],s-1);return f}}}),$p="mean",lO=["typed","add","divide"],qp=L($p,lO,r=>{var{typed:e,add:t,divide:n}=r;return e($p,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":a,"...":function(l){if(Sa(l))throw new TypeError("Scalar values expected in function mean");return i(l)}});function a(o,l){try{var u=Qi(o,l,t),s=Array.isArray(o)?rr(o):o.size();return n(u,s[l])}catch(c){throw dt(c,"mean")}}function i(o){var l,u=0;if(Rn(o,function(s){try{l=l===void 0?s:t(l,s),u++}catch(c){throw dt(c,"mean",s)}}),u===0)throw new Error("Cannot calculate the mean of an empty array");return n(l,u)}}),zp="median",cO=["typed","add","divide","compare","partitionSelect"],fO=L(zp,cO,r=>{var{typed:e,add:t,divide:n,compare:a,partitionSelect:i}=r;function o(s){try{s=yr(s.valueOf());var c=s.length;if(c===0)throw new Error("Cannot calculate median of an empty array");if(c%2===0){for(var f=c/2-1,m=i(s,f+1),v=s[f],p=0;p<f;++p)a(s[p],v)>0&&(v=s[p]);return u(v,m)}else{var d=i(s,(c-1)/2);return l(d)}}catch(y){throw dt(y,"median")}}var l=e({"number | BigNumber | Complex | Unit":function(c){return c}}),u=e({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(c,f){return n(t(c,f),2)}});return e(zp,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(c,f){throw new Error("median(A, dim) is not yet supported")},"...":function(c){if(Sa(c))throw new TypeError("Scalar values expected in function median");return o(c)}})}),Up="mad",mO=["typed","abs","map","median","subtract"],vO=L(Up,mO,r=>{var{typed:e,abs:t,map:n,median:a,subtract:i}=r;return e(Up,{"Array | Matrix":o,"...":function(u){return o(u)}});function o(l){if(l=yr(l.valueOf()),l.length===0)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var u=a(l);return a(n(l,function(s){return t(i(s,u))}))}catch(s){throw s instanceof TypeError&&s.message.includes("median")?new TypeError(s.message.replace("median","mad")):dt(s,"mad")}}}),Ls="unbiased",Lp="variance",pO=["typed","add","subtract","multiply","divide","mapSlices","isNaN"],kp=L(Lp,pO,r=>{var{typed:e,add:t,subtract:n,multiply:a,divide:i,mapSlices:o,isNaN:l}=r;return e(Lp,{"Array | Matrix":function(f){return u(f,Ls)},"Array | Matrix, string":u,"Array | Matrix, number | BigNumber":function(f,m){return s(f,m,Ls)},"Array | Matrix, number | BigNumber, string":s,"...":function(f){return u(f,Ls)}});function u(c,f){var m,v=0;if(c.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Rn(c,function(y){try{m=m===void 0?y:t(m,y),v++}catch(x){throw dt(x,"variance",y)}}),v===0)throw new Error("Cannot calculate variance of an empty array");var p=i(m,v);if(m=void 0,Rn(c,function(y){var x=n(y,p);m=m===void 0?a(x,x):t(m,a(x,x))}),l(m))return m;switch(f){case"uncorrected":return i(m,v);case"biased":return i(m,v+1);case"unbiased":{var d=or(m)?m.mul(0):0;return v===1?d:i(m,v-1)}default:throw new Error('Unknown normalization "'+f+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function s(c,f,m){try{if(c.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return o(c,f,v=>u(v,m))}catch(v){throw dt(v,"variance")}}}),Vp="quantileSeq",dO=["typed","?bignumber","add","subtract","divide","multiply","partitionSelect","compare","isInteger","smaller","smallerEq","larger","mapSlices"],Gp=L(Vp,dO,r=>{var{typed:e,bignumber:t,add:n,subtract:a,divide:i,multiply:o,partitionSelect:l,compare:u,isInteger:s,smaller:c,smallerEq:f,larger:m,mapSlices:v}=r;return e(Vp,{"Array | Matrix, number | BigNumber":(D,h)=>d(D,h,!1),"Array | Matrix, number | BigNumber, number":(D,h,w)=>p(D,h,!1,w,d),"Array | Matrix, number | BigNumber, boolean":d,"Array | Matrix, number | BigNumber, boolean, number":(D,h,w,g)=>p(D,h,w,g,d),"Array | Matrix, Array | Matrix":(D,h)=>y(D,h,!1),"Array | Matrix, Array | Matrix, number":(D,h,w)=>p(D,h,!1,w,y),"Array | Matrix, Array | Matrix, boolean":y,"Array | Matrix, Array | Matrix, boolean, number":(D,h,w,g)=>p(D,h,w,g,y)});function p(D,h,w,g,b){return v(D,g,A=>b(A,h,w))}function d(D,h,w){var g,b=D.valueOf();if(c(h,0))throw new Error("N/prob must be non-negative");if(f(h,1))return Ye(h)?x(b,h,w):t(x(b,h,w));if(m(h,1)){if(!s(h))throw new Error("N must be a positive integer");if(m(h,4294967295))throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var A=n(h,1);g=[];for(var N=0;c(N,h);N++){var E=i(N+1,A);g.push(x(b,E,w))}return Ye(h)?g:t(g)}}function y(D,h,w){for(var g=D.valueOf(),b=h.valueOf(),A=[],N=0;N<b.length;++N)A.push(x(g,b[N],w));return A}function x(D,h,w){var g=yr(D),b=g.length;if(b===0)throw new Error("Cannot calculate quantile of an empty sequence");var A=Ye(h)?h*(b-1):h.times(b-1),N=Ye(h)?Math.floor(A):A.floor().toNumber(),E=Ye(h)?A%1:A.minus(N);if(s(A))return w?g[A]:l(g,Ye(h)?A:A.valueOf());var S,C;if(w)S=g[N],C=g[N+1];else{C=l(g,N+1),S=g[N];for(var M=0;M<N;++M)u(g[M],S)>0&&(S=g[M])}return n(o(S,a(1,E)),o(C,E))}}),Hp="std",hO=["typed","map","sqrt","variance"],Wp=L(Hp,hO,r=>{var{typed:e,map:t,sqrt:n,variance:a}=r;return e(Hp,{"Array | Matrix":i,"Array | Matrix, string":i,"Array | Matrix, number | BigNumber":i,"Array | Matrix, number | BigNumber, string":i,"...":function(l){return i(l)}});function i(o,l){if(o.length===0)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{var u=a.apply(null,arguments);return Mt(u)?t(u,n):n(u)}catch(s){throw s instanceof TypeError&&s.message.includes(" variance")?new TypeError(s.message.replace(" variance"," std")):s}}}),Yp="corr",gO=["typed","matrix","mean","sqrt","sum","add","subtract","multiply","pow","divide"],yO=L(Yp,gO,r=>{var{typed:e,matrix:t,sqrt:n,sum:a,add:i,subtract:o,multiply:l,pow:u,divide:s}=r;return e(Yp,{"Array, Array":function(v,p){return c(v,p)},"Matrix, Matrix":function(v,p){var d=c(v.toArray(),p.toArray());return Array.isArray(d)?t(d):d}});function c(m,v){var p=[];if(Array.isArray(m[0])&&Array.isArray(v[0])){if(m.length!==v.length)throw new SyntaxError("Dimension mismatch. Array A and B must have the same length.");for(var d=0;d<m.length;d++){if(m[d].length!==v[d].length)throw new SyntaxError("Dimension mismatch. Array A and B must have the same number of elements.");p.push(f(m[d],v[d]))}return p}else{if(m.length!==v.length)throw new SyntaxError("Dimension mismatch. Array A and B must have the same number of elements.");return f(m,v)}}function f(m,v){var p=m.length,d=a(m),y=a(v),x=m.reduce((b,A,N)=>i(b,l(A,v[N])),0),D=a(m.map(b=>u(b,2))),h=a(v.map(b=>u(b,2))),w=o(l(p,x),l(d,y)),g=n(l(o(l(p,D),u(d,2)),o(l(p,h),u(y,2))));return s(w,g)}}),Zp="bernoulli",bO=["typed","config","isInteger","number","?BigNumber","?Fraction"],xO=L(Zp,bO,r=>{var{typed:e,config:t,number:n,BigNumber:a,Fraction:i}=r,o=[void 0],l=[void 0],u=[void 0],s=50;return e(Zp,{number:c=>ks(c,f=>f,o,(f,m)=>f+m,(f,m)=>f*m,(f,m)=>f/m),"bigint | Fraction":c=>ks(n(c),f=>new i(f),l,(f,m)=>f.add(m),(f,m)=>f.mul(m),(f,m)=>f.div(m)),BigNumber:c=>(t.precision!==s&&(u=[void 0],s=t.precision),ks(n(c),f=>new a(f),u,(f,m)=>f.add(m),(f,m)=>f.mul(m),(f,m)=>f.div(m)))})});function ks(r,e,t,n,a,i){if(r<0||!Ue(r))throw new RangeError("Bernoulli index must be nonnegative integer");if(r===0)return e(1);if(r===1)return i(e(-1),e(2));if(r%2===1)return e(0);var o=e(1);t.length===1&&t.push([i(o,e(-3)),i(o,e(-2)),i(o,e(6))]);for(var l=r/2,u=e(0),s=e(2);t.length<=l;){for(var c=t.length,f=Math.floor((c+1)/2),m=u,v=1;v<f;++v)m=n(m,a(t[v][0],t[c-v][0]));m=a(m,s),c%2===0&&(m=n(m,a(t[f][0],t[f][0]))),m=i(m,e(-(2*c+1)));var p=i(a(t[c-1][1],e(-c*(2*c-1))),s);t.push([m,p,a(p,m)])}return t[l][2]}var Jp="combinations",wO=["typed"],DO=L(Jp,wO,r=>{var{typed:e}=r;return e(Jp,{"number, number":dc,"BigNumber, BigNumber":function(n,a){var i=n.constructor,o,l,u=n.minus(a),s=new i(1);if(!jp(n)||!jp(a))throw new TypeError("Positive integer value expected in function combinations");if(a.gt(n))throw new TypeError("k must be less than n in function combinations");if(o=s,a.lt(u))for(l=s;l.lte(u);l=l.plus(s))o=o.times(a.plus(l)).dividedBy(l);else for(l=s;l.lte(a);l=l.plus(s))o=o.times(u.plus(l)).dividedBy(l);return o}})});function jp(r){return r.isInteger()&&r.gte(0)}var Xp="combinationsWithRep",NO=["typed"],EO=L(Xp,NO,r=>{var{typed:e}=r;return e(Xp,{"number, number":function(n,a){if(!Ue(n)||n<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!Ue(a)||a<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(n<1)throw new TypeError("k must be less than or equal to n + k - 1");if(a<n-1){var i=dn(n,n+a-1);return i/dn(1,a)}var o=dn(a+1,n+a-1);return o/dn(1,n-1)},"BigNumber, BigNumber":function(n,a){var i=n.constructor,o,l,u=new i(1),s=n.minus(u);if(!Qp(n)||!Qp(a))throw new TypeError("Positive integer value expected in function combinationsWithRep");if(n.lt(u))throw new TypeError("k must be less than or equal to n + k - 1 in function combinationsWithRep");if(o=u,a.lt(s))for(l=u;l.lte(s);l=l.plus(u))o=o.times(a.plus(l)).dividedBy(l);else for(l=u;l.lte(a);l=l.plus(u))o=o.times(s.plus(l)).dividedBy(l);return o}})});function Qp(r){return r.isInteger()&&r.gte(0)}var Kp="gamma",AO=["typed","config","multiplyScalar","pow","BigNumber","Complex"],SO=L(Kp,AO,r=>{var{typed:e,config:t,multiplyScalar:n,pow:a,BigNumber:i,Complex:o}=r;function l(s){if(s.im===0)return ro(s.re);if(s.re<.5){var c=new o(1-s.re,-s.im),f=new o(Math.PI*s.re,Math.PI*s.im);return new o(Math.PI).div(f.sin()).div(l(c))}s=new o(s.re-1,s.im);for(var m=new o(_a[0],0),v=1;v<_a.length;++v){var p=new o(_a[v],0);m=m.add(p.div(s.add(v)))}var d=new o(s.re+gc+.5,s.im),y=Math.sqrt(2*Math.PI),x=d.pow(s.add(.5)),D=d.neg().exp();return m.mul(y).mul(x).mul(D)}return e(Kp,{number:ro,Complex:l,BigNumber:function(c){if(c.isInteger())return c.isNegative()||c.isZero()?new i(1/0):u(c.minus(1));if(!c.isFinite())return new i(c.isNegative()?NaN:1/0);throw new Error("Integer BigNumber expected")}});function u(s){if(s<8)return new i([1,1,2,6,24,120,720,5040][s]);var c=t.precision+(Math.log(s.toNumber())|0),f=i.clone({precision:c});if(s%2===1)return s.times(u(new i(s-1)));for(var m=s,v=new f(s),p=s.toNumber();m>2;)m-=2,p+=m,v=v.times(p);return new i(v.toPrecision(i.precision))}}),ed="lgamma",CO=["Complex","typed"],MO=L(ed,CO,r=>{var{Complex:e,typed:t}=r,n=7,a=7,i=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return t(ed,{number:to,Complex:o,BigNumber:function(){throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function o(s){var c=6.283185307179586,f=1.1447298858494002,m=.1;if(s.isNaN())return new e(NaN,NaN);if(s.im===0)return new e(to(s.re),0);if(s.re>=n||Math.abs(s.im)>=a)return l(s);if(s.re<=m){var v=j0(c,s.im)*Math.floor(.5*s.re+.25),p=s.mul(Math.PI).sin().log(),d=o(new e(1-s.re,-s.im));return new e(f,v).sub(p).sub(d)}else return s.im>=0?u(s):u(s.conjugate()).conjugate()}function l(s){for(var c=s.sub(.5).mul(s.log()).sub(s).add(yc),f=new e(1,0).div(s),m=f.div(s),v=i[0],p=i[1],d=2*m.re,y=m.re*m.re+m.im*m.im,x=2;x<8;x++){var D=p;p=-y*v+i[x],v=d*v+D}var h=f.mul(m.mul(v).add(p));return c.add(h)}function u(s){var c=0,f=0,m=s;for(s=s.add(1);s.re<=n;){m=m.mul(s);var v=m.im<0?1:0;v!==0&&f===0&&c++,f=v,s=s.add(1)}return l(s).sub(m.log()).sub(new e(0,c*2*Math.PI*1))}}),rd="factorial",_O=["typed","gamma"],TO=L(rd,_O,r=>{var{typed:e,gamma:t}=r;return e(rd,{number:function(a){if(a<0)throw new Error("Value must be non-negative");return t(a+1)},BigNumber:function(a){if(a.isNegative())throw new Error("Value must be non-negative");return t(a.plus(1))},"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),td="kldivergence",FO=["typed","matrix","divide","sum","multiply","map","dotDivide","log","isNumeric"],OO=L(td,FO,r=>{var{typed:e,matrix:t,divide:n,sum:a,multiply:i,map:o,dotDivide:l,log:u,isNumeric:s}=r;return e(td,{"Array, Array":function(m,v){return c(t(m),t(v))},"Matrix, Array":function(m,v){return c(m,t(v))},"Array, Matrix":function(m,v){return c(t(m),v)},"Matrix, Matrix":function(m,v){return c(m,v)}});function c(f,m){var v=m.size().length,p=f.size().length;if(v>1)throw new Error("first object must be one dimensional");if(p>1)throw new Error("second object must be one dimensional");if(v!==p)throw new Error("Length of two vectors must be equal");var d=a(f);if(d===0)throw new Error("Sum of elements in first object must be non zero");var y=a(m);if(y===0)throw new Error("Sum of elements in second object must be non zero");var x=n(f,a(f)),D=n(m,a(m)),h=a(i(x,o(l(x,D),w=>u(w))));return s(h)?h:Number.NaN}}),nd="multinomial",BO=["typed","add","divide","multiply","factorial","isInteger","isPositive"],RO=L(nd,BO,r=>{var{typed:e,add:t,divide:n,multiply:a,factorial:i,isInteger:o,isPositive:l}=r;return e(nd,{"Array | Matrix":function(s){var c=0,f=1;return Rn(s,function(m){if(!o(m)||!l(m))throw new TypeError("Positive integer value expected in function multinomial");c=t(c,m),f=a(f,i(m))}),n(i(c),f)}})}),ad="permutations",IO=["typed","factorial"],PO=L(ad,IO,r=>{var{typed:e,factorial:t}=r;return e(ad,{"number | BigNumber":t,"number, number":function(a,i){if(!Ue(a)||a<0)throw new TypeError("Positive integer value expected in function permutations");if(!Ue(i)||i<0)throw new TypeError("Positive integer value expected in function permutations");if(i>a)throw new TypeError("second argument k must be less than or equal to first argument n");return dn(a-i+1,a)},"BigNumber, BigNumber":function(a,i){var o,l;if(!id(a)||!id(i))throw new TypeError("Positive integer value expected in function permutations");if(i.gt(a))throw new TypeError("second argument k must be less than or equal to first argument n");var u=a.mul(0).add(1);for(o=u,l=a.minus(i).plus(1);l.lte(a);l=l.plus(1))o=o.times(l);return o}})});function id(r){return r.isInteger()&&r.gte(0)}var Vs={exports:{}};Vs.exports,function(r){(function(e,t,n){function a(u){var s=this,c=l();s.next=function(){var f=2091639*s.s0+s.c*23283064365386963e-26;return s.s0=s.s1,s.s1=s.s2,s.s2=f-(s.c=f|0)},s.c=1,s.s0=c(" "),s.s1=c(" "),s.s2=c(" "),s.s0-=c(u),s.s0<0&&(s.s0+=1),s.s1-=c(u),s.s1<0&&(s.s1+=1),s.s2-=c(u),s.s2<0&&(s.s2+=1),c=null}function i(u,s){return s.c=u.c,s.s0=u.s0,s.s1=u.s1,s.s2=u.s2,s}function o(u,s){var c=new a(u),f=s&&s.state,m=c.next;return m.int32=function(){return c.next()*4294967296|0},m.double=function(){return m()+(m()*2097152|0)*11102230246251565e-32},m.quick=m,f&&(typeof f=="object"&&i(f,c),m.state=function(){return i(c,{})}),m}function l(){var u=4022871197,s=function(c){c=String(c);for(var f=0;f<c.length;f++){u+=c.charCodeAt(f);var m=.02519603282416938*u;u=m>>>0,m-=u,m*=u,u=m>>>0,m-=u,u+=m*4294967296}return(u>>>0)*23283064365386963e-26};return s}t&&t.exports?t.exports=o:this.alea=o})(ra,r)}(Vs);var $O=Vs.exports,Gs={exports:{}};Gs.exports,function(r){(function(e,t,n){function a(l){var u=this,s="";u.x=0,u.y=0,u.z=0,u.w=0,u.next=function(){var f=u.x^u.x<<11;return u.x=u.y,u.y=u.z,u.z=u.w,u.w^=u.w>>>19^f^f>>>8},l===(l|0)?u.x=l:s+=l;for(var c=0;c<s.length+64;c++)u.x^=s.charCodeAt(c)|0,u.next()}function i(l,u){return u.x=l.x,u.y=l.y,u.z=l.z,u.w=l.w,u}function o(l,u){var s=new a(l),c=u&&u.state,f=function(){return(s.next()>>>0)/4294967296};return f.double=function(){do var m=s.next()>>>11,v=(s.next()>>>0)/4294967296,p=(m+v)/(1<<21);while(p===0);return p},f.int32=s.next,f.quick=f,c&&(typeof c=="object"&&i(c,s),f.state=function(){return i(s,{})}),f}t&&t.exports?t.exports=o:this.xor128=o})(ra,r)}(Gs);var qO=Gs.exports,Hs={exports:{}};Hs.exports,function(r){(function(e,t,n){function a(l){var u=this,s="";u.next=function(){var f=u.x^u.x>>>2;return u.x=u.y,u.y=u.z,u.z=u.w,u.w=u.v,(u.d=u.d+362437|0)+(u.v=u.v^u.v<<4^(f^f<<1))|0},u.x=0,u.y=0,u.z=0,u.w=0,u.v=0,l===(l|0)?u.x=l:s+=l;for(var c=0;c<s.length+64;c++)u.x^=s.charCodeAt(c)|0,c==s.length&&(u.d=u.x<<10^u.x>>>4),u.next()}function i(l,u){return u.x=l.x,u.y=l.y,u.z=l.z,u.w=l.w,u.v=l.v,u.d=l.d,u}function o(l,u){var s=new a(l),c=u&&u.state,f=function(){return(s.next()>>>0)/4294967296};return f.double=function(){do var m=s.next()>>>11,v=(s.next()>>>0)/4294967296,p=(m+v)/(1<<21);while(p===0);return p},f.int32=s.next,f.quick=f,c&&(typeof c=="object"&&i(c,s),f.state=function(){return i(s,{})}),f}t&&t.exports?t.exports=o:this.xorwow=o})(ra,r)}(Hs);var zO=Hs.exports,Ws={exports:{}};Ws.exports,function(r){(function(e,t,n){function a(l){var u=this;u.next=function(){var c=u.x,f=u.i,m,v;return m=c[f],m^=m>>>7,v=m^m<<24,m=c[f+1&7],v^=m^m>>>10,m=c[f+3&7],v^=m^m>>>3,m=c[f+4&7],v^=m^m<<7,m=c[f+7&7],m=m^m<<13,v^=m^m<<9,c[f]=v,u.i=f+1&7,v};function s(c,f){var m,v=[];if(f===(f|0))v[0]=f;else for(f=""+f,m=0;m<f.length;++m)v[m&7]=v[m&7]<<15^f.charCodeAt(m)+v[m+1&7]<<13;for(;v.length<8;)v.push(0);for(m=0;m<8&&v[m]===0;++m);for(m==8?v[7]=-1:v[m],c.x=v,c.i=0,m=256;m>0;--m)c.next()}s(u,l)}function i(l,u){return u.x=l.x.slice(),u.i=l.i,u}function o(l,u){l==null&&(l=+new Date);var s=new a(l),c=u&&u.state,f=function(){return(s.next()>>>0)/4294967296};return f.double=function(){do var m=s.next()>>>11,v=(s.next()>>>0)/4294967296,p=(m+v)/(1<<21);while(p===0);return p},f.int32=s.next,f.quick=f,c&&(c.x&&i(c,s),f.state=function(){return i(s,{})}),f}t&&t.exports?t.exports=o:this.xorshift7=o})(ra,r)}(Ws);var UO=Ws.exports,Ys={exports:{}};Ys.exports,function(r){(function(e,t,n){function a(l){var u=this;u.next=function(){var c=u.w,f=u.X,m=u.i,v,p;return u.w=c=c+1640531527|0,p=f[m+34&127],v=f[m=m+1&127],p^=p<<13,v^=v<<17,p^=p>>>15,v^=v>>>12,p=f[m]=p^v,u.i=m,p+(c^c>>>16)|0};function s(c,f){var m,v,p,d,y,x=[],D=128;for(f===(f|0)?(v=f,f=null):(f=f+"\0",v=0,D=Math.max(D,f.length)),p=0,d=-32;d<D;++d)f&&(v^=f.charCodeAt((d+32)%f.length)),d===0&&(y=v),v^=v<<10,v^=v>>>15,v^=v<<4,v^=v>>>13,d>=0&&(y=y+1640531527|0,m=x[d&127]^=v+y,p=m==0?p+1:0);for(p>=128&&(x[(f&&f.length||0)&127]=-1),p=127,d=4*128;d>0;--d)v=x[p+34&127],m=x[p=p+1&127],v^=v<<13,m^=m<<17,v^=v>>>15,m^=m>>>12,x[p]=v^m;c.w=y,c.X=x,c.i=p}s(u,l)}function i(l,u){return u.i=l.i,u.w=l.w,u.X=l.X.slice(),u}function o(l,u){l==null&&(l=+new Date);var s=new a(l),c=u&&u.state,f=function(){return(s.next()>>>0)/4294967296};return f.double=function(){do var m=s.next()>>>11,v=(s.next()>>>0)/4294967296,p=(m+v)/(1<<21);while(p===0);return p},f.int32=s.next,f.quick=f,c&&(c.X&&i(c,s),f.state=function(){return i(s,{})}),f}t&&t.exports?t.exports=o:this.xor4096=o})(ra,r)}(Ys);var LO=Ys.exports,Zs={exports:{}};Zs.exports,function(r){(function(e,t,n){function a(l){var u=this,s="";u.next=function(){var f=u.b,m=u.c,v=u.d,p=u.a;return f=f<<25^f>>>7^m,m=m-v|0,v=v<<24^v>>>8^p,p=p-f|0,u.b=f=f<<20^f>>>12^m,u.c=m=m-v|0,u.d=v<<16^m>>>16^p,u.a=p-f|0},u.a=0,u.b=0,u.c=-1640531527,u.d=1367130551,l===Math.floor(l)?(u.a=l/4294967296|0,u.b=l|0):s+=l;for(var c=0;c<s.length+20;c++)u.b^=s.charCodeAt(c)|0,u.next()}function i(l,u){return u.a=l.a,u.b=l.b,u.c=l.c,u.d=l.d,u}function o(l,u){var s=new a(l),c=u&&u.state,f=function(){return(s.next()>>>0)/4294967296};return f.double=function(){do var m=s.next()>>>11,v=(s.next()>>>0)/4294967296,p=(m+v)/(1<<21);while(p===0);return p},f.int32=s.next,f.quick=f,c&&(typeof c=="object"&&i(c,s),f.state=function(){return i(s,{})}),f}t&&t.exports?t.exports=o:this.tychei=o})(ra,r)}(Zs);var kO=Zs.exports,od={exports:{}};const VO=D2(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(r){(function(e,t,n){var a=256,i=6,o=52,l="random",u=n.pow(a,i),s=n.pow(2,o),c=s*2,f=a-1,m;function v(w,g,b){var A=[];g=g==!0?{entropy:!0}:g||{};var N=x(y(g.entropy?[w,h(t)]:w??D(),3),A),E=new p(A),S=function(){for(var C=E.g(i),M=u,O=0;C<s;)C=(C+O)*a,M*=a,O=E.g(1);for(;C>=c;)C/=2,M/=2,O>>>=1;return(C+O)/M};return S.int32=function(){return E.g(4)|0},S.quick=function(){return E.g(4)/4294967296},S.double=S,x(h(E.S),t),(g.pass||b||function(C,M,O,I){return I&&(I.S&&d(I,E),C.state=function(){return d(E,{})}),O?(n[l]=C,M):C})(S,N,"global"in g?g.global:this==n,g.state)}function p(w){var g,b=w.length,A=this,N=0,E=A.i=A.j=0,S=A.S=[];for(b||(w=[b++]);N<a;)S[N]=N++;for(N=0;N<a;N++)S[N]=S[E=f&E+w[N%b]+(g=S[N])],S[E]=g;(A.g=function(C){for(var M,O=0,I=A.i,k=A.j,_=A.S;C--;)M=_[I=f&I+1],O=O*a+_[f&(_[I]=_[k=f&k+M])+(_[k]=M)];return A.i=I,A.j=k,O})(a)}function d(w,g){return g.i=w.i,g.j=w.j,g.S=w.S.slice(),g}function y(w,g){var b=[],A=typeof w,N;if(g&&A=="object")for(N in w)try{b.push(y(w[N],g-1))}catch{}return b.length?b:A=="string"?w:w+"\0"}function x(w,g){for(var b=w+"",A,N=0;N<b.length;)g[f&N]=f&(A^=g[f&N]*19)+b.charCodeAt(N++);return h(g)}function D(){try{var w;return m&&(w=m.randomBytes)?w=w(a):(w=new Uint8Array(a),(e.crypto||e.msCrypto).getRandomValues(w)),h(w)}catch{var g=e.navigator,b=g&&g.plugins;return[+new Date,e,b,e.screen,h(t)]}}function h(w){return String.fromCharCode.apply(0,w)}if(x(n.random(),t),r.exports){r.exports=v;try{m=VO}catch{}}else n["seed"+l]=v})(typeof self<"u"?self:ra,[],Math)})(od);var GO=od.exports,HO=$O,WO=qO,YO=zO,ZO=UO,JO=LO,jO=kO,ta=GO;ta.alea=HO,ta.xor128=WO,ta.xorwow=YO,ta.xorshift7=ZO,ta.xor4096=JO,ta.tychei=jO;var XO=ta;const sd=Bs(XO);var QO=sd(Date.now());function Ia(r){var e;function t(a){e=a===null?QO:sd(String(a))}t(r);function n(){return e()}return n}var ud="pickRandom",KO=["typed","config","?on"],eB=L(ud,KO,r=>{var{typed:e,config:t,on:n}=r,a=Ia(t.randomSeed);return n&&n("config",function(o,l){o.randomSeed!==l.randomSeed&&(a=Ia(o.randomSeed))}),e(ud,{"Array | Matrix":function(l){return i(l,{})},"Array | Matrix, Object":function(l,u){return i(l,u)},"Array | Matrix, number":function(l,u){return i(l,{number:u})},"Array | Matrix, Array | Matrix":function(l,u){return i(l,{weights:u})},"Array | Matrix, Array | Matrix, number":function(l,u,s){return i(l,{number:s,weights:u})},"Array | Matrix, number, Array | Matrix":function(l,u,s){return i(l,{number:u,weights:s})}});function i(o,l){var{number:u,weights:s,elementWise:c=!0}=l,f=typeof u>"u";f&&(u=1);var m=Je(o)?o.create:Je(s)?s.create:null;o=o.valueOf(),s&&(s=s.valueOf()),c===!0&&(o=yr(o),s=yr(s));var v=0;if(typeof s<"u"){if(s.length!==o.length)throw new Error("Weights must have the same length as possibles");for(var p=0,d=s.length;p<d;p++){if(!Ye(s[p])||s[p]<0)throw new Error("Weights must be an array of positive numbers");v+=s[p]}}for(var y=o.length,x=[],D;x.length<u;){if(typeof s>"u")D=o[Math.floor(a()*y)];else for(var h=a()*v,w=0,g=o.length;w<g;w++)if(h-=s[w],h<0){D=o[w];break}x.push(D)}return f?x[0]:m?m(x):x}});function Js(r,e){var t=[];if(r=r.slice(0),r.length>1)for(var n=0,a=r.shift();n<a;n++)t.push(Js(r,e));else for(var i=0,o=r.shift();i<o;i++)t.push(e());return t}var ld="random",rB=["typed","config","?on"],tB=L(ld,rB,r=>{var{typed:e,config:t,on:n}=r,a=Ia(t.randomSeed);return n&&n("config",function(l,u){l.randomSeed!==u.randomSeed&&(a=Ia(l.randomSeed))}),e(ld,{"":()=>o(0,1),number:l=>o(0,l),"number, number":(l,u)=>o(l,u),"Array | Matrix":l=>i(l,0,1),"Array | Matrix, number":(l,u)=>i(l,0,u),"Array | Matrix, number, number":(l,u,s)=>i(l,u,s)});function i(l,u,s){var c=Js(l.valueOf(),()=>o(u,s));return Je(l)?l.create(c,"number"):c}function o(l,u){return l+a()*(u-l)}}),cd="randomInt",nB=["typed","config","log2","?on"],aB=L(cd,nB,r=>{var{typed:e,config:t,log2:n,on:a}=r,i=Ia(t.randomSeed);return a&&a("config",function(s,c){s.randomSeed!==c.randomSeed&&(i=Ia(s.randomSeed))}),e(cd,{"":()=>l(0,2),number:s=>l(0,s),"number, number":(s,c)=>l(s,c),bigint:s=>u(0n,s),"bigint, bigint":u,"Array | Matrix":s=>o(s,0,1),"Array | Matrix, number":(s,c)=>o(s,0,c),"Array | Matrix, number, number":(s,c,f)=>o(s,c,f)});function o(s,c,f){var m=Js(s.valueOf(),()=>l(c,f));return Je(s)?s.create(m,"number"):m}function l(s,c){return Math.floor(s+i()*(c-s))}function u(s,c){var f=2n**30n,m=c-s;if(m<=f)return s+BigInt(l(0,Number(m)));for(var v=n(m),p=m;p>=m;){p=0n;for(var d=0;d<v;++d)p=2n*p+(i()<.5?0n:1n)}return s+p}}),fd="stirlingS2",iB=["typed","addScalar","subtractScalar","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],oB=L(fd,iB,r=>{var{typed:e,addScalar:t,subtractScalar:n,multiplyScalar:a,divideScalar:i,pow:o,factorial:l,combinations:u,isNegative:s,isInteger:c,number:f,bignumber:m,larger:v}=r,p=[],d=[];return e(fd,{"number | BigNumber, number | BigNumber":function(x,D){if(!c(x)||s(x)||!c(D)||s(D))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(v(D,x))throw new TypeError("k must be less than or equal to n in function stirlingS2");var h=!(Ye(x)&&Ye(D)),w=h?d:p,g=h?m:f,b=f(x),A=f(D);if(w[b]&&w[b].length>A)return w[b][A];for(var N=0;N<=b;++N)if(w[N]||(w[N]=[g(N===0?1:0)]),N!==0)for(var E=w[N],S=w[N-1],C=E.length;C<=N&&C<=A;++C)C===N?E[C]=1:E[C]=t(a(g(C),S[C]),S[C-1]);return w[b][A]}})}),md="bellNumbers",sB=["typed","addScalar","isNegative","isInteger","stirlingS2"],uB=L(md,sB,r=>{var{typed:e,addScalar:t,isNegative:n,isInteger:a,stirlingS2:i}=r;return e(md,{"number | BigNumber":function(l){if(!a(l)||n(l))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var u=0,s=0;s<=l;s++)u=t(u,i(l,s));return u}})}),vd="catalan",lB=["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],cB=L(vd,lB,r=>{var{typed:e,addScalar:t,divideScalar:n,multiplyScalar:a,combinations:i,isNegative:o,isInteger:l}=r;return e(vd,{"number | BigNumber":function(s){if(!l(s)||o(s))throw new TypeError("Non-negative integer value expected in function catalan");return n(i(a(s,2),s),t(s,1))}})}),pd="composition",fB=["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],mB=L(pd,fB,r=>{var{typed:e,addScalar:t,combinations:n,isPositive:a,isNegative:i,isInteger:o,larger:l}=r;return e(pd,{"number | BigNumber, number | BigNumber":function(s,c){if(!o(s)||!a(s)||!o(c)||!a(c))throw new TypeError("Positive integer value expected in function composition");if(l(c,s))throw new TypeError("k must be less than or equal to n in function composition");return n(t(s,-1),t(c,-1))}})}),dd="leafCount",vB=["parse","typed"],pB=L(dd,vB,r=>{var{parse:e,typed:t}=r;function n(a){var i=0;return a.forEach(o=>{i+=n(o)}),i||1}return t(dd,{Node:function(i){return n(i)}})});function hd(r){return gr(r)||Ur(r)&&r.isUnary()&&gr(r.args[0])}function Bo(r){return!!(gr(r)||(En(r)||Ur(r))&&r.args.every(Bo)||fn(r)&&Bo(r.content))}function gd(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function js(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?gd(Object(t),!0).forEach(function(n){Vr(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):gd(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}var dB="simplifyUtil",hB=["FunctionNode","OperatorNode","SymbolNode"],Xs=L(dB,hB,r=>{var{FunctionNode:e,OperatorNode:t,SymbolNode:n}=r,a=!0,i=!1,o="defaultF",l={add:{trivial:a,total:a,commutative:a,associative:a},unaryPlus:{trivial:a,total:a,commutative:a,associative:a},subtract:{trivial:i,total:a,commutative:i,associative:i},multiply:{trivial:a,total:a,commutative:a,associative:a},divide:{trivial:i,total:a,commutative:i,associative:i},paren:{trivial:a,total:a,commutative:a,associative:i},defaultF:{trivial:i,total:a,commutative:i,associative:i}},u={divide:{total:i},log:{total:i}},s={subtract:{total:i},abs:{trivial:a},log:{total:a}};function c(h,w){var g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:l,b=o;if(typeof h=="string"?b=h:Ur(h)?b=h.fn.toString():En(h)?b=h.name:fn(h)&&(b="paren"),$e(g,b)){var A=g[b];if($e(A,w))return A[w];if($e(l,b))return l[b][w]}if($e(g,o)){var N=g[o];return $e(N,w)?N[w]:l[o][w]}if($e(l,b)){var E=l[b];if($e(E,w))return E[w]}return l[o][w]}function f(h){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:l;return c(h,"commutative",w)}function m(h){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:l;return c(h,"associative",w)}function v(h,w){var g=js({},h);for(var b in w)$e(h,b)?g[b]=js(js({},w[b]),h[b]):g[b]=w[b];return g}function p(h,w){if(!h.args||h.args.length===0)return h;h.args=d(h,w);for(var g=0;g<h.args.length;g++)p(h.args[g],w)}function d(h,w){var g,b=[],A=function(E){for(var S=0;S<E.args.length;S++){var C=E.args[S];Ur(C)&&g===C.op?A(C):b.push(C)}};return m(h,w)?(g=h.op,A(h),b):h.args}function y(h,w){if(!(!h.args||h.args.length===0)){for(var g=D(h),b=h.args.length,A=0;A<b;A++)y(h.args[A],w);if(b>2&&m(h,w)){for(var N=h.args.pop();h.args.length>0;)N=g([h.args.pop(),N]);h.args=N.args}}}function x(h,w){if(!(!h.args||h.args.length===0)){for(var g=D(h),b=h.args.length,A=0;A<b;A++)x(h.args[A],w);if(b>2&&m(h,w)){for(var N=h.args.shift();h.args.length>0;)N=g([N,h.args.shift()]);h.args=N.args}}}function D(h){return Ur(h)?function(w){try{return new t(h.op,h.fn,w,h.implicit)}catch(g){return console.error(g),[]}}:function(w){return new e(new n(h.name),w)}}return{createMakeNodeFunction:D,hasProperty:c,isCommutative:f,isAssociative:m,mergeContext:v,flatten:p,allChildren:d,unflattenr:y,unflattenl:x,defaultContext:l,realContext:u,positiveContext:s}}),gB="simplify",yB=["typed","parse","equal","resolve","simplifyConstant","simplifyCore","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode","replacer"],bB=L(gB,yB,r=>{var{typed:e,parse:t,equal:n,resolve:a,simplifyConstant:i,simplifyCore:o,AccessorNode:l,ArrayNode:u,ConstantNode:s,FunctionNode:c,IndexNode:f,ObjectNode:m,OperatorNode:v,ParenthesisNode:p,SymbolNode:d,replacer:y}=r,{hasProperty:x,isCommutative:D,isAssociative:h,mergeContext:w,flatten:g,unflattenr:b,unflattenl:A,createMakeNodeFunction:N,defaultContext:E,realContext:S,positiveContext:C}=Xs({FunctionNode:c,OperatorNode:v,SymbolNode:d});e.addConversion({from:"Object",to:"Map",convert:va});var M=e("simplify",{Node:q,"Node, Map":(Y,z)=>q(Y,!1,z),"Node, Map, Object":(Y,z,X)=>q(Y,!1,z,X),"Node, Array":q,"Node, Array, Map":q,"Node, Array, Map, Object":q});e.removeConversion({from:"Object",to:"Map",convert:va}),M.defaultContext=E,M.realContext=S,M.positiveContext=C;function O(Y){return Y.transform(function(z){return fn(z)?O(z.content):z})}var I={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};M.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}}},i,{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}}},i,{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"}];function k(Y,z){var X={};if(Y.s){var se=Y.s.split("->");if(se.length===2)X.l=se[0],X.r=se[1];else throw SyntaxError("Could not parse rule: "+Y.s)}else X.l=Y.l,X.r=Y.r;X.l=O(t(X.l)),X.r=O(t(X.r));for(var re of["imposeContext","repeat","assuming"])re in Y&&(X[re]=Y[re]);if(Y.evaluate&&(X.evaluate=t(Y.evaluate)),h(X.l,z)){var pe=!D(X.l,z),ve;pe&&(ve=V());var De=N(X.l),Oe=V();X.expanded={},X.expanded.l=De([X.l,Oe]),g(X.expanded.l,z),b(X.expanded.l,z),X.expanded.r=De([X.r,Oe]),pe&&(X.expandedNC1={},X.expandedNC1.l=De([ve,X.l]),X.expandedNC1.r=De([ve,X.r]),X.expandedNC2={},X.expandedNC2.l=De([ve,X.expanded.l]),X.expandedNC2.r=De([ve,X.expanded.r]))}return X}function _(Y,z){for(var X=[],se=0;se<Y.length;se++){var re=Y[se],pe=void 0,ve=typeof re;switch(ve){case"string":re={s:re};case"object":pe=k(re,z);break;case"function":pe=re;break;default:throw TypeError("Unsupported type of rule: "+ve)}X.push(pe)}return X}var P=0;function V(){return new d("_p"+P++)}function q(Y,z){var X=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Xa(),se=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},re=se.consoleDebug;z=_(z||M.rules,se.context);var pe=a(Y,X);pe=O(pe);for(var ve={},De=pe.toString({parenthesis:"all"});!ve[De];){ve[De]=!0,P=0;var Oe=De;re&&console.log("Working on: ",De);for(var Ie=0;Ie<z.length;Ie++){var _e="";if(typeof z[Ie]=="function"?(pe=z[Ie](pe,se),re&&(_e=z[Ie].name)):(g(pe,se.context),pe=ne(pe,z[Ie],se.context),re&&(_e="".concat(z[Ie].l.toString()," -> ").concat(z[Ie].r.toString()))),re){var Le=pe.toString({parenthesis:"all"});Le!==Oe&&(console.log("Applying",_e,"produced",Le),Oe=Le)}A(pe,se.context)}De=pe.toString({parenthesis:"all"})}return pe}function J(Y,z,X){var se=Y;if(Y)for(var re=0;re<Y.length;++re){var pe=ne(Y[re],z,X);pe!==Y[re]&&(se===Y&&(se=Y.slice()),se[re]=pe)}return se}function ne(Y,z,X){if(z.assuming){for(var se in z.assuming)for(var re in z.assuming[se])if(x(se,re,X)!==z.assuming[se][re])return Y}var pe=w(z.imposeContext,X),ve=Y;if(ve instanceof v||ve instanceof c){var De=J(ve.args,z,X);De!==ve.args&&(ve=ve.clone(),ve.args=De)}else if(ve instanceof p){if(ve.content){var Oe=ne(ve.content,z,X);Oe!==ve.content&&(ve=new p(Oe))}}else if(ve instanceof u){var Ie=J(ve.items,z,X);Ie!==ve.items&&(ve=new u(Ie))}else if(ve instanceof l){var _e=ve.object;ve.object&&(_e=ne(ve.object,z,X));var Le=ve.index;ve.index&&(Le=ne(ve.index,z,X)),(_e!==ve.object||Le!==ve.index)&&(ve=new l(_e,Le))}else if(ve instanceof f){var qe=J(ve.dimensions,z,X);qe!==ve.dimensions&&(ve=new f(qe))}else if(ve instanceof m){var G=!1,ee={};for(var R in ve.properties)ee[R]=ne(ve.properties[R],z,X),ee[R]!==ve.properties[R]&&(G=!0);G&&(ve=new m(ee))}var H=z.r,Q=le(z.l,ve,pe)[0];if(!Q&&z.expanded&&(H=z.expanded.r,Q=le(z.expanded.l,ve,pe)[0]),!Q&&z.expandedNC1&&(H=z.expandedNC1.r,Q=le(z.expandedNC1.l,ve,pe)[0],Q||(H=z.expandedNC2.r,Q=le(z.expandedNC2.l,ve,pe)[0])),Q){var ie=ve.implicit;ve=H.clone(),ie&&"implicit"in H&&(ve.implicit=!0),ve=ve.transform(function(ue){return ue.isSymbolNode&&$e(Q.placeholders,ue.name)?Q.placeholders[ue.name].clone():ue})}return z.repeat&&ve!==Y&&(ve=ne(ve,z,X)),ve}function j(Y,z){var X=[],se,re,pe=N(Y);if(D(Y,z))for(var ve=0;ve<Y.args.length;ve++)re=Y.args.slice(0),re.splice(ve,1),se=re.length===1?re[0]:pe(re),X.push(pe([Y.args[ve],se]));else for(var De=1;De<Y.args.length;De++){var Oe=Y.args[0];De>1&&(Oe=pe(Y.args.slice(0,De))),re=Y.args.slice(De),se=re.length===1?re[0]:pe(re),X.push(pe([Oe,se]))}return X}function F(Y,z){var X={placeholders:{}};if(!Y.placeholders&&!z.placeholders)return X;if(Y.placeholders){if(!z.placeholders)return Y}else return z;for(var se in Y.placeholders)if($e(Y.placeholders,se)&&(X.placeholders[se]=Y.placeholders[se],$e(z.placeholders,se)&&!me(Y.placeholders[se],z.placeholders[se])))return null;for(var re in z.placeholders)$e(z.placeholders,re)&&(X.placeholders[re]=z.placeholders[re]);return X}function U(Y,z){var X=[];if(Y.length===0||z.length===0)return X;for(var se,re=0;re<Y.length;re++)for(var pe=0;pe<z.length;pe++)se=F(Y[re],z[pe]),se&&X.push(se);return X}function $(Y){if(Y.length===0)return Y;for(var z=Y.reduce(U),X=[],se={},re=0;re<z.length;re++){var pe=JSON.stringify(z[re],y);se[pe]||(se[pe]=!0,X.push(z[re]))}return X}function le(Y,z,X,se){var re=[{placeholders:{}}];if(Y instanceof v&&z instanceof v||Y instanceof c&&z instanceof c){if(Y instanceof v){if(Y.op!==z.op||Y.fn!==z.fn)return[]}else if(Y instanceof c&&Y.name!==z.name)return[];if(z.args.length===1&&Y.args.length===1||!h(z,X)&&z.args.length===Y.args.length||se){for(var pe=[],ve=0;ve<Y.args.length;ve++){var De=le(Y.args[ve],z.args[ve],X);if(De.length===0)break;pe.push(De)}if(pe.length!==Y.args.length){if(!D(z,X)||Y.args.length===1)return[];if(Y.args.length>2)throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");var Oe=le(Y.args[0],z.args[1],X);if(Oe.length===0)return[];var Ie=le(Y.args[1],z.args[0],X);if(Ie.length===0)return[];pe=[Oe,Ie]}re=$(pe)}else if(z.args.length>=2&&Y.args.length===2){for(var _e=j(z,X),Le=[],qe=0;qe<_e.length;qe++){var G=le(Y,_e[qe],X,!0);Le=Le.concat(G)}return Le}else{if(Y.args.length>2)throw Error("Unexpected non-binary associative function: "+Y.toString());return[]}}else if(Y instanceof d){if(Y.name.length===0)throw new Error("Symbol in rule has 0 length...!?");if(I[Y.name]){if(Y.name!==z.name)return[]}else switch(Y.name[1]>="a"&&Y.name[1]<="z"?Y.name.substring(0,2):Y.name[0]){case"n":case"_p":re[0].placeholders[Y.name]=z;break;case"c":case"cl":if(gr(z))re[0].placeholders[Y.name]=z;else return[];break;case"v":if(!gr(z))re[0].placeholders[Y.name]=z;else return[];break;case"vl":if(jr(z))re[0].placeholders[Y.name]=z;else return[];break;case"cd":if(hd(z))re[0].placeholders[Y.name]=z;else return[];break;case"vd":if(!hd(z))re[0].placeholders[Y.name]=z;else return[];break;case"ce":if(Bo(z))re[0].placeholders[Y.name]=z;else return[];break;case"ve":if(!Bo(z))re[0].placeholders[Y.name]=z;else return[];break;default:throw new Error("Invalid symbol in rule: "+Y.name)}}else if(Y instanceof s){if(!n(Y.value,z.value))return[]}else return[];return re}function me(Y,z){if(Y instanceof s&&z instanceof s){if(!n(Y.value,z.value))return!1}else if(Y instanceof d&&z instanceof d){if(Y.name!==z.name)return!1}else if(Y instanceof v&&z instanceof v||Y instanceof c&&z instanceof c){if(Y instanceof v){if(Y.op!==z.op||Y.fn!==z.fn)return!1}else if(Y instanceof c&&Y.name!==z.name)return!1;if(Y.args.length!==z.args.length)return!1;for(var X=0;X<Y.args.length;X++)if(!me(Y.args[X],z.args[X]))return!1}else return!1;return!0}return M}),xB="simplifyConstant",wB=["typed","config","mathWithTransform","matrix","isBounded","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],DB=L(xB,wB,r=>{var{typed:e,config:t,mathWithTransform:n,matrix:a,isBounded:i,fraction:o,bignumber:l,AccessorNode:u,ArrayNode:s,ConstantNode:c,FunctionNode:f,IndexNode:m,ObjectNode:v,OperatorNode:p,SymbolNode:d}=r,{isCommutative:y,isAssociative:x,allChildren:D,createMakeNodeFunction:h}=Xs({FunctionNode:f,OperatorNode:p,SymbolNode:d}),w=e("simplifyConstant",{Node:_=>N(k(_,{})),"Node, Object":function(P,V){return N(k(P,V))}});function g(_){return Ka(_)?_.valueOf():_ instanceof Array?_.map(g):Je(_)?a(g(_.valueOf())):_}function b(_,P,V){try{return n[_].apply(null,P)}catch{return P=P.map(g),S(n[_].apply(null,P),V)}}var A=e({Fraction:M,number:function(P){return P<0?C(new c(-P)):new c(P)},BigNumber:function(P){return P<0?C(new c(-P)):new c(P)},bigint:function(P){return P<0n?C(new c(-P)):new c(P)},Complex:function(P){throw new Error("Cannot convert Complex number to Node")},string:function(P){return new c(P)},Matrix:function(P){return new s(P.valueOf().map(V=>A(V)))}});function N(_){return Nr(_)?_:A(_)}function E(_,P){var V=P&&P.exactFractions!==!1;if(V&&i(_)&&o){var q=o(_),J=P&&typeof P.fractionsLimit=="number"?P.fractionsLimit:1/0;if(q.valueOf()===_&&q.n<J&&q.d<J)return q}return _}var S=e({"string, Object":function(P,V){var q=An(P,t);if(q==="BigNumber")return l===void 0&&Ts(),l(P);if(q==="bigint")return BigInt(P);if(q==="Fraction")return o===void 0&&lm(),o(P);var J=parseFloat(P);return E(J,V)},"Fraction, Object":function(P,V){return P},"BigNumber, Object":function(P,V){return P},"number, Object":function(P,V){return E(P,V)},"bigint, Object":function(P,V){return P},"Complex, Object":function(P,V){return P.im!==0?P:E(P.re,V)},"Matrix, Object":function(P,V){return a(E(P.valueOf()))},"Array, Object":function(P,V){return P.map(E)}});function C(_){return new p("-","unaryMinus",[_])}function M(_){var P=J=>t.number==="BigNumber"&&l?l(J):Number(J),V=_.s*_.n,q=V<0n?new p("-","unaryMinus",[new c(-P(V))]):new c(P(V));return _.d===1n?q:new p("/","divide",[q,new c(P(_.d))])}function O(_,P,V){if(!pa(P))return new u(N(_),N(P));if(Rt(_)||Je(_)){for(var q=Array.from(P.dimensions);q.length>0;)if(gr(q[0])&&typeof q[0].value!="string"){var J=S(q.shift().value,V);Rt(_)?_=_.items[J-1]:(_=_.valueOf()[J-1],_ instanceof Array&&(_=a(_)))}else if(q.length>1&&gr(q[1])&&typeof q[1].value!="string"){var ne=S(q[1].value,V),j=[],F=Rt(_)?_.items:_.valueOf();for(var U of F)if(Rt(U))j.push(U.items[ne-1]);else if(Je(_))j.push(U[ne-1]);else break;if(j.length===F.length)Rt(_)?_=new s(j):_=a(j),q.splice(1,1);else break}else break;return q.length===P.dimensions.length?new u(N(_),P):q.length>0?(P=new m(q),new u(N(_),P)):_}if(Oi(_)&&P.dimensions.length===1&&gr(P.dimensions[0])){var $=P.dimensions[0].value;return $ in _.properties?_.properties[$]:new c}return new u(N(_),P)}function I(_,P,V,q){var J=P.shift(),ne=P.reduce((j,F)=>{if(!Nr(F)){var U=j.pop();if(Nr(U))return[U,F];try{return j.push(b(_,[U,F],q)),j}catch{j.push(U)}}j.push(N(j.pop()));var $=j.length===1?j[0]:V(j);return[V([$,N(F)])]},[J]);return ne.length===1?ne[0]:V([ne[0],A(ne[1])])}function k(_,P){switch(_.type){case"SymbolNode":return _;case"ConstantNode":switch(typeof _.value){case"number":return S(_.value,P);case"bigint":return S(_.value,P);case"string":return _.value;default:if(!isNaN(_.value))return S(_.value,P)}return _;case"FunctionNode":if(n[_.name]&&n[_.name].rawArgs)return _;{var V=["add","multiply"];if(!V.includes(_.name)){var q=_.args.map(re=>k(re,P));if(!q.some(Nr))try{return b(_.name,q,P)}catch{}if(_.name==="size"&&q.length===1&&Rt(q[0])){for(var J=[],ne=q[0];Rt(ne);)J.push(ne.items.length),ne=ne.items[0];return a(J)}return new f(_.name,q.map(N))}}case"OperatorNode":{var j=_.fn.toString(),F,U,$=h(_);if(Ur(_)&&_.isUnary())F=[k(_.args[0],P)],Nr(F[0])?U=$(F):U=b(j,F,P);else if(x(_,P.context))if(F=D(_,P.context),F=F.map(re=>k(re,P)),y(j,P.context)){for(var le=[],me=[],Y=0;Y<F.length;Y++)Nr(F[Y])?me.push(F[Y]):le.push(F[Y]);le.length>1?(U=I(j,le,$,P),me.unshift(U),U=I(j,me,$,P)):U=I(j,F,$,P)}else U=I(j,F,$,P);else F=_.args.map(re=>k(re,P)),U=I(j,F,$,P);return U}case"ParenthesisNode":return k(_.content,P);case"AccessorNode":return O(k(_.object,P),k(_.index,P),P);case"ArrayNode":{var z=_.items.map(re=>k(re,P));return z.some(Nr)?new s(z.map(N)):a(z)}case"IndexNode":return new m(_.dimensions.map(re=>w(re,P)));case"ObjectNode":{var X={};for(var se in _.properties)X[se]=w(_.properties[se],P);return new v(X)}case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"RangeNode":case"ConditionalNode":default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(_.type))}}return w}),yd="simplifyCore",NB=["typed","parse","equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],EB=L(yd,NB,r=>{var{typed:e,parse:t,equal:n,isZero:a,add:i,subtract:o,multiply:l,divide:u,pow:s,AccessorNode:c,ArrayNode:f,ConstantNode:m,FunctionNode:v,IndexNode:p,ObjectNode:d,OperatorNode:y,ParenthesisNode:x,SymbolNode:D}=r,h=new m(0),w=new m(1),g=new m(!0),b=new m(!1);function A(C){return Ur(C)&&["and","not","or"].includes(C.op)}var{hasProperty:N,isCommutative:E}=Xs({FunctionNode:v,OperatorNode:y,SymbolNode:D});function S(C){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},O=M?M.context:void 0;if(N(C,"trivial",O)){if(En(C)&&C.args.length===1)return S(C.args[0],M);var I=!1,k=0;if(C.forEach(le=>{++k,k===1&&(I=S(le,M))}),k===1)return I}var _=C;if(En(_)){var P=pS(_.name);if(P){if(_.args.length>2&&N(_,"associative",O))for(;_.args.length>2;){var V=_.args.pop(),q=_.args.pop();_.args.push(new y(P,_.name,[V,q]))}_=new y(P,_.name,_.args)}else return new v(S(_.fn),_.args.map(le=>S(le,M)))}if(Ur(_)&&_.isUnary()){var J=S(_.args[0],M);if(_.op==="~"&&Ur(J)&&J.isUnary()&&J.op==="~"||_.op==="not"&&Ur(J)&&J.isUnary()&&J.op==="not"&&A(J.args[0]))return J.args[0];var ne=!0;if(_.op==="-"&&Ur(J)&&(J.isBinary()&&J.fn==="subtract"&&(_=new y("-","subtract",[J.args[1],J.args[0]]),ne=!1),J.isUnary()&&J.op==="-"))return J.args[0];if(ne)return new y(_.op,_.fn,[J])}if(Ur(_)&&_.isBinary()){var j=S(_.args[0],M),F=S(_.args[1],M);if(_.op==="+"){if(gr(j)&&a(j.value))return F;if(gr(F)&&a(F.value))return j;Ur(F)&&F.isUnary()&&F.op==="-"&&(F=F.args[0],_=new y("-","subtract",[j,F]))}if(_.op==="-")return Ur(F)&&F.isUnary()&&F.op==="-"?S(new y("+","add",[j,F.args[0]]),M):gr(j)&&a(j.value)?S(new y("-","unaryMinus",[F])):gr(F)&&a(F.value)?j:new y(_.op,_.fn,[j,F]);if(_.op==="*"){if(gr(j)){if(a(j.value))return h;if(n(j.value,1))return F}if(gr(F)){if(a(F.value))return h;if(n(F.value,1))return j;if(E(_,O))return new y(_.op,_.fn,[F,j],_.implicit)}return new y(_.op,_.fn,[j,F],_.implicit)}if(_.op==="/")return gr(j)&&a(j.value)?h:gr(F)&&n(F.value,1)?j:new y(_.op,_.fn,[j,F]);if(_.op==="^"&&gr(F)){if(a(F.value))return w;if(n(F.value,1))return j}if(_.op==="and"){if(gr(j))if(j.value){if(A(F))return F;if(gr(F))return F.value?g:b}else return b;if(gr(F))if(F.value){if(A(j))return j}else return b}if(_.op==="or"){if(gr(j)){if(j.value)return g;if(A(F))return F}if(gr(F)){if(F.value)return g;if(A(j))return j}}return new y(_.op,_.fn,[j,F])}if(Ur(_))return new y(_.op,_.fn,_.args.map(le=>S(le,M)));if(Rt(_))return new f(_.items.map(le=>S(le,M)));if(cn(_))return new c(S(_.object,M),S(_.index,M));if(pa(_))return new p(_.dimensions.map(le=>S(le,M)));if(Oi(_)){var U={};for(var $ in _.properties)U[$]=S(_.properties[$],M);return new d(U)}return _}return e(yd,{Node:S,"Node,Object":S})}),AB="resolve",SB=["typed","parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],CB=L(AB,SB,r=>{var{typed:e,parse:t,ConstantNode:n,FunctionNode:a,OperatorNode:i,ParenthesisNode:o}=r;function l(u,s){var c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;if(!s)return u;if(jr(u)){if(c.has(u.name)){var f=Array.from(c).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(f,"}"))}var m=s.get(u.name);if(Nr(m)){var v=new Set(c);return v.add(u.name),l(m,s,v)}else return typeof m=="number"?t(String(m)):m!==void 0?new n(m):u}else if(Ur(u)){var p=u.args.map(function(y){return l(y,s,c)});return new i(u.op,u.fn,p,u.implicit)}else{if(fn(u))return new o(l(u.content,s,c));if(En(u)){var d=u.args.map(function(y){return l(y,s,c)});return new a(u.name,d)}}return u.map(y=>l(y,s,c))}return e("resolve",{Node:l,"Node, Map | null | undefined":l,"Node, Object":(u,s)=>l(u,va(s)),"Array | Matrix":e.referToSelf(u=>s=>s.map(c=>u(c))),"Array | Matrix, null | undefined":e.referToSelf(u=>s=>s.map(c=>u(c))),"Array, Object":e.referTo("Array,Map",u=>(s,c)=>u(s,va(c))),"Matrix, Object":e.referTo("Matrix,Map",u=>(s,c)=>u(s,va(c))),"Array | Matrix, Map":e.referToSelf(u=>(s,c)=>s.map(f=>u(f,c)))})}),bd="symbolicEqual",MB=["parse","simplify","typed","OperatorNode"],_B=L(bd,MB,r=>{var{parse:e,simplify:t,typed:n,OperatorNode:a}=r;function i(o,l){var u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=new a("-","subtract",[o,l]),c=t(s,{},u);return gr(c)&&!c.value}return n(bd,{"Node, Node":i,"Node, Node, Object":i})}),xd="derivative",TB=["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],FB=L(xd,TB,r=>{var{typed:e,config:t,parse:n,simplify:a,equal:i,isZero:o,numeric:l,ConstantNode:u,FunctionNode:s,OperatorNode:c,ParenthesisNode:f,SymbolNode:m}=r;function v(w,g){var b=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{simplify:!0},A=new Map,N=g.name;function E(C){var M=A.get(C);if(M!==void 0)return M;var O=x(E,C,N);return A.set(C,O),O}var S=D(w,E);return b.simplify?a(S):S}function p(w){var g=n(w);if(!g.isSymbolNode)throw new TypeError("Invalid variable. "+"Cannot parse ".concat(JSON.stringify(w)," into a variable in function derivative"));return g}var d=e(xd,{"Node, SymbolNode":v,"Node, SymbolNode, Object":v,"Node, string":(w,g)=>v(w,p(g)),"Node, string, Object":(w,g,b)=>v(w,p(g),b)});d._simplify=!0,d.toTex=function(w){return y.apply(null,w.args)};var y=e("_derivTex",{"Node, SymbolNode":function(g,b){return gr(g)&&Sr(g.value)==="string"?y(n(g.value).toString(),b.toString(),1):y(g.toTex(),b.toString(),1)},"Node, ConstantNode":function(g,b){if(Sr(b.value)==="string")return y(g,n(b.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(g,b,A){return y(g.toString(),b.name,A.value)},"string, string, number":function(g,b,A){var N;return A===1?N="{d\\over d"+b+"}":N="{d^{"+A+"}\\over d"+b+"^{"+A+"}}",N+"\\left[".concat(g,"\\right]")}}),x=e("_isConst",{"function, ConstantNode, string":function(){return!0},"function, SymbolNode, string":function(g,b,A){return b.name!==A},"function, ParenthesisNode, string":function(g,b,A){return g(b.content,A)},"function, FunctionAssignmentNode, string":function(g,b,A){return b.params.includes(A)?g(b.expr,A):!0},"function, FunctionNode | OperatorNode, string":function(g,b,A){return b.args.every(N=>g(N,A))}}),D=e("_derivative",{"ConstantNode, function":function(){return h(0)},"SymbolNode, function":function(g,b){return b(g)?h(0):h(1)},"ParenthesisNode, function":function(g,b){return new f(D(g.content,b))},"FunctionAssignmentNode, function":function(g,b){return b(g)?h(0):D(g.expr,b)},"FunctionNode, function":function(g,b){if(b(g))return h(0);var A=g.args[0],N,E=!1,S=!1,C;switch(g.name){case"cbrt":E=!0,C=new c("*","multiply",[h(3),new c("^","pow",[A,new c("/","divide",[h(2),h(3)])])]);break;case"sqrt":case"nthRoot":if(g.args.length===1)E=!0,C=new c("*","multiply",[h(2),new s("sqrt",[A])]);else if(g.args.length===2)return N=new c("/","divide",[h(1),g.args[1]]),D(new c("^","pow",[A,N]),b);break;case"log10":N=h(10);case"log":if(!N&&g.args.length===1)C=A.clone(),E=!0;else if(g.args.length===1&&N||g.args.length===2&&b(g.args[1]))C=new c("*","multiply",[A.clone(),new s("log",[N||g.args[1]])]),E=!0;else if(g.args.length===2)return D(new c("/","divide",[new s("log",[A]),new s("log",[g.args[1]])]),b);break;case"pow":if(g.args.length===2)return D(new c("^","pow",[A,g.args[1]]),b);break;case"exp":C=new s("exp",[A.clone()]);break;case"sin":C=new s("cos",[A.clone()]);break;case"cos":C=new c("-","unaryMinus",[new s("sin",[A.clone()])]);break;case"tan":C=new c("^","pow",[new s("sec",[A.clone()]),h(2)]);break;case"sec":C=new c("*","multiply",[g,new s("tan",[A.clone()])]);break;case"csc":S=!0,C=new c("*","multiply",[g,new s("cot",[A.clone()])]);break;case"cot":S=!0,C=new c("^","pow",[new s("csc",[A.clone()]),h(2)]);break;case"asin":E=!0,C=new s("sqrt",[new c("-","subtract",[h(1),new c("^","pow",[A.clone(),h(2)])])]);break;case"acos":E=!0,S=!0,C=new s("sqrt",[new c("-","subtract",[h(1),new c("^","pow",[A.clone(),h(2)])])]);break;case"atan":E=!0,C=new c("+","add",[new c("^","pow",[A.clone(),h(2)]),h(1)]);break;case"asec":E=!0,C=new c("*","multiply",[new s("abs",[A.clone()]),new s("sqrt",[new c("-","subtract",[new c("^","pow",[A.clone(),h(2)]),h(1)])])]);break;case"acsc":E=!0,S=!0,C=new c("*","multiply",[new s("abs",[A.clone()]),new s("sqrt",[new c("-","subtract",[new c("^","pow",[A.clone(),h(2)]),h(1)])])]);break;case"acot":E=!0,S=!0,C=new c("+","add",[new c("^","pow",[A.clone(),h(2)]),h(1)]);break;case"sinh":C=new s("cosh",[A.clone()]);break;case"cosh":C=new s("sinh",[A.clone()]);break;case"tanh":C=new c("^","pow",[new s("sech",[A.clone()]),h(2)]);break;case"sech":S=!0,C=new c("*","multiply",[g,new s("tanh",[A.clone()])]);break;case"csch":S=!0,C=new c("*","multiply",[g,new s("coth",[A.clone()])]);break;case"coth":S=!0,C=new c("^","pow",[new s("csch",[A.clone()]),h(2)]);break;case"asinh":E=!0,C=new s("sqrt",[new c("+","add",[new c("^","pow",[A.clone(),h(2)]),h(1)])]);break;case"acosh":E=!0,C=new s("sqrt",[new c("-","subtract",[new c("^","pow",[A.clone(),h(2)]),h(1)])]);break;case"atanh":E=!0,C=new c("-","subtract",[h(1),new c("^","pow",[A.clone(),h(2)])]);break;case"asech":E=!0,S=!0,C=new c("*","multiply",[A.clone(),new s("sqrt",[new c("-","subtract",[h(1),new c("^","pow",[A.clone(),h(2)])])])]);break;case"acsch":E=!0,S=!0,C=new c("*","multiply",[new s("abs",[A.clone()]),new s("sqrt",[new c("+","add",[new c("^","pow",[A.clone(),h(2)]),h(1)])])]);break;case"acoth":E=!0,S=!0,C=new c("-","subtract",[h(1),new c("^","pow",[A.clone(),h(2)])]);break;case"abs":C=new c("/","divide",[new s(new m("abs"),[A.clone()]),A.clone()]);break;case"gamma":default:throw new Error('Cannot process function "'+g.name+'" in derivative: the function is not supported, undefined, or the number of arguments passed to it are not supported')}var M,O;E?(M="/",O="divide"):(M="*",O="multiply");var I=D(A,b);return S&&(I=new c("-","unaryMinus",[I])),new c(M,O,[I,C])},"OperatorNode, function":function(g,b){if(b(g))return h(0);if(g.op==="+")return new c(g.op,g.fn,g.args.map(function(_){return D(_,b)}));if(g.op==="-"){if(g.isUnary())return new c(g.op,g.fn,[D(g.args[0],b)]);if(g.isBinary())return new c(g.op,g.fn,[D(g.args[0],b),D(g.args[1],b)])}if(g.op==="*"){var A=g.args.filter(function(_){return b(_)});if(A.length>0){var N=g.args.filter(function(_){return!b(_)}),E=N.length===1?N[0]:new c("*","multiply",N),S=A.concat(D(E,b));return new c("*","multiply",S)}return new c("+","add",g.args.map(function(_){return new c("*","multiply",g.args.map(function(P){return P===_?D(P,b):P.clone()}))}))}if(g.op==="/"&&g.isBinary()){var C=g.args[0],M=g.args[1];return b(M)?new c("/","divide",[D(C,b),M]):b(C)?new c("*","multiply",[new c("-","unaryMinus",[C]),new c("/","divide",[D(M,b),new c("^","pow",[M.clone(),h(2)])])]):new c("/","divide",[new c("-","subtract",[new c("*","multiply",[D(C,b),M.clone()]),new c("*","multiply",[C.clone(),D(M,b)])]),new c("^","pow",[M.clone(),h(2)])])}if(g.op==="^"&&g.isBinary()){var O=g.args[0],I=g.args[1];if(b(O))return gr(O)&&(o(O.value)||i(O.value,1))?h(0):new c("*","multiply",[g,new c("*","multiply",[new s("log",[O.clone()]),D(I.clone(),b)])]);if(b(I)){if(gr(I)){if(o(I.value))return h(0);if(i(I.value,1))return D(O,b)}var k=new c("^","pow",[O.clone(),new c("-","subtract",[I,h(1)])]);return new c("*","multiply",[I.clone(),new c("*","multiply",[D(O,b),k])])}return new c("*","multiply",[new c("^","pow",[O.clone(),I.clone()]),new c("+","add",[new c("*","multiply",[D(O,b),new c("/","divide",[I.clone(),O.clone()])]),new c("*","multiply",[D(I,b),new s("log",[O.clone()])])])])}throw new Error('Cannot process operator "'+g.op+'" in derivative: the operator is not supported, undefined, or the number of arguments passed to it are not supported')}});function h(w,g){return new u(l(w,An(String(w),t)))}return d}),wd="rationalize",OB=["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"],BB=L(wd,OB,r=>{var{config:e,typed:t,equal:n,isZero:a,add:i,subtract:o,multiply:l,divide:u,pow:s,parse:c,simplifyConstant:f,simplifyCore:m,simplify:v,fraction:p,bignumber:d,mathWithTransform:y,matrix:x,AccessorNode:D,ArrayNode:h,ConstantNode:w,FunctionNode:g,IndexNode:b,ObjectNode:A,OperatorNode:N,SymbolNode:E,ParenthesisNode:S}=r;function C(_){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},V=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,q=O(),J=M(_,P,!0,q.firstRules),ne=J.variables.length,j={exactFractions:!1},F={exactFractions:!0};if(_=J.expression,ne>=1){_=I(_);var U,$,le=!0,me=!1;_=v(_,q.firstRules,{},j);for(var Y;$=le?q.distrDivRules:q.sucDivRules,_=v(_,$,{},F),le=!le,Y=_.toString(),Y!==U;)me=!0,U=Y;me&&(_=v(_,q.firstRulesAgain,{},j)),_=v(_,q.finalRules,{},j)}var z=[],X={};return _.type==="OperatorNode"&&_.isBinary()&&_.op==="/"?(ne===1&&(_.args[0]=k(_.args[0],z),_.args[1]=k(_.args[1])),V&&(X.numerator=_.args[0],X.denominator=_.args[1])):(ne===1&&(_=k(_,z)),V&&(X.numerator=_,X.denominator=null)),V?(X.coefficients=z,X.variables=J.variables,X.expression=_,X):_}return t(wd,{Node:C,"Node, boolean":(_,P)=>C(_,{},P),"Node, Object":C,"Node, Object, boolean":C});function M(_,P,V,q){var J=[],ne=v(_,q,P,{exactFractions:!1});V=!!V;var j="+-*"+(V?"/":"");U(ne);var F={};return F.expression=ne,F.variables=J,F;function U($){var le=$.type;if(le==="FunctionNode")throw new Error("There is an unsolved function call");if(le==="OperatorNode")if($.op==="^"){if($.args[1].type!=="ConstantNode"||!Ue(parseFloat($.args[1].value)))throw new Error("There is a non-integer exponent");U($.args[0])}else{if(!j.includes($.op))throw new Error("Operator "+$.op+" invalid in polynomial expression");for(var me=0;me<$.args.length;me++)U($.args[me])}else if(le==="SymbolNode"){var Y=$.name,z=J.indexOf(Y);z===-1&&J.push(Y)}else if(le==="ParenthesisNode")U($.content);else if(le!=="ConstantNode")throw new Error("type "+le+" is not allowed in polynomial expression")}}function O(){var _=[m,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},f,{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"}],P=[{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)"}],V=[{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)"}],q=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],J={};return J.firstRules=_.concat(P,q),J.distrDivRules=V,J.sucDivRules=q,J.firstRulesAgain=_.concat(P),J.finalRules=[m,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},f,{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))"}],J}function I(_,P,V){var q=_.type,J=arguments.length>1;if(q==="OperatorNode"&&_.isBinary()){var ne=!1,j;if(_.op==="^"&&(_.args[0].type==="ParenthesisNode"||_.args[0].type==="OperatorNode")&&_.args[1].type==="ConstantNode"&&(j=parseFloat(_.args[1].value),ne=j>=2&&Ue(j)),ne){if(j>2){var F=_.args[0],U=new N("^","pow",[_.args[0].cloneDeep(),new w(j-1)]);_=new N("*","multiply",[F,U])}else _=new N("*","multiply",[_.args[0],_.args[0].cloneDeep()]);J&&(V==="content"?P.content=_:P.args[V]=_)}}if(q==="ParenthesisNode")I(_.content,_,"content");else if(q!=="ConstantNode"&&q!=="SymbolNode")for(var $=0;$<_.args.length;$++)I(_.args[$],_,$);if(!J)return _}function k(_,P){P===void 0&&(P=[]),P[0]=0;var V={};V.cte=1,V.oper="+",V.fire="";var q=0,J="";Y(_,null,V),q=P.length-1;for(var ne=!0,j,F=q;F>=0;F--)if(P[F]!==0){var U=new w(ne?P[F]:Math.abs(P[F])),$=P[F]<0?"-":"+";if(F>0){var le=new E(J);if(F>1){var me=new w(F);le=new N("^","pow",[le,me])}P[F]===-1&&ne?U=new N("-","unaryMinus",[le]):Math.abs(P[F])===1?U=le:U=new N("*","multiply",[U,le])}ne?j=U:$==="+"?j=new N("+","add",[j,U]):j=new N("-","subtract",[j,U]),ne=!1}if(ne)return new w(0);return j;function Y(z,X,se){var re=z.type;if(re==="FunctionNode")throw new Error("There is an unsolved function call");if(re==="OperatorNode"){if(!"+-*^".includes(z.op))throw new Error("Operator "+z.op+" invalid");if(X!==null){if((z.fn==="unaryMinus"||z.fn==="pow")&&X.fn!=="add"&&X.fn!=="subtract"&&X.fn!=="multiply")throw new Error("Invalid "+z.op+" placing");if((z.fn==="subtract"||z.fn==="add"||z.fn==="multiply")&&X.fn!=="add"&&X.fn!=="subtract")throw new Error("Invalid "+z.op+" placing");if((z.fn==="subtract"||z.fn==="add"||z.fn==="unaryMinus")&&se.noFil!==0)throw new Error("Invalid "+z.op+" placing")}(z.op==="^"||z.op==="*")&&(se.fire=z.op);for(var pe=0;pe<z.args.length;pe++)z.fn==="unaryMinus"&&(se.oper="-"),(z.op==="+"||z.fn==="subtract")&&(se.fire="",se.cte=1,se.oper=pe===0?"+":z.op),se.noFil=pe,Y(z.args[pe],z,se)}else if(re==="SymbolNode"){if(z.name!==J&&J!=="")throw new Error("There is more than one variable");if(J=z.name,X===null){P[1]=1;return}if(X.op==="^"&&se.noFil!==0)throw new Error("In power the variable should be the first parameter");if(X.op==="*"&&se.noFil!==1)throw new Error("In multiply the variable should be the second parameter");(se.fire===""||se.fire==="*")&&(q<1&&(P[1]=0),P[1]+=se.cte*(se.oper==="+"?1:-1),q=Math.max(1,q))}else if(re==="ConstantNode"){var ve=parseFloat(z.value);if(X===null){P[0]=ve;return}if(X.op==="^"){if(se.noFil!==1)throw new Error("Constant cannot be powered");if(!Ue(ve)||ve<=0)throw new Error("Non-integer exponent is not allowed");for(var De=q+1;De<ve;De++)P[De]=0;ve>q&&(P[ve]=0),P[ve]+=se.cte*(se.oper==="+"?1:-1),q=Math.max(ve,q);return}se.cte=ve,se.fire===""&&(P[0]+=se.cte*(se.oper==="+"?1:-1))}else throw new Error("Type "+re+" is not allowed")}}}),Dd="zpk2tf",RB=["typed","add","multiply","Complex","number"],IB=L(Dd,RB,r=>{var{typed:e,add:t,multiply:n,Complex:a,number:i}=r;return e(Dd,{"Array,Array,number":function(s,c,f){return o(s,c,f)},"Array,Array":function(s,c){return o(s,c,1)},"Matrix,Matrix,number":function(s,c,f){return o(s.valueOf(),c.valueOf(),f)},"Matrix,Matrix":function(s,c){return o(s.valueOf(),c.valueOf(),1)}});function o(u,s,c){u.some(D=>D.type==="BigNumber")&&(u=u.map(D=>i(D))),s.some(D=>D.type==="BigNumber")&&(s=s.map(D=>i(D)));for(var f=[a(1,0)],m=[a(1,0)],v=0;v<u.length;v++){var p=u[v];typeof p=="number"&&(p=a(p,0)),f=l(f,[a(1,0),a(-p.re,-p.im)])}for(var d=0;d<s.length;d++){var y=s[d];typeof y=="number"&&(y=a(y,0)),m=l(m,[a(1,0),a(-y.re,-y.im)])}for(var x=0;x<f.length;x++)f[x]=n(f[x],c);return[f,m]}function l(u,s){for(var c=[],f=0;f<u.length+s.length-1;f++){c[f]=a(0,0);for(var m=0;m<u.length;m++)f-m>=0&&f-m<s.length&&(c[f]=t(c[f],n(u[m],s[f-m])))}return c}}),Nd="freqz",PB=["typed","add","multiply","Complex","divide","matrix"],$B=L(Nd,PB,r=>{var{typed:e,add:t,multiply:n,Complex:a,divide:i,matrix:o}=r;return e(Nd,{"Array, Array":function(c,f){var m=u(512);return l(c,f,m)},"Array, Array, Array":function(c,f,m){return l(c,f,m)},"Array, Array, number":function(c,f,m){if(m<0)throw new Error("w must be a positive number");var v=u(m);return l(c,f,v)},"Matrix, Matrix":function(c,f){var m=u(512),{w:v,h:p}=l(c.valueOf(),f.valueOf(),m);return{w:o(v),h:o(p)}},"Matrix, Matrix, Matrix":function(c,f,m){var{h:v}=l(c.valueOf(),f.valueOf(),m.valueOf());return{h:o(v),w:o(m)}},"Matrix, Matrix, number":function(c,f,m){if(m<0)throw new Error("w must be a positive number");var v=u(m),{h:p}=l(c.valueOf(),f.valueOf(),v);return{h:o(p),w:o(v)}}});function l(s,c,f){for(var m=[],v=[],p=0;p<f.length;p++){for(var d=a(0,0),y=a(0,0),x=0;x<s.length;x++)d=t(d,n(s[x],a(Math.cos(-x*f[p]),Math.sin(-x*f[p]))));for(var D=0;D<c.length;D++)y=t(y,n(c[D],a(Math.cos(-D*f[p]),Math.sin(-D*f[p]))));m.push(d),v.push(y)}for(var h=[],w=0;w<m.length;w++)h.push(i(m[w],v[w]));return{h,w:f}}function u(s){for(var c=[],f=0;f<s;f++)c.push(f/s*Math.PI);return c}}),qB="reviver",zB=["classes"],UB=L(qB,zB,r=>{var{classes:e}=r;return function(n,a){var i=e[a&&a.mathjs];return i&&typeof i.fromJSON=="function"?i.fromJSON(a):a}}),LB="replacer",kB=[],VB=L(LB,kB,()=>function(e,t){return typeof t=="number"&&(!Number.isFinite(t)||isNaN(t))?{mathjs:"number",value:String(t)}:typeof t=="bigint"?{mathjs:"bigint",value:String(t)}:t}),GB="15.2.0",HB=L("true",[],()=>!0),WB=L("false",[],()=>!1),YB=L("null",[],()=>null),ZB=_t("Infinity",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1/0):1/0}),JB=_t("NaN",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(NaN):NaN}),jB=_t("pi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?Rs(t):z1}),XB=_t("tau",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?yE(t):U1}),QB=_t("e",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?hE(t):L1}),KB=_t("phi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?gE(t):k1}),e4=_t("LN2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).ln():Math.LN2}),r4=_t("LN10",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(10).ln():Math.LN10}),t4=_t("LOG2E",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1).div(new t(2).ln()):Math.LOG2E}),n4=_t("LOG10E",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1).div(new t(10).ln()):Math.LOG10E}),a4=_t("SQRT1_2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t("0.5").sqrt():Math.SQRT1_2}),i4=_t("SQRT2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).sqrt():Math.SQRT2}),o4=_t("i",["Complex"],r=>{var{Complex:e}=r;return e.I}),s4=L("version",[],()=>GB);function _t(r,e,t){return L(r,e,t,{recreateOnConfigChange:!0})}var u4=nr("speedOfLight","299792458","m s^-1"),l4=nr("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),c4=nr("planckConstant","6.62607015e-34","J s"),f4=nr("reducedPlanckConstant","1.0545718176461565e-34","J s"),m4=nr("magneticConstant","1.25663706212e-6","N A^-2"),v4=nr("electricConstant","8.8541878128e-12","F m^-1"),p4=nr("vacuumImpedance","376.730313667","ohm"),d4=nr("coulomb","8.987551792261171e9","N m^2 C^-2"),h4=nr("coulombConstant","8.987551792261171e9","N m^2 C^-2"),g4=nr("elementaryCharge","1.602176634e-19","C"),y4=nr("bohrMagneton","9.2740100783e-24","J T^-1"),b4=nr("conductanceQuantum","7.748091729863649e-5","S"),x4=nr("inverseConductanceQuantum","12906.403729652257","ohm"),w4=nr("magneticFluxQuantum","2.0678338484619295e-15","Wb"),D4=nr("nuclearMagneton","5.0507837461e-27","J T^-1"),N4=nr("klitzing","25812.807459304513","ohm"),E4=nr("bohrRadius","5.29177210903e-11","m"),A4=nr("classicalElectronRadius","2.8179403262e-15","m"),S4=nr("electronMass","9.1093837015e-31","kg"),C4=nr("fermiCoupling","1.1663787e-5","GeV^-2"),M4=Ro("fineStructure",.0072973525693),_4=nr("hartreeEnergy","4.3597447222071e-18","J"),T4=nr("protonMass","1.67262192369e-27","kg"),F4=nr("deuteronMass","3.3435830926e-27","kg"),O4=nr("neutronMass","1.6749271613e-27","kg"),B4=nr("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),R4=nr("rydberg","10973731.568160","m^-1"),I4=nr("thomsonCrossSection","6.6524587321e-29","m^2"),P4=Ro("weakMixingAngle",.2229),$4=Ro("efimovFactor",22.7),q4=nr("atomicMass","1.66053906660e-27","kg"),z4=nr("avogadro","6.02214076e23","mol^-1"),U4=nr("boltzmann","1.380649e-23","J K^-1"),L4=nr("faraday","96485.33212331001","C mol^-1"),k4=nr("firstRadiation","3.7417718521927573e-16","W m^2"),V4=nr("loschmidt","2.686780111798444e25","m^-3"),G4=nr("gasConstant","8.31446261815324","J K^-1 mol^-1"),H4=nr("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),W4=nr("molarVolume","0.022413969545014137","m^3 mol^-1"),Y4=Ro("sackurTetrode",-1.16487052358),Z4=nr("secondRadiation","0.014387768775039337","m K"),J4=nr("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),j4=nr("wienDisplacement","2.897771955e-3","m K"),X4=nr("molarMass","0.99999999965e-3","kg mol^-1"),Q4=nr("molarMassC12","11.9999999958e-3","kg mol^-1"),K4=nr("gravity","9.80665","m s^-2"),eR=nr("planckLength","1.616255e-35","m"),rR=nr("planckMass","2.176435e-8","kg"),tR=nr("planckTime","5.391245e-44","s"),nR=nr("planckCharge","1.87554603778e-18","C"),aR=nr("planckTemperature","1.416785e+32","K");function nr(r,e,t){var n=["config","Unit","BigNumber"];return L(r,n,a=>{var{config:i,Unit:o,BigNumber:l}=a,u=i.number==="BigNumber"?new l(e):parseFloat(e),s=new o(u,t);return s.fixPrefix=!0,s})}function Ro(r,e){var t=["config","BigNumber"];return L(r,t,n=>{var{config:a,BigNumber:i}=n;return a.number==="BigNumber"?new i(e):e})}function Ed(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function iR(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ed(Object(t),!0).forEach(function(n){Vr(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Ed(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}var oR="mapSlices",sR=["typed","isInteger"],uR=L(oR,sR,r=>{var{typed:e,isInteger:t}=r,n=xs({typed:e,isInteger:t});return e("mapSlices",{"...any":function(i){var o=i[1];Ye(o)?i[1]=o-1:or(o)&&(i[1]=o.minus(1));try{return n.apply(null,i)}catch(l){throw ht(l)}}})},iR({isTransformFunction:!0},xs.meta)),lR="column",cR=["typed","Index","matrix","range"],fR=L(lR,cR,r=>{var{typed:e,Index:t,matrix:n,range:a}=r,i=Jf({typed:e,Index:t,matrix:n,range:a});return e("column",{"...any":function(l){var u=l.length-1,s=l[u];Ye(s)&&(l[u]=s-1);try{return i.apply(null,l)}catch(c){throw ht(c)}}})},{isTransformFunction:!0});function Qs(r,e,t){var n=r.filter(function(u){return jr(u)&&!(u.name in e)&&!t.has(u.name)})[0];if(!n)throw new Error('No undefined variable found in inline expression "'+r+'"');var a=n.name,i=new Map,o=new Yu(t,i,new Set([a])),l=r.compile();return function(s){return i.set(a,s),l.evaluate(o)}}var mR="transformCallback",vR=["typed"],Ks=L(mR,vR,r=>{var{typed:e}=r;return function(n,a){return e.isTypedFunction(n)?t(n,a):Ad(n,n.length,a)};function t(n,a){var i=Object.fromEntries(Object.entries(n.signatures).map(o=>{var[l,u]=o,s=l.split(",").length;return e.isTypedFunction(u)?[l,t(u,a)]:[l,Ad(u,s,a)]}));return typeof n.name=="string"?e(n.name,i):e(i)}});function Ad(r,e,t){return e===t?r:e===t+1?function(){for(var n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];var o=a.slice(0,t),l=Sd(a[t]);return r(...o,l)}:e>t+1?function(){for(var n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];var o=a.slice(0,t),l=Sd(a[t]),u=a.slice(t+1);return r(...o,l,...u)}:r}function Sd(r){return r.map(e=>e+1)}var pR="filter",dR=["typed"],hR=L(pR,dR,r=>{var{typed:e}=r;function t(a,i,o){var l=Kf({typed:e}),u=Ks({typed:e});if(a.length===0)return l();var s=a[0];if(a.length===1)return l(s);var c=a.length-1,f=a[c];return s&&(s=n(s,o)),f&&(jr(f)||ei(f)?f=n(f,o):f=Qs(f,i,o)),l(s,u(f,c))}t.rawArgs=!0;function n(a,i){return a.compile().evaluate(i)}return t},{isTransformFunction:!0}),gR="forEach",yR=["typed"],bR=L(gR,yR,r=>{var{typed:e}=r,t=tm({typed:e}),n=Ks({typed:e});function a(o,l,u){if(o.length===0)return t();var s=o[0];if(o.length===1)return t(s);var c=o.length-1,f=o[c];return s&&(s=i(s,u)),f&&(jr(f)||ei(f)?f=i(f,u):f=Qs(f,l,u)),t(s,n(f,c))}a.rawArgs=!0;function i(o,l){return o.compile().evaluate(l)}return a},{isTransformFunction:!0}),xR="index",wR=["Index","getMatrixDataType"],DR=L(xR,wR,r=>{var{Index:e,getMatrixDataType:t}=r;return function(){for(var a=[],i=0,o=arguments.length;i<o;i++){var l=arguments[i];if(jo(l))l.start--,l.end-=l.step>0?0:2;else if(l&&l.isSet===!0)l=l.map(function(s){return s-1});else if(Ar(l)||Je(l))t(l)!=="boolean"&&(l=l.map(function(s){return s-1}));else if(Ye(l)||Qa(l))l--;else if(or(l))l=l.toNumber()-1;else if(typeof l!="string")throw new TypeError("Dimension must be an Array, Matrix, number, bigint, string, or Range");a[i]=l}var u=new e;return e.apply(u,a),u}},{isTransformFunction:!0}),NR="map",ER=["typed"],AR=L(NR,ER,r=>{var{typed:e}=r,t=om({typed:e}),n=Ks({typed:e});function a(i,o,l){if(i.length===0)return t();if(i.length===1)return t(i[0]);var u=i.length-1,s=i.slice(0,u),c=i[u];return s=s.map(m=>f(m,l)),c&&(jr(c)||ei(c)?c=f(c,l):c=Qs(c,o,l)),t(...s,n(c,u));function f(m,v){return m.compile().evaluate(v)}}return a.rawArgs=!0,a},{isTransformFunction:!0});function SR(r){return Ye(r)?r-1:or(r)?r.minus(1):r}function CR(r){return Ye(r)||or(r)}function $n(r){if(r.length===2&&Mt(r[0])){r=r.slice();var e=r[1];CR(e)&&(r[1]=SR(e))}return r}var MR="max",_R=["typed","config","numeric","larger","isNaN"],TR=L(MR,_R,r=>{var{typed:e,config:t,numeric:n,larger:a,isNaN:i}=r,o=mv({typed:e,config:t,numeric:n,larger:a,isNaN:i});return e("max",{"...any":function(u){u=$n(u);try{return o.apply(null,u)}catch(s){throw ht(s)}}})},{isTransformFunction:!0}),FR="mean",OR=["typed","add","divide"],BR=L(FR,OR,r=>{var{typed:e,add:t,divide:n}=r,a=qp({typed:e,add:t,divide:n});return e("mean",{"...any":function(o){o=$n(o);try{return a.apply(null,o)}catch(l){throw ht(l)}}})},{isTransformFunction:!0}),RR="min",IR=["typed","config","numeric","smaller","isNaN"],PR=L(RR,IR,r=>{var{typed:e,config:t,numeric:n,smaller:a,isNaN:i}=r,o=pv({typed:e,config:t,numeric:n,smaller:a,isNaN:i});return e("min",{"...any":function(u){u=$n(u);try{return o.apply(null,u)}catch(s){throw ht(s)}}})},{isTransformFunction:!0}),$R="range",qR=["typed","config","?matrix","?bignumber","equal","smaller","smallerEq","larger","largerEq","add","isZero","isPositive"],zR=L($R,qR,r=>{var{typed:e,config:t,matrix:n,bignumber:a,equal:i,smaller:o,smallerEq:l,larger:u,largerEq:s,add:c,isZero:f,isPositive:m}=r,v=fm({typed:e,config:t,matrix:n,bignumber:a,equal:i,smaller:o,smallerEq:l,larger:u,largerEq:s,add:c,isZero:f,isPositive:m});return e("range",{"...any":function(d){var y=d.length-1,x=d[y];return typeof x!="boolean"&&d.push(!0),v.apply(null,d)}})},{isTransformFunction:!0}),UR="row",LR=["typed","Index","matrix","range"],kR=L(UR,LR,r=>{var{typed:e,Index:t,matrix:n,range:a}=r,i=hm({typed:e,Index:t,matrix:n,range:a});return e("row",{"...any":function(l){var u=l.length-1,s=l[u];Ye(s)&&(l[u]=s-1);try{return i.apply(null,l)}catch(c){throw ht(c)}}})},{isTransformFunction:!0}),VR="subset",GR=["typed","matrix","zeros","add"],HR=L(VR,GR,r=>{var{typed:e,matrix:t,zeros:n,add:a}=r,i=xm({typed:e,matrix:t,zeros:n,add:a});return e("subset",{"...any":function(l){try{return i.apply(null,l)}catch(u){throw ht(u)}}})},{isTransformFunction:!0}),WR="concat",YR=["typed","matrix","isInteger"],ZR=L(WR,YR,r=>{var{typed:e,matrix:t,isInteger:n}=r,a=Yf({typed:e,matrix:t,isInteger:n});return e("concat",{"...any":function(o){var l=o.length-1,u=o[l];Ye(u)?o[l]=u-1:or(u)&&(o[l]=u.minus(1));try{return a.apply(null,o)}catch(s){throw ht(s)}}})},{isTransformFunction:!0}),Cd="diff",JR=["typed","matrix","subtract","number","bignumber"],jR=L(Cd,JR,r=>{var{typed:e,matrix:t,subtract:n,number:a,bignumber:i}=r,o=um({typed:e,matrix:t,subtract:n,number:a,bignumber:i});return e(Cd,{"...any":function(u){u=$n(u);try{return o.apply(null,u)}catch(s){throw ht(s)}}})},{isTransformFunction:!0}),XR="std",QR=["typed","map","sqrt","variance"],KR=L(XR,QR,r=>{var{typed:e,map:t,sqrt:n,variance:a}=r,i=Wp({typed:e,map:t,sqrt:n,variance:a});return e("std",{"...any":function(l){l=$n(l);try{return i.apply(null,l)}catch(u){throw ht(u)}}})},{isTransformFunction:!0}),Md="sum",e5=["typed","config","add","numeric"],r5=L(Md,e5,r=>{var{typed:e,config:t,add:n,numeric:a}=r,i=Ip({typed:e,config:t,add:n,numeric:a});return e(Md,{"...any":function(l){l=$n(l);try{return i.apply(null,l)}catch(u){throw ht(u)}}})},{isTransformFunction:!0}),t5="quantileSeq",n5=["typed","bignumber","add","subtract","divide","multiply","partitionSelect","compare","isInteger","smaller","smallerEq","larger","mapSlices"],a5=L(t5,n5,r=>{var{typed:e,bignumber:t,add:n,subtract:a,divide:i,multiply:o,partitionSelect:l,compare:u,isInteger:s,smaller:c,smallerEq:f,larger:m,mapSlices:v}=r,p=Gp({typed:e,bignumber:t,add:n,subtract:a,divide:i,multiply:o,partitionSelect:l,compare:u,isInteger:s,smaller:c,smallerEq:f,larger:m,mapSlices:v});return e("quantileSeq",{"Array | Matrix, number | BigNumber":p,"Array | Matrix, number | BigNumber, number":(y,x,D)=>p(y,x,d(D)),"Array | Matrix, number | BigNumber, boolean":p,"Array | Matrix, number | BigNumber, boolean, number":(y,x,D,h)=>p(y,x,D,d(h)),"Array | Matrix, Array | Matrix":p,"Array | Matrix, Array | Matrix, number":(y,x,D)=>p(y,x,d(D)),"Array | Matrix, Array | Matrix, boolean":p,"Array | Matrix, Array | Matrix, boolean, number":(y,x,D,h)=>p(y,x,D,d(h))});function d(y){return $n([[],y])[1]}},{isTransformFunction:!0}),_d="cumsum",i5=["typed","add","unaryPlus"],o5=L(_d,i5,r=>{var{typed:e,add:t,unaryPlus:n}=r,a=Pp({typed:e,add:t,unaryPlus:n});return e(_d,{"...any":function(o){if(o.length===2&&Mt(o[0])){var l=o[1];Ye(l)?o[1]=l-1:or(l)&&(o[1]=l.minus(1))}try{return a.apply(null,o)}catch(u){throw ht(u)}}})},{isTransformFunction:!0}),Td="variance",s5=["typed","add","subtract","multiply","divide","mapSlices","isNaN"],u5=L(Td,s5,r=>{var{typed:e,add:t,subtract:n,multiply:a,divide:i,mapSlices:o,isNaN:l}=r,u=kp({typed:e,add:t,subtract:n,multiply:a,divide:i,mapSlices:o,isNaN:l});return e(Td,{"...any":function(c){c=$n(c);try{return u.apply(null,c)}catch(f){throw ht(f)}}})},{isTransformFunction:!0}),Fd="print",l5=["typed","matrix","zeros","add"],c5=L(Fd,l5,r=>{var{typed:e,matrix:t,zeros:n,add:a}=r,i=$m({typed:e,matrix:t,zeros:n,add:a});return e(Fd,{"string, Object | Array":function(u,s){return i(o(u),s)},"string, Object | Array, number | Object":function(u,s,c){return i(o(u),s,c)}});function o(l){return l.replace(Im,u=>{var s=u.slice(1).split("."),c=s.map(function(f){return!isNaN(f)&&f.length>0?parseInt(f)-1:f});return"$"+c.join(".")})}},{isTransformFunction:!0}),f5="and",m5=["typed","matrix","zeros","add","equalScalar","not","concat"],v5=L(f5,m5,r=>{var{typed:e,matrix:t,equalScalar:n,zeros:a,not:i,concat:o}=r,l=av({typed:e,matrix:t,equalScalar:n,zeros:a,not:i,concat:o});function u(s,c,f){var m=s[0].compile().evaluate(f);if(!Mt(m)&&!l(m,!0))return!1;var v=s[1].compile().evaluate(f);return l(m,v)}return u.rawArgs=!0,u},{isTransformFunction:!0}),p5="or",d5=["typed","matrix","equalScalar","DenseMatrix","concat"],h5=L(p5,d5,r=>{var{typed:e,matrix:t,equalScalar:n,DenseMatrix:a,concat:i}=r,o=Gf({typed:e,matrix:t,equalScalar:n,DenseMatrix:a,concat:i});function l(u,s,c){var f=u[0].compile().evaluate(c);if(!Mt(f)&&o(f,!1))return!0;var m=u[1].compile().evaluate(c);return o(f,m)}return l.rawArgs=!0,l},{isTransformFunction:!0}),g5="nullish",y5=["typed","matrix","size","flatten","deepEqual"],b5=L(g5,y5,r=>{var{typed:e,matrix:t,size:n,flatten:a,deepEqual:i}=r,o=kf({typed:e,matrix:t,size:n,flatten:a,deepEqual:i});function l(u,s,c){var f=u[0].compile().evaluate(c);if(!Mt(f)&&f!=null&&f!==void 0)return f;var m=u[1].compile().evaluate(c);return o(f,m)}return l.rawArgs=!0,l},{isTransformFunction:!0}),x5="bitAnd",w5=["typed","matrix","zeros","add","equalScalar","not","concat"],D5=L(x5,w5,r=>{var{typed:e,matrix:t,equalScalar:n,zeros:a,not:i,concat:o}=r,l=Ff({typed:e,matrix:t,equalScalar:n,zeros:a,not:i,concat:o});function u(s,c,f){var m=s[0].compile().evaluate(f);if(!Mt(m)){if(isNaN(m))return NaN;if(m===0||m===!1)return 0}var v=s[1].compile().evaluate(f);return l(m,v)}return u.rawArgs=!0,u},{isTransformFunction:!0}),N5="bitOr",E5=["typed","matrix","equalScalar","DenseMatrix","concat"],A5=L(N5,E5,r=>{var{typed:e,matrix:t,equalScalar:n,DenseMatrix:a,concat:i}=r,o=Rf({typed:e,matrix:t,equalScalar:n,DenseMatrix:a,concat:i});function l(u,s,c){var f=u[0].compile().evaluate(c);if(!Mt(f)){if(isNaN(f))return NaN;if(f===-1)return-1;if(f===!0)return 1}var m=u[1].compile().evaluate(c);return o(f,m)}return l.rawArgs=!0,l},{isTransformFunction:!0}),Od="num",S5=["typed","fraction"],C5=L(Od,S5,r=>{var{typed:e,fraction:t}=r;return e(Od,{Fraction:n=>n.s*n.n,BigNumber:n=>{var a=t(n);return a.s*a.n},"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),Bd="den",M5=["typed","fraction"],_5=L(Bd,M5,r=>{var{typed:e,fraction:t}=r;return e(Bd,{Fraction:n=>n.d,BigNumber:n=>t(n).d,"Array | Matrix":e.referToSelf(n=>a=>tr(a,n))})}),Me=Qy({config:ye}),Mr=n1({}),Rd=QB({BigNumber:Me,config:ye}),T5=WB({}),F5=M4({BigNumber:Me,config:ye}),qn=f1({}),Id=o4({Complex:Mr}),O5=ZB({BigNumber:Me,config:ye}),B5=r4({BigNumber:Me,config:ye}),R5=n4({BigNumber:Me,config:ye}),Io=g1({}),I5=JB({BigNumber:Me,config:ye}),P5=YB({}),$5=KB({BigNumber:Me,config:ye}),q5=p1({}),Pd=ty({}),z5=a4({BigNumber:Me,config:ye}),U5=Y4({BigNumber:Me,config:ye}),$d=XB({BigNumber:Me,config:ye}),L5=HB({}),k5=s4({}),sr=B1({Matrix:Io,config:ye}),V5=$4({BigNumber:Me,config:ye}),G5=e4({BigNumber:Me,config:ye}),eu=jB({BigNumber:Me,config:ye}),qd=VB({}),H5=i4({BigNumber:Me,config:ye}),W=Q0({BigNumber:Me,Complex:Mr,DenseMatrix:sr,Fraction:qn}),W5=P4({BigNumber:Me,config:ye}),gt=Qb({typed:W}),Y5=_E({Complex:Mr,config:ye,typed:W}),Z5=BE({BigNumber:Me,typed:W}),J5=$E({BigNumber:Me,Complex:Mr,config:ye,typed:W}),Yr=tx({typed:W}),j5=Vw({typed:W}),X5=VE({BigNumber:Me,Complex:Mr,config:ye,typed:W}),Q5=ZE({typed:W}),zd=XE({typed:W}),K5=rA({Complex:Mr,config:ye,typed:W}),eI=Nb({typed:W}),rI=Pw({typed:W}),tI=Cb({typed:W}),nI=I1({typed:W}),Po=DO({typed:W}),$o=Bb({Complex:Mr,typed:W}),na=Hw({typed:W}),ru=nA({typed:W}),aI=sA({BigNumber:Me,typed:W}),iI=fA({BigNumber:Me,typed:W}),oI=yx({typed:W}),cr=mb({config:ye,typed:W}),sI=fN({typed:W}),Ud=xx({typed:W}),uI=Dx({Complex:Mr,typed:W}),lI=Kf({typed:W}),aa=vD({typed:W}),cI=tm({typed:W}),mi=DN({typed:W}),tu=gD({typed:W}),fI=MN({format:mi,typed:W}),nu=Yw({typed:W}),vi=ib({typed:W}),gn=nb({typed:W}),ia=J1({typed:W}),mI=IN({typed:W}),vI=t4({BigNumber:Me,config:ye}),pI=MO({Complex:Mr,typed:W}),dI=tw({Complex:Mr,config:ye,typed:W}),au=aw({Complex:Mr,config:ye,typed:W}),zn=om({typed:W}),hI=yN({isNaN:gn,isNumeric:ia,typed:W}),qr=sw({typed:W}),qo=Xw({typed:W}),an=xb({typed:W}),gI=SN({format:mi,typed:W}),yI=eB({config:ye,typed:W}),bI=$m({typed:W}),xI=tB({config:ye,typed:W}),iu=Jw({typed:W}),wI=dA({BigNumber:Me,typed:W}),Ld=vw({BigNumber:Me,Fraction:qn,complex:$o,typed:W}),zo=bA({typed:W}),Zr=UD({typed:W}),Jr=db({Matrix:Io,equalScalar:cr,typed:W}),DI=Wb({typed:W}),NI=yw({typed:W}),EI=Ab({typed:W}),Lt=ax({typed:W}),AI=NA({typed:W}),SI=BN({typed:W}),ou=lb({typed:W}),CI=FE({Complex:Mr,config:ye,typed:W}),MI=zE({BigNumber:Me,typed:W}),_I=LE({BigNumber:Me,Complex:Mr,config:ye,typed:W}),Et=Tb({BigNumber:Me,typed:W}),TI=EO({typed:W}),FI=iA({typed:W}),OI=vA({BigNumber:Me,typed:W}),Uo=eS({addScalar:Yr,conj:na,multiplyScalar:qr,size:Zr,typed:W}),BI=X1({isNumeric:ia,typed:W}),RI=sb({isBounded:vi,map:zn,typed:W}),Un=Y1({config:ye,typed:W}),kt=rb({equalScalar:cr,typed:W}),Ce=qb({DenseMatrix:sr,Matrix:Io,SparseMatrix:Jr,typed:W}),II=Ub({isZero:kt,matrix:Ce,typed:W}),Dr=lw({addScalar:Yr,dot:Uo,equalScalar:cr,matrix:Ce,multiplyScalar:qr,typed:W}),PI=SD({BigNumber:Me,config:ye,matrix:Ce,typed:W}),$I=aB({config:ye,log2:au,typed:W}),qI=BD({config:ye,matrix:Ce}),zI=gA({BigNumber:Me,typed:W}),UI=wA({typed:W}),LI=AE({SparseMatrix:Jr,typed:W}),Xt=hw({Complex:Mr,config:ye,typed:W}),kI=kD({typed:W}),VI=SA({typed:W}),pi=ZD({matrix:Ce,typed:W}),kd=Dw({BigNumber:Me,config:ye,matrix:Ce,typed:W}),at=QD({BigNumber:Me,config:ye,matrix:Ce,typed:W}),GI=IE({BigNumber:Me,Complex:Mr,config:ye,typed:W}),HI=HE({Complex:Mr,config:ye,typed:W}),WI=EN({format:mi,typed:W}),YI=lA({BigNumber:Me,typed:W}),su=jD({conj:na,transpose:pi,typed:W}),Vd=lD({DenseMatrix:sr,SparseMatrix:Jr,matrix:Ce,typed:W}),yt=T2({DenseMatrix:sr,SparseMatrix:Jr,equalScalar:cr,matrix:Ce,typed:W}),oa=Pb({Fraction:qn,typed:W}),Ln=bD({BigNumber:Me,DenseMatrix:sr,SparseMatrix:Jr,config:ye,matrix:Ce,typed:W}),bt=$1({equal:yt,typed:W}),ZI=wD({matrix:Ce,multiplyScalar:qr,typed:W}),di=xs({isInteger:bt,typed:W}),uu=Gb({flatten:aa,matrix:Ce,size:Zr,typed:W}),JI=C5({fraction:oa,typed:W}),Gd=TD({isInteger:bt,matrix:Ce,typed:W}),Pa=GN({BigNumber:Me,DenseMatrix:sr,config:ye,equalScalar:cr,matrix:Ce,typed:W,zeros:at}),on=Zb({typed:W}),jI=xO({BigNumber:Me,Fraction:qn,config:ye,isInteger:bt,number:an,typed:W}),Hd=ox({BigNumber:Me,Complex:Mr,Fraction:qn,config:ye,isNegative:Un,matrix:Ce,typed:W,unaryMinus:on}),xr=Yf({isInteger:bt,matrix:Ce,typed:W}),hi=Y2({equal:yt,typed:W}),XI=Mw({concat:xr,equalScalar:cr,matrix:Ce,multiplyScalar:qr,typed:W}),Wd=mf({DenseMatrix:sr,config:ye,equalScalar:cr,matrix:Ce,round:Pa,typed:W,zeros:at}),QI=Jx({BigNumber:Me,DenseMatrix:sr,concat:xr,config:ye,equalScalar:cr,matrix:Ce,round:Pa,typed:W,zeros:at}),sa=K1({config:ye,typed:W}),xt=L2({DenseMatrix:sr,SparseMatrix:Jr,bignumber:Et,concat:xr,config:ye,matrix:Ce,typed:W}),KI=Kx({concat:xr,equalScalar:cr,matrix:Ce,typed:W}),e8=v2({DenseMatrix:sr,concat:xr,equalScalar:cr,matrix:Ce,typed:W,zeros:at}),Yd=df({DenseMatrix:sr,concat:xr,config:ye,equalScalar:cr,matrix:Ce,round:Pa,typed:W,zeros:at}),r8=fw({BigNumber:Me,concat:xr,equalScalar:cr,matrix:Ce,typed:W}),t8=kf({deepEqual:hi,flatten:aa,matrix:Ce,size:Zr,typed:W}),Vt=qN({bignumber:Et,fraction:oa,number:an}),Zd=xN({config:ye,multiplyScalar:qr,numeric:Vt,typed:W}),n8=d2({DenseMatrix:sr,concat:xr,equalScalar:cr,matrix:Ce,typed:W,zeros:at}),wt=I2({DenseMatrix:sr,SparseMatrix:Jr,bignumber:Et,concat:xr,config:ye,matrix:Ce,typed:W}),Lr=xw({DenseMatrix:sr,concat:xr,equalScalar:cr,matrix:Ce,subtractScalar:Lt,typed:W,unaryMinus:on}),a8=FN({concat:xr,matrix:Ce,typed:W}),lu=jb({config:ye,numeric:Vt,typed:W}),i8=rD({DenseMatrix:sr,SparseMatrix:Jr,concat:xr,matrix:Ce,typed:W}),dr=ZA({DenseMatrix:sr,SparseMatrix:Jr,addScalar:Yr,concat:xr,equalScalar:cr,matrix:Ce,typed:W}),o8=KE({BigNumber:Me,DenseMatrix:sr,concat:xr,equalScalar:cr,matrix:Ce,typed:W}),s8=Ff({concat:xr,equalScalar:cr,matrix:Ce,typed:W}),u8=Rf({DenseMatrix:sr,concat:xr,equalScalar:cr,matrix:Ce,typed:W}),l8=Lw({DenseMatrix:sr,SparseMatrix:Jr,concat:xr,matrix:Ce,typed:W}),cu=hx({DenseMatrix:sr,config:ye,equalScalar:cr,matrix:Ce,round:Pa,typed:W,zeros:at}),ua=x2({BigNumber:Me,DenseMatrix:sr,Fraction:qn,concat:xr,config:ye,equalScalar:cr,matrix:Ce,typed:W}),Jd=M2({concat:xr,matrix:Ce,typed:W}),c8=mB({addScalar:Yr,combinations:Po,isInteger:bt,isNegative:Un,isPositive:sa,larger:xt,typed:W}),f8=iD({prod:Zd,size:Zr,typed:W}),m8=sD({matrix:Ce,multiply:Dr,subtract:Lr,typed:W}),v8=um({matrix:Ce,number:an,subtract:Lr,typed:W}),Ir=UN({numeric:Vt,typed:W}),p8=B2({compareText:Jd,isZero:kt,typed:W}),jd=fE({larger:xt,smaller:wt}),Xd=Ax({Complex:Mr,DenseMatrix:sr,ceil:cu,equalScalar:cr,floor:Wd,matrix:Ce,typed:W,zeros:at}),d8=jA({abs:gt,addScalar:Yr,divideScalar:Ir,isPositive:sa,multiplyScalar:qr,smaller:wt,sqrt:Xt,typed:W}),Qd=iE({DenseMatrix:sr,smaller:wt}),ft=uE({ImmutableDenseMatrix:Qd,getMatrixDataType:tu}),h8=oO({abs:gt,add:dr,addScalar:Yr,config:ye,divideScalar:Ir,equalScalar:cr,flatten:aa,isNumeric:ia,isZero:kt,matrix:Ce,multiply:Dr,multiplyScalar:qr,smaller:wt,subtract:Lr,typed:W}),g8=Ew({BigNumber:Me,add:dr,config:ye,equal:yt,isInteger:bt,mod:Yd,smaller:wt,typed:W,xgcd:kd}),Lo=G2({DenseMatrix:sr,SparseMatrix:Jr,concat:xr,config:ye,matrix:Ce,typed:W}),fu=YN({Complex:Mr,config:ye,divideScalar:Ir,typeOf:ou,typed:W}),Kd=n2({DenseMatrix:sr,divideScalar:Ir,equalScalar:cr,matrix:Ce,multiplyScalar:qr,subtractScalar:Lt,typed:W}),y8=kb({flatten:aa,matrix:Ce,size:Zr,typed:W}),b8=pv({config:ye,isNaN:gn,numeric:Vt,smaller:wt,typed:W}),x8=XN({Complex:Mr,config:ye,divideScalar:Ir,typed:W}),ko=Q2({compare:ua,isNaN:gn,isNumeric:ia,typed:W}),mu=lC({addScalar:Yr,complex:$o,conj:na,divideScalar:Ir,equal:yt,identity:Ln,isZero:kt,matrix:Ce,multiplyScalar:qr,sign:Ld,sqrt:Xt,subtractScalar:Lt,typed:W,unaryMinus:on,zeros:at}),w8=g2({DenseMatrix:sr,concat:xr,equalScalar:cr,matrix:Ce,typed:W,zeros:at}),eh=BC({SparseMatrix:Jr,abs:gt,add:dr,divideScalar:Ir,larger:xt,largerEq:Lo,multiply:Dr,subtract:Lr,transpose:pi,typed:W}),rh=pE({FibonacciHeap:jd,addScalar:Yr,equalScalar:cr}),Tt=xm({add:dr,matrix:Ce,typed:W,zeros:at}),vu=Ip({add:dr,config:ye,numeric:Vt,typed:W}),D8=nS({add:dr,matrix:Ce,typed:W}),pu=i2({DenseMatrix:sr,divideScalar:Ir,equalScalar:cr,matrix:Ce,multiplyScalar:qr,subtractScalar:Lt,typed:W}),N8=IB({Complex:Mr,add:dr,multiply:Dr,number:an,typed:W}),E8=cB({addScalar:Yr,combinations:Po,divideScalar:Ir,isInteger:bt,isNegative:Un,multiplyScalar:qr,typed:W}),sn=A2({compare:ua,typed:W}),A8=Pp({add:dr,typed:W,unaryPlus:lu}),th=B3({divideScalar:Ir,isZero:kt,matrix:Ce,multiply:Dr,subtractScalar:Lt,typed:W,unaryMinus:on}),gi=r2({DenseMatrix:sr,SparseMatrix:Jr,concat:xr,divideScalar:Ir,equalScalar:cr,matrix:Ce,typed:W}),nh=iS({Index:ft,typed:W}),la=I3({abs:gt,addScalar:Yr,det:th,divideScalar:Ir,identity:Ln,matrix:Ce,multiply:Dr,typed:W,unaryMinus:on}),S8=JN({Complex:Mr,config:ye,divideScalar:Ir,log:fu,typed:W}),C8=s2({DenseMatrix:sr,divideScalar:Ir,equalScalar:cr,matrix:Ce,multiplyScalar:qr,subtractScalar:Lt,typed:W}),du=mv({config:ye,isNaN:gn,larger:xt,numeric:Vt,typed:W}),M8=Gf({DenseMatrix:sr,concat:xr,equalScalar:cr,matrix:Ce,typed:W}),_8=$3({Complex:Mr,add:dr,ctranspose:su,deepEqual:hi,divideScalar:Ir,dot:Uo,dotDivide:gi,equal:yt,inv:la,matrix:Ce,multiply:Dr,typed:W}),Qt=kN({Complex:Mr,config:ye,fraction:oa,identity:Ln,inv:la,matrix:Ce,multiply:Dr,number:an,typed:W}),T8=MA({DenseMatrix:sr,Index:ft,compareNatural:sn,size:Zr,subset:Tt,typed:W}),F8=OA({DenseMatrix:sr,Index:ft,compareNatural:sn,size:Zr,subset:Tt,typed:W}),O8=PA({Index:ft,compareNatural:sn,size:Zr,subset:Tt,typed:W}),B8=UA({Index:ft,compareNatural:sn,size:Zr,subset:Tt,typed:W}),$a=q2({DenseMatrix:sr,SparseMatrix:Jr,concat:xr,config:ye,matrix:Ce,typed:W}),R8=eE({compare:ua,compareNatural:sn,matrix:Ce,typed:W}),I8=W3({abs:gt,add:dr,identity:Ln,inv:la,map:zn,max:du,multiply:Dr,size:Zr,sqrt:Xt,subtract:Lr,typed:W}),P8=J2({DenseMatrix:sr,SparseMatrix:Jr,concat:xr,config:ye,equalScalar:cr,matrix:Ce,typed:W}),ah=l2({DenseMatrix:sr,divideScalar:Ir,equalScalar:cr,matrix:Ce,multiplyScalar:qr,subtractScalar:Lt,typed:W}),$8=av({concat:xr,equalScalar:cr,matrix:Ce,not:qo,typed:W,zeros:at}),q8=_5({fraction:oa,typed:W}),z8=nO({abs:gt,addScalar:Yr,deepEqual:hi,divideScalar:Ir,multiplyScalar:qr,sqrt:Xt,subtractScalar:Lt,typed:W}),U8=KN({DenseMatrix:sr,SparseMatrix:Jr,concat:xr,equalScalar:cr,matrix:Ce,pow:Qt,typed:W}),L8=G3({abs:gt,add:dr,identity:Ln,inv:la,multiply:Dr,typed:W}),ih=eN({addScalar:Yr,ceil:cu,conj:na,divideScalar:Ir,dotDivide:gi,exp:Ud,i:Id,log2:au,matrix:Ce,multiplyScalar:qr,pow:Qt,tau:$d,typed:W}),hu=SO({BigNumber:Me,Complex:Mr,config:ye,multiplyScalar:qr,pow:Qt,typed:W}),k8=tN({conj:na,dotDivide:gi,fft:ih,typed:W}),oh=sC({DenseMatrix:sr,Spa:rh,SparseMatrix:Jr,abs:gt,addScalar:Yr,divideScalar:Ir,equalScalar:cr,larger:xt,matrix:Ce,multiplyScalar:qr,subtractScalar:Lt,typed:W,unaryMinus:on}),qa=fm({bignumber:Et,matrix:Ce,add:dr,config:ye,equal:yt,isPositive:sa,isZero:kt,larger:xt,largerEq:Lo,smaller:wt,smallerEq:$a,typed:W}),V8=hm({Index:ft,matrix:Ce,range:qa,typed:W}),sh=TA({DenseMatrix:sr,Index:ft,compareNatural:sn,size:Zr,subset:Tt,typed:W}),G8=qA({Index:ft,compareNatural:sn,size:Zr,subset:Tt,typed:W}),uh=GA({Index:ft,concat:xr,setDifference:sh,size:Zr,subset:Tt,typed:W}),Qe=wE({BigNumber:Me,Complex:Mr,Fraction:qn,abs:gt,addScalar:Yr,config:ye,divideScalar:Ir,equal:yt,fix:Xd,format:mi,isNumeric:ia,multiplyScalar:qr,number:an,pow:Qt,round:Pa,subtractScalar:Lt}),H8=p4({BigNumber:Me,Unit:Qe,config:ye}),W8=j4({BigNumber:Me,Unit:Qe,config:ye}),Y8=q4({BigNumber:Me,Unit:Qe,config:ye}),Z8=y4({BigNumber:Me,Unit:Qe,config:ye}),J8=U4({BigNumber:Me,Unit:Qe,config:ye}),lh=Jf({Index:ft,matrix:Ce,range:qa,typed:W}),j8=b4({BigNumber:Me,Unit:Qe,config:ye}),X8=d4({BigNumber:Me,Unit:Qe,config:ye}),Q8=CE({Unit:Qe,typed:W}),K8=F4({BigNumber:Me,Unit:Qe,config:ye}),ch=k3({abs:gt,add:dr,addScalar:Yr,atan:zd,bignumber:Et,column:lh,complex:$o,config:ye,cos:ru,diag:Vd,divideScalar:Ir,dot:Uo,equal:yt,flatten:aa,im:nu,inv:la,larger:xt,matrix:Ce,matrixFromColumns:uu,multiply:Dr,multiplyScalar:qr,number:an,qr:mu,re:iu,reshape:Gd,sin:zo,size:Zr,smaller:wt,sqrt:Xt,subtract:Lr,typed:W,usolve:pu,usolveAll:ah}),eP=S4({BigNumber:Me,Unit:Qe,config:ye}),yi=TO({gamma:hu,typed:W}),rP=C4({BigNumber:Me,Unit:Qe,config:ye}),tP=G4({BigNumber:Me,Unit:Qe,config:ye}),nP=K4({BigNumber:Me,Unit:Qe,config:ye}),aP=N4({BigNumber:Me,Unit:Qe,config:ye}),iP=V4({BigNumber:Me,Unit:Qe,config:ye}),oP=m4({BigNumber:Me,Unit:Qe,config:ye}),sP=X4({BigNumber:Me,Unit:Qe,config:ye}),uP=H4({BigNumber:Me,Unit:Qe,config:ye}),lP=O4({BigNumber:Me,Unit:Qe,config:ye}),cP=D4({BigNumber:Me,Unit:Qe,config:ye}),fP=PO({factorial:yi,typed:W}),mP=c4({BigNumber:Me,Unit:Qe,config:ye}),vP=rR({BigNumber:Me,Unit:Qe,config:ye}),pP=tR({BigNumber:Me,Unit:Qe,config:ye}),dP=T4({BigNumber:Me,Unit:Qe,config:ye}),hP=B4({BigNumber:Me,Unit:Qe,config:ye}),gP=f4({BigNumber:Me,Unit:Qe,config:ye}),yP=Z4({BigNumber:Me,Unit:Qe,config:ye}),bP=kA({compareNatural:sn,typed:W}),xP=u4({BigNumber:Me,Unit:Qe,config:ye}),wP=J4({BigNumber:Me,Unit:Qe,config:ye}),DP=I4({BigNumber:Me,Unit:Qe,config:ye}),NP=z4({BigNumber:Me,Unit:Qe,config:ye}),EP=E4({BigNumber:Me,Unit:Qe,config:ye}),AP=h4({BigNumber:Me,Unit:Qe,config:ye}),it=rO({divideScalar:Ir,equalScalar:cr,inv:la,matrix:Ce,multiply:Dr,typed:W}),SP=g4({BigNumber:Me,Unit:Qe,config:ye}),CP=L4({BigNumber:Me,Unit:Qe,config:ye}),MP=$B({Complex:Mr,add:dr,divide:it,matrix:Ce,multiply:Dr,typed:W}),_P=l4({BigNumber:Me,Unit:Qe,config:ye}),TP=x4({BigNumber:Me,Unit:Qe,config:ye}),fh=IC({DenseMatrix:sr,lsolve:Kd,lup:oh,matrix:Ce,slu:eh,typed:W,usolve:pu}),FP=w4({BigNumber:Me,Unit:Qe,config:ye}),OP=Q4({BigNumber:Me,Unit:Qe,config:ye}),BP=RO({add:dr,divide:it,factorial:yi,isInteger:bt,isPositive:sa,multiply:Dr,typed:W}),RP=nR({BigNumber:Me,Unit:Qe,config:ye}),IP=aR({BigNumber:Me,Unit:Qe,config:ye}),PP=Gp({bignumber:Et,add:dr,compare:ua,divide:it,isInteger:bt,larger:xt,mapSlices:di,multiply:Dr,partitionSelect:ko,smaller:wt,smallerEq:$a,subtract:Lr,typed:W}),$P=R4({BigNumber:Me,Unit:Qe,config:ye}),mh=RA({DenseMatrix:sr,Index:ft,compareNatural:sn,size:Zr,subset:Tt,typed:W}),qP=uN({abs:gt,add:dr,bignumber:Et,divide:it,isNegative:Un,isPositive:sa,larger:xt,map:zn,matrix:Ce,max:du,multiply:Dr,smaller:wt,subtract:Lr,typed:W,unaryMinus:on}),vh=oB({bignumber:Et,addScalar:Yr,combinations:Po,divideScalar:Ir,factorial:yi,isInteger:bt,isNegative:Un,larger:xt,multiplyScalar:qr,number:an,pow:Qt,subtractScalar:Lt,typed:W}),zP=NE({Unit:Qe,typed:W}),UP=uB({addScalar:Yr,isInteger:bt,isNegative:Un,stirlingS2:vh,typed:W}),LP=v4({BigNumber:Me,Unit:Qe,config:ye}),kP=k4({BigNumber:Me,Unit:Qe,config:ye}),VP=_4({BigNumber:Me,Unit:Qe,config:ye}),GP=OO({divide:it,dotDivide:gi,isNumeric:ia,log:fu,map:zn,matrix:Ce,multiply:Dr,sum:vu,typed:W}),ph=qp({add:dr,divide:it,typed:W}),HP=W4({BigNumber:Me,Unit:Qe,config:ye}),WP=eR({BigNumber:Me,Unit:Qe,config:ye}),YP=WA({Index:ft,concat:xr,setIntersect:mh,setSymDifference:uh,size:Zr,subset:Tt,typed:W}),gu=kp({add:dr,divide:it,isNaN:gn,mapSlices:di,multiply:Dr,subtract:Lr,typed:W}),ZP=A4({BigNumber:Me,Unit:Qe,config:ye}),JP=yO({add:dr,divide:it,matrix:Ce,mean:ph,multiply:Dr,pow:Qt,sqrt:Xt,subtract:Lr,sum:vu,typed:W}),dh=fO({add:dr,compare:ua,divide:it,partitionSelect:ko,typed:W}),jP=$C({add:dr,cbrt:Hd,divide:it,equalScalar:cr,im:nu,isZero:kt,multiply:Dr,re:iu,sqrt:Xt,subtract:Lr,typeOf:ou,typed:W,unaryMinus:on}),XP=Wp({map:zn,sqrt:Xt,typed:W,variance:gu}),QP=hN({BigNumber:Me,Complex:Mr,add:dr,config:ye,divide:it,equal:yt,factorial:yi,gamma:hu,isBounded:vi,isNegative:Un,multiply:Dr,pi:eu,pow:Qt,sin:zo,smallerEq:$a,subtract:Lr,typed:W}),KP=vO({abs:gt,map:zn,median:dh,subtract:Lr,typed:W}),yu=QA({abs:gt,add:dr,conj:na,ctranspose:su,eigs:ch,equalScalar:cr,larger:xt,matrix:Ce,multiply:Dr,pow:Qt,smaller:wt,sqrt:Xt,typed:W}),hh=$D({BigNumber:Me,DenseMatrix:sr,SparseMatrix:Jr,addScalar:Yr,config:ye,cos:ru,matrix:Ce,multiplyScalar:qr,norm:yu,sin:zo,typed:W,unaryMinus:on}),e6=ID({multiply:Dr,rotationMatrix:hh,typed:W}),gh=j3({identity:Ln,matrix:Ce,multiply:Dr,norm:yu,qr:mu,subtract:Lr,typed:W}),yh=Z3({abs:gt,add:dr,concat:xr,identity:Ln,index:nh,lusolve:fh,matrix:Ce,matrixFromColumns:uu,multiply:Dr,range:qa,schur:gh,subset:Tt,subtract:Lr,transpose:pi,typed:W}),r6=Q3({matrix:Ce,multiply:Dr,sylvester:yh,transpose:pi,typed:W}),za={},bi={},bh={},mt=uS({mathWithTransform:bi}),Ua=RS({Node:mt}),yn=PS({Node:mt}),ca=qS({Node:mt}),xh=kS({Node:mt}),La=mS({Node:mt}),wh=yS({Node:mt,ResultSet:Pd}),Dh=xS({Node:mt}),Nh=US({Node:mt}),t6=UB({classes:bh}),bu=VC({math:za,typed:W}),Eh=TS({Node:mt,typed:W}),n6=F3({Chain:bu,typed:W}),kn=MS({Node:mt,isBounded:vi}),ka=OS({Node:mt,size:Zr}),Va=cS({Node:mt,subset:Tt}),Ah=hS({matrix:Ce,Node:mt,subset:Tt}),Vn=HS({Unit:Qe,Node:mt,math:za}),Gn=YS({Node:mt,SymbolNode:Vn,math:za}),Kt=JS({AccessorNode:Va,ArrayNode:La,AssignmentNode:Ah,BlockNode:wh,ConditionalNode:Dh,ConstantNode:kn,FunctionAssignmentNode:Eh,FunctionNode:Gn,IndexNode:ka,ObjectNode:Ua,OperatorNode:yn,ParenthesisNode:ca,RangeNode:Nh,RelationalNode:xh,SymbolNode:Vn,config:ye,numeric:Vt,typed:W}),Sh=CB({ConstantNode:kn,FunctionNode:Gn,OperatorNode:yn,ParenthesisNode:ca,parse:Kt,typed:W}),xu=DB({bignumber:Et,fraction:oa,AccessorNode:Va,ArrayNode:La,ConstantNode:kn,FunctionNode:Gn,IndexNode:ka,ObjectNode:Ua,OperatorNode:yn,SymbolNode:Vn,config:ye,isBounded:vi,mathWithTransform:bi,matrix:Ce,typed:W}),a6=XS({parse:Kt,typed:W}),Vo=KS({parse:Kt,typed:W}),Ch=UC({evaluate:Vo}),Mh=tC({evaluate:Vo,parse:Kt}),wu=EB({AccessorNode:Va,ArrayNode:La,ConstantNode:kn,FunctionNode:Gn,IndexNode:ka,ObjectNode:Ua,OperatorNode:yn,ParenthesisNode:ca,SymbolNode:Vn,add:dr,divide:it,equal:yt,isZero:kt,multiply:Dr,parse:Kt,pow:Qt,subtract:Lr,typed:W}),i6=_3({Help:Ch,mathWithTransform:bi,typed:W}),Go=bB({AccessorNode:Va,ArrayNode:La,ConstantNode:kn,FunctionNode:Gn,IndexNode:ka,ObjectNode:Ua,OperatorNode:yn,ParenthesisNode:ca,SymbolNode:Vn,equal:yt,parse:Kt,replacer:qd,resolve:Sh,simplifyConstant:xu,simplifyCore:wu,typed:W}),o6=_B({OperatorNode:yn,parse:Kt,simplify:Go,typed:W}),s6=FB({ConstantNode:kn,FunctionNode:Gn,OperatorNode:yn,ParenthesisNode:ca,SymbolNode:Vn,config:ye,equal:yt,isZero:kt,numeric:Vt,parse:Kt,simplify:Go,typed:W}),u6=iC({Parser:Mh,typed:W}),l6=pB({parse:Kt,typed:W}),c6=BB({bignumber:Et,fraction:oa,AccessorNode:Va,ArrayNode:La,ConstantNode:kn,FunctionNode:Gn,IndexNode:ka,ObjectNode:Ua,OperatorNode:yn,ParenthesisNode:ca,SymbolNode:Vn,add:dr,config:ye,divide:it,equal:yt,isZero:kt,mathWithTransform:bi,matrix:Ce,multiply:Dr,parse:Kt,pow:Qt,simplify:Go,simplifyConstant:xu,simplifyCore:wu,subtract:Lr,typed:W});zr(za,{e:Rd,false:T5,fineStructure:F5,i:Id,Infinity:O5,LN10:B5,LOG10E:R5,NaN:I5,null:P5,phi:$5,SQRT1_2:z5,sackurTetrode:U5,tau:$d,true:L5,E:Rd,version:k5,efimovFactor:V5,LN2:G5,pi:eu,replacer:qd,reviver:t6,SQRT2:H5,typed:W,PI:eu,weakMixingAngle:W5,abs:gt,acos:Y5,acot:Z5,acsc:J5,addScalar:Yr,arg:j5,asech:X5,asinh:Q5,atan:zd,atanh:K5,bigint:eI,bitNot:rI,boolean:tI,clone:nI,combinations:Po,complex:$o,conj:na,cos:ru,cot:aI,csc:iI,cube:oI,equalScalar:cr,erf:sI,exp:Ud,expm1:uI,filter:lI,flatten:aa,forEach:cI,format:mi,getMatrixDataType:tu,hex:fI,im:nu,isBounded:vi,isNaN:gn,isNumeric:ia,isPrime:mI,LOG2E:vI,lgamma:pI,log10:dI,log2:au,map:zn,mode:hI,multiplyScalar:qr,not:qo,number:an,oct:gI,pickRandom:yI,print:bI,random:xI,re:iu,sec:wI,sign:Ld,sin:zo,size:Zr,splitUnit:DI,square:NI,string:EI,subtractScalar:Lt,tan:AI,toBest:SI,typeOf:ou,acosh:CI,acsch:MI,asec:_I,bignumber:Et,chain:n6,combinationsWithRep:TI,cosh:FI,csch:OI,dot:Uo,hasNumericValue:BI,isFinite:RI,isNegative:Un,isZero:kt,matrix:Ce,matrixFromFunction:II,multiply:Dr,ones:PI,randomInt:$I,resize:qI,sech:zI,sinh:UI,sparse:LI,sqrt:Xt,squeeze:kI,tanh:VI,transpose:pi,xgcd:kd,zeros:at,acoth:GI,asin:HI,bin:WI,coth:YI,ctranspose:su,diag:Vd,equal:yt,fraction:oa,identity:Ln,isInteger:bt,kron:ZI,mapSlices:di,matrixFromColumns:uu,num:JI,reshape:Gd,round:Pa,unaryMinus:on,bernoulli:jI,cbrt:Hd,concat:xr,deepEqual:hi,dotMultiply:XI,floor:Wd,gcd:QI,isPositive:sa,larger:xt,lcm:KI,leftShift:e8,mod:Yd,nthRoot:r8,nullish:t8,numeric:Vt,prod:Zd,rightArithShift:n8,smaller:wt,subtract:Lr,to:a8,unaryPlus:lu,xor:i8,add:dr,atan2:o8,bitAnd:s8,bitOr:u8,bitXor:l8,ceil:cu,compare:ua,compareText:Jd,composition:c8,count:f8,cross:m8,diff:v8,divideScalar:Ir,equalText:p8,fix:Xd,hypot:d8,intersect:h8,invmod:g8,largerEq:Lo,log:fu,lsolve:Kd,matrixFromRows:y8,min:b8,nthRoots:x8,partitionSelect:ko,qr:mu,rightLogShift:w8,slu:eh,subset:Tt,sum:vu,trace:D8,usolve:pu,zpk2tf:N8,catalan:E8,compareNatural:sn,cumsum:A8,det:th,dotDivide:gi,index:nh,inv:la,log1p:S8,lsolveAll:C8,max:du,or:M8,pinv:_8,pow:Qt,setCartesian:T8,setDistinct:F8,setIsSubset:O8,setPowerset:B8,smallerEq:$a,sort:R8,sqrtm:I8,unequal:P8,usolveAll:ah,and:$8,den:q8,distance:z8,dotPow:U8,expm:L8,fft:ih,gamma:hu,ifft:k8,lup:oh,range:qa,row:V8,setDifference:sh,setMultiplicity:G8,setSymDifference:uh,vacuumImpedance:H8,wienDisplacement:W8,atomicMass:Y8,bohrMagneton:Z8,boltzmann:J8,column:lh,conductanceQuantum:j8,coulomb:X8,createUnit:Q8,deuteronMass:K8,eigs:ch,electronMass:eP,factorial:yi,fermiCoupling:rP,gasConstant:tP,gravity:nP,klitzing:aP,loschmidt:iP,magneticConstant:oP,molarMass:sP,molarPlanckConstant:uP,neutronMass:lP,nuclearMagneton:cP,permutations:fP,planckConstant:mP,planckMass:vP,planckTime:pP,protonMass:dP,quantumOfCirculation:hP,reducedPlanckConstant:gP,secondRadiation:yP,setSize:bP,speedOfLight:xP,stefanBoltzmann:wP,thomsonCrossSection:DP,avogadro:NP,bohrRadius:EP,coulombConstant:AP,divide:it,elementaryCharge:SP,faraday:CP,freqz:MP,gravitationConstant:_P,inverseConductanceQuantum:TP,lusolve:fh,magneticFluxQuantum:FP,molarMassC12:OP,multinomial:BP,planckCharge:RP,planckTemperature:IP,quantileSeq:PP,rydberg:$P,setIntersect:mh,solveODE:qP,stirlingS2:vh,unit:zP,bellNumbers:UP,electricConstant:LP,firstRadiation:kP,hartreeEnergy:VP,kldivergence:GP,mean:ph,molarVolume:HP,planckLength:WP,setUnion:YP,variance:gu,classicalElectronRadius:ZP,corr:JP,median:dh,parse:Kt,polynomialRoot:jP,resolve:Sh,simplifyConstant:xu,std:XP,zeta:QP,compile:a6,evaluate:Vo,mad:KP,simplifyCore:wu,help:i6,norm:yu,rotationMatrix:hh,simplify:Go,symbolicEqual:o6,derivative:s6,parser:u6,rotate:e6,leafCount:l6,rationalize:c6,schur:gh,sylvester:yh,lyap:r6,config:ye}),zr(bi,za,{map:AR({typed:W}),filter:hR({typed:W}),forEach:bR({typed:W}),mapSlices:uR({isInteger:bt,typed:W}),or:h5({DenseMatrix:sr,concat:xr,equalScalar:cr,matrix:Ce,typed:W}),and:v5({add:dr,concat:xr,equalScalar:cr,matrix:Ce,not:qo,typed:W,zeros:at}),cumsum:o5({add:dr,typed:W,unaryPlus:lu}),max:TR({config:ye,isNaN:gn,larger:xt,numeric:Vt,typed:W}),nullish:b5({deepEqual:hi,flatten:aa,matrix:Ce,size:Zr,typed:W}),print:c5({add:dr,matrix:Ce,typed:W,zeros:at}),bitAnd:D5({add:dr,concat:xr,equalScalar:cr,matrix:Ce,not:qo,typed:W,zeros:at}),concat:ZR({isInteger:bt,matrix:Ce,typed:W}),diff:jR({bignumber:Et,matrix:Ce,number:an,subtract:Lr,typed:W}),min:PR({config:ye,isNaN:gn,numeric:Vt,smaller:wt,typed:W}),subset:HR({add:dr,matrix:Ce,typed:W,zeros:at}),bitOr:A5({DenseMatrix:sr,concat:xr,equalScalar:cr,matrix:Ce,typed:W}),sum:r5({add:dr,config:ye,numeric:Vt,typed:W}),index:DR({Index:ft,getMatrixDataType:tu}),row:kR({Index:ft,matrix:Ce,range:qa,typed:W}),column:fR({Index:ft,matrix:Ce,range:qa,typed:W}),mean:BR({add:dr,divide:it,typed:W}),range:zR({bignumber:Et,matrix:Ce,add:dr,config:ye,equal:yt,isPositive:sa,isZero:kt,larger:xt,largerEq:Lo,smaller:wt,smallerEq:$a,typed:W}),variance:u5({add:dr,divide:it,isNaN:gn,mapSlices:di,multiply:Dr,subtract:Lr,typed:W}),quantileSeq:a5({add:dr,bignumber:Et,compare:ua,divide:it,isInteger:bt,larger:xt,mapSlices:di,multiply:Dr,partitionSelect:ko,smaller:wt,smallerEq:$a,subtract:Lr,typed:W}),std:KR({map:zn,sqrt:Xt,typed:W,variance:gu})}),zr(bh,{BigNumber:Me,Complex:Mr,Fraction:qn,Matrix:Io,Node:mt,ObjectNode:Ua,OperatorNode:yn,ParenthesisNode:ca,Range:q5,RelationalNode:xh,ResultSet:Pd,ArrayNode:La,BlockNode:wh,ConditionalNode:Dh,DenseMatrix:sr,RangeNode:Nh,Chain:bu,FunctionAssignmentNode:Eh,SparseMatrix:Jr,ConstantNode:kn,IndexNode:ka,FibonacciHeap:jd,ImmutableDenseMatrix:Qd,Index:ft,Spa:rh,AccessorNode:Va,AssignmentNode:Ah,Unit:Qe,SymbolNode:Vn,FunctionNode:Gn,Help:Ch,Parser:Mh}),bu.createProxy(za);const ot=class ot{constructor(){}static GetExpressions(e,t){let n=[];for(var a=0,i="";e.length>0;){if(!this.HasFunctionInside(e)&&e.indexOf(",")==-1){n.push(new vt(e));break}if(e.substring(a,a+1)=="("){var o=this.FindEnd(e);if(o==-1)throw"Unbalanced brackets!!!! Expression:"+e;i!=""&&(n.push(new Hn(i)),i=""),n.push(new vt(e.substring(0,o+1))),o<e.length?e=e.substring(o+1):e="";continue}if(e.startsWith("N.%")){i!=""&&(n.push(new Hn(i)),i="");var l=e.substring(3).indexOf("%")+1;n.push(new wn(e.substring(2,l+3),!0)),e=e.substring(l+3);continue}if(e.substring(0,1)=="%"){i!=""&&(n.push(new Hn(i)),i="");var l=e.substring(1).indexOf("%")+1;n.push(new wn(e.substring(0,l+1),!1)),e=e.substring(l+1);continue}if(e.substring(a,a+1)==","){i!=""&&(n.push(new vt(i)),i=""),n.push(new St(e.substring(0,1),"")),1<e.length?e=e.substring(1):e="";continue}var u=!1;if(We.operators.forEach(m=>{if(e.startsWith(m)){i!=""&&(n.push(new vt(i)),i=""),n.push(new Ei(e.substring(0,m.length))),e=e.substring(m.length),u=!0;return}}),u)continue;for(let m=0;m<We.logicaloperators.length;m++){let v=We.logicaloperators[m];if(e.startsWith(v)){i!=""&&(n.push(new vt(i)),i=""),n.push(new Yo(e.substring(0,v.length))),e=e.substring(v.length),u=!0;break}}if(u)continue;var s=!1;let f=e.toLowerCase();var c=Object.keys(ot._suportedFunctions);for(let m=0;m<c.length;m++){let v=c[m];if(f.startsWith(v)){i!=""&&(n.push(new vt(i)),i="");var o=this.FindEnd(e);if(o==-1)throw"Unbalanced brackets!!!! Expression:"+e;let d=Reflect.construct(ot._suportedFunctions[v],[e.substring(0,o+1),v]);n.push(d),o<e.length?e=e.substring(o+1):e="",s=!0;break}}s||(i+=e.substring(0,1),e=e.substring(1))}return i!=""&&(n.push(new vt(i)),i=""),n}static HasFunctionInside(e){if(e==null||e=="")return!1;var t=!1;const n=e.toLowerCase();return Object.keys(ot._suportedFunctions).forEach(a=>{if(n.indexOf(a)!=-1){t=!0;return}}),t}static StartsWithFunction(e){const t=e.toLowerCase();var n=!1;return Object.keys(ot._suportedFunctions).forEach(a=>{if(t.startsWith(a)){n=!0;return}}),n}static FindEnd(e){for(var t=0,n=0,a=0;a<e.length;a++)if(e.substring(a,a+1)=="("?n++:e.substring(a,a+1)==")"&&t++,n>0&&n==t)return a;return-1}static ConcatValues(e,t,n,a,i){if(e==null)return null;if(e.length==1)return e[0].Evaluate(t,n,a,i);let o="";for(let l=0;l<e.length;l++){let u=e[l].Evaluate(t,n,a,i);typeof u=="number"?o+=u.toString():u instanceof Date?o+=u.toISOString():o+=u}return o}static CastToTypeNet(e,t){let n=null;if(t==null)return null;switch(e.TypeNET){case"decimal":{n=parseFloat(t);break}case"int":{n=parseInt(t);break}case"bool":{this.toString().toLowerCase()=="true"||this.toString().toLowerCase()=="false"||(n=t);break}default:{n=t;break}}return n}static ParseAndFillExpression(e,t,n,a,i,o,l){if(n==null)return null;var u=ot.ParseExpressionAndReturnValue(e,n,t,a,0);if(console.log(t.FieldName+" "+e+" "+u),u!=null)if(t.Type=="decimal"||t.Type=="int")try{if(u=="0/0")return a.Record[t.FieldName]=0,0;if(u=="*(-1)")return null;const c=Vo(u);return console.log(t.FieldName+" "+e+" RET: "+u+" EVAL:"+c),c}catch{if(l)return console.log(t.FieldName+" "+e+" Err: 0"),0;var s=ot.CastToTypeNet(t,u);return console.log(t.FieldName+" "+e+" Err: "+s),s}else{var s=ot.CastToTypeNet(t,u);return console.log(t.FieldName+" "+e+" Ret: "+s),s}else return console.log(t.FieldName+" "+e+" Value: "+u),u}static ParseExpressionAndReturnValue(e,t,n,a,i){var s;if(e==null||t==null)return null;let o=null;try{o=ot.GetExpressions(e,null)}catch{debugger}if(o==null)return null;o[0]instanceof vt;var l=a.Record;if(o.length==1){var u=o[0].Evaluate(t,a,l,n);if(u==null)return null;if(u instanceof Date){if(n.TypeDDD=="Date")return We.getIsoDate(u);if(n.TypeDDD=="DateTime")return We.getIsoDateTime(u)}else if(typeof u=="number")return u.toString();return u.toString()}return(s=ot.ConcatValues(o,t,a,l,n))==null?void 0:s.toString()}static ValueExpresion(e,t,n,a){var g;if(t=="null")return null;if(!t.startsWith("%")&&!t.endsWith("%"))return t;let i="";try{i=t.substring(1,t.length-1)}catch(b){throw e!=null?e.FieldName+" "+e.ValueExpression+" Expression:"+t+b:t+b}var o=i.split("."),l=o[0];switch(l){case"V":return n.GetValues(o[1]);case"E":{const b=o[1],A=o[2];if(b.toLowerCase()=="eu_scr")return n.ExternalTables.EU_SCR[A];if(b.toLowerCase()=="session"){for(var u=n.ExternalTables.Session,s=2;s<o.length;s++)if(u[o[s]]!=null)u=u[o[s]];else return null;return u}else return""}case"S":{if(n.Settings==null||n.Settings[o[1]]==null)throw"Can't find setting for "+o[1];var c=n.Settings[o[1]];return c.Value}default:{if(o.length==2){var f=o[0],m=o[1];if(f==((g=a==null?void 0:a.Parent)==null?void 0:g.Tablename)){var v=ot.ReturnFromObject(a.Record,m);if(v.found===!0)return v.return}var p=n.FindTableLevel(f);if(p!=null){if(p.Record!=null){var d=p.Record,v=ot.ReturnFromObject(d.Record,m);if(v.found===!0)return v.return;if(v.found===!1&&m=="InvIssueDate")return null;if(v.found===!1&&m.indexOf("__")!=-1){var y=ot.ReturnFromObject(d.Record,m);if(y.found===!0)return y.return}return null}else if(p.Records!=null){var x=p.Records,D=x.Records.filter(b=>b==a);if(D.length>0){var h=D[0],w=h.Record,v=ot.ReturnFromObject(w,m);if(v.found===!0)return v.return;if(v.found===!1&&m.indexOf("__")!=-1){var y=ot.ReturnFromObject(h.Record,m);if(y.found===!0)return y.return}if(m=="ItemRetailPriceInp"||m=="ItemVatCodeSC__VCCode_EN16931")return null;throw"Can't evaluate "+t+" key:"+e.FieldName}}}}break}}return null}static ReturnFromObject(e,t){return Object.keys(e).indexOf(t)==-1?{found:!1,return:null}:e[t]==null?{found:!0,return:null}:e[t]instanceof Date?{found:!0,return:e[t]}:{found:!0,return:e[t].toString()}}};ot._suportedFunctions={"tonull(":i0,"sum(":qh,"if(":$h,"calcdate(":zh,"addleadzeros(":Ih,"starts(":Uh,"substr(":Lh,"count(":kh,"check(":Gh,"concat(":Vh,"empty(":Bu,"nonempty(":Bu,"exists(":Ou,"notexists(":Ou,"noeval(":o0,"appear(":Ph,"value(":Wh,"year(":Jh,"month(":jh,"screxists(":f0,"inlist(":Tu,"notinlist(":Tu,"indetail(":Fu,"notindetail(":Fu,"upper(":_u,"lower(":_u,"trim(":Hh,"totalminutes(":s0,"datetimeformat(":a0,"time(":u0,"clean(":Xh,"fromcodelist(":c0,"len(":l0,"registrycheck(":Zh,"extract(":Qh,"usefirst(":Yh};let He=ot;class Ft{static GetRecords(e,t){return t.GetReferenceRecords("__VatRate")}static SumByFieldNameAndVarCode(e,t,n){var a=this.GetRecords(t,n);if(a==null)return 0;for(var i=0,o=0;o<a.length;o++)i+=a[o].Record[e]??0;return i}static GetFirstRecordItem(e,t){var n=this.GetRecords(e,t);return n==null?null:n[0]}}class f6{static Execute(e,t,n,a){if(t==null)return"Invoice object is null";switch(e.FieldName){case"VatInvAllowAmount":{n.SetValueToKey(e,Ft.SumByFieldNameAndVarCode("LineInvAllowAmount",t,n),a);break}case"VatTaxableAmount":{n.SetValueToKey(e,Ft.SumByFieldNameAndVarCode("LineTotalNetAmount",t,n),a);break}case"VatTaxAmount":{n.SetValueToKey(e,Ft.SumByFieldNameAndVarCode("LineTotalVatAmount",t,n),a);break}case"VatInvChargeAmount":{n.SetValueToKey(e,Ft.SumByFieldNameAndVarCode("LineTotalVatAmount",t,n),a);break}case"VatInvAllowBaseAmount":{n.SetValueToKey(e,Ft.SumByFieldNameAndVarCode("LineBaseAmountInclAllow",t,n),a);break}case"VatInvChargeBaseAmount":{n.SetValueToKey(e,Ft.SumByFieldNameAndVarCode("LineTotalVatAmount",t,n),a);break}case"VatCatCode":{var i=Ft.GetFirstRecordItem(t,n);i!=null&&n.SetValueToKey(e,i.RecordAnalitic.ItemVatCodeSC__VCCode_EN16931,a);break}case"VatCode":{var i=Ft.GetFirstRecordItem(t,n);i!=null&&n.SetValueToKey(e,i.RecordAnalitic.ItemVatCodeSC__VatCode,a);break}case"VatRate":{var i=Ft.GetFirstRecordItem(t,n);i!=null&&n.SetValueToKey(e,i.RecordAnalitic.ItemVatCodeSC__Rate,a);break}case"VatCodeUI":{var i=Ft.GetFirstRecordItem(t,n);i!=null&&n.SetValueToKey(e,i.RecordAnalitic.ItemVatCodeSC__GroupUIVatCode,a);break}case"VatExemptReasonDesc":{var o=Ft.GetRecords(t,n);if(o!=null&&o.length>0){for(var l=new Set,u=0;u<o.length;u++){var s=o[u];if(s.Record.ItemVatCodeSC__VatCode=="E_999"){l.add(s.Record.VatExemReasonDescE_999??"");continue}l.add(s.RecordAnalitic.ItemVatCodeSC__VERDesc??"")}const c=new Set([...l].filter(f=>f!=""));c.size>0?n.SetValueToKey(e,[...c].join(", "),a):n.SetValueToKey(e,null,a)}break}case"VatExemptReasonCode":{var i=Ft.GetFirstRecordItem(t,n);i!=null&&n.SetValueToKey(e,null,a);break}case"NumOfItems":{var o=Ft.GetRecords(t,n);o!=null&&n.SetValueToKey(e,o.length,a);break}}}}class m6{static Execute(e,t,n,a){if(t==null)return"Invoice object is null";switch(e.FieldName){case"LineIdent":{var i=this.GetRecords(t),o=i.indexOf(n)+1;n.SetValueToKey(e,o,a);break}}}static GetRecords(e){var t=e.FindTableLevel("EU_Invoices_Items");if(t==null)throw Error("Can't find level EU_Invoices_Items");var n=t.Records;return(n==null?void 0:n.Records)??[]}}const bn=class bn{static IsDetailTable(e){return this._objectTablesDetail.indexOf(e)!=-1}static isMultiple(e){return e=="EU_Invoices_Items_Classes"||e=="EU_Invoices_Items_AllowsCharges"||e=="EU_Invoices_CN_IICRefs_Items"||e=="EU_Invoices_AdvanceUsage"||e=="EU_Invoices_AdvanceUsageVatCode"||e=="EU_Invoices_Items_Attributes"}static GetMultipleParent(e){return this.__multipleParent[e]?this.__multipleParent[e]:null}static GetTableForAlias(e){return this._dicAliasMap[e]??e}static GetTableFromAlias(e){for(var t=Object.keys(this._dicAliasMap),n=0;n<t.length;n++)if(this._dicAliasMap[t[n]]==e)return t[n];return e}};bn.masterEntity="EU_Invoices",bn.itemsEntity="EU_Invoices_Items",bn.vatEntity="EU_Invoices_Vats",bn.paymentInstrsEntity="EU_Invoices_PaymentInstrs",bn._objectTablesDetail=["EU_Invoices_Items","EU_Invoices_Items_Classes","EU_Invoices_Items_Attributes","EU_Invoices_Items_AllowsCharges","EU_Invoices_Errors","EU_Invoices_PaymentInstrs","EU_Invoices_Vats","EU_Invoices_VatsFisc","EU_Invoices_VatsCatCode","EU_Invoices_VatsUI","EU_Invoices_PrecedInvs","EU_Invoices_AllowsCharges","EU_Invoices_AddRefDocs","EU_Invoices_AdvanceUsage"],bn._dicAliasMap={EU_Invoices:"Invoice",EU_Invoices_CN_IICRefs:"CreditNoteRefs",EU_Invoices_Items:"Items",EU_Invoices_PaymentInstrs:"Payments",EU_Invoices_AddRefDocs:"Attachments",EU_Invoices_Items_Classes:"ItemsClasses",EU_Invoices_Items_Attributes:"ItemsAttributes",EU_Invoices_Items_Incomes:"ItemsIncomes",EU_Invoices_Items_Expenses:"ItemsExpenses",EU_Invoices_Items_AllowsCharges:"ItemsAllowsCharges"},bn.__multipleParent={EU_Invoices_Items_Classes:"EU_Invoices_Items",EU_Invoices_Items_AllowsCharges:"EU_Invoices_Items",EU_Invoices_CN_IICRefs_Items:"EU_Invoices_Items",EU_Invoices_Items_Attributes:"EU_Invoices_Items",EU_Invoices_Items_Incomes:"EU_Invoices_Items",EU_Invoices_Items_Expenses:"EU_Invoices_Items"};let Ot=bn;class Ga{constructor(e,t,n){if(this.Details=null,this.IsDefaultRecord=!1,this._LeftInstance=null,this._referenceRecords=null,this.RecordAnalitic={},this.Parent=n,e._details!=null){var a={},i=Object.keys(e._details);i.forEach(o=>{var l;a[o]=new xn(o,e._details[o],t,((l=this.Parent)==null?void 0:l.Root)??null)}),this.Details=a,delete e._details}this.Record={}}SetReferenceRecords(e,t){this._referenceRecords==null&&(this._referenceRecords=new Map),this._referenceRecords.set(e,t)}GetReferenceRecords(e){return this._referenceRecords==null?null:this._referenceRecords.get(e)??null}SetLeftInstanceReference(e){this._LeftInstance=e}GetLeftInstanceReference(){return this._LeftInstance}AddDetail(e,t){this.Details==null&&(this.Details={}),this.Details[e]=t}GetDetail(e){return this.Details==null?null:this.Details[e]}HasDetails(e){return this.Details==null?!1:this.Details[e]!=null}SetValueToKey(e,t,n){if(n!=null&&n==this.Record&&(this.RecordAnalitic[e.FieldName]=t),t==null){this.Record[e.FieldName]=null;return}if(e.FieldName!=null){if(typeof t=="string")switch(e.Type){case"int":{t=parseInt(t);break}case"decimal":{t=parseFloat(t);break}case"bool":case"boolean":{t=i=>i.trim().toLowerCase()==="true";break}}if(e.RoundTo!=null){var a=e.RoundTo;typeof t=="number"&&(t=this.roundUp(t,a))}}this.Record[e.FieldName]=t}SetValueToKeyString(e,t,n){if(n!=null&&(this.RecordAnalitic[e]=t),t==null){this.Record[e]=null;return}this.Record[e]=t}roundUp(e,t){let n=!1;e<0?n=!0:n=!1,n?e=e-10**-13:e=e+10**-13,e=Math.abs(e);let a=Math.round(e*Math.pow(10,t))/Math.pow(10,t);return n?-1*a:a}GetObject(){var e=JSON.parse(JSON.stringify(this.Record));if(this.Details!=null){let t=JSON.parse("{}");for(let n=0;n<this.Details.length;n++){let a=this.Details[n].GetObject();a!=null&&(t[this.Details[n].Tablename]=a)}e._details=t}return e}TranslateObj(e){if(this.Details!=null)for(let i=0;i<this.Details.length;i++)this.Details[i].TranslateObj(e);var t=Object.keys(this.Record),n=Object.keys(e),a=t.filter(i=>n.indexOf(i)!=-1);a.length>0&&a.forEach(i=>{var o=e[i].data[this.Record[e[i].key]];o!=null&&(this.Record[i]=e[i].data[this.Record[e[i].key]])})}MapToId(e){e.length!=0&&e.forEach(t=>{this.MapToIdItem(t)})}MapToIdItem(e){var d,y,x,D;if(e==null)return null;var t={},n=e.FieldName,a=Object.keys(this.Record),i=Object.keys((((y=(d=this.Parent)==null?void 0:d.Root)==null?void 0:y.ObjectInfo)??{})[e.TableName??""]).filter(h=>h.startsWith(n+"__")),o=a.filter(h=>h.startsWith(n+"__"));e.FieldName=="ItemVatCodeSC";for(let h=0;h<o.length;h++){var l=o[h].substring((n+"__").length);this.Record[o[h]]!=null&&(t[l]=this.Record[o[h]])}if(Object.keys(t).length==0||e.ConnTable==null)return null;var u=(D=(x=this.Parent)==null?void 0:x.Root)==null?void 0:D.CodeListCache[e.ConnTable],s=Object.keys(t);let c=u;for(let h=0;h<s.length;h++){var f=s[h];if(c=c.filter(w=>w[f]==t[f]),c.length==0)return null}if(c.length>1)throw"More than 1 record found for "+e.FieldName+" with value "+JSON.stringify(t);var m=c[0];this.Record[e.FieldName]=m[e.ByKey??"Id"];for(let h=0;h<i.length;h++){var f=i[h],v=f.substring((n+"__").length);this.Record[f]=m[v]}var p=Object.keys(m);for(let h=0;h<p.length;h++){var f=p[h];this.RecordAnalitic[e.FieldName+"__"+f]=m[f]}}EvaluateInner(e){e.length!=0&&e.forEach(t=>{var a,i,o,l,u;if(((i=(a=this.Parent)==null?void 0:a.Root)==null?void 0:i.EvalType)=="Init"){if(this.Record[t.FieldName]==null&&t.ValueExpressionInit!=null){var n=He.ParseAndFillExpression(t.ValueExpressionInit,t,((o=this==null?void 0:this.Parent)==null?void 0:o.Root)??null,this,this.Record,!0,!1);this.Record[t.FieldName]=n}}else((u=(l=this.Parent)==null?void 0:l.Root)==null?void 0:u.EvalType)=="Eval"&&this.Evaluate(t)})}Evaluate(e){var a,i,o,l;if(!(e.EvalOnlyIfEmpty===!0&&this.Record[e.FieldName]!=null)){if(e.EvaluateOnlyIF!=null){var t=He.ParseExpressionAndReturnValue(e.EvaluateOnlyIF,((a=this==null?void 0:this.Parent)==null?void 0:a.Root)??null,e,this,0);if(t==null||t.toUpperCase()!="TRUE")return}if(e.ValueExpression!=null){var n=He.ParseAndFillExpression(e.ValueExpression,e,((i=this==null?void 0:this.Parent)==null?void 0:i.Root)??null,this,this.Record,!0,!1);this.SetValueToKey(e,n,this.Record)}else this.Record[e.FieldName]==null&&this.SetValueToKey(e,null,this.Record);switch(e.GetValueFrom){case"Code":{switch(e.TableName){case"EU_Invoices_VatsUI":{f6.Execute(e,((o=this.Parent)==null?void 0:o.Root)??null,this,this.Record);break}case"EU_Invoices_Items":{m6.Execute(e,((l=this.Parent)==null?void 0:l.Root)??null,this,this.Record);break}}break}}}}ParseExpressionAndReturnValue(e,t){return this.ParseExpressionAndReturnValueNew(e,t)}ParseExpressionAndReturnValueNew(e,t){var a;if(((a=this.Parent)==null?void 0:a.Root)==null)return null;var n=He.ParseAndFillExpression(e,t,this.Parent.Root,this,this.Record,!1,!1);return n}valueToType(e){return e==null||e=="null"?null:typeof e!="string"?e:e.toLocaleLowerCase()=="true"?!0:e.toLocaleLowerCase()=="false"?!1:isNaN(parseFloat(e))?e:parseFloat(e)}ValueExpresion(e){var i,o,l;if(e==null)return null;if(!e.startsWith("%")||!e.endsWith("%"))return this.valueToType(e);let n=e.substring(1,e.length-1).split(".");var a=n[0];switch(a){case"V":return console.warn("V not supported!"),null;case"E":{const u=n[1];if(u!="EU_AOrg"){if(u!="EU_SCR"){if(u!="Session")return console.warn("Other E not supported!"),null}}break}case"S":return console.warn("S not supported!"),null;default:{if(n.length==2){const u=n[0];if(u==((i=this.Parent)==null?void 0:i.Tablename))return this.Record[n[1]];{let s=(l=(o=this.Parent)==null?void 0:o.Root)==null?void 0:l.FindTableLevel(u);if(s!=null&&s.Record!=null&&(s==null?void 0:s.Record)!=null)return this.valueToType(s==null?void 0:s.Record.Record[n[1]])}}break}}return null}getSaveObject(e){var i,o,l;const t={};if(this.Details!=null){const u={};for(let s=0;s<this.Details.length;s++){const c=this.Details[s].getSaveObject(e);c!=null&&(u[this.Details[s].Tablename]=c)}Object.keys(u).length>0&&(t._details=u)}if(((i=this.Parent)==null?void 0:i.Tablename)==null)return null;const n=e[(o=this.Parent)==null?void 0:o.Tablename],a=Object.keys(n);for(let u=0;u<a.length;u++){const s=a[u];switch(n[s].TypeDDD){case"Date":{t[s]=We.getIsoDate(this.Record[s]);break}case"DateTime":{t[s]=We.getIsoDateTime(this.Record[s]);break}default:{t[s]=this.Record[s];break}}}return this.Record.Id!=null&&(t.Id=this.Record.Id),((l=this.Parent)==null?void 0:l.Tablename)=="EU_Invoices",Object.keys(t).length>0?t:null}getFullObject(e){var o,l,u;const t={};if(this.Details!=null){const s={};var n=Object.keys(this.Details);for(let c=0;c<n.length;c++){const f=this.Details[n[c]].getFullObject(e);f!=null&&(s[this.Details[n[c]].Tablename]=f)}Object.keys(s).length>0&&(t._details=s)}if(((o=this.Parent)==null?void 0:o.Tablename)==null)return null;const a=e[(l=this.Parent)==null?void 0:l.Tablename],i=Object.keys(a);for(let s=0;s<i.length;s++){const c=i[s];switch(a[c].Type){case"Date":{t[c]=We.getIsoDate(this.Record[c]);break}case"DateTime":{t[c]=We.getIsoDateTime(this.Record[c]);break}default:{t[c]=this.Record[c];break}}}return this.Record.Id!=null&&(t.Id=this.Record.Id),((u=this.Parent)==null?void 0:u.Tablename)=="EU_Invoices"&&(t.InvTotalVatAmountCCInp=this.Record.InvTotalVatAmountCC,t.InvAmountInclVatInp=this.Record.InvAmountInclVat),Object.keys(t).length>0?t:null}GetTableForAlias(e){var o,l,u;const t={};if(this.Details!=null){const s={};var n=Object.keys(this.Details);for(let c=0;c<n.length;c++){const f=this.Details[n[c]].GetTableForAlias(e);f!=null&&(s[Ot.GetTableForAlias(this.Details[n[c]].Tablename)]=f)}Object.keys(s).length>0&&(t._details=s)}if(((o=this.Parent)==null?void 0:o.Tablename)==null)return null;const a=e[(l=this.Parent)==null?void 0:l.Tablename],i=Object.keys(a);for(let s=0;s<i.length;s++){const c=i[s],f=a[c].Type,m=a[c].Alias??c;switch(f){case"Date":{t[m]=We.getIsoDate(this.Record[c]);break}case"DateTime":{t[m]=We.getIsoDateTime(this.Record[c]);break}default:{t[m]=this.Record[c];break}}}return this.Record.Id!=null&&(t.Id=this.Record.Id),((u=this.Parent)==null?void 0:u.Tablename)=="EU_Invoices"&&(t.InvTotalVatAmountCCInp=this.Record.InvTotalVatAmountCC,t.InvAmountInclVatInp=this.Record.InvAmountInclVat),Object.keys(t).length>0?t:null}Validate(){}}class Du{constructor(e,t,n){this.Records=[],this.Parent=n,this.ObjectInfo=t,this.Records.push(new Ga(e,t,n))}MapToId(e){if(this.Records!=null)for(let t=0;t<this.Records.length;t++)this.Records[t].MapToId(e)}EvaluateInner(e){if(this.Records!=null)for(let n=0;n<this.Records.length;n++){var t=this.Records[n];try{t.EvaluateInner(e)}catch{debugger}}}TranslateObj(e){if(this.Records.length!=0)for(let t=0;t<this.Records.length;t++)this.Records[t].TranslateObj(e)}GetObject(){if(this.Records.length==0)return null;var e=[];for(let t=0;t<this.Records.length;t++)e.push(this.Records[t].GetObject());return e}getSaveObject(e){var a;if(this.Records==null)return null;var t=[];if(((a=this.Parent)==null?void 0:a.Tablename)=="EU_Invoices_Items_Classes"&&this.Records.length==1){var n=this.Records[0];if(n.Record.ItemClassCodeSchID==null&&n.Record.ItemClassCode==null)return t}for(let i=0;i<this.Records.length;i++)t.push(this.Records[i].getSaveObject(e));return t}getFullObject(e){if(this.Records==null)return null;var t=[];for(let n=0;n<this.Records.length;n++)t.push(this.Records[n].getFullObject(e));return t}GetTableForAlias(e){if(this.Records==null)return null;var t=[];for(let n=0;n<this.Records.length;n++)t.push(this.Records[n].GetTableForAlias(e));return t}Validate(){if(this.Records==null)return null;const e={};for(let i=0;i<this.Records.length;i++){let o=this.Records[i].Validate();o!=null&&(e[i.toString()]=o)}if(Object.keys(e).length==0)return null;const t=Object.keys(e);let n="",a={};for(let i=0;i<t.length;i++){let o="";const l=t[i];let u=e[l];u.missingKeys!=null&&(o="Missing mandatory keys:"+u.missingKeys),o!=null&&(n+="Errors on index "+l+": "+o,a.push([l,u.missingKeys]))}return{errorMessage:n==""?null:n,validateDetailsErrors:a}}}class _h{constructor(e,t,n){this.rootLevel=null,this.LeftObject=null,this.ExternalTables={},this.Settings=null,this._dicValues={},this.EvalType="Init",this.Mappings=null,this.CodeListCache={},this.InvoiceStructure={},this.Legislation=e,this.LeftObject=t,this.ObjectInfo=(n==null?void 0:n.OI)??{},this.CodeListCache=(n==null?void 0:n.CodeList)??{},this.InvoiceStructure=(n==null?void 0:n.InvoiceStructure)??{},this.ExternalTables=(n==null?void 0:n.External)??{},this.Settings=(n==null?void 0:n.Settings)??{},this.prepareValues()}prepareValues(){const e=new Date;this._dicValues={NOW:this.formatDateTime(e),DATE:this.formatDate(e),LEGISLATION:this.Legislation}}static isMultiple(e){return e=="EU_Invoices_Items_Classes"||e=="EU_Invoices_Items_AllowsCharges"||e=="EU_Invoices_CN_IICRefs_Items"||e=="EU_Invoices_AdvanceUsage"||e=="EU_Invoices_AdvanceUsageVatCode"}InitAfterConst(){}formatDate(e){return e.getFullYear()+"-"+this.formatToTwoNumber(e.getMonth()+1)+"-"+this.formatToTwoNumber(e.getDate())}formatDateTime(e){return e.getFullYear()+"-"+this.formatToTwoNumber(e.getMonth()+1)+"-"+this.formatToTwoNumber(e.getDate())+"T"+this.formatToTwoNumber(e.getHours())+":"+this.formatToTwoNumber(e.getMinutes())+":"+this.formatToTwoNumber(e.getSeconds())}formatToTwoNumber(e){return e<10?"0"+e:e.toString()}GetValues(e){var t=e.toUpperCase();return this._dicValues[t]!=null?this._dicValues[t]:null}FindTableLevel(e){var t=this.RecursiveFindLevel(this.rootLevel,e);return t??(console.error("Can't find level "+e),null)}RecursiveFindLevel(e,t){if(e==null&&(e=this.rootLevel),e==null)return null;if((e==null?void 0:e.Tablename)==t)return e;if(e.Record!=null&&e.Record.Details!=null){var n=Object.keys(e.Record.Details);for(let a=0;a<n.length;a++){const i=this.RecursiveFindLevel(e.Record.Details[n[a]],t);if(i!=null)return i}}return null}GetObject(){var e;return(e=this.rootLevel)==null?void 0:e.GetObject()}SumByKey(e){var t=e.split(","),n=t[0].split(".");if(n.length!=2)throw"Key isn't well formmed! "+e;var a=this.RecursiveFindLevel(this.rootLevel,n[0]);if(a==null)throw"Can't find table level "+n[0];let i=null;if(t.length==2){var o=t[1].split(".");i=o[1]}let l=0;if(a.Records!=null)for(var u=a.Records,s=0;s<u.Records.length;s++){const c=u.Records[s];if(c.Record[n[1]]!=null){if(i!=null&&!c.Record[i])continue;l+=c.Record[n[1]]}}return l}getSaveObject(){return{}}getFullObject(){var t,n;const e={};return e[((t=this.rootLevel)==null?void 0:t.Tablename)??"EU_Invoices"]=(n=this.rootLevel)==null?void 0:n.getFullObject(this.ObjectInfo),e}getAliasObject(){var t;const e={};return e[Ot.GetTableForAlias("EU_Invoices")]=(t=this.rootLevel)==null?void 0:t.GetTableForAlias(this.ObjectInfo),e}ValidateBeforeSave(){}TranslateObj(e){var t;(t=this.rootLevel)==null||t.TranslateObj(e)}prepareSchemaStruct(){var e=[],t=Object.keys(this.ObjectInfo);return t.forEach(n=>{var a=Object.keys(this.ObjectInfo[n]);a.forEach(i=>{e.push(this.ObjectInfo[n][i])})}),e}Evaluate(){this.rootLevel=new xn("EU_Invoices",this.InvoiceStructure.EU_Invoices,this.ObjectInfo,this);var e=this.prepareSchemaStruct(),t=e.filter(n=>n.ValueExpressionInit!=null);return this.InicializeEval("Init",t),this.FillInvoiceDataIntoObjStuct(this.LeftObject,e,this.ObjectInfo,!1),console.log(this.getFullObject()),t=e.filter(n=>n.EvalStep=="PRE"&&(n.ValueExpression!=null||n.GetValueFrom=="Mappings"||n.GetValueFrom=="Code")),this.InicializeEval("Eval",t),t=e.filter(n=>n.ConnField),this.MapToId(t),t=e.filter(n=>n.EvalStep=="EVAL"),this.InicializeEval("Eval",t),t=e.filter(n=>n.EvalStep=="POST"&&n.Group=="Vats"),this.vatsPrepare(t),t=e.filter(n=>n.EvalStep=="POST"&&n.Group!="Vats"),this.InicializeEval("Eval",t),!0}InicializeEval(e,t){if(this.EvalType=e,t.length==0)return!0;try{var n=t.sort((o,l)=>(o.CalcPhase??0)-(l.CalcPhase??0)),a=[],i=null;for(let o=0;o<n.length;o++){const l=n[o];if(i==null){i=l.TableName,a.push(l);continue}i!=l.TableName&&(this.InicializeEvalInner(i??"",a),a=[],i=l.TableName),a.push(l)}a.length>0&&this.InicializeEvalInner(i??"",a)}catch(o){return console.error(o),!1}return!0}FillInvoiceDataIntoObjStuct(e,t,n,a){var le,me,Y,z,X,se,re;var i=(le=this.rootLevel)==null?void 0:le.Record;if(t.length>0){const pe=a?Ot.masterEntity:"Invoice";var o=e[pe],l=o._details,u=new Map,s=this.RecursiveFindLevel(null,Ot.masterEntity),i=s==null?void 0:s.Record,c=this.groupBy(t,"TableName"),f=Object.keys(c);if(o!=null||l!=null)for(var m=0;m<f.length;m++){var v=f[m],p=c[v];if(v==Ot.masterEntity){if(o==null||i==null)continue;for(var d=0;d<p.length;d++){var y=p[d];this.setValueForObject(o,i,y,a,null)}}else if(Ot.IsDetailTable(v)){if(l==null)continue;if(Ot.isMultiple(v)){u.set(v,p);continue}var x=a?v:Ot.GetTableForAlias(v);if(l[x]==null||l[x].length==0)continue;var D=this.RecursiveFindLevel(this.rootLevel,v);if(D==null||D==null)continue;var h=[],w=l[x],g={};if((D==null?void 0:D.Records)!=null&&((me=D.Records)==null?void 0:me.Records.length)>0){var b=D.Records.Records[0];b.IsDefaultRecord=!1;for(var A=Object.keys(b.Record),N=0;N<A.length;N++){var E=A[N];g[E]=b.Record[E]}}for(var d=0;d<w.length;d++){for(var S=JSON.parse(JSON.stringify(g)),C=w[d],M=new Ga(S,n,D),O=0;O<p.length;O++){var y=p[O];this.setValueForObject(C,M,y,a,null)}M.SetLeftInstanceReference(C),h.push(M)}D.Records!=null&&(D.Records.Records=h)}}else for(var I=t.filter(Oe=>Oe.FromInputKey!=null),c=this.groupBy(I,"TableName"),m=0;m<f.length;m++){var v=f[m],p=c[v];if(v==Ot.masterEntity&&i!=null)for(var d=0;d<p.length;d++){var y=p[d];this.setValueForObject(o,i,y,a,null)}else{var x=Ot.GetTableForAlias(v),D=this.RecursiveFindLevel(null,v);if(D==null)continue;var h=[],k="",w=this.FindJArray(e,((z=(Y=p[0])==null?void 0:Y.FromInputKey)==null?void 0:z.split("."))??[],k),g={};if(((X=D.Records)==null?void 0:X.Records)==null||D.Records.Records.length===0||D.Records.Records[0].Record==null)continue;for(var _=D.Records.Records[0].Record,P=Object.keys(_),N=0;N<P.length;N++){var E=P[N];g[E]=_.Record[E]}for(var m=0;m<w.length;m++){for(var S=JSON.parse(JSON.stringify(g)),C=w[m],M=new Ga(S,n,D),O=0;O<p.length;O++){var y=p[O];this.setValueForObject(C,M,y,a,null)}M.SetLeftInstanceReference(C),h.push(M)}D.Records=new Du(h,n,D)}}if(u.size>0)return;for(const[De,Oe]of u){var V=Ot.GetMultipleParent(De);if(V==null)throw"Can't find parent for multiple table "+De;var q=this.RecursiveFindLevel(this.rootLevel,V);if(q!=null)for(var J=((se=q.Records)==null?void 0:se.Records)??[],m=0;m<(J==null?void 0:J.length);m++){var ne=J[m].GetLeftInstanceReference();if(ne==null)continue;var j=ne._details;if(j==null)continue;var F=j[De];if(F==null||F.length==0)continue;let _e=null;if(J[m].HasDetails(De)){if(_e=J[m].GetDetail(De),_e==null)continue}else _e=new xn(De,[],this.ObjectInfo,this),J[m].AddDetail(De,_e);for(var U=(re=_e.Records)==null?void 0:re.Records,$=[],m=0;m<F.Count;m++){let qe=null;U&&U.length>m?qe=U[m]:(qe=new Ga({},this.ObjectInfo,_e),$.push(qe));for(var O=0;O<Oe.length;O++){var y=Oe[O];this.setValueForObject(C,qe,y,a,null)}}}}}}FindJArray(e,t,n){if(t.length==0)return null;if(n!=""&&(n+="."),n+=t[0],e[t[0]]!=null&&Array.isArray(e[t[0]])){var a=e[t[0]],i=JSON.parse(JSON.stringify(t));return i.splice(0,1),a.length==1&&t.length>2?this.FindJArray(a[0],i,n):a}var o=JSON.parse(JSON.stringify(t));return o.splice(0,1),this.FindJArray(e[t[0]],o,n)}setValueForObject(e,t,n,a,i){if(e!=null){if(n==null){debugger;return}var o=a?n.FieldName:n.AliasExport??n.FieldName;if(e[o]!=null){var l=t.Record;t.SetValueToKey(n,e[o],l)}else if(n.FromInputKey!=null)for(var u=n.FromInputKey.split("??"),s=0;s<u.length;s++){var c=u[s];if(i!=null&&(c=c.replace(i+".","")),e.Get(c)!=null){var l=t.Record;t.SetValueToKey(n,e.Get(c),l)}}}}InicializeEvalInner(e,t){var n=this.RecursiveFindLevel(null,e);return n==null?!1:(n.Evaluate(t),!0)}MapToId(e){if(e.length==0)return!0;try{var t=e.sort((i,o)=>(i.CalcPhase??0)-(o.CalcPhase??0)),n=[],a=null;for(let i=0;i<t.length;i++){const o=t[i];if(a==null){a=o.TableName,n.push(o);continue}a!=o.TableName&&(this.MapToIdInner(a??"",n),n=[],a=o.TableName),n.push(o)}n.length>0&&this.MapToIdInner(a??"",n)}catch{return!1}return!0}MapToIdInner(e,t){var n=this.RecursiveFindLevel(null,e);return n==null?!1:(n.MapToId(t),!0)}vatsPrepare(e){var l;if(e.length!=0){var t=this.RecursiveFindLevel(null,"EU_Invoices_Items"),n=this.groupBy(e,"TableName");for(const u in n){var a=this.RecursiveFindLevel(null,u);a==null&&(a=new xn(u,[],this.ObjectInfo,this)),a.Records==null&&(a.Records=new Du([],this.ObjectInfo[u],a));var i={};(l=t==null?void 0:t.Records)==null||l.Records.forEach(c=>{var f=c.Record.VatsUIGroupKey;i[f]==null&&(i[f]=[]),i[f].push(c)});var o=[];Object.keys(i).forEach(c=>{var f={};f.__VatRate=c;var m=new Ga({},this.ObjectInfo,a);m.Record=f,m.SetReferenceRecords("__VatRate",i[c]),o.push(m)}),a.Records.Records=o;const s=n[u];a.Evaluate(s)}}}groupBy(e,t){return e.reduce((n,a)=>{const i=String(a[t]);return(n[i]||(n[i]=[])).push(a),n},{})}}class Th{static hasKey(e){return this.getFromSessionStorage(e)!=null}static getFromSessionStorage(e){return localStorage.getItem(e)}static setToSessionStorage(e,t){typeof t=="object"&&(t=JSON.stringify(t)),localStorage.setItem(e,t)}}(function(r,e){typeof At=="object"&&typeof module<"u"?module.exports=e():typeof define=="function"&&define.amd?define(e):(r=typeof globalThis<"u"?globalThis:r||self).axios=e()})(void 0,function(){function r(B){return r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(Z){return typeof Z}:function(Z){return Z&&typeof Symbol=="function"&&Z.constructor===Symbol&&Z!==Symbol.prototype?"symbol":typeof Z},r(B)}function e(B,Z){if(!(B instanceof Z))throw new TypeError("Cannot call a class as a function")}function t(B,Z){for(var te=0;te<Z.length;te++){var ae=Z[te];ae.enumerable=ae.enumerable||!1,ae.configurable=!0,"value"in ae&&(ae.writable=!0),Object.defineProperty(B,ae.key,ae)}}function n(B,Z,te){return Z&&t(B.prototype,Z),te&&t(B,te),Object.defineProperty(B,"prototype",{writable:!1}),B}function a(B,Z){return function(te){if(Array.isArray(te))return te}(B)||function(te,ae){var ce=te==null?null:typeof Symbol<"u"&&te[Symbol.iterator]||te["@@iterator"];if(ce!=null){var fe,ge,Ae=[],Ee=!0,Fe=!1;try{for(ce=ce.call(te);!(Ee=(fe=ce.next()).done)&&(Ae.push(fe.value),!ae||Ae.length!==ae);Ee=!0);}catch(Re){Fe=!0,ge=Re}finally{try{Ee||ce.return==null||ce.return()}finally{if(Fe)throw ge}}return Ae}}(B,Z)||function(te,ae){if(te){if(typeof te=="string")return i(te,ae);var ce=Object.prototype.toString.call(te).slice(8,-1);if(ce==="Object"&&te.constructor&&(ce=te.constructor.name),ce==="Map"||ce==="Set")return Array.from(te);if(ce==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(ce))return i(te,ae)}}(B,Z)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
62
62
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function i(B,Z){(Z==null||Z>B.length)&&(Z=B.length);for(var te=0,ae=new Array(Z);te<Z;te++)ae[te]=B[te];return ae}function o(B,Z){return function(){return B.apply(Z,arguments)}}var l,u=Object.prototype.toString,s=Object.getPrototypeOf,c=(l=Object.create(null),function(B){var Z=u.call(B);return l[Z]||(l[Z]=Z.slice(8,-1).toLowerCase())}),f=function(B){return B=B.toLowerCase(),function(Z){return c(Z)===B}},m=function(B){return function(Z){return r(Z)===B}},v=Array.isArray,p=m("undefined"),d=f("ArrayBuffer"),y=m("string"),x=m("function"),D=m("number"),h=function(B){return B!==null&&r(B)==="object"},w=function(B){if(c(B)!=="object")return!1;var Z=s(B);return!(Z!==null&&Z!==Object.prototype&&Object.getPrototypeOf(Z)!==null||Symbol.toStringTag in B||Symbol.iterator in B)},g=f("Date"),b=f("File"),A=f("Blob"),N=f("FileList"),E=f("URLSearchParams");function S(B,Z){var te,ae,ce=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},fe=ce.allOwnKeys,ge=fe!==void 0&&fe;if(B!=null)if(r(B)!=="object"&&(B=[B]),v(B))for(te=0,ae=B.length;te<ae;te++)Z.call(null,B[te],te,B);else{var Ae,Ee=ge?Object.getOwnPropertyNames(B):Object.keys(B),Fe=Ee.length;for(te=0;te<Fe;te++)Ae=Ee[te],Z.call(null,B[Ae],Ae,B)}}function C(B,Z){Z=Z.toLowerCase();for(var te,ae=Object.keys(B),ce=ae.length;ce-- >0;)if(Z===(te=ae[ce]).toLowerCase())return te;return null}var M=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,O=function(B){return!p(B)&&B!==M},I,k=(I=typeof Uint8Array<"u"&&s(Uint8Array),function(B){return I&&B instanceof I}),_=f("HTMLFormElement"),P=function(B){var Z=Object.prototype.hasOwnProperty;return function(te,ae){return Z.call(te,ae)}}(),V=f("RegExp"),q=function(B,Z){var te=Object.getOwnPropertyDescriptors(B),ae={};S(te,function(ce,fe){Z(ce,fe,B)!==!1&&(ae[fe]=ce)}),Object.defineProperties(B,ae)},J="abcdefghijklmnopqrstuvwxyz",ne="0123456789",j={DIGIT:ne,ALPHA:J,ALPHA_DIGIT:J+J.toUpperCase()+ne},F=f("AsyncFunction"),U={isArray:v,isArrayBuffer:d,isBuffer:function(B){return B!==null&&!p(B)&&B.constructor!==null&&!p(B.constructor)&&x(B.constructor.isBuffer)&&B.constructor.isBuffer(B)},isFormData:function(B){var Z;return B&&(typeof FormData=="function"&&B instanceof FormData||x(B.append)&&((Z=c(B))==="formdata"||Z==="object"&&x(B.toString)&&B.toString()==="[object FormData]"))},isArrayBufferView:function(B){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(B):B&&B.buffer&&d(B.buffer)},isString:y,isNumber:D,isBoolean:function(B){return B===!0||B===!1},isObject:h,isPlainObject:w,isUndefined:p,isDate:g,isFile:b,isBlob:A,isRegExp:V,isFunction:x,isStream:function(B){return h(B)&&x(B.pipe)},isURLSearchParams:E,isTypedArray:k,isFileList:N,forEach:S,merge:function B(){for(var Z=O(this)&&this||{},te=Z.caseless,ae={},ce=function(Ae,Ee){var Fe=te&&C(ae,Ee)||Ee;w(ae[Fe])&&w(Ae)?ae[Fe]=B(ae[Fe],Ae):w(Ae)?ae[Fe]=B({},Ae):v(Ae)?ae[Fe]=Ae.slice():ae[Fe]=Ae},fe=0,ge=arguments.length;fe<ge;fe++)arguments[fe]&&S(arguments[fe],ce);return ae},extend:function(B,Z,te){var ae=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},ce=ae.allOwnKeys;return S(Z,function(fe,ge){te&&x(fe)?B[ge]=o(fe,te):B[ge]=fe},{allOwnKeys:ce}),B},trim:function(B){return B.trim?B.trim():B.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},stripBOM:function(B){return B.charCodeAt(0)===65279&&(B=B.slice(1)),B},inherits:function(B,Z,te,ae){B.prototype=Object.create(Z.prototype,ae),B.prototype.constructor=B,Object.defineProperty(B,"super",{value:Z.prototype}),te&&Object.assign(B.prototype,te)},toFlatObject:function(B,Z,te,ae){var ce,fe,ge,Ae={};if(Z=Z||{},B==null)return Z;do{for(fe=(ce=Object.getOwnPropertyNames(B)).length;fe-- >0;)ge=ce[fe],ae&&!ae(ge,B,Z)||Ae[ge]||(Z[ge]=B[ge],Ae[ge]=!0);B=te!==!1&&s(B)}while(B&&(!te||te(B,Z))&&B!==Object.prototype);return Z},kindOf:c,kindOfTest:f,endsWith:function(B,Z,te){B=String(B),(te===void 0||te>B.length)&&(te=B.length),te-=Z.length;var ae=B.indexOf(Z,te);return ae!==-1&&ae===te},toArray:function(B){if(!B)return null;if(v(B))return B;var Z=B.length;if(!D(Z))return null;for(var te=new Array(Z);Z-- >0;)te[Z]=B[Z];return te},forEachEntry:function(B,Z){for(var te,ae=(B&&B[Symbol.iterator]).call(B);(te=ae.next())&&!te.done;){var ce=te.value;Z.call(B,ce[0],ce[1])}},matchAll:function(B,Z){for(var te,ae=[];(te=B.exec(Z))!==null;)ae.push(te);return ae},isHTMLForm:_,hasOwnProperty:P,hasOwnProp:P,reduceDescriptors:q,freezeMethods:function(B){q(B,function(Z,te){if(x(B)&&["arguments","caller","callee"].indexOf(te)!==-1)return!1;var ae=B[te];x(ae)&&(Z.enumerable=!1,"writable"in Z?Z.writable=!1:Z.set||(Z.set=function(){throw Error("Can not rewrite read-only method '"+te+"'")}))})},toObjectSet:function(B,Z){var te={},ae=function(ce){ce.forEach(function(fe){te[fe]=!0})};return v(B)?ae(B):ae(String(B).split(Z)),te},toCamelCase:function(B){return B.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(Z,te,ae){return te.toUpperCase()+ae})},noop:function(){},toFiniteNumber:function(B,Z){return B=+B,Number.isFinite(B)?B:Z},findKey:C,global:M,isContextDefined:O,ALPHABET:j,generateString:function(){for(var B=arguments.length>0&&arguments[0]!==void 0?arguments[0]:16,Z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:j.ALPHA_DIGIT,te="",ae=Z.length;B--;)te+=Z[Math.random()*ae|0];return te},isSpecCompliantForm:function(B){return!!(B&&x(B.append)&&B[Symbol.toStringTag]==="FormData"&&B[Symbol.iterator])},toJSONObject:function(B){var Z=new Array(10);return function te(ae,ce){if(h(ae)){if(Z.indexOf(ae)>=0)return;if(!("toJSON"in ae)){Z[ce]=ae;var fe=v(ae)?[]:{};return S(ae,function(ge,Ae){var Ee=te(ge,ce+1);!p(Ee)&&(fe[Ae]=Ee)}),Z[ce]=void 0,fe}}return ae}(B,0)},isAsyncFn:F,isThenable:function(B){return B&&(h(B)||x(B))&&x(B.then)&&x(B.catch)}};function $(B,Z,te,ae,ce){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=B,this.name="AxiosError",Z&&(this.code=Z),te&&(this.config=te),ae&&(this.request=ae),ce&&(this.response=ce)}U.inherits($,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:U.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var le=$.prototype,me={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(function(B){me[B]={value:B}}),Object.defineProperties($,me),Object.defineProperty(le,"isAxiosError",{value:!0}),$.from=function(B,Z,te,ae,ce,fe){var ge=Object.create(le);return U.toFlatObject(B,ge,function(Ae){return Ae!==Error.prototype},function(Ae){return Ae!=="isAxiosError"}),$.call(ge,B.message,Z,te,ae,ce),ge.cause=B,ge.name=B.name,fe&&Object.assign(ge,fe),ge};function Y(B){return U.isPlainObject(B)||U.isArray(B)}function z(B){return U.endsWith(B,"[]")?B.slice(0,-2):B}function X(B,Z,te){return B?B.concat(Z).map(function(ae,ce){return ae=z(ae),!te&&ce?"["+ae+"]":ae}).join(te?".":""):Z}var se=U.toFlatObject(U,{},null,function(B){return/^is[A-Z]/.test(B)});function re(B,Z,te){if(!U.isObject(B))throw new TypeError("target must be an object");Z=Z||new FormData;var ae=(te=U.toFlatObject(te,{metaTokens:!0,dots:!1,indexes:!1},!1,function(Ve,je){return!U.isUndefined(je[Ve])})).metaTokens,ce=te.visitor||Fe,fe=te.dots,ge=te.indexes,Ae=(te.Blob||typeof Blob<"u"&&Blob)&&U.isSpecCompliantForm(Z);if(!U.isFunction(ce))throw new TypeError("visitor must be a function");function Ee(Ve){if(Ve===null)return"";if(U.isDate(Ve))return Ve.toISOString();if(!Ae&&U.isBlob(Ve))throw new $("Blob is not supported. Use a Buffer instead.");return U.isArrayBuffer(Ve)||U.isTypedArray(Ve)?Ae&&typeof Blob=="function"?new Blob([Ve]):Buffer.from(Ve):Ve}function Fe(Ve,je,Pe){var mr=Ve;if(Ve&&!Pe&&r(Ve)==="object"){if(U.endsWith(je,"{}"))je=ae?je:je.slice(0,-2),Ve=JSON.stringify(Ve);else if(U.isArray(Ve)&&function(wr){return U.isArray(wr)&&!wr.some(Y)}(Ve)||(U.isFileList(Ve)||U.endsWith(je,"[]"))&&(mr=U.toArray(Ve)))return je=z(je),mr.forEach(function(wr,Pr){!U.isUndefined(wr)&&wr!==null&&Z.append(ge===!0?X([je],Pr,fe):ge===null?je:je+"[]",Ee(wr))}),!1}return!!Y(Ve)||(Z.append(X(Pe,je,fe),Ee(Ve)),!1)}var Re=[],pr=Object.assign(se,{defaultVisitor:Fe,convertValue:Ee,isVisitable:Y});if(!U.isObject(B))throw new TypeError("data must be an object");return function Ve(je,Pe){if(!U.isUndefined(je)){if(Re.indexOf(je)!==-1)throw Error("Circular reference detected in "+Pe.join("."));Re.push(je),U.forEach(je,function(mr,wr){(!(U.isUndefined(mr)||mr===null)&&ce.call(Z,mr,U.isString(wr)?wr.trim():wr,Pe,pr))===!0&&Ve(mr,Pe?Pe.concat(wr):[wr])}),Re.pop()}}(B),Z}function pe(B){var Z={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(B).replace(/[!'()~]|%20|%00/g,function(te){return Z[te]})}function ve(B,Z){this._pairs=[],B&&re(B,this,Z)}var De=ve.prototype;function Oe(B){return encodeURIComponent(B).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Ie(B,Z,te){if(!Z)return B;var ae,ce=te&&te.encode||Oe,fe=te&&te.serialize;if(ae=fe?fe(Z,te):U.isURLSearchParams(Z)?Z.toString():new ve(Z,te).toString(ce)){var ge=B.indexOf("#");ge!==-1&&(B=B.slice(0,ge)),B+=(B.indexOf("?")===-1?"?":"&")+ae}return B}De.append=function(B,Z){this._pairs.push([B,Z])},De.toString=function(B){var Z=B?function(te){return B.call(this,te,pe)}:pe;return this._pairs.map(function(te){return Z(te[0])+"="+Z(te[1])},"").join("&")};var _e,Le=function(){function B(){e(this,B),this.handlers=[]}return n(B,[{key:"use",value:function(Z,te,ae){return this.handlers.push({fulfilled:Z,rejected:te,synchronous:!!ae&&ae.synchronous,runWhen:ae?ae.runWhen:null}),this.handlers.length-1}},{key:"eject",value:function(Z){this.handlers[Z]&&(this.handlers[Z]=null)}},{key:"clear",value:function(){this.handlers&&(this.handlers=[])}},{key:"forEach",value:function(Z){U.forEach(this.handlers,function(te){te!==null&&Z(te)})}}]),B}(),qe={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},G={classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ve,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},isStandardBrowserEnv:(typeof navigator>"u"||(_e=navigator.product)!=="ReactNative"&&_e!=="NativeScript"&&_e!=="NS")&&typeof window<"u"&&typeof document<"u",isStandardBrowserWebWorkerEnv:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",protocols:["http","https","file","blob","url","data"]};function ee(B){function Z(ae,ce,fe,ge){var Ae=ae[ge++],Ee=Number.isFinite(+Ae),Fe=ge>=ae.length;return Ae=!Ae&&U.isArray(fe)?fe.length:Ae,Fe?(U.hasOwnProp(fe,Ae)?fe[Ae]=[fe[Ae],ce]:fe[Ae]=ce,!Ee):(fe[Ae]&&U.isObject(fe[Ae])||(fe[Ae]=[]),Z(ae,ce,fe[Ae],ge)&&U.isArray(fe[Ae])&&(fe[Ae]=function(Re){var pr,Ve,je={},Pe=Object.keys(Re),mr=Pe.length;for(pr=0;pr<mr;pr++)je[Ve=Pe[pr]]=Re[Ve];return je}(fe[Ae])),!Ee)}if(U.isFormData(B)&&U.isFunction(B.entries)){var te={};return U.forEachEntry(B,function(ae,ce){Z(function(fe){return U.matchAll(/\w+|\[(\w*)]/g,fe).map(function(ge){return ge[0]==="[]"?"":ge[1]||ge[0]})}(ae),ce,te,0)}),te}return null}var R={"Content-Type":void 0},H={transitional:qe,adapter:["xhr","http"],transformRequest:[function(B,Z){var te,ae=Z.getContentType()||"",ce=ae.indexOf("application/json")>-1,fe=U.isObject(B);if(fe&&U.isHTMLForm(B)&&(B=new FormData(B)),U.isFormData(B))return ce&&ce?JSON.stringify(ee(B)):B;if(U.isArrayBuffer(B)||U.isBuffer(B)||U.isStream(B)||U.isFile(B)||U.isBlob(B))return B;if(U.isArrayBufferView(B))return B.buffer;if(U.isURLSearchParams(B))return Z.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),B.toString();if(fe){if(ae.indexOf("application/x-www-form-urlencoded")>-1)return function(Ae,Ee){return re(Ae,new G.classes.URLSearchParams,Object.assign({visitor:function(Fe,Re,pr,Ve){return G.isNode&&U.isBuffer(Fe)?(this.append(Re,Fe.toString("base64")),!1):Ve.defaultVisitor.apply(this,arguments)}},Ee))}(B,this.formSerializer).toString();if((te=U.isFileList(B))||ae.indexOf("multipart/form-data")>-1){var ge=this.env&&this.env.FormData;return re(te?{"files[]":B}:B,ge&&new ge,this.formSerializer)}}return fe||ce?(Z.setContentType("application/json",!1),function(Ae,Ee,Fe){if(U.isString(Ae))try{return(Ee||JSON.parse)(Ae),U.trim(Ae)}catch(Re){if(Re.name!=="SyntaxError")throw Re}return(Fe||JSON.stringify)(Ae)}(B)):B}],transformResponse:[function(B){var Z=this.transitional||H.transitional,te=Z&&Z.forcedJSONParsing,ae=this.responseType==="json";if(B&&U.isString(B)&&(te&&!this.responseType||ae)){var ce=!(Z&&Z.silentJSONParsing)&&ae;try{return JSON.parse(B)}catch(fe){if(ce)throw fe.name==="SyntaxError"?$.from(fe,$.ERR_BAD_RESPONSE,this,null,this.response):fe}}return B}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:G.classes.FormData,Blob:G.classes.Blob},validateStatus:function(B){return B>=200&&B<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};U.forEach(["delete","get","head"],function(B){H.headers[B]={}}),U.forEach(["post","put","patch"],function(B){H.headers[B]=U.merge(R)});var Q=H,ie=U.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),ue=Symbol("internals");function oe(B){return B&&String(B).trim().toLowerCase()}function we(B){return B===!1||B==null?B:U.isArray(B)?B.map(we):String(B)}function xe(B,Z,te,ae,ce){return U.isFunction(ae)?ae.call(this,Z,te):(ce&&(Z=te),U.isString(Z)?U.isString(ae)?Z.indexOf(ae)!==-1:U.isRegExp(ae)?ae.test(Z):void 0:void 0)}var Te=function(B,Z){function te(ae){e(this,te),ae&&this.set(ae)}return n(te,[{key:"set",value:function(ae,ce,fe){var ge=this;function Ae(Pe,mr,wr){var Pr=oe(mr);if(!Pr)throw new Error("header name must be a non-empty string");var Br=U.findKey(ge,Pr);(!Br||ge[Br]===void 0||wr===!0||wr===void 0&&ge[Br]!==!1)&&(ge[Br||mr]=we(Pe))}var Ee,Fe,Re,pr,Ve,je=function(Pe,mr){return U.forEach(Pe,function(wr,Pr){return Ae(wr,Pr,mr)})};return U.isPlainObject(ae)||ae instanceof this.constructor?je(ae,ce):U.isString(ae)&&(ae=ae.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(ae.trim())?je((Ve={},(Ee=ae)&&Ee.split(`
|
|
63
63
|
`).forEach(function(Pe){pr=Pe.indexOf(":"),Fe=Pe.substring(0,pr).trim().toLowerCase(),Re=Pe.substring(pr+1).trim(),!Fe||Ve[Fe]&&ie[Fe]||(Fe==="set-cookie"?Ve[Fe]?Ve[Fe].push(Re):Ve[Fe]=[Re]:Ve[Fe]=Ve[Fe]?Ve[Fe]+", "+Re:Re)}),Ve),ce):ae!=null&&Ae(ce,ae,fe),this}},{key:"get",value:function(ae,ce){if(ae=oe(ae)){var fe=U.findKey(this,ae);if(fe){var ge=this[fe];if(!ce)return ge;if(ce===!0)return function(Ae){for(var Ee,Fe=Object.create(null),Re=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;Ee=Re.exec(Ae);)Fe[Ee[1]]=Ee[2];return Fe}(ge);if(U.isFunction(ce))return ce.call(this,ge,fe);if(U.isRegExp(ce))return ce.exec(ge);throw new TypeError("parser must be boolean|regexp|function")}}}},{key:"has",value:function(ae,ce){if(ae=oe(ae)){var fe=U.findKey(this,ae);return!(!fe||this[fe]===void 0||ce&&!xe(0,this[fe],fe,ce))}return!1}},{key:"delete",value:function(ae,ce){var fe=this,ge=!1;function Ae(Ee){if(Ee=oe(Ee)){var Fe=U.findKey(fe,Ee);!Fe||ce&&!xe(0,fe[Fe],Fe,ce)||(delete fe[Fe],ge=!0)}}return U.isArray(ae)?ae.forEach(Ae):Ae(ae),ge}},{key:"clear",value:function(ae){for(var ce=Object.keys(this),fe=ce.length,ge=!1;fe--;){var Ae=ce[fe];ae&&!xe(0,this[Ae],Ae,ae,!0)||(delete this[Ae],ge=!0)}return ge}},{key:"normalize",value:function(ae){var ce=this,fe={};return U.forEach(this,function(ge,Ae){var Ee=U.findKey(fe,Ae);if(Ee)return ce[Ee]=we(ge),void delete ce[Ae];var Fe=ae?function(Re){return Re.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,function(pr,Ve,je){return Ve.toUpperCase()+je})}(Ae):String(Ae).trim();Fe!==Ae&&delete ce[Ae],ce[Fe]=we(ge),fe[Fe]=!0}),this}},{key:"concat",value:function(){for(var ae,ce=arguments.length,fe=new Array(ce),ge=0;ge<ce;ge++)fe[ge]=arguments[ge];return(ae=this.constructor).concat.apply(ae,[this].concat(fe))}},{key:"toJSON",value:function(ae){var ce=Object.create(null);return U.forEach(this,function(fe,ge){fe!=null&&fe!==!1&&(ce[ge]=ae&&U.isArray(fe)?fe.join(", "):fe)}),ce}},{key:Symbol.iterator,value:function(){return Object.entries(this.toJSON())[Symbol.iterator]()}},{key:"toString",value:function(){return Object.entries(this.toJSON()).map(function(ae){var ce=a(ae,2);return ce[0]+": "+ce[1]}).join(`
|
|
64
|
-
`)}},{key:Symbol.toStringTag,get:function(){return"AxiosHeaders"}}],[{key:"from",value:function(ae){return ae instanceof this?ae:new this(ae)}},{key:"concat",value:function(ae){for(var ce=new this(ae),fe=arguments.length,ge=new Array(fe>1?fe-1:0),Ae=1;Ae<fe;Ae++)ge[Ae-1]=arguments[Ae];return ge.forEach(function(Ee){return ce.set(Ee)}),ce}},{key:"accessor",value:function(ae){var ce=(this[ue]=this[ue]={accessors:{}}).accessors,fe=this.prototype;function ge(Ae){var Ee=oe(Ae);ce[Ee]||(function(Fe,Re){var pr=U.toCamelCase(" "+Re);["get","set","has"].forEach(function(Ve){Object.defineProperty(Fe,Ve+pr,{value:function(je,Pe,mr){return this[Ve].call(this,Re,je,Pe,mr)},configurable:!0})})}(fe,Ae),ce[Ee]=!0)}return U.isArray(ae)?ae.forEach(ge):ge(ae),this}}]),te}();Te.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),U.freezeMethods(Te.prototype),U.freezeMethods(Te);var be=Te;function ke(B,Z){var te=this||Q,ae=Z||te,ce=be.from(ae.headers),fe=ae.data;return U.forEach(B,function(ge){fe=ge.call(te,fe,ce.normalize(),Z?Z.status:void 0)}),ce.normalize(),fe}function fr(B){return!(!B||!B.__CANCEL__)}function hr(B,Z,te){$.call(this,B??"canceled",$.ERR_CANCELED,Z,te),this.name="CanceledError"}U.inherits(hr,$,{__CANCEL__:!0});var ir=G.isStandardBrowserEnv?{write:function(B,Z,te,ae,ce,fe){var ge=[];ge.push(B+"="+encodeURIComponent(Z)),U.isNumber(te)&&ge.push("expires="+new Date(te).toGMTString()),U.isString(ae)&&ge.push("path="+ae),U.isString(ce)&&ge.push("domain="+ce),fe===!0&&ge.push("secure"),document.cookie=ge.join("; ")},read:function(B){var Z=document.cookie.match(new RegExp("(^|;\\s*)("+B+")=([^;]*)"));return Z?decodeURIComponent(Z[3]):null},remove:function(B){this.write(B,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}};function Fr(B,Z){return B&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(Z)?function(te,ae){return ae?te.replace(/\/+$/,"")+"/"+ae.replace(/^\/+/,""):te}(B,Z):Z}var T=G.isStandardBrowserEnv?function(){var B,Z=/(msie|trident)/i.test(navigator.userAgent),te=document.createElement("a");function ae(ce){var fe=ce;return Z&&(te.setAttribute("href",fe),fe=te.href),te.setAttribute("href",fe),{href:te.href,protocol:te.protocol?te.protocol.replace(/:$/,""):"",host:te.host,search:te.search?te.search.replace(/^\?/,""):"",hash:te.hash?te.hash.replace(/^#/,""):"",hostname:te.hostname,port:te.port,pathname:te.pathname.charAt(0)==="/"?te.pathname:"/"+te.pathname}}return B=ae(window.location.href),function(ce){var fe=U.isString(ce)?ae(ce):ce;return fe.protocol===B.protocol&&fe.host===B.host}}():function(){return!0};function K(B,Z){var te=0,ae=function(ce,fe){ce=ce||10;var ge,Ae=new Array(ce),Ee=new Array(ce),Fe=0,Re=0;return fe=fe!==void 0?fe:1e3,function(pr){var Ve=Date.now(),je=Ee[Re];ge||(ge=Ve),Ae[Fe]=pr,Ee[Fe]=Ve;for(var Pe=Re,mr=0;Pe!==Fe;)mr+=Ae[Pe++],Pe%=ce;if((Fe=(Fe+1)%ce)===Re&&(Re=(Re+1)%ce),!(Ve-ge<fe)){var wr=je&&Ve-je;return wr?Math.round(1e3*mr/wr):void 0}}}(50,250);return function(ce){var fe=ce.loaded,ge=ce.lengthComputable?ce.total:void 0,Ae=fe-te,Ee=ae(Ae);te=fe;var Fe={loaded:fe,total:ge,progress:ge?fe/ge:void 0,bytes:Ae,rate:Ee||void 0,estimated:Ee&&ge&&fe<=ge?(ge-fe)/Ee:void 0,event:ce};Fe[Z?"download":"upload"]=!0,B(Fe)}}var de={http:null,xhr:typeof XMLHttpRequest<"u"&&function(B){return new Promise(function(Z,te){var ae,ce=B.data,fe=be.from(B.headers).normalize(),ge=B.responseType;function Ae(){B.cancelToken&&B.cancelToken.unsubscribe(ae),B.signal&&B.signal.removeEventListener("abort",ae)}U.isFormData(ce)&&(G.isStandardBrowserEnv||G.isStandardBrowserWebWorkerEnv?fe.setContentType(!1):fe.setContentType("multipart/form-data;",!1));var Ee=new XMLHttpRequest;if(B.auth){var Fe=B.auth.username||"",Re=B.auth.password?unescape(encodeURIComponent(B.auth.password)):"";fe.set("Authorization","Basic "+btoa(Fe+":"+Re))}var pr=Fr(B.baseURL,B.url);function Ve(){if(Ee){var wr=be.from("getAllResponseHeaders"in Ee&&Ee.getAllResponseHeaders());(function(Pr,Br,en){var Rh=en.config.validateStatus;en.status&&Rh&&!Rh(en.status)?Br(new $("Request failed with status code "+en.status,[$.ERR_BAD_REQUEST,$.ERR_BAD_RESPONSE][Math.floor(en.status/100)-4],en.config,en.request,en)):Pr(en)})(function(Pr){Z(Pr),Ae()},function(Pr){te(Pr),Ae()},{data:ge&&ge!=="text"&&ge!=="json"?Ee.response:Ee.responseText,status:Ee.status,statusText:Ee.statusText,headers:wr,config:B,request:Ee}),Ee=null}}if(Ee.open(B.method.toUpperCase(),Ie(pr,B.params,B.paramsSerializer),!0),Ee.timeout=B.timeout,"onloadend"in Ee?Ee.onloadend=Ve:Ee.onreadystatechange=function(){Ee&&Ee.readyState===4&&(Ee.status!==0||Ee.responseURL&&Ee.responseURL.indexOf("file:")===0)&&setTimeout(Ve)},Ee.onabort=function(){Ee&&(te(new $("Request aborted",$.ECONNABORTED,B,Ee)),Ee=null)},Ee.onerror=function(){te(new $("Network Error",$.ERR_NETWORK,B,Ee)),Ee=null},Ee.ontimeout=function(){var wr=B.timeout?"timeout of "+B.timeout+"ms exceeded":"timeout exceeded",Pr=B.transitional||qe;B.timeoutErrorMessage&&(wr=B.timeoutErrorMessage),te(new $(wr,Pr.clarifyTimeoutError?$.ETIMEDOUT:$.ECONNABORTED,B,Ee)),Ee=null},G.isStandardBrowserEnv){var je=(B.withCredentials||T(pr))&&B.xsrfCookieName&&ir.read(B.xsrfCookieName);je&&fe.set(B.xsrfHeaderName,je)}ce===void 0&&fe.setContentType(null),"setRequestHeader"in Ee&&U.forEach(fe.toJSON(),function(wr,Pr){Ee.setRequestHeader(Pr,wr)}),U.isUndefined(B.withCredentials)||(Ee.withCredentials=!!B.withCredentials),ge&&ge!=="json"&&(Ee.responseType=B.responseType),typeof B.onDownloadProgress=="function"&&Ee.addEventListener("progress",K(B.onDownloadProgress,!0)),typeof B.onUploadProgress=="function"&&Ee.upload&&Ee.upload.addEventListener("progress",K(B.onUploadProgress)),(B.cancelToken||B.signal)&&(ae=function(wr){Ee&&(te(!wr||wr.type?new hr(null,B,Ee):wr),Ee.abort(),Ee=null)},B.cancelToken&&B.cancelToken.subscribe(ae),B.signal&&(B.signal.aborted?ae():B.signal.addEventListener("abort",ae)));var Pe,mr=(Pe=/^([-+\w]{1,25})(:?\/\/|:)/.exec(pr))&&Pe[1]||"";mr&&G.protocols.indexOf(mr)===-1?te(new $("Unsupported protocol "+mr+":",$.ERR_BAD_REQUEST,B)):Ee.send(ce||null)})}};U.forEach(de,function(B,Z){if(B){try{Object.defineProperty(B,"name",{value:Z})}catch{}Object.defineProperty(B,"adapterName",{value:Z})}});var Se=function(B){for(var Z,te,ae=(B=U.isArray(B)?B:[B]).length,ce=0;ce<ae&&(Z=B[ce],!(te=U.isString(Z)?de[Z.toLowerCase()]:Z));ce++);if(!te)throw te===!1?new $("Adapter ".concat(Z," is not supported by the environment"),"ERR_NOT_SUPPORT"):new Error(U.hasOwnProp(de,Z)?"Adapter '".concat(Z,"' is not available in the build"):"Unknown adapter '".concat(Z,"'"));if(!U.isFunction(te))throw new TypeError("adapter is not a function");return te};function ze(B){if(B.cancelToken&&B.cancelToken.throwIfRequested(),B.signal&&B.signal.aborted)throw new hr(null,B)}function Ke(B){return ze(B),B.headers=be.from(B.headers),B.data=ke.call(B,B.transformRequest),["post","put","patch"].indexOf(B.method)!==-1&&B.headers.setContentType("application/x-www-form-urlencoded",!1),Se(B.adapter||Q.adapter)(B).then(function(Z){return ze(B),Z.data=ke.call(B,B.transformResponse,Z),Z.headers=be.from(Z.headers),Z},function(Z){return fr(Z)||(ze(B),Z&&Z.response&&(Z.response.data=ke.call(B,B.transformResponse,Z.response),Z.response.headers=be.from(Z.response.headers))),Promise.reject(Z)})}var et=function(B){return B instanceof be?B.toJSON():B};function Ot(B,Z){Z=Z||{};var te={};function ae(Fe,Re,pr){return U.isPlainObject(Fe)&&U.isPlainObject(Re)?U.merge.call({caseless:pr},Fe,Re):U.isPlainObject(Re)?U.merge({},Re):U.isArray(Re)?Re.slice():Re}function ce(Fe,Re,pr){return U.isUndefined(Re)?U.isUndefined(Fe)?void 0:ae(void 0,Fe,pr):ae(Fe,Re,pr)}function fe(Fe,Re){if(!U.isUndefined(Re))return ae(void 0,Re)}function ge(Fe,Re){return U.isUndefined(Re)?U.isUndefined(Fe)?void 0:ae(void 0,Fe):ae(void 0,Re)}function Ae(Fe,Re,pr){return pr in Z?ae(Fe,Re):pr in B?ae(void 0,Fe):void 0}var Ee={url:fe,method:fe,data:fe,baseURL:ge,transformRequest:ge,transformResponse:ge,paramsSerializer:ge,timeout:ge,timeoutMessage:ge,withCredentials:ge,adapter:ge,responseType:ge,xsrfCookieName:ge,xsrfHeaderName:ge,onUploadProgress:ge,onDownloadProgress:ge,decompress:ge,maxContentLength:ge,maxBodyLength:ge,beforeRedirect:ge,transport:ge,httpAgent:ge,httpsAgent:ge,cancelToken:ge,socketPath:ge,responseEncoding:ge,validateStatus:Ae,headers:function(Fe,Re){return ce(et(Fe),et(Re),!0)}};return U.forEach(Object.keys(Object.assign({},B,Z)),function(Fe){var Re=Ee[Fe]||ce,pr=Re(B[Fe],Z[Fe],Fe);U.isUndefined(pr)&&Re!==Ae||(te[Fe]=pr)}),te}var xi="1.4.0",wi={};["object","boolean","number","function","string","symbol"].forEach(function(B,Z){wi[B]=function(te){return r(te)===B||"a"+(Z<1?"n ":" ")+B}});var Wo={};wi.transitional=function(B,Z,te){function ae(ce,fe){return"[Axios v1.4.0] Transitional option '"+ce+"'"+fe+(te?". "+te:"")}return function(ce,fe,ge){if(B===!1)throw new $(ae(fe," has been removed"+(Z?" in "+Z:"")),$.ERR_DEPRECATED);return Z&&!Wo[fe]&&(Wo[fe]=!0,console.warn(ae(fe," has been deprecated since v"+Z+" and will be removed in the near future"))),!B||B(ce,fe,ge)}};var Di={assertOptions:function(B,Z,te){if(r(B)!=="object")throw new $("options must be an object",$.ERR_BAD_OPTION_VALUE);for(var ae=Object.keys(B),ce=ae.length;ce-- >0;){var fe=ae[ce],ge=Z[fe];if(ge){var Ae=B[fe],Ee=Ae===void 0||ge(Ae,fe,B);if(Ee!==!0)throw new $("option "+fe+" must be "+Ee,$.ERR_BAD_OPTION_VALUE)}else if(te!==!0)throw new $("Unknown option "+fe,$.ERR_BAD_OPTION)}},validators:wi},un=Di.validators,Wa=function(){function B(Z){e(this,B),this.defaults=Z,this.interceptors={request:new Le,response:new Le}}return n(B,[{key:"request",value:function(Z,te){typeof Z=="string"?(te=te||{}).url=Z:te=Z||{};var ae,ce=te=Ot(this.defaults,te),fe=ce.transitional,ge=ce.paramsSerializer,Ae=ce.headers;fe!==void 0&&Di.assertOptions(fe,{silentJSONParsing:un.transitional(un.boolean),forcedJSONParsing:un.transitional(un.boolean),clarifyTimeoutError:un.transitional(un.boolean)},!1),ge!=null&&(U.isFunction(ge)?te.paramsSerializer={serialize:ge}:Di.assertOptions(ge,{encode:un.function,serialize:un.function},!0)),te.method=(te.method||this.defaults.method||"get").toLowerCase(),(ae=Ae&&U.merge(Ae.common,Ae[te.method]))&&U.forEach(["delete","get","head","post","put","patch","common"],function(Br){delete Ae[Br]}),te.headers=be.concat(ae,Ae);var Ee=[],Fe=!0;this.interceptors.request.forEach(function(Br){typeof Br.runWhen=="function"&&Br.runWhen(te)===!1||(Fe=Fe&&Br.synchronous,Ee.unshift(Br.fulfilled,Br.rejected))});var Re,pr=[];this.interceptors.response.forEach(function(Br){pr.push(Br.fulfilled,Br.rejected)});var Ve,je=0;if(!Fe){var Pe=[Ke.bind(this),void 0];for(Pe.unshift.apply(Pe,Ee),Pe.push.apply(Pe,pr),Ve=Pe.length,Re=Promise.resolve(te);je<Ve;)Re=Re.then(Pe[je++],Pe[je++]);return Re}Ve=Ee.length;var mr=te;for(je=0;je<Ve;){var wr=Ee[je++],Pr=Ee[je++];try{mr=wr(mr)}catch(Br){Pr.call(this,Br);break}}try{Re=Ke.call(this,mr)}catch(Br){return Promise.reject(Br)}for(je=0,Ve=pr.length;je<Ve;)Re=Re.then(pr[je++],pr[je++]);return Re}},{key:"getUri",value:function(Z){return Ie(Fr((Z=Ot(this.defaults,Z)).baseURL,Z.url),Z.params,Z.paramsSerializer)}}]),B}();U.forEach(["delete","get","head","options"],function(B){Wa.prototype[B]=function(Z,te){return this.request(Ot(te||{},{method:B,url:Z,data:(te||{}).data}))}}),U.forEach(["post","put","patch"],function(B){function Z(te){return function(ae,ce,fe){return this.request(Ot(fe||{},{method:B,headers:te?{"Content-Type":"multipart/form-data"}:{},url:ae,data:ce}))}}Wa.prototype[B]=Z(),Wa.prototype[B+"Form"]=Z(!0)});var Ya=Wa,Su=function(){function B(Z){if(e(this,B),typeof Z!="function")throw new TypeError("executor must be a function.");var te;this.promise=new Promise(function(ce){te=ce});var ae=this;this.promise.then(function(ce){if(ae._listeners){for(var fe=ae._listeners.length;fe-- >0;)ae._listeners[fe](ce);ae._listeners=null}}),this.promise.then=function(ce){var fe,ge=new Promise(function(Ae){ae.subscribe(Ae),fe=Ae}).then(ce);return ge.cancel=function(){ae.unsubscribe(fe)},ge},Z(function(ce,fe,ge){ae.reason||(ae.reason=new hr(ce,fe,ge),te(ae.reason))})}return n(B,[{key:"throwIfRequested",value:function(){if(this.reason)throw this.reason}},{key:"subscribe",value:function(Z){this.reason?Z(this.reason):this._listeners?this._listeners.push(Z):this._listeners=[Z]}},{key:"unsubscribe",value:function(Z){if(this._listeners){var te=this._listeners.indexOf(Z);te!==-1&&this._listeners.splice(te,1)}}}],[{key:"source",value:function(){var Z;return{token:new B(function(te){Z=te}),cancel:Z}}}]),B}(),Ni={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ni).forEach(function(B){var Z=a(B,2),te=Z[0],ae=Z[1];Ni[ae]=te});var Cu=Ni,kr=function B(Z){var te=new Ya(Z),ae=o(Ya.prototype.request,te);return U.extend(ae,Ya.prototype,te,{allOwnKeys:!0}),U.extend(ae,te,null,{allOwnKeys:!0}),ae.create=function(ce){return B(Ot(Z,ce))},ae}(Q);return kr.Axios=Ya,kr.CanceledError=hr,kr.CancelToken=Su,kr.isCancel=fr,kr.VERSION=xi,kr.toFormData=re,kr.AxiosError=$,kr.Cancel=kr.CanceledError,kr.all=function(B){return Promise.all(B)},kr.spread=function(B){return function(Z){return B.apply(null,Z)}},kr.isAxiosError=function(B){return U.isObject(B)&&B.isAxiosError===!0},kr.mergeConfig=Ot,kr.AxiosHeaders=be,kr.formToJSON=function(B){return ee(U.isHTMLForm(B)?new FormData(B):B)},kr.HttpStatusCode=Cu,kr.default=kr,kr});const mt=v6();function v6(){let r=new Date,e=r.getMilliseconds()+1e3*r.getSeconds()+6e4*r.getMinutes()+36e5*r.getHours(),t=null,n=0,a=window.location.pathname.trim().replace(/(^[\/]*|[\/]*$)/g,""),i="(unavailable)";try{i=window.top.location.pathname.trim().replace(/(^[\/]*|[\/]*$)/g,"")}catch{}function o(d,y,x,D,h,w){let g=!0;t||(t=[],g=!1),t.push({id:d,ticket:y,processor:x,progressor:D,context:h,queue:w});let b=0;function A(){if(t&&t.length===0){t=null;return}b++;let N=mt.context().onFinally(function(){b<=2?setTimeout(A,2e3):b<=4?setTimeout(A,3e3):setTimeout(A,5e3)}),E=[];for(let S=0;S<t.length;S++){let C=t[S].ticket;E.push(C)}mt.call("$.QueryPreemptedResponses",{tickets:E}).done(function(S){if(S.error){let C=t.splice(0,E.length);for(let M=0;M<C.length;M++)C[M].processor.process(S);for(let M=0;M<C.length;M++){let O=C[M];O.context.preempted&&(O.context.preempted=null,O.context.__leave())}return!1}for(let C in S.result){let I=function(k,_,P){function V(q,J){if(q.queue.ready||(q.queue.ready=[]),q.queue.ready.push({ticket:_,handler:function(){try{q.processor.process(J)}finally{let ne=q.context.preempted.indexOf(_);q.context.preempted.splice(ne,1),q.context.preempted.length===0&&(q.context.preempted=null,q.context.__leave())}}}),q.queue.ready.length===q.queue.preempted){for(let ne=0;ne<E.length;ne++){let j=E[ne];for(let F=0;F<q.queue.ready.length;F++){let U=q.queue.ready[F];U.ticket===j&&U.handler()}}q.queue.ready=[]}}if(k.status==="error"){let q=t.splice(P,1)[0];V(q,{id:q.id,error:{code:-1,message:k.reason}})}else if(k.status==="ok"){let q=t.splice(P,1)[0];(function(ne){mt.call("$.RetrievePreemptedResponse",{ticket:ne.ticket}).done(function(j){let F=j;F&&F.result&&F.result.code&&F.result.code>=-32700&&F.result.code<=-32e3&&(F={id:F.id,error:F.result}),V(ne,F)}).post(N)})(q)}else{let q=t[P];q.progressor&&q.progressor.progress(k)}},M=S.result[C],O=-1;for(let k=0;k<t.length;k++)if(t[k].ticket===C){O=k;break}O!==-1&&I(M,C,O)}return!1}).post(N)}g||setTimeout(A,2e3)}let l=function(){let d=[],y=null,x=700;function D(h){let w=d;if(d=[],w.length===0)return;w.preempted=0;let g;if(w.length===1)g=w[0].batch;else{g=[];for(let M=0;M<w.length;M++){let O=w[M].batch;for(let I=0;I<O.length;I++)g.push(O[I])}}let b=[];if(g.length===1)b=g[0].request;else{b.push({method:"$.BeginSynchronizedBatch",params:[]});for(let M=0;M<g.length;M++){let O=g[M].request;if(M===0&&O.method===b[0].method){b[0]=O;continue}b.push(g[M].request)}}let A=function(M,O){for(let I=0;I<w.length;I++)w[I].fail(M,O)},N=function(M,O){try{if(!M){A(!0,"Server returned an empty response. This is likely a server bug.");return}if(M.ajaxCallFailed){M.error.status==="timeout"?A(!0,"JSON-RPC call failed. Timeout."):M.error.status==="error"&&!M.error.details?A(!0,"JSON-RPC call failed. No connection to server."):A(!0,"JSON-RPC call failed. Status: '"+M.error.status+"'"+(M.error.details?", Details: "+JSON.stringify(M.error.details,null,2):""));return}let I=typeof M=="object"&&M instanceof Array?M:[M];if(I.length===0){A(!0,"Server returned an empty list of responses.");return}if(I.length===1){let k=I[0];if(typeof k.id<"u"&&k.id.indexOf&&k.id.indexOf("e2-status-")===0){I=[];for(let _=0;_<w.length;_++){let V=w[_].batch;for(let q=0;q<V.length;q++){let J=JSON.parse(JSON.stringify(k));J.id=V[q].request.id,I.push(J)}}}}for(let k=0;k<I.length;k++){let _=I[k];if(typeof _.result>"u"&&!_.error){A(!0,"Server returned invalid JSON-RPC response: "+JSON.stringify(_,null,2));return}let P=null,V=null,q=null;if(typeof _.id<"u")for(let ne=0;ne<w.length;ne++){let j=w[ne],F=j.batch;for(let U=0;U<F.length;U++){let $=F[U];if(!(!$.request.id||$.request.id!==_.id)){P=$.callbacks,V=$.progressCallbacks,q=j.context;break}}if(P)break}q||(q=mt.context(),P=[function(ne){return window.MessagesUI?window.MessagesUI.show({message:ne,json:!0}):console.log(ne),!0}],V=[]);let J={context:q,callbacks:P,process:function(ne,j){let F=this.context.__preview(ne);if(F){if(this.callbacks)for(let U=0;U<this.callbacks.length;U++){let $=this.callbacks[U];$(ne,j)||(F=!1)}F&&(ne.error?this.context.__defaultApiFail(ne.error)||A(!1,ne.error):this.context.__defaultApiSucceed(ne.result)||h.log(ne.result))}}};if(_.error&&_.error.code===-32099&&h.autoQueryPreempted){let ne=_.error.data;q.preempted||(q.preempted=[]),q.preempted.push(ne),w.preempted++;let j={callbacks:V,progress:function(F){if(this.callbacks)for(let U=0;U<this.callbacks.length;U++){let $=this.callbacks[U];$&&$(F)}}};o(_.id,ne,J,j,q,w);continue}J.process(_,O)}}finally{for(let I=0;I<w.length;I++){let k=w[I].context;k.preempted||k.__leave()}}},E={timeout:0,responseType:"blob",withCredentials:!0},S=h.headers;S?S=JSON.parse(JSON.stringify(S)):S={},S["JsonRpc-Preempt-After"]||(S["JsonRpc-Preempt-After"]=h.jsonRpcPreemptAfter),S["JsonRpc-Path-TopLevel"]=i,S["JsonRpc-Path"]=a,E.headers=S,n++,axios.post(h.url,b,E).then(async function(M){n--;let O=M.headers["Content-Length"]??M.headers["content-length"]??M.headers["D3Pro-Uncompressed-Content-Length"]??M.headers["d3pro-uncompressed-content-length"]??0;const I=new Blob([M.data],{type:"application/json"});if(O&&h.largeResponseDownloadLimitMb&&h.largeResponseDownloadLimitMb>0&&O>h.largeResponseDownloadLimitMb*1024*1024){let P=`LargeJsonRpcResponse (${new Date().toISOString().replace("T"," ").replaceAll(":","-")}).json`;console.log("Response too large to load. It will be downloaded to file instead: "+P);const V=document.createElement("a"),q=URL.createObjectURL(I);V.href=q,V.download=P,V.click(),URL.revokeObjectURL(q),N({error:{status:"TOO_LARGE_REDIRECTED_TO_FILE",details:"Response was too large to load. It was saved to a file instead: '"+P+"'."}},M.request)}else{let P=JSON.parse(await I.text());N(P,M.request)}M.headers["D3Pro-Refresh-Top-Level"]=="True"&&(console.log("Response requires a full page refresh. Doing it."),window.top.location.reload())}).catch(function(M){console.log(M),n--,N({error:{status:M.code,details:M.message},ajaxCallFailed:!0})})}return{dispatch:function(h,w,g,b){let A=y;y=new Date,d.length===0&&(d.created=y),d.push({batch:h,context:w,fail:g});let N=b??mt.config;if(h.length===1){let E=h[0].request.method;if(E[0]==="$"&&E.indexOf("Preempted")>-1){if(d.length>1){let S=d.pop();D(N),d=[],d.push(S)}D(N);return}}if(!N.batch){D(N);return}if(A!=null){let E=y-A;y-d.created<3e3&&(n>3||E<x)&&d.timeoutHandle&&(clearTimeout(d.timeoutHandle),d.timeoutHandle=null)}if(n===0){d.timeoutHandle=setTimeout(function(){D(N)},1);return}d.timeoutHandle=setTimeout(function(){D(N)},x+50)}}}();function u(){let d=arguments[0],y=[];const x=D=>D&&[void 0,Object].includes(D.constructor);if(arguments.length===2&&(x(arguments[1])||Array.isArray(arguments[1])))y=arguments[1];else for(let D=1;D<arguments.length;D++)y.push(arguments[D]);return{method:d,params:y}}function s(d,y){let x=[];x.push({request:d,callbacks:[],progressCallbacks:[]});let D=null,h=function(w,g){if(!(D&&w===!0&&D.__rpcFail(g))){if(y&&y.unhandledError){y.unhandledError(g);return}console.log(g)}};return{call:function(){let w=u.apply(null,arguments);return e++,w.id=e,x.push({request:w,callbacks:[],progressCallbacks:[]}),this},notify:function(){let w=u.apply(null,arguments);return x.push({request:w,callbacks:[],progressCallbacks:[]}),this},using:function(w){let g=x[x.length-1].request;return g.id=w,this},done:function(w){let g=x.length>0?x[x.length-1]:null;return typeof w=="function"&&g.callbacks.push(w),this},progress:function(w){let g=x.length>0?x[x.length-1]:null;return typeof w=="function"&&g.progressCallbacks.push(w),this},post:function(w,g){D=w,D||(D=mt.context()),D.__enter();let b=g??mt.config;if(!b){try{h(!0,"RpcClient was invoked without a valid config object!")}finally{D.__leave()}return}if(b.jsonp){let A=[];if(x.length===1)A=x[0].request;else for(let M=0;M<x.length;M++)A.push(x[M].request);let N=b.headers;N||(N={});let E="__jsonpCallback_"+e,S=b.url+"?callback="+E+"&jsonrpc="+JSON.stringify(A);for(let M in N)N.hasOwnProperty(M)&&(S=S+"&"+M+"="+b.headers[M]);let C=document.createElement("script");C.setAttribute("src",S),window[E]=function(M){window[E]=null,document.getElementsByTagName("body")[0].removeChild(C),C=null,handler(M)},document.getElementsByTagName("body")[0].appendChild(C),D.__leave();return}l.dispatch(x,D,h,b)}}}let c={url:"json.rpc",batch:!0,jsonRpcPreemptAfter:7,autoQueryPreempted:!0,log:function(d){console.log(d)},unhandledError:function(d){console.log(d)}},f=null,m=document.getElementsByTagName("head");if(m&&m.length){let d=m[0].getElementsByTagName("base");d&&d.length&&(f=d[0].getAttribute("href"))}function v(d){return d.map(function(y){return y.trim().replace(/(^[\/]*|[\/]*$)/g,"")}).join("/")}let p=window.top.location.pathname.trim().replace(/(^[\/]*|[\/]*$)/g,"");return!p||p===""?f&&(c.url=v([f,c.url])):f?c.url=v([f,p,c.url]):c.url=v([p,c.url]),{config:c,call:function(){let d=u.apply(null,arguments);return e++,d.id=e,s(d,this.config)},notify:function(){let d=u.apply(null,arguments);return s(d,this.config)},context:function(){let d={count:0,rpcErrorHandlers:[],apiErrorHandlers:[],apiSuccessHandlers:[],responsePreviewers:[],finallyHandlers:[]};return{onRpcError:function(y){return typeof y=="function"&&d.rpcErrorHandlers.push(y),this},onDefaultApiError:function(y){return typeof y=="function"&&d.apiErrorHandlers.push(y),this},onDefaultApiSuccess:function(y){return typeof y=="function"&&d.apiSuccessHandlers.push(y),this},onFinally:function(y){return typeof y=="function"&&d.finallyHandlers.push(y),this},onPreviewResponse:function(y){return typeof y=="function"&&d.responsePreviewers.push(y),this},__enter:function(){d.count++},__preview:function(){if(d.responsePreviewers.length===0)return!0;let y=!1;for(let x=0;x<d.responsePreviewers.length;x++)d.responsePreviewers[x].apply(null,arguments)||(y=!0);return!y},__rpcFail:function(){if(d.rpcErrorHandlers.length===0)return!1;for(let y=0;y<d.rpcErrorHandlers.length;y++)d.rpcErrorHandlers[y].apply(null,arguments);return!0},__defaultApiFail:function(){if(d.apiErrorHandlers.length===0)return!1;for(let y=0;y<d.apiErrorHandlers.length;y++)d.apiErrorHandlers[y].apply(null,arguments);return!0},__defaultApiSucceed:function(){if(d.apiSuccessHandlers.length===0)return!1;for(let y=0;y<d.apiSuccessHandlers.length;y++)d.apiSuccessHandlers[y].apply(null,arguments);return!0},__leave:function(){if(d.count--,!(d.count>0))for(let y=0;y<d.finallyHandlers.length;y++)d.finallyHandlers[y].apply(null,arguments)}}}}}const Th=async(r,e,t)=>{mt.config={},mt.config.url=r+"/json.rpc",mt.config.cors=!0;var n="GEI.GetClientLibObj",a={Legislation:e};mt.call(n,a).done(function(i){return t!=null&&t(i),i}).post(Bh())},p6=async(r,e,t,n,a)=>{mt.config={},mt.config.url=r+"/json.rpc",mt.config.cors=!0;var i="GEI.CreateXML",o={Legislation:e,Version:t,InputObj:Au(n)};mt.call(i,o).done(function(l){return a!=null&&a(l),l}).post(Bh())},d6=(r,e,t)=>{var n=Au(e);console.log("Tech obj:"),console.log(n);var a=new Mh(r,n,t);a.Evaluate()||console.log("Errors:");const i=a.getAliasObject();console.log("Aliased obj:"),console.log(i);const o=y6(i,e);return console.log("Edit obj new:"),console.log(o),o},h6=(r,e)=>{var t=Nu("Invoice",e.Invoice);return t},Nu=(r,e)=>{if(e==null)return null;var t={};if(Array.isArray(e)){var n=[];for(let o=0;o<e.length;o++){var a=e[o]??null,i=Nu(r,a);i!=null&&n.push(i)}t=n}else t=g6(r,e);return t},g6=(r,e)=>{if(e._details!=null){var t=e._details,n=Object.keys(t),a={};for(let o=0;o<n.length;o++){const l=n[o],u=t[l]??null;var i=Nu(l,u);i!=null&&(a[l]=i)}Object.keys(a).length>0}},y6=(r,e)=>{var t=Eu("Invoice",r.Invoice,e.Invoice);return t},Eu=(r,e,t)=>{if(e==null||t==null)return null;var n={};if(Array.isArray(e)){var a=[];for(let l=0;l<e.length;l++){var i=t[l]??null,o=Eu(r,e[l],i);o!=null&&a.push(o)}n=a}else n=b6(r,e,t);return n},b6=(r,e,t)=>{var n={};if(e._details!=null){var a=e._details,i=t._details??{},o=Object.keys(a),l={};for(let f=0;f<o.length;f++){const m=o[f],v=i[m]??null,p=a[m]??null;var u=Eu(m,p,v);u!=null&&(l[m]=u)}Object.keys(l).length>0&&(n._details=l)}var s=Object.keys(e);for(let f=0;f<s.length;f++){var c=s[f];c!="_details"&&t[c]!=null&&(t[c].Value=e[c],n[c]=t[c])}return Object.keys(n).length==0?null:n},Au=r=>{var e=Fh("Invoice",r.Invoice);return e},Fh=(r,e)=>{var t=null;e!=null&&(Array.isArray(e)?(t=[],e.forEach(a=>{t.push(Oh(a))})):t=Oh(e));let n={};return n[r]=t,n},Oh=r=>{var e={},t=Object.keys(r);return t.forEach(n=>{if(n=="_details"){var a={},i=Object.keys(r[n]);i.forEach(o=>{var l=Fh(o,r[n][o]);a=Object.assign(a,l)}),e._details=a;return}e[n]=r[n].Value}),e},x6=(r,e)=>{var t=_h.getFromSessionStorage("ClientInfo");if(t==null){var n=i=>{i.result!=null?i.result.Status=="OK"?(w6(i.result.Result),e(i.result.Result)):console.error("Error getting client info from server: "+i.result.Reason):console.error("Error getting client info from server:"+i.error.data)};Th("https://dev.dddinvoices.com",r,n)}else{var a=JSON.parse(t);e(a)}},w6=r=>{_h.setToSessionStorage("ClientInfo",r)},Bh=()=>mt.context().onRpcError(function(r){}).onDefaultApiError(function(r){}).onDefaultApiSuccess(function(r){});Bt.evaluateEdit=d6,Bt.fromEditToTech=Au,Bt.fromEditToView=h6,Bt.generateXMLFromServer=p6,Bt.getClientInfo=x6,Bt.getClientInfoFromServer=Th,Object.defineProperty(Bt,Symbol.toStringTag,{value:"Module"})});
|
|
64
|
+
`)}},{key:Symbol.toStringTag,get:function(){return"AxiosHeaders"}}],[{key:"from",value:function(ae){return ae instanceof this?ae:new this(ae)}},{key:"concat",value:function(ae){for(var ce=new this(ae),fe=arguments.length,ge=new Array(fe>1?fe-1:0),Ae=1;Ae<fe;Ae++)ge[Ae-1]=arguments[Ae];return ge.forEach(function(Ee){return ce.set(Ee)}),ce}},{key:"accessor",value:function(ae){var ce=(this[ue]=this[ue]={accessors:{}}).accessors,fe=this.prototype;function ge(Ae){var Ee=oe(Ae);ce[Ee]||(function(Fe,Re){var pr=U.toCamelCase(" "+Re);["get","set","has"].forEach(function(Ve){Object.defineProperty(Fe,Ve+pr,{value:function(je,Pe,mr){return this[Ve].call(this,Re,je,Pe,mr)},configurable:!0})})}(fe,Ae),ce[Ee]=!0)}return U.isArray(ae)?ae.forEach(ge):ge(ae),this}}]),te}();Te.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),U.freezeMethods(Te.prototype),U.freezeMethods(Te);var be=Te;function ke(B,Z){var te=this||Q,ae=Z||te,ce=be.from(ae.headers),fe=ae.data;return U.forEach(B,function(ge){fe=ge.call(te,fe,ce.normalize(),Z?Z.status:void 0)}),ce.normalize(),fe}function fr(B){return!(!B||!B.__CANCEL__)}function hr(B,Z,te){$.call(this,B??"canceled",$.ERR_CANCELED,Z,te),this.name="CanceledError"}U.inherits(hr,$,{__CANCEL__:!0});var ir=G.isStandardBrowserEnv?{write:function(B,Z,te,ae,ce,fe){var ge=[];ge.push(B+"="+encodeURIComponent(Z)),U.isNumber(te)&&ge.push("expires="+new Date(te).toGMTString()),U.isString(ae)&&ge.push("path="+ae),U.isString(ce)&&ge.push("domain="+ce),fe===!0&&ge.push("secure"),document.cookie=ge.join("; ")},read:function(B){var Z=document.cookie.match(new RegExp("(^|;\\s*)("+B+")=([^;]*)"));return Z?decodeURIComponent(Z[3]):null},remove:function(B){this.write(B,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}};function Fr(B,Z){return B&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(Z)?function(te,ae){return ae?te.replace(/\/+$/,"")+"/"+ae.replace(/^\/+/,""):te}(B,Z):Z}var T=G.isStandardBrowserEnv?function(){var B,Z=/(msie|trident)/i.test(navigator.userAgent),te=document.createElement("a");function ae(ce){var fe=ce;return Z&&(te.setAttribute("href",fe),fe=te.href),te.setAttribute("href",fe),{href:te.href,protocol:te.protocol?te.protocol.replace(/:$/,""):"",host:te.host,search:te.search?te.search.replace(/^\?/,""):"",hash:te.hash?te.hash.replace(/^#/,""):"",hostname:te.hostname,port:te.port,pathname:te.pathname.charAt(0)==="/"?te.pathname:"/"+te.pathname}}return B=ae(window.location.href),function(ce){var fe=U.isString(ce)?ae(ce):ce;return fe.protocol===B.protocol&&fe.host===B.host}}():function(){return!0};function K(B,Z){var te=0,ae=function(ce,fe){ce=ce||10;var ge,Ae=new Array(ce),Ee=new Array(ce),Fe=0,Re=0;return fe=fe!==void 0?fe:1e3,function(pr){var Ve=Date.now(),je=Ee[Re];ge||(ge=Ve),Ae[Fe]=pr,Ee[Fe]=Ve;for(var Pe=Re,mr=0;Pe!==Fe;)mr+=Ae[Pe++],Pe%=ce;if((Fe=(Fe+1)%ce)===Re&&(Re=(Re+1)%ce),!(Ve-ge<fe)){var wr=je&&Ve-je;return wr?Math.round(1e3*mr/wr):void 0}}}(50,250);return function(ce){var fe=ce.loaded,ge=ce.lengthComputable?ce.total:void 0,Ae=fe-te,Ee=ae(Ae);te=fe;var Fe={loaded:fe,total:ge,progress:ge?fe/ge:void 0,bytes:Ae,rate:Ee||void 0,estimated:Ee&&ge&&fe<=ge?(ge-fe)/Ee:void 0,event:ce};Fe[Z?"download":"upload"]=!0,B(Fe)}}var de={http:null,xhr:typeof XMLHttpRequest<"u"&&function(B){return new Promise(function(Z,te){var ae,ce=B.data,fe=be.from(B.headers).normalize(),ge=B.responseType;function Ae(){B.cancelToken&&B.cancelToken.unsubscribe(ae),B.signal&&B.signal.removeEventListener("abort",ae)}U.isFormData(ce)&&(G.isStandardBrowserEnv||G.isStandardBrowserWebWorkerEnv?fe.setContentType(!1):fe.setContentType("multipart/form-data;",!1));var Ee=new XMLHttpRequest;if(B.auth){var Fe=B.auth.username||"",Re=B.auth.password?unescape(encodeURIComponent(B.auth.password)):"";fe.set("Authorization","Basic "+btoa(Fe+":"+Re))}var pr=Fr(B.baseURL,B.url);function Ve(){if(Ee){var wr=be.from("getAllResponseHeaders"in Ee&&Ee.getAllResponseHeaders());(function(Pr,Br,en){var Rh=en.config.validateStatus;en.status&&Rh&&!Rh(en.status)?Br(new $("Request failed with status code "+en.status,[$.ERR_BAD_REQUEST,$.ERR_BAD_RESPONSE][Math.floor(en.status/100)-4],en.config,en.request,en)):Pr(en)})(function(Pr){Z(Pr),Ae()},function(Pr){te(Pr),Ae()},{data:ge&&ge!=="text"&&ge!=="json"?Ee.response:Ee.responseText,status:Ee.status,statusText:Ee.statusText,headers:wr,config:B,request:Ee}),Ee=null}}if(Ee.open(B.method.toUpperCase(),Ie(pr,B.params,B.paramsSerializer),!0),Ee.timeout=B.timeout,"onloadend"in Ee?Ee.onloadend=Ve:Ee.onreadystatechange=function(){Ee&&Ee.readyState===4&&(Ee.status!==0||Ee.responseURL&&Ee.responseURL.indexOf("file:")===0)&&setTimeout(Ve)},Ee.onabort=function(){Ee&&(te(new $("Request aborted",$.ECONNABORTED,B,Ee)),Ee=null)},Ee.onerror=function(){te(new $("Network Error",$.ERR_NETWORK,B,Ee)),Ee=null},Ee.ontimeout=function(){var wr=B.timeout?"timeout of "+B.timeout+"ms exceeded":"timeout exceeded",Pr=B.transitional||qe;B.timeoutErrorMessage&&(wr=B.timeoutErrorMessage),te(new $(wr,Pr.clarifyTimeoutError?$.ETIMEDOUT:$.ECONNABORTED,B,Ee)),Ee=null},G.isStandardBrowserEnv){var je=(B.withCredentials||T(pr))&&B.xsrfCookieName&&ir.read(B.xsrfCookieName);je&&fe.set(B.xsrfHeaderName,je)}ce===void 0&&fe.setContentType(null),"setRequestHeader"in Ee&&U.forEach(fe.toJSON(),function(wr,Pr){Ee.setRequestHeader(Pr,wr)}),U.isUndefined(B.withCredentials)||(Ee.withCredentials=!!B.withCredentials),ge&&ge!=="json"&&(Ee.responseType=B.responseType),typeof B.onDownloadProgress=="function"&&Ee.addEventListener("progress",K(B.onDownloadProgress,!0)),typeof B.onUploadProgress=="function"&&Ee.upload&&Ee.upload.addEventListener("progress",K(B.onUploadProgress)),(B.cancelToken||B.signal)&&(ae=function(wr){Ee&&(te(!wr||wr.type?new hr(null,B,Ee):wr),Ee.abort(),Ee=null)},B.cancelToken&&B.cancelToken.subscribe(ae),B.signal&&(B.signal.aborted?ae():B.signal.addEventListener("abort",ae)));var Pe,mr=(Pe=/^([-+\w]{1,25})(:?\/\/|:)/.exec(pr))&&Pe[1]||"";mr&&G.protocols.indexOf(mr)===-1?te(new $("Unsupported protocol "+mr+":",$.ERR_BAD_REQUEST,B)):Ee.send(ce||null)})}};U.forEach(de,function(B,Z){if(B){try{Object.defineProperty(B,"name",{value:Z})}catch{}Object.defineProperty(B,"adapterName",{value:Z})}});var Se=function(B){for(var Z,te,ae=(B=U.isArray(B)?B:[B]).length,ce=0;ce<ae&&(Z=B[ce],!(te=U.isString(Z)?de[Z.toLowerCase()]:Z));ce++);if(!te)throw te===!1?new $("Adapter ".concat(Z," is not supported by the environment"),"ERR_NOT_SUPPORT"):new Error(U.hasOwnProp(de,Z)?"Adapter '".concat(Z,"' is not available in the build"):"Unknown adapter '".concat(Z,"'"));if(!U.isFunction(te))throw new TypeError("adapter is not a function");return te};function ze(B){if(B.cancelToken&&B.cancelToken.throwIfRequested(),B.signal&&B.signal.aborted)throw new hr(null,B)}function Ke(B){return ze(B),B.headers=be.from(B.headers),B.data=ke.call(B,B.transformRequest),["post","put","patch"].indexOf(B.method)!==-1&&B.headers.setContentType("application/x-www-form-urlencoded",!1),Se(B.adapter||Q.adapter)(B).then(function(Z){return ze(B),Z.data=ke.call(B,B.transformResponse,Z),Z.headers=be.from(Z.headers),Z},function(Z){return fr(Z)||(ze(B),Z&&Z.response&&(Z.response.data=ke.call(B,B.transformResponse,Z.response),Z.response.headers=be.from(Z.response.headers))),Promise.reject(Z)})}var rt=function(B){return B instanceof be?B.toJSON():B};function Bt(B,Z){Z=Z||{};var te={};function ae(Fe,Re,pr){return U.isPlainObject(Fe)&&U.isPlainObject(Re)?U.merge.call({caseless:pr},Fe,Re):U.isPlainObject(Re)?U.merge({},Re):U.isArray(Re)?Re.slice():Re}function ce(Fe,Re,pr){return U.isUndefined(Re)?U.isUndefined(Fe)?void 0:ae(void 0,Fe,pr):ae(Fe,Re,pr)}function fe(Fe,Re){if(!U.isUndefined(Re))return ae(void 0,Re)}function ge(Fe,Re){return U.isUndefined(Re)?U.isUndefined(Fe)?void 0:ae(void 0,Fe):ae(void 0,Re)}function Ae(Fe,Re,pr){return pr in Z?ae(Fe,Re):pr in B?ae(void 0,Fe):void 0}var Ee={url:fe,method:fe,data:fe,baseURL:ge,transformRequest:ge,transformResponse:ge,paramsSerializer:ge,timeout:ge,timeoutMessage:ge,withCredentials:ge,adapter:ge,responseType:ge,xsrfCookieName:ge,xsrfHeaderName:ge,onUploadProgress:ge,onDownloadProgress:ge,decompress:ge,maxContentLength:ge,maxBodyLength:ge,beforeRedirect:ge,transport:ge,httpAgent:ge,httpsAgent:ge,cancelToken:ge,socketPath:ge,responseEncoding:ge,validateStatus:Ae,headers:function(Fe,Re){return ce(rt(Fe),rt(Re),!0)}};return U.forEach(Object.keys(Object.assign({},B,Z)),function(Fe){var Re=Ee[Fe]||ce,pr=Re(B[Fe],Z[Fe],Fe);U.isUndefined(pr)&&Re!==Ae||(te[Fe]=pr)}),te}var xi="1.4.0",wi={};["object","boolean","number","function","string","symbol"].forEach(function(B,Z){wi[B]=function(te){return r(te)===B||"a"+(Z<1?"n ":" ")+B}});var Wo={};wi.transitional=function(B,Z,te){function ae(ce,fe){return"[Axios v1.4.0] Transitional option '"+ce+"'"+fe+(te?". "+te:"")}return function(ce,fe,ge){if(B===!1)throw new $(ae(fe," has been removed"+(Z?" in "+Z:"")),$.ERR_DEPRECATED);return Z&&!Wo[fe]&&(Wo[fe]=!0,console.warn(ae(fe," has been deprecated since v"+Z+" and will be removed in the near future"))),!B||B(ce,fe,ge)}};var Di={assertOptions:function(B,Z,te){if(r(B)!=="object")throw new $("options must be an object",$.ERR_BAD_OPTION_VALUE);for(var ae=Object.keys(B),ce=ae.length;ce-- >0;){var fe=ae[ce],ge=Z[fe];if(ge){var Ae=B[fe],Ee=Ae===void 0||ge(Ae,fe,B);if(Ee!==!0)throw new $("option "+fe+" must be "+Ee,$.ERR_BAD_OPTION_VALUE)}else if(te!==!0)throw new $("Unknown option "+fe,$.ERR_BAD_OPTION)}},validators:wi},un=Di.validators,Wa=function(){function B(Z){e(this,B),this.defaults=Z,this.interceptors={request:new Le,response:new Le}}return n(B,[{key:"request",value:function(Z,te){typeof Z=="string"?(te=te||{}).url=Z:te=Z||{};var ae,ce=te=Bt(this.defaults,te),fe=ce.transitional,ge=ce.paramsSerializer,Ae=ce.headers;fe!==void 0&&Di.assertOptions(fe,{silentJSONParsing:un.transitional(un.boolean),forcedJSONParsing:un.transitional(un.boolean),clarifyTimeoutError:un.transitional(un.boolean)},!1),ge!=null&&(U.isFunction(ge)?te.paramsSerializer={serialize:ge}:Di.assertOptions(ge,{encode:un.function,serialize:un.function},!0)),te.method=(te.method||this.defaults.method||"get").toLowerCase(),(ae=Ae&&U.merge(Ae.common,Ae[te.method]))&&U.forEach(["delete","get","head","post","put","patch","common"],function(Br){delete Ae[Br]}),te.headers=be.concat(ae,Ae);var Ee=[],Fe=!0;this.interceptors.request.forEach(function(Br){typeof Br.runWhen=="function"&&Br.runWhen(te)===!1||(Fe=Fe&&Br.synchronous,Ee.unshift(Br.fulfilled,Br.rejected))});var Re,pr=[];this.interceptors.response.forEach(function(Br){pr.push(Br.fulfilled,Br.rejected)});var Ve,je=0;if(!Fe){var Pe=[Ke.bind(this),void 0];for(Pe.unshift.apply(Pe,Ee),Pe.push.apply(Pe,pr),Ve=Pe.length,Re=Promise.resolve(te);je<Ve;)Re=Re.then(Pe[je++],Pe[je++]);return Re}Ve=Ee.length;var mr=te;for(je=0;je<Ve;){var wr=Ee[je++],Pr=Ee[je++];try{mr=wr(mr)}catch(Br){Pr.call(this,Br);break}}try{Re=Ke.call(this,mr)}catch(Br){return Promise.reject(Br)}for(je=0,Ve=pr.length;je<Ve;)Re=Re.then(pr[je++],pr[je++]);return Re}},{key:"getUri",value:function(Z){return Ie(Fr((Z=Bt(this.defaults,Z)).baseURL,Z.url),Z.params,Z.paramsSerializer)}}]),B}();U.forEach(["delete","get","head","options"],function(B){Wa.prototype[B]=function(Z,te){return this.request(Bt(te||{},{method:B,url:Z,data:(te||{}).data}))}}),U.forEach(["post","put","patch"],function(B){function Z(te){return function(ae,ce,fe){return this.request(Bt(fe||{},{method:B,headers:te?{"Content-Type":"multipart/form-data"}:{},url:ae,data:ce}))}}Wa.prototype[B]=Z(),Wa.prototype[B+"Form"]=Z(!0)});var Ya=Wa,Cu=function(){function B(Z){if(e(this,B),typeof Z!="function")throw new TypeError("executor must be a function.");var te;this.promise=new Promise(function(ce){te=ce});var ae=this;this.promise.then(function(ce){if(ae._listeners){for(var fe=ae._listeners.length;fe-- >0;)ae._listeners[fe](ce);ae._listeners=null}}),this.promise.then=function(ce){var fe,ge=new Promise(function(Ae){ae.subscribe(Ae),fe=Ae}).then(ce);return ge.cancel=function(){ae.unsubscribe(fe)},ge},Z(function(ce,fe,ge){ae.reason||(ae.reason=new hr(ce,fe,ge),te(ae.reason))})}return n(B,[{key:"throwIfRequested",value:function(){if(this.reason)throw this.reason}},{key:"subscribe",value:function(Z){this.reason?Z(this.reason):this._listeners?this._listeners.push(Z):this._listeners=[Z]}},{key:"unsubscribe",value:function(Z){if(this._listeners){var te=this._listeners.indexOf(Z);te!==-1&&this._listeners.splice(te,1)}}}],[{key:"source",value:function(){var Z;return{token:new B(function(te){Z=te}),cancel:Z}}}]),B}(),Ni={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ni).forEach(function(B){var Z=a(B,2),te=Z[0],ae=Z[1];Ni[ae]=te});var Mu=Ni,kr=function B(Z){var te=new Ya(Z),ae=o(Ya.prototype.request,te);return U.extend(ae,Ya.prototype,te,{allOwnKeys:!0}),U.extend(ae,te,null,{allOwnKeys:!0}),ae.create=function(ce){return B(Bt(Z,ce))},ae}(Q);return kr.Axios=Ya,kr.CanceledError=hr,kr.CancelToken=Cu,kr.isCancel=fr,kr.VERSION=xi,kr.toFormData=re,kr.AxiosError=$,kr.Cancel=kr.CanceledError,kr.all=function(B){return Promise.all(B)},kr.spread=function(B){return function(Z){return B.apply(null,Z)}},kr.isAxiosError=function(B){return U.isObject(B)&&B.isAxiosError===!0},kr.mergeConfig=Bt,kr.AxiosHeaders=be,kr.formToJSON=function(B){return ee(U.isHTMLForm(B)?new FormData(B):B)},kr.HttpStatusCode=Mu,kr.default=kr,kr});const Gr=v6();function v6(){let r=new Date,e=r.getMilliseconds()+1e3*r.getSeconds()+6e4*r.getMinutes()+36e5*r.getHours(),t=null,n=0,a=window.location.pathname.trim().replace(/(^[\/]*|[\/]*$)/g,""),i="(unavailable)";try{i=window.top.location.pathname.trim().replace(/(^[\/]*|[\/]*$)/g,"")}catch{}function o(d,y,x,D,h,w){let g=!0;t||(t=[],g=!1),t.push({id:d,ticket:y,processor:x,progressor:D,context:h,queue:w});let b=0;function A(){if(t&&t.length===0){t=null;return}b++;let N=Gr.context().onFinally(function(){b<=2?setTimeout(A,2e3):b<=4?setTimeout(A,3e3):setTimeout(A,5e3)}),E=[];for(let S=0;S<t.length;S++){let C=t[S].ticket;E.push(C)}Gr.call("$.QueryPreemptedResponses",{tickets:E}).done(function(S){if(S.error){let C=t.splice(0,E.length);for(let M=0;M<C.length;M++)C[M].processor.process(S);for(let M=0;M<C.length;M++){let O=C[M];O.context.preempted&&(O.context.preempted=null,O.context.__leave())}return!1}for(let C in S.result){let I=function(k,_,P){function V(q,J){if(q.queue.ready||(q.queue.ready=[]),q.queue.ready.push({ticket:_,handler:function(){try{q.processor.process(J)}finally{let ne=q.context.preempted.indexOf(_);q.context.preempted.splice(ne,1),q.context.preempted.length===0&&(q.context.preempted=null,q.context.__leave())}}}),q.queue.ready.length===q.queue.preempted){for(let ne=0;ne<E.length;ne++){let j=E[ne];for(let F=0;F<q.queue.ready.length;F++){let U=q.queue.ready[F];U.ticket===j&&U.handler()}}q.queue.ready=[]}}if(k.status==="error"){let q=t.splice(P,1)[0];V(q,{id:q.id,error:{code:-1,message:k.reason}})}else if(k.status==="ok"){let q=t.splice(P,1)[0];(function(ne){Gr.call("$.RetrievePreemptedResponse",{ticket:ne.ticket}).done(function(j){let F=j;F&&F.result&&F.result.code&&F.result.code>=-32700&&F.result.code<=-32e3&&(F={id:F.id,error:F.result}),V(ne,F)}).post(N)})(q)}else{let q=t[P];q.progressor&&q.progressor.progress(k)}},M=S.result[C],O=-1;for(let k=0;k<t.length;k++)if(t[k].ticket===C){O=k;break}O!==-1&&I(M,C,O)}return!1}).post(N)}g||setTimeout(A,2e3)}let l=function(){let d=[],y=null,x=700;function D(h){let w=d;if(d=[],w.length===0)return;w.preempted=0;let g;if(w.length===1)g=w[0].batch;else{g=[];for(let M=0;M<w.length;M++){let O=w[M].batch;for(let I=0;I<O.length;I++)g.push(O[I])}}let b=[];if(g.length===1)b=g[0].request;else{b.push({method:"$.BeginSynchronizedBatch",params:[]});for(let M=0;M<g.length;M++){let O=g[M].request;if(M===0&&O.method===b[0].method){b[0]=O;continue}b.push(g[M].request)}}let A=function(M,O){for(let I=0;I<w.length;I++)w[I].fail(M,O)},N=function(M,O){try{if(!M){A(!0,"Server returned an empty response. This is likely a server bug.");return}if(M.ajaxCallFailed){M.error.status==="timeout"?A(!0,"JSON-RPC call failed. Timeout."):M.error.status==="error"&&!M.error.details?A(!0,"JSON-RPC call failed. No connection to server."):A(!0,"JSON-RPC call failed. Status: '"+M.error.status+"'"+(M.error.details?", Details: "+JSON.stringify(M.error.details,null,2):""));return}let I=typeof M=="object"&&M instanceof Array?M:[M];if(I.length===0){A(!0,"Server returned an empty list of responses.");return}if(I.length===1){let k=I[0];if(typeof k.id<"u"&&k.id.indexOf&&k.id.indexOf("e2-status-")===0){I=[];for(let _=0;_<w.length;_++){let V=w[_].batch;for(let q=0;q<V.length;q++){let J=JSON.parse(JSON.stringify(k));J.id=V[q].request.id,I.push(J)}}}}for(let k=0;k<I.length;k++){let _=I[k];if(typeof _.result>"u"&&!_.error){A(!0,"Server returned invalid JSON-RPC response: "+JSON.stringify(_,null,2));return}let P=null,V=null,q=null;if(typeof _.id<"u")for(let ne=0;ne<w.length;ne++){let j=w[ne],F=j.batch;for(let U=0;U<F.length;U++){let $=F[U];if(!(!$.request.id||$.request.id!==_.id)){P=$.callbacks,V=$.progressCallbacks,q=j.context;break}}if(P)break}q||(q=Gr.context(),P=[function(ne){return window.MessagesUI?window.MessagesUI.show({message:ne,json:!0}):console.log(ne),!0}],V=[]);let J={context:q,callbacks:P,process:function(ne,j){let F=this.context.__preview(ne);if(F){if(this.callbacks)for(let U=0;U<this.callbacks.length;U++){let $=this.callbacks[U];$(ne,j)||(F=!1)}F&&(ne.error?this.context.__defaultApiFail(ne.error)||A(!1,ne.error):this.context.__defaultApiSucceed(ne.result)||h.log(ne.result))}}};if(_.error&&_.error.code===-32099&&h.autoQueryPreempted){let ne=_.error.data;q.preempted||(q.preempted=[]),q.preempted.push(ne),w.preempted++;let j={callbacks:V,progress:function(F){if(this.callbacks)for(let U=0;U<this.callbacks.length;U++){let $=this.callbacks[U];$&&$(F)}}};o(_.id,ne,J,j,q,w);continue}J.process(_,O)}}finally{for(let I=0;I<w.length;I++){let k=w[I].context;k.preempted||k.__leave()}}},E={timeout:0,responseType:"blob",withCredentials:!0},S=h.headers;S?S=JSON.parse(JSON.stringify(S)):S={},S["JsonRpc-Preempt-After"]||(S["JsonRpc-Preempt-After"]=h.jsonRpcPreemptAfter),S["JsonRpc-Path-TopLevel"]=i,S["JsonRpc-Path"]=a,E.headers=S,n++,axios.post(h.url,b,E).then(async function(M){n--;let O=M.headers["Content-Length"]??M.headers["content-length"]??M.headers["D3Pro-Uncompressed-Content-Length"]??M.headers["d3pro-uncompressed-content-length"]??0;const I=new Blob([M.data],{type:"application/json"});if(O&&h.largeResponseDownloadLimitMb&&h.largeResponseDownloadLimitMb>0&&O>h.largeResponseDownloadLimitMb*1024*1024){let P=`LargeJsonRpcResponse (${new Date().toISOString().replace("T"," ").replaceAll(":","-")}).json`;console.log("Response too large to load. It will be downloaded to file instead: "+P);const V=document.createElement("a"),q=URL.createObjectURL(I);V.href=q,V.download=P,V.click(),URL.revokeObjectURL(q),N({error:{status:"TOO_LARGE_REDIRECTED_TO_FILE",details:"Response was too large to load. It was saved to a file instead: '"+P+"'."}},M.request)}else{let P=JSON.parse(await I.text());N(P,M.request)}M.headers["D3Pro-Refresh-Top-Level"]=="True"&&(console.log("Response requires a full page refresh. Doing it."),window.top.location.reload())}).catch(function(M){console.log(M),n--,N({error:{status:M.code,details:M.message},ajaxCallFailed:!0})})}return{dispatch:function(h,w,g,b){let A=y;y=new Date,d.length===0&&(d.created=y),d.push({batch:h,context:w,fail:g});let N=b??Gr.config;if(h.length===1){let E=h[0].request.method;if(E[0]==="$"&&E.indexOf("Preempted")>-1){if(d.length>1){let S=d.pop();D(N),d=[],d.push(S)}D(N);return}}if(!N.batch){D(N);return}if(A!=null){let E=y-A;y-d.created<3e3&&(n>3||E<x)&&d.timeoutHandle&&(clearTimeout(d.timeoutHandle),d.timeoutHandle=null)}if(n===0){d.timeoutHandle=setTimeout(function(){D(N)},1);return}d.timeoutHandle=setTimeout(function(){D(N)},x+50)}}}();function u(){let d=arguments[0],y=[];const x=D=>D&&[void 0,Object].includes(D.constructor);if(arguments.length===2&&(x(arguments[1])||Array.isArray(arguments[1])))y=arguments[1];else for(let D=1;D<arguments.length;D++)y.push(arguments[D]);return{method:d,params:y}}function s(d,y){let x=[];x.push({request:d,callbacks:[],progressCallbacks:[]});let D=null,h=function(w,g){if(!(D&&w===!0&&D.__rpcFail(g))){if(y&&y.unhandledError){y.unhandledError(g);return}console.log(g)}};return{call:function(){let w=u.apply(null,arguments);return e++,w.id=e,x.push({request:w,callbacks:[],progressCallbacks:[]}),this},notify:function(){let w=u.apply(null,arguments);return x.push({request:w,callbacks:[],progressCallbacks:[]}),this},using:function(w){let g=x[x.length-1].request;return g.id=w,this},done:function(w){let g=x.length>0?x[x.length-1]:null;return typeof w=="function"&&g.callbacks.push(w),this},progress:function(w){let g=x.length>0?x[x.length-1]:null;return typeof w=="function"&&g.progressCallbacks.push(w),this},post:function(w,g){D=w,D||(D=Gr.context()),D.__enter();let b=g??Gr.config;if(!b){try{h(!0,"RpcClient was invoked without a valid config object!")}finally{D.__leave()}return}if(b.jsonp){let A=[];if(x.length===1)A=x[0].request;else for(let M=0;M<x.length;M++)A.push(x[M].request);let N=b.headers;N||(N={});let E="__jsonpCallback_"+e,S=b.url+"?callback="+E+"&jsonrpc="+JSON.stringify(A);for(let M in N)N.hasOwnProperty(M)&&(S=S+"&"+M+"="+b.headers[M]);let C=document.createElement("script");C.setAttribute("src",S),window[E]=function(M){window[E]=null,document.getElementsByTagName("body")[0].removeChild(C),C=null,handler(M)},document.getElementsByTagName("body")[0].appendChild(C),D.__leave();return}l.dispatch(x,D,h,b)}}}let c={url:"json.rpc",batch:!0,jsonRpcPreemptAfter:7,autoQueryPreempted:!0,log:function(d){console.log(d)},unhandledError:function(d){console.log(d)}},f=null,m=document.getElementsByTagName("head");if(m&&m.length){let d=m[0].getElementsByTagName("base");d&&d.length&&(f=d[0].getAttribute("href"))}function v(d){return d.map(function(y){return y.trim().replace(/(^[\/]*|[\/]*$)/g,"")}).join("/")}let p=window.top.location.pathname.trim().replace(/(^[\/]*|[\/]*$)/g,"");return!p||p===""?f&&(c.url=v([f,c.url])):f?c.url=v([f,p,c.url]):c.url=v([p,c.url]),{config:c,call:function(){let d=u.apply(null,arguments);return e++,d.id=e,s(d,this.config)},notify:function(){let d=u.apply(null,arguments);return s(d,this.config)},context:function(){let d={count:0,rpcErrorHandlers:[],apiErrorHandlers:[],apiSuccessHandlers:[],responsePreviewers:[],finallyHandlers:[]};return{onRpcError:function(y){return typeof y=="function"&&d.rpcErrorHandlers.push(y),this},onDefaultApiError:function(y){return typeof y=="function"&&d.apiErrorHandlers.push(y),this},onDefaultApiSuccess:function(y){return typeof y=="function"&&d.apiSuccessHandlers.push(y),this},onFinally:function(y){return typeof y=="function"&&d.finallyHandlers.push(y),this},onPreviewResponse:function(y){return typeof y=="function"&&d.responsePreviewers.push(y),this},__enter:function(){d.count++},__preview:function(){if(d.responsePreviewers.length===0)return!0;let y=!1;for(let x=0;x<d.responsePreviewers.length;x++)d.responsePreviewers[x].apply(null,arguments)||(y=!0);return!y},__rpcFail:function(){if(d.rpcErrorHandlers.length===0)return!1;for(let y=0;y<d.rpcErrorHandlers.length;y++)d.rpcErrorHandlers[y].apply(null,arguments);return!0},__defaultApiFail:function(){if(d.apiErrorHandlers.length===0)return!1;for(let y=0;y<d.apiErrorHandlers.length;y++)d.apiErrorHandlers[y].apply(null,arguments);return!0},__defaultApiSucceed:function(){if(d.apiSuccessHandlers.length===0)return!1;for(let y=0;y<d.apiSuccessHandlers.length;y++)d.apiSuccessHandlers[y].apply(null,arguments);return!0},__leave:function(){if(d.count--,!(d.count>0))for(let y=0;y<d.finallyHandlers.length;y++)d.finallyHandlers[y].apply(null,arguments)}}}}}const Fh=async(r,e,t)=>{Gr.config={},Gr.config.url=r+"/json.rpc",Gr.config.cors=!0;var n="GEI.GetClientLibObj",a={Legislation:e};Gr.call(n,a).done(function(i){return t!=null&&t(i),i}).post(Su())},p6=async(r,e,t)=>{Gr.config={},Gr.config.url=r+"/json.rpc",Gr.config.cors=!0;var n="EOLN.GetNewEditObj",a={};Gr.call(n,a).done(function(i){return t!=null&&t(i),i}).post(Su())},d6=async(r,e,t,n,a)=>{Gr.config={},Gr.config.url=r+"/json.rpc",Gr.config.cors=!0;var i="GEI.CreateXML",o={Legislation:e,Version:t,InputObj:Au(n)};Gr.call(i,o).done(function(l){return a!=null&&a(l),l}).post(Su())},h6=(r,e,t)=>{var n=Au(e);console.log("Tech obj:"),console.log(n);var a=new _h(r,n,t);a.Evaluate()||console.log("Errors:");const i=a.getAliasObject();console.log("Aliased obj:"),console.log(i);const o=b6(i,e);return console.log("Edit obj new:"),console.log(o),o},g6=(r,e)=>{var t=Nu("Invoice",e.Invoice);return t},Nu=(r,e)=>{if(e==null)return null;var t={};if(Array.isArray(e)){var n=[];for(let o=0;o<e.length;o++){var a=e[o]??null,i=Nu(r,a);i!=null&&n.push(i)}t=n}else t=y6(r,e);return t},y6=(r,e)=>{if(e._details!=null){var t=e._details,n=Object.keys(t),a={};for(let o=0;o<n.length;o++){const l=n[o],u=t[l]??null;var i=Nu(l,u);i!=null&&(a[l]=i)}Object.keys(a).length>0}},b6=(r,e)=>{var t=Eu("Invoice",r.Invoice,e.Invoice);return t},Eu=(r,e,t)=>{if(e==null||t==null)return null;var n={};if(Array.isArray(e)){var a=[];for(let l=0;l<e.length;l++){var i=t[l]??null,o=Eu(r,e[l],i);o!=null&&a.push(o)}n=a}else n=x6(r,e,t);return n},x6=(r,e,t)=>{var n={};if(e._details!=null){var a=e._details,i=t._details??{},o=Object.keys(a),l={};for(let f=0;f<o.length;f++){const m=o[f],v=i[m]??null,p=a[m]??null;var u=Eu(m,p,v);u!=null&&(l[m]=u)}Object.keys(l).length>0&&(n._details=l)}var s=Object.keys(e);for(let f=0;f<s.length;f++){var c=s[f];c!="_details"&&t[c]!=null&&(t[c].Value=e[c],n[c]=t[c])}return Object.keys(n).length==0?null:n},Au=r=>{var e=Oh("Invoice",r.Invoice);return e},Oh=(r,e)=>{var t=null;e!=null&&(Array.isArray(e)?(t=[],e.forEach(a=>{t.push(Bh(a))})):t=Bh(e));let n={};return n[r]=t,n},Bh=r=>{var e={},t=Object.keys(r);return t.forEach(n=>{if(n=="_details"){var a={},i=Object.keys(r[n]);i.forEach(o=>{var l=Oh(o,r[n][o]);a=Object.assign(a,l)}),e._details=a;return}e[n]=r[n].Value}),e},w6=(r,e,t)=>{var n=Th.getFromSessionStorage("ClientInfo");if(n==null){var a=o=>{o.result!=null?o.result.Status=="OK"?(D6(o.result.Result),t(o.result.Result)):console.error("Error getting client info from server: "+o.result.Reason):console.error("Error getting client info from server:"+o.error.data)};Fh(r,e,a)}else{var i=JSON.parse(n);t(i)}},D6=r=>{Th.setToSessionStorage("ClientInfo",r)},Su=()=>Gr.context().onRpcError(function(r){}).onDefaultApiError(function(r){}).onDefaultApiSuccess(function(r){});At.evaluateEdit=h6,At.fromEditToTech=Au,At.fromEditToView=g6,At.generateXMLFromServer=d6,At.getClientInfo=w6,At.getClientInfoFromServer=Fh,At.getEditNewFromServer=p6,Object.defineProperty(At,Symbol.toStringTag,{value:"Module"})});
|